mqtt2matter 0.3.0 → 0.3.1

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 (51) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/model/presets.d.ts +14 -1
  3. package/dist/model/presets.js +95 -17
  4. package/dist/model/presets.js.map +1 -1
  5. package/dist/server/server.js +12 -0
  6. package/dist/server/server.js.map +1 -1
  7. package/docs/api.md +2 -1
  8. package/docs/config.md +14 -5
  9. package/package.json +1 -1
  10. package/presets/mqtt-smarthome/button.json +1 -1
  11. package/presets/mqtt-smarthome/contact.json +1 -1
  12. package/presets/mqtt-smarthome/cover.json +1 -1
  13. package/presets/mqtt-smarthome/dimmer.json +1 -1
  14. package/presets/mqtt-smarthome/humidity.json +1 -1
  15. package/presets/mqtt-smarthome/light.json +1 -1
  16. package/presets/mqtt-smarthome/occupancy.json +1 -1
  17. package/presets/mqtt-smarthome/switch.json +1 -1
  18. package/presets/mqtt-smarthome/temperature.json +1 -1
  19. package/presets/openbeken/color-light.json +1 -1
  20. package/presets/openbeken/ct-light.json +1 -1
  21. package/presets/openbeken/dimmer.json +1 -1
  22. package/presets/openbeken/humidity.json +1 -1
  23. package/presets/openbeken/relay.json +1 -1
  24. package/presets/openbeken/temperature.json +1 -1
  25. package/presets/shelly-gen1/dimmer.json +1 -1
  26. package/presets/shelly-gen1/door-window.json +1 -1
  27. package/presets/shelly-gen1/ht.json +1 -1
  28. package/presets/shelly-gen1/relay-pm.json +1 -1
  29. package/presets/shelly-gen1/relay.json +1 -1
  30. package/presets/shelly-gen1/roller.json +1 -1
  31. package/presets/shelly-gen2/cover.json +1 -1
  32. package/presets/shelly-gen2/dimmer.json +1 -1
  33. package/presets/shelly-gen2/ht.json +1 -1
  34. package/presets/shelly-gen2/i4.json +1 -1
  35. package/presets/shelly-gen2/switch-pm.json +1 -1
  36. package/presets/shelly-gen2/switch.json +1 -1
  37. package/presets/tasmota/climate.json +1 -1
  38. package/presets/tasmota/color-light.json +1 -1
  39. package/presets/tasmota/ct-light.json +1 -1
  40. package/presets/tasmota/dimmer.json +1 -1
  41. package/presets/tasmota/relay.json +1 -1
  42. package/presets/tasmota/shutter.json +1 -1
  43. package/presets/tasmota/temperature-humidity.json +1 -1
  44. package/presets/tasmota/temperature.json +1 -1
  45. package/presets/valetudo/vacuum.json +1 -1
  46. package/presets/wled/dimmer.json +1 -1
  47. package/presets/wled/light.json +1 -1
  48. package/ui/dist/assets/index-CoG5Wu5Q.js +10 -0
  49. package/ui/dist/index.html +1 -1
  50. package/ui/dist/licenses.json +1 -1
  51. package/ui/dist/assets/index-tiKYDC-5.js +0 -10
@@ -0,0 +1,10 @@
1
+ (function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))a(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&a(s)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function a(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();const fl=!1;var vi=Array.isArray,Au=Array.prototype.indexOf,si=Array.prototype.includes,Di=Array.from,pl=Object.defineProperty,Na=Object.getOwnPropertyDescriptor,hl=Object.getOwnPropertyDescriptors,ml=Object.prototype,Pu=Array.prototype,Li=Object.getPrototypeOf,is=Object.isExtensible;const Nu=()=>{};function Mu(e){return e()}function So(e){for(var r=0;r<e.length;r++)e[r]()}function _l(){var e,r,n=new Promise((a,i)=>{e=a,r=i});return{promise:n,resolve:e,reject:r}}function Ci(e,r){if(Array.isArray(e))return e;if(!(Symbol.iterator in e))return Array.from(e);const n=[];for(const a of e)if(n.push(a),n.length===r)break;return n}const Tr=2,Oa=4,fi=8,gl=1<<24,xn=16,Cn=32,oa=64,Co=128,Ho=256,Sn=512,sr=1024,tr=2048,fn=4096,Nr=8192,br=16384,za=32768,li=1<<25,ya=65536,Ai=1<<17,Ru=1<<18,Ha=1<<19,bl=1<<20,Ln=1<<25,Pi=1<<21,Ma=1<<22,ia=1<<23,Wn=Symbol("$state"),yl=Symbol("component"),Iu=Symbol("legacy props"),Ou=Symbol(""),wl=Symbol("attributes"),Ao=Symbol("class"),Po=Symbol("style"),No=Symbol("text"),Ei=Symbol("form reset"),pi=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"},Du=!!globalThis.document?.contentType&&globalThis.document.contentType.includes("xml"),Lu=1,Bu=2,kl=4,qu=8,Uu=16,Fu=1,ju=2,zu=4,Hu=8,$u=16,xl=1,Gu=2,El={},ir=Symbol("uninitialized"),Vu="http://www.w3.org/1999/xhtml";function Ku(){console.warn("https://svelte.dev/e/derived_inert")}function Ju(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function Wu(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function Tl(e){return e===this.v}function Qu(e,r){return e!=e?r==r:e!==r||e!==null&&typeof e=="object"||typeof e=="function"}function Sl(e){return!Qu(e,this.v)}function Cl(e){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function Yu(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function Zu(e,r,n){throw new Error("https://svelte.dev/e/each_key_duplicate")}function Xu(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function ed(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function td(e){throw new Error("https://svelte.dev/e/effect_orphan")}function rd(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function nd(e){throw new Error("https://svelte.dev/e/props_invalid_value")}function ad(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function id(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function od(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function sd(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}let $a=!1,ld=!1;function ud(){$a=!0}const dd=[];function Xa(e,r=!1,n=!1){return Ti(e,new Map,"",dd,null,n)}function Ti(e,r,n,a,i=null,o=!1){if(typeof e=="object"&&e!==null){var s=r.get(e);if(s!==void 0)return s;if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);if(vi(e)){var u=Array(e.length);r.set(e,u),i!==null&&r.set(i,u);for(var v=0;v<e.length;v+=1){var m=e[v];v in e&&(u[v]=Ti(m,r,n,a,null,o))}return u}if(Li(e)===ml){u={},r.set(e,u),i!==null&&r.set(i,u);for(var k of Object.keys(e))u[k]=Ti(e[k],r,n,a,null,o);return u}if(e instanceof Date)return e.getTime(),structuredClone(e);if(typeof e.toJSON=="function"&&!o)return Ti(e.toJSON(),r,n,a,e)}if(e instanceof EventTarget)return e;try{return structuredClone(e)}catch{return e}}let Ft=null;function Da(e){Ft=e}function jt(e,r=!1,n){Ft={p:Ft,i:!1,c:null,e:null,s:e,x:null,r:Tt,l:$a&&!r?{s:null,u:null,$:[]}:null}}function zt(e){var r=Ft,n=r.e;if(n!==null){r.e=null;for(var a of n)$l(a)}return r.i=!0,Ft=r.p,$o(e)}function $o(e={}){return pl(e,yl,{value:!0}),e}function hi(){return!$a||Ft!==null&&Ft.l===null}let pa=[];function Al(){var e=pa;pa=[],So(e)}function Bn(e){if(pa.length===0&&!ni){var r=pa;queueMicrotask(()=>{r===pa&&Al()})}pa.push(e)}function cd(){for(;pa.length>0;)Al()}const vd=-7169;function Zt(e,r){e.f=e.f&vd|r}function Go(e){(e.f&Sn)!==0||e.deps===null?Zt(e,sr):Zt(e,fn)}function Pl(e,r,n){(e.f&tr)!==0?r.add(e):(e.f&fn)!==0&&n.add(e),Zt(e,sr)}function fd(e,r){{const n=document.body;e.autofocus=!0,Bn(()=>{document.activeElement===n&&e.focus()})}}let os=!1;function pd(){os||(os=!0,document.addEventListener("reset",e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(const r of e.target.elements)r[Ei]?.()})},{capture:!0}))}function Ga(e){var r=Et,n=Tt;pn(null),Fn(null);try{return e()}finally{pn(r),Fn(n)}}function Vo(e,r,n,a=n){e.addEventListener(r,()=>Ga(n));const i=e[Ei];i?e[Ei]=()=>{i(),a(!0)}:e[Ei]=()=>a(!0),pd()}function hd(e,r,n,a){const i=hi()?La:Ko;var o=e.filter(_=>!_.settled),s=r.map(i);if(n.length===0&&o.length===0){a(s);return}var u=Tt,v=md(),m=o.length===1?o[0].promise:o.length>1?Promise.all(o.map(_=>_.promise)):null;function k(_){if((u.f&br)===0){v();try{a([...s,..._])}catch(x){Dn(x,u)}Ni()}}var y=Nl();if(n.length===0){m.then(()=>k([])).finally(y);return}function b(){Promise.all(n.map(_=>_d(_))).then(k).catch(_=>Dn(_,u)).finally(y)}m?m.then(()=>{if((u.f&br)!==0){y();return}v(),b(),Ni()}):b()}function md(){var e=Tt,r=Et,n=Ft,a=st;return function(o=!0){Fn(e),pn(r),Da(n),o&&(e.f&br)===0&&(a?.activate(),a?.apply())}}function Ni(e=!0){Fn(null),pn(null),Da(null),e&&st?.deactivate()}function Nl(){var e=Tt,r=e.b,n=st,a=!!r?.is_rendered();return r?.update_pending_count(1,n),n.increment(a,e),()=>{r?.update_pending_count(-1,n),n.decrement(a,e)}}function La(e){var r=Tr|tr;return Tt!==null&&(Tt.f|=Ha),{ctx:Ft,deps:null,effects:null,equals:Tl,f:r,fn:e,reactions:null,rv:0,v:ir,wv:0,parent:Tt,ac:null}}const ei=Symbol("obsolete");function _d(e,r,n){let a=Tt;a===null&&Yu();var i=void 0,o=wa(ir),s=!Et,u=new Set;return Rd(()=>{var v=Tt,m=_l();i=m.promise;try{Promise.resolve(e()).then(m.resolve,_=>{_!==pi&&m.reject(_)}).finally(Ni)}catch(_){m.reject(_),Ni()}var k=st;if(s){if((v.f&za)!==0)var y=Nl();if(a.b?.is_rendered())k.async_deriveds.get(v)?.reject(ei);else for(const _ of u.values())_.reject(ei);u.add(m),k.async_deriveds.set(v,m)}const b=(_,x=void 0)=>{y?.(),u.delete(m),x!==ei&&(k.activate(),x?(o.f|=ia,Ba(o,x)):((o.f&ia)!==0&&(o.f^=ia),Ba(o,_)),k.deactivate())};m.promise.then(b,_=>b(null,_||"unknown"))}),Zo(()=>{for(const v of u)v.reject(ei)}),new Promise(v=>{function m(k){function y(){k===i?v(o):m(i)}k.then(y,y)}m(i)})}function ne(e){const r=La(e);return Ql(r),r}function Ko(e){const r=La(e);return r.equals=Sl,r}function gd(e){var r=e.effects;if(r!==null){e.effects=null;for(var n=0;n<r.length;n+=1)Lr(r[n])}}function Jo(e){var r,n=Tt,a=e.parent;if(!Yn&&a!==null&&e.v!==ir&&(a.f&(br|Nr))!==0)return Ku(),e.v;Fn(a);try{gd(e),r=eu(e)}finally{Fn(n)}return r}function Ml(e){var r=Jo(e);if(!e.equals(r)&&(e.wv=Zl(),(!st?.is_fork||e.deps===null)&&(st!==null?(st.capture(e,r,!0),Ra?.capture(e,r,!0)):e.v=r,e.deps===null))){Zt(e,sr);return}Yn||(En!==null?(Yo()||st?.is_fork)&&En.set(e,r):Go(e))}function bd(e){if(e.effects!==null)for(const r of e.effects)(r.teardown||r.ac)&&(r.teardown?.(),r.ac!==null&&Ga(()=>{r.ac.abort(pi),r.ac=null}),r.fn!==null&&(r.teardown=Nu),ui(r,0),Xo(r))}function Rl(e){if(e.effects!==null)for(const r of e.effects)r.teardown&&r.fn!==null&&qa(r)}let $i=null,Ca=null,st=null,Ra=null,En=null,Mo=null,ni=!1,Gi=!1,ai=null,Si=null;var ss=0;let yd=1;class sa{id=yd++;#e=!1;linked=!0;#r=null;#t=null;async_deriveds=new Map;current=new Map;previous=new Map;#l=new Set;#a=new Set;#o=0;#n=new Map;#s=null;#i=[];#m=[];#u=new Set;#d=new Set;#v=new Map;#_=new Set;is_fork=!1;#c=!1;constructor(){Ca===null?$i=Ca=this:(Ca.#t=this,this.#r=Ca),Ca=this}#w(){if(this.is_fork)return!0;for(const a of this.#n.keys()){for(var r=a,n=!1;r.parent!==null;){if(this.#v.has(r)){n=!0;break}r=r.parent}if(!n)return!0}return!1}skip_effect(r){this.#v.has(r)||this.#v.set(r,{d:[],m:[]}),this.#_.delete(r)}unskip_effect(r,n=a=>this.schedule(a)){var a=this.#v.get(r);if(a){this.#v.delete(r);for(var i of a.d)Zt(i,tr),n(i);for(i of a.m)Zt(i,fn),n(i)}this.#_.add(r)}#k(){var r=[];for(const o of this.#i)if(!((o.f&br)!==0||(o.f&(tr|fn))===0)){for(var n=o,a=!1;n.parent!==null;){n=n.parent;var i=n.f;if((i&(oa|Cn))!==0){if((i&sr)===0){a=!0;break}n.f^=sr}}a||r.push(n)}return this.#i=[],r}#g(){this.#e=!0;for(const u of this.#u)this.#d.delete(u),Zt(u,tr),this.schedule(u);for(const u of this.#d)Zt(u,fn),this.schedule(u);this.apply();for(var r=ai=[],n=[],a=Si=[];this.#i.length>0;){ss++>1e3&&(this.#h(),kd());for(const u of this.#k())try{this.#b(u,r,n)}catch(v){throw Dl(u),this.#w()||this.discard(),v}}if(st=null,a.length>0){var i=sa.ensure();for(const u of a)i.schedule(u)}if(ai=null,Si=null,this.#w()){this.#p(n),this.#p(r);for(const[u,v]of this.#v)Ol(u,v);a.length>0&&st.#g();return}const o=this.#f();if(o){this.#p(n),this.#p(r),o.#x(this);return}this.#u.clear(),this.#d.clear();for(const u of this.#l)u(this);this.#l.clear(),Ra=this,ls(n),ls(r),Ra=null,this.#s?.resolve();var s=st;if(this.#o===0&&(this.#i.length===0||s!==null)&&this.#h(),this.#i.length>0)if(s!==null){for(const u of this.#i)s.#i.push(u);this.#i=[]}else s=this;s!==null&&(qn.clear(),s.#g())}#b(r,n,a){r.f^=sr;for(var i=r.first;i!==null;){var o=i.f,s=(o&(Cn|oa))!==0,u=s&&(o&sr)!==0,v=u||(o&Nr)!==0||this.#v.has(i);if(!v&&i.fn!==null){s?i.f^=sr:(o&Oa)!==0?n.push(i):_i(i)&&((o&xn)!==0&&this.#d.add(i),qa(i));var m=i.first;if(m!==null){i=m;continue}}for(;i!==null;){var k=i.next;if(k!==null){i=k;break}i=i.parent}}}#f(){for(var r=this.#r;r!==null;){if(!r.is_fork){for(const[n,[,a]]of this.current)if(r.current.has(n)&&!a)return r}r=r.#r}return null}#x(r){for(const[a,i]of r.current)!this.previous.has(a)&&r.previous.has(a)&&this.previous.set(a,r.previous.get(a)),this.current.set(a,i);for(const[a,i]of r.async_deriveds){const o=this.async_deriveds.get(a);o&&i.promise.then(o.resolve).catch(o.reject)}r.async_deriveds.clear(),this.transfer_effects(r.#u,r.#d);const n=a=>{var i=a.reactions;if(i!==null&&!((a.f&Tr)!==0&&(a.f&(tr|fn))===0))for(const u of i){var o=u.f;if((o&Tr)!==0)n(u);else{var s=u;o&(Ma|xn)&&!this.async_deriveds.has(s)&&(this.#d.delete(s),Zt(s,tr),this.schedule(s))}}};for(const a of this.current.keys())n(a);this.oncommit(()=>r.discard()),r.#h(),st=this,this.#g()}#p(r){for(var n=0;n<r.length;n+=1)Pl(r[n],this.#u,this.#d)}capture(r,n,a=!1){r.v!==ir&&!this.previous.has(r)&&this.previous.set(r,r.v),(r.f&ia)===0&&(this.current.set(r,[n,a]),En?.set(r,n)),this.is_fork||(r.v=n)}activate(){st=this}deactivate(){st=null,En=null}flush(){try{Gi=!0,st=this,this.#g()}finally{ss=0,Mo=null,ai=null,Si=null,Gi=!1,st=null,En=null,qn.clear()}}discard(){for(const r of this.#a)r(this);this.#a.clear();for(const r of this.async_deriveds.values())r.reject(ei);this.#h(),this.#s?.resolve()}register_created_effect(r){this.#m.push(r)}#y(){for(let y=$i;y!==null;y=y.#t){var r=y.id<this.id,n=[];for(const[b,[_,x]]of this.current){if(y.current.has(b)){var a=y.current.get(b)[0];if(r&&_!==a)y.current.set(b,[_,x]);else continue}n.push(b)}if(r)for(const[b,_]of this.async_deriveds){const x=y.async_deriveds.get(b);x&&_.promise.then(x.resolve).catch(x.reject)}var i=[...y.current.keys()].filter(b=>!y.current.get(b)[1]);if(!(!y.#e||i.length===0)){var o=i.filter(b=>!this.current.has(b));if(o.length===0)r&&y.discard();else if(n.length>0){if(r)for(const b of this.#_)y.unskip_effect(b,_=>{(_.f&(xn|Ma))!==0?y.schedule(_):y.#p([_])});y.activate();var s=new Set,u=new Map;for(var v of n)Il(v,o,s,u);u=new Map;var m=[...y.current].filter(([b,_])=>{const x=this.current.get(b);return x?x[0]!==_[0]||x[1]!==_[1]:!0}).map(([b])=>b);if(m.length>0)for(const b of this.#m)(b.f&(br|Nr|Ai))===0&&Wo(b,m,u)&&((b.f&(Ma|xn))!==0?(Zt(b,tr),y.schedule(b)):y.#u.add(b));if(y.#i.length>0&&!y.#c){y.apply();for(var k of y.#k())y.#b(k,[],[])}y.deactivate()}}}}increment(r,n){if(this.#o+=1,r){let a=this.#n.get(n)??0;this.#n.set(n,a+1)}}decrement(r,n){if(this.#o-=1,r){let a=this.#n.get(n)??0;a===1?this.#n.delete(n):this.#n.set(n,a-1)}this.#c||(this.#c=!0,Bn(()=>{this.#c=!1,this.linked&&this.flush()}))}transfer_effects(r,n){for(const a of r)this.#u.add(a);for(const a of n)this.#d.add(a);r.clear(),n.clear()}oncommit(r){this.#l.add(r)}ondiscard(r){this.#a.add(r)}settled(){return(this.#s??=_l()).promise}static ensure(){if(st===null){const r=st=new sa;!Gi&&!ni&&Bn(()=>{r.#e||r.flush()})}return st}apply(){{En=null;return}}schedule(r){if(Mo=r,r.b?.is_pending&&(r.f&(Oa|fi|gl))!==0&&(r.f&za)===0){r.b.defer_effect(r);return}this.#i.push(r)}#h(){if(this.linked){var r=this.#r,n=this.#t;r===null?$i=n:r.#t=n,n===null?Ca=r:n.#r=r,this.linked=!1}}}function wd(e){var r=ni,n=Ra;Ra=null,ni=!0;try{for(var a;;){if(cd(),st===null)return a;st.flush()}}finally{ni=r,Ra=n}}function kd(){try{rd()}catch(e){Dn(e,Mo)}}let Kn=null;function ls(e){var r=e.length;if(r!==0){for(var n=0;n<r;){var a=e[n++];if((a.f&(br|Nr))===0&&_i(a)&&(Kn=new Set,qa(a),a.deps===null&&a.first===null&&a.nodes===null&&a.teardown===null&&a.ac===null&&Kl(a),Kn?.size>0)){qn.clear();for(const i of Kn){if((i.f&(br|Nr))!==0)continue;const o=[i];let s=i.parent;for(;s!==null;)Kn.has(s)&&(Kn.delete(s),o.push(s)),s=s.parent;for(let u=o.length-1;u>=0;u--){const v=o[u];(v.f&(br|Nr))===0&&qa(v)}}Kn.clear()}}Kn=null}}function Il(e,r,n,a){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(const i of e.reactions){const o=i.f;(o&Tr)!==0?Il(i,r,n,a):(o&(Ma|xn))!==0&&(o&tr)===0&&Wo(i,r,a)&&(Zt(i,tr),Qo(i))}}function Wo(e,r,n){const a=n.get(e);if(a!==void 0)return a;if(e.deps!==null)for(const i of e.deps){if(si.call(r,i))return!0;if((i.f&Tr)!==0&&Wo(i,r,n))return n.set(i,!0),!0}return n.set(e,!1),!1}function Qo(e){st.schedule(e)}function Ol(e,r){if(!((e.f&Cn)!==0&&(e.f&sr)!==0)){(e.f&tr)!==0?r.d.push(e):(e.f&fn)!==0&&r.m.push(e),Zt(e,sr);for(var n=e.first;n!==null;)Ol(n,r),n=n.next}}function Dl(e){Zt(e,sr);for(var r=e.first;r!==null;)Dl(r),r=r.next}let Mi=new Set;const qn=new Map;let Ll=!1;function wa(e,r){var n={f:0,v:e,reactions:null,equals:Tl,rv:0,wv:0};return n}function z(e,r){const n=wa(e);return Ql(n),n}function xd(e,r=!1,n=!0){const a=wa(e);return r||(a.equals=Sl),$a&&n&&Ft!==null&&Ft.l!==null&&(Ft.l.s??=[]).push(a),a}function w(e,r,n=!1){Et!==null&&(!Tn||(Et.f&Ai)!==0)&&hi()&&(Et.f&(Tr|xn|Ma|Ai))!==0&&(Un===null||!Un.has(e))&&od();let a=n?Lt(r):r;return Ba(e,a,Si)}var fa=null,Ro=0;function Ba(e,r,n=null){if(!e.equals(r)){Yn?qn.set(e,r):qn.has(e)||qn.set(e,e.v);var a=sa.ensure();if(a.capture(e,r),(e.f&Tr)!==0){const i=e;(e.f&tr)!==0&&Jo(i),En===null&&Go(i)}e.wv=Zl(),fa=null,Ro=0,Bl(e,tr,n),fa=null,hi()&&Tt!==null&&(Tt.f&sr)!==0&&(Tt.f&(Cn|oa))===0&&(un===null?Dd([e]):un.push(e)),!a.is_fork&&Mi.size>0&&!Ll&&Ed()}return r}function Ed(){Ll=!1;for(const e of Mi){(e.f&sr)!==0&&Zt(e,fn);let r;try{r=_i(e)}catch{r=!0}r&&qa(e)}Mi.clear()}function ii(e){w(e,e.v+1)}function Bl(e,r,n){var a=e.reactions;if(a!==null){var i=hi(),o=a.length;if(Ro+=o,Ro>1e5&&fa===null&&(fa=new Set),fa!==null){if(fa.has(e))return;fa.add(e)}for(var s=0;s<o;s++){var u=a[s],v=u.f;if(!(!i&&u===Tt)){var m=(v&tr)===0;if(m&&Zt(u,r),(v&Ai)!==0)Mi.add(u);else if((v&Tr)!==0){var k=u;En?.delete(k),Bl(k,fn,n)}else if(m){var y=u;(v&xn)!==0&&Kn!==null&&Kn.add(y),n!==null?n.push(y):Qo(y)}}}}}function Lt(e){if(typeof e!="object"||e===null||Wn in e||yl in e)return e;const r=Li(e);if(r!==ml&&r!==Pu)return e;var n=new Map,a=vi(e),i=z(0),o=ga,s=u=>{if(ga===o)return u();var v=Et,m=ga;pn(null),vs(o);var k=u();return pn(v),vs(m),k};return a&&n.set("length",z(e.length)),new Proxy(e,{defineProperty(u,v,m){(!("value"in m)||m.configurable===!1||m.enumerable===!1||m.writable===!1)&&ad();var k=n.get(v);return k===void 0?s(()=>{var y=z(m.value);return n.set(v,y),y}):w(k,m.value,!0),!0},deleteProperty(u,v){var m=n.get(v);if(m===void 0){if(v in u){const k=s(()=>z(ir));n.set(v,k),ii(i)}}else w(m,ir),ii(i);return!0},get(u,v,m){if(v===Wn)return e;var k=n.get(v),y=v in u;if(k===void 0&&(!y||Na(u,v)?.writable)&&(k=s(()=>{var _=Lt(y?u[v]:ir),x=z(_);return x}),n.set(v,k)),k!==void 0){var b=t(k);return b===ir?void 0:b}return Reflect.get(u,v,m)},getOwnPropertyDescriptor(u,v){this.has?.(u,v);var m=Reflect.getOwnPropertyDescriptor(u,v),k=n.get(v);if(k!==void 0){var y=t(k);if(y===ir)return;if(m&&"value"in m)m.value=y;else return{enumerable:!0,configurable:!0,value:y,writable:!0}}return m},has(u,v){if(v===Wn)return!0;var m=n.get(v),k=m!==void 0&&m.v!==ir||Reflect.has(u,v);if(m!==void 0||Tt!==null&&(!k||Na(u,v)?.writable)){m===void 0&&(m=s(()=>{var b=k?Lt(u[v]):ir,_=z(b);return _}),n.set(v,m));var y=t(m);if(y===ir)return!1}return k},set(u,v,m,k){var y=n.get(v),b=v in u;if(a&&v==="length")for(var _=m;_<y.v;_+=1){var x=n.get(_+"");x!==void 0?w(x,ir):_ in u&&(x=s(()=>z(ir)),n.set(_+"",x))}if(y===void 0)(!b||Na(u,v)?.writable)&&(y=s(()=>z(void 0)),w(y,Lt(m)),n.set(v,y));else{b=y.v!==ir;var T=s(()=>Lt(m));w(y,T)}var A=Reflect.getOwnPropertyDescriptor(u,v);if(A?.set&&A.set.call(k,m),!b){if(a&&typeof v=="string"){var C=n.get("length"),I=Number(v);Number.isInteger(I)&&I>=C.v&&w(C,I+1)}ii(i)}return!0},ownKeys(u){t(i);var v=Reflect.ownKeys(u).filter(y=>{var b=n.get(y);return b===void 0||b.v!==ir});for(var[m,k]of n)k.v!==ir&&!(m in u)&&v.push(m);return v},setPrototypeOf(){id()}})}function us(e){try{if(e!==null&&typeof e=="object"&&Wn in e)return e[Wn]}catch{}return e}function ql(e,r){return Object.is(us(e),us(r))}var ds,Io,Ul,Fl,jl;function Td(){if(ds===void 0){ds=window,Io=document,Ul=/Firefox/.test(navigator.userAgent);var e=Element.prototype,r=Node.prototype,n=Text.prototype;Fl=Na(r,"firstChild").get,jl=Na(r,"nextSibling").get,is(e)&&(e[Ao]=void 0,e[wl]=null,e[Po]=void 0,e.__e=void 0),is(n)&&(n[No]=void 0)}}function Qn(e=""){return document.createTextNode(e)}function On(e){return Fl.call(e)}function mi(e){return jl.call(e)}function h(e,r){return On(e)}function Oe(e,r=!1){{var n=On(e);return n instanceof Comment&&n.data===""?mi(n):n}}function f(e,r=!1){return On(e)}function l(e,r=1,n=!1){let a=e;for(;r--;)a=mi(a);return a}function Sd(e){e.textContent=""}function zl(){return!1}function Cd(e,r,n){return n?document.createElement(e,{is:n}):document.createElement(e)}function Ad(e){var r=Tt;if(r===null)return Et.f|=ia,e;if((r.f&za)===0&&(r.f&Oa)===0)throw e;Dn(e,r)}function Dn(e,r){if(e===El)throw e;if(!(r!==null&&(r.f&br)!==0)){for(;r!==null;){if((r.f&Co)!==0&&(r.f&(br|li))===0){if((r.f&za)===0)throw e;try{r.b.error(e);return}catch(n){e=n}}r=r.parent}throw e}}function Hl(e){Tt===null&&(Et===null&&td(),ed()),Yn&&Xu()}function Pd(e,r){var n=r.last;n===null?r.last=r.first=e:(n.next=e,e.prev=n,r.last=e)}function jn(e,r){var n=Tt;n!==null&&(n.f&Nr)!==0&&(e|=Nr);var a={ctx:Ft,deps:null,nodes:null,f:e|tr|Sn,first:null,fn:r,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};st?.register_created_effect(a);var i=a;if((e&Oa)!==0)ai!==null?ai.push(a):sa.ensure().schedule(a);else if(r!==null){try{qa(a)}catch(s){throw Lr(a),s}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&(i.f&Ha)===0&&(i=i.first,(e&xn)!==0&&(e&ya)!==0&&i!==null&&(i.f|=ya))}if(i!==null&&(i.parent=n,n!==null&&Pd(i,n),Et!==null&&(Et.f&Tr)!==0&&(e&oa)===0)){var o=Et;(o.effects??=[]).push(i)}return a}function Yo(){return Et!==null&&!Tn}function Zo(e){const r=jn(fi,null);return Zt(r,sr),r.teardown=e,r}function Br(e){Hl();var r=Tt.f,n=!Et&&(r&Cn)!==0&&Ft!==null&&!Ft.i;if(n){var a=Ft;(a.e??=[]).push(e)}else return $l(e)}function $l(e){return jn(Oa|bl,e)}function Nd(e){return Hl(),jn(fi|bl,e)}function Md(e){sa.ensure();const r=jn(oa|Ha,e);return(n={})=>new Promise(a=>{n.outro?_a(r,()=>{Lr(r),a(void 0)}):(Lr(r),a(void 0))})}function Gl(e){return jn(Oa,e)}function Rd(e){return jn(Ma|Ha,e)}function Bi(e,r=0){return jn(fi|r,e)}function E(e,r=[],n=[],a=[]){hd(a,r,n,i=>{jn(fi,()=>{e(...i.map(t))})})}function qi(e,r=0){var n=jn(xn|r,e);return n}function dn(e){return jn(Cn|Ha,e)}function Vl(e){var r=e.teardown;if(r!==null){const n=Yn,a=Et;cs(!0),pn(null);try{r.call(null)}catch(i){Dn(i,e.parent)}finally{cs(n),pn(a)}}}function Xo(e,r=!1){var n=e.first;for(e.first=e.last=null;n!==null;){const i=n.ac;i!==null&&Ga(()=>{i.abort(pi)});var a=n.next;(n.f&oa)!==0?n.parent=null:Lr(n,r),n=a}}function Id(e){for(var r=e.first;r!==null;){var n=r.next;(r.f&Cn)===0&&Lr(r),r=n}}function Lr(e,r=!0){var n=!1;(r||(e.f&Ru)!==0)&&e.nodes!==null&&e.nodes.end!==null&&(Od(e.nodes.start,e.nodes.end),n=!0),e.f|=li,Xo(e,r&&!n),ui(e,0);var a=e.nodes&&e.nodes.t;if(a!==null)for(const o of a)o.stop();Vl(e),e.f^=li,e.f|=br;var i=e.parent;i!==null&&i.first!==null&&Kl(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Od(e,r){for(;e!==null;){var n=e===r?null:mi(e);e.remove(),e=n}}function Kl(e){var r=e.parent,n=e.prev,a=e.next;n!==null&&(n.next=a),a!==null&&(a.prev=n),r!==null&&(r.first===e&&(r.first=a),r.last===e&&(r.last=n))}function _a(e,r,n=!0){var a=[];e.f|=Ho,Jl(e,a,!0);var i=()=>{n&&Lr(e),r&&r()},o=a.length;if(o>0){var s=()=>--o||i();for(var u of a)u.out(s)}else i()}function Jl(e,r,n){if((e.f&Nr)===0){e.f^=Nr;var a=e.nodes&&e.nodes.t;if(a!==null)for(const u of a)(u.is_global||n)&&r.push(u);for(var i=e.first;i!==null;){var o=i.next;if((i.f&oa)===0){var s=(i.f&ya)!==0||(i.f&Cn)!==0&&(e.f&xn)!==0;Jl(i,r,s?n:!1)}i=o}}}function Ri(e){e.f&=~Ho,Wl(e,!0)}function Wl(e,r){if((e.f&Ho)===0&&(e.f&Nr)!==0){e.f^=Nr,(e.f&sr)===0&&(Zt(e,tr),sa.ensure().schedule(e));for(var n=e.first;n!==null;){var a=n.next,i=(n.f&ya)!==0||(n.f&Cn)!==0;Wl(n,i?r:!1),n=a}var o=e.nodes&&e.nodes.t;if(o!==null)for(const s of o)(s.is_global||r)&&s.in()}}function es(e,r){if(e.nodes)for(var n=e.nodes.start,a=e.nodes.end;n!==null;){var i=n===a?null:mi(n);r.append(n),n=i}}let Yn=!1;function cs(e){Yn=e}let Et=null,Tn=!1;function pn(e){Et=e}let Tt=null;function Fn(e){Tt=e}let Un=null;function Ql(e){Et!==null&&((Et.f&Pi)!==0||(Et.f&Tr)!==0)&&(Un??=new Set).add(e)}let Dr=null,Yr=0,un=null;function Dd(e){un=e}let Yl=1,ha=0,ga=ha;function vs(e){ga=e}function Zl(){return++Yl}function _i(e){var r=e.f;if((r&tr)!==0)return!0;if((r&fn)!==0){for(var n=e.deps,a=n.length,i=0;i<a;i++){var o=n[i];if(_i(o)&&Ml(o),o.wv>e.wv)return!0}(r&Sn)!==0&&En===null&&Zt(e,sr)}return!1}function Xl(e,r,n=!0){var a=e.reactions;if(a!==null&&!(Un!==null&&Un.has(e)))for(var i=0;i<a.length;i++){var o=a[i];(o.f&Tr)!==0?Xl(o,r,!1):r===o&&(n?Zt(o,tr):(o.f&sr)!==0&&Zt(o,fn),Qo(o))}}function eu(e){var r=Dr,n=Yr,a=un,i=Et,o=Un,s=Ft,u=Tn,v=ga,m=e.f;Dr=null,Yr=0,un=null,Et=(m&(Cn|oa))===0?e:null,Un=null,Da(e.ctx),Tn=!1,ga=++ha,e.ac!==null&&(Ga(()=>{e.ac.abort(pi)}),e.ac=null);try{e.f|=Pi;var k=e.fn,y=k();e.f|=za;var b=fs(e);if(hi()&&un!==null&&!Tn&&b!==null&&(e.f&(Tr|fn|tr))===0)for(var _=0;_<un.length;_++)Xl(un[_],e);if(i!==null&&i!==e){if(ha++,i.deps!==null)for(let x=0;x<n;x+=1)i.deps[x].rv=ha;if(r!==null)for(const x of r)x.rv=ha;un!==null&&(a===null?a=un:a.push(...un))}return(e.f&ia)!==0&&(e.f^=ia),y}catch(x){return fs(e),Ad(x)}finally{e.f^=Pi,Dr=r,Yr=n,un=a,Et=i,Un=o,Da(s),Tn=u,ga=v}}function fs(e){var r=e.deps,n=st?.is_fork;if(Dr!==null){var a;if(n||ui(e,Yr),r!==null&&Yr>0)for(r.length=Yr+Dr.length,a=0;a<Dr.length;a++)r[Yr+a]=Dr[a];else e.deps=r=Dr;if(Yo()&&(e.f&Sn)!==0)for(a=Yr;a<r.length;a++)(r[a].reactions??=[]).push(e)}else!n&&r!==null&&Yr<r.length&&(ui(e,Yr),r.length=Yr);return r}function Ld(e,r){let n=r.reactions;if(n!==null){var a=Au.call(n,e);if(a!==-1){var i=n.length-1;i===0?n=r.reactions=null:(n[a]=n[i],n.pop())}}if(n===null&&(r.f&Tr)!==0&&(Dr===null||!si.call(Dr,r))){var o=r;(o.f&Sn)!==0&&(o.f^=Sn),o.v!==ir&&Go(o),o.ac!==null&&Ga(()=>{o.ac.abort(pi),o.ac=null,Zt(o,tr)}),bd(o),ui(o,0)}}function ui(e,r){var n=e.deps;if(n!==null)for(var a=r;a<n.length;a++)Ld(e,n[a])}function qa(e){var r=e.f;if((r&br)===0){Zt(e,sr);var n=Tt;Tt=e;try{(r&(xn|gl))!==0?Id(e):Xo(e),Vl(e);var a=eu(e);e.teardown=typeof a=="function"?a:null,e.wv=Yl;var i;fl&&ld&&(e.f&tr)!==0&&e.deps}finally{Tt=n}}}async function tu(){await Promise.resolve(),wd()}function t(e){var r=e.f,n=(r&Tr)!==0;if(Et!==null&&!Tn){var a=Tt!==null&&(Tt.f&br)!==0;if(!a&&(Un===null||!Un.has(e))){var i=Et.deps;if((Et.f&Pi)!==0)e.rv<ha&&(e.rv=ha,Dr===null&&i!==null&&i[Yr]===e?Yr++:Dr===null?Dr=[e]:Dr.push(e));else{Et.deps??=[],si.call(Et.deps,e)||Et.deps.push(e);var o=e.reactions;o===null?e.reactions=[Et]:si.call(o,Et)||o.push(Et)}}}if(Yn&&qn.has(e))return qn.get(e);if(n){var s=e;if(Yn){var u=s.v;return((s.f&sr)===0&&s.reactions!==null||nu(s))&&(u=Jo(s)),qn.set(s,u),u}var v=(s.f&Sn)===0&&!Tn&&Et!==null&&(Et.f&Sn)!==0,m=(s.f&za)===0;_i(s)&&(v&&(s.f|=Sn),Ml(s)),v&&!m&&(Rl(s),ru(s))}if(En?.has(e))return En.get(e);if((e.f&ia)!==0)throw e.v;return e.v}function ru(e){if(e.f|=Sn,e.deps!==null)for(const n of e.deps){var r=n.reactions;r===null?n.reactions=[e]:si.call(r,e)||r.push(e),(n.f&Tr)!==0&&(n.f&Sn)===0&&(Rl(n),ru(n))}}function nu(e){if(e.v===ir)return!0;if(e.deps===null)return!1;for(const r of e.deps)if(qn.has(r)||(r.f&Tr)!==0&&nu(r))return!0;return!1}function la(e){var r=Tn;try{return Tn=!0,e()}finally{Tn=r}}function Bd(e){if(!(typeof e!="object"||!e||e instanceof EventTarget)){if(Wn in e)Oo(e);else if(!Array.isArray(e))for(let r in e){const n=e[r];typeof n=="object"&&n&&Wn in n&&Oo(n)}}}function Oo(e,r=new Set){if(typeof e=="object"&&e!==null&&!(e instanceof EventTarget)&&!r.has(e)){r.add(e),e instanceof Date&&e.getTime();for(let a in e)try{Oo(e[a],r)}catch{}const n=Li(e);if(n!==Object.prototype&&n!==Array.prototype&&n!==Map.prototype&&n!==Set.prototype&&n!==Date.prototype){const a=hl(n);for(let i in a){const o=a[i].get;if(o)try{o.call(e)}catch{}}}}}const qd=["touchstart","touchmove"];function Ud(e){return qd.includes(e)}const ti=Symbol("events"),au=new Set,Do=new Set;function Fd(e,r,n,a={}){function i(o){if(a.capture||Lo.call(r,o),!o.cancelBubble)return Ga(()=>n?.call(this,o))}return e.startsWith("pointer")||e.startsWith("touch")||e==="wheel"?(i.__removed=!1,Bn(()=>{i.__removed||r.addEventListener(e,i,a)})):r.addEventListener(e,i,a),i}function Ua(e,r,n,a,i){var o={capture:a,passive:i},s=Fd(e,r,n,o);(r===document.body||r===window||r===document||r instanceof HTMLMediaElement)&&Zo(()=>{s.__removed=!0,r.removeEventListener(e,s,o)})}function M(e,r,n){(r[ti]??={})[e]=n}function lr(e){for(var r=0;r<e.length;r++)au.add(e[r]);for(var n of Do)n(e)}let Vi=null,Ki=!1;function Lo(e){var r=this,n=r.ownerDocument,a=e.type,i=e.composedPath?.()||[],o=i[0]||e.target;Vi=e,Ki||(Ki=!0,setTimeout(()=>{Ki=!1,Vi=null}));var s=0,u=Vi===e&&e[ti];if(u){var v=i.indexOf(u);if(v!==-1&&(r===document||r===window)){e[ti]=r;return}var m=i.indexOf(r);if(m===-1)return;v<=m&&(s=v)}if(o=i[s]||e.target,o!==r){pl(e,"currentTarget",{configurable:!0,get(){return o||n}});var k=Et,y=Tt;pn(null),Fn(null);try{for(var b,_=[];o!==null&&o!==r;){try{var x=o[ti]?.[a];x!=null&&(!o.disabled||e.target===o)&&x.call(o,e)}catch(T){b?_.push(T):b=T}if(e.cancelBubble)break;s++,o=s<i.length?i[s]:null}if(b){for(let T of _)queueMicrotask(()=>{throw T});throw b}}finally{e[ti]=r,delete e.currentTarget,pn(k),Fn(y)}}}const jd=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:e=>e});function zd(e){return jd?.createHTML(e)??e}function iu(e){var r=Cd("template");return r.innerHTML=zd(e.replaceAll("<!>","<!---->")),r.content}function Fa(e,r){var n=Tt;n.nodes===null&&(n.nodes={start:e,end:r,a:null,t:null})}function S(e,r){var n=(r&xl)!==0,a=(r&Gu)!==0,i,o=!e.startsWith("<!>");return()=>{i===void 0&&(i=iu(o?e:"<!>"+e),n||(i=On(i)));var s=a||Ul?document.importNode(i,!0):i.cloneNode(!0);if(n){var u=On(s),v=s.lastChild;Fa(u,v)}else Fa(s,s);return s}}function Hd(e,r,n="svg"){var a=!e.startsWith("<!>"),i=(r&xl)!==0,o=`<${n}>${a?e:"<!>"+e}</${n}>`,s;return()=>{if(!s){var u=iu(o),v=On(u);if(i)for(s=document.createDocumentFragment();On(v);)s.appendChild(On(v));else s=On(v)}var m=s.cloneNode(!0);if(i){var k=On(m),y=m.lastChild;Fa(k,y)}else Fa(m,m);return m}}function ua(e,r){return Hd(e,r,"svg")}function ma(e=""){{var r=Qn(e+"");return Fa(r,r),r}}function Zn(){var e=document.createDocumentFragment(),r=document.createComment(""),n=Qn();return e.append(r,n),Fa(r,n),e}function g(e,r){e!==null&&e.before(r)}function $d(e){let r=0,n=wa(0),a;return()=>{Yo()&&(t(n),Bi(()=>(r===0&&(a=la(()=>e(()=>ii(n)))),r+=1,()=>{Bn(()=>{r-=1,r===0&&(a?.(),a=void 0,ii(n))})})))}}var Gd=ya|Ha;function Vd(e,r,n,a){new Kd(e,r,n,a)}class Kd{parent;is_pending=!1;transform_error;#e;#r=null;#t;#l;#a;#o=null;#n=null;#s=null;#i=null;#m=0;#u=0;#d=!1;#v=new Set;#_=new Set;#c=null;#w=$d(()=>(this.#c=wa(this.#m),()=>{this.#c=null}));constructor(r,n,a,i){this.#e=r,this.#t=n,this.#l=o=>{var s=Tt;s.b=this,s.f|=Co,a(o)},this.parent=Tt.b,this.transform_error=i??this.parent?.transform_error??(o=>o),this.#a=qi(()=>{this.#p()},Gd)}#k(){try{this.#o=dn(()=>this.#l(this.#e))}catch(r){this.error(r)}}#g(r){const n=this.#t.failed,{reset:a,invoke_onerror:i}=this.#b(r);Bn(i),n&&(this.#s=dn(()=>{n(this.#e,()=>r,()=>a)}))}#b(r){var n=!1,a=!1;const i=()=>{if(!this.#f()){if(n){Wu();return}n=!0,a&&sd(),this.#s!==null&&_a(this.#s,()=>{this.#s=null}),this.#h(()=>{this.#p()})}};return{reset:i,invoke_onerror:()=>{if(!this.#f())try{a=!0,this.#t.onerror?.(r,i),a=!1}catch(s){Dn(s,this.#a&&this.#a.parent)}}}}#f(){return(this.#a.f&(br|li))!==0}#x(){const r=this.#t.pending;r&&(this.is_pending=!0,this.#n=dn(()=>r(this.#e)),Bn(()=>{if(!this.#f()){var n=this.#i=document.createDocumentFragment(),a=Qn(),i=!1;if(n.append(a),this.#o=this.#h(()=>{try{return dn(()=>this.#l(a))}catch(o){try{this.error(o),i=!0}catch(s){Dn(s,this.#a.parent)}return null}}),this.#o===null){this.#i=null,i&&this.#y(st);return}this.#u===0&&(this.#e.before(n),this.#i=null,_a(this.#n,()=>{this.#n=null}),this.#y(st))}}))}#p(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#m=0,this.#o=dn(()=>{this.#l(this.#e)}),this.#u>0){var r=this.#i=document.createDocumentFragment();es(this.#o,r);const n=this.#t.pending;this.#n=dn(()=>n(this.#e))}else this.#y(st)}catch(n){this.error(n)}}#y(r){this.is_pending=!1,r.transfer_effects(this.#v,this.#_)}defer_effect(r){Pl(r,this.#v,this.#_)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#t.pending}#h(r){var n=Tt,a=Et,i=Ft;Fn(this.#a),pn(this.#a),Da(this.#a.ctx);try{return sa.ensure(),r()}finally{Fn(n),pn(a),Da(i)}}#E(r,n){if(!this.has_pending_snippet()){this.parent&&this.parent.#E(r,n);return}this.#u+=r,this.#u===0&&(this.#y(n),this.#n&&_a(this.#n,()=>{this.#n=null}),this.#i&&(this.#e.before(this.#i),this.#i=null))}update_pending_count(r,n){this.#E(r,n),this.#m+=r,!(!this.#c||this.#d)&&(this.#d=!0,Bn(()=>{this.#d=!1,this.#c&&Ba(this.#c,this.#m)}))}get_effect_pending(){return this.#w(),t(this.#c)}error(r){if(r===El||!this.#t.onerror&&!this.#t.failed)throw r;st?.is_fork?(this.#o&&st.skip_effect(this.#o),this.#n&&st.skip_effect(this.#n),this.#s&&st.skip_effect(this.#s),st.oncommit(()=>{this.#f()||this.#T(r)})):this.#T(r)}#T(r){this.#o&&(Lr(this.#o),this.#o=null),this.#n&&(Lr(this.#n),this.#n=null),this.#s&&(Lr(this.#s),this.#s=null);let n=this.#t.failed;const a=i=>{if(this.#f())return;const{reset:o,invoke_onerror:s}=this.#b(i);s(),n&&!this.#f()&&(this.#s=this.#h(()=>{try{return dn(()=>{var u=Tt;u.b=this,u.f|=Co,n(this.#e,()=>i,()=>o)})}catch(u){return Dn(u,this.#a.parent),null}}))};Bn(()=>{if(!this.#f()){var i;try{i=this.transform_error(r)}catch(o){Dn(o,this.#a&&this.#a.parent);return}i!==null&&typeof i=="object"&&typeof i.then=="function"?i.then(a,o=>Dn(o,this.#a&&this.#a.parent)):a(i)}})}}function c(e,r){var n=r==null?"":typeof r=="object"?`${r}`:r;n!==(e[No]??=e.nodeValue)&&(e[No]=n,e.nodeValue=`${n}`)}function Jd(e,r){return Wd(e,r)}const bi=new Map;function Wd(e,{target:r,anchor:n,props:a={},events:i,context:o,intro:s=!0,transformError:u}){Td();var v=void 0,m=Md(()=>{var k=n??r.appendChild(Qn());Vd(k,{pending:()=>{}},_=>{jt({});var x=Ft;o&&(x.c=o),i&&(a.$$events=i),v=e(_,a)||$o(),zt()},u);var y=new Set,b=_=>{for(var x=0;x<_.length;x++){var T=_[x];if(!y.has(T)){y.add(T);var A=Ud(T);for(const P of[r,document]){var C=bi.get(P);C===void 0&&(C=new Map,bi.set(P,C));var I=C.get(T);I===void 0?(P.addEventListener(T,Lo,{passive:A}),C.set(T,1)):C.set(T,I+1)}}}};return b(Di(au)),Do.add(b),()=>{for(var _ of y)for(const A of[r,document]){var x=bi.get(A),T=x.get(_);--T==0?(A.removeEventListener(_,Lo),x.delete(_),x.size===0&&bi.delete(A)):x.set(_,T)}Do.delete(b),k!==n&&k.parentNode?.removeChild(k)}});return Qd.set(v,m),v}let Qd=new WeakMap;class ou{anchor;#e=new Map;#r=new Map;#t=new Map;#l=new Set;#a=!0;constructor(r,n=!0){this.anchor=r,this.#a=n}#o=r=>{if(this.#e.has(r)){var n=this.#e.get(r),a=this.#r.get(n);if(a)Ri(a),this.#l.delete(n);else{var i=this.#t.get(n);i&&(Ri(i.effect),this.#r.set(n,i.effect),this.#t.delete(n),i.fragment.lastChild.remove(),this.anchor.before(i.fragment),a=i.effect)}for(const[o,s]of this.#e){if(this.#e.delete(o),o===r)break;const u=this.#t.get(s);u&&(Lr(u.effect),this.#t.delete(s))}for(const[o,s]of this.#r){if(o===n||this.#l.has(o))continue;const u=()=>{if(Array.from(this.#e.values()).includes(o)){var m=document.createDocumentFragment();es(s,m),m.append(Qn()),this.#t.set(o,{effect:s,fragment:m})}else Lr(s);this.#l.delete(o),this.#r.delete(o)};this.#a||!a?(this.#l.add(o),_a(s,u,!1)):u()}}};#n=r=>{this.#e.delete(r);const n=Array.from(this.#e.values());for(const[a,i]of this.#t)n.includes(a)||(Lr(i.effect),this.#t.delete(a))};ensure(r,n){var a=st,i=zl();if(n&&!this.#r.has(r)&&!this.#t.has(r))if(i){var o=document.createDocumentFragment(),s=Qn();o.append(s),this.#t.set(r,{effect:dn(()=>n(s)),fragment:o})}else this.#r.set(r,dn(()=>n(this.anchor)));if(this.#e.set(a,r),i){for(const[u,v]of this.#r)u===r?a.unskip_effect(v):a.skip_effect(v);for(const[u,v]of this.#t)u===r?a.unskip_effect(v.effect):a.skip_effect(v.effect);a.oncommit(this.#o),a.ondiscard(this.#n)}else this.#o(a)}}function H(e,r,n=!1){var a=new ou(e),i=n?ya:0;function o(s,u){a.ensure(s,u)}qi(()=>{var s=!1;r((u,v=0)=>{s=!0,o(v,u)}),s||o(-1,null)},i)}function ba(e,r){return r}function Yd(e,r,n){for(var a=[],i=r.length,o,s=r.length,u=0;u<i;u++){let y=r[u];_a(y,()=>{if(o){if(o.pending.delete(y),o.done.add(y),o.pending.size===0){var b=e.outrogroups;Bo(e,Di(o.done)),b.delete(o),b.size===0&&(e.outrogroups=null)}}else s-=1},!1)}if(s===0){var v=a.length===0&&n!==null&&e.pending.size===0;if(v){var m=n,k=m.parentNode;Sd(k),k.append(m),e.items.clear()}Bo(e,r,!v)}else o={pending:new Set(r),done:new Set},(e.outrogroups??=new Set).add(o)}function Bo(e,r,n=!0){var a;if(e.pending.size>0){a=new Set;for(const s of e.pending.values())for(const u of s)a.add(e.items.get(u).e)}for(var i=0;i<r.length;i++){var o=r[i];if(a?.has(o)){o.f|=Ln;const s=document.createDocumentFragment();es(o,s)}else Lr(r[i],n)}}var ps;function tt(e,r,n,a,i,o=null){var s=e,u=new Map,v=(r&kl)!==0;if(v){var m=e;s=m.appendChild(Qn())}var k=null,y=Ko(()=>{var I=n();return vi(I)?I:I==null?[]:Di(I)}),b=new Map,_=!0;function x(I){if((C.effect.f&br)===0){C.pending.delete(I);var P=t(y);C.fallback=k,Zd(C,P,s,r,a),k!==null&&(P.length===0?(k.f&Ln)===0?Ri(k):(k.f^=Ln,ri(k,null,s)):_a(k,()=>{k=null}))}}function T(I){C.pending.delete(I)}var A=qi(()=>{for(var I=t(y),P=I.length,O=new Set,ee=st,R=zl(),F=0;F<P;F+=1){var D=I[F],q=a(D,F),j=_?null:u.get(q);j?(j.v&&Ba(j.v,D),j.i&&Ba(j.i,F),R&&ee.unskip_effect(j.e)):(j=Xd(u,_?s:ps??=Qn(),D,q,F,i,r,n),_||(j.e.f|=Ln),u.set(q,j)),O.add(q)}if(P===0&&o&&!k&&(_?k=dn(()=>o(s)):(k=dn(()=>o(ps??=Qn())),k.f|=Ln)),P>O.size&&Zu(),!_)if(b.set(ee,O),R){for(const[L,J]of u)O.has(L)||ee.skip_effect(J.e);ee.oncommit(x),ee.ondiscard(T)}else x(ee);t(y)}),C={effect:A,items:u,pending:b,outrogroups:null,fallback:k};_=!1}function Qa(e){for(;e!==null&&(e.f&Cn)===0;)e=e.next;return e}function Zd(e,r,n,a,i){var o=(a&qu)!==0,s=r.length,u=e.items,v=Qa(e.effect.first),m,k=null,y,b=[],_=[],x,T,A,C;if(o)for(C=0;C<s;C+=1)x=r[C],T=i(x,C),A=u.get(T).e,(A.f&Ln)===0&&(A.nodes?.a?.measure(),(y??=new Set).add(A));for(C=0;C<s;C+=1){if(x=r[C],T=i(x,C),A=u.get(T).e,e.outrogroups!==null)for(const j of e.outrogroups)j.pending.delete(A),j.done.delete(A);if((A.f&Nr)!==0&&(Ri(A),o&&(A.nodes?.a?.unfix(),(y??=new Set).delete(A))),(A.f&Ln)!==0)if(A.f^=Ln,A===v)ri(A,null,n);else{var I=k?k.next:v;A===e.effect.last&&(e.effect.last=A.prev),A.prev&&(A.prev.next=A.next),A.next&&(A.next.prev=A.prev),ra(e,k,A),ra(e,A,I),ri(A,I,n),k=A,b=[],_=[],v=Qa(k.next);continue}if(A!==v){if(m!==void 0&&m.has(A)){if(b.length<_.length){var P=_[0],O;k=P.prev;var ee=b[0],R=b[b.length-1];for(O=0;O<b.length;O+=1)ri(b[O],P,n);for(O=0;O<_.length;O+=1)m.delete(_[O]);ra(e,ee.prev,R.next),ra(e,k,ee),ra(e,R,P),v=P,k=R,C-=1,b=[],_=[]}else m.delete(A),ri(A,v,n),ra(e,A.prev,A.next),ra(e,A,k===null?e.effect.first:k.next),ra(e,k,A),k=A;continue}for(b=[],_=[];v!==null&&v!==A;)(m??=new Set).add(v),_.push(v),v=Qa(v.next);if(v===null)continue}(A.f&Ln)===0&&b.push(A),k=A,v=Qa(A.next)}if(e.outrogroups!==null){for(const j of e.outrogroups)j.pending.size===0&&(Bo(e,Di(j.done)),e.outrogroups?.delete(j));e.outrogroups.size===0&&(e.outrogroups=null)}if(v!==null||m!==void 0){var F=[];if(m!==void 0)for(A of m)(A.f&Nr)===0&&F.push(A);for(;v!==null;)(v.f&Nr)===0&&v!==e.fallback&&F.push(v),v=Qa(v.next);var D=F.length;if(D>0){var q=(a&kl)!==0&&s===0?n:null;if(o){for(C=0;C<D;C+=1)F[C].nodes?.a?.measure();for(C=0;C<D;C+=1)F[C].nodes?.a?.fix()}Yd(e,F,q)}}o&&Bn(()=>{if(y!==void 0)for(A of y)A.nodes?.a?.apply()})}function Xd(e,r,n,a,i,o,s,u){var v=(s&Lu)!==0?(s&Uu)===0?xd(n,!1,!1):wa(n):null,m=(s&Bu)!==0?wa(i):null;return{v,i:m,e:dn(()=>(o(r,v??n,m??i,u),()=>{e.delete(a)}))}}function ri(e,r,n){if(e.nodes)for(var a=e.nodes.start,i=e.nodes.end,o=r&&(r.f&Ln)===0?r.nodes.start:n;a!==null;){var s=mi(a);if(o.before(a),a===i)return;a=s}}function ra(e,r,n){r===null?e.effect.first=n:r.next=n,n===null?e.effect.last=r:n.prev=r}function hs(e,r,...n){var a=new ou(e);qi(()=>{const i=r()??null;a.ensure(i,i&&(o=>i(o,...n)))},ya)}function su(e){var r,n,a="";if(typeof e=="string"||typeof e=="number")a+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(r=0;r<i;r++)e[r]&&(n=su(e[r]))&&(a&&(a+=" "),a+=n)}else for(n in e)e[n]&&(a&&(a+=" "),a+=n);return a}function ec(){for(var e,r,n=0,a="",i=arguments.length;n<i;n++)(e=arguments[n])&&(r=su(e))&&(a&&(a+=" "),a+=r);return a}function lu(e){return typeof e=="object"?ec(e):e??""}const ms=[...`
2
+ \r\f \v\uFEFF`];function tc(e,r,n){var a=e==null?"":""+e;if(r&&(a=a?a+" "+r:r),n){for(var i of Object.keys(n))if(n[i])a=a?a+" "+i:i;else if(a.length)for(var o=i.length,s=0;(s=a.indexOf(i,s))>=0;){var u=s+o;(s===0||ms.includes(a[s-1]))&&(u===a.length||ms.includes(a[u]))?a=(s===0?"":a.substring(0,s))+a.substring(u+1):s=u}}return a===""?null:a}function _s(e,r=!1){var n=r?" !important;":";",a="";for(var i of Object.keys(e)){var o=e[i];o!=null&&o!==""&&(a+=" "+i+": "+o+n)}return a}function rc(e,r){if(r){var n="",a,i;return Array.isArray(r)?(a=r[0],i=r[1]):a=r,a&&(n+=_s(a)),i&&(n+=_s(i,!0)),n=n.trim(),n===""?null:n}return String(e)}function Nt(e,r,n,a,i,o){var s=e[Ao];if(s!==n||s===void 0){var u=tc(n,a,o);u==null?e.removeAttribute("class"):e.className=u,e[Ao]=n}else if(o&&i!==o)for(var v in o){var m=!!o[v];(i==null||m!==!!i[v])&&e.classList.toggle(v,m)}return o}function Ji(e,r={},n,a){for(var i in n){var o=n[i];r[i]!==o&&(n[i]==null?e.style.removeProperty(i):e.style.setProperty(i,o,a))}}function nc(e,r,n,a){var i=e[Po];if(i!==r){var o=rc(r,a);o==null?e.removeAttribute("style"):e.style.cssText=o,e[Po]=r}else a&&(Array.isArray(a)?(Ji(e,n?.[0],a[0]),Ji(e,n?.[1],a[1],"important")):Ji(e,n,a));return a}function ac(e,r){r?e.hasAttribute("selected")||e.setAttribute("selected",""):e.removeAttribute("selected")}function ic(e,r){var n=e.__defaultValue,a=e.multiple,i=a?n??[]:null;if(!(a&&!vi(i))){e.selectedIndex;for(var o of e.options){var s=Ia(o);ac(o,a?i.includes(s):ql(s,n))}}}function ka(e,r,n=!1){if(e.multiple){if(r==null)return;if(!vi(r))return Ju();for(var a of e.options)a.selected=r.includes(Ia(a));return}for(a of e.options){var i=Ia(a);if(ql(i,r)){a.selected=!0;return}}(!n||r!==void 0)&&(e.selectedIndex=-1)}function er(e){var r=new MutationObserver(n=>{n.every(oc)||("__defaultValue"in e&&ic(e),"__value"in e&&ka(e,e.__value))});r.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Zo(()=>{r.disconnect()})}function xr(e,r,n=r){var a=new WeakSet,i=!0;Vo(e,"change",o=>{var s=o?"[selected]":":checked",u;if(e.multiple)u=[].map.call(e.querySelectorAll(s),Ia);else{var v=e.querySelector(s)??e.querySelector("option:not([disabled])");u=v&&Ia(v)}n(u),e.__value=u,st!==null&&a.add(st)}),Gl(()=>{var o=r();if(e===document.activeElement){var s=st;if(a.has(s))return}if(ka(e,o,i),i&&o===void 0){var u=e.querySelector(":checked");u!==null&&(o=Ia(u),n(o))}e.__value=o,i=!1})}function Ia(e){return"__value"in e?e.__value:e.value}function oc(e){if(e.target.closest("selectedcontent")!==null)return!0;if(e.type==="childList"){var r=[...e.addedNodes,...e.removedNodes];return r.length>0&&r.every(n=>n.nodeName==="SELECTEDCONTENT")}return!1}const sc=Symbol("is custom element"),lc=Symbol("is html"),uc=Du?"progress":"PROGRESS";function In(e,r){var n=ts(e);n.value===(n.value=r??void 0)||e.value===r&&(r!==0||e.nodeName!==uc)||(e.value=r??"")}function dc(e,r){var n=ts(e);n.checked!==(n.checked=r??void 0)&&(e.checked=r)}function Q(e,r,n,a){var i=ts(e);i[r]!==(i[r]=n)&&(r==="loading"&&(e[Ou]=n),n==null?e.removeAttribute(r):typeof n!="string"&&cc(e).has(r)?e[r]=n:e.setAttribute(r,n))}function ts(e){return e[wl]??={[sc]:e.nodeName.includes("-"),[lc]:e.namespaceURI===Vu}}var gs=new Map;function cc(e){var r=e.getAttribute("is")||e.nodeName,n=gs.get(r);if(n)return n;gs.set(r,n=new Set);for(var a,i=e,o=Element.prototype;o!==i;){a=hl(i);for(var s in a)a[s].set&&s!=="innerHTML"&&s!=="textContent"&&s!=="innerText"&&n.add(s);i=Li(i)}return n}function Le(e,r,n=r){var a=new WeakSet;Vo(e,"input",async i=>{var o=i?e.defaultValue:e.value;if(o=Wi(e)?Qi(o):o,n(o),st!==null&&a.add(st),await tu(),o!==(o=r())){var s=e.selectionStart,u=e.selectionEnd,v=e.value.length;if(e.value=o??"",u!==null){var m=e.value.length;s===u&&u===v&&m>v?(e.selectionStart=m,e.selectionEnd=m):(e.selectionStart=s,e.selectionEnd=Math.min(u,m))}}}),la(r)==null&&e.value&&(n(Wi(e)?Qi(e.value):e.value),st!==null&&a.add(st)),Bi(()=>{var i=r();if(e===document.activeElement){var o=st;if(a.has(o))return}Wi(e)&&i===Qi(e.value)||e.type==="date"&&!i&&!e.value||i!==e.value&&(e.value=i??"")})}function uu(e,r,n=r){Vo(e,"change",a=>{var i=a?e.defaultChecked:e.checked;n(i)}),la(r)==null&&n(e.checked),Bi(()=>{var a=r();e.checked=!!a})}function Wi(e){var r=e.type;return r==="number"||r==="range"}function Qi(e){return e===""?null:+e}function Yi(e,r){return e===r||e?.[Wn]===r}function Ui(e=$o(),r,n,a){var i=Ft.r,o=Tt;return Gl(()=>{var s,u;return Bi(()=>{s=u,u=[],la(()=>{Yi(n(...u),e)||(r(e,...u),s&&Yi(n(...s),e)&&r(null,...s))})}),()=>{let v=o;for(;v!==i&&v.parent!==null&&v.parent.f&li;)v=v.parent;const m=()=>{u&&Yi(n(...u),e)&&r(null,...u)},k=v.teardown;v.teardown=()=>{m(),k?.()}}}),e}function vc(e=!1){const r=Ft,n=r.l.u;if(!n)return;let a=()=>Bd(r.s);if(e){let i=0,o={};const s=La(()=>{let u=!1;const v=r.s;for(const m in v)v[m]!==o[m]&&(o[m]=v[m],u=!0);return u&&i++,i});a=()=>t(s)}n.b.length&&Nd(()=>{bs(r,a),So(n.b)}),Br(()=>{const i=la(()=>n.m.map(Mu));return()=>{for(const o of i)typeof o=="function"&&o()}}),n.a.length&&Br(()=>{bs(r,a),So(n.a)})}function bs(e,r){if(e.l.s)for(const n of e.l.s)t(n);r()}let yi=!1;function fc(e){var r=yi;try{return yi=!1,[e(),yi]}finally{yi=r}}function gr(e,r,n,a){var i=!$a||(n&ju)!==0,o=(n&Hu)!==0,s=(n&$u)!==0,u=a,v=!0,m=void 0,k=()=>s&&i?(m??=La(a),t(m)):(v&&(v=!1,u=s?la(a):a),u);let y;if(o){var b=Wn in e||Iu in e;y=Na(e,r)?.set??(b&&r in e?O=>e[r]=O:void 0)}var _,x=!1;o?[_,x]=fc(()=>e[r]):_=e[r],_===void 0&&a!==void 0&&(_=k(),y&&(i&&nd(),y(_)));var T;if(i?T=()=>{var O=e[r];return O===void 0?k():(v=!0,O)}:T=()=>{var O=e[r];return O!==void 0&&(u=void 0),O===void 0?u:O},i&&(n&zu)===0)return T;if(y){var A=e.$$legacy;return(function(O,ee){return arguments.length>0?((!i||!ee||A||x)&&y(ee?T():O),O):T()})}var C=!1,I=((n&Fu)!==0?La:Ko)(()=>(C=!1,T()));o&&t(I);var P=Tt;return(function(O,ee){if(arguments.length>0){const R=ee?t(I):i&&o?Lt(O):O;return w(I,R),C=!0,u!==void 0&&(u=R),O}return Yn&&C||(P.f&br)!==0?I.v:t(I)})}function en(e){Ft===null&&Cl(),$a&&Ft.l!==null?hc(Ft).m.push(e):Br(()=>{const r=la(e);if(typeof r=="function")return r})}function pc(e){Ft===null&&Cl(),en(()=>()=>la(e))}function hc(e){var r=e.l;return r.u??={a:[],b:[],m:[]}}const mc="5";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add(mc);ud();class qo extends Error{status;details;constructor(r,n,a){super(n),this.name="ApiError",this.status=r,this.details=a}get issues(){const r=this.details;return Array.isArray(r?.issues)?r.issues:[]}}let du=()=>{};function _c(e){du=e}async function bt(e,r,n){let a;try{a=await fetch(r,{method:e,...n===void 0?{}:{headers:{"content-type":"application/json"},body:JSON.stringify(n)}})}catch(s){throw new qo(0,s instanceof Error?s.message:String(s))}const i=await a.text(),o=i===""?void 0:JSON.parse(i);if(!a.ok){a.status===401&&!r.startsWith("/api/auth")&&du();const s=o;throw new qo(a.status,s?.error??`${a.status} ${a.statusText}`,s?.details)}return o}const He={auth:()=>bt("GET","/api/auth"),login:e=>bt("POST","/api/auth/login",{password:e}),logout:()=>bt("POST","/api/auth/logout",{}),setAccess:e=>bt("PUT","/api/auth",e),status:()=>bt("GET","/api/status"),stats:()=>bt("GET","/api/stats"),updateStatus:(e=!1)=>bt("GET",`/api/update${e?"?check=1":""}`),requestUpdate:e=>bt("POST","/api/update",{version:e}),restart:()=>bt("POST","/api/restart",{}),config:()=>bt("GET","/api/config"),saveConfig:e=>bt("PUT","/api/config",e),devices:()=>bt("GET","/api/devices"),device:e=>bt("GET",`/api/devices/${encodeURIComponent(e)}`),createDevice:(e,r)=>bt("POST","/api/devices",{key:e,device:r}),saveDevice:(e,r)=>bt("PUT",`/api/devices/${encodeURIComponent(e)}`,r),deleteDevice:e=>bt("DELETE",`/api/devices/${encodeURIComponent(e)}`),deviceState:e=>bt("GET",`/api/devices/${encodeURIComponent(e)}/state`),validate:e=>bt("POST","/api/validate",{device:e}),check:e=>bt("POST","/api/check",e===void 0?{}:{devices:e}),previewStatus:(e,r,n,a)=>bt("POST","/api/preview",{direction:"status",half:e,payload:r,attribute:n,topic:a}),previewCommand:(e,r,n,a)=>bt("POST","/api/preview",{direction:"command",half:e,value:r,attribute:n,fields:a}),publish:(e,r,n=!1,a=0)=>bt("POST","/api/publish",{topic:e,payload:r,retain:n,qos:a}),topics:(e="")=>bt("GET",`/api/topics?prefix=${encodeURIComponent(e)}`),catalog:()=>bt("GET","/api/catalog"),cluster:e=>bt("GET",`/api/catalog/clusters/${encodeURIComponent(e)}`),presets:()=>bt("GET","/api/presets"),applyPreset:(e,r)=>bt("POST",`/api/presets/${encodeURIComponent(e)}/apply`,{values:r}),bridges:()=>bt("GET","/api/bridges"),commissioning:(e,r,n)=>bt("POST",`/api/bridges/${encodeURIComponent(e)}/commissioning`,{open:r,minutes:n}),removeFabric:(e,r)=>bt("DELETE",`/api/bridges/${encodeURIComponent(e)}/fabrics/${r}`),adopt:()=>bt("GET","/api/adopt"),resync:()=>bt("POST","/api/adopt/resync"),adoptDevice:(e,r,n={})=>bt("POST",`/api/adopt/${encodeURIComponent(e)}/${encodeURIComponent(r)}`,n),exportAll:()=>bt("GET","/api/export"),exportDevice:e=>bt("GET",`/api/export?device=${encodeURIComponent(e)}`),importDevices:(e,r)=>bt("POST","/api/import",{devices:e,replace:r}),log:(e=500,r=0)=>bt("GET",`/api/log?limit=${e}&after=${r}`)};function pt(e){if(e instanceof qo){const r=e.issues;return r.length>0?`${e.message}: ${r.map(n=>`${n.path}: ${n.message}`).join("; ")}`:e.message}return e instanceof Error?e.message:String(e)}class gc{#e=z(void 0);get state(){return t(this.#e)}set state(r){w(this.#e,r,!0)}#r=z(!1);get unreachable(){return t(this.#r)}set unreachable(r){w(this.#r,r,!0)}constructor(){_c(()=>{this.state!==void 0&&(this.state={...this.state,authenticated:!1})})}async load(){try{this.state=await He.auth(),this.unreachable=!1}catch{this.unreachable=!0}}async login(r){this.state=await He.login(r)}async logout(){const r=this.state?.mode,n=this.state?.logoutUrl;if(r==="proxy"){n!==void 0&&(window.location.href=n);return}this.state=await He.logout()}}const or=new gc,p=(e,r)=>({de:e,en:r}),bc={Devices:p("Geräte","Devices"),Presets:p("Vorlagen","Presets"),Adopt:p("Übernehmen","Adopt"),Bridges:p("Bridges","Bridges"),Log:p("Protokoll","Log"),Check:p("Prüfen","Check"),Configuration:p("Konfiguration","Configuration"),Pages:p("Seiten","Pages"),Live:p("Live","Live"),Language:p("Sprache","Language"),"Browser language":p("Sprache des Browsers","Browser language"),light:p("hell","light"),dark:p("dunkel","dark"),Display:p("Anzeige","Display"),"in this browser only":p("nur in diesem Browser","in this browser only"),Theme:p("Design","Theme"),"like the system":p("wie das System","like the system"),Licences:p("Lizenzen","Licences"),"Runtime dependencies":p("Laufzeit-Abhängigkeiten","Runtime dependencies"),"User interface":p("Oberfläche","User interface"),"The package has no licence file; its package.json names {license}.":p("Das Paket hat keine Lizenzdatei; seine package.json nennt {license}.","The package has no licence file; its package.json names {license}."),"The licence list could not be loaded: {error}":p("Die Lizenzliste konnte nicht geladen werden: {error}","The licence list could not be loaded: {error}"),"Loading…":p("Wird geladen …","Loading…"),Statistics:p("Statistik","Statistics"),Uptime:p("Laufzeit","Uptime"),Endpoints:p("Endpunkte","Endpoints"),paired:p("gekoppelt","paired"),"Controllers (fabrics)":p("Controller (Fabrics)","Controllers (fabrics)"),"MQTT topics":p("MQTT-Topics","MQTT topics"),"MQTT msg/s":p("MQTT-Nachr./s","MQTT msg/s"),"Memory (RSS)":p("Speicher (RSS)","Memory (RSS)"),Heap:p("Heap","Heap"),"Event loop utilisation":p("Event-Loop-Auslastung","Event loop utilisation"),"Event loop lag mean":p("Event-Loop-Verzögerung Mittel","Event loop lag mean"),"Event loop lag max":p("Event-Loop-Verzögerung Max.","Event loop lag max"),"Averages over the last {seconds} s":p("Mittelwerte der letzten {seconds} s","Averages over the last {seconds} s"),"Not reachable":p("Nicht erreichbar","Not reachable"),"Connected to the broker":p("Mit dem Broker verbunden","Connected to the broker"),"Not connected to the broker":p("Nicht mit dem Broker verbunden","Not connected to the broker"),"Event stream connected":p("Ereignisstrom verbunden","Event stream connected"),"Event stream disconnected":p("Ereignisstrom getrennt","Event stream disconnected"),"Show fewer":p("Weniger anzeigen","Show fewer"),"{count} more":p("{count} weitere","{count} more"),Dismiss:p("Schließen","Dismiss"),Close:p("Schließen","Close"),Cancel:p("Abbrechen","Cancel"),OK:p("OK","OK"),Confirm:p("Bestätigen","Confirm"),Input:p("Eingabe","Input"),Apply:p("Übernehmen","Apply"),Save:p("Speichern","Save"),Reload:p("Neu laden","Reload"),Remove:p("Entfernen","Remove"),Delete:p("Löschen","Delete"),Duplicate:p("Duplizieren","Duplicate"),Export:p("Exportieren","Export"),Import:p("Importieren","Import"),Filter:p("Filter","Filter"),Open:p("Öffnen","Open"),Update:p("Aktualisieren","Update"),Loading:p("Wird geladen","Loading"),Name:p("Name","Name"),Key:p("Schlüssel","Key"),error:p("Fehler","error"),warning:p("Warnung","warning"),ok:p("ok","ok"),"New device":p("Neues Gerät","New device"),"From preset":p("Aus Vorlage","From preset"),"{count} devices":p("{count} Geräte","{count} devices"),"No devices yet. Create one by hand, apply a preset, or adopt a discovered device.":p("Noch keine Geräte. Lege eines von Hand an, wende eine Vorlage an oder übernimm ein entdecktes Gerät.","No devices yet. Create one by hand, apply a preset, or adopt a discovered device."),"Device types":p("Gerätetypen","Device types"),"Device type":p("Gerätetyp","Device type"),Source:p("Quelle","Source"),Bridge:p("Bridge","Bridge"),Endpoint:p("Endpunkt","Endpoint"),State:p("Zustand","State"),manual:p("manuell","manual"),preset:p("Vorlage","preset"),orphaned:p("verwaist","orphaned"),disabled:p("deaktiviert","disabled"),"not built":p("nicht gebaut","not built"),reachable:p("erreichbar","reachable"),unreachable:p("nicht erreichbar","unreachable"),"{count} errors":p("{count} Fehler","{count} errors"),"{count} warnings":p("{count} Warnungen","{count} warnings"),Disable:p("Deaktivieren","Disable"),Enable:p("Aktivieren","Enable"),"Key of the copy":p("Schlüssel der Kopie","Key of the copy"),"A device with this key exists already.":p("Ein Gerät mit diesem Schlüssel gibt es schon.","A device with this key exists already."),"Delete {name}? Controllers lose the device, its rooms and automations.":p("{name} löschen? Controller verlieren das Gerät, seine Räume und Automationen.","Delete {name}? Controllers lose the device, its rooms and automations."),"{name} deleted":p("{name} gelöscht","{name} deleted"),"The key is the Matter endpoint id: stable, never renamed. Letters, digits, : . _ -":p("Der Schlüssel ist die Matter-Endpunkt-Id: stabil, wird nie umbenannt. Buchstaben, Ziffern, : . _ -","The key is the Matter endpoint id: stable, never renamed. Letters, digits, : . _ -"),"The device type brings its mandatory clusters; their mappings are filled in the editor.":p("Der Gerätetyp bringt seine Pflicht-Cluster mit; ihre Zuordnungen werden im Editor ausgefüllt.","The device type brings its mandatory clusters; their mappings are filled in the editor."),Create:p("Anlegen","Create"),Device:p("Gerät","Device"),Vendor:p("Hersteller","Vendor"),Model:p("Modell","Model"),Serial:p("Seriennummer","Serial"),Enabled:p("Aktiviert","Enabled"),"assigned automatically":p("automatisch zugewiesen","assigned automatically"),Availability:p("Verfügbarkeit","Availability"),Mode:p("Modus","Mode"),Topic:p("Topic","Topic"),extract:p("Pfad","extract"),"topic · JSON path · the online payload · the offline payload":p("Topic · JSON-Pfad · das Online-Payload · das Offline-Payload","topic · JSON path · the online payload · the offline payload"),"Without an availability topic the device counts as reachable while it reports (see expire on a status half).":p("Ohne Verfügbarkeits-Topic gilt das Gerät als erreichbar, solange es meldet (siehe expire an einer Status-Hälfte).","Without an availability topic the device counts as reachable while it reports (see expire on a status half)."),"Endpoint (the bridged node)":p("Endpunkt (der Bridged Node)","Endpoint (the bridged node)"),"Child endpoint":p("Kind-Endpunkt","Child endpoint"),"coalesce (ms)":p("zusammenfassen (ms)","coalesce (ms)"),"add type":p("Typ hinzufügen","add type"),Options:p("Optionen","Options"),Target:p("Ziel","Target"),"Status (device → Matter)":p("Status (Gerät → Matter)","Status (device → Matter)"),"Command (Matter → device)":p("Befehl (Matter → Gerät)","Command (Matter → device)"),mandatory:p("Pflicht","mandatory"),Mapping:p("Zuordnung","Mapping"),map:p("Map","map"),format:p("Format","format"),template:p("Template","template"),Form:p("Formular","Form"),"Apply to the form":p("Ins Formular übernehmen","Apply to the form"),"Not valid JSON":p("Kein gültiges JSON","Not valid JSON"),"Checking…":p("Prüfe…","Checking…"),"Strict dry run":p("Strenger Probelauf","Strict dry run"),"matter.js builds the device without complaint.":p("matter.js baut das Gerät ohne Beanstandung.","matter.js builds the device without complaint."),"The device validates.":p("Das Gerät ist gültig.","The device validates."),"endpoint {number}":p("Endpunkt {number}","endpoint {number}"),"{name} saved":p("{name} gespeichert","{name} saved"),"{name} saved and built":p("{name} gespeichert und gebaut","{name} saved and built"),"Discard the unsaved changes?":p("Die ungespeicherten Änderungen verwerfen?","Discard the unsaved changes?"),Discard:p("Verwerfen","Discard"),"Remove this endpoint and its mappings?":p("Diesen Endpunkt und seine Zuordnungen entfernen?","Remove this endpoint and its mappings?"),Kind:p("Art","Kind"),attribute:p("Attribut","attribute"),"command (invoke)":p("Befehl (invoke)","command (invoke)"),"event channel":p("Ereigniskanal","event channel"),"— cluster —":p("— Cluster —","— cluster —"),"— attribute —":p("— Attribut —","— attribute —"),"— command —":p("— Befehl —","— command —"),"— none —":p("— keine —","— none —"),writable:p("schreibbar","writable"),nullable:p("nullable","nullable"),Comment:p("Kommentar","Comment"),Pick:p("Wählen","Pick"),"Extract (JSON path)":p("Extrahieren (JSON-Pfad)","Extract (JSON path)"),Template:p("Template","Template"),Map:p("Map","Map"),payload:p("Payload","payload"),value:p("Wert","value"),Row:p("Zeile","Row"),"Enum names":p("Enum-Namen","Enum names"),Default:p("Standardwert","Default"),Type:p("Typ","Type"),Unit:p("Einheit","Unit"),Scale:p("Skalierung","Scale"),"Offset / round / invert":p("Offset / Runden / Invertieren","Offset / round / invert"),offset:p("Offset","offset"),round:p("Runden","round"),precision:p("Nachkommastellen","precision"),invert:p("invertieren","invert"),"Expire (s)":p("Verfall (s)","Expire (s)"),"without a message for this long the device is unreachable":p("so lange ohne Nachricht gilt das Gerät als nicht erreichbar","without a message for this long the device is unreachable"),"Get request":p("Abfrage (get)","Get request"),topic:p("Topic","topic"),Preview:p("Vorschau","Preview"),Payload:p("Payload","Payload"),"Publish as the device would":p("Senden, wie es das Gerät täte","Publish as the device would"),Format:p("Format","Format"),"Fixed payload":p("Festes Payload","Fixed payload"),"Wrap (JSON path)":p("Einpacken (JSON-Pfad)","Wrap (JSON path)"),"Retain / QoS / optimistic":p("Retain / QoS / optimistisch","Retain / QoS / optimistic"),retain:p("retain","retain"),"optimistic: automatic":p("optimistisch: automatisch","optimistic: automatic"),"optimistic: yes":p("optimistisch: ja","optimistic: yes"),"optimistic: no":p("optimistisch: nein","optimistic: no"),"Matter value":p("Matter-Wert","Matter value"),"a number, text or JSON":p("eine Zahl, Text oder JSON","a number, text or JSON"),"Test-publish":p("Testweise senden","Test-publish"),"Published to {topic}":p("Gesendet an {topic}","Published to {topic}"),"Pick a topic":p("Topic wählen","Pick a topic"),Time:p("Zeit","Time"),"No topic seen yet that matches.":p("Noch kein passendes Topic gesehen.","No topic seen yet that matches."),"Click a key to use the topic with that JSON path:":p("Klicke einen Schlüssel, um das Topic mit diesem JSON-Pfad zu übernehmen:","Click a key to use the topic with that JSON path:"),"Use topic":p("Topic übernehmen","Use topic"),Other:p("Sonstige","Other"),"Search presets":p("Vorlagen durchsuchen","Search presets"),"{count} of {total} presets":p("{count} von {total} Vorlagen","{count} of {total} presets"),"No preset matches “{query}”.":p("Keine Vorlage passt zu „{query}“.","No preset matches “{query}”."),own:p("eigene","own"),"No presets. Put preset files into a directory named in the configuration.":p("Keine Vorlagen. Lege Vorlagen-Dateien in ein Verzeichnis, das in der Konfiguration genannt ist.","No presets. Put preset files into a directory named in the configuration."),"Preset files with problems":p("Vorlagen-Dateien mit Problemen","Preset files with problems"),optional:p("optional","optional"),"Create device":p("Gerät anlegen","Create device"),"{name} created":p("{name} angelegt","{name} created"),"Re-sync":p("Neu abgleichen","Re-sync"),"Adopt all new":p("Alle neuen übernehmen","Adopt all new"),"show unsupported":p("nicht unterstützte zeigen","show unsupported"),"{count} new":p("{count} neu","{count} new"),"{count} changed":p("{count} geändert","{count} changed"),"{count} orphaned":p("{count} verwaist","{count} orphaned"),"{count} adopted":p("{count} übernommen","{count} adopted"),"{count} unsupported":p("{count} nicht unterstützt","{count} unsupported"),"No importer is configured. Discovered devices from Zigbee2MQTT and Home Assistant discovery appear here.":p("Kein Importer ist eingerichtet. Entdeckte Geräte aus Zigbee2MQTT und Home-Assistant-Discovery erscheinen hier.","No importer is configured. Discovered devices from Zigbee2MQTT and Home Assistant discovery appear here."),"Nothing discovered yet. Zigbee2MQTT publishes its devices on <base>/bridge/devices, Home Assistant discovery under <prefix>/; the bridge subscribes both.":p("Noch nichts entdeckt. Zigbee2MQTT veröffentlicht seine Geräte auf <base>/bridge/devices, Home-Assistant-Discovery unter <prefix>/; die Bridge abonniert beides.","Nothing discovered yet. Zigbee2MQTT publishes its devices on <base>/bridge/devices, Home Assistant discovery under <prefix>/; the bridge subscribes both."),Area:p("Bereich","Area"),Native:p("Nativ","Native"),"native: {source}":p("nativ: {source}","native: {source}"),"Also described natively by {source} as {key}; the native description is preferred.":p("Auch nativ von {source} als {key} beschrieben; die native Beschreibung ist vorzuziehen.","Also described natively by {source} as {key}; the native description is preferred."),new:p("neu","new"),changed:p("geändert","changed"),adopted:p("übernommen","adopted"),"back again":p("wieder da","back again"),invalid:p("ungültig","invalid"),unsupported:p("nicht unterstützt","unsupported"),duplicate:p("doppelt","duplicate"),Twins:p("Doppelt übernommen","Twins"),"Adopt anyway":p("Trotzdem übernehmen","Adopt anyway"),Replace:p("Ersetzen","Replace"),"{name} is the same device as {key}, which {source} describes natively. Adopting it here makes a second Matter device for one device: controllers show it twice. Adopt it anyway?":p("{name} ist dasselbe Gerät wie {key}, das {source} nativ beschreibt. Hier übernommen wird es ein zweites Matter-Gerät für ein Gerät: Controller zeigen es doppelt. Trotzdem übernehmen?","{name} is the same device as {key}, which {source} describes natively. Adopting it here makes a second Matter device for one device: controllers show it twice. Adopt it anyway?"),"{name} is already adopted as {key}. Replace it: the native description is adopted and {key} is disabled — it stays in the configuration until you delete it. Controllers see a new device.":p("{name} ist schon als {key} übernommen. Ersetzen: die native Beschreibung wird übernommen und {key} abgeschaltet — es bleibt in der Konfiguration, bis du es löschst. Controller sehen ein neues Gerät.","{name} is already adopted as {key}. Replace it: the native description is adopted and {key} is disabled — it stays in the configuration until you delete it. Controllers see a new device."),"{count} duplicates":p("{count} doppelt","{count} duplicates"),group:p("Gruppe","group"),Notes:p("Hinweise","Notes"),Details:p("Details","Details"),"{count} conflicts":p("{count} Konflikte","{count} conflicts"),"{count} edits":p("{count} eigene Änderungen","{count} edits"),"{count} unmapped":p("{count} nicht abgebildet","{count} unmapped"),"Not mapped":p("Nicht abgebildet","Not mapped"),"Your edits":p("Eigene Änderungen","Your edits"),"Your edit":p("Eigene Änderung","Your edit"),Conflicts:p("Konflikte","Conflicts"),"Your edit and the new description changed the same value; your edit stays.":p("Eigene Änderung und neue Beschreibung ändern denselben Wert; die eigene Änderung bleibt.","Your edit and the new description changed the same value; your edit stays."),"Re-sync every adopted device? {count} entries change: updated ones take the new description (your edits are kept, conflicts reported), orphans are marked.":p("Jedes übernommene Gerät neu abgleichen? {count} Einträge ändern sich: geänderte übernehmen die neue Beschreibung (eigene Änderungen bleiben, Konflikte werden gemeldet), verwaiste werden markiert.","Re-sync every adopted device? {count} entries change: updated ones take the new description (your edits are kept, conflicts reported), orphans are marked."),"{count} devices written":p("{count} Geräte geschrieben","{count} devices written"),"Update {name}? {count} of your edits conflict with the new description; your edits win, the conflicts are listed in the details.":p("{name} aktualisieren? {count} eigene Änderungen stehen im Konflikt mit der neuen Beschreibung; die eigenen Änderungen gewinnen, die Konflikte stehen in den Details.","Update {name}? {count} of your edits conflict with the new description; your edits win, the conflicts are listed in the details."),"Update {name} from the source? Your own edits are kept.":p("{name} aus der Quelle aktualisieren? Eigene Änderungen bleiben erhalten.","Update {name} from the source? Your own edits are kept."),"{name} adopted as {key}":p("{name} übernommen als {key}","{name} adopted as {key}"),"Adopt {count} new devices?":p("{count} neue Geräte übernehmen?","Adopt {count} new devices?"),Path:p("Pfad","Path"),commissioned:p("gekoppelt","commissioned"),"not commissioned":p("nicht gekoppelt","not commissioned"),"port {port}":p("Port {port}","port {port}"),"Manual pairing code":p("Manueller Kopplungscode","Manual pairing code"),"QR payload":p("QR-Inhalt","QR payload"),"No pairing codes: the bridge is not running.":p("Keine Kopplungscodes: die Bridge läuft nicht.","No pairing codes: the bridge is not running."),"Commissioning window":p("Kopplungsfenster","Commissioning window"),closed:p("geschlossen","closed"),"open (basic)":p("offen (basic)","open (basic)"),"open (enhanced)":p("offen (enhanced)","open (enhanced)"),"Open for 15 minutes":p("Für 15 Minuten öffnen","Open for 15 minutes"),"Commissioning window open for 15 minutes":p("Kopplungsfenster für 15 Minuten geöffnet","Commissioning window open for 15 minutes"),"Commissioning window closed":p("Kopplungsfenster geschlossen","Commissioning window closed"),"Pair the bridge from Apple Home, Home Assistant, Google Home or Alexa with the QR code or the manual code. A commissioned bridge needs an open window for a second controller.":p("Kopple die Bridge aus Apple Home, Home Assistant, Google Home oder Alexa mit dem QR-Code oder dem manuellen Code. Eine gekoppelte Bridge braucht für einen zweiten Controller ein offenes Fenster.","Pair the bridge from Apple Home, Home Assistant, Google Home or Alexa with the QR code or the manual code. A commissioned bridge needs an open window for a second controller."),Fabrics:p("Fabrics","Fabrics"),"No controller has paired this bridge yet.":p("Noch kein Controller hat diese Bridge gekoppelt.","No controller has paired this bridge yet."),"Unknown controller":p("Unbekannter Controller","Unknown controller"),"Sessions of this controller with an active peer, and their subscriptions":p("Sitzungen dieses Controllers mit aktiver Gegenstelle und ihre Abonnements","Sessions of this controller with an active peer, and their subscriptions"),"sessions: {sessions} · subscriptions: {subscriptions}":p("Sitzungen: {sessions} · Abonnements: {subscriptions}","sessions: {sessions} · subscriptions: {subscriptions}"),"no active session":p("keine aktive Sitzung","no active session"),"Apple adds this fabric next to the Apple Home one when the bridge is paired from Apple Home; removing the bridge in Apple Home removes both.":p("Apple legt dieses Fabric neben dem von Apple Home an, wenn die Bridge in Apple Home gekoppelt wird; wer die Bridge in Apple Home entfernt, entfernt beide.","Apple adds this fabric next to the Apple Home one when the bridge is paired from Apple Home; removing the bridge in Apple Home removes both."),"Vendor id":p("Hersteller-Id","Vendor id"),Fabric:p("Fabric","Fabric"),"Bridge node id":p("Node-Id der Bridge","Bridge node id"),"Controller node id":p("Node-Id des Controllers","Controller node id"),"Compressed fabric id":p("Komprimierte Fabric-Id","Compressed fabric id"),"The first half of the bridge’s operational mDNS name in this fabric":p("Die erste Hälfte des operativen mDNS-Namens der Bridge in diesem Fabric","The first half of the bridge’s operational mDNS name in this fabric"),"Last contact":p("Letzter Kontakt","Last contact"),"Remove fabric {label}? The controller loses the bridge and every device on it.":p("Fabric {label} entfernen? Der Controller verliert die Bridge und jedes Gerät darauf.","Remove fabric {label}? The controller loses the bridge and every device on it."),Topics:p("Topics","Topics"),"{count} topics":p("{count} Topics","{count} topics"),retained:p("retained","retained"),Publish:p("Senden","Publish"),Messages:p("Nachrichten","Messages"),pause:p("Pause","pause"),Clear:p("Leeren","Clear"),follow:p("folgen","follow"),"{count} lines":p("{count} Zeilen","{count} lines"),"Check every device":p("Jedes Gerät prüfen","Check every device"),"The strict dry run: every device is built in a throw-away Matter node, nothing goes online.":p("Der strenge Probelauf: jedes Gerät wird in einem Wegwerf-Matter-Node gebaut, nichts geht online.","The strict dry run: every device is built in a throw-away Matter node, nothing goes online."),"Every device conforms.":p("Jedes Gerät ist konform.","Every device conforms."),"Some devices do not conform.":p("Manche Geräte sind nicht konform.","Some devices do not conform."),Settings:p("Einstellungen","Settings"),"The top level of the configuration file without the devices: mqtt, storage, log, vendorId, productId, bridges, server, presets. Changes apply at the next start.":p("Die oberste Ebene der Konfigurationsdatei ohne die Geräte: mqtt, storage, log, vendorId, productId, bridges, server, presets. Änderungen gelten ab dem nächsten Start.","The top level of the configuration file without the devices: mqtt, storage, log, vendorId, productId, bridges, server, presets. Changes apply at the next start."),"Set by the environment and not editable here: {paths}":p("Durch die Umgebung gesetzt und hier nicht änderbar: {paths}","Set by the environment and not editable here: {paths}"),"Settings saved. They apply at the next start of mqtt2matter.":p("Einstellungen gespeichert. Sie gelten ab dem nächsten Start von mqtt2matter.","Settings saved. They apply at the next start of mqtt2matter."),"The whole configuration file, as it is on disk. One device exports from the device list.":p("Die ganze Konfigurationsdatei, wie sie auf der Platte liegt. Ein einzelnes Gerät exportiert die Geräteliste.","The whole configuration file, as it is on disk. One device exports from the device list."),"Download mqtt2matter.json":p("mqtt2matter.json herunterladen","Download mqtt2matter.json"),"A configuration file or a devices object; every device is validated before anything is written.":p("Eine Konfigurationsdatei oder ein devices-Objekt; jedes Gerät wird geprüft, bevor etwas geschrieben wird.","A configuration file or a devices object; every device is validated before anything is written."),"The file could not be read.":p("Die Datei konnte nicht gelesen werden.","The file could not be read."),"Import {count} devices":p("{count} Geräte importieren","Import {count} devices"),"Import {count} devices and delete every other device?":p("{count} Geräte importieren und jedes andere Gerät löschen?","Import {count} devices and delete every other device?"),"Import {count} devices? Existing devices with the same key are replaced.":p("{count} Geräte importieren? Vorhandene Geräte mit demselben Schlüssel werden ersetzt.","Import {count} devices? Existing devices with the same key are replaced."),"{count} devices imported":p("{count} Geräte importiert","{count} devices imported"),"replace every device":p("jedes Gerät ersetzen","replace every device"),"The bridge does not answer.":p("Die Bridge antwortet nicht.","The bridge does not answer."),"Try again":p("Erneut versuchen","Try again"),Password:p("Passwort","Password"),"Log in":p("Anmelden","Log in"),"Log out":p("Abmelden","Log out"),"This request was not authenticated by the reverse proxy. Open the UI through the proxy.":p("Diese Anfrage wurde nicht vom Reverse-Proxy authentifiziert. Öffne die Oberfläche über den Proxy.","This request was not authenticated by the reverse proxy. Open the UI through the proxy."),Access:p("Zugang","Access"),"Who may use this UI and its API. Without a login, keep the port on a trusted network.":p("Wer diese Oberfläche und ihre API benutzen darf. Ohne Anmeldung gehört der Port in ein vertrauenswürdiges Netz.","Who may use this UI and its API. Without a login, keep the port on a trusted network."),Login:p("Anmeldung","Login"),none:p("keine","none"),password:p("Passwort","password"),"reverse proxy":p("Reverse-Proxy","reverse proxy"),unchanged:p("unverändert","unchanged"),Repeat:p("Wiederholen","Repeat"),"The passwords differ.":p("Die Passwörter sind verschieden.","The passwords differ."),Header:p("Header","Header"),"Logout URL":p("Abmelde-URL","Logout URL"),'Optional: where "Log out" goes — the sign-out of the proxy.':p("Optional: wohin „Abmelden“ führt — die Abmeldung des Proxys.",'Optional: where "Log out" goes — the sign-out of the proxy.'),"Open the UI to everyone who reaches its port?":p("Die Oberfläche für jeden öffnen, der ihren Port erreicht?","Open the UI to everyone who reaches its port?"),"Protect the UI with this password? Other open sessions end.":p("Die Oberfläche mit diesem Passwort schützen? Andere offene Sitzungen enden.","Protect the UI with this password? Other open sessions end."),"Trust the {header} header of the reverse proxy? Only the proxy may reach the port then, or anyone can send the header.":p("Dem Header {header} des Reverse-Proxys vertrauen? Dann darf nur der Proxy den Port erreichen, sonst kann jeder den Header schicken.","Trust the {header} header of the reverse proxy? Only the proxy may reach the port then, or anyone can send the header."),"Access saved; it applies at once.":p("Zugang gespeichert; er gilt sofort.","Access saved; it applies at once."),Version:p("Version","Version"),Installed:p("Installiert","Installed"),Latest:p("Neueste","Latest"),"up to date":p("aktuell","up to date"),"Update available":p("Update verfügbar","Update available"),"Update to {version}":p("Update auf {version}","Update to {version}"),"Check for updates":p("Nach Updates suchen","Check for updates"),"not published on npm yet":p("noch nicht auf npm veröffentlicht","not published on npm yet"),Restart:p("Neu starten","Restart"),"Install mqtt2matter {version} and restart? The bridge is offline for a moment; the pairings stay.":p("mqtt2matter {version} installieren und neu starten? Die Bridge ist kurz offline; die Kopplungen bleiben.","Install mqtt2matter {version} and restart? The bridge is offline for a moment; the pairings stay."),"Update to {version} requested.":p("Update auf {version} angefordert.","Update to {version} requested."),"Restart mqtt2matter? The bridge is offline for a moment.":p("mqtt2matter neu starten? Die Bridge ist kurz offline.","Restart mqtt2matter? The bridge is offline for a moment."),"Restarting…":p("Startet neu …","Restarting…"),"Waiting for mqtt2matter to come back…":p("Warte, bis mqtt2matter wieder da ist …","Waiting for mqtt2matter to come back…"),"mqtt2matter {version} is running.":p("mqtt2matter {version} läuft.","mqtt2matter {version} is running.")},cu=["de","en"],vu={de:"Deutsch",en:"English"},fu="mqtt2matter.language";function yc(e=wc()){for(const r of e){const n=r.toLowerCase().split("-")[0];if(n==="de"||n==="en")return n}return"en"}function wc(){return typeof navigator>"u"?[]:navigator.languages.length>0?navigator.languages:[navigator.language]}function kc(){try{const e=localStorage.getItem(fu);return e==="de"||e==="en"?e:"auto"}catch{return"auto"}}function xc(e){return e==="auto"?yc():e}function Ec(e,r){return e.replace(/\{(\w+)\}/g,(n,a)=>a in r?String(r[a]):n)}class Tc{#e=z(Lt(kc()));get choice(){return t(this.#e)}set choice(r){w(this.#e,r,!0)}#r=ne(()=>xc(this.choice));get language(){return t(this.#r)}set language(r){w(this.#r,r)}set(r){this.choice=r;try{localStorage.setItem(fu,r)}catch{}}t(r,n){const a=bc[r],i=a===void 0?r:a[this.language];return n===void 0?i:Ec(i,n)}}const di=new Tc;function d(e,r){return di.t(e,r)}var Sc=S('<p class="ui-error-text svelte-12tsuzi"> </p> <div><button type="button" class="ui-button"> </button></div>',1),Cc=S('<p class="ui-error-text svelte-12tsuzi" data-testid="login-error"> </p>'),Ac=S('<form class="svelte-12tsuzi"><label class="ui-form-label svelte-12tsuzi" for="login-password"> </label> <input id="login-password" class="ui-input" type="password" autocomplete="current-password" data-testid="login-password"/> <!> <button type="submit" class="ui-button ui-button-primary" data-testid="login-submit"> </button></form>'),Pc=S('<p class="svelte-12tsuzi"> </p> <div><button type="button" class="ui-button"> </button></div>',1),Nc=S("<option> </option>"),Mc=S('<div class="login svelte-12tsuzi" data-testid="login"><div class="card ui-section svelte-12tsuzi"><div class="brand svelte-12tsuzi">mqtt2matter</div> <!> <select class="ui-select language svelte-12tsuzi"><option> </option><!></select></div></div>');function Rc(e,r){jt(r,!0);let n=z(""),a=z(""),i=z(!1);async function o(C){if(C.preventDefault(),!(t(n)===""||t(i))){w(i,!0),w(a,"");try{await or.login(t(n)),w(n,"")}catch(I){w(a,pt(I),!0)}finally{w(i,!1)}}}var s=Mc(),u=h(s),v=l(h(u),2);{var m=C=>{var I=Sc(),P=Oe(I),O=f(P,!0),ee=l(P,2),R=h(ee),F=f(R,!0);E((D,q)=>{c(O,D),c(F,q)},[()=>d("The bridge does not answer."),()=>d("Try again")]),M("click",R,()=>or.load()),g(C,I)},k=C=>{var I=Ac(),P=h(I),O=f(P,!0),ee=l(P,2),R=l(ee,2);{var F=j=>{var L=Cc(),J=f(L,!0);E(()=>c(J,t(a))),g(j,L)};H(R,j=>{t(a)!==""&&j(F)})}var D=l(R,2),q=f(D,!0);E((j,L)=>{c(O,j),D.disabled=t(n)===""||t(i),c(q,L)},[()=>d("Password"),()=>d("Log in")]),Ua("submit",I,o),Le(ee,()=>t(n),j=>w(n,j)),g(C,I)},y=C=>{var I=Pc(),P=Oe(I),O=f(P,!0),ee=l(P,2),R=h(ee),F=f(R,!0);E((D,q)=>{c(O,D),c(F,q)},[()=>d("This request was not authenticated by the reverse proxy. Open the UI through the proxy."),()=>d("Try again")]),M("click",R,()=>or.load()),g(C,I)};H(v,C=>{or.unreachable?C(m):or.state?.mode==="password"?C(k,1):or.state?.mode==="proxy"&&C(y,2)})}var b=l(v,2),_=h(b),x=f(_,!0);_.value=_.__value="auto";var T=l(_);tt(T,16,()=>cu,C=>C,(C,I)=>{var P=Nc(),O=f(P,!0),ee={};E(()=>{c(O,vu[I]),ee!==(ee=I)&&(P.value=(P.__value=ee)??"")}),g(C,P)});var A;er(b),E((C,I)=>{Q(b,"aria-label",C),c(x,I),A!==(A=di.choice)&&(b.value=(b.__value=A)??"",ka(b,A))},[()=>d("Language"),()=>d("Browser language")]),M("change",b,C=>di.set(C.currentTarget.value)),g(e,s),zt()}lr(["click","change"]);var Ic=ua('<svg viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg>'),Oc=ua('<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"></path><circle cx="12" cy="12" r="3"></circle>',1),Dc=ua('<line x1="18" y1="20" x2="18" y2="10"></line><line x1="12" y1="20" x2="12" y2="4"></line><line x1="6" y1="20" x2="6" y2="14"></line>',1),Lc=ua('<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"></path><polyline points="16 17 21 12 16 7"></polyline><line x1="21" y1="12" x2="9" y2="12"></line>',1),Bc=ua('<polyline points="4 4 4 10 10 10"></polyline><path d="M4 10A9 9 0 1 0 6.5 5"></path>',1),qc=ua('<path d="M18.36 6.64a9 9 0 1 1-12.73 0"></path><line x1="12" y1="2" x2="12" y2="12"></line>',1),Uc=ua('<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><!></svg>');function aa(e,r){let n=gr(r,"size",3,14);var a=Zn(),i=Oe(a);{var o=u=>{var v=Ic();E(()=>{Q(v,"width",n()),Q(v,"height",n())}),g(u,v)},s=u=>{var v=Uc(),m=h(v);{var k=T=>{var A=Oc();g(T,A)},y=T=>{var A=Dc();g(T,A)},b=T=>{var A=Lc();g(T,A)},_=T=>{var A=Bc();g(T,A)},x=T=>{var A=qc();g(T,A)};H(m,T=>{r.name==="gear"?T(k):r.name==="stats"?T(y,1):r.name==="logout"?T(b,2):r.name==="refresh"?T(_,3):r.name==="power"&&T(x,4)})}E(()=>{Q(v,"width",n()),Q(v,"height",n())}),g(u,v)};H(i,u=>{r.name==="github"?u(o):u(s,-1)})}g(e,a)}class Fc{#e=z(void 0);get pending(){return t(this.#e)}set pending(r){w(this.#e,r,!0)}confirm(r,n={}){return new Promise(a=>{this.pending={kind:"confirm",message:r,options:n,resolve:a}})}prompt(r,n={}){return new Promise(a=>{this.pending={kind:"prompt",message:r,options:n,resolve:a}})}settle(r){const n=this.pending;this.pending=void 0,n!==void 0&&(n.kind==="confirm"?n.resolve(r===!0):n.resolve(typeof r=="string"?r:null))}}const rr=new Fc;var jc=S('<button type="button" class="ui-dialog-close svelte-1vv01t1">✕</button>'),zc=S('<div class="ui-dialog-buttons svelte-1vv01t1"><!></div>'),Hc=S('<dialog class="ui-dialog svelte-1vv01t1"><div class="ui-dialog-titlebar svelte-1vv01t1"><span class="ui-dialog-title svelte-1vv01t1"> </span> <!></div> <div class="ui-dialog-body svelte-1vv01t1"><!></div> <!></dialog>');function xa(e,r){jt(r,!0);let n=gr(r,"width",3,"560px"),a=gr(r,"closable",3,!0),i=gr(r,"onclose",3,void 0),o=z(void 0);Br(()=>{t(o)!==void 0&&(r.open&&!t(o).open?t(o).showModal():!r.open&&t(o).open&&t(o).close())});function s(P){P.preventDefault(),a()&&i()?.()}var u=Hc();let v;var m=h(u),k=h(m),y=f(k,!0),b=l(k,2);{var _=P=>{var O=jc();E(ee=>Q(O,"aria-label",ee),[()=>d("Close")]),M("click",O,()=>i()?.()),g(P,O)};H(b,P=>{a()&&P(_)})}var x=l(m,2),T=h(x);{var A=P=>{var O=Zn(),ee=Oe(O);hs(ee,()=>r.children),g(P,O)};H(T,P=>{r.open&&r.children&&P(A)})}var C=l(x,2);{var I=P=>{var O=zc(),ee=h(O);hs(ee,()=>r.buttons),g(P,O)};H(C,P=>{r.buttons&&P(I)})}Ui(u,P=>w(o,P),()=>t(o)),E(()=>{Q(u,"data-testid",r.testId),v=nc(u,"",v,{width:n()}),c(y,r.title)}),Ua("cancel",u,s),Ua("close",u,()=>{r.open&&i()?.()}),g(e,u),zt()}lr(["click"]);var $c=S('<button type="button" class="ui-button"> </button> <button type="button" data-testid="dialog-ok"> </button>',1),Gc=S('<div class="ui-form-help ui-error-text" data-testid="dialog-problem"> </div>'),Vc=S('<input data-testid="dialog-input"/> <!>',1),Kc=S('<p class="message svelte-kd97iv"> </p> <!>',1);function Jc(e,r){jt(r,!0);let n=z(""),a=z(void 0);const i=ne(()=>rr.pending),o=ne(()=>t(i)?.kind!=="prompt"||t(i).options.pattern===void 0||t(i).options.pattern.test(t(n))),s=ne(()=>t(i)?.kind==="prompt"&&t(o)?t(i).options.validate?.(t(n)):void 0),u=ne(()=>t(o)&&t(s)===void 0);Br(()=>{t(i)?.kind==="prompt"&&(w(n,t(i).options.value??"",!0),setTimeout(()=>t(a)?.focus(),0))});function v(){t(i)?.kind==="prompt"?t(u)&&rr.settle(t(n)):rr.settle(!0)}var m=Zn(),k=Oe(m);{var y=b=>{{const _=T=>{var A=$c(),C=Oe(A),I=f(C,!0),P=l(C,2);let O;var ee=f(P,!0);E((R,F)=>{c(I,R),O=Nt(P,1,"ui-button",null,O,{"ui-button-primary":!t(i).options.danger,"ui-button-danger":t(i).options.danger}),P.disabled=!t(u),c(ee,F)},[()=>t(i).options.cancel??d("Cancel"),()=>t(i).options.confirm??d("OK")]),M("click",C,()=>rr.settle(t(i).kind==="prompt"?null:!1)),M("click",P,v),g(T,A)};let x=ne(()=>t(i).options.title??(t(i).kind==="prompt"?d("Input"):d("Confirm")));xa(b,{open:!0,get title(){return t(x)},width:"420px",onclose:()=>rr.settle(t(i).kind==="prompt"?null:!1),get testId(){return`dialog-${t(i).kind??""}`},buttons:_,children:(T,A)=>{var C=Kc(),I=Oe(C),P=f(I,!0),O=l(I,2);{var ee=R=>{var F=Vc(),D=Oe(F);let q;Ui(D,J=>w(a,J),()=>t(a));var j=l(D,2);{var L=J=>{var U=Gc(),W=f(U,!0);E(()=>c(W,t(s))),g(J,U)};H(j,J=>{t(s)!==void 0&&J(L)})}E(()=>{q=Nt(D,1,"ui-input",null,q,{"ui-invalid":!t(u)}),Q(D,"placeholder",t(i).options.placeholder??"")}),M("keydown",D,J=>{J.key==="Enter"&&v()}),Le(D,()=>t(n),J=>w(n,J)),g(R,F)};H(O,R=>{t(i).kind==="prompt"&&R(ee)})}E(()=>c(P,t(i).message)),g(T,C)},$$slots:{buttons:!0,default:!0}})}};H(k,b=>{t(i)&&b(y)})}g(e,m),zt()}lr(["click","keydown"]);var Wc=S('<p class="svelte-9byitx"><a target="_blank" rel="noopener"> </a></p>'),Qc=S('<pre class="ui-pre svelte-9byitx"> </pre>'),Yc=S('<p class="ui-muted svelte-9byitx"> </p>'),Zc=S('<details data-testid="license-package" class="svelte-9byitx"><summary class="svelte-9byitx"><span class="name svelte-9byitx"> </span> <span class="ui-faint"> </span> <span class="ui-badge"> </span></summary> <!> <!></details>'),Xc=S('<section class="svelte-9byitx"><h3 class="svelte-9byitx"> <span class="ui-faint"> </span></h3> <!></section>'),ev=S('<section class="own svelte-9byitx" data-testid="licenses-self"><h3 class="svelte-9byitx"> <span data-testid="licenses-self-license"> </span></h3> <details class="svelte-9byitx"><summary class="svelte-9byitx">LICENSE</summary> <pre class="ui-pre svelte-9byitx"> </pre></details> <details class="svelte-9byitx"><summary class="svelte-9byitx">NOTICE</summary> <pre class="ui-pre svelte-9byitx"> </pre></details></section> <!>',1),tv=S('<p class="ui-warn-text"> </p>'),rv=S('<p class="ui-faint"> </p>');function nv(e,r){jt(r,!0);let n=z(void 0),a=z(void 0);Br(()=>{r.open&&t(n)===void 0&&fetch("licenses.json").then(async o=>{if(!o.ok)throw new Error(`${o.status} ${o.statusText}`);w(n,await o.json(),!0),w(a,void 0)}).catch(o=>{w(a,pt(o),!0)})});const i=ne(()=>t(n)===void 0?[]:[{id:"runtime",title:d("Runtime dependencies"),packages:t(n).runtime},{id:"ui",title:d("User interface"),packages:t(n).ui}]);{let o=ne(()=>d("Licences"));xa(e,{get open(){return r.open},get title(){return t(o)},width:"720px",get onclose(){return r.onclose},testId:"licenses",children:(s,u)=>{var v=Zn(),m=Oe(v);{var k=_=>{var x=ev(),T=Oe(x),A=h(T),C=h(A),I=l(C),P=f(I,!0),O=l(A,2),ee=l(h(O),2),R=f(ee,!0),F=l(O,2),D=l(h(F),2),q=f(D,!0),j=l(T,2);tt(j,17,()=>t(i),L=>L.id,(L,J)=>{var U=Xc(),W=h(U),he=h(W),Ce=l(he),rt=f(Ce),ae=l(W,2);tt(ae,17,()=>t(J).packages,de=>`${de.name}@${de.version}`,(de,fe)=>{var Fe=Zc(),$e=h(Fe),$=h($e),te=f($,!0),B=l($,2),Y=f(B,!0),X=l(B,2),ie=f(X,!0),re=l($e,2);{var ce=xe=>{var Ae=Wc(),V=h(Ae),me=f(V,!0);E(()=>{Q(V,"href",t(fe).repository),c(me,t(fe).repository)}),g(xe,Ae)};H(re,xe=>{t(fe).repository&&xe(ce)})}var Z=l(re,2);{var ue=xe=>{var Ae=Qc(),V=f(Ae,!0);E(()=>c(V,t(fe).text)),g(xe,Ae)},Ee=xe=>{var Ae=Yc(),V=f(Ae,!0);E(me=>c(V,me),[()=>d("The package has no licence file; its package.json names {license}.",{license:t(fe).license})]),g(xe,Ae)};H(Z,xe=>{t(fe).text?xe(ue):xe(Ee,-1)})}E(()=>{c(te,t(fe).name),c(Y,t(fe).version),c(ie,t(fe).license)}),g(de,Fe)}),E(()=>{Q(U,"data-testid",`licenses-${t(J).id??""}`),c(he,`${t(J).title??""} `),c(rt,`(${t(J).packages.length??""})`)}),g(L,U)}),E(()=>{c(C,`${t(n).self.name??""} ${t(n).self.version??""} · `),c(P,t(n).self.license),c(R,t(n).self.text),c(q,t(n).self.notice)}),g(_,x)},y=_=>{var x=tv(),T=f(x,!0);E(A=>c(T,A),[()=>d("The licence list could not be loaded: {error}",{error:t(a)})]),g(_,x)},b=_=>{var x=rv(),T=f(x,!0);E(A=>c(T,A),[()=>d("Loading…")]),g(_,x)};H(m,_=>{t(n)?_(k):t(a)?_(y,1):_(b,-1)})}g(s,v)},$$slots:{default:!0}})}zt()}const ys=4;let av=class{#e=z(Lt([]));get list(){return t(this.#e)}set list(r){w(this.#e,r,!0)}next=1;push(r,n){const a=this.next++;return this.list=[...this.list,{id:a,level:r,message:n}],r!=="error"&&setTimeout(()=>{this.dismiss(a)},6e3),a}info(r){this.push("info",r)}warn(r){this.push("warn",r)}error(r){this.push("error",r)}dismiss(r){this.list=this.list.filter(n=>n.id!==r)}};const Ue=new av;var iv=S('<button type="button" class="more svelte-1cnh99m"> </button>'),ov=S('<div data-testid="notice"><span class="text svelte-1cnh99m"> </span> <button type="button" class="close svelte-1cnh99m">✕</button></div>'),sv=S('<div class="notices svelte-1cnh99m" role="log" aria-live="polite" data-testid="notices"><!> <!></div>');function lv(e,r){jt(r,!0);let n=z(!1);const a=ne(()=>Ue.list),i=ne(()=>Math.max(0,t(a).length-ys)),o=ne(()=>t(n)?t(a):t(a).slice(Math.max(0,t(a).length-ys)));Br(()=>{t(i)===0&&t(n)&&w(n,!1)});var s=sv(),u=h(s);{var v=k=>{var y=iv(),b=f(y,!0);E(_=>c(b,_),[()=>t(n)?d("Show fewer"):d("{count} more",{count:t(i)})]),M("click",y,()=>w(n,!t(n))),g(k,y)};H(u,k=>{t(i)>0&&k(v)})}var m=l(u,2);tt(m,17,()=>t(o),k=>k.id,(k,y)=>{var b=ov();let _;var x=h(b),T=f(x,!0),A=l(x,2);E(C=>{_=Nt(b,1,"notice svelte-1cnh99m",null,_,{warn:t(y).level==="warn",error:t(y).level==="error"}),c(T,t(y).message),Q(A,"aria-label",C)},[()=>d("Dismiss")]),M("click",A,()=>Ue.dismiss(t(y).id)),g(k,b)}),g(e,s),zt()}lr(["click"]);var uv=S('<dl class="ui-kv"><dt> </dt> <dd data-testid="stats-uptime"> </dd> <dt> </dt> <dd data-testid="stats-devices"> </dd> <dt> </dt> <dd data-testid="stats-endpoints"> </dd> <dt> </dt> <dd data-testid="stats-bridges"> </dd> <dt> </dt> <dd data-testid="stats-fabrics"> </dd> <dt> </dt> <dd data-testid="stats-topics"> </dd> <dt> </dt> <dd data-testid="stats-rate"> </dd> <dt> </dt> <dd data-testid="stats-memory"> </dd> <dt> </dt> <dd> </dd> <dt>CPU</dt> <dd data-testid="stats-cpu"> </dd> <dt> </dt> <dd data-testid="stats-elu"> </dd> <dt> </dt> <dd data-testid="stats-lag-mean"> </dd> <dt> </dt> <dd data-testid="stats-lag-max"> </dd></dl> <p class="ui-faint note svelte-qffmqt"> </p>',1),dv=S('<p class="ui-warn-text note svelte-qffmqt"> </p>'),cv=S('<p class="ui-faint note svelte-qffmqt"> </p>'),vv=S('<div class="ui-popup" data-testid="stats"><!></div>'),fv=S('<div class="ui-popup-anchor"><button type="button" class="ui-bar-button" aria-haspopup="true" data-testid="stats-button"><!></button> <!></div>');function pv(e,r){jt(r,!0);let n=z(void 0),a=z(!1);async function i(){try{w(n,await He.stats(),!0),w(a,!1)}catch{w(a,!0)}}Br(()=>{if(!r.open)return;i();const y=setInterval(()=>{i()},5e3);return()=>{clearInterval(y)}});function o(y){const b=Math.floor(y/86400),_=Math.floor(y%86400/3600),x=Math.floor(y%3600/60);return`${b>0?`${b}d `:""}${b>0||_>0?`${_}h `:""}${x}m`}var s=fv(),u=h(s),v=h(u);aa(v,{name:"stats"});var m=l(u,2);{var k=y=>{var b=vv(),_=h(b);{var x=C=>{var I=uv(),P=Oe(I),O=h(P),ee=f(O,!0),R=l(O,2),F=f(R,!0),D=l(R,2),q=f(D,!0),j=l(D,2),L=f(j,!0),J=l(j,2),U=f(J,!0),W=l(J,2),he=f(W,!0),Ce=l(W,2),rt=f(Ce,!0),ae=l(Ce,2),de=f(ae),fe=l(ae,2),Fe=f(fe,!0),$e=l(fe,2),$=f($e,!0),te=l($e,2),B=f(te,!0),Y=l(te,2),X=f(Y,!0),ie=l(Y,2),re=f(ie,!0),ce=l(ie,2),Z=f(ce,!0),ue=l(ce,2),Ee=f(ue,!0),xe=l(ue,2),Ae=f(xe),V=l(xe,2),me=f(V,!0),Se=l(V,2),Ge=f(Se),se=l(Se,4),_e=f(se),Te=l(se,2),le=f(Te,!0),Je=l(Te,2),Ye=f(Je),mt=l(Je,2),_t=f(mt,!0),yt=l(mt,2),Ne=f(yt),ke=l(yt,2),Be=f(ke,!0),Ze=l(ke,2),wt=f(Ze),N=l(P,2),K=f(N,!0);E((G,ve,qe,at,ge,pe,be,De,Ve,dt,ht,it,At,Mt,We)=>{c(ee,G),c(F,ve),c(q,qe),c(L,t(n).devices),c(U,at),c(he,t(n).endpoints),c(rt,ge),c(de,`${t(n).bridgesCommissioned??""} / ${t(n).bridges??""} ${pe??""}`),c(Fe,be),c($,t(n).fabrics),c(B,De),c(X,t(n).mqttTopics),c(re,Ve),c(Z,t(n).mqttMessagesPerSecond),c(Ee,dt),c(Ae,`${t(n).memoryMb??""} MB`),c(me,ht),c(Ge,`${t(n).heapMb??""} MB`),c(_e,`${t(n).cpuPercent??""} %`),c(le,it),c(Ye,`${t(n).eluPercent??""} %`),c(_t,At),c(Ne,`${t(n).lagMeanMs??""} ms`),c(Be,Mt),c(wt,`${t(n).lagMaxMs??""} ms`),c(K,We)},[()=>d("Uptime"),()=>o(t(n).uptime),()=>d("Devices"),()=>d("Endpoints"),()=>d("Bridges"),()=>d("paired"),()=>d("Controllers (fabrics)"),()=>d("MQTT topics"),()=>d("MQTT msg/s"),()=>d("Memory (RSS)"),()=>d("Heap"),()=>d("Event loop utilisation"),()=>d("Event loop lag mean"),()=>d("Event loop lag max"),()=>d("Averages over the last {seconds} s",{seconds:t(n).window})]),g(C,I)},T=C=>{var I=dv(),P=f(I,!0);E(O=>c(P,O),[()=>d("Not reachable")]),g(C,I)},A=C=>{var I=cv(),P=f(I,!0);E(O=>c(P,O),[()=>d("Loading…")]),g(C,I)};H(_,C=>{t(n)?C(x):t(a)?C(T,1):C(A,-1)})}M("click",b,C=>C.stopPropagation()),g(y,b)};H(m,y=>{r.open&&y(k)})}E((y,b)=>{Q(u,"aria-expanded",r.open),Q(u,"aria-label",y),Q(u,"title",b)},[()=>d("Statistics"),()=>d("Statistics")]),M("click",u,y=>{y.stopPropagation(),r.ontoggle()}),g(e,s),zt()}lr(["click"]);var hv=S("<span></span>"),mv=S('<span class="ui-tab-badge svelte-1p26yap"> </span>'),_v=S('<button type="button" role="tab"><!> <span> </span> <!></button>'),gv=S('<div class="ui-tabs svelte-1p26yap" role="tablist"></div>');function bv(e,r){jt(r,!0);let n=gr(r,"label",3,"Pages"),a=gr(r,"onselect",3,void 0);function i(s,u){const v=s.key==="ArrowRight"?1:s.key==="ArrowLeft"?-1:0;if(v===0)return;s.preventDefault();const m=r.tabs[(u+v+r.tabs.length)%r.tabs.length];m!==void 0&&(a()?.(m.id),s.currentTarget.parentElement?.querySelector(`#tab-${m.id}`)?.focus())}var o=gv();tt(o,23,()=>r.tabs,s=>s.id,(s,u,v)=>{var m=_v();let k;var y=h(m);{var b=C=>{var I=hv();E(()=>Nt(I,1,`ui-dot ui-dot-${t(u).dot??""}`,"svelte-1p26yap")),g(C,I)};H(y,C=>{t(u).dot!==void 0&&t(u).dot!=="none"&&C(b)})}var _=l(y,2),x=f(_,!0),T=l(_,2);{var A=C=>{var I=mv(),P=f(I,!0);E(()=>c(P,t(u).badge)),g(C,I)};H(T,C=>{t(u).badge!==void 0&&t(u).badge!==""&&C(A)})}E(()=>{k=Nt(m,1,"ui-tab svelte-1p26yap",null,k,{"ui-tab-active":t(u).id===r.active}),Q(m,"id",`tab-${t(u).id??""}`),Q(m,"aria-selected",t(u).id===r.active),Q(m,"tabindex",t(u).id===r.active?0:-1),Q(m,"data-testid",`tab-${t(u).id??""}`),c(x,t(u).label)}),M("click",m,()=>a()?.(t(u).id)),M("keydown",m,C=>i(C,t(v))),g(s,m)}),E(()=>Q(o,"aria-label",n())),g(e,o),zt()}lr(["click","keydown"]);var yv=S('<span class="ui-update-dot" data-testid="update-dot"></span>'),wv=S('<span class="ui-spinning spin svelte-1af60h4" aria-hidden="true"><!></span>'),kv=S('<span class="ui-faint"> </span>'),xv=S("<span> </span> <!>",1),Ev=S('<p class="ui-warn-text svelte-1af60h4"> </p>'),ws=S('<p class="ui-muted reason svelte-1af60h4"> </p>'),Tv=S('<button type="button" class="ui-popup-primary" data-testid="update"><!> </button> <!>',1),Sv=S('<p class="ui-warn-text svelte-1af60h4" data-testid="waiting"> </p>'),Cv=S('<pre class="ui-pre log svelte-1af60h4" data-testid="update-log"> </pre>'),Av=S('<div class="ui-popup" data-testid="version"><dl class="ui-kv"><dt> </dt> <dd data-testid="version-current"> </dd> <dt> </dt> <dd data-testid="version-latest"><!></dd></dl> <!> <div class="ui-popup-actions"><!> <button type="button" data-testid="check-update"><span><!></span> </button> <button type="button" data-testid="restart"><!> </button> <!></div> <!> <!></div>'),Pv=S('<div class="ui-popup-anchor"><button type="button" class="ui-bar-button version svelte-1af60h4" aria-haspopup="true" data-testid="version-button"> <!> <!></button> <!></div>');function Nv(e,r){jt(r,!0);let n=gr(r,"onchange",3,void 0),a=z(void 0),i=z(!1),o=z(void 0),s;async function u(R=!1){try{w(a,await He.updateStatus(R),!0)}catch(F){t(o)===void 0&&Ue.error(pt(F))}}Br(()=>{r.open&&u()}),pc(()=>{s!==void 0&&clearInterval(s)});function v(){w(o,t(a)?.current??r.version,!0);let R=!1;const F=Date.now();s!==void 0&&clearInterval(s),s=setInterval(()=>{He.updateStatus().then(D=>{w(a,D,!0);const q=t(o)!==void 0&&D.current!==t(o);(q||R&&D.update.requested===void 0)&&(clearInterval(s),s=void 0,w(o,void 0),Ue.info(d("mqtt2matter {version} is running.",{version:D.current})),q&&window.location.reload())},()=>{R=!0}),Date.now()-F>900*1e3&&(clearInterval(s),s=void 0,w(o,void 0))},2e3)}async function m(){w(i,!0),await u(!0),w(i,!1),n()?.()}async function k(){const R=t(a)?.latest;if(!(R===void 0||!await rr.confirm(d("Install mqtt2matter {version} and restart? The bridge is offline for a moment; the pairings stay.",{version:R}),{confirm:d("Update")})))try{await He.requestUpdate(R),Ue.info(d("Update to {version} requested.",{version:R})),await u(),v(),n()?.()}catch(D){Ue.error(pt(D))}}async function y(){if(await rr.confirm(d("Restart mqtt2matter? The bridge is offline for a moment."),{confirm:d("Restart")}))try{await He.restart(),Ue.info(d("Restarting…")),v()}catch(F){Ue.error(pt(F))}}const b=ne(()=>t(a)?.newer??r.newer);var _=Pv(),x=h(_),T=h(x),A=l(T);{var C=R=>{var F=yv();E(D=>Q(F,"title",D),[()=>d("Update available")]),g(R,F)};H(A,R=>{t(b)&&R(C)})}var I=l(A,2);{var P=R=>{var F=wv(),D=h(F);aa(D,{name:"refresh",size:11}),g(R,F)};H(I,R=>{t(o)!==void 0&&R(P)})}var O=l(x,2);{var ee=R=>{var F=Av(),D=h(F),q=h(D),j=f(q,!0),L=l(q,2),J=f(L,!0),U=l(L,2),W=f(U,!0),he=l(U,2),Ce=h(he);{var rt=se=>{var _e=ma("…");g(se,_e)},ae=se=>{var _e=ma();E(Te=>c(_e,Te),[()=>d("not published on npm yet")]),g(se,_e)},de=se=>{var _e=xv(),Te=Oe(_e);let le;var Je=f(Te,!0),Ye=l(Te,2);{var mt=_t=>{var yt=kv(),Ne=f(yt);E(ke=>c(Ne,`· ${ke??""}`),[()=>d("up to date")]),g(_t,yt)};H(Ye,_t=>{t(a).newer||_t(mt)})}E(()=>{le=Nt(Te,1,"svelte-1af60h4",null,le,{newer:t(a).newer}),c(Je,t(a).latest)}),g(se,_e)},fe=se=>{var _e=ma("—");g(se,_e)};H(Ce,se=>{t(a)===void 0?se(rt):t(a).published===!1?se(ae,1):t(a).latest!==void 0?se(de,2):se(fe,-1)})}var Fe=l(D,2);{var $e=se=>{var _e=Ev(),Te=f(_e,!0);E(()=>c(Te,t(a).error)),g(se,_e)};H(Fe,se=>{t(a)?.error&&se($e)})}var $=l(Fe,2),te=h($);{var B=se=>{var _e=Tv(),Te=Oe(_e),le=h(Te);aa(le,{name:"refresh",size:12});var Je=l(le),Ye=l(Te,2);{var mt=_t=>{var yt=ws(),Ne=f(yt,!0);E(()=>c(Ne,t(a).update.reason)),g(_t,yt)};H(Ye,_t=>{!t(a).update.available&&t(a).update.reason&&_t(mt)})}E(_t=>{Te.disabled=!t(a).update.available||t(o)!==void 0,Q(Te,"title",t(a).update.reason??""),c(Je,` ${_t??""}`)},[()=>d("Update to {version}",{version:t(a).latest})]),M("click",Te,k),g(se,_e)};H(te,se=>{t(a)?.newer&&t(a).latest!==void 0&&se(B)})}var Y=l(te,2),X=h(Y);let ie;var re=h(X);aa(re,{name:"refresh",size:11});var ce=l(X),Z=l(Y,2),ue=h(Z);aa(ue,{name:"power",size:12});var Ee=l(ue),xe=l(Z,2);{var Ae=se=>{var _e=ws(),Te=f(_e,!0);E(()=>c(Te,t(a).restart.reason)),g(se,_e)};H(xe,se=>{t(a)!==void 0&&!t(a).restart.available&&t(a).restart.reason&&se(Ae)})}var V=l($,2);{var me=se=>{var _e=Sv(),Te=f(_e,!0);E(le=>c(Te,le),[()=>d("Waiting for mqtt2matter to come back…")]),g(se,_e)};H(V,se=>{t(o)!==void 0&&se(me)})}var Se=l(V,2);{var Ge=se=>{var _e=Cv(),Te=f(_e,!0);E(le=>c(Te,le),[()=>t(a).update.log.join(`
3
+ `)]),g(se,_e)};H(Se,se=>{t(a)!==void 0&&t(a).update.log.length>0&&se(Ge)})}E((se,_e,Te,le)=>{c(j,se),c(J,t(a)?.current??r.version),c(W,_e),Y.disabled=t(i),ie=Nt(X,1,"spin svelte-1af60h4",null,ie,{"ui-spinning":t(i)}),c(ce,` ${Te??""}`),Z.disabled=t(a)===void 0||!t(a).restart.available||t(o)!==void 0,Q(Z,"title",t(a)?.restart.reason??""),c(Ee,` ${le??""}`)},[()=>d("Installed"),()=>d("Latest"),()=>t(i)?d("Checking…"):d("Check for updates"),()=>d("Restart")]),M("click",F,se=>se.stopPropagation()),M("click",Y,m),M("click",Z,y),g(R,F)};H(O,R=>{r.open&&R(ee)})}E(R=>{Q(x,"aria-expanded",r.open),Q(x,"title",R),c(T,`v${r.version??""} `)},[()=>d("Version")]),M("click",x,R=>{R.stopPropagation(),r.ontoggle()}),g(e,_),zt()}lr(["click"]);class Mv{#e=z(!1);get connected(){return t(this.#e)}set connected(r){w(this.#e,r,!0)}#r=z(void 0);get mqttConnected(){return t(this.#r)}set mqttConnected(r){w(this.#r,r,!0)}#t=z("");get version(){return t(this.#t)}set version(r){w(this.#t,r,!0)}socket;listeners=new Set;mqttWanted=0;retry;start(){if(this.socket!==void 0||typeof WebSocket>"u")return;const r=`${location.protocol==="https:"?"wss":"ws"}://${location.host}/api/events`,n=new WebSocket(r);this.socket=n,n.onopen=()=>{this.connected=!0,this.sendSubscription()},n.onmessage=a=>{let i;try{i=JSON.parse(String(a.data))}catch{return}i.type==="hello"?this.version=i.version:i.type==="status"&&(this.mqttConnected=i.mqtt);for(const o of this.listeners)o(i)},n.onclose=()=>{this.connected=!1,this.socket=void 0,this.retry=setTimeout(()=>{this.start()},2e3)},n.onerror=()=>{n.close()}}stop(){this.retry!==void 0&&clearTimeout(this.retry),this.socket?.close(),this.socket=void 0}on(r){return this.listeners.add(r),()=>{this.listeners.delete(r)}}wantMqtt(){return this.mqttWanted++,this.sendSubscription(),()=>{this.mqttWanted--,this.sendSubscription()}}sendSubscription(){this.socket?.readyState===WebSocket.OPEN&&this.socket.send(JSON.stringify({type:"subscribe",mqtt:this.mqttWanted>0}))}}const Er=new Mv,Rv=["devices","presets","adopt","bridges","mqtt","log","check","config"];function Zi(e){const r=e.replace(/^#\/?/,""),[n,...a]=r.split("/"),i=Rv.includes(n??"")?n:"devices",o=a.map(s=>{try{return decodeURIComponent(s)}catch{return s}}).join("/");return{page:i,rest:i===(n??"")?o:""}}function Iv(e,r=""){return r===""?`#/${e}`:`#/${e}/${r.split("/").map(encodeURIComponent).join("/")}`}class Ov{#e=z(Lt(Zi(typeof location>"u"?"":location.hash)));get route(){return t(this.#e)}set route(r){w(this.#e,r,!0)}constructor(){typeof window<"u"&&window.addEventListener("hashchange",()=>{this.route=Zi(location.hash)})}go(r,n=""){const a=Iv(r,n);location.hash===a?this.route=Zi(a):location.hash=a}}const Xr=new Ov;var Dv=ua('<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path></path></svg>');function cn(e,r){let n=gr(r,"size",3,14);const a={pause:"M6 4h3v16H6zM15 4h3v16h-3z",play:"M7 4l12 8-12 8z",copy:"M8 8h12v12H8zM4 4h12v2H6v10H4z",download:"M11 3h2v10.2l3.6-3.6 1.4 1.4-6 6-6-6 1.4-1.4L11 13.2zM4 19h16v2H4z",trash:"M9 3h6v2h5v2H4V5h5zM6 8h12l-1 13H7zM10 10v9h1.5v-9zm2.5 0v9H14v-9z",info:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm0 2a8 8 0 1 1 0 16 8 8 0 0 1 0-16zm-1 3h2v2h-2zm0 4h2v6h-2z",close:"M5.6 4.2 12 10.6l6.4-6.4 1.4 1.4-6.4 6.4 6.4 6.4-1.4 1.4-6.4-6.4-6.4 6.4-1.4-1.4 6.4-6.4-6.4-6.4z"};var i=Dv(),o=f(i);E(()=>{Q(i,"width",n()),Q(i,"height",n()),Q(o,"d",a[r.name])}),g(e,i)}function oi(e){const r=typeof e=="number"?new Date(e):new Date(e);return Number.isNaN(r.getTime())?String(e):r.toLocaleTimeString(void 0,{hour12:!1})}function Lv(e){const r=new Date(e);return Number.isNaN(r.getTime())?String(e):`${r.toLocaleDateString()} ${r.toLocaleTimeString(void 0,{hour12:!1})}`}function ja(e){return e===void 0?"":e===null?"null":typeof e=="object"?JSON.stringify(e):typeof e=="number"&&!Number.isInteger(e)?String(Number(e.toFixed(6))):String(e)}function ci(e){try{return JSON.parse(e)}catch{return}}function vn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Uo(e,r="$"){return vn(e)?Object.entries(e).flatMap(([n,a])=>Uo(a,/^[A-Za-z_][A-Za-z0-9_]*$/.test(n)?`${r}.${n}`:`${r}["${n}"]`)):Array.isArray(e)?e.flatMap((n,a)=>Uo(n,`${r}[${a}]`)):r==="$"?[]:[{path:r,value:e}]}function Jn(e){return JSON.stringify(e,null,2)??""}function Fo(e,r){let n;return(...a)=>{n!==void 0&&clearTimeout(n),n=setTimeout(()=>{n=void 0,e(...a)},r)}}function rs(e,r){const n=new Blob([r],{type:"application/json"}),a=URL.createObjectURL(n),i=document.createElement("a");i.href=a,i.download=e,i.click(),setTimeout(()=>{URL.revokeObjectURL(a)},1e3)}var ks=S('<div class="ui-empty"> </div>'),Bv=S('<span class="ui-badge group svelte-izwxip"> </span>'),qv=S('<span class="ui-badge native svelte-izwxip"> </span>'),Uv=S('<span class="ui-badge ui-badge-warn"> </span>'),xs=S('<span class="ui-badge"> </span>'),Es=S('<button type="button" class="ui-button" data-testid="adopt"> </button>'),Fv=S('<button type="button" class="ui-button" data-testid="update"> </button>'),jv=S('<button type="button" class="ui-button"> </button> <button type="button" class="ui-button ui-button-danger" data-testid="remove-orphan"> </button>',1),Ts=S('<button type="button" class="ui-button"> </button>'),zv=S('<tr data-testid="adopt-row"><td><span> </span></td><td> <!></td><td> <!></td><td data-testid="adopt-area"> </td><td><code> </code></td><td class="notes svelte-izwxip"><!> <!> <!> <span class="ui-muted"> </span></td><td class="ui-actions"><button type="button" class="ui-icon-button" data-testid="show-details"><!></button> <!></td></tr>'),Hv=S('<table class="ui-table" data-testid="adopt-table"><thead><tr><th> </th><th> </th><th> </th><th> </th><th> </th><th> </th><th></th></tr></thead><tbody></tbody></table>'),$v=S('<button type="button" class="ui-button ui-button-primary"> </button>'),Gv=S('<button type="button" class="ui-button"> </button> <!>',1),wi=S("<dt> </dt> <dd> </dd>",1),Ss=S("<dt> </dt> <dd><code> </code></dd>",1),Vv=S('<tr><td><code> </code></td><td class="ui-ok-text"><code> </code></td><td class="ui-warn-text"><code> </code></td></tr>'),Kv=S('<h3> </h3> <p class="ui-muted svelte-izwxip"> </p> <table class="ui-table"><thead><tr><th> </th><th> </th><th> </th></tr></thead><tbody></tbody></table>',1),Jv=S('<dl class="ui-kv"><dt> </dt> <dd> </dd> <dt> </dt> <dd><code> </code></dd> <!> <!> <!> <!> <!> <!></dl> <!>',1),Wv=S('<div class="ui-page" data-testid="adopt-page"><div class="ui-toolbar"><button type="button" class="ui-button" data-testid="resync"> </button> <button type="button" class="ui-button ui-button-primary"> </button> <input class="ui-input filter svelte-izwxip"/> <label class="ui-check"><input type="checkbox"/> </label> <div class="ui-toolbar-trailing"> </div></div> <div class="ui-page-scroll"><!></div></div> <!>',1);function Qv(e,r){jt(r,!0);let n=z(Lt([])),a=z(Lt([])),i=z(!1),o=z(!1),s=z(""),u=z(!1),v=z(void 0);const m={new:0,updated:1,restored:1,orphaned:2,invalid:3,covered:4,unchanged:5,unsupported:6},k=ne(()=>{const B=t(s).trim().toLowerCase();return t(a).filter(Y=>t(u)||Y.status!=="unsupported").filter(Y=>B===""||`${Y.name} ${Y.key} ${Y.area??""} ${Y.notes.join(" ")}`.toLowerCase().includes(B)).sort((Y,X)=>m[Y.status]-m[X.status]||Y.name.localeCompare(X.name))}),y=ne(()=>{const B={};for(const Y of t(a))B[Y.status]=(B[Y.status]??0)+1;return B});async function b(){try{const B=await He.adopt();w(n,B.importers,!0),w(a,B.entries,!0),w(i,!0)}catch(B){Ue.error(pt(B))}}en(()=>(b(),Er.on(B=>{(B.type==="discovered"||B.type==="devices")&&b()})));async function _(){const B=t(a).filter(X=>X.status==="updated"||X.status==="restored"||X.status==="orphaned");if(await rr.confirm(d("Re-sync every adopted device? {count} entries change: updated ones take the new description (your edits are kept, conflicts reported), orphans are marked.",{count:B.length}),{confirm:d("Re-sync")})){w(o,!0);try{const X=await He.resync();w(n,X.importers,!0),w(a,X.entries,!0),Ue.info(d("{count} devices written",{count:X.written.length}))}catch(X){Ue.error(pt(X))}finally{w(o,!1)}}}async function x(B){const Y=B.twins??[];if(B.native===void 0&&Y.length>0)return await rr.confirm(d("{name} is already adopted as {key}. Replace it: the native description is adopted and {key} is disabled — it stays in the configuration until you delete it. Controllers see a new device.",{name:B.name,key:Y.join(", ")}),{confirm:d("Replace")})?{force:!0,replace:!0}:void 0;const X=B.covered??B.native??"";return await rr.confirm(d("{name} is the same device as {key}, which {source} describes natively. Adopting it here makes a second Matter device for one device: controllers show it twice. Adopt it anyway?",{name:B.name,key:X,source:P(X.split(":")[0]??"")}),{confirm:d("Adopt anyway"),danger:!0})?{force:!0,replace:!1}:void 0}async function T(B){let Y={};if(B.status==="covered"){const X=await x(B);if(X===void 0)return;Y=X}if(!((B.status==="updated"||B.status==="restored")&&!await rr.confirm(B.conflicts.length>0?d("Update {name}? {count} of your edits conflict with the new description; your edits win, the conflicts are listed in the details.",{name:B.name,count:B.conflicts.length}):d("Update {name} from the source? Your own edits are kept.",{name:B.name}),{confirm:d("Update")})))try{const X=await He.adoptDevice(B.importer,B.key,Y);Ue.info(d("{name} adopted as {key}",{name:B.name,key:X.key})),w(v,void 0),await b()}catch(X){Ue.error(pt(X))}}async function A(){const B=t(a).filter(Y=>Y.status==="new");if(await rr.confirm(d("Adopt {count} new devices?",{count:B.length}),{confirm:d("Adopt")})){w(o,!0);for(const Y of B)try{await He.adoptDevice(Y.importer,Y.key)}catch(X){Ue.error(`${Y.name}: ${pt(X)}`)}w(o,!1),await b()}}async function C(B){if(await rr.confirm(d("Delete {name}? Controllers lose the device, its rooms and automations.",{name:B.name}),{confirm:d("Delete"),danger:!0}))try{await He.deleteDevice(B.key),await b()}catch(X){Ue.error(pt(X))}}function I(B){return{new:d("new"),unchanged:d("adopted"),updated:d("changed"),restored:d("back again"),orphaned:d("orphaned"),invalid:d("invalid"),unsupported:d("unsupported"),covered:d("duplicate")}[B]}function P(B){return{z2m:"Zigbee2MQTT","ha-discovery":"HA discovery"}[B]??B}function O(B){switch(B){case"new":return"ui-badge-accent";case"unchanged":return"ui-badge-ok";case"updated":case"restored":case"orphaned":return"ui-badge-warn";case"invalid":return"ui-badge-error";default:return""}}var ee=Wv(),R=Oe(ee),F=h(R),D=h(F),q=f(D,!0),j=l(D,2),L=f(j,!0),J=l(j,2),U=l(J,2),W=h(U),he=l(W),Ce=l(U,2),rt=f(Ce),ae=l(F,2),de=h(ae);{var fe=B=>{var Y=ks(),X=f(Y,!0);E(ie=>c(X,ie),[()=>d("No importer is configured. Discovered devices from Zigbee2MQTT and Home Assistant discovery appear here.")]),g(B,Y)},Fe=B=>{var Y=ks(),X=f(Y,!0);E(ie=>c(X,ie),[()=>d("Nothing discovered yet. Zigbee2MQTT publishes its devices on <base>/bridge/devices, Home Assistant discovery under <prefix>/; the bridge subscribes both.")]),g(B,Y)},$e=B=>{var Y=Hv(),X=h(Y),ie=h(X),re=h(ie),ce=f(re,!0),Z=l(re),ue=f(Z,!0),Ee=l(Z),xe=f(Ee,!0),Ae=l(Ee),V=f(Ae,!0),me=l(Ae),Se=f(me,!0),Ge=l(me),se=f(Ge,!0),_e=l(X);tt(_e,21,()=>t(k),Te=>`${Te.importer}/${Te.key}`,(Te,le)=>{var Je=zv(),Ye=h(Je),mt=h(Ye),_t=f(mt,!0),yt=l(Ye),Ne=h(yt),ke=l(Ne);{var Be=Re=>{var Ie=Bv(),vt=f(Ie,!0);E(ot=>c(vt,ot),[()=>d("group")]),g(Re,Ie)};H(ke,Re=>{t(le).kind==="group"&&Re(Be)})}var Ze=l(yt),wt=h(Ze),N=l(wt);{var K=Re=>{var Ie=qv(),vt=f(Ie,!0);E((ot,$t)=>{Q(Ie,"title",ot),c(vt,$t)},[()=>d("Also described natively by {source} as {key}; the native description is preferred.",{source:P(t(le).native.split(":")[0]??""),key:t(le).native}),()=>d("native: {source}",{source:P(t(le).native.split(":")[0]??"")})]),g(Re,Ie)};H(N,Re=>{t(le).native!==void 0&&Re(K)})}var G=l(Ze),ve=f(G,!0),qe=l(G),at=h(qe),ge=f(at,!0),pe=l(qe),be=h(pe);{var De=Re=>{var Ie=Uv(),vt=f(Ie,!0);E(ot=>c(vt,ot),[()=>d("{count} conflicts",{count:t(le).conflicts.length})]),g(Re,Ie)};H(be,Re=>{t(le).conflicts.length>0&&Re(De)})}var Ve=l(be,2);{var dt=Re=>{var Ie=xs(),vt=f(Ie,!0);E(ot=>c(vt,ot),[()=>d("{count} edits",{count:t(le).edits})]),g(Re,Ie)};H(Ve,Re=>{t(le).edits>0&&Re(dt)})}var ht=l(Ve,2);{var it=Re=>{var Ie=xs(),vt=f(Ie,!0);E((ot,$t)=>{Q(Ie,"title",ot),c(vt,$t)},[()=>t(le).unmapped.join(", "),()=>d("{count} unmapped",{count:t(le).unmapped.length})]),g(Re,Ie)};H(ht,Re=>{t(le).unmapped.length>0&&Re(it)})}var At=l(ht,2),Mt=f(At,!0),We=l(pe),ct=h(We),gt=h(ct);cn(gt,{name:"info"});var Rt=l(ct,2);{var Bt=Re=>{var Ie=Es(),vt=f(Ie,!0);E(ot=>{Ie.disabled=t(o),c(vt,ot)},[()=>d("Adopt")]),M("click",Ie,()=>T(t(le))),g(Re,Ie)},dr=Re=>{var Ie=Es(),vt=f(Ie,!0);E(ot=>{Ie.disabled=t(o),c(vt,ot)},[()=>t(le).native===void 0&&(t(le).twins??[]).length>0?d("Replace"):d("Adopt anyway")]),M("click",Ie,()=>T(t(le))),g(Re,Ie)},Ot=Re=>{var Ie=Fv(),vt=f(Ie,!0);E(ot=>{Ie.disabled=t(o),c(vt,ot)},[()=>d("Update")]),M("click",Ie,()=>T(t(le))),g(Re,Ie)},Ht=Re=>{var Ie=jv(),vt=Oe(Ie),ot=f(vt,!0),$t=l(vt,2),cr=f($t,!0);E((vr,Jt)=>{c(ot,vr),c(cr,Jt)},[()=>d("Open"),()=>d("Delete")]),M("click",vt,()=>Xr.go("devices",t(le).key)),M("click",$t,()=>C(t(le))),g(Re,Ie)},qt=Re=>{var Ie=Ts(),vt=f(Ie,!0);E(ot=>c(vt,ot),[()=>d("Open")]),M("click",Ie,()=>Xr.go("devices",t(le).key)),g(Re,Ie)};H(Rt,Re=>{t(le).status==="new"?Re(Bt):t(le).status==="covered"?Re(dr,1):t(le).status==="updated"||t(le).status==="restored"?Re(Ot,2):t(le).status==="orphaned"?Re(Ht,3):(t(le).status==="unchanged"||t(le).status==="invalid")&&Re(qt,4)})}E((Re,Ie,vt,ot,$t)=>{Q(Je,"data-status",t(le).status),Q(Je,"data-key",t(le).key),Nt(mt,1,`ui-badge ${Re??""}`,"svelte-izwxip"),c(_t,Ie),c(Ne,t(le).name),c(wt,vt),c(ve,t(le).area??""),c(ge,t(le).key),c(Mt,ot),Q(ct,"title",$t)},[()=>O(t(le).status),()=>I(t(le).status),()=>P(t(le).importer),()=>t(le).notes.join("; "),()=>d("Details")]),M("click",ct,()=>w(v,t(le),!0)),g(Te,Je)}),E((Te,le,Je,Ye,mt,_t)=>{c(ce,Te),c(ue,le),c(xe,Je),c(V,Ye),c(Se,mt),c(se,_t)},[()=>d("State"),()=>d("Name"),()=>d("Source"),()=>d("Area"),()=>d("Key"),()=>d("Notes")]),g(B,Y)};H(de,B=>{t(i)&&t(n).length===0?B(fe):t(i)&&t(a).length===0?B(Fe,1):B($e,-1)})}var $=l(R,2);{var te=B=>{xa(B,{open:!0,get title(){return t(v).name},width:"760px",onclose:()=>w(v,void 0),testId:"details-dialog",buttons:X=>{var ie=Zn(),re=Oe(ie);{var ce=Z=>{const ue=ne(()=>t(v));var Ee=Gv(),xe=Oe(Ee),Ae=f(xe,!0),V=l(xe,2);{var me=Ge=>{var se=$v(),_e=f(se,!0);E(Te=>c(_e,Te),[()=>t(ue).status==="new"?d("Adopt"):d("Update")]),M("click",se,()=>T(t(ue))),g(Ge,se)},Se=Ge=>{var se=Ts(),_e=f(se,!0);E(Te=>c(_e,Te),[()=>t(ue).native===void 0&&(t(ue).twins??[]).length>0?d("Replace"):d("Adopt anyway")]),M("click",se,()=>T(t(ue))),g(Ge,se)};H(V,Ge=>{t(ue).status==="new"||t(ue).status==="updated"||t(ue).status==="restored"?Ge(me):t(ue).status==="covered"&&Ge(Se,1)})}E(Ge=>c(Ae,Ge),[()=>d("Close")]),M("click",xe,()=>w(v,void 0)),g(Z,Ee)};H(re,Z=>{t(v)&&Z(ce)})}g(X,ie)},children:(X,ie)=>{var re=Jv(),ce=Oe(re),Z=h(ce),ue=f(Z,!0),Ee=l(Z,2),xe=f(Ee,!0),Ae=l(Ee,2),V=f(Ae,!0),me=l(Ae,2),Se=h(me),Ge=f(Se,!0),se=l(me,2);{var _e=N=>{var K=wi(),G=Oe(K),ve=f(G,!0),qe=l(G,2),at=f(qe,!0);E(ge=>{c(ve,ge),c(at,t(v).area)},[()=>d("Area")]),g(N,K)};H(se,N=>{t(v).area!==void 0&&N(_e)})}var Te=l(se,2);{var le=N=>{var K=wi(),G=Oe(K),ve=f(G,!0),qe=l(G,2),at=f(qe,!0);E((ge,pe)=>{c(ve,ge),c(at,pe)},[()=>d("Native"),()=>d("Also described natively by {source} as {key}; the native description is preferred.",{source:P(t(v).native.split(":")[0]??""),key:t(v).native})]),g(N,K)};H(Te,N=>{t(v).native!==void 0&&N(le)})}var Je=l(Te,2);{var Ye=N=>{var K=Ss(),G=Oe(K),ve=f(G,!0),qe=l(G,2),at=h(qe),ge=f(at,!0);E((pe,be)=>{c(ve,pe),c(ge,be)},[()=>d("Twins"),()=>(t(v).twins??[]).join(", ")]),g(N,K)};H(Je,N=>{(t(v).twins??[]).length>0&&N(Ye)})}var mt=l(Je,2);{var _t=N=>{var K=wi(),G=Oe(K),ve=f(G,!0),qe=l(G,2),at=f(qe,!0);E((ge,pe)=>{c(ve,ge),c(at,pe)},[()=>d("Notes"),()=>t(v).notes.join("; ")]),g(N,K)};H(mt,N=>{t(v).notes.length>0&&N(_t)})}var yt=l(mt,2);{var Ne=N=>{var K=Ss(),G=Oe(K),ve=f(G,!0),qe=l(G,2),at=h(qe),ge=f(at,!0);E((pe,be)=>{c(ve,pe),c(ge,be)},[()=>d("Not mapped"),()=>t(v).unmapped.join(", ")]),g(N,K)};H(yt,N=>{t(v).unmapped.length>0&&N(Ne)})}var ke=l(yt,2);{var Be=N=>{var K=wi(),G=Oe(K),ve=f(G,!0),qe=l(G,2),at=f(qe,!0);E(ge=>{c(ve,ge),c(at,t(v).edits)},[()=>d("Your edits")]),g(N,K)};H(ke,N=>{t(v).edits>0&&N(Be)})}var Ze=l(ce,2);{var wt=N=>{var K=Kv(),G=Oe(K),ve=f(G,!0),qe=l(G,2),at=f(qe,!0),ge=l(qe,2),pe=h(ge),be=h(pe),De=h(be),Ve=f(De,!0),dt=l(De),ht=f(dt,!0),it=l(dt),At=f(it,!0),Mt=l(pe);tt(Mt,21,()=>t(v).conflicts,ba,(We,ct)=>{var gt=Vv(),Rt=h(gt),Bt=h(Rt),dr=f(Bt,!0),Ot=l(Rt),Ht=h(Ot),qt=f(Ht,!0),Re=l(Ot),Ie=h(Re),vt=f(Ie,!0);E((ot,$t)=>{c(dr,t(ct).path),c(qt,ot),c(vt,$t)},[()=>ja(t(ct).user),()=>ja(t(ct).now)]),g(We,gt)}),E((We,ct,gt,Rt,Bt)=>{c(ve,We),c(at,ct),c(Ve,gt),c(ht,Rt),c(At,Bt)},[()=>d("Conflicts"),()=>d("Your edit and the new description changed the same value; your edit stays."),()=>d("Path"),()=>d("Your edit"),()=>d("Source")]),g(N,K)};H(Ze,N=>{t(v).conflicts.length>0&&N(wt)})}E((N,K,G)=>{c(ue,N),c(xe,K),c(V,G),c(Ge,t(v).key)},[()=>d("State"),()=>I(t(v).status),()=>d("Key")]),g(X,re)},$$slots:{buttons:!0,default:!0}})};H($,B=>{t(v)&&B(te)})}E((B,Y,X,ie,re,ce,Z,ue,Ee,xe)=>{D.disabled=t(o)||t(n).length===0,c(q,B),j.disabled=t(o)||(t(y).new??0)===0,c(L,Y),Q(J,"placeholder",X),c(he,` ${ie??""}`),c(rt,`${re??""} · ${ce??""} · ${Z??""} · ${ue??""} · ${Ee??""} · ${xe??""}`)},[()=>d("Re-sync"),()=>d("Adopt all new"),()=>d("Filter"),()=>d("show unsupported"),()=>d("{count} new",{count:t(y).new??0}),()=>d("{count} changed",{count:(t(y).updated??0)+(t(y).restored??0)}),()=>d("{count} orphaned",{count:t(y).orphaned??0}),()=>d("{count} adopted",{count:t(y).unchanged??0}),()=>d("{count} duplicates",{count:t(y).covered??0}),()=>d("{count} unsupported",{count:t(y).unsupported??0})]),M("click",D,_),M("click",j,A),Le(J,()=>t(s),B=>w(s,B)),uu(W,()=>t(u),B=>w(u,B)),g(e,ee),zt()}lr(["click"]);function Yv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Aa={},Xi,Cs;function Zv(){return Cs||(Cs=1,Xi=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Xi}var eo={},na={},As;function Ea(){if(As)return na;As=1;let e;const r=[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];return na.getSymbolSize=function(a){if(!a)throw new Error('"version" cannot be null or undefined');if(a<1||a>40)throw new Error('"version" should be in range from 1 to 40');return a*4+17},na.getSymbolTotalCodewords=function(a){return r[a]},na.getBCHDigit=function(n){let a=0;for(;n!==0;)a++,n>>>=1;return a},na.setToSJISFunction=function(a){if(typeof a!="function")throw new Error('"toSJISFunc" is not a valid function.');e=a},na.isKanjiModeEnabled=function(){return typeof e<"u"},na.toSJIS=function(a){return e(a)},na}var to={},Ps;function ns(){return Ps||(Ps=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function r(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.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 new Error("Unknown EC Level: "+n)}}e.isValid=function(a){return a&&typeof a.bit<"u"&&a.bit>=0&&a.bit<4},e.from=function(a,i){if(e.isValid(a))return a;try{return r(a)}catch{return i}}})(to)),to}var ro,Ns;function Xv(){if(Ns)return ro;Ns=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(r){const n=Math.floor(r/8);return(this.buffer[n]>>>7-r%8&1)===1},put:function(r,n){for(let a=0;a<n;a++)this.putBit((r>>>n-a-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),r&&(this.buffer[n]|=128>>>this.length%8),this.length++}},ro=e,ro}var no,Ms;function ef(){if(Ms)return no;Ms=1;function e(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=new Uint8Array(r*r),this.reservedBit=new Uint8Array(r*r)}return e.prototype.set=function(r,n,a,i){const o=r*this.size+n;this.data[o]=a,i&&(this.reservedBit[o]=!0)},e.prototype.get=function(r,n){return this.data[r*this.size+n]},e.prototype.xor=function(r,n,a){this.data[r*this.size+n]^=a},e.prototype.isReserved=function(r,n){return this.reservedBit[r*this.size+n]},no=e,no}var ao={},Rs;function tf(){return Rs||(Rs=1,(function(e){const r=Ea().getSymbolSize;e.getRowColCoords=function(a){if(a===1)return[];const i=Math.floor(a/7)+2,o=r(a),s=o===145?26:Math.ceil((o-13)/(2*i-2))*2,u=[o-7];for(let v=1;v<i-1;v++)u[v]=u[v-1]-s;return u.push(6),u.reverse()},e.getPositions=function(a){const i=[],o=e.getRowColCoords(a),s=o.length;for(let u=0;u<s;u++)for(let v=0;v<s;v++)u===0&&v===0||u===0&&v===s-1||u===s-1&&v===0||i.push([o[u],o[v]]);return i}})(ao)),ao}var io={},Is;function rf(){if(Is)return io;Is=1;const e=Ea().getSymbolSize,r=7;return io.getPositions=function(a){const i=e(a);return[[0,0],[i-r,0],[0,i-r]]},io}var oo={},Os;function nf(){return Os||(Os=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const r={N1:3,N2:3,N3:40,N4:10};e.isValid=function(i){return i!=null&&i!==""&&!isNaN(i)&&i>=0&&i<=7},e.from=function(i){return e.isValid(i)?parseInt(i,10):void 0},e.getPenaltyN1=function(i){const o=i.size;let s=0,u=0,v=0,m=null,k=null;for(let y=0;y<o;y++){u=v=0,m=k=null;for(let b=0;b<o;b++){let _=i.get(y,b);_===m?u++:(u>=5&&(s+=r.N1+(u-5)),m=_,u=1),_=i.get(b,y),_===k?v++:(v>=5&&(s+=r.N1+(v-5)),k=_,v=1)}u>=5&&(s+=r.N1+(u-5)),v>=5&&(s+=r.N1+(v-5))}return s},e.getPenaltyN2=function(i){const o=i.size;let s=0;for(let u=0;u<o-1;u++)for(let v=0;v<o-1;v++){const m=i.get(u,v)+i.get(u,v+1)+i.get(u+1,v)+i.get(u+1,v+1);(m===4||m===0)&&s++}return s*r.N2},e.getPenaltyN3=function(i){const o=i.size;let s=0,u=0,v=0;for(let m=0;m<o;m++){u=v=0;for(let k=0;k<o;k++)u=u<<1&2047|i.get(m,k),k>=10&&(u===1488||u===93)&&s++,v=v<<1&2047|i.get(k,m),k>=10&&(v===1488||v===93)&&s++}return s*r.N3},e.getPenaltyN4=function(i){let o=0;const s=i.data.length;for(let v=0;v<s;v++)o+=i.data[v];return Math.abs(Math.ceil(o*100/s/5)-10)*r.N4};function n(a,i,o){switch(a){case e.Patterns.PATTERN000:return(i+o)%2===0;case e.Patterns.PATTERN001:return i%2===0;case e.Patterns.PATTERN010:return o%3===0;case e.Patterns.PATTERN011:return(i+o)%3===0;case e.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(o/3))%2===0;case e.Patterns.PATTERN101:return i*o%2+i*o%3===0;case e.Patterns.PATTERN110:return(i*o%2+i*o%3)%2===0;case e.Patterns.PATTERN111:return(i*o%3+(i+o)%2)%2===0;default:throw new Error("bad maskPattern:"+a)}}e.applyMask=function(i,o){const s=o.size;for(let u=0;u<s;u++)for(let v=0;v<s;v++)o.isReserved(v,u)||o.xor(v,u,n(i,v,u))},e.getBestMask=function(i,o){const s=Object.keys(e.Patterns).length;let u=0,v=1/0;for(let m=0;m<s;m++){o(m),e.applyMask(m,i);const k=e.getPenaltyN1(i)+e.getPenaltyN2(i)+e.getPenaltyN3(i)+e.getPenaltyN4(i);e.applyMask(m,i),k<v&&(v=k,u=m)}return u}})(oo)),oo}var ki={},Ds;function pu(){if(Ds)return ki;Ds=1;const e=ns(),r=[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],n=[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];return ki.getBlocksCount=function(i,o){switch(o){case e.L:return r[(i-1)*4+0];case e.M:return r[(i-1)*4+1];case e.Q:return r[(i-1)*4+2];case e.H:return r[(i-1)*4+3];default:return}},ki.getTotalCodewordsCount=function(i,o){switch(o){case e.L:return n[(i-1)*4+0];case e.M:return n[(i-1)*4+1];case e.Q:return n[(i-1)*4+2];case e.H:return n[(i-1)*4+3];default:return}},ki}var so={},Ya={},Ls;function af(){if(Ls)return Ya;Ls=1;const e=new Uint8Array(512),r=new Uint8Array(256);return(function(){let a=1;for(let i=0;i<255;i++)e[i]=a,r[a]=i,a<<=1,a&256&&(a^=285);for(let i=255;i<512;i++)e[i]=e[i-255]})(),Ya.log=function(a){if(a<1)throw new Error("log("+a+")");return r[a]},Ya.exp=function(a){return e[a]},Ya.mul=function(a,i){return a===0||i===0?0:e[r[a]+r[i]]},Ya}var Bs;function of(){return Bs||(Bs=1,(function(e){const r=af();e.mul=function(a,i){const o=new Uint8Array(a.length+i.length-1);for(let s=0;s<a.length;s++)for(let u=0;u<i.length;u++)o[s+u]^=r.mul(a[s],i[u]);return o},e.mod=function(a,i){let o=new Uint8Array(a);for(;o.length-i.length>=0;){const s=o[0];for(let v=0;v<i.length;v++)o[v]^=r.mul(i[v],s);let u=0;for(;u<o.length&&o[u]===0;)u++;o=o.slice(u)}return o},e.generateECPolynomial=function(a){let i=new Uint8Array([1]);for(let o=0;o<a;o++)i=e.mul(i,new Uint8Array([1,r.exp(o)]));return i}})(so)),so}var lo,qs;function sf(){if(qs)return lo;qs=1;const e=of();function r(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return r.prototype.initialize=function(a){this.degree=a,this.genPoly=e.generateECPolynomial(this.degree)},r.prototype.encode=function(a){if(!this.genPoly)throw new Error("Encoder not initialized");const i=new Uint8Array(a.length+this.degree);i.set(a);const o=e.mod(i,this.genPoly),s=this.degree-o.length;if(s>0){const u=new Uint8Array(this.degree);return u.set(o,s),u}return o},lo=r,lo}var uo={},co={},vo={},Us;function hu(){return Us||(Us=1,vo.isValid=function(r){return!isNaN(r)&&r>=1&&r<=40}),vo}var Rn={},Fs;function mu(){if(Fs)return Rn;Fs=1;const e="[0-9]+",r="[A-Z $%*+\\-./:]+";let n="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";n=n.replace(/u/g,"\\u");const a="(?:(?![A-Z0-9 $%*+\\-./:]|"+n+`)(?:.|[\r
4
+ ]))+`;Rn.KANJI=new RegExp(n,"g"),Rn.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Rn.BYTE=new RegExp(a,"g"),Rn.NUMERIC=new RegExp(e,"g"),Rn.ALPHANUMERIC=new RegExp(r,"g");const i=new RegExp("^"+n+"$"),o=new RegExp("^"+e+"$"),s=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Rn.testKanji=function(v){return i.test(v)},Rn.testNumeric=function(v){return o.test(v)},Rn.testAlphanumeric=function(v){return s.test(v)},Rn}var js;function Ta(){return js||(js=1,(function(e){const r=hu(),n=mu();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(o,s){if(!o.ccBits)throw new Error("Invalid mode: "+o);if(!r.isValid(s))throw new Error("Invalid version: "+s);return s>=1&&s<10?o.ccBits[0]:s<27?o.ccBits[1]:o.ccBits[2]},e.getBestModeForData=function(o){return n.testNumeric(o)?e.NUMERIC:n.testAlphanumeric(o)?e.ALPHANUMERIC:n.testKanji(o)?e.KANJI:e.BYTE},e.toString=function(o){if(o&&o.id)return o.id;throw new Error("Invalid mode")},e.isValid=function(o){return o&&o.bit&&o.ccBits};function a(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+i)}}e.from=function(o,s){if(e.isValid(o))return o;try{return a(o)}catch{return s}}})(co)),co}var zs;function lf(){return zs||(zs=1,(function(e){const r=Ea(),n=pu(),a=ns(),i=Ta(),o=hu(),s=7973,u=r.getBCHDigit(s);function v(b,_,x){for(let T=1;T<=40;T++)if(_<=e.getCapacity(T,x,b))return T}function m(b,_){return i.getCharCountIndicator(b,_)+4}function k(b,_){let x=0;return b.forEach(function(T){const A=m(T.mode,_);x+=A+T.getBitsLength()}),x}function y(b,_){for(let x=1;x<=40;x++)if(k(b,x)<=e.getCapacity(x,_,i.MIXED))return x}e.from=function(_,x){return o.isValid(_)?parseInt(_,10):x},e.getCapacity=function(_,x,T){if(!o.isValid(_))throw new Error("Invalid QR Code version");typeof T>"u"&&(T=i.BYTE);const A=r.getSymbolTotalCodewords(_),C=n.getTotalCodewordsCount(_,x),I=(A-C)*8;if(T===i.MIXED)return I;const P=I-m(T,_);switch(T){case i.NUMERIC:return Math.floor(P/10*3);case i.ALPHANUMERIC:return Math.floor(P/11*2);case i.KANJI:return Math.floor(P/13);case i.BYTE:default:return Math.floor(P/8)}},e.getBestVersionForData=function(_,x){let T;const A=a.from(x,a.M);if(Array.isArray(_)){if(_.length>1)return y(_,A);if(_.length===0)return 1;T=_[0]}else T=_;return v(T.mode,T.getLength(),A)},e.getEncodedBits=function(_){if(!o.isValid(_)||_<7)throw new Error("Invalid QR Code version");let x=_<<12;for(;r.getBCHDigit(x)-u>=0;)x^=s<<r.getBCHDigit(x)-u;return _<<12|x}})(uo)),uo}var fo={},Hs;function uf(){if(Hs)return fo;Hs=1;const e=Ea(),r=1335,n=21522,a=e.getBCHDigit(r);return fo.getEncodedBits=function(o,s){const u=o.bit<<3|s;let v=u<<10;for(;e.getBCHDigit(v)-a>=0;)v^=r<<e.getBCHDigit(v)-a;return(u<<10|v)^n},fo}var po={},ho,$s;function df(){if($s)return ho;$s=1;const e=Ta();function r(n){this.mode=e.NUMERIC,this.data=n.toString()}return r.getBitsLength=function(a){return 10*Math.floor(a/3)+(a%3?a%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(a){let i,o,s;for(i=0;i+3<=this.data.length;i+=3)o=this.data.substr(i,3),s=parseInt(o,10),a.put(s,10);const u=this.data.length-i;u>0&&(o=this.data.substr(i),s=parseInt(o,10),a.put(s,u*3+1))},ho=r,ho}var mo,Gs;function cf(){if(Gs)return mo;Gs=1;const e=Ta(),r=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function n(a){this.mode=e.ALPHANUMERIC,this.data=a}return n.getBitsLength=function(i){return 11*Math.floor(i/2)+6*(i%2)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(i){let o;for(o=0;o+2<=this.data.length;o+=2){let s=r.indexOf(this.data[o])*45;s+=r.indexOf(this.data[o+1]),i.put(s,11)}this.data.length%2&&i.put(r.indexOf(this.data[o]),6)},mo=n,mo}var _o,Vs;function vf(){if(Vs)return _o;Vs=1;const e=Ta();function r(n){this.mode=e.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}return r.getBitsLength=function(a){return a*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(n){for(let a=0,i=this.data.length;a<i;a++)n.put(this.data[a],8)},_o=r,_o}var go,Ks;function ff(){if(Ks)return go;Ks=1;const e=Ta(),r=Ea();function n(a){this.mode=e.KANJI,this.data=a}return n.getBitsLength=function(i){return i*13},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(a){let i;for(i=0;i<this.data.length;i++){let o=r.toSJIS(this.data[i]);if(o>=33088&&o<=40956)o-=33088;else if(o>=57408&&o<=60351)o-=49472;else throw new Error("Invalid SJIS character: "+this.data[i]+`
5
+ Make sure your charset is UTF-8`);o=(o>>>8&255)*192+(o&255),a.put(o,13)}},go=n,go}var bo={exports:{}},Js;function pf(){return Js||(Js=1,(function(e){var r={single_source_shortest_paths:function(n,a,i){var o={},s={};s[a]=0;var u=r.PriorityQueue.make();u.push(a,0);for(var v,m,k,y,b,_,x,T,A;!u.empty();){v=u.pop(),m=v.value,y=v.cost,b=n[m]||{};for(k in b)b.hasOwnProperty(k)&&(_=b[k],x=y+_,T=s[k],A=typeof s[k]>"u",(A||T>x)&&(s[k]=x,u.push(k,x),o[k]=m))}if(typeof i<"u"&&typeof s[i]>"u"){var C=["Could not find a path from ",a," to ",i,"."].join("");throw new Error(C)}return o},extract_shortest_path_from_predecessor_list:function(n,a){for(var i=[],o=a;o;)i.push(o),n[o],o=n[o];return i.reverse(),i},find_path:function(n,a,i){var o=r.single_source_shortest_paths(n,a,i);return r.extract_shortest_path_from_predecessor_list(o,i)},PriorityQueue:{make:function(n){var a=r.PriorityQueue,i={},o;n=n||{};for(o in a)a.hasOwnProperty(o)&&(i[o]=a[o]);return i.queue=[],i.sorter=n.sorter||a.default_sorter,i},default_sorter:function(n,a){return n.cost-a.cost},push:function(n,a){var i={value:n,cost:a};this.queue.push(i),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=r})(bo)),bo.exports}var Ws;function hf(){return Ws||(Ws=1,(function(e){const r=Ta(),n=df(),a=cf(),i=vf(),o=ff(),s=mu(),u=Ea(),v=pf();function m(C){return unescape(encodeURIComponent(C)).length}function k(C,I,P){const O=[];let ee;for(;(ee=C.exec(P))!==null;)O.push({data:ee[0],index:ee.index,mode:I,length:ee[0].length});return O}function y(C){const I=k(s.NUMERIC,r.NUMERIC,C),P=k(s.ALPHANUMERIC,r.ALPHANUMERIC,C);let O,ee;return u.isKanjiModeEnabled()?(O=k(s.BYTE,r.BYTE,C),ee=k(s.KANJI,r.KANJI,C)):(O=k(s.BYTE_KANJI,r.BYTE,C),ee=[]),I.concat(P,O,ee).sort(function(F,D){return F.index-D.index}).map(function(F){return{data:F.data,mode:F.mode,length:F.length}})}function b(C,I){switch(I){case r.NUMERIC:return n.getBitsLength(C);case r.ALPHANUMERIC:return a.getBitsLength(C);case r.KANJI:return o.getBitsLength(C);case r.BYTE:return i.getBitsLength(C)}}function _(C){return C.reduce(function(I,P){const O=I.length-1>=0?I[I.length-1]:null;return O&&O.mode===P.mode?(I[I.length-1].data+=P.data,I):(I.push(P),I)},[])}function x(C){const I=[];for(let P=0;P<C.length;P++){const O=C[P];switch(O.mode){case r.NUMERIC:I.push([O,{data:O.data,mode:r.ALPHANUMERIC,length:O.length},{data:O.data,mode:r.BYTE,length:O.length}]);break;case r.ALPHANUMERIC:I.push([O,{data:O.data,mode:r.BYTE,length:O.length}]);break;case r.KANJI:I.push([O,{data:O.data,mode:r.BYTE,length:m(O.data)}]);break;case r.BYTE:I.push([{data:O.data,mode:r.BYTE,length:m(O.data)}])}}return I}function T(C,I){const P={},O={start:{}};let ee=["start"];for(let R=0;R<C.length;R++){const F=C[R],D=[];for(let q=0;q<F.length;q++){const j=F[q],L=""+R+q;D.push(L),P[L]={node:j,lastCount:0},O[L]={};for(let J=0;J<ee.length;J++){const U=ee[J];P[U]&&P[U].node.mode===j.mode?(O[U][L]=b(P[U].lastCount+j.length,j.mode)-b(P[U].lastCount,j.mode),P[U].lastCount+=j.length):(P[U]&&(P[U].lastCount=j.length),O[U][L]=b(j.length,j.mode)+4+r.getCharCountIndicator(j.mode,I))}}ee=D}for(let R=0;R<ee.length;R++)O[ee[R]].end=0;return{map:O,table:P}}function A(C,I){let P;const O=r.getBestModeForData(C);if(P=r.from(I,O),P!==r.BYTE&&P.bit<O.bit)throw new Error('"'+C+'" cannot be encoded with mode '+r.toString(P)+`.
6
+ Suggested mode is: `+r.toString(O));switch(P===r.KANJI&&!u.isKanjiModeEnabled()&&(P=r.BYTE),P){case r.NUMERIC:return new n(C);case r.ALPHANUMERIC:return new a(C);case r.KANJI:return new o(C);case r.BYTE:return new i(C)}}e.fromArray=function(I){return I.reduce(function(P,O){return typeof O=="string"?P.push(A(O,null)):O.data&&P.push(A(O.data,O.mode)),P},[])},e.fromString=function(I,P){const O=y(I,u.isKanjiModeEnabled()),ee=x(O),R=T(ee,P),F=v.find_path(R.map,"start","end"),D=[];for(let q=1;q<F.length-1;q++)D.push(R.table[F[q]].node);return e.fromArray(_(D))},e.rawSplit=function(I){return e.fromArray(y(I,u.isKanjiModeEnabled()))}})(po)),po}var Qs;function mf(){if(Qs)return eo;Qs=1;const e=Ea(),r=ns(),n=Xv(),a=ef(),i=tf(),o=rf(),s=nf(),u=pu(),v=sf(),m=lf(),k=uf(),y=Ta(),b=hf();function _(R,F){const D=R.size,q=o.getPositions(F);for(let j=0;j<q.length;j++){const L=q[j][0],J=q[j][1];for(let U=-1;U<=7;U++)if(!(L+U<=-1||D<=L+U))for(let W=-1;W<=7;W++)J+W<=-1||D<=J+W||(U>=0&&U<=6&&(W===0||W===6)||W>=0&&W<=6&&(U===0||U===6)||U>=2&&U<=4&&W>=2&&W<=4?R.set(L+U,J+W,!0,!0):R.set(L+U,J+W,!1,!0))}}function x(R){const F=R.size;for(let D=8;D<F-8;D++){const q=D%2===0;R.set(D,6,q,!0),R.set(6,D,q,!0)}}function T(R,F){const D=i.getPositions(F);for(let q=0;q<D.length;q++){const j=D[q][0],L=D[q][1];for(let J=-2;J<=2;J++)for(let U=-2;U<=2;U++)J===-2||J===2||U===-2||U===2||J===0&&U===0?R.set(j+J,L+U,!0,!0):R.set(j+J,L+U,!1,!0)}}function A(R,F){const D=R.size,q=m.getEncodedBits(F);let j,L,J;for(let U=0;U<18;U++)j=Math.floor(U/3),L=U%3+D-8-3,J=(q>>U&1)===1,R.set(j,L,J,!0),R.set(L,j,J,!0)}function C(R,F,D){const q=R.size,j=k.getEncodedBits(F,D);let L,J;for(L=0;L<15;L++)J=(j>>L&1)===1,L<6?R.set(L,8,J,!0):L<8?R.set(L+1,8,J,!0):R.set(q-15+L,8,J,!0),L<8?R.set(8,q-L-1,J,!0):L<9?R.set(8,15-L-1+1,J,!0):R.set(8,15-L-1,J,!0);R.set(q-8,8,1,!0)}function I(R,F){const D=R.size;let q=-1,j=D-1,L=7,J=0;for(let U=D-1;U>0;U-=2)for(U===6&&U--;;){for(let W=0;W<2;W++)if(!R.isReserved(j,U-W)){let he=!1;J<F.length&&(he=(F[J]>>>L&1)===1),R.set(j,U-W,he),L--,L===-1&&(J++,L=7)}if(j+=q,j<0||D<=j){j-=q,q=-q;break}}}function P(R,F,D){const q=new n;D.forEach(function(W){q.put(W.mode.bit,4),q.put(W.getLength(),y.getCharCountIndicator(W.mode,R)),W.write(q)});const j=e.getSymbolTotalCodewords(R),L=u.getTotalCodewordsCount(R,F),J=(j-L)*8;for(q.getLengthInBits()+4<=J&&q.put(0,4);q.getLengthInBits()%8!==0;)q.putBit(0);const U=(J-q.getLengthInBits())/8;for(let W=0;W<U;W++)q.put(W%2?17:236,8);return O(q,R,F)}function O(R,F,D){const q=e.getSymbolTotalCodewords(F),j=u.getTotalCodewordsCount(F,D),L=q-j,J=u.getBlocksCount(F,D),U=q%J,W=J-U,he=Math.floor(q/J),Ce=Math.floor(L/J),rt=Ce+1,ae=he-Ce,de=new v(ae);let fe=0;const Fe=new Array(J),$e=new Array(J);let $=0;const te=new Uint8Array(R.buffer);for(let re=0;re<J;re++){const ce=re<W?Ce:rt;Fe[re]=te.slice(fe,fe+ce),$e[re]=de.encode(Fe[re]),fe+=ce,$=Math.max($,ce)}const B=new Uint8Array(q);let Y=0,X,ie;for(X=0;X<$;X++)for(ie=0;ie<J;ie++)X<Fe[ie].length&&(B[Y++]=Fe[ie][X]);for(X=0;X<ae;X++)for(ie=0;ie<J;ie++)B[Y++]=$e[ie][X];return B}function ee(R,F,D,q){let j;if(Array.isArray(R))j=b.fromArray(R);else if(typeof R=="string"){let he=F;if(!he){const Ce=b.rawSplit(R);he=m.getBestVersionForData(Ce,D)}j=b.fromString(R,he||40)}else throw new Error("Invalid data");const L=m.getBestVersionForData(j,D);if(!L)throw new Error("The amount of data is too big to be stored in a QR Code");if(!F)F=L;else if(F<L)throw new Error(`
7
+ The chosen QR Code version cannot contain this amount of data.
8
+ Minimum version required to store current data is: `+L+`.
9
+ `);const J=P(F,D,j),U=e.getSymbolSize(F),W=new a(U);return _(W,F),x(W),T(W,F),C(W,D,0),F>=7&&A(W,F),I(W,J),isNaN(q)&&(q=s.getBestMask(W,C.bind(null,W,D))),s.applyMask(q,W),C(W,D,q),{modules:W,version:F,errorCorrectionLevel:D,maskPattern:q,segments:j}}return eo.create=function(F,D){if(typeof F>"u"||F==="")throw new Error("No input text");let q=r.M,j,L;return typeof D<"u"&&(q=r.from(D.errorCorrectionLevel,r.M),j=m.from(D.version),L=s.from(D.maskPattern),D.toSJISFunc&&e.setToSJISFunction(D.toSJISFunc)),ee(F,j,q,L)},eo}var yo={},wo={},Ys;function _u(){return Ys||(Ys=1,(function(e){function r(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let a=n.slice().replace("#","").split("");if(a.length<3||a.length===5||a.length>8)throw new Error("Invalid hex color: "+n);(a.length===3||a.length===4)&&(a=Array.prototype.concat.apply([],a.map(function(o){return[o,o]}))),a.length===6&&a.push("F","F");const i=parseInt(a.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:i&255,hex:"#"+a.slice(0,6).join("")}}e.getOptions=function(a){a||(a={}),a.color||(a.color={});const i=typeof a.margin>"u"||a.margin===null||a.margin<0?4:a.margin,o=a.width&&a.width>=21?a.width:void 0,s=a.scale||4;return{width:o,scale:o?4:s,margin:i,color:{dark:r(a.color.dark||"#000000ff"),light:r(a.color.light||"#ffffffff")},type:a.type,rendererOpts:a.rendererOpts||{}}},e.getScale=function(a,i){return i.width&&i.width>=a+i.margin*2?i.width/(a+i.margin*2):i.scale},e.getImageWidth=function(a,i){const o=e.getScale(a,i);return Math.floor((a+i.margin*2)*o)},e.qrToImageData=function(a,i,o){const s=i.modules.size,u=i.modules.data,v=e.getScale(s,o),m=Math.floor((s+o.margin*2)*v),k=o.margin*v,y=[o.color.light,o.color.dark];for(let b=0;b<m;b++)for(let _=0;_<m;_++){let x=(b*m+_)*4,T=o.color.light;if(b>=k&&_>=k&&b<m-k&&_<m-k){const A=Math.floor((b-k)/v),C=Math.floor((_-k)/v);T=y[u[A*s+C]?1:0]}a[x++]=T.r,a[x++]=T.g,a[x++]=T.b,a[x]=T.a}}})(wo)),wo}var Zs;function _f(){return Zs||(Zs=1,(function(e){const r=_u();function n(i,o,s){i.clearRect(0,0,o.width,o.height),o.style||(o.style={}),o.height=s,o.width=s,o.style.height=s+"px",o.style.width=s+"px"}function a(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(o,s,u){let v=u,m=s;typeof v>"u"&&(!s||!s.getContext)&&(v=s,s=void 0),s||(m=a()),v=r.getOptions(v);const k=r.getImageWidth(o.modules.size,v),y=m.getContext("2d"),b=y.createImageData(k,k);return r.qrToImageData(b.data,o,v),n(y,m,k),y.putImageData(b,0,0),m},e.renderToDataURL=function(o,s,u){let v=u;typeof v>"u"&&(!s||!s.getContext)&&(v=s,s=void 0),v||(v={});const m=e.render(o,s,v),k=v.type||"image/png",y=v.rendererOpts||{};return m.toDataURL(k,y.quality)}})(yo)),yo}var ko={},Xs;function gf(){if(Xs)return ko;Xs=1;const e=_u();function r(i,o){const s=i.a/255,u=o+'="'+i.hex+'"';return s<1?u+" "+o+'-opacity="'+s.toFixed(2).slice(1)+'"':u}function n(i,o,s){let u=i+o;return typeof s<"u"&&(u+=" "+s),u}function a(i,o,s){let u="",v=0,m=!1,k=0;for(let y=0;y<i.length;y++){const b=Math.floor(y%o),_=Math.floor(y/o);!b&&!m&&(m=!0),i[y]?(k++,y>0&&b>0&&i[y-1]||(u+=m?n("M",b+s,.5+_+s):n("m",v,0),v=0,m=!1),b+1<o&&i[y+1]||(u+=n("h",k),k=0)):v++}return u}return ko.render=function(o,s,u){const v=e.getOptions(s),m=o.modules.size,k=o.modules.data,y=m+v.margin*2,b=v.color.light.a?"<path "+r(v.color.light,"fill")+' d="M0 0h'+y+"v"+y+'H0z"/>':"",_="<path "+r(v.color.dark,"stroke")+' d="'+a(k,m,v.margin)+'"/>',x='viewBox="0 0 '+y+" "+y+'"',A='<svg xmlns="http://www.w3.org/2000/svg" '+(v.width?'width="'+v.width+'" height="'+v.width+'" ':"")+x+' shape-rendering="crispEdges">'+b+_+`</svg>
10
+ `;return typeof u=="function"&&u(null,A),A},ko}var el;function bf(){if(el)return Aa;el=1;const e=Zv(),r=mf(),n=_f(),a=gf();function i(o,s,u,v,m){const k=[].slice.call(arguments,1),y=k.length,b=typeof k[y-1]=="function";if(!b&&!e())throw new Error("Callback required as last argument");if(b){if(y<2)throw new Error("Too few arguments provided");y===2?(m=u,u=s,s=v=void 0):y===3&&(s.getContext&&typeof m>"u"?(m=v,v=void 0):(m=v,v=u,u=s,s=void 0))}else{if(y<1)throw new Error("Too few arguments provided");return y===1?(u=s,s=v=void 0):y===2&&!s.getContext&&(v=u,u=s,s=void 0),new Promise(function(_,x){try{const T=r.create(u,v);_(o(T,s,v))}catch(T){x(T)}})}try{const _=r.create(u,v);m(null,o(_,s,v))}catch(_){m(_)}}return Aa.create=r.create,Aa.toCanvas=i.bind(null,n.render),Aa.toDataURL=i.bind(null,n.renderToDataURL),Aa.toString=i.bind(null,function(o,s,u){return a.render(o,u)}),Aa}var yf=bf();const wf=Yv(yf);var kf=S('<canvas class="qr svelte-qzpscf"></canvas>');function xf(e,r){jt(r,!0);let n=gr(r,"size",3,180),a=z(void 0);Br(()=>{t(a)===void 0||r.text===""||wf.toCanvas(t(a),r.text,{width:n(),margin:1,color:{dark:"#000000",light:"#ffffff"}})});var i=kf();Ui(i,o=>w(a,o),()=>t(a)),E(()=>{Q(i,"width",n()),Q(i,"height",n()),Q(i,"aria-label",r.text)}),g(e,i),zt()}var Ef=S('<!> <dl class="ui-kv"><dt> </dt> <dd><code class="code svelte-1amxn89" data-testid="manual-code"> </code></dd> <dt> </dt> <dd><code> </code></dd></dl>',1),tl=S('<div class="ui-muted"> </div>'),Tf=S('<button type="button" class="ui-button" data-testid="open-window"> </button>'),Sf=S('<button type="button" class="ui-button" data-testid="close-window"> </button>'),Cf=S('<span class="ui-muted"> </span>'),Af=S('<p class="ui-faint ui-small hint svelte-1amxn89" data-testid="fabric-hint"> </p>'),Pf=S('<li class="fabric svelte-1amxn89" data-testid="fabric"><div class="fabric-head svelte-1amxn89"><span class="controller svelte-1amxn89" data-testid="fabric-controller"> </span> <!> <span data-testid="fabric-sessions"> </span> <button type="button" class="ui-icon-button remove svelte-1amxn89"><!></button></div> <!> <dl class="ui-kv details svelte-1amxn89"><dt> </dt> <dd><code> </code></dd> <dt> </dt> <dd> <code> </code></dd> <dt> </dt> <dd><code data-testid="fabric-node-id"> </code></dd> <dt> </dt> <dd><code> </code></dd> <dt> </dt> <dd><code> </code></dd> <dt> </dt> <dd> </dd></dl></li>'),Nf=S('<ul class="fabrics svelte-1amxn89" data-testid="fabrics"></ul>'),Mf=S('<section class="ui-section bridge" data-testid="bridge"><div class="ui-section-title"><span></span> <span> </span> <div class="ui-toolbar-trailing"> </div></div> <div class="ui-split"><div class="pairing svelte-1amxn89"><!> <div class="ui-toolbar"><span class="ui-muted"> </span> <!></div> <p class="ui-faint ui-small svelte-1amxn89"> </p></div> <div><h3> </h3> <!></div></div></section>'),Rf=S('<div class="ui-page" data-testid="bridges-page"><div class="ui-page-scroll bridges svelte-1amxn89"></div></div>');function If(e,r){jt(r,!0);let n=z(Lt([])),a=z("");const i=4996;function o(_,x){try{return BigInt(_).toString(16).toUpperCase().padStart(x,"0")}catch{return String(_)}}async function s(){try{w(n,await He.bridges(),!0)}catch(_){Ue.error(pt(_))}}en(()=>{s();const _=setInterval(()=>{s()},1e4),x=Er.on(T=>{T.type==="bridges"&&s()});return()=>{clearInterval(_),x()}});async function u(_,x){w(a,_.id,!0);try{await He.commissioning(_.id,x,15),Ue.info(d(x?"Commissioning window open for 15 minutes":"Commissioning window closed")),await s()}catch(T){Ue.error(pt(T))}finally{w(a,"")}}async function v(_,x){if(await rr.confirm(d("Remove fabric {label}? The controller loses the bridge and every device on it.",{label:x.label||`#${x.index}`}),{confirm:d("Remove"),danger:!0}))try{await He.removeFabric(_.id,x.index),await s()}catch(A){Ue.error(pt(A))}}function m(_){return d(_===0?"closed":_===2?"open (basic)":"open (enhanced)")}function k(_){return _.length===11?`${_.slice(0,4)}-${_.slice(4,7)}-${_.slice(7)}`:_}var y=Rf(),b=h(y);tt(b,21,()=>t(n),_=>_.id,(_,x)=>{var T=Mf(),A=h(T),C=h(A);let I;var P=l(C),O=l(P);let ee;var R=f(O,!0),F=l(O,2),D=f(F),q=l(A,2),j=h(q),L=h(j);{var J=ie=>{var re=Ef(),ce=Oe(re);xf(ce,{get text(){return t(x).pairingCodes.qrPairingCode}});var Z=l(ce,2),ue=h(Z),Ee=f(ue,!0),xe=l(ue,2),Ae=h(xe),V=f(Ae,!0),me=l(xe,2),Se=f(me,!0),Ge=l(me,2),se=h(Ge),_e=f(se,!0);E((Te,le,Je)=>{c(Ee,Te),c(V,le),c(Se,Je),c(_e,t(x).pairingCodes.qrPairingCode)},[()=>d("Manual pairing code"),()=>k(t(x).pairingCodes.manualPairingCode),()=>d("QR payload")]),g(ie,re)},U=ie=>{var re=tl(),ce=f(re,!0);E(Z=>c(ce,Z),[()=>d("No pairing codes: the bridge is not running.")]),g(ie,re)};H(L,ie=>{t(x).pairingCodes?ie(J):ie(U,-1)})}var W=l(L,2),he=h(W),Ce=f(he),rt=l(he,2);{var ae=ie=>{var re=Tf(),ce=f(re,!0);E(Z=>{re.disabled=t(a)===t(x).id,c(ce,Z)},[()=>d("Open for 15 minutes")]),M("click",re,()=>u(t(x),!0)),g(ie,re)},de=ie=>{var re=Sf(),ce=f(re,!0);E(Z=>{re.disabled=t(a)===t(x).id,c(ce,Z)},[()=>d("Close")]),M("click",re,()=>u(t(x),!1)),g(ie,re)};H(rt,ie=>{t(x).windowStatus===0?ie(ae):ie(de,-1)})}var fe=l(W,2),Fe=f(fe,!0),$e=l(j,2),$=h($e),te=f($,!0),B=l($,2);{var Y=ie=>{var re=tl(),ce=f(re,!0);E(Z=>c(ce,Z),[()=>d("No controller has paired this bridge yet.")]),g(ie,re)},X=ie=>{var re=Nf();tt(re,21,()=>t(x).fabrics,ce=>ce.index,(ce,Z)=>{var ue=Pf(),Ee=h(ue),xe=h(Ee),Ae=f(xe,!0),V=l(xe,2);{var me=Ot=>{var Ht=Cf(),qt=f(Ht);E(()=>c(qt,`“${t(Z).label??""}”`)),g(Ot,Ht)};H(V,Ot=>{t(Z).label!==""&&t(Z).label!==t(Z).vendorName&&Ot(me)})}var Se=l(V,2);let Ge;var se=f(Se,!0),_e=l(Se,2),Te=h(_e);cn(Te,{name:"trash"});var le=l(Ee,2);{var Je=Ot=>{var Ht=Af(),qt=f(Ht,!0);E(Re=>c(qt,Re),[()=>d("Apple adds this fabric next to the Apple Home one when the bridge is paired from Apple Home; removing the bridge in Apple Home removes both.")]),g(Ot,Ht)};H(le,Ot=>{t(Z).vendorId===i&&Ot(Je)})}var Ye=l(le,2),mt=h(Ye),_t=f(mt,!0),yt=l(mt,2),Ne=h(yt),ke=f(Ne),Be=l(yt,2),Ze=f(Be,!0),wt=l(Be,2),N=h(wt),K=l(N),G=f(K),ve=l(wt,2),qe=f(ve,!0),at=l(ve,2),ge=h(at),pe=f(ge),be=l(at,2),De=f(be,!0),Ve=l(be,2),dt=h(Ve),ht=f(dt),it=l(Ve,2),At=f(it,!0),Mt=l(it,2),We=h(Mt),ct=f(We,!0),gt=l(Mt,2),Rt=f(gt,!0),Bt=l(gt,2),dr=f(Bt,!0);E((Ot,Ht,qt,Re,Ie,vt,ot,$t,cr,vr,Jt,Sr,lt,St,Dt,It)=>{c(Ae,Ot),Ge=Nt(Se,1,"ui-badge",null,Ge,{"ui-badge-ok":t(Z).sessions>0}),Q(Se,"title",Ht),c(se,qt),Q(_e,"title",Re),c(_t,Ie),c(ke,`0x${vt??""}`),c(Ze,ot),c(N,`#${t(Z).index??""} · `),c(G,`0x${$t??""}`),c(qe,cr),c(pe,`0x${vr??""}`),c(De,Jt),c(ht,`0x${Sr??""}`),Q(it,"title",lt),c(At,St),c(ct,t(Z).compressedFabricId),c(Rt,Dt),c(dr,It)},[()=>t(Z).vendorName??d("Unknown controller"),()=>d("Sessions of this controller with an active peer, and their subscriptions"),()=>t(Z).sessions>0?d("sessions: {sessions} · subscriptions: {subscriptions}",{sessions:t(Z).sessions,subscriptions:t(Z).subscriptions}):d("no active session"),()=>d("Remove"),()=>d("Vendor id"),()=>o(t(Z).vendorId,4),()=>d("Fabric"),()=>o(t(Z).fabricId,16),()=>d("Bridge node id"),()=>o(t(Z).nodeId,16),()=>d("Controller node id"),()=>o(t(Z).rootNodeId,16),()=>d("The first half of the bridge’s operational mDNS name in this fabric"),()=>d("Compressed fabric id"),()=>d("Last contact"),()=>t(Z).lastInteraction===void 0?"—":Lv(t(Z).lastInteraction)]),M("click",_e,()=>v(t(x),t(Z))),g(ce,ue)}),g(ie,re)};H(B,ie=>{t(x).fabrics.length===0?ie(Y):ie(X,-1)})}E((ie,re,ce,Z,ue,Ee,xe)=>{Q(T,"data-id",t(x).id),I=Nt(C,1,"ui-dot",null,I,{"ui-dot-ok":t(x).online,"ui-dot-error":!t(x).online}),c(P,` ${t(x).id??""} `),ee=Nt(O,1,"ui-badge",null,ee,{"ui-badge-ok":t(x).commissioned,"ui-badge-warn":!t(x).commissioned}),c(R,ie),c(D,`${re??""} · ${ce??""}`),c(Ce,`${Z??""}: ${ue??""}`),c(Fe,Ee),c(te,xe)},[()=>t(x).commissioned?d("commissioned"):d("not commissioned"),()=>d("port {port}",{port:t(x).port}),()=>d("{count} devices",{count:t(x).devices}),()=>d("Commissioning window"),()=>m(t(x).windowStatus),()=>d("Pair the bridge from Apple Home, Home Assistant, Google Home or Alexa with the QR code or the manual code. A commissioned bridge needs an open window for a second controller."),()=>d("Fabrics")]),g(_,T)}),g(e,y),zt()}lr(["click"]);var Of=S('<div class="ui-ok-text"> </div>'),Df=S("<code> </code>"),Lf=S("<li><span> </span> <!> </li>"),Bf=S('<ul class="issues svelte-1j1p4r5" data-testid="issues"></ul>');function Ii(e,r){jt(r,!0);let n=gr(r,"empty",3,void 0);var a=Zn(),i=Oe(a);{var o=u=>{var v=Zn(),m=Oe(v);{var k=y=>{var b=Of(),_=f(b,!0);E(()=>c(_,n())),g(y,b)};H(m,y=>{n()!==void 0&&y(k)})}g(u,v)},s=u=>{var v=Bf();tt(v,21,()=>r.issues,ba,(m,k)=>{var y=Lf(),b=h(y);let _;var x=f(b,!0),T=l(b,2);{var A=I=>{var P=Df(),O=f(P,!0);E(()=>c(O,t(k).path)),g(I,P)};H(T,I=>{t(k).path!==""&&I(A)})}var C=l(T);E(I=>{Nt(y,1,lu(t(k).level==="error"?"ui-error-text":"ui-warn-text"),"svelte-1j1p4r5"),_=Nt(b,1,"ui-badge",null,_,{"ui-badge-error":t(k).level==="error","ui-badge-warn":t(k).level!=="error"}),c(x,I),c(C,` ${t(k).message??""}`)},[()=>t(k).level==="error"?d("error"):d("warning")]),g(m,y)}),g(u,v)};H(i,u=>{r.issues.length===0?u(o):u(s,-1)})}g(e,a),zt()}var qf=S('<section class="ui-section svelte-1wugbv7"><div class="ui-section-title"><a> </a></div> <!></section>'),Uf=S('<div data-testid="check-verdict"> </div> <!>',1),Ff=S('<div class="ui-page" data-testid="check-page"><div class="ui-toolbar"><button type="button" class="ui-button ui-button-primary" data-testid="run-check"> </button> <span class="ui-muted"> </span></div> <div class="ui-page-scroll"><!></div></div>');function jf(e,r){jt(r,!0);let n=z(void 0),a=z(!1);async function i(){w(a,!0);try{w(n,await He.check(),!0)}catch(x){Ue.error(pt(x))}finally{w(a,!1)}}var o=Ff(),s=h(o),u=h(s),v=f(u,!0),m=l(u,2),k=f(m,!0),y=l(s,2),b=h(y);{var _=x=>{var T=Uf(),A=Oe(T);let C;var I=f(A,!0),P=l(A,2);tt(P,17,()=>Object.entries(t(n).devices),([O,ee])=>O,(O,ee)=>{var R=ne(()=>Ci(t(ee),2));let F=()=>t(R)[0],D=()=>t(R)[1];var q=qf(),j=h(q),L=h(j),J=f(L,!0),U=l(j,2);Ii(U,{get issues(){return D()}}),E(W=>{Q(L,"href",W),c(J,F())},[()=>`#/devices/${encodeURIComponent(F())}`]),M("click",L,W=>{W.preventDefault(),Xr.go("devices",F())}),g(O,q)}),E(O=>{C=Nt(A,1,"verdict svelte-1wugbv7",null,C,{"ui-ok-text":t(n).ok,"ui-error-text":!t(n).ok}),c(I,O)},[()=>t(n).ok?d("Every device conforms."):d("Some devices do not conform.")]),g(x,T)};H(b,x=>{t(n)&&x(_)})}E((x,T)=>{u.disabled=t(a),c(v,x),c(k,T)},[()=>t(a)?d("Checking…"):d("Check every device"),()=>d("The strict dry run: every device is built in a throw-away Matter node, nothing goes online.")]),M("click",u,i),g(e,o),zt()}lr(["click"]);var zf=S("<span> </span>"),Hf=S('<label><input type="checkbox"/> <!></label>');function Zr(e,r){jt(r,!0);let n=gr(r,"checked",15),a=gr(r,"label",3,""),i=gr(r,"disabled",3,!1),o=gr(r,"title",3,void 0),s=gr(r,"onchange",3,void 0);var u=Hf();let v;var m=h(u),k=l(m,2);{var y=b=>{var _=zf(),x=f(_,!0);E(()=>c(x,a())),g(b,_)};H(k,b=>{a()!==""&&b(y)})}E(()=>{v=Nt(u,1,"ui-check",null,v,{"ui-disabled":i()}),Q(u,"title",o()),m.disabled=i(),Q(m,"data-testid",r.testId)}),M("change",m,b=>s()?.(b.currentTarget.checked)),uu(m,n),g(e,u),zt()}lr(["change"]);const gu="mqtt2matter.theme";function bu(){try{const e=localStorage.getItem(gu);return e==="light"||e==="dark"?e:"system"}catch{return"system"}}function yu(e=bu()){const r=document.documentElement;e==="system"?r.removeAttribute("data-theme"):r.setAttribute("data-theme",e)}function $f(e){try{localStorage.setItem(gu,e)}catch{}yu(e)}var Gf=S("<option> </option>"),Vf=S('<span class="ui-faint ui-small"> </span>'),rl=S('<p class="ui-warn-text svelte-ovo0td"> </p>'),Kf=S('<span class="ui-error-text"> </span>'),Jf=S('<div class="ui-form-help ui-error-text"> </div>'),Wf=S('<label class="ui-form-label" for="access-password"> </label> <div class="ui-form-field"><input id="access-password" class="ui-input" type="password" autocomplete="new-password" data-testid="access-password"/></div> <label class="ui-form-label" for="access-repeat"> </label> <div class="ui-form-field"><input id="access-repeat" class="ui-input" type="password" autocomplete="new-password" data-testid="access-repeat"/></div> <!>',1),Qf=S('<label class="ui-form-label" for="access-header"> </label> <div class="ui-form-field"><input id="access-header" class="ui-input"/></div> <label class="ui-form-label" for="access-logout"> </label> <div class="ui-form-field"><input id="access-logout" class="ui-input" placeholder="https://…"/></div> <div class="ui-form-help"> </div>',1),Yf=S('<div class="ui-page" data-testid="config-page"><div class="ui-page-scroll columns svelte-ovo0td"><section class="ui-section display svelte-ovo0td" data-testid="display"><div class="ui-section-title"> <span class="ui-faint ui-small"> </span></div> <div class="display-row svelte-ovo0td"><label class="display-field svelte-ovo0td"><span class="ui-muted"> </span> <select class="ui-select svelte-ovo0td" data-testid="language"><option> </option><!></select></label> <label class="display-field svelte-ovo0td"><span class="ui-muted"> </span> <select class="ui-select svelte-ovo0td" data-testid="theme"><option> </option><option> </option><option> </option></select></label></div></section> <section class="ui-section"><div class="ui-section-title"> <!></div> <p class="ui-muted svelte-ovo0td"> </p> <!> <textarea class="ui-textarea" rows="18" spellcheck="false" data-testid="settings-json"></textarea> <div class="ui-toolbar"><button type="button" class="ui-button ui-button-primary" data-testid="save-settings"> </button> <button type="button" class="ui-button"> </button> <!></div></section> <div class="stack svelte-ovo0td"><section class="ui-section" data-testid="access"><div class="ui-section-title"> </div> <p class="ui-muted svelte-ovo0td"> </p> <!> <div class="ui-form"><label class="ui-form-label" for="access-mode"> </label> <div class="ui-form-field"><select id="access-mode" class="ui-select" data-testid="access-mode"><option> </option><option> </option><option> </option></select></div> <!></div> <div><button type="button" class="ui-button ui-button-primary" data-testid="save-access"> </button></div></section> <section class="ui-section"><div class="ui-section-title"> </div> <p class="ui-muted svelte-ovo0td"> </p> <div><button type="button" class="ui-button" data-testid="export-all"> </button></div></section> <section class="ui-section"><div class="ui-section-title"> </div> <p class="ui-muted svelte-ovo0td"> </p> <input type="file" accept="application/json,.json"/> <textarea class="ui-textarea" rows="8" spellcheck="false" data-testid="import-json"></textarea> <div class="ui-toolbar"><button type="button" class="ui-button ui-button-primary" data-testid="import"> </button> <!></div></section></div></div></div>');function Zf(e,r){jt(r,!0);let n=z(void 0),a=z(""),i=z(Lt(bu())),o=z(""),s=z(!1),u=z(!1);const v=ne(()=>ci(t(a))),m=ne(()=>vn(t(v))),k=ne(()=>ci(t(o))),y=ne(()=>{if(!vn(t(k)))return;const ye=vn(t(k).devices)?t(k).devices:t(k);return Object.keys(ye).length>0?ye:void 0});let b=z("none"),_=z(""),x=z(""),T=z("X-Remote-User"),A=z(""),C=z(!1);const I=ne(()=>t(n)?.overridden.some(ye=>ye.startsWith("server.auth"))??!1),P=ne(()=>t(b)!=="password"||t(_)===t(x)&&(t(_)!==""||or.state?.mode==="password"));function O(ye){const ut=vn(ye.effective.server)?ye.effective.server:{},nt=vn(ut.auth)?ut.auth:{};w(b,nt.mode==="password"||nt.mode==="proxy"?nt.mode:"none",!0),w(T,typeof nt.proxyHeader=="string"?nt.proxyHeader:"X-Remote-User",!0),w(A,typeof nt.proxyLogoutUrl=="string"?nt.proxyLogoutUrl:"",!0),w(_,""),w(x,"")}async function ee(){if(!t(P))return;const ye={none:d("Open the UI to everyone who reaches its port?"),password:d("Protect the UI with this password? Other open sessions end."),proxy:d("Trust the {header} header of the reverse proxy? Only the proxy may reach the port then, or anyone can send the header.",{header:t(T)})}[t(b)];if(await rr.confirm(ye,{confirm:d("Save")})){w(C,!0);try{await He.setAccess({mode:t(b),...t(_)===""?{}:{password:t(_)},...t(b)==="proxy"?{proxyHeader:t(T)}:{},...t(b)==="proxy"&&t(A)!==""?{proxyLogoutUrl:t(A)}:{}}),Ue.info(d("Access saved; it applies at once.")),await or.load(),await R()}catch(ut){Ue.error(pt(ut))}finally{w(C,!1)}}}async function R(){try{w(n,await He.config(),!0),w(a,Jn(t(n).settings),!0),O(t(n))}catch(ye){Ue.error(pt(ye))}}en(()=>{R()});async function F(){if(t(m)){w(u,!0);try{await He.saveConfig(t(v)),Ue.warn(d("Settings saved. They apply at the next start of mqtt2matter.")),await R()}catch(ye){Ue.error(pt(ye))}finally{w(u,!1)}}}async function D(){try{rs("mqtt2matter.json",Jn(await He.exportAll()))}catch(ye){Ue.error(pt(ye))}}function q(ye){const ut=ye.currentTarget.files?.[0];ut!==void 0&&ut.text().then(nt=>{w(o,nt,!0)},()=>Ue.error(d("The file could not be read.")))}async function j(){if(t(y)===void 0)return;const ye=Object.keys(t(y)).length;if(await rr.confirm(t(s)?d("Import {count} devices and delete every other device?",{count:ye}):d("Import {count} devices? Existing devices with the same key are replaced.",{count:ye}),{confirm:d("Import"),danger:t(s)}))try{const nt=await He.importDevices(t(y),t(s));Ue.info(d("{count} devices imported",{count:nt.imported})),w(o,"")}catch(nt){Ue.error(pt(nt))}}var L=Yf(),J=h(L),U=h(J),W=h(U),he=h(W),Ce=l(he),rt=f(Ce,!0),ae=l(W,2),de=h(ae),fe=h(de),Fe=f(fe,!0),$e=l(fe,2),$=h($e),te=f($,!0);$.value=$.__value="auto";var B=l($);tt(B,16,()=>cu,ye=>ye,(ye,ut)=>{var nt=Gf(),Gt=f(nt,!0),Xt={};E(()=>{c(Gt,vu[ut]),Xt!==(Xt=ut)&&(nt.value=(nt.__value=Xt)??"")}),g(ye,nt)});var Y;er($e);var X=l(de,2),ie=h(X),re=f(ie,!0),ce=l(ie,2),Z=h(ce),ue=f(Z,!0);Z.value=Z.__value="system";var Ee=l(Z),xe=f(Ee,!0);Ee.value=Ee.__value="light";var Ae=l(Ee),V=f(Ae,!0);Ae.value=Ae.__value="dark";var me;er(ce);var Se=l(U,2),Ge=h(Se),se=h(Ge),_e=l(se);{var Te=ye=>{var ut=Vf(),nt=f(ut,!0);E(()=>c(nt,t(n).path)),g(ye,ut)};H(_e,ye=>{t(n)&&ye(Te)})}var le=l(Ge,2),Je=f(le,!0),Ye=l(le,2);{var mt=ye=>{var ut=rl(),nt=f(ut,!0);E(Gt=>c(nt,Gt),[()=>d("Set by the environment and not editable here: {paths}",{paths:t(n).overridden.join(", ")})]),g(ye,ut)};H(Ye,ye=>{t(n)&&t(n).overridden.length>0&&ye(mt)})}var _t=l(Ye,2),yt=l(_t,2),Ne=h(yt),ke=f(Ne,!0),Be=l(Ne,2),Ze=f(Be,!0),wt=l(Be,2);{var N=ye=>{var ut=Kf(),nt=f(ut,!0);E(Gt=>c(nt,Gt),[()=>d("Not valid JSON")]),g(ye,ut)};H(wt,ye=>{t(m)||ye(N)})}var K=l(Se,2),G=h(K),ve=h(G),qe=f(ve,!0),at=l(ve,2),ge=f(at,!0),pe=l(at,2);{var be=ye=>{var ut=rl(),nt=f(ut,!0);E(Gt=>c(nt,Gt),[()=>d("Set by the environment and not editable here: {paths}",{paths:"server.auth"})]),g(ye,ut)};H(pe,ye=>{t(I)&&ye(be)})}var De=l(pe,2),Ve=h(De),dt=f(Ve,!0),ht=l(Ve,2),it=h(ht),At=h(it),Mt=f(At,!0);At.value=At.__value="none";var We=l(At),ct=f(We,!0);We.value=We.__value="password";var gt=l(We),Rt=f(gt,!0);gt.value=gt.__value="proxy",er(it);var Bt=l(ht,2);{var dr=ye=>{var ut=Wf(),nt=Oe(ut),Gt=f(nt,!0),Xt=l(nt,2),Rr=h(Xt),Ur=l(Xt,2),Fr=f(Ur,!0),Cr=l(Ur,2),jr=h(Cr),zr=l(Cr,2);{var tn=Vt=>{var yr=Jf(),Hr=f(yr,!0);E(mn=>c(Hr,mn),[()=>d("The passwords differ.")]),g(Vt,yr)};H(zr,Vt=>{t(_)!==t(x)&&Vt(tn)})}E((Vt,yr,Hr)=>{c(Gt,Vt),Q(Rr,"placeholder",yr),c(Fr,Hr)},[()=>d("Password"),()=>or.state?.mode==="password"?d("unchanged"):"",()=>d("Repeat")]),Le(Rr,()=>t(_),Vt=>w(_,Vt)),Le(jr,()=>t(x),Vt=>w(x,Vt)),g(ye,ut)},Ot=ye=>{var ut=Qf(),nt=Oe(ut),Gt=f(nt,!0),Xt=l(nt,2),Rr=h(Xt),Ur=l(Xt,2),Fr=f(Ur,!0),Cr=l(Ur,2),jr=h(Cr),zr=l(Cr,2),tn=f(zr,!0);E((Vt,yr,Hr)=>{c(Gt,Vt),c(Fr,yr),c(tn,Hr)},[()=>d("Header"),()=>d("Logout URL"),()=>d('Optional: where "Log out" goes — the sign-out of the proxy.')]),Le(Rr,()=>t(T),Vt=>w(T,Vt)),Le(jr,()=>t(A),Vt=>w(A,Vt)),g(ye,ut)};H(Bt,ye=>{t(b)==="password"?ye(dr):t(b)==="proxy"&&ye(Ot,1)})}var Ht=l(De,2),qt=h(Ht),Re=f(qt,!0),Ie=l(G,2),vt=h(Ie),ot=f(vt,!0),$t=l(vt,2),cr=f($t,!0),vr=l($t,2),Jt=h(vr),Sr=f(Jt,!0),lt=l(Ie,2),St=h(lt),Dt=f(St,!0),It=l(St,2),hn=f(It,!0),qr=l(It,2),fr=l(qr,2);Q(fr,"placeholder",'{"devices": {…}}');var da=l(fr,2),Mr=h(da),zn=f(Mr,!0),Hn=l(Mr,2);{let ye=ne(()=>d("replace every device"));Zr(Hn,{get label(){return t(ye)},get checked(){return t(s)},set checked(ut){w(s,ut,!0)}})}E((ye,ut,nt,Gt,Xt,Rr,Ur,Fr,Cr,jr,zr,tn,Vt,yr,Hr,mn,_n,pr,$n,je,Xe,et,Ut,Wt,nr)=>{c(he,`${ye??""} `),c(rt,ut),c(Fe,nt),c(te,Gt),Y!==(Y=di.choice)&&($e.value=($e.__value=Y)??"",ka($e,Y)),c(re,Xt),c(ue,Rr),c(xe,Ur),c(V,Fr),me!==(me=t(i))&&(ce.value=(ce.__value=me)??"",ka(ce,me)),c(se,`${Cr??""} `),c(Je,jr),Ne.disabled=!t(m)||t(u),c(ke,zr),c(Ze,tn),c(qe,Vt),c(ge,yr),c(dt,Hr),it.disabled=t(I),c(Mt,mn),c(ct,_n),c(Rt,pr),qt.disabled=t(I)||!t(P)||t(C),c(Re,$n),c(ot,je),c(cr,Xe),c(Sr,et),c(Dt,Ut),c(hn,Wt),Mr.disabled=t(y)===void 0,c(zn,nr)},[()=>d("Display"),()=>d("in this browser only"),()=>d("Language"),()=>d("Browser language"),()=>d("Theme"),()=>d("like the system"),()=>d("light"),()=>d("dark"),()=>d("Settings"),()=>d("The top level of the configuration file without the devices: mqtt, storage, log, vendorId, productId, bridges, server, presets. Changes apply at the next start."),()=>d("Save"),()=>d("Reload"),()=>d("Access"),()=>d("Who may use this UI and its API. Without a login, keep the port on a trusted network."),()=>d("Login"),()=>d("none"),()=>d("password"),()=>d("reverse proxy"),()=>d("Save"),()=>d("Export"),()=>d("The whole configuration file, as it is on disk. One device exports from the device list."),()=>d("Download mqtt2matter.json"),()=>d("Import"),()=>d("A configuration file or a devices object; every device is validated before anything is written."),()=>t(y)===void 0?d("Import"):d("Import {count} devices",{count:Object.keys(t(y)).length})]),M("change",$e,ye=>di.set(ye.currentTarget.value)),M("change",ce,ye=>{w(i,ye.currentTarget.value,!0),$f(t(i))}),Le(_t,()=>t(a),ye=>w(a,ye)),M("click",Ne,F),M("click",Be,R),xr(it,()=>t(b),ye=>w(b,ye)),M("click",qt,ee),M("click",Jt,D),M("change",qr,q),Le(fr,()=>t(o),ye=>w(o,ye)),M("click",Mr,j),g(e,L),zt()}lr(["change","click"]);const jo=/^[A-Za-z0-9][A-Za-z0-9:._-]{0,63}$/,wu=64;function ku(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,wu)}function zo(e,r){if(e==="")return"";const n=new Set(r);if(!n.has(e))return e;for(let a=2;;a++){const i=`-${a}`,o=`${e.slice(0,wu-i.length)}${i}`;if(!n.has(o))return o}}const Xf={OnOff:[{kind:"attribute",name:"OnOff.onOff"}],LevelControl:[{kind:"attribute",name:"LevelControl.currentLevel"}],ColorControl:[{kind:"attribute",name:"ColorControl.colorTemperatureMireds"},{kind:"attribute",name:"ColorControl.colorHs"},{kind:"attribute",name:"ColorControl.colorXy"},{kind:"attribute",name:"ColorControl.colorRgb"},{kind:"attribute",name:"ColorControl.colorMode"}],WindowCovering:[{kind:"attribute",name:"WindowCovering.currentPositionLiftPercent100ths"},{kind:"attribute",name:"WindowCovering.targetPositionLiftPercent100ths"},{kind:"attribute",name:"WindowCovering.motion"},{kind:"invoke",name:"WindowCovering.upOrOpen"},{kind:"invoke",name:"WindowCovering.downOrClose"},{kind:"invoke",name:"WindowCovering.stopMotion"},{kind:"attribute",name:"WindowCovering.currentPositionTiltPercent100ths"},{kind:"attribute",name:"WindowCovering.targetPositionTiltPercent100ths"}],Thermostat:[{kind:"attribute",name:"Thermostat.localTemperature"},{kind:"attribute",name:"Thermostat.occupiedHeatingSetpoint"},{kind:"attribute",name:"Thermostat.occupiedCoolingSetpoint"},{kind:"attribute",name:"Thermostat.systemMode"},{kind:"attribute",name:"Thermostat.thermostatRunningState"}],DoorLock:[{kind:"attribute",name:"DoorLock.lockState"}],FanControl:[{kind:"attribute",name:"FanControl.percentSetting"},{kind:"attribute",name:"FanControl.percentCurrent"},{kind:"attribute",name:"FanControl.fanMode"},{kind:"attribute",name:"FanControl.speedSetting"}],Switch:[{kind:"event",name:"Switch"}],PowerSource:[{kind:"attribute",name:"PowerSource.batPercentRemaining"},{kind:"attribute",name:"PowerSource.batVoltage"},{kind:"attribute",name:"PowerSource.batChargeLevel"}],TemperatureMeasurement:[{kind:"attribute",name:"TemperatureMeasurement.measuredValue"}],RelativeHumidityMeasurement:[{kind:"attribute",name:"RelativeHumidityMeasurement.measuredValue"}],IlluminanceMeasurement:[{kind:"attribute",name:"IlluminanceMeasurement.measuredValue"}],PressureMeasurement:[{kind:"attribute",name:"PressureMeasurement.measuredValue"}],FlowMeasurement:[{kind:"attribute",name:"FlowMeasurement.measuredValue"}],BooleanState:[{kind:"attribute",name:"BooleanState.stateValue"}],OccupancySensing:[{kind:"attribute",name:"OccupancySensing.occupancy"}],AirQuality:[{kind:"attribute",name:"AirQuality.airQuality"}],SmokeCoAlarm:[{kind:"attribute",name:"SmokeCoAlarm.smokeState"},{kind:"attribute",name:"SmokeCoAlarm.coState"},{kind:"attribute",name:"SmokeCoAlarm.batteryAlert"}],Identify:[{kind:"invoke",name:"Identify.identify"}]},xu={onOff:["OnOff"],light:["OnOff","LevelControl","ColorControl"],cover:["WindowCovering"],climate:["Thermostat"],fan:["FanControl"],switch:["Switch"],powerSource:["PowerSource"]},ep={light:{onCommandType:["first","last","brightness"]},switch:{kind:["momentary","latching"]}};function as(e){return e.split(".")[0]??e}function Oi(e){return e.attribute!==void 0?{kind:"attribute",name:e.attribute}:e.invoke!==void 0?{kind:"invoke",name:e.invoke}:{kind:"event",name:e.event??""}}function nl(e){return new Set(e.mappings.map(r=>as(Oi(r).name)))}function tp(e){const r=new Set(e);return Object.entries(xu).filter(([,n])=>n.some(a=>r.has(a))).map(([n])=>n)}function rp(e,r){return{id:e,deviceTypes:r,mappings:[],options:{},coalesce:0}}function np(e){const r={};return e.kind==="attribute"?r.attribute=e.name:e.kind==="invoke"?r.invoke=e.name:r.event=e.name,r}function al(e){const r={};for(const[n,a]of Object.entries(e))if(!(a===void 0||a===""||typeof a=="number"&&Number.isNaN(a))&&!(vn(a)&&n!=="scale"&&n!=="get"&&n!=="codec"&&Object.keys(a).length===0)&&!(n==="get"&&vn(a)&&(a.topic===""||a.topic===void 0))){if(n==="scale"&&vn(a)){const i=a.from,o=a.to;if([...i,...o].some(s=>typeof s!="number"||Number.isNaN(s)))continue}r[n]=a}return r}function Eu(e){const r={...e};return r.status!==void 0&&(r.status=al(r.status)),r.command!==void 0&&(r.command=al(r.command)),r.comment===""&&delete r.comment,r}function Za(e){const r=JSON.parse(JSON.stringify(e));for(const n of r.endpoints)n.mappings=n.mappings.map(Eu),n.features!==void 0&&Object.keys(n.features).length===0&&delete n.features,n.attributes!==void 0&&Object.keys(n.attributes).length===0&&delete n.attributes;if(r.availability!==void 0)if(r.availability.topics=r.availability.topics.filter(n=>n.topic!==""),r.availability.topics.length===0)delete r.availability;else for(const n of r.availability.topics)n.extract===""&&delete n.extract,n.template===""&&delete n.template;for(const n of["vendor","model","serial","bridge"])r[n]===""&&delete r[n];return r}function il(e){return e==="true"?!0:e==="false"?!1:e.trim()!==""&&!Number.isNaN(Number(e))?Number(e):e}function ap(e){const r=e.trim();if(r==="")return"";try{return JSON.parse(r)}catch{return r}}var ip=S('<button type="button" class="ui-button"> </button> <button type="button" class="ui-button ui-button-primary" data-testid="picker-use"> </button>',1),op=S('<tr data-testid="picker-row"><td><code> </code></td><td class="payload svelte-1w7v0oq"><code> </code></td><td class="ui-muted"> </td></tr>'),sp=S('<div class="ui-empty"> </div>'),lp=S('<button type="button" class="ui-button" data-testid="picker-path"><code> </code> <span class="ui-muted"> </span></button>'),up=S('<div class="ui-muted"> </div> <div class="paths svelte-1w7v0oq"></div>',1),dp=S('<div class="detail svelte-1w7v0oq"><div><code> </code></div> <pre class="ui-pre short svelte-1w7v0oq"> </pre> <!></div>'),cp=S('<input class="ui-input" data-testid="picker-filter"/> <div class="list svelte-1w7v0oq"><table class="ui-table"><thead><tr><th> </th><th> </th><th> </th></tr></thead><tbody></tbody></table> <!></div> <!>',1);function vp(e,r){jt(r,!0);let n=gr(r,"initial",3,""),a=gr(r,"withExtract",3,!0),i=z(Lt([])),o=z(""),s=z(void 0);const u=ne(()=>{const k=t(o).trim().toLowerCase();return t(i).filter(y=>k===""||y.topic.toLowerCase().includes(k)).slice(0,500)}),v=ne(()=>t(s)===void 0?[]:Uo(ci(t(s).payload)));async function m(){try{w(i,await He.topics(),!0)}catch(k){Ue.error(pt(k))}}Br(()=>{r.open&&(w(o,n().split("/").slice(0,2).join("/"),!0),w(s,void 0),m())}),en(()=>{const k=Er.wantMqtt(),y=Er.on(b=>{if(b.type!=="mqtt"||!r.open)return;const _=t(i).findIndex(T=>T.topic===b.topic),x={topic:b.topic,payload:b.payload,retain:b.retain,ts:b.ts};_===-1?w(i,[...t(i),x].sort((T,A)=>T.topic.localeCompare(A.topic)),!0):t(i)[_]=x,t(s)?.topic===b.topic&&w(s,x,!0)});return()=>{k(),y()}});{const k=b=>{var _=ip(),x=Oe(_),T=f(x,!0),A=l(x,2),C=f(A,!0);E((I,P)=>{c(T,I),A.disabled=t(s)===void 0,c(C,P)},[()=>d("Cancel"),()=>d("Use topic")]),M("click",x,function(...I){r.onclose?.apply(this,I)}),M("click",A,()=>t(s)&&r.onpick(t(s).topic)),g(b,_)};let y=ne(()=>d("Pick a topic"));xa(e,{get open(){return r.open},get title(){return t(y)},width:"760px",get onclose(){return r.onclose},testId:"topic-picker",buttons:k,children:(b,_)=>{var x=cp(),T=Oe(x),A=l(T,2),C=h(A),I=h(C),P=h(I),O=h(P),ee=f(O,!0),R=l(O),F=f(R,!0),D=l(R),q=f(D,!0),j=l(I);tt(j,21,()=>t(u),he=>he.topic,(he,Ce)=>{var rt=op();let ae;var de=h(rt),fe=h(de),Fe=f(fe,!0),$e=l(de),$=h($e),te=f($,!0),B=l($e),Y=f(B,!0);E(X=>{ae=Nt(rt,1,"ui-row-link",null,ae,{"ui-row-selected":t(Ce).topic===t(s)?.topic}),c(Fe,t(Ce).topic),c(te,t(Ce).payload),c(Y,X)},[()=>oi(t(Ce).ts)]),M("click",rt,()=>w(s,t(Ce),!0)),M("dblclick",rt,()=>r.onpick(t(Ce).topic)),g(he,rt)});var L=l(C,2);{var J=he=>{var Ce=sp(),rt=f(Ce,!0);E(ae=>c(rt,ae),[()=>d("No topic seen yet that matches.")]),g(he,Ce)};H(L,he=>{t(u).length===0&&he(J)})}var U=l(A,2);{var W=he=>{var Ce=dp(),rt=h(Ce),ae=h(rt),de=f(ae,!0),fe=l(rt,2),Fe=f(fe,!0),$e=l(fe,2);{var $=te=>{var B=up(),Y=Oe(B),X=f(Y,!0),ie=l(Y,2);tt(ie,21,()=>t(v),re=>re.path,(re,ce)=>{var Z=lp(),ue=h(Z),Ee=f(ue,!0),xe=l(ue,2),Ae=f(xe);E(V=>{c(Ee,t(ce).path),c(Ae,`= ${V??""}`)},[()=>ja(t(ce).value)]),M("click",Z,()=>t(s)&&r.onpick(t(s).topic,t(ce).path)),g(re,Z)}),E(re=>c(X,re),[()=>d("Click a key to use the topic with that JSON path:")]),g(te,B)};H($e,te=>{a()&&t(v).length>0&&te($)})}E(()=>{c(de,t(s).topic),c(Fe,t(s).payload)}),g(he,Ce)};H(U,he=>{t(s)&&he(W)})}E((he,Ce,rt,ae)=>{Q(T,"placeholder",he),c(ee,Ce),c(F,rt),c(q,ae)},[()=>d("Filter"),()=>d("Topic"),()=>d("Payload"),()=>d("Time")]),Le(T,()=>t(o),he=>w(o,he)),g(b,x)},$$slots:{buttons:!0,default:!0}})}zt()}lr(["click","dblclick"]);var fp=S('<button type="button" class="ui-button"> </button> <button type="button" class="ui-button ui-button-primary" data-testid="mapping-save"> </button>',1),Pa=S("<option> </option>"),pp=S('<select class="ui-select ui-field-medium"></select>'),hp=S('<select class="ui-select ui-field-medium" data-testid="mapping-cluster"><option> </option><!></select> <select class="ui-select" data-testid="mapping-member"><option> </option><!></select>',1),mp=S('<div class="ui-form-help"> </div>'),_p=S('<div class="ui-form-help"> <!> <!></div>'),gp=S('<div class="row svelte-92wfck"><input class="ui-input ui-mono" data-testid="map-key"/> <span>→</span> <input class="ui-input ui-mono" data-testid="map-value"/> <button type="button" class="ui-icon-button">✕</button></div>'),ol=S('<button type="button" class="ui-button"> </button>'),sl=S('<input class="ui-input ui-field-narrow" type="number"/>–<input class="ui-input ui-field-narrow" type="number"/> → <input class="ui-input ui-field-narrow" type="number"/>–<input class="ui-input ui-field-narrow" type="number"/>',1),ll=S("<code> </code>"),ul=S('<li><span class="ui-muted step svelte-92wfck"> </span> <!></li>'),dl=S('<div class="ui-error-text"> </div>'),bp=S('<ol class="stages svelte-92wfck" data-testid="status-stages"></ol> <!>',1),yp=S('<div class="ui-form compact svelte-92wfck"><label class="ui-form-label" for="status-topic"> </label> <div class="ui-form-field"><input id="status-topic" class="ui-input ui-mono" data-testid="status-topic"/> <button type="button" class="ui-button" data-testid="pick-status-topic"> </button></div> <label class="ui-form-label" for="status-extract"> </label> <div class="ui-form-field"><input id="status-extract" class="ui-input ui-mono" placeholder="$.state" data-testid="status-extract"/></div> <label class="ui-form-label" for="status-template"> </label> <div class="ui-form-field"><input id="status-template" class="ui-input ui-mono"/></div> <span class="ui-form-label"> </span> <div class="rows svelte-92wfck"><!> <div><button type="button" class="ui-button" data-testid="map-add"> </button> <!></div></div> <label class="ui-form-label" for="status-default"> </label> <div class="ui-form-field"><input id="status-default" class="ui-input ui-field-medium"/></div> <label class="ui-form-label" for="status-type"> </label> <div class="ui-form-field"><select id="status-type" class="ui-select ui-field-medium"><option> </option><option>boolean</option><option>number</option><option>string</option></select></div> <label class="ui-form-label" for="status-unit"> </label> <div class="ui-form-field"><select id="status-unit" class="ui-select ui-field-medium" data-testid="status-unit"><option> </option><!></select></div> <span class="ui-form-label"> </span> <div class="ui-form-field"><!> <!></div> <span class="ui-form-label"> </span> <div class="ui-form-field"><input class="ui-input ui-field-narrow" type="number" step="any"/> <input class="ui-input ui-field-narrow" type="number" min="0" max="10"/> <!></div> <label class="ui-form-label" for="status-expire"> </label> <div class="ui-form-field"><input id="status-expire" class="ui-input ui-field-narrow" type="number" min="1"/> <span class="ui-muted ui-small"> </span></div> <label class="ui-form-label" for="status-get"> </label> <div class="ui-form-field"><input id="status-get" class="ui-input ui-mono"/> <input class="ui-input ui-mono ui-field-medium"/></div></div> <div class="preview svelte-92wfck"><div class="ui-section-title"> </div> <div class="ui-form compact svelte-92wfck"><label class="ui-form-label" for="status-payload"> </label> <div class="ui-form-field"><textarea id="status-payload" class="ui-textarea" rows="2" data-testid="status-payload"></textarea></div></div> <!> <div><button type="button" class="ui-button" data-testid="send-status"> </button></div></div>',1),wp=S('<div class="row svelte-92wfck"><input class="ui-input ui-mono" data-testid="format-key"/> <span>→</span> <input class="ui-input ui-mono" data-testid="format-value"/> <button type="button" class="ui-icon-button">✕</button></div>'),kp=S('<button type="button" class="ui-button">ON / OFF</button>'),xp=S('<select id="command-value" class="ui-select"><option>—</option><!></select>'),Ep=S('<select id="command-value" class="ui-select ui-field-medium" data-testid="command-value"><option>—</option><option>true</option><option>false</option></select>'),Tp=S('<input id="command-value" class="ui-input ui-mono" data-testid="command-value"/>'),Sp=S('<ol class="stages svelte-92wfck" data-testid="command-stages"></ol> <!>',1),Cp=S('<div class="ui-form compact svelte-92wfck"><label class="ui-form-label" for="command-topic"> </label> <div class="ui-form-field"><input id="command-topic" class="ui-input ui-mono" data-testid="command-topic"/> <button type="button" class="ui-button"> </button></div> <label class="ui-form-label" for="command-unit"> </label> <div class="ui-form-field"><select id="command-unit" class="ui-select ui-field-medium"><option> </option><!></select></div> <span class="ui-form-label"> </span> <div class="ui-form-field"><!> <!></div> <span class="ui-form-label"> </span> <div class="ui-form-field"><input class="ui-input ui-field-narrow" type="number" step="any"/> <input class="ui-input ui-field-narrow" type="number" min="0" max="10"/> <input class="ui-input ui-field-narrow" type="number" min="0" max="10"/> <!></div> <span class="ui-form-label"> </span> <div class="rows svelte-92wfck"><!> <div><button type="button" class="ui-button" data-testid="format-add"> </button> <!> <!></div></div> <label class="ui-form-label" for="command-payload"> </label> <div class="ui-form-field"><input id="command-payload" class="ui-input ui-mono"/></div> <label class="ui-form-label" for="command-template"> </label> <div class="ui-form-field"><input id="command-template" class="ui-input ui-mono"/></div> <label class="ui-form-label" for="command-wrap"> </label> <div class="ui-form-field"><input id="command-wrap" class="ui-input ui-mono" placeholder="state" data-testid="command-wrap"/></div> <span class="ui-form-label"> </span> <div class="ui-form-field"><!> <select class="ui-select ui-field-narrow"><option>QoS 0</option><option>QoS 1</option><option>QoS 2</option></select> <select class="ui-select ui-field-medium"><option> </option><option> </option><option> </option></select></div></div> <div class="preview svelte-92wfck"><div class="ui-section-title"> </div> <div class="ui-form compact svelte-92wfck"><label class="ui-form-label" for="command-value"> </label> <div class="ui-form-field"><!></div></div> <!> <div><button type="button" class="ui-button" data-testid="send-command"> </button></div></div>',1),Ap=S('<div class="ui-form compact svelte-92wfck"><span class="ui-form-label"> </span> <div class="ui-form-field"><select class="ui-select ui-field-medium" data-testid="mapping-kind"><option> </option><option> </option><option> </option></select> <!></div> <!> <label class="ui-form-label" for="mapping-comment"> </label> <div class="ui-form-field"><input id="mapping-comment" class="ui-input"/></div></div> <div class="halves svelte-92wfck"><section class="ui-section"><div class="ui-section-title"><!></div> <!></section> <section class="ui-section"><div class="ui-section-title"><!></div> <!></section></div>',1),Pp=S("<!> <!>",1);function Np(e,r){jt(r,!0);let n=z("attribute"),a=z(""),i=z(""),o=z(""),s=z(void 0),u=z(void 0),v=z(Lt([])),m=z(Lt([])),k=z("auto"),y=z(void 0),b=z(""),_=z(void 0),x=z(""),T=z(void 0),A=z(void 0);const C=ne(()=>t(a)===""||t(i)===""?"":t(n)==="event"?t(a):`${t(a)}.${t(i)}`),I=ne(()=>[...r.endpointClusters,...r.catalog.clusters.filter($=>!r.endpointClusters.includes($))]),P=ne(()=>t(y)?.attributes.find($=>$.name===t(i))),O=ne(()=>r.catalog.composites[t(C)]),ee=ne(()=>{if(t(n)==="event")return[];if(t(n)==="invoke")return(t(y)?.commands??[]).map(B=>({name:B.name,hint:B.fields.join(", ")}));const $=(t(y)?.attributes??[]).map(B=>({name:B.name,hint:`${B.metatype}${B.writable?` · ${d("writable")}`:""}${B.conformance==="M"?` · ${d("mandatory")}`:""}`}));return[...Object.entries(r.catalog.composites).filter(([,B])=>B.cluster===t(a)).map(([B,Y])=>({name:B.split(".")[1]??B,hint:Y.description})),...$]}),R=ne(()=>t(P)?.enumMembers===void 0?[]:Object.keys(t(P).enumMembers));Br(()=>{if(!r.open)return;const $=Oi(r.mapping);w(n,$.kind,!0),w(a,$.kind==="event"?$.name||"Switch":as($.name),!0),w(i,$.kind==="event"?"Switch":$.name.split(".")[1]??"",!0),w(o,r.mapping.comment??"",!0),w(s,r.mapping.status===void 0?void 0:structuredClone(Xa(r.mapping.status)),!0),w(u,r.mapping.command===void 0?void 0:structuredClone(Xa(r.mapping.command)),!0),w(v,Object.entries(r.mapping.status?.map??{}).map(([te,B])=>({key:te,value:String(B)})),!0),w(m,Object.entries(r.mapping.command?.format??{}).map(([te,B])=>({key:te,value:B})),!0),w(k,r.mapping.command?.optimistic===void 0?"auto":r.mapping.command.optimistic?"true":"false",!0),w(_,void 0),w(T,void 0),w(x,""),w(b,""),F(r.mapping.status?.topic)}),Br(()=>{if(t(a)===""||t(n)==="event"){w(y,void 0);return}const $=t(a);He.cluster($).then(te=>{$===t(a)&&w(y,te,!0)},()=>{w(y,void 0)})});async function F($){if(!($===void 0||$===""))try{const te=(await He.topics($)).find(B=>B.topic===$);te!==void 0&&t(b)===""&&(w(b,te.payload,!0),q())}catch{}}function D(){const $={};if(t(n)==="attribute"?$.attribute=t(C):t(n)==="invoke"?$.invoke=t(C):$.event=t(a),t(o)!==""&&($.comment=t(o)),t(s)!==void 0){const te={...Xa(t(s))},B=Object.fromEntries(t(v).filter(Y=>Y.key!=="").map(Y=>[Y.key,il(Y.value)]));Object.keys(B).length>0?te.map=B:delete te.map,te.default!==void 0&&typeof te.default=="string"&&(te.default=il(te.default)),$.status=te}if(t(u)!==void 0){const te={...Xa(t(u))},B=Object.fromEntries(t(m).filter(Y=>Y.key!=="").map(Y=>[Y.key,Y.value]));Object.keys(B).length>0?te.format=B:delete te.format,t(k)==="auto"?delete te.optimistic:te.optimistic=t(k)==="true",$.command=te}return Eu($)}const q=Fo(()=>{const $=D();if($.status===void 0){w(_,void 0);return}He.previewStatus($.status,t(b),$.attribute).then(te=>w(_,te,!0),te=>{w(_,{stages:[],ok:!1,reason:pt(te)},!0)})},250),j=Fo(()=>{const $=D();if($.command===void 0){w(T,void 0);return}He.previewCommand($.command,ap(t(x)),$.attribute).then(te=>w(T,te,!0),te=>{w(T,{stages:[],ok:!1,reason:pt(te)},!0)})},250);function L(){q(),j()}async function J($,te){if(!($===void 0||$===""||typeof te!="string"))try{await He.publish($,te),Ue.info(d("Published to {topic}",{topic:$}))}catch(B){Ue.error(pt(B))}}function U($){w(s,$?{topic:""}:void 0,!0),L()}function W($){w(u,$?{topic:""}:void 0,!0),L()}function he($){return $.scale??={from:[0,100],to:[0,100]},$.scale}function Ce($,te){te?he($):delete $.scale,L()}function rt($,te){t(A)==="status"&&t(s)!==void 0?(t(s).topic=$,te!==void 0&&(t(s).extract=te),F($)):t(A)==="command"&&t(u)!==void 0?t(u).topic=$:t(A)==="get"&&t(s)!==void 0&&(t(s).get={topic:$,payload:t(s).get?.payload??""}),w(A,void 0),L()}function ae(){t(C)===""||t(s)===void 0&&t(u)===void 0||r.onsave(D())}function de($){return $===""?void 0:Number($)}en(()=>()=>{});var fe=Pp(),Fe=Oe(fe);{const $=B=>{var Y=fp(),X=Oe(Y),ie=f(X,!0),re=l(X,2),ce=f(re,!0);E((Z,ue)=>{c(ie,Z),re.disabled=t(C)===""||t(s)===void 0&&t(u)===void 0,c(ce,ue)},[()=>d("Cancel"),()=>d("Apply")]),M("click",X,function(...Z){r.onclose?.apply(this,Z)}),M("click",re,ae),g(B,Y)};let te=ne(()=>t(C)===""?d("Mapping"):t(C));xa(Fe,{get open(){return r.open},get title(){return t(te)},width:"980px",get onclose(){return r.onclose},testId:"mapping-editor",buttons:$,children:(B,Y)=>{var X=Ap(),ie=Oe(X),re=h(ie),ce=f(re,!0),Z=l(re,2),ue=h(Z),Ee=h(ue),xe=f(Ee,!0);Ee.value=Ee.__value="attribute";var Ae=l(Ee),V=f(Ae,!0);Ae.value=Ae.__value="invoke";var me=l(Ae),Se=f(me,!0);me.value=me.__value="event",er(ue);var Ge=l(ue,2);{var se=ge=>{var pe=pp();tt(pe,20,()=>r.catalog.eventChannels,be=>be,(be,De)=>{var Ve=Pa(),dt=f(Ve,!0),ht={};E(()=>{c(dt,De),ht!==(ht=De)&&(Ve.value=(Ve.__value=ht)??"")}),g(be,Ve)}),er(pe),M("change",pe,L),xr(pe,()=>t(a),be=>w(a,be)),g(ge,pe)},_e=ge=>{var pe=hp(),be=Oe(pe),De=h(be),Ve=f(De,!0);De.value=De.__value="";var dt=l(De);tt(dt,16,()=>t(I),We=>We,(We,ct)=>{var gt=Pa(),Rt=f(gt,!0),Bt={};E(()=>{c(Rt,ct),Bt!==(Bt=ct)&&(gt.value=(gt.__value=Bt)??"")}),g(We,gt)}),er(be);var ht=l(be,2),it=h(ht),At=f(it,!0);it.value=it.__value="";var Mt=l(it);tt(Mt,17,()=>t(ee),We=>We.name,(We,ct)=>{var gt=Pa(),Rt=f(gt),Bt={};E(()=>{c(Rt,`${t(ct).name??""} — ${t(ct).hint??""}`),Bt!==(Bt=t(ct).name)&&(gt.value=(gt.__value=Bt)??"")}),g(We,gt)}),er(ht),E((We,ct)=>{c(Ve,We),c(At,ct)},[()=>d("— cluster —"),()=>t(n)==="invoke"?d("— command —"):d("— attribute —")]),M("change",be,()=>{w(i,""),L()}),xr(be,()=>t(a),We=>w(a,We)),M("change",ht,L),xr(ht,()=>t(i),We=>w(i,We)),g(ge,pe)};H(Ge,ge=>{t(n)==="event"?ge(se):ge(_e,-1)})}var Te=l(Z,2);{var le=ge=>{var pe=mp(),be=f(pe,!0);E(()=>c(be,t(O).description)),g(ge,pe)},Je=ge=>{var pe=_p(),be=h(pe),De=l(be);{var Ve=it=>{var At=ma();E(Mt=>c(At,`· ${Mt??""}`),[()=>t(R).join(", ")]),g(it,At)};H(De,it=>{t(R).length>0&&it(Ve)})}var dt=l(De,2);{var ht=it=>{var At=ma();E(Mt=>c(At,`· ${Mt??""}`),[()=>t(P).bitFields.map(Mt=>Mt.name).join(", ")]),g(it,At)};H(dt,it=>{t(P).bitFields&&it(ht)})}E(it=>c(be,`${t(P).metatype??""}${it??""}${t(P).min!==void 0||t(P).max!==void 0?` · ${t(P).min??""}–${t(P).max??""}`:""} `),[()=>t(P).nullable?` · ${d("nullable")}`:""]),g(ge,pe)};H(Te,ge=>{t(O)?ge(le):t(P)&&ge(Je,1)})}var Ye=l(Te,2),mt=f(Ye,!0),_t=l(Ye,2),yt=h(_t),Ne=l(ie,2),ke=h(Ne),Be=h(ke),Ze=h(Be);{let ge=ne(()=>t(s)!==void 0),pe=ne(()=>d("Status (device → Matter)"));Zr(Ze,{get checked(){return t(ge)},get label(){return t(pe)},onchange:U,testId:"status-enabled"})}var wt=l(Be,2);{var N=ge=>{var pe=yp(),be=Oe(pe),De=h(be),Ve=f(De,!0),dt=l(De,2),ht=h(dt),it=l(ht,2),At=f(it,!0),Mt=l(dt,2),We=f(Mt,!0),ct=l(Mt,2),gt=h(ct),Rt=l(ct,2),Bt=f(Rt,!0),dr=l(Rt,2),Ot=h(dr);Q(Ot,"placeholder","{{ value_json.state }}");var Ht=l(dr,2),qt=f(Ht,!0),Re=l(Ht,2),Ie=h(Re);tt(Ie,17,()=>t(v),ba,(Me,Pt,oe)=>{var we=gp(),Pe=h(we),Ke=l(Pe,4),ze=l(Ke,2);E((ft,Ct,Kt)=>{Q(Pe,"placeholder",ft),Q(Ke,"placeholder",Ct),Q(ze,"title",Kt)},[()=>d("payload"),()=>d("value"),()=>d("Remove")]),M("input",Pe,L),Le(Pe,()=>t(Pt).key,ft=>t(Pt).key=ft),M("input",Ke,L),Le(Ke,()=>t(Pt).value,ft=>t(Pt).value=ft),M("click",ze,()=>{t(v).splice(oe,1),L()}),g(Me,we)});var vt=l(Ie,2),ot=h(vt),$t=f(ot),cr=l(ot,2);{var vr=Me=>{var Pt=ol(),oe=f(Pt,!0);E(we=>c(oe,we),[()=>d("Enum names")]),M("click",Pt,()=>{w(v,t(R).map(we=>({key:we.toLowerCase(),value:we})),!0),L()}),g(Me,Pt)};H(cr,Me=>{t(R).length>0&&t(v).length===0&&Me(vr)})}var Jt=l(Re,2),Sr=f(Jt,!0),lt=l(Jt,2),St=h(lt),Dt=l(lt,2),It=f(Dt,!0),hn=l(Dt,2),qr=h(hn),fr=h(qr),da=f(fr,!0);fr.value=(fr.__value=void 0)??"";var Mr=l(fr);Mr.value=Mr.__value="boolean";var zn=l(Mr);zn.value=zn.__value="number";var Hn=l(zn);Hn.value=Hn.__value="string",er(qr);var ye=l(hn,2),ut=f(ye,!0),nt=l(ye,2),Gt=h(nt),Xt=h(Gt),Rr=f(Xt,!0);Xt.value=(Xt.__value=void 0)??"";var Ur=l(Xt);tt(Ur,16,()=>r.catalog.units,Me=>Me,(Me,Pt)=>{var oe=Pa(),we=f(oe,!0),Pe={};E(()=>{c(we,Pt),Pe!==(Pe=Pt)&&(oe.value=(oe.__value=Pe)??"")}),g(Me,oe)}),er(Gt);var Fr=l(nt,2),Cr=f(Fr,!0),jr=l(Fr,2),zr=h(jr);{let Me=ne(()=>t(s).scale!==void 0);Zr(zr,{get checked(){return t(Me)},onchange:Pt=>t(s)&&Ce(t(s),Pt)})}var tn=l(zr,2);{var Vt=Me=>{var Pt=sl(),oe=Oe(Pt),we=l(oe,2),Pe=l(we,2),Ke=l(Pe,2);M("input",oe,L),Le(oe,()=>t(s).scale.from[0],ze=>t(s).scale.from[0]=ze),M("input",we,L),Le(we,()=>t(s).scale.from[1],ze=>t(s).scale.from[1]=ze),M("input",Pe,L),Le(Pe,()=>t(s).scale.to[0],ze=>t(s).scale.to[0]=ze),M("input",Ke,L),Le(Ke,()=>t(s).scale.to[1],ze=>t(s).scale.to[1]=ze),g(Me,Pt)};H(tn,Me=>{t(s).scale&&Me(Vt)})}var yr=l(jr,2),Hr=f(yr,!0),mn=l(yr,2),_n=h(mn),pr=l(_n,2),$n=l(pr,2);{let Me=ne(()=>t(s).invert===!0),Pt=ne(()=>d("invert"));Zr($n,{get checked(){return t(Me)},get label(){return t(Pt)},onchange:oe=>{t(s)&&(t(s).invert=oe?!0:void 0),L()}})}var je=l(mn,2),Xe=f(je,!0),et=l(je,2),Ut=h(et),Wt=l(Ut,2),nr=f(Wt,!0),ur=l(et,2),rn=f(ur,!0),nn=l(ur,2),$r=h(nn),an=l($r,2),Gn=l(be,2),gn=h(Gn),Xn=f(gn,!0),Vn=l(gn,2),Gr=h(Vn),hr=f(Gr,!0),bn=l(Gr,2),An=h(bn),Vr=l(Vn,2);{var Pn=Me=>{var Pt=bp(),oe=Oe(Pt);tt(oe,21,()=>t(_).stages,Ke=>Ke.step,(Ke,ze)=>{var ft=ul();let Ct;var Kt=h(ft),Ar=f(Kt,!0),mr=l(Kt,2);{var sn=wr=>{var Ir=ll(),Or=f(Ir,!0);E(Qe=>c(Or,Qe),[()=>ja(t(ze).value)]),g(wr,Ir)},Kr=wr=>{var Ir=ma();E(()=>c(Ir,t(ze).reason)),g(wr,Ir)};H(mr,wr=>{t(ze).ok?wr(sn):wr(Kr,-1)})}E(()=>{Ct=Nt(ft,1,"",null,Ct,{"ui-error-text":!t(ze).ok}),c(Ar,t(ze).step)}),g(Ke,ft)});var we=l(oe,2);{var Pe=Ke=>{var ze=dl(),ft=f(ze,!0);E(()=>c(ft,t(_).reason)),g(Ke,ze)};H(we,Ke=>{t(_).stages.length===0&&t(_).reason&&Ke(Pe)})}g(Me,Pt)};H(Vr,Me=>{t(_)&&Me(Pn)})}var ea=l(Vr,2),on=h(ea),yn=f(on,!0);E((Me,Pt,oe,we,Pe,Ke,ze,ft,Ct,Kt,Ar,mr,sn,Kr,wr,Ir,Or,Qe,kt,xt,Qt,ar,kr)=>{c(Ve,Me),c(At,Pt),c(We,oe),c(Bt,we),c(qt,Pe),c($t,`+ ${Ke??""}`),c(Sr,ze),c(It,ft),c(da,Ct),c(ut,Kt),c(Rr,Ar),c(Cr,mr),c(Hr,sn),Q(_n,"placeholder",Kr),In(_n,t(s).offset??""),Q(pr,"placeholder",wr),In(pr,t(s).round??""),c(Xe,Ir),In(Ut,t(s).expire??""),c(nr,Or),c(rn,Qe),Q($r,"placeholder",kt),In($r,t(s).get?.topic??""),Q(an,"placeholder",xt),In(an,t(s).get?.payload??""),c(Xn,Qt),c(hr,ar),on.disabled=t(s).topic===""||t(b)==="",c(yn,kr)},[()=>d("Topic"),()=>d("Pick"),()=>d("Extract (JSON path)"),()=>d("Template"),()=>d("Map"),()=>d("Row"),()=>d("Default"),()=>d("Type"),()=>d("— none —"),()=>d("Unit"),()=>d("— none —"),()=>d("Scale"),()=>d("Offset / round / invert"),()=>d("offset"),()=>d("round"),()=>d("Expire (s)"),()=>d("without a message for this long the device is unreachable"),()=>d("Get request"),()=>d("topic"),()=>d("payload"),()=>d("Preview"),()=>d("Payload"),()=>d("Publish as the device would")]),M("input",ht,L),Le(ht,()=>t(s).topic,Me=>t(s).topic=Me),M("click",it,()=>w(A,"status")),M("input",gt,L),Le(gt,()=>t(s).extract,Me=>t(s).extract=Me),M("input",Ot,L),Le(Ot,()=>t(s).template,Me=>t(s).template=Me),M("click",ot,()=>t(v).push({key:"",value:""})),M("input",St,L),Le(St,()=>t(s).default,Me=>t(s).default=Me),M("change",qr,L),xr(qr,()=>t(s).type,Me=>t(s).type=Me),M("change",Gt,L),xr(Gt,()=>t(s).unit,Me=>t(s).unit=Me),M("input",_n,Me=>{t(s)&&(t(s).offset=de(Me.currentTarget.value)),L()}),M("input",pr,Me=>{t(s)&&(t(s).round=de(Me.currentTarget.value)),L()}),M("input",Ut,Me=>{t(s)&&(t(s).expire=de(Me.currentTarget.value))}),M("input",$r,Me=>{t(s)&&(t(s).get={topic:Me.currentTarget.value,payload:t(s).get?.payload??""})}),M("input",an,Me=>{t(s)&&(t(s).get={topic:t(s).get?.topic??"",payload:Me.currentTarget.value})}),M("input",An,q),Le(An,()=>t(b),Me=>w(b,Me)),M("click",on,()=>J(t(s)?.topic,t(b))),g(ge,pe)};H(wt,ge=>{t(s)&&ge(N)})}var K=l(ke,2),G=h(K),ve=h(G);{let ge=ne(()=>t(u)!==void 0),pe=ne(()=>d("Command (Matter → device)"));Zr(ve,{get checked(){return t(ge)},get label(){return t(pe)},onchange:W,testId:"command-enabled"})}var qe=l(G,2);{var at=ge=>{var pe=Cp(),be=Oe(pe),De=h(be),Ve=f(De,!0),dt=l(De,2),ht=h(dt),it=l(ht,2),At=f(it,!0),Mt=l(dt,2),We=f(Mt,!0),ct=l(Mt,2),gt=h(ct),Rt=h(gt),Bt=f(Rt,!0);Rt.value=(Rt.__value=void 0)??"";var dr=l(Rt);tt(dr,16,()=>r.catalog.units,oe=>oe,(oe,we)=>{var Pe=Pa(),Ke=f(Pe,!0),ze={};E(()=>{c(Ke,we),ze!==(ze=we)&&(Pe.value=(Pe.__value=ze)??"")}),g(oe,Pe)}),er(gt);var Ot=l(ct,2),Ht=f(Ot,!0),qt=l(Ot,2),Re=h(qt);{let oe=ne(()=>t(u).scale!==void 0);Zr(Re,{get checked(){return t(oe)},onchange:we=>t(u)&&Ce(t(u),we)})}var Ie=l(Re,2);{var vt=oe=>{var we=sl(),Pe=Oe(we),Ke=l(Pe,2),ze=l(Ke,2),ft=l(ze,2);M("input",Pe,L),Le(Pe,()=>t(u).scale.from[0],Ct=>t(u).scale.from[0]=Ct),M("input",Ke,L),Le(Ke,()=>t(u).scale.from[1],Ct=>t(u).scale.from[1]=Ct),M("input",ze,L),Le(ze,()=>t(u).scale.to[0],Ct=>t(u).scale.to[0]=Ct),M("input",ft,L),Le(ft,()=>t(u).scale.to[1],Ct=>t(u).scale.to[1]=Ct),g(oe,we)};H(Ie,oe=>{t(u).scale&&oe(vt)})}var ot=l(qt,2),$t=f(ot,!0),cr=l(ot,2),vr=h(cr),Jt=l(vr,2),Sr=l(Jt,2),lt=l(Sr,2);{let oe=ne(()=>t(u).invert===!0),we=ne(()=>d("invert"));Zr(lt,{get checked(){return t(oe)},get label(){return t(we)},onchange:Pe=>{t(u)&&(t(u).invert=Pe?!0:void 0),L()}})}var St=l(cr,2),Dt=f(St,!0),It=l(St,2),hn=h(It);tt(hn,17,()=>t(m),ba,(oe,we,Pe)=>{var Ke=wp(),ze=h(Ke),ft=l(ze,4),Ct=l(ft,2);E((Kt,Ar,mr)=>{Q(ze,"placeholder",Kt),Q(ft,"placeholder",Ar),Q(Ct,"title",mr)},[()=>d("value"),()=>d("payload"),()=>d("Remove")]),M("input",ze,L),Le(ze,()=>t(we).key,Kt=>t(we).key=Kt),M("input",ft,L),Le(ft,()=>t(we).value,Kt=>t(we).value=Kt),M("click",Ct,()=>{t(m).splice(Pe,1),L()}),g(oe,Ke)});var qr=l(hn,2),fr=h(qr),da=f(fr),Mr=l(fr,2);{var zn=oe=>{var we=kp();M("click",we,()=>{w(m,[{key:"true",value:"ON"},{key:"false",value:"OFF"}],!0),L()}),g(oe,we)};H(Mr,oe=>{t(P)?.metatype==="boolean"&&t(m).length===0&&oe(zn)})}var Hn=l(Mr,2);{var ye=oe=>{var we=ol(),Pe=f(we,!0);E(Ke=>c(Pe,Ke),[()=>d("Enum names")]),M("click",we,()=>{w(m,t(R).map(Ke=>({key:Ke,value:Ke.toLowerCase()})),!0),L()}),g(oe,we)};H(Hn,oe=>{t(R).length>0&&t(m).length===0&&oe(ye)})}var ut=l(It,2),nt=f(ut,!0),Gt=l(ut,2),Xt=h(Gt),Rr=l(Gt,2),Ur=f(Rr,!0),Fr=l(Rr,2),Cr=h(Fr);Q(Cr,"placeholder",'{"brightness": {{ brightness }}}');var jr=l(Fr,2),zr=f(jr,!0),tn=l(jr,2),Vt=h(tn),yr=l(tn,2),Hr=f(yr,!0),mn=l(yr,2),_n=h(mn);{let oe=ne(()=>t(u).retain===!0),we=ne(()=>d("retain"));Zr(_n,{get checked(){return t(oe)},get label(){return t(we)},onchange:Pe=>{t(u)&&(t(u).retain=Pe?!0:void 0)}})}var pr=l(_n,2),$n=h(pr);$n.value=$n.__value=0;var je=l($n);je.value=je.__value=1;var Xe=l(je);Xe.value=Xe.__value=2;var et;er(pr);var Ut=l(pr,2),Wt=h(Ut),nr=f(Wt,!0);Wt.value=Wt.__value="auto";var ur=l(Wt),rn=f(ur,!0);ur.value=ur.__value="true";var nn=l(ur),$r=f(nn,!0);nn.value=nn.__value="false",er(Ut);var an=l(be,2),Gn=h(an),gn=f(Gn,!0),Xn=l(Gn,2),Vn=h(Xn),Gr=f(Vn,!0),hr=l(Vn,2),bn=h(hr);{var An=oe=>{var we=xp(),Pe=h(we);Pe.value=Pe.__value="";var Ke=l(Pe);tt(Ke,17,()=>Object.entries(t(P).enumMembers),([ze,ft])=>ze,(ze,ft)=>{var Ct=ne(()=>Ci(t(ft),2));let Kt=()=>t(Ct)[0],Ar=()=>t(Ct)[1];var mr=Pa(),sn=f(mr),Kr={};E(wr=>{c(sn,`${Kt()??""} (${Ar()??""})`),Kr!==(Kr=wr)&&(mr.value=(mr.__value=Kr)??"")},[()=>String(Ar())]),g(ze,mr)}),er(we),M("change",we,j),xr(we,()=>t(x),ze=>w(x,ze)),g(oe,we)},Vr=oe=>{var we=Ep(),Pe=h(we);Pe.value=Pe.__value="";var Ke=l(Pe);Ke.value=Ke.__value="true";var ze=l(Ke);ze.value=ze.__value="false",er(we),M("change",we,j),xr(we,()=>t(x),ft=>w(x,ft)),g(oe,we)},Pn=oe=>{var we=Tp();E(Pe=>Q(we,"placeholder",Pe),[()=>d("a number, text or JSON")]),M("input",we,j),Le(we,()=>t(x),Pe=>w(x,Pe)),g(oe,we)};H(bn,oe=>{t(R).length>0&&t(P)?.enumMembers?oe(An):t(P)?.metatype==="boolean"?oe(Vr,1):oe(Pn,-1)})}var ea=l(Xn,2);{var on=oe=>{var we=Sp(),Pe=Oe(we);tt(Pe,21,()=>t(T).stages,ft=>ft.step,(ft,Ct)=>{var Kt=ul();let Ar;var mr=h(Kt),sn=f(mr,!0),Kr=l(mr,2);{var wr=Or=>{var Qe=ll(),kt=f(Qe,!0);E(xt=>c(kt,xt),[()=>ja(t(Ct).value)]),g(Or,Qe)},Ir=Or=>{var Qe=ma();E(()=>c(Qe,t(Ct).reason)),g(Or,Qe)};H(Kr,Or=>{t(Ct).ok?Or(wr):Or(Ir,-1)})}E(()=>{Ar=Nt(Kt,1,"",null,Ar,{"ui-error-text":!t(Ct).ok}),c(sn,t(Ct).step)}),g(ft,Kt)});var Ke=l(Pe,2);{var ze=ft=>{var Ct=dl(),Kt=f(Ct,!0);E(()=>c(Kt,t(T).reason)),g(ft,Ct)};H(Ke,ft=>{t(T).stages.length===0&&t(T).reason&&ft(ze)})}g(oe,we)};H(ea,oe=>{t(T)&&oe(on)})}var yn=l(ea,2),Me=h(yn),Pt=f(Me,!0);E((oe,we,Pe,Ke,ze,ft,Ct,Kt,Ar,mr,sn,Kr,wr,Ir,Or,Qe,kt,xt,Qt,ar,kr)=>{c(Ve,oe),c(At,we),c(We,Pe),c(Bt,Ke),c(Ht,ze),c($t,ft),Q(vr,"placeholder",Ct),In(vr,t(u).offset??""),Q(Jt,"placeholder",Kt),In(Jt,t(u).round??""),Q(Sr,"placeholder",Ar),In(Sr,t(u).precision??""),c(Dt,mr),c(da,`+ ${sn??""}`),c(nt,Kr),c(Ur,wr),c(zr,Ir),c(Hr,Or),et!==(et=t(u).qos??0)&&(pr.value=(pr.__value=et)??"",ka(pr,et)),c(nr,Qe),c(rn,kt),c($r,xt),c(gn,Qt),c(Gr,ar),Me.disabled=t(u).topic===""||t(T)?.ok!==!0,c(Pt,kr)},[()=>d("Topic"),()=>d("Pick"),()=>d("Unit"),()=>d("— none —"),()=>d("Scale"),()=>d("Offset / round / invert"),()=>d("offset"),()=>d("round"),()=>d("precision"),()=>d("Format"),()=>d("Row"),()=>d("Fixed payload"),()=>d("Template"),()=>d("Wrap (JSON path)"),()=>d("Retain / QoS / optimistic"),()=>d("optimistic: automatic"),()=>d("optimistic: yes"),()=>d("optimistic: no"),()=>d("Preview"),()=>d("Matter value"),()=>d("Test-publish")]),M("input",ht,L),Le(ht,()=>t(u).topic,oe=>t(u).topic=oe),M("click",it,()=>w(A,"command")),M("change",gt,L),xr(gt,()=>t(u).unit,oe=>t(u).unit=oe),M("input",vr,oe=>{t(u)&&(t(u).offset=de(oe.currentTarget.value)),L()}),M("input",Jt,oe=>{t(u)&&(t(u).round=de(oe.currentTarget.value)),L()}),M("input",Sr,oe=>{t(u)&&(t(u).precision=de(oe.currentTarget.value)),L()}),M("click",fr,()=>t(m).push({key:"",value:""})),M("input",Xt,L),Le(Xt,()=>t(u).payload,oe=>t(u).payload=oe),M("input",Cr,L),Le(Cr,()=>t(u).template,oe=>t(u).template=oe),M("input",Vt,L),Le(Vt,()=>t(u).wrap,oe=>t(u).wrap=oe),M("change",pr,oe=>{t(u)&&(t(u).qos=Number(oe.currentTarget.value))}),xr(Ut,()=>t(k),oe=>w(k,oe)),M("click",Me,()=>J(t(u)?.topic,t(T)?.result)),g(ge,pe)};H(qe,ge=>{t(u)&&ge(at)})}E((ge,pe,be,De,Ve)=>{c(ce,ge),c(xe,pe),c(V,be),c(Se,De),c(mt,Ve)},[()=>d("Kind"),()=>d("attribute"),()=>d("command (invoke)"),()=>d("event channel"),()=>d("Comment")]),M("change",ue,()=>{w(i,t(n)==="event"?"Switch":"",!0),t(n)==="event"&&w(a,"Switch"),L()}),xr(ue,()=>t(n),ge=>w(n,ge)),Le(yt,()=>t(o),ge=>w(o,ge)),g(B,X)},$$slots:{buttons:!0,default:!0}})}var $e=l(Fe,2);{let $=ne(()=>t(A)!==void 0),te=ne(()=>t(A)==="command"?t(u)?.topic??"":t(s)?.topic??""),B=ne(()=>t(A)==="status");vp($e,{get open(){return t($)},get initial(){return t(te)},get withExtract(){return t(B)},onpick:rt,onclose:()=>w(A,void 0)})}g(e,fe),zt()}lr(["click","change","input"]);var Mp=S('<span class="ui-badge ui-badge-ok"> </span>'),xi=S('<span class="ui-badge"> </span>'),xo=S('<span class="ui-badge ui-badge-warn"> </span>'),cl=S("<!> <!>",1),Rp=S('<span class="ui-error-text"> </span>'),Ip=S('<div class="ui-page-scroll column svelte-21g4qu"><textarea class="ui-textarea json svelte-21g4qu" spellcheck="false" data-testid="device-json"></textarea> <div class="ui-toolbar"><button type="button" class="ui-button ui-button-primary" data-testid="apply-json"> </button> <!></div></div>'),Op=S('<section class="ui-section"><div class="ui-section-title"> </div> <!></section>'),Eo=S("<option> </option>"),Dp=S("<code> </code>"),Lp=S('<label class="ui-form-label"> </label> <div class="ui-form-field"><input class="ui-input ui-mono"/> <input class="ui-input ui-mono ui-field-narrow"/> <input class="ui-input ui-field-narrow"/> <input class="ui-input ui-field-narrow"/> <button type="button" class="ui-icon-button"><!></button></div>',1),Bp=S('<div class="ui-form"><label class="ui-form-label" for="av-mode"> </label> <div class="ui-form-field"><select id="av-mode" class="ui-select ui-field-medium"><option>latest</option><option>all</option><option>any</option></select></div> <!> <span></span> <div><button type="button" class="ui-button"> </button></div> <div class="ui-form-help"> </div></div>'),qp=S('<div class="ui-muted"> </div>'),Up=S('<button type="button" class="ui-icon-button"><!></button>'),Fp=S('<button type="button" class="chip-remove svelte-21g4qu"><!></button>'),jp=S('<span class="chip svelte-21g4qu" data-testid="device-type-chip"> <!></span>'),zp=S('<select class="ui-select svelte-21g4qu"></select>'),Hp=S('<input type="checkbox"/>'),$p=S('<input class="ui-input ui-field-narrow" type="number" step="any"/>'),Gp=S('<label class="option svelte-21g4qu"><span class="ui-muted"> </span> <!></label>'),Vp=S('<div class="options svelte-21g4qu"><span class="ui-muted"> </span> <!></div>'),Kp=S('<span class="ui-faint"> </span>'),Jp=S('<tr class="ui-row-link" data-testid="mapping-row"><td><code> </code> <!> <!></td><td><code> </code></td><td><code> </code></td><td><code> </code></td><td class="ui-actions"><button type="button" class="ui-icon-button"><!></button> <button type="button" class="ui-icon-button" data-testid="remove-mapping"><!></button></td></tr>'),Wp=S('<button type="button" class="ui-button suggest svelte-21g4qu" data-testid="bind-suggestion"> </button>'),Qp=S('<tr class="suggestion svelte-21g4qu" data-testid="suggestion-row"><td colspan="4" class="svelte-21g4qu"><span class="ui-muted"> </span> <!> <!></td><td class="svelte-21g4qu"></td></tr>'),Yp=S('<section class="ui-section" data-testid="endpoint"><div class="ui-section-title"> <input class="ui-input ui-mono ui-field-medium"/> <!> <div class="ui-toolbar-trailing"><label class="ui-muted"> </label> <input class="ui-input ui-field-narrow" type="number" min="0" max="5000"/> <!></div></div> <div class="types svelte-21g4qu"><span class="ui-muted"> </span> <!> <select class="ui-select ui-field-medium" data-testid="add-device-type"><option> </option><!></select></div> <!> <table class="ui-table" data-testid="mappings"><thead><tr><th> </th><th> </th><th> </th><th> </th><th></th></tr></thead><tbody><!><!></tbody></table> <div><button type="button" class="ui-button" data-testid="add-mapping"> </button></div></section>'),Zp=S('<div class="ui-page-scroll column svelte-21g4qu"><!> <!> <div class="ui-split"><section class="ui-section"><div class="ui-section-title"> </div> <div class="ui-form"><label class="ui-form-label" for="dev-name"> </label> <div class="ui-form-field"><input id="dev-name" class="ui-input" maxlength="32" data-testid="device-name"/></div> <label class="ui-form-label" for="dev-vendor"> </label> <div class="ui-form-field"><input id="dev-vendor" class="ui-input" maxlength="32"/></div> <label class="ui-form-label" for="dev-model"> </label> <div class="ui-form-field"><input id="dev-model" class="ui-input" maxlength="32"/></div> <label class="ui-form-label" for="dev-serial"> </label> <div class="ui-form-field"><input id="dev-serial" class="ui-input" maxlength="32"/></div> <label class="ui-form-label" for="dev-bridge"> </label> <div class="ui-form-field"><select id="dev-bridge" class="ui-select ui-field-medium"><option> </option><!></select></div> <span class="ui-form-label"> </span> <div class="ui-form-field"><!></div> <span class="ui-form-label"> </span> <div class="ui-form-field"><span> </span> <!> <!></div></div></section> <section class="ui-section"><div class="ui-section-title"><!></div> <!></section></div> <!> <div><button type="button" class="ui-button" data-testid="add-endpoint"> </button></div></div>'),Xp=S('<div class="ui-empty"> </div>'),eh=S('<div class="ui-page" data-testid="device-editor"><div class="ui-toolbar"><button type="button" class="ui-button" data-testid="editor-back"> </button> <h2 class="title svelte-21g4qu"> <code class="ui-faint"> </code></h2> <!> <div class="ui-toolbar-trailing"><button type="button"> </button> <button type="button" data-testid="view-json">JSON</button> <button type="button" class="ui-button"> </button> <button type="button" class="ui-button" data-testid="check-device"> </button> <button type="button" class="ui-button ui-button-primary" data-testid="save-device"> </button></div></div> <!></div>');function th(e,r){jt(r,!0);let n=z(void 0),a=z(void 0),i=z(void 0),o=z(Lt([])),s=z(void 0),u=z(Lt([])),v=z(!1),m=z(!1),k=z(!1),y=z(void 0),b=z("form"),_=z(""),x=z(!1),T=z(void 0),A=Lt({});const C=ne(()=>ci(t(_))),I=ne(()=>(t(i)?.deviceTypes??[]).filter(N=>N.classification!=="node"&&N.name!=="RootNode"&&N.name!=="Aggregator").map(N=>N.name));function P(N){const K=new Map;for(const G of N.deviceTypes)for(const ve of t(i)?.deviceTypes.find(qe=>qe.name===G)?.clusters??[])ve.cluster==="Identify"||ve.cluster==="Groups"||ve.cluster==="ScenesManagement"||K.set(ve.cluster,(K.get(ve.cluster)??!1)||ve.mandatory);for(const G of nl(N))K.has(G)||K.set(G,!1);return[...K.entries()].map(([G,ve])=>({cluster:G,mandatory:ve})).sort((G,ve)=>Number(ve.mandatory)-Number(G.mandatory))}function O(N){return P(N).map(K=>K.cluster)}function ee(N){const K=new Set(N.mappings.map(G=>Oi(G).name));return P(N).map(({cluster:G,mandatory:ve})=>({cluster:G,mandatory:ve,targets:(Xf[G]??[]).filter(qe=>!K.has(qe.name))})).filter(G=>G.targets.length>0)}function R(N){const K=new Set([...O(N),...nl(N)]);return tp(K).map(G=>({family:G,options:N.options[G]??{}}))}const F=Fo(()=>{t(a)!==void 0&&He.validate(Za(t(a))).then(N=>w(u,N.issues,!0),()=>{})},300);function D(){w(v,!0),F()}async function q(){try{w(n,await He.device(r.key),!0),w(a,JSON.parse(JSON.stringify(t(n).device)),!0),w(u,t(n).issues,!0),w(s,t(n).state,!0),w(x,t(a).availability!==void 0),w(v,!1),w(_,Jn(t(a)),!0)}catch(N){Ue.error(pt(N)),r.onclose()}}en(()=>(q(),He.catalog().then(N=>w(i,N,!0)),He.bridges().then(N=>w(o,N,!0)),Er.on(N=>{if(N.type==="attribute"&&N.key===r.key&&t(s)!==void 0){const K=t(s)[N.endpoint];K!==void 0&&(K.state[N.cluster]={...K.state[N.cluster]??{},[N.attribute]:N.value})}})));async function j(){if(t(a)!==void 0){w(m,!0);try{const N=await He.saveDevice(r.key,Za(t(a)));w(n,N,!0),w(a,JSON.parse(JSON.stringify(N.device)),!0),w(u,N.issues,!0),w(s,N.state,!0),w(v,!1),w(_,Jn(t(a)),!0),Ue.info(N.built?d("{name} saved and built",{name:N.device.name}):d("{name} saved",{name:N.device.name}))}catch(N){Ue.error(pt(N))}finally{w(m,!1)}}}async function L(){if(t(a)!==void 0){w(k,!0);try{const N=await He.check({[r.key]:Za(t(a))});w(y,N.devices[r.key]??[],!0)}catch(N){Ue.error(pt(N))}finally{w(k,!1)}}}async function J(){t(v)&&!await rr.confirm(d("Discard the unsaved changes?"),{confirm:d("Discard"),danger:!0})||r.onclose()}function U(){vn(t(C))&&(w(a,t(C),!0),w(x,t(a).availability!==void 0),w(b,"form"),D())}function W(){t(a)!==void 0&&rs(`${r.key}.json`,Jn({[r.key]:Za(t(a))}))}function he(){if(t(a)===void 0)return;const N=`child${t(a).endpoints.length}`;t(a).endpoints.push(rp(N,["TemperatureSensor"])),D()}async function Ce(N){t(a)===void 0||N===0||await rr.confirm(d("Remove this endpoint and its mappings?"),{confirm:d("Remove"),danger:!0})&&(t(a).endpoints.splice(N,1),D())}function rt(N){const K=A[N],G=t(a)?.endpoints[N];G===void 0||K===void 0||K===""||G.deviceTypes.includes(K)||(G.deviceTypes.push(K),A[N]="",D())}function ae(N,K){const G=t(a)?.endpoints[N];G===void 0||G.deviceTypes.length<=1||(G.deviceTypes=G.deviceTypes.filter(ve=>ve!==K),D())}function de(N,K,G){w(T,{endpoint:N,index:K,mapping:G},!0)}function fe(N,K){w(T,{endpoint:N,index:-1,mapping:np(K)},!0)}function Fe(N){if(t(T)===void 0||t(a)===void 0)return;const K=t(a).endpoints[t(T).endpoint];K!==void 0&&(t(T).index===-1?K.mappings.push(N):K.mappings[t(T).index]=N,w(T,void 0),D())}function $e(N,K){t(a)?.endpoints[N]?.mappings.splice(K,1),D()}function $(N,K){const G=t(a)?.endpoints[N]?.mappings,ve=G?.[K];G!==void 0&&ve!==void 0&&(G.splice(K+1,0,structuredClone(Xa(ve))),D())}function te(N,K,G,ve){N.options[K]={...N.options[K]??{},[G]:ve},D()}function B(N){return{onOff:["momentary"],light:["onCommandType","transition","minMireds","maxMireds"],cover:["echoFilter","reportTimeout","tolerance"],climate:["minHeat","maxHeat","minCool","maxCool","deadband"],fan:["low","medium","speedMax"],switch:["kind","numberOfPositions","multiPressMax","multiPressDelay","longPressDelay","pressDuration"],powerSource:["warning","critical"]}[N]??[]}const Y={onOff:{momentary:0},light:{onCommandType:"last",transition:!0,minMireds:153,maxMireds:500},cover:{echoFilter:!1,reportTimeout:30,tolerance:100},climate:{minHeat:7,maxHeat:30,minCool:16,maxCool:32,deadband:2},fan:{low:33,medium:66,speedMax:0},switch:{kind:"momentary",numberOfPositions:2,multiPressMax:3,multiPressDelay:300,longPressDelay:500,pressDuration:50},powerSource:{warning:20,critical:10}};function X(N){t(a)!==void 0&&(w(x,N,!0),N?t(a).availability??={mode:"latest",topics:[{topic:"",online:"online",offline:"offline"}]}:delete t(a).availability,D())}function ie(N,K){const G=N[K];if(G===void 0)return"";const ve=[G.topic];return"extract"in G&&G.extract!==void 0&&ve.push(G.extract),G.unit!==void 0&&ve.push(G.unit),"map"in G&&G.map!==void 0&&ve.push(d("map")),"format"in G&&G.format!==void 0&&ve.push(d("format")),G.template!==void 0&&ve.push(d("template")),ve.join(" · ")}var re=eh(),ce=h(re),Z=h(ce),ue=f(Z),Ee=l(Z,2),xe=h(Ee),Ae=l(xe),V=f(Ae,!0),me=l(Ee,2);{var Se=N=>{var K=cl(),G=Oe(K);{var ve=be=>{var De=Mp(),Ve=f(De,!0);E(dt=>c(Ve,dt),[()=>d("endpoint {number}",{number:t(n).number})]),g(be,De)},qe=be=>{var De=xi(),Ve=f(De,!0);E(dt=>c(Ve,dt),[()=>d("disabled")]),g(be,De)},at=be=>{var De=xo(),Ve=f(De,!0);E(dt=>c(Ve,dt),[()=>d("not built")]),g(be,De)};H(G,be=>{t(n).built?be(ve):t(a)?.enabled===!1?be(qe,1):be(at,-1)})}var ge=l(G,2);{var pe=be=>{var De=xi(),Ve=f(De,!0);E(()=>c(Ve,t(n).bridge)),g(be,De)};H(ge,be=>{t(n).bridge&&be(pe)})}g(N,K)};H(me,N=>{t(n)&&N(Se)})}var Ge=l(me,2),se=h(Ge);let _e;var Te=f(se,!0),le=l(se,2);let Je;var Ye=l(le,2),mt=f(Ye,!0),_t=l(Ye,2),yt=f(_t,!0),Ne=l(_t,2),ke=f(Ne,!0),Be=l(ce,2);{var Ze=N=>{var K=cl(),G=Oe(K);{var ve=pe=>{var be=Ip(),De=h(be),Ve=l(De,2),dt=h(Ve),ht=f(dt,!0),it=l(dt,2);{var At=We=>{var ct=Rp(),gt=f(ct,!0);E(Rt=>c(gt,Rt),[()=>d("Not valid JSON")]),g(We,ct)},Mt=ne(()=>!vn(t(C)));H(it,We=>{t(Mt)&&We(At)})}E((We,ct)=>{dt.disabled=We,c(ht,ct)},[()=>!vn(t(C)),()=>d("Apply to the form")]),Le(De,()=>t(_),We=>w(_,We)),M("click",dt,U),g(pe,be)},qe=pe=>{var be=Zp(),De=h(be);{let je=ne(()=>d("The device validates."));Ii(De,{get issues(){return t(u)},get empty(){return t(je)}})}var Ve=l(De,2);{var dt=je=>{var Xe=Op(),et=h(Xe),Ut=f(et,!0),Wt=l(et,2);{let nr=ne(()=>d("matter.js builds the device without complaint."));Ii(Wt,{get issues(){return t(y)},get empty(){return t(nr)}})}E(nr=>c(Ut,nr),[()=>d("Strict dry run")]),g(je,Xe)};H(Ve,je=>{t(y)&&je(dt)})}var ht=l(Ve,2),it=h(ht),At=h(it),Mt=f(At,!0),We=l(At,2),ct=h(We),gt=f(ct,!0),Rt=l(ct,2),Bt=h(Rt),dr=l(Rt,2),Ot=f(dr,!0),Ht=l(dr,2),qt=h(Ht),Re=l(Ht,2),Ie=f(Re,!0),vt=l(Re,2),ot=h(vt),$t=l(vt,2),cr=f($t,!0),vr=l($t,2),Jt=h(vr),Sr=l(vr,2),lt=f(Sr,!0),St=l(Sr,2),Dt=h(St),It=h(Dt),hn=f(It,!0);It.value=(It.__value=void 0)??"";var qr=l(It);tt(qr,17,()=>t(o),je=>je.id,(je,Xe)=>{var et=Eo(),Ut=f(et,!0),Wt={};E(()=>{c(Ut,t(Xe).id),Wt!==(Wt=t(Xe).id)&&(et.value=(et.__value=Wt)??"")}),g(je,et)}),er(Dt);var fr=l(St,2),da=f(fr,!0),Mr=l(fr,2),zn=h(Mr);Zr(zn,{onchange:D,testId:"device-enabled",get checked(){return t(a).enabled},set checked(je){t(a).enabled=je}});var Hn=l(Mr,2),ye=f(Hn,!0),ut=l(Hn,2),nt=h(ut);let Gt;var Xt=f(nt,!0),Rr=l(nt,2);{var Ur=je=>{var Xe=Dp(),et=f(Xe,!0);E(()=>c(et,t(a).source.key)),g(je,Xe)};H(Rr,je=>{t(a).source.key&&je(Ur)})}var Fr=l(Rr,2);{var Cr=je=>{var Xe=xo(),et=f(Xe,!0);E(Ut=>c(et,Ut),[()=>d("orphaned")]),g(je,Xe)};H(Fr,je=>{t(a).source.orphaned&&je(Cr)})}var jr=l(it,2),zr=h(jr),tn=h(zr);{let je=ne(()=>d("Availability"));Zr(tn,{get checked(){return t(x)},get label(){return t(je)},onchange:X})}var Vt=l(zr,2);{var yr=je=>{var Xe=Bp(),et=h(Xe),Ut=f(et,!0),Wt=l(et,2),nr=h(Wt),ur=h(nr);ur.value=ur.__value="latest";var rn=l(ur);rn.value=rn.__value="all";var nn=l(rn);nn.value=nn.__value="any",er(nr);var $r=l(Wt,2);tt($r,17,()=>t(a).availability.topics,ba,(Gr,hr,bn)=>{var An=Lp(),Vr=Oe(An);Q(Vr,"for",`av-topic-${bn}`);var Pn=f(Vr,!0),ea=l(Vr,2),on=h(ea);Q(on,"id",`av-topic-${bn}`);var yn=l(on,2),Me=l(yn,2),Pt=l(Me,2),oe=l(Pt,2),we=h(oe);cn(we,{name:"close",size:12}),E((Pe,Ke,ze)=>{c(Pn,Pe),Q(yn,"placeholder",Ke),Q(oe,"title",ze)},[()=>d("Topic"),()=>d("extract"),()=>d("Remove")]),M("input",on,D),Le(on,()=>t(hr).topic,Pe=>t(hr).topic=Pe),M("input",yn,D),Le(yn,()=>t(hr).extract,Pe=>t(hr).extract=Pe),M("input",Me,D),Le(Me,()=>t(hr).online,Pe=>t(hr).online=Pe),M("input",Pt,D),Le(Pt,()=>t(hr).offline,Pe=>t(hr).offline=Pe),M("click",oe,()=>{t(a)?.availability?.topics.splice(bn,1),D()}),g(Gr,An)});var an=l($r,4),Gn=h(an),gn=f(Gn),Xn=l(an,2),Vn=f(Xn,!0);E((Gr,hr,bn)=>{c(Ut,Gr),c(gn,`+ ${hr??""}`),c(Vn,bn)},[()=>d("Mode"),()=>d("Topic"),()=>d("topic · JSON path · the online payload · the offline payload")]),M("change",nr,D),xr(nr,()=>t(a).availability.mode,Gr=>t(a).availability.mode=Gr),M("click",Gn,()=>{t(a)?.availability?.topics.push({topic:"",online:"online",offline:"offline"}),D()}),g(je,Xe)},Hr=je=>{var Xe=qp(),et=f(Xe,!0);E(Ut=>c(et,Ut),[()=>d("Without an availability topic the device counts as reachable while it reports (see expire on a status half).")]),g(je,Xe)};H(Vt,je=>{t(a).availability?je(yr):je(Hr,-1)})}var mn=l(ht,2);tt(mn,17,()=>t(a).endpoints,ba,(je,Xe,et)=>{var Ut=Yp(),Wt=h(Ut),nr=h(Wt),ur=l(nr),rn=l(ur,2);{var nn=Qe=>{var kt=xi(),xt=f(kt);E(()=>c(xt,`#${t(s)[t(Xe).id]?.number??""}`)),g(Qe,kt)};H(rn,Qe=>{t(s)?.[t(Xe).id]?.number!==void 0&&Qe(nn)})}var $r=l(rn,2),an=h($r);Q(an,"for",`coalesce-${et}`);var Gn=f(an,!0),gn=l(an,2);Q(gn,"id",`coalesce-${et}`);var Xn=l(gn,2);{var Vn=Qe=>{var kt=Up(),xt=h(kt);cn(xt,{name:"trash"}),E(Qt=>Q(kt,"title",Qt),[()=>d("Remove")]),M("click",kt,()=>Ce(et)),g(Qe,kt)};H(Xn,Qe=>{et>0&&Qe(Vn)})}var Gr=l(Wt,2),hr=h(Gr),bn=f(hr),An=l(hr,2);tt(An,16,()=>t(Xe).deviceTypes,Qe=>Qe,(Qe,kt)=>{var xt=jp(),Qt=h(xt),ar=l(Qt);{var kr=Jr=>{var Wr=Fp(),Qr=h(Wr);cn(Qr,{name:"close",size:12}),E(Yt=>Q(Wr,"title",Yt),[()=>d("Remove")]),M("click",Wr,()=>ae(et,kt)),g(Jr,Wr)};H(ar,Jr=>{t(Xe).deviceTypes.length>1&&Jr(kr)})}E(()=>c(Qt,`${kt??""} `)),g(Qe,xt)});var Vr=l(An,2),Pn=h(Vr),ea=f(Pn);Pn.value=Pn.__value="";var on=l(Pn);tt(on,16,()=>t(I),Qe=>Qe,(Qe,kt)=>{var xt=Eo(),Qt=f(xt,!0),ar={};E(()=>{c(Qt,kt),ar!==(ar=kt)&&(xt.value=(xt.__value=ar)??"")}),g(Qe,xt)}),er(Vr);var yn=l(Gr,2);tt(yn,17,()=>R(t(Xe)),({family:Qe,options:kt})=>Qe,(Qe,kt)=>{let xt=()=>t(kt).family,Qt=()=>t(kt).options;var ar=Vp(),kr=h(ar),Jr=f(kr),Wr=l(kr,2);tt(Wr,16,()=>B(xt()),Qr=>Qr,(Qr,Yt)=>{const Pr=ne(()=>Qt()[Yt]??Y[xt()]?.[Yt]),wn=ne(()=>ep[xt()]?.[Yt]);var ta=Gp(),Va=h(ta),Fi=f(Va,!0),ji=l(Va,2);{var gi=ln=>{var _r=zp();tt(_r,20,()=>t(wn),Mn=>Mn,(Mn,ca)=>{var Sa=Eo(),Ka=f(Sa,!0),Ja={};E(()=>{c(Ka,ca),Ja!==(Ja=ca)&&(Sa.value=(Sa.__value=Ja)??"")}),g(Mn,Sa)});var Nn;er(_r),E(Mn=>{Nn!==(Nn=Mn)&&(_r.value=(_r.__value=Nn)??"",ka(_r,Nn))},[()=>String(t(Pr))]),M("change",_r,Mn=>te(t(Xe),xt(),Yt,Mn.currentTarget.value)),g(ln,_r)},zi=ln=>{var _r=Hp();E(()=>dc(_r,t(Pr))),M("change",_r,Nn=>te(t(Xe),xt(),Yt,Nn.currentTarget.checked)),g(ln,_r)},Hi=ln=>{var _r=$p();E(()=>In(_r,t(Pr))),M("change",_r,Nn=>te(t(Xe),xt(),Yt,Number(Nn.currentTarget.value))),g(ln,_r)};H(ji,ln=>{t(wn)?ln(gi):typeof t(Pr)=="boolean"?ln(zi,1):ln(Hi,-1)})}E(()=>c(Fi,Yt)),g(Qr,ta)}),E((Qr,Yt)=>c(Jr,`${Qr??""} ${xt()??""} (${Yt??""}):`),[()=>d("Options"),()=>xu[xt()]?.join(", ")]),g(Qe,ar)});var Me=l(yn,2),Pt=h(Me),oe=h(Pt),we=h(oe),Pe=f(we,!0),Ke=l(we),ze=f(Ke,!0),ft=l(Ke),Ct=f(ft,!0),Kt=l(ft),Ar=f(Kt,!0),mr=l(Pt),sn=h(mr);tt(sn,17,()=>t(Xe).mappings,ba,(Qe,kt,xt)=>{const Qt=ne(()=>Oi(t(kt))),ar=ne(()=>t(s)?.[t(Xe).id]?.state[as(t(Qt).name)]?.[t(Qt).name.split(".")[1]??""]);var kr=Jp(),Jr=h(kr),Wr=h(Jr),Qr=f(Wr,!0),Yt=l(Wr,2);{var Pr=kn=>{var va=xi(),Wa=f(va,!0);E(()=>c(Wa,t(Qt).kind)),g(kn,va)};H(Yt,kn=>{t(Qt).kind!=="attribute"&&kn(Pr)})}var wn=l(Yt,2);{var ta=kn=>{var va=Kp(),Wa=f(va);E(()=>c(Wa,`— ${t(kt).comment??""}`)),g(kn,va)};H(wn,kn=>{t(kt).comment&&kn(ta)})}var Va=l(Jr),Fi=h(Va),ji=f(Fi,!0),gi=l(Va),zi=h(gi),Hi=f(zi,!0),ln=l(gi),_r=h(ln),Nn=f(_r,!0),Mn=l(ln),ca=h(Mn),Sa=h(ca);cn(Sa,{name:"copy"});var Ka=l(ca,2),Ja=h(Ka);cn(Ja,{name:"trash"}),E((kn,va,Wa,Su,Cu)=>{c(Qr,t(Qt).name),c(ji,kn),c(Hi,va),c(Nn,Wa),Q(ca,"title",Su),Q(Ka,"title",Cu)},[()=>ie(t(kt),"status"),()=>ie(t(kt),"command"),()=>ja(t(ar)),()=>d("Duplicate"),()=>d("Remove")]),M("click",kr,()=>de(et,xt,t(kt))),M("click",Mn,kn=>kn.stopPropagation()),M("click",ca,()=>$(et,xt)),M("click",Ka,()=>$e(et,xt)),g(Qe,kr)});var Kr=l(sn);tt(Kr,17,()=>ee(t(Xe)),Qe=>Qe.cluster,(Qe,kt)=>{var xt=Qp(),Qt=h(xt),ar=h(Qt),kr=f(ar,!0),Jr=l(ar,2);{var Wr=Yt=>{var Pr=xo(),wn=f(Pr,!0);E(ta=>c(wn,ta),[()=>d("mandatory")]),g(Yt,Pr)};H(Jr,Yt=>{t(kt).mandatory&&Yt(Wr)})}var Qr=l(Jr,2);tt(Qr,17,()=>t(kt).targets,Yt=>Yt.name,(Yt,Pr)=>{var wn=Wp(),ta=f(wn);E(()=>{Q(wn,"data-target",t(Pr).name),c(ta,`+ ${t(Pr).name??""}${t(Pr).kind!=="attribute"?` (${t(Pr).kind})`:""}`)}),M("click",wn,()=>fe(et,t(Pr))),g(Yt,wn)}),E(()=>c(kr,t(kt).cluster)),g(Qe,xt)});var wr=l(Me,2),Ir=h(wr),Or=f(Ir);E((Qe,kt,xt,Qt,ar,kr,Jr,Wr,Qr)=>{Q(Ut,"data-id",t(Xe).id),c(nr,`${Qe??""} `),ur.disabled=et===0&&t(Xe).id==="main",c(Gn,kt),c(bn,`${xt??""}:`),c(ea,`+ ${Qt??""}`),c(Pe,ar),c(ze,kr),c(Ct,Jr),c(Ar,Wr),c(Or,`+ ${Qr??""}`)},[()=>d(et===0?"Endpoint (the bridged node)":"Child endpoint"),()=>d("coalesce (ms)"),()=>d("Device types"),()=>d("add type"),()=>d("Target"),()=>d("Status (device → Matter)"),()=>d("Command (Matter → device)"),()=>d("Live"),()=>d("Mapping")]),M("input",ur,D),Le(ur,()=>t(Xe).id,Qe=>t(Xe).id=Qe),M("input",gn,D),Le(gn,()=>t(Xe).coalesce,Qe=>t(Xe).coalesce=Qe),M("change",Vr,()=>rt(et)),xr(Vr,()=>A[et],Qe=>A[et]=Qe),M("click",Ir,()=>fe(et,{kind:"attribute",name:""})),g(je,Ut)});var _n=l(mn,2),pr=h(_n),$n=f(pr);E((je,Xe,et,Ut,Wt,nr,ur,rn,nn,$r)=>{c(Mt,je),c(gt,Xe),c(Ot,et),c(Ie,Ut),c(cr,Wt),Q(Jt,"placeholder",r.key),c(lt,nr),c(hn,ur),c(da,rn),c(ye,nn),Gt=Nt(nt,1,"ui-badge",null,Gt,{"ui-badge-accent":t(a).source.kind!=="manual"}),c(Xt,t(a).source.kind),c($n,`+ ${$r??""}`)},[()=>d("Device"),()=>d("Name"),()=>d("Vendor"),()=>d("Model"),()=>d("Serial"),()=>d("Bridge"),()=>d("assigned automatically"),()=>d("Enabled"),()=>d("Source"),()=>d("Child endpoint")]),M("input",Bt,D),Le(Bt,()=>t(a).name,je=>t(a).name=je),M("input",qt,D),Le(qt,()=>t(a).vendor,je=>t(a).vendor=je),M("input",ot,D),Le(ot,()=>t(a).model,je=>t(a).model=je),M("input",Jt,D),Le(Jt,()=>t(a).serial,je=>t(a).serial=je),M("change",Dt,D),xr(Dt,()=>t(a).bridge,je=>t(a).bridge=je),M("click",pr,he),g(pe,be)};H(G,pe=>{t(b)==="json"?pe(ve):pe(qe,-1)})}var at=l(G,2);{var ge=pe=>{const be=ne(()=>t(a).endpoints[t(T).endpoint]);{let De=ne(()=>t(be)===void 0?[]:O(t(be)));Np(pe,{open:!0,get mapping(){return t(T).mapping},get catalog(){return t(i)},get endpointClusters(){return t(De)},onsave:Fe,onclose:()=>w(T,void 0)})}};H(at,pe=>{t(T)&&pe(ge)})}g(N,K)},wt=N=>{var K=Xp(),G=f(K);E(ve=>c(G,`${ve??""}…`),[()=>d("Loading")]),g(N,K)};H(Be,N=>{t(a)&&t(i)?N(Ze):N(wt,-1)})}E((N,K,G,ve,qe)=>{c(ue,`← ${N??""}`),c(xe,`${t(a)?.name??r.key??""} `),c(V,r.key),_e=Nt(se,1,"ui-button",null,_e,{"ui-button-primary":t(b)==="form"}),c(Te,K),Je=Nt(le,1,"ui-button",null,Je,{"ui-button-primary":t(b)==="json"}),c(mt,G),_t.disabled=t(k),c(yt,ve),Ne.disabled=t(m)||!t(v),c(ke,qe)},[()=>d("Devices"),()=>d("Form"),()=>d("Export"),()=>t(k)?d("Checking…"):d("Check"),()=>d("Save")]),M("click",Z,J),M("click",se,()=>w(b,"form")),M("click",le,()=>{w(_,t(a)===void 0?"":Jn(Za(t(a))),!0),w(b,"json")}),M("click",Ye,W),M("click",_t,L),M("click",Ne,j),g(e,re),zt()}lr(["click","input","change"]);var rh=S('<div class="ui-empty"> </div>'),To=S('<span class="ui-badge ui-badge-warn"> </span>'),nh=S('<span class="ui-badge"> </span>'),ah=S('<span class="ui-badge ui-badge-error"> </span>'),ih=S('<span class="ui-badge ui-badge-ok"> </span>'),oh=S('<tr class="ui-row-link" data-testid="device-row"><td><span></span> </td><td><code> </code></td><td> </td><td><span> </span> <!></td><td> </td><td> </td><td><!></td><td class="ui-actions"><button type="button" class="ui-icon-button"><!></button> <button type="button" class="ui-icon-button" data-testid="duplicate-device"><!></button> <button type="button" class="ui-icon-button"><!></button> <button type="button" class="ui-icon-button" data-testid="delete-device"><!></button></td></tr>'),sh=S('<table class="ui-table" data-testid="device-table"><thead><tr><th> </th><th> </th><th> </th><th> </th><th> </th><th> </th><th> </th><th></th></tr></thead><tbody></tbody></table>'),lh=S('<button type="button" class="ui-button"> </button> <button type="button" class="ui-button ui-button-primary" data-testid="create-device"> </button>',1),uh=S("<option> </option>"),dh=S('<div class="ui-form"><label class="ui-form-label" for="new-name"> </label> <div class="ui-form-field"><input id="new-name" class="ui-input" maxlength="32" data-testid="new-name"/></div> <label class="ui-form-label" for="new-key"> </label> <div class="ui-form-field"><input id="new-key" data-testid="new-key"/></div> <div data-testid="new-key-help"> </div> <label class="ui-form-label" for="type-filter"> </label> <div class="ui-form-field"><input id="type-filter" class="ui-input"/></div> <div class="ui-form-full"><select class="ui-select types svelte-19ysaj4" size="8" data-testid="new-type"></select></div> <div class="ui-form-help"> </div></div>'),ch=S('<div class="ui-page" data-testid="devices-page"><div class="ui-toolbar"><button type="button" class="ui-button ui-button-primary" data-testid="new-device"> </button> <button type="button" class="ui-button"> </button> <input class="ui-input filter svelte-19ysaj4" data-testid="device-filter"/> <div class="ui-toolbar-trailing"> </div></div> <div class="ui-page-scroll"><!></div></div> <!>',1);function vh(e,r){jt(r,!0);let n=z(Lt([])),a=z(!1),i=z(""),o=z(void 0),s=z(!1),u=z(""),v=z(""),m=z("OnOffPlugInUnit"),k=z("");const y=ne(()=>Xr.route.rest),b=ne(()=>t(n).some(U=>U.key===t(u))),_=ne(()=>jo.test(t(u))&&!t(b)),x=ne(()=>{const U=t(i).trim().toLowerCase();return[...U===""?t(n):t(n).filter(he=>[he.key,he.name,he.deviceTypes.join(" "),he.source.kind,he.bridge??""].join(" ").toLowerCase().includes(U))].sort((he,Ce)=>he.name.localeCompare(Ce.name))}),T=ne(()=>{const U=t(k).trim().toLowerCase();return(t(o)?.deviceTypes??[]).filter(W=>W.classification!=="node"&&W.name!=="RootNode"&&W.name!=="Aggregator").filter(W=>U===""||W.name.toLowerCase().includes(U))});async function A(){try{w(n,await He.devices(),!0),w(a,!0)}catch(U){Ue.error(pt(U))}}en(()=>(A(),He.catalog().then(U=>w(o,U,!0)),Er.on(U=>{(U.type==="devices"||U.type==="attribute"&&U.cluster==="BridgedDeviceBasicInformation")&&A()})));function C(U){return{manual:d("manual"),z2m:"Zigbee2MQTT","ha-discovery":"HA discovery",preset:d("preset")}[U]??U}function I(){w(u,""),w(v,""),w(k,""),w(s,!0)}function P(){(t(u)===""||!t(_))&&w(u,zo(ku(t(v)),t(n).map(U=>U.key)),!0)}async function O(){if(!(!t(_)||t(v).trim()===""))try{await He.createDevice(t(u),{name:t(v).trim(),endpoints:[{deviceTypes:[t(m)]}]}),w(s,!1),Xr.go("devices",t(u))}catch(U){Ue.error(pt(U))}}async function ee(U){try{const W=await He.device(U.key);await He.saveDevice(U.key,{...W.device,enabled:!U.enabled}),await A()}catch(W){Ue.error(pt(W))}}async function R(U){const W=t(n).map(Ce=>Ce.key),he=await rr.prompt(d("Key of the copy"),{value:zo(`${U.key}-copy`,W),pattern:jo,validate:Ce=>W.includes(Ce)?d("A device with this key exists already."):void 0,confirm:d("Duplicate")});if(he!==null)try{const Ce=await He.device(U.key);await He.createDevice(he,{...Ce.device,name:`${Ce.device.name} 2`.slice(0,32),source:{kind:"manual"},bridge:void 0}),Xr.go("devices",he)}catch(Ce){Ue.error(pt(Ce))}}async function F(U){try{rs(`${U.key}.json`,Jn(await He.exportDevice(U.key)))}catch(W){Ue.error(pt(W))}}async function D(U){if(await rr.confirm(d("Delete {name}? Controllers lose the device, its rooms and automations.",{name:U.name}),{confirm:d("Delete"),danger:!0}))try{await He.deleteDevice(U.key),Ue.info(d("{name} deleted",{name:U.name})),await A()}catch(he){Ue.error(pt(he))}}var q=Zn(),j=Oe(q);{var L=U=>{th(U,{get key(){return t(y)},onclose:()=>Xr.go("devices")})},J=U=>{var W=ch(),he=Oe(W),Ce=h(he),rt=h(Ce),ae=f(rt),de=l(rt,2),fe=f(de,!0),Fe=l(de,2),$e=l(Fe,2),$=f($e,!0),te=l(Ce,2),B=h(te);{var Y=re=>{var ce=rh(),Z=f(ce,!0);E(ue=>c(Z,ue),[()=>d("No devices yet. Create one by hand, apply a preset, or adopt a discovered device.")]),g(re,ce)},X=re=>{var ce=sh(),Z=h(ce),ue=h(Z),Ee=h(ue),xe=f(Ee,!0),Ae=l(Ee),V=f(Ae,!0),me=l(Ae),Se=f(me,!0),Ge=l(me),se=f(Ge,!0),_e=l(Ge),Te=f(_e,!0),le=l(_e),Je=f(le,!0),Ye=l(le),mt=f(Ye,!0),_t=l(Z);tt(_t,21,()=>t(x),yt=>yt.key,(yt,Ne)=>{var ke=oh(),Be=h(ke),Ze=h(Be);let wt;var N=l(Ze),K=l(Be),G=h(K),ve=f(G,!0),qe=l(K),at=f(qe),ge=l(qe),pe=h(ge);let be;var De=f(pe,!0),Ve=l(pe,2);{var dt=lt=>{var St=To(),Dt=f(St,!0);E(It=>c(Dt,It),[()=>d("orphaned")]),g(lt,St)};H(Ve,lt=>{t(Ne).source.orphaned&&lt(dt)})}var ht=l(ge),it=f(ht,!0),At=l(ht),Mt=f(At,!0),We=l(At),ct=h(We);{var gt=lt=>{var St=nh(),Dt=f(St,!0);E(It=>c(Dt,It),[()=>d("disabled")]),g(lt,St)},Rt=lt=>{var St=ah(),Dt=f(St,!0);E(It=>c(Dt,It),[()=>d("{count} errors",{count:t(Ne).errors})]),g(lt,St)},Bt=lt=>{var St=To(),Dt=f(St,!0);E(It=>c(Dt,It),[()=>d("not built")]),g(lt,St)},dr=lt=>{var St=To(),Dt=f(St,!0);E(It=>c(Dt,It),[()=>d("{count} warnings",{count:t(Ne).violations+t(Ne).warnings})]),g(lt,St)},Ot=lt=>{var St=ih(),Dt=f(St,!0);E(It=>c(Dt,It),[()=>d("ok")]),g(lt,St)};H(ct,lt=>{t(Ne).enabled?t(Ne).errors>0?lt(Rt,1):t(Ne).built?t(Ne).violations>0||t(Ne).warnings>0?lt(dr,3):lt(Ot,-1):lt(Bt,2):lt(gt)})}var Ht=l(We),qt=h(Ht),Re=h(qt);{var Ie=lt=>{cn(lt,{name:"pause"})},vt=lt=>{cn(lt,{name:"play"})};H(Re,lt=>{t(Ne).enabled?lt(Ie):lt(vt,-1)})}var ot=l(qt,2),$t=h(ot);cn($t,{name:"copy"});var cr=l(ot,2),vr=h(cr);cn(vr,{name:"download"});var Jt=l(cr,2),Sr=h(Jt);cn(Sr,{name:"trash"}),E((lt,St,Dt,It,hn,qr,fr)=>{Q(ke,"data-key",t(Ne).key),wt=Nt(Ze,1,"ui-dot",null,wt,{"ui-dot-ok":t(Ne).reachable===!0,"ui-dot-error":t(Ne).reachable===!1}),Q(Ze,"title",lt),c(N,` ${t(Ne).name??""}`),c(ve,t(Ne).key),c(at,`${St??""}${t(Ne).endpoints>1?` +${t(Ne).endpoints-1}`:""}`),be=Nt(pe,1,"ui-badge",null,be,{"ui-badge-accent":t(Ne).source.kind!=="manual"}),c(De,Dt),c(it,t(Ne).bridge??""),c(Mt,t(Ne).number??""),Q(qt,"title",It),Q(ot,"title",hn),Q(cr,"title",qr),Q(Jt,"title",fr)},[()=>t(Ne).reachable===void 0?d("not built"):t(Ne).reachable?d("reachable"):d("unreachable"),()=>t(Ne).deviceTypes.join(", "),()=>C(t(Ne).source.kind),()=>t(Ne).enabled?d("Disable"):d("Enable"),()=>d("Duplicate"),()=>d("Export"),()=>d("Delete")]),M("click",ke,()=>Xr.go("devices",t(Ne).key)),M("click",Ht,lt=>lt.stopPropagation()),M("click",qt,()=>ee(t(Ne))),M("click",ot,()=>R(t(Ne))),M("click",cr,()=>F(t(Ne))),M("click",Jt,()=>D(t(Ne))),g(yt,ke)}),E((yt,Ne,ke,Be,Ze,wt,N)=>{c(xe,yt),c(V,Ne),c(Se,ke),c(se,Be),c(Te,Ze),c(Je,wt),c(mt,N)},[()=>d("Name"),()=>d("Key"),()=>d("Device types"),()=>d("Source"),()=>d("Bridge"),()=>d("Endpoint"),()=>d("State")]),g(re,ce)};H(B,re=>{t(a)&&t(n).length===0?re(Y):re(X,-1)})}var ie=l(he,2);{const re=Z=>{var ue=lh(),Ee=Oe(ue),xe=f(Ee,!0),Ae=l(Ee,2),V=f(Ae,!0);E((me,Se,Ge)=>{c(xe,me),Ae.disabled=Se,c(V,Ge)},[()=>d("Cancel"),()=>!t(_)||t(v).trim()==="",()=>d("Create")]),M("click",Ee,()=>w(s,!1)),M("click",Ae,O),g(Z,ue)};let ce=ne(()=>d("New device"));xa(ie,{get open(){return t(s)},get title(){return t(ce)},onclose:()=>w(s,!1),testId:"create-dialog",buttons:re,children:(Z,ue)=>{var Ee=dh(),xe=h(Ee),Ae=f(xe,!0),V=l(xe,2),me=h(V),Se=l(V,2),Ge=f(Se,!0),se=l(Se,2),_e=h(se);let Te;var le=l(se,2);let Je;var Ye=f(le,!0),mt=l(le,2),_t=f(mt,!0),yt=l(mt,2),Ne=h(yt),ke=l(yt,2),Be=h(ke);tt(Be,21,()=>t(T),N=>N.name,(N,K)=>{var G=uh(),ve=f(G,!0),qe={};E(()=>{c(ve,t(K).name),qe!==(qe=t(K).name)&&(G.value=(G.__value=qe)??"")}),g(N,G)}),er(Be);var Ze=l(ke,2),wt=f(Ze,!0);E((N,K,G,ve,qe,at)=>{c(Ae,N),c(Ge,K),Te=Nt(_e,1,"ui-input ui-mono",null,Te,{"ui-invalid":t(u)!==""&&!t(_)}),Je=Nt(le,1,"ui-form-help",null,Je,{"ui-error-text":t(b)}),c(Ye,G),c(_t,ve),Q(Ne,"placeholder",qe),c(wt,at)},[()=>d("Name"),()=>d("Key"),()=>t(b)?d("A device with this key exists already."):d("The key is the Matter endpoint id: stable, never renamed. Letters, digits, : . _ -"),()=>d("Device type"),()=>d("Filter"),()=>d("The device type brings its mandatory clusters; their mappings are filled in the editor.")]),Ua("blur",me,P),Le(me,()=>t(v),N=>w(v,N)),Le(_e,()=>t(u),N=>w(u,N)),Le(Ne,()=>t(k),N=>w(k,N)),xr(Be,()=>t(m),N=>w(m,N)),g(Z,Ee)},$$slots:{buttons:!0,default:!0}})}E((re,ce,Z,ue)=>{c(ae,`+ ${re??""}`),c(fe,ce),Q(Fe,"placeholder",Z),c($,ue)},[()=>d("New device"),()=>d("From preset"),()=>d("Filter"),()=>d("{count} devices",{count:t(n).length})]),M("click",rt,I),M("click",de,()=>Xr.go("presets")),Le(Fe,()=>t(i),re=>w(i,re)),g(U,W)};H(j,U=>{t(y)!==""?U(L):U(J,-1)})}g(e,q),zt()}lr(["click"]);var fh=S('<tr data-testid="log-row"><td class="ui-muted ts svelte-skp5ex"> </td><td class="level-cell svelte-skp5ex"> </td><td class="ui-muted scope svelte-skp5ex"> </td><td class="message svelte-skp5ex"> </td></tr>'),ph=S('<div class="ui-page" data-testid="log-page"><div class="ui-toolbar"><select class="ui-select level svelte-skp5ex" data-testid="log-level"><option>debug</option><option>info</option><option>warn</option><option>error</option></select> <input class="ui-input filter svelte-skp5ex"/> <!> <div class="ui-toolbar-trailing"> </div></div> <div class="ui-page-scroll"><table class="ui-table log svelte-skp5ex"><tbody></tbody></table></div></div>');function hh(e,r){jt(r,!0);let n=z(Lt([])),a=z(""),i=z("debug"),o=z(!0),s=z(void 0);const u={debug:0,info:1,warn:2,error:3},v=2e3,m=ne(()=>{const q=t(a).trim().toLowerCase(),j=u[t(i)]??0;return t(n).filter(L=>(u[L.level]??0)>=j&&(q===""||`${L.scope} ${L.message}`.toLowerCase().includes(q)))});async function k(){await tu(),t(o)&&t(s)!==void 0&&(t(s).scrollTop=t(s).scrollHeight)}en(()=>(He.log(v).then(q=>{w(n,q,!0),k()}).catch(q=>Ue.error(pt(q))),Er.on(q=>{q.type==="log"&&(w(n,[...t(n),q.entry].slice(-v),!0),k())})));var y=ph(),b=h(y),_=h(b),x=h(_);x.value=x.__value="debug";var T=l(x);T.value=T.__value="info";var A=l(T);A.value=A.__value="warn";var C=l(A);C.value=C.__value="error",er(_);var I=l(_,2),P=l(I,2);{let q=ne(()=>d("follow"));Zr(P,{get label(){return t(q)},get checked(){return t(o)},set checked(j){w(o,j,!0)}})}var O=l(P,2),ee=f(O,!0),R=l(b,2),F=h(R),D=h(F);tt(D,21,()=>t(m),q=>q.id,(q,j)=>{var L=fh(),J=h(L),U=f(J,!0),W=l(J),he=f(W,!0),Ce=l(W),rt=f(Ce,!0),ae=l(Ce),de=f(ae,!0);E(fe=>{Nt(L,1,lu(t(j).level),"svelte-skp5ex"),c(U,fe),c(he,t(j).level),c(rt,t(j).scope),c(de,t(j).message)},[()=>oi(t(j).ts)]),g(q,L)}),Ui(R,q=>w(s,q),()=>t(s)),E((q,j)=>{Q(I,"placeholder",q),c(ee,j)},[()=>d("Filter"),()=>d("{count} lines",{count:t(m).length})]),xr(_,()=>t(i),q=>w(i,q)),Le(I,()=>t(a),q=>w(a,q)),g(e,y),zt()}var mh=S('<span class="ui-badge retain svelte-1q9v7x1">R</span>'),_h=S('<tr data-testid="topic-row"><td><code> </code><!></td><td class="payload svelte-1q9v7x1"><code> </code></td><td class="ui-muted"> </td></tr>'),gh=S('<div class="detail svelte-1q9v7x1"><div class="ui-muted"><code> </code> </div> <pre class="ui-pre"> </pre></div>'),bh=S('<tr data-testid="message-row"><td class="ui-muted time svelte-1q9v7x1"> </td><td><code> </code></td><td class="payload svelte-1q9v7x1"><code> </code></td></tr>'),yh=S('<div class="ui-page" data-testid="mqtt-page"><div class="ui-split split svelte-1q9v7x1"><section class="ui-section column svelte-1q9v7x1"><div class="ui-section-title"> <div class="ui-toolbar-trailing"> </div></div> <input class="ui-input" data-testid="topic-filter"/> <div class="ui-page-scroll"><table class="ui-table"><thead><tr><th> </th><th> </th><th> </th></tr></thead><tbody></tbody></table></div> <!></section> <div class="column right svelte-1q9v7x1"><section class="ui-section"><div class="ui-section-title"> </div> <div class="ui-form"><label class="ui-form-label" for="pub-topic"> </label> <div class="ui-form-field"><input id="pub-topic" class="ui-input ui-mono" data-testid="publish-topic"/></div> <label class="ui-form-label" for="pub-payload"> </label> <div class="ui-form-field"><textarea id="pub-payload" class="ui-textarea" rows="3" data-testid="publish-payload"></textarea></div> <span></span> <div class="ui-form-field"><!> <button type="button" class="ui-button ui-button-primary" data-testid="publish"> </button></div></div></section> <section class="ui-section column svelte-1q9v7x1"><div class="ui-section-title"> <div class="ui-toolbar-trailing"><!> <button type="button" class="ui-button"> </button></div></div> <div class="ui-page-scroll"><table class="ui-table"><tbody></tbody></table></div></section></div></div></div>');function wh(e,r){jt(r,!0);let n=z(Lt(new Map)),a=z(""),i=z(""),o=z(Lt([])),s=z(!1),u=z(""),v=z(""),m=z(!1),k=1;const y=300,b=ne(()=>{const ke=t(a).trim().toLowerCase();return[...t(n).values()].filter(Be=>ke===""||Be.topic.toLowerCase().includes(ke)).sort((Be,Ze)=>Be.topic.localeCompare(Ze.topic))}),_=ne(()=>t(i)===""?void 0:t(n).get(t(i))),x=ne(()=>t(_)===void 0?void 0:ci(t(_).payload));async function T(){try{w(n,new Map((await He.topics()).map(ke=>[ke.topic,ke])),!0)}catch(ke){Ue.error(pt(ke))}}en(()=>{T();const ke=Er.wantMqtt(),Be=Er.on(Ze=>{if(Ze.type!=="mqtt")return;const wt={topic:Ze.topic,payload:Ze.payload,retain:Ze.retain,ts:Ze.ts};t(n).set(Ze.topic,wt),w(n,new Map(t(n)),!0),t(s)||w(o,[{id:k++,...wt},...t(o)].slice(0,y),!0)});return()=>{ke(),Be()}});async function A(){try{await He.publish(t(u),t(v),t(m)),Ue.info(d("Published to {topic}",{topic:t(u)}))}catch(ke){Ue.error(pt(ke))}}function C(ke){w(i,ke.topic,!0),w(u,ke.topic,!0),w(v,ke.payload,!0)}var I=yh(),P=h(I),O=h(P),ee=h(O),R=h(ee),F=l(R),D=f(F,!0),q=l(ee,2),j=l(q,2),L=h(j),J=h(L),U=h(J),W=h(U),he=f(W,!0),Ce=l(W),rt=f(Ce,!0),ae=l(Ce),de=f(ae,!0),fe=l(J);tt(fe,21,()=>t(b),ke=>ke.topic,(ke,Be)=>{var Ze=_h();let wt;var N=h(Ze),K=h(N),G=f(K,!0),ve=l(K);{var qe=Ve=>{var dt=mh();g(Ve,dt)};H(ve,Ve=>{t(Be).retain&&Ve(qe)})}var at=l(N),ge=h(at),pe=f(ge,!0),be=l(at),De=f(be,!0);E(Ve=>{wt=Nt(Ze,1,"ui-row-link",null,wt,{"ui-row-selected":t(Be).topic===t(i)}),c(G,t(Be).topic),c(pe,t(Be).payload),c(De,Ve)},[()=>oi(t(Be).ts)]),M("click",Ze,()=>C(t(Be))),g(ke,Ze)});var Fe=l(j,2);{var $e=ke=>{var Be=gh(),Ze=h(Be),wt=h(Ze),N=f(wt,!0),K=l(wt),G=l(Ze,2),ve=f(G,!0);E((qe,at,ge)=>{c(N,t(_).topic),c(K,` · ${qe??""}${at??""}`),c(ve,ge)},[()=>oi(t(_).ts),()=>t(_).retain?` · ${d("retained")}`:"",()=>t(x)===void 0?t(_).payload:Jn(t(x))]),g(ke,Be)};H(Fe,ke=>{t(_)&&ke($e)})}var $=l(O,2),te=h($),B=h(te),Y=f(B,!0),X=l(B,2),ie=h(X),re=f(ie,!0),ce=l(ie,2),Z=h(ce),ue=l(ce,2),Ee=f(ue,!0),xe=l(ue,2),Ae=h(xe),V=l(xe,4),me=h(V);{let ke=ne(()=>d("retain"));Zr(me,{get label(){return t(ke)},get checked(){return t(m)},set checked(Be){w(m,Be,!0)}})}var Se=l(me,2),Ge=f(Se,!0),se=l(te,2),_e=h(se),Te=h(_e),le=l(Te),Je=h(le);{let ke=ne(()=>d("pause"));Zr(Je,{get label(){return t(ke)},get checked(){return t(s)},set checked(Be){w(s,Be,!0)}})}var Ye=l(Je,2),mt=f(Ye,!0),_t=l(_e,2),yt=h(_t),Ne=h(yt);tt(Ne,21,()=>t(o),ke=>ke.id,(ke,Be)=>{var Ze=bh(),wt=h(Ze),N=f(wt,!0),K=l(wt),G=h(K),ve=f(G,!0),qe=l(K),at=h(qe),ge=f(at,!0);E(pe=>{c(N,pe),c(ve,t(Be).topic),c(ge,t(Be).payload)},[()=>oi(t(Be).ts)]),g(ke,Ze)}),E((ke,Be,Ze,wt,N,K,G,ve,qe,at,ge,pe)=>{c(R,`${ke??""} `),c(D,Be),Q(q,"placeholder",Ze),c(he,wt),c(rt,N),c(de,K),c(Y,G),c(re,ve),c(Ee,qe),Se.disabled=t(u)==="",c(Ge,at),c(Te,`${ge??""} `),c(mt,pe)},[()=>d("Topics"),()=>d("{count} topics",{count:t(n).size}),()=>d("Filter"),()=>d("Topic"),()=>d("Payload"),()=>d("Time"),()=>d("Publish"),()=>d("Topic"),()=>d("Payload"),()=>d("Publish"),()=>d("Messages"),()=>d("Clear")]),Le(q,()=>t(a),ke=>w(a,ke)),Le(Z,()=>t(u),ke=>w(u,ke)),Le(Ae,()=>t(v),ke=>w(v,ke)),M("click",Se,A),M("click",Ye,()=>w(o,[],!0)),g(e,I),zt()}lr(["click"]);const kh=/%([A-Za-z_][A-Za-z0-9_]*)(?:\|(words))?%/g,xh=/%[A-Za-z_][A-Za-z0-9_]*(?:\|words)?%/;function Eh(e,r){return r==="words"?e.replace(/\//g," ").replace(/\s+/g," ").trim():e}function Th(e){return xh.test(e?.default??"")}function vl(e,r,n){const a=new Map,i=(o,s)=>{const u=a.get(o);if(u!==void 0)return u;const v=e[o];let m;return v===void 0||s.includes(o)?m="":!Th(v)||n.has(o)?m=r[o]??v.default??"":m=(v.default??"").replace(kh,(k,y,b)=>Eh(i(y,[...s,o]),b)).trim(),a.set(o,m),m};return Object.fromEntries(Object.keys(e).map(o=>[o,i(o,[])]))}var Sh=S('<div class="ui-toolbar"><input type="search" class="ui-input search svelte-11516m7" data-testid="preset-search"/> <div class="ui-toolbar-trailing"> </div></div>'),Ch=S('<div class="ui-empty"> </div>'),Ah=S('<div class="ui-empty" data-testid="preset-no-match"> </div>'),Ph=S('<span class="ui-muted description svelte-11516m7"> </span>'),Nh=S('<button type="button" class="card svelte-11516m7" data-testid="preset"><span class="name svelte-11516m7"> </span> <!> <span class="ui-faint ui-small"><code> </code> </span></button>'),Mh=S('<section class="group svelte-11516m7"><h3 class="svelte-11516m7"> </h3> <div class="cards svelte-11516m7"></div></section>'),Rh=S('<div class="ui-small"><code> </code> </div>'),Ih=S('<section class="ui-section"><div class="ui-section-title ui-warn-text"> </div> <!></section>'),Oh=S('<button type="button" class="ui-button"> </button> <button type="button" class="ui-button ui-button-primary" data-testid="preset-create"> </button>',1),Dh=S('<p class="ui-muted intro svelte-11516m7"> </p>'),Lh=S('<div class="ui-form-help"> </div>'),Bh=S('<label class="ui-form-label"> </label> <div class="ui-form-field"><input class="ui-input"/></div> <!>',1),qh=S('<div class="ui-form-help ui-error-text" data-testid="preset-key-taken"> </div>'),Uh=S('<div class="ui-form"><label class="ui-form-label" for="preset-key"> </label> <div class="ui-form-field"><input id="preset-key" data-testid="preset-key"/></div> <!></div> <!> <pre class="ui-pre"> </pre>',1),Fh=S('<!> <div class="ui-form"><!> <span></span> <div class="ui-form-field"><button type="button" class="ui-button" data-testid="preset-preview"> </button></div></div> <!>',1),jh=S('<div class="ui-page" data-testid="presets-page"><!> <div class="ui-page-scroll"><!> <!> <!></div></div> <!>',1);function zh(e,r){jt(r,!0);let n=z(Lt([])),a=z(Lt([])),i=z(!1),o=z(void 0),s=z(Lt({})),u=new Set,v=z(""),m=z(void 0),k=z(!1),y=z(Lt([]));const b=ne(()=>t(y).includes(t(v))),_=ne(()=>jo.test(t(v))&&!t(b));let x=z("");const T=ne(()=>{const ae=t(x).trim().toLowerCase().split(/\s+/).filter(de=>de!=="");return ae.length===0?t(n):t(n).filter(de=>{const fe=[de.name,de.vendor??"",de.id,de.description??""].join(" ").toLowerCase();return ae.every(Fe=>fe.includes(Fe))})}),A=ne(()=>{const ae=new Map;for(const de of t(T)){const fe=de.vendor??d("Other");ae.set(fe,[...ae.get(fe)??[],de])}return[...ae.entries()].sort(([de],[fe])=>de.localeCompare(fe))});en(()=>{He.presets().then(ae=>{w(n,ae.presets,!0),w(a,ae.problems,!0),w(i,!0)}).catch(ae=>Ue.error(pt(ae)))});function C(ae){w(o,ae,!0),u=new Set,w(s,vl(ae.variables,{},u),!0),w(v,""),w(m,void 0),He.devices().then(de=>w(y,de.map(fe=>fe.key),!0)).catch(de=>Ue.error(pt(de)))}function I(ae,de){t(o)!==void 0&&(de===""?u.delete(ae):u.add(ae),w(s,vl(t(o).variables,{...t(s),[ae]:de},u),!0))}async function P(){if(t(o)!==void 0){w(k,!0);try{w(m,await He.applyPreset(t(o).id,t(s)),!0),t(v)===""&&w(v,zo(ku(t(m).device.name),t(y)),!0)}catch(ae){Ue.error(pt(ae))}finally{w(k,!1)}}}async function O(){if(!(t(m)===void 0||!t(_)))try{await He.createDevice(t(v),t(m).device),Ue.info(d("{name} created",{name:t(m).device.name})),w(o,void 0),Xr.go("devices",t(v))}catch(ae){Ue.error(pt(ae))}}var ee=jh(),R=Oe(ee),F=h(R);{var D=ae=>{var de=Sh(),fe=h(de);fd(fe);var Fe=l(fe,2),$e=f(Fe,!0);E(($,te,B)=>{Q(fe,"placeholder",$),Q(fe,"aria-label",te),c($e,B)},[()=>d("Search presets"),()=>d("Search presets"),()=>d("{count} of {total} presets",{count:t(T).length,total:t(n).length})]),Le(fe,()=>t(x),$=>w(x,$)),g(ae,de)};H(F,ae=>{t(n).length>0&&ae(D)})}var q=l(F,2),j=h(q);{var L=ae=>{var de=Ch(),fe=f(de,!0);E(Fe=>c(fe,Fe),[()=>d("No presets. Put preset files into a directory named in the configuration.")]),g(ae,de)},J=ae=>{var de=Ah(),fe=f(de,!0);E(Fe=>c(fe,Fe),[()=>d("No preset matches “{query}”.",{query:t(x).trim()})]),g(ae,de)};H(j,ae=>{t(i)&&t(n).length===0?ae(L):t(n).length>0&&t(T).length===0&&ae(J,1)})}var U=l(j,2);tt(U,17,()=>t(A),([ae,de])=>ae,(ae,de)=>{var fe=ne(()=>Ci(t(de),2));let Fe=()=>t(fe)[0],$e=()=>t(fe)[1];var $=Mh(),te=h($),B=f(te,!0),Y=l(te,2);tt(Y,21,$e,X=>X.id,(X,ie)=>{var re=Nh(),ce=h(re),Z=f(ce,!0),ue=l(ce,2);{var Ee=Se=>{var Ge=Ph(),se=f(Ge,!0);E(()=>c(se,t(ie).description)),g(Se,Ge)};H(ue,Se=>{t(ie).description&&Se(Ee)})}var xe=l(ue,2),Ae=h(xe),V=f(Ae,!0),me=l(Ae,1,!0);E(Se=>{Q(re,"data-id",t(ie).id),c(Z,t(ie).name),c(V,t(ie).id),c(me,Se)},[()=>t(ie).shipped?"":` · ${d("own")}`]),M("click",re,()=>C(t(ie))),g(X,re)}),E(()=>c(B,Fe())),g(ae,$)});var W=l(U,2);{var he=ae=>{var de=Ih(),fe=h(de),Fe=f(fe,!0),$e=l(fe,2);tt($e,17,()=>t(a),$=>$.file,($,te)=>{var B=Rh(),Y=h(B),X=f(Y,!0),ie=l(Y);E(()=>{c(X,t(te).file),c(ie,`: ${t(te).message??""}`)}),g($,B)}),E($=>c(Fe,$),[()=>d("Preset files with problems")]),g(ae,de)};H(W,ae=>{t(a).length>0&&ae(he)})}var Ce=l(R,2);{var rt=ae=>{xa(ae,{open:!0,get title(){return t(o).name},width:"640px",onclose:()=>w(o,void 0),testId:"preset-dialog",buttons:fe=>{var Fe=Oh(),$e=Oe(Fe),$=f($e,!0),te=l($e,2),B=f(te,!0);E((Y,X)=>{c($,Y),te.disabled=t(m)===void 0||!t(_),c(B,X)},[()=>d("Cancel"),()=>d("Create device")]),M("click",$e,()=>w(o,void 0)),M("click",te,O),g(fe,Fe)},children:(fe,Fe)=>{var $e=Fh(),$=Oe($e);{var te=ue=>{var Ee=Dh(),xe=f(Ee,!0);E(()=>c(xe,t(o).description)),g(ue,Ee)};H($,ue=>{t(o).description&&ue(te)})}var B=l($,2),Y=h(B);tt(Y,17,()=>Object.entries(t(o).variables),([ue,Ee])=>ue,(ue,Ee)=>{var xe=ne(()=>Ci(t(Ee),2));let Ae=()=>t(xe)[0],V=()=>t(xe)[1];var me=Bh(),Se=Oe(me),Ge=f(Se,!0),se=l(Se,2),_e=h(se),Te=l(se,2);{var le=Je=>{var Ye=Lh(),mt=f(Ye,!0);E(()=>c(mt,V().description)),g(Je,Ye)};H(Te,Je=>{V().description&&Je(le)})}E(Je=>{Q(Se,"for",`var-${Ae()??""}`),c(Ge,V().label),Q(_e,"id",`var-${Ae()??""}`),In(_e,t(s)[Ae()]??""),Q(_e,"placeholder",Je),Q(_e,"data-testid",`preset-var-${Ae()??""}`)},[()=>V().optional?d("optional"):""]),M("input",_e,Je=>I(Ae(),Je.currentTarget.value)),g(ue,me)});var X=l(Y,4),ie=h(X),re=f(ie,!0),ce=l(B,2);{var Z=ue=>{var Ee=Uh(),xe=Oe(Ee),Ae=h(xe),V=f(Ae,!0),me=l(Ae,2),Se=h(me);let Ge;var se=l(me,2);{var _e=Ye=>{var mt=qh(),_t=f(mt,!0);E(yt=>c(_t,yt),[()=>d("A device with this key exists already.")]),g(Ye,mt)};H(se,Ye=>{t(b)&&Ye(_e)})}var Te=l(xe,2);{let Ye=ne(()=>d("The device validates."));Ii(Te,{get issues(){return t(m).issues},get empty(){return t(Ye)}})}var le=l(Te,2),Je=f(le,!0);E((Ye,mt)=>{c(V,Ye),Ge=Nt(Se,1,"ui-input ui-mono",null,Ge,{"ui-invalid":!t(_)}),c(Je,mt)},[()=>d("Key"),()=>Jn(t(m).device)]),Le(Se,()=>t(v),Ye=>w(v,Ye)),g(ue,Ee)};H(ce,ue=>{t(m)&&ue(Z)})}E(ue=>{ie.disabled=t(k),c(re,ue)},[()=>d("Preview")]),M("click",ie,P),g(fe,$e)},$$slots:{buttons:!0,default:!0}})};H(Ce,ae=>{t(o)&&ae(rt)})}g(e,ee),zt()}lr(["click","input"]);var Hh=S('<span class="status user svelte-pjescm" data-testid="user"> </span>'),$h=S('<button type="button" class="ui-bar-button" data-testid="logout"><!></button>'),Gh=S('<div class="shell svelte-pjescm" data-testid="app"><header class="header svelte-pjescm"><span class="brand svelte-pjescm">mqtt2matter</span> <div class="tabs svelte-pjescm"><!></div> <div class="actions svelte-pjescm"><span class="status svelte-pjescm"><span></span>MQTT</span> <span class="status svelte-pjescm"><span></span> </span> <!> <a class="ui-bar-button" target="_blank" rel="noopener" title="GitHub" aria-label="GitHub" data-testid="github"><!></a> <button type="button" class="ui-bar-button paragraph svelte-pjescm" data-testid="licenses-button">§</button> <!> <!> <button type="button" data-testid="config-button"><!></button> <!></div></header> <main class="main svelte-pjescm"><!></main> <!> <!> <!></div>');function Vh(e,r){jt(r,!0);let n=z(void 0),a=z("none"),i=z(void 0),o=z(!1);const s=ne(()=>Xr.route.page),u=ne(()=>Er.mqttConnected??t(n)?.mqtt.connected??!1),v=ne(()=>t(n)?.bridges.some(V=>V.commissioned)??!1),m=ne(()=>t(n)?.importers??[]),k=ne(()=>[{id:"devices",label:d("Devices"),badge:t(n)===void 0?void 0:String(t(n).devices)},{id:"presets",label:d("Presets")},{id:"adopt",label:d("Adopt"),dot:t(m).length===0?"none":void 0},{id:"bridges",label:d("Bridges"),dot:t(v)?"ok":"warn"},{id:"mqtt",label:"MQTT",dot:t(u)?"ok":"error"},{id:"log",label:d("Log"),dot:t(a)==="none"?"none":t(a)},{id:"check",label:d("Check")}]),y="https://github.com/hobbyquaker/mqtt2matter";function b(V){w(i,t(i)===V?void 0:V,!0)}async function _(){try{w(n,await He.status(),!0)}catch{w(n,void 0)}}en(()=>{Er.start(),_();const V=setInterval(()=>{_()},15e3),me=Er.on(Se=>{(Se.type==="devices"||Se.type==="bridges"||Se.type==="status")&&_(),Se.type==="log"&&t(s)!=="log"&&(Se.entry.level==="error"?w(a,"error"):Se.entry.level==="warn"&&t(a)!=="error"&&w(a,"warn"))});return()=>{clearInterval(V),me(),Er.stop()}}),Br(()=>{t(s)==="log"&&w(a,"none")});var x=Gh();Ua("click",Io,V=>{V.target instanceof Element&&V.target.closest("dialog")!==null||w(i,void 0)}),Ua("keydown",Io,V=>{V.key==="Escape"&&w(i,void 0)});var T=h(x),A=l(h(T),2),C=h(A);{let V=ne(()=>d("Pages"));bv(C,{get tabs(){return t(k)},get active(){return t(s)},get label(){return t(V)},onselect:me=>Xr.go(me)})}var I=l(A,2),P=h(I),O=h(P);let ee;var R=l(P,2),F=h(R);let D;var q=l(F),j=l(R,2);{var L=V=>{var me=Hh(),Se=f(me,!0);E(()=>c(Se,or.state.user)),g(V,me)};H(j,V=>{or.state?.mode==="proxy"&&or.state.user!==void 0&&V(L)})}var J=l(j,2);Q(J,"href",y);var U=h(J);aa(U,{name:"github"});var W=l(J,2),he=l(W,2);{var Ce=V=>{{let me=ne(()=>t(i)==="version"),Se=ne(()=>t(n).update?.newer===!0);Nv(V,{get open(){return t(me)},get version(){return t(n).version},get newer(){return t(Se)},ontoggle:()=>b("version"),onchange:()=>{_()}})}};H(he,V=>{t(n)&&V(Ce)})}var rt=l(he,2);{let V=ne(()=>t(i)==="stats");pv(rt,{get open(){return t(V)},ontoggle:()=>b("stats")})}var ae=l(rt,2);let de;var fe=h(ae);aa(fe,{name:"gear"});var Fe=l(ae,2);{var $e=V=>{var me=$h(),Se=h(me);aa(Se,{name:"logout"}),E((Ge,se)=>{Q(me,"title",Ge),Q(me,"aria-label",se)},[()=>d("Log out"),()=>d("Log out")]),M("click",me,()=>or.logout()),g(V,me)};H(Fe,V=>{(or.state?.mode==="password"||or.state?.logoutUrl!==void 0)&&V($e)})}var $=l(T,2),te=h($);{var B=V=>{vh(V,{})},Y=V=>{zh(V,{})},X=V=>{Qv(V,{})},ie=V=>{If(V,{})},re=V=>{wh(V,{})},ce=V=>{hh(V,{})},Z=V=>{jf(V,{})},ue=V=>{Zf(V,{})};H(te,V=>{t(s)==="devices"?V(B):t(s)==="presets"?V(Y,1):t(s)==="adopt"?V(X,2):t(s)==="bridges"?V(ie,3):t(s)==="mqtt"?V(re,4):t(s)==="log"?V(ce,5):t(s)==="check"?V(Z,6):t(s)==="config"&&V(ue,7)})}var Ee=l($,2);lv(Ee,{});var xe=l(Ee,2);nv(xe,{get open(){return t(o)},onclose:()=>{w(o,!1)}});var Ae=l(xe,2);Jc(Ae,{}),E((V,me,Se,Ge,se,_e,Te)=>{Q(P,"title",V),ee=Nt(O,1,"ui-dot",null,ee,{"ui-dot-ok":t(u),"ui-dot-error":!t(u)}),Q(R,"title",me),D=Nt(F,1,"ui-dot",null,D,{"ui-dot-ok":Er.connected,"ui-dot-error":!Er.connected}),c(q,` ${Se??""}`),Q(W,"title",Ge),Q(W,"aria-label",se),de=Nt(ae,1,"ui-bar-button",null,de,{"ui-bar-button-active":t(s)==="config"}),Q(ae,"title",_e),Q(ae,"aria-label",Te),Q(ae,"aria-current",t(s)==="config"?"page":void 0)},[()=>t(u)?d("Connected to the broker"):d("Not connected to the broker"),()=>Er.connected?d("Event stream connected"):d("Event stream disconnected"),()=>d("Live"),()=>d("Licences"),()=>d("Licences"),()=>d("Configuration"),()=>d("Configuration")]),M("click",W,()=>{w(o,!0)}),M("click",ae,()=>Xr.go("config")),g(e,x),zt()}lr(["click"]);function Kh(e,r){jt(r,!1),en(()=>{or.load()}),vc();var n=Zn(),a=Oe(n);{var i=s=>{Vh(s,{})},o=s=>{Rc(s,{})};H(a,s=>{or.state?.authenticated===!0?s(i):(or.state!==void 0||or.unreachable)&&s(o,1)})}g(e,n),zt()}yu();const Tu=document.getElementById("app");if(Tu===null)throw new Error("no #app");Jd(Kh,{target:Tu});