myio-js-library 0.1.565 → 0.1.567

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -222,9 +222,12 @@ __export(src_exports, {
222
222
  IMPORTANCE_COLORS: () => IMPORTANCE_COLORS,
223
223
  IMPORTANCE_LABELS: () => IMPORTANCE_LABELS,
224
224
  IMPORTANCE_LABELS_EN: () => IMPORTANCE_LABELS_EN,
225
+ ImportApiError: () => ImportApiError,
225
226
  InfoTooltip: () => InfoTooltip,
226
227
  LoadingSpinner: () => LoadingSpinner,
227
228
  LogHelper: () => LogHelper,
229
+ MANUAL_ASSET_SUFFIX: () => MANUAL_ASSET_SUFFIX,
230
+ MANUAL_DEVICE_PROFILES: () => MANUAL_DEVICE_PROFILES,
228
231
  MEASUREMENT_DOMAIN_CONFIG: () => DOMAIN_CONFIG5,
229
232
  MENU_SHOPPING_CSS_PREFIX: () => MENU_SHOPPING_CSS_PREFIX,
230
233
  METRO_TILE_COLORS: () => METRO_TILE_COLORS,
@@ -235,6 +238,7 @@ __export(src_exports, {
235
238
  MYIO_ACCENT: () => MYIO_ACCENT,
236
239
  MYIO_CHART_PALETTE: () => MYIO_CHART_PALETTE,
237
240
  MYIO_CHART_PALETTE_DARK: () => MYIO_CHART_PALETTE_DARK,
241
+ ManualDeviceError: () => ManualDeviceError,
238
242
  MenuController: () => MenuController,
239
243
  MenuShoppingView: () => MenuShoppingView,
240
244
  MenuView: () => MenuView,
@@ -276,6 +280,7 @@ __export(src_exports, {
276
280
  POWER_LIMITS_DEVICE_TYPES: () => DEVICE_TYPES,
277
281
  POWER_LIMITS_STATUS_CONFIG: () => STATUS_CONFIG,
278
282
  POWER_LIMITS_TELEMETRY_TYPES: () => TELEMETRY_TYPES,
283
+ PUMP_POWER_KEY: () => PUMP_POWER_KEY,
279
284
  REPORT_MONEY_HEADER: () => REPORT_MONEY_HEADER,
280
285
  SCHEDULE_HOLIDAY_CSS_PREFIX: () => SCHEDULE_HOLIDAY_CSS_PREFIX,
281
286
  SCHEDULE_IR_CSS_PREFIX: () => SCHEDULE_IR_CSS_PREFIX,
@@ -328,6 +333,7 @@ __export(src_exports, {
328
333
  TempSensorSummaryTooltip: () => TempSensorSummaryTooltip,
329
334
  Temperature: () => Temperature,
330
335
  UsersSummaryTooltip: () => UsersSummaryTooltip,
336
+ VALVE_STATE_KEYS: () => VALVE_STATE_KEYS,
331
337
  VARIANCE_LABEL_ABOVE: () => VARIANCE_LABEL_ABOVE,
332
338
  VARIANCE_LABEL_BELOW: () => VARIANCE_LABEL_BELOW,
333
339
  VARIANCE_LABEL_ONTARGET: () => VARIANCE_LABEL_ONTARGET,
@@ -375,6 +381,7 @@ __export(src_exports, {
375
381
  buildMoneyVarianceHTML: () => buildMoneyVarianceHTML,
376
382
  buildMyioIngestionAuth: () => buildMyioIngestionAuth,
377
383
  buildReportItemsList: () => buildReportItemsList,
384
+ buildTemplateCsv: () => buildTemplateCsv,
378
385
  buildTemplateExport: () => buildTemplateExport,
379
386
  buildTicketServiceOrchestrator: () => buildTicketServiceOrchestrator,
380
387
  buildVerdictHTML: () => buildVerdictHTML,
@@ -450,6 +457,7 @@ __export(src_exports, {
450
457
  createDistributionChartWidget: () => createDistributionChartWidget,
451
458
  createDivCard: () => createDivCard,
452
459
  createEnergyPanelComponent: () => createEnergyPanelComponent,
460
+ createEquipmentIndicatorStrip: () => createEquipmentIndicatorStrip,
453
461
  createErrorSpan: () => createErrorSpan,
454
462
  createExportButton: () => createExportButton,
455
463
  createFakeDeviceCategoryPort: () => createFakeDeviceCategoryPort,
@@ -473,6 +481,7 @@ __export(src_exports, {
473
481
  createLibraryVersionChecker: () => createLibraryVersionChecker,
474
482
  createLoadingSpinner: () => createLoadingSpinner,
475
483
  createLogHelper: () => createLogHelper,
484
+ createManualDevice: () => createManualDevice,
476
485
  createMenuComponent: () => createMenuComponent,
477
486
  createMenuShoppingComponent: () => createMenuShoppingComponent,
478
487
  createModalFooter: () => createModalFooter,
@@ -509,6 +518,7 @@ __export(src_exports, {
509
518
  createTbEnvelopeStore: () => createTbEnvelopeStore,
510
519
  createTelemetryGridComponent: () => createTelemetryGridComponent,
511
520
  createTelemetryGridShoppingComponent: () => createTelemetryGridShoppingComponent,
521
+ createTelemetryImportApi: () => createTelemetryImportApi,
512
522
  createTelemetryInfoShoppingComponent: () => createTelemetryInfoShoppingComponent,
513
523
  createTicketDetailModal: () => createTicketDetailModal,
514
524
  createTicketsTab: () => createTicketsTab,
@@ -544,7 +554,7 @@ __export(src_exports, {
544
554
  doSchedulesOverlap: () => doSchedulesOverlap,
545
555
  downloadAnnotationsTextFile: () => downloadTextFile,
546
556
  encodeDeviceProductCode: () => encodeDeviceProductCode,
547
- escapeAnnotationHtml: () => escapeHtml16,
557
+ escapeAnnotationHtml: () => escapeHtml20,
548
558
  evaluateDeviceStatus: () => evaluateDeviceStatus,
549
559
  expandBandHours: () => expandBandHours,
550
560
  expandBandToHourBucketsByYear: () => expandBandToHourBucketsByYear,
@@ -676,6 +686,7 @@ __export(src_exports, {
676
686
  hasCoverageGaps: () => hasCoverageGaps,
677
687
  hasSelectedDays: () => hasSelectedDays,
678
688
  highlightAnnotationMatches: () => highlightMatches,
689
+ indicatorsFromModalData: () => indicatorsFromModalData,
679
690
  initMyIOAuthContext: () => initMyIOAuthContext,
680
691
  initOnOffTimelineTooltips: () => initOnOffTimelineTooltips,
681
692
  injectActionButtonStyles: () => injectActionButtonStyles,
@@ -687,7 +698,7 @@ __export(src_exports, {
687
698
  injectCustomerCardV1Styles: () => injectCustomerCardV1Styles,
688
699
  injectCustomerCardV2Styles: () => injectCustomerCardV2Styles,
689
700
  injectDeviceCategoryStyles: () => injectDeviceCategoryStyles,
690
- injectDeviceGridV6Styles: () => injectStyles19,
701
+ injectDeviceGridV6Styles: () => injectStyles22,
691
702
  injectDeviceOperationalCardGridStyles: () => injectDeviceOperationalCardGridStyles,
692
703
  injectDeviceOperationalCardStyles: () => injectDeviceOperationalCardStyles,
693
704
  injectExportButtonStyles: () => injectExportButtonStyles,
@@ -712,6 +723,7 @@ __export(src_exports, {
712
723
  injectSolenoidControlStyles: () => injectSolenoidControlStyles,
713
724
  injectSwitchControlStyles: () => injectSwitchControlStyles,
714
725
  interpolateTemperature: () => interpolateTemperature,
726
+ intervalsFromTelemetry: () => intervalsFromTelemetry,
715
727
  inventory: () => inventory_exports,
716
728
  isAlarmActive: () => isAlarmActive,
717
729
  isAnnotationOverdue: () => isOverdue,
@@ -741,10 +753,12 @@ __export(src_exports, {
741
753
  isValidTimeFormat: () => isValidTimeFormat,
742
754
  isWaterCategory: () => isWaterCategory,
743
755
  latestHourlyTemperature: () => latestHourlyTemperature,
756
+ latestPowerKw: () => latestPowerKw,
744
757
  liftProfileToTree: () => liftProfileToTree,
745
758
  listDeviceProductTypes: () => listDeviceProductTypes,
746
759
  listDomains: () => listDomains,
747
760
  listGroups: () => listGroups,
761
+ manualDeviceName: () => manualDeviceName,
748
762
  mapConnectionStatus: () => mapConnectionStatus,
749
763
  mapDeviceStatusToCardStatus: () => mapDeviceStatusToCardStatus,
750
764
  mapDeviceToConnectionStatus: () => mapDeviceToConnectionStatus,
@@ -753,6 +767,7 @@ __export(src_exports, {
753
767
  minutesToMs: () => minutesToMs,
754
768
  msToMinutes: () => msToMinutes,
755
769
  myioExportData: () => myioExportData,
770
+ nextManualSeq: () => nextManualSeq,
756
771
  nfdNormalizeAnnotationSearch: () => nfdNormalize,
757
772
  normalizeBudgetBlock: () => normalizeBudgetBlock,
758
773
  normalizeConnectionStatus: () => normalizeConnectionStatus,
@@ -790,6 +805,7 @@ __export(src_exports, {
790
805
  openGoalsPanel: () => openGoalsPanel,
791
806
  openHelpModal: () => openHelpModal,
792
807
  openIntegrationsModal: () => openIntegrationsModal,
808
+ openManualDeviceModal: () => openManualDeviceModal,
793
809
  openMeasurementSetupModal: () => openMeasurementSetupModal,
794
810
  openMessageDialog: () => openMessageDialog,
795
811
  openMetasGuide: () => openMetasGuide,
@@ -802,6 +818,8 @@ __export(src_exports, {
802
818
  openRealTimeTelemetryModal: () => openRealTimeTelemetryModal,
803
819
  openReportsHub: () => openReportsHub,
804
820
  openSettingsHubModal: () => openSettingsHubModal,
821
+ openStandardModal: () => openStandardModal,
822
+ openTelemetryImportModal: () => openTelemetryImportModal,
805
823
  openTemperatureComparisonModal: () => openTemperatureComparisonModal,
806
824
  openTemperatureModal: () => openTemperatureModal,
807
825
  openTemperatureSettingsModal: () => openTemperatureSettingsModal,
@@ -809,17 +827,21 @@ __export(src_exports, {
809
827
  openUpsellModal: () => openUpsellModal,
810
828
  openUserManagementModal: () => openUserManagementModal,
811
829
  openWelcomeModal: () => openWelcomeModal,
830
+ openWellPumpsModal: () => openWellPumpsModal,
812
831
  overlayWithholdsVerdict: () => overlayWithholdsVerdict,
813
832
  panelCategoryToWire: () => panelCategoryToWire,
814
833
  panelDomainToWire: () => panelDomainToWire,
815
834
  panelTermToDeviceCategory: () => panelTermToDeviceCategory,
835
+ parseBinaryState: () => parseBinaryState,
816
836
  parseClassificationEntities: () => parseClassificationEntities,
837
+ parseCsv: () => parseCsv,
817
838
  parseGcdrEnergyRoot: () => parseGcdrEnergyRoot,
818
839
  parseGcdrEntityForest: () => parseGcdrEntityForest,
819
840
  parseInputDateToDate: () => parseInputDateToDate,
820
841
  parseLogAnnotations: () => parseLogAnnotations,
821
842
  periodKey: () => periodKey,
822
843
  pickUniqueCustomerCode: () => pickUniqueCustomerCode,
844
+ pumpHistoryFromConsumption: () => pumpHistoryFromConsumption,
823
845
  readFreshdeskTicketsFromTB: () => readFreshdeskTicketsFromTB,
824
846
  recalculateDeviceStatus: () => recalculateDeviceStatus,
825
847
  recomputeDeviceGridPercentages: () => recomputePercentages,
@@ -847,6 +869,8 @@ __export(src_exports, {
847
869
  renderDashboardDowntimeList: () => renderDowntimeList,
848
870
  renderDeviceGridList: () => renderList,
849
871
  renderDualLineChart: () => renderDualLineChart,
872
+ renderEquipmentShortcutHTML: () => renderEquipmentShortcutHTML,
873
+ renderEquipmentTilesHTML: () => renderEquipmentTilesHTML,
850
874
  renderFinancialIndicators: () => renderFinancialIndicators,
851
875
  renderGatedMoney: () => renderGatedMoney,
852
876
  renderKPICards: () => renderKPICards,
@@ -871,17 +895,19 @@ __export(src_exports, {
871
895
  resolveSubcategory: () => resolveSubcategory,
872
896
  resolveWithFallback: () => resolveWithFallback,
873
897
  routeMoneyRender: () => routeMoneyRender,
898
+ rowsFromTable: () => rowsFromTable,
874
899
  schedCreateDateInput: () => createDateInput,
875
900
  schedCreateNumberInput: () => createNumberInput,
876
901
  schedCreateSelect: () => createSelect,
877
902
  schedCreateTimeInput: () => createTimeInput,
878
- schedEscapeHtml: () => escapeHtml15,
903
+ schedEscapeHtml: () => escapeHtml19,
879
904
  schedShowConfirmModal: () => showConfirmModal,
880
905
  schedShowNotificationModal: () => showNotificationModal,
881
906
  selectBreakdownItems: () => selectBreakdownItems,
882
907
  setActiveProfile: () => setActiveProfile,
883
908
  shouldFlashIcon: () => shouldFlashIcon,
884
909
  shouldVirtualizeAnnotationList: () => shouldVirtualize,
910
+ siglaFromManualAsset: () => siglaFromManualAsset,
885
911
  signOf: () => signOf,
886
912
  slugifyCustomerName: () => slugifyCustomerName,
887
913
  sortAnnotationGroups: () => sortGroups,
@@ -911,6 +937,7 @@ __export(src_exports, {
911
937
  validateDeviceProductName: () => validateDeviceProductName,
912
938
  validateProfile: () => validateProfile,
913
939
  validateTree: () => validateTree,
940
+ valveHistoryFromTelemetry: () => valveHistoryFromTelemetry,
914
941
  version: () => version,
915
942
  waterDeviceStatusIcons: () => waterDeviceStatusIcons,
916
943
  wireCategoryToPanel: () => wireCategoryToPanel,
@@ -923,7 +950,7 @@ module.exports = __toCommonJS(src_exports);
923
950
  // package.json
924
951
  var package_default = {
925
952
  name: "myio-js-library",
926
- version: "0.1.565",
953
+ version: "0.1.567",
927
954
  description: "A clean, standalone JS SDK for MYIO projects",
928
955
  license: "MIT",
929
956
  repository: "github:gh-myio/myio-js-library",
@@ -2307,6 +2334,7 @@ var DeviceIconType = {
2307
2334
  BOMBA_CAG: "BOMBA_CAG",
2308
2335
  BOMBA_INCENDIO: "BOMBA_INCENDIO",
2309
2336
  BOMBA: "BOMBA",
2337
+ BOMBA_POCO: "BOMBA_POCO",
2310
2338
  MEDIDOR_3F: "3F_MEDIDOR",
2311
2339
  RELOGIO: "RELOGIO",
2312
2340
  ENTRADA: "ENTRADA",
@@ -2318,6 +2346,8 @@ var DeviceIconType = {
2318
2346
  HIDROMETRO_AREA_COMUM: "HIDROMETRO_AREA_COMUM",
2319
2347
  HIDROMETRO_SHOPPING: "HIDROMETRO_SHOPPING",
2320
2348
  CAIXA_DAGUA: "CAIXA_DAGUA",
2349
+ CISTERNA: "CISTERNA",
2350
+ CISTERNA_ENTRADA: "CISTERNA_ENTRADA",
2321
2351
  TERMOSTATO: "TERMOSTATO",
2322
2352
  COMPRESSOR: "COMPRESSOR",
2323
2353
  VENTILADOR: "VENTILADOR",
@@ -2327,6 +2357,11 @@ var DeviceIconType = {
2327
2357
  };
2328
2358
  var BOX_ICON_SVG = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" fill="none" stroke-linejoin="round"><ellipse cx="48" cy="85" rx="36" ry="5" fill="#000" opacity=".08"/><polygon points="12,40 56,22 84,36 40,54" fill="#E3BC85" stroke="#7A5527" stroke-width="2"/><polygon points="12,40 40,54 40,84 12,70" fill="#C99A5B" stroke="#7A5527" stroke-width="2"/><polygon points="40,54 84,36 84,66 40,84" fill="#B5823F" stroke="#7A5527" stroke-width="2"/><polygon points="22.6,45.3 66.6,27.3 73.4,30.7 29.4,48.7" fill="#F3DDB0"/><polygon points="22.6,45.3 29.4,48.7 29.4,59 22.6,55.6" fill="#E6CB96"/><path d="M26 47L70 29" stroke="#7A5527" stroke-width="1" opacity=".55"/><polygon points="64.2,59.1 77.4,53.7 77.4,62.7 64.2,68.1" fill="#FBF6EC" stroke="#7A5527" stroke-width="1"/><path d="M66.6 61.4l8.6-3.5M66.6 64.6l5.6-2.3" stroke="#7A5527" stroke-width="1.2" stroke-linecap="round"/></svg>';
2329
2359
  var BOX_ICON_DATA_URI = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(BOX_ICON_SVG);
2360
+ var CISTERNA_ICON_SVG = (
2361
+ // width/height explícitos: sem tamanho intrínseco o <img> do card (.device-image, height auto) renderiza 0×0
2362
+ '<svg xmlns="http://www.w3.org/2000/svg" width="96" height="96" viewBox="0 0 96 96" fill="none" stroke-linejoin="round" stroke-linecap="round"><path d="M3 36h24M66 40h10M66 66h10" stroke="#0B3B5C" stroke-width="7"/><path d="M3 36h24M66 40h10M66 66h10" stroke="#B0BEC5" stroke-width="3.5"/><path d="M26 28v46c0 3.3 9 6 20 6s20-2.7 20-6V28" fill="#29B6F6"/><path d="M26 44c0 3.3 9 6 20 6s20-2.7 20-6v15c0 3.3-9 6-20 6s-20-2.7-20-6z" fill="#4FC3F7"/><path d="M26 44c0 3.3 9 6 20 6s20-2.7 20-6M26 59c0 3.3 9 6 20 6s20-2.7 20-6" stroke="#0B3B5C" stroke-width="2.5"/><path d="M26 28v46c0 3.3 9 6 20 6s20-2.7 20-6V28" stroke="#0B3B5C" stroke-width="3.5"/><ellipse cx="46" cy="28" rx="20" ry="6" fill="#81D4FA" stroke="#0B3B5C" stroke-width="3.5"/><path d="M14 36v-9" stroke="#0B3B5C" stroke-width="2.5"/><rect x="8.5" y="17" width="11" height="9" rx="2" fill="#FFB300" stroke="#0B3B5C" stroke-width="2.5"/><path d="M8 30l12 12V30L8 42z" fill="#29B6F6" stroke="#0B3B5C" stroke-width="2.5"/><circle cx="83" cy="40" r="9" fill="#ECEFF1" stroke="#0B3B5C" stroke-width="3"/><path d="M87 35v10l-8-5z" fill="#0B3B5C"/><circle cx="83" cy="66" r="9" fill="#ECEFF1" stroke="#0B3B5C" stroke-width="3"/><path d="M87 61v10l-8-5z" fill="#0B3B5C"/></svg>'
2363
+ );
2364
+ var CISTERNA_ICON_DATA_URI = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(CISTERNA_ICON_SVG);
2330
2365
  var deviceIcons = {
2331
2366
  ESCADA_ROLANTE: "https://dashboard.myio-bas.com/api/images/public/EJ997iB2HD1AYYUHwIloyQOOszeqb2jp",
2332
2367
  ELEVADOR: "https://dashboard.myio-bas.com/api/images/public/rAjOvdsYJLGah6w6BABPJSD9znIyrkJX",
@@ -2335,6 +2370,8 @@ var deviceIcons = {
2335
2370
  BOMBA_CAG: "https://dashboard.myio-bas.com/api/images/public/rbO2wQb6iKBtX0Ec04DFDcO3Qg04EOoD",
2336
2371
  BOMBA_INCENDIO: "https://dashboard.myio-bas.com/api/images/public/YJkELCk9kluQSM6QXaFINX6byQWI7vbB",
2337
2372
  BOMBA: "https://dashboard.myio-bas.com/api/images/public/Rge8Q3t0CP5PW8XyTn9bBK9aVP6uzSTT",
2373
+ // BOMBA_POCO (ED-1354): bomba de poço artesiano — sem arte própria ainda, usa a do MOTOR/BOMBA.
2374
+ BOMBA_POCO: "https://dashboard.myio-bas.com/api/images/public/Rge8Q3t0CP5PW8XyTn9bBK9aVP6uzSTT",
2338
2375
  "3F_MEDIDOR": "https://dashboard.myio-bas.com/api/images/public/f9Ce4meybsdaAhAkUlAfy5ei3I4kcN4k",
2339
2376
  RELOGIO: "https://dashboard.myio-bas.com/api/images/public/ljHZostWg0G5AfKiyM8oZixWRIIGRASB",
2340
2377
  ENTRADA: "https://dashboard.myio-bas.com/api/images/public/TQHPFqiejMW6lOSVsb8Pi85WtC0QKOLU",
@@ -2349,6 +2386,10 @@ var deviceIcons = {
2349
2386
  HIDROMETRO_AREA_COMUM: "https://dashboard.myio-bas.com/api/images/public/IbEhjsvixAxwKg1ntGGZc5xZwwvGKv2t",
2350
2387
  HIDROMETRO_SHOPPING: "https://dashboard.myio-bas.com/api/images/public/OIMmvN4ZTKYDvrpPGYY5agqMRoSaWNTI",
2351
2388
  CAIXA_DAGUA: "https://dashboard.myio-bas.com/api/images/public/3t6WVhMQJFsrKA8bSZmrngDsNPkZV7fq",
2389
+ // CISTERNA (ED-1354): poço/cisterna (nível + bombas BOMBA_POCO + solenoides) — SVG inline no estilo do TANK.
2390
+ CISTERNA: CISTERNA_ICON_DATA_URI,
2391
+ // CISTERNA_ENTRADA: mesma arte — o sufixo só decide a coluna (Entrada × Área Comum)
2392
+ CISTERNA_ENTRADA: CISTERNA_ICON_DATA_URI,
2352
2393
  TERMOSTATO: "https://dashboard.myio-bas.com/api/images/public/rtCcq6kZZVCD7wgJywxEurRZwR8LA7Q7",
2353
2394
  // COMPRESSOR shares FANCOIL art; VENTILADOR shares MOTOR/BOMBA art (single static icons, no on/off variation).
2354
2395
  COMPRESSOR: "https://dashboard.myio-bas.com/api/images/public/4BWMuVIFHnsfqatiV86DmTrOB7IF0X8Y",
@@ -2369,6 +2410,7 @@ var deviceIconLabels = {
2369
2410
  BOMBA_CAG: "Bomba CAG",
2370
2411
  BOMBA_INCENDIO: "Bomba Inc\xEAndio",
2371
2412
  BOMBA: "Bomba",
2413
+ BOMBA_POCO: "Bomba de Po\xE7o",
2372
2414
  "3F_MEDIDOR": "Medidor 3F",
2373
2415
  RELOGIO: "Rel\xF3gio",
2374
2416
  ENTRADA: "Entrada",
@@ -2380,6 +2422,8 @@ var deviceIconLabels = {
2380
2422
  HIDROMETRO_AREA_COMUM: "Hidr\xF4metro \xC1rea Comum",
2381
2423
  HIDROMETRO_SHOPPING: "Hidr\xF4metro Shopping",
2382
2424
  CAIXA_DAGUA: "Caixa d'\xC1gua",
2425
+ CISTERNA: "Cisterna",
2426
+ CISTERNA_ENTRADA: "Cisterna (Entrada)",
2383
2427
  TERMOSTATO: "Termostato",
2384
2428
  COMPRESSOR: "Compressor",
2385
2429
  VENTILADOR: "Ventilador",
@@ -2421,7 +2465,15 @@ var DEVICE_TYPE_CONFIG = {
2421
2465
  HIDROMETRO: { category: "water", image: deviceIcons.HIDROMETRO },
2422
2466
  HIDROMETRO_AREA_COMUM: { category: "water", image: deviceIcons.HIDROMETRO_AREA_COMUM },
2423
2467
  HIDROMETRO_SHOPPING: { category: "water", image: deviceIcons.HIDROMETRO_SHOPPING },
2468
+ HIDROMETRO_ENTRADA: { category: "water", image: deviceIcons.HIDROMETRO_SHOPPING },
2469
+ // Virtual: Entrada − Σ consumos (calculado no dashboard; card informativo na coluna Entrada)
2470
+ HIDROMETRO_ENTRADA_RETROLAVAGEM: { category: "water", image: deviceIcons.HIDROMETRO_SHOPPING },
2424
2471
  CAIXA_DAGUA: { category: "water", image: deviceIcons.CAIXA_DAGUA },
2472
+ // ED-1354: poço/cisterna (nível, como CAIXA_DAGUA) — _ENTRADA vai p/ a coluna Entrada, o outro p/ Área Comum
2473
+ CISTERNA: { category: "water", image: deviceIcons.CISTERNA },
2474
+ CISTERNA_ENTRADA: { category: "water", image: deviceIcons.CISTERNA_ENTRADA },
2475
+ BOMBA_POCO: { category: "energy", image: deviceIcons.BOMBA_POCO },
2476
+ // ED-1354: bomba do poço (consumption W)
2425
2477
  // Tank devices (dynamic images based on level)
2426
2478
  TANK: { category: "tank", image: null },
2427
2479
  // Temperature devices (dynamic images based on status)
@@ -20781,6 +20833,251 @@ function resolvePercentDecimals(explicit) {
20781
20833
  return 2;
20782
20834
  }
20783
20835
 
20836
+ // src/components/well-pumps/equipmentState.ts
20837
+ var HOUR_MS = 36e5;
20838
+ var DAY_MS = 24 * HOUR_MS;
20839
+ var TRUE_WORDS = /* @__PURE__ */ new Set(["1", "true", "on", "ligada", "ligado", "open", "opened", "aberta", "aberto", "running", "run"]);
20840
+ var FALSE_WORDS = /* @__PURE__ */ new Set(["0", "false", "off", "desligada", "desligado", "closed", "close", "fechada", "fechado", "stopped", "stop"]);
20841
+ function parseBinaryState(value) {
20842
+ if (typeof value === "boolean") return value;
20843
+ if (typeof value === "number") return Number.isFinite(value) ? value !== 0 : null;
20844
+ if (typeof value !== "string") return null;
20845
+ const v = value.trim().toLowerCase();
20846
+ if (TRUE_WORDS.has(v)) return true;
20847
+ if (FALSE_WORDS.has(v)) return false;
20848
+ const n = Number(v);
20849
+ return v !== "" && Number.isFinite(n) ? n !== 0 : null;
20850
+ }
20851
+ function intervalsFromTelemetry(points, opts = {}) {
20852
+ const toState = (v) => {
20853
+ if (typeof opts.threshold !== "number") return parseBinaryState(v);
20854
+ const n = typeof v === "number" ? v : typeof v === "string" && v.trim() !== "" ? Number(v) : NaN;
20855
+ return Number.isFinite(n) ? n > opts.threshold : null;
20856
+ };
20857
+ const sorted = (points || []).map((p) => ({ ts: Number(p?.ts), state: toState(p?.value) })).filter((p) => Number.isFinite(p.ts) && p.state !== null).sort((a, b) => a.ts - b.ts);
20858
+ const out = [];
20859
+ let open = null;
20860
+ for (const p of sorted) {
20861
+ if (p.state && open === null) open = p.ts;
20862
+ else if (!p.state && open !== null) {
20863
+ out.push([open, p.ts]);
20864
+ open = null;
20865
+ }
20866
+ }
20867
+ if (open !== null) out.push([open, null]);
20868
+ return out;
20869
+ }
20870
+ function hasUsableTelemetryPoint(points, parseValue) {
20871
+ return (points || []).some((point) => {
20872
+ const ts = Number(point?.ts);
20873
+ return point?.ts !== null && point?.ts !== void 0 && Number.isFinite(ts) && parseValue(point?.value) !== null;
20874
+ });
20875
+ }
20876
+ function parseNumericTelemetry(value) {
20877
+ if (typeof value !== "number" && typeof value !== "string") return null;
20878
+ if (typeof value === "string" && value.trim() === "") return null;
20879
+ const number = Number(value);
20880
+ return Number.isFinite(number) ? number : null;
20881
+ }
20882
+ var PUMP_POWER_KEY = "consumption";
20883
+ var VALVE_STATE_KEYS = ["state", "status"];
20884
+ function pumpHistoryFromConsumption(points, thresholdW = 0) {
20885
+ if (!hasUsableTelemetryPoint(points, parseNumericTelemetry)) return null;
20886
+ return intervalsFromTelemetry(points, { threshold: thresholdW });
20887
+ }
20888
+ function valveHistoryFromTelemetry(points) {
20889
+ if (!hasUsableTelemetryPoint(points, parseBinaryState)) return null;
20890
+ return intervalsFromTelemetry(points);
20891
+ }
20892
+ function latestPowerKw(points) {
20893
+ let best = null;
20894
+ for (const p of points || []) {
20895
+ const ts = Number(p?.ts);
20896
+ const v = parseNumericTelemetry(p?.value);
20897
+ if (!Number.isFinite(ts) || v === null) continue;
20898
+ if (!best || ts > best.ts) best = { ts, v };
20899
+ }
20900
+ return best ? best.v / 1e3 : null;
20901
+ }
20902
+ function isActive(history) {
20903
+ const last = history?.[history.length - 1];
20904
+ return !!last && last[1] === null;
20905
+ }
20906
+ function stateSince(history) {
20907
+ const last = history?.[history.length - 1];
20908
+ if (!last) return null;
20909
+ return last[1] === null ? last[0] : last[1];
20910
+ }
20911
+ function dayStats(history, now = Date.now()) {
20912
+ const midnight = new Date(now);
20913
+ midnight.setHours(0, 0, 0, 0);
20914
+ const m = midnight.getTime();
20915
+ let activeMs = 0;
20916
+ let starts = 0;
20917
+ for (const [s, e] of history || []) {
20918
+ const end = Math.min(e ?? now, now);
20919
+ const a = Math.max(s, m);
20920
+ if (end > a) activeMs += end - a;
20921
+ if (s >= m && s <= now) starts++;
20922
+ }
20923
+ return { activeMs, starts };
20924
+ }
20925
+ function timelineSegments(history, now = Date.now(), windowMs = DAY_MS) {
20926
+ const from = now - windowMs;
20927
+ const out = [];
20928
+ for (const [s, e] of history || []) {
20929
+ const b = Math.min(e ?? now, now);
20930
+ if (b <= from || s >= now) continue;
20931
+ const a = Math.max(s, from);
20932
+ out.push({
20933
+ leftPct: (a - from) / windowMs * 100,
20934
+ widthPct: Math.max((b - a) / windowMs * 100, 0.6),
20935
+ live: e === null,
20936
+ start: s,
20937
+ end: e
20938
+ });
20939
+ }
20940
+ return out;
20941
+ }
20942
+ function formatClock(ts) {
20943
+ if (ts === null || ts === void 0 || !Number.isFinite(ts)) return "\u2014";
20944
+ return new Date(ts).toLocaleTimeString("pt-BR", { hour: "2-digit", minute: "2-digit" });
20945
+ }
20946
+ function formatDuration2(ms) {
20947
+ const m = Math.max(0, Math.round(ms / 6e4));
20948
+ return m < 60 ? `${m} min` : `${Math.floor(m / 60)} h ${String(m % 60).padStart(2, "0")}`;
20949
+ }
20950
+ function indicatorsFromModalData(data) {
20951
+ if (!data) return [];
20952
+ const list = (data.pumps || []).map((p) => ({
20953
+ code: p.code,
20954
+ label: p.label,
20955
+ kind: "pump",
20956
+ active: Array.isArray(p.history) ? isActive(p.history) : null,
20957
+ since: stateSince(p.history),
20958
+ deviceProfile: p.deviceProfile || "BOMBA_POCO"
20959
+ }));
20960
+ (data.valves || []).forEach((v) => {
20961
+ list.push({
20962
+ code: v.code,
20963
+ label: v.label,
20964
+ kind: "valve",
20965
+ active: Array.isArray(v.history) ? isActive(v.history) : null,
20966
+ since: stateSince(v.history),
20967
+ deviceProfile: v.deviceProfile || "SOLENOIDE"
20968
+ });
20969
+ });
20970
+ return list;
20971
+ }
20972
+
20973
+ // src/components/well-pumps/equipmentIndicators.ts
20974
+ var STYLE_ID4 = "myio-equipment-indicators-styles";
20975
+ var PUMP_SVG = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><circle cx="12" cy="12" r="8"/><g class="myio-eq-rotor"><path d="M12 4v4M12 16v4M4 12h4M16 12h4"/></g></svg>`;
20976
+ var VALVE_SVG = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linejoin="round" aria-hidden="true"><path d="M3 7v10l9-5zM21 7v10l-9-5z"/><path d="M12 12V5M9 5h6"/></svg>`;
20977
+ function escapeHtml2(s) {
20978
+ return String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c]);
20979
+ }
20980
+ function indicatorStateClass(ind) {
20981
+ if (ind.active === null || ind.active === void 0) return "unk";
20982
+ if (ind.kind === "valve") return ind.active ? "open" : "closed";
20983
+ return ind.active ? "on" : "off";
20984
+ }
20985
+ function indicatorStateText(ind, short = false) {
20986
+ if (ind.active === null || ind.active === void 0) return short ? "S/ leit." : "sem leitura";
20987
+ if (ind.kind === "valve") return ind.active ? short ? "Aberta" : "aberta" : short ? "Fechada" : "fechada";
20988
+ return ind.active ? short ? "Ligada" : "ligada" : short ? "Deslig." : "desligada";
20989
+ }
20990
+ function indicatorTitle(ind) {
20991
+ const profile = ind.deviceProfile ? ` (${ind.deviceProfile})` : "";
20992
+ const since = ind.since ? ` desde ${formatClock(ind.since)}` : "";
20993
+ return `${ind.code} \xB7 ${ind.label}${profile}: ${indicatorStateText(ind)}${ind.active === null || ind.active === void 0 ? "" : since}`;
20994
+ }
20995
+ function ensureEquipmentIndicatorStyles() {
20996
+ if (typeof document === "undefined" || document.getElementById(STYLE_ID4)) return;
20997
+ const style = document.createElement("style");
20998
+ style.id = STYLE_ID4;
20999
+ style.textContent = `
21000
+ .myio-eq-strip{position:absolute;right:12px;top:50%;transform:translateY(-50%);z-index:25;display:flex;flex-direction:column;flex-wrap:wrap-reverse;align-content:flex-end;max-height:96px;gap:4px;font-family:Nunito,system-ui,sans-serif}
21001
+ .myio-eq-strip.clickable{cursor:pointer}
21002
+ .myio-eq-b{position:relative;display:inline-flex;align-items:center;justify-content:center;min-width:26px;height:22px;padding:0 5px;
21003
+ border-radius:6px;font:800 11px Nunito,system-ui,sans-serif;border:1.5px solid;transition:all .25s;box-sizing:border-box}
21004
+ .myio-eq-b svg{width:13px;height:13px}
21005
+ .myio-eq-b.on{background:#22c55e;border-color:#16a34a;color:#fff;box-shadow:0 0 0 2px rgba(34,197,94,.25)}
21006
+ .myio-eq-b.off{background:#f1f5f9;border-color:#cbd5e1;color:#94a3b8}
21007
+ .myio-eq-b.open{background:#3b82f6;border-color:#1d4ed8;color:#fff;box-shadow:0 0 0 2px rgba(59,130,246,.25)}
21008
+ .myio-eq-b.closed{background:#fef2f2;border-color:#f87171;color:#dc2626}
21009
+ .myio-eq-b.unk{background:#fff;border-style:dashed;border-color:#cbd5e1;color:#94a3b8}
21010
+ .myio-eq-b.on::after,.myio-eq-b.open::after{content:'';position:absolute;top:-3px;right:-3px;width:7px;height:7px;border-radius:50%;
21011
+ border:1.5px solid #fff;animation:myioEqPulse 1.4s ease-in-out infinite}
21012
+ .myio-eq-b.on::after{background:#16a34a}.myio-eq-b.open::after{background:#1d4ed8}
21013
+
21014
+ .myio-eq-tiles{display:flex;gap:6px;justify-content:center;flex-wrap:wrap}
21015
+ .myio-eq-ti{width:50px;padding:6px 0 5px;border-radius:10px;background:rgba(255,255,255,.75);border:1px solid #e2e8f0;
21016
+ box-shadow:0 1px 2px rgba(15,23,42,.06);display:flex;flex-direction:column;align-items:center;gap:2px;
21017
+ font-family:Nunito,system-ui,sans-serif;transition:all .3s}
21018
+ .myio-eq-ti b{font-size:11.5px;font-weight:800;color:#334155;line-height:1}
21019
+ .myio-eq-ti small{font-size:9px;font-weight:700;color:#94a3b8;text-transform:uppercase;letter-spacing:.3px;line-height:1}
21020
+ .myio-eq-ti i{width:8px;height:8px;border-radius:50%;background:#cbd5e1;margin-bottom:2px}
21021
+ .myio-eq-ti.on{border-color:#bbf7d0;background:linear-gradient(180deg,#f0fdf4,#fff)}
21022
+ .myio-eq-ti.on i{background:#22c55e;box-shadow:0 0 0 3px rgba(34,197,94,.18);animation:myioEqPulse 1.6s ease-in-out infinite}
21023
+ .myio-eq-ti.on small{color:#16a34a}
21024
+ .myio-eq-ti.open{border-color:#bfdbfe;background:linear-gradient(180deg,#eff6ff,#fff)}
21025
+ .myio-eq-ti.open i{background:#3b82f6;box-shadow:0 0 0 3px rgba(59,130,246,.18);animation:myioEqPulse 1.6s ease-in-out infinite}
21026
+ .myio-eq-ti.open small{color:#2563eb}
21027
+ .myio-eq-ti.closed{border-color:#fecaca}.myio-eq-ti.closed i{background:#ef4444}.myio-eq-ti.closed small{color:#dc2626}
21028
+
21029
+ .myio-eq-shortcut{display:inline-flex;align-items:center;gap:5px;margin-right:6px;padding:5px 10px;border-radius:8px;cursor:pointer;
21030
+ background:rgba(255,255,255,.14);border:1px solid rgba(255,255,255,.35);color:#fff;font:700 12px Nunito,system-ui,sans-serif}
21031
+ .myio-eq-shortcut:hover{background:rgba(255,255,255,.26)}
21032
+ .myio-eq-shortcut svg{width:15px;height:15px}
21033
+ .myio-eq-shortcut i{font-style:normal;font-size:10px;font-weight:800;padding:1px 5px;border-radius:4px}
21034
+ .myio-eq-shortcut i.on{background:#22c55e;color:#fff}.myio-eq-shortcut i.off,.myio-eq-shortcut i.unk{background:rgba(255,255,255,.25);color:#e2e8f0}
21035
+ .myio-eq-shortcut i.open{background:#3b82f6;color:#fff}.myio-eq-shortcut i.closed{background:#ef4444;color:#fff}
21036
+
21037
+ .myio-eq-rotor{transform-origin:12px 12px}
21038
+ .myio-eq-spin .myio-eq-rotor{animation:myioEqSpin 1s linear infinite}
21039
+ @keyframes myioEqSpin{to{transform:rotate(360deg)}}
21040
+ @keyframes myioEqPulse{0%,100%{opacity:1}50%{opacity:.35}}
21041
+ @media (prefers-reduced-motion:reduce){.myio-eq-b::after,.myio-eq-ti i,.myio-eq-spin .myio-eq-rotor{animation:none!important}}
21042
+ `;
21043
+ document.head.appendChild(style);
21044
+ }
21045
+ function renderEquipmentStripHTML(indicators) {
21046
+ return (indicators || []).map((ind) => {
21047
+ const cls = indicatorStateClass(ind);
21048
+ const content = ind.kind === "valve" && ind.code.length <= 1 ? VALVE_SVG : escapeHtml2(ind.code);
21049
+ return `<span class="myio-eq-b ${cls}" data-code="${escapeHtml2(ind.code)}" title="${escapeHtml2(indicatorTitle(ind))}">${content}</span>`;
21050
+ }).join("");
21051
+ }
21052
+ function createEquipmentIndicatorStrip(indicators, opts = {}) {
21053
+ ensureEquipmentIndicatorStyles();
21054
+ const el2 = document.createElement("div");
21055
+ el2.className = "myio-eq-strip";
21056
+ el2.setAttribute("role", "group");
21057
+ el2.setAttribute("aria-label", "Bombas e solenoide");
21058
+ el2.innerHTML = renderEquipmentStripHTML(indicators);
21059
+ if (typeof opts.onClick === "function") {
21060
+ el2.classList.add("clickable");
21061
+ el2.addEventListener("click", (ev) => {
21062
+ ev.stopPropagation();
21063
+ ev.preventDefault();
21064
+ opts.onClick(ev);
21065
+ });
21066
+ }
21067
+ return el2;
21068
+ }
21069
+ function renderEquipmentTilesHTML(indicators) {
21070
+ if (!indicators?.length) return "";
21071
+ return `<div class="myio-eq-tiles">${indicators.map((ind) => {
21072
+ const cls = indicatorStateClass(ind);
21073
+ return `<div class="myio-eq-ti ${cls}" title="${escapeHtml2(indicatorTitle(ind))}"><i></i><b>${escapeHtml2(ind.code)}</b><small>${indicatorStateText(ind, true)}</small></div>`;
21074
+ }).join("")}</div>`;
21075
+ }
21076
+ function renderEquipmentShortcutHTML(indicators, label = "Bombas") {
21077
+ const anyOn = (indicators || []).some((i) => i.kind === "pump" && i.active === true);
21078
+ 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("");
21079
+ }
21080
+
20784
21081
  // src/components/cards/main-view/v5.2.0/template-card-v5.js
20785
21082
  var LABEL_CHAR_LIMIT2 = 18;
20786
21083
  var ENERGY_DEVICE_TYPES = getTypesByCategory("energy");
@@ -20815,7 +21112,9 @@ function renderCardComponentV5({
20815
21112
  // Tooltip on device image for temperature devices
20816
21113
  // Decimal places for the % badge. Resolved at render time so it can be changed
20817
21114
  // without rebuilding the lib: this prop > window.MyIOUtils.percentDecimals > 2.
20818
- percentDecimals
21115
+ percentDecimals,
21116
+ // ED-1354: clique na coluna B1/B2/S (entityObject.equipmentIndicators) — ex.: abre a modal das bombas
21117
+ handleActionEquipment
20819
21118
  }) {
20820
21119
  const {
20821
21120
  entityId,
@@ -20864,10 +21163,14 @@ function renderCardComponentV5({
20864
21163
  excludeGroupsTotals,
20865
21164
  // Card já desenhado, telemetria (valor/status) ainda chegando → spinner no valor, sem selo,
20866
21165
  // status neutro (não marca offline nem pisca enquanto carrega)
20867
- dataLoading = false
21166
+ dataLoading = false,
21167
+ // ED-1354: indicadores B1/B2/S (bombas MOTOR + solenoide) no card do poço
21168
+ equipmentIndicators
20868
21169
  } = entityObject;
20869
- const deviceStatus = dataLoading ? "loading" : rawDeviceStatus;
20870
- const deviceType = deviceProfile || legacyDeviceType || "";
21170
+ const rawProfile = String(deviceProfile || legacyDeviceType || "");
21171
+ const isManualDevice = /_MANUAL$/i.test(rawProfile);
21172
+ const deviceType = isManualDevice ? rawProfile.replace(/_MANUAL$/i, "") : rawProfile;
21173
+ const deviceStatus = dataLoading ? "loading" : isManualDevice ? "power_on" : rawDeviceStatus;
20871
21174
  const MyIOToast2 = (function() {
20872
21175
  let toastContainer = null;
20873
21176
  let toastTimeout = null;
@@ -21019,7 +21322,7 @@ function renderCardComponentV5({
21019
21322
  };
21020
21323
  const isEnergyDevice2 = (deviceType2) => isEnergyDeviceType(deviceType2);
21021
21324
  const isTemperatureDevice2 = (deviceType2) => isTemperatureDeviceType(deviceType2);
21022
- const isTankDevice2 = deviceType === "TANK" || deviceType === "CAIXA_DAGUA";
21325
+ const isTankDevice2 = deviceType === "TANK" || deviceType === "CAIXA_DAGUA" || deviceType === "CISTERNA" || deviceType === "CISTERNA_ENTRADA";
21023
21326
  const percentageForDisplay = isTankDevice2 ? (waterPercentage || 0) * 100 : perc;
21024
21327
  const tankLevelCm = isTankDevice2 ? Number(waterLevel ?? val) : null;
21025
21328
  const _pctDecimals = resolvePercentDecimals(percentDecimals);
@@ -21455,6 +21758,13 @@ function renderCardComponentV5({
21455
21758
  `;
21456
21759
  container.innerHTML = cardHTML;
21457
21760
  const enhancedCardElement = container.querySelector(".device-card-centered");
21761
+ if (Array.isArray(equipmentIndicators) && equipmentIndicators.length > 0 && enhancedCardElement) {
21762
+ enhancedCardElement.appendChild(
21763
+ createEquipmentIndicatorStrip(equipmentIndicators, {
21764
+ onClick: typeof handleActionEquipment === "function" ? () => handleActionEquipment(entityObject) : void 0
21765
+ })
21766
+ );
21767
+ }
21458
21768
  try {
21459
21769
  const _excl = typeof excludeGroupsTotals === "string" ? JSON.parse(excludeGroupsTotals) : excludeGroupsTotals;
21460
21770
  const _isExcluded = !!(_excl && _excl.enabled === true && (_excl.groups && Object.values(_excl.groups).some((v) => v === true) || Array.isArray(_excl.excludedGroups) && _excl.excludedGroups.length > 0));
@@ -27318,7 +27628,7 @@ var TOAST_TYPE_META = {
27318
27628
  warning: { icon: "\u26A0\uFE0F", title: "Aviso" },
27319
27629
  error: { icon: "\u{1F6AB}", title: "Erro" }
27320
27630
  };
27321
- function escapeHtml2(text2) {
27631
+ function escapeHtml3(text2) {
27322
27632
  const div = document.createElement("div");
27323
27633
  div.textContent = text2 == null ? "" : String(text2);
27324
27634
  return div.innerHTML;
@@ -27515,7 +27825,7 @@ var MyIOToast = (function() {
27515
27825
  InfoTooltip_default.show(expandBtn, {
27516
27826
  icon: meta.icon,
27517
27827
  title: meta.title,
27518
- content: escapeHtml2(fullMessage).replace(/\n/g, "<br>")
27828
+ content: escapeHtml3(fullMessage).replace(/\n/g, "<br>")
27519
27829
  });
27520
27830
  });
27521
27831
  toastEl.appendChild(expandBtn);
@@ -32119,8 +32429,8 @@ var EnergyDataFetcher = class {
32119
32429
  // src/components/premium-modals/internal/engines/CsvExporter.ts
32120
32430
  var toCsv = (rows, locale = "pt-BR", sep = ";") => {
32121
32431
  const fmt2 = new Intl.NumberFormat(locale, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
32122
- const esc9 = (v) => (typeof v === "number" ? fmt2.format(v) : String(v)).replace(/"/g, '""');
32123
- return rows.map((r) => r.map((c) => `"${esc9(c)}"`).join(sep)).join("\r\n");
32432
+ const esc10 = (v) => (typeof v === "number" ? fmt2.format(v) : String(v)).replace(/"/g, '""');
32433
+ return rows.map((r) => r.map((c) => `"${esc10(c)}"`).join(sep)).join("\r\n");
32124
32434
  };
32125
32435
 
32126
32436
  // src/components/premium-modals/energy/types.ts
@@ -35759,7 +36069,7 @@ function paletteColor(base, index, dark) {
35759
36069
  }
35760
36070
  var defaultFormatValue = (v) => Number(v || 0).toLocaleString("pt-BR", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
35761
36071
  var fmtPct = (pct) => `${pct.toLocaleString("pt-BR", { minimumFractionDigits: 0, maximumFractionDigits: 1 })}%`;
35762
- function escapeHtml3(s) {
36072
+ function escapeHtml4(s) {
35763
36073
  return String(s).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
35764
36074
  }
35765
36075
  function slugify2(s) {
@@ -35924,7 +36234,7 @@ function createParticipationChart(container, params) {
35924
36234
  content: `
35925
36235
  <div class="myio-info-tooltip__section" style="min-width:180px;">
35926
36236
  <div style="font-size:12px;line-height:1.6;">
35927
- <div><strong>Valor:</strong> ${escapeHtml3(settings.formatValue(item.value))}${settings.unit ? ` ${escapeHtml3(settings.unit)}` : ""}</div>
36237
+ <div><strong>Valor:</strong> ${escapeHtml4(settings.formatValue(item.value))}${settings.unit ? ` ${escapeHtml4(settings.unit)}` : ""}</div>
35928
36238
  <div><strong>Participa\xE7\xE3o:</strong> ${fmtPct(pct)}</div>
35929
36239
  </div>
35930
36240
  </div>
@@ -36471,14 +36781,14 @@ var DeviceReportModal = class {
36471
36781
  // Header: "Relatório - <identifier> - <label>" + nome do device (sutil, com copiar).
36472
36782
  // O customer já aparece no footer premium. Texto escapado — o shell usa innerHTML no título.
36473
36783
  buildHeaderTitleHTML() {
36474
- const esc9 = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
36475
- const base = esc9(
36784
+ const esc10 = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
36785
+ const base = esc10(
36476
36786
  `Relat\xF3rio - ${this.params.identifier || "SEM IDENTIFICADOR"} - ${this.params.label || "SEM ETIQUETA"}`
36477
36787
  );
36478
36788
  const deviceName = String(this.params.deviceName || "").trim();
36479
36789
  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;">
36480
- ${esc9(deviceName)}
36481
- <button type="button" class="myio-dr-copy" data-copy="${esc9(deviceName)}" title="Copiar nome do dispositivo"
36790
+ ${esc10(deviceName)}
36791
+ <button type="button" class="myio-dr-copy" data-copy="${esc10(deviceName)}" title="Copiar nome do dispositivo"
36482
36792
  aria-label="Copiar nome do dispositivo"
36483
36793
  style="border:none;background:transparent;color:inherit;cursor:pointer;padding:0 2px;line-height:1;opacity:.9;display:inline-flex;">
36484
36794
  <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>
@@ -41006,6 +41316,9 @@ var WaterTankModalView = class {
41006
41316
  * Get tank image URL based on level percentage (same logic as device card)
41007
41317
  */
41008
41318
  getTankImageUrl(percentage) {
41319
+ if (/^CISTERNA(_ENTRADA)?$/.test(String(this.config.params.deviceType || "").toUpperCase())) {
41320
+ return deviceIcons.CISTERNA;
41321
+ }
41009
41322
  if (percentage >= 70) {
41010
41323
  return "https://dashboard.myio-bas.com/api/images/public/3t6WVhMQJFsrKA8bSZmrngDsNPkZV7fq";
41011
41324
  } else if (percentage >= 40) {
@@ -41043,10 +41356,10 @@ var WaterTankModalView = class {
41043
41356
  */
41044
41357
  render() {
41045
41358
  const { params } = this.config;
41046
- const STYLE_ID18 = "myio-water-tank-modal-styles";
41047
- if (!document.getElementById(STYLE_ID18)) {
41359
+ const STYLE_ID23 = "myio-water-tank-modal-styles";
41360
+ if (!document.getElementById(STYLE_ID23)) {
41048
41361
  const style = document.createElement("style");
41049
- style.id = STYLE_ID18;
41362
+ style.id = STYLE_ID23;
41050
41363
  style.textContent = `
41051
41364
  @media (max-width: 640px) {
41052
41365
  .myio-water-tank-modal { width: 100vw !important; max-width: 100vw !important; max-height: 100vh !important; border-radius: 0 !important; }
@@ -41059,6 +41372,7 @@ var WaterTankModalView = class {
41059
41372
  `;
41060
41373
  document.head.appendChild(style);
41061
41374
  }
41375
+ if (params.equipmentIndicators?.length || params.headerActions?.length) ensureEquipmentIndicatorStyles();
41062
41376
  this.overlay = document.createElement("div");
41063
41377
  this.overlay.className = "myio-water-tank-modal-overlay";
41064
41378
  this.overlay.style.cssText = `
@@ -41122,6 +41436,7 @@ var WaterTankModalView = class {
41122
41436
  line-height: 2;
41123
41437
  ">\u{1F4A7} ${title}</h2>
41124
41438
  <div style="display: flex; gap: 4px; align-items: center;">
41439
+ ${this.renderHeaderActions()}
41125
41440
  <button class="myio-water-tank-modal-close" title="${this.i18n.close}" style="
41126
41441
  background: none;
41127
41442
  border: none;
@@ -41136,6 +41451,46 @@ var WaterTankModalView = class {
41136
41451
  </div>
41137
41452
  `;
41138
41453
  }
41454
+ /**
41455
+ * ED-1354: botões extras do header (ex.: atalho "Bombas B1 B2 S")
41456
+ */
41457
+ renderHeaderActions() {
41458
+ const actions = this.config.params.headerActions || [];
41459
+ return actions.map((a, i) => {
41460
+ const content = a.indicators ? renderEquipmentShortcutHTML(a.indicators, a.label) : `<span>${escapeHtml2(a.label)}</span>`;
41461
+ return `<button type="button" class="myio-eq-shortcut" data-header-action="${i}" title="${escapeHtml2(a.title || a.label)}">${content}</button>`;
41462
+ }).join("");
41463
+ }
41464
+ /**
41465
+ * ED-1354: B1/B2/S sob o ícone do reservatório
41466
+ */
41467
+ renderEquipmentTiles() {
41468
+ const indicators = this.config.params.equipmentIndicators;
41469
+ if (!indicators?.length) return "";
41470
+ return `<div class="myio-water-tank-equipment">${renderEquipmentTilesHTML(indicators)}</div>`;
41471
+ }
41472
+ /**
41473
+ * ED-1354: atualiza tiles e mini-badges dos atalhos sem re-renderizar a modal
41474
+ */
41475
+ updateEquipmentIndicators(indicators) {
41476
+ const { params } = this.config;
41477
+ params.equipmentIndicators = indicators;
41478
+ if (!this.modal) return;
41479
+ ensureEquipmentIndicatorStyles();
41480
+ const tiles = this.modal.querySelector(".myio-water-tank-equipment");
41481
+ if (tiles) {
41482
+ tiles.innerHTML = renderEquipmentTilesHTML(indicators);
41483
+ } else {
41484
+ const img = this.modal.querySelector(".myio-water-tank-tank-panel img");
41485
+ img?.insertAdjacentHTML("afterend", this.renderEquipmentTiles());
41486
+ }
41487
+ (params.headerActions || []).forEach((a, i) => {
41488
+ if (!a.indicators) return;
41489
+ a.indicators = indicators;
41490
+ const btn = this.modal.querySelector(`[data-header-action="${i}"]`);
41491
+ if (btn) btn.innerHTML = renderEquipmentShortcutHTML(indicators, a.label);
41492
+ });
41493
+ }
41139
41494
  /**
41140
41495
  * RFC-0107: Render modal body with new layout
41141
41496
  * Left side: Tank visualization with percentage
@@ -41294,6 +41649,7 @@ var WaterTankModalView = class {
41294
41649
  height: auto;
41295
41650
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
41296
41651
  "/>
41652
+ ${this.renderEquipmentTiles()}
41297
41653
  <div style="
41298
41654
  font-size: 42px;
41299
41655
  font-weight: 700;
@@ -41756,6 +42112,17 @@ var WaterTankModalView = class {
41756
42112
  if (closeBtn) {
41757
42113
  closeBtn.addEventListener("click", () => this.config.onClose());
41758
42114
  }
42115
+ this.modal.querySelectorAll("[data-header-action]").forEach((btn) => {
42116
+ btn.addEventListener("click", (e) => {
42117
+ e.stopPropagation();
42118
+ const action = this.config.params.headerActions?.[Number(btn.dataset.headerAction)];
42119
+ try {
42120
+ action?.onClick();
42121
+ } catch (err) {
42122
+ console.warn("[WaterTankModal] headerAction falhou:", err);
42123
+ }
42124
+ });
42125
+ });
41759
42126
  const exportBtn = this.modal.querySelector(".myio-water-tank-export-btn");
41760
42127
  if (exportBtn) {
41761
42128
  exportBtn.addEventListener("click", () => this.config.onExport());
@@ -42401,7 +42768,9 @@ var WaterTankModal = class {
42401
42768
  }
42402
42769
  dbg5("[WaterTankModal] Modal opened successfully");
42403
42770
  return {
42404
- close: () => this.close()
42771
+ close: () => this.close(),
42772
+ // ED-1354: host atualiza B1/B2/S (tiles + atalho) sem reabrir a modal
42773
+ updateEquipmentIndicators: (indicators) => this.view?.updateEquipmentIndicators(indicators)
42405
42774
  };
42406
42775
  } catch (error) {
42407
42776
  console.error("[WaterTankModal] Failed to show modal:", error);
@@ -50986,8 +51355,8 @@ var AnnotationsTab = class {
50986
51355
  */
50987
51356
  toggleTypeFilter(type) {
50988
51357
  if (type === "archived") {
50989
- const isActive = this.filters.statusList?.includes("archived") || false;
50990
- this.filters.statusList = isActive ? [] : ["archived"];
51358
+ const isActive2 = this.filters.statusList?.includes("archived") || false;
51359
+ this.filters.statusList = isActive2 ? [] : ["archived"];
50991
51360
  this.applyFilters();
50992
51361
  return;
50993
51362
  }
@@ -53660,24 +54029,24 @@ var BUILDING_ICON = `<svg xmlns="http://www.w3.org/2000/svg" width="14" height="
53660
54029
  function renderAlarmCard(alarm, _params) {
53661
54030
  const severityConfig = SEVERITY_CONFIG[alarm.severity];
53662
54031
  const stateConfig = STATE_CONFIG[alarm.state];
53663
- const isActive = isAlarmActive(alarm.state);
54032
+ const isActive2 = isAlarmActive(alarm.state);
53664
54033
  const firstSeenRelative = formatRelativeTimeShort(alarm.firstOccurrence);
53665
54034
  const lastSeenRelative = formatRelativeTimeShort(alarm.lastOccurrence);
53666
54035
  const isSelected = _params?.selected ?? false;
53667
54036
  const rawTitle = alarm.title || "Sem t\xEDtulo";
53668
54037
  const truncatedTitle = rawTitle.length > 42 ? rawTitle.substring(0, 42) + "\u2026" : rawTitle;
53669
- const safeTitle = escapeHtml4(truncatedTitle);
53670
- const safeTitleFull = escapeHtml4(rawTitle);
53671
- const safeCustomerName = escapeHtml4(alarm.customerName || "N/A");
54038
+ const safeTitle = escapeHtml5(truncatedTitle);
54039
+ const safeTitleFull = escapeHtml5(rawTitle);
54040
+ const safeCustomerName = escapeHtml5(alarm.customerName || "N/A");
53672
54041
  const safeOccurrences = alarm.occurrenceCount || 1;
53673
54042
  const showCustomer = _params?.showCustomerName ?? true;
53674
54043
  const showDeviceBadge = _params?.showDeviceBadge ?? false;
53675
- const safeSource = escapeHtml4(alarm.source || "");
54044
+ const safeSource = escapeHtml5(alarm.source || "");
53676
54045
  const alarmTypes = _params?.alarmTypes ?? [];
53677
54046
  const typeChipsHtml = alarmTypes.length > 0 ? `<div class="alarm-card-type-scroll">
53678
54047
  <button class="alarm-type-scroll-btn alarm-type-scroll-btn--left" tabindex="-1" aria-hidden="true">&#8249;</button>
53679
54048
  <div class="alarm-card-type-list">${alarmTypes.map(
53680
- (t) => `<span class="alarm-type-chip" title="${escapeHtml4(t)}">${escapeHtml4(t.length > 22 ? t.substring(0, 22) + "\u2026" : t)}</span>`
54049
+ (t) => `<span class="alarm-type-chip" title="${escapeHtml5(t)}">${escapeHtml5(t.length > 22 ? t.substring(0, 22) + "\u2026" : t)}</span>`
53681
54050
  ).join("")}</div>
53682
54051
  <button class="alarm-type-scroll-btn alarm-type-scroll-btn--right" tabindex="-1" aria-hidden="true">&#8250;</button>
53683
54052
  </div>` : "";
@@ -53687,7 +54056,7 @@ function renderAlarmCard(alarm, _params) {
53687
54056
  return `<article class="alarm-card${isSelected ? " alarm-card--selected" : ""}${hideDetails ? " alarm-card--clickable" : ""}" data-alarm-id="${alarm.id}" data-severity="${alarm.severity}" data-state="${alarm.state}">
53688
54057
  <header class="alarm-card-header">
53689
54058
  ${!hideSelect ? `<label class="alarm-card-checkbox-wrap" title="Selecionar para a\xE7\xE3o em lote" onclick="event.stopPropagation()">
53690
- <input type="checkbox" class="alarm-card-select" data-alarm-id="${alarm.id}" data-alarm-title="${escapeHtml4(rawTitle)}"${isSelected ? " checked" : ""}>
54059
+ <input type="checkbox" class="alarm-card-select" data-alarm-id="${alarm.id}" data-alarm-title="${escapeHtml5(rawTitle)}"${isSelected ? " checked" : ""}>
53691
54060
  </label>` : ""}
53692
54061
  ${showDeviceBadge && safeSource ? `<span class="alarm-card-device-badge" title="${safeSource}">${safeSource}</span>` : ""}
53693
54062
  <div class="alarm-card-badges">
@@ -53715,7 +54084,7 @@ function renderAlarmCard(alarm, _params) {
53715
54084
  </div>
53716
54085
  </div>
53717
54086
  <footer class="alarm-card-footer">
53718
- ${!_params?.hideActions && _params?.canAcknowledge !== false && isActive ? `<button class="btn btn-ack" data-action="acknowledge" data-alarm-id="${alarm.id}" title="Reconhecer"><svg viewBox="0 0 24 24" width="12" height="12" fill="currentColor" aria-hidden="true"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/></svg></button>` : ""}
54087
+ ${!_params?.hideActions && _params?.canAcknowledge !== false && isActive2 ? `<button class="btn btn-ack" data-action="acknowledge" data-alarm-id="${alarm.id}" title="Reconhecer"><svg viewBox="0 0 24 24" width="12" height="12" fill="currentColor" aria-hidden="true"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/></svg></button>` : ""}
53719
54088
  ${!_params?.hideActions && _params?.canSnooze !== false && alarm.state !== "CLOSED" ? `<button class="btn btn-snooze" data-action="snooze" data-alarm-id="${alarm.id}" title="Adiar"><svg viewBox="0 0 24 24" width="12" height="12" fill="currentColor" aria-hidden="true"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67V7z"/></svg></button>` : ""}
53720
54089
  ${!_params?.hideActions && _params?.canEscalate !== false && alarm.state !== "CLOSED" ? `<button class="btn btn-escalate" data-action="escalate" data-alarm-id="${alarm.id}" title="Escalar"><svg viewBox="0 0 24 24" width="12" height="12" fill="currentColor" aria-hidden="true"><path d="M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"/></svg></button>` : ""}
53721
54090
  ${!hideDetails ? `<button class="btn btn-details" data-action="details" data-alarm-id="${alarm.id}" title="Detalhes"><svg viewBox="0 0 24 24" width="12" height="12" fill="currentColor" aria-hidden="true"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></svg></button>` : ""}
@@ -53843,7 +54212,7 @@ function _attachAnnotationBadges(card, alarmId) {
53843
54212
  if (!addedAny) return;
53844
54213
  card.appendChild(container);
53845
54214
  }
53846
- function escapeHtml4(text2) {
54215
+ function escapeHtml5(text2) {
53847
54216
  const div = document.createElement("div");
53848
54217
  div.textContent = text2;
53849
54218
  return div.innerHTML;
@@ -55110,7 +55479,7 @@ function openAlarmDetailsModal(alarm, themeMode = "light", groupMode, onAction)
55110
55479
  }
55111
55480
  const showDevice = !isSeparado && devices.length > 0;
55112
55481
  const showAlarm = groupMode === "porDispositivo" && (alarm._groupAlarmIds?.length || 0) > 1;
55113
- const isActive = alarm.state === "OPEN" || alarm.state === "ESCALATED";
55482
+ const isActive2 = alarm.state === "OPEN" || alarm.state === "ESCALATED";
55114
55483
  const isClosed = alarm.state === "CLOSED";
55115
55484
  const occIndex = /* @__PURE__ */ new Map();
55116
55485
  occEvents().forEach((e, i) => occIndex.set(e, i + 1));
@@ -55159,7 +55528,7 @@ function openAlarmDetailsModal(alarm, themeMode = "light", groupMode, onAction)
55159
55528
  <td class="adm-rpt-cell adm-tl-action-cell">
55160
55529
  ${e.occurrence ? `<label class="adm-tl-cb-wrap" data-cb-wrap><input type="checkbox" class="adm-tl-row-cb" data-item-id="${escHtml2(itemId)}"></label>
55161
55530
  <div class="adm-tl-row-btns" data-row-btns>
55162
- ${isActive ? `<button class="adm-tl-row-btn adm-tl-row-btn--ack" data-action="acknowledge" data-item-id="${escHtml2(itemId)}" title="Reconhecer">${_svgAck}</button>` : ""}
55531
+ ${isActive2 ? `<button class="adm-tl-row-btn adm-tl-row-btn--ack" data-action="acknowledge" data-item-id="${escHtml2(itemId)}" title="Reconhecer">${_svgAck}</button>` : ""}
55163
55532
  ${!isClosed ? `<button class="adm-tl-row-btn adm-tl-row-btn--snooze" data-action="snooze" data-item-id="${escHtml2(itemId)}" title="Adiar">${_svgSnooze}</button>` : ""}
55164
55533
  ${!isClosed ? `<button class="adm-tl-row-btn adm-tl-row-btn--escalate" data-action="escalate" data-item-id="${escHtml2(itemId)}" title="Escalar">${_svgEscalate}</button>` : ""}
55165
55534
  </div>` : ""}
@@ -62634,6 +63003,249 @@ var DeviceProfileTab = class {
62634
63003
  }
62635
63004
  };
62636
63005
 
63006
+ // src/components/premium-modals/settings/well-equipment/WellEquipmentTab.ts
63007
+ var ATTRIBUTE_KEYS = "deviceProfile,gcdrDeviceId,pumpBindings";
63008
+ var MAX_CUSTOMER_DEVICE_PAGES = 100;
63009
+ function escapeHtml6(value) {
63010
+ return value.replace(/[&<>"']/g, (char) => ({
63011
+ "&": "&amp;",
63012
+ "<": "&lt;",
63013
+ ">": "&gt;",
63014
+ '"': "&quot;",
63015
+ "'": "&#39;"
63016
+ })[char]);
63017
+ }
63018
+ function normalizeBindings(value) {
63019
+ const parsed = typeof value === "string" ? JSON.parse(value) : value;
63020
+ const bindings = parsed && typeof parsed === "object" ? parsed : {};
63021
+ const valid = (items, codes) => (Array.isArray(items) ? items : []).filter((item) => !!item && typeof item === "object" && typeof item.tbId === "string" && codes.has(item.code)).map((item) => ({ ...item }));
63022
+ return {
63023
+ pumps: valid(bindings.pumps, /* @__PURE__ */ new Set(["B1", "B2"])),
63024
+ valves: valid(bindings.valves, /* @__PURE__ */ new Set(["S"]))
63025
+ };
63026
+ }
63027
+ var WellEquipmentTab = class {
63028
+ config;
63029
+ equipment = [];
63030
+ bindings = { pumps: [], valves: [] };
63031
+ loaded = false;
63032
+ catalogWarnings = 0;
63033
+ constructor(config2) {
63034
+ this.config = config2;
63035
+ }
63036
+ async init() {
63037
+ this.config.container.innerHTML = '<p class="wet-state">Carregando v\xEDnculos e equipamentos\u2026</p>';
63038
+ try {
63039
+ const [wellAttributes, equipment] = await Promise.all([
63040
+ this.fetchAttributes(this.config.deviceId, "pumpBindings"),
63041
+ this.fetchEquipment()
63042
+ ]);
63043
+ const stored = wellAttributes.get("pumpBindings");
63044
+ this.bindings = stored == null ? { pumps: [], valves: [] } : normalizeBindings(stored);
63045
+ this.equipment = equipment;
63046
+ this.loaded = true;
63047
+ this.render();
63048
+ if (this.catalogWarnings > 0) {
63049
+ this.showMessage(
63050
+ `${this.catalogWarnings} equipamento(s) n\xE3o puderam ser verificados e foram omitidos do cat\xE1logo.`,
63051
+ true
63052
+ );
63053
+ }
63054
+ } catch (error) {
63055
+ this.config.container.innerHTML = `<p class="wet-state wet-error" role="alert">N\xE3o foi poss\xEDvel carregar os v\xEDnculos ou o cat\xE1logo de equipamentos: ${escapeHtml6(this.errorMessage(error))}</p>`;
63056
+ }
63057
+ }
63058
+ destroy() {
63059
+ }
63060
+ headers() {
63061
+ return {
63062
+ "X-Authorization": `Bearer ${this.config.jwtToken}`,
63063
+ "Content-Type": "application/json"
63064
+ };
63065
+ }
63066
+ async fetchAttributes(deviceId, keys) {
63067
+ const url = `${this.config.tbBaseUrl}/api/plugins/telemetry/DEVICE/${encodeURIComponent(deviceId)}/values/attributes/SERVER_SCOPE?keys=${encodeURIComponent(keys)}`;
63068
+ const response = await fetch(url, { headers: this.headers() });
63069
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
63070
+ const raw = await response.json();
63071
+ if (!Array.isArray(raw)) throw new Error("Resposta de atributos inv\xE1lida");
63072
+ return new Map(raw.map(({ key, value }) => [key, value]));
63073
+ }
63074
+ async fetchEquipment() {
63075
+ if (!this.config.customerId) throw new Error("customerId indispon\xEDvel");
63076
+ const devices = [];
63077
+ let page = 0;
63078
+ let hasNext = true;
63079
+ while (hasNext) {
63080
+ if (page >= MAX_CUSTOMER_DEVICE_PAGES) {
63081
+ throw new Error(`Cat\xE1logo excede o limite de ${MAX_CUSTOMER_DEVICE_PAGES} p\xE1ginas`);
63082
+ }
63083
+ const query = new URLSearchParams({ pageSize: "1000", page: String(page) });
63084
+ const url = `${this.config.tbBaseUrl}/api/customer/${encodeURIComponent(this.config.customerId)}/devices?${query}`;
63085
+ const response = await fetch(url, { headers: this.headers() });
63086
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
63087
+ const result = await response.json();
63088
+ if (!Array.isArray(result.data)) throw new Error("Resposta de equipamentos inv\xE1lida");
63089
+ if (result.hasNext === true && result.data.length === 0) {
63090
+ throw new Error("Pagina\xE7\xE3o do cat\xE1logo n\xE3o avan\xE7ou");
63091
+ }
63092
+ devices.push(...result.data);
63093
+ hasNext = result.hasNext === true;
63094
+ page += 1;
63095
+ }
63096
+ const candidates = devices.map((device) => ({
63097
+ device,
63098
+ tbId: typeof device.id === "string" ? device.id : device.id?.id
63099
+ })).filter((item) => !!item.tbId);
63100
+ const queue = [...candidates];
63101
+ const matching = [];
63102
+ const worker = async () => {
63103
+ while (queue.length) {
63104
+ const item = queue.shift();
63105
+ if (!item) return;
63106
+ try {
63107
+ const attributes = await this.fetchAttributes(item.tbId, ATTRIBUTE_KEYS);
63108
+ const profile = String(attributes.get("deviceProfile") || "").toUpperCase();
63109
+ if (profile !== "BOMBA_POCO" && profile !== "SOLENOIDE") continue;
63110
+ matching.push({
63111
+ tbId: item.tbId,
63112
+ profile,
63113
+ label: String(item.device.label || item.device.name || item.tbId),
63114
+ gcdrId: attributes.get("gcdrDeviceId") == null ? void 0 : String(attributes.get("gcdrDeviceId"))
63115
+ });
63116
+ } catch (error) {
63117
+ this.catalogWarnings += 1;
63118
+ console.warn(`[WellEquipmentTab] Falha ao ler atributos do equipamento ${item.tbId}:`, error);
63119
+ }
63120
+ }
63121
+ };
63122
+ await Promise.all(Array.from({ length: Math.min(8, Math.max(1, queue.length)) }, () => worker()));
63123
+ return matching.sort((a, b) => a.label.localeCompare(b.label));
63124
+ }
63125
+ render() {
63126
+ const options = (profile, code, existing) => {
63127
+ const eligible = this.equipment.filter((item) => item.profile === profile);
63128
+ const missing = existing && !eligible.some((item) => item.tbId === existing.tbId) ? `<option value="${escapeHtml6(existing.tbId)}" selected data-unavailable="true">V\xEDnculo atual indispon\xEDvel \u2014 ${escapeHtml6(existing.label)}</option>` : "";
63129
+ const items = eligible.map(
63130
+ (item) => `<option value="${escapeHtml6(item.tbId)}"${item.tbId === existing?.tbId ? " selected" : ""}>${escapeHtml6(item.label)}</option>`
63131
+ ).join("");
63132
+ return `<select id="wet-${code.toLowerCase()}-device" data-slot="${code}" aria-label="Equipamento ${code}">
63133
+ <option value="">Nenhum</option>${missing}${items}
63134
+ </select>`;
63135
+ };
63136
+ const binding = (items, code) => items.find((item) => item.code === code);
63137
+ const labelInput = (code, existing) => `<input id="wet-${code.toLowerCase()}-label" data-label="${code}" aria-label="R\xF3tulo ${code}" value="${escapeHtml6(existing?.label || "")}" placeholder="R\xF3tulo opcional">`;
63138
+ this.config.container.innerHTML = `
63139
+ <section class="wet-tab">
63140
+ <p>Configure as bombas e o solenoide associados a este po\xE7o. O mesmo equipamento pode ser usado em outros po\xE7os.</p>
63141
+ <div class="wet-grid">
63142
+ <label for="wet-b1-device">Bomba B1</label>${options("BOMBA_POCO", "B1", binding(this.bindings.pumps, "B1"))}${labelInput("B1", binding(this.bindings.pumps, "B1"))}
63143
+ <label for="wet-b2-device">Bomba B2</label>${options("BOMBA_POCO", "B2", binding(this.bindings.pumps, "B2"))}${labelInput("B2", binding(this.bindings.pumps, "B2"))}
63144
+ <label for="wet-s-device">Solenoide S</label>${options("SOLENOIDE", "S", binding(this.bindings.valves, "S"))}${labelInput("S", binding(this.bindings.valves, "S"))}
63145
+ </div>
63146
+ <p id="wet-message" class="wet-message" role="status" aria-live="polite"></p>
63147
+ <button type="button" id="wet-save" ${this.loaded ? "" : "disabled"}>Salvar v\xEDnculos</button>
63148
+ </section>
63149
+ <style>
63150
+ .wet-tab{padding:24px;color:#374151}.wet-grid{display:grid;grid-template-columns:130px minmax(180px,1fr) minmax(180px,1fr);gap:12px;align-items:center}
63151
+ .wet-grid label{font-weight:600}.wet-grid select,.wet-grid input{box-sizing:border-box;width:100%;min-height:38px;padding:7px 9px;border:1px solid #d1d5db;border-radius:6px;background:white}
63152
+ #wet-save{margin-top:18px;padding:9px 16px;border:0;border-radius:6px;background:#2563eb;color:white;font-weight:600;cursor:pointer}
63153
+ #wet-save:disabled{opacity:.6;cursor:wait}.wet-message{min-height:20px;margin:12px 0 0}.wet-message.wet-error,.wet-error{color:#b91c1c}.wet-message.wet-success{color:#15803d}.wet-state{text-align:center;padding:30px;color:#6b7280}
63154
+ </style>`;
63155
+ this.config.container.querySelectorAll("[data-slot]").forEach((select) => {
63156
+ select.addEventListener("change", () => {
63157
+ const slot = select.dataset.slot || "";
63158
+ const selected = this.equipment.find((item) => item.tbId === select.value);
63159
+ const label = this.config.container.querySelector(`[data-label="${slot}"]`);
63160
+ if (label && selected) label.value = selected.label;
63161
+ if (label && !selected) label.value = "";
63162
+ this.showMessage("");
63163
+ });
63164
+ });
63165
+ this.config.container.querySelector("#wet-save")?.addEventListener("click", () => {
63166
+ void this.save();
63167
+ });
63168
+ }
63169
+ async save() {
63170
+ const container = this.config.container;
63171
+ const saveButton = container.querySelector("#wet-save");
63172
+ if (!this.loaded || !saveButton) return;
63173
+ const b1 = container.querySelector("#wet-b1-device")?.value || "";
63174
+ const b2 = container.querySelector("#wet-b2-device")?.value || "";
63175
+ const solenoid = container.querySelector("#wet-s-device")?.value || "";
63176
+ if (b1 && b1 === b2) {
63177
+ this.showMessage("Selecione bombas diferentes para B1 e B2.", true);
63178
+ return;
63179
+ }
63180
+ const selected = [
63181
+ ...b1 ? [{ id: b1, profile: "BOMBA_POCO", code: "B1" }] : [],
63182
+ ...b2 ? [{ id: b2, profile: "BOMBA_POCO", code: "B2" }] : [],
63183
+ ...solenoid ? [{ id: solenoid, profile: "SOLENOIDE", code: "S" }] : []
63184
+ ];
63185
+ for (const item of selected) {
63186
+ const current = item.code === "S" ? this.bindings.valves.find((binding) => binding.code === item.code) : this.bindings.pumps.find((binding) => binding.code === item.code);
63187
+ const unchangedUnavailableBinding = current?.tbId === item.id && !this.equipment.some((equipment) => equipment.tbId === item.id);
63188
+ if (!unchangedUnavailableBinding && !this.equipment.some((equipment) => equipment.tbId === item.id && equipment.profile === item.profile)) {
63189
+ this.showMessage(`O equipamento selecionado para ${item.code} n\xE3o pertence ao cat\xE1logo v\xE1lido.`, true);
63190
+ return;
63191
+ }
63192
+ }
63193
+ const oldBinding = (code) => code === "S" ? this.bindings.valves.find((item) => item.code === code) : this.bindings.pumps.find((item) => item.code === code);
63194
+ const createBinding = (id, code) => {
63195
+ if (!id) return null;
63196
+ const current = oldBinding(code);
63197
+ const equipment = this.equipment.find((item) => item.tbId === id);
63198
+ const label = container.querySelector(`[data-label="${code}"]`)?.value.trim() || equipment?.label || current?.label || id;
63199
+ return {
63200
+ tbId: id,
63201
+ ...equipment?.gcdrId || (current?.tbId === id ? current.gcdrId : void 0) ? { gcdrId: equipment?.gcdrId || current?.gcdrId } : {},
63202
+ code,
63203
+ label,
63204
+ ...code !== "S" && current?.tbId === id && current.thresholdW !== void 0 ? { thresholdW: current.thresholdW } : {}
63205
+ };
63206
+ };
63207
+ const bindings = {
63208
+ pumps: [createBinding(b1, "B1"), createBinding(b2, "B2")].filter((item) => !!item),
63209
+ valves: [createBinding(solenoid, "S")].filter((item) => !!item)
63210
+ };
63211
+ saveButton.disabled = true;
63212
+ saveButton.textContent = "Salvando\u2026";
63213
+ this.showMessage("");
63214
+ try {
63215
+ const response = await fetch(
63216
+ `${this.config.tbBaseUrl}/api/plugins/telemetry/DEVICE/${encodeURIComponent(this.config.deviceId)}/attributes/SERVER_SCOPE`,
63217
+ {
63218
+ method: "POST",
63219
+ headers: this.headers(),
63220
+ body: JSON.stringify({ pumpBindings: bindings })
63221
+ }
63222
+ );
63223
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
63224
+ this.bindings = bindings;
63225
+ this.render();
63226
+ this.showMessage("V\xEDnculos salvos com sucesso.", false, true);
63227
+ } catch (error) {
63228
+ this.showMessage(`Falha ao salvar os v\xEDnculos: ${this.errorMessage(error)}`, true);
63229
+ } finally {
63230
+ const button = container.querySelector("#wet-save");
63231
+ if (button) {
63232
+ button.disabled = false;
63233
+ button.textContent = "Salvar v\xEDnculos";
63234
+ }
63235
+ }
63236
+ }
63237
+ showMessage(message, isError = false, isSuccess = false) {
63238
+ const element = this.config.container.querySelector("#wet-message");
63239
+ if (!element) return;
63240
+ element.textContent = message;
63241
+ element.classList.toggle("wet-error", isError);
63242
+ element.classList.toggle("wet-success", isSuccess);
63243
+ }
63244
+ errorMessage(error) {
63245
+ return error instanceof Error ? error.message : String(error);
63246
+ }
63247
+ };
63248
+
62637
63249
  // src/services/freshdesk/FreshdeskClient.ts
62638
63250
  var FreshdeskClient_exports = {};
62639
63251
  __export(FreshdeskClient_exports, {
@@ -63550,10 +64162,10 @@ ${this._formatFileSize(f.size)} \xB7 ${f.type || "arquivo"}`;
63550
64162
  // Styles
63551
64163
  // ==========================================================================
63552
64164
  injectStyles() {
63553
- const STYLE_ID18 = "myio-tickets-tab-styles";
63554
- if (document.getElementById(STYLE_ID18)) return;
64165
+ const STYLE_ID23 = "myio-tickets-tab-styles";
64166
+ if (document.getElementById(STYLE_ID23)) return;
63555
64167
  const style = document.createElement("style");
63556
- style.id = STYLE_ID18;
64168
+ style.id = STYLE_ID23;
63557
64169
  style.textContent = `
63558
64170
  /* ===== TicketsTab layout ===== */
63559
64171
  .ct-tab {
@@ -64235,7 +64847,7 @@ async function createInputDateRangePickerInsideDIV(params) {
64235
64847
  placeholder = "Clique para selecionar per\xEDodo",
64236
64848
  pickerOptions = {},
64237
64849
  classNames = {},
64238
- injectStyles: injectStyles23 = true,
64850
+ injectStyles: injectStyles26 = true,
64239
64851
  showHelper = true
64240
64852
  } = params;
64241
64853
  validateId(containerId, "containerId");
@@ -64244,7 +64856,7 @@ async function createInputDateRangePickerInsideDIV(params) {
64244
64856
  if (!container) {
64245
64857
  throw new Error(`[createInputDateRangePickerInsideDIV] Container '#${containerId}' not found`);
64246
64858
  }
64247
- if (injectStyles23) {
64859
+ if (injectStyles26) {
64248
64860
  injectPremiumStyles();
64249
64861
  }
64250
64862
  let inputEl = document.getElementById(inputId);
@@ -64383,6 +64995,7 @@ var SettingsModalView = class _SettingsModalView {
64383
64995
  // Exclusão de Grupos tab
64384
64996
  exclusionGroupsTab = null;
64385
64997
  deviceProfileTab = null;
64998
+ wellEquipmentTab = null;
64386
64999
  currentTab = "general";
64387
65000
  currentUser = null;
64388
65001
  permissions = null;
@@ -64431,6 +65044,9 @@ var SettingsModalView = class _SettingsModalView {
64431
65044
  canEditIdentifier() {
64432
65045
  return this.isSuperAdmin() || this.config.holdingAdmin === true;
64433
65046
  }
65047
+ isWellEquipmentDevice() {
65048
+ return ["CISTERNA", "CISTERNA_ENTRADA"].includes(String(this.config.deviceProfile || "").toUpperCase());
65049
+ }
64434
65050
  render(initialData) {
64435
65051
  this.originalActiveElement = document.activeElement;
64436
65052
  document.body.appendChild(this.container);
@@ -64465,6 +65081,9 @@ var SettingsModalView = class _SettingsModalView {
64465
65081
  this.initChamadosTab();
64466
65082
  this.initExclusionGroupsTab();
64467
65083
  this.initDeviceProfileTab();
65084
+ if (this.isWellEquipmentDevice() && this.isSuperAdmin()) {
65085
+ this.initWellEquipmentTab();
65086
+ }
64468
65087
  if (this.config.isGateway && this.isSuperAdmin()) {
64469
65088
  this.bindIncidentsTabEvents();
64470
65089
  this.initIncidentsDateRange();
@@ -64718,6 +65337,30 @@ var SettingsModalView = class _SettingsModalView {
64718
65337
  container.innerHTML = '<p style="color:#dc3545;padding:20px;text-align:center;">Erro ao carregar perfil do dispositivo</p>';
64719
65338
  }
64720
65339
  }
65340
+ async initWellEquipmentTab() {
65341
+ const container = this.modal.querySelector("#well-equipment-tab-content");
65342
+ if (!container || !this.isWellEquipmentDevice() || !this.isSuperAdmin()) return;
65343
+ const customerId = this.config.customerId || window.MyIOUtils?.customerTB_ID;
65344
+ const { deviceId, jwtToken, tbBaseUrl, deviceProfile } = this.config;
65345
+ if (!deviceId || !jwtToken || !customerId) {
65346
+ container.innerHTML = '<p class="wet-state wet-error" role="alert">Configura\xE7\xE3o de equipamentos indispon\xEDvel: deviceId, autentica\xE7\xE3o ou customerId n\xE3o informado.</p>';
65347
+ return;
65348
+ }
65349
+ try {
65350
+ this.wellEquipmentTab = new WellEquipmentTab({
65351
+ container,
65352
+ deviceId,
65353
+ deviceProfile: String(deviceProfile || ""),
65354
+ customerId,
65355
+ jwtToken,
65356
+ tbBaseUrl: tbBaseUrl ?? window.location.origin
65357
+ });
65358
+ await this.wellEquipmentTab.init();
65359
+ } catch (error) {
65360
+ console.error("[SettingsModalView] Failed to initialize WellEquipmentTab:", error);
65361
+ container.innerHTML = '<p class="wet-state wet-error" role="alert">Erro ao carregar configura\xE7\xF5es de equipamentos do po\xE7o.</p>';
65362
+ }
65363
+ }
64721
65364
  // RFC-0104 / RFC-0180 / RFC-0198: Switch between tabs
64722
65365
  switchTab(tab) {
64723
65366
  this.currentTab = tab;
@@ -64731,12 +65374,14 @@ var SettingsModalView = class _SettingsModalView {
64731
65374
  const chamadosContent = this.modal.querySelector("#chamados-tab-content");
64732
65375
  const exclusionGroupsContent = this.modal.querySelector("#exclusion-groups-tab-content");
64733
65376
  const deviceProfileContent = this.modal.querySelector("#device-profile-tab-content");
65377
+ const wellEquipmentContent = this.modal.querySelector("#well-equipment-tab-content");
64734
65378
  const incidentsContent = this.modal.querySelector("#incidents-tab-content");
64735
65379
  if (generalContent) generalContent.style.display = tab === "general" ? "block" : "none";
64736
65380
  if (annotationsContent) annotationsContent.style.display = tab === "annotations" ? "block" : "none";
64737
65381
  if (alarmsContent) alarmsContent.style.display = tab === "alarms" ? "block" : "none";
64738
65382
  if (chamadosContent) chamadosContent.style.display = tab === "chamados" ? "block" : "none";
64739
65383
  if (deviceProfileContent) deviceProfileContent.style.display = tab === "device-profile" ? "block" : "none";
65384
+ if (wellEquipmentContent) wellEquipmentContent.style.display = tab === "well-equipment" ? "block" : "none";
64740
65385
  if (exclusionGroupsContent) exclusionGroupsContent.style.display = tab === "exclusion-groups" ? "block" : "none";
64741
65386
  if (incidentsContent) incidentsContent.style.display = tab === "incidents" ? "block" : "none";
64742
65387
  const saveBtn = this.modal.querySelector(".btn-save");
@@ -64767,6 +65412,10 @@ var SettingsModalView = class _SettingsModalView {
64767
65412
  this.deviceProfileTab.destroy();
64768
65413
  this.deviceProfileTab = null;
64769
65414
  }
65415
+ if (this.wellEquipmentTab) {
65416
+ this.wellEquipmentTab.destroy();
65417
+ this.wellEquipmentTab = null;
65418
+ }
64770
65419
  if (this.incidentsDateRangeController) {
64771
65420
  this.incidentsDateRangeController.destroy();
64772
65421
  this.incidentsDateRangeController = null;
@@ -64946,6 +65595,13 @@ var SettingsModalView = class _SettingsModalView {
64946
65595
  </svg>
64947
65596
  Perfil de Dispositivo
64948
65597
  </button>` : ""}
65598
+ ${this.isWellEquipmentDevice() && this.isSuperAdmin() ? `<button type="button" class="modal-tab" data-tab="well-equipment">
65599
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
65600
+ <path d="M4 18h16M6 18V8l6-4 6 4v10M9 18v-5h6v5"></path>
65601
+ <path d="M12 4v4"></path>
65602
+ </svg>
65603
+ Equipamentos do Po\xE7o
65604
+ </button>` : ""}
64949
65605
  <!-- RFC-0232: Incidentes (interpola\xE7\xE3o) \u2014 central + admin MyIO only -->
64950
65606
  ${this.config.isGateway && this.isSuperAdmin() ? `<button type="button" class="modal-tab" data-tab="incidents">
64951
65607
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
@@ -65000,6 +65656,9 @@ var SettingsModalView = class _SettingsModalView {
65000
65656
  <p>Carregando perfil do dispositivo...</p>
65001
65657
  </div>
65002
65658
  </div>
65659
+ ${this.isWellEquipmentDevice() && this.isSuperAdmin() ? `<div id="well-equipment-tab-content" class="tab-content" style="display:none;">
65660
+ <p class="wet-state">Carregando v\xEDnculos e equipamentos\u2026</p>
65661
+ </div>` : ""}
65003
65662
  <!-- RFC-0232: Incidentes (interpola\xE7\xE3o) Tab Content \u2014 central + admin MyIO only.
65004
65663
  Rendered synchronously (data comes pre-fetched via config.interpolatedSlots,
65005
65664
  same as getGatewayInfoHTML() \u2014 no async loading state needed here). -->
@@ -65147,8 +65806,8 @@ var SettingsModalView = class _SettingsModalView {
65147
65806
  const segmentEl = this.modal.querySelector("#segment");
65148
65807
  const activityEl = this.modal.querySelector("#activity");
65149
65808
  if (!segmentEl || !activityEl) return;
65150
- const esc9 = (s) => s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
65151
- const options = (values, selected, placeholder) => `<option value="">${placeholder}</option>` + values.map((v) => `<option value="${esc9(v)}"${v === selected ? " selected" : ""}>${esc9(v)}</option>`).join("");
65809
+ const esc10 = (s) => s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
65810
+ const options = (values, selected, placeholder) => `<option value="">${placeholder}</option>` + values.map((v) => `<option value="${esc10(v)}"${v === selected ? " selected" : ""}>${esc10(v)}</option>`).join("");
65152
65811
  const catalog = await loadStoreSegmentCatalog(this.config.segmentCatalog);
65153
65812
  const savedSegment = String(saved.segment || "");
65154
65813
  const savedActivity = String(saved.activity || "");
@@ -68606,11 +69265,11 @@ function connectivityFieldsetHtml(data, l, language, errors) {
68606
69265
  </div>
68607
69266
  `;
68608
69267
  }
68609
- var STYLE_ID4 = "myio-central-settings-modal-styles";
69268
+ var STYLE_ID5 = "myio-central-settings-modal-styles";
68610
69269
  function injectStyles9() {
68611
- if (typeof document === "undefined" || document.getElementById(STYLE_ID4)) return;
69270
+ if (typeof document === "undefined" || document.getElementById(STYLE_ID5)) return;
68612
69271
  const tag = document.createElement("style");
68613
- tag.id = STYLE_ID4;
69272
+ tag.id = STYLE_ID5;
68614
69273
  tag.textContent = `
68615
69274
  .myio-csettings__input{
68616
69275
  font:600 13px 'Nunito', system-ui, sans-serif;padding:6px 8px;border-radius:6px;
@@ -71631,7 +72290,7 @@ var WelcomeModalView = class _WelcomeModalView {
71631
72290
  if (this.metaTipEl) this.metaTipEl.style.display = "none";
71632
72291
  }
71633
72292
  buildMetaTipHtml(type, card) {
71634
- const esc9 = _WelcomeModalView.escapeMetaHtml;
72293
+ const esc10 = _WelcomeModalView.escapeMetaHtml;
71635
72294
  const chip = _WelcomeModalView.metaChip;
71636
72295
  const meta = card.metaCounts || {};
71637
72296
  const details = card.metaDetails || {};
@@ -71641,7 +72300,7 @@ var WelcomeModalView = class _WelcomeModalView {
71641
72300
  ).padStart(2, "0")}:${String(now.getMinutes()).padStart(2, "0")}`;
71642
72301
  const frame = (icon2, label, body) => `<div class="myio-welcome-meta-tip__header">
71643
72302
  <span class="myio-welcome-meta-tip__icon">${icon2}</span>
71644
- <span class="myio-welcome-meta-tip__title">${label} (${esc9(card.title)})</span>
72303
+ <span class="myio-welcome-meta-tip__title">${label} (${esc10(card.title)})</span>
71645
72304
  <span class="myio-welcome-meta-tip__timestamp">${stamp}</span>
71646
72305
  <button type="button" class="myio-welcome-meta-tip__close" title="Fechar">\u2715</button>
71647
72306
  </div>
@@ -71669,8 +72328,8 @@ var WelcomeModalView = class _WelcomeModalView {
71669
72328
  const chips = Object.entries(byState).map(([s, n]) => chip(`${s}: ${n}`)).join("");
71670
72329
  const rows = alarms.slice(0, 10).map(
71671
72330
  (a) => row(
71672
- esc9(a.deviceName ? `${a.deviceName} \u2014 ${a.title || "Alarme"}` : a.title || "Alarme"),
71673
- [a.severity, a.state].filter(Boolean).map(esc9).join(" \xB7 ")
72331
+ esc10(a.deviceName ? `${a.deviceName} \u2014 ${a.title || "Alarme"}` : a.title || "Alarme"),
72332
+ [a.severity, a.state].filter(Boolean).map(esc10).join(" \xB7 ")
71674
72333
  )
71675
72334
  ).join("");
71676
72335
  return frame(
@@ -71694,7 +72353,7 @@ var WelcomeModalView = class _WelcomeModalView {
71694
72353
  const rows = annotations.slice(0, 10).map((a) => {
71695
72354
  const when = a.createdAt ? new Date(a.createdAt).toLocaleDateString("pt-BR") : "";
71696
72355
  const text2 = a.text.length > 90 ? `${a.text.slice(0, 90)}\u2026` : a.text;
71697
- return row(esc9(a.deviceLabel || "Dispositivo"), `${esc9(text2)}${when ? ` \xB7 ${esc9(when)}` : ""}`);
72356
+ return row(esc10(a.deviceLabel || "Dispositivo"), `${esc10(text2)}${when ? ` \xB7 ${esc10(when)}` : ""}`);
71698
72357
  }).join("");
71699
72358
  return frame(
71700
72359
  "\u{1F4CB}",
@@ -71705,7 +72364,7 @@ var WelcomeModalView = class _WelcomeModalView {
71705
72364
  if (type === "users") {
71706
72365
  if (meta.users === null) return frame("\u{1F465}", "Usu\xE1rios", loadingBody);
71707
72366
  const users = details.users || [];
71708
- const rows = users.slice(0, 10).map((u) => row(esc9(u.name), esc9(u.email || ""))).join("");
72367
+ const rows = users.slice(0, 10).map((u) => row(esc10(u.name), esc10(u.email || ""))).join("");
71709
72368
  return frame(
71710
72369
  "\u{1F465}",
71711
72370
  "Usu\xE1rios",
@@ -74600,14 +75259,14 @@ var DEFAULT_CONFIG_TEMPLATE2 = {
74600
75259
  };
74601
75260
 
74602
75261
  // src/components/footer/styles.ts
74603
- var STYLE_ID5 = "myio-footer-component-styles";
75262
+ var STYLE_ID6 = "myio-footer-component-styles";
74604
75263
  function areStylesInjected() {
74605
- return !!document.getElementById(STYLE_ID5);
75264
+ return !!document.getElementById(STYLE_ID6);
74606
75265
  }
74607
75266
  function injectStyles10() {
74608
75267
  if (areStylesInjected()) return;
74609
75268
  const style = document.createElement("style");
74610
- style.id = STYLE_ID5;
75269
+ style.id = STYLE_ID6;
74611
75270
  style.textContent = getStyles();
74612
75271
  document.head.appendChild(style);
74613
75272
  }
@@ -75925,10 +76584,10 @@ function render(container, modalId, state6) {
75925
76584
  <div class="alarm-list">
75926
76585
  ${state6.alarms.map((a) => `
75927
76586
  <div class="alarm-row">
75928
- <div class="alarm-title">${escapeHtml5(a.title || a.id)}</div>
75929
- <div class="alarm-meta">${escapeHtml5(a.customerName || "")}</div>
75930
- <div class="alarm-meta">${escapeHtml5(a.severity)}</div>
75931
- <div class="alarm-meta">${escapeHtml5(a.state)}</div>
76587
+ <div class="alarm-title">${escapeHtml7(a.title || a.id)}</div>
76588
+ <div class="alarm-meta">${escapeHtml7(a.customerName || "")}</div>
76589
+ <div class="alarm-meta">${escapeHtml7(a.severity)}</div>
76590
+ <div class="alarm-meta">${escapeHtml7(a.state)}</div>
75932
76591
  <div class="alarm-meta">${formatDate2(a.lastOccurrence, state6.locale, true)}</div>
75933
76592
  </div>
75934
76593
  `).join("")}
@@ -76115,7 +76774,7 @@ function buildBars(data, order, colors2) {
76115
76774
  const pct = Math.round(value / maxVal * 100);
76116
76775
  return `
76117
76776
  <div class="bar-row">
76118
- <span class="bar-label">${escapeHtml5(String(key))}</span>
76777
+ <span class="bar-label">${escapeHtml7(String(key))}</span>
76119
76778
  <div class="bar-track"><div class="bar-fill" style="width:${pct}%"></div></div>
76120
76779
  <span class="bar-value">${value}</span>
76121
76780
  </div>
@@ -76145,7 +76804,7 @@ function toTime(value) {
76145
76804
  const parsed = new Date(value).getTime();
76146
76805
  return Number.isNaN(parsed) ? 0 : parsed;
76147
76806
  }
76148
- function escapeHtml5(text2) {
76807
+ function escapeHtml7(text2) {
76149
76808
  const div = document.createElement("div");
76150
76809
  div.textContent = text2 || "";
76151
76810
  return div.innerHTML;
@@ -76332,8 +76991,8 @@ function render2(container, modalId, state6) {
76332
76991
  </div>
76333
76992
  ${state6.devices.map((d) => `
76334
76993
  <div class="device-table-row">
76335
- <div class="col-name">${escapeHtml6(d.name)}</div>
76336
- <div class="col-customer">${escapeHtml6(d.customerName)}</div>
76994
+ <div class="col-name">${escapeHtml8(d.name)}</div>
76995
+ <div class="col-customer">${escapeHtml8(d.customerName)}</div>
76337
76996
  <div class="col-status">
76338
76997
  <span class="status-badge" style="background: ${STATUS_COLORS3[d.status] || "#6b7280"}20; color: ${STATUS_COLORS3[d.status] || "#6b7280"};">
76339
76998
  ${STATUS_LABELS5[d.status] || d.status}
@@ -76580,7 +77239,7 @@ function buildHorizontalBarChart(devices, metric, unit, colors2, getColor, inver
76580
77239
  const displayValue = metric === "availability" ? value.toFixed(1) : value.toFixed(metric === "mttr" ? 1 : 0);
76581
77240
  return `
76582
77241
  <div class="bar-row">
76583
- <span class="bar-label" title="${escapeHtml6(d.name)}">${escapeHtml6(d.name)}</span>
77242
+ <span class="bar-label" title="${escapeHtml8(d.name)}">${escapeHtml8(d.name)}</span>
76584
77243
  <div class="bar-track">
76585
77244
  <div class="bar-fill" style="width:${pct}%; background:${color};"></div>
76586
77245
  </div>
@@ -76611,7 +77270,7 @@ function formatDate3(value, locale) {
76611
77270
  if (isNaN(d.getTime())) return "-";
76612
77271
  return d.toLocaleDateString(locale, { day: "2-digit", month: "2-digit", year: "numeric" });
76613
77272
  }
76614
- function escapeHtml6(text2) {
77273
+ function escapeHtml8(text2) {
76615
77274
  const div = document.createElement("div");
76616
77275
  div.textContent = text2 || "";
76617
77276
  return div.innerHTML;
@@ -78504,8 +79163,8 @@ var SettingsController = class {
78504
79163
  // RFC-0076: Pass deviceProfile for 3F_MEDIDOR fallback
78505
79164
  customerName: params.customerName,
78506
79165
  // RFC-0077: Pass customer/shopping name for display
78507
- customerId: params.customerId,
78508
- // RFC-0080: Pass customerId for fetching GLOBAL mapInstantaneousPower
79166
+ customerId: params.customerId || window.MyIOUtils?.customerTB_ID || void 0,
79167
+ // Shared customer context for settings tabs
78509
79168
  deviceId: params.deviceId,
78510
79169
  // RFC-0077: Pass deviceId for Power Limits feature
78511
79170
  jwtToken: params.jwtToken,
@@ -78913,6 +79572,249 @@ async function openDashboardPopupSettings(params) {
78913
79572
  }
78914
79573
  }
78915
79574
 
79575
+ // src/components/well-pumps/WellPumpsModal.ts
79576
+ var STYLE_ID7 = "myio-well-pumps-modal-styles";
79577
+ var TICK_MS = 3e4;
79578
+ function ensureStyles() {
79579
+ if (document.getElementById(STYLE_ID7)) return;
79580
+ const style = document.createElement("style");
79581
+ style.id = STYLE_ID7;
79582
+ style.textContent = `
79583
+ .myio-wp-overlay{position:fixed;inset:0;background:rgba(15,23,42,.55);backdrop-filter:blur(2px);display:flex;align-items:center;
79584
+ justify-content:center;font-family:Nunito,system-ui,sans-serif;animation:myioWpFade .15s ease-out}
79585
+ @keyframes myioWpFade{from{opacity:0}to{opacity:1}}
79586
+ .myio-wp-modal{width:min(880px,94vw);max-height:90vh;overflow:auto;background:#f8fafc;border-radius:14px;box-shadow:0 24px 64px rgba(0,0,0,.35);color:#1e293b}
79587
+ .myio-wp-head{display:flex;align-items:center;gap:12px;padding:16px 20px;color:#fff;background:linear-gradient(135deg,#3e1a7d 0%,#5b2bb5 100%);
79588
+ border-radius:14px 14px 0 0;position:sticky;top:0;z-index:2}
79589
+ .myio-wp-head h2{margin:0;font-size:17px;font-weight:800;color:#fff}
79590
+ .myio-wp-head p{margin:2px 0 0;font-size:12px;opacity:.85}
79591
+ .myio-wp-sim{margin-left:auto;font-size:10px;font-weight:800;background:rgba(255,255,255,.18);border:1px solid rgba(255,255,255,.35);padding:2px 8px;border-radius:999px}
79592
+ .myio-wp-close{margin-left:auto;background:rgba(255,255,255,.15);border:0;color:#fff;width:32px;height:32px;border-radius:8px;font-size:18px;cursor:pointer;flex:none}
79593
+ .myio-wp-sim + .myio-wp-close{margin-left:0}
79594
+ .myio-wp-close:hover{background:rgba(255,255,255,.28)}
79595
+ .myio-wp-body{padding:18px 20px 20px;display:flex;flex-direction:column;gap:16px}
79596
+ .myio-wp-empty{padding:28px;text-align:center;color:#64748b;font-size:13px}
79597
+ .myio-wp-kpis{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
79598
+ .myio-wp-kpi{background:#fff;border:1px solid #e2e8f0;border-radius:10px;padding:10px 12px}
79599
+ .myio-wp-kpi small{display:block;font-size:11px;color:#64748b;font-weight:700;text-transform:uppercase;letter-spacing:.3px}
79600
+ .myio-wp-kpi b{font-size:20px;font-weight:800}
79601
+ .myio-wp-kpi .sub{font-size:11px;color:#64748b}
79602
+ .myio-wp-kpi b.open{color:#1d4ed8}.myio-wp-kpi b.closed{color:#b91c1c}
79603
+ .myio-wp-pumps{display:grid;grid-template-columns:1fr 1fr;gap:14px}
79604
+ @media (max-width:720px){.myio-wp-pumps,.myio-wp-kpis{grid-template-columns:1fr}}
79605
+ .myio-wp-card{background:#fff;border:1px solid #e2e8f0;border-radius:12px;padding:14px;display:flex;flex-direction:column;gap:12px;transition:box-shadow .2s,border-color .2s}
79606
+ .myio-wp-card.focus{border-color:#7c3aed;box-shadow:0 0 0 3px rgba(124,58,237,.18)}
79607
+ .myio-wp-top{display:flex;align-items:center;gap:12px}
79608
+ .myio-wp-img{width:54px;height:54px;object-fit:contain;transition:filter .3s}
79609
+ .myio-wp-card.is-off .myio-wp-img,.myio-wp-card.is-closed .myio-wp-img{filter:grayscale(1) opacity(.55)}
79610
+ .myio-wp-name{font-weight:800;font-size:15px}
79611
+ .myio-wp-tag{display:inline-flex;align-items:center;justify-content:center;min-width:26px;height:22px;padding:0 5px;border-radius:6px;
79612
+ font:800 11px Nunito,system-ui,sans-serif;margin-right:6px;vertical-align:middle;background:#e2e8f0;color:#64748b}
79613
+ .myio-wp-card.is-on .myio-wp-tag{background:#22c55e;color:#fff}
79614
+ .myio-wp-card.is-open .myio-wp-tag{background:#3b82f6;color:#fff}
79615
+ .myio-wp-card.is-closed .myio-wp-tag{background:#fecaca;color:#b91c1c}
79616
+ .myio-wp-meta{font-size:11.5px;color:#64748b;display:flex;gap:6px;align-items:center;flex-wrap:wrap;margin-top:2px}
79617
+ .myio-wp-prof{font-size:10px;font-weight:800;color:#475569;background:#f1f5f9;border:1px solid #e2e8f0;border-radius:4px;padding:0 5px}
79618
+ .myio-wp-state{margin-left:auto;display:inline-flex;align-items:center;gap:6px;padding:6px 12px;border-radius:999px;font-weight:800;font-size:13px;border:1px solid;white-space:nowrap}
79619
+ .myio-wp-state svg{width:16px;height:16px}
79620
+ .myio-wp-state.on{background:#dcfce7;border-color:#22c55e;color:#15803d}
79621
+ .myio-wp-state.off{background:#f1f5f9;border-color:#cbd5e1;color:#64748b}
79622
+ .myio-wp-state.open{background:#dbeafe;border-color:#3b82f6;color:#1d4ed8}
79623
+ .myio-wp-state.closed{background:#fef2f2;border-color:#fca5a5;color:#b91c1c}
79624
+ .myio-wp-state.unk{background:#fff;border-style:dashed;border-color:#cbd5e1;color:#94a3b8}
79625
+ .myio-wp-state.on .myio-eq-rotor{transform-origin:12px 12px;animation:myioWpSpin 1s linear infinite}
79626
+ @keyframes myioWpSpin{to{transform:rotate(360deg)}}
79627
+ .myio-wp-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
79628
+ .myio-wp-cell{background:#f8fafc;border:1px solid #eef2f7;border-radius:8px;padding:7px 9px}
79629
+ .myio-wp-cell small{display:block;font-size:10.5px;color:#64748b;font-weight:700}
79630
+ .myio-wp-cell span{font-size:14px;font-weight:800}
79631
+ .myio-wp-level{display:flex;align-items:center;gap:8px;font-size:12px;color:#475569}
79632
+ .myio-wp-bar{flex:1;height:8px;border-radius:999px;background:#e2e8f0;overflow:hidden}
79633
+ .myio-wp-bar i{display:block;height:100%;background:linear-gradient(90deg,#38bdf8,#0284c7);border-radius:999px}
79634
+ .myio-wp-tl small{font-size:10.5px;color:#64748b;font-weight:700;display:flex;justify-content:space-between}
79635
+ .myio-wp-track{position:relative;height:16px;border-radius:5px;background:#eef2f7;margin:4px 0 2px;overflow:hidden}
79636
+ .myio-wp-seg{position:absolute;top:0;bottom:0;background:#22c55e;border-radius:3px}
79637
+ .myio-wp-seg.live{background:repeating-linear-gradient(45deg,#22c55e 0 6px,#16a34a 6px 12px)}
79638
+ .myio-wp-seg.valve{background:#3b82f6}
79639
+ .myio-wp-seg.valve.live{background:repeating-linear-gradient(45deg,#3b82f6 0 6px,#1d4ed8 6px 12px)}
79640
+ .myio-wp-valve{display:grid;grid-template-columns:auto 1fr;gap:12px 16px;align-items:center}
79641
+ .myio-wp-foot{font-size:11.5px;color:#64748b}
79642
+ @media (prefers-reduced-motion:reduce){.myio-wp-overlay{animation:none}.myio-wp-state.on .myio-eq-rotor{animation:none}}
79643
+ `;
79644
+ document.head.appendChild(style);
79645
+ }
79646
+ var fmtKw = (n) => `${n.toFixed(1).replace(".", ",")} kW`;
79647
+ function timelineHTML(history, now, kind) {
79648
+ const segs = timelineSegments(history, now, DAY_MS).map((s) => {
79649
+ const title = `${kind === "valve" ? "aberta " : ""}${formatClock(s.start)} \u2013 ${s.end ? formatClock(s.end) : "agora"}`;
79650
+ return `<span class="myio-wp-seg ${kind === "valve" ? "valve" : ""} ${s.live ? "live" : ""}" style="left:${s.leftPct.toFixed(3)}%;width:${s.widthPct.toFixed(3)}%" title="${title}"></span>`;
79651
+ }).join("");
79652
+ return `
79653
+ <div class="myio-wp-tl">
79654
+ <small><span>\xDAltimas 24 h</span><span>${kind === "valve" ? "azul = aberta" : "verde = ligada"}</span></small>
79655
+ <div class="myio-wp-track">${segs}</div>
79656
+ <small><span>${formatClock(now - DAY_MS)}</span><span>agora</span></small>
79657
+ </div>`;
79658
+ }
79659
+ function pumpCardHTML(p, now, images, focusWellId) {
79660
+ const on = isActive(p.history);
79661
+ const known = Array.isArray(p.history);
79662
+ const stateClass = !known ? "is-unknown" : on ? "is-on" : "is-off";
79663
+ const since = stateSince(p.history);
79664
+ const { activeMs, starts } = dayStats(p.history || [], now);
79665
+ const power = !known ? "\u2014" : on ? typeof p.powerKw === "number" ? fmtKw(p.powerKw) : "\u2014" : fmtKw(0).replace(",0", "");
79666
+ const hasLevel = typeof p.wellLevelMca === "number";
79667
+ const hasPerc = typeof p.wellPercentage === "number";
79668
+ const pct = hasPerc ? Math.round(Math.max(0, Math.min(1, p.wellPercentage)) * 100) : null;
79669
+ const meta = [p.identifier, p.wellLabel].filter(Boolean).map(escapeHtml2).join(" \xB7 ");
79670
+ return `
79671
+ <div class="myio-wp-card ${stateClass} ${focusWellId && p.wellId === focusWellId ? "focus" : ""}" data-code="${escapeHtml2(p.code)}">
79672
+ <div class="myio-wp-top">
79673
+ <img class="myio-wp-img" src="${escapeHtml2(images.pump)}" alt="">
79674
+ <div>
79675
+ <div class="myio-wp-name"><span class="myio-wp-tag">${escapeHtml2(p.code)}</span>${escapeHtml2(p.label)}</div>
79676
+ <div class="myio-wp-meta"><span class="myio-wp-prof">${escapeHtml2(p.deviceProfile || "BOMBA_POCO")}</span>${meta}</div>
79677
+ </div>
79678
+ <span class="myio-wp-state ${!known ? "unk" : on ? "on" : "off"}">${PUMP_SVG}${!known ? "SEM LEITURA" : on ? "LIGADA" : "DESLIGADA"}</span>
79679
+ </div>
79680
+ <div class="myio-wp-grid">
79681
+ <div class="myio-wp-cell"><small>${known ? on ? "Ligada desde" : "Desligada desde" : "Estado desde"}</small><span>${formatClock(since)}</span></div>
79682
+ <div class="myio-wp-cell"><small>Tempo ligada hoje</small><span>${known ? formatDuration2(activeMs) : "\u2014"}</span></div>
79683
+ <div class="myio-wp-cell"><small>Acionamentos hoje</small><span>${known ? starts : "\u2014"}</span></div>
79684
+ <div class="myio-wp-cell"><small>Pot\xEAncia atual</small><span>${power}</span></div>
79685
+ <div class="myio-wp-cell"><small>Estado h\xE1</small><span>${since ? formatDuration2(now - since) : "\u2014"}</span></div>
79686
+ <div class="myio-wp-cell"><small>N\xEDvel do po\xE7o</small><span>${hasLevel ? `${(p.wellLevelMca / 100).toFixed(2).replace(".", ",")} M.C.A` : "\u2014"}</span></div>
79687
+ </div>
79688
+ ${pct !== null ? `<div class="myio-wp-level">${escapeHtml2(p.wellLabel || "Po\xE7o")}<div class="myio-wp-bar"><i style="width:${pct}%"></i></div>${pct}%</div>` : ""}
79689
+ ${timelineHTML(p.history || [], now, "pump")}
79690
+ </div>`;
79691
+ }
79692
+ function valveCardHTML(v, now, images) {
79693
+ const open = isActive(v.history);
79694
+ const known = Array.isArray(v.history);
79695
+ const stateClass = !known ? "is-unknown" : open ? "is-open" : "is-closed";
79696
+ const since = stateSince(v.history);
79697
+ const { activeMs, starts } = dayStats(v.history || [], now);
79698
+ const meta = [v.identifier, v.description].filter(Boolean).map(escapeHtml2).join(" \xB7 ");
79699
+ return `
79700
+ <div class="myio-wp-card myio-wp-valve ${stateClass}" data-code="${escapeHtml2(v.code)}">
79701
+ <img class="myio-wp-img" src="${escapeHtml2(images.valve)}" alt="">
79702
+ <div style="display:flex;flex-direction:column;gap:10px;min-width:0">
79703
+ <div class="myio-wp-top">
79704
+ <div>
79705
+ <div class="myio-wp-name"><span class="myio-wp-tag">${escapeHtml2(v.code)}</span>${escapeHtml2(v.label)}</div>
79706
+ <div class="myio-wp-meta"><span class="myio-wp-prof">${escapeHtml2(v.deviceProfile || "SOLENOIDE")}</span>${meta}</div>
79707
+ </div>
79708
+ <span class="myio-wp-state ${!known ? "unk" : open ? "open" : "closed"}">${VALVE_SVG}${!known ? "SEM LEITURA" : open ? "ABERTA" : "FECHADA"}</span>
79709
+ </div>
79710
+ <div class="myio-wp-grid">
79711
+ <div class="myio-wp-cell"><small>${known ? open ? "Aberta desde" : "Fechada desde" : "Estado desde"}</small><span>${formatClock(since)}</span></div>
79712
+ <div class="myio-wp-cell"><small>Tempo aberta hoje</small><span>${known ? formatDuration2(activeMs) : "\u2014"}</span></div>
79713
+ <div class="myio-wp-cell"><small>Aberturas hoje</small><span>${known ? starts : "\u2014"}</span></div>
79714
+ </div>
79715
+ ${timelineHTML(v.history || [], now, "valve")}
79716
+ </div>
79717
+ </div>`;
79718
+ }
79719
+ function renderWellPumpsBodyHTML(data, opts = {}) {
79720
+ const now = opts.now ?? Date.now();
79721
+ const images = {
79722
+ pump: opts.images?.pump || deviceIcons.BOMBA_POCO,
79723
+ valve: opts.images?.valve || deviceIcons.SOLENOIDE
79724
+ };
79725
+ const pumps = data?.pumps || [];
79726
+ const valves = data?.valves || [];
79727
+ if (!pumps.length && !valves.length) return `<div class="myio-wp-empty">Nenhuma bomba ou solenoide vinculada a este po\xE7o.</div>`;
79728
+ const onPumps = pumps.filter((p) => isActive(p.history));
79729
+ const unknownPumpCount = pumps.filter((p) => !Array.isArray(p.history)).length;
79730
+ const knownPower = onPumps.filter((p) => typeof p.powerKw === "number");
79731
+ const totalPower = unknownPumpCount > 0 ? knownPower.length ? `${fmtKw(knownPower.reduce((s, p) => s + p.powerKw, 0))} parcial` : "\u2014" : knownPower.length ? fmtKw(knownPower.reduce((s, p) => s + p.powerKw, 0)) : onPumps.length ? "\u2014" : "0 kW";
79732
+ const openValves = valves.filter((v) => isActive(v.history));
79733
+ const unknownValveCount = valves.filter((v) => !Array.isArray(v.history)).length;
79734
+ const valveKpi = valves.length === 1 ? `<div class="myio-wp-kpi"><small>${escapeHtml2(valves[0].label)}</small><b class="${!Array.isArray(valves[0].history) ? "" : openValves.length ? "open" : "closed"}">${!Array.isArray(valves[0].history) ? "SEM LEITURA" : openValves.length ? "Aberta" : "Fechada"}</b>
79735
+ <div class="sub">${Array.isArray(valves[0].history) ? `desde ${formatClock(stateSince(valves[0].history))}` : "Estado desconhecido"}</div></div>` : valves.length > 1 ? `<div class="myio-wp-kpi"><small>Solenoides abertas</small><b>${openValves.length} de ${valves.length}</b>${unknownValveCount ? `<div class="sub">${unknownValveCount} sem leitura</div>` : ""}</div>` : "";
79736
+ const pumpKpis = pumps.length ? `<div class="myio-wp-kpi"><small>Bombas ligadas</small><b>${onPumps.length} de ${pumps.length}</b>${unknownPumpCount ? `<div class="sub">${unknownPumpCount} sem leitura</div>` : ""}</div>
79737
+ <div class="myio-wp-kpi"><small>Pot\xEAncia total</small><b>${totalPower}</b>${unknownPumpCount && knownPower.length ? `<div class="sub">${unknownPumpCount} sem leitura</div>` : ""}</div>` : "";
79738
+ return `
79739
+ <div class="myio-wp-kpis">${pumpKpis}${valveKpi}</div>
79740
+ ${pumps.length ? `<div class="myio-wp-pumps">${pumps.map((p) => pumpCardHTML(p, now, images, opts.focusWellId)).join("")}</div>` : ""}
79741
+ ${valves.map((v) => valveCardHTML(v, now, images)).join("")}
79742
+ ${opts.footnote ? `<div class="myio-wp-foot">\u24D8 ${escapeHtml2(opts.footnote)}</div>` : ""}`;
79743
+ }
79744
+ function openWellPumpsModal(params) {
79745
+ ensureStyles();
79746
+ const overlay = document.createElement("div");
79747
+ overlay.className = "myio-wp-overlay";
79748
+ overlay.style.zIndex = String(params.zIndex ?? 1e5);
79749
+ overlay.innerHTML = `
79750
+ <div class="myio-wp-modal" role="dialog" aria-modal="true" aria-labelledby="myio-wp-title">
79751
+ <div class="myio-wp-head">
79752
+ <div>
79753
+ <h2 id="myio-wp-title">${escapeHtml2(params.title || "Automa\xE7\xE3o dos Po\xE7os")}</h2>
79754
+ ${params.subtitle ? `<p>${escapeHtml2(params.subtitle)}</p>` : ""}
79755
+ </div>
79756
+ ${params.simulated ? '<span class="myio-wp-sim">SIMULADO</span>' : ""}
79757
+ <button type="button" class="myio-wp-close" title="Fechar" aria-label="Fechar">\xD7</button>
79758
+ </div>
79759
+ <div class="myio-wp-body"><div class="myio-wp-empty">Carregando\u2026</div></div>
79760
+ </div>`;
79761
+ const body = overlay.querySelector(".myio-wp-body");
79762
+ let current = null;
79763
+ let closed = false;
79764
+ const timers = [];
79765
+ const render3 = () => {
79766
+ if (closed || !current) return;
79767
+ body.innerHTML = renderWellPumpsBodyHTML(current, {
79768
+ focusWellId: params.focusWellId,
79769
+ footnote: params.footnote,
79770
+ images: params.images
79771
+ });
79772
+ };
79773
+ const update = (data) => {
79774
+ current = data;
79775
+ render3();
79776
+ };
79777
+ const load = async () => {
79778
+ if (typeof params.data !== "function") return;
79779
+ try {
79780
+ update(await params.data());
79781
+ } catch (err) {
79782
+ console.warn("[WellPumpsModal] falha ao carregar dados:", err);
79783
+ if (!current) body.innerHTML = `<div class="myio-wp-empty">N\xE3o foi poss\xEDvel carregar o estado das bombas.</div>`;
79784
+ }
79785
+ };
79786
+ const onKey = (e) => {
79787
+ if (e.key === "Escape") close();
79788
+ };
79789
+ function close() {
79790
+ if (closed) return;
79791
+ closed = true;
79792
+ timers.forEach(clearInterval);
79793
+ document.removeEventListener("keydown", onKey);
79794
+ overlay.remove();
79795
+ try {
79796
+ params.onClose?.();
79797
+ } catch (err) {
79798
+ console.warn("[WellPumpsModal] onClose falhou:", err);
79799
+ }
79800
+ }
79801
+ overlay.addEventListener("click", (e) => {
79802
+ if (e.target === overlay) close();
79803
+ });
79804
+ overlay.querySelector(".myio-wp-close").addEventListener("click", close);
79805
+ document.addEventListener("keydown", onKey);
79806
+ document.body.appendChild(overlay);
79807
+ overlay.querySelector(".myio-wp-close").focus();
79808
+ if (typeof params.data === "function") {
79809
+ load();
79810
+ if (params.refreshIntervalMs && params.refreshIntervalMs > 0) timers.push(setInterval(load, params.refreshIntervalMs));
79811
+ } else {
79812
+ update(params.data);
79813
+ }
79814
+ timers.push(setInterval(render3, TICK_MS));
79815
+ return { update, close, element: overlay };
79816
+ }
79817
+
78916
79818
  // src/utils/telemetryUtils.ts
78917
79819
  function detectTelemetryType(keys) {
78918
79820
  if (!keys) {
@@ -80570,7 +81472,7 @@ async function openDemandModal(params) {
80570
81472
 
80571
81473
  // src/components/premium-modals/dialog/styles.ts
80572
81474
  var FONT_LINK_ID = "myio-dialog-font-nunito";
80573
- var STYLE_ID6 = "myio-dialog-styles";
81475
+ var STYLE_ID8 = "myio-dialog-styles";
80574
81476
  function injectDialogStyles() {
80575
81477
  if (!document.getElementById(FONT_LINK_ID)) {
80576
81478
  const link = document.createElement("link");
@@ -80579,9 +81481,9 @@ function injectDialogStyles() {
80579
81481
  link.href = "https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap";
80580
81482
  document.head.appendChild(link);
80581
81483
  }
80582
- if (document.getElementById(STYLE_ID6)) return;
81484
+ if (document.getElementById(STYLE_ID8)) return;
80583
81485
  const style = document.createElement("style");
80584
- style.id = STYLE_ID6;
81486
+ style.id = STYLE_ID8;
80585
81487
  style.textContent = `
80586
81488
  .myio-dialog-overlay {
80587
81489
  position: fixed;
@@ -80720,11 +81622,11 @@ function injectDialogStyles() {
80720
81622
  // src/components/premium-modals/dialog/openDialog.ts
80721
81623
  var BASE_Z_INDEX = 10500;
80722
81624
  var openCount = 0;
80723
- function escapeHtml7(value) {
81625
+ function escapeHtml9(value) {
80724
81626
  return String(value).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
80725
81627
  }
80726
81628
  function escapeMessage(value) {
80727
- return escapeHtml7(value).replace(/\n/g, "<br>");
81629
+ return escapeHtml9(value).replace(/\n/g, "<br>");
80728
81630
  }
80729
81631
  function cssWidth(width) {
80730
81632
  if (width == null) return "420px";
@@ -80749,7 +81651,7 @@ function openDialog(params) {
80749
81651
  overlay.style.zIndex = String(BASE_Z_INDEX + openCount);
80750
81652
  const buttonsHtml = params.buttons.map((btn, i) => {
80751
81653
  const variant = btn.variant ?? "secondary";
80752
- return `<button type="button" class="myio-dialog__btn myio-dialog__btn--${variant}" data-index="${i}">${escapeHtml7(btn.label)}</button>`;
81654
+ return `<button type="button" class="myio-dialog__btn myio-dialog__btn--${variant}" data-index="${i}">${escapeHtml9(btn.label)}</button>`;
80753
81655
  }).join("");
80754
81656
  overlay.innerHTML = `
80755
81657
  <div class="myio-dialog${params.modifier ? ` ${params.modifier}` : ""}"
@@ -80759,7 +81661,7 @@ function openDialog(params) {
80759
81661
  <div class="myio-dialog__accent"></div>
80760
81662
  <div class="myio-dialog__header">
80761
81663
  ${params.icon ? `<span class="myio-dialog__icon" aria-hidden="true">${params.icon}</span>` : ""}
80762
- <h3 class="myio-dialog__title" id="${idBase}-title">${escapeHtml7(params.title)}</h3>
81664
+ <h3 class="myio-dialog__title" id="${idBase}-title">${escapeHtml9(params.title)}</h3>
80763
81665
  ${dismissible ? `<button type="button" class="myio-dialog__close" aria-label="Fechar">\u2715</button>` : ""}
80764
81666
  </div>
80765
81667
  <p class="myio-dialog__message" id="${idBase}-message">${escapeMessage(params.message)}</p>
@@ -80851,11 +81753,11 @@ function openMessageDialog(params) {
80851
81753
  }
80852
81754
 
80853
81755
  // src/components/premium-modals/dialog/openGenericModal.ts
80854
- var STYLE_ID7 = "myio-genmodal-styles";
81756
+ var STYLE_ID9 = "myio-genmodal-styles";
80855
81757
  var FONT_LINK_ID2 = "myio-dialog-font-nunito";
80856
81758
  var BASE_Z_INDEX2 = 10600;
80857
81759
  var openCount2 = 0;
80858
- function escapeHtml8(value) {
81760
+ function escapeHtml10(value) {
80859
81761
  return String(value).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
80860
81762
  }
80861
81763
  function cssSize(v, fallback) {
@@ -80870,9 +81772,9 @@ function injectGenericModalStyles() {
80870
81772
  link.href = "https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap";
80871
81773
  document.head.appendChild(link);
80872
81774
  }
80873
- if (document.getElementById(STYLE_ID7)) return;
81775
+ if (document.getElementById(STYLE_ID9)) return;
80874
81776
  const style = document.createElement("style");
80875
- style.id = STYLE_ID7;
81777
+ style.id = STYLE_ID9;
80876
81778
  style.textContent = `
80877
81779
  .myio-genmodal-overlay {
80878
81780
  position: fixed;
@@ -80904,12 +81806,15 @@ function injectGenericModalStyles() {
80904
81806
  flex-shrink: 0;
80905
81807
  }
80906
81808
  .myio-genmodal__icon { font-size: 22px; line-height: 1.3; }
80907
- .myio-genmodal__title {
81809
+ /* h3.\u2026 + prefixo do overlay: vence o "h3" global do ThingsBoard (mat-typography) */
81810
+ .myio-genmodal-overlay h3.myio-genmodal__title {
80908
81811
  flex: 1;
80909
81812
  margin: 0;
81813
+ font-family: inherit;
80910
81814
  font-size: 18px;
80911
81815
  font-weight: 700;
80912
81816
  line-height: 1.35;
81817
+ letter-spacing: normal;
80913
81818
  }
80914
81819
  .myio-genmodal__close {
80915
81820
  border: none;
@@ -81005,17 +81910,17 @@ function openGenericModal(params) {
81005
81910
  overlay.style.zIndex = String(BASE_Z_INDEX2 + openCount2);
81006
81911
  const buttonsHtml = buttons.map((btn, i) => {
81007
81912
  const variant = btn.variant ?? "secondary";
81008
- return `<button type="button" class="myio-genmodal__btn myio-genmodal__btn--${variant}" data-index="${i}">${escapeHtml8(btn.label)}</button>`;
81913
+ return `<button type="button" class="myio-genmodal__btn myio-genmodal__btn--${variant}" data-index="${i}">${escapeHtml10(btn.label)}</button>`;
81009
81914
  }).join("");
81010
81915
  overlay.innerHTML = `
81011
- <div class="myio-genmodal${params.className ? ` ${escapeHtml8(params.className)}` : ""}"
81916
+ <div class="myio-genmodal${params.className ? ` ${escapeHtml10(params.className)}` : ""}"
81012
81917
  role="dialog" aria-modal="true"
81013
81918
  aria-labelledby="${idBase}-title"
81014
81919
  style="width:${cssSize(params.width, "560px")}">
81015
81920
  <div class="myio-genmodal__accent"></div>
81016
81921
  <div class="myio-genmodal__header">
81017
81922
  ${params.icon ? `<span class="myio-genmodal__icon" aria-hidden="true">${params.icon}</span>` : ""}
81018
- <h3 class="myio-genmodal__title" id="${idBase}-title">${escapeHtml8(params.title)}</h3>
81923
+ <h3 class="myio-genmodal__title" id="${idBase}-title">${escapeHtml10(params.title)}</h3>
81019
81924
  ${dismissible ? `<button type="button" class="myio-genmodal__close" aria-label="Fechar">\u2715</button>` : ""}
81020
81925
  </div>
81021
81926
  <div class="myio-genmodal__body" id="${idBase}-body" style="max-height:${cssSize(params.bodyMaxHeight, "70vh")}"></div>
@@ -81253,7 +82158,7 @@ function telemetriesInCatalogOrder(keys) {
81253
82158
 
81254
82159
  // src/utils/reports/demand/period.ts
81255
82160
  var SP_OFFSET_MS2 = -3 * 36e5;
81256
- var DAY_MS = 864e5;
82161
+ var DAY_MS2 = 864e5;
81257
82162
  var END_TOLERANCE_MS = 5 * 6e4;
81258
82163
  var MIN_PERIOD_START = "2019-03-01";
81259
82164
  var MIN_PERIOD_START_MS = Date.UTC(2019, 2, 1) - SP_OFFSET_MS2;
@@ -81305,7 +82210,7 @@ function localMidnightOf(ms) {
81305
82210
  }
81306
82211
  function bucketCount(start, end, resolution) {
81307
82212
  if (!(end > start)) return 0;
81308
- if (resolution === "1d") return Math.ceil((localMidnightOf(end - 1) - localMidnightOf(start)) / DAY_MS) + 1;
82213
+ if (resolution === "1d") return Math.ceil((localMidnightOf(end - 1) - localMidnightOf(start)) / DAY_MS2) + 1;
81309
82214
  return Math.ceil((end - start) / RESOLUTION_BY_ID[resolution].ms);
81310
82215
  }
81311
82216
  function finestFittingResolution(range, limits) {
@@ -81313,7 +82218,7 @@ function finestFittingResolution(range, limits) {
81313
82218
  const len = range.end - range.start;
81314
82219
  return RESOLUTIONS.find((r) => {
81315
82220
  const d = limits.maxDaysByResolution[r.id];
81316
- return d != null && len <= d * DAY_MS;
82221
+ return d != null && len <= d * DAY_MS2;
81317
82222
  })?.id ?? null;
81318
82223
  }
81319
82224
  function maxPeriodDays(resolution, limits) {
@@ -81327,7 +82232,7 @@ function periodErrors(range, resolution, now, limits = null) {
81327
82232
  if (range.start > now) errs.push("O in\xEDcio est\xE1 no futuro.");
81328
82233
  if (range.end > now + END_TOLERANCE_MS) errs.push("O fim n\xE3o pode estar no futuro.");
81329
82234
  const maxDays = maxPeriodDays(resolution, limits);
81330
- if (maxDays != null && range.end - range.start > maxDays * DAY_MS) {
82235
+ if (maxDays != null && range.end - range.start > maxDays * DAY_MS2) {
81331
82236
  errs.push(`Com intervalos de ${RESOLUTION_BY_ID[resolution].label}, o per\xEDodo m\xE1ximo \xE9 ${maxDays} dia(s).`);
81332
82237
  }
81333
82238
  if (resolution === "1d" && !isLocalMidnight(range.start)) {
@@ -84340,7 +85245,7 @@ function openGoalsPanel(params) {
84340
85245
  function sampleHourValue() {
84341
85246
  return isAverage() ? 22 : 150;
84342
85247
  }
84343
- function buildTemplateCsv() {
85248
+ function buildTemplateCsv2() {
84344
85249
  const avg = isAverage();
84345
85250
  const monthlyValue = avg ? 22 : 1e5;
84346
85251
  const dayValue = avg ? 22 : 3200;
@@ -84442,7 +85347,7 @@ function openGoalsPanel(params) {
84442
85347
  rootEl.setAttribute("role", "dialog");
84443
85348
  rootEl.setAttribute("aria-modal", "true");
84444
85349
  container.appendChild(rootEl);
84445
- injectStyles23();
85350
+ injectStyles26();
84446
85351
  rootEl.addEventListener("click", onClick);
84447
85352
  rootEl.addEventListener("change", onChange);
84448
85353
  rootEl.addEventListener("input", onInput);
@@ -84503,7 +85408,7 @@ function openGoalsPanel(params) {
84503
85408
  openImport();
84504
85409
  break;
84505
85410
  case "download-template":
84506
- downloadCsv(buildTemplateCsv(), "template");
85411
+ downloadCsv(buildTemplateCsv2(), "template");
84507
85412
  break;
84508
85413
  case "download-hourly":
84509
85414
  downloadCsv(buildHourlyExampleCsv(), "hourly-example");
@@ -85097,7 +86002,7 @@ ${state6.year}-03-15T08,15`)}">${esc5(state6.csv)}</textarea>
85097
86002
  return "";
85098
86003
  }
85099
86004
  }
85100
- function injectStyles23() {
86005
+ function injectStyles26() {
85101
86006
  const id = "myio-goals-gcdr-styles";
85102
86007
  const prev = document.getElementById(id);
85103
86008
  if (prev) prev.remove();
@@ -92050,13 +92955,13 @@ var COLUMN_SUMMARY_CSS = `
92050
92955
  var _cssInjected2 = false;
92051
92956
  function injectCSS10() {
92052
92957
  if (_cssInjected2 || typeof document === "undefined") return;
92053
- const STYLE_ID18 = "myio-column-summary-tooltip-css";
92054
- if (document.getElementById(STYLE_ID18)) {
92958
+ const STYLE_ID23 = "myio-column-summary-tooltip-css";
92959
+ if (document.getElementById(STYLE_ID23)) {
92055
92960
  _cssInjected2 = true;
92056
92961
  return;
92057
92962
  }
92058
92963
  const style = document.createElement("style");
92059
- style.id = STYLE_ID18;
92964
+ style.id = STYLE_ID23;
92060
92965
  style.textContent = COLUMN_SUMMARY_CSS;
92061
92966
  document.head.appendChild(style);
92062
92967
  _cssInjected2 = true;
@@ -99219,7 +100124,7 @@ function createConsumptionChartWidget(config2) {
99219
100124
  </div>
99220
100125
  `;
99221
100126
  }
99222
- function injectStyles23() {
100127
+ function injectStyles26() {
99223
100128
  if (styleElement) return;
99224
100129
  styleElement = document.createElement("style");
99225
100130
  styleElement.id = `${widgetId}-styles`;
@@ -99733,7 +100638,7 @@ function createConsumptionChartWidget(config2) {
99733
100638
  console.error(`[ConsumptionWidget] Container #${config2.containerId} not found`);
99734
100639
  return;
99735
100640
  }
99736
- injectStyles23();
100641
+ injectStyles26();
99737
100642
  containerElement.innerHTML = renderHTML();
99738
100643
  setupListeners();
99739
100644
  applyCollapseState();
@@ -99867,12 +100772,12 @@ function createConsumptionChartWidget(config2) {
99867
100772
  }
99868
100773
 
99869
100774
  // src/components/tooltips/goals-bar-tooltip/createGoalsBarTooltip.ts
99870
- var STYLE_ID8 = "myio-goals-bar-tooltip-styles";
100775
+ var STYLE_ID10 = "myio-goals-bar-tooltip-styles";
99871
100776
  var DEFAULT_ACCENT = "#6c5ce7";
99872
100777
  function injectStyles12(doc) {
99873
- if (doc.getElementById(STYLE_ID8)) return;
100778
+ if (doc.getElementById(STYLE_ID10)) return;
99874
100779
  const s = doc.createElement("style");
99875
- s.id = STYLE_ID8;
100780
+ s.id = STYLE_ID10;
99876
100781
  s.textContent = `
99877
100782
  .myio-gbt {
99878
100783
  position: fixed;
@@ -100981,11 +101886,11 @@ function _rerenderFromCache() {
100981
101886
  const { labels, totals, goalLine, prevTotals, domain } = _lastRender;
100982
101887
  _renderChart(canvas, labels, totals, goalLine, domain, prevTotals);
100983
101888
  }
100984
- var STYLE_ID9 = "myio-goals-modal-v2-styles";
101889
+ var STYLE_ID11 = "myio-goals-modal-v2-styles";
100985
101890
  function _injectStyles(topDoc) {
100986
- if (topDoc.getElementById(STYLE_ID9)) return;
101891
+ if (topDoc.getElementById(STYLE_ID11)) return;
100987
101892
  const s = topDoc.createElement("style");
100988
- s.id = STYLE_ID9;
101893
+ s.id = STYLE_ID11;
100989
101894
  s.textContent = `
100990
101895
  .gm-overlay{position:fixed;inset:0;z-index:1000000;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,.5);backdrop-filter:blur(4px);opacity:0;transition:opacity .2s ease;font-family:'Nunito', system-ui, sans-serif;}
100991
101896
  .gm-overlay.show{opacity:1;}
@@ -101187,19 +102092,19 @@ function _updateCoverageHint(topDoc) {
101187
102092
  const deviceCount = data.granularity === "DEVICE" ? data.devices?.length ?? 0 : 0;
101188
102093
  hint.textContent = `\u26A0 Meta incompleta para este dom\xEDnio/ano` + (deviceCount > 0 ? ` \xB7 Por medidor (${deviceCount})` : "") + ` \u2014 passe o mouse para detalhes`;
101189
102094
  tabs.insertAdjacentElement("afterend", hint);
101190
- const esc9 = (s) => String(s ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
102095
+ const esc10 = (s) => String(s ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
101191
102096
  try {
101192
102097
  _coverageDetach = InfoTooltip.attach(hint, () => {
101193
102098
  const d = _getGoalsData(_currentDomain);
101194
102099
  const parts = [];
101195
102100
  if (hasCoverageGaps(d?.coverageGaps)) {
101196
- parts.push(`<p style="margin:0 0 8px;">${esc9(buildCoverageWarningTextPtBR(d?.coverageGaps, "GERAL"))}</p>`);
102101
+ parts.push(`<p style="margin:0 0 8px;">${esc10(buildCoverageWarningTextPtBR(d?.coverageGaps, "GERAL"))}</p>`);
101197
102102
  }
101198
102103
  (d?.devices || []).forEach((dev) => {
101199
102104
  if (!hasCoverageGaps(dev?.coverageGaps)) return;
101200
102105
  const label = dev.label || dev.code || "medidor";
101201
102106
  parts.push(
101202
- `<p style="margin:0 0 8px;">${esc9(buildCoverageWarningTextPtBR(dev.coverageGaps, `do medidor ${label}`))}</p>`
102107
+ `<p style="margin:0 0 8px;">${esc10(buildCoverageWarningTextPtBR(dev.coverageGaps, `do medidor ${label}`))}</p>`
101203
102108
  );
101204
102109
  });
101205
102110
  return {
@@ -103836,7 +104741,7 @@ function createMyIOTheme(settings, mode) {
103836
104741
  // src/components/settings-hub/openSettingsHubModal.ts
103837
104742
  var ROUTE_DELAY_MS = 250;
103838
104743
  var MODAL_ID2 = "myio-conf-picker";
103839
- var STYLE_ID10 = "myio-conf-picker-styles";
104744
+ var STYLE_ID12 = "myio-conf-picker-styles";
103840
104745
  var HUB_OPTIONS = [
103841
104746
  {
103842
104747
  action: "temperature",
@@ -104027,7 +104932,7 @@ var HUB_CSS = `
104027
104932
  color: var(--myio-brand-700, #7B2FF7);
104028
104933
  }
104029
104934
  `;
104030
- function escapeHtml9(value) {
104935
+ function escapeHtml11(value) {
104031
104936
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
104032
104937
  }
104033
104938
  function resolveTopDocument() {
@@ -104047,9 +104952,9 @@ function resolveHubThemeVars(explicit) {
104047
104952
  function openSettingsHubModal(options) {
104048
104953
  const { customerName = "", isSuperAdmin: isSuperAdmin2 = false, handlers } = options;
104049
104954
  const doc = options.targetDocument || resolveTopDocument();
104050
- if (!doc.getElementById(STYLE_ID10)) {
104955
+ if (!doc.getElementById(STYLE_ID12)) {
104051
104956
  const style = doc.createElement("style");
104052
- style.id = STYLE_ID10;
104957
+ style.id = STYLE_ID12;
104053
104958
  style.textContent = HUB_CSS;
104054
104959
  doc.head.appendChild(style);
104055
104960
  }
@@ -104074,7 +104979,7 @@ function openSettingsHubModal(options) {
104074
104979
  <div class="myio-conf-picker__overlay"></div>
104075
104980
  <div class="myio-conf-picker__content">
104076
104981
  <div class="myio-conf-picker__header">
104077
- <h3>\u2699\uFE0F Configura\xE7\xF5es${customerName ? ` \u2014 ${escapeHtml9(customerName)}` : ""}</h3>
104982
+ <h3>\u2699\uFE0F Configura\xE7\xF5es${customerName ? ` \u2014 ${escapeHtml11(customerName)}` : ""}</h3>
104078
104983
  <button class="myio-conf-picker__close" aria-label="Fechar">&times;</button>
104079
104984
  </div>
104080
104985
  <div class="myio-conf-picker__body">${cardsHtml}
@@ -105269,7 +106174,7 @@ function createTariffApiAdapter(client, opts) {
105269
106174
 
105270
106175
  // src/components/pricing-panel/openPricingPanel.ts
105271
106176
  var MODAL_ID3 = "myio-pricing-panel";
105272
- function escapeHtml10(value) {
106177
+ function escapeHtml12(value) {
105273
106178
  return String(value).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
105274
106179
  }
105275
106180
  function resolveTopDocument2() {
@@ -105424,7 +106329,7 @@ function openPricingPanel(params) {
105424
106329
  }
105425
106330
  const initDomain = params.domain || "energy";
105426
106331
  const initCategory = params.category || "lojas";
105427
- const customerOptions = customers.map((c) => `<option value="${escapeHtml10(resolveCustomerId(c))}">${escapeHtml10(c.title)}</option>`).join("");
106332
+ const customerOptions = customers.map((c) => `<option value="${escapeHtml12(resolveCustomerId(c))}">${escapeHtml12(c.title)}</option>`).join("");
105428
106333
  modal.innerHTML = `
105429
106334
  <div class="myio-pricing__overlay"></div>
105430
106335
  <div class="myio-pricing__content">
@@ -105639,9 +106544,9 @@ function openPricingPanel(params) {
105639
106544
  const pushAudit = (rec) => {
105640
106545
  if (rec) auditLog = [rec, ...auditLog];
105641
106546
  };
105642
- const badge = (domain, category) => `<span class="myio-pricing__badge${domain === "water" ? " myio-pricing__badge--water" : ""}">${escapeHtml10(
106547
+ const badge = (domain, category) => `<span class="myio-pricing__badge${domain === "water" ? " myio-pricing__badge--water" : ""}">${escapeHtml12(
105643
106548
  DOMAIN_LABEL[domain]
105644
- )} \xB7 ${escapeHtml10(CATEGORY_LABEL[category])}</span>`;
106549
+ )} \xB7 ${escapeHtml12(CATEGORY_LABEL[category])}</span>`;
105645
106550
  const renderList2 = () => {
105646
106551
  const customerId = customerSel.value;
105647
106552
  const rows = entries.filter((e) => e.customerId === customerId).sort((a, b) => {
@@ -105654,15 +106559,15 @@ function openPricingPanel(params) {
105654
106559
  const boundsKey = b ? `${b.start}__${b.end}` : "";
105655
106560
  return `
105656
106561
  <li class="myio-pricing__item">
105657
- <span class="myio-pricing__item-period">${badge(e.domain, e.category)} ${escapeHtml10(
106562
+ <span class="myio-pricing__item-period">${badge(e.domain, e.category)} ${escapeHtml12(
105658
106563
  formatPeriodLabel(e)
105659
106564
  )}</span>
105660
- <span class="myio-pricing__item-price">${escapeHtml10(formatBRL2(e.pricePerKwh))} ${escapeHtml10(
106565
+ <span class="myio-pricing__item-price">${escapeHtml12(formatBRL2(e.pricePerKwh))} ${escapeHtml12(
105661
106566
  unitLabel(e.domain)
105662
106567
  )}</span>
105663
- <button class="myio-pricing__remove" data-remove="${escapeHtml10(e.domain)}|${escapeHtml10(
106568
+ <button class="myio-pricing__remove" data-remove="${escapeHtml12(e.domain)}|${escapeHtml12(
105664
106569
  e.category
105665
- )}|${escapeHtml10(boundsKey)}" aria-label="Remover" type="button">\u2715</button>
106570
+ )}|${escapeHtml12(boundsKey)}" aria-label="Remover" type="button">\u2715</button>
105666
106571
  </li>`;
105667
106572
  }).join("");
105668
106573
  emptyEl.style.display = rows.length ? "none" : "";
@@ -105761,8 +106666,8 @@ function openPricingPanel(params) {
105761
106666
  kpiEl.innerHTML = cards.map(
105762
106667
  (c) => `
105763
106668
  <div class="myio-pricing__kpi">
105764
- <div class="myio-pricing__kpi-value">${escapeHtml10(c.value)}</div>
105765
- <div class="myio-pricing__kpi-label">${escapeHtml10(c.label)}</div>
106669
+ <div class="myio-pricing__kpi-value">${escapeHtml12(c.value)}</div>
106670
+ <div class="myio-pricing__kpi-label">${escapeHtml12(c.label)}</div>
105766
106671
  </div>`
105767
106672
  ).join("");
105768
106673
  renderReport();
@@ -105781,11 +106686,11 @@ function openPricingPanel(params) {
105781
106686
  reportBody.innerHTML = rows.length ? rows.map(
105782
106687
  (e) => `
105783
106688
  <tr>
105784
- <td>${escapeHtml10(customerTitle(e.customerId))}</td>
105785
- <td>${escapeHtml10(DOMAIN_LABEL[e.domain])}</td>
105786
- <td>${escapeHtml10(CATEGORY_LABEL[e.category])}</td>
105787
- <td>${escapeHtml10(formatPeriodLabel(e))}</td>
105788
- <td>${escapeHtml10(formatBRL2(e.pricePerKwh))} ${escapeHtml10(unitLabel(e.domain))}</td>
106689
+ <td>${escapeHtml12(customerTitle(e.customerId))}</td>
106690
+ <td>${escapeHtml12(DOMAIN_LABEL[e.domain])}</td>
106691
+ <td>${escapeHtml12(CATEGORY_LABEL[e.category])}</td>
106692
+ <td>${escapeHtml12(formatPeriodLabel(e))}</td>
106693
+ <td>${escapeHtml12(formatBRL2(e.pricePerKwh))} ${escapeHtml12(unitLabel(e.domain))}</td>
105789
106694
  </tr>`
105790
106695
  ).join("") : `<tr><td colspan="5" style="text-align:center;color:var(--myio-text-muted,#6b7280);padding:24px;">Nenhum pre\xE7o para o filtro selecionado.</td></tr>`;
105791
106696
  }
@@ -105795,15 +106700,15 @@ function openPricingPanel(params) {
105795
106700
  return `
105796
106701
  <li class="myio-pricing__history-item">
105797
106702
  <div class="myio-pricing__history-head">
105798
- <span class="myio-pricing__action myio-pricing__action--${escapeHtml10(rec.action)}">${escapeHtml10(
106703
+ <span class="myio-pricing__action myio-pricing__action--${escapeHtml12(rec.action)}">${escapeHtml12(
105799
106704
  rec.action
105800
106705
  )}</span>
105801
106706
  ${badge(rec.domain, rec.category)}
105802
- <span>${escapeHtml10(rec.periodLabel)}${escapeHtml10(priceInfo)}</span>
106707
+ <span>${escapeHtml12(rec.periodLabel)}${escapeHtml12(priceInfo)}</span>
105803
106708
  </div>
105804
- <div class="myio-pricing__history-meta">${escapeHtml10(customerTitle(rec.customerId))} \xB7 ${escapeHtml10(
106709
+ <div class="myio-pricing__history-meta">${escapeHtml12(customerTitle(rec.customerId))} \xB7 ${escapeHtml12(
105805
106710
  rec.by || "\u2014"
105806
- )} \xB7 ${escapeHtml10(fmtTimestamp(rec.at))}</div>
106711
+ )} \xB7 ${escapeHtml12(fmtTimestamp(rec.at))}</div>
105807
106712
  </li>`;
105808
106713
  }).join("");
105809
106714
  historyEmpty.style.display = auditLog.length ? "none" : "";
@@ -109381,11 +110286,11 @@ function renderModal6(container, state6, modalId, t, error) {
109381
110286
  setupEventListeners5(container, state6, modalId, t);
109382
110287
  }
109383
110288
  function renderStepIndicator(step, label, currentStep, colors2) {
109384
- const isActive = step === currentStep;
110289
+ const isActive2 = step === currentStep;
109385
110290
  const isCompleted = step < currentStep;
109386
- const bgColor = isActive ? MYIO_PURPLE : isCompleted ? colors2.success : colors2.cardBg;
109387
- const textColor = isActive || isCompleted ? "white" : colors2.textMuted;
109388
- const borderColor = isActive || isCompleted ? "transparent" : colors2.border;
110291
+ const bgColor = isActive2 ? MYIO_PURPLE : isCompleted ? colors2.success : colors2.cardBg;
110292
+ const textColor = isActive2 || isCompleted ? "white" : colors2.textMuted;
110293
+ const borderColor = isActive2 || isCompleted ? "transparent" : colors2.border;
109389
110294
  return `
109390
110295
  <div style="
109391
110296
  display: flex; align-items: center; gap: 8px;
@@ -109425,10 +110330,10 @@ function renderStep1(state6, modalId, colors2, t) {
109425
110330
  const { field: sortField, order: sortOrder } = state6.customerSort;
109426
110331
  const sortedCustomers = sortCustomers(state6.customers, sortField, sortOrder, state6.customerNameMap);
109427
110332
  const sortIcon = sortOrder === "asc" ? "\u2191" : "\u2193";
109428
- const btnStyle = (isActive) => `
109429
- background: ${isActive ? MYIO_PURPLE : colors2.cardBg};
109430
- color: ${isActive ? "white" : colors2.text};
109431
- border: 1px solid ${isActive ? MYIO_PURPLE : colors2.border};
110333
+ const btnStyle = (isActive2) => `
110334
+ background: ${isActive2 ? MYIO_PURPLE : colors2.cardBg};
110335
+ color: ${isActive2 ? "white" : colors2.text};
110336
+ border: 1px solid ${isActive2 ? MYIO_PURPLE : colors2.border};
109432
110337
  padding: 6px 12px; border-radius: 6px; cursor: pointer;
109433
110338
  font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 4px;
109434
110339
  `;
@@ -109653,16 +110558,16 @@ function renderStep2(state6, modalId, colors2, t) {
109653
110558
  const gridHeight = state6.isMaximized ? "calc(100vh - 340px)" : "360px";
109654
110559
  const hasActiveFilters = filterTypes.length > 0 || filterDeviceTypes.length > 0 || filterDeviceProfiles.length > 0 || filterStatuses.length > 0 || filterTelemetryKeys.length > 0;
109655
110560
  const renderSortableHeader = (col2, label, field, width) => {
109656
- const isActive = sortField === field;
109657
- const arrow = isActive ? sortOrder === "asc" ? "\u25B2" : "\u25BC" : "\u25BD";
110561
+ const isActive2 = sortField === field;
110562
+ const arrow = isActive2 ? sortOrder === "asc" ? "\u25B2" : "\u25BC" : "\u25BD";
109658
110563
  return `
109659
110564
  <div id="${modalId}-sort-col-${col2}" data-sort-field="${field}" style="
109660
110565
  width: ${width}px; padding: 0 6px; display: flex; align-items: center; justify-content: space-between;
109661
110566
  border-right: 1px solid ${colors2.border}; cursor: pointer; user-select: none;
109662
- ${isActive ? `background: rgba(62,26,125,0.1);` : ""}
110567
+ ${isActive2 ? `background: rgba(62,26,125,0.1);` : ""}
109663
110568
  ">
109664
110569
  <span>${label}</span>
109665
- <span style="font-size: 8px; color: ${isActive ? MYIO_PURPLE : colors2.textMuted};">${arrow}</span>
110570
+ <span style="font-size: 8px; color: ${isActive2 ? MYIO_PURPLE : colors2.textMuted};">${arrow}</span>
109666
110571
  </div>
109667
110572
  `;
109668
110573
  };
@@ -109945,10 +110850,10 @@ function renderStep2(state6, modalId, colors2, t) {
109945
110850
  });
109946
110851
  const colSpan = multiCol ? 16 : 15;
109947
110852
  const cfSortHeader = (field, label, rowspan = 1, extraStyle = "") => {
109948
- const isActive = state6.checkFixSort.field === field;
109949
- const arrow = isActive ? state6.checkFixSort.order === "asc" ? "\u25B2" : "\u25BC" : "\u25BD";
109950
- return `<th ${rowspan > 1 ? `rowspan="${rowspan}"` : ""} id="${modalId}-cf-sort-${field}" data-cf-sort="${field}" style="${thStyle(extraStyle)} cursor:pointer; user-select:none; ${isActive ? `background:rgba(62,26,125,0.18);` : ""}">
109951
- <span style="display:flex;align-items:center;gap:3px;white-space:nowrap;">${label}<span style="font-size:7px;color:${isActive ? MYIO_PURPLE : colors2.textMuted};">${arrow}</span></span>
110853
+ const isActive2 = state6.checkFixSort.field === field;
110854
+ const arrow = isActive2 ? state6.checkFixSort.order === "asc" ? "\u25B2" : "\u25BC" : "\u25BD";
110855
+ return `<th ${rowspan > 1 ? `rowspan="${rowspan}"` : ""} id="${modalId}-cf-sort-${field}" data-cf-sort="${field}" style="${thStyle(extraStyle)} cursor:pointer; user-select:none; ${isActive2 ? `background:rgba(62,26,125,0.18);` : ""}">
110856
+ <span style="display:flex;align-items:center;gap:3px;white-space:nowrap;">${label}<span style="font-size:7px;color:${isActive2 ? MYIO_PURPLE : colors2.textMuted};">${arrow}</span></span>
109952
110857
  </th>`;
109953
110858
  };
109954
110859
  const allDomains = [...new Set(state6.checkFixReport.records.map((r) => r.domain || "null"))].sort();
@@ -114138,6 +115043,1116 @@ function refreshIncidentBadges(opts) {
114138
115043
  });
114139
115044
  }
114140
115045
 
115046
+ // src/components/premium-modals/standard-modal/openStandardModal.ts
115047
+ var STYLE_ID13 = "myio-stdmodal-styles";
115048
+ var FONT_LINK_ID3 = "myio-dialog-font-nunito";
115049
+ var BASE_Z_INDEX3 = 10700;
115050
+ var openCount3 = 0;
115051
+ function escapeHtml13(v) {
115052
+ return String(v).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
115053
+ }
115054
+ function injectStyles13() {
115055
+ if (!document.getElementById(FONT_LINK_ID3)) {
115056
+ const link = document.createElement("link");
115057
+ link.id = FONT_LINK_ID3;
115058
+ link.rel = "stylesheet";
115059
+ link.href = "https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap";
115060
+ document.head.appendChild(link);
115061
+ }
115062
+ if (document.getElementById(STYLE_ID13)) return;
115063
+ const style = document.createElement("style");
115064
+ style.id = STYLE_ID13;
115065
+ style.textContent = `
115066
+ .myio-stdmodal-overlay {
115067
+ position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
115068
+ background: rgba(0, 0, 0, 0.5); font-family: 'Nunito', system-ui, sans-serif;
115069
+ }
115070
+ .myio-stdmodal {
115071
+ background: #fff; color: #1f2937; border-radius: 10px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
115072
+ max-width: 94vw; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
115073
+ }
115074
+ .myio-stdmodal__body { padding: 20px 24px; overflow-y: auto; font-size: 14px; color: #374151; }
115075
+ .myio-stdmodal__footer {
115076
+ display: flex; justify-content: flex-end; gap: 12px; padding: 16px 24px;
115077
+ border-top: 1px solid #e0e0e0; background: #fff;
115078
+ }
115079
+ .myio-stdmodal__btn {
115080
+ font-family: inherit; padding: 10px 20px; border: none; border-radius: 6px; font-size: 14px;
115081
+ font-weight: 500; cursor: pointer; transition: all 0.2s; color: #fff;
115082
+ }
115083
+ .myio-stdmodal__btn--secondary { background: #6c757d; }
115084
+ .myio-stdmodal__btn--secondary:hover:not(:disabled) { background: #545b62; }
115085
+ .myio-stdmodal__btn--primary { background: var(--myio-brand-700, #3e1a7d); }
115086
+ .myio-stdmodal__btn--primary:hover:not(:disabled) { background: var(--myio-brand-600, #2d1458); }
115087
+ .myio-stdmodal__btn--danger { background: #dc3545; }
115088
+ .myio-stdmodal__btn--danger:hover:not(:disabled) { background: #b02a37; }
115089
+ .myio-stdmodal__btn:disabled { opacity: 0.6; cursor: not-allowed; }
115090
+ .myio-stdmodal__btn:focus-visible { outline: 2px solid #7c3aed; outline-offset: 2px; }
115091
+ `;
115092
+ document.head.appendChild(style);
115093
+ }
115094
+ var FOCUSABLE2 = 'button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
115095
+ function openStandardModal(params) {
115096
+ injectStyles13();
115097
+ const dismissible = params.dismissible ?? true;
115098
+ const buttons = params.buttons ?? [];
115099
+ const modalId = `myio-stdmodal-${++openCount3}`;
115100
+ const width = params.width == null ? "480px" : typeof params.width === "number" ? `${params.width}px` : params.width;
115101
+ const overlay = document.createElement("div");
115102
+ overlay.className = "myio-stdmodal-overlay";
115103
+ overlay.style.zIndex = String(BASE_Z_INDEX3 + openCount3);
115104
+ overlay.innerHTML = `
115105
+ <div class="myio-stdmodal" role="dialog" aria-modal="true" aria-label="${escapeHtml13(params.title)}" style="width:${width}">
115106
+ ${ModalHeader.generateHTML({
115107
+ icon: params.icon,
115108
+ title: escapeHtml13(params.title),
115109
+ modalId,
115110
+ showThemeToggle: false,
115111
+ showMaximize: false,
115112
+ showClose: dismissible,
115113
+ draggable: false
115114
+ })}
115115
+ <div class="myio-stdmodal__body"></div>
115116
+ ${buttons.length ? `<div class="myio-stdmodal__footer">${buttons.map(
115117
+ (b, i) => `<button type="button" class="myio-stdmodal__btn myio-stdmodal__btn--${b.variant ?? "secondary"}" data-index="${i}" data-value="${escapeHtml13(b.value)}">${escapeHtml13(b.label)}</button>`
115118
+ ).join("")}</div>` : ""}
115119
+ </div>`;
115120
+ const root = overlay.querySelector(".myio-stdmodal");
115121
+ const bodyEl = root.querySelector(".myio-stdmodal__body");
115122
+ bodyEl.innerHTML = params.bodyHtml;
115123
+ const previousFocus = document.activeElement;
115124
+ (params.container ?? document.body).appendChild(overlay);
115125
+ let closed = false;
115126
+ const close = () => {
115127
+ if (closed) return;
115128
+ closed = true;
115129
+ document.removeEventListener("keydown", onKeydown, true);
115130
+ overlay.remove();
115131
+ if (previousFocus?.isConnected) previousFocus.focus();
115132
+ params.onClose?.();
115133
+ };
115134
+ const onKeydown = (e) => {
115135
+ if (!overlay.isConnected) return;
115136
+ if (e.key === "Escape" && dismissible) {
115137
+ e.stopPropagation();
115138
+ close();
115139
+ } else if (e.key === "Tab") {
115140
+ const f = Array.from(root.querySelectorAll(FOCUSABLE2)).filter((el2) => el2.offsetParent !== null || el2 === document.activeElement);
115141
+ if (!f.length) return;
115142
+ const first = f[0];
115143
+ const last = f[f.length - 1];
115144
+ if (e.shiftKey && document.activeElement === first) {
115145
+ e.preventDefault();
115146
+ last.focus();
115147
+ } else if (!e.shiftKey && document.activeElement === last) {
115148
+ e.preventDefault();
115149
+ first.focus();
115150
+ }
115151
+ }
115152
+ };
115153
+ document.addEventListener("keydown", onKeydown, true);
115154
+ root.querySelector(`#${modalId}-close`)?.addEventListener("click", (e) => {
115155
+ e.stopPropagation();
115156
+ close();
115157
+ });
115158
+ if (dismissible) {
115159
+ overlay.addEventListener("click", (e) => {
115160
+ if (e.target === overlay) close();
115161
+ });
115162
+ }
115163
+ root.querySelectorAll(".myio-stdmodal__btn").forEach((el2) => {
115164
+ el2.addEventListener("click", () => {
115165
+ const b = buttons[Number(el2.dataset.index)];
115166
+ if (!b || el2.disabled) return;
115167
+ params.onButton?.(b.value);
115168
+ if (b.closeOnClick !== false) close();
115169
+ });
115170
+ });
115171
+ (root.querySelector(`.myio-stdmodal__body ${FOCUSABLE2}`) ?? root.querySelector(".myio-stdmodal__btn--primary") ?? root)?.focus?.();
115172
+ return {
115173
+ close,
115174
+ getRoot: () => root,
115175
+ getBodyEl: () => bodyEl,
115176
+ setBodyHtml: (html) => {
115177
+ bodyEl.innerHTML = html;
115178
+ },
115179
+ setButton: (value, patch) => {
115180
+ const el2 = Array.from(root.querySelectorAll(".myio-stdmodal__btn")).find(
115181
+ (b) => b.dataset.value === value
115182
+ );
115183
+ if (!el2) return;
115184
+ if (patch.label !== void 0) el2.textContent = patch.label;
115185
+ if (patch.disabled !== void 0) el2.disabled = patch.disabled;
115186
+ if (patch.hidden !== void 0) el2.style.display = patch.hidden ? "none" : "";
115187
+ }
115188
+ };
115189
+ }
115190
+
115191
+ // src/components/premium-modals/telemetry-import/sheet.ts
115192
+ var VALUE_COLUMN = {
115193
+ energy: "value_kwh",
115194
+ water: "value_m3"
115195
+ };
115196
+ var MAX_IMPORT_ROWS = 5e3;
115197
+ var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
115198
+ var pad24 = (n) => String(n).padStart(2, "0");
115199
+ function splitImportableDevices(devices) {
115200
+ const ok = [];
115201
+ const missingKey = [];
115202
+ for (const d of devices || []) {
115203
+ const slave = Number(d?.slaveId);
115204
+ if (d?.centralId && UUID_RE.test(String(d.centralId)) && Number.isInteger(slave) && slave >= 1 && slave <= 247) ok.push(d);
115205
+ else missingKey.push(d);
115206
+ }
115207
+ return { ok, missingKey };
115208
+ }
115209
+ function daysBetween(start, end) {
115210
+ const out = [];
115211
+ const [y1, m1, d1] = start.split("-").map(Number);
115212
+ const [y2, m2, d2] = end.split("-").map(Number);
115213
+ const cur = new Date(Date.UTC(y1, m1 - 1, d1));
115214
+ const last = Date.UTC(y2, m2 - 1, d2);
115215
+ while (cur.getTime() <= last && out.length < 400) {
115216
+ out.push(`${cur.getUTCFullYear()}-${pad24(cur.getUTCMonth() + 1)}-${pad24(cur.getUTCDate())}`);
115217
+ cur.setUTCDate(cur.getUTCDate() + 1);
115218
+ }
115219
+ return out;
115220
+ }
115221
+ function nowSaoPaulo(now) {
115222
+ const d = new Date(now - 3 * 3600 * 1e3);
115223
+ return { date: `${d.getUTCFullYear()}-${pad24(d.getUTCMonth() + 1)}-${pad24(d.getUTCDate())}`, hour: d.getUTCHours() };
115224
+ }
115225
+ function buildTemplateCsv(domain, devices, start, end, now = Date.now()) {
115226
+ const valueCol = VALUE_COLUMN[domain];
115227
+ const header = ["gateway_id", "slave_id", "device_name", "date", "hour", valueCol];
115228
+ if (domain === "energy") header.push("value_reactive_kvarh");
115229
+ const today = nowSaoPaulo(now);
115230
+ const lines = [header.join(";")];
115231
+ const esc10 = (v) => /[;"\n]/.test(v) ? `"${v.replace(/"/g, '""')}"` : v;
115232
+ const { ok } = splitImportableDevices(devices);
115233
+ for (const dev of ok) {
115234
+ for (const date of daysBetween(start, end)) {
115235
+ if (date > today.date) break;
115236
+ for (let h3 = 0; h3 < 24; h3++) {
115237
+ if (date === today.date && h3 >= today.hour) break;
115238
+ const cols = [String(dev.centralId), String(Number(dev.slaveId)), esc10(dev.label || ""), date, `${pad24(h3)}:00`, ""];
115239
+ if (domain === "energy") cols.push("");
115240
+ lines.push(cols.join(";"));
115241
+ }
115242
+ }
115243
+ }
115244
+ return { csv: "\uFEFF" + lines.join("\r\n") + "\r\n", rows: lines.length - 1 };
115245
+ }
115246
+ function parseCsv(text2) {
115247
+ const src = String(text2 || "").replace(/^/, "");
115248
+ const firstLine = src.split(/\r?\n/, 1)[0] || "";
115249
+ const sep = (firstLine.match(/;/g) || []).length >= (firstLine.match(/,/g) || []).length ? ";" : ",";
115250
+ const out = [];
115251
+ let row = [];
115252
+ let cell = "";
115253
+ let quoted = false;
115254
+ for (let i = 0; i < src.length; i++) {
115255
+ const c = src[i];
115256
+ if (quoted) {
115257
+ if (c === '"' && src[i + 1] === '"') {
115258
+ cell += '"';
115259
+ i++;
115260
+ } else if (c === '"') quoted = false;
115261
+ else cell += c;
115262
+ } else if (c === '"') quoted = true;
115263
+ else if (c === sep) {
115264
+ row.push(cell);
115265
+ cell = "";
115266
+ } else if (c === "\n" || c === "\r") {
115267
+ if (c === "\r" && src[i + 1] === "\n") i++;
115268
+ row.push(cell);
115269
+ out.push(row);
115270
+ row = [];
115271
+ cell = "";
115272
+ } else cell += c;
115273
+ }
115274
+ if (cell !== "" || row.length) {
115275
+ row.push(cell);
115276
+ out.push(row);
115277
+ }
115278
+ return out;
115279
+ }
115280
+ function normalizeDate(v) {
115281
+ if (typeof v === "number" && Number.isFinite(v) && v > 2e4 && v < 8e4) {
115282
+ const d = new Date(Date.UTC(1899, 11, 30) + Math.floor(v) * 864e5);
115283
+ return `${d.getUTCFullYear()}-${pad24(d.getUTCMonth() + 1)}-${pad24(d.getUTCDate())}`;
115284
+ }
115285
+ const s = String(v ?? "").trim();
115286
+ let m = /^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(s);
115287
+ if (m) return `${m[1]}-${pad24(+m[2])}-${pad24(+m[3])}`;
115288
+ m = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(s);
115289
+ if (m) return `${m[3]}-${pad24(+m[2])}-${pad24(+m[1])}`;
115290
+ return null;
115291
+ }
115292
+ function normalizeHour(v) {
115293
+ if (typeof v === "number" && Number.isFinite(v) && v >= 0 && v < 1) {
115294
+ const mins = Math.round(v * 24 * 60);
115295
+ return mins % 60 === 0 ? `${pad24(mins / 60)}:00` : null;
115296
+ }
115297
+ const s = String(v ?? "").trim();
115298
+ const m = /^(\d{1,2})(?::(\d{2})(?::(\d{2}))?)?$/.exec(s);
115299
+ if (!m) return null;
115300
+ const h3 = Number(m[1]);
115301
+ if (h3 > 23 || Number(m[2] || 0) !== 0 || Number(m[3] || 0) !== 0) return null;
115302
+ return `${pad24(h3)}:00`;
115303
+ }
115304
+ function parseDecimal(v) {
115305
+ if (typeof v === "number") return Number.isFinite(v) ? v : NaN;
115306
+ const s = String(v ?? "").trim();
115307
+ if (!s) return null;
115308
+ const norm2 = s.includes(",") ? s.replace(/\./g, "").replace(",", ".") : s;
115309
+ return /^-?\d+(\.\d+)?$/.test(norm2) ? Number(norm2) : NaN;
115310
+ }
115311
+ function rowsFromTable(domain, table) {
115312
+ const errors = [];
115313
+ const rows = [];
115314
+ let skippedEmpty = 0;
115315
+ const valueCol = VALUE_COLUMN[domain];
115316
+ const header = (table[0] || []).map((h3) => String(h3 ?? "").trim().toLowerCase());
115317
+ const col2 = (name) => header.indexOf(name);
115318
+ const idx = { gw: col2("gateway_id"), slave: col2("slave_id"), date: col2("date"), hour: col2("hour"), value: col2(valueCol), reactive: col2("value_reactive_kvarh") };
115319
+ const missing = ["gateway_id", "slave_id", "date", "hour", valueCol].filter((c) => col2(c) < 0);
115320
+ if (missing.length) {
115321
+ return { rows, errors: [{ line: 1, reason: `Coluna obrigat\xF3ria ausente: ${missing.join(", ")}` }], skippedEmpty };
115322
+ }
115323
+ const seen = /* @__PURE__ */ new Map();
115324
+ for (let i = 1; i < table.length; i++) {
115325
+ const r = table[i] || [];
115326
+ const line = i + 1;
115327
+ if (r.every((c) => String(c ?? "").trim() === "")) continue;
115328
+ const gw = String(r[idx.gw] ?? "").trim();
115329
+ const slave = Number(String(r[idx.slave] ?? "").trim());
115330
+ const date = normalizeDate(r[idx.date]);
115331
+ const hour = normalizeHour(r[idx.hour]);
115332
+ const value = parseDecimal(r[idx.value]);
115333
+ if (value === null) {
115334
+ skippedEmpty++;
115335
+ continue;
115336
+ }
115337
+ const lineErrors = [];
115338
+ if (!UUID_RE.test(gw)) lineErrors.push("gateway_id inv\xE1lido");
115339
+ if (!Number.isInteger(slave) || slave < 1 || slave > 247) lineErrors.push("slave_id deve ser inteiro de 1 a 247");
115340
+ if (!date) lineErrors.push("data inv\xE1lida (use AAAA-MM-DD)");
115341
+ if (!hour) lineErrors.push("hora inv\xE1lida (use HH:00)");
115342
+ if (Number.isNaN(value) || value < 0) lineErrors.push("valor deve ser n\xFAmero \u2265 0");
115343
+ let reactive;
115344
+ if (domain === "energy" && idx.reactive >= 0) {
115345
+ const rv = parseDecimal(r[idx.reactive]);
115346
+ if (Number.isNaN(rv)) lineErrors.push("reativo inv\xE1lido");
115347
+ else if (rv !== null) reactive = rv;
115348
+ }
115349
+ if (lineErrors.length) {
115350
+ errors.push({ line, reason: lineErrors.join("; ") });
115351
+ continue;
115352
+ }
115353
+ const key = `${gw.toLowerCase()}|${slave}|${date}|${hour}`;
115354
+ if (seen.has(key)) {
115355
+ errors.push({ line, reason: `linha duplicada (mesmo device/data/hora da linha ${seen.get(key)})` });
115356
+ continue;
115357
+ }
115358
+ seen.set(key, line);
115359
+ const row = { line, gateway_id: gw, slave_id: slave, date, hour, [valueCol]: value };
115360
+ if (reactive !== void 0) row.value_reactive_kvarh = reactive;
115361
+ rows.push(row);
115362
+ }
115363
+ if (rows.length > MAX_IMPORT_ROWS) {
115364
+ errors.push({ line: 1, reason: `M\xE1ximo de ${MAX_IMPORT_ROWS} linhas por importa\xE7\xE3o (${rows.length} enviadas)` });
115365
+ }
115366
+ return { rows, errors, skippedEmpty };
115367
+ }
115368
+ var SHEETJS_URL = "https://cdn.jsdelivr.net/npm/xlsx@0.18.5/dist/xlsx.full.min.js";
115369
+ async function loadSheetJs() {
115370
+ const w = window;
115371
+ if (w.XLSX) return w.XLSX;
115372
+ await new Promise((resolve, reject) => {
115373
+ const s = document.createElement("script");
115374
+ s.src = SHEETJS_URL;
115375
+ s.onload = () => resolve();
115376
+ s.onerror = () => reject(new Error("N\xE3o foi poss\xEDvel carregar o leitor de Excel"));
115377
+ document.head.appendChild(s);
115378
+ });
115379
+ return w.XLSX;
115380
+ }
115381
+ function readFile(file, as) {
115382
+ return new Promise((resolve, reject) => {
115383
+ const fr = new FileReader();
115384
+ fr.onload = () => resolve(fr.result);
115385
+ fr.onerror = () => reject(new Error("N\xE3o foi poss\xEDvel ler o arquivo"));
115386
+ if (as === "text") fr.readAsText(file, "utf-8");
115387
+ else fr.readAsArrayBuffer(file);
115388
+ });
115389
+ }
115390
+ async function parseSheetFile(file) {
115391
+ const name = String(file?.name || "").toLowerCase();
115392
+ if (name.endsWith(".csv") || name.endsWith(".txt")) return parseCsv(await readFile(file, "text"));
115393
+ if (name.endsWith(".xlsx") || name.endsWith(".xls")) {
115394
+ const XLSX = await loadSheetJs();
115395
+ const wb = XLSX.read(await readFile(file, "buffer"), { type: "array" });
115396
+ const ws = wb.Sheets[wb.SheetNames[0]];
115397
+ return XLSX.utils.sheet_to_json(ws, { header: 1, raw: true, defval: "" });
115398
+ }
115399
+ throw new Error("Formato n\xE3o suportado \u2014 envie .xlsx ou .csv");
115400
+ }
115401
+
115402
+ // src/components/premium-modals/telemetry-import/importApi.ts
115403
+ var TERMINAL_JOB_STATUSES = ["completed", "failed", "cancelled", "reverted"];
115404
+ var ImportApiError = class extends Error {
115405
+ constructor(message, status, detail) {
115406
+ super(message);
115407
+ this.status = status;
115408
+ this.detail = detail;
115409
+ this.name = "ImportApiError";
115410
+ }
115411
+ };
115412
+ function createTelemetryImportApi(cfg) {
115413
+ const base = String(cfg.baseUrl || "").replace(/\/+$/, "");
115414
+ const doFetch = cfg.fetchImpl ?? fetch.bind(window);
115415
+ const call = async (method, path, body, accept422 = false) => {
115416
+ const token = await cfg.getToken();
115417
+ const res = await doFetch(`${base}/import${path}`, {
115418
+ method,
115419
+ headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
115420
+ body: body === void 0 ? void 0 : JSON.stringify(body)
115421
+ });
115422
+ const text2 = await res.text().catch(() => "");
115423
+ let data = null;
115424
+ try {
115425
+ data = text2 ? JSON.parse(text2) : null;
115426
+ } catch {
115427
+ data = null;
115428
+ }
115429
+ if (res.ok || accept422 && res.status === 422) return { status: res.status, data: data?.data ?? data };
115430
+ const apiMsg = data?.message || data?.error || "";
115431
+ const msg = res.status === 404 ? "A importa\xE7\xE3o ainda n\xE3o est\xE1 dispon\xEDvel neste ambiente." : res.status === 401 || res.status === 403 ? "Sem permiss\xE3o para importar telemetria (credencial sem o escopo telemetry.import)." : res.status === 409 ? apiMsg || "Opera\xE7\xE3o n\xE3o permitida no estado atual da importa\xE7\xE3o." : `Falha na API de importa\xE7\xE3o (${res.status}).`;
115432
+ throw new ImportApiError(msg, res.status, `${method} /import${path} \u2192 ${res.status} ${String(apiMsg || text2).slice(0, 200)}`);
115433
+ };
115434
+ return {
115435
+ async validate(body) {
115436
+ const { status, data } = await call("POST", "/validate", body, true);
115437
+ if (status === 422 || data?.valid === false) {
115438
+ return { valid: false, invalidCount: Number(data?.invalidCount ?? data?.errors?.length ?? 0), errors: data?.errors || [] };
115439
+ }
115440
+ return { valid: true, validationId: data.validationId, expiresAt: data.expiresAt, preview: data.preview || {} };
115441
+ },
115442
+ async startJob(body) {
115443
+ const { data } = await call("POST", "/jobs", body);
115444
+ return { jobId: data.jobId, status: data.status || "queued" };
115445
+ },
115446
+ async getJob(jobId) {
115447
+ const { data } = await call("GET", `/jobs/${encodeURIComponent(jobId)}`);
115448
+ return { jobId, ...data || {} };
115449
+ },
115450
+ async cancelJob(jobId) {
115451
+ const { data } = await call("POST", `/jobs/${encodeURIComponent(jobId)}/cancel`);
115452
+ return data ? { jobId, ...data } : null;
115453
+ }
115454
+ };
115455
+ }
115456
+
115457
+ // src/components/premium-modals/telemetry-import/openTelemetryImportModal.ts
115458
+ var STEPS2 = [
115459
+ { n: 1, label: "Modelo" },
115460
+ { n: 2, label: "Planilha" },
115461
+ { n: 3, label: "Valida\xE7\xE3o" },
115462
+ { n: 4, label: "Importa\xE7\xE3o" }
115463
+ ];
115464
+ var DOMAIN_TEXT = {
115465
+ energy: { noun: "energia", unit: "kWh", icon: "\u26A1" },
115466
+ water: { noun: "\xE1gua", unit: "m\xB3", icon: "\u{1F4A7}" }
115467
+ };
115468
+ var JOB_STATUS_TEXT = {
115469
+ queued: "Na fila",
115470
+ executing: "Importando",
115471
+ completed: "Conclu\xEDda",
115472
+ failed: "Falhou",
115473
+ cancelled: "Cancelada",
115474
+ reverted: "Revertida"
115475
+ };
115476
+ var STYLE_ID14 = "myio-tlmimport-styles";
115477
+ function esc9(v) {
115478
+ return String(v ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
115479
+ }
115480
+ var fmtNum = (n, d = 0) => Number.isFinite(Number(n)) ? Number(n).toLocaleString("pt-BR", { minimumFractionDigits: d, maximumFractionDigits: d }) : "\u2014";
115481
+ function injectStyles14() {
115482
+ if (document.getElementById(STYLE_ID14)) return;
115483
+ const style = document.createElement("style");
115484
+ style.id = STYLE_ID14;
115485
+ style.textContent = `
115486
+ .tlmi { --tlmi-ac: #3e1a7d; --tlmi-ac-soft: #f1ecfa; --tlmi-ok: #16a34a; --tlmi-warn: #d97706; --tlmi-err: #dc2626;
115487
+ display: flex; flex-direction: column; gap: 12px; font-size: 14px; color: #1e293b; }
115488
+ .tlmi-stepper { display: flex; gap: 6px; }
115489
+ .tlmi-step { flex: 1; display: flex; align-items: center; gap: 8px; color: #64748b; padding: 6px 8px; border-radius: 10px; font-size: 13px; }
115490
+ .tlmi-step b { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
115491
+ border: 2px solid #e2e8f0; font-size: 12px; flex-shrink: 0; }
115492
+ .tlmi-step[data-state="current"] { color: var(--tlmi-ac); font-weight: 800; background: var(--tlmi-ac-soft); }
115493
+ .tlmi-step[data-state="current"] b { border-color: var(--tlmi-ac); background: var(--tlmi-ac); color: #fff; }
115494
+ .tlmi-step[data-state="done"] { color: #1e293b; }
115495
+ .tlmi-step[data-state="done"] b { border-color: var(--tlmi-ok); background: var(--tlmi-ok); color: #fff; }
115496
+ .tlmi-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 14px 16px; }
115497
+ .tlmi-card h3 { margin: 0 0 10px !important; font-size: 14px !important; font-weight: 700 !important; line-height: 1.4 !important; }
115498
+ .tlmi-muted { color: #64748b; font-size: 13px; margin: 0; line-height: 1.5; }
115499
+ .tlmi-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
115500
+ .tlmi-field { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 12px; color: #64748b; }
115501
+ .tlmi-field input { border: 1px solid #ddd; border-radius: 6px; padding: 8px 10px; font: inherit; color: #1e293b; }
115502
+ .tlmi-btn { font: inherit; font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: 6px; border: 1px solid #d1d5db;
115503
+ background: #fff; color: #374151; cursor: pointer; }
115504
+ .tlmi-btn.primary { background: var(--tlmi-ac); border-color: var(--tlmi-ac); color: #fff; }
115505
+ .tlmi-btn:disabled { opacity: 0.55; cursor: not-allowed; }
115506
+ .tlmi-drop { border: 2px dashed #cbd5e1; border-radius: 12px; padding: 22px; text-align: center; color: #64748b; cursor: pointer; }
115507
+ .tlmi-drop[data-over="1"] { border-color: var(--tlmi-ac); background: var(--tlmi-ac-soft); }
115508
+ .tlmi-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
115509
+ .tlmi-kpi { border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px 12px; }
115510
+ .tlmi-kpi span { display: block; font-size: 11.5px; color: #64748b; }
115511
+ .tlmi-kpi strong { font-size: 18px; }
115512
+ .tlmi-banner { padding: 9px 12px; border-radius: 10px; font-size: 13px; line-height: 1.5; }
115513
+ .tlmi-banner.warn { background: #fef3c7; border: 1px solid #fcd34d; color: #78350f; }
115514
+ .tlmi-banner.err { background: #fee2e2; border: 1px solid #fca5a5; color: #7f1d1d; }
115515
+ .tlmi-banner.ok { background: #dcfce7; border: 1px solid #86efac; color: #14532d; }
115516
+ .tlmi-errors { max-height: 220px; overflow: auto; border: 1px solid #fecaca; border-radius: 8px; }
115517
+ .tlmi-errors table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
115518
+ .tlmi-errors th, .tlmi-errors td { padding: 5px 8px; border-bottom: 1px solid #fee2e2; text-align: left; }
115519
+ .tlmi-errors th { background: #fef2f2; position: sticky; top: 0; }
115520
+ .tlmi-progress { height: 10px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
115521
+ .tlmi-progress > i { display: block; height: 100%; background: var(--tlmi-ac); transition: width 0.4s; }
115522
+ .tlmi-check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }
115523
+ .tlmi-tech { font-size: 11.5px; color: #6b7280; word-break: break-word; }
115524
+ `;
115525
+ document.head.appendChild(style);
115526
+ }
115527
+ function issuesTable(errors, limit = 100) {
115528
+ const rows = errors.slice(0, limit).map((e) => `<tr><td>${esc9(e.line)}</td><td>${esc9(e.reason)}</td></tr>`).join("");
115529
+ const more = errors.length > limit ? `<p class="tlmi-muted">\u2026 e mais ${errors.length - limit} erro(s).</p>` : "";
115530
+ return `<div class="tlmi-errors"><table><thead><tr><th>Linha</th><th>Problema</th></tr></thead><tbody>${rows}</tbody></table></div>${more}`;
115531
+ }
115532
+ function defaultPeriod(now) {
115533
+ const sp = new Date(now - 3 * 3600 * 1e3);
115534
+ const ymd = (d) => d.toISOString().slice(0, 10);
115535
+ const end = new Date(Date.UTC(sp.getUTCFullYear(), sp.getUTCMonth(), sp.getUTCDate() - 1));
115536
+ const start = new Date(end.getTime() - 6 * 864e5);
115537
+ return { start: ymd(start), end: ymd(end) };
115538
+ }
115539
+ function openTelemetryImportModal(params) {
115540
+ injectStyles14();
115541
+ const domain = params.domain;
115542
+ const txt = DOMAIN_TEXT[domain];
115543
+ const now = params.now ?? (() => Date.now());
115544
+ const api = "validate" in params.api ? params.api : createTelemetryImportApi(params.api);
115545
+ const { ok: importable, missingKey } = splitImportableDevices(params.devices);
115546
+ const s = {
115547
+ step: 1,
115548
+ period: defaultPeriod(now()),
115549
+ fileName: "",
115550
+ rows: [],
115551
+ localErrors: [],
115552
+ skippedEmpty: 0,
115553
+ parseError: "",
115554
+ busy: false,
115555
+ validation: null,
115556
+ apiError: "",
115557
+ apiDetail: "",
115558
+ confirmReal: false,
115559
+ job: null
115560
+ };
115561
+ let pollTimer = null;
115562
+ let closed = false;
115563
+ const modal = openStandardModal({
115564
+ icon: "\u{1F4E5}",
115565
+ title: `Importar dados de ${txt.noun}`,
115566
+ width: 760,
115567
+ bodyHtml: '<div class="tlmi"></div>',
115568
+ container: params.container,
115569
+ buttons: [
115570
+ { label: "Voltar", value: "back", variant: "secondary", closeOnClick: false },
115571
+ { label: "Fechar", value: "close", variant: "secondary" },
115572
+ { label: "Avan\xE7ar", value: "next", variant: "primary", closeOnClick: false }
115573
+ ],
115574
+ onButton: (v) => {
115575
+ if (v === "back") goBack();
115576
+ if (v === "next") void goNext();
115577
+ },
115578
+ onClose: () => {
115579
+ closed = true;
115580
+ if (pollTimer) clearTimeout(pollTimer);
115581
+ }
115582
+ });
115583
+ const root = modal.getBodyEl().querySelector(".tlmi");
115584
+ const setError = (err) => {
115585
+ s.apiError = err instanceof ImportApiError ? err.message : err?.message || "Erro inesperado.";
115586
+ s.apiDetail = params.showTechnicalDetails ? err instanceof ImportApiError ? err.detail || "" : String(err) : "";
115587
+ };
115588
+ function stepper() {
115589
+ return `<div class="tlmi-stepper">${STEPS2.map((st) => {
115590
+ const state6 = st.n === s.step ? "current" : st.n < s.step ? "done" : "todo";
115591
+ return `<div class="tlmi-step" data-state="${state6}"><b>${state6 === "done" ? "\u2713" : st.n}</b>${st.label}</div>`;
115592
+ }).join("")}</div>`;
115593
+ }
115594
+ function apiErrorBanner() {
115595
+ if (!s.apiError) return "";
115596
+ return `<div class="tlmi-banner err" role="alert">${esc9(s.apiError)}${s.apiDetail ? `<div class="tlmi-tech">${esc9(s.apiDetail)}</div>` : ""}</div>`;
115597
+ }
115598
+ function step1() {
115599
+ const warn = missingKey.length ? `<div class="tlmi-banner warn">${missingKey.length} dispositivo(s) sem central/endere\xE7o cadastrados ficam fora do modelo: ${esc9(
115600
+ missingKey.slice(0, 5).map((d) => d.label).join(", ")
115601
+ )}${missingKey.length > 5 ? "\u2026" : ""}</div>` : "";
115602
+ return `
115603
+ <div class="tlmi-card"><h3>Como funciona</h3>
115604
+ <p class="tlmi-muted">1) Baixe o modelo com os dispositivos desta lista, uma linha por hora. 2) Preencha a coluna
115605
+ <strong>${VALUE_COLUMN[domain]}</strong> (${txt.unit}); apague ou deixe em branco as horas que n\xE3o quer alterar.
115606
+ 3) Envie a planilha: ela \xE9 validada por inteiro \u2014 qualquer linha inv\xE1lida cancela a importa\xE7\xE3o.
115607
+ Os valores importados <strong>substituem</strong> as leituras existentes nas horas enviadas.</p>
115608
+ </div>
115609
+ ${warn}
115610
+ <div class="tlmi-card"><h3>Modelo da planilha</h3>
115611
+ <div class="tlmi-row">
115612
+ <label class="tlmi-field">In\xEDcio<input type="date" data-field="start" value="${esc9(s.period.start)}" /></label>
115613
+ <label class="tlmi-field">Fim<input type="date" data-field="end" value="${esc9(s.period.end)}" /></label>
115614
+ <button class="tlmi-btn" type="button" data-action="template" ${importable.length ? "" : "disabled"}>\u2B07 Baixar modelo (CSV)</button>
115615
+ </div>
115616
+ <p class="tlmi-muted" style="margin-top:8px">${importable.length} dispositivo(s) no modelo. J\xE1 tem a planilha preenchida? Clique em <strong>Avan\xE7ar</strong>.</p>
115617
+ </div>`;
115618
+ }
115619
+ function step2() {
115620
+ const summary = s.fileName ? s.parseError ? `<div class="tlmi-banner err">${esc9(s.parseError)}</div>` : `<div class="tlmi-kpis">
115621
+ <div class="tlmi-kpi"><span>Arquivo</span><strong style="font-size:13px">${esc9(s.fileName)}</strong></div>
115622
+ <div class="tlmi-kpi"><span>Linhas para importar</span><strong>${fmtNum(s.rows.length)}</strong></div>
115623
+ <div class="tlmi-kpi"><span>Em branco (ignoradas)</span><strong>${fmtNum(s.skippedEmpty)}</strong></div>
115624
+ <div class="tlmi-kpi"><span>Com erro</span><strong style="color:${s.localErrors.length ? "#dc2626" : "#16a34a"}">${fmtNum(s.localErrors.length)}</strong></div>
115625
+ </div>
115626
+ ${s.localErrors.length ? `<div class="tlmi-banner err">Corrija as linhas abaixo e envie de novo \u2014 nada foi importado.</div>${issuesTable(s.localErrors)}` : ""}
115627
+ ${!s.localErrors.length && !s.rows.length ? '<div class="tlmi-banner warn">Nenhuma linha com valor preenchido.</div>' : ""}` : "";
115628
+ return `
115629
+ <div class="tlmi-card"><h3>Planilha preenchida</h3>
115630
+ <label class="tlmi-drop" data-role="drop">
115631
+ <input type="file" accept=".xlsx,.xls,.csv" data-field="file" hidden />
115632
+ \u{1F4C4} Clique ou arraste a planilha aqui (.xlsx ou .csv)
115633
+ </label>
115634
+ </div>
115635
+ ${summary}`;
115636
+ }
115637
+ function step3() {
115638
+ const v = s.validation;
115639
+ if (!v) return `${apiErrorBanner()}<div class="tlmi-card"><p class="tlmi-muted">${s.busy ? "Validando\u2026" : "Aguardando valida\xE7\xE3o."}</p></div>`;
115640
+ if (v.valid === false) {
115641
+ return `<div class="tlmi-banner err">A planilha foi recusada: ${fmtNum(v.invalidCount)} linha(s) inv\xE1lida(s). Nada foi importado.</div>
115642
+ ${issuesTable(v.errors)}`;
115643
+ }
115644
+ const p = v.preview || {};
115645
+ const real = Number(p.existingRealReadings || 0);
115646
+ const period = typeof p.period === "string" ? p.period : p.period ? `${p.period.start || ""} \u2192 ${p.period.end || ""}` : "\u2014";
115647
+ const devices = Array.isArray(p.devices) ? p.devices.length : p.devices;
115648
+ return `
115649
+ <div class="tlmi-banner ok">Planilha v\xE1lida. Confira o resumo antes de importar.</div>
115650
+ <div class="tlmi-kpis">
115651
+ <div class="tlmi-kpi"><span>Horas a gravar</span><strong>${fmtNum(p.targetSlots)}</strong></div>
115652
+ <div class="tlmi-kpi"><span>Dispositivos</span><strong>${fmtNum(devices)}</strong></div>
115653
+ <div class="tlmi-kpi"><span>Total (${txt.unit})</span><strong>${fmtNum(p.totalValue, 2)}</strong></div>
115654
+ <div class="tlmi-kpi"><span>Leituras substitu\xEDdas</span><strong>${fmtNum(p.existingReadingsInTarget)}</strong></div>
115655
+ </div>
115656
+ <p class="tlmi-muted">Per\xEDodo: ${esc9(period)}</p>
115657
+ ${real > 0 ? `<div class="tlmi-banner warn"><strong>${fmtNum(real)} leitura(s) reais do medidor</strong> ser\xE3o substitu\xEDdas pelos valores da planilha.
115658
+ <label class="tlmi-check" style="margin-top:6px"><input type="checkbox" data-field="confirmReal" ${s.confirmReal ? "checked" : ""} />
115659
+ Confirmo a substitui\xE7\xE3o das leituras reais.</label></div>` : ""}
115660
+ ${apiErrorBanner()}`;
115661
+ }
115662
+ function step4() {
115663
+ const j = s.job;
115664
+ if (!j) return `${apiErrorBanner()}<div class="tlmi-card"><p class="tlmi-muted">Iniciando importa\xE7\xE3o\u2026</p></div>`;
115665
+ const pct = Math.max(0, Math.min(100, Number(j.progress ?? (j.status === "completed" ? 100 : 0))));
115666
+ const statusText = JOB_STATUS_TEXT[j.status] || j.status;
115667
+ const terminal = TERMINAL_JOB_STATUSES.includes(j.status);
115668
+ let banner = "";
115669
+ if (j.status === "completed") {
115670
+ banner = j.refreshStatus === "failed" ? '<div class="tlmi-banner warn">Dados importados, mas a atualiza\xE7\xE3o dos totais falhou. Avise o suporte MyIO.</div>' : '<div class="tlmi-banner ok">Importa\xE7\xE3o conclu\xEDda. Os totais podem levar alguns minutos para refletir.</div>';
115671
+ } else if (j.status === "failed") {
115672
+ banner = `<div class="tlmi-banner err">A importa\xE7\xE3o falhou${j.error ? `: ${esc9(j.error)}` : "."}</div>`;
115673
+ } else if (j.status === "cancelled") {
115674
+ banner = '<div class="tlmi-banner warn">Importa\xE7\xE3o cancelada. As leituras anteriores foram mantidas.</div>';
115675
+ }
115676
+ return `
115677
+ <div class="tlmi-card"><h3>Importa\xE7\xE3o <span style="font-weight:600;color:#64748b">${esc9(statusText)}</span></h3>
115678
+ <div class="tlmi-progress" role="progressbar" aria-valuenow="${pct}" aria-valuemin="0" aria-valuemax="100"><i style="width:${pct}%"></i></div>
115679
+ <div class="tlmi-kpis" style="margin-top:12px">
115680
+ <div class="tlmi-kpi"><span>Progresso</span><strong>${fmtNum(pct)}%</strong></div>
115681
+ <div class="tlmi-kpi"><span>Leituras removidas</span><strong>${fmtNum(j.deleted)}</strong></div>
115682
+ <div class="tlmi-kpi"><span>Leituras gravadas</span><strong>${fmtNum(j.inserted)}</strong></div>
115683
+ </div>
115684
+ ${j.phase && !terminal ? `<p class="tlmi-muted" style="margin-top:8px">Etapa: ${esc9(j.phase)}</p>` : ""}
115685
+ ${!terminal ? `<div style="margin-top:12px"><button class="tlmi-btn" type="button" data-action="cancel" ${s.busy ? "disabled" : ""}>Cancelar importa\xE7\xE3o</button>
115686
+ <span class="tlmi-muted" style="margin-left:8px">Voc\xEA pode fechar esta janela; a importa\xE7\xE3o continua.</span></div>` : ""}
115687
+ </div>
115688
+ ${banner}
115689
+ ${apiErrorBanner()}`;
115690
+ }
115691
+ function render3() {
115692
+ if (closed) return;
115693
+ const body = s.step === 1 ? step1() : s.step === 2 ? step2() : s.step === 3 ? step3() : step4();
115694
+ root.innerHTML = stepper() + body;
115695
+ syncFooter();
115696
+ }
115697
+ function syncFooter() {
115698
+ const v = s.validation;
115699
+ const terminal = s.job ? TERMINAL_JOB_STATUSES.includes(s.job.status) : false;
115700
+ modal.setButton("back", { hidden: s.step === 1 || s.step === 4, disabled: s.busy });
115701
+ if (s.step === 1) modal.setButton("next", { label: "Avan\xE7ar", disabled: false, hidden: false });
115702
+ if (s.step === 2)
115703
+ modal.setButton("next", { label: "Validar planilha", disabled: s.busy || !s.rows.length || !!s.localErrors.length || !!s.parseError, hidden: false });
115704
+ if (s.step === 3) {
115705
+ const real = v && v.valid ? Number(v.preview?.existingRealReadings || 0) : 0;
115706
+ modal.setButton("next", {
115707
+ label: s.busy ? "Iniciando\u2026" : "Importar",
115708
+ hidden: !v || !v.valid,
115709
+ disabled: s.busy || real > 0 && !s.confirmReal
115710
+ });
115711
+ }
115712
+ if (s.step === 4) modal.setButton("next", { label: "Concluir", hidden: !terminal, disabled: false });
115713
+ }
115714
+ function goBack() {
115715
+ if (s.busy || s.step === 1 || s.step === 4) return;
115716
+ s.apiError = "";
115717
+ if (s.step === 3) s.validation = null;
115718
+ s.step = s.step - 1;
115719
+ render3();
115720
+ }
115721
+ async function goNext() {
115722
+ if (s.busy) return;
115723
+ if (s.step === 1) {
115724
+ s.step = 2;
115725
+ render3();
115726
+ } else if (s.step === 2) {
115727
+ await validate2();
115728
+ } else if (s.step === 3) {
115729
+ await start();
115730
+ } else if (s.step === 4) {
115731
+ if (s.job?.status === "completed") params.onCompleted?.(s.job);
115732
+ modal.close();
115733
+ }
115734
+ }
115735
+ function downloadTemplate() {
115736
+ const { csv, rows } = buildTemplateCsv(domain, importable, s.period.start, s.period.end, now());
115737
+ if (!rows) return;
115738
+ const blob = new Blob([csv], { type: "text/csv;charset=utf-8" });
115739
+ const a = document.createElement("a");
115740
+ a.href = URL.createObjectURL(blob);
115741
+ const who = (params.customerName || "shopping").replace(/[^\w-]+/g, "_");
115742
+ a.download = `importacao-${domain === "energy" ? "energia" : "agua"}-${who}-${s.period.start}_${s.period.end}.csv`;
115743
+ document.body.appendChild(a);
115744
+ a.click();
115745
+ a.remove();
115746
+ setTimeout(() => URL.revokeObjectURL(a.href), 1e3);
115747
+ }
115748
+ async function loadFile(file) {
115749
+ if (!file) return;
115750
+ s.fileName = file.name;
115751
+ s.parseError = "";
115752
+ s.rows = [];
115753
+ s.localErrors = [];
115754
+ s.skippedEmpty = 0;
115755
+ s.validation = null;
115756
+ try {
115757
+ const table = await parseSheetFile(file);
115758
+ const r = rowsFromTable(domain, table);
115759
+ s.rows = r.rows;
115760
+ s.localErrors = r.errors;
115761
+ s.skippedEmpty = r.skippedEmpty;
115762
+ } catch (err) {
115763
+ s.parseError = err?.message || "N\xE3o foi poss\xEDvel ler a planilha.";
115764
+ }
115765
+ render3();
115766
+ }
115767
+ async function validate2() {
115768
+ s.busy = true;
115769
+ s.apiError = "";
115770
+ s.validation = null;
115771
+ s.step = 3;
115772
+ render3();
115773
+ try {
115774
+ s.validation = await api.validate({ customerId: params.customerId, readingType: domain, rows: s.rows, sourceRef: s.fileName });
115775
+ } catch (err) {
115776
+ setError(err);
115777
+ } finally {
115778
+ s.busy = false;
115779
+ render3();
115780
+ }
115781
+ }
115782
+ async function start() {
115783
+ const v = s.validation;
115784
+ if (!v || !v.valid) return;
115785
+ s.busy = true;
115786
+ s.apiError = "";
115787
+ render3();
115788
+ try {
115789
+ const started = await api.startJob({ validationId: v.validationId, confirmReplaceReal: s.confirmReal || void 0 });
115790
+ s.job = { jobId: started.jobId, status: started.status };
115791
+ s.step = 4;
115792
+ s.busy = false;
115793
+ render3();
115794
+ schedulePoll(0);
115795
+ } catch (err) {
115796
+ setError(err);
115797
+ s.busy = false;
115798
+ render3();
115799
+ }
115800
+ }
115801
+ function schedulePoll(delay = params.pollMs ?? 5e3) {
115802
+ if (closed || !s.job?.jobId) return;
115803
+ pollTimer = setTimeout(async () => {
115804
+ if (closed || !s.job?.jobId) return;
115805
+ try {
115806
+ s.job = { ...await api.getJob(s.job.jobId), jobId: s.job.jobId };
115807
+ s.apiError = "";
115808
+ } catch (err) {
115809
+ setError(err);
115810
+ }
115811
+ render3();
115812
+ if (s.job && !TERMINAL_JOB_STATUSES.includes(s.job.status)) schedulePoll();
115813
+ }, delay);
115814
+ }
115815
+ async function cancelJob() {
115816
+ if (!s.job?.jobId || s.busy) return;
115817
+ s.busy = true;
115818
+ render3();
115819
+ try {
115820
+ const j = await api.cancelJob(s.job.jobId);
115821
+ if (j?.status) s.job = { ...s.job, ...j };
115822
+ } catch (err) {
115823
+ setError(err);
115824
+ } finally {
115825
+ s.busy = false;
115826
+ render3();
115827
+ }
115828
+ }
115829
+ root.addEventListener("click", (e) => {
115830
+ const el2 = e.target.closest("[data-action]");
115831
+ if (!el2) return;
115832
+ if (el2.dataset.action === "template") downloadTemplate();
115833
+ if (el2.dataset.action === "cancel") void cancelJob();
115834
+ });
115835
+ root.addEventListener("change", (e) => {
115836
+ const t = e.target;
115837
+ if (t.dataset.field === "start") s.period.start = t.value;
115838
+ if (t.dataset.field === "end") s.period.end = t.value;
115839
+ if (t.dataset.field === "file") void loadFile(t.files?.[0]);
115840
+ if (t.dataset.field === "confirmReal") {
115841
+ s.confirmReal = t.checked;
115842
+ syncFooter();
115843
+ }
115844
+ });
115845
+ root.addEventListener("dragover", (e) => {
115846
+ const drop = e.target.closest('[data-role="drop"]');
115847
+ if (!drop) return;
115848
+ e.preventDefault();
115849
+ drop.dataset.over = "1";
115850
+ });
115851
+ root.addEventListener("dragleave", (e) => {
115852
+ const drop = e.target.closest('[data-role="drop"]');
115853
+ if (drop) drop.dataset.over = "";
115854
+ });
115855
+ root.addEventListener("drop", (e) => {
115856
+ const drop = e.target.closest('[data-role="drop"]');
115857
+ if (!drop) return;
115858
+ e.preventDefault();
115859
+ void loadFile(e.dataTransfer?.files?.[0]);
115860
+ });
115861
+ render3();
115862
+ return modal;
115863
+ }
115864
+
115865
+ // src/components/premium-modals/manual-device/createManualDevice.ts
115866
+ var MANUAL_DEVICE_PROFILES = {
115867
+ energy: "3F_MEDIDOR_MANUAL",
115868
+ water: "HIDROMETRO_MANUAL"
115869
+ };
115870
+ var NAME_PREFIX = {
115871
+ energy: "3F ",
115872
+ water: "Hidr. "
115873
+ };
115874
+ var MANUAL_ASSET_SUFFIX = "_DEVICES_MANUAIS";
115875
+ var ManualDeviceError = class extends Error {
115876
+ constructor(message, detail) {
115877
+ super(message);
115878
+ this.detail = detail;
115879
+ this.name = "ManualDeviceError";
115880
+ }
115881
+ };
115882
+ function manualDeviceName(domain, sigla, seq) {
115883
+ return `${NAME_PREFIX[domain]}${sigla}_LOJA_${String(seq).padStart(3, "0")}_MANUAL`;
115884
+ }
115885
+ function siglaFromManualAsset(assetName) {
115886
+ const upper = String(assetName || "").trim().toUpperCase();
115887
+ if (!upper.endsWith(MANUAL_ASSET_SUFFIX)) return null;
115888
+ const sigla = upper.slice(0, -MANUAL_ASSET_SUFFIX.length).replace(/^ASSET_/, "");
115889
+ return /^[A-Z0-9_]+$/.test(sigla) ? sigla : null;
115890
+ }
115891
+ function nextManualSeq(domain, sigla, existingNames) {
115892
+ const esc10 = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
115893
+ const re = new RegExp(`^${esc10(NAME_PREFIX[domain])}${esc10(sigla)}_LOJA_(\\d+)_MANUAL$`, "i");
115894
+ const max = existingNames.reduce((acc, n) => {
115895
+ const m = re.exec(String(n || "").trim());
115896
+ return m ? Math.max(acc, Number(m[1])) : acc;
115897
+ }, 0);
115898
+ return max + 1;
115899
+ }
115900
+ async function createManualDevice(params) {
115901
+ const domain = params.domain;
115902
+ const profile = MANUAL_DEVICE_PROFILES[domain];
115903
+ if (!profile) throw new ManualDeviceError(`Dom\xEDnio inv\xE1lido: ${domain}`);
115904
+ const label = String(params.label || "").trim();
115905
+ const identifier = String(params.identifier || "").trim();
115906
+ if (!label) throw new ManualDeviceError("Informe a etiqueta.");
115907
+ if (!identifier) throw new ManualDeviceError("Informe o identificador.");
115908
+ if (!params.customerId) throw new ManualDeviceError("Cliente n\xE3o identificado.");
115909
+ const base = params.baseUrl ?? "";
115910
+ const doFetch = params.fetchImpl ?? fetch.bind(window);
115911
+ const tokenValue = typeof params.token === "function" ? await params.token() : params.token;
115912
+ const headers = { "X-Authorization": `Bearer ${tokenValue}`, "Content-Type": "application/json" };
115913
+ const api = async (method, path, body, okStatuses = []) => {
115914
+ const res = await doFetch(`${base}${path}`, {
115915
+ method,
115916
+ headers,
115917
+ body: body === void 0 ? void 0 : JSON.stringify(body)
115918
+ });
115919
+ if (!res.ok && !okStatuses.includes(res.status)) {
115920
+ const text3 = await res.text().catch(() => "");
115921
+ throw new ManualDeviceError(`Falha na API (${res.status}).`, `${method} ${path} \u2192 ${res.status} ${text3.slice(0, 200)}`);
115922
+ }
115923
+ const text2 = await res.text().catch(() => "");
115924
+ return text2 ? JSON.parse(text2) : null;
115925
+ };
115926
+ const cid = encodeURIComponent(params.customerId);
115927
+ const assets = await api("GET", `/api/customer/${cid}/assets?pageSize=100&page=0&textSearch=MANUAIS`);
115928
+ const asset = (assets?.data || []).find(
115929
+ (a) => String(a?.name || "").toUpperCase().endsWith(MANUAL_ASSET_SUFFIX)
115930
+ );
115931
+ if (!asset) {
115932
+ throw new ManualDeviceError(
115933
+ "Local de dispositivos manuais n\xE3o configurado para este shopping.",
115934
+ `nenhum asset do customer termina em ${MANUAL_ASSET_SUFFIX}`
115935
+ );
115936
+ }
115937
+ const sigla = siglaFromManualAsset(asset.name);
115938
+ if (!sigla) {
115939
+ throw new ManualDeviceError(
115940
+ "Local de dispositivos manuais n\xE3o configurado para este shopping.",
115941
+ `n\xE3o foi poss\xEDvel extrair a sigla de "${asset.name}"`
115942
+ );
115943
+ }
115944
+ const existing = await api(
115945
+ "GET",
115946
+ `/api/customer/${cid}/devices?pageSize=1000&page=0&textSearch=${encodeURIComponent(`${sigla}_LOJA_`)}`
115947
+ );
115948
+ const existingNames = (existing?.data || []).map((d) => String(d?.name || ""));
115949
+ let seq = nextManualSeq(domain, sigla, existingNames);
115950
+ let deviceProfileId;
115951
+ try {
115952
+ const profiles = await api("GET", `/api/deviceProfileInfos?pageSize=50&page=0&textSearch=${encodeURIComponent(profile)}`);
115953
+ const p = (profiles?.data || []).find((x) => x?.name === profile);
115954
+ if (p?.id?.id) deviceProfileId = { id: p.id.id, entityType: "DEVICE_PROFILE" };
115955
+ } catch {
115956
+ }
115957
+ let name = manualDeviceName(domain, sigla, seq);
115958
+ let created = null;
115959
+ for (let attempt = 0; ; attempt++) {
115960
+ try {
115961
+ created = await api("POST", "/api/device", {
115962
+ name,
115963
+ label,
115964
+ ...deviceProfileId ? { deviceProfileId } : { type: profile },
115965
+ customerId: { id: params.customerId, entityType: "CUSTOMER" }
115966
+ });
115967
+ break;
115968
+ } catch (err) {
115969
+ const dup = /already exists|já existe/i.test(err?.detail || "");
115970
+ if (!dup || attempt >= 4) throw err;
115971
+ seq += 1;
115972
+ name = manualDeviceName(domain, sigla, seq);
115973
+ }
115974
+ }
115975
+ const deviceId = created?.id?.id;
115976
+ if (!deviceId) throw new ManualDeviceError("O dispositivo n\xE3o foi criado.", "POST /api/device sem id na resposta");
115977
+ try {
115978
+ if (created?.customerId?.id !== params.customerId) {
115979
+ try {
115980
+ await api("POST", `/api/owner/CUSTOMER/${cid}/DEVICE/${deviceId}`);
115981
+ } catch {
115982
+ await api("POST", `/api/customer/${cid}/device/${deviceId}`);
115983
+ }
115984
+ }
115985
+ await api("POST", "/api/relation", {
115986
+ from: { id: asset.id.id, entityType: "ASSET" },
115987
+ to: { id: deviceId, entityType: "DEVICE" },
115988
+ type: "Contains",
115989
+ typeGroup: "COMMON"
115990
+ });
115991
+ await api("POST", `/api/plugins/telemetry/DEVICE/${deviceId}/attributes/SERVER_SCOPE`, {
115992
+ deviceProfile: profile,
115993
+ identifier
115994
+ });
115995
+ } catch (err) {
115996
+ await api("DELETE", `/api/device/${deviceId}`).catch(() => void 0);
115997
+ throw err;
115998
+ }
115999
+ return { deviceId, name, label, identifier, deviceProfile: profile, assetId: asset.id.id, assetName: asset.name };
116000
+ }
116001
+
116002
+ // src/components/premium-modals/manual-device/openManualDeviceModal.ts
116003
+ var DOMAIN_TEXT2 = {
116004
+ energy: { title: "Novo medidor de energia manual", icon: "\u26A1", noun: "Medidor de energia" },
116005
+ water: { title: "Novo hidr\xF4metro manual", icon: "\u{1F4A7}", noun: "Hidr\xF4metro" }
116006
+ };
116007
+ var STYLE_ID15 = "myio-manualdev-styles";
116008
+ function escapeHtml14(v) {
116009
+ return String(v ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
116010
+ }
116011
+ function injectStyles15() {
116012
+ if (document.getElementById(STYLE_ID15)) return;
116013
+ const style = document.createElement("style");
116014
+ style.id = STYLE_ID15;
116015
+ style.textContent = `
116016
+ .myio-manualdev { display: flex; flex-direction: column; gap: 16px; }
116017
+ .myio-manualdev__hint { margin: 0; font-size: 13px; color: #6b7280; line-height: 1.5; }
116018
+ .myio-manualdev__field { display: flex; flex-direction: column; gap: 6px; }
116019
+ .myio-manualdev__label { font-size: 14px; font-weight: 500; color: #333; }
116020
+ .myio-manualdev__input {
116021
+ font-family: inherit; font-size: 14px; padding: 10px 12px; border: 1px solid #ddd;
116022
+ border-radius: 6px; outline: none; color: #111827; background: #fff; box-sizing: border-box; width: 100%;
116023
+ }
116024
+ .myio-manualdev__input:focus { border-color: var(--myio-brand-700, #3e1a7d); box-shadow: 0 0 0 3px rgba(62, 26, 125, 0.12); }
116025
+ .myio-manualdev__input[aria-invalid="true"] { border-color: #dc3545; }
116026
+ .myio-manualdev__input:disabled { background: #f8f9fa; color: #6c757d; }
116027
+ .myio-manualdev__type {
116028
+ display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
116029
+ font-size: 12px; font-weight: 600; color: #3e1a7d; background: #f1ecfa;
116030
+ padding: 4px 10px; border-radius: 999px;
116031
+ }
116032
+ .myio-manualdev__error {
116033
+ margin: 0; font-size: 13px; color: #991b1b; background: #fee2e2; border-radius: 6px; padding: 8px 10px;
116034
+ }
116035
+ .myio-manualdev__detail { display: block; margin-top: 4px; font-size: 11.5px; color: #7f1d1d; opacity: 0.85; word-break: break-word; }
116036
+ .myio-manualdev__ok { text-align: center; padding: 4px 0; }
116037
+ .myio-manualdev__ok-icon { font-size: 34px; line-height: 1; }
116038
+ .myio-manualdev__ok-title { margin: 8px 0 4px; font-size: 16px; font-weight: 700; color: #065f46; }
116039
+ .myio-manualdev__ok-text { margin: 0; font-size: 13px; color: #4b5563; }
116040
+ .myio-manualdev__tech {
116041
+ margin-top: 12px; text-align: left; font-size: 11.5px; color: #6b7280; background: #f9fafb;
116042
+ border: 1px dashed #e5e7eb; border-radius: 6px; padding: 8px 10px; line-height: 1.6;
116043
+ }
116044
+ .myio-manualdev__tech code { font-size: 11.5px; color: #374151; }
116045
+ `;
116046
+ document.head.appendChild(style);
116047
+ }
116048
+ function formHtml(domain, values, error, detail) {
116049
+ const t = DOMAIN_TEXT2[domain];
116050
+ return `
116051
+ <form class="myio-manualdev" novalidate>
116052
+ <p class="myio-manualdev__hint">Cadastre um ponto de leitura manual. Ele aparece nesta lista e n\xE3o entra nos totais nem nos relat\xF3rios.</p>
116053
+ <span class="myio-manualdev__type">${t.icon} ${escapeHtml14(t.noun)} manual</span>
116054
+ <label class="myio-manualdev__field">
116055
+ <span class="myio-manualdev__label">Etiqueta</span>
116056
+ <input class="myio-manualdev__input" name="label" maxlength="80" autocomplete="off"
116057
+ placeholder="Ex.: Burger King" value="${escapeHtml14(values.label)}" />
116058
+ </label>
116059
+ <label class="myio-manualdev__field">
116060
+ <span class="myio-manualdev__label">Identificador</span>
116061
+ <input class="myio-manualdev__input" name="identifier" maxlength="40" autocomplete="off"
116062
+ placeholder="Ex.: STB01010" value="${escapeHtml14(values.identifier)}" />
116063
+ </label>
116064
+ ${error ? `<p class="myio-manualdev__error" role="alert">${escapeHtml14(error)}${detail ? `<small class="myio-manualdev__detail">${escapeHtml14(detail)}</small>` : ""}</p>` : ""}
116065
+ <button type="submit" hidden></button>
116066
+ </form>`;
116067
+ }
116068
+ function successHtml(domain, r, tech) {
116069
+ return `
116070
+ <div class="myio-manualdev__ok">
116071
+ <div class="myio-manualdev__ok-icon">\u2705</div>
116072
+ <p class="myio-manualdev__ok-title">${escapeHtml14(DOMAIN_TEXT2[domain].noun)} criado</p>
116073
+ <p class="myio-manualdev__ok-text"><strong>${escapeHtml14(r.label)}</strong> \xB7 ${escapeHtml14(r.identifier)}</p>
116074
+ ${tech ? `<div class="myio-manualdev__tech">
116075
+ device <code>${escapeHtml14(r.name)}</code><br/>
116076
+ profile <code>${escapeHtml14(r.deviceProfile)}</code><br/>
116077
+ asset <code>${escapeHtml14(r.assetName)}</code><br/>
116078
+ id <code>${escapeHtml14(r.deviceId)}</code>
116079
+ </div>` : ""}
116080
+ </div>`;
116081
+ }
116082
+ function openManualDeviceModal(params) {
116083
+ const domain = params.domain;
116084
+ if (!MANUAL_DEVICE_PROFILES[domain]) throw new Error(`[openManualDeviceModal] dom\xEDnio inv\xE1lido: ${domain}`);
116085
+ injectStyles15();
116086
+ const values = { label: "", identifier: "" };
116087
+ let busy = false;
116088
+ let created = null;
116089
+ const modal = openStandardModal({
116090
+ title: DOMAIN_TEXT2[domain].title,
116091
+ icon: DOMAIN_TEXT2[domain].icon,
116092
+ bodyHtml: formHtml(domain, values),
116093
+ width: 460,
116094
+ container: params.container,
116095
+ buttons: [
116096
+ { label: "Cancelar", value: "cancel", variant: "secondary" },
116097
+ { label: "Criar", value: "create", variant: "primary", closeOnClick: false }
116098
+ ],
116099
+ onButton: (v) => {
116100
+ if (v !== "create") return;
116101
+ if (created) {
116102
+ const r = created;
116103
+ modal.close();
116104
+ params.onCreated?.(r);
116105
+ } else {
116106
+ void submit();
116107
+ }
116108
+ }
116109
+ });
116110
+ const bindForm = (focus = true) => {
116111
+ const form = modal.getBodyEl().querySelector("form");
116112
+ form?.addEventListener("submit", (e) => {
116113
+ e.preventDefault();
116114
+ void submit();
116115
+ });
116116
+ if (focus) form?.querySelector('input[name="label"]')?.focus();
116117
+ };
116118
+ bindForm();
116119
+ async function submit() {
116120
+ if (busy || created) return;
116121
+ const body = modal.getBodyEl();
116122
+ values.label = (body.querySelector('input[name="label"]')?.value || "").trim();
116123
+ values.identifier = (body.querySelector('input[name="identifier"]')?.value || "").trim();
116124
+ const missing = !values.label ? "label" : !values.identifier ? "identifier" : null;
116125
+ if (missing) {
116126
+ modal.setBodyHtml(formHtml(domain, values, missing === "label" ? "Informe a etiqueta." : "Informe o identificador."));
116127
+ bindForm(false);
116128
+ const input = body.querySelector(`input[name="${missing}"]`);
116129
+ input?.setAttribute("aria-invalid", "true");
116130
+ input?.focus();
116131
+ return;
116132
+ }
116133
+ busy = true;
116134
+ modal.setButton("create", { disabled: true, label: "Criando\u2026" });
116135
+ modal.setButton("cancel", { disabled: true });
116136
+ body.querySelectorAll("input").forEach((i) => i.disabled = true);
116137
+ try {
116138
+ created = await createManualDevice({ ...params, label: values.label, identifier: values.identifier });
116139
+ modal.setBodyHtml(successHtml(domain, created, !!params.showTechnicalDetails));
116140
+ modal.setButton("cancel", { hidden: true });
116141
+ modal.setButton("create", { disabled: false, label: "Concluir" });
116142
+ } catch (err) {
116143
+ const msg = err instanceof ManualDeviceError ? err.message : "N\xE3o foi poss\xEDvel criar o dispositivo.";
116144
+ const detail = params.showTechnicalDetails ? (err instanceof ManualDeviceError ? err.detail : String(err?.message || err)) || void 0 : void 0;
116145
+ modal.setBodyHtml(formHtml(domain, values, msg, detail));
116146
+ bindForm();
116147
+ modal.setButton("create", { disabled: false, label: "Criar" });
116148
+ modal.setButton("cancel", { disabled: false });
116149
+ } finally {
116150
+ busy = false;
116151
+ }
116152
+ }
116153
+ return modal;
116154
+ }
116155
+
114141
116156
  // src/components/myio-gcdr-login/dom.ts
114142
116157
  function h2(doc, tag, attrs = {}, ...children) {
114143
116158
  const el2 = doc.createElement(tag);
@@ -116222,22 +118237,22 @@ function openMyioGcdrLoginModal(options) {
116222
118237
  }
116223
118238
 
116224
118239
  // src/components/img-gallery/ScrollableTabs.ts
116225
- var STYLE_ID11 = "myio-tabs-styles";
116226
- var FONT_LINK_ID3 = "myio-dialog-font-nunito";
116227
- function escapeHtml11(value) {
118240
+ var STYLE_ID16 = "myio-tabs-styles";
118241
+ var FONT_LINK_ID4 = "myio-dialog-font-nunito";
118242
+ function escapeHtml15(value) {
116228
118243
  return String(value).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
116229
118244
  }
116230
- function injectStyles13() {
116231
- if (!document.getElementById(FONT_LINK_ID3)) {
118245
+ function injectStyles16() {
118246
+ if (!document.getElementById(FONT_LINK_ID4)) {
116232
118247
  const link = document.createElement("link");
116233
- link.id = FONT_LINK_ID3;
118248
+ link.id = FONT_LINK_ID4;
116234
118249
  link.rel = "stylesheet";
116235
118250
  link.href = "https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap";
116236
118251
  document.head.appendChild(link);
116237
118252
  }
116238
- if (document.getElementById(STYLE_ID11)) return;
118253
+ if (document.getElementById(STYLE_ID16)) return;
116239
118254
  const style = document.createElement("style");
116240
- style.id = STYLE_ID11;
118255
+ style.id = STYLE_ID16;
116241
118256
  style.textContent = `
116242
118257
  .myio-tabs {
116243
118258
  display: flex;
@@ -116312,7 +118327,7 @@ function createScrollableTabs(options) {
116312
118327
  if (typeof document === "undefined") {
116313
118328
  throw new Error("[createScrollableTabs] requires a browser environment");
116314
118329
  }
116315
- injectStyles13();
118330
+ injectStyles16();
116316
118331
  const theme = options.theme ?? "light";
116317
118332
  const accent = options.accent ?? "#7C3AED";
116318
118333
  const showArrows = options.showArrows ?? "auto";
@@ -116338,10 +118353,10 @@ function createScrollableTabs(options) {
116338
118353
  root.appendChild(left);
116339
118354
  root.appendChild(scroll);
116340
118355
  root.appendChild(right);
116341
- function styleTab(btn, isActive) {
116342
- btn.classList.toggle("myio-tabs__tab--active", isActive);
116343
- btn.setAttribute("aria-selected", isActive ? "true" : "false");
116344
- if (isActive) {
118356
+ function styleTab(btn, isActive2) {
118357
+ btn.classList.toggle("myio-tabs__tab--active", isActive2);
118358
+ btn.setAttribute("aria-selected", isActive2 ? "true" : "false");
118359
+ if (isActive2) {
116345
118360
  btn.style.background = accent;
116346
118361
  btn.style.color = "#fff";
116347
118362
  btn.style.borderColor = accent;
@@ -116360,7 +118375,7 @@ function createScrollableTabs(options) {
116360
118375
  btn.setAttribute("role", "tab");
116361
118376
  btn.dataset.key = t.key;
116362
118377
  if (t.disabled) btn.disabled = true;
116363
- btn.innerHTML = `${t.icon ? `<span aria-hidden="true">${t.icon}</span>` : ""}<span>${escapeHtml11(t.label)}</span>`;
118378
+ btn.innerHTML = `${t.icon ? `<span aria-hidden="true">${t.icon}</span>` : ""}<span>${escapeHtml15(t.label)}</span>`;
116364
118379
  styleTab(btn, t.key === active);
116365
118380
  btn.addEventListener("click", () => {
116366
118381
  if (t.disabled || t.key === active) return;
@@ -116445,23 +118460,23 @@ function createScrollableTabs(options) {
116445
118460
  }
116446
118461
 
116447
118462
  // src/components/img-gallery/ImgGallery.ts
116448
- var STYLE_ID12 = "myio-gallery-styles";
116449
- var FONT_LINK_ID4 = "myio-dialog-font-nunito";
116450
- function escapeHtml12(value) {
118463
+ var STYLE_ID17 = "myio-gallery-styles";
118464
+ var FONT_LINK_ID5 = "myio-dialog-font-nunito";
118465
+ function escapeHtml16(value) {
116451
118466
  return String(value == null ? "" : value).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
116452
118467
  }
116453
118468
  var PRM = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
116454
- function injectStyles14() {
116455
- if (!document.getElementById(FONT_LINK_ID4)) {
118469
+ function injectStyles17() {
118470
+ if (!document.getElementById(FONT_LINK_ID5)) {
116456
118471
  const link = document.createElement("link");
116457
- link.id = FONT_LINK_ID4;
118472
+ link.id = FONT_LINK_ID5;
116458
118473
  link.rel = "stylesheet";
116459
118474
  link.href = "https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap";
116460
118475
  document.head.appendChild(link);
116461
118476
  }
116462
- if (document.getElementById(STYLE_ID12)) return;
118477
+ if (document.getElementById(STYLE_ID17)) return;
116463
118478
  const style = document.createElement("style");
116464
- style.id = STYLE_ID12;
118479
+ style.id = STYLE_ID17;
116465
118480
  style.textContent = `
116466
118481
  .myio-gallery {
116467
118482
  font-family: 'Nunito', system-ui, sans-serif;
@@ -116620,7 +118635,7 @@ function createImgGallery(options) {
116620
118635
  if (typeof document === "undefined") {
116621
118636
  throw new Error("[createImgGallery] requires a browser environment");
116622
118637
  }
116623
- injectStyles14();
118638
+ injectStyles17();
116624
118639
  const locale = options.locale === "en-US" ? "en-US" : "pt-BR";
116625
118640
  const theme = options.theme ?? "light";
116626
118641
  const accent = options.accent ?? "#7C3AED";
@@ -116671,10 +118686,10 @@ function createImgGallery(options) {
116671
118686
  root.appendChild(grid);
116672
118687
  function detailsHtml(img) {
116673
118688
  const lines = [];
116674
- if (img.filename) lines.push(`<span title="${escapeHtml12(img.filename)}">${escapeHtml12(img.filename)}</span>`);
116675
- if (typeof img.sizeBytes === "number") lines.push(`<span>${escapeHtml12(formatSize(img.sizeBytes))}</span>`);
118689
+ if (img.filename) lines.push(`<span title="${escapeHtml16(img.filename)}">${escapeHtml16(img.filename)}</span>`);
118690
+ if (typeof img.sizeBytes === "number") lines.push(`<span>${escapeHtml16(formatSize(img.sizeBytes))}</span>`);
116676
118691
  const dims = typeof img.width === "number" && typeof img.height === "number" ? `${img.width} \xD7 ${img.height}px` : "";
116677
- lines.push(`<span data-dims>${escapeHtml12(dims)}</span>`);
118692
+ lines.push(`<span data-dims>${escapeHtml16(dims)}</span>`);
116678
118693
  return lines.join("");
116679
118694
  }
116680
118695
  function renderDescription(body, img, index) {
@@ -123888,10 +125903,10 @@ var MenuView = class {
123888
125903
  </div>
123889
125904
  <div class="myio-unified-column-options">
123890
125905
  ${tab.contexts.map((ctx) => {
123891
- const isActive = isActiveTab && ctx.id === currentContextId;
125906
+ const isActive2 = isActiveTab && ctx.id === currentContextId;
123892
125907
  return `
123893
125908
  <button
123894
- class="myio-unified-option ${tab.id} ${isActive ? "is-active" : ""}"
125909
+ class="myio-unified-option ${tab.id} ${isActive2 ? "is-active" : ""}"
123895
125910
  data-tab-id="${tab.id}"
123896
125911
  data-context-id="${ctx.id}"
123897
125912
  data-target="${ctx.target}"
@@ -123914,20 +125929,20 @@ var MenuView = class {
123914
125929
  * Only active tab shows context detail, others show only domain label
123915
125930
  */
123916
125931
  buildTabHTML(tab) {
123917
- const isActive = tab.id === this.activeTabId;
123918
- const label = this.getTabLabel(tab.id, isActive);
125932
+ const isActive2 = tab.id === this.activeTabId;
125933
+ const label = this.getTabLabel(tab.id, isActive2);
123919
125934
  return `
123920
125935
  <button
123921
125936
  id="menuTab_${tab.id}"
123922
- class="tab ${isActive ? "is-active" : ""}"
125937
+ class="tab ${isActive2 ? "is-active" : ""}"
123923
125938
  data-tab-id="${tab.id}"
123924
125939
  role="tab"
123925
- aria-selected="${isActive}"
125940
+ aria-selected="${isActive2}"
123926
125941
  aria-controls="menuContextModal_${tab.id}"
123927
125942
  >
123928
125943
  <span class="ico">${tab.icon}</span>
123929
125944
  <span class="tab-label">${label}</span>
123930
- ${isActive ? '<span class="dropdown-arrow">\u25BC</span>' : ""}
125945
+ ${isActive2 ? '<span class="dropdown-arrow">\u25BC</span>' : ""}
123931
125946
  </button>
123932
125947
  `;
123933
125948
  }
@@ -123936,10 +125951,10 @@ var MenuView = class {
123936
125951
  * Active tab: "Domain: Context" (e.g., "Energia: Equipamentos")
123937
125952
  * Inactive tab: "Domain" only (e.g., "Agua")
123938
125953
  */
123939
- getTabLabel(tabId, isActive) {
125954
+ getTabLabel(tabId, isActive2) {
123940
125955
  const tab = this.tabs.find((t) => t.id === tabId);
123941
125956
  if (!tab) return "";
123942
- if (isActive) {
125957
+ if (isActive2) {
123943
125958
  const currentContextId = this.contextsByTab.get(tabId) ?? tab.defaultContext ?? tab.contexts[0]?.id;
123944
125959
  const currentContext = tab.contexts.find((c) => c.id === currentContextId);
123945
125960
  return currentContext ? `${tab.label}: ${currentContext.title}` : tab.label;
@@ -123951,20 +125966,20 @@ var MenuView = class {
123951
125966
  */
123952
125967
  updateAllTabLabels() {
123953
125968
  this.tabs.forEach((tab) => {
123954
- const isActive = tab.id === this.activeTabId;
125969
+ const isActive2 = tab.id === this.activeTabId;
123955
125970
  const tabEl = this.root.querySelector(`#menuTab_${tab.id}`);
123956
125971
  if (!tabEl) return;
123957
125972
  const labelEl = tabEl.querySelector(".tab-label");
123958
125973
  if (labelEl) {
123959
- labelEl.textContent = this.getTabLabel(tab.id, isActive);
125974
+ labelEl.textContent = this.getTabLabel(tab.id, isActive2);
123960
125975
  }
123961
125976
  const arrowEl = tabEl.querySelector(".dropdown-arrow");
123962
- if (isActive && !arrowEl) {
125977
+ if (isActive2 && !arrowEl) {
123963
125978
  const arrow = document.createElement("span");
123964
125979
  arrow.className = "dropdown-arrow";
123965
125980
  arrow.textContent = "\u25BC";
123966
125981
  tabEl.appendChild(arrow);
123967
- } else if (!isActive && arrowEl) {
125982
+ } else if (!isActive2 && arrowEl) {
123968
125983
  arrowEl.remove();
123969
125984
  }
123970
125985
  });
@@ -123998,10 +126013,10 @@ var MenuView = class {
123998
126013
  /**
123999
126014
  * Build a single context option HTML
124000
126015
  */
124001
- buildContextOptionHTML(tab, ctx, isActive) {
126016
+ buildContextOptionHTML(tab, ctx, isActive2) {
124002
126017
  return `
124003
126018
  <button
124004
- class="myio-menu-context-option ${tab.id} ${isActive ? "is-active" : ""}"
126019
+ class="myio-menu-context-option ${tab.id} ${isActive2 ? "is-active" : ""}"
124005
126020
  data-tab-id="${tab.id}"
124006
126021
  data-context-id="${ctx.id}"
124007
126022
  data-target="${ctx.target}"
@@ -124060,13 +126075,13 @@ var MenuView = class {
124060
126075
  * Build Mobile Tab HTML (for mobile drawer)
124061
126076
  */
124062
126077
  buildMobileTabHTML(tab) {
124063
- const isActive = tab.id === this.activeTabId;
126078
+ const isActive2 = tab.id === this.activeTabId;
124064
126079
  const currentContextId = this.contextsByTab.get(tab.id) ?? tab.defaultContext ?? tab.contexts[0]?.id;
124065
126080
  const currentContext = tab.contexts.find((c) => c.id === currentContextId);
124066
126081
  const contextTitle = currentContext ? currentContext.title : "";
124067
126082
  return `
124068
126083
  <button
124069
- class="tab ${isActive ? "is-active" : ""}"
126084
+ class="tab ${isActive2 ? "is-active" : ""}"
124070
126085
  data-tab-id="${tab.id}"
124071
126086
  data-mobile-tab="true"
124072
126087
  >
@@ -124671,8 +126686,8 @@ var MenuView = class {
124671
126686
  const contextId = el2.dataset.contextId;
124672
126687
  const currentContextId = this.contextsByTab.get(tabId);
124673
126688
  const isActiveTab = tabId === this.activeTabId;
124674
- const isActive = isActiveTab && contextId === currentContextId;
124675
- el2.classList.toggle("is-active", isActive);
126689
+ const isActive2 = isActiveTab && contextId === currentContextId;
126690
+ el2.classList.toggle("is-active", isActive2);
124676
126691
  });
124677
126692
  this.root.querySelectorAll(".myio-unified-column").forEach((col2) => {
124678
126693
  const tabId = col2.classList.contains("energy") ? "energy" : col2.classList.contains("water") ? "water" : col2.classList.contains("temperature") ? "temperature" : "";
@@ -130259,7 +132274,7 @@ var MODAL_CSS2 = `
130259
132274
  background: rgba(255, 255, 255, 0.2);
130260
132275
  }
130261
132276
  `;
130262
- function injectStyles15() {
132277
+ function injectStyles18() {
130263
132278
  if (document.getElementById(CSS_ID5)) return;
130264
132279
  const style = document.createElement("style");
130265
132280
  style.id = CSS_ID5;
@@ -130276,7 +132291,7 @@ var FilterModalComponent = class {
130276
132291
  showDeviceGrid;
130277
132292
  deviceSearchQuery = "";
130278
132293
  constructor(options) {
130279
- injectStyles15();
132294
+ injectStyles18();
130280
132295
  this.options = options;
130281
132296
  this.themeMode = options.themeMode || "light";
130282
132297
  this.selectedCategories = new Set(
@@ -131180,7 +133195,7 @@ function createCustomerCardV1(params) {
131180
133195
  }
131181
133196
 
131182
133197
  // src/components/cards/customer-goals/v1.0.0/styles.ts
131183
- var STYLE_ID13 = "myio-customer-goals-card-css";
133198
+ var STYLE_ID18 = "myio-customer-goals-card-css";
131184
133199
  var CSS4 = `
131185
133200
  .myio-cgc{
131186
133201
  --cgc-surface:#ffffff;
@@ -131281,9 +133296,9 @@ var CSS4 = `
131281
133296
  `;
131282
133297
  function injectCustomerGoalsCardStyles() {
131283
133298
  if (typeof document === "undefined") return;
131284
- if (document.getElementById(STYLE_ID13)) return;
133299
+ if (document.getElementById(STYLE_ID18)) return;
131285
133300
  const tag = document.createElement("style");
131286
- tag.id = STYLE_ID13;
133301
+ tag.id = STYLE_ID18;
131287
133302
  tag.textContent = CSS4;
131288
133303
  document.head.appendChild(tag);
131289
133304
  }
@@ -134133,7 +136148,7 @@ var WATER_FIXTURES = {
134133
136148
  var DEFAULT_FIXTURES = ENERGY_FIXTURES;
134134
136149
 
134135
136150
  // src/components/metas-guide/openMetasGuide.ts
134136
- var STYLE_ID14 = "myio-metas-guide-styles";
136151
+ var STYLE_ID19 = "myio-metas-guide-styles";
134137
136152
  var ROOT_ID = "myio-metas-guide-root";
134138
136153
  var FALLBACK_THEME = {
134139
136154
  accent: "#6c5ce7",
@@ -134141,7 +136156,7 @@ var FALLBACK_THEME = {
134141
136156
  accentText: "#ffffff",
134142
136157
  mode: "light"
134143
136158
  };
134144
- function escapeHtml13(value) {
136159
+ function escapeHtml17(value) {
134145
136160
  return String(value ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
134146
136161
  }
134147
136162
  var nfInt = new Intl.NumberFormat("pt-BR", { maximumFractionDigits: 0 });
@@ -134169,7 +136184,7 @@ function legendHtml() {
134169
136184
  [SERIES_COLORS.orcado, "Or\xE7ado"]
134170
136185
  ];
134171
136186
  return `<div class="myio-mg-legend">${items.map(
134172
- ([c, l]) => `<span class="myio-mg-legend__item"><span class="myio-mg-legend__dot" style="background:${c}" aria-hidden="true"></span>${escapeHtml13(
136187
+ ([c, l]) => `<span class="myio-mg-legend__item"><span class="myio-mg-legend__dot" style="background:${c}" aria-hidden="true"></span>${escapeHtml17(
134173
136188
  l
134174
136189
  )}</span>`
134175
136190
  ).join("")}</div>`;
@@ -134209,7 +136224,7 @@ function miniChartSvg(s) {
134209
136224
  const pts = data.map((v, i) => `${(i * bandW + bandW / 2).toFixed(1)},${y(v).toFixed(1)}`).join(" ");
134210
136225
  return `<polyline points="${pts}" fill="none" stroke="${color}" stroke-width="2" stroke-linejoin="round" stroke-linecap="round"></polyline>`;
134211
136226
  };
134212
- return `<svg class="myio-mg-chart" viewBox="0 0 ${W} ${H}" role="img" aria-label="Gr\xE1fico ilustrativo de ${escapeHtml13(
136227
+ return `<svg class="myio-mg-chart" viewBox="0 0 ${W} ${H}" role="img" aria-label="Gr\xE1fico ilustrativo de ${escapeHtml17(
134213
136228
  s.name
134214
136229
  )}" preserveAspectRatio="none">
134215
136230
  ${bars}
@@ -134226,8 +136241,8 @@ function kpiRowHtml(s, unit) {
134226
136241
  ];
134227
136242
  return `<div class="myio-mg-kpis">${kpis.map(
134228
136243
  ([label, val, color]) => `<div class="myio-mg-kpi">
134229
- <span class="myio-mg-kpi__label" style="color:${color}">${escapeHtml13(label)}</span>
134230
- <span class="myio-mg-kpi__value">${fmtInt(val)} <small>${escapeHtml13(unit)}</small></span>
136244
+ <span class="myio-mg-kpi__label" style="color:${color}">${escapeHtml17(label)}</span>
136245
+ <span class="myio-mg-kpi__value">${fmtInt(val)} <small>${escapeHtml17(unit)}</small></span>
134231
136246
  </div>`
134232
136247
  ).join("")}</div>`;
134233
136248
  }
@@ -134235,7 +136250,7 @@ function chipsHtml(s) {
134235
136250
  const c = computeChips(s);
134236
136251
  const chip = (label, ratio) => {
134237
136252
  const cls = ratio > 0 ? "is-up" : ratio < 0 ? "is-down" : "is-flat";
134238
- return `<span class="myio-mg-chip ${cls}">${escapeHtml13(label)} <strong>${escapeHtml13(
136253
+ return `<span class="myio-mg-chip ${cls}">${escapeHtml17(label)} <strong>${escapeHtml17(
134239
136254
  fmtPct4(ratio)
134240
136255
  )}</strong></span>`;
134241
136256
  };
@@ -134250,7 +136265,7 @@ function miniCardHtml(s, unit, opts) {
134250
136265
  const showKpis = opts?.kpis !== false;
134251
136266
  const showChips = opts?.chips !== false;
134252
136267
  return `<div class="myio-mg-card">
134253
- <h5 class="myio-mg-card__title">${escapeHtml13(s.name)}</h5>
136268
+ <h5 class="myio-mg-card__title">${escapeHtml17(s.name)}</h5>
134254
136269
  ${showChart ? legendHtml() + miniChartSvg(s) : ""}
134255
136270
  ${showKpis ? kpiRowHtml(s, unit) : ""}
134256
136271
  ${showChips ? chipsHtml(s) : ""}
@@ -134260,7 +136275,7 @@ function miniSidebarHtml(shoppings, unit, prevY, curY) {
134260
136275
  const total = deriveTotal({ shoppings });
134261
136276
  const row = (name, a, r, o, m, isTotal) => `
134262
136277
  <div class="myio-mg-side__row${isTotal ? " is-total" : ""}">
134263
- <span class="myio-mg-side__name">${escapeHtml13(name)}</span>
136278
+ <span class="myio-mg-side__name">${escapeHtml17(name)}</span>
134264
136279
  <span class="myio-mg-side__vals">
134265
136280
  <b style="color:${SERIES_COLORS.aMinus1}">${fmtInt(a)}</b>
134266
136281
  <b style="color:${SERIES_COLORS.realizado}">${fmtInt(r)}</b>
@@ -134271,7 +136286,7 @@ function miniSidebarHtml(shoppings, unit, prevY, curY) {
134271
136286
  return `<div class="myio-mg-side">
134272
136287
  <div class="myio-mg-side__head">
134273
136288
  <span>Resumo por shopping</span>
134274
- <span class="myio-mg-side__unit">${escapeHtml13(unit)}</span>
136289
+ <span class="myio-mg-side__unit">${escapeHtml17(unit)}</span>
134275
136290
  </div>
134276
136291
  <div class="myio-mg-side__cols">
134277
136292
  <span>Shopping</span>
@@ -134298,10 +136313,10 @@ function miniToolbarHtml(prevY, curY, highlight) {
134298
136313
  </div>`;
134299
136314
  }
134300
136315
  function bannerHtml(text2) {
134301
- return `<p class="myio-mg-banner">${escapeHtml13(text2)}</p>`;
136316
+ return `<p class="myio-mg-banner">${escapeHtml17(text2)}</p>`;
134302
136317
  }
134303
136318
  function paras(sentences) {
134304
- return `<div class="myio-mg-copy">${sentences.map((s) => `<p>${escapeHtml13(s)}</p>`).join("")}</div>`;
136319
+ return `<div class="myio-mg-copy">${sentences.map((s) => `<p>${escapeHtml17(s)}</p>`).join("")}</div>`;
134305
136320
  }
134306
136321
  function buildSections(ctx) {
134307
136322
  const { energy, water, curY, prevY } = ctx;
@@ -134326,8 +136341,8 @@ function buildSections(ctx) {
134326
136341
  "A r\xE9gua da meta muda por dom\xEDnio: em Energia a refer\xEAncia \xE9 a ENTRADA; em \xC1gua, os hidr\xF4metros.",
134327
136342
  "Os n\xFAmeros e a unidade de cada card acompanham o dom\xEDnio selecionado."
134328
136343
  ]) + miniToolbarHtml(prevY, curY, "domain") + `<div class="myio-mg-two">
134329
- <div><div class="myio-mg-two__tag">\u26A1 Energia \xB7 ${escapeHtml13(energy.unit)}</div>${miniCardHtml(e0, energy.unit, { chips: false })}</div>
134330
- <div><div class="myio-mg-two__tag">\u{1F4A7} \xC1gua \xB7 ${escapeHtml13(water.unit)}</div>${miniCardHtml(w0, water.unit, { chips: false })}</div>
136344
+ <div><div class="myio-mg-two__tag">\u26A1 Energia \xB7 ${escapeHtml17(energy.unit)}</div>${miniCardHtml(e0, energy.unit, { chips: false })}</div>
136345
+ <div><div class="myio-mg-two__tag">\u{1F4A7} \xC1gua \xB7 ${escapeHtml17(water.unit)}</div>${miniCardHtml(w0, water.unit, { chips: false })}</div>
134331
136346
  </div>`
134332
136347
  },
134333
136348
  {
@@ -134398,7 +136413,7 @@ function buildSections(ctx) {
134398
136413
  ]) + `<div class="myio-mg-order">
134399
136414
  <span class="myio-mg-order__btn">Data de Inaugura\xE7\xE3o \u2191 \xB7 \u2699\uFE0F</span>
134400
136415
  <span class="myio-mg-order__btn">\u25BD Filtros</span>
134401
- </div><ul class="myio-mg-order__list">${energy.shoppings.slice().sort((a, b) => a.inaugurationDate.localeCompare(b.inaugurationDate)).map((s) => `<li><b>${escapeHtml13(s.name)}</b> <span>inaugurado em ${escapeHtml13(s.inaugurationDate)}</span></li>`).join("")}</ul>`
136416
+ </div><ul class="myio-mg-order__list">${energy.shoppings.slice().sort((a, b) => a.inaugurationDate.localeCompare(b.inaugurationDate)).map((s) => `<li><b>${escapeHtml17(s.name)}</b> <span>inaugurado em ${escapeHtml17(s.inaugurationDate)}</span></li>`).join("")}</ul>`
134402
136417
  },
134403
136418
  {
134404
136419
  id: "engine",
@@ -134426,10 +136441,10 @@ function buildSections(ctx) {
134426
136441
  }
134427
136442
  ];
134428
136443
  }
134429
- function injectStyles16() {
134430
- if (document.getElementById(STYLE_ID14)) return;
136444
+ function injectStyles19() {
136445
+ if (document.getElementById(STYLE_ID19)) return;
134431
136446
  const style = document.createElement("style");
134432
- style.id = STYLE_ID14;
136447
+ style.id = STYLE_ID19;
134433
136448
  style.textContent = `
134434
136449
  #${ROOT_ID}{position:fixed;inset:0;z-index:100001;display:flex;align-items:center;justify-content:center;padding:20px;background:rgba(15,23,42,.6);backdrop-filter:blur(4px);font-family:'Nunito',system-ui,sans-serif;}
134435
136450
  #${ROOT_ID} *{box-sizing:border-box;}
@@ -134528,7 +136543,7 @@ function openMetasGuide(options = {}) {
134528
136543
  const sections = buildSections({ energy, water, curY, prevY });
134529
136544
  const total = sections.length;
134530
136545
  document.getElementById(ROOT_ID)?.remove();
134531
- injectStyles16();
136546
+ injectStyles19();
134532
136547
  const previouslyFocused = document.activeElement;
134533
136548
  let index = 0;
134534
136549
  let closed = false;
@@ -134537,9 +136552,9 @@ function openMetasGuide(options = {}) {
134537
136552
  root.innerHTML = `
134538
136553
  <div class="myio-mg-modal${theme.mode === "dark" ? " is-dark" : ""}" role="dialog" aria-modal="true"
134539
136554
  aria-labelledby="myio-mg-title"
134540
- style="--mg-accent:${escapeHtml13(theme.accent)};--mg-accent-dark:${escapeHtml13(
136555
+ style="--mg-accent:${escapeHtml17(theme.accent)};--mg-accent-dark:${escapeHtml17(
134541
136556
  theme.accentDark
134542
- )};--mg-accent-text:${escapeHtml13(theme.accentText)};">
136557
+ )};--mg-accent-text:${escapeHtml17(theme.accentText)};">
134543
136558
  <div class="myio-mg-header">
134544
136559
  <div class="myio-mg-header__l">
134545
136560
  <span class="myio-mg-header__logo" aria-hidden="true">\u{1F393}</span>
@@ -138373,7 +140388,7 @@ var TELEMETRY_GRID_SHOPPING_STYLES = `
138373
140388
  text-overflow: ellipsis;
138374
140389
  }
138375
140390
  `;
138376
- function injectStyles17(_container) {
140391
+ function injectStyles20(_container) {
138377
140392
  const styleId = "telemetry-grid-shopping-styles";
138378
140393
  if (document.getElementById(styleId)) {
138379
140394
  return;
@@ -138421,7 +140436,7 @@ var TelemetryGridShoppingView = class {
138421
140436
  // Render
138422
140437
  // =========================================================================
138423
140438
  render() {
138424
- injectStyles17(this.root);
140439
+ injectStyles20(this.root);
138425
140440
  this.root.innerHTML = this.buildHTML();
138426
140441
  this.cacheElements();
138427
140442
  this.bindEvents();
@@ -140092,7 +142107,7 @@ var TELEMETRY_INFO_SHOPPING_STYLES = `
140092
142107
  }
140093
142108
  }
140094
142109
  `;
140095
- function injectStyles18(_container) {
142110
+ function injectStyles21(_container) {
140096
142111
  const styleId = "telemetry-info-shopping-styles-v2";
140097
142112
  if (document.getElementById(styleId)) {
140098
142113
  return;
@@ -140152,7 +142167,7 @@ var TelemetryInfoShoppingView = class _TelemetryInfoShoppingView {
140152
142167
  // Render
140153
142168
  // =========================================================================
140154
142169
  render() {
140155
- injectStyles18(this.root);
142170
+ injectStyles21(this.root);
140156
142171
  this.root.innerHTML = this.buildHTML();
140157
142172
  this.cacheElements();
140158
142173
  this.bindEvents();
@@ -144765,7 +146780,7 @@ var DeviceOperationalCardView = class {
144765
146780
  }
144766
146781
  renderCard(alarm) {
144767
146782
  const severityConfig = SEVERITY_CONFIG[alarm.severity];
144768
- const isActive = isAlarmActive(alarm.state);
146783
+ const isActive2 = isAlarmActive(alarm.state);
144769
146784
  const isCritical = alarm.severity === "CRITICAL" && alarm.state === "OPEN";
144770
146785
  const severityChipClass = this.getSeverityChipClass(alarm.severity);
144771
146786
  const stateChipClass = this.getStateChipClass(alarm.state);
@@ -144840,7 +146855,7 @@ var DeviceOperationalCardView = class {
144840
146855
 
144841
146856
  <!-- Actions -->
144842
146857
  <div class="myio-alarm-card-actions">
144843
- ${isActive ? `
146858
+ ${isActive2 ? `
144844
146859
  <button class="btn-ack" data-action="acknowledge">Reconhecer</button>
144845
146860
  ` : ""}
144846
146861
  <button class="btn-details" data-action="details">Detalhes</button>
@@ -148207,12 +150222,12 @@ var AlarmsNotificationsPanelView = class {
148207
150222
  }
148208
150223
  const badgeEl = this.root.querySelector("#alarmCountBadge");
148209
150224
  if (badgeEl) {
148210
- const openCount3 = state6.allAlarms.filter(
150225
+ const openCount4 = state6.allAlarms.filter(
148211
150226
  (a) => a.state === "OPEN" || a.state === "ESCALATED"
148212
150227
  ).length;
148213
- badgeEl.textContent = openCount3 > 99 ? "99+" : String(openCount3);
150228
+ badgeEl.textContent = openCount4 > 99 ? "99+" : String(openCount4);
148214
150229
  badgeEl.style.display = "inline-flex";
148215
- badgeEl.classList.toggle("is-zero", openCount3 === 0);
150230
+ badgeEl.classList.toggle("is-zero", openCount4 === 0);
148216
150231
  }
148217
150232
  const loadingOverlay = this.root.querySelector("#loadingOverlay");
148218
150233
  if (loadingOverlay) {
@@ -148533,10 +150548,10 @@ var AlarmsNotificationsPanelView = class {
148533
150548
  const renderListPanel = (group, items, sel) => {
148534
150549
  if (items.length === 0) return '<div class="afm-empty">Nenhum item encontrado</div>';
148535
150550
  return items.map((item) => {
148536
- const esc9 = this.esc(item);
150551
+ const esc10 = this.esc(item);
148537
150552
  return `<label class="afm-check-item">
148538
- <input type="checkbox" class="afm-checkbox" data-group="${group}" data-value="${esc9}"${sel.has(item) ? " checked" : ""}>
148539
- <span class="afm-check-label">${esc9}</span>
150553
+ <input type="checkbox" class="afm-checkbox" data-group="${group}" data-value="${esc10}"${sel.has(item) ? " checked" : ""}>
150554
+ <span class="afm-check-label">${esc10}</span>
148540
150555
  </label>`;
148541
150556
  }).join("");
148542
150557
  };
@@ -148731,15 +150746,15 @@ var AlarmsNotificationsPanelView = class {
148731
150746
  const rows = alarms.map((alarm) => {
148732
150747
  const sev = SEVERITY_CONFIG[alarm.severity];
148733
150748
  const st = STATE_CONFIG[alarm.state];
148734
- const isActive = alarm.state !== "CLOSED";
150749
+ const isActive2 = alarm.state !== "CLOSED";
148735
150750
  const sel = this.selectedIds.has(alarm.id);
148736
150751
  const escTitle = this.esc(alarm.title);
148737
150752
  const escCustomer = this.esc(alarm.customerName || "-");
148738
150753
  const escSource = this.esc(alarm.source || "-");
148739
150754
  const actionBtns = `
148740
150755
  ${this.isAlarmActionAllowed("acknowledge") && alarm.state === "OPEN" ? `<button class="atbl-btn atbl-btn--ack" data-action="acknowledge" data-alarm-id="${alarm.id}" title="Reconhecer"><svg viewBox="0 0 24 24" width="11" height="11" fill="currentColor"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/></svg></button>` : ""}
148741
- ${this.isAlarmActionAllowed("snooze") && isActive ? `<button class="atbl-btn atbl-btn--snooze" data-action="snooze" data-alarm-id="${alarm.id}" title="Adiar"><svg viewBox="0 0 24 24" width="11" height="11" fill="currentColor"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67V7z"/></svg></button>` : ""}
148742
- ${this.isAlarmActionAllowed("escalate") && isActive ? `<button class="atbl-btn atbl-btn--escalate" data-action="escalate" data-alarm-id="${alarm.id}" title="Escalar"><svg viewBox="0 0 24 24" width="11" height="11" fill="currentColor"><path d="M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"/></svg></button>` : ""}
150756
+ ${this.isAlarmActionAllowed("snooze") && isActive2 ? `<button class="atbl-btn atbl-btn--snooze" data-action="snooze" data-alarm-id="${alarm.id}" title="Adiar"><svg viewBox="0 0 24 24" width="11" height="11" fill="currentColor"><path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67V7z"/></svg></button>` : ""}
150757
+ ${this.isAlarmActionAllowed("escalate") && isActive2 ? `<button class="atbl-btn atbl-btn--escalate" data-action="escalate" data-alarm-id="${alarm.id}" title="Escalar"><svg viewBox="0 0 24 24" width="11" height="11" fill="currentColor"><path d="M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"/></svg></button>` : ""}
148743
150758
  <button class="atbl-btn atbl-btn--details" data-action="details" data-alarm-id="${alarm.id}" title="Detalhes"><svg viewBox="0 0 24 24" width="11" height="11" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></svg></button>
148744
150759
  `;
148745
150760
  const tiposHtml = isPorDispositivo && alarm._alarmTypes?.length ? alarm._alarmTypes.slice(0, 2).map(
@@ -152635,8 +154650,8 @@ function renderDowntimeList(downtimeList) {
152635
154650
  <div class="downtime-item">
152636
154651
  <span class="rank">${index + 1}</span>
152637
154652
  <div class="item-info">
152638
- <span class="item-name">${escapeHtml14(item.name)}</span>
152639
- <span class="item-location">${escapeHtml14(item.location)}</span>
154653
+ <span class="item-name">${escapeHtml18(item.name)}</span>
154654
+ <span class="item-location">${escapeHtml18(item.location)}</span>
152640
154655
  </div>
152641
154656
  <div class="item-metrics">
152642
154657
  <span class="downtime-hours">${item.downtime}h</span>
@@ -152649,7 +154664,7 @@ function renderDowntimeList(downtimeList) {
152649
154664
  `
152650
154665
  ).join("");
152651
154666
  }
152652
- function escapeHtml14(text2) {
154667
+ function escapeHtml18(text2) {
152653
154668
  const div = document.createElement("div");
152654
154669
  div.textContent = text2;
152655
154670
  return div.innerHTML;
@@ -157232,7 +159247,7 @@ function removeSchedulingSharedStyles() {
157232
159247
  }
157233
159248
 
157234
159249
  // src/components/scheduling-shared/view-helpers.ts
157235
- function escapeHtml15(str) {
159250
+ function escapeHtml19(str) {
157236
159251
  const div = document.createElement("div");
157237
159252
  div.textContent = str;
157238
159253
  return div.innerHTML;
@@ -157393,7 +159408,7 @@ function showConfirmModal(container, title, message) {
157393
159408
  overlay.innerHTML = `
157394
159409
  <div class="${SCHED_CSS_PREFIX}__modal-backdrop"></div>
157395
159410
  <div class="${SCHED_CSS_PREFIX}__modal-content">
157396
- <h3>${escapeHtml15(title)}</h3>
159411
+ <h3>${escapeHtml19(title)}</h3>
157397
159412
  <p>${message}</p>
157398
159413
  <div class="${SCHED_CSS_PREFIX}__modal-actions">
157399
159414
  <button class="${SCHED_CSS_PREFIX}__modal-btn-cancel">Cancelar</button>
@@ -157427,8 +159442,8 @@ function showNotificationModal(container, type, message, autoCloseMs = 6e3) {
157427
159442
  overlay.innerHTML = `
157428
159443
  <div class="${SCHED_CSS_PREFIX}__modal-backdrop"></div>
157429
159444
  <div class="${SCHED_CSS_PREFIX}__modal-content">
157430
- <h3>${escapeHtml15(title)}</h3>
157431
- <p>${escapeHtml15(message)}</p>
159445
+ <h3>${escapeHtml19(title)}</h3>
159446
+ <p>${escapeHtml19(message)}</p>
157432
159447
  <div class="${SCHED_CSS_PREFIX}__modal-actions">
157433
159448
  <button class="${SCHED_CSS_PREFIX}__modal-btn-close">Fechar</button>
157434
159449
  </div>
@@ -159005,7 +161020,7 @@ var STYLES = `
159005
161020
  color: var(--dgv6-ink-2);
159006
161021
  }
159007
161022
  `;
159008
- function injectStyles19() {
161023
+ function injectStyles22() {
159009
161024
  if (document.getElementById(CSS_ID6)) return;
159010
161025
  const style = document.createElement("style");
159011
161026
  style.id = CSS_ID6;
@@ -159044,7 +161059,7 @@ var DeviceGridV6View = class {
159044
161059
  // Render
159045
161060
  // =========================================================================
159046
161061
  render() {
159047
- injectStyles19();
161062
+ injectStyles22();
159048
161063
  this.root.innerHTML = this.buildHTML();
159049
161064
  this.cacheElements();
159050
161065
  this.bindEvents();
@@ -159149,10 +161164,10 @@ var DeviceGridV6View = class {
159149
161164
  }
159150
161165
  toggleSearch() {
159151
161166
  if (!this.searchWrapEl) return;
159152
- const isActive = this.searchWrapEl.classList.toggle("active");
159153
- if (isActive && this.searchInputEl) {
161167
+ const isActive2 = this.searchWrapEl.classList.toggle("active");
161168
+ if (isActive2 && this.searchInputEl) {
159154
161169
  this.searchInputEl.focus();
159155
- } else if (!isActive && this.searchInputEl) {
161170
+ } else if (!isActive2 && this.searchInputEl) {
159156
161171
  this.searchInputEl.value = "";
159157
161172
  this.controller.setSearchTerm("");
159158
161173
  this.renderCards();
@@ -160694,7 +162709,7 @@ var DEFAULT_CONFIG4 = {
160694
162709
  off: "Desligado"
160695
162710
  }
160696
162711
  };
160697
- function formatDuration2(minutes) {
162712
+ function formatDuration3(minutes) {
160698
162713
  if (minutes < 60) {
160699
162714
  return `${Math.round(minutes)}min`;
160700
162715
  }
@@ -160764,7 +162779,7 @@ function renderTimelineSVG(data, config2) {
160764
162779
  text-anchor="middle"
160765
162780
  class="${ONOFF_TIMELINE_CSS_PREFIX}__duration-label"
160766
162781
  >
160767
- ${formatDuration2(seg.durationMinutes)}
162782
+ ${formatDuration3(seg.durationMinutes)}
160768
162783
  </text>
160769
162784
  `;
160770
162785
  }
@@ -160790,7 +162805,7 @@ function renderTimelineSVG(data, config2) {
160790
162805
  data-state="${stateClass}"
160791
162806
  data-start="${formatDateTime4(seg.startTime)}"
160792
162807
  data-end="${formatDateTime4(seg.endTime)}"
160793
- data-duration="${formatDuration2(seg.durationMinutes)}"
162808
+ data-duration="${formatDuration3(seg.durationMinutes)}"
160794
162809
  data-source="${seg.source || "unknown"}"
160795
162810
  />
160796
162811
  `;
@@ -160887,7 +162902,7 @@ function renderSummary(data, labels) {
160887
162902
  </div>
160888
162903
  <div class="${ONOFF_TIMELINE_CSS_PREFIX}__summary-item">
160889
162904
  <span class="${ONOFF_TIMELINE_CSS_PREFIX}__summary-value">
160890
- ${formatDuration2(data.totalOnMinutes)}
162905
+ ${formatDuration3(data.totalOnMinutes)}
160891
162906
  </span>
160892
162907
  <span class="${ONOFF_TIMELINE_CSS_PREFIX}__summary-label">Tempo ${labels.on || "ON"}</span>
160893
162908
  </div>
@@ -161414,7 +163429,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
161414
163429
  const docTitle = buildActivationReportTitle(deviceName, opts.customerName);
161415
163430
  const issuedAt = formatIssuedAt(/* @__PURE__ */ new Date(), locale);
161416
163431
  const utilization = data.totalHours > 0 ? (data.totalOnMinutes / (data.totalHours * 60) * 100).toFixed(1) : "0.0";
161417
- const esc9 = (s) => String(s).replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c]);
163432
+ const esc10 = (s) => String(s).replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c]);
161418
163433
  const htmlContent = `
161419
163434
  <!DOCTYPE html>
161420
163435
  <html lang="pt-BR">
@@ -161466,14 +163481,14 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
161466
163481
  <div class="brand">MyIO BAS</div>
161467
163482
  <h1>Relat\xF3rio de Acionamentos</h1>
161468
163483
  <div class="meta">
161469
- <div><b>Dispositivo:</b> ${esc9(deviceName)}</div>
163484
+ <div><b>Dispositivo:</b> ${esc10(deviceName)}</div>
161470
163485
  <div><b>Per\xEDodo:</b> ${periodStart} \u2014 ${periodEnd}</div>
161471
163486
  </div>
161472
163487
  </div>
161473
163488
  ${customerName ? `
161474
163489
  <div class="customer-badge">
161475
163490
  <div class="label">Cliente</div>
161476
- <div class="value">${esc9(customerName)}</div>
163491
+ <div class="value">${esc10(customerName)}</div>
161477
163492
  </div>` : ""}
161478
163493
  </div>
161479
163494
 
@@ -161484,7 +163499,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
161484
163499
  </div>
161485
163500
  <div class="summary-card accent-green">
161486
163501
  <div class="summary-value">${formatDurationMinutes(data.totalOnMinutes)}</div>
161487
- <div class="summary-label">Tempo ${esc9(labelOn)}</div>
163502
+ <div class="summary-label">Tempo ${esc10(labelOn)}</div>
161488
163503
  </div>
161489
163504
  <div class="summary-card accent-amber">
161490
163505
  <div class="summary-value">${utilization}%</div>
@@ -161512,7 +163527,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
161512
163527
  <tr>
161513
163528
  <td>${formatDateForExport(seg.startTime, locale)}</td>
161514
163529
  <td>${formatDateForExport(seg.endTime, locale)}</td>
161515
- <td><span class="pill ${seg.state === "on" ? "pill-on" : "pill-off"}">${seg.state === "on" ? esc9(labelOn) : esc9(labelOff)}</span></td>
163530
+ <td><span class="pill ${seg.state === "on" ? "pill-on" : "pill-off"}">${seg.state === "on" ? esc10(labelOn) : esc10(labelOff)}</span></td>
161516
163531
  <td>${formatDurationMinutes(seg.durationMinutes)}</td>
161517
163532
  <td>${seg.source === "manual" ? "Manual" : seg.source === "schedule" ? "Agendamento" : seg.source === "automation" ? "Automa\xE7\xE3o" : "Desconhecido"}</td>
161518
163533
  </tr>
@@ -161521,7 +163536,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
161521
163536
  </table>
161522
163537
 
161523
163538
  <div class="footer">
161524
- <span class="issued">Emitido em ${issuedAt}</span>${customerName ? ` &middot; ${esc9(customerName)}` : ""} &middot; <span class="brand">MyIO BAS</span>
163539
+ <span class="issued">Emitido em ${issuedAt}</span>${customerName ? ` &middot; ${esc10(customerName)}` : ""} &middot; <span class="brand">MyIO BAS</span>
161525
163540
  </div>
161526
163541
  </body>
161527
163542
  </html>
@@ -165901,8 +167916,8 @@ var SidebarMenuView = class {
165901
167916
  `;
165902
167917
  }
165903
167918
  renderItem(item, section) {
165904
- const isActive = this.activeItemId === item.id;
165905
- const activeClass = isActive ? "active" : "";
167919
+ const isActive2 = this.activeItemId === item.id;
167920
+ const activeClass = isActive2 ? "active" : "";
165906
167921
  const disabledClass = item.disabled ? "disabled" : "";
165907
167922
  return `
165908
167923
  <div
@@ -165912,7 +167927,7 @@ var SidebarMenuView = class {
165912
167927
  data-action="item-click"
165913
167928
  role="menuitem"
165914
167929
  tabindex="${item.disabled ? -1 : 0}"
165915
- aria-current="${isActive ? "page" : "false"}"
167930
+ aria-current="${isActive2 ? "page" : "false"}"
165916
167931
  ${item.disabled ? 'aria-disabled="true"' : ""}
165917
167932
  >
165918
167933
  <span class="${SIDEBAR_MENU_CSS_PREFIX}__item-icon">
@@ -167511,7 +169526,7 @@ var STYLES2 = `
167511
169526
  }
167512
169527
  #${MODAL_ID5} .gcdr-fail-item:last-child { border-bottom: none; }
167513
169528
  `;
167514
- function injectStyles20() {
169529
+ function injectStyles23() {
167515
169530
  if (document.getElementById(`${MODAL_ID5}-styles`)) return;
167516
169531
  const style = document.createElement("style");
167517
169532
  style.id = `${MODAL_ID5}-styles`;
@@ -167620,7 +169635,7 @@ function escHtml4(str) {
167620
169635
  return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
167621
169636
  }
167622
169637
  async function openGCDRSyncModal(params) {
167623
- injectStyles20();
169638
+ injectStyles23();
167624
169639
  removeExistingModal();
167625
169640
  if (!params.thingsboardToken) {
167626
169641
  alert("Token ThingsBoard n\xE3o encontrado. Fa\xE7a login novamente.");
@@ -168193,7 +170208,7 @@ var STYLES3 = `
168193
170208
  .abm-confirm-btn--confirm { background: #e67e22; color: #fff; }
168194
170209
  .abm-confirm-btn--confirm:hover { background: #cf6d17; }
168195
170210
  `;
168196
- function injectStyles21() {
170211
+ function injectStyles24() {
168197
170212
  if (document.getElementById(`${MODAL_ID6}-styles`)) return;
168198
170213
  const style = document.createElement("style");
168199
170214
  style.id = `${MODAL_ID6}-styles`;
@@ -168255,7 +170270,7 @@ var DAY_NAMES = {
168255
170270
  "5": "Sex",
168256
170271
  "6": "S\xE1b"
168257
170272
  };
168258
- function formatDuration3(ms) {
170273
+ function formatDuration4(ms) {
168259
170274
  if (!ms) return "";
168260
170275
  const min = Math.round(ms / 6e4);
168261
170276
  if (min < 60) return `${min} min`;
@@ -168276,7 +170291,7 @@ function renderRuleDetailContent(rule) {
168276
170291
  }
168277
170292
  function renderRuleChips(rule) {
168278
170293
  const op = OPERATOR_LABELS2[rule.operator] ?? rule.operator;
168279
- const dur = formatDuration3(rule.duration);
170294
+ const dur = formatDuration4(rule.duration);
168280
170295
  const time = rule.startAt && rule.endAt ? `${rule.startAt} \u2013 ${rule.endAt}` : "";
168281
170296
  const agg = rule.aggregation ?? "";
168282
170297
  const chips = [
@@ -168312,7 +170327,7 @@ function openGranularValueEdit(ruleItem, rule, device, bundle, gcdrTenantId, bas
168312
170327
  const originalChipsHtml = detailEl.innerHTML;
168313
170328
  const baseRuleId = rule.parentRuleId ?? rule.id;
168314
170329
  const isOverride = !!rule.parentRuleId;
168315
- const formHtml = `
170330
+ const formHtml2 = `
168316
170331
  <div class="abm-edit-form">
168317
170332
  <div class="abm-ef-row">
168318
170333
  <span class="abm-ef-label">Valor</span>
@@ -168327,7 +170342,7 @@ function openGranularValueEdit(ruleItem, rule, device, bundle, gcdrTenantId, bas
168327
170342
  </div>
168328
170343
  </div>
168329
170344
  `;
168330
- detailEl.innerHTML = formHtml;
170345
+ detailEl.innerHTML = formHtml2;
168331
170346
  const form = detailEl.querySelector(".abm-edit-form");
168332
170347
  const valueInput = form.querySelector("#abm-ef-value");
168333
170348
  const valuePreview = form.querySelector("#abm-ef-value-preview");
@@ -168400,7 +170415,7 @@ function openFullRuleEdit(ruleItemOrDetail, rule, bundle, gcdrTenantId, baseUrl)
168400
170415
  const on = editDays[key] === true;
168401
170416
  return `<button class="abm-ef-day-btn ${on ? "on" : ""}" data-day-key="${key}" type="button">${label}</button>`;
168402
170417
  }).join("");
168403
- const formHtml = `
170418
+ const formHtml2 = `
168404
170419
  <div class="abm-edit-form">
168405
170420
  <div class="abm-ef-row" style="align-items:flex-start;">
168406
170421
  <span class="abm-ef-label">Descri\xE7\xE3o</span>
@@ -168430,7 +170445,7 @@ function openFullRuleEdit(ruleItemOrDetail, rule, bundle, gcdrTenantId, baseUrl)
168430
170445
  </div>
168431
170446
  </div>
168432
170447
  `;
168433
- detailEl.innerHTML = formHtml;
170448
+ detailEl.innerHTML = formHtml2;
168434
170449
  const form = detailEl.querySelector(".abm-edit-form");
168435
170450
  form.querySelectorAll(".abm-ef-day-btn").forEach((btn) => {
168436
170451
  btn.addEventListener("click", () => {
@@ -168872,7 +170887,7 @@ async function fetchBundle(customerTB_ID, gcdrTenantId, baseUrl) {
168872
170887
  return json.data;
168873
170888
  }
168874
170889
  async function openAlarmBundleMapModal(params) {
168875
- injectStyles21();
170890
+ injectStyles24();
168876
170891
  removeExistingModal2();
168877
170892
  if (!params.customerTB_ID) {
168878
170893
  alert("Customer TB ID n\xE3o informado. N\xE3o \xE9 poss\xEDvel carregar o mapa de alarmes.");
@@ -170042,11 +172057,11 @@ function _esc(s) {
170042
172057
  const str = s == null ? "" : String(s);
170043
172058
  return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
170044
172059
  }
170045
- var STYLE_ID15 = "ntw-styles";
172060
+ var STYLE_ID20 = "ntw-styles";
170046
172061
  function _injectStyles2() {
170047
- if (document.getElementById(STYLE_ID15)) return;
172062
+ if (document.getElementById(STYLE_ID20)) return;
170048
172063
  const s = document.createElement("style");
170049
- s.id = STYLE_ID15;
172064
+ s.id = STYLE_ID20;
170050
172065
  s.textContent = NTW_CSS;
170051
172066
  document.head.appendChild(s);
170052
172067
  }
@@ -172747,7 +174762,7 @@ var IMPORTANCE_COLORS4 = {
172747
174762
  // red
172748
174763
  };
172749
174764
  var ITEM_TEXT_MAX = 120;
172750
- function escapeHtml16(input) {
174765
+ function escapeHtml20(input) {
172751
174766
  if (input == null) return "";
172752
174767
  return String(input).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
172753
174768
  }
@@ -172785,24 +174800,24 @@ function renderAnnotationItemCard(device, annotation, searchTerm) {
172785
174800
  const domainIcon = DOMAIN_ICONS3[device.domain] ?? DOMAIN_ICONS3.unknown;
172786
174801
  const typeIcon = TYPE_ICONS[annotation.type] ?? "\xB7";
172787
174802
  const importance = Math.max(1, Math.min(5, annotation.importance || 1));
172788
- const textEscaped = escapeHtml16(truncate2(annotation.text || "", ITEM_TEXT_MAX));
172789
- const deviceLabelEscaped = escapeHtml16(device.label || device.name || device.deviceId);
172790
- const author = escapeHtml16(annotation.createdBy?.name || "sem autor");
172791
- const when = escapeHtml16(formatRelative(annotation.createdAt));
174803
+ const textEscaped = escapeHtml20(truncate2(annotation.text || "", ITEM_TEXT_MAX));
174804
+ const deviceLabelEscaped = escapeHtml20(device.label || device.name || device.deviceId);
174805
+ const author = escapeHtml20(annotation.createdBy?.name || "sem autor");
174806
+ const when = escapeHtml20(formatRelative(annotation.createdAt));
172792
174807
  const overdueTag = isOverdue(annotation) ? '<span class="myio-annotations-overdue">Vencida</span>' : "";
172793
174808
  const text2 = searchTerm ? highlightMatches(textEscaped, searchTerm) : textEscaped;
172794
174809
  const deviceLabel = searchTerm ? highlightMatches(deviceLabelEscaped, searchTerm) : deviceLabelEscaped;
172795
- const identifierEscaped = device.identifier ? escapeHtml16(device.identifier) : "";
174810
+ const identifierEscaped = device.identifier ? escapeHtml20(device.identifier) : "";
172796
174811
  const identifierHighlighted = searchTerm && identifierEscaped ? highlightMatches(identifierEscaped, searchTerm) : identifierEscaped;
172797
174812
  const identifierTag = device.identifier ? `<span class="myio-annotations-item-device">${identifierHighlighted}</span>` : "";
172798
174813
  return `
172799
174814
  <button
172800
174815
  class="myio-annotations-item"
172801
174816
  type="button"
172802
- data-device-id="${escapeHtml16(device.deviceId)}"
172803
- data-annotation-id="${escapeHtml16(annotation.id)}"
174817
+ data-device-id="${escapeHtml20(device.deviceId)}"
174818
+ data-annotation-id="${escapeHtml20(annotation.id)}"
172804
174819
  tabindex="0"
172805
- aria-label="${escapeHtml16(annotation.text)} \u2014 ${deviceLabel}"
174820
+ aria-label="${escapeHtml20(annotation.text)} \u2014 ${deviceLabel}"
172806
174821
  >
172807
174822
  <span class="myio-annotations-item-icon" aria-hidden="true">${typeIcon}</span>
172808
174823
  <div class="myio-annotations-item-body">
@@ -173009,7 +175024,7 @@ var STYLES4 = `
173009
175024
  background: #cbd5e1; border-color: #cbd5e1; cursor: not-allowed;
173010
175025
  }
173011
175026
  `;
173012
- function injectStyles22() {
175027
+ function injectStyles25() {
173013
175028
  if (typeof document === "undefined") return;
173014
175029
  if (document.getElementById(STYLES_ID4)) return;
173015
175030
  const el2 = document.createElement("style");
@@ -173019,7 +175034,7 @@ function injectStyles22() {
173019
175034
  }
173020
175035
  var _activeBackdrop = null;
173021
175036
  function openExportModal(options) {
173022
- injectStyles22();
175037
+ injectStyles25();
173023
175038
  closeExportModal();
173024
175039
  const backdrop = document.createElement("div");
173025
175040
  backdrop.className = `${MODAL_DOM_ID}-backdrop`;
@@ -173779,8 +175794,8 @@ var HeaderAnnotationsPanel = class _HeaderAnnotationsPanel {
173779
175794
  // group header
173780
175795
  render: () => `
173781
175796
  <header class="myio-annotations-group-header ${groupClass}">
173782
- ${g.icon ? `<span class="myio-annotations-group-icon" aria-hidden="true">${escapeHtml16(g.icon)}</span>` : ""}
173783
- <span class="myio-annotations-group-label">${escapeHtml16(g.label)}</span>
175797
+ ${g.icon ? `<span class="myio-annotations-group-icon" aria-hidden="true">${escapeHtml20(g.icon)}</span>` : ""}
175798
+ <span class="myio-annotations-group-label">${escapeHtml20(g.label)}</span>
173784
175799
  <span class="myio-annotations-group-count">${g.totalAnnotations}</span>
173785
175800
  </header>`
173786
175801
  });
@@ -173905,9 +175920,9 @@ ${this._renderToolbar(filteredCount, totalAllUnfiltered)}
173905
175920
  }
173906
175921
  _renderToolbar(filteredCount, totalCount) {
173907
175922
  const sortOptions = SORT_OPTIONS.map(
173908
- (o) => `<option value="${o.key}" ${o.key === this.sortBy ? "selected" : ""}>${escapeHtml16(o.label)}</option>`
175923
+ (o) => `<option value="${o.key}" ${o.key === this.sortBy ? "selected" : ""}>${escapeHtml20(o.label)}</option>`
173909
175924
  ).join("");
173910
- const term = escapeHtml16(this.filter.searchTerm || "");
175925
+ const term = escapeHtml20(this.filter.searchTerm || "");
173911
175926
  const filtersActiveCount = this._activeFilterCount();
173912
175927
  const filterIndicator = filtersActiveCount > 0 ? `<span class="myio-annotations-group-count">${filtersActiveCount}</span>` : "";
173913
175928
  const showingHtml = filteredCount === totalCount ? `${totalCount} anota\xE7\xF5es` : `${filteredCount} de ${totalCount} anota\xE7\xF5es`;
@@ -173948,13 +175963,13 @@ ${this._renderToolbar(filteredCount, totalAllUnfiltered)}
173948
175963
  const typesHtml = FILTER_TYPE_OPTIONS.map(
173949
175964
  (t) => `<label class="myio-annotations-filter-chip ${this.filter.types.has(t.id) ? "is-on" : ""}">
173950
175965
  <input type="checkbox" data-filter="type" value="${t.id}" ${this.filter.types.has(t.id) ? "checked" : ""} />
173951
- <span>${t.icon} ${escapeHtml16(t.label)}</span>
175966
+ <span>${t.icon} ${escapeHtml20(t.label)}</span>
173952
175967
  </label>`
173953
175968
  ).join("");
173954
175969
  const statusHtml = FILTER_STATUS_OPTIONS.map(
173955
175970
  (s) => `<label class="myio-annotations-filter-chip ${this.filter.statuses.has(s.id) ? "is-on" : ""}">
173956
175971
  <input type="checkbox" data-filter="status" value="${s.id}" ${this.filter.statuses.has(s.id) ? "checked" : ""} />
173957
- <span>${escapeHtml16(s.label)}</span>
175972
+ <span>${escapeHtml20(s.label)}</span>
173958
175973
  </label>`
173959
175974
  ).join("");
173960
175975
  const impHtml = [1, 2, 3, 4, 5].map(
@@ -174031,12 +176046,12 @@ ${this._renderToolbar(filteredCount, totalAllUnfiltered)}
174031
176046
  return `
174032
176047
  <section class="${groupClass}">
174033
176048
  <header class="myio-annotations-group-header" role="button" tabindex="0"
174034
- data-group-toggle="${escapeHtml16(group.key)}"
176049
+ data-group-toggle="${escapeHtml20(group.key)}"
174035
176050
  aria-expanded="${!isCollapsed}"
174036
176051
  title="${isCollapsed ? "Expandir grupo" : "Recolher grupo"}">
174037
176052
  <span class="myio-annotations-group-chevron" aria-hidden="true">${isCollapsed ? "\u25B6" : "\u25BC"}</span>
174038
- ${group.icon ? `<span class="myio-annotations-group-icon" aria-hidden="true">${escapeHtml16(group.icon)}</span>` : ""}
174039
- <span class="myio-annotations-group-label">${escapeHtml16(group.label)}</span>
176053
+ ${group.icon ? `<span class="myio-annotations-group-icon" aria-hidden="true">${escapeHtml20(group.icon)}</span>` : ""}
176054
+ <span class="myio-annotations-group-label">${escapeHtml20(group.label)}</span>
174040
176055
  <span class="myio-annotations-group-count">${group.totalAnnotations}</span>
174041
176056
  </header>
174042
176057
  ${itemsHtml}
@@ -174578,7 +176593,7 @@ function prefixForProductType(productType) {
174578
176593
  if (entry) return entry.prefix;
174579
176594
  return `T${productType}`;
174580
176595
  }
174581
- function pad24(n) {
176596
+ function pad25(n) {
174582
176597
  return String(n).padStart(2, "0");
174583
176598
  }
174584
176599
  function pad4(n) {
@@ -174586,9 +176601,9 @@ function pad4(n) {
174586
176601
  }
174587
176602
  function deviceProductCodeToName(value) {
174588
176603
  const prefix = prefixForProductType(value.productType);
174589
- const yy = pad24(value.year % 100);
174590
- const mm = pad24(value.month);
174591
- const dd = pad24(value.day);
176604
+ const yy = pad25(value.year % 100);
176605
+ const mm = pad25(value.month);
176606
+ const dd = pad25(value.day);
174592
176607
  const unit = value.seq3 * 254 + value.seq;
174593
176608
  return `${prefix} ${yy}${mm}${dd}-${pad4(unit)}`;
174594
176609
  }
@@ -174697,7 +176712,7 @@ function validateDeviceProductCode(code) {
174697
176712
  }
174698
176713
 
174699
176714
  // src/components/cards/central-status/v1.0.0/styles.ts
174700
- var STYLE_ID16 = "myio-central-status-card-styles";
176715
+ var STYLE_ID21 = "myio-central-status-card-styles";
174701
176716
  var CSS5 = `
174702
176717
  .myio-cscard{
174703
176718
  --cscard-surface:#ffffff;
@@ -175000,9 +177015,9 @@ var CSS5 = `
175000
177015
  `;
175001
177016
  function injectCentralStatusCardStyles() {
175002
177017
  if (typeof document === "undefined") return;
175003
- if (document.getElementById(STYLE_ID16)) return;
177018
+ if (document.getElementById(STYLE_ID21)) return;
175004
177019
  const tag = document.createElement("style");
175005
- tag.id = STYLE_ID16;
177020
+ tag.id = STYLE_ID21;
175006
177021
  tag.textContent = CSS5;
175007
177022
  document.head.appendChild(tag);
175008
177023
  }
@@ -175062,7 +177077,7 @@ function deriveCentralConnectivity(ev, opts) {
175062
177077
  }
175063
177078
 
175064
177079
  // src/components/cards/central-status/v1.0.0/TimelineModal.ts
175065
- var STYLE_ID17 = "myio-cscard-timeline-styles";
177080
+ var STYLE_ID22 = "myio-cscard-timeline-styles";
175066
177081
  var DEFAULT_PERIODS = [1, 7, 30, 90];
175067
177082
  function escAttr5(s) {
175068
177083
  return String(s ?? "").replace(
@@ -175071,9 +177086,9 @@ function escAttr5(s) {
175071
177086
  );
175072
177087
  }
175073
177088
  function injectTimelineModalStyles() {
175074
- if (typeof document === "undefined" || document.getElementById(STYLE_ID17)) return;
177089
+ if (typeof document === "undefined" || document.getElementById(STYLE_ID22)) return;
175075
177090
  const tag = document.createElement("style");
175076
- tag.id = STYLE_ID17;
177091
+ tag.id = STYLE_ID22;
175077
177092
  tag.textContent = `
175078
177093
  .myio-tlmodal{
175079
177094
  --tl-online:#3b82f6;
@@ -175412,7 +177427,7 @@ function formatSince(iso, nowMs, language) {
175412
177427
  else rel = `${Math.round(s / 86400)}d`;
175413
177428
  return `${abs} (${rel})`;
175414
177429
  }
175415
- function formatDuration4(ms) {
177430
+ function formatDuration5(ms) {
175416
177431
  const totalMin = Math.max(0, Math.round(ms / 6e4));
175417
177432
  const hours = Math.floor(totalMin / 60);
175418
177433
  const minutes = totalMin % 60;
@@ -175750,7 +177765,7 @@ var CentralStatusCard = class _CentralStatusCard {
175750
177765
  this.el.removeAttribute("draggable");
175751
177766
  }
175752
177767
  this.el.style.zoom = p.scale && p.scale !== 1 ? String(p.scale) : "";
175753
- const connLabel = l.connectivityValue?.[connectivity] || (pastHard && sinceSuccessMs != null ? `${CONNECTIVITY_VALUE_DEFAULT.OFFLINE} ${formatDuration4(sinceSuccessMs)}` : CONNECTIVITY_VALUE_DEFAULT[connectivity]);
177768
+ const connLabel = l.connectivityValue?.[connectivity] || (pastHard && sinceSuccessMs != null ? `${CONNECTIVITY_VALUE_DEFAULT.OFFLINE} ${formatDuration5(sinceSuccessMs)}` : CONNECTIVITY_VALUE_DEFAULT[connectivity]);
175754
177769
  const staleBadge = stale ? `<span class="myio-cscard__stale">${STALE_BADGE_TEXT[this.language()]}</span>` : "";
175755
177770
  const divergenceGlyph = (() => {
175756
177771
  const o = p.icons?.divergence;
@@ -176358,9 +178373,12 @@ var version = package_default.version || "0.0.0";
176358
178373
  IMPORTANCE_COLORS,
176359
178374
  IMPORTANCE_LABELS,
176360
178375
  IMPORTANCE_LABELS_EN,
178376
+ ImportApiError,
176361
178377
  InfoTooltip,
176362
178378
  LoadingSpinner,
176363
178379
  LogHelper,
178380
+ MANUAL_ASSET_SUFFIX,
178381
+ MANUAL_DEVICE_PROFILES,
176364
178382
  MEASUREMENT_DOMAIN_CONFIG,
176365
178383
  MENU_SHOPPING_CSS_PREFIX,
176366
178384
  METRO_TILE_COLORS,
@@ -176371,6 +178389,7 @@ var version = package_default.version || "0.0.0";
176371
178389
  MYIO_ACCENT,
176372
178390
  MYIO_CHART_PALETTE,
176373
178391
  MYIO_CHART_PALETTE_DARK,
178392
+ ManualDeviceError,
176374
178393
  MenuController,
176375
178394
  MenuShoppingView,
176376
178395
  MenuView,
@@ -176412,6 +178431,7 @@ var version = package_default.version || "0.0.0";
176412
178431
  POWER_LIMITS_DEVICE_TYPES,
176413
178432
  POWER_LIMITS_STATUS_CONFIG,
176414
178433
  POWER_LIMITS_TELEMETRY_TYPES,
178434
+ PUMP_POWER_KEY,
176415
178435
  REPORT_MONEY_HEADER,
176416
178436
  SCHEDULE_HOLIDAY_CSS_PREFIX,
176417
178437
  SCHEDULE_IR_CSS_PREFIX,
@@ -176464,6 +178484,7 @@ var version = package_default.version || "0.0.0";
176464
178484
  TempSensorSummaryTooltip,
176465
178485
  Temperature,
176466
178486
  UsersSummaryTooltip,
178487
+ VALVE_STATE_KEYS,
176467
178488
  VARIANCE_LABEL_ABOVE,
176468
178489
  VARIANCE_LABEL_BELOW,
176469
178490
  VARIANCE_LABEL_ONTARGET,
@@ -176511,6 +178532,7 @@ var version = package_default.version || "0.0.0";
176511
178532
  buildMoneyVarianceHTML,
176512
178533
  buildMyioIngestionAuth,
176513
178534
  buildReportItemsList,
178535
+ buildTemplateCsv,
176514
178536
  buildTemplateExport,
176515
178537
  buildTicketServiceOrchestrator,
176516
178538
  buildVerdictHTML,
@@ -176586,6 +178608,7 @@ var version = package_default.version || "0.0.0";
176586
178608
  createDistributionChartWidget,
176587
178609
  createDivCard,
176588
178610
  createEnergyPanelComponent,
178611
+ createEquipmentIndicatorStrip,
176589
178612
  createErrorSpan,
176590
178613
  createExportButton,
176591
178614
  createFakeDeviceCategoryPort,
@@ -176609,6 +178632,7 @@ var version = package_default.version || "0.0.0";
176609
178632
  createLibraryVersionChecker,
176610
178633
  createLoadingSpinner,
176611
178634
  createLogHelper,
178635
+ createManualDevice,
176612
178636
  createMenuComponent,
176613
178637
  createMenuShoppingComponent,
176614
178638
  createModalFooter,
@@ -176645,6 +178669,7 @@ var version = package_default.version || "0.0.0";
176645
178669
  createTbEnvelopeStore,
176646
178670
  createTelemetryGridComponent,
176647
178671
  createTelemetryGridShoppingComponent,
178672
+ createTelemetryImportApi,
176648
178673
  createTelemetryInfoShoppingComponent,
176649
178674
  createTicketDetailModal,
176650
178675
  createTicketsTab,
@@ -176812,6 +178837,7 @@ var version = package_default.version || "0.0.0";
176812
178837
  hasCoverageGaps,
176813
178838
  hasSelectedDays,
176814
178839
  highlightAnnotationMatches,
178840
+ indicatorsFromModalData,
176815
178841
  initMyIOAuthContext,
176816
178842
  initOnOffTimelineTooltips,
176817
178843
  injectActionButtonStyles,
@@ -176848,6 +178874,7 @@ var version = package_default.version || "0.0.0";
176848
178874
  injectSolenoidControlStyles,
176849
178875
  injectSwitchControlStyles,
176850
178876
  interpolateTemperature,
178877
+ intervalsFromTelemetry,
176851
178878
  inventory,
176852
178879
  isAlarmActive,
176853
178880
  isAnnotationOverdue,
@@ -176877,10 +178904,12 @@ var version = package_default.version || "0.0.0";
176877
178904
  isValidTimeFormat,
176878
178905
  isWaterCategory,
176879
178906
  latestHourlyTemperature,
178907
+ latestPowerKw,
176880
178908
  liftProfileToTree,
176881
178909
  listDeviceProductTypes,
176882
178910
  listDomains,
176883
178911
  listGroups,
178912
+ manualDeviceName,
176884
178913
  mapConnectionStatus,
176885
178914
  mapDeviceStatusToCardStatus,
176886
178915
  mapDeviceToConnectionStatus,
@@ -176889,6 +178918,7 @@ var version = package_default.version || "0.0.0";
176889
178918
  minutesToMs,
176890
178919
  msToMinutes,
176891
178920
  myioExportData,
178921
+ nextManualSeq,
176892
178922
  nfdNormalizeAnnotationSearch,
176893
178923
  normalizeBudgetBlock,
176894
178924
  normalizeConnectionStatus,
@@ -176926,6 +178956,7 @@ var version = package_default.version || "0.0.0";
176926
178956
  openGoalsPanel,
176927
178957
  openHelpModal,
176928
178958
  openIntegrationsModal,
178959
+ openManualDeviceModal,
176929
178960
  openMeasurementSetupModal,
176930
178961
  openMessageDialog,
176931
178962
  openMetasGuide,
@@ -176938,6 +178969,8 @@ var version = package_default.version || "0.0.0";
176938
178969
  openRealTimeTelemetryModal,
176939
178970
  openReportsHub,
176940
178971
  openSettingsHubModal,
178972
+ openStandardModal,
178973
+ openTelemetryImportModal,
176941
178974
  openTemperatureComparisonModal,
176942
178975
  openTemperatureModal,
176943
178976
  openTemperatureSettingsModal,
@@ -176945,17 +178978,21 @@ var version = package_default.version || "0.0.0";
176945
178978
  openUpsellModal,
176946
178979
  openUserManagementModal,
176947
178980
  openWelcomeModal,
178981
+ openWellPumpsModal,
176948
178982
  overlayWithholdsVerdict,
176949
178983
  panelCategoryToWire,
176950
178984
  panelDomainToWire,
176951
178985
  panelTermToDeviceCategory,
178986
+ parseBinaryState,
176952
178987
  parseClassificationEntities,
178988
+ parseCsv,
176953
178989
  parseGcdrEnergyRoot,
176954
178990
  parseGcdrEntityForest,
176955
178991
  parseInputDateToDate,
176956
178992
  parseLogAnnotations,
176957
178993
  periodKey,
176958
178994
  pickUniqueCustomerCode,
178995
+ pumpHistoryFromConsumption,
176959
178996
  readFreshdeskTicketsFromTB,
176960
178997
  recalculateDeviceStatus,
176961
178998
  recomputeDeviceGridPercentages,
@@ -176983,6 +179020,8 @@ var version = package_default.version || "0.0.0";
176983
179020
  renderDashboardDowntimeList,
176984
179021
  renderDeviceGridList,
176985
179022
  renderDualLineChart,
179023
+ renderEquipmentShortcutHTML,
179024
+ renderEquipmentTilesHTML,
176986
179025
  renderFinancialIndicators,
176987
179026
  renderGatedMoney,
176988
179027
  renderKPICards,
@@ -177007,6 +179046,7 @@ var version = package_default.version || "0.0.0";
177007
179046
  resolveSubcategory,
177008
179047
  resolveWithFallback,
177009
179048
  routeMoneyRender,
179049
+ rowsFromTable,
177010
179050
  schedCreateDateInput,
177011
179051
  schedCreateNumberInput,
177012
179052
  schedCreateSelect,
@@ -177018,6 +179058,7 @@ var version = package_default.version || "0.0.0";
177018
179058
  setActiveProfile,
177019
179059
  shouldFlashIcon,
177020
179060
  shouldVirtualizeAnnotationList,
179061
+ siglaFromManualAsset,
177021
179062
  signOf,
177022
179063
  slugifyCustomerName,
177023
179064
  sortAnnotationGroups,
@@ -177047,6 +179088,7 @@ var version = package_default.version || "0.0.0";
177047
179088
  validateDeviceProductName,
177048
179089
  validateProfile,
177049
179090
  validateTree,
179091
+ valveHistoryFromTelemetry,
177050
179092
  version,
177051
179093
  waterDeviceStatusIcons,
177052
179094
  wireCategoryToPanel,