myio-js-library 0.1.576 → 0.1.578
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 +1082 -490
- package/dist/index.d.cts +246 -8
- package/dist/index.d.ts +246 -8
- package/dist/index.js +1036 -468
- package/dist/myio-js-library.umd.js +1035 -467
- 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.578",
|
|
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>`;
|
|
@@ -65399,6 +66129,13 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
65399
66129
|
canEditIdentifier() {
|
|
65400
66130
|
return this.isSuperAdmin() || this.config.holdingAdmin === true;
|
|
65401
66131
|
}
|
|
66132
|
+
/**
|
|
66133
|
+
* Campos comerciais (ABL / Contrato / Segmento / Atividade): visíveis para todos,
|
|
66134
|
+
* editáveis só para admin — mesma regra do Identificador (superadmin ou holding admin).
|
|
66135
|
+
*/
|
|
66136
|
+
canEditCommercial() {
|
|
66137
|
+
return this.canEditIdentifier();
|
|
66138
|
+
}
|
|
65402
66139
|
isWellEquipmentDevice() {
|
|
65403
66140
|
return ["CISTERNA", "CISTERNA_ENTRADA"].includes(String(this.config.deviceProfile || "").toUpperCase());
|
|
65404
66141
|
}
|
|
@@ -65424,9 +66161,7 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
65424
66161
|
if (lastUpdatedEl) {
|
|
65425
66162
|
lastUpdatedEl.textContent = formData.lastUpdatedTime ? this.formatTs(formData.lastUpdatedTime) : "\u2014";
|
|
65426
66163
|
}
|
|
65427
|
-
|
|
65428
|
-
this.initCommercialFields(formData);
|
|
65429
|
-
}
|
|
66164
|
+
this.initCommercialFields(formData);
|
|
65430
66165
|
if (!this.config.gcdrDeviceId && formData.gcdrDeviceId) {
|
|
65431
66166
|
this.config.gcdrDeviceId = formData.gcdrDeviceId;
|
|
65432
66167
|
}
|
|
@@ -65856,7 +66591,7 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
65856
66591
|
cancelBtn.disabled = isLoading;
|
|
65857
66592
|
}
|
|
65858
66593
|
formInputs.forEach((input) => {
|
|
65859
|
-
input.disabled = isLoading;
|
|
66594
|
+
input.disabled = isLoading || input.dataset.locked === "true";
|
|
65860
66595
|
});
|
|
65861
66596
|
}
|
|
65862
66597
|
formatDomainLabel(domain) {
|
|
@@ -66146,7 +66881,7 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66146
66881
|
</div>
|
|
66147
66882
|
|
|
66148
66883
|
</div>
|
|
66149
|
-
${this.
|
|
66884
|
+
${this.getCommercialFieldsHTML()}
|
|
66150
66885
|
</div>
|
|
66151
66886
|
|
|
66152
66887
|
<!-- Central/gateway identity+telemetry \u2014 only for CentralSettingsModal (isGateway);
|
|
@@ -66165,12 +66900,14 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66165
66900
|
`;
|
|
66166
66901
|
}
|
|
66167
66902
|
/**
|
|
66168
|
-
* Campos comerciais —
|
|
66169
|
-
*
|
|
66903
|
+
* Campos comerciais — visíveis para todos, editáveis só para admin (canEditCommercial).
|
|
66904
|
+
* Sem permissão: ABL/Contrato readonly (o FormData reenvia o valor carregado, sem mudança)
|
|
66905
|
+
* e selects disabled + data-locked (não entram no FormData → o save não toca segment/activity).
|
|
66170
66906
|
* Linha 1: ABL + Contrato (texto). Linha 2: Segmento → Atividade (selects em cascata,
|
|
66171
66907
|
* opções preenchidas em initCommercialFields após carregar o catálogo).
|
|
66172
66908
|
*/
|
|
66173
66909
|
getCommercialFieldsHTML() {
|
|
66910
|
+
const ro = this.canEditCommercial() ? "" : " readonly";
|
|
66174
66911
|
const customerName = String(
|
|
66175
66912
|
this.config.customerName || window.MyIOUtils?.customerName || ""
|
|
66176
66913
|
).trim();
|
|
@@ -66181,11 +66918,11 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66181
66918
|
<div class="commercial-grid">
|
|
66182
66919
|
<div class="commercial-field">
|
|
66183
66920
|
<label class="identity-field-label" for="abl">ABL</label>
|
|
66184
|
-
<input type="text" id="abl" name="abl" class="identity-input" maxlength="50" placeholder="Ex.: 120,50 m\xB2">
|
|
66921
|
+
<input type="text" id="abl" name="abl" class="identity-input" maxlength="50" placeholder="${ro ? "\u2014" : "Ex.: 120,50 m\xB2"}"${ro}>
|
|
66185
66922
|
</div>
|
|
66186
66923
|
<div class="commercial-field">
|
|
66187
66924
|
<label class="identity-field-label" for="contract">Contrato</label>
|
|
66188
|
-
<input type="text" id="contract" name="contract" class="identity-input" maxlength="100" placeholder="N\xBA / identifica\xE7\xE3o do contrato">
|
|
66925
|
+
<input type="text" id="contract" name="contract" class="identity-input" maxlength="100" placeholder="${ro ? "\u2014" : "N\xBA / identifica\xE7\xE3o do contrato"}"${ro}>
|
|
66189
66926
|
</div>
|
|
66190
66927
|
<div class="commercial-field">
|
|
66191
66928
|
<label class="identity-field-label" for="segment">Segmento</label>
|
|
@@ -66208,25 +66945,31 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
66208
66945
|
const segmentEl = this.modal.querySelector("#segment");
|
|
66209
66946
|
const activityEl = this.modal.querySelector("#activity");
|
|
66210
66947
|
if (!segmentEl || !activityEl) return;
|
|
66211
|
-
const
|
|
66212
|
-
const options = (values, selected, placeholder) => `<option value="">${placeholder}</option>` + values.map((v) => `<option value="${
|
|
66948
|
+
const esc11 = (s) => s.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
66949
|
+
const options = (values, selected, placeholder) => `<option value="">${placeholder}</option>` + values.map((v) => `<option value="${esc11(v)}"${v === selected ? " selected" : ""}>${esc11(v)}</option>`).join("");
|
|
66213
66950
|
const catalog = await loadStoreSegmentCatalog(this.config.segmentCatalog);
|
|
66214
66951
|
const savedSegment = String(saved.segment || "");
|
|
66215
66952
|
const savedActivity = String(saved.activity || "");
|
|
66216
66953
|
const segments = catalog.map((s) => s.segment);
|
|
66217
66954
|
if (savedSegment && !segments.includes(savedSegment)) segments.push(savedSegment);
|
|
66218
|
-
|
|
66219
|
-
segmentEl.
|
|
66955
|
+
const canEdit = this.canEditCommercial();
|
|
66956
|
+
segmentEl.innerHTML = options(segments, savedSegment, canEdit ? "Selecione\u2026" : "\u2014");
|
|
66957
|
+
segmentEl.disabled = !canEdit;
|
|
66220
66958
|
const fillActivities = (segment, selected) => {
|
|
66221
66959
|
if (!segment) {
|
|
66222
|
-
activityEl.innerHTML = options([], "", "Selecione o segmento primeiro");
|
|
66960
|
+
activityEl.innerHTML = options([], "", canEdit ? "Selecione o segmento primeiro" : "\u2014");
|
|
66223
66961
|
activityEl.disabled = true;
|
|
66224
66962
|
return;
|
|
66225
66963
|
}
|
|
66226
|
-
activityEl.innerHTML = options(activitiesForSegment(catalog, segment, selected), selected, "Selecione\u2026");
|
|
66227
|
-
activityEl.disabled =
|
|
66964
|
+
activityEl.innerHTML = options(activitiesForSegment(catalog, segment, selected), selected, canEdit ? "Selecione\u2026" : "\u2014");
|
|
66965
|
+
activityEl.disabled = !canEdit;
|
|
66228
66966
|
};
|
|
66229
66967
|
fillActivities(savedSegment, savedActivity);
|
|
66968
|
+
if (!canEdit) {
|
|
66969
|
+
segmentEl.dataset.locked = "true";
|
|
66970
|
+
activityEl.dataset.locked = "true";
|
|
66971
|
+
return;
|
|
66972
|
+
}
|
|
66230
66973
|
segmentEl.addEventListener("change", () => fillActivities(segmentEl.value, ""));
|
|
66231
66974
|
}
|
|
66232
66975
|
/** RFC-0171: Offset de Temperatura — sempre visível para domain=temperature; editável só para @myio.com.br */
|
|
@@ -67912,7 +68655,7 @@ var SettingsModalView = class _SettingsModalView {
|
|
|
67912
68655
|
cursor: default;
|
|
67913
68656
|
}
|
|
67914
68657
|
|
|
67915
|
-
/* Campos comerciais (s\xF3
|
|
68658
|
+
/* Campos comerciais (vis\xEDveis para todos; edit\xE1veis s\xF3 para admin) */
|
|
67916
68659
|
.commercial-block {
|
|
67917
68660
|
margin-top: 14px;
|
|
67918
68661
|
padding-top: 12px;
|
|
@@ -72692,7 +73435,7 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
72692
73435
|
if (this.metaTipEl) this.metaTipEl.style.display = "none";
|
|
72693
73436
|
}
|
|
72694
73437
|
buildMetaTipHtml(type, card) {
|
|
72695
|
-
const
|
|
73438
|
+
const esc11 = _WelcomeModalView.escapeMetaHtml;
|
|
72696
73439
|
const chip = _WelcomeModalView.metaChip;
|
|
72697
73440
|
const meta = card.metaCounts || {};
|
|
72698
73441
|
const details = card.metaDetails || {};
|
|
@@ -72702,7 +73445,7 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
72702
73445
|
).padStart(2, "0")}:${String(now.getMinutes()).padStart(2, "0")}`;
|
|
72703
73446
|
const frame = (icon2, label, body) => `<div class="myio-welcome-meta-tip__header">
|
|
72704
73447
|
<span class="myio-welcome-meta-tip__icon">${icon2}</span>
|
|
72705
|
-
<span class="myio-welcome-meta-tip__title">${label} (${
|
|
73448
|
+
<span class="myio-welcome-meta-tip__title">${label} (${esc11(card.title)})</span>
|
|
72706
73449
|
<span class="myio-welcome-meta-tip__timestamp">${stamp}</span>
|
|
72707
73450
|
<button type="button" class="myio-welcome-meta-tip__close" title="Fechar">\u2715</button>
|
|
72708
73451
|
</div>
|
|
@@ -72730,8 +73473,8 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
72730
73473
|
const chips = Object.entries(byState).map(([s, n]) => chip(`${s}: ${n}`)).join("");
|
|
72731
73474
|
const rows = alarms.slice(0, 10).map(
|
|
72732
73475
|
(a) => row(
|
|
72733
|
-
|
|
72734
|
-
[a.severity, a.state].filter(Boolean).map(
|
|
73476
|
+
esc11(a.deviceName ? `${a.deviceName} \u2014 ${a.title || "Alarme"}` : a.title || "Alarme"),
|
|
73477
|
+
[a.severity, a.state].filter(Boolean).map(esc11).join(" \xB7 ")
|
|
72735
73478
|
)
|
|
72736
73479
|
).join("");
|
|
72737
73480
|
return frame(
|
|
@@ -72755,7 +73498,7 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
72755
73498
|
const rows = annotations.slice(0, 10).map((a) => {
|
|
72756
73499
|
const when = a.createdAt ? new Date(a.createdAt).toLocaleDateString("pt-BR") : "";
|
|
72757
73500
|
const text2 = a.text.length > 90 ? `${a.text.slice(0, 90)}\u2026` : a.text;
|
|
72758
|
-
return row(
|
|
73501
|
+
return row(esc11(a.deviceLabel || "Dispositivo"), `${esc11(text2)}${when ? ` \xB7 ${esc11(when)}` : ""}`);
|
|
72759
73502
|
}).join("");
|
|
72760
73503
|
return frame(
|
|
72761
73504
|
"\u{1F4CB}",
|
|
@@ -72766,7 +73509,7 @@ var WelcomeModalView = class _WelcomeModalView {
|
|
|
72766
73509
|
if (type === "users") {
|
|
72767
73510
|
if (meta.users === null) return frame("\u{1F465}", "Usu\xE1rios", loadingBody);
|
|
72768
73511
|
const users = details.users || [];
|
|
72769
|
-
const rows = users.slice(0, 10).map((u) => row(
|
|
73512
|
+
const rows = users.slice(0, 10).map((u) => row(esc11(u.name), esc11(u.email || ""))).join("");
|
|
72770
73513
|
return frame(
|
|
72771
73514
|
"\u{1F465}",
|
|
72772
73515
|
"Usu\xE1rios",
|
|
@@ -79477,7 +80220,7 @@ var DefaultSettingsFetcher = class _DefaultSettingsFetcher {
|
|
|
79477
80220
|
"label",
|
|
79478
80221
|
"floor",
|
|
79479
80222
|
"identifier",
|
|
79480
|
-
// Campos comerciais (só
|
|
80223
|
+
// Campos comerciais (visíveis para todos; editáveis só para admin no modal)
|
|
79481
80224
|
"abl",
|
|
79482
80225
|
"contract",
|
|
79483
80226
|
"segment",
|
|
@@ -83132,7 +83875,7 @@ var PRESETS = [
|
|
|
83132
83875
|
{ id: "custom", label: "Personalizado" }
|
|
83133
83876
|
];
|
|
83134
83877
|
var STEPS = ["Dispositivos", "Per\xEDodo", "Telemetrias", "Resumo"];
|
|
83135
|
-
var
|
|
83878
|
+
var esc5 = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
83136
83879
|
var norm = (s) => String(s ?? "").normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase();
|
|
83137
83880
|
var fmtN = (n) => n.toLocaleString("pt-BR");
|
|
83138
83881
|
var pad = (n) => String(n).padStart(2, "0");
|
|
@@ -83520,8 +84263,8 @@ var DemandPanelV2 = class {
|
|
|
83520
84263
|
highlight(text2) {
|
|
83521
84264
|
const q = norm(this.s.search).trim();
|
|
83522
84265
|
const i = q ? norm(text2).indexOf(q) : -1;
|
|
83523
|
-
if (i < 0) return
|
|
83524
|
-
return
|
|
84266
|
+
if (i < 0) return esc5(text2);
|
|
84267
|
+
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
84268
|
}
|
|
83526
84269
|
deviceRow(d, mode) {
|
|
83527
84270
|
const picked = this.s.selected.includes(d.tbDeviceId);
|
|
@@ -83529,13 +84272,13 @@ var DemandPanelV2 = class {
|
|
|
83529
84272
|
const cat = this.categoryOf.get(d.tbDeviceId);
|
|
83530
84273
|
const chip = this.chips.find((c) => c.key === cat);
|
|
83531
84274
|
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="${
|
|
84275
|
+
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
84276
|
return `<div class="dp2-item ${el2.ok ? "" : "blocked"}">
|
|
83534
|
-
<img class="dp2-ico" src="${
|
|
84277
|
+
<img class="dp2-ico" src="${esc5(deviceIconUrl(d.deviceProfile))}" alt="" loading="lazy">
|
|
83535
84278
|
<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) :
|
|
84279
|
+
<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>
|
|
84280
|
+
<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>` : ""}
|
|
84281
|
+
${mode === "result" ? this.highlight(d.name) : esc5(d.name)}${d.identifier ? " \xB7 " + esc5(d.identifier) : ""}</div>
|
|
83539
84282
|
</div>
|
|
83540
84283
|
<div>${action}</div>
|
|
83541
84284
|
</div>`;
|
|
@@ -83553,8 +84296,8 @@ var DemandPanelV2 = class {
|
|
|
83553
84296
|
this.el.body.innerHTML = `<div class="dp2-s1">
|
|
83554
84297
|
<section class="dp2-col" aria-label="Buscar medidores">
|
|
83555
84298
|
<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="${
|
|
84299
|
+
<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">
|
|
84300
|
+
<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
84301
|
<h3><span>${fmtN(results.length)} resultado(s)</span>
|
|
83559
84302
|
<button class="dp2-btn link" type="button" data-action="add-all" ${addable ? "" : "disabled"}>+ Adicionar todos (${addable})</button></h3>
|
|
83560
84303
|
</div>
|
|
@@ -83593,7 +84336,7 @@ var DemandPanelV2 = class {
|
|
|
83593
84336
|
<div class="dp2-card"><h3 tabindex="-1" data-role="step-title">Per\xEDodo</h3>
|
|
83594
84337
|
<div class="dp2-chips" style="margin-bottom:12px">${PRESETS.map((p) => {
|
|
83595
84338
|
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 ${
|
|
84339
|
+
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
84340
|
}).join("")}</div>
|
|
83598
84341
|
<div class="dp2-row">
|
|
83599
84342
|
<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 +84349,24 @@ var DemandPanelV2 = class {
|
|
|
83606
84349
|
const d = limits?.maxDaysByResolution[x.id];
|
|
83607
84350
|
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
84351
|
}).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>${
|
|
84352
|
+
<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)" : ""}.
|
|
84353
|
+
${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
84354
|
${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 ${
|
|
84355
|
+
${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>
|
|
84356
|
+
${fit ? `<button class="dp2-btn sm primary" type="button" data-action="resolution" data-res="${fit}">Usar ${esc5(RESOLUTION_BY_ID[fit].label)}</button>` : ""}
|
|
83614
84357
|
<button class="dp2-btn sm" type="button" data-action="shorten">Encurtar para os \xFAltimos ${maxDays} dia(s)</button></div>` : ""}
|
|
83615
84358
|
${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 ${
|
|
84359
|
+
<button class="dp2-btn sm primary" type="button" data-action="snap-midnight">Come\xE7ar em ${esc5(formatLocalDateTime(localMidnightOf(start)))}</button></div>` : ""}
|
|
83617
84360
|
</div>
|
|
83618
|
-
${otherErrs.length ? `<p class="dp2-err">${otherErrs.map(
|
|
84361
|
+
${otherErrs.length ? `<p class="dp2-err">${otherErrs.map(esc5).join("<br>")}</p>` : ""}`;
|
|
83619
84362
|
}
|
|
83620
84363
|
renderStep3() {
|
|
83621
84364
|
this.el.body.innerHTML = `<div class="dp2-tgrid">${TELEMETRY_GROUPS.map((g) => {
|
|
83622
84365
|
const all = g.items.every((t) => this.s.telemetries.has(t.key));
|
|
83623
|
-
return `<div class="dp2-card"><h3><span>${g.icon} ${
|
|
84366
|
+
return `<div class="dp2-card"><h3><span>${g.icon} ${esc5(g.label)}</span>
|
|
83624
84367
|
<button class="dp2-btn link" type="button" data-action="group-all" data-gid="${g.id}">${all ? "Desmarcar" : "Marcar"} todos</button></h3>
|
|
83625
84368
|
${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
|
-
${
|
|
84369
|
+
${esc5(t.label)}<span class="u">${this.p.supportMode ? esc5(t.key) + " \xB7 " : ""}${esc5(t.unit)}</span></label>`).join("")}
|
|
83627
84370
|
</div>`;
|
|
83628
84371
|
}).join("")}</div>
|
|
83629
84372
|
<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 +84386,14 @@ var DemandPanelV2 = class {
|
|
|
83643
84386
|
let validation = "";
|
|
83644
84387
|
if (v.state === "loading") validation = '<div class="dp2-info">\u23F3 Validando o pedido no servidor\u2026</div>';
|
|
83645
84388
|
else if (v.state === "error") {
|
|
83646
|
-
validation = `<div class="dp2-err">N\xE3o foi poss\xEDvel validar agora: ${
|
|
84389
|
+
validation = `<div class="dp2-err">N\xE3o foi poss\xEDvel validar agora: ${esc5(v.error)}
|
|
83647
84390
|
<button class="dp2-btn link" type="button" data-action="revalidate">Tentar de novo</button></div>`;
|
|
83648
84391
|
} else if (vr) {
|
|
83649
84392
|
const warns = (vr.warnings || []).map((w) => {
|
|
83650
84393
|
const dev = w.deviceId;
|
|
83651
|
-
return `<li>${
|
|
84394
|
+
return `<li>${esc5(warningText(w.code, w.message) + (dev ? this.devicesSuffix({ devices: [{ deviceId: dev }] }) : ""))}</li>`;
|
|
83652
84395
|
}).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 ${
|
|
84396
|
+
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
84397
|
<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
84398
|
validation = `${vr.ok ? '<div class="dp2-info">\u2713 Pedido validado no servidor.</div>' : ""}
|
|
83656
84399
|
${warns ? `<ul class="dp2-info" style="margin:6px 0 0;padding-left:18px">${warns}</ul>` : ""}${reuse}`;
|
|
@@ -83658,12 +84401,12 @@ var DemandPanelV2 = class {
|
|
|
83658
84401
|
this.el.body.innerHTML = `
|
|
83659
84402
|
<div class="dp2-card"><h3 tabindex="-1" data-role="step-title">Resumo do pedido</h3>
|
|
83660
84403
|
<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">${
|
|
84404
|
+
<dt>Solicitante</dt><dd>${esc5(this.p.user.name)}</dd>
|
|
84405
|
+
<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
84406
|
<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 ${
|
|
84407
|
+
<dt>Resolu\xE7\xE3o</dt><dd>${esc5(this.resolutionLabel(req.resolution))} <span class="dp2-info">(${esc5(BUCKET_STATS_LABEL)})</span></dd>
|
|
84408
|
+
<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>
|
|
84409
|
+
${req.telemetries.some((t) => t.key === "consumption") ? `<div class="dp2-info" style="margin-top:4px">Inclui a ${esc5(this.demandLabel())}.</div>` : ""}</dd>
|
|
83667
84410
|
<dt>Tamanho</dt><dd><span class="dp2-size ${cls}">${txt}</span> <span class="dp2-info">\u2248 ${fmtN(pts)} pontos</span>
|
|
83668
84411
|
<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
84412
|
<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 +84414,15 @@ var DemandPanelV2 = class {
|
|
|
83671
84414
|
<div style="margin-top:12px">${validation}</div>
|
|
83672
84415
|
<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
84416
|
</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(
|
|
84417
|
+
${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>` : ""}
|
|
84418
|
+
${errs.length ? `<p class="dp2-err">${errs.map(esc5).join("<br>")}</p>` : ""}`;
|
|
83676
84419
|
}
|
|
83677
84420
|
renderNav() {
|
|
83678
84421
|
const errs = this.stepErrors(this.s.step);
|
|
83679
84422
|
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
84423
|
this.el.nav.innerHTML = `
|
|
83681
84424
|
<button class="dp2-btn" type="button" data-action="back" ${this.s.step === 1 ? "disabled" : ""}>\u2190 Voltar</button>
|
|
83682
|
-
<span class="hint">${
|
|
84425
|
+
<span class="hint">${esc5(hints[this.s.step])}</span>
|
|
83683
84426
|
${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
84427
|
}
|
|
83685
84428
|
jobTitle(e) {
|
|
@@ -83697,7 +84440,7 @@ var DemandPanelV2 = class {
|
|
|
83697
84440
|
return;
|
|
83698
84441
|
}
|
|
83699
84442
|
if (s.listState === "error") {
|
|
83700
|
-
this.el.body.innerHTML = `<div class="dp2-empty">N\xE3o foi poss\xEDvel carregar os relat\xF3rios (${
|
|
84443
|
+
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
84444
|
return;
|
|
83702
84445
|
}
|
|
83703
84446
|
const orphans = this.p.supportMode ? s.active.filter((j) => !s.keys.includes(envelopeKey(j.jobId))) : [];
|
|
@@ -83715,43 +84458,43 @@ var DemandPanelV2 = class {
|
|
|
83715
84458
|
const note = (cls, text2) => `<div class="${cls}" style="margin-top:6px">${text2}</div>`;
|
|
83716
84459
|
const queue = st === "queued" && j?.queue?.position ? ` (N\xBA ${j.queue.position})` : "";
|
|
83717
84460
|
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="${
|
|
84461
|
+
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))}` : ""}` : "";
|
|
84462
|
+
return `<article class="dp2-job" aria-label="${esc5(this.jobTitle(e))}">
|
|
83720
84463
|
<div class="dp2-job-top">
|
|
83721
|
-
<span class="dp2-job-title">${
|
|
84464
|
+
<span class="dp2-job-title">${esc5(this.jobTitle(e))}</span>
|
|
83722
84465
|
<span class="dp2-status ${st}">${JOB_STATE_LABEL[st]}${queue}${st === "running" ? ` ${progress}%` : ""}</span>
|
|
83723
84466
|
<span style="flex:1"></span>
|
|
83724
|
-
<span class="dp2-info">${
|
|
84467
|
+
<span class="dp2-info">${esc5(e.requestedBy.name)} \xB7 ${when(e.requestedAt)}</span>
|
|
83725
84468
|
</div>
|
|
83726
84469
|
${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", `${
|
|
84470
|
+
${st === "queued" && j?.queue?.estimatedStartAt ? note("dp2-info", `In\xEDcio estimado: ${esc5(when(j.queue.estimatedStartAt))}`) : ""}
|
|
84471
|
+
${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>` : ""}`) : ""}
|
|
84472
|
+
${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
84473
|
${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
84474
|
${st === "query_unavailable" ? note("dp2-info", "N\xE3o foi poss\xEDvel consultar o andamento agora \u2014 tentaremos de novo.") : ""}
|
|
83732
84475
|
${st === "old_request" ? note("dp2-info", 'Pedido antigo, sem registro de processamento. Use "Duplicar e editar".') : ""}
|
|
83733
84476
|
${st === "result_expired" ? note("dp2-info", "O relat\xF3rio foi conclu\xEDdo, mas os arquivos j\xE1 expiraram (ficam 3 dias).") : ""}
|
|
83734
84477
|
${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 ${
|
|
84478
|
+
${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
84479
|
${st === "succeeded" && peakTxt ? note("dp2-info", peakTxt) : ""}
|
|
83737
|
-
${st === "succeeded" && j?.expiresAt ? note("dp2-info", `Arquivos dispon\xEDveis at\xE9 ${
|
|
84480
|
+
${st === "succeeded" && j?.expiresAt ? note("dp2-info", `Arquivos dispon\xEDveis at\xE9 ${esc5(when(j.expiresAt))}.`) : ""}
|
|
83738
84481
|
${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
84482
|
<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">${
|
|
84483
|
+
${st === "succeeded" ? `<button class="dp2-btn sm primary" type="button" data-action="download" data-kind="xlsx" data-job="${esc5(e.jobId)}">\u2B07 XLSX</button>
|
|
84484
|
+
<button class="dp2-btn sm" type="button" data-action="download" data-kind="csv" data-job="${esc5(e.jobId)}">CSV</button>
|
|
84485
|
+
<button class="dp2-btn sm" type="button" data-action="download" data-kind="json" data-job="${esc5(e.jobId)}">JSON</button>` : ""}
|
|
84486
|
+
${st === "queued" || st === "running" ? `<button class="dp2-btn sm" type="button" data-action="cancel" data-job="${esc5(e.jobId)}" ${busy}>\u2715 Cancelar</button>` : ""}
|
|
84487
|
+
${v.canResend ? `<button class="dp2-btn sm primary" type="button" data-action="resend" data-job="${esc5(e.jobId)}" ${busy}>\u21BB Reenviar</button>` : ""}
|
|
84488
|
+
${["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>` : ""}
|
|
84489
|
+
${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>` : ""}
|
|
84490
|
+
</div>
|
|
84491
|
+
${this.p.supportMode && s.openDetails.has(e.jobId) ? `<pre class="dp2-json">${esc5(JSON.stringify(e, null, 2))}</pre>` : ""}
|
|
83749
84492
|
</article>`;
|
|
83750
84493
|
}).join("");
|
|
83751
84494
|
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>${
|
|
84495
|
+
<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>
|
|
84496
|
+
<span style="flex:1"></span><span class="dp2-info">${esc5(j.requestedBy?.userId ?? "")} \xB7 ${when(j.createdAt)}</span></div>
|
|
84497
|
+
<div class="dp2-info" style="margin-top:4px"><code>${esc5(j.jobId)}</code></div></article>`).join("");
|
|
83755
84498
|
this.el.body.innerHTML = cards + orphanCards;
|
|
83756
84499
|
}
|
|
83757
84500
|
/* ------------------------------------------------------------------ data flows */
|
|
@@ -84598,6 +85341,7 @@ var groupReportHandler = {
|
|
|
84598
85341
|
} : {};
|
|
84599
85342
|
const theme = visual.palette ?? base.theme;
|
|
84600
85343
|
const customerName = visual.customerName || base.customerName;
|
|
85344
|
+
const money = context.getReportMoney?.(d) || null;
|
|
84601
85345
|
return () => {
|
|
84602
85346
|
openDashboardPopupAllReport({
|
|
84603
85347
|
...base,
|
|
@@ -84606,7 +85350,8 @@ var groupReportHandler = {
|
|
|
84606
85350
|
group: item.id,
|
|
84607
85351
|
itemsList,
|
|
84608
85352
|
...theme ? { theme } : {},
|
|
84609
|
-
...customerName ? { customerName } : {}
|
|
85353
|
+
...customerName ? { customerName } : {},
|
|
85354
|
+
...money ? { money } : {}
|
|
84610
85355
|
});
|
|
84611
85356
|
};
|
|
84612
85357
|
}
|
|
@@ -85141,11 +85886,21 @@ function createDashboardReportsHubContext(opts) {
|
|
|
85141
85886
|
})
|
|
85142
85887
|
};
|
|
85143
85888
|
};
|
|
85889
|
+
const getReportMoney = (domain) => {
|
|
85890
|
+
if (domain === "temperature" || typeof orch.getReportMoney !== "function") return null;
|
|
85891
|
+
try {
|
|
85892
|
+
return orch.getReportMoney(domain) || null;
|
|
85893
|
+
} catch (err) {
|
|
85894
|
+
log.warn("getReportMoney failed:", err?.message || err);
|
|
85895
|
+
return null;
|
|
85896
|
+
}
|
|
85897
|
+
};
|
|
85144
85898
|
return {
|
|
85145
85899
|
domains,
|
|
85146
85900
|
getGroups,
|
|
85147
85901
|
ensureDomainLoaded,
|
|
85148
85902
|
getAllReportBase,
|
|
85903
|
+
getReportMoney,
|
|
85149
85904
|
...validRange || idealRange ? { temperature: { ...validRange ? { validRange } : {}, ...idealRange ? { idealRange } : {} } } : {},
|
|
85150
85905
|
...demandPossible ? { getDemandPanelParams } : {}
|
|
85151
85906
|
};
|
|
@@ -85184,7 +85939,7 @@ var GOAL_DOMAIN_CONFIG = {
|
|
|
85184
85939
|
};
|
|
85185
85940
|
var MONTH_KEYS = Array.from({ length: 12 }, (_, i) => String(i + 1).padStart(2, "0"));
|
|
85186
85941
|
var HOUR_KEYS = Array.from({ length: 24 }, (_, i) => String(i).padStart(2, "0"));
|
|
85187
|
-
var
|
|
85942
|
+
var pad22 = (n) => String(n).padStart(2, "0");
|
|
85188
85943
|
function daysInMonth(year, month) {
|
|
85189
85944
|
if (month === 2) {
|
|
85190
85945
|
const leap = year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
@@ -85198,7 +85953,7 @@ function buildYearOptions() {
|
|
|
85198
85953
|
for (let y = now + 2; y >= now - 2; y--) out.push(y);
|
|
85199
85954
|
return out;
|
|
85200
85955
|
}
|
|
85201
|
-
function
|
|
85956
|
+
function esc6(s) {
|
|
85202
85957
|
return String(s == null ? "" : s).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
85203
85958
|
}
|
|
85204
85959
|
function resolveThemeVars(theme) {
|
|
@@ -85392,7 +86147,7 @@ function openGoalsPanel(params) {
|
|
|
85392
86147
|
function dailyFromTree(tree, monthKey, dayCount) {
|
|
85393
86148
|
const out = {};
|
|
85394
86149
|
for (let d = 1; d <= dayCount; d++) {
|
|
85395
|
-
const dd =
|
|
86150
|
+
const dd = pad22(d);
|
|
85396
86151
|
const node = tree && tree.daily && tree.daily[`${monthKey}-${dd}`];
|
|
85397
86152
|
out[dd] = node && typeof node.value === "number" ? String(node.value) : "";
|
|
85398
86153
|
}
|
|
@@ -85442,7 +86197,7 @@ function openGoalsPanel(params) {
|
|
|
85442
86197
|
if (state6.level === "month") return MONTH_KEYS;
|
|
85443
86198
|
if (state6.level === "day") {
|
|
85444
86199
|
const c = state6.selectedMonth ? daysInMonth(state6.year, Number(state6.selectedMonth)) : 0;
|
|
85445
|
-
return Array.from({ length: c }, (_, i) =>
|
|
86200
|
+
return Array.from({ length: c }, (_, i) => pad22(i + 1));
|
|
85446
86201
|
}
|
|
85447
86202
|
return HOUR_KEYS;
|
|
85448
86203
|
}
|
|
@@ -85668,7 +86423,7 @@ function openGoalsPanel(params) {
|
|
|
85668
86423
|
const dayValue = avg ? 22 : 3200;
|
|
85669
86424
|
const hourValue = avg ? 22 : 150;
|
|
85670
86425
|
const lines = ["bucket,value"];
|
|
85671
|
-
for (let m = 1; m <= 12; m++) lines.push(`${state6.year}-${
|
|
86426
|
+
for (let m = 1; m <= 12; m++) lines.push(`${state6.year}-${pad22(m)},${monthlyValue}`);
|
|
85672
86427
|
lines.push(`${state6.year}-03-15,${dayValue}`);
|
|
85673
86428
|
lines.push(`${state6.year}-03-15T08,${hourValue}`);
|
|
85674
86429
|
return lines.join("\n");
|
|
@@ -85677,7 +86432,7 @@ function openGoalsPanel(params) {
|
|
|
85677
86432
|
const value = sampleHourValue();
|
|
85678
86433
|
const day = `${state6.year}-03-15`;
|
|
85679
86434
|
const lines = ["bucket,value"];
|
|
85680
|
-
for (let h3 = 0; h3 < 24; h3++) lines.push(`${day}T${
|
|
86435
|
+
for (let h3 = 0; h3 < 24; h3++) lines.push(`${day}T${pad22(h3)},${value}`);
|
|
85681
86436
|
return lines.join("\n");
|
|
85682
86437
|
}
|
|
85683
86438
|
function downloadCsv(csv, suffix) {
|
|
@@ -86014,13 +86769,13 @@ function openGoalsPanel(params) {
|
|
|
86014
86769
|
const g = state6.goals || {};
|
|
86015
86770
|
const parts = [];
|
|
86016
86771
|
if (hasCoverageGaps(g.coverageGaps)) {
|
|
86017
|
-
parts.push(`<p style="margin:0 0 8px;">${
|
|
86772
|
+
parts.push(`<p style="margin:0 0 8px;">${esc6(buildCoverageWarningTextPtBR(g.coverageGaps, "GERAL"))}</p>`);
|
|
86018
86773
|
}
|
|
86019
86774
|
(Array.isArray(g.devices) ? g.devices : []).forEach((d) => {
|
|
86020
86775
|
if (!hasCoverageGaps(d && d.coverageGaps)) return;
|
|
86021
86776
|
const label = d.label || d.code || "medidor";
|
|
86022
86777
|
parts.push(
|
|
86023
|
-
`<p style="margin:0 0 8px;">${
|
|
86778
|
+
`<p style="margin:0 0 8px;">${esc6(buildCoverageWarningTextPtBR(d.coverageGaps, `do medidor ${label}`))}</p>`
|
|
86024
86779
|
);
|
|
86025
86780
|
});
|
|
86026
86781
|
return `<div style="font-size:12px;line-height:1.55;color:#334155;">${parts.join("")}</div>`;
|
|
@@ -86060,7 +86815,7 @@ function openGoalsPanel(params) {
|
|
|
86060
86815
|
html += `<div class="myio-goals-alert myio-goals-alert-amber">${icon2("alert")} ${i18n2.versionConflict}</div>`;
|
|
86061
86816
|
}
|
|
86062
86817
|
if (state6.saveError && !state6.conflict) {
|
|
86063
|
-
html += `<div class="myio-goals-alert myio-goals-alert-red">${icon2("alert")} ${
|
|
86818
|
+
html += `<div class="myio-goals-alert myio-goals-alert-red">${icon2("alert")} ${esc6(state6.saveError)}</div>`;
|
|
86064
86819
|
}
|
|
86065
86820
|
if (state6.saved && !state6.saveError) {
|
|
86066
86821
|
html += `<div class="myio-goals-alert myio-goals-alert-green">${icon2("check")} ${i18n2.saveSuccess}</div>`;
|
|
@@ -86075,7 +86830,7 @@ function openGoalsPanel(params) {
|
|
|
86075
86830
|
return `
|
|
86076
86831
|
<div class="myio-goals-center myio-goals-center-col">
|
|
86077
86832
|
${icon2("alert-lg")}
|
|
86078
|
-
<p>${
|
|
86833
|
+
<p>${esc6(state6.error)}</p>
|
|
86079
86834
|
<button class="myio-goals-btn myio-goals-btn-outline" data-action="retry">${i18n2.retry}</button>
|
|
86080
86835
|
</div>`;
|
|
86081
86836
|
}
|
|
@@ -86165,7 +86920,7 @@ function openGoalsPanel(params) {
|
|
|
86165
86920
|
const cellLabel = state6.level === "month" ? i18n2.months[key] : state6.level === "day" ? i18n2.dayCell.replace("{day}", Number(key)) : `${key}:00`;
|
|
86166
86921
|
const canDrill = state6.level !== "hour";
|
|
86167
86922
|
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 ?
|
|
86923
|
+
const val = state6.draft[key] !== void 0 ? esc6(state6.draft[key]) : "";
|
|
86169
86924
|
const minAttr = cfg.allowsNegative ? "" : 'min="0"';
|
|
86170
86925
|
return `
|
|
86171
86926
|
<div class="myio-goals-cell">
|
|
@@ -86233,7 +86988,7 @@ function openGoalsPanel(params) {
|
|
|
86233
86988
|
const actor = ev.actor ? `${String(ev.actor).slice(0, 8)}\u2026` : i18n2.history.system;
|
|
86234
86989
|
const extra = ev.bucketCount - (ev.details ? ev.details.length : 0);
|
|
86235
86990
|
const chips = (ev.details || []).slice(0, DETAIL_PREVIEW).map(
|
|
86236
|
-
(d) => `<span class="myio-goals-tl-chip"><span class="myio-goals-tl-ref">${
|
|
86991
|
+
(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
86992
|
).join("");
|
|
86238
86993
|
const more = extra > 0 ? `<span class="myio-goals-tl-more">${i18n2.history.moreDetails.replace("{n}", extra)}</span>` : "";
|
|
86239
86994
|
return `
|
|
@@ -86243,7 +86998,7 @@ function openGoalsPanel(params) {
|
|
|
86243
86998
|
<span class="myio-goals-tl-title">${i18n2.history.source[ev.source] || i18n2.history.source.EDIT}</span>
|
|
86244
86999
|
<span class="myio-goals-tl-ver">v${ev.version}</span>
|
|
86245
87000
|
</div>
|
|
86246
|
-
<p class="myio-goals-tl-meta" title="${
|
|
87001
|
+
<p class="myio-goals-tl-meta" title="${esc6(new Date(ev.changedAt).toLocaleString(locale))}">${esc6(actor)} \xB7 ${esc6(timeAgo(ev.changedAt))}</p>
|
|
86247
87002
|
<p class="myio-goals-tl-records">${i18n2.history.records.replace("{n}", ev.bucketCount)} \xB7 ${i18n2.levels[ev.actionLevel] || ev.actionLevel}</p>
|
|
86248
87003
|
${chips || more ? `<div class="myio-goals-tl-chips">${chips}${more}</div>` : ""}
|
|
86249
87004
|
</li>`;
|
|
@@ -86290,7 +87045,7 @@ ${state6.year}-03-15T08,15`;
|
|
|
86290
87045
|
let html = `
|
|
86291
87046
|
<div class="myio-goals-import-hint">
|
|
86292
87047
|
<p>${i18n2.import.formatHint}</p>
|
|
86293
|
-
<code>${
|
|
87048
|
+
<code>${esc6(sample)}</code>
|
|
86294
87049
|
</div>`;
|
|
86295
87050
|
if (!applied) {
|
|
86296
87051
|
html += `
|
|
@@ -86304,16 +87059,16 @@ ${state6.year}-03-15T08,15`;
|
|
|
86304
87059
|
<input type="file" id="myio-goals-csv-file" accept=".csv,.txt,text/csv,text/plain" style="display:none" />
|
|
86305
87060
|
</div>
|
|
86306
87061
|
</div>
|
|
86307
|
-
<textarea id="myio-goals-csv-textarea" rows="8" spellcheck="false" placeholder="${
|
|
87062
|
+
<textarea id="myio-goals-csv-textarea" rows="8" spellcheck="false" placeholder="${esc6(`bucket,value
|
|
86308
87063
|
${state6.year},100000
|
|
86309
87064
|
${state6.year}-03,9000
|
|
86310
87065
|
${state6.year}-03-15,310
|
|
86311
|
-
${state6.year}-03-15T08,15`)}">${
|
|
87066
|
+
${state6.year}-03-15T08,15`)}">${esc6(state6.csv)}</textarea>
|
|
86312
87067
|
<p class="myio-goals-microhint">${i18n2.import.unitNote.replace("{unit}", unitLabel2())}</p>
|
|
86313
87068
|
</div>`;
|
|
86314
87069
|
}
|
|
86315
87070
|
if (state6.saveError && state6.conflictVersion === null) {
|
|
86316
|
-
html += `<div class="myio-goals-alert myio-goals-alert-red">${icon2("alert")} ${
|
|
87071
|
+
html += `<div class="myio-goals-alert myio-goals-alert-red">${icon2("alert")} ${esc6(state6.saveError)}</div>`;
|
|
86317
87072
|
}
|
|
86318
87073
|
if (state6.conflictVersion !== null) {
|
|
86319
87074
|
html += `<div class="myio-goals-alert myio-goals-alert-amber">${icon2("alert")} ${i18n2.import.conflict}</div>`;
|
|
@@ -86342,7 +87097,7 @@ ${state6.year}-03-15T08,15`)}">${esc5(state6.csv)}</textarea>
|
|
|
86342
87097
|
<div class="myio-goals-import-diags">
|
|
86343
87098
|
<p class="myio-goals-import-diags-title">${i18n2.import.diagnosticsTitle}</p>
|
|
86344
87099
|
<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">[${
|
|
87100
|
+
(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
87101
|
).join("")}</ul>
|
|
86347
87102
|
</div>`;
|
|
86348
87103
|
}
|
|
@@ -86350,7 +87105,7 @@ ${state6.year}-03-15T08,15`)}">${esc5(state6.csv)}</textarea>
|
|
|
86350
87105
|
html += `
|
|
86351
87106
|
<div class="myio-goals-import-log">
|
|
86352
87107
|
<p class="myio-goals-import-log-title">${i18n2.import.logTitle}</p>
|
|
86353
|
-
<ul>${result.log.map((line) => `<li>${
|
|
87108
|
+
<ul>${result.log.map((line) => `<li>${esc6(line)}</li>`).join("")}</ul>
|
|
86354
87109
|
</div>`;
|
|
86355
87110
|
}
|
|
86356
87111
|
html += `</div>`;
|
|
@@ -93388,7 +94143,7 @@ function injectCSS10() {
|
|
|
93388
94143
|
document.head.appendChild(style);
|
|
93389
94144
|
_cssInjected2 = true;
|
|
93390
94145
|
}
|
|
93391
|
-
function
|
|
94146
|
+
function esc7(value) {
|
|
93392
94147
|
return String(value == null ? "" : value).replace(
|
|
93393
94148
|
/[&<>"]/g,
|
|
93394
94149
|
(c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]
|
|
@@ -93438,7 +94193,7 @@ function buildPieSvg(visible, total) {
|
|
|
93438
94193
|
const val = Number(v.d.value) || 0;
|
|
93439
94194
|
return `<svg class="myio-col-summary__pie" viewBox="0 0 220 220">
|
|
93440
94195
|
<circle class="myio-col-summary__slice" data-idx="${v.idx}" cx="110" cy="110" r="100"
|
|
93441
|
-
fill="${sliceColor(v.idx)}"><title>${
|
|
94196
|
+
fill="${sliceColor(v.idx)}"><title>${esc7(v.d.name)} \u2014 ${esc7(fmt2(val))} (${fmtPct2(
|
|
93442
94197
|
val,
|
|
93443
94198
|
total,
|
|
93444
94199
|
pd
|
|
@@ -93453,7 +94208,7 @@ function buildPieSvg(visible, total) {
|
|
|
93453
94208
|
const a1 = acc / total * 360;
|
|
93454
94209
|
return `<path class="myio-col-summary__slice" data-idx="${v.idx}"
|
|
93455
94210
|
d="${arcPath(110, 110, 100, a0, a1)}" fill="${sliceColor(v.idx)}"
|
|
93456
|
-
><title>${
|
|
94211
|
+
><title>${esc7(v.d.name)} \u2014 ${esc7(fmt2(val))} (${fmtPct2(val, total, pd)})</title></path>`;
|
|
93457
94212
|
}).join("");
|
|
93458
94213
|
return `<svg class="myio-col-summary__pie" viewBox="0 0 220 220">${paths}</svg>`;
|
|
93459
94214
|
}
|
|
@@ -93467,8 +94222,8 @@ function buildLegend(total) {
|
|
|
93467
94222
|
return `<div class="myio-col-summary__legend-row${isExcl ? " is-excluded" : ""}" data-idx="${idx}"
|
|
93468
94223
|
title="Clique para ${isExcl ? "incluir" : "remover"} da pizza">
|
|
93469
94224
|
<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">${
|
|
94225
|
+
<span class="myio-col-summary__legend-name">${esc7(d.name)}</span>
|
|
94226
|
+
<span class="myio-col-summary__legend-val">${esc7(fmt2(val))}</span>
|
|
93472
94227
|
<span class="myio-col-summary__legend-pct">${pct}</span>
|
|
93473
94228
|
</div>`;
|
|
93474
94229
|
}).join("");
|
|
@@ -93489,25 +94244,25 @@ function buildAverageInner() {
|
|
|
93489
94244
|
const dash = "\u2014";
|
|
93490
94245
|
const periodRow = data.periodLabel ? `<div class="myio-col-summary__kpi">
|
|
93491
94246
|
<span class="myio-col-summary__kpi-label">Per\xEDodo</span>
|
|
93492
|
-
<span class="myio-col-summary__kpi-value">${
|
|
94247
|
+
<span class="myio-col-summary__kpi-value">${esc7(data.periodLabel)}</span>
|
|
93493
94248
|
</div>` : "";
|
|
93494
94249
|
const note = "M\xE9dia, m\xEDnima e m\xE1xima consideram apenas dispositivos online (com leitura).";
|
|
93495
94250
|
const kpis = `<div class="myio-col-summary__kpis">
|
|
93496
94251
|
${periodRow}
|
|
93497
94252
|
<div class="myio-col-summary__kpi">
|
|
93498
94253
|
<span class="myio-col-summary__kpi-label">Dispositivos
|
|
93499
|
-
<span class="myio-col-summary__info" title="${
|
|
94254
|
+
<span class="myio-col-summary__info" title="${esc7(note)}" aria-label="${esc7(note)}"
|
|
93500
94255
|
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
94256
|
</span>
|
|
93502
94257
|
<span class="myio-col-summary__kpi-value">${online.length} online \xB7 ${offline.length} offline</span>
|
|
93503
94258
|
</div>
|
|
93504
94259
|
<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 :
|
|
94260
|
+
<span class="myio-col-summary__kpi-label">${esc7(measure)} m\xE9dia</span>
|
|
94261
|
+
<span class="myio-col-summary__kpi-value myio-col-summary__kpi-value--accent">${avg === null ? dash : esc7(fmt2(avg))}</span>
|
|
93507
94262
|
</div>
|
|
93508
94263
|
<div class="myio-col-summary__kpi">
|
|
93509
94264
|
<span class="myio-col-summary__kpi-label">M\xEDnima \xB7 M\xE1xima</span>
|
|
93510
|
-
<span class="myio-col-summary__kpi-value">${minV ?
|
|
94265
|
+
<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
94266
|
</div>
|
|
93512
94267
|
</div>`;
|
|
93513
94268
|
if (!data.devices.length) {
|
|
@@ -93516,12 +94271,12 @@ function buildAverageInner() {
|
|
|
93516
94271
|
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
94272
|
const row = (v) => `
|
|
93518
94273
|
<div class="myio-col-summary__row">
|
|
93519
|
-
<span class="myio-col-summary__name" title="${
|
|
93520
|
-
<span class="myio-col-summary__val">${
|
|
94274
|
+
<span class="myio-col-summary__name" title="${esc7(v.d.name)}">${esc7(v.d.name)}</span>
|
|
94275
|
+
<span class="myio-col-summary__val">${esc7(fmt2(Number(v.d.value) || 0))}</span>
|
|
93521
94276
|
</div>`;
|
|
93522
94277
|
const offRow = (v) => `
|
|
93523
94278
|
<div class="myio-col-summary__row">
|
|
93524
|
-
<span class="myio-col-summary__name" title="${
|
|
94279
|
+
<span class="myio-col-summary__name" title="${esc7(v.d.name)}">${esc7(v.d.name)}</span>
|
|
93525
94280
|
<span class="myio-col-summary__val" style="color:#94a3b8;">sem leitura</span>
|
|
93526
94281
|
</div>`;
|
|
93527
94282
|
const group = (label, list, r = row) => list.length ? `<div class="myio-col-summary__group">
|
|
@@ -93538,8 +94293,8 @@ function buildAverageInner() {
|
|
|
93538
94293
|
</div>
|
|
93539
94294
|
</div>
|
|
93540
94295
|
<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 :
|
|
94296
|
+
<span class="myio-col-summary__footer-label">${esc7(measure)} m\xE9dia \xB7 ${online.length} online</span>
|
|
94297
|
+
<span class="myio-col-summary__footer-value">${avg === null ? dash : esc7(fmt2(avg))}</span>
|
|
93543
94298
|
</div>`;
|
|
93544
94299
|
}
|
|
93545
94300
|
function buildInner() {
|
|
@@ -93552,7 +94307,7 @@ function buildInner() {
|
|
|
93552
94307
|
const avg = count ? total / count : 0;
|
|
93553
94308
|
const periodRow = data.periodLabel ? `<div class="myio-col-summary__kpi">
|
|
93554
94309
|
<span class="myio-col-summary__kpi-label">Per\xEDodo</span>
|
|
93555
|
-
<span class="myio-col-summary__kpi-value">${
|
|
94310
|
+
<span class="myio-col-summary__kpi-value">${esc7(data.periodLabel)}</span>
|
|
93556
94311
|
</div>` : "";
|
|
93557
94312
|
const kpis = `<div class="myio-col-summary__kpis">
|
|
93558
94313
|
${periodRow}
|
|
@@ -93562,13 +94317,13 @@ function buildInner() {
|
|
|
93562
94317
|
</div>
|
|
93563
94318
|
<div class="myio-col-summary__kpi">
|
|
93564
94319
|
<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">${
|
|
94320
|
+
<span class="myio-col-summary__kpi-value myio-col-summary__kpi-value--accent">${esc7(
|
|
93566
94321
|
fmt2(avg)
|
|
93567
94322
|
)}</span>
|
|
93568
94323
|
</div>
|
|
93569
94324
|
<div class="myio-col-summary__kpi">
|
|
93570
94325
|
<span class="myio-col-summary__kpi-label">Consumo total</span>
|
|
93571
|
-
<span class="myio-col-summary__kpi-value">${
|
|
94326
|
+
<span class="myio-col-summary__kpi-value">${esc7(fmt2(total))}</span>
|
|
93572
94327
|
</div>
|
|
93573
94328
|
</div>`;
|
|
93574
94329
|
if (!data.devices.length) {
|
|
@@ -93582,8 +94337,8 @@ function buildInner() {
|
|
|
93582
94337
|
).slice(0, 3);
|
|
93583
94338
|
const row = (v) => `
|
|
93584
94339
|
<div class="myio-col-summary__row">
|
|
93585
|
-
<span class="myio-col-summary__name" title="${
|
|
93586
|
-
<span class="myio-col-summary__val">${
|
|
94340
|
+
<span class="myio-col-summary__name" title="${esc7(v.d.name)}">${esc7(v.d.name)}</span>
|
|
94341
|
+
<span class="myio-col-summary__val">${esc7(fmt2(Number(v.d.value) || 0))}</span>
|
|
93587
94342
|
<span class="myio-col-summary__pct">${fmtPct2(Number(v.d.value) || 0, total, pd)}</span>
|
|
93588
94343
|
</div>`;
|
|
93589
94344
|
const group = (label, list) => list.length ? `<div class="myio-col-summary__group">
|
|
@@ -93606,7 +94361,7 @@ function buildInner() {
|
|
|
93606
94361
|
</div>
|
|
93607
94362
|
<div class="myio-col-summary__footer">
|
|
93608
94363
|
<span class="myio-col-summary__footer-label">Consumo Total \xB7 ${count} dispositivos</span>
|
|
93609
|
-
<span class="myio-col-summary__footer-value">${
|
|
94364
|
+
<span class="myio-col-summary__footer-value">${esc7(fmt2(total))}</span>
|
|
93610
94365
|
</div>`;
|
|
93611
94366
|
}
|
|
93612
94367
|
function setHighlight(idx) {
|
|
@@ -101386,7 +102141,7 @@ function injectStyles12(doc) {
|
|
|
101386
102141
|
`;
|
|
101387
102142
|
(doc.head || doc.documentElement).appendChild(s);
|
|
101388
102143
|
}
|
|
101389
|
-
function
|
|
102144
|
+
function esc8(v) {
|
|
101390
102145
|
return String(v ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
101391
102146
|
}
|
|
101392
102147
|
function fmtPct3(pct) {
|
|
@@ -101407,8 +102162,8 @@ function renderDeltaChip(delta) {
|
|
|
101407
102162
|
const tone = delta.tone === "good" ? "good" : delta.tone === "bad" ? "bad" : "neutral";
|
|
101408
102163
|
const arrow = delta.arrow === "up" ? "\u2191" : delta.arrow === "down" ? "\u2193" : "\u2248";
|
|
101409
102164
|
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} ${
|
|
102165
|
+
const txt = delta.text ? ` ${esc8(delta.text)}` : "";
|
|
102166
|
+
return `<span class="myio-gbt__chip myio-gbt__chip--${tone}">${arrow} ${esc8(pctTxt)}${txt}</span>`;
|
|
101412
102167
|
}
|
|
101413
102168
|
function renderRow(row, level) {
|
|
101414
102169
|
const hasChildren = Array.isArray(row.children) && row.children.length > 0;
|
|
@@ -101416,12 +102171,12 @@ function renderRow(row, level) {
|
|
|
101416
102171
|
const id = `gbtr-${++_rowSeq}`;
|
|
101417
102172
|
const pct = row.pct;
|
|
101418
102173
|
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">${
|
|
102174
|
+
const swatch = row.color ? `<span class="myio-gbt__swatch" style="background:${esc8(row.color)}"></span>` : "";
|
|
102175
|
+
const icon2 = row.icon ? `<span class="myio-gbt__icon">${esc8(row.icon)}</span>` : "";
|
|
101421
102176
|
const chipHtml = row.delta ? renderDeltaChip(row.delta) : "";
|
|
101422
|
-
const pctHtml = !row.delta && pct != null && isFinite(pct) ? `<span class="myio-gbt__pct">${
|
|
102177
|
+
const pctHtml = !row.delta && pct != null && isFinite(pct) ? `<span class="myio-gbt__pct">${esc8(fmtPct3(pct))}</span>` : "";
|
|
101423
102178
|
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">${
|
|
102179
|
+
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
102180
|
if (hasChildren) {
|
|
101426
102181
|
const childHtml = row.children.map((c) => renderRow(c, level + 1)).join("");
|
|
101427
102182
|
html += `<div class="myio-gbt__children${open ? " is-open" : ""}" data-children="${id}">${childHtml}</div>`;
|
|
@@ -101504,8 +102259,8 @@ function createGoalsBarTooltip(opts) {
|
|
|
101504
102259
|
<div class="myio-gbt__card">
|
|
101505
102260
|
<div class="myio-gbt__header">
|
|
101506
102261
|
<div class="myio-gbt__title-wrap">
|
|
101507
|
-
<div class="myio-gbt__title">${
|
|
101508
|
-
${data.subtitle ? `<div class="myio-gbt__subtitle">${
|
|
102262
|
+
<div class="myio-gbt__title">${esc8(data.title)}</div>
|
|
102263
|
+
${data.subtitle ? `<div class="myio-gbt__subtitle">${esc8(data.subtitle)}</div>` : ""}
|
|
101509
102264
|
</div>
|
|
101510
102265
|
<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
102266
|
<button class="myio-gbt__btn myio-gbt__btn--close" data-action="close" title="Fechar">\u2715</button>
|
|
@@ -102514,19 +103269,19 @@ function _updateCoverageHint(topDoc) {
|
|
|
102514
103269
|
const deviceCount = data.granularity === "DEVICE" ? data.devices?.length ?? 0 : 0;
|
|
102515
103270
|
hint.textContent = `\u26A0 Meta incompleta para este dom\xEDnio/ano` + (deviceCount > 0 ? ` \xB7 Por medidor (${deviceCount})` : "") + ` \u2014 passe o mouse para detalhes`;
|
|
102516
103271
|
tabs.insertAdjacentElement("afterend", hint);
|
|
102517
|
-
const
|
|
103272
|
+
const esc11 = (s) => String(s ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
102518
103273
|
try {
|
|
102519
103274
|
_coverageDetach = InfoTooltip.attach(hint, () => {
|
|
102520
103275
|
const d = _getGoalsData(_currentDomain);
|
|
102521
103276
|
const parts = [];
|
|
102522
103277
|
if (hasCoverageGaps(d?.coverageGaps)) {
|
|
102523
|
-
parts.push(`<p style="margin:0 0 8px;">${
|
|
103278
|
+
parts.push(`<p style="margin:0 0 8px;">${esc11(buildCoverageWarningTextPtBR(d?.coverageGaps, "GERAL"))}</p>`);
|
|
102524
103279
|
}
|
|
102525
103280
|
(d?.devices || []).forEach((dev) => {
|
|
102526
103281
|
if (!hasCoverageGaps(dev?.coverageGaps)) return;
|
|
102527
103282
|
const label = dev.label || dev.code || "medidor";
|
|
102528
103283
|
parts.push(
|
|
102529
|
-
`<p style="margin:0 0 8px;">${
|
|
103284
|
+
`<p style="margin:0 0 8px;">${esc11(buildCoverageWarningTextPtBR(dev.coverageGaps, `do medidor ${label}`))}</p>`
|
|
102530
103285
|
);
|
|
102531
103286
|
});
|
|
102532
103287
|
return {
|
|
@@ -105680,7 +106435,7 @@ function parseBRL(raw) {
|
|
|
105680
106435
|
const n = Number(s);
|
|
105681
106436
|
return Number.isFinite(n) ? n : NaN;
|
|
105682
106437
|
}
|
|
105683
|
-
function
|
|
106438
|
+
function pad23(n) {
|
|
105684
106439
|
return String(n).padStart(2, "0");
|
|
105685
106440
|
}
|
|
105686
106441
|
function daysInMonth2(periodKey2) {
|
|
@@ -105691,7 +106446,7 @@ function entryBounds(entry) {
|
|
|
105691
106446
|
if (entry.periodType === "month") {
|
|
105692
106447
|
if (!entry.periodKey || !/^\d{4}-\d{2}$/.test(entry.periodKey)) return null;
|
|
105693
106448
|
const last = daysInMonth2(entry.periodKey);
|
|
105694
|
-
return { start: `${entry.periodKey}-01`, end: `${entry.periodKey}-${
|
|
106449
|
+
return { start: `${entry.periodKey}-01`, end: `${entry.periodKey}-${pad23(last)}` };
|
|
105695
106450
|
}
|
|
105696
106451
|
if (entry.periodType === "range") {
|
|
105697
106452
|
if (!entry.start || !entry.end) return null;
|
|
@@ -106226,6 +106981,13 @@ function tariffQuery(sel, granularity) {
|
|
|
106226
106981
|
if (granularity) qs.set("granularity", granularity);
|
|
106227
106982
|
return qs.toString();
|
|
106228
106983
|
}
|
|
106984
|
+
function unwrapGcdrEnvelope(body) {
|
|
106985
|
+
if (body && typeof body === "object" && !Array.isArray(body)) {
|
|
106986
|
+
const b = body;
|
|
106987
|
+
if (b.success === true && b.data && typeof b.data === "object") return b.data;
|
|
106988
|
+
}
|
|
106989
|
+
return body;
|
|
106990
|
+
}
|
|
106229
106991
|
function parseETagVersion(headers) {
|
|
106230
106992
|
const raw = headers.get("ETag") || headers.get("etag");
|
|
106231
106993
|
if (!raw) return void 0;
|
|
@@ -106269,7 +107031,7 @@ var TariffApiClient = class {
|
|
|
106269
107031
|
const body = await this.readBody(res);
|
|
106270
107032
|
if (!res.ok) throw this.toError(res, body);
|
|
106271
107033
|
const etagVersion = parseETagVersion(res.headers);
|
|
106272
|
-
const parsed = body || {};
|
|
107034
|
+
const parsed = unwrapGcdrEnvelope(body) || {};
|
|
106273
107035
|
return {
|
|
106274
107036
|
customerId: sel.customerId,
|
|
106275
107037
|
domain: sel.domain,
|
|
@@ -106317,7 +107079,8 @@ var TariffApiClient = class {
|
|
|
106317
107079
|
const body = await this.readBody(res);
|
|
106318
107080
|
if (!res.ok) throw this.toError(res, body);
|
|
106319
107081
|
const etagVersion = parseETagVersion(res.headers);
|
|
106320
|
-
const
|
|
107082
|
+
const data = unwrapGcdrEnvelope(body);
|
|
107083
|
+
const v = (data && data.version) ?? etagVersion;
|
|
106321
107084
|
return typeof v === "number" ? { version: v } : {};
|
|
106322
107085
|
}
|
|
106323
107086
|
async write(method, sel, body, expectedVersion) {
|
|
@@ -106336,7 +107099,8 @@ var TariffApiClient = class {
|
|
|
106336
107099
|
const parsed = await this.readBody(res);
|
|
106337
107100
|
if (!res.ok) throw this.toError(res, parsed);
|
|
106338
107101
|
const etagVersion = parseETagVersion(res.headers);
|
|
106339
|
-
const
|
|
107102
|
+
const data = unwrapGcdrEnvelope(parsed);
|
|
107103
|
+
const v = (data && data.version) ?? etagVersion;
|
|
106340
107104
|
return { version: typeof v === "number" ? v : (expectedVersion ?? 0) + 1 };
|
|
106341
107105
|
}
|
|
106342
107106
|
async readBody(res) {
|
|
@@ -106431,7 +107195,7 @@ function daysInMonthYear(year, month) {
|
|
|
106431
107195
|
if (month === 2 && isLeapYear(year)) return 29;
|
|
106432
107196
|
return MONTH_DAYS[month - 1];
|
|
106433
107197
|
}
|
|
106434
|
-
function
|
|
107198
|
+
function pad24(n) {
|
|
106435
107199
|
return String(n).padStart(2, "0");
|
|
106436
107200
|
}
|
|
106437
107201
|
function assertValidCivilDate(date) {
|
|
@@ -106442,7 +107206,7 @@ function assertValidCivilDate(date) {
|
|
|
106442
107206
|
const d = Number(m[3]);
|
|
106443
107207
|
if (mo < 1 || mo > 12) throw new Error(`Invalid month in date: ${date}`);
|
|
106444
107208
|
if (d < 1 || d > daysInMonthYear(y, mo)) {
|
|
106445
|
-
throw new Error(`Invalid day for ${y}-${
|
|
107209
|
+
throw new Error(`Invalid day for ${y}-${pad24(mo)} (leap=${isLeapYear(y)}): ${date}`);
|
|
106446
107210
|
}
|
|
106447
107211
|
}
|
|
106448
107212
|
function* eachDate(start, end) {
|
|
@@ -106451,7 +107215,7 @@ function* eachDate(start, end) {
|
|
|
106451
107215
|
const t1 = Date.UTC(ye, me - 1, de);
|
|
106452
107216
|
for (let t = Date.UTC(ys, ms - 1, ds); t <= t1; t += 864e5) {
|
|
106453
107217
|
const dt = new Date(t);
|
|
106454
|
-
yield `${dt.getUTCFullYear()}-${
|
|
107218
|
+
yield `${dt.getUTCFullYear()}-${pad24(dt.getUTCMonth() + 1)}-${pad24(dt.getUTCDate())}`;
|
|
106455
107219
|
}
|
|
106456
107220
|
}
|
|
106457
107221
|
function normalizeBand(input) {
|
|
@@ -106515,7 +107279,7 @@ function bandToPanelEntry(band, customerId) {
|
|
|
106515
107279
|
function expandDayToHourBuckets(date, price) {
|
|
106516
107280
|
assertValidCivilDate(date);
|
|
106517
107281
|
const out = [];
|
|
106518
|
-
for (let h3 = 0; h3 < 24; h3++) out.push({ level: "HOUR", ref: `${date}T${
|
|
107282
|
+
for (let h3 = 0; h3 < 24; h3++) out.push({ level: "HOUR", ref: `${date}T${pad24(h3)}`, price });
|
|
106519
107283
|
return out;
|
|
106520
107284
|
}
|
|
106521
107285
|
function expandBandHours(date, startHour, endHour, price) {
|
|
@@ -106524,7 +107288,7 @@ function expandBandHours(date, startHour, endHour, price) {
|
|
|
106524
107288
|
throw new Error(`Invalid hour band ${startHour}-${endHour} for ${date}`);
|
|
106525
107289
|
}
|
|
106526
107290
|
const out = [];
|
|
106527
|
-
for (let h3 = startHour; h3 <= endHour; h3++) out.push({ level: "HOUR", ref: `${date}T${
|
|
107291
|
+
for (let h3 = startHour; h3 <= endHour; h3++) out.push({ level: "HOUR", ref: `${date}T${pad24(h3)}`, price });
|
|
106528
107292
|
return out;
|
|
106529
107293
|
}
|
|
106530
107294
|
function bandDateBounds(band) {
|
|
@@ -106532,7 +107296,7 @@ function bandDateBounds(band) {
|
|
|
106532
107296
|
case "month": {
|
|
106533
107297
|
if (!band.periodKey) throw new Error("month band missing periodKey");
|
|
106534
107298
|
const [y, m] = band.periodKey.split("-").map(Number);
|
|
106535
|
-
return { start: `${band.periodKey}-01`, end: `${band.periodKey}-${
|
|
107299
|
+
return { start: `${band.periodKey}-01`, end: `${band.periodKey}-${pad24(daysInMonthYear(y, m))}` };
|
|
106536
107300
|
}
|
|
106537
107301
|
case "range": {
|
|
106538
107302
|
if (!band.start || !band.end) throw new Error("range band missing start/end");
|
|
@@ -106676,7 +107440,7 @@ function collapseTreeToBands(tree, dims) {
|
|
|
106676
107440
|
} else if (typeof node.price === "string") {
|
|
106677
107441
|
const last = daysInMonthYear(dims.year, Number(mm));
|
|
106678
107442
|
for (let d = 1; d <= last; d++) {
|
|
106679
|
-
dayBands.push({ ...dimOnly, periodType: "day", date: `${dims.year}-${mm}-${
|
|
107443
|
+
dayBands.push({ ...dimOnly, periodType: "day", date: `${dims.year}-${mm}-${pad24(d)}`, price: node.price });
|
|
106680
107444
|
}
|
|
106681
107445
|
}
|
|
106682
107446
|
}
|
|
@@ -107522,11 +108286,16 @@ var GoalsMoneyClient = class {
|
|
|
107522
108286
|
const v = (body && body.version) ?? etagVersion;
|
|
107523
108287
|
return typeof v === "number" ? { version: v } : {};
|
|
107524
108288
|
}
|
|
108289
|
+
/**
|
|
108290
|
+
* Parse the body and unwrap GCDR's `{ success: true, data, meta }` success
|
|
108291
|
+
* envelope (bare shape still accepted). Error envelopes stay intact for
|
|
108292
|
+
* `toError`.
|
|
108293
|
+
*/
|
|
107525
108294
|
async readBody(res) {
|
|
107526
108295
|
try {
|
|
107527
108296
|
const text2 = await res.text();
|
|
107528
108297
|
if (!text2) return null;
|
|
107529
|
-
return JSON.parse(text2);
|
|
108298
|
+
return unwrapGcdrEnvelope(JSON.parse(text2));
|
|
107530
108299
|
} catch {
|
|
107531
108300
|
return null;
|
|
107532
108301
|
}
|
|
@@ -108034,11 +108803,11 @@ function deviceCategoryToPanelTerm(cat) {
|
|
|
108034
108803
|
function panelTermToDeviceCategory(term) {
|
|
108035
108804
|
return term == null ? null : panelCategoryToWire(term);
|
|
108036
108805
|
}
|
|
108037
|
-
function
|
|
108806
|
+
function esc9(s) {
|
|
108038
108807
|
return String(s ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
108039
108808
|
}
|
|
108040
108809
|
function categoryOptionsHTML(selected) {
|
|
108041
|
-
const opt = (value, label, isSel) => `<option value="${value}"${isSel ? " selected" : ""}>${
|
|
108810
|
+
const opt = (value, label, isSel) => `<option value="${value}"${isSel ? " selected" : ""}>${esc9(label)}</option>`;
|
|
108042
108811
|
return opt("", NONE_LABEL, selected == null) + opt("COMMON_AREA", deviceCategoryLabel("COMMON_AREA"), selected === "COMMON_AREA") + opt("SPECIFIC", deviceCategoryLabel("SPECIFIC"), selected === "SPECIFIC");
|
|
108043
108812
|
}
|
|
108044
108813
|
function openDeviceCategoryPanel(params) {
|
|
@@ -108075,8 +108844,8 @@ function openDeviceCategoryPanel(params) {
|
|
|
108075
108844
|
<select class="myio-devcat__filter" data-devcat-filter="1" aria-label="Filtrar por categoria">
|
|
108076
108845
|
<option value="all">Todas as categorias</option>
|
|
108077
108846
|
<option value="uncategorized">Sem categoria</option>
|
|
108078
|
-
<option value="COMMON_AREA">${
|
|
108079
|
-
<option value="SPECIFIC">${
|
|
108847
|
+
<option value="COMMON_AREA">${esc9(deviceCategoryLabel("COMMON_AREA"))}</option>
|
|
108848
|
+
<option value="SPECIFIC">${esc9(deviceCategoryLabel("SPECIFIC"))}</option>
|
|
108080
108849
|
</select>
|
|
108081
108850
|
<label class="myio-devcat__filter" style="display:flex;align-items:center;gap:6px;cursor:pointer;">
|
|
108082
108851
|
<input type="checkbox" data-devcat-selectall="1" /> Selecionar vis\xEDveis
|
|
@@ -108085,9 +108854,9 @@ function openDeviceCategoryPanel(params) {
|
|
|
108085
108854
|
<div class="myio-devcat__bulkbar" data-devcat-bulkbar="1">
|
|
108086
108855
|
<span data-devcat-bulkcount="1">0 selecionados</span>
|
|
108087
108856
|
<select data-devcat-bulkcat="1" aria-label="Categoria para os selecionados">
|
|
108088
|
-
<option value="">${
|
|
108089
|
-
<option value="COMMON_AREA">${
|
|
108090
|
-
<option value="SPECIFIC">${
|
|
108857
|
+
<option value="">${esc9(NONE_LABEL)}</option>
|
|
108858
|
+
<option value="COMMON_AREA">${esc9(deviceCategoryLabel("COMMON_AREA"))}</option>
|
|
108859
|
+
<option value="SPECIFIC">${esc9(deviceCategoryLabel("SPECIFIC"))}</option>
|
|
108091
108860
|
</select>
|
|
108092
108861
|
<button type="button" class="myio-devcat__bulk-apply" data-devcat-bulkapply="1">Aplicar a selecionados</button>
|
|
108093
108862
|
</div>
|
|
@@ -108117,16 +108886,16 @@ function openDeviceCategoryPanel(params) {
|
|
|
108117
108886
|
return rows.filter((r) => matchesFilter(r) && matchesSearch(r));
|
|
108118
108887
|
}
|
|
108119
108888
|
function rowHTML(r) {
|
|
108120
|
-
const name =
|
|
108121
|
-
const code = r.code ? `<span class="myio-devcat__row-code">${
|
|
108889
|
+
const name = esc9(r.label || r.code || r.deviceId);
|
|
108890
|
+
const code = r.code ? `<span class="myio-devcat__row-code">${esc9(r.code)}</span>` : "";
|
|
108122
108891
|
const checked = selected.has(r.deviceId) ? " checked" : "";
|
|
108123
108892
|
const focused = r.deviceId === params.focusDeviceId ? ' data-focused="1"' : "";
|
|
108124
108893
|
const catAttr = r.tariffCategory == null ? "null" : r.tariffCategory;
|
|
108125
|
-
return `<div class="myio-devcat__row" data-devcat-row="${
|
|
108894
|
+
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
108895
|
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="${
|
|
108896
|
+
)}"${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
108897
|
r.deviceId
|
|
108129
|
-
)}" aria-label="Categoria de ${name}">${categoryOptionsHTML(r.tariffCategory)}</select><div class="myio-devcat__row-conflict" data-devcat-conflict="${
|
|
108898
|
+
)}" aria-label="Categoria de ${name}">${categoryOptionsHTML(r.tariffCategory)}</select><div class="myio-devcat__row-conflict" data-devcat-conflict="${esc9(r.deviceId)}"></div></div>`;
|
|
108130
108899
|
}
|
|
108131
108900
|
function render3() {
|
|
108132
108901
|
const vis = visibleRows();
|
|
@@ -108286,7 +109055,7 @@ function openDeviceCategoryPanel(params) {
|
|
|
108286
109055
|
rows = await port.listDevices({ customerId, domain: params.domain });
|
|
108287
109056
|
} catch (err) {
|
|
108288
109057
|
rows = [];
|
|
108289
|
-
body.innerHTML = `<div class="myio-devcat__empty">N\xE3o foi poss\xEDvel carregar os dispositivos: ${
|
|
109058
|
+
body.innerHTML = `<div class="myio-devcat__empty">N\xE3o foi poss\xEDvel carregar os dispositivos: ${esc9(
|
|
108290
109059
|
err?.message || "erro"
|
|
108291
109060
|
)}</div>`;
|
|
108292
109061
|
countEl.textContent = "";
|
|
@@ -108397,207 +109166,6 @@ function renderGatedMoney(params, renderers) {
|
|
|
108397
109166
|
return renderers.renderCoverage(routing.coverageOverlay);
|
|
108398
109167
|
}
|
|
108399
109168
|
|
|
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
109169
|
// src/components/premium-modals/measurement-setup/types.ts
|
|
108602
109170
|
var WATER_UNITS = [
|
|
108603
109171
|
{ value: "m3", label: "Metros C\xFAbicos (m\xB3)" },
|
|
@@ -116056,14 +116624,14 @@ function buildTemplateCsv(domain, devices, start, end, now = Date.now()) {
|
|
|
116056
116624
|
if (domain === "energy") header.push("value_reactive_kvarh");
|
|
116057
116625
|
const today = nowSaoPaulo(now);
|
|
116058
116626
|
const lines = [header.join(";")];
|
|
116059
|
-
const
|
|
116627
|
+
const esc11 = (v) => /[;"\n]/.test(v) ? `"${v.replace(/"/g, '""')}"` : v;
|
|
116060
116628
|
const { ok } = splitImportableDevices(devices);
|
|
116061
116629
|
for (const dev of ok) {
|
|
116062
116630
|
for (const date of daysBetween(start, end)) {
|
|
116063
116631
|
if (date > today.date) break;
|
|
116064
116632
|
for (let h3 = 0; h3 < 24; h3++) {
|
|
116065
116633
|
if (date === today.date && h3 >= today.hour) break;
|
|
116066
|
-
const cols = [String(dev.centralId), String(Number(dev.slaveId)),
|
|
116634
|
+
const cols = [String(dev.centralId), String(Number(dev.slaveId)), esc11(dev.label || ""), date, `${pad25(h3)}:00`, ""];
|
|
116067
116635
|
if (domain === "energy") cols.push("");
|
|
116068
116636
|
lines.push(cols.join(";"));
|
|
116069
116637
|
}
|
|
@@ -116324,10 +116892,10 @@ function accumulatedRows(domain, entries, profile = DEFAULT_DISTRIBUTION_PROFILE
|
|
|
116324
116892
|
}
|
|
116325
116893
|
function buildAccumulatedTemplateCsv(domain, devices, start, end) {
|
|
116326
116894
|
const lines = [["gateway_id", "slave_id", "device_name", "start_date", "end_date", TOTAL_COLUMN[domain]].join(";")];
|
|
116327
|
-
const
|
|
116895
|
+
const esc11 = (v) => /[;"\n]/.test(v) ? `"${v.replace(/"/g, '""')}"` : v;
|
|
116328
116896
|
for (const dev of devices || []) {
|
|
116329
116897
|
if (!isImportableKey(dev)) continue;
|
|
116330
|
-
lines.push([String(dev.centralId), String(Number(dev.slaveId)),
|
|
116898
|
+
lines.push([String(dev.centralId), String(Number(dev.slaveId)), esc11(dev.label || ""), start, end, ""].join(";"));
|
|
116331
116899
|
}
|
|
116332
116900
|
return { csv: "\uFEFF" + lines.join("\r\n") + "\r\n", rows: lines.length - 1 };
|
|
116333
116901
|
}
|
|
@@ -116517,7 +117085,7 @@ function fmtSaoPaulo(iso) {
|
|
|
116517
117085
|
return `${p(d.getUTCDate())}/${p(d.getUTCMonth() + 1)}/${d.getUTCFullYear()} ${p(d.getUTCHours())}:00`;
|
|
116518
117086
|
}
|
|
116519
117087
|
var STYLE_ID15 = "myio-tlmimport-styles";
|
|
116520
|
-
function
|
|
117088
|
+
function esc10(v) {
|
|
116521
117089
|
return String(v ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
116522
117090
|
}
|
|
116523
117091
|
var fmtNum = (n, d = 0) => Number.isFinite(Number(n)) ? Number(n).toLocaleString("pt-BR", { minimumFractionDigits: d, maximumFractionDigits: d }) : "\u2014";
|
|
@@ -116580,7 +117148,7 @@ function injectStyles14() {
|
|
|
116580
117148
|
document.head.appendChild(style);
|
|
116581
117149
|
}
|
|
116582
117150
|
function issuesTable(errors, limit = 100) {
|
|
116583
|
-
const rows = errors.slice(0, limit).map((e) => `<tr><td>${
|
|
117151
|
+
const rows = errors.slice(0, limit).map((e) => `<tr><td>${esc10(e.line)}</td><td>${esc10(e.reason)}</td></tr>`).join("");
|
|
116584
117152
|
const more = errors.length > limit ? `<p class="tlmi-muted">\u2026 e mais ${errors.length - limit} erro(s).</p>` : "";
|
|
116585
117153
|
return `<div class="tlmi-errors"><table><thead><tr><th>Linha</th><th>Problema</th></tr></thead><tbody>${rows}</tbody></table></div>${more}`;
|
|
116586
117154
|
}
|
|
@@ -116658,10 +117226,10 @@ function openTelemetryImportModal(params) {
|
|
|
116658
117226
|
}
|
|
116659
117227
|
function apiErrorBanner() {
|
|
116660
117228
|
if (!s.apiError) return "";
|
|
116661
|
-
return `<div class="tlmi-banner err" role="alert">${
|
|
117229
|
+
return `<div class="tlmi-banner err" role="alert">${esc10(s.apiError)}${s.apiDetail ? `<div class="tlmi-tech">${esc10(s.apiDetail)}</div>` : ""}</div>`;
|
|
116662
117230
|
}
|
|
116663
117231
|
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: ${
|
|
117232
|
+
const warn = missingKey.length ? `<div class="tlmi-banner warn">${missingKey.length} dispositivo(s) sem central/endere\xE7o cadastrados ficam fora do modelo: ${esc10(
|
|
116665
117233
|
missingKey.slice(0, 5).map((d) => d.label).join(", ")
|
|
116666
117234
|
)}${missingKey.length > 5 ? "\u2026" : ""}</div>` : "";
|
|
116667
117235
|
const model = (value, title, hint) => `
|
|
@@ -116688,16 +117256,16 @@ function openTelemetryImportModal(params) {
|
|
|
116688
117256
|
${warn}
|
|
116689
117257
|
<div class="tlmi-card"><h3>${s.model === "accumulated" ? "Per\xEDodo" : "Modelo da planilha"}</h3>
|
|
116690
117258
|
<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="${
|
|
117259
|
+
<label class="tlmi-field">In\xEDcio<input type="date" data-field="start" value="${esc10(s.period.start)}" /></label>
|
|
117260
|
+
<label class="tlmi-field">Fim<input type="date" data-field="end" value="${esc10(s.period.end)}" /></label>
|
|
116693
117261
|
<button class="tlmi-btn" type="button" data-action="template" ${importable.length ? "" : "disabled"}>\u2B07 Baixar modelo (CSV)</button>
|
|
116694
117262
|
</div>
|
|
116695
117263
|
<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
117264
|
</div>`;
|
|
116697
117265
|
}
|
|
116698
117266
|
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">${
|
|
117267
|
+
const summary = s.fileName ? s.parseError ? `<div class="tlmi-banner err">${esc10(s.parseError)}</div>` : `<div class="tlmi-kpis">
|
|
117268
|
+
<div class="tlmi-kpi"><span>Arquivo</span><strong style="font-size:13px">${esc10(s.fileName)}</strong></div>
|
|
116701
117269
|
<div class="tlmi-kpi"><span>Linhas para importar</span><strong>${fmtNum(s.rows.length)}</strong></div>
|
|
116702
117270
|
<div class="tlmi-kpi"><span>Em branco (ignoradas)</span><strong>${fmtNum(s.skippedEmpty)}</strong></div>
|
|
116703
117271
|
<div class="tlmi-kpi"><span>Com erro</span><strong style="color:${s.localErrors.length ? "#dc2626" : "#16a34a"}">${fmtNum(s.localErrors.length)}</strong></div>
|
|
@@ -116737,12 +117305,12 @@ function openTelemetryImportModal(params) {
|
|
|
116737
117305
|
}
|
|
116738
117306
|
function step2Accumulated() {
|
|
116739
117307
|
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: ${
|
|
117308
|
+
const form = fromFile ? `<p class="tlmi-muted">Usando <strong>${esc10(s.fileName)}</strong>.
|
|
117309
|
+
<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
117310
|
<div class="tlmi-acc"><table><thead><tr><th>Dispositivo</th><th>Total (${txt.unit})</th></tr></thead><tbody>
|
|
116743
117311
|
${importable.map(
|
|
116744
|
-
(d, i) => `<tr><td>${
|
|
116745
|
-
<td><input inputmode="decimal" data-total="${i}" aria-label="Total de ${
|
|
117312
|
+
(d, i) => `<tr><td>${esc10(d.label)}</td>
|
|
117313
|
+
<td><input inputmode="decimal" data-total="${i}" aria-label="Total de ${esc10(d.label)}" value="${esc10(s.formTotals[i] ?? "")}" /></td></tr>`
|
|
116746
117314
|
).join("")}
|
|
116747
117315
|
</tbody></table></div>`;
|
|
116748
117316
|
return `
|
|
@@ -116755,7 +117323,7 @@ function openTelemetryImportModal(params) {
|
|
|
116755
117323
|
<input type="file" accept=".xlsx,.xls,.csv" data-field="file" hidden />
|
|
116756
117324
|
\u{1F4C4} Clique ou arraste a planilha aqui (.xlsx ou .csv)
|
|
116757
117325
|
</label>
|
|
116758
|
-
${s.parseError ? `<div class="tlmi-banner err" style="margin-top:10px">${
|
|
117326
|
+
${s.parseError ? `<div class="tlmi-banner err" style="margin-top:10px">${esc10(s.parseError)}</div>` : ""}
|
|
116759
117327
|
</div>
|
|
116760
117328
|
<div data-role="acc-summary" style="display:flex;flex-direction:column;gap:12px">${accSummaryHtml()}</div>`;
|
|
116761
117329
|
}
|
|
@@ -116781,7 +117349,7 @@ function openTelemetryImportModal(params) {
|
|
|
116781
117349
|
<div class="tlmi-kpi"><span>Total (${txt.unit})</span><strong>${fmtNum(p.totalValue, 2)}</strong></div>
|
|
116782
117350
|
<div class="tlmi-kpi"><span>Leituras substitu\xEDdas</span><strong>${fmtNum(p.existingReadingsInTarget)}</strong></div>
|
|
116783
117351
|
</div>
|
|
116784
|
-
<p class="tlmi-muted">Per\xEDodo (hor\xE1rio de Bras\xEDlia): ${
|
|
117352
|
+
<p class="tlmi-muted">Per\xEDodo (hor\xE1rio de Bras\xEDlia): ${esc10(period)}</p>
|
|
116785
117353
|
${reactiveWarn}
|
|
116786
117354
|
${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
117355
|
<label class="tlmi-check" style="margin-top:6px"><input type="checkbox" data-field="confirmReal" ${s.confirmReal ? "checked" : ""} />
|
|
@@ -116800,7 +117368,7 @@ function openTelemetryImportModal(params) {
|
|
|
116800
117368
|
<div class="tlmi-muted" style="margin-top:4px">Dispositivos manuais continuam aparecendo sem comunica\xE7\xE3o no status:
|
|
116801
117369
|
o status conta s\xF3 leitura medida. Os totais e os cards usam os dados importados.</div></div>`;
|
|
116802
117370
|
} else if (j.status === "failed") {
|
|
116803
|
-
banner = `<div class="tlmi-banner err">A importa\xE7\xE3o falhou${j.error ? `: ${
|
|
117371
|
+
banner = `<div class="tlmi-banner err">A importa\xE7\xE3o falhou${j.error ? `: ${esc10(j.error)}` : "."}</div>`;
|
|
116804
117372
|
} else if (j.status === "cancelled") {
|
|
116805
117373
|
banner = '<div class="tlmi-banner warn">Importa\xE7\xE3o cancelada. As leituras anteriores foram mantidas.</div>';
|
|
116806
117374
|
} else if (j.status === "reverted") {
|
|
@@ -116812,14 +117380,14 @@ function openTelemetryImportModal(params) {
|
|
|
116812
117380
|
<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
117381
|
</div>` : "";
|
|
116814
117382
|
return `
|
|
116815
|
-
<div class="tlmi-card"><h3>Importa\xE7\xE3o <span style="font-weight:600;color:#64748b">${
|
|
117383
|
+
<div class="tlmi-card"><h3>Importa\xE7\xE3o <span style="font-weight:600;color:#64748b">${esc10(statusText)}</span></h3>
|
|
116816
117384
|
<div class="tlmi-progress" role="progressbar" aria-valuenow="${pct}" aria-valuemin="0" aria-valuemax="100"><i style="width:${pct}%"></i></div>
|
|
116817
117385
|
<div class="tlmi-kpis" style="margin-top:12px">
|
|
116818
117386
|
<div class="tlmi-kpi"><span>Progresso</span><strong>${fmtNum(pct)}%</strong></div>
|
|
116819
117387
|
<div class="tlmi-kpi"><span>Leituras removidas</span><strong>${fmtNum(j.deleted)}</strong></div>
|
|
116820
117388
|
<div class="tlmi-kpi"><span>Leituras gravadas</span><strong>${fmtNum(j.inserted)}</strong></div>
|
|
116821
117389
|
</div>
|
|
116822
|
-
${j.phase && !terminal ? `<p class="tlmi-muted" style="margin-top:8px">Etapa: ${
|
|
117390
|
+
${j.phase && !terminal ? `<p class="tlmi-muted" style="margin-top:8px">Etapa: ${esc10(j.phase)}</p>` : ""}
|
|
116823
117391
|
${!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
117392
|
<span class="tlmi-muted" style="margin-left:8px">Voc\xEA pode fechar esta janela; a importa\xE7\xE3o continua.</span></div>` : ""}
|
|
116825
117393
|
${revert}
|
|
@@ -117129,8 +117697,8 @@ function siglaFromManualAsset(assetName) {
|
|
|
117129
117697
|
return /^[A-Z0-9_]+$/.test(sigla) ? sigla : null;
|
|
117130
117698
|
}
|
|
117131
117699
|
function nextManualSeq(domain, sigla, existingNames) {
|
|
117132
|
-
const
|
|
117133
|
-
const re = new RegExp(`^${
|
|
117700
|
+
const esc11 = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
117701
|
+
const re = new RegExp(`^${esc11(NAME_PREFIX[domain])}${esc11(sigla)}_LOJA_(\\d+)_MANUAL$`, "i");
|
|
117134
117702
|
const max = existingNames.reduce((acc, n) => {
|
|
117135
117703
|
const m = re.exec(String(n || "").trim());
|
|
117136
117704
|
return m ? Math.max(acc, Number(m[1])) : acc;
|
|
@@ -151995,10 +152563,10 @@ var AlarmsNotificationsPanelView = class {
|
|
|
151995
152563
|
const renderListPanel = (group, items, sel) => {
|
|
151996
152564
|
if (items.length === 0) return '<div class="afm-empty">Nenhum item encontrado</div>';
|
|
151997
152565
|
return items.map((item) => {
|
|
151998
|
-
const
|
|
152566
|
+
const esc11 = this.esc(item);
|
|
151999
152567
|
return `<label class="afm-check-item">
|
|
152000
|
-
<input type="checkbox" class="afm-checkbox" data-group="${group}" data-value="${
|
|
152001
|
-
<span class="afm-check-label">${
|
|
152568
|
+
<input type="checkbox" class="afm-checkbox" data-group="${group}" data-value="${esc11}"${sel.has(item) ? " checked" : ""}>
|
|
152569
|
+
<span class="afm-check-label">${esc11}</span>
|
|
152002
152570
|
</label>`;
|
|
152003
152571
|
}).join("");
|
|
152004
152572
|
};
|
|
@@ -164876,7 +165444,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
164876
165444
|
const docTitle = buildActivationReportTitle(deviceName, opts.customerName);
|
|
164877
165445
|
const issuedAt = formatIssuedAt(/* @__PURE__ */ new Date(), locale);
|
|
164878
165446
|
const utilization = data.totalHours > 0 ? (data.totalOnMinutes / (data.totalHours * 60) * 100).toFixed(1) : "0.0";
|
|
164879
|
-
const
|
|
165447
|
+
const esc11 = (s) => String(s).replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]);
|
|
164880
165448
|
const htmlContent = `
|
|
164881
165449
|
<!DOCTYPE html>
|
|
164882
165450
|
<html lang="pt-BR">
|
|
@@ -164928,14 +165496,14 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
164928
165496
|
<div class="brand">MyIO BAS</div>
|
|
164929
165497
|
<h1>Relat\xF3rio de Acionamentos</h1>
|
|
164930
165498
|
<div class="meta">
|
|
164931
|
-
<div><b>Dispositivo:</b> ${
|
|
165499
|
+
<div><b>Dispositivo:</b> ${esc11(deviceName)}</div>
|
|
164932
165500
|
<div><b>Per\xEDodo:</b> ${periodStart} \u2014 ${periodEnd}</div>
|
|
164933
165501
|
</div>
|
|
164934
165502
|
</div>
|
|
164935
165503
|
${customerName ? `
|
|
164936
165504
|
<div class="customer-badge">
|
|
164937
165505
|
<div class="label">Cliente</div>
|
|
164938
|
-
<div class="value">${
|
|
165506
|
+
<div class="value">${esc11(customerName)}</div>
|
|
164939
165507
|
</div>` : ""}
|
|
164940
165508
|
</div>
|
|
164941
165509
|
|
|
@@ -164946,7 +165514,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
164946
165514
|
</div>
|
|
164947
165515
|
<div class="summary-card accent-green">
|
|
164948
165516
|
<div class="summary-value">${formatDurationMinutes(data.totalOnMinutes)}</div>
|
|
164949
|
-
<div class="summary-label">Tempo ${
|
|
165517
|
+
<div class="summary-label">Tempo ${esc11(labelOn)}</div>
|
|
164950
165518
|
</div>
|
|
164951
165519
|
<div class="summary-card accent-amber">
|
|
164952
165520
|
<div class="summary-value">${utilization}%</div>
|
|
@@ -164974,7 +165542,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
164974
165542
|
<tr>
|
|
164975
165543
|
<td>${formatDateForExport(seg.startTime, locale)}</td>
|
|
164976
165544
|
<td>${formatDateForExport(seg.endTime, locale)}</td>
|
|
164977
|
-
<td><span class="pill ${seg.state === "on" ? "pill-on" : "pill-off"}">${seg.state === "on" ?
|
|
165545
|
+
<td><span class="pill ${seg.state === "on" ? "pill-on" : "pill-off"}">${seg.state === "on" ? esc11(labelOn) : esc11(labelOff)}</span></td>
|
|
164978
165546
|
<td>${formatDurationMinutes(seg.durationMinutes)}</td>
|
|
164979
165547
|
<td>${seg.source === "manual" ? "Manual" : seg.source === "schedule" ? "Agendamento" : seg.source === "automation" ? "Automa\xE7\xE3o" : "Desconhecido"}</td>
|
|
164980
165548
|
</tr>
|
|
@@ -164983,7 +165551,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
|
|
|
164983
165551
|
</table>
|
|
164984
165552
|
|
|
164985
165553
|
<div class="footer">
|
|
164986
|
-
<span class="issued">Emitido em ${issuedAt}</span>${customerName ? ` · ${
|
|
165554
|
+
<span class="issued">Emitido em ${issuedAt}</span>${customerName ? ` · ${esc11(customerName)}` : ""} · <span class="brand">MyIO BAS</span>
|
|
164987
165555
|
</div>
|
|
164988
165556
|
</body>
|
|
164989
165557
|
</html>
|
|
@@ -179830,8 +180398,13 @@ var version = package_default.version || "0.0.0";
|
|
|
179830
180398
|
MEASUREMENT_DOMAIN_CONFIG,
|
|
179831
180399
|
MENU_SHOPPING_CSS_PREFIX,
|
|
179832
180400
|
METRO_TILE_COLORS,
|
|
180401
|
+
MONEY_CONVERTIBLE_GROUPS,
|
|
179833
180402
|
MONEY_DASH,
|
|
180403
|
+
MONEY_ESTIMATE_LABEL,
|
|
179834
180404
|
MONEY_HOURLY_MAX_DAYS,
|
|
180405
|
+
MONEY_INCOMPLETE_LABEL,
|
|
180406
|
+
MONEY_MAX_SEGMENT_FETCHES,
|
|
180407
|
+
MONEY_REPORT_HEADER,
|
|
179835
180408
|
MONEY_REQUIRES_DEVICE_GRANULARITY,
|
|
179836
180409
|
MONEY_VARIANCE_HEADER,
|
|
179837
180410
|
MOTOR_SORT_OPTIONS,
|
|
@@ -179934,6 +180507,7 @@ var version = package_default.version || "0.0.0";
|
|
|
179934
180507
|
TempSensorSummaryTooltip,
|
|
179935
180508
|
Temperature,
|
|
179936
180509
|
UsersSummaryTooltip,
|
|
180510
|
+
VALUE_DISPLAY_MODE_STORAGE_PREFIX,
|
|
179937
180511
|
VALVE_STATE_KEYS,
|
|
179938
180512
|
VARIANCE_LABEL_ABOVE,
|
|
179939
180513
|
VARIANCE_LABEL_BELOW,
|
|
@@ -179981,9 +180555,12 @@ var version = package_default.version || "0.0.0";
|
|
|
179981
180555
|
buildFinancialRowHTML,
|
|
179982
180556
|
buildGcdrEnergyRoot,
|
|
179983
180557
|
buildListItemsThingsboardByUniqueDatasource,
|
|
180558
|
+
buildMoneyChipHTML,
|
|
180559
|
+
buildMoneyCoverageMarkerHTML,
|
|
179984
180560
|
buildMoneyVarianceHTML,
|
|
179985
180561
|
buildMyioIngestionAuth,
|
|
179986
180562
|
buildReportItemsList,
|
|
180563
|
+
buildReportMoneyConfig,
|
|
179987
180564
|
buildTemplateCsv,
|
|
179988
180565
|
buildTemplateExport,
|
|
179989
180566
|
buildTicketServiceOrchestrator,
|
|
@@ -180208,6 +180785,7 @@ var version = package_default.version || "0.0.0";
|
|
|
180208
180785
|
formatDuration,
|
|
180209
180786
|
formatEnergy,
|
|
180210
180787
|
formatHours,
|
|
180788
|
+
formatItemMoney,
|
|
180211
180789
|
formatMoneyBRL,
|
|
180212
180790
|
formatNumberReadable,
|
|
180213
180791
|
formatPower,
|
|
@@ -180348,6 +180926,7 @@ var version = package_default.version || "0.0.0";
|
|
|
180348
180926
|
isInRange,
|
|
180349
180927
|
isLeapYear,
|
|
180350
180928
|
isMoneyColumnConfident,
|
|
180929
|
+
isMoneyConvertibleGroup,
|
|
180351
180930
|
isMyioGcdrLoginModalOpen,
|
|
180352
180931
|
isOnOffDeviceProfile,
|
|
180353
180932
|
isSolenoidDevice,
|
|
@@ -180372,6 +180951,9 @@ var version = package_default.version || "0.0.0";
|
|
|
180372
180951
|
metasGuideComputeChips,
|
|
180373
180952
|
metasGuideDeriveTotal,
|
|
180374
180953
|
minutesToMs,
|
|
180954
|
+
moneyCoverageTitle,
|
|
180955
|
+
moneyReasonText,
|
|
180956
|
+
moneyStateChipLabel,
|
|
180375
180957
|
msToMinutes,
|
|
180376
180958
|
myioExportData,
|
|
180377
180959
|
nextManualSeq,
|
|
@@ -180447,10 +181029,12 @@ var version = package_default.version || "0.0.0";
|
|
|
180447
181029
|
parseGcdrEntityForest,
|
|
180448
181030
|
parseInputDateToDate,
|
|
180449
181031
|
parseLogAnnotations,
|
|
181032
|
+
parseMoneyCategoryRule,
|
|
180450
181033
|
periodKey,
|
|
180451
181034
|
pickUniqueCustomerCode,
|
|
180452
181035
|
pumpHistoryFromConsumption,
|
|
180453
181036
|
readFreshdeskTicketsFromTB,
|
|
181037
|
+
readValueDisplayMode,
|
|
180454
181038
|
recalculateDeviceStatus,
|
|
180455
181039
|
recomputeDeviceGridPercentages,
|
|
180456
181040
|
refreshAlarmBadges,
|
|
@@ -180494,15 +181078,18 @@ var version = package_default.version || "0.0.0";
|
|
|
180494
181078
|
resolveBudget,
|
|
180495
181079
|
resolveCategory,
|
|
180496
181080
|
resolveClassification,
|
|
181081
|
+
resolveEffectiveDisplayMode,
|
|
180497
181082
|
resolveGoalAmount,
|
|
180498
181083
|
resolveGroup,
|
|
180499
181084
|
resolveManualDeviceName,
|
|
181085
|
+
resolveMoneyCategory,
|
|
180500
181086
|
resolveMoneyRollout,
|
|
180501
181087
|
resolveMoneyRowValues,
|
|
180502
181088
|
resolvePercentDecimals,
|
|
180503
181089
|
resolveReportItemStates,
|
|
180504
181090
|
resolveSubcategory,
|
|
180505
181091
|
resolveWithFallback,
|
|
181092
|
+
roundMoney2,
|
|
180506
181093
|
routeMoneyRender,
|
|
180507
181094
|
rowsFromTable,
|
|
180508
181095
|
schedCreateDateInput,
|
|
@@ -180524,6 +181111,7 @@ var version = package_default.version || "0.0.0";
|
|
|
180524
181111
|
sortDeviceGridDevices,
|
|
180525
181112
|
strings,
|
|
180526
181113
|
subtractDecimals,
|
|
181114
|
+
sumItemMoney,
|
|
180527
181115
|
sumMoneyDecimals,
|
|
180528
181116
|
summaryDeviceToTotalsRow,
|
|
180529
181117
|
summaryLastReadingTs,
|
|
@@ -180538,6 +181126,7 @@ var version = package_default.version || "0.0.0";
|
|
|
180538
181126
|
toCSV,
|
|
180539
181127
|
toFixedSafe,
|
|
180540
181128
|
toFreshdeskTicketSummary,
|
|
181129
|
+
toItemMoney,
|
|
180541
181130
|
truncateAnnotationText,
|
|
180542
181131
|
updateDeviceGridStats,
|
|
180543
181132
|
updateFreshdeskTicket,
|
|
@@ -180547,11 +181136,14 @@ var version = package_default.version || "0.0.0";
|
|
|
180547
181136
|
validateDeviceProductName,
|
|
180548
181137
|
validateProfile,
|
|
180549
181138
|
validateTree,
|
|
181139
|
+
valuateDomainMoney,
|
|
181140
|
+
valueDisplayModeStorageKey,
|
|
180550
181141
|
valveHistoryFromTelemetry,
|
|
180551
181142
|
version,
|
|
180552
181143
|
waterDeviceStatusIcons,
|
|
180553
181144
|
wireCategoryToPanel,
|
|
180554
181145
|
wireDomainToPanel,
|
|
180555
181146
|
writeFreshdeskSyncedAtToTB,
|
|
180556
|
-
writeFreshdeskTicketsToTB
|
|
181147
|
+
writeFreshdeskTicketsToTB,
|
|
181148
|
+
writeValueDisplayMode
|
|
180557
181149
|
});
|