matter-all-in-one-addon 2.3.13 → 2.3.18

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.
Files changed (95) hide show
  1. package/README.md +18 -12
  2. package/dist/camera/browser-preview.js +12 -10
  3. package/dist/camera/browser-preview.js.map +1 -1
  4. package/dist/camera/homekit/homekit-camera-recording.delegate.d.ts +5 -0
  5. package/dist/camera/homekit/homekit-camera-recording.delegate.js +14 -0
  6. package/dist/camera/homekit/homekit-camera-recording.delegate.js.map +1 -1
  7. package/dist/camera/homekit/homekit-camera-stream.delegate.d.ts +8 -2
  8. package/dist/camera/homekit/homekit-camera-stream.delegate.js +113 -49
  9. package/dist/camera/homekit/homekit-camera-stream.delegate.js.map +1 -1
  10. package/dist/camera/homekit/homekit-camera.accessory.js +17 -3
  11. package/dist/camera/homekit/homekit-camera.accessory.js.map +1 -1
  12. package/dist/camera/homekit/tuya-hap-talkback.d.ts +1 -0
  13. package/dist/camera/homekit/tuya-hap-talkback.js +11 -8
  14. package/dist/camera/homekit/tuya-hap-talkback.js.map +1 -1
  15. package/dist/camera/matter/camera-endpoint.builder.js +31 -18
  16. package/dist/camera/matter/camera-endpoint.builder.js.map +1 -1
  17. package/dist/converters/binary_sensor.converter.d.ts +1 -1
  18. package/dist/converters/binary_sensor.converter.js +2 -2
  19. package/dist/converters/climate.converter.d.ts +14 -1
  20. package/dist/converters/climate.converter.js +44 -2
  21. package/dist/converters/climate.converter.js.map +1 -1
  22. package/dist/converters/sensor.converter.js +6 -6
  23. package/dist/converters/sensor.converter.js.map +1 -1
  24. package/dist/device-profiles.js +33 -2
  25. package/dist/device-profiles.js.map +1 -1
  26. package/dist/device-registry.js +12 -0
  27. package/dist/device-registry.js.map +1 -1
  28. package/dist/entities/air_quality.entity.js +24 -1
  29. package/dist/entities/air_quality.entity.js.map +1 -1
  30. package/dist/entities/base.entity.js +25 -5
  31. package/dist/entities/base.entity.js.map +1 -1
  32. package/dist/entities/climate.entity.d.ts +23 -0
  33. package/dist/entities/climate.entity.js +174 -0
  34. package/dist/entities/climate.entity.js.map +1 -0
  35. package/dist/entities/closure.entity.js +24 -1
  36. package/dist/entities/closure.entity.js.map +1 -1
  37. package/dist/entities/composite-device.entity.js +23 -7
  38. package/dist/entities/composite-device.entity.js.map +1 -1
  39. package/dist/entities/cooktop.entity.d.ts +1 -0
  40. package/dist/entities/cooktop.entity.js +18 -3
  41. package/dist/entities/cooktop.entity.js.map +1 -1
  42. package/dist/entities/energy_tariff.entity.js +16 -4
  43. package/dist/entities/energy_tariff.entity.js.map +1 -1
  44. package/dist/entities/humidifier.entity.d.ts +3 -0
  45. package/dist/entities/humidifier.entity.js +61 -45
  46. package/dist/entities/humidifier.entity.js.map +1 -1
  47. package/dist/entities/lock.entity.js +9 -5
  48. package/dist/entities/lock.entity.js.map +1 -1
  49. package/dist/entities/oven.entity.d.ts +2 -0
  50. package/dist/entities/oven.entity.js +50 -8
  51. package/dist/entities/oven.entity.js.map +1 -1
  52. package/dist/entities/soil_sensor.entity.js +2 -1
  53. package/dist/entities/soil_sensor.entity.js.map +1 -1
  54. package/dist/entities/vacuum.entity.js +4 -4
  55. package/dist/entities/vacuum.entity.js.map +1 -1
  56. package/dist/entities/valve.entity.js +29 -5
  57. package/dist/entities/valve.entity.js.map +1 -1
  58. package/dist/frontend/assets/CameraConfigModal-DnDZbkpj.js +6 -0
  59. package/dist/frontend/assets/CameraUiModal-DVCgRtyT.js +1 -0
  60. package/dist/frontend/assets/DeviceModal-DFgXDEzB.js +5 -0
  61. package/dist/frontend/assets/QRCodeDisplay-B3RFLtWz.js +8 -0
  62. package/dist/frontend/assets/ScryptedModal-DZ4B2NLt.js +1 -0
  63. package/dist/frontend/assets/SettingsModal-BBflJWuJ.js +2 -0
  64. package/dist/frontend/assets/clipboard-CnKYMNaq.js +1 -0
  65. package/dist/frontend/assets/index-CONl6ATp.js +10 -0
  66. package/dist/frontend/index.html +1 -1
  67. package/dist/hap/hap-generic-accessory.d.ts +6 -0
  68. package/dist/hap/hap-generic-accessory.js +641 -26
  69. package/dist/hap/hap-generic-accessory.js.map +1 -1
  70. package/dist/homeAssistant.d.ts +1 -0
  71. package/dist/homeAssistant.js +40 -1
  72. package/dist/homeAssistant.js.map +1 -1
  73. package/dist/mqtt/mqtt-client.d.ts +2 -0
  74. package/dist/mqtt/mqtt-client.js +44 -2
  75. package/dist/mqtt/mqtt-client.js.map +1 -1
  76. package/dist/mqtt/mqtt.entity.d.ts +12 -0
  77. package/dist/mqtt/mqtt.entity.js +231 -82
  78. package/dist/mqtt/mqtt.entity.js.map +1 -1
  79. package/dist/platform.d.ts +2 -0
  80. package/dist/platform.js +111 -37
  81. package/dist/platform.js.map +1 -1
  82. package/dist/proxy.js +13 -1
  83. package/dist/proxy.js.map +1 -1
  84. package/dist/utils/hap-firmware.js +1 -1
  85. package/dist/utils/hap-firmware.js.map +1 -1
  86. package/dist/utils/matter-command-response.js +64 -44
  87. package/dist/utils/matter-command-response.js.map +1 -1
  88. package/dist/utils/matter-reset-storage.d.ts +2 -0
  89. package/dist/utils/matter-reset-storage.js +74 -0
  90. package/dist/utils/matter-reset-storage.js.map +1 -0
  91. package/dist/utils/measurements.d.ts +8 -0
  92. package/dist/utils/measurements.js +42 -0
  93. package/dist/utils/measurements.js.map +1 -0
  94. package/package.json +17 -17
  95. package/dist/frontend/assets/index-1k-iTL-m.js +0 -26
