myio-js-library 0.1.576 → 0.1.577
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 +1053 -474
- package/dist/index.d.cts +245 -7
- package/dist/index.d.ts +245 -7
- package/dist/index.js +1007 -452
- package/dist/myio-js-library.umd.js +1006 -451
- package/dist/myio-js-library.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -232,8 +232,13 @@ __export(src_exports, {
|
|
|
232
232
|
MEASUREMENT_DOMAIN_CONFIG: () => DOMAIN_CONFIG5,
|
|
233
233
|
MENU_SHOPPING_CSS_PREFIX: () => MENU_SHOPPING_CSS_PREFIX,
|
|
234
234
|
METRO_TILE_COLORS: () => METRO_TILE_COLORS,
|
|
235
|
+
MONEY_CONVERTIBLE_GROUPS: () => MONEY_CONVERTIBLE_GROUPS,
|
|
235
236
|
MONEY_DASH: () => DASH,
|
|
237
|
+
MONEY_ESTIMATE_LABEL: () => MONEY_ESTIMATE_LABEL,
|
|
236
238
|
MONEY_HOURLY_MAX_DAYS: () => MONEY_HOURLY_MAX_DAYS,
|
|
239
|
+
MONEY_INCOMPLETE_LABEL: () => MONEY_INCOMPLETE_LABEL,
|
|
240
|
+
MONEY_MAX_SEGMENT_FETCHES: () => MONEY_MAX_SEGMENT_FETCHES,
|
|
241
|
+
MONEY_REPORT_HEADER: () => MONEY_REPORT_HEADER,
|
|
237
242
|
MONEY_REQUIRES_DEVICE_GRANULARITY: () => MONEY_REQUIRES_DEVICE_GRANULARITY,
|
|
238
243
|
MONEY_VARIANCE_HEADER: () => MONEY_VARIANCE_HEADER,
|
|
239
244
|
MOTOR_SORT_OPTIONS: () => MOTOR_SORT_OPTIONS,
|
|
@@ -336,6 +341,7 @@ __export(src_exports, {
|
|
|
336
341
|
TempSensorSummaryTooltip: () => TempSensorSummaryTooltip,
|
|
337
342
|
Temperature: () => Temperature,
|
|
338
343
|
UsersSummaryTooltip: () => UsersSummaryTooltip,
|
|
344
|
+
VALUE_DISPLAY_MODE_STORAGE_PREFIX: () => VALUE_DISPLAY_MODE_STORAGE_PREFIX,
|
|
339
345
|
VALVE_STATE_KEYS: () => VALVE_STATE_KEYS,
|
|
340
346
|
VARIANCE_LABEL_ABOVE: () => VARIANCE_LABEL_ABOVE,
|
|
341
347
|
VARIANCE_LABEL_BELOW: () => VARIANCE_LABEL_BELOW,
|
|
@@ -383,9 +389,12 @@ __export(src_exports, {
|
|
|
383
389
|
buildFinancialRowHTML: () => buildFinancialRowHTML,
|
|
384
390
|
buildGcdrEnergyRoot: () => buildGcdrEnergyRoot,
|
|
385
391
|
buildListItemsThingsboardByUniqueDatasource: () => buildListItemsThingsboardByUniqueDatasource,
|
|
392
|
+
buildMoneyChipHTML: () => buildMoneyChipHTML,
|
|
393
|
+
buildMoneyCoverageMarkerHTML: () => buildMoneyCoverageMarkerHTML,
|
|
386
394
|
buildMoneyVarianceHTML: () => buildMoneyVarianceHTML,
|
|
387
395
|
buildMyioIngestionAuth: () => buildMyioIngestionAuth,
|
|
388
396
|
buildReportItemsList: () => buildReportItemsList,
|
|
397
|
+
buildReportMoneyConfig: () => buildReportMoneyConfig,
|
|
389
398
|
buildTemplateCsv: () => buildTemplateCsv,
|
|
390
399
|
buildTemplateExport: () => buildTemplateExport,
|
|
391
400
|
buildTicketServiceOrchestrator: () => buildTicketServiceOrchestrator,
|
|
@@ -610,6 +619,7 @@ __export(src_exports, {
|
|
|
610
619
|
formatDuration: () => formatDuration,
|
|
611
620
|
formatEnergy: () => formatEnergy,
|
|
612
621
|
formatHours: () => formatHours2,
|
|
622
|
+
formatItemMoney: () => formatItemMoney,
|
|
613
623
|
formatMoneyBRL: () => formatBRL,
|
|
614
624
|
formatNumberReadable: () => formatNumberReadable,
|
|
615
625
|
formatPower: () => formatPower,
|
|
@@ -750,6 +760,7 @@ __export(src_exports, {
|
|
|
750
760
|
isInRange: () => isInRange,
|
|
751
761
|
isLeapYear: () => isLeapYear,
|
|
752
762
|
isMoneyColumnConfident: () => isMoneyColumnConfident,
|
|
763
|
+
isMoneyConvertibleGroup: () => isMoneyConvertibleGroup,
|
|
753
764
|
isMyioGcdrLoginModalOpen: () => isMyioGcdrLoginModalOpen,
|
|
754
765
|
isOnOffDeviceProfile: () => isOnOffDeviceProfile,
|
|
755
766
|
isSolenoidDevice: () => isSolenoidDevice,
|
|
@@ -774,6 +785,9 @@ __export(src_exports, {
|
|
|
774
785
|
metasGuideComputeChips: () => computeChips,
|
|
775
786
|
metasGuideDeriveTotal: () => deriveTotal,
|
|
776
787
|
minutesToMs: () => minutesToMs,
|
|
788
|
+
moneyCoverageTitle: () => moneyCoverageTitle,
|
|
789
|
+
moneyReasonText: () => moneyReasonText,
|
|
790
|
+
moneyStateChipLabel: () => moneyStateChipLabel,
|
|
777
791
|
msToMinutes: () => msToMinutes,
|
|
778
792
|
myioExportData: () => myioExportData,
|
|
779
793
|
nextManualSeq: () => nextManualSeq,
|
|
@@ -849,10 +863,12 @@ __export(src_exports, {
|
|
|
849
863
|
parseGcdrEntityForest: () => parseGcdrEntityForest,
|
|
850
864
|
parseInputDateToDate: () => parseInputDateToDate,
|
|
851
865
|
parseLogAnnotations: () => parseLogAnnotations,
|
|
866
|
+
parseMoneyCategoryRule: () => parseMoneyCategoryRule,
|
|
852
867
|
periodKey: () => periodKey,
|
|
853
868
|
pickUniqueCustomerCode: () => pickUniqueCustomerCode,
|
|
854
869
|
pumpHistoryFromConsumption: () => pumpHistoryFromConsumption,
|
|
855
870
|
readFreshdeskTicketsFromTB: () => readFreshdeskTicketsFromTB,
|
|
871
|
+
readValueDisplayMode: () => readValueDisplayMode,
|
|
856
872
|
recalculateDeviceStatus: () => recalculateDeviceStatus,
|
|
857
873
|
recomputeDeviceGridPercentages: () => recomputePercentages,
|
|
858
874
|
refreshAlarmBadges: () => refreshAlarmBadges,
|
|
@@ -896,15 +912,18 @@ __export(src_exports, {
|
|
|
896
912
|
resolveBudget: () => resolveBudget,
|
|
897
913
|
resolveCategory: () => resolveCategory,
|
|
898
914
|
resolveClassification: () => resolveClassification,
|
|
915
|
+
resolveEffectiveDisplayMode: () => resolveEffectiveDisplayMode,
|
|
899
916
|
resolveGoalAmount: () => resolveGoalAmount,
|
|
900
917
|
resolveGroup: () => resolveGroup,
|
|
901
918
|
resolveManualDeviceName: () => resolveManualDeviceName,
|
|
919
|
+
resolveMoneyCategory: () => resolveMoneyCategory,
|
|
902
920
|
resolveMoneyRollout: () => resolveMoneyRollout,
|
|
903
921
|
resolveMoneyRowValues: () => resolveMoneyRowValues,
|
|
904
922
|
resolvePercentDecimals: () => resolvePercentDecimals,
|
|
905
923
|
resolveReportItemStates: () => resolveReportItemStates,
|
|
906
924
|
resolveSubcategory: () => resolveSubcategory,
|
|
907
925
|
resolveWithFallback: () => resolveWithFallback,
|
|
926
|
+
roundMoney2: () => roundMoney2,
|
|
908
927
|
routeMoneyRender: () => routeMoneyRender,
|
|
909
928
|
rowsFromTable: () => rowsFromTable,
|
|
910
929
|
schedCreateDateInput: () => createDateInput,
|
|
@@ -926,6 +945,7 @@ __export(src_exports, {
|
|
|
926
945
|
sortDeviceGridDevices: () => sortDevices,
|
|
927
946
|
strings: () => strings_exports,
|
|
928
947
|
subtractDecimals: () => subtractDecimals,
|
|
948
|
+
sumItemMoney: () => sumItemMoney,
|
|
929
949
|
sumMoneyDecimals: () => sumMoneyDecimals,
|
|
930
950
|
summaryDeviceToTotalsRow: () => summaryDeviceToTotalsRow,
|
|
931
951
|
summaryLastReadingTs: () => summaryLastReadingTs,
|
|
@@ -940,6 +960,7 @@ __export(src_exports, {
|
|
|
940
960
|
toCSV: () => toCSV,
|
|
941
961
|
toFixedSafe: () => toFixedSafe,
|
|
942
962
|
toFreshdeskTicketSummary: () => toSummary,
|
|
963
|
+
toItemMoney: () => toItemMoney,
|
|
943
964
|
truncateAnnotationText: () => truncate2,
|
|
944
965
|
updateDeviceGridStats: () => updateStats,
|
|
945
966
|
updateFreshdeskTicket: () => updateTicket,
|
|
@@ -949,20 +970,23 @@ __export(src_exports, {
|
|
|
949
970
|
validateDeviceProductName: () => validateDeviceProductName,
|
|
950
971
|
validateProfile: () => validateProfile,
|
|
951
972
|
validateTree: () => validateTree,
|
|
973
|
+
valuateDomainMoney: () => valuateDomainMoney,
|
|
974
|
+
valueDisplayModeStorageKey: () => valueDisplayModeStorageKey,
|
|
952
975
|
valveHistoryFromTelemetry: () => valveHistoryFromTelemetry,
|
|
953
976
|
version: () => version,
|
|
954
977
|
waterDeviceStatusIcons: () => waterDeviceStatusIcons,
|
|
955
978
|
wireCategoryToPanel: () => wireCategoryToPanel,
|
|
956
979
|
wireDomainToPanel: () => wireDomainToPanel,
|
|
957
980
|
writeFreshdeskSyncedAtToTB: () => writeFreshdeskSyncedAtToTB,
|
|
958
|
-
writeFreshdeskTicketsToTB: () => writeFreshdeskTicketsToTB
|
|
981
|
+
writeFreshdeskTicketsToTB: () => writeFreshdeskTicketsToTB,
|
|
982
|
+
writeValueDisplayMode: () => writeValueDisplayMode
|
|
959
983
|
});
|
|
960
984
|
module.exports = __toCommonJS(src_exports);
|
|
961
985
|
|
|
962
986
|
// package.json
|
|
963
987
|
var package_default = {
|
|
964
988
|
name: "myio-js-library",
|
|
965
|
-
version: "0.1.
|
|
989
|
+
version: "0.1.577",
|
|
966
990
|
description: "A clean, standalone JS SDK for MYIO projects",
|
|
967
991
|
license: "MIT",
|
|
968
992
|
repository: "github:gh-myio/myio-js-library",
|
|
@@ -21130,6 +21154,650 @@ function renderEquipmentShortcutHTML(indicators, label = "Bombas") {
|
|
|
21130
21154
|
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("");
|
|
21131
21155
|
}
|
|
21132
21156
|
|
|
21157
|
+
// src/components/financial-goals/moneyFormat.ts
|
|
21158
|
+
var DASH = "\u2014";
|
|
21159
|
+
function toDecimalParts(input) {
|
|
21160
|
+
const s = input.trim();
|
|
21161
|
+
if (!s) return null;
|
|
21162
|
+
const m = /^([+-]?)(\d+)(?:\.(\d+))?$/.exec(s);
|
|
21163
|
+
if (!m) return null;
|
|
21164
|
+
const negative = m[1] === "-";
|
|
21165
|
+
let intDigits = m[2].replace(/^0+(?=\d)/, "");
|
|
21166
|
+
const frac = m[3] || "";
|
|
21167
|
+
let cents = frac.slice(0, 2).padEnd(2, "0");
|
|
21168
|
+
const roundDigit = frac.charAt(2);
|
|
21169
|
+
if (roundDigit && roundDigit >= "5") {
|
|
21170
|
+
const bumped = String(Number(cents) + 1).padStart(2, "0");
|
|
21171
|
+
if (bumped.length > 2) {
|
|
21172
|
+
cents = "00";
|
|
21173
|
+
intDigits = incrementDigits(intDigits);
|
|
21174
|
+
} else {
|
|
21175
|
+
cents = bumped;
|
|
21176
|
+
}
|
|
21177
|
+
}
|
|
21178
|
+
return { negative, intDigits, frac2: cents };
|
|
21179
|
+
}
|
|
21180
|
+
function incrementDigits(digits) {
|
|
21181
|
+
const arr = digits.split("");
|
|
21182
|
+
let i = arr.length - 1;
|
|
21183
|
+
for (; i >= 0; i--) {
|
|
21184
|
+
if (arr[i] === "9") {
|
|
21185
|
+
arr[i] = "0";
|
|
21186
|
+
} else {
|
|
21187
|
+
arr[i] = String(Number(arr[i]) + 1);
|
|
21188
|
+
return arr.join("");
|
|
21189
|
+
}
|
|
21190
|
+
}
|
|
21191
|
+
return "1" + arr.join("");
|
|
21192
|
+
}
|
|
21193
|
+
function groupThousands(intDigits) {
|
|
21194
|
+
return intDigits.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
|
21195
|
+
}
|
|
21196
|
+
function formatBRL(amount) {
|
|
21197
|
+
if (amount == null) return DASH;
|
|
21198
|
+
const parts = toDecimalParts(String(amount));
|
|
21199
|
+
if (!parts) return DASH;
|
|
21200
|
+
const grouped = groupThousands(parts.intDigits);
|
|
21201
|
+
const sign = parts.negative && !(parts.intDigits === "0" && parts.frac2 === "00") ? "-" : "";
|
|
21202
|
+
return `R$ ${sign}${grouped},${parts.frac2}`;
|
|
21203
|
+
}
|
|
21204
|
+
function signOf(value) {
|
|
21205
|
+
if (value == null || !Number.isFinite(value) || value === 0) return "";
|
|
21206
|
+
return value > 0 ? "+" : "\u2212";
|
|
21207
|
+
}
|
|
21208
|
+
function computeDeltaPct(current, baseline) {
|
|
21209
|
+
if (current == null || baseline == null) return null;
|
|
21210
|
+
const c = Number(String(current).trim());
|
|
21211
|
+
const b = Number(String(baseline).trim());
|
|
21212
|
+
if (!Number.isFinite(c) || !Number.isFinite(b) || b === 0) return null;
|
|
21213
|
+
return (c - b) / Math.abs(b) * 100;
|
|
21214
|
+
}
|
|
21215
|
+
function formatDeltaPct(pct, digits = 1) {
|
|
21216
|
+
if (pct == null || !Number.isFinite(pct)) return DASH;
|
|
21217
|
+
const abs = Math.abs(pct).toFixed(digits).replace(".", ",");
|
|
21218
|
+
const sign = pct > 0 ? "+" : pct < 0 ? "\u2212" : "";
|
|
21219
|
+
return `${sign}${abs}%`;
|
|
21220
|
+
}
|
|
21221
|
+
function formatBRLDelta(amount) {
|
|
21222
|
+
if (amount == null) return DASH;
|
|
21223
|
+
const parts = toDecimalParts(String(amount));
|
|
21224
|
+
if (!parts) return DASH;
|
|
21225
|
+
const isZero = parts.intDigits === "0" && parts.frac2 === "00";
|
|
21226
|
+
const sign = isZero ? "" : parts.negative ? "\u2212" : "+";
|
|
21227
|
+
const grouped = groupThousands(parts.intDigits);
|
|
21228
|
+
return `${sign}R$ ${grouped},${parts.frac2}`;
|
|
21229
|
+
}
|
|
21230
|
+
|
|
21231
|
+
// src/components/financial-goals/tariffValuation.ts
|
|
21232
|
+
var MONEY_HOURLY_MAX_DAYS = 31;
|
|
21233
|
+
var TARIFF_DEFAULT_TIMEZONE = "America/Sao_Paulo";
|
|
21234
|
+
var HOUR_MS2 = 36e5;
|
|
21235
|
+
var QTY_SCALE = 6;
|
|
21236
|
+
var PRICE_SCALE = 6;
|
|
21237
|
+
var AMOUNT_SCALE = QTY_SCALE + PRICE_SCALE;
|
|
21238
|
+
var MONEY_MAX_SEGMENT_FETCHES = 31;
|
|
21239
|
+
function toItemMoney(dm) {
|
|
21240
|
+
if (!dm) return { state: "missing", currency: "BRL", coverage: 0, reason: "no-data" };
|
|
21241
|
+
if (dm.state === "complete" && typeof dm.amount === "string") {
|
|
21242
|
+
const out = { state: "complete", amount: dm.amount, currency: "BRL", coverage: 1 };
|
|
21243
|
+
if (dm.priceVaries) out.priceVaries = true;
|
|
21244
|
+
return out;
|
|
21245
|
+
}
|
|
21246
|
+
if (dm.state === "uncategorized" || dm.state === "not-convertible") {
|
|
21247
|
+
return { state: "uncategorized", currency: "BRL", coverage: 0, reason: dm.reason || "no-category" };
|
|
21248
|
+
}
|
|
21249
|
+
const hourlyOnly = dm.reason === "needs-hourly" || dm.reason === "intraday-tariff-long-period";
|
|
21250
|
+
if (dm.state === "partial" || dm.state === "none" && hourlyOnly) {
|
|
21251
|
+
const out = {
|
|
21252
|
+
state: "partial",
|
|
21253
|
+
currency: "BRL",
|
|
21254
|
+
coverage: typeof dm.coveredRatio === "number" ? dm.coveredRatio : 0
|
|
21255
|
+
};
|
|
21256
|
+
if (dm.reason) out.reason = dm.reason;
|
|
21257
|
+
if (dm.priceVaries) out.priceVaries = true;
|
|
21258
|
+
return out;
|
|
21259
|
+
}
|
|
21260
|
+
return { state: "missing", currency: "BRL", coverage: 0, reason: dm.reason || "no-tariff" };
|
|
21261
|
+
}
|
|
21262
|
+
function sumItemMoney(list) {
|
|
21263
|
+
const items = Array.isArray(list) ? list : [];
|
|
21264
|
+
const total = items.length;
|
|
21265
|
+
if (total === 0) return { state: "none", covered: 0, total: 0 };
|
|
21266
|
+
let acc = 0n;
|
|
21267
|
+
let covered = 0;
|
|
21268
|
+
for (const m of items) {
|
|
21269
|
+
if (!m || m.state !== "complete" || typeof m.amount !== "string") continue;
|
|
21270
|
+
const v = parseScaled(m.amount, AMOUNT_SCALE);
|
|
21271
|
+
if (v == null) continue;
|
|
21272
|
+
acc += v;
|
|
21273
|
+
covered += 1;
|
|
21274
|
+
}
|
|
21275
|
+
if (covered === total) return { state: "complete", amount: formatScaled(acc, AMOUNT_SCALE), covered, total };
|
|
21276
|
+
return { state: covered > 0 ? "partial" : "none", covered, total };
|
|
21277
|
+
}
|
|
21278
|
+
function roundMoney2(amount) {
|
|
21279
|
+
if (typeof amount !== "string") return null;
|
|
21280
|
+
const m = DECIMAL_RE.exec(amount.trim());
|
|
21281
|
+
if (!m) return null;
|
|
21282
|
+
const frac = m[3] || "";
|
|
21283
|
+
let cents = BigInt(m[2]) * 100n + BigInt(frac.slice(0, 2).padEnd(2, "0"));
|
|
21284
|
+
if (frac.charAt(2) >= "5") cents += 1n;
|
|
21285
|
+
const neg = m[1] === "-" && cents !== 0n;
|
|
21286
|
+
return `${neg ? "-" : ""}${(cents / 100n).toString()}.${(cents % 100n).toString().padStart(2, "0")}`;
|
|
21287
|
+
}
|
|
21288
|
+
function moneyStateChipLabel(state6) {
|
|
21289
|
+
if (state6 === "uncategorized") return "Sem categoria";
|
|
21290
|
+
if (state6 === "missing") return "Sem tarifa";
|
|
21291
|
+
if (state6 === "partial") return "Tarifa parcial";
|
|
21292
|
+
return "";
|
|
21293
|
+
}
|
|
21294
|
+
function moneyReasonText(reason) {
|
|
21295
|
+
switch (reason) {
|
|
21296
|
+
case "no-category":
|
|
21297
|
+
return "Dispositivo sem categoria tarif\xE1ria (Lojas / \xC1rea Comum).";
|
|
21298
|
+
case "no-tariff":
|
|
21299
|
+
return "N\xE3o h\xE1 tarifa cadastrada para todo o per\xEDodo.";
|
|
21300
|
+
case "no-data":
|
|
21301
|
+
return "Sem dados de consumo em parte do per\xEDodo.";
|
|
21302
|
+
case "needs-hourly":
|
|
21303
|
+
case "intraday-tariff-long-period":
|
|
21304
|
+
return "Tarifa hor\xE1ria ainda n\xE3o suportada nesta vis\xE3o.";
|
|
21305
|
+
case "too-many-segments":
|
|
21306
|
+
return "Tarifa muda muitas vezes no per\xEDodo; reduza o intervalo.";
|
|
21307
|
+
case "invalid-qty":
|
|
21308
|
+
return "Consumo inv\xE1lido em parte do per\xEDodo.";
|
|
21309
|
+
default:
|
|
21310
|
+
return "";
|
|
21311
|
+
}
|
|
21312
|
+
}
|
|
21313
|
+
var DECIMAL_RE = /^([+-]?)(\d+)(?:\.(\d+))?$/;
|
|
21314
|
+
function parseScaled(s, scale) {
|
|
21315
|
+
const m = DECIMAL_RE.exec(String(s).trim());
|
|
21316
|
+
if (!m) return null;
|
|
21317
|
+
const frac = (m[3] || "").slice(0, scale).padEnd(scale, "0");
|
|
21318
|
+
const v = BigInt(m[2] + frac);
|
|
21319
|
+
return m[1] === "-" ? -v : v;
|
|
21320
|
+
}
|
|
21321
|
+
function formatScaled(v, scale) {
|
|
21322
|
+
const neg = v < 0n;
|
|
21323
|
+
const abs = neg ? -v : v;
|
|
21324
|
+
const digits = abs.toString().padStart(scale + 1, "0");
|
|
21325
|
+
const int = digits.slice(0, digits.length - scale);
|
|
21326
|
+
let frac = digits.slice(digits.length - scale).replace(/0+$/, "");
|
|
21327
|
+
if (frac.length < 2) frac = frac.padEnd(2, "0");
|
|
21328
|
+
const isZero = abs === 0n;
|
|
21329
|
+
return `${neg && !isZero ? "-" : ""}${int}.${frac}`;
|
|
21330
|
+
}
|
|
21331
|
+
function qtyToScaled(qty) {
|
|
21332
|
+
if (typeof qty !== "number" || !Number.isFinite(qty) || Math.abs(qty) >= 1e15) return null;
|
|
21333
|
+
return parseScaled(qty.toFixed(QTY_SCALE), QTY_SCALE);
|
|
21334
|
+
}
|
|
21335
|
+
function isPriceString(p) {
|
|
21336
|
+
return typeof p === "string" && DECIMAL_RE.test(p.trim());
|
|
21337
|
+
}
|
|
21338
|
+
function makeLocalPartsFn(timezone) {
|
|
21339
|
+
let fmt2 = null;
|
|
21340
|
+
try {
|
|
21341
|
+
fmt2 = new Intl.DateTimeFormat("en-US", {
|
|
21342
|
+
timeZone: timezone,
|
|
21343
|
+
year: "numeric",
|
|
21344
|
+
month: "2-digit",
|
|
21345
|
+
day: "2-digit",
|
|
21346
|
+
hour: "2-digit",
|
|
21347
|
+
hourCycle: "h23"
|
|
21348
|
+
});
|
|
21349
|
+
} catch {
|
|
21350
|
+
fmt2 = null;
|
|
21351
|
+
}
|
|
21352
|
+
return (ts) => {
|
|
21353
|
+
if (fmt2) {
|
|
21354
|
+
const out = {};
|
|
21355
|
+
for (const p of fmt2.formatToParts(new Date(ts))) {
|
|
21356
|
+
if (p.type === "year" || p.type === "month" || p.type === "day" || p.type === "hour") {
|
|
21357
|
+
out[p.type] = Number(p.value);
|
|
21358
|
+
}
|
|
21359
|
+
}
|
|
21360
|
+
return { year: out.year, month: out.month, day: out.day, hour: out.hour % 24 };
|
|
21361
|
+
}
|
|
21362
|
+
const d = new Date(ts - 3 * HOUR_MS2);
|
|
21363
|
+
return { year: d.getUTCFullYear(), month: d.getUTCMonth() + 1, day: d.getUTCDate(), hour: d.getUTCHours() };
|
|
21364
|
+
};
|
|
21365
|
+
}
|
|
21366
|
+
var pad2 = (n) => String(n).padStart(2, "0");
|
|
21367
|
+
function nodePrice(node) {
|
|
21368
|
+
return node && isPriceString(node.price) ? node.price.trim() : null;
|
|
21369
|
+
}
|
|
21370
|
+
function hourPrice(dayNode, hour) {
|
|
21371
|
+
const hourly = dayNode?.hourly;
|
|
21372
|
+
if (!hourly) return null;
|
|
21373
|
+
return nodePrice(hourly[String(hour)]) ?? nodePrice(hourly[pad2(hour)]);
|
|
21374
|
+
}
|
|
21375
|
+
function resolveTreePrice(tree, p) {
|
|
21376
|
+
const mm = pad2(p.month);
|
|
21377
|
+
const dd = pad2(p.day);
|
|
21378
|
+
const mmdd = `${mm}-${dd}`;
|
|
21379
|
+
const monthNode = tree.monthly?.[mm];
|
|
21380
|
+
const dayNodes = [tree.daily?.[mmdd], monthNode?.daily?.[dd], monthNode?.daily?.[mmdd]];
|
|
21381
|
+
for (const dn of dayNodes) {
|
|
21382
|
+
const hp = hourPrice(dn, p.hour);
|
|
21383
|
+
if (hp) return hp;
|
|
21384
|
+
}
|
|
21385
|
+
for (const dn of dayNodes) {
|
|
21386
|
+
const dp = nodePrice(dn);
|
|
21387
|
+
if (dp) return dp;
|
|
21388
|
+
}
|
|
21389
|
+
return nodePrice(monthNode) ?? nodePrice(tree.annual);
|
|
21390
|
+
}
|
|
21391
|
+
function createTariffValuator(options) {
|
|
21392
|
+
const trees = options?.trees || {};
|
|
21393
|
+
const rawLocalParts = makeLocalPartsFn(options?.timezone || TARIFF_DEFAULT_TIMEZONE);
|
|
21394
|
+
const partsCache = /* @__PURE__ */ new Map();
|
|
21395
|
+
const localParts = (ts) => {
|
|
21396
|
+
let p = partsCache.get(ts);
|
|
21397
|
+
if (!p) {
|
|
21398
|
+
if (partsCache.size > 5e4) partsCache.clear();
|
|
21399
|
+
p = rawLocalParts(ts);
|
|
21400
|
+
partsCache.set(ts, p);
|
|
21401
|
+
}
|
|
21402
|
+
return p;
|
|
21403
|
+
};
|
|
21404
|
+
const byYear = {};
|
|
21405
|
+
Object.keys(trees).forEach((cat) => {
|
|
21406
|
+
const map = /* @__PURE__ */ new Map();
|
|
21407
|
+
for (const res of trees[cat] || []) {
|
|
21408
|
+
if (res && typeof res.year === "number" && res.tree) map.set(res.year, res.tree);
|
|
21409
|
+
}
|
|
21410
|
+
byYear[cat] = map;
|
|
21411
|
+
});
|
|
21412
|
+
function hasAnyTariff(category) {
|
|
21413
|
+
const map = byYear[category];
|
|
21414
|
+
return !!map && map.size > 0;
|
|
21415
|
+
}
|
|
21416
|
+
function priceAt(category, ts) {
|
|
21417
|
+
const map = byYear[category];
|
|
21418
|
+
if (!map || !Number.isFinite(ts)) return null;
|
|
21419
|
+
const p = localParts(ts);
|
|
21420
|
+
const tree = map.get(p.year);
|
|
21421
|
+
return tree ? resolveTreePrice(tree, p) : null;
|
|
21422
|
+
}
|
|
21423
|
+
function pricesInside(category, startTs, endTs) {
|
|
21424
|
+
const out = [];
|
|
21425
|
+
const end = Math.max(endTs, startTs + 1);
|
|
21426
|
+
for (let t = startTs; t < end; t += HOUR_MS2) out.push(priceAt(category, t));
|
|
21427
|
+
return out;
|
|
21428
|
+
}
|
|
21429
|
+
function valuate(series, opts) {
|
|
21430
|
+
const needsHourlyReason = opts?.intradayLimited ? "intraday-tariff-long-period" : "needs-hourly";
|
|
21431
|
+
const category = series?.category ?? null;
|
|
21432
|
+
if (!category) return { state: "uncategorized", reason: "no-category" };
|
|
21433
|
+
if (!hasAnyTariff(category)) return { state: "none", reason: "no-tariff", coveredRatio: 0 };
|
|
21434
|
+
const buckets = Array.isArray(series.buckets) ? series.buckets : [];
|
|
21435
|
+
if (buckets.length === 0) return { state: "none", reason: "no-data", coveredRatio: 0 };
|
|
21436
|
+
let acc = 0n;
|
|
21437
|
+
let covered = 0;
|
|
21438
|
+
let firstReason;
|
|
21439
|
+
const distinct = /* @__PURE__ */ new Set();
|
|
21440
|
+
for (const b of buckets) {
|
|
21441
|
+
const qty = qtyToScaled(b?.qty);
|
|
21442
|
+
if (qty == null || !Number.isFinite(b.startTs) || !Number.isFinite(b.endTs)) {
|
|
21443
|
+
firstReason = firstReason || "invalid-qty";
|
|
21444
|
+
continue;
|
|
21445
|
+
}
|
|
21446
|
+
const prices = pricesInside(category, b.startTs, b.endTs);
|
|
21447
|
+
if (prices.some((p) => p == null)) {
|
|
21448
|
+
firstReason = firstReason || "no-tariff";
|
|
21449
|
+
continue;
|
|
21450
|
+
}
|
|
21451
|
+
const unique = new Set(prices);
|
|
21452
|
+
if (unique.size > 1) {
|
|
21453
|
+
firstReason = firstReason || needsHourlyReason;
|
|
21454
|
+
continue;
|
|
21455
|
+
}
|
|
21456
|
+
const price = prices[0];
|
|
21457
|
+
const scaledPrice = parseScaled(price, PRICE_SCALE);
|
|
21458
|
+
if (scaledPrice == null) {
|
|
21459
|
+
firstReason = firstReason || "no-tariff";
|
|
21460
|
+
continue;
|
|
21461
|
+
}
|
|
21462
|
+
distinct.add(formatScaled(scaledPrice, PRICE_SCALE));
|
|
21463
|
+
acc += qty * scaledPrice;
|
|
21464
|
+
covered += 1;
|
|
21465
|
+
}
|
|
21466
|
+
const ratio = covered / buckets.length;
|
|
21467
|
+
const priceVaries = distinct.size > 1;
|
|
21468
|
+
if (covered === buckets.length) {
|
|
21469
|
+
return { state: "complete", amount: formatScaled(acc, AMOUNT_SCALE), coveredRatio: 1, priceVaries };
|
|
21470
|
+
}
|
|
21471
|
+
if (covered === 0) return { state: "none", reason: firstReason || "no-tariff", coveredRatio: 0 };
|
|
21472
|
+
return { state: "partial", reason: firstReason, coveredRatio: ratio, priceVaries };
|
|
21473
|
+
}
|
|
21474
|
+
function sum2(list) {
|
|
21475
|
+
return sumItemMoney(list);
|
|
21476
|
+
}
|
|
21477
|
+
function normPrice(p) {
|
|
21478
|
+
if (p == null) return null;
|
|
21479
|
+
const v = parseScaled(p, PRICE_SCALE);
|
|
21480
|
+
return v == null ? null : formatScaled(v, PRICE_SCALE);
|
|
21481
|
+
}
|
|
21482
|
+
function planSegments(categories, startTs, endTs) {
|
|
21483
|
+
const cats = Array.from(new Set((categories || []).filter(Boolean)));
|
|
21484
|
+
const empty = { startTs, endTs, segments: [], fetchCount: 0, tooMany: false };
|
|
21485
|
+
if (!cats.length || !Number.isFinite(startTs) || !Number.isFinite(endTs) || endTs <= startTs) return empty;
|
|
21486
|
+
const hours = [];
|
|
21487
|
+
const dayKeys = [];
|
|
21488
|
+
const prices = {};
|
|
21489
|
+
cats.forEach((c) => prices[c] = []);
|
|
21490
|
+
for (let t = startTs; t < endTs; t += HOUR_MS2) {
|
|
21491
|
+
const p = localParts(t);
|
|
21492
|
+
hours.push(t);
|
|
21493
|
+
dayKeys.push(`${p.year}-${p.month}-${p.day}`);
|
|
21494
|
+
for (const c of cats) prices[c].push(normPrice(priceAt(c, t)));
|
|
21495
|
+
}
|
|
21496
|
+
const intraday = {};
|
|
21497
|
+
for (const c of cats) {
|
|
21498
|
+
const first = /* @__PURE__ */ new Map();
|
|
21499
|
+
const set = /* @__PURE__ */ new Set();
|
|
21500
|
+
hours.forEach((_, i) => {
|
|
21501
|
+
const dk = dayKeys[i];
|
|
21502
|
+
if (!first.has(dk)) first.set(dk, prices[c][i]);
|
|
21503
|
+
else if (first.get(dk) !== prices[c][i]) set.add(dk);
|
|
21504
|
+
});
|
|
21505
|
+
intraday[c] = set;
|
|
21506
|
+
}
|
|
21507
|
+
const segments = [];
|
|
21508
|
+
let curKey = "";
|
|
21509
|
+
hours.forEach((t, i) => {
|
|
21510
|
+
const parts = cats.map((c) => intraday[c].has(dayKeys[i]) ? "H" : prices[c][i] ?? "-");
|
|
21511
|
+
const key = parts.join("|");
|
|
21512
|
+
if (segments.length && key === curKey) return;
|
|
21513
|
+
if (segments.length) segments[segments.length - 1].endTs = t;
|
|
21514
|
+
curKey = key;
|
|
21515
|
+
const seg = { startTs: t, endTs, prices: {}, states: {}, needsFetch: false };
|
|
21516
|
+
cats.forEach((c, ci) => {
|
|
21517
|
+
const k = parts[ci];
|
|
21518
|
+
if (k === "H") seg.states[c] = "hourly";
|
|
21519
|
+
else if (k === "-") seg.states[c] = "none";
|
|
21520
|
+
else {
|
|
21521
|
+
seg.states[c] = "priced";
|
|
21522
|
+
seg.prices[c] = k;
|
|
21523
|
+
seg.needsFetch = true;
|
|
21524
|
+
}
|
|
21525
|
+
});
|
|
21526
|
+
segments.push(seg);
|
|
21527
|
+
});
|
|
21528
|
+
const fetchCount = segments.filter((s) => s.needsFetch).length;
|
|
21529
|
+
return { startTs, endTs, segments, fetchCount, tooMany: fetchCount > MONEY_MAX_SEGMENT_FETCHES };
|
|
21530
|
+
}
|
|
21531
|
+
function valuatePlan(category, plan, qtyBySegment) {
|
|
21532
|
+
if (!category) return { state: "uncategorized", reason: "no-category" };
|
|
21533
|
+
if (!hasAnyTariff(category)) return { state: "none", reason: "no-tariff", coveredRatio: 0 };
|
|
21534
|
+
const segs = plan?.segments || [];
|
|
21535
|
+
if (!segs.length) return { state: "none", reason: "no-data", coveredRatio: 0 };
|
|
21536
|
+
if (plan.tooMany) return { state: "partial", reason: "too-many-segments", coveredRatio: 0 };
|
|
21537
|
+
const span = Math.max(1, plan.endTs - plan.startTs);
|
|
21538
|
+
let acc = 0n;
|
|
21539
|
+
let coveredMs = 0;
|
|
21540
|
+
let coveredSegs = 0;
|
|
21541
|
+
let firstReason;
|
|
21542
|
+
const distinct = /* @__PURE__ */ new Set();
|
|
21543
|
+
segs.forEach((seg, i) => {
|
|
21544
|
+
const st = seg.states[category];
|
|
21545
|
+
if (st === "hourly") {
|
|
21546
|
+
firstReason = firstReason || "needs-hourly";
|
|
21547
|
+
return;
|
|
21548
|
+
}
|
|
21549
|
+
if (st !== "priced" || !seg.prices[category]) {
|
|
21550
|
+
firstReason = firstReason || "no-tariff";
|
|
21551
|
+
return;
|
|
21552
|
+
}
|
|
21553
|
+
const raw = qtyBySegment?.[i];
|
|
21554
|
+
const qty = raw == null ? null : qtyToScaled(raw);
|
|
21555
|
+
if (qty == null) {
|
|
21556
|
+
firstReason = firstReason || (raw == null ? "no-data" : "invalid-qty");
|
|
21557
|
+
return;
|
|
21558
|
+
}
|
|
21559
|
+
const price = parseScaled(seg.prices[category], PRICE_SCALE);
|
|
21560
|
+
distinct.add(seg.prices[category]);
|
|
21561
|
+
acc += qty * price;
|
|
21562
|
+
coveredMs += seg.endTs - seg.startTs;
|
|
21563
|
+
coveredSegs += 1;
|
|
21564
|
+
});
|
|
21565
|
+
const priceVaries = distinct.size > 1;
|
|
21566
|
+
if (coveredSegs === segs.length) {
|
|
21567
|
+
return { state: "complete", amount: formatScaled(acc, AMOUNT_SCALE), coveredRatio: 1, priceVaries };
|
|
21568
|
+
}
|
|
21569
|
+
if (coveredSegs === 0) {
|
|
21570
|
+
if (firstReason === "needs-hourly") return { state: "partial", reason: firstReason, coveredRatio: 0 };
|
|
21571
|
+
return { state: "none", reason: firstReason || "no-tariff", coveredRatio: 0 };
|
|
21572
|
+
}
|
|
21573
|
+
return { state: "partial", reason: firstReason, coveredRatio: coveredMs / span, priceVaries };
|
|
21574
|
+
}
|
|
21575
|
+
function chooseGranularity(categories, startTs, endTs) {
|
|
21576
|
+
const cats = Array.from(new Set((categories || []).filter(Boolean)));
|
|
21577
|
+
let intraday = false;
|
|
21578
|
+
outer: for (const cat of cats) {
|
|
21579
|
+
let dayKey = "";
|
|
21580
|
+
let dayPrice;
|
|
21581
|
+
for (let t = startTs; t < endTs; t += HOUR_MS2) {
|
|
21582
|
+
const p = localParts(t);
|
|
21583
|
+
const key = `${p.year}-${p.month}-${p.day}`;
|
|
21584
|
+
const price = priceAt(cat, t);
|
|
21585
|
+
if (key !== dayKey) {
|
|
21586
|
+
dayKey = key;
|
|
21587
|
+
dayPrice = price;
|
|
21588
|
+
} else if (price !== dayPrice) {
|
|
21589
|
+
intraday = true;
|
|
21590
|
+
break outer;
|
|
21591
|
+
}
|
|
21592
|
+
}
|
|
21593
|
+
}
|
|
21594
|
+
if (!intraday) return { granularity: "1d", intradayLimited: false };
|
|
21595
|
+
const days = (endTs - startTs) / (24 * HOUR_MS2);
|
|
21596
|
+
if (days <= MONEY_HOURLY_MAX_DAYS) return { granularity: "1h", intradayLimited: false };
|
|
21597
|
+
return { granularity: "1d", intradayLimited: true };
|
|
21598
|
+
}
|
|
21599
|
+
return { priceAt, valuate, sum: sum2, chooseGranularity, planSegments, valuatePlan };
|
|
21600
|
+
}
|
|
21601
|
+
|
|
21602
|
+
// src/components/financial-goals/moneyDisplay.ts
|
|
21603
|
+
var MONEY_ESTIMATE_LABEL = "Custo estimado";
|
|
21604
|
+
var MONEY_REPORT_HEADER = "Custo estimado (R$)";
|
|
21605
|
+
var MONEY_INCOMPLETE_LABEL = "Cobertura incompleta";
|
|
21606
|
+
var VALUE_DISPLAY_MODE_STORAGE_PREFIX = "myio:value-display-mode:v1";
|
|
21607
|
+
function valueDisplayModeStorageKey(tbUserId, customerTbId) {
|
|
21608
|
+
return `${VALUE_DISPLAY_MODE_STORAGE_PREFIX}:${tbUserId || "anon"}:${customerTbId || "default"}`;
|
|
21609
|
+
}
|
|
21610
|
+
function readValueDisplayMode(storage, key) {
|
|
21611
|
+
try {
|
|
21612
|
+
return storage?.getItem(key) === "money" ? "money" : "physical";
|
|
21613
|
+
} catch {
|
|
21614
|
+
return "physical";
|
|
21615
|
+
}
|
|
21616
|
+
}
|
|
21617
|
+
function writeValueDisplayMode(storage, key, mode) {
|
|
21618
|
+
try {
|
|
21619
|
+
if (!storage) return false;
|
|
21620
|
+
storage.setItem(key, mode === "money" ? "money" : "physical");
|
|
21621
|
+
return true;
|
|
21622
|
+
} catch {
|
|
21623
|
+
return false;
|
|
21624
|
+
}
|
|
21625
|
+
}
|
|
21626
|
+
function resolveEffectiveDisplayMode(args) {
|
|
21627
|
+
return args.requested === "money" && args.eligible === true && args.available === true ? "money" : "physical";
|
|
21628
|
+
}
|
|
21629
|
+
var MONEY_CONVERTIBLE_GROUPS = {
|
|
21630
|
+
energy: ["lojas", "areacomum"],
|
|
21631
|
+
water: ["lojas", "areacomum", "banheiros"]
|
|
21632
|
+
};
|
|
21633
|
+
var normGroup = (g) => String(g ?? "").trim().toLowerCase().replace(/[\s_-]+/g, "");
|
|
21634
|
+
function isMoneyConvertibleGroup(domain, group) {
|
|
21635
|
+
const list = MONEY_CONVERTIBLE_GROUPS[domain];
|
|
21636
|
+
return !!list && list.includes(normGroup(group));
|
|
21637
|
+
}
|
|
21638
|
+
function parseMoneyCategoryRule(raw) {
|
|
21639
|
+
let v = raw;
|
|
21640
|
+
if (typeof v === "string") {
|
|
21641
|
+
try {
|
|
21642
|
+
v = JSON.parse(v);
|
|
21643
|
+
} catch {
|
|
21644
|
+
return null;
|
|
21645
|
+
}
|
|
21646
|
+
}
|
|
21647
|
+
if (!v || typeof v !== "object" || Array.isArray(v)) return null;
|
|
21648
|
+
const o = v;
|
|
21649
|
+
if (o.source != null && o.source !== "classification") return null;
|
|
21650
|
+
const list = (x) => Array.isArray(x) ? x.map((s) => String(s).trim() === "*" ? "*" : normGroup(s)).filter(Boolean) : [];
|
|
21651
|
+
const SPECIFIC = list(o.SPECIFIC);
|
|
21652
|
+
const COMMON_AREA = list(o.COMMON_AREA);
|
|
21653
|
+
if (!SPECIFIC.length && !COMMON_AREA.length) return null;
|
|
21654
|
+
return { source: "classification", SPECIFIC, COMMON_AREA };
|
|
21655
|
+
}
|
|
21656
|
+
function resolveMoneyCategory(rule, group) {
|
|
21657
|
+
if (!rule) return null;
|
|
21658
|
+
const g = normGroup(group);
|
|
21659
|
+
if (!g) return null;
|
|
21660
|
+
if (rule.SPECIFIC.includes(g)) return "SPECIFIC";
|
|
21661
|
+
if (rule.COMMON_AREA.includes(g)) return "COMMON_AREA";
|
|
21662
|
+
if (rule.SPECIFIC.includes("*")) return "SPECIFIC";
|
|
21663
|
+
if (rule.COMMON_AREA.includes("*")) return "COMMON_AREA";
|
|
21664
|
+
return null;
|
|
21665
|
+
}
|
|
21666
|
+
function qtyOf(map, key) {
|
|
21667
|
+
if (!map) return void 0;
|
|
21668
|
+
const v = map instanceof Map ? map.get(key) : map[key];
|
|
21669
|
+
return typeof v === "number" && Number.isFinite(v) ? v : void 0;
|
|
21670
|
+
}
|
|
21671
|
+
function yearsSpanned(startTs, endTs, timezone) {
|
|
21672
|
+
const yearOf = (ts) => {
|
|
21673
|
+
try {
|
|
21674
|
+
return Number(new Intl.DateTimeFormat("en-US", { timeZone: timezone, year: "numeric" }).format(new Date(ts)));
|
|
21675
|
+
} catch {
|
|
21676
|
+
return new Date(ts - 3 * 36e5).getUTCFullYear();
|
|
21677
|
+
}
|
|
21678
|
+
};
|
|
21679
|
+
const a = yearOf(startTs);
|
|
21680
|
+
const b = yearOf(Math.max(startTs, endTs - 1));
|
|
21681
|
+
const out = [];
|
|
21682
|
+
for (let y = a; y <= b; y++) out.push(y);
|
|
21683
|
+
return out;
|
|
21684
|
+
}
|
|
21685
|
+
var WIRE_DOMAIN = { energy: "ENERGY", water: "WATER" };
|
|
21686
|
+
async function valuateDomainMoney(opts) {
|
|
21687
|
+
const timezone = opts.timezone || TARIFF_DEFAULT_TIMEZONE;
|
|
21688
|
+
const devices = (opts.devices || []).filter((d) => d && d.key && isMoneyConvertibleGroup(opts.domain, d.group));
|
|
21689
|
+
const categoryByKey = /* @__PURE__ */ new Map();
|
|
21690
|
+
for (const d of devices) categoryByKey.set(d.key, resolveMoneyCategory(opts.rule, d.group));
|
|
21691
|
+
const categories = Array.from(new Set(Array.from(categoryByKey.values()).filter(Boolean)));
|
|
21692
|
+
const trees = {};
|
|
21693
|
+
const years = yearsSpanned(opts.startTs, opts.endTs, timezone);
|
|
21694
|
+
await Promise.all(
|
|
21695
|
+
categories.flatMap(
|
|
21696
|
+
(category) => years.map(async (year) => {
|
|
21697
|
+
let res = null;
|
|
21698
|
+
try {
|
|
21699
|
+
res = await opts.loadTree({ domain: WIRE_DOMAIN[opts.domain], category, year });
|
|
21700
|
+
} catch {
|
|
21701
|
+
res = null;
|
|
21702
|
+
}
|
|
21703
|
+
if (res && res.tree && Object.keys(res.tree).length > 0) {
|
|
21704
|
+
(trees[category] = trees[category] || []).push({ ...res, year });
|
|
21705
|
+
}
|
|
21706
|
+
})
|
|
21707
|
+
)
|
|
21708
|
+
);
|
|
21709
|
+
const valuator = createTariffValuator({ trees, timezone });
|
|
21710
|
+
const plan = valuator.planSegments(categories, opts.startTs, opts.endTs);
|
|
21711
|
+
const qtyBySeg = plan.segments.map(() => null);
|
|
21712
|
+
let segmentFetches = 0;
|
|
21713
|
+
if (plan.segments.length === 1 && plan.segments[0].needsFetch) {
|
|
21714
|
+
qtyBySeg[0] = opts.periodTotals;
|
|
21715
|
+
} else if (!plan.tooMany && typeof opts.fetchSegmentTotals === "function") {
|
|
21716
|
+
for (let i = 0; i < plan.segments.length; i++) {
|
|
21717
|
+
const seg = plan.segments[i];
|
|
21718
|
+
if (!seg.needsFetch) continue;
|
|
21719
|
+
segmentFetches += 1;
|
|
21720
|
+
try {
|
|
21721
|
+
qtyBySeg[i] = await opts.fetchSegmentTotals(seg.startTs, seg.endTs);
|
|
21722
|
+
} catch {
|
|
21723
|
+
qtyBySeg[i] = null;
|
|
21724
|
+
}
|
|
21725
|
+
}
|
|
21726
|
+
}
|
|
21727
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
21728
|
+
for (const d of devices) {
|
|
21729
|
+
const qtys = plan.segments.map((_, i) => qtyOf(qtyBySeg[i], d.key));
|
|
21730
|
+
byKey.set(d.key, toItemMoney(valuator.valuatePlan(categoryByKey.get(d.key) ?? null, plan, qtys)));
|
|
21731
|
+
}
|
|
21732
|
+
return {
|
|
21733
|
+
domain: opts.domain,
|
|
21734
|
+
startTs: opts.startTs,
|
|
21735
|
+
endTs: opts.endTs,
|
|
21736
|
+
byKey,
|
|
21737
|
+
categoryByKey,
|
|
21738
|
+
coverage: sumItemMoney(Array.from(byKey.values())),
|
|
21739
|
+
valuator,
|
|
21740
|
+
plan,
|
|
21741
|
+
segmentFetches
|
|
21742
|
+
};
|
|
21743
|
+
}
|
|
21744
|
+
function buildReportMoneyConfig(result, opts = {}) {
|
|
21745
|
+
const keys = opts.deviceKeys && opts.deviceKeys.length ? opts.deviceKeys : Array.from(result.byKey.keys());
|
|
21746
|
+
const perDevice = {};
|
|
21747
|
+
const listed = [];
|
|
21748
|
+
for (const k of keys) {
|
|
21749
|
+
const m = result.byKey.get(k);
|
|
21750
|
+
if (!m) continue;
|
|
21751
|
+
listed.push(m);
|
|
21752
|
+
perDevice[k] = m.state === "complete" ? roundMoney2(m.amount) : null;
|
|
21753
|
+
}
|
|
21754
|
+
const sum2 = sumItemMoney(listed);
|
|
21755
|
+
const complete = sum2.state === "complete";
|
|
21756
|
+
return {
|
|
21757
|
+
overlay: {
|
|
21758
|
+
state: "available",
|
|
21759
|
+
currency: "BRL",
|
|
21760
|
+
coverageComplete: complete,
|
|
21761
|
+
uncategorizedDevices: []
|
|
21762
|
+
},
|
|
21763
|
+
perDevice,
|
|
21764
|
+
total: complete ? roundMoney2(sum2.amount) : null,
|
|
21765
|
+
// The report may list a subset (one group): its total is round(Σ raw) of THOSE rows.
|
|
21766
|
+
totalFor: (ids) => {
|
|
21767
|
+
const s = sumItemMoney((ids || []).map((k) => result.byKey.get(k) || { state: "missing" }));
|
|
21768
|
+
return s.state === "complete" ? roundMoney2(s.amount) : null;
|
|
21769
|
+
},
|
|
21770
|
+
headerLabel: MONEY_REPORT_HEADER,
|
|
21771
|
+
period: opts.period ? { startISO: opts.period.startISO ?? null, endISO: opts.period.endISO ?? null } : { startISO: new Date(result.startTs).toISOString(), endISO: new Date(result.endTs).toISOString() },
|
|
21772
|
+
valuateBucket: (deviceKey, startTs, endTs, qty) => {
|
|
21773
|
+
const cat = result.categoryByKey.get(deviceKey);
|
|
21774
|
+
if (cat === void 0) return null;
|
|
21775
|
+
return toItemMoney(result.valuator.valuate({ deviceKey, category: cat, buckets: [{ startTs, endTs, qty }] }));
|
|
21776
|
+
}
|
|
21777
|
+
};
|
|
21778
|
+
}
|
|
21779
|
+
var esc = (s) => String(s ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
21780
|
+
function formatItemMoney(money) {
|
|
21781
|
+
if (!money || money.state !== "complete" || typeof money.amount !== "string") return null;
|
|
21782
|
+
const s = formatBRL(money.amount);
|
|
21783
|
+
return s === "\u2014" ? null : s;
|
|
21784
|
+
}
|
|
21785
|
+
function moneyCoverageTitle(money) {
|
|
21786
|
+
if (!money) return "";
|
|
21787
|
+
const label = moneyStateChipLabel(money.state);
|
|
21788
|
+
const why = moneyReasonText(money.reason);
|
|
21789
|
+
return [label, why].filter(Boolean).join(" \u2014 ");
|
|
21790
|
+
}
|
|
21791
|
+
function buildMoneyChipHTML(money) {
|
|
21792
|
+
const label = money ? moneyStateChipLabel(money.state) : "";
|
|
21793
|
+
if (!label) return "";
|
|
21794
|
+
return `<span class="myio-money-chip" data-money-state="${esc(money.state)}" title="${esc(moneyCoverageTitle(money))}" style="display:inline-block;margin-left:6px;padding:1px 6px;border-radius:999px;font:600 10px Nunito,sans-serif;background:#fef3c7;color:#92400e;vertical-align:middle;white-space:nowrap;">${esc(label)}</span>`;
|
|
21795
|
+
}
|
|
21796
|
+
function buildMoneyCoverageMarkerHTML(sum2) {
|
|
21797
|
+
if (!sum2 || !sum2.total) return "";
|
|
21798
|
+
return `<span class="myio-money-coverage" data-money-coverage="incomplete" title="Total exibido em unidade f\xEDsica: nem todos os dispositivos t\xEAm custo estimado completo." style="display:inline-block;margin-left:6px;padding:1px 6px;border-radius:999px;font:600 10px Nunito,sans-serif;background:#fef3c7;color:#92400e;white-space:nowrap;">${MONEY_INCOMPLETE_LABEL} (${sum2.covered} de ${sum2.total})</span>`;
|
|
21799
|
+
}
|
|
21800
|
+
|
|
21133
21801
|
// src/components/cards/main-view/v5.2.0/template-card-v5.js
|
|
21134
21802
|
var LABEL_CHAR_LIMIT2 = 18;
|
|
21135
21803
|
var ENERGY_DEVICE_TYPES = getTypesByCategory("energy");
|
|
@@ -21217,7 +21885,10 @@ function renderCardComponentV5({
|
|
|
21217
21885
|
// status neutro (não marca offline nem pisca enquanto carrega)
|
|
21218
21886
|
dataLoading = false,
|
|
21219
21887
|
// ED-1354: indicadores B1/B2/S (bombas MOTOR + solenoide) no card do poço
|
|
21220
|
-
equipmentIndicators
|
|
21888
|
+
equipmentIndicators,
|
|
21889
|
+
// RFC-0241 Part B: 'money' → "Custo estimado" em R$ quando money.state === 'complete'
|
|
21890
|
+
displayMode,
|
|
21891
|
+
money
|
|
21221
21892
|
} = entityObject;
|
|
21222
21893
|
const rawProfile = String(deviceProfile || legacyDeviceType || "");
|
|
21223
21894
|
const isManualDevice = /_MANUAL$/i.test(rawProfile);
|
|
@@ -21470,6 +22141,16 @@ function renderCardComponentV5({
|
|
|
21470
22141
|
ingestionId: ingestionId || entityId
|
|
21471
22142
|
// Store ingestionId for API calls
|
|
21472
22143
|
};
|
|
22144
|
+
const moneyValueHTML = (() => {
|
|
22145
|
+
if (displayMode !== "money" || dataLoading || isTankDevice2) return null;
|
|
22146
|
+
if (!isEnergyDevice2(deviceType) && !isWaterDeviceType(deviceType)) return null;
|
|
22147
|
+
const physical = formatCardValue(cardEntity.lastValue, deviceType);
|
|
22148
|
+
const brl = formatItemMoney(money);
|
|
22149
|
+
if (brl) {
|
|
22150
|
+
return `<span class="consumption-value" data-money="complete" title="Custo estimado \u2014 ${physical}">${brl}</span><span class="myio-money-label" style="margin-left:4px;font:600 9px Nunito,sans-serif;opacity:.7;white-space:nowrap;">Custo estimado</span>`;
|
|
22151
|
+
}
|
|
22152
|
+
return `<span class="consumption-value">${physical}</span>${buildMoneyChipHTML(money)}`;
|
|
22153
|
+
})();
|
|
21473
22154
|
if (enableSelection && MyIOSelectionStore) {
|
|
21474
22155
|
MyIOSelectionStore.registerEntity(cardEntity);
|
|
21475
22156
|
}
|
|
@@ -21796,7 +22477,7 @@ function renderCardComponentV5({
|
|
|
21796
22477
|
<span class="flash-icon ${shouldFlashIcon2 ? "flash" : ""}">
|
|
21797
22478
|
${icon2}
|
|
21798
22479
|
</span>
|
|
21799
|
-
${dataLoading ? `<span class="consumption-value myio-value-loading" title="Carregando dados de telemetria" aria-busy="true"><span class="myio-value-spinner" aria-hidden="true"></span>Carregando\u2026</span>` : `<span class="consumption-value"${showNoTempReading ? ' style="color:#9ca3af;font-weight:500;font-size:0.85em;"' : ""}${tempValueTitle ? ` title="${tempValueTitle}"` : ""}>${formatCardValue(cardEntity.lastValue, deviceType)}</span>`}${!dataLoading && showTempWarning ? `<span class="myio-temp-warn-icon" title="${tempValueTitle}" aria-label="Leitura atrasada">\u26A0\uFE0F</span>` : ""}
|
|
22480
|
+
${moneyValueHTML !== null ? moneyValueHTML : dataLoading ? `<span class="consumption-value myio-value-loading" title="Carregando dados de telemetria" aria-busy="true"><span class="myio-value-spinner" aria-hidden="true"></span>Carregando\u2026</span>` : `<span class="consumption-value"${showNoTempReading ? ' style="color:#9ca3af;font-weight:500;font-size:0.85em;"' : ""}${tempValueTitle ? ` title="${tempValueTitle}"` : ""}>${formatCardValue(cardEntity.lastValue, deviceType)}</span>`}${!dataLoading && showTempWarning ? `<span class="myio-temp-warn-icon" title="${tempValueTitle}" aria-label="Leitura atrasada">\u26A0\uFE0F</span>` : ""}
|
|
21800
22481
|
</div>
|
|
21801
22482
|
</div>
|
|
21802
22483
|
${dataLoading ? "" : isTankDevice2 ? `<span class="device-percentage-badge device-tank-level-badge" style="position: absolute; bottom: 12px; right: 12px; z-index: 20; background: none !important;">${formatTankHeadFromCm(tankLevelCm)}</span>` : !isTermostatoDevice ? `<span class="device-percentage-badge percentage-tooltip-trigger" style="position: absolute; bottom: 12px; right: 12px; z-index: 20; background: none !important; cursor: help;">${percentageForDisplay.toFixed(_pctDecimals).replace(".", ",")}%</span>` : tempDeviationPercent ? `<span class="device-percentage-badge temp-deviation-badge temp-comparison-tooltip-trigger" style="position: absolute; bottom: 12px; right: 12px; z-index: 20; background: none !important; color: ${tempDeviationPercent.isAbove ? "#ef4444" : tempDeviationPercent.isBelow ? "#3b82f6" : "#16a34a"}; font-weight: 600; cursor: help;" title="${tempDeviationPercent.title}">${tempDeviationPercent.text}</span>` : ""}
|
|
@@ -32481,8 +33162,8 @@ var EnergyDataFetcher = class {
|
|
|
32481
33162
|
// src/components/premium-modals/internal/engines/CsvExporter.ts
|
|
32482
33163
|
var toCsv = (rows, locale = "pt-BR", sep = ";") => {
|
|
32483
33164
|
const fmt2 = new Intl.NumberFormat(locale, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
32484
|
-
const
|
|
32485
|
-
return rows.map((r) => r.map((c) => `"${
|
|
33165
|
+
const esc11 = (v) => (typeof v === "number" ? fmt2.format(v) : String(v)).replace(/"/g, '""');
|
|
33166
|
+
return rows.map((r) => r.map((c) => `"${esc11(c)}"`).join(sep)).join("\r\n");
|
|
32486
33167
|
};
|
|
32487
33168
|
|
|
32488
33169
|
// src/components/premium-modals/energy/types.ts
|
|
@@ -36852,14 +37533,14 @@ var DeviceReportModal = class {
|
|
|
36852
37533
|
// Header: "Relatório - <identifier> - <label>" + nome do device (sutil, com copiar).
|
|
36853
37534
|
// O customer já aparece no footer premium. Texto escapado — o shell usa innerHTML no título.
|
|
36854
37535
|
buildHeaderTitleHTML() {
|
|
36855
|
-
const
|
|
36856
|
-
const base =
|
|
37536
|
+
const esc11 = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
37537
|
+
const base = esc11(
|
|
36857
37538
|
`Relat\xF3rio - ${this.params.identifier || "SEM IDENTIFICADOR"} - ${this.params.label || "SEM ETIQUETA"}`
|
|
36858
37539
|
);
|
|
36859
37540
|
const deviceName = String(this.params.deviceName || "").trim();
|
|
36860
37541
|
const deviceHTML = deviceName ? `<span class="myio-dr-devname" style="margin-left:10px;font-size:0.72em;font-weight:400;opacity:.75;display:inline-flex;align-items:center;gap:4px;vertical-align:middle;">
|
|
36861
|
-
${
|
|
36862
|
-
<button type="button" class="myio-dr-copy" data-copy="${
|
|
37542
|
+
${esc11(deviceName)}
|
|
37543
|
+
<button type="button" class="myio-dr-copy" data-copy="${esc11(deviceName)}" title="Copiar nome do dispositivo"
|
|
36863
37544
|
aria-label="Copiar nome do dispositivo"
|
|
36864
37545
|
style="border:none;background:transparent;color:inherit;cursor:pointer;padding:0 2px;line-height:1;opacity:.9;display:inline-flex;">
|
|
36865
37546
|
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>
|
|
@@ -38655,80 +39336,6 @@ function attachFilterOrderingModal(props) {
|
|
|
38655
39336
|
};
|
|
38656
39337
|
}
|
|
38657
39338
|
|
|
38658
|
-
// src/components/financial-goals/moneyFormat.ts
|
|
38659
|
-
var DASH = "\u2014";
|
|
38660
|
-
function toDecimalParts(input) {
|
|
38661
|
-
const s = input.trim();
|
|
38662
|
-
if (!s) return null;
|
|
38663
|
-
const m = /^([+-]?)(\d+)(?:\.(\d+))?$/.exec(s);
|
|
38664
|
-
if (!m) return null;
|
|
38665
|
-
const negative = m[1] === "-";
|
|
38666
|
-
let intDigits = m[2].replace(/^0+(?=\d)/, "");
|
|
38667
|
-
const frac = m[3] || "";
|
|
38668
|
-
let cents = frac.slice(0, 2).padEnd(2, "0");
|
|
38669
|
-
const roundDigit = frac.charAt(2);
|
|
38670
|
-
if (roundDigit && roundDigit >= "5") {
|
|
38671
|
-
const bumped = String(Number(cents) + 1).padStart(2, "0");
|
|
38672
|
-
if (bumped.length > 2) {
|
|
38673
|
-
cents = "00";
|
|
38674
|
-
intDigits = incrementDigits(intDigits);
|
|
38675
|
-
} else {
|
|
38676
|
-
cents = bumped;
|
|
38677
|
-
}
|
|
38678
|
-
}
|
|
38679
|
-
return { negative, intDigits, frac2: cents };
|
|
38680
|
-
}
|
|
38681
|
-
function incrementDigits(digits) {
|
|
38682
|
-
const arr = digits.split("");
|
|
38683
|
-
let i = arr.length - 1;
|
|
38684
|
-
for (; i >= 0; i--) {
|
|
38685
|
-
if (arr[i] === "9") {
|
|
38686
|
-
arr[i] = "0";
|
|
38687
|
-
} else {
|
|
38688
|
-
arr[i] = String(Number(arr[i]) + 1);
|
|
38689
|
-
return arr.join("");
|
|
38690
|
-
}
|
|
38691
|
-
}
|
|
38692
|
-
return "1" + arr.join("");
|
|
38693
|
-
}
|
|
38694
|
-
function groupThousands(intDigits) {
|
|
38695
|
-
return intDigits.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
|
38696
|
-
}
|
|
38697
|
-
function formatBRL(amount) {
|
|
38698
|
-
if (amount == null) return DASH;
|
|
38699
|
-
const parts = toDecimalParts(String(amount));
|
|
38700
|
-
if (!parts) return DASH;
|
|
38701
|
-
const grouped = groupThousands(parts.intDigits);
|
|
38702
|
-
const sign = parts.negative && !(parts.intDigits === "0" && parts.frac2 === "00") ? "-" : "";
|
|
38703
|
-
return `R$ ${sign}${grouped},${parts.frac2}`;
|
|
38704
|
-
}
|
|
38705
|
-
function signOf(value) {
|
|
38706
|
-
if (value == null || !Number.isFinite(value) || value === 0) return "";
|
|
38707
|
-
return value > 0 ? "+" : "\u2212";
|
|
38708
|
-
}
|
|
38709
|
-
function computeDeltaPct(current, baseline) {
|
|
38710
|
-
if (current == null || baseline == null) return null;
|
|
38711
|
-
const c = Number(String(current).trim());
|
|
38712
|
-
const b = Number(String(baseline).trim());
|
|
38713
|
-
if (!Number.isFinite(c) || !Number.isFinite(b) || b === 0) return null;
|
|
38714
|
-
return (c - b) / Math.abs(b) * 100;
|
|
38715
|
-
}
|
|
38716
|
-
function formatDeltaPct(pct, digits = 1) {
|
|
38717
|
-
if (pct == null || !Number.isFinite(pct)) return DASH;
|
|
38718
|
-
const abs = Math.abs(pct).toFixed(digits).replace(".", ",");
|
|
38719
|
-
const sign = pct > 0 ? "+" : pct < 0 ? "\u2212" : "";
|
|
38720
|
-
return `${sign}${abs}%`;
|
|
38721
|
-
}
|
|
38722
|
-
function formatBRLDelta(amount) {
|
|
38723
|
-
if (amount == null) return DASH;
|
|
38724
|
-
const parts = toDecimalParts(String(amount));
|
|
38725
|
-
if (!parts) return DASH;
|
|
38726
|
-
const isZero = parts.intDigits === "0" && parts.frac2 === "00";
|
|
38727
|
-
const sign = isZero ? "" : parts.negative ? "\u2212" : "+";
|
|
38728
|
-
const grouped = groupThousands(parts.intDigits);
|
|
38729
|
-
return `${sign}R$ ${grouped},${parts.frac2}`;
|
|
38730
|
-
}
|
|
38731
|
-
|
|
38732
39339
|
// src/components/financial-goals/moneyTypes.ts
|
|
38733
39340
|
var MONEY_REQUIRES_DEVICE_GRANULARITY = "MONEY_REQUIRES_DEVICE_GRANULARITY";
|
|
38734
39341
|
function normalizeMoneyBlock(raw, rawBudget) {
|
|
@@ -39038,11 +39645,11 @@ function coveragePercentLabel(pricedHours, totalHours) {
|
|
|
39038
39645
|
const txt = Number.isInteger(rounded) ? String(rounded) : rounded.toFixed(1).replace(".", ",");
|
|
39039
39646
|
return `${txt}%`;
|
|
39040
39647
|
}
|
|
39041
|
-
function
|
|
39648
|
+
function esc2(s) {
|
|
39042
39649
|
return String(s ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
39043
39650
|
}
|
|
39044
39651
|
function deviceDisplayName(d) {
|
|
39045
|
-
return
|
|
39652
|
+
return esc2(d.label || d.code || d.deviceId || "Dispositivo");
|
|
39046
39653
|
}
|
|
39047
39654
|
function unavailableHTML(reason, offerDeepLink) {
|
|
39048
39655
|
const isGranularity2 = reason === MONEY_REQUIRES_DEVICE_GRANULARITY;
|
|
@@ -39057,8 +39664,8 @@ function devicesHTML(devices) {
|
|
|
39057
39664
|
if (!devices.length) return "";
|
|
39058
39665
|
const items = devices.map((d) => {
|
|
39059
39666
|
const name = deviceDisplayName(d);
|
|
39060
|
-
const code = d.code ? `<span class="myio-cov__device-code">${
|
|
39061
|
-
return `<li><button type="button" class="myio-cov__device" data-cov-device="${
|
|
39667
|
+
const code = d.code ? `<span class="myio-cov__device-code">${esc2(d.code)}</span>` : "";
|
|
39668
|
+
return `<li><button type="button" class="myio-cov__device" data-cov-device="${esc2(d.deviceId)}"><span class="myio-cov__device-label">${name}</span>` + code + `<span class="myio-cov__device-cta">Categorizar \u2192</span></button></li>`;
|
|
39062
39669
|
}).join("");
|
|
39063
39670
|
return `<div class="myio-cov__section-title">Dispositivos sem categoria de tarifa</div><ul class="myio-cov__devices">${items}</ul>`;
|
|
39064
39671
|
}
|
|
@@ -39510,7 +40117,7 @@ var AllReportModal = class {
|
|
|
39510
40117
|
this.domainConfig = DOMAIN_CONFIG2[domain];
|
|
39511
40118
|
this.granularity = params.granularity ?? (domain === "temperature" ? "1h" : "1d");
|
|
39512
40119
|
this.debugEnabled = params.debug === 1;
|
|
39513
|
-
this.moneyColumn = createReportMoneyColumn(
|
|
40120
|
+
this.moneyColumn = createReportMoneyColumn(this.activeMoney());
|
|
39514
40121
|
if (this.moneyColumn.enabled && typeof document !== "undefined") {
|
|
39515
40122
|
injectCoverageStyles(document);
|
|
39516
40123
|
}
|
|
@@ -39588,6 +40195,82 @@ var AllReportModal = class {
|
|
|
39588
40195
|
// RFC-0228 A7 — per-consumer realized-vs-goal R$ variance column. Disabled (all
|
|
39589
40196
|
// fragments '') when params.money.perDeviceGoal is absent → byte-identical.
|
|
39590
40197
|
varianceColumn;
|
|
40198
|
+
/**
|
|
40199
|
+
* RFC-0241 rev. 2 — the money config valid for the loaded period. When the caller
|
|
40200
|
+
* declared the period its R$ were computed for (`money.period`) and the report loads a
|
|
40201
|
+
* different one, per-device/total R$ are withheld (overlay `unavailable`) — never a
|
|
40202
|
+
* dashboard-period R$ next to another period's kWh. Tolerance: 24 h per edge (the
|
|
40203
|
+
* dashboard "until now" vs the picker's end of day).
|
|
40204
|
+
*/
|
|
40205
|
+
activeMoney() {
|
|
40206
|
+
const m = this.params.money ?? null;
|
|
40207
|
+
if (!m || !m.period || !this.exportPeriod?.startISO || !this.exportPeriod?.endISO) return m;
|
|
40208
|
+
const DAY = 24 * 3600 * 1e3;
|
|
40209
|
+
const near = (a, b) => {
|
|
40210
|
+
const x = Date.parse(String(a || ""));
|
|
40211
|
+
const y = Date.parse(String(b || ""));
|
|
40212
|
+
return Number.isFinite(x) && Number.isFinite(y) && Math.abs(x - y) <= DAY;
|
|
40213
|
+
};
|
|
40214
|
+
if (near(m.period.startISO, this.exportPeriod.startISO) && near(m.period.endISO, this.exportPeriod.endISO)) {
|
|
40215
|
+
return m;
|
|
40216
|
+
}
|
|
40217
|
+
return {
|
|
40218
|
+
...m,
|
|
40219
|
+
overlay: { state: "unavailable", reason: "PERIOD_MISMATCH" },
|
|
40220
|
+
perDevice: {},
|
|
40221
|
+
total: null,
|
|
40222
|
+
totalFor: void 0,
|
|
40223
|
+
valuateBucket: void 0
|
|
40224
|
+
};
|
|
40225
|
+
}
|
|
40226
|
+
/** RFC-0241 rev. 2 — R$ of one series bucket (Diário/Horário), or null when money is off. */
|
|
40227
|
+
bucketMoney(id, ts, gran, qty) {
|
|
40228
|
+
const vb = this.moneyColumn.enabled ? this.activeMoney()?.valuateBucket : void 0;
|
|
40229
|
+
if (!vb || this.isTemperature) return null;
|
|
40230
|
+
const span = gran === "1h" ? 3600 * 1e3 : 24 * 3600 * 1e3;
|
|
40231
|
+
return vb(id, ts, ts + span, qty) || { state: "uncategorized" };
|
|
40232
|
+
}
|
|
40233
|
+
/** Money cell for CSV (comma decimal, 2dp) — '' when not complete (never 0). */
|
|
40234
|
+
csvMoney(amount) {
|
|
40235
|
+
const r = roundMoney2(amount ?? null);
|
|
40236
|
+
return r ? r.replace(".", ",") : "";
|
|
40237
|
+
}
|
|
40238
|
+
/** Header of the R$ column (A6 default for RFC-0228 callers; Part B passes "Custo estimado (R$)"). */
|
|
40239
|
+
moneyHeaderLabel() {
|
|
40240
|
+
return this.params.money?.headerLabel || "Custo projetado (R$)";
|
|
40241
|
+
}
|
|
40242
|
+
/**
|
|
40243
|
+
* CSV footer for the R$ column: the total (BigInt cents, DEC-8 row sum) only when every
|
|
40244
|
+
* row has an amount; otherwise "Cobertura incompleta (n de m)" — never a partial sum.
|
|
40245
|
+
*/
|
|
40246
|
+
moneyTotalCsvRow(rows) {
|
|
40247
|
+
const label = `${this.moneyHeaderLabel()} \u2014 total`;
|
|
40248
|
+
const amount = this.moneyTotalAmount(rows);
|
|
40249
|
+
if (amount) return [label, "", this.csvMoney(amount)];
|
|
40250
|
+
const covered = rows.filter((r) => this.rowMoney(r.id)).length;
|
|
40251
|
+
return [label, "", `Cobertura incompleta (${covered} de ${rows.length})`];
|
|
40252
|
+
}
|
|
40253
|
+
/**
|
|
40254
|
+
* Honest R$ total of `rows`: `totalFor(ids)` (round Σ raw of exactly these rows, RFC-0241)
|
|
40255
|
+
* when provided, else the A6 resolution (backend total / 2dp row sum). null = incomplete.
|
|
40256
|
+
*/
|
|
40257
|
+
moneyTotalAmount(rows) {
|
|
40258
|
+
const m = this.activeMoney();
|
|
40259
|
+
if (!m || !this.moneyColumn.enabled) return null;
|
|
40260
|
+
if (typeof m.totalFor === "function") {
|
|
40261
|
+
if (m.overlay?.state !== "available") return null;
|
|
40262
|
+
const ids = rows.map((r) => r.id).filter((id) => !!id);
|
|
40263
|
+
return ids.length === rows.length ? m.totalFor(ids) : null;
|
|
40264
|
+
}
|
|
40265
|
+
const total = this.moneyColumn.resolveTotal(rows.map((r) => this.rowMoney(r.id)));
|
|
40266
|
+
return total && total.kind === "amount" ? total.amount : null;
|
|
40267
|
+
}
|
|
40268
|
+
/** Per-device period R$ (2dp string) of the loaded period, or null. */
|
|
40269
|
+
rowMoney(id) {
|
|
40270
|
+
if (!id) return null;
|
|
40271
|
+
const v = this.activeMoney()?.perDevice?.[id];
|
|
40272
|
+
return typeof v === "string" && v.trim() ? v : null;
|
|
40273
|
+
}
|
|
39591
40274
|
// Debug logging helper
|
|
39592
40275
|
debugLog(message, data) {
|
|
39593
40276
|
if (this.debugEnabled) {
|
|
@@ -39962,6 +40645,7 @@ var AllReportModal = class {
|
|
|
39962
40645
|
const { startISO, endISO } = this.dateRangePicker.getDates();
|
|
39963
40646
|
this.debugLog("\u{1F4C5} Date range selected", { startISO, endISO });
|
|
39964
40647
|
this.exportPeriod = { startISO, endISO };
|
|
40648
|
+
if (this.params.money) this.moneyColumn = createReportMoneyColumn(this.activeMoney());
|
|
39965
40649
|
this.hourlySeriesCache = null;
|
|
39966
40650
|
this.deviceSeriesCache.clear();
|
|
39967
40651
|
this.temperatureStats.clear();
|
|
@@ -40146,10 +40830,17 @@ var AllReportModal = class {
|
|
|
40146
40830
|
// the overlay is confidently priced (DEC-8), otherwise a coverage state label.
|
|
40147
40831
|
computeMoneyKpi() {
|
|
40148
40832
|
if (!this.moneyColumn.enabled) return null;
|
|
40149
|
-
const
|
|
40833
|
+
const money = this.activeMoney();
|
|
40834
|
+
if (money && typeof money.totalFor === "function") {
|
|
40835
|
+
const label2 = money.headerLabel || "Custo projetado (R$)";
|
|
40836
|
+
if (money.overlay?.state !== "available") return { value: "Indispon\xEDvel", label: label2 };
|
|
40837
|
+
const amount = this.moneyTotalAmount(this.data);
|
|
40838
|
+
return { value: amount ? formatBRL(amount) : "Cobertura incompleta", label: label2 };
|
|
40839
|
+
}
|
|
40840
|
+
const rowValues = this.data.map((r) => r.id ? this.activeMoney()?.perDevice?.[r.id] : null);
|
|
40150
40841
|
const total = this.moneyColumn.resolveTotal(rowValues);
|
|
40151
40842
|
if (!total) return null;
|
|
40152
|
-
const label = this.
|
|
40843
|
+
const label = this.activeMoney()?.headerLabel || "Custo projetado (R$)";
|
|
40153
40844
|
if (total.kind === "amount") {
|
|
40154
40845
|
return { value: total.formatted, label };
|
|
40155
40846
|
}
|
|
@@ -40365,6 +41056,19 @@ var AllReportModal = class {
|
|
|
40365
41056
|
timeZone: "America/Sao_Paulo"
|
|
40366
41057
|
}) : new Date(ts).toLocaleDateString("pt-BR", { timeZone: "America/Sao_Paulo" });
|
|
40367
41058
|
const valueLabel = this.isTemperature ? gran === "1h" ? "Temperatura (\xB0C)" : "M\xE9dia do dia (\xB0C)" : this.domainConfig.label;
|
|
41059
|
+
if (this.bucketMoney(id, points[0].timestamp, gran, points[0].value)) {
|
|
41060
|
+
const money = points.map((p) => this.bucketMoney(id, p.timestamp, gran, p.value));
|
|
41061
|
+
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>`;
|
|
41062
|
+
const sub = sumItemMoney(money);
|
|
41063
|
+
const subCell = sub.state === "complete" && sub.amount ? formatBRL(sub.amount) : `<span class="rp-muted">Cobertura incompleta (${sub.covered} de ${sub.total})</span>`;
|
|
41064
|
+
box.innerHTML = `
|
|
41065
|
+
<table>
|
|
41066
|
+
<thead><tr><th>${gran === "1h" ? "Data/Hora" : "Dia"}</th><th class="num">${valueLabel}</th><th class="num">${this.moneyHeaderLabel()}</th></tr></thead>
|
|
41067
|
+
<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>
|
|
41068
|
+
<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>
|
|
41069
|
+
</table>`;
|
|
41070
|
+
return;
|
|
41071
|
+
}
|
|
40368
41072
|
box.innerHTML = `
|
|
40369
41073
|
<table>
|
|
40370
41074
|
<thead><tr><th>${gran === "1h" ? "Data/Hora" : "Dia"}</th><th class="num">${valueLabel}</th></tr></thead>
|
|
@@ -40668,6 +41372,11 @@ var AllReportModal = class {
|
|
|
40668
41372
|
// Data rows
|
|
40669
41373
|
...sortedData.map((row) => [row.identifier, row.name, row.consumption.toFixed(2).replace(".", ",")])
|
|
40670
41374
|
];
|
|
41375
|
+
if (this.moneyColumn.enabled) {
|
|
41376
|
+
csvData[0].push(this.moneyHeaderLabel());
|
|
41377
|
+
sortedData.forEach((row, i) => csvData[i + 1].push(this.csvMoney(this.rowMoney(row.id))));
|
|
41378
|
+
csvData.push([], this.moneyTotalCsvRow(sortedData));
|
|
41379
|
+
}
|
|
40671
41380
|
const csvContent = toCsv(csvData);
|
|
40672
41381
|
this.downloadCSV(csvContent, `relatorio-geral-lojas-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.csv`);
|
|
40673
41382
|
}
|
|
@@ -40748,16 +41457,31 @@ var AllReportModal = class {
|
|
|
40748
41457
|
const csvData = [
|
|
40749
41458
|
["Identificador", "Nome", "Data/Hora", `Consumo (${this.domainConfig.unit})`]
|
|
40750
41459
|
];
|
|
41460
|
+
const withMoney = this.moneyColumn.enabled && !!this.activeMoney()?.valuateBucket;
|
|
41461
|
+
if (withMoney) csvData[0].push(this.moneyHeaderLabel());
|
|
41462
|
+
let moneyRows = 0;
|
|
41463
|
+
let moneyComplete = 0;
|
|
40751
41464
|
for (const row of sortedData) {
|
|
40752
41465
|
const points = row.id && series.get(row.id) || [];
|
|
40753
41466
|
for (const p of points) {
|
|
40754
|
-
|
|
41467
|
+
const line = [row.identifier, row.name, fmtTs(p.timestamp), p.value.toFixed(2).replace(".", ",")];
|
|
41468
|
+
if (withMoney) {
|
|
41469
|
+
const m = this.bucketMoney(row.id, p.timestamp, "1h", p.value);
|
|
41470
|
+
const ok = m?.state === "complete" ? this.csvMoney(m.amount) : "";
|
|
41471
|
+
moneyRows += 1;
|
|
41472
|
+
if (ok) moneyComplete += 1;
|
|
41473
|
+
line.push(ok);
|
|
41474
|
+
}
|
|
41475
|
+
csvData.push(line);
|
|
40755
41476
|
}
|
|
40756
41477
|
}
|
|
40757
41478
|
if (csvData.length === 1) {
|
|
40758
41479
|
this.showError("Nenhum dado hor\xE1rio dispon\xEDvel para o per\xEDodo selecionado.");
|
|
40759
41480
|
return;
|
|
40760
41481
|
}
|
|
41482
|
+
if (withMoney && moneyComplete < moneyRows) {
|
|
41483
|
+
csvData.push([], [`${this.moneyHeaderLabel()}`, "", "", "", `Cobertura incompleta (${moneyComplete} de ${moneyRows})`]);
|
|
41484
|
+
}
|
|
40761
41485
|
const csvContent = toCsv(csvData);
|
|
40762
41486
|
this.downloadCSV(
|
|
40763
41487
|
csvContent,
|
|
@@ -40828,7 +41552,11 @@ var AllReportModal = class {
|
|
|
40828
41552
|
val: this.isTemperature && r.noData ? null : r.consumption,
|
|
40829
41553
|
perc: this.isTemperature ? void 0 : grandTotal > 0 ? r.consumption / grandTotal * 100 : 0
|
|
40830
41554
|
};
|
|
40831
|
-
if (!this.isTemperature)
|
|
41555
|
+
if (!this.isTemperature) {
|
|
41556
|
+
if (!this.moneyColumn.enabled) return base;
|
|
41557
|
+
const v = this.rowMoney(r.id);
|
|
41558
|
+
return { ...base, extraCells: [v ? formatBRL(v) : ""] };
|
|
41559
|
+
}
|
|
40832
41560
|
const off = r.id && !r.noData ? this.temperatureOffsetFor(r.id) : 0;
|
|
40833
41561
|
return {
|
|
40834
41562
|
...base,
|
|
@@ -40870,7 +41598,9 @@ var AllReportModal = class {
|
|
|
40870
41598
|
}
|
|
40871
41599
|
// Colunas do PDF/XLS = colunas da tela. Temperatura: Sensor | Média | Mín | Máx (sem %).
|
|
40872
41600
|
exportColumns() {
|
|
40873
|
-
if (!this.isTemperature)
|
|
41601
|
+
if (!this.isTemperature) {
|
|
41602
|
+
return this.moneyColumn.enabled ? { extraColumns: [{ label: this.moneyHeaderLabel(), pdfW: 40 }] } : null;
|
|
41603
|
+
}
|
|
40874
41604
|
return {
|
|
40875
41605
|
nameLabel: "Sensor",
|
|
40876
41606
|
valueLabel: "M\xE9dia (\xB0C)",
|
|
@@ -53352,7 +54082,7 @@ var IMPORTANCE_COLORS2 = {
|
|
|
53352
54082
|
5: "#ff7675"
|
|
53353
54083
|
};
|
|
53354
54084
|
var ORDERED_TYPES = ["observation", "pending", "maintenance", "activity"];
|
|
53355
|
-
function
|
|
54085
|
+
function esc3(s) {
|
|
53356
54086
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
53357
54087
|
}
|
|
53358
54088
|
function fmtDt(iso) {
|
|
@@ -53382,11 +54112,11 @@ function renderCard(ann) {
|
|
|
53382
54112
|
<span class="adm-annot-imp-badge" style="background:${ic};color:${darkText ? "#fff" : "#333"}" title="${IMPORTANCE_LABELS2[ann.importance]}">${stars}</span>
|
|
53383
54113
|
${ann.archived ? '<span class="adm-annot-archived-badge">Arquivada</span>' : ""}
|
|
53384
54114
|
</div>
|
|
53385
|
-
<div class="adm-annot-card-text">${
|
|
54115
|
+
<div class="adm-annot-card-text">${esc3(ann.text)}</div>
|
|
53386
54116
|
${ann.dueDate ? `<div class="adm-annot-due">\u23F0 Prazo: ${new Date(ann.dueDate).toLocaleDateString("pt-BR")}</div>` : ""}
|
|
53387
54117
|
<div class="adm-annot-card-meta">
|
|
53388
54118
|
<div class="adm-annot-avatar">${ini}</div>
|
|
53389
|
-
<span class="adm-annot-author">${
|
|
54119
|
+
<span class="adm-annot-author">${esc3(ann.createdBy)}</span>
|
|
53390
54120
|
<span class="adm-annot-date">${fmtDt(ann.createdAt)}</span>
|
|
53391
54121
|
</div>
|
|
53392
54122
|
${!ann.archived ? `<div class="adm-annot-actions">
|
|
@@ -53414,7 +54144,7 @@ function renderForm(editAnn) {
|
|
|
53414
54144
|
<div class="adm-annot-form" data-edit-id="${editAnn?.id ?? ""}">
|
|
53415
54145
|
<div class="adm-annot-form-title">${editAnn ? "\u270F\uFE0F Editar Anota\xE7\xE3o" : "\u270F\uFE0F Nova Anota\xE7\xE3o"}</div>
|
|
53416
54146
|
<textarea class="adm-annot-textarea" id="admAnnotText" maxlength="255"
|
|
53417
|
-
placeholder="Digite sua anota\xE7\xE3o (m\xE1x. 255 caracteres)...">${editAnn ?
|
|
54147
|
+
placeholder="Digite sua anota\xE7\xE3o (m\xE1x. 255 caracteres)...">${editAnn ? esc3(editAnn.text) : ""}</textarea>
|
|
53418
54148
|
<div class="adm-annot-char-count"><span id="admAnnotCC">${editAnn ? editAnn.text.length : 0}</span> / 255</div>
|
|
53419
54149
|
<div class="adm-annot-form-row">
|
|
53420
54150
|
<div class="adm-annot-form-field">
|
|
@@ -53800,7 +54530,7 @@ function initials2(name) {
|
|
|
53800
54530
|
const parts = name.trim().split(/\s+/);
|
|
53801
54531
|
return parts.length >= 2 ? (parts[0][0] + parts[parts.length - 1][0]).toUpperCase() : name.substring(0, 2).toUpperCase();
|
|
53802
54532
|
}
|
|
53803
|
-
function
|
|
54533
|
+
function esc4(s) {
|
|
53804
54534
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
53805
54535
|
}
|
|
53806
54536
|
function buildTooltipHtml(annotations) {
|
|
@@ -53821,11 +54551,11 @@ function buildTooltipHtml(annotations) {
|
|
|
53821
54551
|
<span class="annot-tooltip__type-badge" style="background:${tc}18;color:${tc};border:1px solid ${tc}40">${TYPE_LABELS2[ann.type]}</span>
|
|
53822
54552
|
<span class="annot-tooltip__stars" style="color:${ic}">${stars}</span>
|
|
53823
54553
|
</div>
|
|
53824
|
-
<div class="annot-tooltip__text">${
|
|
54554
|
+
<div class="annot-tooltip__text">${esc4(ann.text)}</div>
|
|
53825
54555
|
${ann.dueDate ? `<div class="annot-tooltip__due">\u23F0 Prazo: ${new Date(ann.dueDate).toLocaleDateString("pt-BR")}</div>` : ""}
|
|
53826
54556
|
<div class="annot-tooltip__meta">
|
|
53827
54557
|
<span class="annot-tooltip__avatar">${ini}</span>
|
|
53828
|
-
<span class="annot-tooltip__author">${
|
|
54558
|
+
<span class="annot-tooltip__author">${esc4(ann.createdBy)}</span>
|
|
53829
54559
|
<span class="annot-tooltip__date">${fmtDt2(ann.createdAt)}</span>
|
|
53830
54560
|
</div>
|
|
53831
54561
|
</div>`;
|
|
@@ -66208,8 +66938,8 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66208
66938
|
const segmentEl = this.modal.querySelector("#segment");
|
|
66209
66939
|
const activityEl = this.modal.querySelector("#activity");
|
|
66210
66940
|
if (!segmentEl || !activityEl) return;
|
|
66211
|
-
const
|
|
66212
|
-
const options = (values, selected, placeholder) => `<option value="">${placeholder}</option>` + values.map((v) => `<option value="${
|
|
66941
|
+
const esc11 = (s) => s.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
66942
|
+
const options = (values, selected, placeholder) => `<option value="">${placeholder}</option>` + values.map((v) => `<option value="${esc11(v)}"${v === selected ? " selected" : ""}>${esc11(v)}</option>`).join("");
|
|
66213
66943
|
const catalog = await loadStoreSegmentCatalog(this.config.segmentCatalog);
|
|
66214
66944
|
const savedSegment = String(saved.segment || "");
|
|
66215
66945
|
const savedActivity = String(saved.activity || "");
|
|
@@ -72692,7 +73422,7 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
72692
73422
|
if (this.metaTipEl) this.metaTipEl.style.display = "none";
|
|
72693
73423
|
}
|
|
72694
73424
|
buildMetaTipHtml(type, card) {
|
|
72695
|
-
const
|
|
73425
|
+
const esc11 = _WelcomeModalView.escapeMetaHtml;
|
|
72696
73426
|
const chip = _WelcomeModalView.metaChip;
|
|
72697
73427
|
const meta = card.metaCounts || {};
|
|
72698
73428
|
const details = card.metaDetails || {};
|
|
@@ -72702,7 +73432,7 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
72702
73432
|
).padStart(2, "0")}:${String(now.getMinutes()).padStart(2, "0")}`;
|
|
72703
73433
|
const frame = (icon2, label, body) => `<div class="myio-welcome-meta-tip__header">
|
|
72704
73434
|
<span class="myio-welcome-meta-tip__icon">${icon2}</span>
|
|
72705
|
-
<span class="myio-welcome-meta-tip__title">${label} (${
|
|
73435
|
+
<span class="myio-welcome-meta-tip__title">${label} (${esc11(card.title)})</span>
|
|
72706
73436
|
<span class="myio-welcome-meta-tip__timestamp">${stamp}</span>
|
|
72707
73437
|
<button type="button" class="myio-welcome-meta-tip__close" title="Fechar">\u2715</button>
|
|
72708
73438
|
</div>
|
|
@@ -72730,8 +73460,8 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
72730
73460
|
const chips = Object.entries(byState).map(([s, n]) => chip(`${s}: ${n}`)).join("");
|
|
72731
73461
|
const rows = alarms.slice(0, 10).map(
|
|
72732
73462
|
(a) => row(
|
|
72733
|
-
|
|
72734
|
-
[a.severity, a.state].filter(Boolean).map(
|
|
73463
|
+
esc11(a.deviceName ? `${a.deviceName} \u2014 ${a.title || "Alarme"}` : a.title || "Alarme"),
|
|
73464
|
+
[a.severity, a.state].filter(Boolean).map(esc11).join(" \xB7 ")
|
|
72735
73465
|
)
|
|
72736
73466
|
).join("");
|
|
72737
73467
|
return frame(
|
|
@@ -72755,7 +73485,7 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
72755
73485
|
const rows = annotations.slice(0, 10).map((a) => {
|
|
72756
73486
|
const when = a.createdAt ? new Date(a.createdAt).toLocaleDateString("pt-BR") : "";
|
|
72757
73487
|
const text2 = a.text.length > 90 ? `${a.text.slice(0, 90)}\u2026` : a.text;
|
|
72758
|
-
return row(
|
|
73488
|
+
return row(esc11(a.deviceLabel || "Dispositivo"), `${esc11(text2)}${when ? ` \xB7 ${esc11(when)}` : ""}`);
|
|
72759
73489
|
}).join("");
|
|
72760
73490
|
return frame(
|
|
72761
73491
|
"\u{1F4CB}",
|
|
@@ -72766,7 +73496,7 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
72766
73496
|
if (type === "users") {
|
|
72767
73497
|
if (meta.users === null) return frame("\u{1F465}", "Usu\xE1rios", loadingBody);
|
|
72768
73498
|
const users = details.users || [];
|
|
72769
|
-
const rows = users.slice(0, 10).map((u) => row(
|
|
73499
|
+
const rows = users.slice(0, 10).map((u) => row(esc11(u.name), esc11(u.email || ""))).join("");
|
|
72770
73500
|
return frame(
|
|
72771
73501
|
"\u{1F465}",
|
|
72772
73502
|
"Usu\xE1rios",
|
|
@@ -83132,7 +83862,7 @@ var PRESETS = [
|
|
|
83132
83862
|
{ id: "custom", label: "Personalizado" }
|
|
83133
83863
|
];
|
|
83134
83864
|
var STEPS = ["Dispositivos", "Per\xEDodo", "Telemetrias", "Resumo"];
|
|
83135
|
-
var
|
|
83865
|
+
var esc5 = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
83136
83866
|
var norm = (s) => String(s ?? "").normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase();
|
|
83137
83867
|
var fmtN = (n) => n.toLocaleString("pt-BR");
|
|
83138
83868
|
var pad = (n) => String(n).padStart(2, "0");
|
|
@@ -83520,8 +84250,8 @@ var DemandPanelV2 = class {
|
|
|
83520
84250
|
highlight(text2) {
|
|
83521
84251
|
const q = norm(this.s.search).trim();
|
|
83522
84252
|
const i = q ? norm(text2).indexOf(q) : -1;
|
|
83523
|
-
if (i < 0) return
|
|
83524
|
-
return
|
|
84253
|
+
if (i < 0) return esc5(text2);
|
|
84254
|
+
return esc5(text2.slice(0, i)) + `<mark class="dp2-mark">${esc5(text2.slice(i, i + q.length))}</mark>` + esc5(text2.slice(i + q.length));
|
|
83525
84255
|
}
|
|
83526
84256
|
deviceRow(d, mode) {
|
|
83527
84257
|
const picked = this.s.selected.includes(d.tbDeviceId);
|
|
@@ -83529,13 +84259,13 @@ var DemandPanelV2 = class {
|
|
|
83529
84259
|
const cat = this.categoryOf.get(d.tbDeviceId);
|
|
83530
84260
|
const chip = this.chips.find((c) => c.key === cat);
|
|
83531
84261
|
const dup = (this.labelCount.get(d.label) || 0) > 1;
|
|
83532
|
-
const action = mode === "result" ? picked ? '<span class="dp2-added">\u2713 Adicionado</span>' : `<button class="dp2-btn sm" type="button" data-action="add" data-id="${
|
|
84262
|
+
const action = mode === "result" ? picked ? '<span class="dp2-added">\u2713 Adicionado</span>' : `<button class="dp2-btn sm" type="button" data-action="add" data-id="${esc5(d.tbDeviceId)}" ${el2.ok ? "" : "disabled"} aria-label="Adicionar ${esc5(d.label)}">+ Adicionar</button>` : `<button class="dp2-btn sm" type="button" data-action="remove" data-id="${esc5(d.tbDeviceId)}" aria-label="Remover ${esc5(d.label)}">\u2715 Remover</button>`;
|
|
83533
84263
|
return `<div class="dp2-item ${el2.ok ? "" : "blocked"}">
|
|
83534
|
-
<img class="dp2-ico" src="${
|
|
84264
|
+
<img class="dp2-ico" src="${esc5(deviceIconUrl(d.deviceProfile))}" alt="" loading="lazy">
|
|
83535
84265
|
<div style="min-width:0">
|
|
83536
|
-
<div class="dp2-name">${mode === "result" ? this.highlight(d.label) :
|
|
83537
|
-
<div class="dp2-sub">${chip ? `<span class="dp2-tag">${
|
|
83538
|
-
${mode === "result" ? this.highlight(d.name) :
|
|
84266
|
+
<div class="dp2-name">${mode === "result" ? this.highlight(d.label) : esc5(d.label)}${dup && d.identifier ? ` <small class="dp2-info">\xB7 ${esc5(d.identifier)}</small>` : ""}</div>
|
|
84267
|
+
<div class="dp2-sub">${chip ? `<span class="dp2-tag">${esc5(chip.label)}</span>` : ""}${el2.text ? `<span class="dp2-tag ${el2.cls}" title="${esc5(el2.title)}">${el2.text}</span>` : ""}
|
|
84268
|
+
${mode === "result" ? this.highlight(d.name) : esc5(d.name)}${d.identifier ? " \xB7 " + esc5(d.identifier) : ""}</div>
|
|
83539
84269
|
</div>
|
|
83540
84270
|
<div>${action}</div>
|
|
83541
84271
|
</div>`;
|
|
@@ -83553,8 +84283,8 @@ var DemandPanelV2 = class {
|
|
|
83553
84283
|
this.el.body.innerHTML = `<div class="dp2-s1">
|
|
83554
84284
|
<section class="dp2-col" aria-label="Buscar medidores">
|
|
83555
84285
|
<div class="dp2-col-head">
|
|
83556
|
-
<input class="dp2-search" data-role="search" type="search" placeholder="\u{1F50E} Buscar por nome, identificador ou tipo\u2026" value="${
|
|
83557
|
-
<div class="dp2-chips" role="group" aria-label="Filtrar por tipo">${chips.map((c) => `<button class="dp2-chip" type="button" data-action="category" data-key="${
|
|
84286
|
+
<input class="dp2-search" data-role="search" type="search" placeholder="\u{1F50E} Buscar por nome, identificador ou tipo\u2026" value="${esc5(this.s.search)}" aria-label="Buscar medidores">
|
|
84287
|
+
<div class="dp2-chips" role="group" aria-label="Filtrar por tipo">${chips.map((c) => `<button class="dp2-chip" type="button" data-action="category" data-key="${esc5(c.key)}" aria-pressed="${this.s.category === c.key}">${c.icon ? esc5(c.icon) + " " : ""}${esc5(c.label)} \xB7 ${c.count}</button>`).join("")}</div>
|
|
83558
84288
|
<h3><span>${fmtN(results.length)} resultado(s)</span>
|
|
83559
84289
|
<button class="dp2-btn link" type="button" data-action="add-all" ${addable ? "" : "disabled"}>+ Adicionar todos (${addable})</button></h3>
|
|
83560
84290
|
</div>
|
|
@@ -83593,7 +84323,7 @@ var DemandPanelV2 = class {
|
|
|
83593
84323
|
<div class="dp2-card"><h3 tabindex="-1" data-role="step-title">Per\xEDodo</h3>
|
|
83594
84324
|
<div class="dp2-chips" style="margin-bottom:12px">${PRESETS.map((p) => {
|
|
83595
84325
|
const off = p.id !== "custom" && presetTooLong(p.id);
|
|
83596
|
-
return `<button class="dp2-chip" type="button" data-action="preset" data-preset="${p.id}" aria-pressed="${preset === p.id}" ${off ? `disabled title="at\xE9 ${maxDays} dia(s) com intervalos de ${
|
|
84326
|
+
return `<button class="dp2-chip" type="button" data-action="preset" data-preset="${p.id}" aria-pressed="${preset === p.id}" ${off ? `disabled title="at\xE9 ${maxDays} dia(s) com intervalos de ${esc5(r.label)}"` : ""}>${p.label}</button>`;
|
|
83597
84327
|
}).join("")}</div>
|
|
83598
84328
|
<div class="dp2-row">
|
|
83599
84329
|
<label class="dp2-field">In\xEDcio<input type="datetime-local" data-role="start" min="${MIN_PERIOD_START}T00:00" value="${Number.isFinite(start) ? toLocalDateTimeInput(start) : ""}"></label>
|
|
@@ -83606,24 +84336,24 @@ var DemandPanelV2 = class {
|
|
|
83606
84336
|
const d = limits?.maxDaysByResolution[x.id];
|
|
83607
84337
|
return `<button class="dp2-chip" type="button" data-action="resolution" data-res="${x.id}" aria-pressed="${this.s.resolution === x.id}">${x.label}${d != null ? ` <small>(at\xE9 ${d} d)</small>` : ""}</button>`;
|
|
83608
84338
|
}).join("")}</div>
|
|
83609
|
-
<p class="dp2-info" style="margin:10px 0 0">Cada linha do relat\xF3rio \xE9 um intervalo com <b>${
|
|
83610
|
-
${this.s.telemetries.has("consumption") ? `Com <b>Pot\xEAncia Total</b>, o arquivo traz tamb\xE9m a <b>${
|
|
84339
|
+
<p class="dp2-info" style="margin:10px 0 0">Cada linha do relat\xF3rio \xE9 um intervalo com <b>${esc5(BUCKET_STATS_LABEL)}</b> de cada telemetria. Os intervalos contam a partir do in\xEDcio do per\xEDodo${this.s.resolution === "1d" ? " (com 1 dia, cada linha \xE9 um dia do calend\xE1rio)" : ""}.
|
|
84340
|
+
${this.s.telemetries.has("consumption") ? `Com <b>Pot\xEAncia Total</b>, o arquivo traz tamb\xE9m a <b>${esc5(this.demandLabel())}</b>, em janelas de 15 min alinhadas ao rel\xF3gio.` : ""}</p>
|
|
83611
84341
|
${valid && !tooLong ? `<p class="dp2-info" style="margin:6px 0 0">${fmtN(bucketCount(start, end, this.s.resolution))} intervalo(s) por medidor.</p>` : ""}
|
|
83612
|
-
${tooLong ? `<div class="dp2-fix"><span class="dp2-err">O per\xEDodo \xE9 longo demais para intervalos de ${
|
|
83613
|
-
${fit ? `<button class="dp2-btn sm primary" type="button" data-action="resolution" data-res="${fit}">Usar ${
|
|
84342
|
+
${tooLong ? `<div class="dp2-fix"><span class="dp2-err">O per\xEDodo \xE9 longo demais para intervalos de ${esc5(r.label)} (m\xE1ximo ${maxDays} dia(s)).</span>
|
|
84343
|
+
${fit ? `<button class="dp2-btn sm primary" type="button" data-action="resolution" data-res="${fit}">Usar ${esc5(RESOLUTION_BY_ID[fit].label)}</button>` : ""}
|
|
83614
84344
|
<button class="dp2-btn sm" type="button" data-action="shorten">Encurtar para os \xFAltimos ${maxDays} dia(s)</button></div>` : ""}
|
|
83615
84345
|
${misaligned ? `<div class="dp2-fix"><span class="dp2-err">Com intervalos de 1 dia, o in\xEDcio precisa ser \xE0 meia-noite.</span>
|
|
83616
|
-
<button class="dp2-btn sm primary" type="button" data-action="snap-midnight">Come\xE7ar em ${
|
|
84346
|
+
<button class="dp2-btn sm primary" type="button" data-action="snap-midnight">Come\xE7ar em ${esc5(formatLocalDateTime(localMidnightOf(start)))}</button></div>` : ""}
|
|
83617
84347
|
</div>
|
|
83618
|
-
${otherErrs.length ? `<p class="dp2-err">${otherErrs.map(
|
|
84348
|
+
${otherErrs.length ? `<p class="dp2-err">${otherErrs.map(esc5).join("<br>")}</p>` : ""}`;
|
|
83619
84349
|
}
|
|
83620
84350
|
renderStep3() {
|
|
83621
84351
|
this.el.body.innerHTML = `<div class="dp2-tgrid">${TELEMETRY_GROUPS.map((g) => {
|
|
83622
84352
|
const all = g.items.every((t) => this.s.telemetries.has(t.key));
|
|
83623
|
-
return `<div class="dp2-card"><h3><span>${g.icon} ${
|
|
84353
|
+
return `<div class="dp2-card"><h3><span>${g.icon} ${esc5(g.label)}</span>
|
|
83624
84354
|
<button class="dp2-btn link" type="button" data-action="group-all" data-gid="${g.id}">${all ? "Desmarcar" : "Marcar"} todos</button></h3>
|
|
83625
84355
|
${g.items.map((t) => `<label class="dp2-check"><input type="checkbox" data-role="tel" data-key="${t.key}" ${this.s.telemetries.has(t.key) ? "checked" : ""}>
|
|
83626
|
-
${
|
|
84356
|
+
${esc5(t.label)}<span class="u">${this.p.supportMode ? esc5(t.key) + " \xB7 " : ""}${esc5(t.unit)}</span></label>`).join("")}
|
|
83627
84357
|
</div>`;
|
|
83628
84358
|
}).join("")}</div>
|
|
83629
84359
|
<p class="dp2-info">${this.s.telemetries.size} de ${TELEMETRY_CATALOG.length} telemetrias. Mesmo cat\xE1logo da modal "Telemetrias Instant\xE2neas e Pico de Demanda".</p>`;
|
|
@@ -83643,14 +84373,14 @@ var DemandPanelV2 = class {
|
|
|
83643
84373
|
let validation = "";
|
|
83644
84374
|
if (v.state === "loading") validation = '<div class="dp2-info">\u23F3 Validando o pedido no servidor\u2026</div>';
|
|
83645
84375
|
else if (v.state === "error") {
|
|
83646
|
-
validation = `<div class="dp2-err">N\xE3o foi poss\xEDvel validar agora: ${
|
|
84376
|
+
validation = `<div class="dp2-err">N\xE3o foi poss\xEDvel validar agora: ${esc5(v.error)}
|
|
83647
84377
|
<button class="dp2-btn link" type="button" data-action="revalidate">Tentar de novo</button></div>`;
|
|
83648
84378
|
} else if (vr) {
|
|
83649
84379
|
const warns = (vr.warnings || []).map((w) => {
|
|
83650
84380
|
const dev = w.deviceId;
|
|
83651
|
-
return `<li>${
|
|
84381
|
+
return `<li>${esc5(warningText(w.code, w.message) + (dev ? this.devicesSuffix({ devices: [{ deviceId: dev }] }) : ""))}</li>`;
|
|
83652
84382
|
}).join("");
|
|
83653
|
-
const reuse = vr.reusable ? `<div class="dp2-banner info" style="margin-top:8px">\u267B J\xE1 existe um relat\xF3rio id\xEAntico${vr.reusable.generatedAt ? ` gerado em ${
|
|
84383
|
+
const reuse = vr.reusable ? `<div class="dp2-banner info" style="margin-top:8px">\u267B J\xE1 existe um relat\xF3rio id\xEAntico${vr.reusable.generatedAt ? ` gerado em ${esc5(formatLocalDateTime(Date.parse(vr.reusable.generatedAt)))}` : ""}${vr.reusable.generatedBy?.userId ? ` por ${esc5(vr.reusable.generatedBy.userId)}` : ""}. Confirmar reaproveita o arquivo (sem custo de cota).
|
|
83654
84384
|
<label class="dp2-check" style="margin-top:6px"><input type="checkbox" data-role="force" ${this.s.force ? "checked" : ""}> Gerar novamente mesmo assim</label></div>` : "";
|
|
83655
84385
|
validation = `${vr.ok ? '<div class="dp2-info">\u2713 Pedido validado no servidor.</div>' : ""}
|
|
83656
84386
|
${warns ? `<ul class="dp2-info" style="margin:6px 0 0;padding-left:18px">${warns}</ul>` : ""}${reuse}`;
|
|
@@ -83658,12 +84388,12 @@ var DemandPanelV2 = class {
|
|
|
83658
84388
|
this.el.body.innerHTML = `
|
|
83659
84389
|
<div class="dp2-card"><h3 tabindex="-1" data-role="step-title">Resumo do pedido</h3>
|
|
83660
84390
|
<dl class="dp2-sum">
|
|
83661
|
-
<dt>Solicitante</dt><dd>${
|
|
83662
|
-
<dt>Medidores (${req.devices.length})</dt><dd><div class="dp2-pills">${req.devices.map((d) => `<span class="dp2-pill">${
|
|
84391
|
+
<dt>Solicitante</dt><dd>${esc5(this.p.user.name)}</dd>
|
|
84392
|
+
<dt>Medidores (${req.devices.length})</dt><dd><div class="dp2-pills">${req.devices.map((d) => `<span class="dp2-pill">${esc5(labelOf(d))}</span>`).join("")}</div></dd>
|
|
83663
84393
|
<dt>Per\xEDodo</dt><dd>${formatLocalDateTime(start)} \u2192 ${formatLocalDateTime(end)} <span class="dp2-info">(${fmtDuration(end - start)}, hor\xE1rio de Bras\xEDlia${req.period.preset === "today" || req.period.preset === "thisMonth" ? `, calculado \xE0s ${formatLocalDateTime(snap.takenAt).slice(11)}` : ""})</span></dd>
|
|
83664
|
-
<dt>Resolu\xE7\xE3o</dt><dd>${
|
|
83665
|
-
<dt>Telemetrias (${req.telemetries.length})</dt><dd><div class="dp2-pills">${req.telemetries.map((t) => `<span class="dp2-pill">${
|
|
83666
|
-
${req.telemetries.some((t) => t.key === "consumption") ? `<div class="dp2-info" style="margin-top:4px">Inclui a ${
|
|
84394
|
+
<dt>Resolu\xE7\xE3o</dt><dd>${esc5(this.resolutionLabel(req.resolution))} <span class="dp2-info">(${esc5(BUCKET_STATS_LABEL)})</span></dd>
|
|
84395
|
+
<dt>Telemetrias (${req.telemetries.length})</dt><dd><div class="dp2-pills">${req.telemetries.map((t) => `<span class="dp2-pill">${esc5(t.label)} \xB7 ${esc5(t.unit)}</span>`).join("")}</div>
|
|
84396
|
+
${req.telemetries.some((t) => t.key === "consumption") ? `<div class="dp2-info" style="margin-top:4px">Inclui a ${esc5(this.demandLabel())}.</div>` : ""}</dd>
|
|
83667
84397
|
<dt>Tamanho</dt><dd><span class="dp2-size ${cls}">${txt}</span> <span class="dp2-info">\u2248 ${fmtN(pts)} pontos</span>
|
|
83668
84398
|
<details class="dp2-details"><summary>Detalhes</summary><span class="dp2-info">${fmtN(est.buckets)} intervalos \xD7 ${req.devices.length} medidores \xD7 ${req.telemetries.length} telemetrias${this.limits()?.maxPoints != null ? ` \xB7 limite ${fmtN(this.limits().maxPoints)}` : ""}</span></details></dd>
|
|
83669
84399
|
<dt>Entrega</dt><dd>Arquivos XLSX, CSV e JSON <span class="dp2-info">(dispon\xEDveis por 3 dias; o resumo fica por 1 ano)</span></dd>
|
|
@@ -83671,15 +84401,15 @@ var DemandPanelV2 = class {
|
|
|
83671
84401
|
<div style="margin-top:12px">${validation}</div>
|
|
83672
84402
|
<p class="dp2-info" style="margin:12px 0 0">Seu pedido fica registrado (quem, quando, o qu\xEA) e \xE9 processado em segundo plano. <b>Voc\xEA pode fechar este painel</b> e acompanhar em Relat\xF3rios.</p>
|
|
83673
84403
|
</div>
|
|
83674
|
-
${this.p.supportMode ? `<div class="dp2-card"><h3>Pedido que ser\xE1 registrado (suporte)</h3><pre class="dp2-json">${
|
|
83675
|
-
${errs.length ? `<p class="dp2-err">${errs.map(
|
|
84404
|
+
${this.p.supportMode ? `<div class="dp2-card"><h3>Pedido que ser\xE1 registrado (suporte)</h3><pre class="dp2-json">${esc5(JSON.stringify(req, null, 2))}</pre></div>` : ""}
|
|
84405
|
+
${errs.length ? `<p class="dp2-err">${errs.map(esc5).join("<br>")}</p>` : ""}`;
|
|
83676
84406
|
}
|
|
83677
84407
|
renderNav() {
|
|
83678
84408
|
const errs = this.stepErrors(this.s.step);
|
|
83679
84409
|
const hints = ["", `${this.s.selected.length} medidor(es) na lista`, "Escolha o per\xEDodo e a resolu\xE7\xE3o", `${this.s.telemetries.size} telemetria(s)`, "Revise e confirme"];
|
|
83680
84410
|
this.el.nav.innerHTML = `
|
|
83681
84411
|
<button class="dp2-btn" type="button" data-action="back" ${this.s.step === 1 ? "disabled" : ""}>\u2190 Voltar</button>
|
|
83682
|
-
<span class="hint">${
|
|
84412
|
+
<span class="hint">${esc5(hints[this.s.step])}</span>
|
|
83683
84413
|
${this.s.step === 4 ? `<button class="dp2-btn primary" type="button" data-action="confirm" ${errs.length || this.s.submitting || this.s.validation.state !== "ok" ? "disabled" : ""}>${this.s.submitting ? "Enviando\u2026" : "\u2713 Confirmar e enviar"}</button>` : `<button class="dp2-btn primary" type="button" data-action="next" ${errs.length ? "disabled" : ""}>Pr\xF3ximo \u2192</button>`}`;
|
|
83684
84414
|
}
|
|
83685
84415
|
jobTitle(e) {
|
|
@@ -83697,7 +84427,7 @@ var DemandPanelV2 = class {
|
|
|
83697
84427
|
return;
|
|
83698
84428
|
}
|
|
83699
84429
|
if (s.listState === "error") {
|
|
83700
|
-
this.el.body.innerHTML = `<div class="dp2-empty">N\xE3o foi poss\xEDvel carregar os relat\xF3rios (${
|
|
84430
|
+
this.el.body.innerHTML = `<div class="dp2-empty">N\xE3o foi poss\xEDvel carregar os relat\xF3rios (${esc5(s.listError)}).<br><button class="dp2-btn" type="button" data-action="reload">Tentar de novo</button></div>`;
|
|
83701
84431
|
return;
|
|
83702
84432
|
}
|
|
83703
84433
|
const orphans = this.p.supportMode ? s.active.filter((j) => !s.keys.includes(envelopeKey(j.jobId))) : [];
|
|
@@ -83715,43 +84445,43 @@ var DemandPanelV2 = class {
|
|
|
83715
84445
|
const note = (cls, text2) => `<div class="${cls}" style="margin-top:6px">${text2}</div>`;
|
|
83716
84446
|
const queue = st === "queued" && j?.queue?.position ? ` (N\xBA ${j.queue.position})` : "";
|
|
83717
84447
|
const peak = j?.totals?.largestDevicePeak;
|
|
83718
|
-
const peakTxt = peak && (peak.kw != null || peak.w != null) ? `Maior pico individual: <b>${
|
|
83719
|
-
return `<article class="dp2-job" aria-label="${
|
|
84448
|
+
const peakTxt = peak && (peak.kw != null || peak.w != null) ? `Maior pico individual: <b>${esc5(fmtN(Number(peak.kw ?? peak.w / 1e3)))} kW</b>${peak.label ? ` \xB7 ${esc5(peak.label)}` : ""}${peak.at ? ` \xB7 ${esc5(when(peak.at))}` : ""}` : "";
|
|
84449
|
+
return `<article class="dp2-job" aria-label="${esc5(this.jobTitle(e))}">
|
|
83720
84450
|
<div class="dp2-job-top">
|
|
83721
|
-
<span class="dp2-job-title">${
|
|
84451
|
+
<span class="dp2-job-title">${esc5(this.jobTitle(e))}</span>
|
|
83722
84452
|
<span class="dp2-status ${st}">${JOB_STATE_LABEL[st]}${queue}${st === "running" ? ` ${progress}%` : ""}</span>
|
|
83723
84453
|
<span style="flex:1"></span>
|
|
83724
|
-
<span class="dp2-info">${
|
|
84454
|
+
<span class="dp2-info">${esc5(e.requestedBy.name)} \xB7 ${when(e.requestedAt)}</span>
|
|
83725
84455
|
</div>
|
|
83726
84456
|
${st === "queued" || st === "running" ? `<div class="dp2-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${progress}"><span style="width:${progress}%"></span></div>` : ""}
|
|
83727
|
-
${st === "queued" && j?.queue?.estimatedStartAt ? note("dp2-info", `In\xEDcio estimado: ${
|
|
83728
|
-
${st === "failed" ? note("dp2-err", `${
|
|
83729
|
-
${st === "rejected" ? note("dp2-err", `${
|
|
84457
|
+
${st === "queued" && j?.queue?.estimatedStartAt ? note("dp2-info", `In\xEDcio estimado: ${esc5(when(j.queue.estimatedStartAt))}`) : ""}
|
|
84458
|
+
${st === "failed" ? note("dp2-err", `${esc5(failureText(j?.error?.code))}${this.p.supportMode && j?.error ? ` <small>(${esc5(j.error.code)}: ${esc5(j.error.message)})</small>` : ""}`) : ""}
|
|
84459
|
+
${st === "rejected" ? note("dp2-err", `${esc5(rejectionText(v.code, v.reason, v.message))}${this.p.supportMode ? ` <small>(${esc5(v.code)}${v.reason ? " \xB7 " + esc5(v.reason) : ""})</small>` : ""}`) : ""}
|
|
83730
84460
|
${st === "not_received" ? note("dp2-err", "O pedido est\xE1 registrado, mas o processamento n\xE3o o recebeu. Reenviar \xE9 seguro: n\xE3o gera relat\xF3rio duplicado.") : ""}
|
|
83731
84461
|
${st === "query_unavailable" ? note("dp2-info", "N\xE3o foi poss\xEDvel consultar o andamento agora \u2014 tentaremos de novo.") : ""}
|
|
83732
84462
|
${st === "old_request" ? note("dp2-info", 'Pedido antigo, sem registro de processamento. Use "Duplicar e editar".') : ""}
|
|
83733
84463
|
${st === "result_expired" ? note("dp2-info", "O relat\xF3rio foi conclu\xEDdo, mas os arquivos j\xE1 expiraram (ficam 3 dias).") : ""}
|
|
83734
84464
|
${st === "purged" ? note("dp2-info", "O conte\xFAdo deste relat\xF3rio foi removido.") : ""}
|
|
83735
|
-
${st === "succeeded" && j?.reused ? note("dp2-info", `\u267B Resultado reaproveitado${j.generatedAt ? ` \u2014 gerado em ${
|
|
84465
|
+
${st === "succeeded" && j?.reused ? note("dp2-info", `\u267B Resultado reaproveitado${j.generatedAt ? ` \u2014 gerado em ${esc5(when(j.generatedAt))}` : ""}${j.generatedBy?.userId ? ` por ${esc5(j.generatedBy.userId)}` : ""}.`) : ""}
|
|
83736
84466
|
${st === "succeeded" && peakTxt ? note("dp2-info", peakTxt) : ""}
|
|
83737
|
-
${st === "succeeded" && j?.expiresAt ? note("dp2-info", `Arquivos dispon\xEDveis at\xE9 ${
|
|
84467
|
+
${st === "succeeded" && j?.expiresAt ? note("dp2-info", `Arquivos dispon\xEDveis at\xE9 ${esc5(when(j.expiresAt))}.`) : ""}
|
|
83738
84468
|
${s.auditPending.has(e.jobId) ? '<div class="dp2-audit-warn">\u26A0 A a\xE7\xE3o foi aceita, mas o registro de auditoria falhou \u2014 ser\xE1 reconciliado.</div>' : ""}
|
|
83739
84469
|
<div class="dp2-job-actions">
|
|
83740
|
-
${st === "succeeded" ? `<button class="dp2-btn sm primary" type="button" data-action="download" data-kind="xlsx" data-job="${
|
|
83741
|
-
<button class="dp2-btn sm" type="button" data-action="download" data-kind="csv" data-job="${
|
|
83742
|
-
<button class="dp2-btn sm" type="button" data-action="download" data-kind="json" data-job="${
|
|
83743
|
-
${st === "queued" || st === "running" ? `<button class="dp2-btn sm" type="button" data-action="cancel" data-job="${
|
|
83744
|
-
${v.canResend ? `<button class="dp2-btn sm primary" type="button" data-action="resend" data-job="${
|
|
83745
|
-
${["failed", "cancelled", "succeeded", "result_expired", "purged", "old_request", "rejected"].includes(st) ? `<button class="dp2-btn sm" type="button" data-action="clone" data-job="${
|
|
83746
|
-
${this.p.supportMode ? `<button class="dp2-btn link" type="button" data-action="details" data-job="${
|
|
83747
|
-
</div>
|
|
83748
|
-
${this.p.supportMode && s.openDetails.has(e.jobId) ? `<pre class="dp2-json">${
|
|
84470
|
+
${st === "succeeded" ? `<button class="dp2-btn sm primary" type="button" data-action="download" data-kind="xlsx" data-job="${esc5(e.jobId)}">\u2B07 XLSX</button>
|
|
84471
|
+
<button class="dp2-btn sm" type="button" data-action="download" data-kind="csv" data-job="${esc5(e.jobId)}">CSV</button>
|
|
84472
|
+
<button class="dp2-btn sm" type="button" data-action="download" data-kind="json" data-job="${esc5(e.jobId)}">JSON</button>` : ""}
|
|
84473
|
+
${st === "queued" || st === "running" ? `<button class="dp2-btn sm" type="button" data-action="cancel" data-job="${esc5(e.jobId)}" ${busy}>\u2715 Cancelar</button>` : ""}
|
|
84474
|
+
${v.canResend ? `<button class="dp2-btn sm primary" type="button" data-action="resend" data-job="${esc5(e.jobId)}" ${busy}>\u21BB Reenviar</button>` : ""}
|
|
84475
|
+
${["failed", "cancelled", "succeeded", "result_expired", "purged", "old_request", "rejected"].includes(st) ? `<button class="dp2-btn sm" type="button" data-action="clone" data-job="${esc5(e.jobId)}">\u29C9 Duplicar e editar</button>` : ""}
|
|
84476
|
+
${this.p.supportMode ? `<button class="dp2-btn link" type="button" data-action="details" data-job="${esc5(e.jobId)}">${s.openDetails.has(e.jobId) ? "Ocultar" : "Detalhes /"} auditoria</button>` : ""}
|
|
84477
|
+
</div>
|
|
84478
|
+
${this.p.supportMode && s.openDetails.has(e.jobId) ? `<pre class="dp2-json">${esc5(JSON.stringify(e, null, 2))}</pre>` : ""}
|
|
83749
84479
|
</article>`;
|
|
83750
84480
|
}).join("");
|
|
83751
84481
|
const orphanCards = orphans.map((j) => `<article class="dp2-job ghost"><div class="dp2-job-top">
|
|
83752
|
-
<span class="dp2-job-title">Job sem registro no ThingsBoard (O-6)</span><span class="dp2-status ${j.status}">${
|
|
83753
|
-
<span style="flex:1"></span><span class="dp2-info">${
|
|
83754
|
-
<div class="dp2-info" style="margin-top:4px"><code>${
|
|
84482
|
+
<span class="dp2-job-title">Job sem registro no ThingsBoard (O-6)</span><span class="dp2-status ${j.status}">${esc5(JOB_STATE_LABEL[j.status] ?? j.status)}</span>
|
|
84483
|
+
<span style="flex:1"></span><span class="dp2-info">${esc5(j.requestedBy?.userId ?? "")} \xB7 ${when(j.createdAt)}</span></div>
|
|
84484
|
+
<div class="dp2-info" style="margin-top:4px"><code>${esc5(j.jobId)}</code></div></article>`).join("");
|
|
83755
84485
|
this.el.body.innerHTML = cards + orphanCards;
|
|
83756
84486
|
}
|
|
83757
84487
|
/* ------------------------------------------------------------------ data flows */
|
|
@@ -84598,6 +85328,7 @@ var groupReportHandler = {
|
|
|
84598
85328
|
} : {};
|
|
84599
85329
|
const theme = visual.palette ?? base.theme;
|
|
84600
85330
|
const customerName = visual.customerName || base.customerName;
|
|
85331
|
+
const money = context.getReportMoney?.(d) || null;
|
|
84601
85332
|
return () => {
|
|
84602
85333
|
openDashboardPopupAllReport({
|
|
84603
85334
|
...base,
|
|
@@ -84606,7 +85337,8 @@ var groupReportHandler = {
|
|
|
84606
85337
|
group: item.id,
|
|
84607
85338
|
itemsList,
|
|
84608
85339
|
...theme ? { theme } : {},
|
|
84609
|
-
...customerName ? { customerName } : {}
|
|
85340
|
+
...customerName ? { customerName } : {},
|
|
85341
|
+
...money ? { money } : {}
|
|
84610
85342
|
});
|
|
84611
85343
|
};
|
|
84612
85344
|
}
|
|
@@ -85141,11 +85873,21 @@ function createDashboardReportsHubContext(opts) {
|
|
|
85141
85873
|
})
|
|
85142
85874
|
};
|
|
85143
85875
|
};
|
|
85876
|
+
const getReportMoney = (domain) => {
|
|
85877
|
+
if (domain === "temperature" || typeof orch.getReportMoney !== "function") return null;
|
|
85878
|
+
try {
|
|
85879
|
+
return orch.getReportMoney(domain) || null;
|
|
85880
|
+
} catch (err) {
|
|
85881
|
+
log.warn("getReportMoney failed:", err?.message || err);
|
|
85882
|
+
return null;
|
|
85883
|
+
}
|
|
85884
|
+
};
|
|
85144
85885
|
return {
|
|
85145
85886
|
domains,
|
|
85146
85887
|
getGroups,
|
|
85147
85888
|
ensureDomainLoaded,
|
|
85148
85889
|
getAllReportBase,
|
|
85890
|
+
getReportMoney,
|
|
85149
85891
|
...validRange || idealRange ? { temperature: { ...validRange ? { validRange } : {}, ...idealRange ? { idealRange } : {} } } : {},
|
|
85150
85892
|
...demandPossible ? { getDemandPanelParams } : {}
|
|
85151
85893
|
};
|
|
@@ -85184,7 +85926,7 @@ var GOAL_DOMAIN_CONFIG = {
|
|
|
85184
85926
|
};
|
|
85185
85927
|
var MONTH_KEYS = Array.from({ length: 12 }, (_, i) => String(i + 1).padStart(2, "0"));
|
|
85186
85928
|
var HOUR_KEYS = Array.from({ length: 24 }, (_, i) => String(i).padStart(2, "0"));
|
|
85187
|
-
var
|
|
85929
|
+
var pad22 = (n) => String(n).padStart(2, "0");
|
|
85188
85930
|
function daysInMonth(year, month) {
|
|
85189
85931
|
if (month === 2) {
|
|
85190
85932
|
const leap = year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
@@ -85198,7 +85940,7 @@ function buildYearOptions() {
|
|
|
85198
85940
|
for (let y = now + 2; y >= now - 2; y--) out.push(y);
|
|
85199
85941
|
return out;
|
|
85200
85942
|
}
|
|
85201
|
-
function
|
|
85943
|
+
function esc6(s) {
|
|
85202
85944
|
return String(s == null ? "" : s).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
85203
85945
|
}
|
|
85204
85946
|
function resolveThemeVars(theme) {
|
|
@@ -85392,7 +86134,7 @@ function openGoalsPanel(params) {
|
|
|
85392
86134
|
function dailyFromTree(tree, monthKey, dayCount) {
|
|
85393
86135
|
const out = {};
|
|
85394
86136
|
for (let d = 1; d <= dayCount; d++) {
|
|
85395
|
-
const dd =
|
|
86137
|
+
const dd = pad22(d);
|
|
85396
86138
|
const node = tree && tree.daily && tree.daily[`${monthKey}-${dd}`];
|
|
85397
86139
|
out[dd] = node && typeof node.value === "number" ? String(node.value) : "";
|
|
85398
86140
|
}
|
|
@@ -85442,7 +86184,7 @@ function openGoalsPanel(params) {
|
|
|
85442
86184
|
if (state6.level === "month") return MONTH_KEYS;
|
|
85443
86185
|
if (state6.level === "day") {
|
|
85444
86186
|
const c = state6.selectedMonth ? daysInMonth(state6.year, Number(state6.selectedMonth)) : 0;
|
|
85445
|
-
return Array.from({ length: c }, (_, i) =>
|
|
86187
|
+
return Array.from({ length: c }, (_, i) => pad22(i + 1));
|
|
85446
86188
|
}
|
|
85447
86189
|
return HOUR_KEYS;
|
|
85448
86190
|
}
|
|
@@ -85668,7 +86410,7 @@ function openGoalsPanel(params) {
|
|
|
85668
86410
|
const dayValue = avg ? 22 : 3200;
|
|
85669
86411
|
const hourValue = avg ? 22 : 150;
|
|
85670
86412
|
const lines = ["bucket,value"];
|
|
85671
|
-
for (let m = 1; m <= 12; m++) lines.push(`${state6.year}-${
|
|
86413
|
+
for (let m = 1; m <= 12; m++) lines.push(`${state6.year}-${pad22(m)},${monthlyValue}`);
|
|
85672
86414
|
lines.push(`${state6.year}-03-15,${dayValue}`);
|
|
85673
86415
|
lines.push(`${state6.year}-03-15T08,${hourValue}`);
|
|
85674
86416
|
return lines.join("\n");
|
|
@@ -85677,7 +86419,7 @@ function openGoalsPanel(params) {
|
|
|
85677
86419
|
const value = sampleHourValue();
|
|
85678
86420
|
const day = `${state6.year}-03-15`;
|
|
85679
86421
|
const lines = ["bucket,value"];
|
|
85680
|
-
for (let h3 = 0; h3 < 24; h3++) lines.push(`${day}T${
|
|
86422
|
+
for (let h3 = 0; h3 < 24; h3++) lines.push(`${day}T${pad22(h3)},${value}`);
|
|
85681
86423
|
return lines.join("\n");
|
|
85682
86424
|
}
|
|
85683
86425
|
function downloadCsv(csv, suffix) {
|
|
@@ -86014,13 +86756,13 @@ function openGoalsPanel(params) {
|
|
|
86014
86756
|
const g = state6.goals || {};
|
|
86015
86757
|
const parts = [];
|
|
86016
86758
|
if (hasCoverageGaps(g.coverageGaps)) {
|
|
86017
|
-
parts.push(`<p style="margin:0 0 8px;">${
|
|
86759
|
+
parts.push(`<p style="margin:0 0 8px;">${esc6(buildCoverageWarningTextPtBR(g.coverageGaps, "GERAL"))}</p>`);
|
|
86018
86760
|
}
|
|
86019
86761
|
(Array.isArray(g.devices) ? g.devices : []).forEach((d) => {
|
|
86020
86762
|
if (!hasCoverageGaps(d && d.coverageGaps)) return;
|
|
86021
86763
|
const label = d.label || d.code || "medidor";
|
|
86022
86764
|
parts.push(
|
|
86023
|
-
`<p style="margin:0 0 8px;">${
|
|
86765
|
+
`<p style="margin:0 0 8px;">${esc6(buildCoverageWarningTextPtBR(d.coverageGaps, `do medidor ${label}`))}</p>`
|
|
86024
86766
|
);
|
|
86025
86767
|
});
|
|
86026
86768
|
return `<div style="font-size:12px;line-height:1.55;color:#334155;">${parts.join("")}</div>`;
|
|
@@ -86060,7 +86802,7 @@ function openGoalsPanel(params) {
|
|
|
86060
86802
|
html += `<div class="myio-goals-alert myio-goals-alert-amber">${icon2("alert")} ${i18n2.versionConflict}</div>`;
|
|
86061
86803
|
}
|
|
86062
86804
|
if (state6.saveError && !state6.conflict) {
|
|
86063
|
-
html += `<div class="myio-goals-alert myio-goals-alert-red">${icon2("alert")} ${
|
|
86805
|
+
html += `<div class="myio-goals-alert myio-goals-alert-red">${icon2("alert")} ${esc6(state6.saveError)}</div>`;
|
|
86064
86806
|
}
|
|
86065
86807
|
if (state6.saved && !state6.saveError) {
|
|
86066
86808
|
html += `<div class="myio-goals-alert myio-goals-alert-green">${icon2("check")} ${i18n2.saveSuccess}</div>`;
|
|
@@ -86075,7 +86817,7 @@ function openGoalsPanel(params) {
|
|
|
86075
86817
|
return `
|
|
86076
86818
|
<div class="myio-goals-center myio-goals-center-col">
|
|
86077
86819
|
${icon2("alert-lg")}
|
|
86078
|
-
<p>${
|
|
86820
|
+
<p>${esc6(state6.error)}</p>
|
|
86079
86821
|
<button class="myio-goals-btn myio-goals-btn-outline" data-action="retry">${i18n2.retry}</button>
|
|
86080
86822
|
</div>`;
|
|
86081
86823
|
}
|
|
@@ -86165,7 +86907,7 @@ function openGoalsPanel(params) {
|
|
|
86165
86907
|
const cellLabel = state6.level === "month" ? i18n2.months[key] : state6.level === "day" ? i18n2.dayCell.replace("{day}", Number(key)) : `${key}:00`;
|
|
86166
86908
|
const canDrill = state6.level !== "hour";
|
|
86167
86909
|
const labelEl = canDrill ? `<button class="myio-goals-cell-drill" data-action="${state6.level === "month" ? "open-month" : "open-day"}" data-key="${key}" title="${i18n2.drill.openTitle}">${cellLabel} ${icon2("chevron-sm")}</button>` : `<span class="myio-goals-cell-label">${cellLabel}</span>`;
|
|
86168
|
-
const val = state6.draft[key] !== void 0 ?
|
|
86910
|
+
const val = state6.draft[key] !== void 0 ? esc6(state6.draft[key]) : "";
|
|
86169
86911
|
const minAttr = cfg.allowsNegative ? "" : 'min="0"';
|
|
86170
86912
|
return `
|
|
86171
86913
|
<div class="myio-goals-cell">
|
|
@@ -86233,7 +86975,7 @@ function openGoalsPanel(params) {
|
|
|
86233
86975
|
const actor = ev.actor ? `${String(ev.actor).slice(0, 8)}\u2026` : i18n2.history.system;
|
|
86234
86976
|
const extra = ev.bucketCount - (ev.details ? ev.details.length : 0);
|
|
86235
86977
|
const chips = (ev.details || []).slice(0, DETAIL_PREVIEW).map(
|
|
86236
|
-
(d) => `<span class="myio-goals-tl-chip"><span class="myio-goals-tl-ref">${
|
|
86978
|
+
(d) => `<span class="myio-goals-tl-chip"><span class="myio-goals-tl-ref">${esc6(formatRef(d.ref))}</span>${d.value === null ? "\u2014" : fmt2(d.value)}</span>`
|
|
86237
86979
|
).join("");
|
|
86238
86980
|
const more = extra > 0 ? `<span class="myio-goals-tl-more">${i18n2.history.moreDetails.replace("{n}", extra)}</span>` : "";
|
|
86239
86981
|
return `
|
|
@@ -86243,7 +86985,7 @@ function openGoalsPanel(params) {
|
|
|
86243
86985
|
<span class="myio-goals-tl-title">${i18n2.history.source[ev.source] || i18n2.history.source.EDIT}</span>
|
|
86244
86986
|
<span class="myio-goals-tl-ver">v${ev.version}</span>
|
|
86245
86987
|
</div>
|
|
86246
|
-
<p class="myio-goals-tl-meta" title="${
|
|
86988
|
+
<p class="myio-goals-tl-meta" title="${esc6(new Date(ev.changedAt).toLocaleString(locale))}">${esc6(actor)} \xB7 ${esc6(timeAgo(ev.changedAt))}</p>
|
|
86247
86989
|
<p class="myio-goals-tl-records">${i18n2.history.records.replace("{n}", ev.bucketCount)} \xB7 ${i18n2.levels[ev.actionLevel] || ev.actionLevel}</p>
|
|
86248
86990
|
${chips || more ? `<div class="myio-goals-tl-chips">${chips}${more}</div>` : ""}
|
|
86249
86991
|
</li>`;
|
|
@@ -86290,7 +87032,7 @@ ${state6.year}-03-15T08,15`;
|
|
|
86290
87032
|
let html = `
|
|
86291
87033
|
<div class="myio-goals-import-hint">
|
|
86292
87034
|
<p>${i18n2.import.formatHint}</p>
|
|
86293
|
-
<code>${
|
|
87035
|
+
<code>${esc6(sample)}</code>
|
|
86294
87036
|
</div>`;
|
|
86295
87037
|
if (!applied) {
|
|
86296
87038
|
html += `
|
|
@@ -86304,16 +87046,16 @@ ${state6.year}-03-15T08,15`;
|
|
|
86304
87046
|
<input type="file" id="myio-goals-csv-file" accept=".csv,.txt,text/csv,text/plain" style="display:none" />
|
|
86305
87047
|
</div>
|
|
86306
87048
|
</div>
|
|
86307
|
-
<textarea id="myio-goals-csv-textarea" rows="8" spellcheck="false" placeholder="${
|
|
87049
|
+
<textarea id="myio-goals-csv-textarea" rows="8" spellcheck="false" placeholder="${esc6(`bucket,value
|
|
86308
87050
|
${state6.year},100000
|
|
86309
87051
|
${state6.year}-03,9000
|
|
86310
87052
|
${state6.year}-03-15,310
|
|
86311
|
-
${state6.year}-03-15T08,15`)}">${
|
|
87053
|
+
${state6.year}-03-15T08,15`)}">${esc6(state6.csv)}</textarea>
|
|
86312
87054
|
<p class="myio-goals-microhint">${i18n2.import.unitNote.replace("{unit}", unitLabel2())}</p>
|
|
86313
87055
|
</div>`;
|
|
86314
87056
|
}
|
|
86315
87057
|
if (state6.saveError && state6.conflictVersion === null) {
|
|
86316
|
-
html += `<div class="myio-goals-alert myio-goals-alert-red">${icon2("alert")} ${
|
|
87058
|
+
html += `<div class="myio-goals-alert myio-goals-alert-red">${icon2("alert")} ${esc6(state6.saveError)}</div>`;
|
|
86317
87059
|
}
|
|
86318
87060
|
if (state6.conflictVersion !== null) {
|
|
86319
87061
|
html += `<div class="myio-goals-alert myio-goals-alert-amber">${icon2("alert")} ${i18n2.import.conflict}</div>`;
|
|
@@ -86342,7 +87084,7 @@ ${state6.year}-03-15T08,15`)}">${esc5(state6.csv)}</textarea>
|
|
|
86342
87084
|
<div class="myio-goals-import-diags">
|
|
86343
87085
|
<p class="myio-goals-import-diags-title">${i18n2.import.diagnosticsTitle}</p>
|
|
86344
87086
|
<ul>${result.diagnostics.map(
|
|
86345
|
-
(d) => `<li>${icon2("alert-sm")} <span><span class="myio-goals-diag-line">${i18n2.import.line.replace("{line}", d.line)}</span>${d.bucket ? ` <span class="myio-goals-diag-bucket">[${
|
|
87087
|
+
(d) => `<li>${icon2("alert-sm")} <span><span class="myio-goals-diag-line">${i18n2.import.line.replace("{line}", d.line)}</span>${d.bucket ? ` <span class="myio-goals-diag-bucket">[${esc6(d.bucket)}]</span>` : ""} ${esc6(d.reason)}</span></li>`
|
|
86346
87088
|
).join("")}</ul>
|
|
86347
87089
|
</div>`;
|
|
86348
87090
|
}
|
|
@@ -86350,7 +87092,7 @@ ${state6.year}-03-15T08,15`)}">${esc5(state6.csv)}</textarea>
|
|
|
86350
87092
|
html += `
|
|
86351
87093
|
<div class="myio-goals-import-log">
|
|
86352
87094
|
<p class="myio-goals-import-log-title">${i18n2.import.logTitle}</p>
|
|
86353
|
-
<ul>${result.log.map((line) => `<li>${
|
|
87095
|
+
<ul>${result.log.map((line) => `<li>${esc6(line)}</li>`).join("")}</ul>
|
|
86354
87096
|
</div>`;
|
|
86355
87097
|
}
|
|
86356
87098
|
html += `</div>`;
|
|
@@ -93388,7 +94130,7 @@ function injectCSS10() {
|
|
|
93388
94130
|
document.head.appendChild(style);
|
|
93389
94131
|
_cssInjected2 = true;
|
|
93390
94132
|
}
|
|
93391
|
-
function
|
|
94133
|
+
function esc7(value) {
|
|
93392
94134
|
return String(value == null ? "" : value).replace(
|
|
93393
94135
|
/[&<>"]/g,
|
|
93394
94136
|
(c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]
|
|
@@ -93438,7 +94180,7 @@ function buildPieSvg(visible, total) {
|
|
|
93438
94180
|
const val = Number(v.d.value) || 0;
|
|
93439
94181
|
return `<svg class="myio-col-summary__pie" viewBox="0 0 220 220">
|
|
93440
94182
|
<circle class="myio-col-summary__slice" data-idx="${v.idx}" cx="110" cy="110" r="100"
|
|
93441
|
-
fill="${sliceColor(v.idx)}"><title>${
|
|
94183
|
+
fill="${sliceColor(v.idx)}"><title>${esc7(v.d.name)} \u2014 ${esc7(fmt2(val))} (${fmtPct2(
|
|
93442
94184
|
val,
|
|
93443
94185
|
total,
|
|
93444
94186
|
pd
|
|
@@ -93453,7 +94195,7 @@ function buildPieSvg(visible, total) {
|
|
|
93453
94195
|
const a1 = acc / total * 360;
|
|
93454
94196
|
return `<path class="myio-col-summary__slice" data-idx="${v.idx}"
|
|
93455
94197
|
d="${arcPath(110, 110, 100, a0, a1)}" fill="${sliceColor(v.idx)}"
|
|
93456
|
-
><title>${
|
|
94198
|
+
><title>${esc7(v.d.name)} \u2014 ${esc7(fmt2(val))} (${fmtPct2(val, total, pd)})</title></path>`;
|
|
93457
94199
|
}).join("");
|
|
93458
94200
|
return `<svg class="myio-col-summary__pie" viewBox="0 0 220 220">${paths}</svg>`;
|
|
93459
94201
|
}
|
|
@@ -93467,8 +94209,8 @@ function buildLegend(total) {
|
|
|
93467
94209
|
return `<div class="myio-col-summary__legend-row${isExcl ? " is-excluded" : ""}" data-idx="${idx}"
|
|
93468
94210
|
title="Clique para ${isExcl ? "incluir" : "remover"} da pizza">
|
|
93469
94211
|
<span class="myio-col-summary__legend-dot" style="background:${sliceColor(idx)};"></span>
|
|
93470
|
-
<span class="myio-col-summary__legend-name">${
|
|
93471
|
-
<span class="myio-col-summary__legend-val">${
|
|
94212
|
+
<span class="myio-col-summary__legend-name">${esc7(d.name)}</span>
|
|
94213
|
+
<span class="myio-col-summary__legend-val">${esc7(fmt2(val))}</span>
|
|
93472
94214
|
<span class="myio-col-summary__legend-pct">${pct}</span>
|
|
93473
94215
|
</div>`;
|
|
93474
94216
|
}).join("");
|
|
@@ -93489,25 +94231,25 @@ function buildAverageInner() {
|
|
|
93489
94231
|
const dash = "\u2014";
|
|
93490
94232
|
const periodRow = data.periodLabel ? `<div class="myio-col-summary__kpi">
|
|
93491
94233
|
<span class="myio-col-summary__kpi-label">Per\xEDodo</span>
|
|
93492
|
-
<span class="myio-col-summary__kpi-value">${
|
|
94234
|
+
<span class="myio-col-summary__kpi-value">${esc7(data.periodLabel)}</span>
|
|
93493
94235
|
</div>` : "";
|
|
93494
94236
|
const note = "M\xE9dia, m\xEDnima e m\xE1xima consideram apenas dispositivos online (com leitura).";
|
|
93495
94237
|
const kpis = `<div class="myio-col-summary__kpis">
|
|
93496
94238
|
${periodRow}
|
|
93497
94239
|
<div class="myio-col-summary__kpi">
|
|
93498
94240
|
<span class="myio-col-summary__kpi-label">Dispositivos
|
|
93499
|
-
<span class="myio-col-summary__info" title="${
|
|
94241
|
+
<span class="myio-col-summary__info" title="${esc7(note)}" aria-label="${esc7(note)}"
|
|
93500
94242
|
style="display:inline-flex;align-items:center;justify-content:center;width:13px;height:13px;margin-left:4px;border-radius:50%;background:#3e1a7d;color:#fff;font-size:9px;font-weight:700;font-style:italic;font-family:Georgia,serif;cursor:help;vertical-align:middle;">i</span>
|
|
93501
94243
|
</span>
|
|
93502
94244
|
<span class="myio-col-summary__kpi-value">${online.length} online \xB7 ${offline.length} offline</span>
|
|
93503
94245
|
</div>
|
|
93504
94246
|
<div class="myio-col-summary__kpi">
|
|
93505
|
-
<span class="myio-col-summary__kpi-label">${
|
|
93506
|
-
<span class="myio-col-summary__kpi-value myio-col-summary__kpi-value--accent">${avg === null ? dash :
|
|
94247
|
+
<span class="myio-col-summary__kpi-label">${esc7(measure)} m\xE9dia</span>
|
|
94248
|
+
<span class="myio-col-summary__kpi-value myio-col-summary__kpi-value--accent">${avg === null ? dash : esc7(fmt2(avg))}</span>
|
|
93507
94249
|
</div>
|
|
93508
94250
|
<div class="myio-col-summary__kpi">
|
|
93509
94251
|
<span class="myio-col-summary__kpi-label">M\xEDnima \xB7 M\xE1xima</span>
|
|
93510
|
-
<span class="myio-col-summary__kpi-value">${minV ?
|
|
94252
|
+
<span class="myio-col-summary__kpi-value">${minV ? esc7(fmt2(Number(minV.d.value))) : dash} \xB7 ${maxV ? esc7(fmt2(Number(maxV.d.value))) : dash}</span>
|
|
93511
94253
|
</div>
|
|
93512
94254
|
</div>`;
|
|
93513
94255
|
if (!data.devices.length) {
|
|
@@ -93516,12 +94258,12 @@ function buildAverageInner() {
|
|
|
93516
94258
|
const near3 = avg === null ? [] : online.slice().sort((a, b) => Math.abs(Number(a.d.value) - avg) - Math.abs(Number(b.d.value) - avg)).slice(0, 3);
|
|
93517
94259
|
const row = (v) => `
|
|
93518
94260
|
<div class="myio-col-summary__row">
|
|
93519
|
-
<span class="myio-col-summary__name" title="${
|
|
93520
|
-
<span class="myio-col-summary__val">${
|
|
94261
|
+
<span class="myio-col-summary__name" title="${esc7(v.d.name)}">${esc7(v.d.name)}</span>
|
|
94262
|
+
<span class="myio-col-summary__val">${esc7(fmt2(Number(v.d.value) || 0))}</span>
|
|
93521
94263
|
</div>`;
|
|
93522
94264
|
const offRow = (v) => `
|
|
93523
94265
|
<div class="myio-col-summary__row">
|
|
93524
|
-
<span class="myio-col-summary__name" title="${
|
|
94266
|
+
<span class="myio-col-summary__name" title="${esc7(v.d.name)}">${esc7(v.d.name)}</span>
|
|
93525
94267
|
<span class="myio-col-summary__val" style="color:#94a3b8;">sem leitura</span>
|
|
93526
94268
|
</div>`;
|
|
93527
94269
|
const group = (label, list, r = row) => list.length ? `<div class="myio-col-summary__group">
|
|
@@ -93538,8 +94280,8 @@ function buildAverageInner() {
|
|
|
93538
94280
|
</div>
|
|
93539
94281
|
</div>
|
|
93540
94282
|
<div class="myio-col-summary__footer">
|
|
93541
|
-
<span class="myio-col-summary__footer-label">${
|
|
93542
|
-
<span class="myio-col-summary__footer-value">${avg === null ? dash :
|
|
94283
|
+
<span class="myio-col-summary__footer-label">${esc7(measure)} m\xE9dia \xB7 ${online.length} online</span>
|
|
94284
|
+
<span class="myio-col-summary__footer-value">${avg === null ? dash : esc7(fmt2(avg))}</span>
|
|
93543
94285
|
</div>`;
|
|
93544
94286
|
}
|
|
93545
94287
|
function buildInner() {
|
|
@@ -93552,7 +94294,7 @@ function buildInner() {
|
|
|
93552
94294
|
const avg = count ? total / count : 0;
|
|
93553
94295
|
const periodRow = data.periodLabel ? `<div class="myio-col-summary__kpi">
|
|
93554
94296
|
<span class="myio-col-summary__kpi-label">Per\xEDodo</span>
|
|
93555
|
-
<span class="myio-col-summary__kpi-value">${
|
|
94297
|
+
<span class="myio-col-summary__kpi-value">${esc7(data.periodLabel)}</span>
|
|
93556
94298
|
</div>` : "";
|
|
93557
94299
|
const kpis = `<div class="myio-col-summary__kpis">
|
|
93558
94300
|
${periodRow}
|
|
@@ -93562,13 +94304,13 @@ function buildInner() {
|
|
|
93562
94304
|
</div>
|
|
93563
94305
|
<div class="myio-col-summary__kpi">
|
|
93564
94306
|
<span class="myio-col-summary__kpi-label">Consumo m\xE9dio</span>
|
|
93565
|
-
<span class="myio-col-summary__kpi-value myio-col-summary__kpi-value--accent">${
|
|
94307
|
+
<span class="myio-col-summary__kpi-value myio-col-summary__kpi-value--accent">${esc7(
|
|
93566
94308
|
fmt2(avg)
|
|
93567
94309
|
)}</span>
|
|
93568
94310
|
</div>
|
|
93569
94311
|
<div class="myio-col-summary__kpi">
|
|
93570
94312
|
<span class="myio-col-summary__kpi-label">Consumo total</span>
|
|
93571
|
-
<span class="myio-col-summary__kpi-value">${
|
|
94313
|
+
<span class="myio-col-summary__kpi-value">${esc7(fmt2(total))}</span>
|
|
93572
94314
|
</div>
|
|
93573
94315
|
</div>`;
|
|
93574
94316
|
if (!data.devices.length) {
|
|
@@ -93582,8 +94324,8 @@ function buildInner() {
|
|
|
93582
94324
|
).slice(0, 3);
|
|
93583
94325
|
const row = (v) => `
|
|
93584
94326
|
<div class="myio-col-summary__row">
|
|
93585
|
-
<span class="myio-col-summary__name" title="${
|
|
93586
|
-
<span class="myio-col-summary__val">${
|
|
94327
|
+
<span class="myio-col-summary__name" title="${esc7(v.d.name)}">${esc7(v.d.name)}</span>
|
|
94328
|
+
<span class="myio-col-summary__val">${esc7(fmt2(Number(v.d.value) || 0))}</span>
|
|
93587
94329
|
<span class="myio-col-summary__pct">${fmtPct2(Number(v.d.value) || 0, total, pd)}</span>
|
|
93588
94330
|
</div>`;
|
|
93589
94331
|
const group = (label, list) => list.length ? `<div class="myio-col-summary__group">
|
|
@@ -93606,7 +94348,7 @@ function buildInner() {
|
|
|
93606
94348
|
</div>
|
|
93607
94349
|
<div class="myio-col-summary__footer">
|
|
93608
94350
|
<span class="myio-col-summary__footer-label">Consumo Total \xB7 ${count} dispositivos</span>
|
|
93609
|
-
<span class="myio-col-summary__footer-value">${
|
|
94351
|
+
<span class="myio-col-summary__footer-value">${esc7(fmt2(total))}</span>
|
|
93610
94352
|
</div>`;
|
|
93611
94353
|
}
|
|
93612
94354
|
function setHighlight(idx) {
|
|
@@ -101386,7 +102128,7 @@ function injectStyles12(doc) {
|
|
|
101386
102128
|
`;
|
|
101387
102129
|
(doc.head || doc.documentElement).appendChild(s);
|
|
101388
102130
|
}
|
|
101389
|
-
function
|
|
102131
|
+
function esc8(v) {
|
|
101390
102132
|
return String(v ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
101391
102133
|
}
|
|
101392
102134
|
function fmtPct3(pct) {
|
|
@@ -101407,8 +102149,8 @@ function renderDeltaChip(delta) {
|
|
|
101407
102149
|
const tone = delta.tone === "good" ? "good" : delta.tone === "bad" ? "bad" : "neutral";
|
|
101408
102150
|
const arrow = delta.arrow === "up" ? "\u2191" : delta.arrow === "down" ? "\u2193" : "\u2248";
|
|
101409
102151
|
const pctTxt = fmtPct3(Math.abs(Number(delta.pct)));
|
|
101410
|
-
const txt = delta.text ? ` ${
|
|
101411
|
-
return `<span class="myio-gbt__chip myio-gbt__chip--${tone}">${arrow} ${
|
|
102152
|
+
const txt = delta.text ? ` ${esc8(delta.text)}` : "";
|
|
102153
|
+
return `<span class="myio-gbt__chip myio-gbt__chip--${tone}">${arrow} ${esc8(pctTxt)}${txt}</span>`;
|
|
101412
102154
|
}
|
|
101413
102155
|
function renderRow(row, level) {
|
|
101414
102156
|
const hasChildren = Array.isArray(row.children) && row.children.length > 0;
|
|
@@ -101416,12 +102158,12 @@ function renderRow(row, level) {
|
|
|
101416
102158
|
const id = `gbtr-${++_rowSeq}`;
|
|
101417
102159
|
const pct = row.pct;
|
|
101418
102160
|
const caret = hasChildren ? `<button class="myio-gbt__caret${open ? " is-open" : ""}" data-caret="${id}" title="Expandir/recolher">\u25B8</button>` : `<span class="myio-gbt__caret-spacer"></span>`;
|
|
101419
|
-
const swatch = row.color ? `<span class="myio-gbt__swatch" style="background:${
|
|
101420
|
-
const icon2 = row.icon ? `<span class="myio-gbt__icon">${
|
|
102161
|
+
const swatch = row.color ? `<span class="myio-gbt__swatch" style="background:${esc8(row.color)}"></span>` : "";
|
|
102162
|
+
const icon2 = row.icon ? `<span class="myio-gbt__icon">${esc8(row.icon)}</span>` : "";
|
|
101421
102163
|
const chipHtml = row.delta ? renderDeltaChip(row.delta) : "";
|
|
101422
|
-
const pctHtml = !row.delta && pct != null && isFinite(pct) ? `<span class="myio-gbt__pct">${
|
|
102164
|
+
const pctHtml = !row.delta && pct != null && isFinite(pct) ? `<span class="myio-gbt__pct">${esc8(fmtPct3(pct))}</span>` : "";
|
|
101423
102165
|
const rowClass = level > 0 ? "myio-gbt__row myio-gbt__row--child" : "myio-gbt__row";
|
|
101424
|
-
let html = `<div class="${rowClass}">` + caret + swatch + icon2 + `<span class="myio-gbt__label">${
|
|
102166
|
+
let html = `<div class="${rowClass}">` + caret + swatch + icon2 + `<span class="myio-gbt__label">${esc8(row.label)}</span><span class="myio-gbt__value">${esc8(row.valueText)}</span>` + chipHtml + pctHtml + `</div>`;
|
|
101425
102167
|
if (hasChildren) {
|
|
101426
102168
|
const childHtml = row.children.map((c) => renderRow(c, level + 1)).join("");
|
|
101427
102169
|
html += `<div class="myio-gbt__children${open ? " is-open" : ""}" data-children="${id}">${childHtml}</div>`;
|
|
@@ -101504,8 +102246,8 @@ function createGoalsBarTooltip(opts) {
|
|
|
101504
102246
|
<div class="myio-gbt__card">
|
|
101505
102247
|
<div class="myio-gbt__header">
|
|
101506
102248
|
<div class="myio-gbt__title-wrap">
|
|
101507
|
-
<div class="myio-gbt__title">${
|
|
101508
|
-
${data.subtitle ? `<div class="myio-gbt__subtitle">${
|
|
102249
|
+
<div class="myio-gbt__title">${esc8(data.title)}</div>
|
|
102250
|
+
${data.subtitle ? `<div class="myio-gbt__subtitle">${esc8(data.subtitle)}</div>` : ""}
|
|
101509
102251
|
</div>
|
|
101510
102252
|
<button class="myio-gbt__btn myio-gbt__btn--pin${pinned ? " is-pinned" : ""}" data-action="pin" title="${pinned ? "Desafixar" : "Fixar na tela"}">\u{1F4CC}</button>
|
|
101511
102253
|
<button class="myio-gbt__btn myio-gbt__btn--close" data-action="close" title="Fechar">\u2715</button>
|
|
@@ -102514,19 +103256,19 @@ function _updateCoverageHint(topDoc) {
|
|
|
102514
103256
|
const deviceCount = data.granularity === "DEVICE" ? data.devices?.length ?? 0 : 0;
|
|
102515
103257
|
hint.textContent = `\u26A0 Meta incompleta para este dom\xEDnio/ano` + (deviceCount > 0 ? ` \xB7 Por medidor (${deviceCount})` : "") + ` \u2014 passe o mouse para detalhes`;
|
|
102516
103258
|
tabs.insertAdjacentElement("afterend", hint);
|
|
102517
|
-
const
|
|
103259
|
+
const esc11 = (s) => String(s ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
102518
103260
|
try {
|
|
102519
103261
|
_coverageDetach = InfoTooltip.attach(hint, () => {
|
|
102520
103262
|
const d = _getGoalsData(_currentDomain);
|
|
102521
103263
|
const parts = [];
|
|
102522
103264
|
if (hasCoverageGaps(d?.coverageGaps)) {
|
|
102523
|
-
parts.push(`<p style="margin:0 0 8px;">${
|
|
103265
|
+
parts.push(`<p style="margin:0 0 8px;">${esc11(buildCoverageWarningTextPtBR(d?.coverageGaps, "GERAL"))}</p>`);
|
|
102524
103266
|
}
|
|
102525
103267
|
(d?.devices || []).forEach((dev) => {
|
|
102526
103268
|
if (!hasCoverageGaps(dev?.coverageGaps)) return;
|
|
102527
103269
|
const label = dev.label || dev.code || "medidor";
|
|
102528
103270
|
parts.push(
|
|
102529
|
-
`<p style="margin:0 0 8px;">${
|
|
103271
|
+
`<p style="margin:0 0 8px;">${esc11(buildCoverageWarningTextPtBR(dev.coverageGaps, `do medidor ${label}`))}</p>`
|
|
102530
103272
|
);
|
|
102531
103273
|
});
|
|
102532
103274
|
return {
|
|
@@ -105680,7 +106422,7 @@ function parseBRL(raw) {
|
|
|
105680
106422
|
const n = Number(s);
|
|
105681
106423
|
return Number.isFinite(n) ? n : NaN;
|
|
105682
106424
|
}
|
|
105683
|
-
function
|
|
106425
|
+
function pad23(n) {
|
|
105684
106426
|
return String(n).padStart(2, "0");
|
|
105685
106427
|
}
|
|
105686
106428
|
function daysInMonth2(periodKey2) {
|
|
@@ -105691,7 +106433,7 @@ function entryBounds(entry) {
|
|
|
105691
106433
|
if (entry.periodType === "month") {
|
|
105692
106434
|
if (!entry.periodKey || !/^\d{4}-\d{2}$/.test(entry.periodKey)) return null;
|
|
105693
106435
|
const last = daysInMonth2(entry.periodKey);
|
|
105694
|
-
return { start: `${entry.periodKey}-01`, end: `${entry.periodKey}-${
|
|
106436
|
+
return { start: `${entry.periodKey}-01`, end: `${entry.periodKey}-${pad23(last)}` };
|
|
105695
106437
|
}
|
|
105696
106438
|
if (entry.periodType === "range") {
|
|
105697
106439
|
if (!entry.start || !entry.end) return null;
|
|
@@ -106226,6 +106968,13 @@ function tariffQuery(sel, granularity) {
|
|
|
106226
106968
|
if (granularity) qs.set("granularity", granularity);
|
|
106227
106969
|
return qs.toString();
|
|
106228
106970
|
}
|
|
106971
|
+
function unwrapGcdrEnvelope(body) {
|
|
106972
|
+
if (body && typeof body === "object" && !Array.isArray(body)) {
|
|
106973
|
+
const b = body;
|
|
106974
|
+
if (b.success === true && b.data && typeof b.data === "object") return b.data;
|
|
106975
|
+
}
|
|
106976
|
+
return body;
|
|
106977
|
+
}
|
|
106229
106978
|
function parseETagVersion(headers) {
|
|
106230
106979
|
const raw = headers.get("ETag") || headers.get("etag");
|
|
106231
106980
|
if (!raw) return void 0;
|
|
@@ -106269,7 +107018,7 @@ var TariffApiClient = class {
|
|
|
106269
107018
|
const body = await this.readBody(res);
|
|
106270
107019
|
if (!res.ok) throw this.toError(res, body);
|
|
106271
107020
|
const etagVersion = parseETagVersion(res.headers);
|
|
106272
|
-
const parsed = body || {};
|
|
107021
|
+
const parsed = unwrapGcdrEnvelope(body) || {};
|
|
106273
107022
|
return {
|
|
106274
107023
|
customerId: sel.customerId,
|
|
106275
107024
|
domain: sel.domain,
|
|
@@ -106317,7 +107066,8 @@ var TariffApiClient = class {
|
|
|
106317
107066
|
const body = await this.readBody(res);
|
|
106318
107067
|
if (!res.ok) throw this.toError(res, body);
|
|
106319
107068
|
const etagVersion = parseETagVersion(res.headers);
|
|
106320
|
-
const
|
|
107069
|
+
const data = unwrapGcdrEnvelope(body);
|
|
107070
|
+
const v = (data && data.version) ?? etagVersion;
|
|
106321
107071
|
return typeof v === "number" ? { version: v } : {};
|
|
106322
107072
|
}
|
|
106323
107073
|
async write(method, sel, body, expectedVersion) {
|
|
@@ -106336,7 +107086,8 @@ var TariffApiClient = class {
|
|
|
106336
107086
|
const parsed = await this.readBody(res);
|
|
106337
107087
|
if (!res.ok) throw this.toError(res, parsed);
|
|
106338
107088
|
const etagVersion = parseETagVersion(res.headers);
|
|
106339
|
-
const
|
|
107089
|
+
const data = unwrapGcdrEnvelope(parsed);
|
|
107090
|
+
const v = (data && data.version) ?? etagVersion;
|
|
106340
107091
|
return { version: typeof v === "number" ? v : (expectedVersion ?? 0) + 1 };
|
|
106341
107092
|
}
|
|
106342
107093
|
async readBody(res) {
|
|
@@ -106431,7 +107182,7 @@ function daysInMonthYear(year, month) {
|
|
|
106431
107182
|
if (month === 2 && isLeapYear(year)) return 29;
|
|
106432
107183
|
return MONTH_DAYS[month - 1];
|
|
106433
107184
|
}
|
|
106434
|
-
function
|
|
107185
|
+
function pad24(n) {
|
|
106435
107186
|
return String(n).padStart(2, "0");
|
|
106436
107187
|
}
|
|
106437
107188
|
function assertValidCivilDate(date) {
|
|
@@ -106442,7 +107193,7 @@ function assertValidCivilDate(date) {
|
|
|
106442
107193
|
const d = Number(m[3]);
|
|
106443
107194
|
if (mo < 1 || mo > 12) throw new Error(`Invalid month in date: ${date}`);
|
|
106444
107195
|
if (d < 1 || d > daysInMonthYear(y, mo)) {
|
|
106445
|
-
throw new Error(`Invalid day for ${y}-${
|
|
107196
|
+
throw new Error(`Invalid day for ${y}-${pad24(mo)} (leap=${isLeapYear(y)}): ${date}`);
|
|
106446
107197
|
}
|
|
106447
107198
|
}
|
|
106448
107199
|
function* eachDate(start, end) {
|
|
@@ -106451,7 +107202,7 @@ function* eachDate(start, end) {
|
|
|
106451
107202
|
const t1 = Date.UTC(ye, me - 1, de);
|
|
106452
107203
|
for (let t = Date.UTC(ys, ms - 1, ds); t <= t1; t += 864e5) {
|
|
106453
107204
|
const dt = new Date(t);
|
|
106454
|
-
yield `${dt.getUTCFullYear()}-${
|
|
107205
|
+
yield `${dt.getUTCFullYear()}-${pad24(dt.getUTCMonth() + 1)}-${pad24(dt.getUTCDate())}`;
|
|
106455
107206
|
}
|
|
106456
107207
|
}
|
|
106457
107208
|
function normalizeBand(input) {
|
|
@@ -106515,7 +107266,7 @@ function bandToPanelEntry(band, customerId) {
|
|
|
106515
107266
|
function expandDayToHourBuckets(date, price) {
|
|
106516
107267
|
assertValidCivilDate(date);
|
|
106517
107268
|
const out = [];
|
|
106518
|
-
for (let h3 = 0; h3 < 24; h3++) out.push({ level: "HOUR", ref: `${date}T${
|
|
107269
|
+
for (let h3 = 0; h3 < 24; h3++) out.push({ level: "HOUR", ref: `${date}T${pad24(h3)}`, price });
|
|
106519
107270
|
return out;
|
|
106520
107271
|
}
|
|
106521
107272
|
function expandBandHours(date, startHour, endHour, price) {
|
|
@@ -106524,7 +107275,7 @@ function expandBandHours(date, startHour, endHour, price) {
|
|
|
106524
107275
|
throw new Error(`Invalid hour band ${startHour}-${endHour} for ${date}`);
|
|
106525
107276
|
}
|
|
106526
107277
|
const out = [];
|
|
106527
|
-
for (let h3 = startHour; h3 <= endHour; h3++) out.push({ level: "HOUR", ref: `${date}T${
|
|
107278
|
+
for (let h3 = startHour; h3 <= endHour; h3++) out.push({ level: "HOUR", ref: `${date}T${pad24(h3)}`, price });
|
|
106528
107279
|
return out;
|
|
106529
107280
|
}
|
|
106530
107281
|
function bandDateBounds(band) {
|
|
@@ -106532,7 +107283,7 @@ function bandDateBounds(band) {
|
|
|
106532
107283
|
case "month": {
|
|
106533
107284
|
if (!band.periodKey) throw new Error("month band missing periodKey");
|
|
106534
107285
|
const [y, m] = band.periodKey.split("-").map(Number);
|
|
106535
|
-
return { start: `${band.periodKey}-01`, end: `${band.periodKey}-${
|
|
107286
|
+
return { start: `${band.periodKey}-01`, end: `${band.periodKey}-${pad24(daysInMonthYear(y, m))}` };
|
|
106536
107287
|
}
|
|
106537
107288
|
case "range": {
|
|
106538
107289
|
if (!band.start || !band.end) throw new Error("range band missing start/end");
|
|
@@ -106676,7 +107427,7 @@ function collapseTreeToBands(tree, dims) {
|
|
|
106676
107427
|
} else if (typeof node.price === "string") {
|
|
106677
107428
|
const last = daysInMonthYear(dims.year, Number(mm));
|
|
106678
107429
|
for (let d = 1; d <= last; d++) {
|
|
106679
|
-
dayBands.push({ ...dimOnly, periodType: "day", date: `${dims.year}-${mm}-${
|
|
107430
|
+
dayBands.push({ ...dimOnly, periodType: "day", date: `${dims.year}-${mm}-${pad24(d)}`, price: node.price });
|
|
106680
107431
|
}
|
|
106681
107432
|
}
|
|
106682
107433
|
}
|
|
@@ -107522,11 +108273,16 @@ var GoalsMoneyClient = class {
|
|
|
107522
108273
|
const v = (body && body.version) ?? etagVersion;
|
|
107523
108274
|
return typeof v === "number" ? { version: v } : {};
|
|
107524
108275
|
}
|
|
108276
|
+
/**
|
|
108277
|
+
* Parse the body and unwrap GCDR's `{ success: true, data, meta }` success
|
|
108278
|
+
* envelope (bare shape still accepted). Error envelopes stay intact for
|
|
108279
|
+
* `toError`.
|
|
108280
|
+
*/
|
|
107525
108281
|
async readBody(res) {
|
|
107526
108282
|
try {
|
|
107527
108283
|
const text2 = await res.text();
|
|
107528
108284
|
if (!text2) return null;
|
|
107529
|
-
return JSON.parse(text2);
|
|
108285
|
+
return unwrapGcdrEnvelope(JSON.parse(text2));
|
|
107530
108286
|
} catch {
|
|
107531
108287
|
return null;
|
|
107532
108288
|
}
|
|
@@ -108034,11 +108790,11 @@ function deviceCategoryToPanelTerm(cat) {
|
|
|
108034
108790
|
function panelTermToDeviceCategory(term) {
|
|
108035
108791
|
return term == null ? null : panelCategoryToWire(term);
|
|
108036
108792
|
}
|
|
108037
|
-
function
|
|
108793
|
+
function esc9(s) {
|
|
108038
108794
|
return String(s ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
108039
108795
|
}
|
|
108040
108796
|
function categoryOptionsHTML(selected) {
|
|
108041
|
-
const opt = (value, label, isSel) => `<option value="${value}"${isSel ? " selected" : ""}>${
|
|
108797
|
+
const opt = (value, label, isSel) => `<option value="${value}"${isSel ? " selected" : ""}>${esc9(label)}</option>`;
|
|
108042
108798
|
return opt("", NONE_LABEL, selected == null) + opt("COMMON_AREA", deviceCategoryLabel("COMMON_AREA"), selected === "COMMON_AREA") + opt("SPECIFIC", deviceCategoryLabel("SPECIFIC"), selected === "SPECIFIC");
|
|
108043
108799
|
}
|
|
108044
108800
|
function openDeviceCategoryPanel(params) {
|
|
@@ -108075,8 +108831,8 @@ function openDeviceCategoryPanel(params) {
|
|
|
108075
108831
|
<select class="myio-devcat__filter" data-devcat-filter="1" aria-label="Filtrar por categoria">
|
|
108076
108832
|
<option value="all">Todas as categorias</option>
|
|
108077
108833
|
<option value="uncategorized">Sem categoria</option>
|
|
108078
|
-
<option value="COMMON_AREA">${
|
|
108079
|
-
<option value="SPECIFIC">${
|
|
108834
|
+
<option value="COMMON_AREA">${esc9(deviceCategoryLabel("COMMON_AREA"))}</option>
|
|
108835
|
+
<option value="SPECIFIC">${esc9(deviceCategoryLabel("SPECIFIC"))}</option>
|
|
108080
108836
|
</select>
|
|
108081
108837
|
<label class="myio-devcat__filter" style="display:flex;align-items:center;gap:6px;cursor:pointer;">
|
|
108082
108838
|
<input type="checkbox" data-devcat-selectall="1" /> Selecionar vis\xEDveis
|
|
@@ -108085,9 +108841,9 @@ function openDeviceCategoryPanel(params) {
|
|
|
108085
108841
|
<div class="myio-devcat__bulkbar" data-devcat-bulkbar="1">
|
|
108086
108842
|
<span data-devcat-bulkcount="1">0 selecionados</span>
|
|
108087
108843
|
<select data-devcat-bulkcat="1" aria-label="Categoria para os selecionados">
|
|
108088
|
-
<option value="">${
|
|
108089
|
-
<option value="COMMON_AREA">${
|
|
108090
|
-
<option value="SPECIFIC">${
|
|
108844
|
+
<option value="">${esc9(NONE_LABEL)}</option>
|
|
108845
|
+
<option value="COMMON_AREA">${esc9(deviceCategoryLabel("COMMON_AREA"))}</option>
|
|
108846
|
+
<option value="SPECIFIC">${esc9(deviceCategoryLabel("SPECIFIC"))}</option>
|
|
108091
108847
|
</select>
|
|
108092
108848
|
<button type="button" class="myio-devcat__bulk-apply" data-devcat-bulkapply="1">Aplicar a selecionados</button>
|
|
108093
108849
|
</div>
|
|
@@ -108117,16 +108873,16 @@ function openDeviceCategoryPanel(params) {
|
|
|
108117
108873
|
return rows.filter((r) => matchesFilter(r) && matchesSearch(r));
|
|
108118
108874
|
}
|
|
108119
108875
|
function rowHTML(r) {
|
|
108120
|
-
const name =
|
|
108121
|
-
const code = r.code ? `<span class="myio-devcat__row-code">${
|
|
108876
|
+
const name = esc9(r.label || r.code || r.deviceId);
|
|
108877
|
+
const code = r.code ? `<span class="myio-devcat__row-code">${esc9(r.code)}</span>` : "";
|
|
108122
108878
|
const checked = selected.has(r.deviceId) ? " checked" : "";
|
|
108123
108879
|
const focused = r.deviceId === params.focusDeviceId ? ' data-focused="1"' : "";
|
|
108124
108880
|
const catAttr = r.tariffCategory == null ? "null" : r.tariffCategory;
|
|
108125
|
-
return `<div class="myio-devcat__row" data-devcat-row="${
|
|
108881
|
+
return `<div class="myio-devcat__row" data-devcat-row="${esc9(r.deviceId)}" data-cat="${catAttr}"${focused}><input type="checkbox" class="myio-devcat__row-check" data-devcat-rowcheck="${esc9(
|
|
108126
108882
|
r.deviceId
|
|
108127
|
-
)}"${checked} aria-label="Selecionar ${name}" /><div class="myio-devcat__row-main"><span class="myio-devcat__row-label" title="${name}">${name}</span>` + code + `</div><select class="myio-devcat__row-select" data-devcat-rowselect="${
|
|
108883
|
+
)}"${checked} aria-label="Selecionar ${name}" /><div class="myio-devcat__row-main"><span class="myio-devcat__row-label" title="${name}">${name}</span>` + code + `</div><select class="myio-devcat__row-select" data-devcat-rowselect="${esc9(
|
|
108128
108884
|
r.deviceId
|
|
108129
|
-
)}" aria-label="Categoria de ${name}">${categoryOptionsHTML(r.tariffCategory)}</select><div class="myio-devcat__row-conflict" data-devcat-conflict="${
|
|
108885
|
+
)}" aria-label="Categoria de ${name}">${categoryOptionsHTML(r.tariffCategory)}</select><div class="myio-devcat__row-conflict" data-devcat-conflict="${esc9(r.deviceId)}"></div></div>`;
|
|
108130
108886
|
}
|
|
108131
108887
|
function render3() {
|
|
108132
108888
|
const vis = visibleRows();
|
|
@@ -108286,7 +109042,7 @@ function openDeviceCategoryPanel(params) {
|
|
|
108286
109042
|
rows = await port.listDevices({ customerId, domain: params.domain });
|
|
108287
109043
|
} catch (err) {
|
|
108288
109044
|
rows = [];
|
|
108289
|
-
body.innerHTML = `<div class="myio-devcat__empty">N\xE3o foi poss\xEDvel carregar os dispositivos: ${
|
|
109045
|
+
body.innerHTML = `<div class="myio-devcat__empty">N\xE3o foi poss\xEDvel carregar os dispositivos: ${esc9(
|
|
108290
109046
|
err?.message || "erro"
|
|
108291
109047
|
)}</div>`;
|
|
108292
109048
|
countEl.textContent = "";
|
|
@@ -108397,207 +109153,6 @@ function renderGatedMoney(params, renderers) {
|
|
|
108397
109153
|
return renderers.renderCoverage(routing.coverageOverlay);
|
|
108398
109154
|
}
|
|
108399
109155
|
|
|
108400
|
-
// src/components/financial-goals/tariffValuation.ts
|
|
108401
|
-
var MONEY_HOURLY_MAX_DAYS = 31;
|
|
108402
|
-
var TARIFF_DEFAULT_TIMEZONE = "America/Sao_Paulo";
|
|
108403
|
-
var HOUR_MS2 = 36e5;
|
|
108404
|
-
var QTY_SCALE = 6;
|
|
108405
|
-
var PRICE_SCALE = 6;
|
|
108406
|
-
var AMOUNT_SCALE = QTY_SCALE + PRICE_SCALE;
|
|
108407
|
-
var DECIMAL_RE = /^([+-]?)(\d+)(?:\.(\d+))?$/;
|
|
108408
|
-
function parseScaled(s, scale) {
|
|
108409
|
-
const m = DECIMAL_RE.exec(String(s).trim());
|
|
108410
|
-
if (!m) return null;
|
|
108411
|
-
const frac = (m[3] || "").slice(0, scale).padEnd(scale, "0");
|
|
108412
|
-
const v = BigInt(m[2] + frac);
|
|
108413
|
-
return m[1] === "-" ? -v : v;
|
|
108414
|
-
}
|
|
108415
|
-
function formatScaled(v, scale) {
|
|
108416
|
-
const neg = v < 0n;
|
|
108417
|
-
const abs = neg ? -v : v;
|
|
108418
|
-
const digits = abs.toString().padStart(scale + 1, "0");
|
|
108419
|
-
const int = digits.slice(0, digits.length - scale);
|
|
108420
|
-
let frac = digits.slice(digits.length - scale).replace(/0+$/, "");
|
|
108421
|
-
if (frac.length < 2) frac = frac.padEnd(2, "0");
|
|
108422
|
-
const isZero = abs === 0n;
|
|
108423
|
-
return `${neg && !isZero ? "-" : ""}${int}.${frac}`;
|
|
108424
|
-
}
|
|
108425
|
-
function qtyToScaled(qty) {
|
|
108426
|
-
if (typeof qty !== "number" || !Number.isFinite(qty) || Math.abs(qty) >= 1e15) return null;
|
|
108427
|
-
return parseScaled(qty.toFixed(QTY_SCALE), QTY_SCALE);
|
|
108428
|
-
}
|
|
108429
|
-
function isPriceString(p) {
|
|
108430
|
-
return typeof p === "string" && DECIMAL_RE.test(p.trim());
|
|
108431
|
-
}
|
|
108432
|
-
function makeLocalPartsFn(timezone) {
|
|
108433
|
-
let fmt2 = null;
|
|
108434
|
-
try {
|
|
108435
|
-
fmt2 = new Intl.DateTimeFormat("en-US", {
|
|
108436
|
-
timeZone: timezone,
|
|
108437
|
-
year: "numeric",
|
|
108438
|
-
month: "2-digit",
|
|
108439
|
-
day: "2-digit",
|
|
108440
|
-
hour: "2-digit",
|
|
108441
|
-
hourCycle: "h23"
|
|
108442
|
-
});
|
|
108443
|
-
} catch {
|
|
108444
|
-
fmt2 = null;
|
|
108445
|
-
}
|
|
108446
|
-
return (ts) => {
|
|
108447
|
-
if (fmt2) {
|
|
108448
|
-
const out = {};
|
|
108449
|
-
for (const p of fmt2.formatToParts(new Date(ts))) {
|
|
108450
|
-
if (p.type === "year" || p.type === "month" || p.type === "day" || p.type === "hour") {
|
|
108451
|
-
out[p.type] = Number(p.value);
|
|
108452
|
-
}
|
|
108453
|
-
}
|
|
108454
|
-
return { year: out.year, month: out.month, day: out.day, hour: out.hour % 24 };
|
|
108455
|
-
}
|
|
108456
|
-
const d = new Date(ts - 3 * HOUR_MS2);
|
|
108457
|
-
return { year: d.getUTCFullYear(), month: d.getUTCMonth() + 1, day: d.getUTCDate(), hour: d.getUTCHours() };
|
|
108458
|
-
};
|
|
108459
|
-
}
|
|
108460
|
-
var pad24 = (n) => String(n).padStart(2, "0");
|
|
108461
|
-
function nodePrice(node) {
|
|
108462
|
-
return node && isPriceString(node.price) ? node.price.trim() : null;
|
|
108463
|
-
}
|
|
108464
|
-
function hourPrice(dayNode, hour) {
|
|
108465
|
-
const hourly = dayNode?.hourly;
|
|
108466
|
-
if (!hourly) return null;
|
|
108467
|
-
return nodePrice(hourly[String(hour)]) ?? nodePrice(hourly[pad24(hour)]);
|
|
108468
|
-
}
|
|
108469
|
-
function resolveTreePrice(tree, p) {
|
|
108470
|
-
const mm = pad24(p.month);
|
|
108471
|
-
const dd = pad24(p.day);
|
|
108472
|
-
const mmdd = `${mm}-${dd}`;
|
|
108473
|
-
const monthNode = tree.monthly?.[mm];
|
|
108474
|
-
const dayNodes = [tree.daily?.[mmdd], monthNode?.daily?.[dd], monthNode?.daily?.[mmdd]];
|
|
108475
|
-
for (const dn of dayNodes) {
|
|
108476
|
-
const hp = hourPrice(dn, p.hour);
|
|
108477
|
-
if (hp) return hp;
|
|
108478
|
-
}
|
|
108479
|
-
for (const dn of dayNodes) {
|
|
108480
|
-
const dp = nodePrice(dn);
|
|
108481
|
-
if (dp) return dp;
|
|
108482
|
-
}
|
|
108483
|
-
return nodePrice(monthNode) ?? nodePrice(tree.annual);
|
|
108484
|
-
}
|
|
108485
|
-
function createTariffValuator(options) {
|
|
108486
|
-
const trees = options?.trees || {};
|
|
108487
|
-
const localParts = makeLocalPartsFn(options?.timezone || TARIFF_DEFAULT_TIMEZONE);
|
|
108488
|
-
const byYear = {};
|
|
108489
|
-
Object.keys(trees).forEach((cat) => {
|
|
108490
|
-
const map = /* @__PURE__ */ new Map();
|
|
108491
|
-
for (const res of trees[cat] || []) {
|
|
108492
|
-
if (res && typeof res.year === "number" && res.tree) map.set(res.year, res.tree);
|
|
108493
|
-
}
|
|
108494
|
-
byYear[cat] = map;
|
|
108495
|
-
});
|
|
108496
|
-
function hasAnyTariff(category) {
|
|
108497
|
-
const map = byYear[category];
|
|
108498
|
-
return !!map && map.size > 0;
|
|
108499
|
-
}
|
|
108500
|
-
function priceAt(category, ts) {
|
|
108501
|
-
const map = byYear[category];
|
|
108502
|
-
if (!map || !Number.isFinite(ts)) return null;
|
|
108503
|
-
const p = localParts(ts);
|
|
108504
|
-
const tree = map.get(p.year);
|
|
108505
|
-
return tree ? resolveTreePrice(tree, p) : null;
|
|
108506
|
-
}
|
|
108507
|
-
function pricesInside(category, startTs, endTs) {
|
|
108508
|
-
const out = [];
|
|
108509
|
-
const end = Math.max(endTs, startTs + 1);
|
|
108510
|
-
for (let t = startTs; t < end; t += HOUR_MS2) out.push(priceAt(category, t));
|
|
108511
|
-
return out;
|
|
108512
|
-
}
|
|
108513
|
-
function valuate(series, opts) {
|
|
108514
|
-
const needsHourlyReason = opts?.intradayLimited ? "intraday-tariff-long-period" : "needs-hourly";
|
|
108515
|
-
const category = series?.category ?? null;
|
|
108516
|
-
if (!category) return { state: "uncategorized", reason: "no-category" };
|
|
108517
|
-
if (!hasAnyTariff(category)) return { state: "none", reason: "no-tariff", coveredRatio: 0 };
|
|
108518
|
-
const buckets = Array.isArray(series.buckets) ? series.buckets : [];
|
|
108519
|
-
if (buckets.length === 0) return { state: "none", reason: "no-data", coveredRatio: 0 };
|
|
108520
|
-
let acc = 0n;
|
|
108521
|
-
let covered = 0;
|
|
108522
|
-
let firstReason;
|
|
108523
|
-
const distinct = /* @__PURE__ */ new Set();
|
|
108524
|
-
for (const b of buckets) {
|
|
108525
|
-
const qty = qtyToScaled(b?.qty);
|
|
108526
|
-
if (qty == null || !Number.isFinite(b.startTs) || !Number.isFinite(b.endTs)) {
|
|
108527
|
-
firstReason = firstReason || "invalid-qty";
|
|
108528
|
-
continue;
|
|
108529
|
-
}
|
|
108530
|
-
const prices = pricesInside(category, b.startTs, b.endTs);
|
|
108531
|
-
if (prices.some((p) => p == null)) {
|
|
108532
|
-
firstReason = firstReason || "no-tariff";
|
|
108533
|
-
continue;
|
|
108534
|
-
}
|
|
108535
|
-
const unique = new Set(prices);
|
|
108536
|
-
if (unique.size > 1) {
|
|
108537
|
-
firstReason = firstReason || needsHourlyReason;
|
|
108538
|
-
continue;
|
|
108539
|
-
}
|
|
108540
|
-
const price = prices[0];
|
|
108541
|
-
const scaledPrice = parseScaled(price, PRICE_SCALE);
|
|
108542
|
-
if (scaledPrice == null) {
|
|
108543
|
-
firstReason = firstReason || "no-tariff";
|
|
108544
|
-
continue;
|
|
108545
|
-
}
|
|
108546
|
-
distinct.add(formatScaled(scaledPrice, PRICE_SCALE));
|
|
108547
|
-
acc += qty * scaledPrice;
|
|
108548
|
-
covered += 1;
|
|
108549
|
-
}
|
|
108550
|
-
const ratio = covered / buckets.length;
|
|
108551
|
-
const priceVaries = distinct.size > 1;
|
|
108552
|
-
if (covered === buckets.length) {
|
|
108553
|
-
return { state: "complete", amount: formatScaled(acc, AMOUNT_SCALE), coveredRatio: 1, priceVaries };
|
|
108554
|
-
}
|
|
108555
|
-
if (covered === 0) return { state: "none", reason: firstReason || "no-tariff", coveredRatio: 0 };
|
|
108556
|
-
return { state: "partial", reason: firstReason, coveredRatio: ratio, priceVaries };
|
|
108557
|
-
}
|
|
108558
|
-
function sum2(list) {
|
|
108559
|
-
const items = Array.isArray(list) ? list : [];
|
|
108560
|
-
const total = items.length;
|
|
108561
|
-
if (total === 0) return { state: "none", covered: 0, total: 0 };
|
|
108562
|
-
let acc = 0n;
|
|
108563
|
-
let covered = 0;
|
|
108564
|
-
for (const m of items) {
|
|
108565
|
-
if (m?.state !== "complete" || m.amount == null) continue;
|
|
108566
|
-
const v = parseScaled(m.amount, AMOUNT_SCALE);
|
|
108567
|
-
if (v == null) continue;
|
|
108568
|
-
acc += v;
|
|
108569
|
-
covered += 1;
|
|
108570
|
-
}
|
|
108571
|
-
if (covered === total) return { state: "complete", amount: formatScaled(acc, AMOUNT_SCALE), covered, total };
|
|
108572
|
-
return { state: covered > 0 ? "partial" : "none", covered, total };
|
|
108573
|
-
}
|
|
108574
|
-
function chooseGranularity(categories, startTs, endTs) {
|
|
108575
|
-
const cats = Array.from(new Set((categories || []).filter(Boolean)));
|
|
108576
|
-
let intraday = false;
|
|
108577
|
-
outer: for (const cat of cats) {
|
|
108578
|
-
let dayKey = "";
|
|
108579
|
-
let dayPrice;
|
|
108580
|
-
for (let t = startTs; t < endTs; t += HOUR_MS2) {
|
|
108581
|
-
const p = localParts(t);
|
|
108582
|
-
const key = `${p.year}-${p.month}-${p.day}`;
|
|
108583
|
-
const price = priceAt(cat, t);
|
|
108584
|
-
if (key !== dayKey) {
|
|
108585
|
-
dayKey = key;
|
|
108586
|
-
dayPrice = price;
|
|
108587
|
-
} else if (price !== dayPrice) {
|
|
108588
|
-
intraday = true;
|
|
108589
|
-
break outer;
|
|
108590
|
-
}
|
|
108591
|
-
}
|
|
108592
|
-
}
|
|
108593
|
-
if (!intraday) return { granularity: "1d", intradayLimited: false };
|
|
108594
|
-
const days = (endTs - startTs) / (24 * HOUR_MS2);
|
|
108595
|
-
if (days <= MONEY_HOURLY_MAX_DAYS) return { granularity: "1h", intradayLimited: false };
|
|
108596
|
-
return { granularity: "1d", intradayLimited: true };
|
|
108597
|
-
}
|
|
108598
|
-
return { priceAt, valuate, sum: sum2, chooseGranularity };
|
|
108599
|
-
}
|
|
108600
|
-
|
|
108601
109156
|
// src/components/premium-modals/measurement-setup/types.ts
|
|
108602
109157
|
var WATER_UNITS = [
|
|
108603
109158
|
{ value: "m3", label: "Metros C\xFAbicos (m\xB3)" },
|
|
@@ -116056,14 +116611,14 @@ function buildTemplateCsv(domain, devices, start, end, now = Date.now()) {
|
|
|
116056
116611
|
if (domain === "energy") header.push("value_reactive_kvarh");
|
|
116057
116612
|
const today = nowSaoPaulo(now);
|
|
116058
116613
|
const lines = [header.join(";")];
|
|
116059
|
-
const
|
|
116614
|
+
const esc11 = (v) => /[;"\n]/.test(v) ? `"${v.replace(/"/g, '""')}"` : v;
|
|
116060
116615
|
const { ok } = splitImportableDevices(devices);
|
|
116061
116616
|
for (const dev of ok) {
|
|
116062
116617
|
for (const date of daysBetween(start, end)) {
|
|
116063
116618
|
if (date > today.date) break;
|
|
116064
116619
|
for (let h3 = 0; h3 < 24; h3++) {
|
|
116065
116620
|
if (date === today.date && h3 >= today.hour) break;
|
|
116066
|
-
const cols = [String(dev.centralId), String(Number(dev.slaveId)),
|
|
116621
|
+
const cols = [String(dev.centralId), String(Number(dev.slaveId)), esc11(dev.label || ""), date, `${pad25(h3)}:00`, ""];
|
|
116067
116622
|
if (domain === "energy") cols.push("");
|
|
116068
116623
|
lines.push(cols.join(";"));
|
|
116069
116624
|
}
|
|
@@ -116324,10 +116879,10 @@ function accumulatedRows(domain, entries, profile = DEFAULT_DISTRIBUTION_PROFILE
|
|
|
116324
116879
|
}
|
|
116325
116880
|
function buildAccumulatedTemplateCsv(domain, devices, start, end) {
|
|
116326
116881
|
const lines = [["gateway_id", "slave_id", "device_name", "start_date", "end_date", TOTAL_COLUMN[domain]].join(";")];
|
|
116327
|
-
const
|
|
116882
|
+
const esc11 = (v) => /[;"\n]/.test(v) ? `"${v.replace(/"/g, '""')}"` : v;
|
|
116328
116883
|
for (const dev of devices || []) {
|
|
116329
116884
|
if (!isImportableKey(dev)) continue;
|
|
116330
|
-
lines.push([String(dev.centralId), String(Number(dev.slaveId)),
|
|
116885
|
+
lines.push([String(dev.centralId), String(Number(dev.slaveId)), esc11(dev.label || ""), start, end, ""].join(";"));
|
|
116331
116886
|
}
|
|
116332
116887
|
return { csv: "\uFEFF" + lines.join("\r\n") + "\r\n", rows: lines.length - 1 };
|
|
116333
116888
|
}
|
|
@@ -116517,7 +117072,7 @@ function fmtSaoPaulo(iso) {
|
|
|
116517
117072
|
return `${p(d.getUTCDate())}/${p(d.getUTCMonth() + 1)}/${d.getUTCFullYear()} ${p(d.getUTCHours())}:00`;
|
|
116518
117073
|
}
|
|
116519
117074
|
var STYLE_ID15 = "myio-tlmimport-styles";
|
|
116520
|
-
function
|
|
117075
|
+
function esc10(v) {
|
|
116521
117076
|
return String(v ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
116522
117077
|
}
|
|
116523
117078
|
var fmtNum = (n, d = 0) => Number.isFinite(Number(n)) ? Number(n).toLocaleString("pt-BR", { minimumFractionDigits: d, maximumFractionDigits: d }) : "\u2014";
|
|
@@ -116580,7 +117135,7 @@ function injectStyles14() {
|
|
|
116580
117135
|
document.head.appendChild(style);
|
|
116581
117136
|
}
|
|
116582
117137
|
function issuesTable(errors, limit = 100) {
|
|
116583
|
-
const rows = errors.slice(0, limit).map((e) => `<tr><td>${
|
|
117138
|
+
const rows = errors.slice(0, limit).map((e) => `<tr><td>${esc10(e.line)}</td><td>${esc10(e.reason)}</td></tr>`).join("");
|
|
116584
117139
|
const more = errors.length > limit ? `<p class="tlmi-muted">\u2026 e mais ${errors.length - limit} erro(s).</p>` : "";
|
|
116585
117140
|
return `<div class="tlmi-errors"><table><thead><tr><th>Linha</th><th>Problema</th></tr></thead><tbody>${rows}</tbody></table></div>${more}`;
|
|
116586
117141
|
}
|
|
@@ -116658,10 +117213,10 @@ function openTelemetryImportModal(params) {
|
|
|
116658
117213
|
}
|
|
116659
117214
|
function apiErrorBanner() {
|
|
116660
117215
|
if (!s.apiError) return "";
|
|
116661
|
-
return `<div class="tlmi-banner err" role="alert">${
|
|
117216
|
+
return `<div class="tlmi-banner err" role="alert">${esc10(s.apiError)}${s.apiDetail ? `<div class="tlmi-tech">${esc10(s.apiDetail)}</div>` : ""}</div>`;
|
|
116662
117217
|
}
|
|
116663
117218
|
function step1() {
|
|
116664
|
-
const warn = missingKey.length ? `<div class="tlmi-banner warn">${missingKey.length} dispositivo(s) sem central/endere\xE7o cadastrados ficam fora do modelo: ${
|
|
117219
|
+
const warn = missingKey.length ? `<div class="tlmi-banner warn">${missingKey.length} dispositivo(s) sem central/endere\xE7o cadastrados ficam fora do modelo: ${esc10(
|
|
116665
117220
|
missingKey.slice(0, 5).map((d) => d.label).join(", ")
|
|
116666
117221
|
)}${missingKey.length > 5 ? "\u2026" : ""}</div>` : "";
|
|
116667
117222
|
const model = (value, title, hint) => `
|
|
@@ -116688,16 +117243,16 @@ function openTelemetryImportModal(params) {
|
|
|
116688
117243
|
${warn}
|
|
116689
117244
|
<div class="tlmi-card"><h3>${s.model === "accumulated" ? "Per\xEDodo" : "Modelo da planilha"}</h3>
|
|
116690
117245
|
<div class="tlmi-row">
|
|
116691
|
-
<label class="tlmi-field">In\xEDcio<input type="date" data-field="start" value="${
|
|
116692
|
-
<label class="tlmi-field">Fim<input type="date" data-field="end" value="${
|
|
117246
|
+
<label class="tlmi-field">In\xEDcio<input type="date" data-field="start" value="${esc10(s.period.start)}" /></label>
|
|
117247
|
+
<label class="tlmi-field">Fim<input type="date" data-field="end" value="${esc10(s.period.end)}" /></label>
|
|
116693
117248
|
<button class="tlmi-btn" type="button" data-action="template" ${importable.length ? "" : "disabled"}>\u2B07 Baixar modelo (CSV)</button>
|
|
116694
117249
|
</div>
|
|
116695
117250
|
<p class="tlmi-muted" style="margin-top:8px">${importable.length} dispositivo(s) no modelo. ${s.model === "accumulated" ? "Para digitar na tela, clique em <strong>Avan\xE7ar</strong>." : "J\xE1 tem a planilha preenchida? Clique em <strong>Avan\xE7ar</strong>."}</p>
|
|
116696
117251
|
</div>`;
|
|
116697
117252
|
}
|
|
116698
117253
|
function step2() {
|
|
116699
|
-
const summary = s.fileName ? s.parseError ? `<div class="tlmi-banner err">${
|
|
116700
|
-
<div class="tlmi-kpi"><span>Arquivo</span><strong style="font-size:13px">${
|
|
117254
|
+
const summary = s.fileName ? s.parseError ? `<div class="tlmi-banner err">${esc10(s.parseError)}</div>` : `<div class="tlmi-kpis">
|
|
117255
|
+
<div class="tlmi-kpi"><span>Arquivo</span><strong style="font-size:13px">${esc10(s.fileName)}</strong></div>
|
|
116701
117256
|
<div class="tlmi-kpi"><span>Linhas para importar</span><strong>${fmtNum(s.rows.length)}</strong></div>
|
|
116702
117257
|
<div class="tlmi-kpi"><span>Em branco (ignoradas)</span><strong>${fmtNum(s.skippedEmpty)}</strong></div>
|
|
116703
117258
|
<div class="tlmi-kpi"><span>Com erro</span><strong style="color:${s.localErrors.length ? "#dc2626" : "#16a34a"}">${fmtNum(s.localErrors.length)}</strong></div>
|
|
@@ -116737,12 +117292,12 @@ function openTelemetryImportModal(params) {
|
|
|
116737
117292
|
}
|
|
116738
117293
|
function step2Accumulated() {
|
|
116739
117294
|
const fromFile = !!s.fileName && !s.parseError;
|
|
116740
|
-
const form = fromFile ? `<p class="tlmi-muted">Usando <strong>${
|
|
116741
|
-
<button class="tlmi-btn" type="button" data-action="use-form">Preencher na tela</button></p>` : `<p class="tlmi-muted" style="margin-bottom:8px">Per\xEDodo: ${
|
|
117295
|
+
const form = fromFile ? `<p class="tlmi-muted">Usando <strong>${esc10(s.fileName)}</strong>.
|
|
117296
|
+
<button class="tlmi-btn" type="button" data-action="use-form">Preencher na tela</button></p>` : `<p class="tlmi-muted" style="margin-bottom:8px">Per\xEDodo: ${esc10(s.period.start)} a ${esc10(s.period.end)}. Deixe em branco o que n\xE3o quer importar.</p>
|
|
116742
117297
|
<div class="tlmi-acc"><table><thead><tr><th>Dispositivo</th><th>Total (${txt.unit})</th></tr></thead><tbody>
|
|
116743
117298
|
${importable.map(
|
|
116744
|
-
(d, i) => `<tr><td>${
|
|
116745
|
-
<td><input inputmode="decimal" data-total="${i}" aria-label="Total de ${
|
|
117299
|
+
(d, i) => `<tr><td>${esc10(d.label)}</td>
|
|
117300
|
+
<td><input inputmode="decimal" data-total="${i}" aria-label="Total de ${esc10(d.label)}" value="${esc10(s.formTotals[i] ?? "")}" /></td></tr>`
|
|
116746
117301
|
).join("")}
|
|
116747
117302
|
</tbody></table></div>`;
|
|
116748
117303
|
return `
|
|
@@ -116755,7 +117310,7 @@ function openTelemetryImportModal(params) {
|
|
|
116755
117310
|
<input type="file" accept=".xlsx,.xls,.csv" data-field="file" hidden />
|
|
116756
117311
|
\u{1F4C4} Clique ou arraste a planilha aqui (.xlsx ou .csv)
|
|
116757
117312
|
</label>
|
|
116758
|
-
${s.parseError ? `<div class="tlmi-banner err" style="margin-top:10px">${
|
|
117313
|
+
${s.parseError ? `<div class="tlmi-banner err" style="margin-top:10px">${esc10(s.parseError)}</div>` : ""}
|
|
116759
117314
|
</div>
|
|
116760
117315
|
<div data-role="acc-summary" style="display:flex;flex-direction:column;gap:12px">${accSummaryHtml()}</div>`;
|
|
116761
117316
|
}
|
|
@@ -116781,7 +117336,7 @@ function openTelemetryImportModal(params) {
|
|
|
116781
117336
|
<div class="tlmi-kpi"><span>Total (${txt.unit})</span><strong>${fmtNum(p.totalValue, 2)}</strong></div>
|
|
116782
117337
|
<div class="tlmi-kpi"><span>Leituras substitu\xEDdas</span><strong>${fmtNum(p.existingReadingsInTarget)}</strong></div>
|
|
116783
117338
|
</div>
|
|
116784
|
-
<p class="tlmi-muted">Per\xEDodo (hor\xE1rio de Bras\xEDlia): ${
|
|
117339
|
+
<p class="tlmi-muted">Per\xEDodo (hor\xE1rio de Bras\xEDlia): ${esc10(period)}</p>
|
|
116785
117340
|
${reactiveWarn}
|
|
116786
117341
|
${real > 0 ? `<div class="tlmi-banner warn"><strong>${fmtNum(real)} leitura(s) reais do medidor</strong> ser\xE3o substitu\xEDdas pelos valores da planilha.
|
|
116787
117342
|
<label class="tlmi-check" style="margin-top:6px"><input type="checkbox" data-field="confirmReal" ${s.confirmReal ? "checked" : ""} />
|
|
@@ -116800,7 +117355,7 @@ function openTelemetryImportModal(params) {
|
|
|
116800
117355
|
<div class="tlmi-muted" style="margin-top:4px">Dispositivos manuais continuam aparecendo sem comunica\xE7\xE3o no status:
|
|
116801
117356
|
o status conta s\xF3 leitura medida. Os totais e os cards usam os dados importados.</div></div>`;
|
|
116802
117357
|
} else if (j.status === "failed") {
|
|
116803
|
-
banner = `<div class="tlmi-banner err">A importa\xE7\xE3o falhou${j.error ? `: ${
|
|
117358
|
+
banner = `<div class="tlmi-banner err">A importa\xE7\xE3o falhou${j.error ? `: ${esc10(j.error)}` : "."}</div>`;
|
|
116804
117359
|
} else if (j.status === "cancelled") {
|
|
116805
117360
|
banner = '<div class="tlmi-banner warn">Importa\xE7\xE3o cancelada. As leituras anteriores foram mantidas.</div>';
|
|
116806
117361
|
} else if (j.status === "reverted") {
|
|
@@ -116812,14 +117367,14 @@ function openTelemetryImportModal(params) {
|
|
|
116812
117367
|
<span class="tlmi-muted">${s.confirmRevert ? "Remove as horas importadas e devolve as leituras apagadas. Clique de novo para confirmar." : "Use para remover uma importa\xE7\xE3o errada ou de teste."}</span>
|
|
116813
117368
|
</div>` : "";
|
|
116814
117369
|
return `
|
|
116815
|
-
<div class="tlmi-card"><h3>Importa\xE7\xE3o <span style="font-weight:600;color:#64748b">${
|
|
117370
|
+
<div class="tlmi-card"><h3>Importa\xE7\xE3o <span style="font-weight:600;color:#64748b">${esc10(statusText)}</span></h3>
|
|
116816
117371
|
<div class="tlmi-progress" role="progressbar" aria-valuenow="${pct}" aria-valuemin="0" aria-valuemax="100"><i style="width:${pct}%"></i></div>
|
|
116817
117372
|
<div class="tlmi-kpis" style="margin-top:12px">
|
|
116818
117373
|
<div class="tlmi-kpi"><span>Progresso</span><strong>${fmtNum(pct)}%</strong></div>
|
|
116819
117374
|
<div class="tlmi-kpi"><span>Leituras removidas</span><strong>${fmtNum(j.deleted)}</strong></div>
|
|
116820
117375
|
<div class="tlmi-kpi"><span>Leituras gravadas</span><strong>${fmtNum(j.inserted)}</strong></div>
|
|
116821
117376
|
</div>
|
|
116822
|
-
${j.phase && !terminal ? `<p class="tlmi-muted" style="margin-top:8px">Etapa: ${
|
|
117377
|
+
${j.phase && !terminal ? `<p class="tlmi-muted" style="margin-top:8px">Etapa: ${esc10(j.phase)}</p>` : ""}
|
|
116823
117378
|
${!terminal && j.status !== "reverting" ? `<div style="margin-top:12px"><button class="tlmi-btn" type="button" data-action="cancel" ${s.busy ? "disabled" : ""}>Cancelar importa\xE7\xE3o</button>
|
|
116824
117379
|
<span class="tlmi-muted" style="margin-left:8px">Voc\xEA pode fechar esta janela; a importa\xE7\xE3o continua.</span></div>` : ""}
|
|
116825
117380
|
${revert}
|
|
@@ -117129,8 +117684,8 @@ function siglaFromManualAsset(assetName) {
|
|
|
117129
117684
|
return /^[A-Z0-9_]+$/.test(sigla) ? sigla : null;
|
|
117130
117685
|
}
|
|
117131
117686
|
function nextManualSeq(domain, sigla, existingNames) {
|
|
117132
|
-
const
|
|
117133
|
-
const re = new RegExp(`^${
|
|
117687
|
+
const esc11 = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
117688
|
+
const re = new RegExp(`^${esc11(NAME_PREFIX[domain])}${esc11(sigla)}_LOJA_(\\d+)_MANUAL$`, "i");
|
|
117134
117689
|
const max = existingNames.reduce((acc, n) => {
|
|
117135
117690
|
const m = re.exec(String(n || "").trim());
|
|
117136
117691
|
return m ? Math.max(acc, Number(m[1])) : acc;
|
|
@@ -151995,10 +152550,10 @@ var AlarmsNotificationsPanelView = class {
|
|
|
151995
152550
|
const renderListPanel = (group, items, sel) => {
|
|
151996
152551
|
if (items.length === 0) return '<div class="afm-empty">Nenhum item encontrado</div>';
|
|
151997
152552
|
return items.map((item) => {
|
|
151998
|
-
const
|
|
152553
|
+
const esc11 = this.esc(item);
|
|
151999
152554
|
return `<label class="afm-check-item">
|
|
152000
|
-
<input type="checkbox" class="afm-checkbox" data-group="${group}" data-value="${
|
|
152001
|
-
<span class="afm-check-label">${
|
|
152555
|
+
<input type="checkbox" class="afm-checkbox" data-group="${group}" data-value="${esc11}"${sel.has(item) ? " checked" : ""}>
|
|
152556
|
+
<span class="afm-check-label">${esc11}</span>
|
|
152002
152557
|
</label>`;
|
|
152003
152558
|
}).join("");
|
|
152004
152559
|
};
|
|
@@ -164876,7 +165431,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
164876
165431
|
const docTitle = buildActivationReportTitle(deviceName, opts.customerName);
|
|
164877
165432
|
const issuedAt = formatIssuedAt(/* @__PURE__ */ new Date(), locale);
|
|
164878
165433
|
const utilization = data.totalHours > 0 ? (data.totalOnMinutes / (data.totalHours * 60) * 100).toFixed(1) : "0.0";
|
|
164879
|
-
const
|
|
165434
|
+
const esc11 = (s) => String(s).replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]);
|
|
164880
165435
|
const htmlContent = `
|
|
164881
165436
|
<!DOCTYPE html>
|
|
164882
165437
|
<html lang="pt-BR">
|
|
@@ -164928,14 +165483,14 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
164928
165483
|
<div class="brand">MyIO BAS</div>
|
|
164929
165484
|
<h1>Relat\xF3rio de Acionamentos</h1>
|
|
164930
165485
|
<div class="meta">
|
|
164931
|
-
<div><b>Dispositivo:</b> ${
|
|
165486
|
+
<div><b>Dispositivo:</b> ${esc11(deviceName)}</div>
|
|
164932
165487
|
<div><b>Per\xEDodo:</b> ${periodStart} \u2014 ${periodEnd}</div>
|
|
164933
165488
|
</div>
|
|
164934
165489
|
</div>
|
|
164935
165490
|
${customerName ? `
|
|
164936
165491
|
<div class="customer-badge">
|
|
164937
165492
|
<div class="label">Cliente</div>
|
|
164938
|
-
<div class="value">${
|
|
165493
|
+
<div class="value">${esc11(customerName)}</div>
|
|
164939
165494
|
</div>` : ""}
|
|
164940
165495
|
</div>
|
|
164941
165496
|
|
|
@@ -164946,7 +165501,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
164946
165501
|
</div>
|
|
164947
165502
|
<div class="summary-card accent-green">
|
|
164948
165503
|
<div class="summary-value">${formatDurationMinutes(data.totalOnMinutes)}</div>
|
|
164949
|
-
<div class="summary-label">Tempo ${
|
|
165504
|
+
<div class="summary-label">Tempo ${esc11(labelOn)}</div>
|
|
164950
165505
|
</div>
|
|
164951
165506
|
<div class="summary-card accent-amber">
|
|
164952
165507
|
<div class="summary-value">${utilization}%</div>
|
|
@@ -164974,7 +165529,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
164974
165529
|
<tr>
|
|
164975
165530
|
<td>${formatDateForExport(seg.startTime, locale)}</td>
|
|
164976
165531
|
<td>${formatDateForExport(seg.endTime, locale)}</td>
|
|
164977
|
-
<td><span class="pill ${seg.state === "on" ? "pill-on" : "pill-off"}">${seg.state === "on" ?
|
|
165532
|
+
<td><span class="pill ${seg.state === "on" ? "pill-on" : "pill-off"}">${seg.state === "on" ? esc11(labelOn) : esc11(labelOff)}</span></td>
|
|
164978
165533
|
<td>${formatDurationMinutes(seg.durationMinutes)}</td>
|
|
164979
165534
|
<td>${seg.source === "manual" ? "Manual" : seg.source === "schedule" ? "Agendamento" : seg.source === "automation" ? "Automa\xE7\xE3o" : "Desconhecido"}</td>
|
|
164980
165535
|
</tr>
|
|
@@ -164983,7 +165538,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
164983
165538
|
</table>
|
|
164984
165539
|
|
|
164985
165540
|
<div class="footer">
|
|
164986
|
-
<span class="issued">Emitido em ${issuedAt}</span>${customerName ? ` · ${
|
|
165541
|
+
<span class="issued">Emitido em ${issuedAt}</span>${customerName ? ` · ${esc11(customerName)}` : ""} · <span class="brand">MyIO BAS</span>
|
|
164987
165542
|
</div>
|
|
164988
165543
|
</body>
|
|
164989
165544
|
</html>
|
|
@@ -179830,8 +180385,13 @@ var version = package_default.version || "0.0.0";
|
|
|
179830
180385
|
MEASUREMENT_DOMAIN_CONFIG,
|
|
179831
180386
|
MENU_SHOPPING_CSS_PREFIX,
|
|
179832
180387
|
METRO_TILE_COLORS,
|
|
180388
|
+
MONEY_CONVERTIBLE_GROUPS,
|
|
179833
180389
|
MONEY_DASH,
|
|
180390
|
+
MONEY_ESTIMATE_LABEL,
|
|
179834
180391
|
MONEY_HOURLY_MAX_DAYS,
|
|
180392
|
+
MONEY_INCOMPLETE_LABEL,
|
|
180393
|
+
MONEY_MAX_SEGMENT_FETCHES,
|
|
180394
|
+
MONEY_REPORT_HEADER,
|
|
179835
180395
|
MONEY_REQUIRES_DEVICE_GRANULARITY,
|
|
179836
180396
|
MONEY_VARIANCE_HEADER,
|
|
179837
180397
|
MOTOR_SORT_OPTIONS,
|
|
@@ -179934,6 +180494,7 @@ var version = package_default.version || "0.0.0";
|
|
|
179934
180494
|
TempSensorSummaryTooltip,
|
|
179935
180495
|
Temperature,
|
|
179936
180496
|
UsersSummaryTooltip,
|
|
180497
|
+
VALUE_DISPLAY_MODE_STORAGE_PREFIX,
|
|
179937
180498
|
VALVE_STATE_KEYS,
|
|
179938
180499
|
VARIANCE_LABEL_ABOVE,
|
|
179939
180500
|
VARIANCE_LABEL_BELOW,
|
|
@@ -179981,9 +180542,12 @@ var version = package_default.version || "0.0.0";
|
|
|
179981
180542
|
buildFinancialRowHTML,
|
|
179982
180543
|
buildGcdrEnergyRoot,
|
|
179983
180544
|
buildListItemsThingsboardByUniqueDatasource,
|
|
180545
|
+
buildMoneyChipHTML,
|
|
180546
|
+
buildMoneyCoverageMarkerHTML,
|
|
179984
180547
|
buildMoneyVarianceHTML,
|
|
179985
180548
|
buildMyioIngestionAuth,
|
|
179986
180549
|
buildReportItemsList,
|
|
180550
|
+
buildReportMoneyConfig,
|
|
179987
180551
|
buildTemplateCsv,
|
|
179988
180552
|
buildTemplateExport,
|
|
179989
180553
|
buildTicketServiceOrchestrator,
|
|
@@ -180208,6 +180772,7 @@ var version = package_default.version || "0.0.0";
|
|
|
180208
180772
|
formatDuration,
|
|
180209
180773
|
formatEnergy,
|
|
180210
180774
|
formatHours,
|
|
180775
|
+
formatItemMoney,
|
|
180211
180776
|
formatMoneyBRL,
|
|
180212
180777
|
formatNumberReadable,
|
|
180213
180778
|
formatPower,
|
|
@@ -180348,6 +180913,7 @@ var version = package_default.version || "0.0.0";
|
|
|
180348
180913
|
isInRange,
|
|
180349
180914
|
isLeapYear,
|
|
180350
180915
|
isMoneyColumnConfident,
|
|
180916
|
+
isMoneyConvertibleGroup,
|
|
180351
180917
|
isMyioGcdrLoginModalOpen,
|
|
180352
180918
|
isOnOffDeviceProfile,
|
|
180353
180919
|
isSolenoidDevice,
|
|
@@ -180372,6 +180938,9 @@ var version = package_default.version || "0.0.0";
|
|
|
180372
180938
|
metasGuideComputeChips,
|
|
180373
180939
|
metasGuideDeriveTotal,
|
|
180374
180940
|
minutesToMs,
|
|
180941
|
+
moneyCoverageTitle,
|
|
180942
|
+
moneyReasonText,
|
|
180943
|
+
moneyStateChipLabel,
|
|
180375
180944
|
msToMinutes,
|
|
180376
180945
|
myioExportData,
|
|
180377
180946
|
nextManualSeq,
|
|
@@ -180447,10 +181016,12 @@ var version = package_default.version || "0.0.0";
|
|
|
180447
181016
|
parseGcdrEntityForest,
|
|
180448
181017
|
parseInputDateToDate,
|
|
180449
181018
|
parseLogAnnotations,
|
|
181019
|
+
parseMoneyCategoryRule,
|
|
180450
181020
|
periodKey,
|
|
180451
181021
|
pickUniqueCustomerCode,
|
|
180452
181022
|
pumpHistoryFromConsumption,
|
|
180453
181023
|
readFreshdeskTicketsFromTB,
|
|
181024
|
+
readValueDisplayMode,
|
|
180454
181025
|
recalculateDeviceStatus,
|
|
180455
181026
|
recomputeDeviceGridPercentages,
|
|
180456
181027
|
refreshAlarmBadges,
|
|
@@ -180494,15 +181065,18 @@ var version = package_default.version || "0.0.0";
|
|
|
180494
181065
|
resolveBudget,
|
|
180495
181066
|
resolveCategory,
|
|
180496
181067
|
resolveClassification,
|
|
181068
|
+
resolveEffectiveDisplayMode,
|
|
180497
181069
|
resolveGoalAmount,
|
|
180498
181070
|
resolveGroup,
|
|
180499
181071
|
resolveManualDeviceName,
|
|
181072
|
+
resolveMoneyCategory,
|
|
180500
181073
|
resolveMoneyRollout,
|
|
180501
181074
|
resolveMoneyRowValues,
|
|
180502
181075
|
resolvePercentDecimals,
|
|
180503
181076
|
resolveReportItemStates,
|
|
180504
181077
|
resolveSubcategory,
|
|
180505
181078
|
resolveWithFallback,
|
|
181079
|
+
roundMoney2,
|
|
180506
181080
|
routeMoneyRender,
|
|
180507
181081
|
rowsFromTable,
|
|
180508
181082
|
schedCreateDateInput,
|
|
@@ -180524,6 +181098,7 @@ var version = package_default.version || "0.0.0";
|
|
|
180524
181098
|
sortDeviceGridDevices,
|
|
180525
181099
|
strings,
|
|
180526
181100
|
subtractDecimals,
|
|
181101
|
+
sumItemMoney,
|
|
180527
181102
|
sumMoneyDecimals,
|
|
180528
181103
|
summaryDeviceToTotalsRow,
|
|
180529
181104
|
summaryLastReadingTs,
|
|
@@ -180538,6 +181113,7 @@ var version = package_default.version || "0.0.0";
|
|
|
180538
181113
|
toCSV,
|
|
180539
181114
|
toFixedSafe,
|
|
180540
181115
|
toFreshdeskTicketSummary,
|
|
181116
|
+
toItemMoney,
|
|
180541
181117
|
truncateAnnotationText,
|
|
180542
181118
|
updateDeviceGridStats,
|
|
180543
181119
|
updateFreshdeskTicket,
|
|
@@ -180547,11 +181123,14 @@ var version = package_default.version || "0.0.0";
|
|
|
180547
181123
|
validateDeviceProductName,
|
|
180548
181124
|
validateProfile,
|
|
180549
181125
|
validateTree,
|
|
181126
|
+
valuateDomainMoney,
|
|
181127
|
+
valueDisplayModeStorageKey,
|
|
180550
181128
|
valveHistoryFromTelemetry,
|
|
180551
181129
|
version,
|
|
180552
181130
|
waterDeviceStatusIcons,
|
|
180553
181131
|
wireCategoryToPanel,
|
|
180554
181132
|
wireDomainToPanel,
|
|
180555
181133
|
writeFreshdeskSyncedAtToTB,
|
|
180556
|
-
writeFreshdeskTicketsToTB
|
|
181134
|
+
writeFreshdeskTicketsToTB,
|
|
181135
|
+
writeValueDisplayMode
|
|
180557
181136
|
});
|