@@ -1 +1 @@
1
- {"version":3,"file":"valve.entity.js","sourceRoot":"","sources":["../../src/entities/valve.entity.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAI9C,OAAO,EACL,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,+BAA+B,CAAC;AAEvC,MAAM,CAAC,MAAM,8BAA8B,GAAG,MAA0B,CAAC;AAEzE,MAAM,OAAO,WAAY,SAAQ,UAAU;IAClC,MAAM,CAAU,eAAe,GAAG,YAAY,CAAC;IAEnC,qBAAqB;QACtC,MAAM,QAAQ,GAAG,KAAK,CAAC,qBAAqB,EAAE,CAAC;QAC/C,QAAQ,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;QAC9C,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEe,KAAK,CAAC,WAAW,CAC/B,KAAgB,EAChB,aAAa,GAAG,KAAK;QAErB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,OAAO;QAE3B,MAAM,QAAQ,GAAG,aAAa,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,mBAAmB,CAAC;QACxE,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,KAAK,MAAM,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC;QACnE,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,uBAAuB;QAE1D,MAAM,QAAQ,CACZ,IAAI,CAAC,QAAQ,EACb,8BAA8B,EAC9B,cAAc,EACd,UAAU,EACV,IAAI,CAAC,QAAQ,CAAC,GAAG,CAClB,CAAC;QAEF,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,EAAE,gBAAgB,CAAC;QACpD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;YAChD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YACvE,MAAM,QAAQ,CACZ,IAAI,CAAC,QAAQ,EACb,8BAA8B,EAC9B,cAAc,EACd,KAAK,EACL,IAAI,CAAC,QAAQ,CAAC,GAAG,CAClB,CAAC;QACJ,CAAC;IACH,CAAC;IAEkB,uBAAuB,CACxC,QAA+B;QAE/B,MAAM,cAAc,GAAG,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC;QACjD,IAAI,CAAC,cAAc;YAAE,OAAO;QAE5B,cAAc,CAAC,iBAAiB,CAAC,MAAM,EAAE,KAAK,EAAE,IAAS,EAAE,EAAE;YAC3D,MAAM,QAAQ,GAAG,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC;YAC5C,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;gBAChD,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,CACjC,OAAO,EACP,oBAAoB,EACpB,IAAI,CAAC,QAAQ,EACb,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,CAC/B,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,CACjC,OAAO,EACP,YAAY,EACZ,IAAI,CAAC,QAAQ,CACd,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,cAAc,CAAC,iBAAiB,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE;YACnD,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,CACjC,OAAO,EACP,aAAa,EACb,IAAI,CAAC,QAAQ,CACd,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
1
+ {"version":3,"file":"valve.entity.js","sourceRoot":"","sources":["../../src/entities/valve.entity.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAI9C,OAAO,EACL,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,+BAA+B,CAAC;AAEvC,MAAM,CAAC,MAAM,8BAA8B,GAAG,MAA0B,CAAC;AAEzE,MAAM,OAAO,WAAY,SAAQ,UAAU;IAClC,MAAM,CAAU,eAAe,GAAG,YAAY,CAAC;IAEnC,qBAAqB;QACtC,MAAM,QAAQ,GAAG,KAAK,CAAC,qBAAqB,EAAE,CAAC;QAC/C,QAAQ,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;QAC9C,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEe,KAAK,CAAC,WAAW,CAC/B,KAAgB,EAChB,aAAa,GAAG,KAAK;QAErB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,OAAO;QAE3B,MAAM,QAAQ,GAAG,aAAa,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,mBAAmB,CAAC;QACxE,MAAM,WAAW,GAA2B;YAC1C,MAAM,EAAE,CAAC;YACT,IAAI,EAAE,CAAC;YACP,OAAO,EAAE,CAAC;YACV,OAAO,EAAE,CAAC;SACX,CAAC;QACF,MAAM,UAAU,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5C,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,QAAQ,CACZ,IAAI,CAAC,QAAQ,EACb,8BAA8B,EAC9B,cAAc,EACd,UAAU,EACV,IAAI,CAAC,QAAQ,CAAC,GAAG,CAClB,CAAC;QACJ,CAAC;QAED,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,EAAE,gBAAgB,CAAC;QACpD,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9D,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YACvE,MAAM,QAAQ,CACZ,IAAI,CAAC,QAAQ,EACb,8BAA8B,EAC9B,cAAc,EACd,KAAK,EACL,IAAI,CAAC,QAAQ,CAAC,GAAG,CAClB,CAAC;QACJ,CAAC;IACH,CAAC;IAEkB,uBAAuB,CACxC,QAA+B;QAE/B,MAAM,cAAc,GAAG,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC;QACjD,IAAI,CAAC,cAAc;YAAE,OAAO;QAE5B,cAAc,CAAC,iBAAiB,CAAC,MAAM,EAAE,KAAK,EAAE,IAAS,EAAE,EAAE;YAC3D,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,MAAM,OAAO,GAAG,IAAI,EAAE,OAAO,IAAI,IAAI,IAAI,EAAE,CAAC;YAC5C,qFAAqF;YACrF,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,IAAI,OAAO,CAAC,YAAY,KAAK,IAAI;gBACrE,MAAM,IAAI,KAAK,CACb,0DAA0D,CAC3D,CAAC;YACJ,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC;YACrC,IACE,QAAQ,KAAK,SAAS;gBACtB,QAAQ,KAAK,IAAI;gBACjB,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC,IAAI,QAAQ,GAAG,GAAG,CAAC;gBAE9D,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;YACzC,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;gBAChD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,kBAAkB,CAAC;gBAC3D,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,EAAE,CAAC;oBACpD,IAAI,QAAQ,KAAK,GAAG;wBAClB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;oBACxD,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,CACjC,OAAO,EACP,YAAY,EACZ,IAAI,CAAC,QAAQ,CACd,CAAC;oBACF,OAAO;gBACT,CAAC;gBACD,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,CACjC,OAAO,EACP,oBAAoB,EACpB,IAAI,CAAC,QAAQ,EACb,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,CAC/B,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,CACjC,OAAO,EACP,YAAY,EACZ,IAAI,CAAC,QAAQ,CACd,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,cAAc,CAAC,iBAAiB,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE;YACnD,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,WAAW,CACjC,OAAO,EACP,aAAa,EACb,IAAI,CAAC,QAAQ,CACd,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ import{i as e,n as t,o as n,r,t as i}from"./index-CONl6ATp.js";import{n as a,t as o}from"./QRCodeDisplay-B3RFLtWz.js";import{t as s}from"./clipboard-CnKYMNaq.js";var c=n(e(),1),l=t();function u(e,t){try{let n=(parseInt(String(e).replace(/-/g,``),10)|-1879048192)>>>0,r=(BigInt(8)*4294967296n+BigInt(n)).toString(36).toUpperCase();for(;r.length<9;)r=`0`+r;return`X-HM://${r}${t.substring(0,4).toUpperCase().padStart(4,`S`)}`}catch{return`X-HM://00GW95DQA${t.substring(0,4).toUpperCase().padStart(4,`S`)}`}}function d(e){if(!e||typeof e!=`string`)return``;let t=e.trim(),n=t.match(/^([a-zA-Z0-9_+.-]+:\/\/)/);if(!n)return t;let r=n[1],i=t.substring(r.length),a=i.indexOf(`/`),o=i.indexOf(`?`),s=a===-1?o===-1?i.length:o:a,c=i.substring(0,s),l=i.substring(s),u=c.lastIndexOf(`@`);if(u===-1)return t;let d=c.substring(0,u),f=c.substring(u+1),p=d.indexOf(`:`);if(p===-1)return`${r}${encodeURIComponent(decodeURIComponent(d))}@${f}${l}`;let m=d.substring(0,p),h=d.substring(p+1);return`${r}${encodeURIComponent(decodeURIComponent(m))}:${encodeURIComponent(decodeURIComponent(h))}@${f}${l}`}var f=({camera:e,onClose:t,onRefresh:n,showToast:f})=>{let[p,m]=(0,c.useState)(`homekit`),[h,g]=(0,c.useState)(``),[_,ee]=(0,c.useState)(`tcp`),[v,te]=(0,c.useState)(!1),[ne,re]=(0,c.useState)(!1),[ie,ae]=(0,c.useState)(!1),[oe,se]=(0,c.useState)(!1),[y,b]=(0,c.useState)(null),[x,S]=(0,c.useState)(!1),[C,ce]=(0,c.useState)(null),[le,ue]=(0,c.useState)(!1),[w,de]=(0,c.useState)(null),[fe,pe]=(0,c.useState)(null),[T,me]=(0,c.useState)(!1),[E,D]=(0,c.useState)(``),[he,ge]=(0,c.useState)(!1),[_e,ve]=(0,c.useState)(null),[ye,be]=(0,c.useState)(null),[xe,Se]=(0,c.useState)({}),[Ce,O]=(0,c.useState)({}),[k,A]=(0,c.useState)({enabled:!0,targets:[`person`,`dog`,`cat`,`bird`,`raccoon`,`snake`,`spider`],sensitivity:85,motionTimeoutSeconds:15,publishMqtt:!0}),[we,Te]=(0,c.useState)(null),[Ee,De]=(0,c.useState)(!1),[Oe,ke]=(0,c.useState)(!1),[Ae,j]=(0,c.useState)(null),[M,je]=(0,c.useState)(null),N=e&&(`cameraId`in e?e.cameraId:e.id),P=Ae&&Ae.cameraId===N?Ae.id:null;(0,c.useEffect)(()=>{j(e=>e?.cameraId===N?e:null)},[N]),(0,c.useEffect)(()=>{if(!P||!N)return;let e=N,t=new AbortController,n=setTimeout(()=>j(null),9e4),r=setInterval(()=>{fetch(`./api/custom/cameras/${encodeURIComponent(e)}/preview/status?session=${P}`,{signal:t.signal}).then(e=>e.json()).then(e=>{t.signal.aborted||je(e)}).catch(()=>{})},1e3);return()=>{clearTimeout(n),clearInterval(r),t.abort(),je(null),ke(!1)}},[P,N]);let[Me,Ne]=(0,c.useState)(`auto`),[Pe,Fe]=(0,c.useState)(`auto`),[Ie,Le]=(0,c.useState)(`auto`),[Re,ze]=(0,c.useState)(`auto`),[Be,Ve]=(0,c.useState)(!1),F=!!(e&&`id`in e&&!(`cameraId`in e)),I=e?`cameraId`in e?e.cameraId:e.id:``,L=e?.name||``;(0,c.useEffect)(()=>{if(!e)return;let t=e?.lightEntityId||`auto`,n=e?.sirenEntityId||`auto`,i=e?.motionEntityId||`auto`,a=e?.exportConfig?.exportMode||e?.exportMode||`auto`;Ne(t),Fe(n),Le(i),ze(a),ce(null);let o=``,s=`tcp`,c=``;if(F){let t=e;if(o=t.rtspUrl||``,c=t.model||``,D(c),g(o),ee(`tcp`),de(null),pe(null),ue(!1),t.videoCodecSource===`ffprobe`&&t.codecProbeUrl===o&&t.codecProbedAt&&t.width&&t.height){S(!0);let e=t.width,n=t.height,r=(t.videoCodec||`desconocido`).toUpperCase(),i=t.fps||`—`,a=t.hasAudio?`Con Audio (${t.audioCodec||`códec no medido`})`:`Sin Audio`;b({text:`✓ RTSP medido por ffprobe (${r} ${e}x${n} @ ${i}fps, ${a}).`})}else o?(S(!1),b({text:`ℹ️ Sin medición ffprobe vigente para esta URL. Pulsa 'Verificar Stream' para comprobar el códec real entregado por RTSP.`})):(S(!1),b({text:`ℹ️ Sin URL de stream RTSP directa configurada.`,isError:!0}))}else{let t=e;o=t.source?.streamReference?.directUrl||t.source?.profiles?.find(e=>e.directUrl)?.directUrl||``,s=t.exportConfig?.rtspTransportPreference||`tcp`,c=t.displayModel||t.model||``,D(c),g(o),ee(s),de(null),pe(null),ue(!1);let n=t.capabilities?.observed;if((t.source?.streamValidationStatus===`verified`||t.source?.streamReference?.validationStatus===`verified`)&&n){S(!0);let e=n.resolution?.width||`No medido`,t=n.resolution?.height||`No medido`,r=(n.videoCodec||`No medido`).toUpperCase(),i=n.fps||`No medido`,a=n.hasAudio===!1?`Sin Audio`:`Con Audio`;b({text:`✓ Medición anterior de la fuente (${r} ${e}x${t} @ ${i}fps, ${a}). Esta medición no confirma reproducción actual en Casa.`})}else o?(S(!1),b({text:`ℹ️ Pulsa 'Verificar Stream' para probar la conectividad y resolución nativa en vivo.`})):(S(!1),b({text:t.provider===`home_assistant`?`Pulsa Verificar Stream para obtener y probar automáticamente la fuente de Home Assistant / Omni.`:`ℹ️ Sin URL de stream configurada. Ingresa una URL RTSP directa para activar Live View.`,isError:t.provider!==`home_assistant`}))}I&&r.getCameraAiConfig(I).then(e=>{e?.config&&A(e.config),e?.active&&Te(e.active)}).catch(()=>{})},[I,F]);let He=async()=>{if(I){De(!0);try{(await r.saveCameraAiConfig(I,k))?.success?f(`✓ Configuración de IA guardada correctamente`):f(`Error al guardar configuración de IA`,!0)}catch{f(`Error al conectar con el servidor`,!0)}finally{De(!1)}}};if(!e)return null;let R=i(e),Ue=F?e.status===`online`&&e.homeKitEnabled!==!1:e?.status?.connection===`online`&&e?.status?.isOnline===!0,z=F?!!e.isPaired:e?.identity?.homeKitPairingState===`paired`,B=F?e.homeKitEnabled!==!1:e?.exportConfig?.homeKitEnabled!==!1&&e?.exportConfig?.exportMode!==`disabled`,We=async()=>{if(Be)return;Ve(!0);let t=!B;try{F?(await r.toggleCameraUiHomeKit(I),e.homeKitEnabled=t):(await r.toggleCameraHomeKit(I),e.exportConfig||={},e.exportConfig.homeKitEnabled=t,e.exportConfig.exportMode=t?`auto`:`disabled`),f(t?`✓ ${L} activada para Apple Home`:`${L} desactivada de Apple Home`),n()}catch(e){f(e.message||`Error al modificar estado de HomeKit`,!0)}finally{Ve(!1)}},Ge=!F&&(R===`GOOGLE`||R===`NEST`||I.includes(`nest`)||I.includes(`google`)||e?.capabilities?.observed?.streamSourceType===`webrtc`&&e?.capabilities?.observed?.strategy===`unsupported`),Ke=Ge&&e?.capabilities?.observed?.strategy===`unsupported`,V=F?e.pincode||`031-45-154`:e?.identity?.homeKitPincode||`031-45-154`,qe=F?e.setupId||`CUI1`:e?.identity?.homeKitSetupId||`SC01`,Je=()=>{if(F){let t=e;return t.setupUri?t.setupUri:u(V,qe)}let t=e;return t.provider===`home_assistant`?t.exportConfig?.homeKitEnabled===!0&&t.identity?.homeKitSetupUri||``:t.identity?.homeKitSetupUri?t.identity.homeKitSetupUri:u(V,qe)},Ye=!F&&!!(e.bindingState?.matterCommissioned||e.bindingState?.fabrics&&e.bindingState.fabrics.length>0),Xe=p===`homekit`?Je():w||(F?``:e.identity?.matterPairingCode)||``,Ze=F?e.model||`Modelo no identificado`:e.displayModel||e.model||`Modelo no identificado`,Qe=async t=>{let i=(t??E).trim();if(i){ge(!0);try{F?e.model=i:(await r.updateCameraIdentity(I,{manufacturer:R,model:i}),e.displayModel=i,e.model=i,e.identityOverride||={},e.identityOverride.model=i),D(i),f(`✓ Modelo actualizado a «${i}»`),n()}catch(e){f(e.message||`Error al actualizar modelo`,!0)}finally{ge(!1)}}},H=[];if(e.realEntities&&Array.isArray(e.realEntities)&&H.push(...e.realEntities),F){let t=e;t.hasLight&&!H.some(e=>e.type===`light`)&&H.push({id:`cameraui.${t.id}.light`,domain:`light`,type:`light`,name:`${t.name} Foco / Luz`,state:!!t.lightActive,matterExported:!1}),t.hasSiren&&!H.some(e=>e.type===`siren`)&&H.push({id:`cameraui.${t.id}.siren`,domain:`siren`,type:`siren`,name:`${t.name} Sirena`,state:!!t.sirenActive,matterExported:!1}),t.motionTopic&&!H.some(e=>e.type===`motion`)&&H.push({id:`cameraui.${t.id}.motion`,domain:`binary_sensor`,type:`motion`,name:`${t.name} Sensor Movimiento`,state:!!t.motionActive,topic:t.motionTopic}),t.doorbellTopic&&!H.some(e=>e.type===`doorbell`)&&H.push({id:`cameraui.${t.id}.doorbell`,domain:`event`,type:`doorbell`,name:`${t.name} Timbre`,state:!!t.doorbellActive,topic:t.doorbellTopic})}else if(`sensors`in e&&Array.isArray(e.sensors))for(let t of e.sensors||[])t.type!==`light`&&t.type!==`siren`&&t.type!==`motion`&&t.type!==`doorbell`||H.some(e=>e.type===t.type)||H.push({id:`sensor.${t.sensorId}`,domain:t.type===`motion`?`binary_sensor`:t.type===`doorbell`?`event`:t.type,type:t.type,name:t.name||`${e.name} ${t.type}`,state:!!t.state,matterExported:!1});let U=`—`,W=`—`,G=`—`,K=`—`,q=!1,$e=`Sin medición ffprobe vigente`,J;if(F){let t=e;J=t.videoCodecSource===`ffprobe`&&t.codecProbeUrl===h&&t.codecProbedAt?t:void 0;let n=C?.sourceUrl===h?C:J;n?.videoCodec&&(U=String(n.videoCodec).toUpperCase(),$e=`ffprobe ${n.validatedAt||n.codecProbedAt||`reciente`}`);let r=n?.resolution||(J?{width:J.width,height:J.height}:void 0);r?.width&&r?.height&&(W=`${r.width}x${r.height}`,q=!0),n?.fps&&(G=`${n.fps} fps`),n?.hasAudio!==void 0&&(K=n.hasAudio?String(n.audioCodec||`códec no medido`).toUpperCase():`Sin Audio`)}else{let t=e,n=t.capabilities?.observed,r=t.source?.streamValidationStatus===`verified`||t.source?.streamReference?.validationStatus===`verified`||!!n?.resolution;n?.videoCodec&&(U=n.videoCodec.toUpperCase(),r&&($e=`Validación de stream almacenada`)),n?.resolution?.width&&n?.resolution?.height&&(W=`${n.resolution.width}x${n.resolution.height}`,q=!0),n?.fps&&(G=`${n.fps} fps`),n?.hasAudio!==void 0&&(K=n.hasAudio?n.audioCodec?.toUpperCase()||`AAC`:`Sin Audio`),r&&(q=!0)}let Y=U.includes(`HEVC`)||U.includes(`265`)||U.includes(`HVC1`)||!!e?.videoCodec?.toLowerCase().includes(`hevc`),X=e?.liveViewCapabilities,et=e?.liveViewTelemetry,Z=et?.active?.[0]||et?.recent?.[0],Q=e?.hksvConfiguration,tt=F?J?.videoProfile:e.capabilities?.observed?.profile,nt=F?J?.videoLevel:void 0,rt=F?J?.videoBitrateKbps:void 0,it=F?J?.videoPixFmt:void 0,at=F&&J?`${J.rFrameRate||`No medido`} / ${J.avgFrameRate||`No medido`}`:`No medido`,$=F?void 0:{resolution:e.resolution,fps:e.fps},ot={copy:`Copia directa`,normalization:`Normalización / downscale`,transcode:`Transcodificación`,fallback:`Fallback`},st=async()=>{if(confirm(`¿Restablecer emparejamiento HomeKit para "${L}"?`)){ae(!0);try{if(F)(await r.resetCameraUiPairing(I)).success?(f(`✓ Vinculación HAP restablecida. Escanea el nuevo código QR en Apple Home.`),n()):f(`No se pudo restablecer el emparejamiento`,!0);else{let t=await r.resetCameraPairing(`scrypted.${I}`);t.success&&t.setupUri?(e.identity||={},e.identity.homeKitSetupUri=t.setupUri,e.identity.homeKitPairingState=`not_paired`,f(`✓ Vinculación restablecida. Escanea el nuevo código QR.`),n()):f(t.error||`No se pudo restablecer`,!0)}}catch(e){f(e.message||`Error al reiniciar vinculación`,!0)}finally{ae(!1)}}},ct=async()=>{if(confirm(`¿Eliminar la cámara "${L}" de la exportación?`)){se(!0);try{F?await r.toggleCameraUiHomeKit(I):await r.removeCamera(I),f(`✓ Cámara eliminada de la exportación`),n(),t()}catch(e){f(e.message||`Error al eliminar cámara`,!0)}finally{se(!1)}}},lt=async()=>{me(!0);try{let e=F?`cameraui.${I}`:`scrypted.${I}`,t=await r.openCommissioning(e);(t?.pairingCode||t?.manualPairingCode)&&(de(t.pairingCode||null),pe(t.manualPairingCode||null)),ue(!0),f(`✓ Ventana de emparejamiento (Multi-Admin) abierta por 15 min. Escanea en Google Home, Alexa o SmartThings.`)}catch(e){f(e.message||`Error al abrir Multi-Admin`,!0)}finally{me(!1)}},ut=async()=>{let t=d(h);if(!t&&e?.provider!==`home_assistant`)f(`Ingresa una URL RTSP para verificar`,!0);else{t!==h&&g(t),te(!0),b({text:`Verificando stream RTSP/HTTP (ffprobe en vivo)...`});try{let n=await r.verifyCameraStream(I,t,_);if(n.ok&&n.status===`verified`){if(S(!0),ce({...n.validation,sourceUrl:t}),n.validation&&!F){let t=e;t.capabilities||={},t.capabilities.observed||(t.capabilities.observed={}),n.validation.resolution&&(t.capabilities.observed.resolution=n.validation.resolution),n.validation.videoCodec&&(t.capabilities.observed.videoCodec=n.validation.videoCodec),n.validation.audioCodec&&(t.capabilities.observed.audioCodec=n.validation.audioCodec),n.validation.hasAudio!==void 0&&(t.capabilities.observed.hasAudio=n.validation.hasAudio),n.validation.fps&&(t.capabilities.observed.fps=n.validation.fps)}let r=n.validation?.resolution?.width||1920,i=n.validation?.resolution?.height||1080,a=(n.validation?.videoCodec||`desconocido`).toUpperCase(),o=n.validation?.fps||`—`;b({text:`✓ Stream verificado con éxito (${a} ${r}x${i} @ ${o}fps). Esta medición no confirma reproducción actual en Casa.`})}else S(!1),b({text:`❌ ${n.validation?.error||`Stream inválido o no compatible`}`,isError:!0})}catch(e){S(!1),b({text:`❌ Error: ${e.message}`,isError:!0})}finally{te(!1)}}},dt=async()=>{let t=d(h);if(!t&&e?.provider!==`home_assistant`)f(`Ingresa una URL RTSP para diagnosticar`,!0);else{t!==h&&g(t),re(!0),b({text:`Midiendo conexión RTSP y analizando codec, FPS y GOP...`});try{let e=await r.diagnoseCameraStream(I,t,_);if(e.success&&e.metrics){let t=e.metrics.timeToDescribeMs?.value??`—`,n=e.metrics.observedFps?.value??`—`,r=e.metrics.observedGopSeconds?.value?`${e.metrics.observedGopSeconds.value}s`:`—`,i=(e.metrics.selectedTransport?.value||_).toUpperCase();b({text:`✓ Diagnóstico completado: Probe RTSP total: ${t}ms · 1er frame: no medido · FPS: ${n} · GOP: ${r} · Transporte: ${i}`})}else b({text:`❌ Diagnóstico fallido: ${e.metrics?.error||`Error al conectar con el stream`}`,isError:!0})}catch(e){b({text:`❌ Error de diagnóstico: ${e.message}`,isError:!0})}finally{re(!1)}}},ft=async()=>{let e=d(h);if(e){e!==h&&g(e);try{await r.saveCameraStreamUrl(I,e),f(`✓ URL de stream guardada`),n()}catch(e){f(e.message||`Error al guardar stream`,!0)}}},pt=async()=>{try{await r.saveCameraExportConfig(I,{matterEnabled:!0,homeKitEnabled:Re!==`disabled`,exportMode:Re,hksvEnabledByDefault:!0,googleHomeEnabled:!1,alexaEnabled:!1,smartThingsEnabled:!1,nasEnabled:!1,rtspTransportPreference:_,rtspUrl:h.trim()||void 0,model:E.trim()||void 0,lightEntityId:Me,sirenEntityId:Pe,motionEntityId:Ie}),f(`✓ Configuración de cámara guardada`),n(),t()}catch(e){f(e.message||`Error al guardar configuración`,!0)}},mt=async e=>{ve(e.id);let t=e.domain===`button`?`press`:e.state?`turn_off`:`turn_on`;try{let i=await r.controlCameraEntity(e.id,t);i.success?(e.state=i.state===void 0?!e.state:i.state,f(`✓ ${e.name}: ${e.state?`Encendido/Activado`:`Apagado/Silenciado`}`),n()):f(i.error||`No se pudo cambiar el estado`,!0)}catch(e){f(e.message||`Error al controlar entidad`,!0)}finally{ve(null)}},ht=async e=>{if(ye===e.id)be(null);else if(be(e.id),!e.matterPairingCode&&!xe[e.id]){O(t=>({...t,[e.id]:!0}));try{e.matterExported||=(await r.toggleExport(e.id,!0),!0);let t=await r.openCommissioning(e.id);(t?.pairingCode||t?.manualPairingCode)&&(Se(n=>({...n,[e.id]:{pairingCode:t.pairingCode,manualCode:t.manualPairingCode||t.pairingCode}})),e.matterPairingCode=t.pairingCode,e.matterManualCode=t.manualPairingCode,f(`✓ Código Matter generado para ${e.name}`),n())}catch(e){f(e.message||`Error al generar código Matter`,!0)}finally{O(t=>({...t,[e.id]:!1}))}}},gt=async e=>{O(t=>({...t,[e.id]:!0}));try{let t=await r.openCommissioning(e.id);(t?.pairingCode||t?.manualPairingCode)&&(Se(n=>({...n,[e.id]:{pairingCode:t.pairingCode,manualCode:t.manualPairingCode||t.pairingCode}})),e.matterPairingCode=t.pairingCode,e.matterManualCode=t.manualPairingCode,f(`✓ Modo Multi-Admin abierto (15 min) para ${e.name}`),n())}catch(e){f(e.message||`Error al abrir Multi-Admin`,!0)}finally{O(t=>({...t,[e.id]:!1}))}};return(0,l.jsx)(`div`,{className:`modal-backdrop open`,role:`dialog`,"aria-modal":`true`,children:(0,l.jsxs)(`section`,{className:`modal modal-wide`,style:{maxWidth:940},children:[(0,l.jsx)(`button`,{className:`icon-button`,type:`button`,"aria-label":`Cerrar`,onClick:t,children:`×`}),(0,l.jsxs)(`header`,{className:`modal-header`,children:[(0,l.jsx)(`span`,{className:`modal-icon`,style:{fontSize:`1.8rem`},children:`📹`}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`p`,{className:`eyebrow`,children:F?e.sourceProvider===`home_assistant`?`CÁMARA HOME ASSISTANT RTSP · APPLE HOME HAP`:`CÁMARA CAMERA.UI · APPLE HOME HAP & MATTER`:`CÁMARA SCRYPTED · APPLE HOME HAP & MATTER`}),(0,l.jsx)(`h2`,{children:L}),(0,l.jsxs)(`p`,{className:`entity-id`,children:[Ue?`🟢 En línea`:`🔴 Desconectada`,` · `,R,` `,Ze&&`(${Ze})`,` · ID: `,I,F&&e.port&&(0,l.jsxs)(l.Fragment,{children:[` `,`· Puerto HAP:`,` `,(0,l.jsx)(`code`,{children:e.port})]}),` `,`· Firmware HAP:`,` `,(0,l.jsx)(`code`,{children:e.firmwareRevision||`Versión HAP no disponible`})]})]})]}),(0,l.jsxs)(`div`,{className:`camera-modal-layout`,children:[(0,l.jsxs)(`div`,{className:`qr-panel`,children:[(0,l.jsxs)(`div`,{className:`tab-group`,style:{display:`flex`,gap:6,marginBottom:12,flexWrap:`wrap`},children:[(0,l.jsxs)(`button`,{className:`button button-sm ${p===`homekit`?`button-primary`:`button-secondary`}`,type:`button`,onClick:()=>m(`homekit`),children:[`Apple Home (HAP)`,` `,B?z?`✓`:``:`⚪`]}),(0,l.jsx)(`button`,{className:`button button-sm ${p===`matter`?`button-primary`:`button-secondary`}`,type:`button`,onClick:()=>m(`matter`),children:`Matter 1.6`}),(0,l.jsx)(`button`,{className:`button button-sm ${p===`ai`?`button-primary`:`button-secondary`}`,type:`button`,onClick:()=>m(`ai`),children:`🧠 IA & Fauna`}),Ge&&(0,l.jsx)(`button`,{className:`button button-sm ${p===`nest`?`button-primary`:`button-secondary`}`,type:`button`,onClick:()=>m(`nest`),style:Ke?{borderColor:`#fb923c`,color:p===`nest`?void 0:`#fb923c`}:void 0,children:`📡 Google Nest`})]}),p===`nest`?(0,l.jsxs)(`div`,{className:`card`,style:{padding:16},children:[(0,l.jsx)(`h4`,{style:{margin:`0 0 8px`,fontSize:`0.95rem`,color:`#fb923c`},children:`📡 Google Nest — Live Stream en HomeKit`}),Ke?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{style:{background:`rgba(251,146,60,0.1)`,border:`1px solid rgba(251,146,60,0.4)`,borderRadius:8,padding:`10px 14px`,marginBottom:14,fontSize:`0.82rem`,color:`#fb923c`},children:[(0,l.jsx)(`strong`,{children:`⚠️ Sin stream disponible:`}),` La integración`,` `,(0,l.jsx)(`code`,{children:`google_nest`}),` de HA solo hace WebRTC efímero a Google Cloud. Para tener live stream estable en HomeKit necesitas `,(0,l.jsx)(`strong`,{children:`go2rtc`}),` como puente RTSP local.`]}),(0,l.jsxs)(`p`,{style:{fontSize:`0.82rem`,color:`var(--text-muted)`,marginBottom:12},children:[`go2rtc se conecta directamente al Google SDM API con tus credenciales OAuth2 y expone un endpoint RTSP local (`,(0,l.jsxs)(`code`,{children:[`rtsp://127.0.0.1:8554/`,L.toLowerCase().replace(/\s+/g,`_`)]}),`) que nuestro addon detecta automáticamente y exporta a HomeKit con `,(0,l.jsx)(`strong`,{children:`passthrough H.264`}),` y`,` `,(0,l.jsx)(`strong`,{children:`audio AAC-ELD`}),`.`]}),(0,l.jsxs)(`div`,{style:{fontSize:`0.82rem`,color:`var(--text-secondary)`},children:[(0,l.jsx)(`p`,{style:{fontWeight:600,color:`#f1f5f9`,marginBottom:6},children:`Pasos de configuración:`}),(0,l.jsxs)(`ol`,{style:{paddingLeft:18,margin:0,lineHeight:1.9},children:[(0,l.jsxs)(`li`,{children:[(0,l.jsx)(`a`,{href:`https://console.cloud.google.com/apis/library/smartdevicemanagement.googleapis.com`,target:`_blank`,rel:`noreferrer`,style:{color:`#60a5fa`},children:`Google Cloud Console`}),` `,`→ Habilitar`,` `,(0,l.jsx)(`strong`,{children:`Smart Device Management API`})]}),(0,l.jsxs)(`li`,{children:[`APIs & Services → Credentials → Create OAuth 2.0 Client ID → Guardar `,(0,l.jsx)(`code`,{children:`client_id`}),` y`,` `,(0,l.jsx)(`code`,{children:`client_secret`})]}),(0,l.jsxs)(`li`,{children:[(0,l.jsx)(`a`,{href:`https://console.nest.google.com/device-access/project-list`,target:`_blank`,rel:`noreferrer`,style:{color:`#60a5fa`},children:`Google Device Access Console`}),` `,`→ Create project (`,(0,l.jsx)(`strong`,{children:`pago único \\$5`}),`) → Guardar `,(0,l.jsx)(`code`,{children:`project_id`})]}),(0,l.jsxs)(`li`,{children:[`Completar OAuth flow para obtener`,` `,(0,l.jsx)(`code`,{children:`refresh_token`}),` `,(0,l.jsx)(`a`,{href:`https://developers.google.com/nest/device-access/authorize`,target:`_blank`,rel:`noreferrer`,style:{color:`#60a5fa`},children:`(guía oficial)`})]}),(0,l.jsxs)(`li`,{children:[`Obtener `,(0,l.jsx)(`code`,{children:`device_id`}),`:`,` `,(0,l.jsx)(`code`,{children:`GET /v1/enterprises/{project_id}/devices`}),` `,`con tu access token`]}),(0,l.jsxs)(`li`,{children:[`En HA → Settings → go2rtc → agregar stream:`,(0,l.jsx)(`pre`,{style:{background:`#0f172a`,borderRadius:6,padding:`8px 10px`,fontSize:`0.75rem`,color:`#a5f3fc`,marginTop:6,overflowX:`auto`,whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:`streams:
2
+ ${L.toLowerCase().replace(/\s+/g,`_`)}:
3
+ - nest:?client_id=TU_ID&client_secret=TU_SECRET
4
+ &project_id=TU_PROJECT&refresh_token=TU_TOKEN
5
+ &device_id=TU_DEVICE_ID`})]}),(0,l.jsx)(`li`,{children:`Reiniciar HA → Nuestro addon detecta el stream automáticamente al iniciar`})]})]}),(0,l.jsxs)(`div`,{style:{marginTop:14,fontSize:`0.78rem`,color:`var(--text-muted)`},children:[`💡 `,(0,l.jsx)(`strong`,{children:`Tip:`}),` go2rtc gestiona la re-autenticación automáticamente. No es necesario renovar el token manualmente. El stream aparecerá como`,` `,(0,l.jsxs)(`code`,{children:[`rtsp://127.0.0.1:8554/`,L.toLowerCase().replace(/\s+/g,`_`)]}),` `,`y será detectado en el próximo inicio del addon.`]})]}):(0,l.jsxs)(`div`,{style:{background:`rgba(16,185,129,0.1)`,border:`1px solid rgba(16,185,129,0.4)`,borderRadius:8,padding:`10px 14px`,fontSize:`0.82rem`,color:`#6ee7b7`},children:[`✅ `,(0,l.jsx)(`strong`,{children:`go2rtc detectado:`}),` El addon está recibiendo el stream RTSP local de esta cámara Nest. Live view y audio AAC-ELD están disponibles en HomeKit.`]})]}):p===`ai`?(0,l.jsxs)(`div`,{className:`card`,style:{padding:16},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:12},children:[(0,l.jsx)(`h4`,{style:{margin:0,fontSize:`0.95rem`,color:`#38bdf8`},children:`🧠 Detección IA Local`}),(0,l.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:6,cursor:`pointer`,fontSize:`0.85rem`},children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:k.enabled,onChange:e=>A({...k,enabled:e.target.checked})}),(0,l.jsx)(`span`,{children:k.enabled?`Activa`:`Inactiva`})]})]}),(0,l.jsx)(`p`,{style:{fontSize:`0.8rem`,color:`var(--text-muted)`,marginBottom:14},children:`Estas opciones no activan visión artificial ni identifican gatos o perros. MIAO detecta movimiento por cambios de imagen; para clasificar animales necesita eventos ya etiquetados por Camera.UI u otra entidad de Home Assistant. Estas casillas solo filtran esas etiquetas externas.`}),we&&(0,l.jsxs)(`div`,{style:{background:`rgba(56, 189, 248, 0.15)`,border:`1px solid rgba(56, 189, 248, 0.3)`,borderRadius:8,padding:10,marginBottom:14},children:[(0,l.jsx)(`div`,{style:{fontSize:`0.85rem`,fontWeight:600,color:`#38bdf8`},children:`🚨 Detección Activa`}),(0,l.jsxs)(`div`,{style:{fontSize:`0.8rem`,marginTop:4},children:[we.labels?.join(`, `),` (`,(we.confidence*100).toFixed(0),`%)`]})]}),(0,l.jsxs)(`div`,{style:{marginBottom:14},children:[(0,l.jsx)(`label`,{style:{fontSize:`0.8rem`,fontWeight:600,display:`block`,marginBottom:6},children:`Objetivos de Detección:`}),(0,l.jsx)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:8},children:[{id:`person`,label:`👤 Persona`},{id:`vehicle`,label:`🚗 Vehículo`},{id:`dog`,label:`🐶 Perro`},{id:`cat`,label:`🐱 Gato`},{id:`bird`,label:`🦜 Ave`},{id:`raccoon`,label:`🦝 Mapache`},{id:`snake`,label:`🐍 Serpiente`},{id:`spider`,label:`🕷️ Araña`}].map(e=>{let t=k.targets.includes(e.id);return(0,l.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`6px 10px`,borderRadius:6,background:t?`rgba(56, 189, 248, 0.1)`:`rgba(255,255,255,0.03)`,border:`1px solid ${t?`rgba(56, 189, 248, 0.3)`:`rgba(255,255,255,0.08)`}`,cursor:`pointer`,fontSize:`0.85rem`},children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:t,onChange:t=>{let n=t.target.checked?[...k.targets,e.id]:k.targets.filter(t=>t!==e.id);A({...k,targets:n})}}),(0,l.jsx)(`span`,{children:e.label})]},e.id)})})]}),(0,l.jsxs)(`div`,{style:{marginBottom:14},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,fontSize:`0.8rem`,marginBottom:4},children:[(0,l.jsx)(`span`,{children:`Sensibilidad:`}),(0,l.jsxs)(`span`,{style:{fontWeight:600,color:`#38bdf8`},children:[k.sensitivity,`%`]})]}),(0,l.jsx)(`input`,{type:`range`,min:50,max:95,value:k.sensitivity,onChange:e=>A({...k,sensitivity:Number(e.target.value)}),style:{width:`100%`}})]}),(0,l.jsxs)(`div`,{style:{marginBottom:14},children:[(0,l.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,cursor:`pointer`,fontSize:`0.85rem`},children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:k.publishMqtt,onChange:e=>A({...k,publishMqtt:e.target.checked})}),(0,l.jsx)(`span`,{children:`📡 Publicar eventos en broker MQTT`})]}),k.publishMqtt&&(0,l.jsxs)(`div`,{style:{fontSize:`0.75rem`,color:`var(--text-muted)`,marginTop:4,paddingLeft:24},children:[`Tópico:`,` `,(0,l.jsx)(`code`,{children:k.mqttTopic||`matter-all-in-one/ai/${I.replace(/[^a-zA-Z0-9_]/g,`_`)}/detection`})]})]}),(0,l.jsx)(`button`,{className:`button button-primary`,type:`button`,style:{width:`100%`,marginTop:8},onClick:He,disabled:Ee,children:Ee?`Guardando...`:`💾 Guardar Configuración de IA`})]}):p===`matter`?Ye&&!le?(0,l.jsxs)(`div`,{className:`paired-success-glass-card`,id:`paired-camera-matter-card`,children:[(0,l.jsx)(`div`,{className:`paired-apple-home-badge`,children:(0,l.jsx)(o,{variant:`mono`,size:56})}),(0,l.jsx)(`h4`,{className:`paired-card-title`,children:`¡Cámara activa en red Matter!`}),(0,l.jsx)(`p`,{className:`paired-card-desc`,children:`Esta cámara está sincronizada en el puente Matter. El código inicial se oculta para proteger la sesión activa.`}),(0,l.jsxs)(`div`,{className:`paired-multiadmin-box`,children:[(0,l.jsx)(`p`,{className:`paired-multiadmin-subtext`,children:`¿Deseas agregarla a Google Home, Alexa o SmartThings?`}),(0,l.jsx)(`button`,{className:`button button-primary button-open-multiadmin`,type:`button`,onClick:lt,disabled:T,id:`cam-open-multiadmin-btn`,children:(0,l.jsx)(`span`,{children:T?`Abriendo...`:`🌐 Abrir Modo Multi-Admin (15 min)`})})]})]}):le||w?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{id:`cam-multi-admin-hint`,className:`multi-admin-hint`,style:{display:`block`,marginBottom:10},children:[(0,l.jsx)(`p`,{className:`hint-title`,children:`🌐 Modo Multi-Admin Abierto (15 min)`}),(0,l.jsxs)(`p`,{className:`hint-desc`,children:[`Ventana de emparejamiento abierta. Escanea este código QR en `,(0,l.jsx)(`strong`,{children:`Google Home`}),`, `,(0,l.jsx)(`strong`,{children:`Alexa`}),` o`,` `,(0,l.jsx)(`strong`,{children:`SmartThings`}),`.`]})]}),(0,l.jsx)(a,{pairingCode:w||(F?``:e.identity?.matterPairingCode)||``,manualCode:fe||w||(F?``:e.identity?.matterPairingCode),entityName:L,elementId:`cam-matter-qr-code`,variant:`multi-admin-glass`,noteText:`Escanea con Google Home, Alexa o SmartThings (Matter 1.6)`})]}):!F&&e.identity?.matterPairingCode?(0,l.jsx)(a,{pairingCode:e.identity.matterPairingCode,manualCode:e.identity.matterPairingCode,entityName:L,elementId:`cam-matter-qr-code`,variant:`matter-badge`,noteText:`Escanea para agregar por Matter 1.6 a Apple Home o Google Home`}):(0,l.jsxs)(`div`,{className:`paired-success-glass-card`,style:{textAlign:`center`,padding:`20px 16px`},children:[(0,l.jsx)(`div`,{style:{fontSize:`2.2rem`,marginBottom:8},children:`⚡`}),(0,l.jsx)(`h4`,{className:`paired-card-title`,style:{fontSize:`1rem`},children:`Vincular Cámara con Matter 1.6`}),(0,l.jsx)(`p`,{className:`paired-card-desc`,style:{fontSize:`0.82rem`,marginBottom:14},children:`Genera el código de emparejamiento dinámico para agregar esta cámara a Google Home, Alexa o Apple Home.`}),(0,l.jsx)(`button`,{className:`button button-primary`,type:`button`,onClick:lt,disabled:T,style:{width:`100%`,justifyContent:`center`},children:(0,l.jsx)(`span`,{children:T?`Generando código...`:`⚡ Generar Código de Emparejamiento`})})]}):p===`homekit`?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`12px 14px`,background:B?`rgba(245, 158, 11, 0.12)`:`rgba(255, 255, 255, 0.03)`,border:`1px solid ${B?`rgba(245, 158, 11, 0.4)`:`var(--border)`}`,borderRadius:8,marginBottom:14},children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{style:{fontWeight:600,fontSize:`0.95rem`,color:B?`#fcd34d`:`var(--text)`},children:`Activar HomeKit HAP (Apple Home)`}),(0,l.jsx)(`div`,{style:{fontSize:`0.75rem`,color:`var(--muted)`,marginTop:2},children:B?z?`✓ Cámara activa y vinculada en Apple Home`:`✓ Accesorio activo en HomeKit HAP (código QR y PIN listos)`:`Apagado (activa el switch para exportar y generar código QR en Apple Casa)`})]}),(0,l.jsxs)(`label`,{className:`toggle`,style:{margin:0},children:[(0,l.jsx)(`input`,{type:`checkbox`,checked:!!B,onChange:We,disabled:Be}),(0,l.jsx)(`span`,{})]})]}),B?z?(0,l.jsxs)(`div`,{className:`paired-success-glass-card`,id:`paired-camera-card`,children:[(0,l.jsx)(`div`,{className:`paired-apple-home-badge`,children:(0,l.jsx)(o,{variant:`color`,size:56})}),(0,l.jsx)(`h4`,{className:`paired-card-title`,children:`¡Cámara vinculada en Apple Home!`}),(0,l.jsxs)(`p`,{className:`paired-card-desc`,children:[`Esta cámara ya está configurada en Apple Home para Live View HAP`,Y?` (HEVC / HKSV3 Nativo)`:``,`. El código QR se oculta para proteger la sesión activa.`]}),(0,l.jsxs)(`div`,{style:{marginTop:12,padding:`10px 14px`,background:`rgba(59, 130, 246, 0.12)`,borderRadius:8,border:`1px solid rgba(59, 130, 246, 0.3)`,fontSize:`0.82rem`,textAlign:`left`},children:[(0,l.jsx)(`strong`,{style:{color:`#93c5fd`},children:`💡 IMPORTANTE PARA GRABAR EN ICLOUD (HKSV):`}),(0,l.jsxs)(`div`,{style:{marginTop:6,color:`#bfdbfe`,lineHeight:1.4},children:[`Apple Home desactiva la grabación por defecto. En tu iPhone/iPad:`,(0,l.jsxs)(`ol`,{style:{margin:`4px 0 0 16px`,padding:0},children:[(0,l.jsxs)(`li`,{children:[`Abre la app `,(0,l.jsx)(`strong`,{children:`Casa`}),` y toca esta cámara.`]}),(0,l.jsxs)(`li`,{children:[`Toca ⚙️ `,(0,l.jsx)(`strong`,{children:`Ajustes de la cámara`}),` →`,` `,(0,l.jsx)(`strong`,{children:`Opciones de grabación`}),`.`]}),(0,l.jsxs)(`li`,{children:[`Selecciona`,` `,(0,l.jsx)(`strong`,{children:`«Transmitir y permitir la grabación»`}),` `,`(tanto En casa como Fuera de casa).`]})]})]})]})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(a,{pairingCode:Xe,manualCode:V,pinCode:p===`homekit`?V:void 0,variant:p===`homekit`?`hap-homekit`:`matter-badge`,entityName:L,elementId:`cam-modal-qr-code`,noteText:Y?`Escanea con la app Casa de Apple para HAP HEVC / HKSV3`:`Escanea con la app Casa de Apple para Live View HAP`,videoCodec:e?.videoCodec||e?.capabilities?.observed?.videoCodec,isHevc:Y}),(0,l.jsxs)(`div`,{style:{marginTop:10,padding:`10px 12px`,background:`rgba(245, 158, 11, 0.1)`,borderRadius:8,border:`1px solid rgba(245, 158, 11, 0.3)`,fontSize:`0.78rem`,textAlign:`left`},children:[(0,l.jsx)(`strong`,{style:{color:`#fcd34d`},children:`📲 Cómo vincular en Apple Casa:`}),(0,l.jsxs)(`ol`,{style:{margin:`4px 0 0 16px`,padding:0,color:`#fef08a`},children:[(0,l.jsxs)(`li`,{children:[`Abre la app `,(0,l.jsx)(`strong`,{children:`Casa`}),` en tu iPhone o iPad.`]}),(0,l.jsxs)(`li`,{children:[`Toca `,(0,l.jsx)(`strong`,{children:`+`}),` →`,` `,(0,l.jsx)(`strong`,{children:`Agregar accesorio`}),` y escanea el código QR.`]}),(0,l.jsxs)(`li`,{children:[`O toca `,(0,l.jsx)(`em`,{children:`«Más opciones...»`}),`, elige`,` `,(0,l.jsx)(`strong`,{children:L}),` e introduce el PIN:`,` `,(0,l.jsx)(`strong`,{children:V}),`.`]})]})]})]}):(0,l.jsxs)(`div`,{style:{padding:`24px 16px`,background:`rgba(255, 255, 255, 0.02)`,border:`1px dashed var(--border)`,borderRadius:8,textAlign:`center`},children:[(0,l.jsx)(`div`,{style:{fontSize:`2rem`,marginBottom:8},children:`⏸️`}),(0,l.jsx)(`strong`,{style:{color:`var(--text)`,fontSize:`0.95rem`,display:`block`,marginBottom:6},children:`Exportación a Apple Home desactivada`}),(0,l.jsx)(`p`,{style:{color:`var(--muted)`,fontSize:`0.82rem`,margin:`0 auto`,maxWidth:420,lineHeight:1.4},children:`Esta cámara no está exportada a HomeKit HAP. Los procesos de streaming, prebuffer de grabación y puertos mDNS están apagados para ahorrar CPU. Activa el interruptor superior cuando desees vincularla en Apple Home.`})]})]}):null,(0,l.jsxs)(`div`,{className:`qr-actions`,style:{display:`flex`,flexDirection:`column`,gap:8,marginTop:12},children:[p===`homekit`&&B&&(0,l.jsx)(`button`,{className:`button button-danger-outline button-sm`,type:`button`,onClick:st,disabled:ie,children:ie?`Restableciendo...`:`🔄 Restablecer emparejamiento`}),p===`matter`&&Ye&&(0,l.jsx)(`button`,{className:`button button-secondary button-sm`,type:`button`,onClick:lt,disabled:T,children:T?`Abriendo...`:`🌐 Reabrir Multi-Admin (15 min)`})]})]}),(0,l.jsxs)(`div`,{className:`selection-panel`,children:[(0,l.jsx)(`div`,{style:{marginBottom:12,padding:`8px 12px`,background:`rgba(255, 255, 255, 0.03)`,border:`1px solid rgba(255, 255, 255, 0.08)`,borderRadius:8,display:`flex`,flexWrap:`wrap`,alignItems:`center`,justifyContent:`space-between`,gap:8},children:(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,flex:1,minWidth:260},children:[(0,l.jsx)(`span`,{style:{fontSize:`0.74rem`,fontWeight:700,color:`var(--dim)`,textTransform:`uppercase`},children:`MODELO DE CÁMARA:`}),(0,l.jsx)(`input`,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:`ej. Tapo C402, Tapo C120, Wyze Cam Pan v2`,style:{background:`rgba(0, 0, 0, 0.3)`,border:`1px solid var(--border)`,borderRadius:6,padding:`3px 8px`,color:`var(--text)`,fontSize:`0.82rem`,flex:1}}),(0,l.jsx)(`button`,{className:`button button-sm button-secondary`,type:`button`,onClick:()=>Qe(),disabled:he,style:{whiteSpace:`nowrap`},children:he?`...`:`Guardar`})]})}),(0,l.jsxs)(`div`,{className:`camera-modal-specs-box`,children:[(0,l.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:8},children:[(0,l.jsx)(`span`,{style:{fontSize:`0.74rem`,fontWeight:700,color:`var(--dim)`,textTransform:`uppercase`},children:`ESPECIFICACIONES TÉCNICAS REALES`}),(0,l.jsx)(`span`,{style:{fontSize:`0.72rem`,padding:`2px 8px`,borderRadius:4,background:v?`rgba(59, 130, 246, 0.15)`:q||x?`rgba(16, 185, 129, 0.15)`:`rgba(239, 68, 68, 0.15)`,color:v?`#93c5fd`:q||x?`#6ee7b7`:`#fca5a5`,border:`1px solid ${v?`rgba(59, 130, 246, 0.3)`:q||x?`rgba(52, 211, 153, 0.3)`:`rgba(239, 68, 68, 0.3)`}`},children:v?`🔄 Verificando stream...`:q||x?`🟢 Stream verificado`:`🔴 Stream sin verificar`})]}),(0,l.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:6,fontSize:`0.8rem`},children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`📹 Video:`}),` `,U===`—`?`No verificado`:U,` ·`,` `,W===`—`?`Pendiente de detección`:W,` `,G===`—`?``:`@ ${G}`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`🔊 Audio:`}),` `,K===`—`?`No verificado`:K]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`⚡ Latencia:`}),` <200ms (LAN Ultra Baja)`]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`🍏 HAP:`}),` `,Y?`Passthrough HEVC / HKSV3 Nativo (sin transcodificación)`:`Passthrough H.264 (sin transcodificación de vídeo)`]})]})]}),(0,l.jsxs)(`div`,{style:{background:`rgba(255, 255, 255, 0.03)`,border:`1px solid var(--border)`,borderRadius:12,padding:14,marginTop:12},children:[(0,l.jsxs)(`span`,{style:{fontSize:`0.74rem`,fontWeight:700,color:Y?`#c084fc`:`var(--dim)`,textTransform:`uppercase`,display:`block`,marginBottom:6},children:[`URL DIRECTA DEL STREAM RTSP`,` `,Y?`(HEVC / H.265)`:`(H.264)`]}),(0,l.jsxs)(`div`,{style:{display:`flex`,gap:8,marginBottom:8},children:[(0,l.jsx)(`input`,{type:`text`,placeholder:`rtsp://192.168.1.50:8554/cam1`,value:h,onChange:e=>g(e.target.value),style:{flex:1,background:`rgba(0, 0, 0, 0.3)`,border:`1px solid var(--border)`,borderRadius:8,padding:`6px 10px`,color:`var(--text)`,fontSize:`0.85rem`}}),(0,l.jsx)(`button`,{className:`button button-sm button-secondary`,type:`button`,onClick:ft,children:`💾 Guardar`})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`,alignItems:`center`},children:[(0,l.jsx)(`button`,{className:`button button-sm button-secondary`,type:`button`,onClick:ut,disabled:v,children:v?`Verificando...`:`🔍 Verificar Stream`}),(0,l.jsx)(`button`,{className:`button button-sm button-secondary`,type:`button`,onClick:dt,disabled:ne,children:ne?`Diagnosticando...`:`⚡ Diagnosticar Stream`}),(0,l.jsxs)(`select`,{value:_,onChange:e=>ee(e.target.value),style:{background:`rgba(0, 0, 0, 0.3)`,border:`1px solid var(--border)`,borderRadius:6,padding:`4px 8px`,color:`var(--text)`,fontSize:`0.78rem`},children:[(0,l.jsx)(`option`,{value:`tcp`,children:`TCP (Recomendado)`}),(0,l.jsx)(`option`,{value:`udp`,children:`UDP`})]})]}),y&&(0,l.jsx)(`div`,{style:{marginTop:8,padding:8,borderRadius:6,fontSize:`0.8rem`,background:y.isError?`rgba(239, 68, 68, 0.1)`:`rgba(16, 185, 129, 0.1)`,color:y.isError?`#fca5a5`:`#6ee7b7`,border:y.isError?`1px solid rgba(239, 68, 68, 0.3)`:`1px solid rgba(52, 211, 153, 0.3)`},children:y.text}),/wyze/i.test(L||E||h)&&(0,l.jsxs)(`div`,{style:{marginTop:8,padding:`8px 12px`,borderRadius:6,fontSize:`0.78rem`,background:`rgba(56, 189, 248, 0.08)`,border:`1px solid rgba(56, 189, 248, 0.25)`,color:`#7dd3fc`,display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(`span`,{style:{fontSize:`1.1rem`},children:`💡`}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{children:`Calidad Prioritaria Wyze:`}),` `,(0,l.jsx)(`code`,{children:`/stream0`}),` es la resolución máxima`,` `,(0,l.jsx)(`strong`,{children:`1080p (Full HD @ 20fps)`}),`. El sub-stream`,` `,(0,l.jsx)(`code`,{children:`/stream1`}),` reduce la calidad a`,` `,(0,l.jsx)(`strong`,{children:`360p`}),`. Nuestro sistema mantiene`,` `,(0,l.jsx)(`code`,{children:`/stream0`}),` con transporte directo de cero latencia para máxima fidelidad visual sin lag.`]})]}),(0,l.jsxs)(`div`,{style:{marginTop:12,padding:`10px 12px`,background:`rgba(0, 0, 0, 0.45)`,borderRadius:8,border:`1px solid rgba(255, 255, 255, 0.1)`},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:8},children:[(0,l.jsx)(`span`,{style:{fontSize:`0.78rem`,fontWeight:700,color:`#38bdf8`,display:`flex`,alignItems:`center`,gap:6},children:`Vista previa temporal · hasta 90 segundos`}),(0,l.jsx)(`button`,{className:`button button-sm button-secondary`,type:`button`,onClick:()=>{je(null),ke(!1),j(P?null:{cameraId:I,id:crypto.randomUUID()})},style:{fontSize:`0.72rem`,padding:`2px 8px`},children:P?`Detener preview`:`Ver stream`})]}),(0,l.jsxs)(`div`,{style:{position:`relative`,width:`100%`,aspectRatio:`16/9`,background:`#080808`,borderRadius:6,overflow:`hidden`,display:`flex`,alignItems:`center`,justifyContent:`center`,border:`1px solid rgba(255, 255, 255, 0.05)`},children:[P?(0,l.jsx)(`video`,{autoPlay:!0,controls:!0,playsInline:!0,onPlaying:()=>ke(!0),onWaiting:()=>ke(!1),src:`./api/custom/cameras/${encodeURIComponent(I)}/preview?session=${P}`,"aria-label":`Vista previa con vídeo y sonido`,style:{width:`100%`,height:`100%`,objectFit:`contain`,display:`block`},onError:()=>{j(null),f(`No se pudo abrir la preview; cierra Live View en Casa e inténtalo de nuevo`,!0)}},P):null,!P&&(0,l.jsx)(`div`,{style:{color:`var(--text-muted)`,fontSize:`0.8rem`,textAlign:`center`,padding:16},children:`Pulsa Ver stream para abrir una preview temporal. Se detiene al cerrar este modal.`})]}),P&&Oe&&(0,l.jsxs)(`div`,{role:`status`,style:{padding:12},children:[`Fuente: `,M?.videoCodec||`No medido`,` ·`,` `,M?.width&&M?.height?`${M.width}×${M.height}`:`Resolución no medida`,` ·`,` `,M?.sourceFps?`${M.sourceFps} fps declarados`:`FPS no medidos`,(0,l.jsx)(`br`,{}),`Audio fuente: `,M?.audioCodec||`No medido`,` `,M?.sampleRate?`${M.sampleRate} Hz`:``,(0,l.jsx)(`br`,{}),`Vídeo de preview: `,M?.outputVideo?`${M.outputVideo} sin recodificar`:`No medido`,` · Audio de preview: `,M?.outputAudio?`${M.outputAudio} transcodificado${M.outputSampleRate?` · ${M.outputSampleRate} Hz`:``}`:`No medido`]}),(0,l.jsx)(`p`,{style:{color:`var(--text-muted)`},children:`HomeKit muestra Talk solo cuando Omni confirma el retorno de audio para esta cámara. La audibilidad en el altavoz físico aún requiere una prueba junto al dispositivo.`}),(0,l.jsxs)(`details`,{children:[(0,l.jsx)(`summary`,{children:`Diagnóstico avanzado de Apple Casa`}),(0,l.jsxs)(`div`,{style:{marginTop:10,display:`flex`,flexDirection:`column`,gap:8,fontSize:`0.75rem`},children:[(0,l.jsxs)(`div`,{style:{padding:`10px 12px`,background:`rgba(255, 255, 255, 0.03)`,borderRadius:6,border:`1px solid rgba(255, 255, 255, 0.08)`},children:[(0,l.jsx)(`div`,{style:{fontWeight:700,color:`#38bdf8`,marginBottom:4,display:`flex`,alignItems:`center`,gap:6},children:(0,l.jsx)(`span`,{children:`🔍 1. Fuente detectada`})}),(0,l.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:`4px 8px`,color:`#cbd5e1`},children:[(0,l.jsxs)(`div`,{children:[`Vídeo:`,` `,(0,l.jsx)(`strong`,{style:{color:`#f8fafc`},children:U}),` `,`(`,W,`)`]}),(0,l.jsxs)(`div`,{children:[`FPS:`,` `,(0,l.jsx)(`strong`,{style:{color:`#f8fafc`},children:G})]}),(0,l.jsxs)(`div`,{children:[`Perfil / Nivel:`,` `,(0,l.jsxs)(`strong`,{style:{color:`#f8fafc`},children:[tt||`No medido`,` /`,` `,nt||`No medido`]})]}),(0,l.jsxs)(`div`,{children:[`Bitrate / Pix fmt:`,` `,(0,l.jsxs)(`strong`,{style:{color:`#f8fafc`},children:[rt?`${rt} kb/s`:`No medido`,` `,`/ `,it||`No medido`]})]}),(0,l.jsxs)(`div`,{children:[`r/avg frame rate:`,` `,(0,l.jsx)(`strong`,{style:{color:`#f8fafc`},children:at})]}),(0,l.jsxs)(`div`,{children:[`Audio:`,` `,(0,l.jsx)(`strong`,{style:{color:`#f8fafc`},children:K})]}),(0,l.jsxs)(`div`,{children:[`Muestreo / Ch:`,` `,(0,l.jsx)(`strong`,{style:{color:`#f8fafc`},children:F&&C?.sourceUrl===h&&C?.audioSampleRate?`${C.audioSampleRate} Hz / ${C.audioChannels||`—`} ch`:J?.audioSampleRate?`${J.audioSampleRate} Hz / ${J.audioChannels||`—`} ch`:`No medido`})]})]}),(0,l.jsxs)(`div`,{style:{color:`#94a3b8`,marginTop:6},children:[`Evidencia: `,$e]}),$&&($.resolution||$.fps)&&(0,l.jsxs)(`div`,{style:{color:`#94a3b8`,marginTop:4},children:[`Configuración declarada, no medida:`,` `,$.resolution?`${$.resolution.width}×${$.resolution.height}`:`resolución no indicada`,$.fps?` @ ${$.fps} fps`:``]})]}),(0,l.jsxs)(`div`,{style:{padding:`10px 12px`,background:`rgba(255, 255, 255, 0.03)`,borderRadius:6,border:`1px solid rgba(255, 255, 255, 0.08)`},children:[(0,l.jsx)(`div`,{style:{fontWeight:700,color:`#a78bfa`,marginBottom:4},children:`📢 2. Live View anunciado a Apple Home`}),X?(0,l.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:`4px 8px`,color:`#cbd5e1`},children:[(0,l.jsxs)(`div`,{children:[`Codec:`,` `,(0,l.jsx)(`strong`,{style:{color:`#f8fafc`},children:X.codec.toUpperCase()})]}),(0,l.jsxs)(`div`,{children:[`Perfil / Nivel:`,` `,(0,l.jsxs)(`strong`,{style:{color:`#f8fafc`},children:[X.profiles.join(`, `),` /`,` `,X.levels.join(`, `)]})]}),(0,l.jsxs)(`div`,{style:{gridColumn:`1 / -1`},children:[`Resoluciones:`,` `,(0,l.jsx)(`strong`,{style:{color:`#f8fafc`},children:X.resolutions.map(e=>`${e[0]}×${e[1]}@${e[2]}`).join(`, `)})]})]}):(0,l.jsx)(`div`,{style:{color:`#94a3b8`},children:`Accesorio HomeKit no activo; no hay capacidades Live View disponibles.`})]}),(0,l.jsxs)(`div`,{style:{padding:`10px 12px`,background:`rgba(255, 255, 255, 0.03)`,borderRadius:6,border:`1px solid rgba(255, 255, 255, 0.08)`},children:[(0,l.jsx)(`div`,{style:{fontWeight:700,color:`#f59e0b`,marginBottom:4},children:`🤝 3. Solicitud Live View de Apple Home`}),Z?(0,l.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:`4px 8px`,color:`#cbd5e1`},children:[(0,l.jsxs)(`div`,{children:[`Sesión / SSRC:`,` `,(0,l.jsxs)(`strong`,{style:{color:`#f8fafc`},children:[Z.sessionId,` /`,` `,Z.videoSsrc??`—`]})]}),(0,l.jsxs)(`div`,{children:[`Estado:`,` `,(0,l.jsx)(`strong`,{style:{color:`#f8fafc`},children:Z.state})]}),(0,l.jsxs)(`div`,{children:[`Vídeo pedido:`,` `,(0,l.jsxs)(`strong`,{style:{color:`#f8fafc`},children:[Z.requestedVideo.width,`×`,Z.requestedVideo.height,`@`,Z.requestedVideo.fps,` fps`]})]}),(0,l.jsxs)(`div`,{children:[`Perfil / Nivel:`,` `,(0,l.jsxs)(`strong`,{style:{color:`#f8fafc`},children:[Z.requestedVideo.profile,` /`,` `,Z.requestedVideo.level]})]}),(0,l.jsxs)(`div`,{children:[`Audio pedido:`,` `,(0,l.jsx)(`strong`,{style:{color:`#f8fafc`},children:Z.requestedAudio?`${Z.requestedAudio.codec} ${Z.requestedAudio.sampleRate||`—`} Hz`:`Sin audio`})]}),(0,l.jsxs)(`div`,{children:[`Duración:`,` `,(0,l.jsx)(`strong`,{style:{color:`#f8fafc`},children:Z.durationMs===void 0?`Activa`:`${Z.durationMs} ms`})]})]}):(0,l.jsx)(`div`,{style:{color:`#94a3b8`},children:`Aún no hay una sesión Live View de Apple Home.`})]}),(0,l.jsxs)(`div`,{style:{padding:`10px 12px`,background:`rgba(255, 255, 255, 0.03)`,borderRadius:6,border:`1px solid rgba(255, 255, 255, 0.08)`},children:[(0,l.jsx)(`div`,{style:{fontWeight:700,color:`#34d399`,marginBottom:4},children:`🎞️ 4. Salida efectiva de FFmpeg`}),Z?.output?(0,l.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:`4px 8px`,color:`#cbd5e1`},children:[(0,l.jsxs)(`div`,{children:[`Procesamiento:`,` `,(0,l.jsx)(`strong`,{style:{color:`#f8fafc`},children:ot[Z.effectiveMode]})]}),(0,l.jsxs)(`div`,{children:[`Salida:`,` `,(0,l.jsxs)(`strong`,{style:{color:`#f8fafc`},children:[Z.output.width,`×`,Z.output.height,`@`,Z.output.fps,` fps`]})]}),(0,l.jsxs)(`div`,{children:[`Codec / Perfil / Nivel:`,` `,(0,l.jsxs)(`strong`,{style:{color:`#f8fafc`},children:[Z.output.codec,` /`,` `,Z.output.profile||`—`,` /`,` `,Z.output.level||`—`]})]}),(0,l.jsxs)(`div`,{children:[`Bitrate / Pix fmt:`,` `,(0,l.jsxs)(`strong`,{style:{color:`#f8fafc`},children:[Z.output.bitrateKbps?`${Z.output.bitrateKbps} kb/s`:`—`,` `,`/ `,Z.output.pixFmt||`—`]})]}),Z.effectiveMode===`normalization`&&(0,l.jsx)(`div`,{style:{gridColumn:`1 / -1`,color:`#fcd34d`},children:`La fuente 2K se reduce a 1080p antes de enviarse a HomeKit.`}),Z.fallbackReason&&(0,l.jsxs)(`div`,{style:{gridColumn:`1 / -1`,color:`#fcd34d`},children:[`Fallback: `,Z.fallbackReason]}),Z.error&&(0,l.jsxs)(`div`,{style:{gridColumn:`1 / -1`,color:`#fca5a5`},children:[`Error: `,Z.error]})]}):(0,l.jsx)(`div`,{style:{color:`#94a3b8`},children:`La salida aparecerá al iniciar Live View.`})]}),(0,l.jsxs)(`div`,{style:{padding:`10px 12px`,background:e?.hksvVerified?`rgba(16, 185, 129, 0.12)`:`rgba(255, 255, 255, 0.03)`,borderRadius:6,border:e?.hksvVerified?`1px solid rgba(16, 185, 129, 0.4)`:`1px solid rgba(255, 255, 255, 0.08)`},children:[(0,l.jsx)(`div`,{style:{fontWeight:700,color:e?.hksvVerified?`#34d399`:`#94a3b8`,marginBottom:4},children:`🎬 5. Grabación HKSV`}),Q?(0,l.jsxs)(`div`,{style:{color:`#cbd5e1`},children:[`Configuración del Hub:`,` `,(0,l.jsxs)(`strong`,{children:[Q.resolution[0],`×`,Q.resolution[1],`@`,Q.resolution[2],` fps`]}),` `,`· Fragmentos `,Q.fragmentLength,` ms · Prebuffer `,Q.prebufferLength,` ms`]}):(0,l.jsx)(`div`,{style:{color:`#94a3b8`},children:`Sin configuración HKSV seleccionada por el Hub.`})]})]})]}),(0,l.jsxs)(`div`,{style:{marginTop:12,padding:`10px 12px`,background:`rgba(15, 23, 42, 0.6)`,borderRadius:6,border:`1px solid rgba(255, 255, 255, 0.08)`},children:[(0,l.jsx)(`label`,{style:{display:`block`,fontSize:`0.78rem`,fontWeight:700,color:`#93c5fd`,marginBottom:6},children:`🍏 Modo de exportación Apple Home / HAP`}),Y?(0,l.jsxs)(`div`,{style:{fontSize:`0.76rem`,color:`#c084fc`,padding:`6px 8px`,background:`rgba(168, 85, 247, 0.1)`,border:`1px solid rgba(168, 85, 247, 0.25)`,borderRadius:4},children:[`💜 `,(0,l.jsx)(`strong`,{children:`HEVC / HKSV3 Nativo:`}),` Vídeo passthrough puro (-c:v copy). Audio remuestreado a AAC-LC/ELD. Cumple con iOS 27 y Apple HomeKit.`]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`select`,{className:`input`,value:Re,onChange:e=>ze(e.target.value),style:{width:`100%`,fontSize:`0.8rem`,padding:`6px 10px`},children:[(0,l.jsx)(`option`,{value:`auto`,children:`Auto (Passthrough H.264 en CameraController)`}),(0,l.jsx)(`option`,{value:`passthrough_h264`,children:`Passthrough H.264 (CameraController clásico)`}),(0,l.jsx)(`option`,{value:`disabled`,children:`Desactivado (No exportar a Apple Home)`})]}),(0,l.jsx)(`div`,{style:{fontSize:`0.72rem`,color:`#60a5fa`,marginTop:4},children:`✨ Vídeo passthrough puro (-c:v copy). Audio AAC compatible o transcodificado exclusivamente a AAC si la fuente es PCM/alaw.`})]})]})]})]}),(0,l.jsxs)(`div`,{style:{marginTop:14},children:[(0,l.jsxs)(`div`,{style:{marginBottom:10,padding:`10px 12px`,borderRadius:8,background:`rgba(59, 130, 246, 0.08)`,border:`1px solid rgba(59, 130, 246, 0.25)`,fontSize:`0.78rem`,color:`#93c5fd`,display:`flex`,alignItems:`flex-start`,gap:8},children:[(0,l.jsx)(`span`,{style:{fontSize:`1.2rem`,lineHeight:1},children:`🍏`}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`strong`,{style:{color:`#dbeafe`},children:`Luz y Sirena Nativas en Apple Home (Casa):`}),(0,l.jsxs)(`div`,{style:{marginTop:3,color:`#bfdbfe`,fontSize:`0.74rem`,lineHeight:1.4},children:[`Al emparejar la cámara mediante su código QR HAP principal (`,(0,l.jsx)(`strong`,{children:`📲 Enlazar QR`}),`),`,` `,(0,l.jsx)(`strong`,{children:`el foco/reflector y la sirena se integran de forma nativa dentro del mismo mosaico de la cámara en la app Casa`}),`. No necesitas escanear códigos adicionales en Casa. El botón `,(0,l.jsx)(`em`,{children:`"⚡ QR Matter"`}),` es exclusivamente si deseas sincronizar el foco o sirena como accesorio independiente en Google Home o Alexa.`]})]})]}),(0,l.jsxs)(`div`,{style:{marginBottom:14,padding:`12px 14px`,borderRadius:8,background:`rgba(0, 0, 0, 0.3)`,border:`1px solid rgba(56, 189, 248, 0.2)`,display:`flex`,flexDirection:`column`,gap:6},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(`span`,{style:{fontSize:`1.1rem`},children:`✨`}),(0,l.jsx)(`span`,{style:{fontSize:`0.82rem`,fontWeight:700,color:`#38bdf8`},children:`Hardware Físico Genuino de la Cámara`})]}),(0,l.jsxs)(`div`,{style:{color:`#94a3b8`,fontSize:`0.75rem`,lineHeight:1.4},children:[`El sistema extrae y asocia`,` `,(0,l.jsx)(`strong`,{children:`única y exclusivamente los componentes físicos integrados en el cuerpo de esta cámara`}),` `,`(foco/reflector, sirena y sensor de movimiento) a través de su identificador de hardware en Home Assistant. No se vincula ninguna luminaria ni interruptor ajeno del hogar.`]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:8},children:[(0,l.jsxs)(`span`,{style:{fontSize:`0.74rem`,fontWeight:700,color:`var(--dim)`,textTransform:`uppercase`},children:[`ESTADO EN TIEMPO REAL (`,H.length,` FUNCIONES ACTIVAS)`]}),(0,l.jsx)(`span`,{style:{fontSize:`0.72rem`,color:`#6ee7b7`,fontWeight:600},children:`🍏 Live View HAP + Controles Interactivos`})]}),H.length===0?(0,l.jsx)(`div`,{style:{padding:`12px 14px`,borderRadius:8,background:`rgba(255,255,255,0.02)`,border:`1px solid rgba(255,255,255,0.06)`,fontSize:`0.8rem`,color:`var(--dim)`,textAlign:`center`},children:`No se detectaron reflectores de luz ni sirenas físicas integradas para esta cámara.`}):(0,l.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:8},children:H.map(e=>{let t=_e===e.id,i=ye===e.id,o=!!Ce[e.id],s=xe[e.id]||(e.matterPairingCode?{pairingCode:e.matterPairingCode,manualCode:e.matterManualCode}:null),c=e.domain===`number`?`🥣`:e.domain===`button`?`▶`:e.type===`switch`?`⏻`:e.type===`light`?`💡`:e.type===`siren`?`🚨`:e.type===`doorbell`?`🔔`:`🏃`,u=[`number`,`button`,`switch`].includes(e.type)?`Control real de Home Assistant / Omni`:e.type===`light`?`Reflector / Foco físico integrado. Control directo y exportable a Matter.`:e.type===`siren`?`Sirena de alarma integrada. Activación disuasoria en tiempo real.`:e.type===`doorbell`?`Pulsador de timbre con notificación acústica y visual.`:`Sensor de presencia y movimiento con detección instantánea.`,d=e.domain===`number`?String(e.value??`No medido`):e.domain===`button`?`Acción puntual`:e.type===`switch`?e.state?`Activo`:`Apagado`:e.type===`light`?e.state?`🟢 Encendida`:`⚪ Apagada`:e.type===`siren`?e.state?`🚨 Activada`:`⚪ Silenciada`:e.type===`doorbell`?e.state?`🔔 Activo`:`⚪ En reposo`:e.state?`🟢 Movimiento`:`⚪ En reposo`;return(0,l.jsxs)(`div`,{style:{background:`rgba(255, 255, 255, 0.025)`,border:`1px solid rgba(255, 255, 255, 0.07)`,borderRadius:8,padding:`10px 12px`,display:`flex`,flexDirection:`column`,gap:8},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,flexWrap:`wrap`,gap:8},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[(0,l.jsx)(`span`,{style:{fontSize:`1.4rem`},children:c}),(0,l.jsxs)(`div`,{children:[(0,l.jsxs)(`div`,{style:{fontSize:`0.86rem`,fontWeight:600,display:`flex`,alignItems:`center`,gap:6,flexWrap:`wrap`},children:[(0,l.jsx)(`span`,{children:e.name}),e.topic&&(0,l.jsxs)(`span`,{style:{fontSize:`0.68rem`,color:`#a78bfa`,background:`rgba(139, 92, 246, 0.15)`,padding:`1px 6px`,borderRadius:4},children:[`MQTT: `,e.topic]})]}),(0,l.jsxs)(`div`,{style:{fontSize:`0.72rem`,color:`var(--text-secondary)`},children:[u,` ·`,` `,(0,l.jsx)(`code`,{style:{fontSize:`0.7rem`,color:`var(--dim)`},children:e.id})]})]})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,l.jsx)(`span`,{className:`tag`,style:{fontSize:`0.7rem`,whiteSpace:`nowrap`,background:e.state?`rgba(16, 185, 129, 0.15)`:`rgba(255,255,255,0.05)`,color:e.state?`#6ee7b7`:`var(--dim)`,border:e.state?`1px solid rgba(52, 211, 153, 0.3)`:`1px solid rgba(255,255,255,0.08)`},children:d}),(e.type===`light`||e.type===`siren`||e.type===`switch`||e.type===`button`)&&(0,l.jsx)(`button`,{className:`button button-sm ${e.state?`button-danger`:`button-primary`}`,type:`button`,onClick:()=>mt(e),disabled:t,style:{fontSize:`0.76rem`,padding:`4px 10px`},children:t?`...`:e.domain===`button`?`Ejecutar`:e.type===`light`?e.state?`💡 Apagar Luz`:`💡 Encender Luz`:e.type===`siren`?e.state?`🚨 Silenciar`:`🚨 Activar Sirena`:e.state?`Apagar`:`Encender`}),e.domain===`number`&&(0,l.jsxs)(`label`,{children:[`Porciones / valor`,(0,l.jsx)(`input`,{type:`number`,"aria-label":e.name,defaultValue:e.value,min:e.min,max:e.max,step:e.step||1,onBlur:async t=>{let i=Number(t.currentTarget.value);try{await r.controlCameraEntity(e.id,`set_value`,i),n(),f(`Valor guardado en Omni`)}catch(e){f(e.message,!0)}}})]}),(0,l.jsx)(`button`,{className:`button button-sm ${i?`button-primary`:`button-secondary`}`,type:`button`,onClick:()=>ht(e),disabled:o||e.domain===`number`,style:{fontSize:`0.76rem`,padding:`4px 10px`},title:`Ver código QR Matter independiente para vincular esta entidad`,children:o?`Generando...`:`⚡ QR Matter (Separado)`})]})]}),i&&(0,l.jsxs)(`div`,{style:{marginTop:6,padding:`12px`,background:`rgba(0, 0, 0, 0.35)`,borderRadius:8,border:`1px solid rgba(139, 92, 246, 0.3)`},children:[(0,l.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:8},children:[(0,l.jsxs)(`span`,{style:{fontSize:`0.78rem`,fontWeight:700,color:`#c084fc`},children:[`⚡ VINCULACIÓN MATTER 1.6 ·`,` `,e.name.toUpperCase()]}),(0,l.jsx)(`span`,{style:{fontSize:`0.7rem`,color:`var(--dim)`},children:`QR INDEPENDIENTE DE CÁMARA`})]}),s?.pairingCode?(0,l.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,gap:8},children:[(0,l.jsx)(a,{pairingCode:s.pairingCode,manualCode:s.manualCode||s.pairingCode,entityName:e.name,elementId:`matter-qr-entity-${e.id.replace(/[^a-zA-Z0-9]/g,`_`)}`,variant:`matter-badge`,noteText:`⚡ Para Google Home o Alexa (Matter 1.6). En Apple Home ya está integrada de forma nativa dentro de la cámara (no escanear aquí para Casa).`}),(0,l.jsx)(`button`,{className:`button button-sm button-secondary`,type:`button`,onClick:()=>gt(e),disabled:o||e.domain===`number`,style:{fontSize:`0.74rem`},children:o?`Abriendo...`:`🌐 Reabrir Multi-Admin (15 min)`})]}):(0,l.jsxs)(`div`,{style:{textAlign:`center`,padding:`8px 0`},children:[(0,l.jsx)(`p`,{style:{fontSize:`0.8rem`,color:`var(--dim)`,marginBottom:8},children:`Esta entidad aún no está publicada individualmente en el bus Matter.`}),(0,l.jsx)(`button`,{className:`button button-primary button-sm`,type:`button`,onClick:()=>ht(e),disabled:o||e.domain===`number`,style:{fontSize:`0.78rem`},children:o?`Publicando...`:`⚡ Publicar en Matter y Generar QR`})]})]})]},e.id)})})]}),(0,l.jsxs)(`div`,{className:`diagnostics-panel`,style:{marginTop:14,userSelect:`text`},children:[(0,l.jsxs)(`div`,{className:`diagnostics-heading`,children:[(0,l.jsx)(`span`,{"aria-hidden":`true`,children:`✓`}),(0,l.jsx)(`strong`,{children:`Diagnóstico y estado de la cámara`}),(0,l.jsx)(`button`,{className:`copy-diagnostics-button`,type:`button`,onClick:async()=>{let t=[`=== DIAGNÓSTICO DE CÁMARA ===`,`ID: ${I}`,`Nombre: ${L}`,`Fuente de vídeo: ${F?e.sourceProvider===`home_assistant`?`Home Assistant RTSP directo`:`Camera.UI`:`Scrypted`}`,`Marca: ${R}`,`Modelo: ${Ze}`,`Estado: ${Ue?`En línea`:`Desconectada`}`,`RTSP URL: ${h||`No configurada`}`,`Transporte RTSP: ${_.toUpperCase()}`,`HomeKit HAP: ${z?`Emparejado en Apple Home`:`Listo para vincular`}`,`HomeKit Setup PIN: ${V}`,`HomeKit Setup ID: ${qe}`,`HomeKit Setup URI: ${Je()}`,`Resolución Probed: ${W}`,`Códec Video: ${U}`,`FPS: ${G}`,`Audio: ${K}`,`Entidades Físicas Descubiertas: ${H.length}`,...H.map(e=>` - [${e.type.toUpperCase()}] ${e.name} (${e.id}) - Estado: ${e.state?`ON`:`OFF`}${e.topic?` - MQTT: ${e.topic}`:``}`)].join(`
6
+ `);await s(t)?f(`✓ Diagnóstico de cámara copiado al portapapeles`):f(`⚠️ No se pudo acceder al portapapeles`,!0)},title:`Copiar diagnóstico de cámara`,children:`📋 Copiar diagnóstico`})]}),(0,l.jsx)(`p`,{style:{margin:`6px 0 4px`,fontSize:`0.78rem`,color:`var(--dim)`},children:Ue?`Cámara en línea y operativa para Live View HAP.`:`Cámara no responde o desconectada.`})]}),(0,l.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginTop:16},children:[(0,l.jsx)(`button`,{className:`button button-danger`,type:`button`,onClick:ct,disabled:oe,children:`🗑️ Eliminar de la exportación`}),(0,l.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,l.jsx)(`button`,{className:`button button-secondary`,type:`button`,onClick:t,children:`Cancelar`}),(0,l.jsx)(`button`,{className:`button button-primary`,type:`button`,onClick:pt,children:`💾 Guardar`})]})]})]})]})]})})};export{f as CameraConfigModal};
@@ -0,0 +1 @@
1
+ import{i as e,n as t,o as n,r}from"./index-CONl6ATp.js";var i=n(e(),1),a=t(),o=({config:e,onClose:t,onRefresh:n,showToast:o})=>{let[s,c]=(0,i.useState)(!1),[l,u]=(0,i.useState)(``),[d,f]=(0,i.useState)(``),[p,m]=(0,i.useState)(``),[h,g]=(0,i.useState)(``),[_,v]=(0,i.useState)(``),[y,b]=(0,i.useState)(!0),[x,S]=(0,i.useState)(!0),[C,w]=(0,i.useState)(`camera.ui`),[T,E]=(0,i.useState)(!1),[D,O]=(0,i.useState)(!1),[k,A]=(0,i.useState)(!1),[j,M]=(0,i.useState)(null),[N,P]=(0,i.useState)([]),[F,I]=(0,i.useState)(`settings`),L=(0,i.useRef)(!1);(0,i.useEffect)(()=>{if(e&&!L.current){L.current=!0,c(e.enabled??!0);let t=(e.serverUrl||``).trim();u(t||`http://127.0.0.1:8181`),f(e.username||``),g(e.rtspUsername||``),b(e.allowSelfSignedCertificate??!0),S(e.mqttEnabled??!0),w(e.mqttTopicPrefix||`camera.ui`)}R()},[e]);let R=async()=>{try{let e=await r.getCameraUiCameras();P(e)}catch{}},z=async()=>{let t=l.trim()||e?.serverUrl||`http://127.0.0.1:8181`;if(!t)o(`Ingresa la URL del servidor Camera.UI (ej. http://192.168.1.100:8181)`,!0);else{E(!0),M({text:`Comprobando conexión con Camera.UI...`});try{let e=await r.testCameraUiConnection({serverUrl:t,username:d.trim()||void 0,password:p.trim()?p:void 0,allowSelfSignedCertificate:y});e.ok?M({text:`✓ ${e.message}`}):M({text:`❌ ${e.message}`,isError:!0})}catch(e){M({text:`❌ Error: ${e.message}`,isError:!0})}finally{E(!1)}}},B=async()=>{let t=l.trim()||e?.serverUrl||`http://127.0.0.1:8181`;if(!t)o(`Ingresa la URL del servidor Camera.UI (ej. http://192.168.1.100:8181)`,!0);else{O(!0);try{let e=await r.syncCameraUiCameras({serverUrl:t,username:d.trim()||void 0,password:p.trim()?p:void 0,allowSelfSignedCertificate:y});e.success?(o(`✓ Sincronización completa: ${e.totalCameras} cámaras detectadas (${e.newCameras} nuevas).`),P(e.cameras||[]),n()):o(`Error al sincronizar cámaras de Camera.UI`,!0)}catch(e){o(e.message||`Error al sincronizar`,!0)}finally{O(!1)}}},V=async e=>{try{await r.toggleCameraUiHomeKit(e),await R(),o(`✓ Estado de HomeKit actualizado.`),n()}catch(e){o(`Error: ${e.message}`,!0)}},H=async e=>{try{(await r.resetCameraUiPairing(e)).success?(o(`✓ Emparejamiento HomeKit restablecido. Listo para escanear en Apple Home.`),await R(),n()):o(`No se pudo restablecer el emparejamiento`,!0)}catch(e){o(`Error: ${e.message}`,!0)}};return(0,a.jsx)(`div`,{className:`modal-backdrop open`,role:`dialog`,"aria-modal":`true`,children:(0,a.jsxs)(`section`,{className:`modal`,style:{maxWidth:620,maxHeight:`90vh`,overflowY:`auto`},children:[(0,a.jsx)(`button`,{className:`icon-button`,type:`button`,"aria-label":`Cerrar`,onClick:t,children:`×`}),(0,a.jsxs)(`header`,{className:`modal-header`,children:[(0,a.jsx)(`span`,{className:`modal-icon`,style:{fontSize:`1.8rem`},children:`🎥`}),(0,a.jsxs)(`div`,{children:[(0,a.jsx)(`p`,{className:`eyebrow`,children:`INTEGRACIÓN DE CÁMARAS Y MQTT`}),(0,a.jsx)(`h2`,{children:`Camera.UI / Homebridge Camera.UI`}),(0,a.jsx)(`p`,{className:`entity-id`,children:`Descubrimiento RTSP, eventos MQTT (movimiento/timbre) y puente directo HomeKit HAP`})]})]}),(0,a.jsxs)(`div`,{style:{display:`flex`,gap:10,margin:`12px 0 16px`,borderBottom:`1px solid rgba(255,255,255,0.1)`,paddingBottom:8},children:[(0,a.jsx)(`button`,{type:`button`,className:`button ${F===`settings`?`button-primary`:`button-secondary`}`,style:{fontSize:`0.85rem`,padding:`6px 14px`},onClick:()=>I(`settings`),children:`⚙️ Configuración y Conexión`}),(0,a.jsxs)(`button`,{type:`button`,className:`button ${F===`cameras`?`button-primary`:`button-secondary`}`,style:{fontSize:`0.85rem`,padding:`6px 14px`},onClick:()=>{I(`cameras`),R()},children:[`📷 Cámaras Descubiertas (`,N.length,`)`]})]}),F===`settings`?(0,a.jsxs)(`form`,{onSubmit:async e=>{if(e.preventDefault(),!l.trim())o(`Ingresa la URL del servidor Camera.UI`,!0);else{A(!0);try{await r.saveCameraUiConfig({enabled:s,serverUrl:l.trim(),username:d.trim()||void 0,password:p||void 0,rtspUsername:h.trim()||void 0,rtspPassword:_||void 0,allowSelfSignedCertificate:y,mqttEnabled:x,mqttTopicPrefix:C.trim()||`camera.ui`}),o(`✓ Configuración de Camera.UI guardada exitosamente`),n(),t()}catch(e){o(e.message||`Error al guardar`,!0)}finally{A(!1)}}},style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,a.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:10,cursor:`pointer`,fontSize:`0.9rem`,fontWeight:600},children:[(0,a.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked)}),(0,a.jsx)(`span`,{children:`Habilitar integración Camera.UI`})]}),(0,a.jsxs)(`div`,{children:[(0,a.jsx)(`label`,{style:{display:`block`,fontSize:`0.8rem`,color:`var(--dim)`,marginBottom:4},children:`URL del Servidor Camera.UI`}),(0,a.jsx)(`input`,{type:`url`,value:l,onChange:e=>u(e.target.value),placeholder:`http://192.168.1.100:8181 o https://camera-ui.example`,required:!0,style:{width:`100%`,padding:`8px 12px`,borderRadius:8,background:`rgba(0,0,0,0.2)`,border:`1px solid rgba(255,255,255,0.1)`,color:`#fff`}}),(0,a.jsx)(`span`,{style:{fontSize:`0.75rem`,color:`var(--dim)`},children:`Puerto REST por defecto de Camera.UI: 8181 (o HTTPS en 3543). El RTSP nativo de esta instalación usa el puerto 2101.`}),(0,a.jsx)(`div`,{style:{marginTop:8},children:(0,a.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,cursor:`pointer`,fontSize:`0.8rem`,color:`var(--dim)`},children:[(0,a.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>b(e.target.checked)}),(0,a.jsx)(`span`,{children:`Permitir certificados SSL autofirmados (HTTPS local)`})]})})]}),(0,a.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:10},children:[(0,a.jsxs)(`div`,{children:[(0,a.jsx)(`label`,{style:{display:`block`,fontSize:`0.8rem`,color:`var(--dim)`,marginBottom:4},children:`Usuario RTSP de Camera.UI`}),(0,a.jsx)(`input`,{type:`text`,value:h,onChange:e=>g(e.target.value),placeholder:`admin`,style:{width:`100%`,padding:`8px 12px`,borderRadius:8,background:`rgba(0,0,0,0.2)`,border:`1px solid rgba(255,255,255,0.1)`,color:`#fff`}})]}),(0,a.jsxs)(`div`,{children:[(0,a.jsx)(`label`,{style:{display:`block`,fontSize:`0.8rem`,color:`var(--dim)`,marginBottom:4},children:`Contraseña RTSP`}),(0,a.jsx)(`input`,{type:`password`,value:_,onChange:e=>v(e.target.value),placeholder:e?.hasRtspPassword?`•••••••• (guardada)`:`••••••••`,style:{width:`100%`,padding:`8px 12px`,borderRadius:8,background:`rgba(0,0,0,0.2)`,border:`1px solid rgba(255,255,255,0.1)`,color:`#fff`}})]})]}),(0,a.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:10},children:[(0,a.jsxs)(`div`,{children:[(0,a.jsx)(`label`,{style:{display:`block`,fontSize:`0.8rem`,color:`var(--dim)`,marginBottom:4},children:`Usuario (opcional)`}),(0,a.jsx)(`input`,{type:`text`,value:d,onChange:e=>f(e.target.value),placeholder:`admin`,style:{width:`100%`,padding:`8px 12px`,borderRadius:8,background:`rgba(0,0,0,0.2)`,border:`1px solid rgba(255,255,255,0.1)`,color:`#fff`}})]}),(0,a.jsxs)(`div`,{children:[(0,a.jsx)(`label`,{style:{display:`block`,fontSize:`0.8rem`,color:`var(--dim)`,marginBottom:4},children:`Contraseña (opcional)`}),(0,a.jsx)(`input`,{type:`password`,value:p,onChange:e=>m(e.target.value),placeholder:e?.hasPassword?`•••••••• (guardada)`:`••••••••`,style:{width:`100%`,padding:`8px 12px`,borderRadius:8,background:`rgba(0,0,0,0.2)`,border:`1px solid rgba(255,255,255,0.1)`,color:`#fff`}})]})]}),(0,a.jsxs)(`div`,{style:{padding:`10px 12px`,borderRadius:8,background:`rgba(255,255,255,0.03)`,border:`1px solid rgba(255,255,255,0.08)`},children:[(0,a.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,cursor:`pointer`,fontSize:`0.85rem`,fontWeight:500},children:[(0,a.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked)}),(0,a.jsx)(`span`,{children:`Escuchar tópicos MQTT de Camera.UI para Movimiento y Timbre`})]}),x&&(0,a.jsxs)(`div`,{style:{marginTop:8},children:[(0,a.jsx)(`label`,{style:{display:`block`,fontSize:`0.75rem`,color:`var(--dim)`,marginBottom:4},children:`Prefijo de Tópicos MQTT`}),(0,a.jsx)(`input`,{type:`text`,value:C,onChange:e=>w(e.target.value),placeholder:`camera.ui`,style:{width:`100%`,padding:`6px 10px`,borderRadius:6,background:`rgba(0,0,0,0.2)`,border:`1px solid rgba(255,255,255,0.1)`,color:`#fff`,fontSize:`0.85rem`}}),(0,a.jsxs)(`span`,{style:{fontSize:`0.75rem`,color:`var(--dim)`,display:`block`,marginTop:4},children:[`Se suscribe automáticamente a `,(0,a.jsx)(`code`,{children:`camera.ui/#`}),` y `,(0,a.jsx)(`code`,{children:`cameraui/#`}),` para disparar notificaciones de movimiento y timbres en Apple Home.`]})]})]}),j&&(0,a.jsx)(`div`,{style:{padding:`8px 12px`,borderRadius:8,fontSize:`0.8rem`,background:j.isError?`rgba(239,68,68,0.15)`:`rgba(16,185,129,0.15)`,color:j.isError?`#fca5a5`:`#6ee7b7`},children:j.text}),(0,a.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,gap:8,marginTop:12},children:[(0,a.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,a.jsx)(`button`,{className:`button button-secondary`,type:`button`,onClick:z,disabled:T,children:T?`Comprobando...`:`Probar Conexión`}),(0,a.jsx)(`button`,{className:`button button-secondary`,type:`button`,onClick:B,disabled:D,children:D?`Sincronizando...`:`🔄 Sincronizar Cámaras`})]}),(0,a.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,a.jsx)(`button`,{className:`button button-secondary`,type:`button`,onClick:t,children:`Cancelar`}),(0,a.jsx)(`button`,{className:`button button-primary`,type:`submit`,disabled:k,children:k?`Guardando...`:`Guardar`})]})]})]}):(0,a.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,a.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,a.jsx)(`span`,{style:{fontSize:`0.85rem`,color:`var(--dim)`},children:N.length===0?`No se han sincronizado cámaras aún.`:`${N.length} cámaras encontradas en Camera.UI.`}),(0,a.jsx)(`button`,{className:`button button-secondary`,type:`button`,onClick:B,disabled:D,style:{fontSize:`0.8rem`,padding:`4px 10px`},children:D?`Sincronizando...`:`🔄 Sincronizar Ahora`})]}),N.length===0?(0,a.jsx)(`div`,{style:{padding:`24px 16px`,textAlign:`center`,background:`rgba(255,255,255,0.02)`,borderRadius:8,border:`1px dashed rgba(255,255,255,0.1)`},children:(0,a.jsxs)(`p`,{style:{margin:0,color:`var(--dim)`,fontSize:`0.9rem`},children:[`Asegúrate de que la URL del servidor sea correcta y presiona `,(0,a.jsx)(`strong`,{children:`Sincronizar Ahora`}),`.`]})}):(0,a.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:N.map(e=>(0,a.jsxs)(`div`,{style:{padding:`12px`,borderRadius:8,background:`rgba(255,255,255,0.03)`,border:`1px solid rgba(255,255,255,0.08)`,display:`flex`,flexDirection:`column`,gap:8},children:[(0,a.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`flex-start`},children:[(0,a.jsxs)(`div`,{children:[(0,a.jsx)(`strong`,{style:{fontSize:`0.95rem`},children:e.name}),(0,a.jsxs)(`div`,{style:{fontSize:`0.75rem`,color:`var(--dim)`,marginTop:2},children:[`ID: `,(0,a.jsx)(`code`,{children:e.id}),` · Puerto HAP: `,(0,a.jsx)(`code`,{children:e.port||`Pendiente`}),` · Firmware: `,(0,a.jsx)(`code`,{children:e.firmwareRevision||`Versión HAP no disponible`})]})]}),(0,a.jsx)(`span`,{style:{fontSize:`0.75rem`,padding:`2px 8px`,borderRadius:6,background:e.isPaired?`rgba(16,185,129,0.2)`:`rgba(245,158,11,0.2)`,color:e.isPaired?`#6ee7b7`:`#fde68a`},children:e.isPaired?`✓ Vinculada en Apple Home`:`⚠️ Lista para vincular`})]}),(0,a.jsxs)(`div`,{style:{fontSize:`0.8rem`,color:`var(--dim)`,wordBreak:`break-all`},children:[`RTSP: `,(0,a.jsx)(`code`,{children:e.rtspUrl})]}),(0,a.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginTop:4,paddingTop:8,borderTop:`1px solid rgba(255,255,255,0.06)`},children:[(0,a.jsxs)(`div`,{style:{display:`flex`,gap:8,alignItems:`center`},children:[(0,a.jsxs)(`span`,{style:{fontSize:`0.8rem`},children:[`PIN: `,(0,a.jsx)(`strong`,{children:e.pincode||`031-45-154`})]}),e.setupUri&&!e.isPaired&&(0,a.jsx)(`a`,{href:e.setupUri,target:`_blank`,rel:`noopener noreferrer`,className:`button button-secondary`,style:{fontSize:`0.75rem`,padding:`2px 8px`,textDecoration:`none`},children:`🔗 Código HomeKit`})]}),(0,a.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,a.jsx)(`button`,{type:`button`,className:`button button-secondary`,style:{fontSize:`0.75rem`,padding:`3px 8px`},onClick:()=>H(e.id),title:`Restablece el ID y genera nuevo PIN si Apple Home no la encuentra`,children:`Restablecer PIN`}),(0,a.jsx)(`button`,{type:`button`,className:`button ${e.homeKitEnabled?`button-primary`:`button-secondary`}`,style:{fontSize:`0.75rem`,padding:`3px 8px`},onClick:()=>V(e.id),title:e.homeKitEnabled?`Desactiva la exportación HAP de esta cámara`:`Activa y publica esta cámara para Apple Home`,children:e.homeKitEnabled?`Desactivar HomeKit`:`Activar HomeKit`})]})]})]},e.id))})]})]})})};export{o as CameraUiModal};
@@ -0,0 +1,5 @@
1
+ import{i as e,n as t,o as n,r}from"./index-CONl6ATp.js";import{n as i,t as a}from"./QRCodeDisplay-B3RFLtWz.js";import{t as o}from"./clipboard-CnKYMNaq.js";var s=n(e(),1),c=t(),l=({entity:e,onClose:t,onSuccess:n,showToast:i})=>{let[a,o]=(0,s.useState)([]),[l,u]=(0,s.useState)(`humidifier`),[d,f]=(0,s.useState)(!1),[p,m]=(0,s.useState)(!0);return(0,s.useEffect)(()=>{r.getHapProfiles().then(t=>{o(t);let n=e.domain,r={humidifier:`humidifier`,media_player:`television`,valve:`valve_irrigation`,alarm_control_panel:`security_system`,cover:`garage_door`,input_boolean:`switch_hap`,input_select:`switch_hap`,remote:`television`,climate:`heater_cooler`,water_heater:`heater_cooler`,number:`number_hap`,select:`switch_hap`,button:`switch_hap`,scene:`switch_hap`,script:`switch_hap`,automation:`switch_hap`,input_number:`number_hap`};r[n]&&u(r[n])}).catch(()=>i(`Error al cargar perfiles HAP`,!0)).finally(()=>m(!1))},[e.domain]),(0,c.jsx)(`div`,{style:{position:`fixed`,inset:0,background:`rgba(0,0,0,0.75)`,display:`flex`,alignItems:`center`,justifyContent:`center`,zIndex:1e3},onClick:t,children:(0,c.jsxs)(`div`,{style:{background:`#1a1a2e`,border:`1px solid rgba(245,158,11,0.35)`,borderRadius:16,padding:`28px 32px`,maxWidth:480,width:`90%`,boxShadow:`0 8px 40px rgba(0,0,0,0.6)`,color:`#e5e7eb`},onClick:e=>e.stopPropagation(),children:[(0,c.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:20},children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`span`,{style:{fontSize:22},children:`🏠`}),` `,(0,c.jsx)(`span`,{style:{fontWeight:700,fontSize:18,color:`#fcd34d`},children:`Exportar como HomeKit HAP`})]}),(0,c.jsx)(`button`,{onClick:t,style:{background:`none`,border:`none`,color:`#9ca3af`,fontSize:22,cursor:`pointer`,lineHeight:1},children:`×`})]}),(0,c.jsxs)(`p`,{style:{margin:`0 0 16px`,color:`#9ca3af`,fontSize:13},children:[`Entidad:`,` `,(0,c.jsx)(`span`,{style:{color:`#e5e7eb`,fontWeight:600},children:e.name||e.entityId}),` `,(0,c.jsx)(`code`,{style:{background:`rgba(255,255,255,0.07)`,borderRadius:4,padding:`1px 6px`,fontSize:11},children:e.entityId})]}),(0,c.jsx)(`label`,{style:{display:`block`,marginBottom:8,fontWeight:600,fontSize:13,color:`#d1d5db`},children:`Tipo de accesorio HomeKit`}),p?(0,c.jsx)(`p`,{style:{color:`#6b7280`,fontSize:13},children:`Cargando perfiles…`}):(0,c.jsx)(`select`,{value:l,onChange:e=>u(e.target.value),style:{width:`100%`,padding:`10px 12px`,background:`rgba(255,255,255,0.06)`,border:`1px solid rgba(245,158,11,0.3)`,borderRadius:8,color:`#e5e7eb`,fontSize:14,marginBottom:20,cursor:`pointer`},children:a.map(e=>(0,c.jsx)(`option`,{value:e.id,style:{background:`#1a1a2e`},children:e.label},e.id))}),(0,c.jsxs)(`div`,{style:{background:`rgba(245,158,11,0.08)`,border:`1px solid rgba(245,158,11,0.2)`,borderRadius:8,padding:`10px 14px`,marginBottom:20,fontSize:12,color:`#fbbf24`},children:[`🏠 Este accesorio aparecerá en Apple Home con el icono del tipo seleccionado. Escanea el código QR en la app `,(0,c.jsx)(`strong`,{children:`Apple Home`}),` para vincularlo.`]}),(0,c.jsxs)(`div`,{style:{display:`flex`,gap:12,justifyContent:`flex-end`},children:[(0,c.jsx)(`button`,{onClick:t,style:{padding:`9px 20px`,background:`rgba(255,255,255,0.06)`,border:`1px solid rgba(255,255,255,0.12)`,borderRadius:8,color:`#9ca3af`,cursor:`pointer`,fontSize:14},children:`Cancelar`}),(0,c.jsx)(`button`,{onClick:async()=>{f(!0);try{let t=await r.registerHap(e.entityId,l);t.success?(i(`✓ ${e.name||e.entityId} publicado como "${a.find(e=>e.id===l)?.label||l}" vía HomeKit HAP (PIN: ${t.pincode})`),n(t.pincode||``,t.port||0)):i(t.error||`Error al publicar accesorio HAP`,!0)}catch(e){i(e.message||`Error al publicar accesorio HAP`,!0)}finally{f(!1)}},disabled:d||p,style:{padding:`9px 22px`,background:`rgba(245,158,11,0.15)`,border:`1px solid rgba(245,158,11,0.4)`,borderRadius:8,color:`#fcd34d`,fontWeight:700,cursor:d?`not-allowed`:`pointer`,fontSize:14,opacity:d?.6:1},children:d?`Publicando…`:`🏠 Publicar en HomeKit HAP`})]})]})})};function u(e){if(!e||!e.entities||e.entities.length===0)return{isRecommended:!1,recommendedProfile:`humidifier`,categoryName:``,badgeText:``,reason:``,appleAdvantage:``};let t=[e.name||``,e.model||``,e.manufacturer||``,...e.entities.flatMap(e=>[e.entityId,e.name||``,e.domain||``,e.device_class||``])].join(` `).toLowerCase(),n=new Set(e.entities.map(e=>e.domain));if(n.has(`vacuum`)||e.entities.some(e=>e.domain===`vacuum`)||/\b(vacuum|aspiradora|robotina|rvc|roborock|roomba|deebot|dreame)\b/i.test(`${e.name||``} ${e.model||``}`))return{isRecommended:!1,recommendedProfile:`humidifier`,categoryName:``,badgeText:``,reason:``,appleAdvantage:``};if(n.has(`climate`)||e.entities.some(e=>e.domain===`climate`)||/\b(aire|ac|a\/c|air_conditioner|clima|climate|minisplit|split|hvac)\b/i.test(t)){let t=e.entities.find(e=>e.domain===`climate`)?.attributes?.hvac_modes;return Array.isArray(t)&&t.includes(`heat`)&&!t.some(e=>e===`cool`||e===`heat_cool`)?{isRecommended:!0,recommendedProfile:`thermostat_hap`,categoryName:`Termostato HomeKit`,badgeText:`⭐ Recomendado para Apple Casa (Termostato)`,reason:`Home Assistant anuncia calefacción sin modo de frío.`,appleAdvantage:`Apple Casa presenta la temperatura y la consigna en el control de termostato.`}:{isRecommended:!0,recommendedProfile:`heater_cooler`,categoryName:`Aire Acondicionado (HeaterCooler)`,badgeText:`⭐ Recomendado para Apple Home (Aire Acondicionado)`,reason:`En Matter, los aires acondicionados se exponen como termostatos básicos de pared sin control de velocidad de ventilador ni oscilación.`,appleAdvantage:`En HomeKit HAP (HeaterCooler) se integra con la tarjeta nativa de Aire Acondicionado en Apple Casa: selector de temperatura, velocidad del ventilador (0-100%) y botón de oscilación (swing).`}}if(n.has(`alarm_control_panel`)||/alarm|alarma|argus|seguridad|security|panel_alarma|siren|sirena/i.test(t))return{isRecommended:!0,recommendedProfile:`security_system`,categoryName:`Panel de Alarma / Sistema de Seguridad`,badgeText:`⭐ Recomendado para Apple Home (Sistema de Alarma)`,reason:`Apple Home no soporta Paneles de Alarma de forma nativa en la especificación actual de Matter.`,appleAdvantage:`En HomeKit HAP se reconoce con el widget nativo de Sistema de Seguridad en Apple Casa (Armar en casa, Armar fuera, Noche y Desarmar) con alertas y notificaciones críticas de iOS.`};if(n.has(`humidifier`)||/difusor|diffuser|humidif|deshumidif|dehumidif|aroma|esencia/i.test(t)){let e=/deshumidif|dehumidif/i.test(t);return{isRecommended:!0,recommendedProfile:e?`dehumidifier`:`humidifier`,categoryName:e?`Deshumidificador`:`Difusor / Humidificador`,badgeText:`⭐ Recomendado para Apple Home (${e?`Deshumidificador`:`Difusor`})`,reason:`Matter no incluye la categoría de Difusor ni Humidificador en Apple Home, exponiéndolos como simples ventiladores con niebla.`,appleAdvantage:`En HomeKit HAP se integra como ${e?`Deshumidificador`:`Difusor / Humidificador`} nativo en Apple Casa con icono propio y ajuste porcentual de humedad relativa.`}}if(/purificad|air_purifier|purifier|filtro_aire/i.test(t))return{isRecommended:!0,recommendedProfile:`air_purifier`,categoryName:`Purificador de Aire`,badgeText:`⭐ Recomendado para Apple Home (Purificador)`,reason:`En Matter los purificadores suelen exponerse como simples interruptores o ventiladores sin calidad de aire.`,appleAdvantage:`En HomeKit HAP se integra como Purificador de Aire nativo con velocidad de ventilador, calidad del aire y estado de filtro.`};if(n.has(`media_player`)||/\b(televisi[oó]n|tv|media_player|roku|appletv|apple_tv|chromecast|soundbar|kodi)\b/i.test(t))return{isRecommended:!0,recommendedProfile:`television`,categoryName:`Televisor / Reproductor Multimedia`,badgeText:`⭐ Recomendado para Apple Home (Televisor)`,reason:`Apple Home no soporta reproductores multimedia en Matter de manera completa.`,appleAdvantage:`En HomeKit HAP se integra como Televisor en Apple Casa y activa el mando a distancia interactivo en el Centro de Control de iOS con cambio de entradas y encendido/apagado.`};if(n.has(`valve`)||/v[aá]lvula|valve|riego|irrigation|grifo|faucet|sprinkler/i.test(t)){let e=/grifo|faucet/i.test(t);return{isRecommended:!0,recommendedProfile:e?`valve_faucet`:`valve_irrigation`,categoryName:e?`Grifo / Válvula`:`Sistema de Riego / Válvula`,badgeText:`⭐ Recomendado para Apple Home (Válvula)`,reason:`Las válvulas en Matter tienen soporte limitado y no interactivo en Apple Home.`,appleAdvantage:`En HomeKit HAP ofrece temporizador de apertura configurable y control directo de agua en Apple Casa.`}}return/garaje|garage/i.test(t)?{isRecommended:!0,recommendedProfile:`garage_door`,categoryName:`Puerta de Garaje`,badgeText:`⭐ Recomendado para Apple Home (Garaje)`,reason:`En Matter suele aparecer como persiana genérica.`,appleAdvantage:`En HomeKit HAP muestra el icono nativo de Garaje, estados 'Abriendo/Cerrando' y compatibilidad con Siri y CarPlay al aproximarte a tu casa.`}:{isRecommended:!1,recommendedProfile:`humidifier`,categoryName:``,badgeText:``,reason:``,appleAdvantage:``}}function d(e){switch(e){case`light`:return`💡`;case`switch`:return`🔌`;case`camera`:return`📹`;case`climate`:return`❄️`;case`fan`:return`🌀`;case`cover`:return`🪟`;case`lock`:return`🔒`;case`sensor`:return`🌡️`;case`binary_sensor`:return`🔔`;case`vacuum`:return`🤖`;case`humidifier`:return`💧`;case`select`:return`🎛️`;case`button`:return`🔘`;default:return`⚡`}}function f(e,t){let n=t||`Controlador Matter`,r=e==null?null:Number(e);return r===4937||/apple/i.test(n)?{icon:`🍎`,name:`Apple Home`}:r===24582||/google/i.test(n)?{icon:`🌐`,name:`Google Home`}:r===4625||/amazon|alexa/i.test(n)?{icon:`🔊`,name:`Amazon Alexa`}:r!==null&&[4321,4362,4731,4469,4960].includes(r)||/smartthings|samsung/i.test(n)?{icon:`💠`,name:`Samsung SmartThings`}:r===4877||/home assistant/i.test(n)?{icon:`🏠`,name:`Home Assistant`}:{icon:`📱`,name:n}}function p(e,t,n){let r=new Map;if(!t)return r;let i=e.filter(e=>(e.domain===`switch`||e.domain===`light`)&&!e.auxiliary),a=n?`Enchufe`:`Botón`,o=n?`🔌`:`🔘`,s=new Map,c=[];for(let e of i){let t=e.entityId.toLowerCase(),n=(e.name||e.attributes?.friendly_name||``).toLowerCase();if(/master|general|todos?|all/i.test(n)||/master|general|all/i.test(t)){r.set(e.entityId,{badge:`⚡ Maestro (Todos)`,isMaster:!0});continue}let i=t.match(/(?:canal|channel|gang|btn|boton|botón|switch|plug|enchufe|socket|relay|_)?_?(\d+)$/i)||n.match(/(?:canal|channel|gang|btn|boton|botón|switch|plug|enchufe|socket|relay)\s*(\d+)/i)||n.match(/(\d+)$/);i?s.set(e.entityId,parseInt(i[1],10)):c.push(e.entityId)}let l=new Set(s.values()),u=1;for(let e of c){for(;l.has(u);)u++;s.set(e,u),l.add(u)}for(let[e,t]of s.entries())r.set(e,{badge:`${o} ${a} ${t}`,isMaster:!1});return r}var m=({device:e,targetEntity:t,onClose:n,onRefresh:m,showToast:h})=>{let[g,_]=(0,s.useState)(null),[v,y]=(0,s.useState)(!1),[ee,b]=(0,s.useState)(!1),[x,te]=(0,s.useState)(``),[ne,re]=(0,s.useState)(!1),[S,C]=(0,s.useState)(null),[w,T]=(0,s.useState)(null),[ie,E]=(0,s.useState)(null),[ae,D]=(0,s.useState)(!1),[O,oe]=(0,s.useState)(null),[k,se]=(0,s.useState)(!1),A=(0,s.useMemo)(()=>u(e),[e]),j=e?.entities.find(e=>e.hapAccessory?.published)?.hapAccessory||(e?.entities[0]?.hapAccessory?.published?e.entities[0].hapAccessory:null),[M,N]=(0,s.useState)(()=>j||null),[ce,P]=(0,s.useState)(()=>!!e?.entities.some(e=>e.composite&&e.exported)),F=!!M?.published,I=M,[L,le]=(0,s.useState)(()=>e?.entities.some(e=>e.domain===`vacuum`)?`matter`:j?.published?`hap`:`matter`),[ue,de]=(0,s.useState)([]),[R,fe]=(0,s.useState)(()=>j?.hapProfile?j.hapProfile:A.isRecommended?A.recommendedProfile:e?.entities.some(e=>e.domain===`light`)?`lightbulb_hap`:`humidifier`);(0,s.useEffect)(()=>{r.getHapProfiles().then(e=>{Array.isArray(e)&&e.length>0&&de(e)}).catch(()=>{})},[]),/\b(light|lamp|tira|neon|foco|bombilla|bulb|rgb|rgbic|led)\b/i.test(e?.name||``)||/\b(light|lamp|tira|neon|foco|bulb|rgb|rgbic|led|h61\w*)\b/i.test(e?.model||``);let pe=!!e?.entities.some(e=>e.domain===`fan`&&!e.auxiliary),me=!!e?.entities.some(e=>e.domain===`light`&&!e.auxiliary),he=(e?.entities||[]).filter(e=>(e.domain===`switch`||e.domain===`light`)&&!e.auxiliary),ge=(e?.entities||[]).filter(e=>e.domain===`switch`&&!e.auxiliary),_e=(e?.entities||[]).filter(e=>e.domain===`light`&&!e.auxiliary),z=!pe&&(he.length>=2||ge.length>=2||_e.length>=2||/apagador|interruptor|switch|gang|canal|channel|plug|enchufe|regleta|toma|socket|outlet|power\s*strip|controlador|botonera|mando|panel|teclado|conmutador|pulsador|dimmer/i.test(e?.name||``)&&he.length>=1),B=!/apagador|interruptor|switch|gang|pulsador/i.test((e?.name||``)+` `+(e?.model||``))&&(/plug|enchufe|regleta|toma|socket|outlet|power\s*strip/i.test((e?.name||``)+` `+(e?.model||``))||!!e?.entities.some(e=>/plug|enchufe|outlet|socket/i.test(e.entityId+` `+(e.name||``)))),V=(0,s.useMemo)(()=>p(e?.entities||[],z,B),[e,z,B]),H=e?[...e.entities].sort((e,n)=>{if(t){if(e.entityId===t.entityId)return-1;if(n.entityId===t.entityId)return 1}let r=[`unavailable`,`unknown`,`offline`].includes((e.state||``).toLowerCase()),i=[`unavailable`,`unknown`,`offline`].includes((n.state||``).toLowerCase()),a=(e.hasIssue||r)&&e.exported,o=(n.hasIssue||i)&&n.exported;if(a&&!o)return-1;if(!a&&o)return 1;if(z){let t=V.get(e.entityId)?.badge||``,r=V.get(n.entityId)?.badge||``;if(t&&r)return t.localeCompare(r,void 0,{numeric:!0})}let s=Number(n.entityId===n.compositePrimaryEntityId||n.domain===`vacuum`)-Number(e.entityId===e.compositePrimaryEntityId||e.domain===`vacuum`),c=Number(!!e.auxiliary)-Number(!!n.auxiliary);return s||Number(n.exported)-Number(e.exported)||c||(e.name||e.attributes?.friendly_name||e.entityId).localeCompare(n.name||n.attributes?.friendly_name||n.entityId,void 0,{numeric:!0})}):[];if((0,s.useEffect)(()=>{if(e&&(P(e.entities.some(e=>e.composite&&e.exported)),j&&N(j),_(n=>{if(n){let t=e.entities.find(e=>e.entityId===n.entityId);if(t)return t}return t||H[0]||e.entities[0]||null}),!(z?g?.commissioned:e.entities.some(e=>e.commissioned)))){D(!1);let t=z?g?.pairingCode:e.entities.find(e=>e.exported&&e.pairingCode)?.pairingCode;t&&(!w||t===w)&&(T(null),E(null))}},[e,t,j,z,g?.entityId]),!e)return null;let U=g||H[0]||null,W=!z&&(e.entities.some(e=>(e.composite||e.isComposite||e.compositeDeviceId)&&!e.auxiliary)||pe&&me),G=e.entities.find(e=>e.entityId===e.compositePrimaryEntityId)||e.entities.find(e=>e.domain===`media_player`)||e.entities.find(e=>e.domain===`fan`)||e.entities.find(e=>e.domain===`humidifier`)||e.entities[0],K=ce,q=U?.domain===`vacuum`,J=!!(S&&S.entityId===U?.entityId);(0,s.useEffect)(()=>{if(!S)return;let e=setTimeout(()=>C(null),Math.max(0,S.expiresAt-Date.now()));return()=>clearTimeout(e)},[S]);let ve=(J?S?.pairingCode:void 0)||w||(q?U?.pairingCode:W?G?.pairingCode:z?U?.pairingCode:U?.pairingCode||e.entities.find(e=>e.exported&&e.pairingCode)?.pairingCode)||``,ye=(J?S?.manualCode:void 0)||ie||(q?U?.manualPairingCode:W?G?.manualPairingCode:z?U?.manualPairingCode:U?.manualPairingCode||e.entities.find(e=>e.exported&&e.manualPairingCode)?.manualPairingCode)||``,be=ae?[]:Array.isArray(U?.matterFabrics)&&U.matterFabrics.length>0?U.matterFabrics:z||q?Array.isArray(U?.matterFabrics)?U.matterFabrics:[]:Array.isArray(G?.matterFabrics)&&G.matterFabrics.length>0?G.matterFabrics:Array.isArray(e.entities.find(e=>e.matterFabrics?.length)?.matterFabrics)?e.entities.find(e=>e.matterFabrics?.length).matterFabrics:[],Y=W?!!K:!!U?.exported,X=!ae&&(W?!!G?.commissioned||e.entities.some(e=>e.composite&&e.commissioned):!!U?.commissioned),xe=async()=>{if(!G||v)return;y(!0);let t=!K;P(t),e.entities.forEach(e=>{e.composite&&(e.exported=t)});try{let e=await r.toggleExport(G.entityId,t);if(e&&e.success===!1)throw Error(e.error||`No se pudo modificar la publicación en Matter`);t||(T(null),E(null),C(null)),t&&e?.pairingCode&&T(e.pairingCode),t&&e?.manualPairingCode&&E(e.manualPairingCode),h(t?`✓ Accesorio publicado en Matter`:`Accesorio retirado de Matter`),await m()}catch(n){P(!t),e.entities.forEach(e=>{e.composite&&(e.exported=!t)}),h(n.message||`Error al modificar publicación`,!0)}finally{y(!1)}},Se=async e=>{if(v)return;y(!0);let t=!e.exported;e.exported=t,U?.entityId===e.entityId&&_({...U,exported:t});try{let n=await r.toggleExport(e.entityId,t);if(n&&n.success===!1)throw Error(n.error||`No se pudo modificar la publicación en Matter`);t||(T(null),E(null),C(null),e.pairingCode=void 0,e.manualPairingCode=void 0),t&&n?.pairingCode&&(T(n.pairingCode),e.pairingCode=n.pairingCode),t&&n?.manualPairingCode&&(E(n.manualPairingCode),e.manualPairingCode=n.manualPairingCode),U?.entityId===e.entityId&&_({...U,exported:t,pairingCode:t?n?.pairingCode||e.pairingCode:void 0,manualPairingCode:t?n?.manualPairingCode||e.manualPairingCode:void 0}),h(t?`✓ ${e.name||e.entityId} publicado en Matter`:`${e.name||e.entityId} retirado de Matter`),m()}catch(n){e.exported=!t,U?.entityId===e.entityId&&_({...U,exported:!t}),h(n.message||`Error al modificar publicación`,!0)}finally{y(!1)}},Ce=async()=>{let t=e.entities.find(e=>e.domain===`media_player`),n=e.entities.find(e=>e.domain===`climate`),i=R===`television`&&t?t.entityId:(R===`heater_cooler`||R===`thermostat_hap`)&&n?n.entityId:G?.entityId||U?.entityId||e.entities[0].entityId;b(!0),y(!0);try{let t=await r.registerHap(i,R);if(t.success){if(!t.setupUri||!/^X-HM:\/\/[0-9A-Z]{13}$/.test(t.setupUri))throw Error(`HAP no devolvió un código de configuración válido.`);h(`✓ Publicado en HomeKit HAP (PIN: ${t.pincode})`);let n=t.setupUri,r={published:!0,isPaired:!1,hapProfile:R,profileLabel:ue.find(e=>e.id===R)?.label||R,pincode:t.pincode||``,port:t.port||0,setupId:t.setupId||`HAP1`,setupUri:n,pairingState:`⏳ Listo para vincular (Escanea el código QR en Apple Home)`};e.entities.forEach(e=>{e.hapAccessory=r}),U&&(U.hapAccessory=r),N(r),m()}else h(t.error||`Error al publicar HAP`,!0)}catch(e){h(e.message||`Error al publicar HAP`,!0)}finally{b(!1),y(!1)}},we=async()=>{let t=e.entities.find(e=>e.domain===`media_player`),n=e.entities.find(e=>e.domain===`climate`);if(v)return;let i=e.entities.find(e=>e.hapAccessory?.published)?.entityId??(R===`television`&&t?t.entityId:(R===`heater_cooler`||R===`thermostat_hap`)&&n?n.entityId:G?.entityId||U?.entityId||e.entities[0].entityId),a=M;N(null),b(!0),y(!0);try{let t=await r.unregisterHap(i);if(t?.success===!1)throw Error(t.error||`No se pudo retirar el accesorio de HAP`);let n=e.entities.find(e=>e.entityId===i);n&&(n.hapAccessory=null),N(e.entities.find(e=>e.hapAccessory?.published)?.hapAccessory||null),h(`Accesorio retirado de HomeKit HAP`),m()}catch(e){N(a),h(e.message||`Error al retirar de HAP`,!0)}finally{b(!1),y(!1)}},Te=async(t=x)=>{let n=I?.hapProfile===`security_system`?e?.entities.find(e=>e.hapAccessory?.published)?.entityId:void 0;if(n){re(!0);try{let e=await r.setHapAlarmCode(n,t);if(!e.success)throw Error(e.error||`No se pudo guardar el PIN de alarma.`);N(t=>t&&{...t,alarmCodeConfigured:!!e.configured}),te(``),h(e.configured?`PIN de alarma guardado. No se muestra ni se registra en logs.`:`PIN de alarma eliminado.`)}catch(e){h(e.message||`No se pudo guardar el PIN de alarma.`,!0)}finally{re(!1)}}},Ee=async t=>{if(!U||v)return;y(!0),h(`Desconectando fabric Matter...`);let n=!z&&W&&G?.entityId||U.entityId;try{let i=await r.removeFabric(n,t);i?.remainingFabrics===0||i?.pairingCode?(C(null),D(!0),i?.pairingCode&&T(i.pairingCode),i?.manualPairingCode&&E(i.manualPairingCode),U.commissioned=!1,U.matterFabrics=[],i?.pairingCode&&(U.pairingCode=i.pairingCode),i?.manualPairingCode&&(U.manualPairingCode=i.manualPairingCode),_({...U,commissioned:!1,matterFabrics:[],pairingCode:i?.pairingCode||U.pairingCode,manualPairingCode:i?.manualPairingCode||U.manualPairingCode}),z||e.entities.forEach(e=>{e.commissioned=!1,e.matterFabrics=[],i?.pairingCode&&(e.pairingCode=i.pairingCode),i?.manualPairingCode&&(e.manualPairingCode=i.manualPairingCode)})):(U.matterFabrics&&=U.matterFabrics.filter(e=>String(e.fabricIndex)!==String(t)&&String(e.fabricId)!==String(t)),z||e.entities.forEach(e=>{e.matterFabrics&&=e.matterFabrics.filter(e=>String(e.fabricIndex)!==String(t)&&String(e.fabricId)!==String(t))})),h(`✓ Fabric desconectado de este accesorio`),m()}catch(e){h(e.message||`Error al desconectar fabric`,!0)}finally{y(!1)}},De=async()=>{if(!U)return;y(!0),h(`Reconectando accesorio Matter...`);let e=!z&&W&&G?.entityId||U.entityId;try{await r.reconnectAccessory(!z&&U.compositeDeviceId?U.compositeDeviceId:e),h(`✓ Accesorio reconectado`),m()}catch(e){h(e.message||`Error al reconectar`,!0)}finally{y(!1)}},Oe=async()=>{if(!U||v)return;y(!0);let e=!z&&W&&G?.entityId||U.entityId;try{let t=await r.openCommissioning(e);if(!t.pairingCode)throw Error(`El nodo no devolvió un código QR utilizable.`);C({entityId:U.entityId,pairingCode:t.pairingCode,manualCode:t.manualPairingCode??void 0,expiresAt:Date.now()+(t.windowTimeout??900)*1e3}),h(`✓ Modo Multi-Admin Abierto. Puedes emparejar en una segunda plataforma.`)}catch(e){h(e.message||`Error al abrir Multi-Admin`,!0)}finally{y(!1)}},ke=async()=>{if(!U||v)return;y(!0),h(`Desconectando fabrics y preparando el código de vinculación...`);let t=!z&&W&&G?.entityId||U.entityId;try{let n=await r.resetAccessory(t),i=n?.pairingCode||null,a=n?.manualPairingCode||null;T(i),E(a),D(!0),C(null),U.pairingCode=i||void 0,U.manualPairingCode=a||void 0,U.commissioned=!1,U.matterFabrics=[],_({...U,pairingCode:i||void 0,manualPairingCode:a||void 0,commissioned:!1,matterFabrics:[]}),z||e.entities.forEach(e=>{e.commissioned=!1,e.matterFabrics=[],i&&(e.pairingCode=i),a&&(e.manualPairingCode=a)}),h(i?`✓ Accesorio desvinculado; código de emparejamiento disponible`:`Accesorio desvinculado. El nodo aún no entregó el código.`),m()}catch(e){h(e.message||`Error al desvincular`,!0)}finally{y(!1)}},Ae=g||U,Z=(Ae?.state||``).toLowerCase(),Q=Z===`unavailable`||Z===`unknown`||Z===`offline`,je=Ae?.diagnostics||[],Me=g?.logs||Ae?.logs||[],$=(0,s.useMemo)(()=>{let e=[];Q&&e.push({text:`Home Assistant informa estado "${Z.toUpperCase()}". El dispositivo físico no responde (posiblemente apagado, sin batería, fuera de rango o con la integración origen caída).`,level:`warning`});for(let t of je)e.push({text:t.message,level:t.level||`warning`,timestamp:t.timestamp});for(let t of Me){let n=typeof t==`string`?t:t?.message||JSON.stringify(t),r=typeof t==`object`&&t?.level?t.level:`error`;e.push({text:n,level:r})}return e},[Q,Z,je,Me]),Ne=async()=>{if(!U)return;let e=$.map(e=>`${e.timestamp?`[${new Date(e.timestamp).toLocaleTimeString()}] `:``}[${e.level.toUpperCase()}] ${e.text}`).join(`
2
+ `),t=[`=== DIAGNÓSTICO DE ACCESORIO MATTER ===`,`Entidad: ${U.entityId}`,`Nombre: ${U.name||U.friendly_name||`Desconocido`}`,`Dominio: ${U.domain}`,`Estado en Home Assistant: ${U.state?U.state.toUpperCase():`N/A`}`,...Q?[`Causa detectada: Dispositivo físico no responde en Home Assistant (apagado, sin batería o sin enlace con la integración)`]:[],`Publicado en Matter: ${U.exported?`SÍ`:`NO`}`,`Emparejado: ${U.commissioned?`SÍ (Vinculado)`:`NO`}`,`Código de emparejamiento manual: ${U.manualPairingCode||`N/A`}`,`Incidencias activas: ${U.hasIssue||Q?`SÍ`:`NO`}`,`\n=== HISTORIAL DE EVENTOS Y DIAGNÓSTICO (${$.length}) ===`,e||`(Sin incidencias ni eventos registrados)`].join(`
3
+ `);await o(t)?h(`✓ Diagnóstico y logs copiados al portapapeles`):h(`⚠️ No se pudo acceder al portapapeles, intenta seleccionar el texto manualmente`,!0)},Pe=async()=>{if(U)try{await r.clearEntityDiagnostics(U.entityId),U.diagnostics&&=[],U.hasIssue=!1,h(`✓ Historial de diagnósticos borrado`),m?.()}catch{h(`⚠️ No se pudo limpiar el historial`,!0)}},Fe=new Set(e.entities.filter(e=>e.exported).map(e=>e.compositeDeviceId||e.entityId)).size;return(0,c.jsxs)(`div`,{className:`modal-backdrop device-modal-backdrop open`,id:`device-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`device-modal-name`,children:[(0,c.jsxs)(`section`,{className:`modal modal-wide modal-fullscreen device-modal-shell`,children:[(0,c.jsx)(`button`,{className:`icon-button`,id:`device-modal-close`,type:`button`,"aria-label":`Cerrar`,onClick:n,children:`×`}),(0,c.jsxs)(`header`,{className:`modal-header`,style:{marginBottom:8},children:[(0,c.jsx)(`span`,{className:`modal-icon`,id:`device-modal-icon`,children:d(U?.domain||H[0]?.domain||e.entities[0]?.domain)}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`p`,{className:`eyebrow`,children:`DISPOSITIVO IOT · MATTER ALL-IN-ONE`}),(0,c.jsx)(`h2`,{id:`device-modal-name`,children:e.name}),(0,c.jsxs)(`p`,{className:`entity-id`,id:`device-modal-id`,children:[e.manufacturer?`${e.manufacturer} · `:``,e.model?`${e.model} · `:``,e.area?`📍 ${e.area}`:e.id]})]})]}),(0,c.jsxs)(`div`,{className:`device-modal-protocol-selector`,style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:10,gap:12,flexWrap:`wrap`,flexShrink:0},children:[(0,c.jsxs)(`div`,{style:{display:`inline-flex`,background:`rgba(255,255,255,0.05)`,padding:`3px`,borderRadius:10,border:`1px solid var(--border)`,gap:4},children:[(0,c.jsxs)(`button`,{type:`button`,onClick:()=>le(`matter`),style:{padding:`6px 16px`,borderRadius:8,fontSize:12.5,fontWeight:600,cursor:`pointer`,border:`none`,background:L===`matter`?`#2563eb`:`transparent`,color:L===`matter`?`#ffffff`:`var(--muted)`,transition:`all 0.15s ease`},children:[`⚡ Matter (Multi-plataforma) `,Y?`✓ Activo`:``]}),(0,c.jsxs)(`button`,{type:`button`,onClick:()=>le(`hap`),className:A.isRecommended?`hap-recommended-pulse`:``,style:{padding:`6px 16px`,borderRadius:8,fontSize:12.5,fontWeight:600,cursor:`pointer`,border:L===`hap`?`1px solid rgba(245,158,11,0.6)`:A.isRecommended?`1px solid rgba(245,158,11,0.5)`:`none`,background:L===`hap`?`rgba(245,158,11,0.25)`:A.isRecommended?`rgba(245,158,11,0.12)`:`transparent`,color:L===`hap`?`#fcd34d`:A.isRecommended?`#fde68a`:`var(--muted)`,transition:`all 0.15s ease`},children:[`🏠 HomeKit HAP `,F?`✓ Activo`:A.isRecommended?`⭐ Recomendado (${A.categoryName})`:``]})]}),(0,c.jsx)(`div`,{style:{fontSize:11.5,color:`var(--muted)`},children:L===`matter`?`Compatible con Apple Home, Google Home, Alexa y SmartThings`:A.isRecommended?`Accesorio HomeKit nativo (reconocido como ${A.categoryName})`:`Accesorio HomeKit nativo (reconocido como Alarma, Difusor, TV, Válvula, etc.)`})]}),A.isRecommended&&L===`matter`&&!Y&&(0,c.jsxs)(`div`,{style:{background:`linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(245, 158, 11, 0.05))`,border:`1px solid rgba(245, 158, 11, 0.35)`,borderRadius:10,padding:`10px 14px`,marginBottom:10,display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:12,flexShrink:0},children:[(0,c.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:10},children:[(0,c.jsx)(`span`,{style:{fontSize:20},children:`⭐`}),(0,c.jsxs)(`div`,{style:{fontSize:12,color:`#fef3c7`,lineHeight:1.4},children:[(0,c.jsxs)(`strong`,{style:{color:`#fcd34d`},children:[`Recomendación para Apple Home (`,A.categoryName,`):`]}),` `,A.reason,` `,A.appleAdvantage]})]}),(0,c.jsx)(`button`,{type:`button`,onClick:()=>{le(`hap`),A.recommendedProfile&&fe(A.recommendedProfile)},style:{whiteSpace:`nowrap`,padding:`6px 14px`,background:`rgba(245, 158, 11, 0.25)`,border:`1px solid rgba(245, 158, 11, 0.5)`,color:`#fde68a`,borderRadius:8,fontSize:12,fontWeight:650,cursor:`pointer`,boxShadow:`0 2px 8px rgba(245,158,11,0.2)`},children:`Cambiar a HomeKit HAP →`})]}),F&&L===`matter`&&(0,c.jsxs)(`div`,{style:{background:`linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(16, 185, 129, 0.08))`,border:`1px solid rgba(59, 130, 246, 0.35)`,borderRadius:10,padding:`10px 14px`,marginBottom:10,display:`flex`,alignItems:`center`,gap:10,flexShrink:0,fontSize:12,color:`#e2e8f0`,lineHeight:1.4},children:[(0,c.jsx)(`span`,{style:{fontSize:18},children:`🌐`}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`strong`,{style:{color:`#60a5fa`},children:`Modo Coexistencia HAP + Matter Multi-Admin:`}),` `,`Accesorio activo en `,(0,c.jsx)(`strong`,{children:`HomeKit HAP (Apple Home)`}),`. Puedes publicar y escanear este código QR de Matter en `,(0,c.jsx)(`strong`,{children:`Google Home`}),`, `,(0,c.jsx)(`strong`,{children:`Alexa`}),` o `,(0,c.jsx)(`strong`,{children:`SmartThings`}),` para controlarlo en todas tus plataformas.`,(0,c.jsx)(`span`,{style:{display:`block`,fontSize:11,color:`#94a3b8`,marginTop:2},children:`💡 Importante: Como ya lo tienes en Apple Casa vía HAP, escanea este código Matter exclusivamente en Google Home, Alexa o SmartThings para evitar duplicados en tu iPhone.`})]})]}),(0,c.jsxs)(`div`,{className:`modal-layout device-modal-layout`,children:[(0,c.jsxs)(`div`,{className:`entity-list-col`,style:{display:`flex`,flexDirection:`column`,minHeight:0,height:`100%`},children:[(0,c.jsxs)(`div`,{className:`section-header`,style:{marginBottom:W?`8px`:`12px`},children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`h3`,{style:{margin:0},children:L===`hap`?`Accesorio HomeKit HAP`:W?`Endpoints del Accesorio`:`Entidades disponibles`}),(0,c.jsx)(`p`,{style:{fontSize:`11px`,color:`var(--muted)`,margin:`2px 0 0`},children:L===`hap`?F?`1 accesorio activo en HomeKit HAP`:`Publica y gestiona el accesorio desde el panel derecho`:W?`1 accesorio Matter unificado (1 solo código QR)`:z?`${e.entities.filter(e=>e.exported).length}/${e.entities.filter(e=>!e.auxiliary).length} publicadas`:e.entities.some(e=>e.exported)?`✓ 1 accesorio activo en Matter`:`0 accesorios en Matter`})]}),(0,c.jsx)(`span`,{id:`modal-export-count`,children:L===`hap`?F?`✓ 1 HAP`:`0/1 HAP`:W?K?`✓ 1 accesorio activo en Matter`:`0 accesorios en Matter`:Fe?z?`${Fe} accesorio Matter · ${e.entities.filter(e=>e.exported).length}/${e.entities.filter(e=>!e.auxiliary).length} endpoints`:`${Fe} accesorio Matter (1 QR)`:`0/${e.entities.filter(e=>!e.auxiliary).length} publicadas`})]}),L===`hap`?(0,c.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`12px 14px`,background:F?`rgba(245, 158, 11, 0.12)`:`rgba(255, 255, 255, 0.03)`,border:`1px solid ${F?`rgba(245, 158, 11, 0.4)`:`var(--border)`}`,borderRadius:`10px`,marginBottom:`12px`,flexShrink:0},children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`div`,{style:{fontSize:`13px`,fontWeight:700,color:F?`#fcd34d`:`var(--text)`},children:`Activar HomeKit HAP (Apple Home)`}),(0,c.jsx)(`div`,{style:{fontSize:`11px`,color:`var(--muted)`,marginTop:`2px`},children:F?`✓ Accesorio activo en HomeKit HAP con código QR y PIN`:`Apagado (activa el switch para generar código QR en Apple Casa)`})]}),(0,c.jsxs)(`label`,{className:`toggle`,style:{margin:0},children:[(0,c.jsx)(`input`,{type:`checkbox`,checked:!!F,onChange:()=>{F?we():Ce()},disabled:v}),(0,c.jsx)(`span`,{})]})]}):W?(0,c.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`12px 14px`,background:Y?F?`rgba(59, 130, 246, 0.12)`:`rgba(16, 185, 129, 0.1)`:`rgba(255, 255, 255, 0.03)`,border:`1px solid ${Y?F?`rgba(59, 130, 246, 0.4)`:`rgba(16, 185, 129, 0.35)`:`var(--border)`}`,borderRadius:`10px`,marginBottom:`12px`,flexShrink:0},children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`div`,{style:{fontSize:`13px`,fontWeight:700,color:Y?F?`#93c5fd`:`#34d399`:`var(--text)`},children:F?`Activar Matter Multi-Admin (Google, Alexa, SmartThings)`:`Activar Matter (Multi-plataforma)`}),(0,c.jsx)(`div`,{style:{fontSize:`11px`,color:`var(--muted)`,marginTop:`2px`},children:Y?F?`✓ Matter activo para Google Home, Alexa o SmartThings`:`✓ Accesorio publicado en Matter`:F?`HAP está activo en Apple Casa. Activa aquí para compartir con Google/Alexa`:`Apagado (activa el switch para publicar en Matter)`})]}),(0,c.jsxs)(`label`,{className:`toggle`,style:{margin:0},children:[(0,c.jsx)(`input`,{type:`checkbox`,checked:!!Y,onChange:()=>{xe()},disabled:v}),(0,c.jsx)(`span`,{})]})]}):z?(0,c.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:`10px 14px`,background:`rgba(255, 255, 255, 0.03)`,border:`1px solid var(--border)`,borderRadius:`10px`,marginBottom:`12px`,flexShrink:0},children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`div`,{style:{fontSize:`12.5px`,fontWeight:700,color:`var(--text)`},children:B?`Enchufes / Plugs Independientes`:`Botones / Canales Independientes`}),(0,c.jsxs)(`div`,{style:{fontSize:`11px`,color:`var(--muted)`,marginTop:`2px`},children:[`Exporta y empareja cada `,B?`enchufe`:`botón`,` por separado con su propio código QR`]})]}),(0,c.jsxs)(`span`,{className:`badge`,style:{fontSize:`11px`,padding:`3px 8px`,borderRadius:`6px`,background:`rgba(59, 130, 246, 0.15)`,color:`#60a5fa`,border:`1px solid rgba(59, 130, 246, 0.3)`,fontWeight:600},children:[e.entities.filter(e=>e.exported).length,` / `,e.entities.filter(e=>!e.auxiliary).length,` activos`]})]}):null,(0,c.jsx)(`div`,{className:`entity-list`,id:`entity-list`,style:{flex:1,minHeight:0,maxHeight:`none`,overflowY:`auto`},children:H.map((e,t)=>{let n=U?.entityId===e.entityId,r=e.entityId===e.compositePrimaryEntityId||W&&e.domain===`fan`,i=W&&(e.domain===`fan`||e.domain===`light`)&&!e.auxiliary,a=W&&e.auxiliary,o=W?null:V.get(e.entityId)??null;return(0,c.jsxs)(`div`,{className:`entity-row${e.exported?``:` dimmed`}${n?` selected`:``}`,onClick:()=>{U?.entityId!==e.entityId&&(T(null),E(null),D(!1)),_(e)},children:[(0,c.jsx)(`span`,{className:`entity-row-icon`,children:d(e.domain)}),(0,c.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,c.jsx)(`div`,{className:`entity-row-name`,children:e.name||e.attributes?.friendly_name||e.entityId}),(0,c.jsx)(`div`,{className:`entity-row-id`,children:e.entityId}),(0,c.jsxs)(`div`,{style:{display:`flex`,gap:`6px`,alignItems:`center`,marginTop:`3px`,flexWrap:`wrap`},children:[(0,c.jsxs)(`span`,{className:`entity-state${e.state===`on`||e.state===`cleaning`?` on`:``}`,children:[e.state||`desconocido`,e.attributes?.unit_of_measurement?` ${e.attributes.unit_of_measurement}`:``]}),o&&(0,c.jsx)(`span`,{className:`tag`,style:{fontSize:`10px`,padding:`1px 6px`,background:o.isMaster?`rgba(245, 158, 11, 0.15)`:`rgba(59, 130, 246, 0.15)`,color:o.isMaster?`#fcd34d`:`#60a5fa`,border:`1px solid ${o.isMaster?`rgba(245, 158, 11, 0.3)`:`rgba(59, 130, 246, 0.3)`}`,fontWeight:600},children:o.badge}),W&&r&&(0,c.jsxs)(`span`,{className:`tag`,style:{fontSize:`10px`,padding:`1px 6px`,background:`rgba(59, 130, 246, 0.15)`,color:`#60a5fa`,border:`1px solid rgba(59, 130, 246, 0.3)`},children:[`Endpoint 1 · `,e.domain===`humidifier`?`Difusor / Humidificador`:e.domain===`fan`?`Ventilador`:e.domain===`light`?`Luz`:e.deviceTypeLabel||e.domain]}),W&&!r&&i&&(0,c.jsxs)(`span`,{className:`tag`,style:{fontSize:`10px`,padding:`1px 6px`,background:`rgba(16, 185, 129, 0.15)`,color:`#34d399`,border:`1px solid rgba(16, 185, 129, 0.3)`},children:[`Endpoint 2 · `,e.domain===`light`?`Luz (Dimmer + Kelvin)`:e.domain===`switch`?`Interruptor`:e.domain===`fan`?`Ventilador`:e.deviceTypeLabel||e.domain]}),a&&(0,c.jsx)(`span`,{className:`tag`,style:{fontSize:`10px`,padding:`1px 6px`,background:`rgba(156, 163, 175, 0.15)`,color:`#9ca3af`,border:`1px solid rgba(156, 163, 175, 0.25)`},children:`Auxiliar (Omitido)`}),e.exported&&([`unavailable`,`unknown`,`offline`].includes((e.state||``).toLowerCase())||e.hasIssue)&&(0,c.jsx)(`span`,{className:`tag`,style:{fontSize:`10px`,padding:`1px 6px`,background:`rgba(245, 158, 11, 0.2)`,color:`#fbbf24`,border:`1px solid rgba(245, 158, 11, 0.4)`,fontWeight:600},children:`⚠️ Requiere atención`})]})]}),(0,c.jsx)(`div`,{className:`export-control`,onClick:e=>e.stopPropagation(),children:L===`hap`?(0,c.jsx)(`span`,{className:`badge`,style:{fontSize:`10.5px`,padding:`2px 8px`,borderRadius:`6px`,background:F?`rgba(245, 158, 11, 0.18)`:`rgba(255, 255, 255, 0.05)`,color:F?`#fcd34d`:`var(--muted)`,border:`1px solid ${F?`rgba(245, 158, 11, 0.4)`:`rgba(255, 255, 255, 0.1)`}`,fontWeight:550},children:F?`✓ HAP Activo`:`HAP`}):W?a?(0,c.jsx)(`span`,{style:{fontSize:`11px`,color:`var(--muted)`,fontStyle:`italic`},children:`Excluido`}):(0,c.jsx)(`span`,{className:`badge ${e.exported?`badge-success`:`badge-muted`}`,style:{fontSize:`10.5px`,padding:`2px 8px`,borderRadius:`6px`,background:e.exported?`rgba(16, 185, 129, 0.15)`:`rgba(255, 255, 255, 0.05)`,color:e.exported?`#34d399`:`var(--muted)`,border:`1px solid ${e.exported?`rgba(16, 185, 129, 0.3)`:`rgba(255, 255, 255, 0.1)`}`,fontWeight:500},children:e.exported?`✓ En Matter`:`Inactivo`}):e.auxiliary?e.primaryEntityId?.startsWith(`vacuum.`)?(0,c.jsx)(`span`,{className:`badge`,style:{fontSize:`10px`,padding:`2px 7px`,borderRadius:`6px`,background:`rgba(59, 130, 246, 0.14)`,color:`#93c5fd`,border:`1px solid rgba(59, 130, 246, 0.3)`,fontWeight:550},children:`✓ RVC Matter`}):(0,c.jsx)(`span`,{style:{fontSize:`11px`,color:`var(--muted)`,fontStyle:`italic`},children:`Auxiliar`}):(0,c.jsxs)(`label`,{className:`toggle`,style:{opacity:v?.6:1,pointerEvents:v?`none`:`auto`},children:[(0,c.jsx)(`input`,{type:`checkbox`,checked:!!e.exported,onChange:()=>Se(e),disabled:v}),(0,c.jsx)(`span`,{})]})})]},e.entityId)})})]}),(0,c.jsxs)(`aside`,{className:`selection-panel`,id:`selection-panel`,style:{flex:1,minHeight:0,maxHeight:`none`,overflowY:`auto`,padding:22,gap:14},children:[(0,c.jsx)(`p`,{className:`card-label`,children:L===`hap`?`CONFIGURACIÓN HOMEKIT HAP`:`SELECCIÓN Y CONFIGURACIÓN`}),(0,c.jsxs)(`h3`,{id:`selection-title`,children:[(0,c.jsx)(`span`,{className:`selection-title-text`,children:L===`hap`?`${e.name} (Apple Home)`:U?.name&&U.name.trim().length>1?U.name:e.name||U?.entityId||`Selecciona una entidad`}),L===`hap`?F&&(0,c.jsx)(`span`,{className:`home-badge`,style:{background:I?.isPaired?`rgba(16, 185, 129, 0.15)`:`rgba(245, 158, 11, 0.15)`,color:I?.isPaired?`#34d399`:`#fcd34d`,border:`1px solid ${I?.isPaired?`rgba(16, 185, 129, 0.3)`:`rgba(245, 158, 11, 0.3)`}`},children:I?.isPaired?`🍏 Vinculado`:`⏳ PIN Activo`}):X&&(0,c.jsx)(`span`,{className:`home-badge commissioned`,children:`🏠 Vinculado`})]}),L===`hap`?(0,c.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:14},children:[(0,c.jsx)(`p`,{id:`selection-description`,style:{color:`var(--text-secondary)`,fontSize:13,lineHeight:1.5,margin:0},children:`HomeKit HAP expone este dispositivo directamente a Apple Home usando la especificación oficial de accesorios de Apple (HAP 2.2.3).`}),(0,c.jsxs)(`div`,{className:`profile-field`,style:{display:`flex`,flexDirection:`column`,gap:6,padding:14,background:`rgba(255, 255, 255, 0.03)`,border:`1px solid rgba(245, 158, 11, 0.3)`,borderRadius:10},children:[(0,c.jsx)(`label`,{htmlFor:`hap-profile-select`,style:{fontSize:10,fontWeight:750,letterSpacing:`0.05em`,color:`#fcd34d`,textTransform:`uppercase`},children:`Tipo de Accesorio en Apple Home (Perfil HAP)`}),(0,c.jsx)(`select`,{id:`hap-profile-select`,"aria-label":`Perfil HomeKit HAP`,value:R,onChange:e=>fe(e.target.value),disabled:F||v,style:{width:`100%`,padding:`9px 12px`,background:`#0b1528`,color:`var(--text)`,border:`1px solid rgba(245, 158, 11, 0.4)`,borderRadius:8,fontSize:13,cursor:F?`default`:`pointer`},children:ue.map(e=>(0,c.jsx)(`option`,{value:e.id,style:{background:`#1a1a2e`},children:e.label},e.id))}),(0,c.jsx)(`small`,{style:{color:`#fef08a`,fontSize:11,lineHeight:1.4,marginTop:4},children:R===`security_system`?`Apple Home lo reconocerá como Panel de Alarma / Sistema de Seguridad nativo con modos En Casa, Fuera, Noche y Desarmado.`:R===`heater_cooler`?`Apple Home lo reconocerá como Aire Acondicionado nativo con tarjeta dedicada en iOS: selector de temperatura, velocidad del ventilador (0-100%) y botón de oscilación (swing).`:R===`thermostat_hap`?`Apple Home lo reconocerá como Termostato HAP nativo con dial de temperatura y modos calor/frío/auto.`:R===`humidifier`?`Apple Home lo reconocerá como Difusor / Humidificador nativo con icono de gota, porcentaje de humedad y control de niebla.`:R===`dehumidifier`?`Apple Home lo reconocerá como Deshumidificador nativo con control porcentual de humedad.`:R===`air_purifier`?`Apple Home lo reconocerá como Purificador de Aire nativo con velocidad de ventilador y estado de filtros.`:R===`television`?`Apple Home lo reconocerá como Televisor nativo con selector de entradas HDMI y control remoto integrado en iOS.`:R.startsWith(`valve`)?`Apple Home lo reconocerá como Válvula / Sistema de Riego con temporizador nativo.`:R===`garage_door`?`Apple Home lo reconocerá como Puerta de Garaje con compatibilidad Siri y CarPlay.`:`Apple Home creará el accesorio con los servicios y características nativas de HomeKit HAP.`})]}),(0,c.jsxs)(`dl`,{className:`selection-meta`,id:`selection-meta`,children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`dt`,{children:`Entidad Principal`}),(0,c.jsx)(`dd`,{children:(R===`television`?e.entities.find(e=>e.domain===`media_player`)?.entityId:void 0)||(R===`heater_cooler`||R===`thermostat_hap`?e.entities.find(e=>e.domain===`climate`)?.entityId:void 0)||G?.entityId||U?.entityId||e.entities[0]?.entityId})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`dt`,{children:`Fabricante`}),(0,c.jsx)(`dd`,{children:e.manufacturer||`Home Assistant`})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`dt`,{children:`Modelo`}),(0,c.jsx)(`dd`,{children:e.model||`HAP Device`})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`dt`,{children:`Estado HAP`}),(0,c.jsx)(`dd`,{style:{color:F?I?.isPaired?`#34d399`:`#fcd34d`:`var(--muted)`},children:F?I?.isPaired?`✓ Vinculado a Apple Home (Activo)`:`Listo para vincular (PIN activo)`:`Sin publicar`})]})]})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`p`,{id:`selection-description`,children:W?U?.auxiliary?`Esta entidad es auxiliar (ej. buzzer/beeper) y se omite en Matter para mantener limpio el accesorio.`:Y?`Este canal forma parte del accesorio unificado y está activo en Matter bajo el mismo código QR.`:`Activa el interruptor general arriba para publicar el accesorio (ventilador y luz juntos en 1 QR).`:U?.auxiliary?U?.primaryEntityId?.startsWith(`vacuum.`)?`Esta entidad forma parte de la aspiradora robot (RVC Matter 1.4) y sus estados/modos se sincronizan automáticamente con Apple Home (iOS 27).`:`Esta entidad es auxiliar (ej. segmento RGBIC) y se controla automáticamente a través de la luz principal.`:z?Y?`Este ${B?`enchufe`:`botón`} está activo y publicado en Matter con su propio código QR independiente.`:`Activa el interruptor para publicar este ${B?`enchufe`:`botón`} en Matter con su propio QR.`:Y?`Esta entidad está activa y expuesta a través de Matter.`:`Activa el interruptor para publicar esta entidad en Matter.`}),U&&Array.isArray(U.profiles)&&U.profiles.length>0&&!U.auxiliary&&(0,c.jsxs)(`div`,{className:`profile-field`,id:`profile-field`,style:{display:`flex`,flexDirection:`column`,gap:6,marginTop:14,padding:12,background:`rgba(255, 255, 255, 0.03)`,border:`1px solid var(--border)`,borderRadius:10},children:[(0,c.jsx)(`label`,{htmlFor:`profile-select`,style:{fontSize:10,fontWeight:750,letterSpacing:`0.05em`,color:`var(--dim)`,textTransform:`uppercase`},children:`Perfil Matter`}),(0,c.jsx)(`select`,{id:`profile-select`,"aria-label":`Perfil Matter`,value:U.profileId||U.matterType||``,onChange:async e=>{let t=e.target.value;try{y(!0),await r.setDeviceProfile(U.entityId,t),U.profileId=t,U.matterType=t,h(`✓ Perfil Matter actualizado a ${t}`),m()}catch(e){h(e.message||`Error al cambiar perfil Matter`,!0)}finally{y(!1)}},disabled:v,style:{width:`100%`,padding:`8px 10px`,background:`#0b1528`,color:`var(--text)`,border:`1px solid var(--border)`,borderRadius:8,fontSize:12,cursor:`pointer`},children:U.profiles.map(e=>(0,c.jsxs)(`option`,{value:e.id,children:[e.label,e.appleHome===`supported`?``:e.appleHome===`experimental`?` · experimental`:` · no compatible con Apple Home`]},e.id))}),(()=>{let e=U.profiles.find(e=>e.id===(U.profileId||U.matterType))||U.profiles[0];return e?(0,c.jsx)(`small`,{id:`profile-note`,style:{color:`var(--muted)`,fontSize:10,lineHeight:1.4},children:e.description}):null})()]}),(0,c.jsxs)(`dl`,{className:`selection-meta`,id:`selection-meta`,children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`dt`,{children:`Entidad ID`}),(0,c.jsx)(`dd`,{children:U?.entityId||`—`})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`dt`,{children:`Dominio`}),(0,c.jsx)(`dd`,{children:U?.domain||`—`})]}),U?.area_name&&(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`dt`,{children:`Área`}),(0,c.jsx)(`dd`,{children:U.area_name})]}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`dt`,{children:`Estado Matter`}),(0,c.jsx)(`dd`,{children:X?`Emparejado en red Matter`:Y?`Listo para vincular`:`Sin publicar`})]})]}),(0,c.jsxs)(`section`,{className:`fabrics-section`,id:`fabrics-section`,children:[(0,c.jsxs)(`div`,{className:`fabrics-heading`,children:[(0,c.jsx)(`span`,{className:`fabrics-icon`,"aria-hidden":`true`,children:`🏠`}),(0,c.jsx)(`strong`,{children:`Casas / Controladores Conectados`})]}),(0,c.jsx)(`p`,{className:`fabrics-subtitle`,children:`Desconectar de ecosistemas Matter existentes si cambias de controlador o si ya eliminaste este accesorio en tu app de Apple Home, Google Home o Alexa.`}),be.length>0?(0,c.jsx)(`div`,{className:`fabrics-list`,children:be.map((e,t)=>{let n=f(e.vendorId,e.controller),r=e.fabricIndex??e.fabricId??t+1;return(0,c.jsxs)(`div`,{className:`fabric-item`,children:[(0,c.jsxs)(`div`,{className:`fabric-info`,children:[(0,c.jsxs)(`div`,{className:`fabric-controller-line`,children:[(0,c.jsx)(`span`,{style:{fontSize:15},children:n.icon}),(0,c.jsx)(`span`,{className:`fabric-name`,children:n.name})]}),e.label&&(0,c.jsxs)(`span`,{className:`fabric-home-name`,children:[`Casa: `,(0,c.jsx)(`strong`,{children:e.label})]}),(0,c.jsxs)(`span`,{className:`fabric-detail`,children:[`Fabric `,r,e.vendorId?` · VID: 0x${Number(e.vendorId).toString(16).toUpperCase()}`:``]})]}),(0,c.jsx)(`button`,{type:`button`,className:`button button-danger-outline button-xs`,onClick:()=>Ee(r),disabled:v,title:`Desconectar únicamente esta casa`,style:{padding:`4px 8px`,fontSize:`11px`,borderRadius:`6px`,cursor:`pointer`,background:`rgba(239, 68, 68, 0.15)`,color:`#fca5a5`,border:`1px solid rgba(239, 68, 68, 0.35)`},children:`Desconectar`})]},r)})}):(0,c.jsx)(`div`,{style:{fontSize:11,color:`var(--muted)`,fontStyle:`italic`,padding:`4px 0`},children:X?`Sesión registrada en el puente (sin etiquetas de controlador reportadas).`:`No hay casas ni controladores vinculados a este accesorio.`})]})]}),(0,c.jsxs)(`section`,{className:`diagnostics-panel ${Q||U?.hasIssue?`has-issues`:``}`,id:`diagnostics-panel`,"aria-live":`polite`,style:{userSelect:`text`,background:Q?`rgba(245, 158, 11, 0.08)`:`rgba(255, 255, 255, 0.03)`,border:Q?`1px solid rgba(245, 158, 11, 0.3)`:`1px solid var(--border)`,borderRadius:`10px`,padding:`14px`},children:[(0,c.jsxs)(`div`,{className:`diagnostics-heading`,style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:`8px`},children:[(0,c.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`6px`},children:[(0,c.jsx)(`span`,{id:`diagnostics-icon`,"aria-hidden":`true`,style:{fontSize:`16px`},children:Q||U?.hasIssue?`⚠️`:$.length>0?`ℹ️`:`✓`}),(0,c.jsx)(`strong`,{id:`diagnostics-heading-text`,style:{fontSize:`13px`},children:Q?`Estado de Conexión y Diagnóstico`:U?.hasIssue?`Incidencia activa detectada`:`Diagnóstico y logs`})]}),(0,c.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`6px`},children:[(0,c.jsx)(`button`,{type:`button`,onClick:()=>se(!k),title:k?`Ocultar texto sin formato`:`Ver texto completo para copiar`,style:{background:k?`rgba(255,255,255,0.12)`:`rgba(255,255,255,0.05)`,border:`1px solid var(--border)`,borderRadius:`7px`,padding:`5px 9px`,color:`var(--text)`,fontSize:`11px`,cursor:`pointer`,fontWeight:500,flexShrink:0},children:k?`👁️ Ocultar texto`:`📄 Ver texto`}),(0,c.jsx)(`button`,{id:`copy-diagnostics-button`,className:`copy-diagnostics-button`,type:`button`,onClick:Ne,title:`Copiar diagnóstico y logs al portapapeles`,style:{background:`rgba(99,102,241,0.15)`,border:`1px solid rgba(99,102,241,0.4)`,borderRadius:`7px`,padding:`5px 10px`,color:`#a5b4fc`,fontSize:`11px`,cursor:`pointer`,fontWeight:600,flexShrink:0},children:`📋 Copiar logs`}),(0,c.jsx)(`button`,{id:`clear-diagnostics-button`,type:`button`,onClick:Pe,title:`Limpiar registro y borrar errores pasados de este accesorio`,style:{background:`rgba(239,68,68,0.12)`,border:`1px solid rgba(239,68,68,0.35)`,borderRadius:`7px`,padding:`5px 9px`,color:`#fca5a5`,fontSize:`11px`,cursor:`pointer`,fontWeight:600,flexShrink:0},children:`🧹 Limpiar`})]})]}),k&&(0,c.jsxs)(`div`,{style:{marginBottom:`12px`},children:[(0,c.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:`4px`},children:[(0,c.jsx)(`span`,{style:{fontSize:`10px`,color:`var(--muted)`},children:`Texto completo seleccionable:`}),(0,c.jsx)(`button`,{type:`button`,onClick:e=>{let t=e.currentTarget.parentElement?.nextElementSibling;t&&(t.select(),t.setSelectionRange(0,99999),document.execCommand(`copy`),h(`✓ Todo el texto seleccionado y copiado`))},style:{background:`none`,border:`none`,color:`#38bdf8`,fontSize:`10.5px`,cursor:`pointer`,textDecoration:`underline`,padding:0},children:`Seleccionar todo y copiar`})]}),(0,c.jsx)(`textarea`,{readOnly:!0,rows:6,value:[`=== DIAGNÓSTICO DE ACCESORIO MATTER ===`,`Entidad: ${U?.entityId}`,`Nombre: ${U?.name||U?.friendly_name||`Desconocido`}`,`Dominio: ${U?.domain}`,`Estado en Home Assistant: ${U?.state?U.state.toUpperCase():`N/A`}`,...Q?[`Causa detectada: Dispositivo físico no responde en Home Assistant (apagado, sin batería o sin enlace con la integración)`]:[],`Publicado en Matter: ${U?.exported?`SÍ`:`NO`}`,`Emparejado: ${U?.commissioned?`SÍ (Vinculado)`:`NO`}`,`Código de emparejamiento manual: ${U?.manualPairingCode||`N/A`}`,`Incidencias activas: ${U?.hasIssue||Q?`SÍ`:`NO`}`,`\n=== HISTORIAL DE EVENTOS Y DIAGNÓSTICO (${$.length}) ===`,$.map(e=>`${e.timestamp?`[${new Date(e.timestamp).toLocaleTimeString()}] `:``}[${e.level.toUpperCase()}] ${e.text}`).join(`
4
+ `)||`(Sin incidencias ni eventos registrados)`].join(`
5
+ `),style:{width:`100%`,boxSizing:`border-box`,background:`#080f1d`,color:`#94a3b8`,border:`1px solid rgba(255,255,255,0.12)`,borderRadius:`6px`,padding:`8px`,fontSize:`10.5px`,fontFamily:`monospace`,resize:`vertical`,userSelect:`all`}})]}),Q&&(0,c.jsxs)(`div`,{style:{background:`rgba(245, 158, 11, 0.15)`,borderLeft:`3px solid #f59e0b`,padding:`9px 11px`,borderRadius:`5px`,fontSize:`11.5px`,color:`#fbbf24`,marginBottom:`8px`,lineHeight:`1.5`},children:[(0,c.jsx)(`strong`,{style:{display:`block`,marginBottom:3},children:`⚠️ Causa del problema:`}),(0,c.jsxs)(`span`,{style:{color:`var(--text)`},children:[`Home Assistant informa estado `,(0,c.jsx)(`strong`,{children:Z.toUpperCase()}),`. El dispositivo físico no responde (posiblemente apagado, sin batería, fuera de rango o la integración origen está caída). El puente Matter sigue activo pero el aparato no puede recibir comandos.`]})]}),!Q&&U?.hasIssue&&$.length>0&&(()=>{let e=$[0];if(e.level===`info`)return null;let t=e.level===`error`;return(0,c.jsxs)(`div`,{style:{background:t?`rgba(239,68,68,0.12)`:`rgba(245,158,11,0.12)`,borderLeft:`3px solid ${t?`#ef4444`:`#f59e0b`}`,padding:`9px 11px`,borderRadius:`5px`,fontSize:`11.5px`,color:t?`#fca5a5`:`#fbbf24`,marginBottom:`8px`,lineHeight:`1.5`,userSelect:`text`},children:[(0,c.jsx)(`strong`,{style:{display:`block`,marginBottom:3},children:t?`🔴 Error detectado:`:`⚠️ Causa del problema:`}),(0,c.jsx)(`span`,{style:{color:`var(--text)`,wordBreak:`break-word`},children:e.text}),e.timestamp&&(0,c.jsxs)(`span`,{style:{display:`block`,marginTop:4,fontSize:`10px`,opacity:.6},children:[`Registrado: `,new Date(e.timestamp).toLocaleString()]})]})})(),!Q&&!U?.hasIssue&&(0,c.jsxs)(`div`,{style:{background:`rgba(16, 185, 129, 0.08)`,borderLeft:`3px solid #10b981`,padding:`8px 11px`,borderRadius:`5px`,fontSize:`11.5px`,color:`#6ee7b7`,marginBottom:`8px`,lineHeight:`1.4`},children:[(0,c.jsx)(`strong`,{style:{display:`block`,marginBottom:2},children:`✓ Dispositivo activo y comunicado`}),(0,c.jsxs)(`span`,{style:{color:`var(--text)`},children:[`Conectado con Home Assistant (estado: `,(0,c.jsx)(`strong`,{children:Z.toUpperCase()}),`). Sin incidencias activas.`]})]}),(0,c.jsx)(`p`,{id:`diagnostics-summary`,style:{margin:`4px 0`,fontSize:`11.5px`,color:Q?`#fbbf24`:`var(--muted)`},children:$.length===0?`Sin errores registrados para este accesorio.`:`${$.length} evento${$.length===1?``:`s`} registrado${$.length===1?``:`s`}`}),$.length>0&&(0,c.jsx)(`ul`,{id:`diagnostics-list`,style:{userSelect:`text`,maxHeight:`180px`,overflowY:`auto`,margin:`6px 0 0`,paddingLeft:`16px`,fontSize:`11px`,display:`flex`,flexDirection:`column`,gap:`4px`},children:$.slice(-25).map((e,t)=>(0,c.jsxs)(`li`,{style:{userSelect:`text`,wordBreak:`break-word`,color:e.level===`warning`?`#fbbf24`:e.level===`error`?`#f87171`:`var(--text)`},children:[e.timestamp?(0,c.jsxs)(`span`,{style:{opacity:.6,marginRight:`5px`},children:[`[`,new Date(e.timestamp).toLocaleTimeString(),`]`]}):null,(0,c.jsxs)(`span`,{style:{fontWeight:600,marginRight:`4px`},children:[`[`,e.level.toUpperCase(),`]`]}),e.text]},t))})]})]}),(0,c.jsxs)(`div`,{className:`qr-panel`,id:`qr-panel`,style:{display:`flex`,flexDirection:`column`,gap:8,minHeight:0,height:`100%`,overflowY:`auto`,overflowX:`hidden`,paddingRight:6},children:[(0,c.jsx)(`p`,{className:`card-label`,style:{margin:`0 0 2px 0`,flexShrink:0},children:L===`hap`?`CÓDIGO HOMEKIT HAP`:z?`CÓDIGO MATTER · ${U?.name||U?.attributes?.friendly_name||`BOTÓN`}`:`CÓDIGO MATTER`}),(0,c.jsx)(`div`,{className:`qr-status-label${L===`hap`?F?I?.isPaired?` commissioned`:` active`:``:X?` commissioned`:Y?` active`:``}`,id:`qr-status-label`,style:{flexShrink:0},children:L===`hap`?F?I?.isPaired?`Vinculado a Apple Home`:`Listo para emparejar`:`Sin publicar`:X?`Vinculado a Matter`:Y?`Listo para emparejar`:`Sin publicar`}),L===`hap`?F&&I?I.isPaired?(0,c.jsxs)(`div`,{className:`paired-success-glass-card`,id:`paired-hap-device-card`,children:[(0,c.jsx)(`div`,{className:`paired-apple-home-badge`,children:(0,c.jsx)(a,{variant:`color`,size:56})}),(0,c.jsx)(`h4`,{className:`paired-card-title`,children:`¡Accesorio HAP vinculado en Apple Home!`}),(0,c.jsxs)(`p`,{className:`paired-card-desc`,children:[`Este accesorio ya está vinculado y activo en tu app Casa de Apple como`,` `,(0,c.jsx)(`strong`,{style:{color:`#fcd34d`},children:I.profileLabel||I.hapProfile}),`.`]}),(0,c.jsxs)(`div`,{style:{marginTop:12,padding:`10px 14px`,background:`rgba(245, 158, 11, 0.1)`,borderRadius:10,border:`1px solid rgba(245, 158, 11, 0.3)`,fontSize:12,textAlign:`left`,color:`#fde68a`},children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`strong`,{children:`Código PIN de configuración:`}),` `,(0,c.jsx)(`code`,{children:I.pincode})]}),(0,c.jsxs)(`div`,{style:{marginTop:4},children:[(0,c.jsx)(`strong`,{children:`Puerto HAP:`}),` `,I.port]}),(0,c.jsxs)(`div`,{style:{marginTop:4},children:[(0,c.jsx)(`strong`,{children:`Firmware:`}),` `,(0,c.jsx)(`code`,{children:I.firmwareRevision||`Versión HAP no disponible`})]})]})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(i,{pairingCode:I.setupUri||``,manualCode:I.pincode,pinCode:I.pincode,variant:`hap-homekit`,entityName:e.name,elementId:`hap-device-qr-code`,noteText:`Escanea con la app Casa de Apple para vincular accesorio HAP`,badgeLabel:`Apple HomeKit HAP`}),(0,c.jsxs)(`div`,{style:{marginTop:10,padding:`10px 12px`,background:`rgba(245, 158, 11, 0.1)`,borderRadius:8,border:`1px solid rgba(245, 158, 11, 0.3)`,fontSize:`0.78rem`,textAlign:`left`},children:[(0,c.jsx)(`strong`,{style:{color:`#fcd34d`},children:`📲 Cómo vincular en Apple Casa:`}),(0,c.jsxs)(`ol`,{style:{margin:`4px 0 0 16px`,padding:0,color:`#fef3c7`,lineHeight:1.4},children:[(0,c.jsxs)(`li`,{children:[`Abre la app `,(0,c.jsx)(`strong`,{children:`Casa`}),` en tu iPhone, iPad o Mac.`]}),(0,c.jsxs)(`li`,{children:[`Toca `,(0,c.jsx)(`strong`,{children:`+`}),` y selecciona `,(0,c.jsx)(`strong`,{children:`Añadir accesorio`}),`.`]}),(0,c.jsxs)(`li`,{children:[`Escanea la pegatina interactiva amarilla de arriba o introduce el PIN manual `,(0,c.jsx)(`strong`,{children:I.pincode}),`.`]})]})]})]}):(0,c.jsxs)(`div`,{className:`qr-liquid-glass-card`,style:{padding:22,textAlign:`center`,color:`var(--text-secondary)`,flexShrink:0},children:[(0,c.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,marginBottom:12},children:(0,c.jsx)(a,{variant:`color`,size:54})}),(0,c.jsx)(`h4`,{style:{margin:`0 0 8px 0`,color:`#fcd34d`,fontSize:15,fontWeight:700},children:`Accesorio HomeKit HAP no publicado`}),(0,c.jsx)(`p`,{style:{fontSize:12.5,lineHeight:1.5,margin:`0 0 16px 0`,color:`#e5e7eb`},children:A.isRecommended?`Recomendado para este dispositivo (${A.categoryName}): se publicará como accesorio HAP nativo con soporte directo en Apple Casa.`:`Publica este accesorio en HomeKit HAP para generar su código QR interactivo con la casita amarilla de Apple Casa y código PIN de 8 dígitos.`}),(0,c.jsx)(`button`,{type:`button`,className:`button button-primary`,style:{background:`linear-gradient(135deg, #f59e0b, #d97706)`,color:`#000`,fontWeight:750,padding:`9px 18px`,borderRadius:8,border:`none`,cursor:`pointer`,width:`100%`,boxShadow:`0 4px 12px rgba(245, 158, 11, 0.25)`},onClick:Ce,disabled:v,children:ee?`Publicando en HomeKit HAP…`:`⚡ Publicar en HomeKit HAP ahora`})]}):Y?X&&!J?(0,c.jsxs)(`div`,{className:`paired-success-glass-card`,id:`paired-device-card`,children:[(0,c.jsx)(`div`,{className:`paired-apple-home-badge`,children:(0,c.jsx)(a,{variant:`color`,size:56})}),(0,c.jsx)(`h4`,{className:`paired-card-title`,children:`¡Accesorio vinculado en Apple Home!`}),(0,c.jsx)(`p`,{className:`paired-card-desc`,children:`Este dispositivo ya está emparejado y activo en tu red Matter. El código QR inicial se oculta para proteger la sesión activa.`}),(0,c.jsxs)(`div`,{className:`paired-multiadmin-box`,children:[(0,c.jsx)(`p`,{className:`paired-multiadmin-subtext`,children:`¿Deseas compartirlo con Google Home, Alexa o SmartThings?`}),(0,c.jsx)(`button`,{className:`button button-primary button-open-multiadmin`,type:`button`,onClick:Oe,disabled:v,id:`paired-open-multiadmin-btn`,children:(0,c.jsx)(`span`,{children:`🌐 Abrir Modo Multi-Admin (15 min)`})})]})]}):(0,c.jsxs)(c.Fragment,{children:[J&&(0,c.jsxs)(`div`,{id:`multi-admin-hint`,className:`multi-admin-hint`,style:{display:`block`,flexShrink:0},children:[(0,c.jsx)(`p`,{className:`hint-title`,children:`🌐 Modo Multi-Admin Abierto (15 min)`}),(0,c.jsxs)(`p`,{className:`hint-desc`,children:[`Ventana de emparejamiento abierta. Escanea este código QR en`,(0,c.jsx)(`strong`,{children:` Google Home`}),`, `,(0,c.jsx)(`strong`,{children:`Alexa`}),` o`,` `,(0,c.jsx)(`strong`,{children:`SmartThings`}),`.`]})]}),(0,c.jsx)(i,{pairingCode:ve,manualCode:ye,entityName:W?G?.name||e.name:U?.name||U?.attributes?.friendly_name||e.name,elementId:`device-qr-code`,variant:J?`multi-admin-glass`:`matter-badge`,badgeLabel:F?`Matter (Google / Alexa / SmartThings)`:`Matter (Multi-plataforma)`})]}):(0,c.jsx)(`div`,{className:`qr-liquid-glass-card`,style:{padding:20,textAlign:`center`,color:`var(--text-secondary)`,flexShrink:0},children:W?`Activa el interruptor general del accesorio para generar el código QR de Matter.`:z?`Activa este ${B?`enchufe`:`botón`} para generar su código QR independiente de Matter.`:`Activa la entidad para generar el código QR de Matter.`}),(0,c.jsxs)(`div`,{className:`accessory-controls`,id:`accessory-controls`,style:{flexShrink:0,paddingTop:6},children:[L===`matter`&&Y&&(0,c.jsxs)(`div`,{className:`matter-actions`,style:{display:`flex`,flexDirection:`column`,gap:6},children:[(0,c.jsx)(`button`,{className:`button button-secondary action-btn`,id:`reconnect-accessory-button`,type:`button`,onClick:De,disabled:v,title:`Refresca la conexión con Home Assistant y Matter`,style:{padding:`7px 10px`,fontSize:11.5},children:`↻ Recargar / Sincronizar`}),(0,c.jsx)(`button`,{className:`button button-secondary action-btn`,id:`regenerate-code-button`,type:`button`,onClick:Oe,disabled:v,style:{padding:`7px 10px`,fontSize:11.5},children:`Abrir Modo Multi-Admin`}),(0,c.jsx)(`button`,{className:`button button-danger action-btn`,id:`reset-accessory-button`,type:`button`,onClick:ke,disabled:v,title:`Desconectar de todas las casas y mostrar el código de vinculación`,style:{padding:`7px 10px`,fontSize:11.5},children:`Desconectar todo y mostrar QR`})]}),L===`hap`&&F&&(0,c.jsxs)(`div`,{className:`hap-actions`,style:{display:`flex`,flexDirection:`column`,gap:6},children:[I?.hapProfile===`security_system`&&(0,c.jsxs)(`div`,{className:`qr-liquid-glass-card`,style:{padding:12,display:`grid`,gap:8},children:[(0,c.jsx)(`strong`,{children:`PIN de la alarma de Home Assistant`}),(0,c.jsxs)(`span`,{style:{fontSize:12,color:`var(--text-secondary)`},children:[`Es independiente del PIN de emparejamiento HAP. Se envía a Home Assistant sólo si la entidad requiere código.`,I.alarmCodeConfigured?` Hay un PIN guardado.`:` No hay un PIN guardado.`]}),(0,c.jsx)(`input`,{"aria-label":`PIN de alarma de Home Assistant`,autoComplete:`new-password`,type:`password`,inputMode:`numeric`,value:x,onChange:e=>te(e.target.value),placeholder:I.alarmCodeConfigured?`Introduce para reemplazar el PIN`:`Introduce el PIN de Home Assistant`}),(0,c.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,c.jsx)(`button`,{className:`button button-secondary action-btn`,type:`button`,disabled:ne||!x,onClick:()=>void Te(),children:ne?`Guardando…`:`Guardar PIN`}),I.alarmCodeConfigured&&(0,c.jsx)(`button`,{className:`button button-secondary action-btn`,type:`button`,disabled:ne,onClick:()=>{te(``),Te(``)},children:`Borrar PIN`})]})]}),(0,c.jsx)(`button`,{className:`button button-danger action-btn`,id:`unregister-hap-button`,type:`button`,onClick:we,disabled:v,title:`Retirar accesorio de HomeKit HAP`,style:{padding:`7px 10px`,fontSize:11.5},children:ee?`Retirando de HomeKit HAP…`:`Retirar de HomeKit HAP`})]})]})]})]})]}),O&&(0,c.jsx)(l,{entity:O,onClose:()=>oe(null),onSuccess:(e,t)=>{O&&(O.hapAccessory={published:!0,isPaired:!1,hapProfile:`humidifier`,profileLabel:``,pincode:e,port:t}),oe(null),m()},showToast:h})]})};export{m as DeviceModal};
@@ -0,0 +1,8 @@
1
+ import{a as e,i as t,n,o as r}from"./index-CONl6ATp.js";var i=e(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),a=e((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),o=e((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),s=e(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),c=e(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),l=e((e=>{var t=a().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),u=e((e=>{var t=a().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),d=e((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),f=e((e=>{var t=o(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),p=e((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),m=e((e=>{var t=p();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),h=e(((e,t)=>{var n=m();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),g=e((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),_=e((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
2
+ ]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^[0-9]+$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),v=e((e=>{var t=g(),n=_();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),y=e((e=>{var t=a(),n=f(),r=o(),i=v(),s=g(),c=7973,l=t.getBCHDigit(c);function u(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function d(e,t){return i.getCharCountIndicator(e,t)+4}function p(e,t){let n=0;return e.forEach(function(e){let r=d(e.mode,t);n+=r+e.getBitsLength()}),n}function m(t,n){for(let r=1;r<=40;r++)if(p(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return s.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,a){if(!s.isValid(e))throw Error(`Invalid QR Code version`);a===void 0&&(a=i.BYTE);let o=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(a===i.MIXED)return o;let c=o-d(a,e);switch(a){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return m(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return u(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!s.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-l>=0;)n^=c<<t.getBCHDigit(n)-l;return e<<12|n}})),b=e((e=>{var t=a(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),x=e(((e,t)=>{var n=v();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),S=e(((e,t)=>{var n=v(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t=0;for(;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),C=e(((e,t)=>{var n=v();function r(e){this.mode=n.BYTE,this.data=typeof e==`string`?new TextEncoder().encode(e):new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),w=e(((e,t)=>{var n=v(),r=a();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t=0;for(;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
3
+ Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),T=e(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),E=e((e=>{var t=v(),n=x(),r=S(),i=C(),o=w(),s=_(),c=a(),l=T();function u(e){return unescape(encodeURIComponent(e)).length}function d(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function f(e){let n=d(s.NUMERIC,t.NUMERIC,e),r=d(s.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return c.isKanjiModeEnabled()?(i=d(s.BYTE,t.BYTE,e),a=d(s.KANJI,t.KANJI,e)):(i=d(s.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function p(e,a){switch(a){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return o.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function m(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function h(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:u(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:u(i.data)}])}}return n}function g(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=p(r[o].lastCount+l.length,l.mode)-p(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=p(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function y(e,a){let s,l=t.getBestModeForData(e);if(s=t.from(a,l),s!==t.BYTE&&s.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(s)+`.
4
+ Suggested mode is: `+t.toString(l));switch(s===t.KANJI&&!c.isKanjiModeEnabled()&&(s=t.BYTE),s){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new o(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(y(t,null)):t.data&&e.push(y(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=g(h(f(t,c.isKanjiModeEnabled())),n),i=l.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(m(a))},e.rawSplit=function(t){return e.fromArray(f(t,c.isKanjiModeEnabled()))}})),D=e((e=>{var t=a(),n=o(),r=s(),i=c(),p=l(),m=u(),g=d(),_=f(),x=h(),S=y(),C=b(),w=v(),T=E();function D(e,t){let n=e.size,r=m.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function O(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function k(e,t){let n=p.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function A(e,t){let n=e.size,r=S.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function j(e,t,n){let r=e.size,i=C.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function M(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function N(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),w.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-_.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return P(a,e,n)}function P(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-_.getTotalCodewordsCount(n,r),o=_.getBlocksCount(n,r),s=o-i%o,c=Math.floor(i/o),l=Math.floor(a/o),u=l+1,d=c-l,f=new x(d),p=0,m=Array(o),h=Array(o),g=0,v=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?l:u;m[e]=v.slice(p,p+t),h[e]=f.encode(m[e]),p+=t,g=Math.max(g,t)}let y=new Uint8Array(i),b=0,S,C;for(S=0;S<g;S++)for(C=0;C<o;C++)S<m[C].length&&(y[b++]=m[C][S]);for(S=0;S<d;S++)for(C=0;C<o;C++)y[b++]=h[C][S];return y}function F(e,n,r,a){let o;if(Array.isArray(e))o=T.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=T.rawSplit(e);t=S.getBestVersionForData(n,r)}o=T.fromString(e,t||40)}else throw Error(`Invalid data`);let s=S.getBestVersionForData(o,r);if(!s)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=s;else if(n<s)throw Error(`
5
+ The chosen QR Code version cannot contain this amount of data.
6
+ Minimum version required to store current data is: `+s+`.
7
+ `);let c=N(n,r,o),l=new i(t.getSymbolSize(n));return D(l,n),O(l),k(l,n),j(l,r,0),n>=7&&A(l,n),M(l,c),isNaN(a)&&(a=g.getBestMask(l,j.bind(null,l,r))),g.applyMask(a,l),j(l,r,a),{modules:l,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=S.from(r.version),o=g.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),F(e,a,i,o)}})),O=e((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||={},e.color||(e.color={});let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[+!!a[t*i+r]]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),k=e((e=>{var t=O();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||={},t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o!==void 0||i&&i.getContext||(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i!==void 0||n&&n.getContext||(i=n,n=void 0),i||={};let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),A=e((e=>{var t=O();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>0&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg>
8
+ `;return typeof a==`function`&&a(null,p),p}})),j=e((e=>{var t=i(),n=D(),r=k(),a=A();function o(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=o.bind(null,r.render),e.toDataURL=o.bind(null,r.renderToDataURL),e.toString=o.bind(null,function(e,t,n){return a.render(e,n)})})),M=r(t(),1),N=r(j(),1),P=n(),F=({variant:e=`color`,size:t=48})=>{let n=e===`purple`,r=e===`color`,i=n?`purp`:r?`col`:`mon`;return(0,P.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 100 100`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:{display:`block`,flexShrink:0},"aria-hidden":`true`,children:[(0,P.jsx)(`defs`,{children:n?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`linearGradient`,{id:`${i}-out`,x1:`50`,y1:`8`,x2:`50`,y2:`92`,gradientUnits:`userSpaceOnUse`,children:[(0,P.jsx)(`stop`,{offset:`0%`,stopColor:`#9333ea`}),(0,P.jsx)(`stop`,{offset:`100%`,stopColor:`#7e22ce`})]}),(0,P.jsxs)(`linearGradient`,{id:`${i}-mid`,x1:`50`,y1:`26`,x2:`50`,y2:`82`,gradientUnits:`userSpaceOnUse`,children:[(0,P.jsx)(`stop`,{offset:`0%`,stopColor:`#c084fc`}),(0,P.jsx)(`stop`,{offset:`100%`,stopColor:`#a855f7`})]}),(0,P.jsxs)(`linearGradient`,{id:`${i}-in`,x1:`50`,y1:`44`,x2:`50`,y2:`74`,gradientUnits:`userSpaceOnUse`,children:[(0,P.jsx)(`stop`,{offset:`0%`,stopColor:`#faf5ff`}),(0,P.jsx)(`stop`,{offset:`100%`,stopColor:`#f3e8ff`})]}),(0,P.jsx)(`filter`,{id:`${i}-sh1`,x:`0`,y:`0`,width:`100`,height:`100`,filterUnits:`userSpaceOnUse`,children:(0,P.jsx)(`feDropShadow`,{dx:`0`,dy:`2.5`,stdDeviation:`2.5`,floodColor:`#581c87`,floodOpacity:`0.4`})}),(0,P.jsx)(`filter`,{id:`${i}-sh2`,x:`0`,y:`0`,width:`100`,height:`100`,filterUnits:`userSpaceOnUse`,children:(0,P.jsx)(`feDropShadow`,{dx:`0`,dy:`1.5`,stdDeviation:`1.5`,floodColor:`#6b21a8`,floodOpacity:`0.3`})})]}):r?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`linearGradient`,{id:`${i}-out`,x1:`50`,y1:`8`,x2:`50`,y2:`92`,gradientUnits:`userSpaceOnUse`,children:[(0,P.jsx)(`stop`,{offset:`0%`,stopColor:`#ff9f0a`}),(0,P.jsx)(`stop`,{offset:`100%`,stopColor:`#f57c00`})]}),(0,P.jsxs)(`linearGradient`,{id:`${i}-mid`,x1:`50`,y1:`26`,x2:`50`,y2:`82`,gradientUnits:`userSpaceOnUse`,children:[(0,P.jsx)(`stop`,{offset:`0%`,stopColor:`#ffc83b`}),(0,P.jsx)(`stop`,{offset:`100%`,stopColor:`#ffab10`})]}),(0,P.jsxs)(`linearGradient`,{id:`${i}-in`,x1:`50`,y1:`44`,x2:`50`,y2:`74`,gradientUnits:`userSpaceOnUse`,children:[(0,P.jsx)(`stop`,{offset:`0%`,stopColor:`#fffde7`}),(0,P.jsx)(`stop`,{offset:`100%`,stopColor:`#fff3b0`})]}),(0,P.jsx)(`filter`,{id:`${i}-sh1`,x:`0`,y:`0`,width:`100`,height:`100`,filterUnits:`userSpaceOnUse`,children:(0,P.jsx)(`feDropShadow`,{dx:`0`,dy:`2.5`,stdDeviation:`2.5`,floodColor:`#b25000`,floodOpacity:`0.35`})}),(0,P.jsx)(`filter`,{id:`${i}-sh2`,x:`0`,y:`0`,width:`100`,height:`100`,filterUnits:`userSpaceOnUse`,children:(0,P.jsx)(`feDropShadow`,{dx:`0`,dy:`1.5`,stdDeviation:`1.5`,floodColor:`#d97706`,floodOpacity:`0.25`})})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`linearGradient`,{id:`${i}-out`,x1:`50`,y1:`8`,x2:`50`,y2:`92`,gradientUnits:`userSpaceOnUse`,children:[(0,P.jsx)(`stop`,{offset:`0%`,stopColor:`#1e293b`}),(0,P.jsx)(`stop`,{offset:`100%`,stopColor:`#0f172a`})]}),(0,P.jsxs)(`linearGradient`,{id:`${i}-mid`,x1:`50`,y1:`26`,x2:`50`,y2:`82`,gradientUnits:`userSpaceOnUse`,children:[(0,P.jsx)(`stop`,{offset:`0%`,stopColor:`#64748b`}),(0,P.jsx)(`stop`,{offset:`100%`,stopColor:`#475569`})]}),(0,P.jsxs)(`linearGradient`,{id:`${i}-in`,x1:`50`,y1:`44`,x2:`50`,y2:`74`,gradientUnits:`userSpaceOnUse`,children:[(0,P.jsx)(`stop`,{offset:`0%`,stopColor:`#ffffff`}),(0,P.jsx)(`stop`,{offset:`100%`,stopColor:`#f1f5f9`})]}),(0,P.jsx)(`filter`,{id:`${i}-sh1`,x:`0`,y:`0`,width:`100`,height:`100`,filterUnits:`userSpaceOnUse`,children:(0,P.jsx)(`feDropShadow`,{dx:`0`,dy:`2.5`,stdDeviation:`2.5`,floodColor:`#000000`,floodOpacity:`0.45`})}),(0,P.jsx)(`filter`,{id:`${i}-sh2`,x:`0`,y:`0`,width:`100`,height:`100`,filterUnits:`userSpaceOnUse`,children:(0,P.jsx)(`feDropShadow`,{dx:`0`,dy:`1.5`,stdDeviation:`1.5`,floodColor:`#0f172a`,floodOpacity:`0.3`})})]})}),(0,P.jsx)(`path`,{d:`M72 18V38H84V22.5C84 20.01 81.99 18 79.5 18H72Z`,fill:`url(#${i}-out)`}),(0,P.jsx)(`path`,{d:`M47.45 9.77C48.98 8.44 51.02 8.44 52.55 9.77L90.8 42.87C92.68 44.5 91.53 47.6 89.04 47.6H79.5V81.5C79.5 86.47 75.47 90.5 70.5 90.5H29.5C24.53 90.5 20.5 86.47 20.5 81.5V47.6H10.96C8.47 47.6 7.32 44.5 9.2 42.87L47.45 9.77Z`,fill:`url(#${i}-out)`}),(0,P.jsx)(`path`,{d:`M48.1 27.8C49.2 26.8 50.8 26.8 51.9 27.8L71.8 44.7C73.2 45.9 72.4 48.2 70.5 48.2H66.5V74.5C66.5 77.8 63.8 80.5 60.5 80.5H39.5C36.2 80.5 33.5 77.8 33.5 74.5V48.2H29.5C27.6 48.2 26.8 45.9 28.2 44.7L48.1 27.8Z`,fill:`url(#${i}-mid)`,filter:`url(#${i}-sh1)`}),(0,P.jsx)(`path`,{d:`M48.7 44.2C49.5 43.5 50.5 43.5 51.3 44.2L60.5 52.1C61.4 52.9 60.8 54.5 59.6 54.5H57.5V69.5C57.5 71.4 55.9 73 54 73H46C44.1 73 42.5 71.4 42.5 69.5V54.5H40.4C39.2 54.5 38.6 52.9 39.5 52.1L48.7 44.2Z`,fill:`url(#${i}-in)`,filter:`url(#${i}-sh2)`})]})};function I(e){if(!e)return`—————`;let t=String(e).replace(/\D/g,``);return t.length===11?`${t.slice(0,4)}-${t.slice(4,7)}-${t.slice(7)}`:t.length===21?`${t.slice(0,4)}-${t.slice(4,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16)}`:e}function L(e,t){if(!e)return{line1:`••••`,line2:`••••`};let n=String(e).replace(/\D/g,``);if(n.length===8)return{line1:n.slice(0,4).split(``).join(` `),line2:n.slice(4,8).split(``).join(` `)};if(n.length===11)return{line1:n.slice(0,4).split(``).join(` `),line2:`${n.slice(4,7)}-${n.slice(7)}`};if(n.length===21)return{line1:n.slice(0,4).split(``).join(` `),line2:`${n.slice(4,11)}...`};let r=Math.ceil(n.length/2);return{line1:n.slice(0,r).split(``).join(` `),line2:n.slice(r)}}var R=({pairingCode:e,manualCode:t,pinCode:n,entityName:r=`matter-accessory`,elementId:i=`device-qr-code`,noteText:a,variant:o=`matter-badge`,videoCodec:s,isHevc:c=!1,badgeLabel:l})=>{let u=(0,M.useRef)(null),[d,f]=(0,M.useState)(!1),[p,m]=(0,M.useState)(null),h=o===`multi-admin-glass`,g=o===`hap-homekit`,_=!!c;(0,M.useEffect)(()=>{e&&u.current&&(m(null),N.toCanvas(u.current,e,{width:180,margin:4,color:{dark:`#000000`,light:`#ffffff`},errorCorrectionLevel:`M`}).catch(e=>{console.error(`Error al renderizar código QR:`,e),m(`Error al generar código QR`)}))},[e,o]);let v=async r=>{let i=r||t||n||e;if(i)try{await navigator.clipboard.writeText(i),f(!0),setTimeout(()=>f(!1),2500)}catch{let e=document.createElement(`input`);e.value=i,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e),f(!0),setTimeout(()=>f(!1),2500)}},y=async()=>{if(!e)return;let t=`${r.toLowerCase().replace(/[^a-z0-9]+/g,`-`)}-qr.png`;try{let n=await N.toDataURL(e,{width:920,margin:4,errorCorrectionLevel:`M`}),r=document.createElement(`a`);r.download=t,r.href=n,r.click()}catch{m(`No se pudo descargar el código QR`)}};if(!e)return(0,P.jsx)(`div`,{className:`qr-empty-card`,children:`Sin código QR disponible.`});let b=g?n||t:t||e,x=L(b,g);return(0,P.jsxs)(`div`,{className:`qr-display-container`,style:{display:`block`},children:[h?(0,P.jsxs)(`div`,{className:`qr-liquid-glass-card multi-admin-mode`,children:[(0,P.jsxs)(`div`,{className:`qr-badge-header multi-admin-header`,children:[(0,P.jsxs)(`div`,{className:`qr-badge-title-group`,children:[(0,P.jsx)(`span`,{className:`multi-admin-sparkle-icon`,"aria-hidden":`true`,children:(0,P.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#38bdf8`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,P.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,P.jsx)(`line`,{x1:`2`,y1:`12`,x2:`22`,y2:`12`}),(0,P.jsx)(`path`,{d:`M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z`})]})}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`strong`,{className:`qr-badge-brand text-cyan`,children:`Modo Multi-Admin`}),(0,P.jsx)(`span`,{className:`qr-badge-type`,children:`Ventana abierta (15 min)`})]})]}),(0,P.jsx)(`span`,{className:`qr-protocol-tag tag-multi-admin`,children:`Activo`})]}),(0,P.jsxs)(`div`,{className:`qr-visual-wrapper`,children:[(0,P.jsx)(`div`,{className:`qr-frame-glow`,"aria-hidden":`true`}),(0,P.jsx)(`div`,{className:`qr-frame`,children:(0,P.jsx)(`div`,{id:i,children:(0,P.jsx)(`canvas`,{ref:u,style:{width:`100%`,height:`100%`,display:`block`}})})})]}),(0,P.jsxs)(`div`,{className:`qr-manual-box box-multi-admin`,children:[(0,P.jsx)(`span`,{className:`manual-code-label`,children:`CÓDIGO MATTER MULTI-ADMIN`}),(0,P.jsxs)(`div`,{className:`manual-code-row`,children:[(0,P.jsx)(`code`,{className:`manual-code-display code-cyan`,children:I(t||e)}),(0,P.jsxs)(`button`,{className:`button-copy-code`,type:`button`,onClick:()=>v(t||e),title:`Copiar código temporal Matter`,"aria-label":`Copiar código manual`,children:[(0,P.jsx)(`span`,{className:`copy-icon`,children:`📋`}),(0,P.jsx)(`span`,{className:`copy-text`,children:d?`¡Copiado!`:`Copiar`})]})]})]})]}):(0,P.jsxs)(`div`,{className:`ios27-glass-sticker ${_?`sticker-hevc`:g?`sticker-hap`:`sticker-matter`}`,children:[(0,P.jsxs)(`div`,{className:`sticker-header`,children:[(0,P.jsx)(`div`,{className:`sticker-house-col`,children:(0,P.jsx)(F,{variant:_?`purple`:g?`color`:`mono`,size:48})}),(0,P.jsxs)(`div`,{className:`sticker-code-col`,children:[(0,P.jsx)(`div`,{className:`sticker-code-line line-1`,children:x.line1}),(0,P.jsx)(`div`,{className:`sticker-code-line line-2`,children:x.line2})]})]}),(0,P.jsx)(`div`,{className:`sticker-qr-frame`,children:(0,P.jsx)(`div`,{id:i,className:`sticker-qr-canvas-wrapper`,children:(0,P.jsx)(`canvas`,{ref:u,style:{width:`100%`,height:`100%`,display:`block`}})})}),(0,P.jsxs)(`div`,{className:`sticker-footer-row`,children:[(0,P.jsx)(`span`,{className:`sticker-badge-tag`,children:l||(g?`Apple HomeKit HAP`:`Matter (Multi-plataforma)`)}),(0,P.jsx)(`button`,{className:`button-sticker-copy`,type:`button`,onClick:()=>v(b),title:`Copiar código`,"aria-label":`Copiar código`,children:(0,P.jsx)(`span`,{children:d?`¡Copiado!`:`Copiar`})})]})]}),p&&(0,P.jsx)(`p`,{style:{color:`#f87171`,fontSize:`0.8rem`,marginTop:6,textAlign:`center`},children:p}),(0,P.jsx)(`div`,{className:`qr-card-actions`,children:(0,P.jsx)(`button`,{className:`button-download-qr`,type:`button`,onClick:y,title:`Descargar código QR en alta resolución (PNG)`,children:(0,P.jsx)(`span`,{children:`💾 Descargar QR (PNG)`})})}),a&&(0,P.jsx)(`small`,{className:`qr-note`,children:a})]})};export{R as n,F as t};
@@ -0,0 +1 @@
1
+ import{i as e,n as t,o as n,r}from"./index-CONl6ATp.js";var i=n(e(),1),a=t(),o=({config:e,onClose:t,onRefresh:n,showToast:o})=>{let[s,c]=(0,i.useState)(``),[l,u]=(0,i.useState)(``),[d,f]=(0,i.useState)(``),[p,m]=(0,i.useState)(!1),[h,g]=(0,i.useState)(!1),[_,v]=(0,i.useState)(!1),[y,b]=(0,i.useState)(null);(0,i.useEffect)(()=>{e&&(c(e.serverUrl||``),u(e.username||``),m(!!e.allowSelfSignedCertificate))},[e]);let x=async()=>{if(!s.trim()||!l.trim()||!d)o(`Completa la URL, usuario y contraseña`,!0);else{g(!0),b({text:`Comprobando conexión con Scrypted...`});try{let e=await r.testScryptedConnection({serverUrl:s.trim(),username:l.trim(),password:d,allowSelfSignedCertificate:p});e.success?b({text:`✓ Conexión exitosa. Se detectaron ${e.cameraCount||0} cámaras.`}):b({text:`❌ ${e.error||`No se pudo conectar`}`,isError:!0})}catch(e){b({text:`❌ Error: ${e.message}`,isError:!0})}finally{g(!1)}}},S=async e=>{if(e.preventDefault(),!s.trim()||!l.trim())o(`Ingresa la URL y el usuario`,!0);else{v(!0);try{await r.saveScryptedConfig({serverUrl:s.trim(),username:l.trim(),password:d,allowSelfSignedCertificate:p}),o(`✓ Configuración de Scrypted guardada exitosamente`),n(),t()}catch(e){o(e.message||`Error al guardar`,!0)}finally{v(!1)}}},[C,w]=(0,i.useState)(!1);return(0,a.jsx)(`div`,{className:`modal-backdrop open`,role:`dialog`,"aria-modal":`true`,children:(0,a.jsxs)(`section`,{className:`modal`,style:{maxWidth:520},children:[(0,a.jsx)(`button`,{className:`icon-button`,type:`button`,"aria-label":`Cerrar`,onClick:t,children:`×`}),(0,a.jsxs)(`header`,{className:`modal-header`,children:[(0,a.jsx)(`span`,{className:`modal-icon`,style:{fontSize:`1.8rem`},children:`📹`}),(0,a.jsxs)(`div`,{children:[(0,a.jsx)(`p`,{className:`eyebrow`,children:`INTEGRACIÓN DE CÁMARAS`}),(0,a.jsx)(`h2`,{children:`Conectar con Scrypted`}),(0,a.jsx)(`p`,{className:`entity-id`,children:`Transmisión de alta velocidad HAP y Matter`})]})]}),(0,a.jsxs)(`form`,{onSubmit:S,style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,a.jsxs)(`div`,{children:[(0,a.jsx)(`label`,{style:{display:`block`,fontSize:`0.8rem`,color:`var(--dim)`,marginBottom:4},children:`URL del Servidor Scrypted`}),(0,a.jsx)(`input`,{type:`url`,value:s,onChange:e=>c(e.target.value),placeholder:`https://192.168.1.100:10443`,required:!0,style:{width:`100%`,padding:`8px 12px`,borderRadius:8,background:`rgba(0,0,0,0.2)`,border:`1px solid rgba(255,255,255,0.1)`,color:`#fff`}})]}),(0,a.jsxs)(`div`,{children:[(0,a.jsx)(`label`,{style:{display:`block`,fontSize:`0.8rem`,color:`var(--dim)`,marginBottom:4},children:`Usuario de Scrypted`}),(0,a.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),placeholder:`admin`,required:!0,style:{width:`100%`,padding:`8px 12px`,borderRadius:8,background:`rgba(0,0,0,0.2)`,border:`1px solid rgba(255,255,255,0.1)`,color:`#fff`}})]}),(0,a.jsxs)(`div`,{children:[(0,a.jsx)(`label`,{style:{display:`block`,fontSize:`0.8rem`,color:`var(--dim)`,marginBottom:4},children:`Contraseña`}),(0,a.jsx)(`input`,{type:`password`,value:d,onChange:e=>f(e.target.value),placeholder:`••••••••`,style:{width:`100%`,padding:`8px 12px`,borderRadius:8,background:`rgba(0,0,0,0.2)`,border:`1px solid rgba(255,255,255,0.1)`,color:`#fff`}})]}),(0,a.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8,cursor:`pointer`,fontSize:`0.82rem`},children:[(0,a.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked)}),(0,a.jsx)(`span`,{children:`Permitir certificados SSL autofirmados (HTTPS local)`})]}),y&&(0,a.jsx)(`div`,{style:{padding:`8px 12px`,borderRadius:8,fontSize:`0.8rem`,background:y.isError?`rgba(239,68,68,0.15)`:`rgba(16,185,129,0.15)`,color:y.isError?`#fca5a5`:`#6ee7b7`},children:y.text}),(0,a.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,gap:8,marginTop:12,flexWrap:`wrap`},children:[(0,a.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,a.jsx)(`button`,{className:`button button-secondary`,type:`button`,onClick:x,disabled:h,children:h?`Comprobando...`:`Probar Conexión`}),!!e?.serverUrl&&(0,a.jsx)(`button`,{className:`button button-danger-outline`,type:`button`,onClick:async()=>{if(confirm(`¿Desvincular Scrypted y limpiar todas las cámaras en caché de Scrypted?`)){w(!0);try{await r.deleteScryptedConfig(),o(`✓ Scrypted desvinculado y caché de cámaras limpiada`),n(),t()}catch(e){o(e.message||`Error al desvincular`,!0)}finally{w(!1)}}},disabled:C,title:`Elimina las credenciales y limpia las cámaras de Scrypted en caché`,style:{background:`rgba(239, 68, 68, 0.12)`,color:`#fca5a5`,borderColor:`rgba(239, 68, 68, 0.35)`,fontSize:`0.8rem`},children:C?`Limpiando...`:`Desvincular y Limpiar`})]}),(0,a.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,a.jsx)(`button`,{className:`button button-secondary`,type:`button`,onClick:t,children:`Cancelar`}),(0,a.jsx)(`button`,{className:`button button-primary`,type:`submit`,disabled:_,children:_?`Guardando...`:`Guardar`})]})]})]})]})})};export{o as ScryptedModal};
@@ -0,0 +1,2 @@
1
+ import{i as e,n as t,o as n,r}from"./index-CONl6ATp.js";import{t as i}from"./clipboard-CnKYMNaq.js";var a=n(e(),1),o=t();function s(e){let t=e.toLowerCase();return/\b(error|failed|failure|exception|unable|crash|fatal)\b/.test(t)?`error`:/\b(warn|warning|timeout|retry|deprecated)\b/.test(t)?`warn`:/\b(info|notice|debug|connected|registered|online)\b/.test(t)?`info`:`default`}var c=({isOpen:e,onClose:t,showToast:n,status:c,stats:l,onRefresh:u})=>{let[d,f]=(0,a.useState)(``),[p,m]=(0,a.useState)(1883),[h,g]=(0,a.useState)(``),[_,v]=(0,a.useState)(``),[y,b]=(0,a.useState)(!1),[x,S]=(0,a.useState)(!1),[C,w]=(0,a.useState)(!1),[T,E]=(0,a.useState)([]),[D,O]=(0,a.useState)(!1),[k,A]=(0,a.useState)(`all`),[j,M]=(0,a.useState)(``),[N,P]=(0,a.useState)(!0),F=(0,a.useRef)(null),I=async()=>{O(!0);try{let e=await r.getLogs();E(e.logs||[])}catch(e){n(e.message||`Error al cargar logs`,!0)}finally{O(!1)}};(0,a.useEffect)(()=>{e&&(r.getMqttConfig().then(e=>{e&&(f(e.host||``),m(e.port||1883),g(e.username||e.user||``),b(!!e.hasPassword),v(``),S(!1))}).catch(()=>{}),I())},[e]);let L=(0,a.useMemo)(()=>{let e=0,t=0,n=0;for(let r of T){let i=s(r);i===`error`?e++:i===`warn`?t++:i===`info`&&n++}return{all:T.length,errors:e,warns:t,infos:n}},[T]),R=(0,a.useMemo)(()=>{let e=T;if(k!==`all`&&(e=e.filter(e=>s(e)===k)),j.trim()){let t=j.toLowerCase().trim();e=e.filter(e=>e.toLowerCase().includes(t))}return e},[T,k,j]);return(0,a.useEffect)(()=>{N&&F.current&&(F.current.scrollTop=F.current.scrollHeight)},[R,N]),e?(0,o.jsx)(`div`,{className:`modal-backdrop open`,id:`settings-modal`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`settings-title`,children:(0,o.jsxs)(`section`,{className:`modal modal-settings-wide`,children:[(0,o.jsx)(`button`,{className:`icon-button`,id:`settings-modal-close`,type:`button`,"aria-label":`Cerrar`,onClick:t,children:`×`}),(0,o.jsx)(`div`,{className:`settings-modal-header`,children:(0,o.jsxs)(`div`,{className:`settings-modal-header-left`,children:[(0,o.jsx)(`span`,{className:`settings-sparkle`,children:`⚙️`}),(0,o.jsxs)(`div`,{children:[(0,o.jsxs)(`div`,{className:`settings-header-badge-row`,children:[(0,o.jsx)(`span`,{className:`settings-badge-eyebrow`,children:`MANTENIMIENTO & SISTEMA`}),(0,o.jsx)(`span`,{className:`settings-ha-status-pill`,children:c?.haStatus===`conectado`?(0,o.jsx)(`span`,{className:`pill-healthy`,children:`✓ HA Conectado`}):(0,o.jsx)(`span`,{className:`pill-warning`,children:`⚠️ HA Desconectado`})}),(0,o.jsxs)(`span`,{className:`settings-version-pill`,children:[`v`,c?.version||`1.5.76`]})]}),(0,o.jsx)(`h2`,{id:`settings-title`,children:`Ajustes del Servicio & Registros`})]})]})}),(0,o.jsxs)(`div`,{className:`settings-grid-layout`,children:[(0,o.jsxs)(`div`,{className:`settings-left-col`,children:[(0,o.jsxs)(`div`,{className:`settings-card-glass`,children:[(0,o.jsxs)(`div`,{className:`settings-card-title`,children:[(0,o.jsx)(`span`,{children:`📊`}),` Telemetría del Servicio`]}),(0,o.jsxs)(`div`,{className:`settings-telemetry-grid`,children:[(0,o.jsxs)(`div`,{className:`telemetry-item`,children:[(0,o.jsx)(`span`,{className:`telemetry-label`,children:`Servicio Bridge`}),(0,o.jsx)(`strong`,{className:`telemetry-value`,title:c?.bridgeName,children:c?.bridgeName||`Matter All-in-One`})]}),(0,o.jsxs)(`div`,{className:`telemetry-item`,children:[(0,o.jsx)(`span`,{className:`telemetry-label`,children:`Nodos Activos`}),(0,o.jsx)(`strong`,{className:`telemetry-value`,children:l?.exportedNodes??c?.exportedNodes??0})]}),(0,o.jsxs)(`div`,{className:`telemetry-item`,children:[(0,o.jsx)(`span`,{className:`telemetry-label`,children:`Emparejados`}),(0,o.jsx)(`strong`,{className:`telemetry-value text-green`,children:l?.pairedTotal??c?.commissionedNodes??0})]}),(0,o.jsxs)(`div`,{className:`telemetry-item`,children:[(0,o.jsx)(`span`,{className:`telemetry-label`,children:`Incidencias`}),(0,o.jsx)(`strong`,{className:`telemetry-value ${(l?.issues??0)>0?`text-amber`:`text-green`}`,children:l?.issues??0})]})]})]}),(0,o.jsxs)(`div`,{className:`settings-card-glass`,children:[(0,o.jsxs)(`div`,{className:`settings-card-title`,children:[(0,o.jsx)(`span`,{children:`📡`}),` Configuración MQTT (Auto-Discovery)`]}),(0,o.jsx)(`p`,{className:`settings-card-desc`,children:`Habilita la integración de dispositivos MQTT directamente en el ecosistema Matter.`}),(0,o.jsxs)(`div`,{className:`mqtt-form-grid`,children:[(0,o.jsxs)(`div`,{className:`input-group`,children:[(0,o.jsx)(`label`,{htmlFor:`mqtt-host`,children:`Broker IP / Host`}),(0,o.jsx)(`input`,{type:`text`,id:`mqtt-host`,placeholder:`ej. 192.168.110.147`,"aria-label":`MQTT Host`,className:`form-input`,value:d,onChange:e=>f(e.target.value)})]}),(0,o.jsxs)(`div`,{className:`input-group`,children:[(0,o.jsx)(`label`,{htmlFor:`mqtt-port`,children:`Puerto`}),(0,o.jsx)(`input`,{type:`number`,id:`mqtt-port`,placeholder:`1883`,"aria-label":`MQTT Port`,className:`form-input`,value:p,onChange:e=>m(Number(e.target.value))})]}),(0,o.jsxs)(`div`,{className:`input-group`,children:[(0,o.jsx)(`label`,{htmlFor:`mqtt-user`,children:`Usuario (opcional)`}),(0,o.jsx)(`input`,{type:`text`,id:`mqtt-user`,placeholder:`Usuario MQTT`,"aria-label":`MQTT User`,className:`form-input`,value:h,onChange:e=>g(e.target.value)})]}),(0,o.jsxs)(`div`,{className:`input-group`,children:[(0,o.jsx)(`label`,{htmlFor:`mqtt-pass`,children:`Nueva contraseña (opcional)`}),(0,o.jsx)(`input`,{type:`password`,id:`mqtt-pass`,placeholder:y?`Guardada; vacío conserva la actual`:`Contraseña`,"aria-label":`MQTT Password`,className:`form-input`,value:_,onChange:e=>v(e.target.value)})]})]}),y&&(0,o.jsxs)(`label`,{className:`checkbox-row`,htmlFor:`mqtt-clear-password`,children:[(0,o.jsx)(`input`,{id:`mqtt-clear-password`,type:`checkbox`,checked:x,onChange:e=>S(e.target.checked)}),`Eliminar la contraseña guardada`]}),(0,o.jsx)(`button`,{className:`button button-primary button-full`,id:`mqtt-save-button`,type:`button`,onClick:async()=>{w(!0);try{await r.saveMqttConfig({host:d,port:Number(p),user:h,username:h,password:_,clearPassword:x}),x?(b(!1),S(!1)):_&&(b(!0),v(``)),n(`✓ Configuración MQTT guardada`),u&&u()}catch(e){n(e.message||`Error al guardar MQTT`,!0)}finally{w(!1)}},disabled:C,children:C?`Guardando...`:`💾 Guardar Configuración MQTT`})]}),(0,o.jsxs)(`div`,{className:`settings-card-glass`,children:[(0,o.jsxs)(`div`,{className:`settings-card-title`,children:[(0,o.jsx)(`span`,{children:`⚡`}),` Operaciones del Servicio`]}),(0,o.jsxs)(`div`,{className:`operations-row`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`strong`,{children:`Reiniciar servicio`}),(0,o.jsx)(`p`,{children:`Recarga el runtime y restablece conexiones activas.`})]}),(0,o.jsx)(`button`,{className:`button button-secondary`,id:`restart-button`,type:`button`,onClick:async()=>{if(confirm(`¿Deseas reiniciar el servicio de Matter All-in-One?`))try{await r.restartService(),n(`Reiniciando servicio...`),t()}catch(e){n(e.message||`Error al reiniciar servicio`,!0)}},children:`🔄 Reiniciar`})]})]}),(0,o.jsxs)(`div`,{className:`settings-card-glass danger-card`,children:[(0,o.jsxs)(`div`,{className:`settings-card-title danger-title`,children:[(0,o.jsx)(`span`,{children:`⚠️`}),` Zona de Mantenimiento Crítico`]}),(0,o.jsxs)(`div`,{className:`operations-row`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`strong`,{className:`text-red`,children:`Restablecimiento de fábrica`}),(0,o.jsx)(`p`,{children:`Elimina toda la configuración y obligará a volver a emparejar.`})]}),(0,o.jsx)(`button`,{className:`button button-danger`,id:`factory-reset-button`,type:`button`,onClick:async()=>{if(confirm(`¿Restablecer todos los accesorios Matter de este add-on? Se borrarán sus vínculos con los controladores y tendrás que volver a emparejarlos.`))try{n((await r.factoryReset()).message||`Matter restablecido.`),t()}catch(e){n(e.message||`Error al restablecer`,!0)}},children:`Restablecer`})]})]})]}),(0,o.jsx)(`div`,{className:`settings-right-col`,children:(0,o.jsxs)(`div`,{className:`glass-terminal-wrapper`,children:[(0,o.jsxs)(`div`,{className:`terminal-header`,children:[(0,o.jsxs)(`div`,{className:`terminal-header-title`,children:[(0,o.jsx)(`span`,{className:`terminal-dot red`}),(0,o.jsx)(`span`,{className:`terminal-dot yellow`}),(0,o.jsx)(`span`,{className:`terminal-dot green`}),(0,o.jsx)(`span`,{className:`terminal-title-text`,children:`REGISTROS DEL SISTEMA (CONSOLE LOGS)`})]}),(0,o.jsxs)(`div`,{className:`terminal-header-actions`,children:[(0,o.jsxs)(`label`,{className:`terminal-search-box`,children:[(0,o.jsx)(`span`,{children:`⌕`}),(0,o.jsx)(`input`,{type:`search`,placeholder:`Buscar en logs...`,value:j,onChange:e=>M(e.target.value)}),j&&(0,o.jsx)(`button`,{type:`button`,onClick:()=>M(``),className:`search-clear-btn`,title:`Borrar búsqueda`,children:`×`})]}),(0,o.jsx)(`button`,{className:`terminal-action-btn ${N?`active`:``}`,type:`button`,onClick:()=>P(!N),title:N?`Auto-scroll activado`:`Auto-scroll pausado`,children:N?`⬇ Auto-scroll`:`⏸ Pausado`}),(0,o.jsxs)(`button`,{className:`terminal-action-btn`,type:`button`,onClick:I,disabled:D,title:`Recargar registros`,children:[(0,o.jsx)(`span`,{className:D?`spin`:``,children:`↻`}),D?`Cargando…`:`Actualizar`]}),(0,o.jsx)(`button`,{className:`terminal-action-btn`,type:`button`,onClick:async()=>{try{let e=R.join(`
2
+ `);if(!e){n(`No hay registros para copiar`,!0);return}await i(e)?n(`✓ ${R.length} líneas copiadas al portapapeles`):n(`⚠️ No se pudo acceder al portapapeles`,!0)}catch(e){n(e.message||`Error al copiar logs`,!0)}},title:`Copiar registros visibles al portapapeles`,children:`📋 Copiar`}),(0,o.jsx)(`button`,{className:`terminal-action-btn btn-danger-subtle`,type:`button`,onClick:async()=>{if(confirm(`¿Deseas vaciar el historial de registros del Add-on?`))try{await r.clearLogs(),E([]),n(`✓ Registros del sistema vaciados`)}catch(e){n(e.message||`Error al vaciar logs`,!0)}},title:`Vaciar historial de logs del Add-on`,children:`🗑️ Limpiar`})]})]}),(0,o.jsxs)(`div`,{className:`terminal-filters-row`,children:[(0,o.jsxs)(`button`,{type:`button`,className:`filter-tab-pill ${k===`all`?`active`:``}`,onClick:()=>A(`all`),children:[`Todos `,(0,o.jsx)(`span`,{className:`pill-count`,children:L.all})]}),(0,o.jsxs)(`button`,{type:`button`,className:`filter-tab-pill pill-error ${k===`error`?`active`:``}`,onClick:()=>A(`error`),children:[`❌ Errores `,(0,o.jsx)(`span`,{className:`pill-count`,children:L.errors})]}),(0,o.jsxs)(`button`,{type:`button`,className:`filter-tab-pill pill-warn ${k===`warn`?`active`:``}`,onClick:()=>A(`warn`),children:[`⚠️ Advertencias `,(0,o.jsx)(`span`,{className:`pill-count`,children:L.warns})]}),(0,o.jsxs)(`button`,{type:`button`,className:`filter-tab-pill pill-info ${k===`info`?`active`:``}`,onClick:()=>A(`info`),children:[`ℹ️ Info / Eventos `,(0,o.jsx)(`span`,{className:`pill-count`,children:L.infos})]}),(0,o.jsxs)(`span`,{className:`terminal-status-counter`,children:[`Mostrando: `,(0,o.jsx)(`strong`,{children:R.length}),` de `,T.length]})]}),(0,o.jsx)(`div`,{className:`glass-terminal-body`,ref:F,children:R.length===0?(0,o.jsx)(`div`,{className:`terminal-empty-state`,children:D?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{className:`spinner`}),(0,o.jsx)(`p`,{children:`Cargando registros del sistema…`})]}):(0,o.jsx)(`p`,{children:j?`No se encontraron registros que coincidan con "${j}".`:`No hay registros disponibles para este filtro.`})}):(0,o.jsx)(`div`,{className:`terminal-lines-list`,children:R.map((e,t)=>{let n=s(e);return(0,o.jsxs)(`div`,{className:`terminal-line line-${n}`,children:[(0,o.jsx)(`span`,{className:`line-num`,children:t+1}),(0,o.jsx)(`span`,{className:`line-content`,children:e})]},t)})})})]})})]})]})}):null};export{c as SettingsModal};
@@ -0,0 +1 @@
1
+ async function e(e){if(navigator?.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`-9999px`,t.style.left=`-9999px`,t.style.opacity=`0`,document.body.appendChild(t),t.focus(),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch(e){return console.warn(`Failed to copy to clipboard:`,e),!1}}export{e as t};