@owloops/browserbird 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -1
- package/dist/index.mjs +922 -162
- package/package.json +1 -1
- package/web/dist/assets/index-BehCAKeW.css +1 -0
- package/web/dist/assets/index-BsCZjyRj.js +8 -0
- package/web/dist/index.html +2 -2
- package/web/dist/assets/index-C4T4JGQp.css +0 -1
- package/web/dist/assets/index-rMAhMQyM.js +0 -8
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))n(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const r of i.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&n(r)}).observe(document,{childList:!0,subtree:!0});function s(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(a){if(a.ep)return;a.ep=!0;const i=s(a);fetch(a.href,i)}})();const ur=!1;var Ul=Array.isArray,Cd=Array.prototype.indexOf,ta=Array.prototype.includes,Ci=Array.from,Ed=Object.defineProperty,Jn=Object.getOwnPropertyDescriptor,Hl=Object.getOwnPropertyDescriptors,Ad=Object.prototype,Kd=Array.prototype,Lr=Object.getPrototypeOf,so=Object.isExtensible;const xa=()=>{};function Fd(t){return t()}function hr(t){for(var e=0;e<t.length;e++)t[e]()}function zl(){var t,e,s=new Promise((n,a)=>{t=n,e=a});return{promise:s,resolve:t,reject:e}}const It=2,Ra=4,Ia=8,Ol=1<<24,nn=16,Fs=32,zn=64,fr=128,_s=512,Xt=1024,Qt=2048,Ks=4096,os=8192,Js=16384,In=32768,Qn=65536,no=1<<17,Vl=1<<18,oa=1<<19,Gl=1<<20,Zs=1<<25,Nn=65536,_r=1<<21,Pr=1<<22,_n=1<<23,Pn=Symbol("$state"),Td=Symbol("legacy props"),Md=Symbol(""),Fn=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"},Xd=!!globalThis.document?.contentType&&globalThis.document.contentType.includes("xml");function Ld(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function Pd(t,e,s){throw new Error("https://svelte.dev/e/each_key_duplicate")}function Bd(t){throw new Error("https://svelte.dev/e/effect_in_teardown")}function Dd(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function Rd(t){throw new Error("https://svelte.dev/e/effect_orphan")}function Id(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function Qd(t){throw new Error("https://svelte.dev/e/props_invalid_value")}function Nd(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function Ud(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function Hd(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function zd(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const Od=1,Vd=2,ql=4,Gd=8,qd=16,Wd=1,jd=2,Yd=4,Zd=8,Jd=16,$d=1,eu=2,Dt=Symbol(),Wl="http://www.w3.org/1999/xhtml",tu="http://www.w3.org/2000/svg",su="http://www.w3.org/1998/Math/MathML";function nu(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function jl(t){return t===this.v}function au(t,e){return t!=t?e==e:t!==e||t!==null&&typeof t=="object"||typeof t=="function"}function Yl(t){return!au(t,this.v)}let Qa=!1,iu=!1;function ru(){Qa=!0}let Lt=null;function sa(t){Lt=t}function st(t,e=!1,s){Lt={p:Lt,i:!1,c:null,e:null,s:t,x:null,l:Qa&&!e?{s:null,u:null,$:[]}:null}}function nt(t){var e=Lt,s=e.e;if(s!==null){e.e=null;for(var n of s)pc(n)}return e.i=!0,Lt=e.p,{}}function Na(){return!Qa||Lt!==null&&Lt.l===null}let Tn=[];function Zl(){var t=Tn;Tn=[],hr(t)}function $s(t){if(Tn.length===0&&!Sa){var e=Tn;queueMicrotask(()=>{e===Tn&&Zl()})}Tn.push(t)}function ou(){for(;Tn.length>0;)Zl()}function Jl(t){var e=De;if(e===null)return Pe.f|=_n,t;if((e.f&In)===0&&(e.f&Ra)===0)throw t;un(t,e)}function un(t,e){for(;e!==null;){if((e.f&fr)!==0){if((e.f&In)===0)throw t;try{e.b.error(t);return}catch(s){t=s}}e=e.parent}throw t}const lu=-7169;function kt(t,e){t.f=t.f&lu|e}function Br(t){(t.f&_s)!==0||t.deps===null?kt(t,Xt):kt(t,Ks)}function $l(t){if(t!==null)for(const e of t)(e.f&It)===0||(e.f&Nn)===0||(e.f^=Nn,$l(e.deps))}function ec(t,e,s){(t.f&Qt)!==0?e.add(t):(t.f&Ks)!==0&&s.add(t),$l(t.deps),kt(t,Xt)}const ja=new Set;let We=null,vr=null,ks=null,Jt=[],Ei=null,pr=!1,Sa=!1;class vn{current=new Map;previous=new Map;#t=new Set;#o=new Set;#e=0;#i=0;#s=null;#r=new Set;#n=new Set;#a=new Map;is_fork=!1;#l=!1;#d(){return this.is_fork||this.#i>0}skip_effect(e){this.#a.has(e)||this.#a.set(e,{d:[],m:[]})}unskip_effect(e){var s=this.#a.get(e);if(s){this.#a.delete(e);for(var n of s.d)kt(n,Qt),Cs(n);for(n of s.m)kt(n,Ks),Cs(n)}}process(e){Jt=[],this.apply();var s=[],n=[];for(const a of e)this.#c(a,s,n);if(this.#d()){this.#u(n),this.#u(s);for(const[a,i]of this.#a)ac(a,i)}else{for(const a of this.#t)a();this.#t.clear(),this.#e===0&&this.#f(),vr=this,We=null,ao(n),ao(s),vr=null,this.#s?.resolve()}ks=null}#c(e,s,n){e.f^=Xt;for(var a=e.first;a!==null;){var i=a.f,r=(i&(Fs|zn))!==0,o=r&&(i&Xt)!==0,d=o||(i&os)!==0||this.#a.has(a);if(!d&&a.fn!==null){r?a.f^=Xt:(i&Ra)!==0?s.push(a):za(a)&&((i&nn)!==0&&this.#n.add(a),aa(a));var l=a.first;if(l!==null){a=l;continue}}for(;a!==null;){var u=a.next;if(u!==null){a=u;break}a=a.parent}}}#u(e){for(var s=0;s<e.length;s+=1)ec(e[s],this.#r,this.#n)}capture(e,s){s!==Dt&&!this.previous.has(e)&&this.previous.set(e,s),(e.f&_n)===0&&(this.current.set(e,e.v),ks?.set(e,e.v))}activate(){We=this,this.apply()}deactivate(){We===this&&(We=null,ks=null)}flush(){if(this.activate(),Jt.length>0){if(tc(),We!==null&&We!==this)return}else this.#e===0&&this.process([]);this.deactivate()}discard(){for(const e of this.#o)e(this);this.#o.clear()}#f(){if(ja.size>1){this.previous.clear();var e=ks,s=!0;for(const a of ja){if(a===this){s=!1;continue}const i=[];for(const[o,d]of this.current){if(a.current.has(o))if(s&&d!==a.current.get(o))a.current.set(o,d);else continue;i.push(o)}if(i.length===0)continue;const r=[...a.current.keys()].filter(o=>!this.current.has(o));if(r.length>0){var n=Jt;Jt=[];const o=new Set,d=new Map;for(const l of i)sc(l,r,o,d);if(Jt.length>0){We=a,a.apply();for(const l of Jt)a.#c(l,[],[]);a.deactivate()}Jt=n}}We=null,ks=e}ja.delete(this)}increment(e){this.#e+=1,e&&(this.#i+=1)}decrement(e){this.#e-=1,e&&(this.#i-=1),!this.#l&&(this.#l=!0,$s(()=>{this.#l=!1,this.#d()?Jt.length>0&&this.flush():this.revive()}))}revive(){for(const e of this.#r)this.#n.delete(e),kt(e,Qt),Cs(e);for(const e of this.#n)kt(e,Ks),Cs(e);this.flush()}oncommit(e){this.#t.add(e)}ondiscard(e){this.#o.add(e)}settled(){return(this.#s??=zl()).promise}static ensure(){if(We===null){const e=We=new vn;ja.add(We),Sa||$s(()=>{We===e&&e.flush()})}return We}apply(){}}function cu(t){var e=Sa;Sa=!0;try{for(var s;;){if(ou(),Jt.length===0&&(We?.flush(),Jt.length===0))return Ei=null,s;tc()}}finally{Sa=e}}function tc(){pr=!0;var t=null;try{for(var e=0;Jt.length>0;){var s=vn.ensure();if(e++>1e3){var n,a;du()}s.process(Jt),pn.clear()}}finally{Jt=[],pr=!1,Ei=null}}function du(){try{Id()}catch(t){un(t,Ei)}}let Ws=null;function ao(t){var e=t.length;if(e!==0){for(var s=0;s<e;){var n=t[s++];if((n.f&(Js|os))===0&&za(n)&&(Ws=new Set,aa(n),n.deps===null&&n.first===null&&n.nodes===null&&n.teardown===null&&n.ac===null&&bc(n),Ws?.size>0)){pn.clear();for(const a of Ws){if((a.f&(Js|os))!==0)continue;const i=[a];let r=a.parent;for(;r!==null;)Ws.has(r)&&(Ws.delete(r),i.push(r)),r=r.parent;for(let o=i.length-1;o>=0;o--){const d=i[o];(d.f&(Js|os))===0&&aa(d)}}Ws.clear()}}Ws=null}}function sc(t,e,s,n){if(!s.has(t)&&(s.add(t),t.reactions!==null))for(const a of t.reactions){const i=a.f;(i&It)!==0?sc(a,e,s,n):(i&(Pr|nn))!==0&&(i&Qt)===0&&nc(a,e,n)&&(kt(a,Qt),Cs(a))}}function nc(t,e,s){const n=s.get(t);if(n!==void 0)return n;if(t.deps!==null)for(const a of t.deps){if(ta.call(e,a))return!0;if((a.f&It)!==0&&nc(a,e,s))return s.set(a,!0),!0}return s.set(t,!1),!1}function Cs(t){var e=Ei=t,s=e.b;if(s?.is_pending&&(t.f&(Ra|Ia|Ol))!==0&&(t.f&In)===0){s.defer_effect(t);return}for(;e.parent!==null;){e=e.parent;var n=e.f;if(pr&&e===De&&(n&nn)!==0&&(n&Vl)===0&&(n&In)!==0)return;if((n&(zn|Fs))!==0){if((n&Xt)===0)return;e.f^=Xt}}Jt.push(e)}function ac(t,e){if(!((t.f&Fs)!==0&&(t.f&Xt)!==0)){(t.f&Qt)!==0?e.d.push(t):(t.f&Ks)!==0&&e.m.push(t),kt(t,Xt);for(var s=t.first;s!==null;)ac(s,e),s=s.next}}function uu(t){let e=0,s=Un(0),n;return()=>{Ir()&&(c(s),Qr(()=>(e===0&&(n=Oa(()=>t(()=>Ca(s)))),e+=1,()=>{$s(()=>{e-=1,e===0&&(n?.(),n=void 0,Ca(s))})})))}}var hu=Qn|oa;function fu(t,e,s,n){new _u(t,e,s,n)}class _u{parent;is_pending=!1;transform_error;#t;#o=null;#e;#i;#s;#r=null;#n=null;#a=null;#l=null;#d=0;#c=0;#u=!1;#f=new Set;#_=new Set;#h=null;#b=uu(()=>(this.#h=Un(this.#d),()=>{this.#h=null}));constructor(e,s,n,a){this.#t=e,this.#e=s,this.#i=i=>{var r=De;r.b=this,r.f|=fr,n(i)},this.parent=De.b,this.transform_error=a??this.parent?.transform_error??(i=>i),this.#s=Ki(()=>{this.#g()},hu)}#m(){try{this.#r=us(()=>this.#i(this.#t))}catch(e){this.error(e)}}#w(e){const s=this.#e.failed;s&&(this.#a=us(()=>{s(this.#t,()=>e,()=>()=>{})}))}#y(){const e=this.#e.pending;e&&(this.is_pending=!0,this.#n=us(()=>e(this.#t)),$s(()=>{var s=this.#l=document.createDocumentFragment(),n=en();s.append(n),this.#r=this.#p(()=>(vn.ensure(),us(()=>this.#i(n)))),this.#c===0&&(this.#t.before(s),this.#l=null,Bn(this.#n,()=>{this.#n=null}),this.#v())}))}#g(){try{if(this.is_pending=this.has_pending_snippet(),this.#c=0,this.#d=0,this.#r=us(()=>{this.#i(this.#t)}),this.#c>0){var e=this.#l=document.createDocumentFragment();yc(this.#r,e);const s=this.#e.pending;this.#n=us(()=>s(this.#t))}else this.#v()}catch(s){this.error(s)}}#v(){this.is_pending=!1;for(const e of this.#f)kt(e,Qt),Cs(e);for(const e of this.#_)kt(e,Ks),Cs(e);this.#f.clear(),this.#_.clear()}defer_effect(e){ec(e,this.#f,this.#_)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#e.pending}#p(e){var s=De,n=Pe,a=Lt;Ns(this.#s),ps(this.#s),sa(this.#s.ctx);try{return e()}catch(i){return Jl(i),null}finally{Ns(s),ps(n),sa(a)}}#x(e){if(!this.has_pending_snippet()){this.parent&&this.parent.#x(e);return}this.#c+=e,this.#c===0&&(this.#v(),this.#n&&Bn(this.#n,()=>{this.#n=null}),this.#l&&(this.#t.before(this.#l),this.#l=null))}update_pending_count(e){this.#x(e),this.#d+=e,!(!this.#h||this.#u)&&(this.#u=!0,$s(()=>{this.#u=!1,this.#h&&na(this.#h,this.#d)}))}get_effect_pending(){return this.#b(),c(this.#h)}error(e){var s=this.#e.onerror;let n=this.#e.failed;if(!s&&!n)throw e;this.#r&&(ts(this.#r),this.#r=null),this.#n&&(ts(this.#n),this.#n=null),this.#a&&(ts(this.#a),this.#a=null);var a=!1,i=!1;const r=()=>{if(a){nu();return}a=!0,i&&zd(),this.#a!==null&&Bn(this.#a,()=>{this.#a=null}),this.#p(()=>{vn.ensure(),this.#g()})},o=d=>{try{i=!0,s?.(d,r),i=!1}catch(l){un(l,this.#s&&this.#s.parent)}n&&(this.#a=this.#p(()=>{vn.ensure();try{return us(()=>{var l=De;l.b=this,l.f|=fr,n(this.#t,()=>d,()=>r)})}catch(l){return un(l,this.#s.parent),null}}))};$s(()=>{var d;try{d=this.transform_error(e)}catch(l){un(l,this.#s&&this.#s.parent);return}d!==null&&typeof d=="object"&&typeof d.then=="function"?d.then(o,l=>un(l,this.#s&&this.#s.parent)):o(d)})}}function vu(t,e,s,n){const a=Na()?Ua:Dr;var i=t.filter(_=>!_.settled);if(s.length===0&&i.length===0){n(e.map(a));return}var r=De,o=pu(),d=i.length===1?i[0].promise:i.length>1?Promise.all(i.map(_=>_.promise)):null;function l(_){o();try{n(_)}catch(p){(r.f&Js)===0&&un(p,r)}gr()}if(s.length===0){d.then(()=>l(e.map(a)));return}function u(){o(),Promise.all(s.map(_=>xu(_))).then(_=>l([...e.map(a),..._])).catch(_=>un(_,r))}d?d.then(u):u()}function pu(){var t=De,e=Pe,s=Lt,n=We;return function(i=!0){Ns(t),ps(e),sa(s),i&&n?.activate()}}function gr(t=!0){Ns(null),ps(null),sa(null),t&&We?.deactivate()}function gu(){var t=De.b,e=We,s=t.is_rendered();return t.update_pending_count(1),e.increment(s),()=>{t.update_pending_count(-1),e.decrement(s)}}function Ua(t){var e=It|Qt,s=Pe!==null&&(Pe.f&It)!==0?Pe:null;return De!==null&&(De.f|=oa),{ctx:Lt,deps:null,effects:null,equals:jl,f:e,fn:t,reactions:null,rv:0,v:Dt,wv:0,parent:s??De,ac:null}}function xu(t,e,s){De===null&&Ld();var a=void 0,i=Un(Dt),r=!Pe,o=new Map;return Xu(()=>{var d=zl();a=d.promise;try{Promise.resolve(t()).then(d.resolve,d.reject).finally(gr)}catch(p){d.reject(p),gr()}var l=We;if(r){var u=gu();o.get(l)?.reject(Fn),o.delete(l),o.set(l,d)}const _=(p,v=void 0)=>{if(l.activate(),v)v!==Fn&&(i.f|=_n,na(i,v));else{(i.f&_n)!==0&&(i.f^=_n),na(i,p);for(const[x,y]of o){if(o.delete(x),x===l)break;y.reject(Fn)}}u&&u()};d.promise.then(_,p=>_(null,p||"unknown"))}),vc(()=>{for(const d of o.values())d.reject(Fn)}),new Promise(d=>{function l(u){function _(){u===a?d(i):l(a)}u.then(_,_)}l(a)})}function Ae(t){const e=Ua(t);return kc(e),e}function Dr(t){const e=Ua(t);return e.equals=Yl,e}function bu(t){var e=t.effects;if(e!==null){t.effects=null;for(var s=0;s<e.length;s+=1)ts(e[s])}}function mu(t){for(var e=t.parent;e!==null;){if((e.f&It)===0)return(e.f&Js)===0?e:null;e=e.parent}return null}function Rr(t){var e,s=De;Ns(mu(t));try{t.f&=~Nn,bu(t),e=Ac(t)}finally{Ns(s)}return e}function ic(t){var e=Rr(t);if(!t.equals(e)&&(t.wv=Cc(),(!We?.is_fork||t.deps===null)&&(t.v=e,t.deps===null))){kt(t,Xt);return}mn||(ks!==null?(Ir()||We?.is_fork)&&ks.set(t,e):Br(t))}function wu(t){if(t.effects!==null)for(const e of t.effects)(e.teardown||e.ac)&&(e.teardown?.(),e.ac?.abort(Fn),e.teardown=xa,e.ac=null,Ma(e,0),Nr(e))}function rc(t){if(t.effects!==null)for(const e of t.effects)e.teardown&&aa(e)}let xr=new Set;const pn=new Map;let oc=!1;function Un(t,e){var s={f:0,v:t,reactions:null,equals:jl,rv:0,wv:0};return s}function W(t,e){const s=Un(t);return kc(s),s}function yu(t,e=!1,s=!0){const n=Un(t);return e||(n.equals=Yl),Qa&&s&&Lt!==null&&Lt.l!==null&&(Lt.l.s??=[]).push(n),n}function b(t,e,s=!1){Pe!==null&&(!Es||(Pe.f&no)!==0)&&Na()&&(Pe.f&(It|nn|Pr|no))!==0&&(vs===null||!ta.call(vs,t))&&Hd();let n=s?Ne(e):e;return na(t,n)}function na(t,e){if(!t.equals(e)){var s=t.v;mn?pn.set(t,e):pn.set(t,s),t.v=e;var n=vn.ensure();if(n.capture(t,s),(t.f&It)!==0){const a=t;(t.f&Qt)!==0&&Rr(a),Br(a)}t.wv=Cc(),lc(t,Qt),Na()&&De!==null&&(De.f&Xt)!==0&&(De.f&(Fs|zn))===0&&(ds===null?Pu([t]):ds.push(t)),!n.is_fork&&xr.size>0&&!oc&&ku()}return e}function ku(){oc=!1;for(const t of xr)(t.f&Xt)!==0&&kt(t,Ks),za(t)&&aa(t);xr.clear()}function br(t,e=1){var s=c(t),n=e===1?s++:s--;return b(t,s),n}function Ca(t){b(t,t.v+1)}function lc(t,e){var s=t.reactions;if(s!==null)for(var n=Na(),a=s.length,i=0;i<a;i++){var r=s[i],o=r.f;if(!(!n&&r===De)){var d=(o&Qt)===0;if(d&&kt(r,e),(o&It)!==0){var l=r;ks?.delete(l),(o&Nn)===0&&(o&_s&&(r.f|=Nn),lc(l,Ks))}else d&&((o&nn)!==0&&Ws!==null&&Ws.add(r),Cs(r))}}}function Ne(t){if(typeof t!="object"||t===null||Pn in t)return t;const e=Lr(t);if(e!==Ad&&e!==Kd)return t;var s=new Map,n=Ul(t),a=W(0),i=Dn,r=o=>{if(Dn===i)return o();var d=Pe,l=Dn;ps(null),oo(i);var u=o();return ps(d),oo(l),u};return n&&s.set("length",W(t.length)),new Proxy(t,{defineProperty(o,d,l){(!("value"in l)||l.configurable===!1||l.enumerable===!1||l.writable===!1)&&Nd();var u=s.get(d);return u===void 0?r(()=>{var _=W(l.value);return s.set(d,_),_}):b(u,l.value,!0),!0},deleteProperty(o,d){var l=s.get(d);if(l===void 0){if(d in o){const u=r(()=>W(Dt));s.set(d,u),Ca(a)}}else b(l,Dt),Ca(a);return!0},get(o,d,l){if(d===Pn)return t;var u=s.get(d),_=d in o;if(u===void 0&&(!_||Jn(o,d)?.writable)&&(u=r(()=>{var v=Ne(_?o[d]:Dt),x=W(v);return x}),s.set(d,u)),u!==void 0){var p=c(u);return p===Dt?void 0:p}return Reflect.get(o,d,l)},getOwnPropertyDescriptor(o,d){var l=Reflect.getOwnPropertyDescriptor(o,d);if(l&&"value"in l){var u=s.get(d);u&&(l.value=c(u))}else if(l===void 0){var _=s.get(d),p=_?.v;if(_!==void 0&&p!==Dt)return{enumerable:!0,configurable:!0,value:p,writable:!0}}return l},has(o,d){if(d===Pn)return!0;var l=s.get(d),u=l!==void 0&&l.v!==Dt||Reflect.has(o,d);if(l!==void 0||De!==null&&(!u||Jn(o,d)?.writable)){l===void 0&&(l=r(()=>{var p=u?Ne(o[d]):Dt,v=W(p);return v}),s.set(d,l));var _=c(l);if(_===Dt)return!1}return u},set(o,d,l,u){var _=s.get(d),p=d in o;if(n&&d==="length")for(var v=l;v<_.v;v+=1){var x=s.get(v+"");x!==void 0?b(x,Dt):v in o&&(x=r(()=>W(Dt)),s.set(v+"",x))}if(_===void 0)(!p||Jn(o,d)?.writable)&&(_=r(()=>W(void 0)),b(_,Ne(l)),s.set(d,_));else{p=_.v!==Dt;var y=r(()=>Ne(l));b(_,y)}var w=Reflect.getOwnPropertyDescriptor(o,d);if(w?.set&&w.set.call(u,l),!p){if(n&&typeof d=="string"){var S=s.get("length"),C=Number(d);Number.isInteger(C)&&C>=S.v&&b(S,C+1)}Ca(a)}return!0},ownKeys(o){c(a);var d=Reflect.ownKeys(o).filter(_=>{var p=s.get(_);return p===void 0||p.v!==Dt});for(var[l,u]of s)u.v!==Dt&&!(l in o)&&d.push(l);return d},setPrototypeOf(){Ud()}})}var _i,cc,dc,uc;function Su(){if(_i===void 0){_i=window,cc=/Firefox/.test(navigator.userAgent);var t=Element.prototype,e=Node.prototype,s=Text.prototype;dc=Jn(e,"firstChild").get,uc=Jn(e,"nextSibling").get,so(t)&&(t.__click=void 0,t.__className=void 0,t.__attributes=null,t.__style=void 0,t.__e=void 0),so(s)&&(s.__t=void 0)}}function en(t=""){return document.createTextNode(t)}function tn(t){return dc.call(t)}function Ha(t){return uc.call(t)}function h(t,e){return tn(t)}function me(t,e=!1){{var s=tn(t);return s instanceof Comment&&s.data===""?Ha(s):s}}function f(t,e=1,s=!1){let n=t;for(;e--;)n=Ha(n);return n}function Cu(t){t.textContent=""}function hc(){return!1}function fc(t,e,s){return document.createElementNS(e??Wl,t,void 0)}let io=!1;function Eu(){io||(io=!0,document.addEventListener("reset",t=>{Promise.resolve().then(()=>{if(!t.defaultPrevented)for(const e of t.target.elements)e.__on_r?.()})},{capture:!0}))}function Ai(t){var e=Pe,s=De;ps(null),Ns(null);try{return t()}finally{ps(e),Ns(s)}}function Au(t,e,s,n=s){t.addEventListener(e,()=>Ai(s));const a=t.__on_r;a?t.__on_r=()=>{a(),n(!0)}:t.__on_r=()=>n(!0),Eu()}function _c(t){De===null&&(Pe===null&&Rd(),Dd()),mn&&Bd()}function Ku(t,e){var s=e.last;s===null?e.last=e.first=t:(s.next=t,t.prev=s,e.last=t)}function Us(t,e,s){var n=De;n!==null&&(n.f&os)!==0&&(t|=os);var a={ctx:Lt,deps:null,nodes:null,f:t|Qt|_s,first:null,fn:e,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};if(s)try{aa(a)}catch(o){throw ts(a),o}else e!==null&&Cs(a);var i=a;if(s&&i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&(i.f&oa)===0&&(i=i.first,(t&nn)!==0&&(t&Qn)!==0&&i!==null&&(i.f|=Qn)),i!==null&&(i.parent=n,n!==null&&Ku(i,n),Pe!==null&&(Pe.f&It)!==0&&(t&zn)===0)){var r=Pe;(r.effects??=[]).push(i)}return a}function Ir(){return Pe!==null&&!Es}function vc(t){const e=Us(Ia,null,!1);return kt(e,Xt),e.teardown=t,e}function xt(t){_c();var e=De.f,s=!Pe&&(e&Fs)!==0&&(e&In)===0;if(s){var n=Lt;(n.e??=[]).push(t)}else return pc(t)}function pc(t){return Us(Ra|Gl,t,!1)}function Fu(t){return _c(),Us(Ia|Gl,t,!0)}function Tu(t){vn.ensure();const e=Us(zn|oa,t,!0);return(s={})=>new Promise(n=>{s.outro?Bn(e,()=>{ts(e),n(void 0)}):(ts(e),n(void 0))})}function Mu(t){return Us(Ra,t,!1)}function Xu(t){return Us(Pr|oa,t,!0)}function Qr(t,e=0){return Us(Ia|e,t,!0)}function V(t,e=[],s=[],n=[]){vu(n,e,s,a=>{Us(Ia,()=>t(...a.map(c)),!0)})}function Ki(t,e=0){var s=Us(nn|e,t,!0);return s}function us(t){return Us(Fs|oa,t,!0)}function gc(t){var e=t.teardown;if(e!==null){const s=mn,n=Pe;ro(!0),ps(null);try{e.call(null)}finally{ro(s),ps(n)}}}function Nr(t,e=!1){var s=t.first;for(t.first=t.last=null;s!==null;){const a=s.ac;a!==null&&Ai(()=>{a.abort(Fn)});var n=s.next;(s.f&zn)!==0?s.parent=null:ts(s,e),s=n}}function Lu(t){for(var e=t.first;e!==null;){var s=e.next;(e.f&Fs)===0&&ts(e),e=s}}function ts(t,e=!0){var s=!1;(e||(t.f&Vl)!==0)&&t.nodes!==null&&t.nodes.end!==null&&(xc(t.nodes.start,t.nodes.end),s=!0),Nr(t,e&&!s),Ma(t,0),kt(t,Js);var n=t.nodes&&t.nodes.t;if(n!==null)for(const i of n)i.stop();gc(t);var a=t.parent;a!==null&&a.first!==null&&bc(t),t.next=t.prev=t.teardown=t.ctx=t.deps=t.fn=t.nodes=t.ac=null}function xc(t,e){for(;t!==null;){var s=t===e?null:Ha(t);t.remove(),t=s}}function bc(t){var e=t.parent,s=t.prev,n=t.next;s!==null&&(s.next=n),n!==null&&(n.prev=s),e!==null&&(e.first===t&&(e.first=n),e.last===t&&(e.last=s))}function Bn(t,e,s=!0){var n=[];mc(t,n,!0);var a=()=>{s&&ts(t),e&&e()},i=n.length;if(i>0){var r=()=>--i||a();for(var o of n)o.out(r)}else a()}function mc(t,e,s){if((t.f&os)===0){t.f^=os;var n=t.nodes&&t.nodes.t;if(n!==null)for(const o of n)(o.is_global||s)&&e.push(o);for(var a=t.first;a!==null;){var i=a.next,r=(a.f&Qn)!==0||(a.f&Fs)!==0&&(t.f&nn)!==0;mc(a,e,r?s:!1),a=i}}}function Ur(t){wc(t,!0)}function wc(t,e){if((t.f&os)!==0){t.f^=os,(t.f&Xt)===0&&(kt(t,Qt),Cs(t));for(var s=t.first;s!==null;){var n=s.next,a=(s.f&Qn)!==0||(s.f&Fs)!==0;wc(s,a?e:!1),s=n}var i=t.nodes&&t.nodes.t;if(i!==null)for(const r of i)(r.is_global||e)&&r.in()}}function yc(t,e){if(t.nodes)for(var s=t.nodes.start,n=t.nodes.end;s!==null;){var a=s===n?null:Ha(s);e.append(s),s=a}}let ci=!1,mn=!1;function ro(t){mn=t}let Pe=null,Es=!1;function ps(t){Pe=t}let De=null;function Ns(t){De=t}let vs=null;function kc(t){Pe!==null&&(vs===null?vs=[t]:vs.push(t))}let $t=null,is=0,ds=null;function Pu(t){ds=t}let Sc=1,Mn=0,Dn=Mn;function oo(t){Dn=t}function Cc(){return++Sc}function za(t){var e=t.f;if((e&Qt)!==0)return!0;if(e&It&&(t.f&=~Nn),(e&Ks)!==0){for(var s=t.deps,n=s.length,a=0;a<n;a++){var i=s[a];if(za(i)&&ic(i),i.wv>t.wv)return!0}(e&_s)!==0&&ks===null&&kt(t,Xt)}return!1}function Ec(t,e,s=!0){var n=t.reactions;if(n!==null&&!(vs!==null&&ta.call(vs,t)))for(var a=0;a<n.length;a++){var i=n[a];(i.f&It)!==0?Ec(i,e,!1):e===i&&(s?kt(i,Qt):(i.f&Xt)!==0&&kt(i,Ks),Cs(i))}}function Ac(t){var e=$t,s=is,n=ds,a=Pe,i=vs,r=Lt,o=Es,d=Dn,l=t.f;$t=null,is=0,ds=null,Pe=(l&(Fs|zn))===0?t:null,vs=null,sa(t.ctx),Es=!1,Dn=++Mn,t.ac!==null&&(Ai(()=>{t.ac.abort(Fn)}),t.ac=null);try{t.f|=_r;var u=t.fn,_=u();t.f|=In;var p=t.deps,v=We?.is_fork;if($t!==null){var x;if(v||Ma(t,is),p!==null&&is>0)for(p.length=is+$t.length,x=0;x<$t.length;x++)p[is+x]=$t[x];else t.deps=p=$t;if(Ir()&&(t.f&_s)!==0)for(x=is;x<p.length;x++)(p[x].reactions??=[]).push(t)}else!v&&p!==null&&is<p.length&&(Ma(t,is),p.length=is);if(Na()&&ds!==null&&!Es&&p!==null&&(t.f&(It|Ks|Qt))===0)for(x=0;x<ds.length;x++)Ec(ds[x],t);if(a!==null&&a!==t){if(Mn++,a.deps!==null)for(let y=0;y<s;y+=1)a.deps[y].rv=Mn;if(e!==null)for(const y of e)y.rv=Mn;ds!==null&&(n===null?n=ds:n.push(...ds))}return(t.f&_n)!==0&&(t.f^=_n),_}catch(y){return Jl(y)}finally{t.f^=_r,$t=e,is=s,ds=n,Pe=a,vs=i,sa(r),Es=o,Dn=d}}function Bu(t,e){let s=e.reactions;if(s!==null){var n=Cd.call(s,t);if(n!==-1){var a=s.length-1;a===0?s=e.reactions=null:(s[n]=s[a],s.pop())}}if(s===null&&(e.f&It)!==0&&($t===null||!ta.call($t,e))){var i=e;(i.f&_s)!==0&&(i.f^=_s,i.f&=~Nn),Br(i),wu(i),Ma(i,0)}}function Ma(t,e){var s=t.deps;if(s!==null)for(var n=e;n<s.length;n++)Bu(t,s[n])}function aa(t){var e=t.f;if((e&Js)===0){kt(t,Xt);var s=De,n=ci;De=t,ci=!0;try{(e&(nn|Ol))!==0?Lu(t):Nr(t),gc(t);var a=Ac(t);t.teardown=typeof a=="function"?a:null,t.wv=Sc;var i;ur&&iu&&(t.f&Qt)!==0&&t.deps}finally{ci=n,De=s}}}async function Kc(){await Promise.resolve(),cu()}function c(t){var e=t.f,s=(e&It)!==0;if(Pe!==null&&!Es){var n=De!==null&&(De.f&Js)!==0;if(!n&&(vs===null||!ta.call(vs,t))){var a=Pe.deps;if((Pe.f&_r)!==0)t.rv<Mn&&(t.rv=Mn,$t===null&&a!==null&&a[is]===t?is++:$t===null?$t=[t]:$t.push(t));else{(Pe.deps??=[]).push(t);var i=t.reactions;i===null?t.reactions=[Pe]:ta.call(i,Pe)||i.push(Pe)}}}if(mn&&pn.has(t))return pn.get(t);if(s){var r=t;if(mn){var o=r.v;return((r.f&Xt)===0&&r.reactions!==null||Tc(r))&&(o=Rr(r)),pn.set(r,o),o}var d=(r.f&_s)===0&&!Es&&Pe!==null&&(ci||(Pe.f&_s)!==0),l=(r.f&In)===0;za(r)&&(d&&(r.f|=_s),ic(r)),d&&!l&&(rc(r),Fc(r))}if(ks?.has(t))return ks.get(t);if((t.f&_n)!==0)throw t.v;return t.v}function Fc(t){if(t.f|=_s,t.deps!==null)for(const e of t.deps)(e.reactions??=[]).push(t),(e.f&It)!==0&&(e.f&_s)===0&&(rc(e),Fc(e))}function Tc(t){if(t.v===Dt)return!0;if(t.deps===null)return!1;for(const e of t.deps)if(pn.has(e)||(e.f&It)!==0&&Tc(e))return!0;return!1}function Oa(t){var e=Es;try{return Es=!0,t()}finally{Es=e}}function Du(t){if(!(typeof t!="object"||!t||t instanceof EventTarget)){if(Pn in t)mr(t);else if(!Array.isArray(t))for(let e in t){const s=t[e];typeof s=="object"&&s&&Pn in s&&mr(s)}}}function mr(t,e=new Set){if(typeof t=="object"&&t!==null&&!(t instanceof EventTarget)&&!e.has(t)){e.add(t),t instanceof Date&&t.getTime();for(let n in t)try{mr(t[n],e)}catch{}const s=Lr(t);if(s!==Object.prototype&&s!==Array.prototype&&s!==Map.prototype&&s!==Set.prototype&&s!==Date.prototype){const n=Hl(s);for(let a in n){const i=n[a].get;if(i)try{i.call(t)}catch{}}}}}const Ru=["touchstart","touchmove"];function Iu(t){return Ru.includes(t)}const ba=Symbol("events"),Mc=new Set,wr=new Set;function Qu(t,e,s,n={}){function a(i){if(n.capture||yr.call(e,i),!i.cancelBubble)return Ai(()=>s?.call(this,i))}return t.startsWith("pointer")||t.startsWith("touch")||t==="wheel"?$s(()=>{e.addEventListener(t,a,n)}):e.addEventListener(t,a,n),a}function Rn(t,e,s,n,a){var i={capture:n,passive:a},r=Qu(t,e,s,i);(e===document.body||e===window||e===document||e instanceof HTMLMediaElement)&&vc(()=>{e.removeEventListener(t,r,i)})}function G(t,e,s){(e[ba]??={})[t]=s}function _t(t){for(var e=0;e<t.length;e++)Mc.add(t[e]);for(var s of wr)s(t)}let lo=null;function yr(t){var e=this,s=e.ownerDocument,n=t.type,a=t.composedPath?.()||[],i=a[0]||t.target;lo=t;var r=0,o=lo===t&&t[ba];if(o){var d=a.indexOf(o);if(d!==-1&&(e===document||e===window)){t[ba]=e;return}var l=a.indexOf(e);if(l===-1)return;d<=l&&(r=d)}if(i=a[r]||t.target,i!==e){Ed(t,"currentTarget",{configurable:!0,get(){return i||s}});var u=Pe,_=De;ps(null),Ns(null);try{for(var p,v=[];i!==null;){var x=i.assignedSlot||i.parentNode||i.host||null;try{var y=i[ba]?.[n];y!=null&&(!i.disabled||t.target===i)&&y.call(i,t)}catch(w){p?v.push(w):p=w}if(t.cancelBubble||x===e||x===null)break;i=x}if(p){for(let w of v)queueMicrotask(()=>{throw w});throw p}}finally{t[ba]=e,delete t.currentTarget,ps(u),Ns(_)}}}const Nu=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:t=>t});function Uu(t){return Nu?.createHTML(t)??t}function Xc(t){var e=fc("template");return e.innerHTML=Uu(t.replaceAll("<!>","<!---->")),e.content}function ia(t,e){var s=De;s.nodes===null&&(s.nodes={start:t,end:e,a:null,t:null})}function F(t,e){var s=(e&$d)!==0,n=(e&eu)!==0,a,i=!t.startsWith("<!>");return()=>{a===void 0&&(a=Xc(i?t:"<!>"+t),s||(a=tn(a)));var r=n||cc?document.importNode(a,!0):a.cloneNode(!0);if(s){var o=tn(r),d=r.lastChild;ia(o,d)}else ia(r,r);return r}}function Hu(t,e,s="svg"){var n=!t.startsWith("<!>"),a=`<${s}>${n?t:"<!>"+t}</${s}>`,i;return()=>{if(!i){var r=Xc(a),o=tn(r);i=tn(o)}var d=i.cloneNode(!0);return ia(d,d),d}}function kn(t,e){return Hu(t,e,"svg")}function Ss(t=""){{var e=en(t+"");return ia(e,e),e}}function yt(){var t=document.createDocumentFragment(),e=document.createComment(""),s=en();return t.append(e,s),ia(e,s),t}function k(t,e){t!==null&&t.before(e)}function M(t,e){var s=e==null?"":typeof e=="object"?e+"":e;s!==(t.__t??=t.nodeValue)&&(t.__t=s,t.nodeValue=s+"")}function zu(t,e){return Ou(t,e)}const Ya=new Map;function Ou(t,{target:e,anchor:s,props:n={},events:a,context:i,intro:r=!0,transformError:o}){Su();var d=void 0,l=Tu(()=>{var u=s??e.appendChild(en());fu(u,{pending:()=>{}},v=>{st({});var x=Lt;i&&(x.c=i),a&&(n.$$events=a),d=t(v,n)||{},nt()},o);var _=new Set,p=v=>{for(var x=0;x<v.length;x++){var y=v[x];if(!_.has(y)){_.add(y);var w=Iu(y);for(const K of[e,document]){var S=Ya.get(K);S===void 0&&(S=new Map,Ya.set(K,S));var C=S.get(y);C===void 0?(K.addEventListener(y,yr,{passive:w}),S.set(y,1)):S.set(y,C+1)}}}};return p(Ci(Mc)),wr.add(p),()=>{for(var v of _)for(const w of[e,document]){var x=Ya.get(w),y=x.get(v);--y==0?(w.removeEventListener(v,yr),x.delete(v),x.size===0&&Ya.delete(w)):x.set(v,y)}wr.delete(p),u!==s&&u.parentNode?.removeChild(u)}});return Vu.set(d,l),d}let Vu=new WeakMap;class Lc{anchor;#t=new Map;#o=new Map;#e=new Map;#i=new Set;#s=!0;constructor(e,s=!0){this.anchor=e,this.#s=s}#r=()=>{var e=We;if(this.#t.has(e)){var s=this.#t.get(e),n=this.#o.get(s);if(n)Ur(n),this.#i.delete(s);else{var a=this.#e.get(s);a&&(this.#o.set(s,a.effect),this.#e.delete(s),a.fragment.lastChild.remove(),this.anchor.before(a.fragment),n=a.effect)}for(const[i,r]of this.#t){if(this.#t.delete(i),i===e)break;const o=this.#e.get(r);o&&(ts(o.effect),this.#e.delete(r))}for(const[i,r]of this.#o){if(i===s||this.#i.has(i))continue;const o=()=>{if(Array.from(this.#t.values()).includes(i)){var l=document.createDocumentFragment();yc(r,l),l.append(en()),this.#e.set(i,{effect:r,fragment:l})}else ts(r);this.#i.delete(i),this.#o.delete(i)};this.#s||!n?(this.#i.add(i),Bn(r,o,!1)):o()}}};#n=e=>{this.#t.delete(e);const s=Array.from(this.#t.values());for(const[n,a]of this.#e)s.includes(n)||(ts(a.effect),this.#e.delete(n))};ensure(e,s){var n=We,a=hc();if(s&&!this.#o.has(e)&&!this.#e.has(e))if(a){var i=document.createDocumentFragment(),r=en();i.append(r),this.#e.set(e,{effect:us(()=>s(r)),fragment:i})}else this.#o.set(e,us(()=>s(this.anchor)));if(this.#t.set(n,e),a){for(const[o,d]of this.#o)o===e?n.unskip_effect(d):n.skip_effect(d);for(const[o,d]of this.#e)o===e?n.unskip_effect(d.effect):n.skip_effect(d.effect);n.oncommit(this.#r),n.ondiscard(this.#n)}else this.#r()}}function O(t,e,s=!1){var n=new Lc(t),a=s?Qn:0;function i(r,o){n.ensure(r,o)}Ki(()=>{var r=!1;e((o,d=0)=>{r=!0,i(d,o)}),r||i(!1,null)},a)}function Pc(t,e){return e}function Gu(t,e,s){for(var n=[],a=e.length,i,r=e.length,o=0;o<a;o++){let _=e[o];Bn(_,()=>{if(i){if(i.pending.delete(_),i.done.add(_),i.pending.size===0){var p=t.outrogroups;kr(Ci(i.done)),p.delete(i),p.size===0&&(t.outrogroups=null)}}else r-=1},!1)}if(r===0){var d=n.length===0&&s!==null;if(d){var l=s,u=l.parentNode;Cu(u),u.append(l),t.items.clear()}kr(e,!d)}else i={pending:new Set(e),done:new Set},(t.outrogroups??=new Set).add(i)}function kr(t,e=!0){for(var s=0;s<t.length;s++)ts(t[s],e)}var co;function Mt(t,e,s,n,a,i=null){var r=t,o=new Map,d=(e&ql)!==0;if(d){var l=t;r=l.appendChild(en())}var u=null,_=Dr(()=>{var S=s();return Ul(S)?S:S==null?[]:Ci(S)}),p,v=!0;function x(){w.fallback=u,qu(w,p,r,e,n),u!==null&&(p.length===0?(u.f&Zs)===0?Ur(u):(u.f^=Zs,ma(u,null,r)):Bn(u,()=>{u=null}))}var y=Ki(()=>{p=c(_);for(var S=p.length,C=new Set,K=We,E=hc(),U=0;U<S;U+=1){var te=p[U],T=n(te,U),A=v?null:o.get(T);A?(A.v&&na(A.v,te),A.i&&na(A.i,U),E&&K.unskip_effect(A.e)):(A=Wu(o,v?r:co??=en(),te,T,U,a,e,s),v||(A.e.f|=Zs),o.set(T,A)),C.add(T)}if(S===0&&i&&!u&&(v?u=us(()=>i(r)):(u=us(()=>i(co??=en())),u.f|=Zs)),S>C.size&&Pd(),!v)if(E){for(const[X,L]of o)C.has(X)||K.skip_effect(L.e);K.oncommit(x),K.ondiscard(()=>{})}else x();c(_)}),w={effect:y,items:o,outrogroups:null,fallback:u};v=!1}function da(t){for(;t!==null&&(t.f&Fs)===0;)t=t.next;return t}function qu(t,e,s,n,a){var i=(n&Gd)!==0,r=e.length,o=t.items,d=da(t.effect.first),l,u=null,_,p=[],v=[],x,y,w,S;if(i)for(S=0;S<r;S+=1)x=e[S],y=a(x,S),w=o.get(y).e,(w.f&Zs)===0&&(w.nodes?.a?.measure(),(_??=new Set).add(w));for(S=0;S<r;S+=1){if(x=e[S],y=a(x,S),w=o.get(y).e,t.outrogroups!==null)for(const L of t.outrogroups)L.pending.delete(w),L.done.delete(w);if((w.f&Zs)!==0)if(w.f^=Zs,w===d)ma(w,null,s);else{var C=u?u.next:d;w===t.effect.last&&(t.effect.last=w.prev),w.prev&&(w.prev.next=w.next),w.next&&(w.next.prev=w.prev),on(t,u,w),on(t,w,C),ma(w,C,s),u=w,p=[],v=[],d=da(u.next);continue}if((w.f&os)!==0&&(Ur(w),i&&(w.nodes?.a?.unfix(),(_??=new Set).delete(w))),w!==d){if(l!==void 0&&l.has(w)){if(p.length<v.length){var K=v[0],E;u=K.prev;var U=p[0],te=p[p.length-1];for(E=0;E<p.length;E+=1)ma(p[E],K,s);for(E=0;E<v.length;E+=1)l.delete(v[E]);on(t,U.prev,te.next),on(t,u,U),on(t,te,K),d=K,u=te,S-=1,p=[],v=[]}else l.delete(w),ma(w,d,s),on(t,w.prev,w.next),on(t,w,u===null?t.effect.first:u.next),on(t,u,w),u=w;continue}for(p=[],v=[];d!==null&&d!==w;)(l??=new Set).add(d),v.push(d),d=da(d.next);if(d===null)continue}(w.f&Zs)===0&&p.push(w),u=w,d=da(w.next)}if(t.outrogroups!==null){for(const L of t.outrogroups)L.pending.size===0&&(kr(Ci(L.done)),t.outrogroups?.delete(L));t.outrogroups.size===0&&(t.outrogroups=null)}if(d!==null||l!==void 0){var T=[];if(l!==void 0)for(w of l)(w.f&os)===0&&T.push(w);for(;d!==null;)(d.f&os)===0&&d!==t.fallback&&T.push(d),d=da(d.next);var A=T.length;if(A>0){var X=(n&ql)!==0&&r===0?s:null;if(i){for(S=0;S<A;S+=1)T[S].nodes?.a?.measure();for(S=0;S<A;S+=1)T[S].nodes?.a?.fix()}Gu(t,T,X)}}i&&$s(()=>{if(_!==void 0)for(w of _)w.nodes?.a?.apply()})}function Wu(t,e,s,n,a,i,r,o){var d=(r&Od)!==0?(r&qd)===0?yu(s,!1,!1):Un(s):null,l=(r&Vd)!==0?Un(a):null;return{v:d,i:l,e:us(()=>(i(e,d??s,l??a,o),()=>{t.delete(n)}))}}function ma(t,e,s){if(t.nodes)for(var n=t.nodes.start,a=t.nodes.end,i=e&&(e.f&Zs)===0?e.nodes.start:s;n!==null;){var r=Ha(n);if(i.before(n),n===a)return;n=r}}function on(t,e,s){e===null?t.effect.first=s:e.next=s,s===null?t.effect.last=e:s.prev=e}function ju(t,e,s=!1,n=!1,a=!1){var i=t,r="";V(()=>{var o=De;if(r!==(r=e()??"")&&(o.nodes!==null&&(xc(o.nodes.start,o.nodes.end),o.nodes=null),r!=="")){var d=s?tu:n?su:void 0,l=fc(s?"svg":n?"math":"template",d);l.innerHTML=r;var u=s||n?l:l.content;if(ia(tn(u),u.lastChild),s||n)for(;tn(u);)i.before(tn(u));else i.before(u)}})}function uo(t,e,...s){var n=new Lc(t);Ki(()=>{const a=e()??null;n.ensure(a,a&&(i=>a(i,...s)))},Qn)}function Bc(t){var e,s,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var a=t.length;for(e=0;e<a;e++)t[e]&&(s=Bc(t[e]))&&(n&&(n+=" "),n+=s)}else for(s in t)t[s]&&(n&&(n+=" "),n+=s);return n}function Yu(){for(var t,e,s=0,n="",a=arguments.length;s<a;s++)(t=arguments[s])&&(e=Bc(t))&&(n&&(n+=" "),n+=e);return n}function Zu(t){return typeof t=="object"?Yu(t):t??""}const ho=[...`
|
|
2
|
-
\r\f \v\uFEFF`];function Ju(t,e,s){var n=t==null?"":""+t;if(e&&(n=n?n+" "+e:e),s){for(var a of Object.keys(s))if(s[a])n=n?n+" "+a:a;else if(n.length)for(var i=a.length,r=0;(r=n.indexOf(a,r))>=0;){var o=r+i;(r===0||ho.includes(n[r-1]))&&(o===n.length||ho.includes(n[o]))?n=(r===0?"":n.substring(0,r))+n.substring(o+1):r=o}}return n===""?null:n}function pe(t,e,s,n,a,i){var r=t.__className;if(r!==s||r===void 0){var o=Ju(s,n,i);o==null?t.removeAttribute("class"):t.className=o,t.__className=s}else if(i&&a!==i)for(var d in i){var l=!!i[d];(a==null||l!==!!a[d])&&t.classList.toggle(d,l)}return i}const $u=Symbol("is custom element"),eh=Symbol("is html"),th=Xd?"progress":"PROGRESS";function Dc(t,e){var s=Rc(t);s.value===(s.value=e??void 0)||t.value===e&&(e!==0||t.nodeName!==th)||(t.value=e??"")}function jt(t,e,s,n){var a=Rc(t);a[e]!==(a[e]=s)&&(e==="loading"&&(t[Md]=s),s==null?t.removeAttribute(e):typeof s!="string"&&sh(t).includes(e)?t[e]=s:t.setAttribute(e,s))}function Rc(t){return t.__attributes??={[$u]:t.nodeName.includes("-"),[eh]:t.namespaceURI===Wl}}var fo=new Map;function sh(t){var e=t.getAttribute("is")||t.nodeName,s=fo.get(e);if(s)return s;fo.set(e,s=[]);for(var n,a=t,i=Element.prototype;i!==a;){n=Hl(a);for(var r in n)n[r].set&&s.push(r);a=Lr(a)}return s}function He(t,e,s=e){var n=new WeakSet;Au(t,"input",async a=>{var i=a?t.defaultValue:t.value;if(i=Ni(t)?Ui(i):i,s(i),We!==null&&n.add(We),await Kc(),i!==(i=e())){var r=t.selectionStart,o=t.selectionEnd,d=t.value.length;if(t.value=i??"",o!==null){var l=t.value.length;r===o&&o===d&&l>d?(t.selectionStart=l,t.selectionEnd=l):(t.selectionStart=r,t.selectionEnd=Math.min(o,l))}}}),Oa(e)==null&&t.value&&(s(Ni(t)?Ui(t.value):t.value),We!==null&&n.add(We)),Qr(()=>{var a=e();if(t===document.activeElement){var i=vr??We;if(n.has(i))return}Ni(t)&&a===Ui(t.value)||t.type==="date"&&!a&&!t.value||a!==t.value&&(t.value=a??"")})}function Ni(t){var e=t.type;return e==="number"||e==="range"}function Ui(t){return t===""?null:+t}function _o(t,e){return t===e||t?.[Pn]===e}function nh(t={},e,s,n){return Mu(()=>{var a,i;return Qr(()=>{a=i,i=[],Oa(()=>{t!==s(...i)&&(e(t,...i),a&&_o(s(...a),t)&&e(null,...a))})}),()=>{$s(()=>{i&&_o(s(...i),t)&&e(null,...i)})}}),t}function Ic(t=!1){const e=Lt,s=e.l.u;if(!s)return;let n=()=>Du(e.s);if(t){let a=0,i={};const r=Ua(()=>{let o=!1;const d=e.s;for(const l in d)d[l]!==i[l]&&(i[l]=d[l],o=!0);return o&&a++,a});n=()=>c(r)}s.b.length&&Fu(()=>{vo(e,n),hr(s.b)}),xt(()=>{const a=Oa(()=>s.m.map(Fd));return()=>{for(const i of a)typeof i=="function"&&i()}}),s.a.length&&xt(()=>{vo(e,n),hr(s.a)})}function vo(t,e){if(t.l.s)for(const s of t.l.s)c(s);e()}let Za=!1;function ah(t){var e=Za;try{return Za=!1,[t(),Za]}finally{Za=e}}function Wn(t,e,s,n){var a=!Qa||(s&jd)!==0,i=(s&Zd)!==0,r=(s&Jd)!==0,o=n,d=!0,l=()=>(d&&(d=!1,o=r?Oa(n):n),o),u;if(i){var _=Pn in t||Td in t;u=Jn(t,e)?.set??(_&&e in t?K=>t[e]=K:void 0)}var p,v=!1;i?[p,v]=ah(()=>t[e]):p=t[e],p===void 0&&n!==void 0&&(p=l(),u&&(a&&Qd(),u(p)));var x;if(a?x=()=>{var K=t[e];return K===void 0?l():(d=!0,K)}:x=()=>{var K=t[e];return K!==void 0&&(o=void 0),K===void 0?o:K},a&&(s&Yd)===0)return x;if(u){var y=t.$$legacy;return(function(K,E){return arguments.length>0?((!a||!E||y||v)&&u(E?x():K),K):x()})}var w=!1,S=((s&Wd)!==0?Ua:Dr)(()=>(w=!1,x()));i&&c(S);var C=De;return(function(K,E){if(arguments.length>0){const U=E?c(S):a&&i?Ne(K):K;return b(S,U),w=!0,o!==void 0&&(o=U),K}return mn&&w||(C.f&Js)!==0?S.v:c(S)})}const ih="5";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add(ih);const Hr="browserbird_auth_token",ra="";let Qc=null;function rh(t){Qc=t}function Fi(){return localStorage.getItem(Hr)}function po(t){localStorage.setItem(Hr,t)}function zr(){localStorage.removeItem(Hr)}async function ke(t,e){const s={},n=Fi();n&&(s.Authorization=`Bearer ${n}`),e?.body!==void 0&&(s["Content-Type"]="application/json");const a=await fetch(`${ra}${t}`,{method:e?.method??"GET",headers:s,body:e?.body!==void 0?JSON.stringify(e.body):void 0});if(a.status===401)throw zr(),Qc?.(),new Error("Unauthorized");if(!a.ok){const i=await a.json().catch(()=>({error:a.statusText}));throw new Error(i.error??`${a.status}`)}return a.json()}async function go(){return(await fetch(`${ra}/api/auth/check`)).json()}async function oh(t,e){const s=await fetch(`${ra}/api/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t,password:e})});if(!s.ok){const n=await s.json().catch(()=>({error:"Login failed"}));throw new Error(n.error??"Login failed")}return s.json()}async function lh(t,e){const s=await fetch(`${ra}/api/auth/setup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t,password:e})});if(!s.ok){const n=await s.json().catch(()=>({error:"Setup failed"}));throw new Error(n.error??"Setup failed")}return s.json()}async function ch(){try{return await ke("/api/auth/verify",{method:"POST"}),!0}catch{return zr(),!1}}function xo(){const t=window.location.hash.slice(2),e=t.indexOf("?");return(e===-1?t:t.slice(0,e))||"status"}function Ti(){const t=window.location.hash.slice(2),e=t.indexOf("?");return new URLSearchParams(e===-1?"":t.slice(e+1))}async function dh(){return ke("/api/onboarding/defaults")}async function uh(t,e){return ke("/api/onboarding/slack",{method:"POST",body:{botToken:t,appToken:e}})}async function hh(t){return ke("/api/onboarding/agent",{method:"POST",body:t})}async function fh(t){return ke("/api/onboarding/auth",{method:"POST",body:t})}async function _h(t){return ke("/api/onboarding/browser",{method:"POST",body:t})}async function vh(t,e){return ke("/api/onboarding/browser/probe",{method:"POST",body:{host:t,port:e}})}async function ph(){return ke("/api/onboarding/complete",{method:"POST",body:{}})}let es=null,Sr=null,Cr=null,wa=null,Ea=null,Aa=null;function bo(t,e,s){Nc(),Sr=t,Cr=e??null,wa=s??null;const n=Fi(),a=n?`${ra}/api/events?token=${encodeURIComponent(n)}`:`${ra}/api/events`;es=new EventSource(a),Ea=i=>{wa?.("connected");try{const r=JSON.parse(i.data);Sr?.(r)}catch{}},Aa=i=>{try{const r=JSON.parse(i.data);Cr?.(r)}catch{}},es.addEventListener("status",Ea),es.addEventListener("invalidate",Aa),es.onerror=()=>{wa?.("disconnected")},es.onopen=()=>{wa?.("connected")}}function Nc(){es&&(Ea&&(es.removeEventListener("status",Ea),Ea=null),Aa&&(es.removeEventListener("invalidate",Aa),Aa=null),es.onerror=null,es.onopen=null,es.close(),es=null),Sr=null,Cr=null,wa=null}function gh(){return es!==null&&es.readyState===EventSource.OPEN}const Er=new Set;function Mi(t){return Er.add(t),()=>Er.delete(t)}function mo(t){for(const e of Er)e(t)}var xh=F('<div class="drawer-backdrop svelte-181dlmc" role="presentation"></div>'),bh=F('<a><svg class="nav-icon svelte-181dlmc" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><!></svg> <span class="nav-label svelte-181dlmc"> </span></a>'),mh=kn('<path d="m9 18 6-6-6-6"></path>'),wh=kn('<path d="m15 18-6-6 6-6"></path>'),yh=F('<!> <nav><div class="sidebar-brand svelte-181dlmc"><img src="/logo.svg" alt="BrowserBird" class="brand-logo brand-logo-full svelte-181dlmc"/> <img src="/logo-icon.svg" alt="BrowserBird" class="brand-logo brand-logo-icon svelte-181dlmc"/></div> <div class="sidebar-nav svelte-181dlmc"><!> <button class="nav-item signout-item svelte-181dlmc"><svg class="nav-icon svelte-181dlmc" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><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></svg> <span class="nav-label svelte-181dlmc">Sign out</span></button></div> <div class="sidebar-footer svelte-181dlmc"><button class="toggle-btn svelte-181dlmc"><svg class="toggle-icon svelte-181dlmc" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><!></svg></button></div></nav>',1);function kh(t,e){st(e,!0);const s=[{page:"status",label:"Mission Control",svg:'<rect width="7" height="9" x="3" y="3" rx="1"/><rect width="7" height="5" x="14" y="3" rx="1"/><rect width="7" height="9" x="14" y="12" rx="1"/><rect width="7" height="5" x="3" y="16" rx="1"/>'},{page:"sessions",label:"Sessions",svg:'<path d="M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"/><path d="M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1"/>'},{page:"birds",label:"Birds",svg:'<path d="M16 7h.01"/><path d="M3.4 18H12a8 8 0 0 0 8-8V7a4 4 0 0 0-7.28-2.3L2 20"/><path d="m20 7 2 .5-2 .5"/><path d="M10 18v3"/><path d="M14 17.75V21"/><path d="M7 18a6 6 0 0 0 3.84-10.61"/>'},{page:"computer",label:"Computer",svg:'<rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/>'},{page:"settings",label:"Settings",svg:'<path d="M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"/><circle cx="12" cy="12" r="3"/>'}];function n(){e.onmobileclose()}var a=yh(),i=me(a);{var r=C=>{var K=xh();G("click",K,function(...E){e.onmobileclose?.apply(this,E)}),k(C,K)};O(i,C=>{e.mobileOpen&&C(r)})}var o=f(i,2);let d;var l=f(h(o),2),u=h(l);Mt(u,17,()=>s,Pc,(C,K)=>{var E=bh();let U;var te=h(E),T=h(te);ju(T,()=>c(K).svg,!0);var A=f(te,2),X=h(A);V(()=>{U=pe(E,1,"nav-item svelte-181dlmc",null,U,{active:e.currentPage===c(K).page}),jt(E,"href",`#/${(c(K).page==="status"?"":c(K).page)??""}`),jt(E,"title",e.collapsed?c(K).label:void 0),M(X,c(K).label)}),G("click",E,n),k(C,E)});var _=f(u,2),p=f(l,2),v=h(p),x=h(v),y=h(x);{var w=C=>{var K=mh();k(C,K)},S=C=>{var K=wh();k(C,K)};O(y,C=>{e.collapsed?C(w):C(S,!1)})}V(()=>{d=pe(o,1,"sidebar svelte-181dlmc",null,d,{collapsed:e.collapsed,"mobile-open":e.mobileOpen}),jt(_,"title",e.collapsed?"Sign out":void 0),jt(v,"title",e.collapsed?"Expand sidebar":"Collapse sidebar")}),G("click",_,function(...C){e.onsignout?.apply(this,C)}),G("click",v,function(...C){e.ontoggle?.apply(this,C)}),k(t,a),nt()}_t(["click"]);var Sh=F('<div><span></span> <span class="svc-row-label svelte-nma0bt"> </span> <span class="svc-row-detail mono svelte-nma0bt"> </span></div>'),Ch=F('<div class="svc-popover svelte-nma0bt"></div>'),Eh=F('<div class="svc-status svelte-nma0bt"><button class="svc-btn svelte-nma0bt" title="Service status"><span></span></button> <!></div>');function Ah(t,e){st(e,!0);let s=W(!1);const n=Ae(()=>e.status?[{label:"Agent CLI",ok:e.status.agent.available,detail:e.status.agent.available?"ready":"not found",applicable:!0},{label:"Slack",ok:e.status.slack.connected,detail:e.status.slack.connected?"connected":"disconnected",applicable:!0},{label:"Browser",ok:e.status.browser.connected,detail:e.status.browser.connected?"connected":"unreachable",applicable:e.status.browser.enabled}]:[]),a=Ae(()=>c(n).filter(w=>w.applicable)),i=Ae(()=>c(a).length>0&&c(a).every(w=>w.ok)),r=Ae(()=>c(a).length===0||c(a).every(w=>!w.ok)),o=Ae(()=>c(i)?"ok":c(r)?"err":"warn");function d(){b(s,!c(s))}function l(w){w.target.closest(".svc-status")||b(s,!1)}xt(()=>{if(c(s))return document.addEventListener("click",l,!0),()=>document.removeEventListener("click",l,!0)});var u=Eh(),_=h(u),p=h(_);let v;var x=f(_,2);{var y=w=>{var S=Ch();Mt(S,21,()=>c(n),C=>C.label,(C,K)=>{var E=Sh();let U;var te=h(E);let T;var A=f(te,2),X=h(A),L=f(A,2),se=h(L);V(()=>{U=pe(E,1,"svc-row svelte-nma0bt",null,U,{"svc-row-disabled":!c(K).applicable}),T=pe(te,1,"svc-row-dot svelte-nma0bt",null,T,{"svc-ok":c(K).applicable&&c(K).ok,"svc-err":c(K).applicable&&!c(K).ok,"svc-off":!c(K).applicable}),M(X,c(K).label),M(se,c(K).applicable?c(K).detail:"disabled")}),k(C,E)}),k(w,S)};O(x,w=>{c(s)&&w(y)})}V(()=>v=pe(p,1,"svc-dot svelte-nma0bt",null,v,{"svc-ok":c(o)==="ok","svc-warn":c(o)==="warn","svc-err":c(o)==="err"})),G("click",_,d),k(t,u),nt()}_t(["click"]);ru();let Kh=0;const Ar=new Map;let vi=Ne([]);function Me(t,e="info"){const s=Kh++;vi.push({id:s,message:t,type:e}),Ar.set(s,setTimeout(()=>Uc(s),4e3))}function Uc(t){const e=Ar.get(t);e!=null&&(clearTimeout(e),Ar.delete(t));const s=vi.findIndex(n=>n.id===t);s!==-1&&vi.splice(s,1)}var Fh=F('<div><span class="toast-message svelte-1ig2a9j"> </span> <button class="toast-close svelte-1ig2a9j" aria-label="Dismiss">×</button></div>'),Th=F('<div class="toast-container svelte-1ig2a9j"></div>');function Mh(t,e){st(e,!1),Ic();var s=Th();Mt(s,5,()=>vi,n=>n.id,(n,a)=>{var i=Fh(),r=h(i),o=h(r),d=f(r,2);V(()=>{pe(i,1,`toast toast-${c(a).type??""}`,"svelte-1ig2a9j"),M(o,c(a).message)}),G("click",d,()=>Uc(c(a).id)),k(n,i)}),k(t,s),nt()}_t(["click"]);const gn=Ne({pending:null});function Or(t){return new Promise(e=>{gn.pending={message:t,resolve:e}})}function ua(t){if(gn.pending==null)return;const{resolve:e}=gn.pending;gn.pending=null,e(t)}var Xh=F('<div class="overlay svelte-1efofyg"><button class="backdrop svelte-1efofyg" type="button" aria-label="Close dialog"></button> <div class="dialog svelte-1efofyg" role="alertdialog" aria-modal="true"><p class="message svelte-1efofyg"> </p> <div class="actions svelte-1efofyg"><button class="btn btn-outline btn-sm">Cancel</button> <button class="btn btn-danger btn-sm">Confirm</button></div></div></div>');function Lh(t,e){st(e,!1);function s(r){gn.pending&&(r.key==="Escape"&&ua(!1),r.key==="Enter"&&ua(!0))}Ic();var n=yt();Rn("keydown",_i,s);var a=me(n);{var i=r=>{var o=Xh(),d=h(o),l=f(d,2),u=h(l),_=h(u),p=f(u,2),v=h(p),x=f(v,2);V(()=>M(_,gn.pending.message)),G("click",d,()=>ua(!1)),G("click",v,()=>ua(!1)),G("click",x,()=>ua(!0)),k(r,o)};O(a,r=>{gn.pending&&r(i)})}k(t,n),nt()}_t(["click"]);function Tt(t){const e=t.indexOf("_");return e===-1?t.slice(0,10):t.slice(0,e+1+7)}function Ph(t){const e=Math.floor(t/6e4),s=Math.floor(e/1440),n=Math.floor(e%1440/60),a=e%60;return s>0?`${s}d ${n}h`:n>0?`${n}h ${a}m`:`${a}m`}function fs(t){const e=Date.now()-new Date(t+"Z").getTime(),s=Math.floor(e/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;const n=Math.floor(s/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}function wn(){return new Date().toLocaleTimeString()}function Bh(t){const e=new Date(t).getTime()-Date.now();if(e<=0)return"now";const s=Math.floor(e/6e4);if(s<60)return`${s}m`;const n=Math.floor(s/60),a=s%60;return n<24?a>0?`${n}h ${a}m`:`${n}h`:`${Math.floor(n/24)}d ${n%24}h`}function pi(t,e){if(!e)return"-";const s=new Date(e).getTime()-new Date(t).getTime();if(s<0)return"-";const n=Math.round(s/1e3);return n>=60?`${Math.floor(n/60)}m ${n%60}s`:`${n}s`}var Dh=F('<input type="search" class="search-input svelte-b78yyc"/>'),Rh=F('<div class="table-toolbar svelte-b78yyc"><!> <!></div>'),Ih=kn('<svg class="sort-icon svelte-b78yyc" viewBox="0 0 10 6" fill="none" aria-hidden="true"><path d="M1 5L5 1L9 5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>'),Qh=kn('<svg class="sort-icon svelte-b78yyc" viewBox="0 0 10 6" fill="none" aria-hidden="true"><path d="M1 1L5 5L9 1" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg>'),Nh=F('<button class="sort-btn svelte-b78yyc"> <!></button>'),Uh=F("<th><!></th>"),Hh=F('<tr><td class="empty-state svelte-b78yyc"> </td></tr>'),zh=F('<div class="pagination svelte-b78yyc"><button class="pg-btn svelte-b78yyc"><svg class="pg-icon svelte-b78yyc" viewBox="0 0 6 10" fill="none" aria-hidden="true"><path d="M5 1L1 5L5 9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg> Prev</button> <span class="pg-info svelte-b78yyc"> </span> <button class="pg-btn svelte-b78yyc">Next <svg class="pg-icon svelte-b78yyc" viewBox="0 0 6 10" fill="none" aria-hidden="true"><path d="M1 1L5 5L1 9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg></button></div>'),Oh=F('<!> <div><div class="table-scroll svelte-b78yyc"><table class="table svelte-b78yyc"><thead><tr></tr></thead><tbody><!></tbody></table></div> <!></div>',1);function dn(t,e){st(e,!0);let s=Wn(e,"emptyMessage",3,"No data"),n=Wn(e,"searchPlaceholder",3,"Search...");const a=Ae(()=>e.page!=null&&e.totalPages!=null&&e.onPageChange!=null);function i(T){return e.sort?e.sort===`-${T}`?"desc":e.sort===T?"asc":null:null}let r;function o(T){const A=T.target.value;clearTimeout(r),r=setTimeout(()=>e.onSearchChange?.(A),300)}var d=Oh(),l=me(d);{var u=T=>{var A=Rh(),X=h(A);{var L=de=>{var $=yt(),H=me($);uo(H,()=>e.toolbar),k(de,$)};O(X,de=>{e.toolbar&&de(L)})}var se=f(X,2);{var oe=de=>{var $=Dh();V(()=>{jt($,"placeholder",n()),Dc($,e.search??"")}),G("input",$,o),k(de,$)};O(se,de=>{e.onSearchChange&&de(oe)})}k(T,A)};O(l,T=>{(e.toolbar||e.onSearchChange)&&T(u)})}var _=f(l,2);let p;var v=h(_),x=h(v),y=h(x),w=h(y);Mt(w,21,()=>e.columns,T=>T.key,(T,A)=>{var X=Uh(),L=h(X);{var se=de=>{const $=Ae(()=>i(c(A).key));var H=Nh(),ne=h(H),ae=f(ne);{var xe=he=>{var Fe=Ih();k(he,Fe)},ge=he=>{var Fe=Qh();k(he,Fe)};O(ae,he=>{c($)==="asc"?he(xe):c($)==="desc"&&he(ge,1)})}V(()=>M(ne,`${c(A).label??""} `)),G("click",H,()=>e.onSortChange(c(A).key)),k(de,H)},oe=de=>{var $=Ss();V(()=>M($,c(A).label)),k(de,$)};O(L,de=>{c(A).sortable&&e.onSortChange?de(se):de(oe,!1)})}V(()=>pe(X,1,Zu(c(A).class??""),"svelte-b78yyc")),k(T,X)});var S=f(y),C=h(S);{var K=T=>{var A=Hh(),X=h(A),L=h(X);V(()=>{jt(X,"colspan",e.columns.length),M(L,s())}),k(T,A)},E=T=>{var A=yt(),X=me(A);uo(X,()=>e.children),k(T,A)};O(C,T=>{e.isEmpty?T(K):T(E,!1)})}var U=f(v,2);{var te=T=>{var A=zh(),X=h(A),L=f(X,2),se=h(L),oe=f(L,2);V(()=>{X.disabled=e.page===1,M(se,`Page ${e.page??""} of ${e.totalPages??""}${e.totalItems!=null?` | ${e.totalItems} total`:""}`),oe.disabled=e.page===e.totalPages}),G("click",X,()=>e.onPageChange(e.page-1)),G("click",oe,()=>e.onPageChange(e.page+1)),k(T,A)};O(U,T=>{c(a)&&e.totalPages>1&&T(te)})}V(()=>p=pe(_,1,"table-card svelte-b78yyc",null,p,{"table-fetching":e.fetching})),k(t,d),nt()}_t(["input","click"]);var Vh=F("<span> </span>");function xn(t,e){const s={pending:"badge-warning",running:"badge-accent",completed:"badge-success",failed:"badge-error",success:"badge-success",error:"badge-error",triggered:"badge-accent",debug:"badge-muted",info:"badge-accent",warn:"badge-warning"},n=Ae(()=>s[e.status]??"badge-muted");var a=Vh(),i=h(a);V(()=>{pe(a,1,`badge ${c(n)??""}`,"svelte-1fmrh5r"),M(i,e.status)}),k(t,a)}var Gh=F('<div class="loading">Loading...</div>'),qh=F('<div><span></span> <span class="svc-label svelte-ybr8ix">Browser</span> <span class="svc-detail mono svelte-ybr8ix"> </span></div>'),Wh=F('<tr><td class="mono"> </td><td><a class="bird-link svelte-ybr8ix"> </a></td><td class="mono failure-count svelte-ybr8ix"> </td><td><!></td><td> </td><td><button class="btn btn-outline btn-sm">Retry</button></td></tr>'),jh=F('<div class="section svelte-ybr8ix"><div class="section-header svelte-ybr8ix"><h2 class="section-title section-title-error svelte-ybr8ix">Failing Birds</h2> <span class="last-updated svelte-ybr8ix"> </span></div> <!></div>'),Yh=F('<tr class="clickable-row svelte-ybr8ix"><td class="mono"> </td><td> </td><td><!></td><td class="mono"> </td><td> </td></tr>'),Zh=F('<div class="section svelte-ybr8ix"><div class="section-header svelte-ybr8ix"><h2 class="section-title section-title-active svelte-ybr8ix">Active Flights</h2></div> <!></div>'),Jh=F('<tr class="clickable-row svelte-ybr8ix"><td class="mono"> </td><td> </td><td class="mono"> </td><td class="mono countdown svelte-ybr8ix"> </td></tr>'),$h=F('<div class="section svelte-ybr8ix"><div class="section-header svelte-ybr8ix"><h2 class="section-title svelte-ybr8ix">Next Up</h2></div> <!></div>'),e0=F('<tr class="clickable-row svelte-ybr8ix"><td class="mono"> </td><td> </td><td><!></td><td class="mono"> </td><td> </td></tr>'),t0=F('<tr class="clickable-row svelte-ybr8ix"><td class="mono"> </td><td class="mono"> </td><td> </td><td> </td><td> </td></tr>'),s0=F('<div class="svc-row svelte-ybr8ix"><div><span></span> <span class="svc-label svelte-ybr8ix">Agent CLI</span> <span class="svc-detail mono svelte-ybr8ix"> </span></div> <div><span></span> <span class="svc-label svelte-ybr8ix">Slack</span> <span class="svc-detail mono svelte-ybr8ix"> </span></div> <!></div> <div class="num-grid svelte-ybr8ix"><div class="num-card num-card-accent svelte-ybr8ix"><div class="num-head svelte-ybr8ix"><span class="num-label svelte-ybr8ix">Flights</span> <span class="num-badge mono svelte-ybr8ix"> </span></div> <div class="num-value svelte-ybr8ix"> </div> <div class="num-sub svelte-ybr8ix"><span> </span> <span class="num-sep svelte-ybr8ix"></span> <span> </span></div></div> <div class="num-card num-card-neutral svelte-ybr8ix"><div class="num-head svelte-ybr8ix"><span class="num-label svelte-ybr8ix">Messages</span></div> <div class="num-value svelte-ybr8ix"> </div> <div class="num-sub svelte-ybr8ix"><span> </span></div></div> <div class="num-card num-card-warm svelte-ybr8ix"><div class="num-head svelte-ybr8ix"><span class="num-label svelte-ybr8ix">Tokens</span></div> <div class="num-value svelte-ybr8ix"> </div> <div class="num-sub svelte-ybr8ix"><span> </span> <span class="num-sep svelte-ybr8ix"></span> <span> </span></div></div></div> <!> <!> <!> <div class="section svelte-ybr8ix"><div class="section-header svelte-ybr8ix"><h2 class="section-title svelte-ybr8ix">Recent Flights</h2> <a href="#/birds" class="section-link svelte-ybr8ix">View all</a></div> <!></div> <div class="section svelte-ybr8ix"><div class="section-header svelte-ybr8ix"><h2 class="section-title svelte-ybr8ix">Recent Sessions</h2> <a href="#/sessions" class="section-link svelte-ybr8ix">View all</a></div> <!></div>',1);function n0(t,e){st(e,!0);let s=W(Ne([])),n=W(Ne([])),a=W(Ne([])),i=W(Ne([])),r=W(Ne([])),o=W(Ne(wn())),d=W(!0);const l=[{key:"uid",label:"ID"},{key:"name",label:"Bird"},{key:"failure_count",label:"Failures"},{key:"last_status",label:"Status"},{key:"last_run",label:"Last Run"},{key:"actions",label:""}],u=[{key:"uid",label:"ID"},{key:"name",label:"Bird"},{key:"schedule",label:"Schedule"},{key:"next_run",label:"Next Run"}],_=[{key:"uid",label:"ID"},{key:"bird_name",label:"Bird"},{key:"status",label:"Status"},{key:"duration",label:"Duration"},{key:"started_at",label:"Started"}],p=[{key:"uid",label:"ID"},{key:"channel_id",label:"Channel"},{key:"agent_id",label:"Agent"},{key:"message_count",label:"Messages"},{key:"last_active",label:"Last Active"}];async function v(T){try{const[A,X,L,se,oe]=await Promise.all([ke("/api/birds?perPage=100"),ke("/api/birds/upcoming?limit=5"),ke("/api/flights?status=running&perPage=5"),ke("/api/flights?perPage=5"),ke("/api/sessions?perPage=5")]);if(T.aborted)return;b(s,A.items.filter(de=>de.failure_count>0),!0),c(s).sort((de,$)=>$.failure_count-de.failure_count),b(n,X,!0),b(a,L.items,!0),b(i,se.items,!0),b(r,oe.items,!0),b(o,wn(),!0)}catch{}finally{T.aborted||b(d,!1)}}xt(()=>{const T=new AbortController;v(T.signal);const A=Mi(X=>{(X.resource==="sessions"||X.resource==="birds")&&v(T.signal)});return()=>{T.abort(),A()}});async function x(T){try{await ke(`/api/birds/${T}/fly`,{method:"POST"}),Me(`Bird ${Tt(T)} sent on a flight`,"success")}catch(A){Me(`Failed: ${A.message}`,"error")}}const y=Ae(()=>e.status?.slack.connected??!1),w=Ae(()=>e.status?.agent.available??!1),S=Ae(()=>e.status?.browser.enabled??!1),C=Ae(()=>e.status?.browser.connected??!1);var K=yt(),E=me(K);{var U=T=>{var A=Gh();k(T,A)},te=T=>{var A=s0(),X=me(A),L=h(X);let se;var oe=h(L);let de;var $=f(oe,4),H=h($),ne=f(L,2);let ae;var xe=h(ne);let ge;var he=f(xe,4),Fe=h(he),Be=f(ne,2);{var Xe=Ve=>{var Ze=qh();let ct;var dt=h(Ze);let Kt;var ut=f(dt,4),Je=h(ut);V(()=>{ct=pe(Ze,1,"svc-card svelte-ybr8ix",null,ct,{"svc-ok":c(C),"svc-err":!c(C)}),Kt=pe(dt,1,"svc-dot svelte-ybr8ix",null,Kt,{"dot-ok":c(C),"dot-err":!c(C)}),M(Je,c(C)?"connected":"unreachable")}),k(Ve,Ze)};O(Be,Ve=>{c(S)&&Ve(Xe)})}var q=f(X,2),re=h(q),fe=h(re),we=f(h(fe),2),le=h(we),_e=f(fe,2),Z=h(_e),be=f(_e,2),z=h(be),J=h(z),ue=f(z,4),Se=h(ue),Ie=f(re,2),et=f(h(Ie),2),je=h(et),bt=f(et,2),tt=h(bt),Ye=h(tt),mt=f(Ie,2),ye=f(h(mt),2),Oe=h(ye),lt=f(ye,2),ls=h(lt),ss=h(ls),gs=f(ls,4),Ts=h(gs),Ct=f(q,2);{var xs=Ve=>{var Ze=jh(),ct=h(Ze),dt=f(h(ct),2),Kt=h(dt),ut=f(ct,2);dn(ut,{get columns(){return l},isEmpty:!1,children:(Je,ht)=>{var Ge=yt(),Y=me(Ge);Mt(Y,17,()=>c(s),ie=>ie.uid,(ie,ve)=>{var Ke=Wh(),Qe=h(Ke),qe=h(Qe),ft=f(Qe),wt=h(ft),Pt=h(wt),Bt=f(ft),Nt=h(Bt),Ps=f(Bt),Te=h(Ps);{var $e=Bs=>{xn(Bs,{get status(){return c(ve).last_status}})},at=Bs=>{var ca=Ss("-");k(Bs,ca)};O(Te,Bs=>{c(ve).last_status?Bs($e):Bs(at,!1)})}var Ut=f(Ps),qt=h(Ut),Sn=f(Ut),Vs=h(Sn);V((Bs,ca,Di)=>{M(qe,Bs),jt(wt,"href",`#/birds?search=${ca??""}`),M(Pt,c(ve).name),M(Nt,c(ve).failure_count),M(qt,Di)},[()=>Tt(c(ve).uid),()=>encodeURIComponent(Tt(c(ve).uid)),()=>c(ve).last_run?fs(c(ve).last_run):"-"]),G("click",Vs,()=>x(c(ve).uid)),k(ie,Ke)}),k(Je,Ge)},$$slots:{default:!0}}),V(()=>M(Kt,`Updated ${c(o)??""}`)),k(Ve,Ze)};O(Ct,Ve=>{c(s).length>0&&Ve(xs)})}var Hs=f(Ct,2);{var Ms=Ve=>{var Ze=Zh(),ct=f(h(Ze),2);dn(ct,{get columns(){return _},isEmpty:!1,children:(dt,Kt)=>{var ut=yt(),Je=me(ut);Mt(Je,17,()=>c(a),ht=>ht.uid,(ht,Ge)=>{var Y=Yh(),ie=h(Y),ve=h(ie),Ke=f(ie),Qe=h(Ke),qe=f(Ke),ft=h(qe);xn(ft,{get status(){return c(Ge).status}});var wt=f(qe),Pt=h(wt),Bt=f(wt),Nt=h(Bt);V((Ps,Te,$e)=>{M(ve,Ps),M(Qe,c(Ge).bird_name),M(Pt,Te),M(Nt,$e)},[()=>Tt(c(Ge).uid),()=>pi(c(Ge).started_at,c(Ge).finished_at),()=>fs(c(Ge).started_at)]),G("click",Y,()=>{window.location.hash=`#/birds?expand=${c(Ge).bird_uid}`}),k(ht,Y)}),k(dt,ut)},$$slots:{default:!0}}),k(Ve,Ze)};O(Hs,Ve=>{c(a).length>0&&Ve(Ms)})}var Xs=f(Hs,2);{var Ls=Ve=>{var Ze=$h(),ct=f(h(Ze),2);dn(ct,{get columns(){return u},isEmpty:!1,children:(dt,Kt)=>{var ut=yt(),Je=me(ut);Mt(Je,17,()=>c(n),ht=>ht.uid,(ht,Ge)=>{var Y=Jh(),ie=h(Y),ve=h(ie),Ke=f(ie),Qe=h(Ke),qe=f(Ke),ft=h(qe),wt=f(qe),Pt=h(wt);V((Bt,Nt)=>{M(ve,Bt),M(Qe,c(Ge).name),M(ft,c(Ge).schedule),M(Pt,Nt)},[()=>Tt(c(Ge).uid),()=>Bh(c(Ge).next_run)]),G("click",Y,()=>{window.location.hash=`#/birds?search=${encodeURIComponent(Tt(c(Ge).uid))}`}),k(ht,Y)}),k(dt,ut)},$$slots:{default:!0}}),k(Ve,Ze)};O(Xs,Ve=>{c(n).length>0&&Ve(Ls)})}var bs=f(Xs,2),zs=f(h(bs),2);{let Ve=Ae(()=>c(i).length===0);dn(zs,{get columns(){return _},get isEmpty(){return c(Ve)},emptyMessage:"No flights recorded",children:(Ze,ct)=>{var dt=yt(),Kt=me(dt);Mt(Kt,17,()=>c(i),ut=>ut.uid,(ut,Je)=>{var ht=e0(),Ge=h(ht),Y=h(Ge),ie=f(Ge),ve=h(ie),Ke=f(ie),Qe=h(Ke);xn(Qe,{get status(){return c(Je).status}});var qe=f(Ke),ft=h(qe),wt=f(qe),Pt=h(wt);V((Bt,Nt,Ps)=>{M(Y,Bt),M(ve,c(Je).bird_name),M(ft,Nt),M(Pt,Ps)},[()=>Tt(c(Je).uid),()=>pi(c(Je).started_at,c(Je).finished_at),()=>fs(c(Je).started_at)]),G("click",ht,()=>{window.location.hash=`#/birds?expand=${c(Je).bird_uid}`}),k(ut,ht)}),k(Ze,dt)},$$slots:{default:!0}})}var Os=f(bs,2),an=f(h(Os),2);{let Ve=Ae(()=>c(r).length===0);dn(an,{get columns(){return p},get isEmpty(){return c(Ve)},emptyMessage:"No active sessions",children:(Ze,ct)=>{var dt=yt(),Kt=me(dt);Mt(Kt,17,()=>c(r),ut=>ut.uid,(ut,Je)=>{var ht=t0(),Ge=h(ht),Y=h(Ge),ie=f(Ge),ve=h(ie),Ke=f(ie),Qe=h(Ke),qe=f(Ke),ft=h(qe),wt=f(qe),Pt=h(wt);V((Bt,Nt)=>{M(Y,Bt),M(ve,c(Je).channel_id),M(Qe,c(Je).agent_id),M(ft,c(Je).message_count),M(Pt,Nt)},[()=>Tt(c(Je).uid),()=>fs(c(Je).last_active)]),G("click",ht,()=>{window.location.hash=`#/session-detail?id=${c(Je).uid}`}),k(ut,ht)}),k(Ze,dt)},$$slots:{default:!0}})}V((Ve,Ze,ct)=>{se=pe(L,1,"svc-card svelte-ybr8ix",null,se,{"svc-ok":c(w),"svc-err":!c(w)}),de=pe(oe,1,"svc-dot svelte-ybr8ix",null,de,{"dot-ok":c(w),"dot-err":!c(w)}),M(H,c(w)?"ready":"unavailable"),ae=pe(ne,1,"svc-card svelte-ybr8ix",null,ae,{"svc-ok":c(y),"svc-err":!c(y)}),ge=pe(xe,1,"svc-dot svelte-ybr8ix",null,ge,{"dot-ok":c(y),"dot-err":!c(y)}),M(Fe,c(y)?"connected":"disconnected"),M(le,`${e.status.processes.active??""}/${e.status.processes.maxConcurrent??""} processes`),M(Z,e.status.flights.running),M(J,`${e.status.flights.completed??""} done`),M(Se,`${e.status.flights.failed??""} failed`),M(je,e.status.messages.totalMessages),M(Ye,`${e.status.sessions.total??""} ${e.status.sessions.total===1?"session":"sessions"}`),M(Oe,Ve),M(ss,`${Ze??""} in`),M(Ts,`${ct??""} out`)},[()=>(e.status.messages.totalTokensIn+e.status.messages.totalTokensOut).toLocaleString(),()=>e.status.messages.totalTokensIn.toLocaleString(),()=>e.status.messages.totalTokensOut.toLocaleString()]),k(T,A)};O(E,T=>{e.status?T(te,!1):T(U)})}k(t,K),nt()}_t(["click"]);function a0(t){const e=Ti();return{page:Math.max(Number(e.get("page"))||1,1),sort:e.get("sort")??t,search:e.get("search")??""}}function i0(t,e,s,n){const a=window.location.hash,i=a.indexOf("?"),r=i===-1?a:a.slice(0,i),o=new URLSearchParams(i===-1?"":a.slice(i+1));t>1?o.set("page",String(t)):o.delete("page"),e&&e!==n?o.set("sort",e):o.delete("sort"),s?o.set("search",s):o.delete("search");const d=o.toString(),l=d?`${r}?${d}`:r;l!==a&&history.replaceState(null,"",l)}function Vr(t){const e=t.defaultSort??"",s=a0(e);let n=W(Ne([])),a=W(Ne(s.page)),i=W(1),r=W(0),o=W(Ne(t.defaultPerPage??15)),d=W(!0),l=W(!1),u=!1,_=W(Ne(s.sort)),p=W(Ne(s.search));xt(()=>{i0(c(a),c(_),c(p),e)}),xt(()=>{const w=c(a),S=c(_),C=c(p),K=c(o);t.watchExtras?.();const E=new AbortController,U=async()=>{const T=new URLSearchParams;T.set("page",String(w)),T.set("perPage",String(K)),S&&S!==e&&T.set("sort",S),C&&T.set("search",C);const A=t.buildParams?.();if(A)for(const[L,se]of Object.entries(A))se&&T.set(L,se);const X=t.endpoint.includes("?")?"&":"?";try{const L=await ke(`${t.endpoint}${X}${T.toString()}`);if(E.signal.aborted)return;t.onResponse?.(L);const se=t.transformResponse?t.transformResponse(L):L;b(n,se.items,!0),b(i,se.totalPages,!0),b(r,se.totalItems,!0),b(o,se.perPage,!0)}catch{}finally{E.signal.aborted||(b(d,!1),b(l,!1),u=!0)}};u||b(d,!0),b(l,!0),U();const te=t.invalidateOn?Mi(T=>{T.resource===t.invalidateOn&&U()}):()=>{};return()=>{E.abort(),te()}});function v(w){b(a,w,!0)}function x(w){c(_)===w?b(_,`-${w}`):c(_)===`-${w}`?b(_,w,!0):b(_,`-${w}`),b(a,1)}function y(w){b(p,w,!0),b(a,1)}return{get items(){return c(n)},get page(){return c(a)},get totalPages(){return c(i)},get totalItems(){return c(r)},get perPage(){return c(o)},get loading(){return c(d)},get fetching(){return c(l)},get sort(){return c(_)},get search(){return c(p)},setPage:v,setSort:x,setSearch:y}}var r0=F('<div class="loading">Loading...</div>'),o0=F('<div class="filter-spacer svelte-15gdqrj"></div> <span class="last-updated svelte-15gdqrj"> </span>',1),l0=F('<tr class="clickable-row svelte-15gdqrj"><td class="mono"> </td><td class="mono"> </td><td class="mono"> </td><td> </td><td> </td><td> </td></tr>');function c0(t,e){st(e,!0);const s=[{key:"uid",label:"ID",sortable:!0},{key:"channel_id",label:"Channel",sortable:!0},{key:"thread_id",label:"Thread"},{key:"agent_id",label:"Agent",sortable:!0},{key:"message_count",label:"Messages",sortable:!0},{key:"last_active",label:"Last Active",sortable:!0}];let n=W(Ne(wn()));const a=Vr({endpoint:"/api/sessions",columns:s,defaultSort:"-last_active",invalidateOn:"sessions",onResponse:()=>{b(n,wn(),!0)}});var i=yt(),r=me(i);{var o=l=>{var u=r0();k(l,u)},d=l=>{{const u=p=>{var v=o0(),x=f(me(v),2),y=h(x);V(()=>M(y,`Updated ${c(n)??""}`)),k(p,v)};let _=Ae(()=>a.items.length===0);dn(l,{get columns(){return s},get isEmpty(){return c(_)},emptyMessage:"No active sessions",get fetching(){return a.fetching},get page(){return a.page},get totalPages(){return a.totalPages},get totalItems(){return a.totalItems},get sort(){return a.sort},get search(){return a.search},searchPlaceholder:"Search sessions...",get onPageChange(){return a.setPage},get onSortChange(){return a.setSort},get onSearchChange(){return a.setSearch},toolbar:u,children:(p,v)=>{var x=yt(),y=me(x);Mt(y,17,()=>a.items,w=>w.uid,(w,S)=>{var C=l0(),K=h(C),E=h(K),U=f(K),te=h(U),T=f(U),A=h(T),X=f(T),L=h(X),se=f(X),oe=h(se),de=f(se),$=h(de);V((H,ne)=>{M(E,H),M(te,c(S).channel_id),M(A,c(S).thread_id??"-"),M(L,c(S).agent_id),M(oe,c(S).message_count),M($,ne)},[()=>Tt(c(S).uid),()=>fs(c(S).last_active)]),G("click",C,()=>{window.location.hash=`#/session-detail?id=${c(S).uid}`}),k(w,C)}),k(p,x)},$$slots:{toolbar:!0,default:!0}})}};O(r,l=>{a.loading?l(o):l(d,!1)})}k(t,i),nt()}_t(["click"]);var d0=F('<div role="switch" tabindex="0"></div>');function Xn(t,e){st(e,!0);var s=d0();let n;V(()=>{n=pe(s,1,"toggle svelte-aw96os",null,n,{active:e.active}),jt(s,"aria-checked",e.active)}),G("click",s,function(...a){e.onToggle?.apply(this,a)}),G("keydown",s,a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),e.onToggle())}),k(t,s),nt()}_t(["click","keydown"]);var u0=F("<textarea></textarea>"),h0=F('<input type="text"/>'),f0=kn('<svg viewBox="0 0 16 16" fill="none" aria-hidden="true" class="svelte-1npf1z3"><path d="M3 8.5l3.5 3.5L13 4.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>'),_0=F('<div><!> <div class="inline-actions svelte-1npf1z3"><button class="inline-btn inline-btn-save svelte-1npf1z3" title="Save"><!></button> <button class="inline-btn inline-btn-cancel svelte-1npf1z3" title="Cancel"><svg viewBox="0 0 16 16" fill="none" aria-hidden="true" class="svelte-1npf1z3"><path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg></button></div></div>');function gt(t,e){st(e,!0);let s=Wn(e,"value",15,""),n=Wn(e,"mono",3,!1),a=Wn(e,"multiline",3,!1),i=Wn(e,"saving",3,!1);function r(C){C.key==="Escape"?e.oncancel():C.key==="Enter"&&(a()?C.metaKey:!C.shiftKey)&&(C.preventDefault(),e.onsave(s()))}var o=_0();let d;var l=h(o);{var u=C=>{var K=u0();let E;V(()=>{E=pe(K,1,"inline-input inline-textarea svelte-1npf1z3",null,E,{mono:n()}),jt(K,"placeholder",e.placeholder)}),G("keydown",K,r),He(K,s),k(C,K)},_=C=>{var K=h0();let E;V(()=>{E=pe(K,1,"inline-input svelte-1npf1z3",null,E,{mono:n()}),jt(K,"placeholder",e.placeholder)}),G("keydown",K,r),He(K,s),k(C,K)};O(l,C=>{a()?C(u):C(_,!1)})}var p=f(l,2),v=h(p),x=h(v);{var y=C=>{var K=Ss("...");k(C,K)},w=C=>{var K=f0();k(C,K)};O(x,C=>{i()?C(y):C(w,!1)})}var S=f(v,2);V(()=>{d=pe(o,1,"inline-edit svelte-1npf1z3",null,d,{"inline-edit-multiline":a()}),v.disabled=i()}),G("click",v,()=>e.onsave(s())),G("click",S,function(...C){e.oncancel?.apply(this,C)}),k(t,o),nt()}_t(["keydown","click"]);var v0=F('<div class="flight-summary svelte-1jo1oiw"> </div>'),p0=F('<p class="detail-label error-label svelte-1jo1oiw">Error</p> <pre class="detail-pre error-pre svelte-1jo1oiw"> </pre>',1),g0=F('<p class="detail-label svelte-1jo1oiw">Result</p> <pre class="detail-pre svelte-1jo1oiw"> </pre>',1),x0=F('<button class="btn btn-outline btn-sm retry-btn svelte-1jo1oiw">Retry</button>'),b0=F('<div class="flight-detail svelte-1jo1oiw"><!> <!> <!></div>'),m0=F('<div role="button" tabindex="0"><div class="flight-top svelte-1jo1oiw"><span></span> <span class="flight-duration mono svelte-1jo1oiw"> </span> <span class="flight-age svelte-1jo1oiw"> </span></div> <!> <!></div>');function w0(t,e){st(e,!0);function s(w){return w==="success"?"dot-ok":w==="error"?"dot-err":"dot-running"}function n(w){(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),e.ontoggle())}var a=m0();let i;var r=h(a),o=h(r),d=f(o,2),l=h(d),u=f(d,2),_=h(u),p=f(r,2);{var v=w=>{var S=v0(),C=h(S);V(()=>M(C,e.flight.error??e.flight.result??"")),k(w,S)};O(p,w=>{(e.flight.error||e.flight.result)&&w(v)})}var x=f(p,2);{var y=w=>{var S=b0(),C=h(S);{var K=A=>{var X=p0(),L=f(me(X),2),se=h(L);V(()=>M(se,e.flight.error)),k(A,X)};O(C,A=>{e.flight.error&&A(K)})}var E=f(C,2);{var U=A=>{var X=g0(),L=f(me(X),2),se=h(L);V(()=>M(se,e.flight.result)),k(A,X)};O(E,A=>{e.flight.result&&A(U)})}var te=f(E,2);{var T=A=>{var X=x0();G("click",X,L=>{L.stopPropagation(),e.onretry()}),k(A,X)};O(te,A=>{e.flight.status==="error"&&A(T)})}k(w,S)};O(x,w=>{e.expanded&&w(y)})}V((w,S,C)=>{i=pe(a,1,"flight-card svelte-1jo1oiw",null,i,{"flight-expanded":e.expanded}),pe(o,1,`svc-dot ${w??""}`,"svelte-1jo1oiw"),M(l,S),M(_,C)},[()=>s(e.flight.status),()=>pi(e.flight.started_at,e.flight.finished_at),()=>fs(e.flight.started_at)]),G("click",a,function(...w){e.ontoggle?.apply(this,w)}),G("keydown",a,n),k(t,a),nt()}_t(["click","keydown"]);var y0=F("<button> </button>"),k0=F("<button> </button>"),S0=F("<button> </button>"),C0=F("<button> </button>"),E0=F('<button class="btn btn-danger btn-sm">Delete</button>'),A0=F('<span class="flights-count mono svelte-1o8kr72"> </span>'),K0=F('<div class="flights-empty svelte-1o8kr72">Loading flights...</div>'),F0=F('<div class="flights-empty svelte-1o8kr72"> </div>'),T0=F('<div class="pagination svelte-1o8kr72"><button class="pg-btn svelte-1o8kr72"><svg class="pg-icon svelte-1o8kr72" viewBox="0 0 6 10" fill="none" aria-hidden="true"><path d="M5 1L1 5L5 9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg> Prev</button> <span class="pg-info svelte-1o8kr72"> </span> <button class="pg-btn svelte-1o8kr72">Next <svg class="pg-icon svelte-1o8kr72" viewBox="0 0 6 10" fill="none" aria-hidden="true"><path d="M1 1L5 5L1 9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg></button></div>'),M0=F('<div class="flight-list svelte-1o8kr72"></div> <!>',1),X0=F('<div><button class="backdrop svelte-1o8kr72" aria-label="Close drawer"></button> <div class="drawer-panel svelte-1o8kr72"><div class="drawer-header svelte-1o8kr72"><div class="header-top svelte-1o8kr72"><h2 class="bird-name svelte-1o8kr72"> </h2> <button class="close-btn svelte-1o8kr72" aria-label="Close"><svg viewBox="0 0 16 16" fill="none" aria-hidden="true" class="svelte-1o8kr72"><path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg></button></div> <div class="meta-row svelte-1o8kr72"><!> <div class="toggle-wrapper svelte-1o8kr72"><!></div> <!></div></div> <div class="drawer-body svelte-1o8kr72"><div class="config-section svelte-1o8kr72"><div class="config-grid svelte-1o8kr72"><div class="config-item svelte-1o8kr72"><span class="config-label svelte-1o8kr72">Agent</span> <!></div> <div class="config-item svelte-1o8kr72"><span class="config-label svelte-1o8kr72">Channel</span> <!></div></div> <div class="prompt-block svelte-1o8kr72"><span class="config-label svelte-1o8kr72">Prompt</span> <!></div></div> <div class="actions-row svelte-1o8kr72"><button class="btn btn-outline btn-sm">Fly</button> <!></div> <div class="divider svelte-1o8kr72"></div> <div class="flights-section svelte-1o8kr72"><div class="flights-header svelte-1o8kr72"><span class="flights-title svelte-1o8kr72">Flight Log</span> <!></div> <div class="filter-row svelte-1o8kr72"><button>All</button> <button>Success</button> <button>Error</button> <button>Running</button> <input type="search" class="flight-search svelte-1o8kr72" placeholder="Search flights..."/></div> <!></div></div></div></div>');function L0(t,e){st(e,!0);let s=W(Ne([])),n=W(!0),a=W(1),i=W(1),r=W(0),o=W(""),d=W(""),l=W(null),u=W(!1),_=W(null);const p=Ae(()=>c(_)??!!e.bird.enabled);xt(()=>{e.bird.enabled,b(_,null)});let v=W(null),x=W(""),y=W(!1),w,S=W("");const C=Ae(()=>e.bird.name.startsWith("__bb_"));Kc().then(()=>{b(u,!0)});function K(){b(u,!1),setTimeout(e.onclose,200)}function E(Y){if(Y.key==="Escape"){if(gn.pending)return;c(v)?L():K()}}function U(Y,ie,ve,Ke){let Qe=`/api/flights?birdUid=${Y}&perPage=10&sort=-started_at&page=${ie}`;return ve&&(Qe+=`&status=${ve}`),Ke&&(Qe+=`&search=${encodeURIComponent(Ke)}`),Qe}xt(()=>{const Y=e.bird.uid,ie=c(a),ve=c(o),Ke=c(S),Qe=new AbortController;return b(n,!0),ke(U(Y,ie,ve,Ke)).then(qe=>{Qe.signal.aborted||(b(s,qe.items,!0),b(i,qe.totalPages,!0),b(r,qe.totalItems,!0))}).catch(()=>{Qe.signal.aborted||(b(s,[],!0),b(i,1),b(r,0))}).finally(()=>{Qe.signal.aborted||b(n,!1)}),()=>Qe.abort()}),xt(()=>{const Y=e.bird.uid;return Mi(ve=>{if(ve.resource==="birds"){const Ke=U(Y,c(a),c(o),c(S));ke(Ke).then(Qe=>{b(s,Qe.items,!0),b(i,Qe.totalPages,!0),b(r,Qe.totalItems,!0)}).catch(()=>{})}})});function te(Y){b(o,Y,!0),b(a,1),b(l,null)}function T(Y){const ie=Y.target.value;b(d,ie,!0),clearTimeout(w),w=setTimeout(()=>{b(S,ie,!0),b(a,1),b(l,null)},300)}async function A(){const Y=!c(p);b(_,Y);const ie=Y?"enable":"disable";try{await ke(`/api/birds/${e.bird.uid}/${ie}`,{method:"PATCH"}),Me(`Bird ${Tt(e.bird.uid)} ${ie}d`,"success")}catch(ve){b(_,null),Me(`Failed: ${ve.message}`,"error")}}function X(Y){c(C)||(b(v,Y,!0),b(x,e.bird[Y]??"",!0))}function L(){b(v,null),b(x,"")}async function se(){if(!c(v))return;const Y=c(x).trim(),ie=(e.bird[c(v)]??"").trim();if(Y===ie){L();return}const ve=c(v)==="target_channel_id";if(!Y&&!ve){Me("Value cannot be empty","error");return}b(y,!0);const Ke={schedule:"schedule",prompt:"prompt",agent_id:"agent",target_channel_id:"channel"};try{await ke(`/api/birds/${e.bird.uid}`,{method:"PATCH",body:{[Ke[c(v)]]:Y||null}}),Me(`Updated ${c(v).replace("_"," ")}`,"success"),L()}catch(Qe){Me(`Failed: ${Qe.message}`,"error")}finally{b(y,!1)}}async function oe(){try{const Y=await ke(`/api/birds/${e.bird.uid}/fly`,{method:"POST"});Me(`Bird ${Tt(e.bird.uid)} sent on a flight (job #${Y.jobId})`,"success")}catch(Y){Me(`Failed: ${Y.message}`,"error")}}async function de(){if(await Or(`Delete bird "${e.bird.name}"? This will also remove all flight history.`))try{await ke(`/api/birds/${e.bird.uid}`,{method:"DELETE"}),Me(`Bird ${Tt(e.bird.uid)} deleted`,"success"),K()}catch(Y){Me(`Failed: ${Y.message}`,"error")}}async function $(Y){try{await ke(`/api/birds/${Y.bird_uid}/fly`,{method:"POST"}),Me(`Retrying ${Y.bird_name}`,"success")}catch(ie){Me(`Failed: ${ie.message}`,"error")}}var H=X0();Rn("keydown",_i,E);let ne;var ae=h(H),xe=f(ae,2),ge=h(xe),he=h(ge),Fe=h(he),Be=h(Fe),Xe=f(Fe,2),q=f(he,2),re=h(q);{var fe=Y=>{gt(Y,{mono:!0,get saving(){return c(y)},onsave:se,oncancel:L,get value(){return c(x)},set value(ie){b(x,ie,!0)}})},we=Y=>{var ie=y0();let ve;var Ke=h(ie);V(()=>{ve=pe(ie,1,"schedule-pill mono svelte-1o8kr72",null,ve,{editable:!c(C)}),M(Ke,e.bird.schedule)}),G("click",ie,()=>X("schedule")),k(Y,ie)};O(re,Y=>{c(v)==="schedule"?Y(fe):Y(we,!1)})}var le=f(re,2),_e=h(le);Xn(_e,{get active(){return c(p)},onToggle:A});var Z=f(le,2);{var be=Y=>{xn(Y,{get status(){return e.bird.last_status}})};O(Z,Y=>{e.bird.last_status&&Y(be)})}var z=f(ge,2),J=h(z),ue=h(J),Se=h(ue),Ie=f(h(Se),2);{var et=Y=>{gt(Y,{get saving(){return c(y)},onsave:se,oncancel:L,get value(){return c(x)},set value(ie){b(x,ie,!0)}})},je=Y=>{var ie=k0();let ve;var Ke=h(ie);V(()=>{ve=pe(ie,1,"config-value svelte-1o8kr72",null,ve,{editable:!c(C)}),M(Ke,e.bird.agent_id)}),G("click",ie,()=>X("agent_id")),k(Y,ie)};O(Ie,Y=>{c(v)==="agent_id"?Y(et):Y(je,!1)})}var bt=f(Se,2),tt=f(h(bt),2);{var Ye=Y=>{gt(Y,{mono:!0,placeholder:"Channel ID",get saving(){return c(y)},onsave:se,oncancel:L,get value(){return c(x)},set value(ie){b(x,ie,!0)}})},mt=Y=>{var ie=S0();let ve;var Ke=h(ie);V(()=>{ve=pe(ie,1,"config-value mono svelte-1o8kr72",null,ve,{editable:!c(C)}),M(Ke,e.bird.target_channel_id??"default")}),G("click",ie,()=>X("target_channel_id")),k(Y,ie)};O(tt,Y=>{c(v)==="target_channel_id"?Y(Ye):Y(mt,!1)})}var ye=f(ue,2),Oe=f(h(ye),2);{var lt=Y=>{gt(Y,{mono:!0,multiline:!0,get saving(){return c(y)},onsave:se,oncancel:L,get value(){return c(x)},set value(ie){b(x,ie,!0)}})},ls=Y=>{var ie=C0();let ve;var Ke=h(ie);V(()=>{ve=pe(ie,1,"prompt-pre svelte-1o8kr72",null,ve,{editable:!c(C)}),M(Ke,e.bird.prompt)}),G("click",ie,()=>X("prompt")),k(Y,ie)};O(Oe,Y=>{c(v)==="prompt"?Y(lt):Y(ls,!1)})}var ss=f(J,2),gs=h(ss),Ts=f(gs,2);{var Ct=Y=>{var ie=E0();G("click",ie,de),k(Y,ie)};O(Ts,Y=>{c(C)||Y(Ct)})}var xs=f(ss,4),Hs=h(xs),Ms=f(h(Hs),2);{var Xs=Y=>{var ie=A0(),ve=h(ie);V(()=>M(ve,c(r))),k(Y,ie)};O(Ms,Y=>{c(r)>0&&Y(Xs)})}var Ls=f(Hs,2),bs=h(Ls);let zs;var Os=f(bs,2);let an;var Ve=f(Os,2);let Ze;var ct=f(Ve,2);let dt;var Kt=f(ct,2),ut=f(Ls,2);{var Je=Y=>{var ie=K0();k(Y,ie)},ht=Y=>{var ie=F0(),ve=h(ie);V(()=>M(ve,c(d)||c(o)?"No matching flights":"No flights yet")),k(Y,ie)},Ge=Y=>{var ie=M0(),ve=me(ie);Mt(ve,21,()=>c(s),qe=>qe.uid,(qe,ft)=>{{let wt=Ae(()=>c(l)===c(ft).uid);w0(qe,{get flight(){return c(ft)},get expanded(){return c(wt)},ontoggle:()=>{b(l,c(l)===c(ft).uid?null:c(ft).uid,!0)},onretry:()=>$(c(ft))})}});var Ke=f(ve,2);{var Qe=qe=>{var ft=T0(),wt=h(ft),Pt=f(wt,2),Bt=h(Pt),Nt=f(Pt,2);V(()=>{wt.disabled=c(a)===1,M(Bt,`${c(a)??""} / ${c(i)??""}`),Nt.disabled=c(a)===c(i)}),G("click",wt,()=>{br(a,-1)}),G("click",Nt,()=>{br(a)}),k(qe,ft)};O(Ke,qe=>{c(i)>1&&qe(Qe)})}k(Y,ie)};O(ut,Y=>{c(n)?Y(Je):c(s).length===0?Y(ht,1):Y(Ge,!1)})}V(()=>{ne=pe(H,1,"overlay svelte-1o8kr72",null,ne,{visible:c(u)}),M(Be,e.bird.name),zs=pe(bs,1,"filter-chip svelte-1o8kr72",null,zs,{"filter-all-active":c(o)===""}),an=pe(Os,1,"filter-chip svelte-1o8kr72",null,an,{"filter-success-active":c(o)==="success"}),Ze=pe(Ve,1,"filter-chip svelte-1o8kr72",null,Ze,{"filter-error-active":c(o)==="error"}),dt=pe(ct,1,"filter-chip svelte-1o8kr72",null,dt,{"filter-running-active":c(o)==="running"}),Dc(Kt,c(d))}),G("click",ae,K),G("click",Xe,K),G("click",gs,oe),G("click",bs,()=>te("")),G("click",Os,()=>te("success")),G("click",Ve,()=>te("error")),G("click",ct,()=>te("running")),G("input",Kt,T),k(t,H),nt()}_t(["click","input"]);var P0=F('<div class="loading">Loading...</div>'),B0=F('<span class="cell-btn-label svelte-3q62eu">...</span>'),D0=kn('<svg viewBox="0 0 16 16" fill="none" aria-hidden="true" class="svelte-3q62eu"><path d="M3 8.5l3.5 3.5L13 4.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>'),R0=F('<div class="cell-edit-actions svelte-3q62eu"><button class="cell-btn cell-btn-save svelte-3q62eu" title="Save"><!></button> <button class="cell-btn cell-btn-cancel svelte-3q62eu" title="Cancel"><svg viewBox="0 0 16 16" fill="none" aria-hidden="true" class="svelte-3q62eu"><path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg></button></div>'),I0=F('<div class="create-form svelte-3q62eu"><div class="form-title svelte-3q62eu">New Bird</div> <div class="form-row svelte-3q62eu"><label class="form-label">Schedule <input class="form-input" type="text" placeholder="*/30 * * * *"/></label> <label class="form-label">Channel ID <input class="form-input" type="text" placeholder="Optional"/></label> <label class="form-label">Agent ID <input class="form-input" type="text" placeholder="default"/></label></div> <label class="form-label">Prompt <textarea class="form-textarea" placeholder="What should the agent do?"></textarea></label> <div class="form-actions svelte-3q62eu"><button class="btn btn-primary btn-sm"> </button> <button class="btn btn-outline btn-sm">Cancel</button></div></div>'),Q0=F('<button class="btn btn-primary btn-sm"> </button> <div class="filter-spacer svelte-3q62eu"></div> <span class="last-updated svelte-3q62eu"> </span>',1),N0=F('<div class="cell-edit-overlay svelte-3q62eu"><input class="cell-input mono svelte-3q62eu" type="text"/> <!></div>'),U0=F('<div class="cell-edit-overlay svelte-3q62eu"><textarea class="cell-input cell-textarea svelte-3q62eu"></textarea> <!></div>'),H0=F('<div class="cell-edit-overlay svelte-3q62eu"><input class="cell-input svelte-3q62eu" type="text"/> <!></div>'),z0=F('<div class="cell-edit-overlay svelte-3q62eu"><input class="cell-input mono svelte-3q62eu" type="text" placeholder="Channel ID"/> <!></div>'),O0=F('<span class="last-run-age svelte-3q62eu"> </span> <!>',1),V0=F('<button class="btn btn-danger btn-sm">Delete</button>'),G0=F('<tr class="bird-row svelte-3q62eu"><td class="mono"> </td><td> </td><td><span> </span> <!></td><td><span> </span> <!></td><td><span> </span> <!></td><td><span> </span> <!></td><td><div class="toggle-wrapper svelte-3q62eu"><!></div></td><td class="last-run-cell svelte-3q62eu"><!></td><td><div class="actions-cell svelte-3q62eu"><button class="btn btn-outline btn-sm">Fly</button> <!></div></td></tr>'),q0=F("<!> <!> <!>",1);function W0(t,e){st(e,!0);const s=[{key:"uid",label:"ID",sortable:!0},{key:"name",label:"Name",sortable:!0},{key:"schedule",label:"Schedule",sortable:!0},{key:"prompt",label:"Prompt"},{key:"agent_id",label:"Agent",sortable:!0},{key:"target_channel_id",label:"Channel"},{key:"enabled",label:"Enabled",sortable:!0},{key:"last_run",label:"Last Run",sortable:!0},{key:"actions",label:"Actions"}];let n=W(Ne(wn()));const a=Vr({endpoint:"/api/birds",columns:s,defaultSort:"created_at",invalidateOn:"birds",onResponse:()=>{b(n,wn(),!0)}});let i=W(!1),r=W(""),o=W(""),d=W(""),l=W(""),u=W(!1),_=W(null),p=W(!1),v=W(null);const x=Ae(()=>c(v)?a.items.find(H=>H.uid===c(v))??null:null);xt(()=>{if(a.loading)return;const H=Ti().get("expand");if(!H)return;const ne=a.items.find(ae=>ae.uid===H);if(ne){b(v,ne.uid,!0);const ae=window.location.hash,xe=ae.indexOf("?"),ge=xe===-1?ae:ae.slice(0,xe),he=new URLSearchParams(xe===-1?"":ae.slice(xe+1));he.delete("expand");const Fe=he.toString();history.replaceState(null,"",Fe?`${ge}?${Fe}`:ge)}});function y(H,ne){H.target.closest(".cell-editable, .actions-cell, .toggle-wrapper")||b(v,ne.uid,!0)}async function w(H,ne){const ae=ne?"disable":"enable";try{await ke(`/api/birds/${H}/${ae}`,{method:"PATCH"}),Me(`Bird ${Tt(H)} ${ae}d`,"success")}catch(xe){Me(`Failed: ${xe.message}`,"error")}}function S(){b(r,""),b(o,""),b(d,""),b(l,""),b(i,!0)}function C(){b(i,!1)}async function K(){if(!c(r).trim()||!c(o).trim()){Me("Schedule and prompt are required","error");return}b(u,!0);try{const H={schedule:c(r).trim(),prompt:c(o).trim()};c(d).trim()&&(H.channel=c(d).trim()),c(l).trim()&&(H.agent=c(l).trim()),await ke("/api/birds",{method:"POST",body:H}),Me("Bird created","success"),C()}catch(H){Me(`Failed: ${H.message}`,"error")}finally{b(u,!1)}}function E(H,ne){if(H.name.startsWith("__bb_"))return;const ae=H[ne]??"";b(_,{uid:H.uid,field:ne,value:ae,original:ae},!0)}function U(){b(_,null)}async function te(){if(c(_)==null)return;const H=c(_).value.trim();if(H===c(_).original.trim()){b(_,null);return}const ne=c(_).field==="target_channel_id";if(!H&&!ne){Me("Value cannot be empty","error");return}b(p,!0);const ae={schedule:"schedule",prompt:"prompt",agent_id:"agent",target_channel_id:"channel"};try{await ke(`/api/birds/${c(_).uid}`,{method:"PATCH",body:{[ae[c(_).field]]:H||null}}),Me(`Updated ${c(_).field.replace("_"," ")}`,"success"),b(_,null)}catch(xe){Me(`Failed: ${xe.message}`,"error")}finally{b(p,!1)}}function T(H){H.key==="Escape"?U():H.key==="Enter"&&(c(_)?.field==="prompt"?H.metaKey:!H.shiftKey)&&(H.preventDefault(),te())}function A(H,ne){return c(_)!=null&&c(_).uid===H&&c(_).field===ne}async function X(H){try{const ne=await ke(`/api/birds/${H}/fly`,{method:"POST"});Me(`Bird ${Tt(H)} sent on a flight (job #${ne.jobId})`,"success")}catch(ne){Me(`Failed: ${ne.message}`,"error")}}async function L(H,ne){if(await Or(`Delete bird "${ne}"? This will also remove all flight history.`))try{await ke(`/api/birds/${H}`,{method:"DELETE"}),Me(`Bird ${Tt(H)} deleted`,"success")}catch(ae){Me(`Failed: ${ae.message}`,"error")}}var se=yt(),oe=me(se);{var de=H=>{var ne=P0();k(H,ne)},$=H=>{const ne=Xe=>{var q=R0(),re=h(q),fe=h(re);{var we=Z=>{var be=B0();k(Z,be)},le=Z=>{var be=D0();k(Z,be)};O(fe,Z=>{c(p)?Z(we):Z(le,!1)})}var _e=f(re,2);V(()=>re.disabled=c(p)),G("click",re,Z=>{Z.stopPropagation(),te()}),G("click",_e,Z=>{Z.stopPropagation(),U()}),k(Xe,q)};var ae=q0(),xe=me(ae);{var ge=Xe=>{var q=I0(),re=f(h(q),2),fe=h(re),we=f(h(fe)),le=f(fe,2),_e=f(h(le)),Z=f(le,2),be=f(h(Z)),z=f(re,2),J=f(h(z)),ue=f(z,2),Se=h(ue),Ie=h(Se),et=f(Se,2);V(()=>{Se.disabled=c(u),M(Ie,c(u)?"Saving...":"Create")}),He(we,()=>c(r),je=>b(r,je)),He(_e,()=>c(d),je=>b(d,je)),He(be,()=>c(l),je=>b(l,je)),He(J,()=>c(o),je=>b(o,je)),G("click",Se,K),G("click",et,C),k(Xe,q)};O(xe,Xe=>{c(i)&&Xe(ge)})}var he=f(xe,2);{const Xe=re=>{var fe=Q0(),we=me(fe),le=h(we),_e=f(we,4),Z=h(_e);V(()=>{M(le,c(i)?"Cancel":"Add Bird"),M(Z,`Updated ${c(n)??""}`)}),G("click",we,()=>{c(i)?C():S()}),k(re,fe)};let q=Ae(()=>a.items.length===0);dn(he,{get columns(){return s},get isEmpty(){return c(q)},emptyMessage:"No birds configured",get fetching(){return a.fetching},get page(){return a.page},get totalPages(){return a.totalPages},get totalItems(){return a.totalItems},get sort(){return a.sort},get search(){return a.search},searchPlaceholder:"Search birds...",get onPageChange(){return a.setPage},get onSortChange(){return a.setSort},get onSearchChange(){return a.setSearch},toolbar:Xe,children:(re,fe)=>{var we=yt(),le=me(we);Mt(le,17,()=>a.items,_e=>_e.uid,(_e,Z)=>{const be=Ae(()=>c(Z).name.startsWith("__bb_"));var z=G0(),J=h(z),ue=h(J),Se=f(J),Ie=h(Se),et=f(Se);let je;var bt=h(et);let tt;var Ye=h(bt),mt=f(bt,2);{var ye=Te=>{var $e=N0(),at=h($e),Ut=f(at,2);ne(Ut),G("keydown",at,T),He(at,()=>c(_).value,qt=>c(_).value=qt),k(Te,$e)},Oe=Ae(()=>A(c(Z).uid,"schedule"));O(mt,Te=>{c(Oe)&&Te(ye)})}var lt=f(et);let ls;var ss=h(lt);let gs;var Ts=h(ss),Ct=f(ss,2);{var xs=Te=>{var $e=U0(),at=h($e),Ut=f(at,2);ne(Ut),G("keydown",at,T),He(at,()=>c(_).value,qt=>c(_).value=qt),k(Te,$e)},Hs=Ae(()=>A(c(Z).uid,"prompt"));O(Ct,Te=>{c(Hs)&&Te(xs)})}var Ms=f(lt);let Xs;var Ls=h(Ms);let bs;var zs=h(Ls),Os=f(Ls,2);{var an=Te=>{var $e=H0(),at=h($e),Ut=f(at,2);ne(Ut),G("keydown",at,T),He(at,()=>c(_).value,qt=>c(_).value=qt),k(Te,$e)},Ve=Ae(()=>A(c(Z).uid,"agent_id"));O(Os,Te=>{c(Ve)&&Te(an)})}var Ze=f(Ms);let ct;var dt=h(Ze);let Kt;var ut=h(dt),Je=f(dt,2);{var ht=Te=>{var $e=z0(),at=h($e),Ut=f(at,2);ne(Ut),G("keydown",at,T),He(at,()=>c(_).value,qt=>c(_).value=qt),k(Te,$e)},Ge=Ae(()=>A(c(Z).uid,"target_channel_id"));O(Je,Te=>{c(Ge)&&Te(ht)})}var Y=f(Ze),ie=h(Y),ve=h(ie);{let Te=Ae(()=>!!c(Z).enabled);Xn(ve,{get active(){return c(Te)},onToggle:()=>w(c(Z).uid,!!c(Z).enabled)})}var Ke=f(Y),Qe=h(Ke);{var qe=Te=>{var $e=O0(),at=me($e),Ut=h(at),qt=f(at,2);{var Sn=Vs=>{xn(Vs,{get status(){return c(Z).last_status}})};O(qt,Vs=>{c(Z).last_status&&Vs(Sn)})}V(Vs=>M(Ut,Vs),[()=>fs(c(Z).last_run)]),k(Te,$e)},ft=Te=>{var $e=Ss("-");k(Te,$e)};O(Qe,Te=>{c(Z).last_run?Te(qe):Te(ft,!1)})}var wt=f(Ke),Pt=h(wt),Bt=h(Pt),Nt=f(Bt,2);{var Ps=Te=>{var $e=V0();G("click",$e,()=>L(c(Z).uid,c(Z).name)),k(Te,$e)};O(Nt,Te=>{c(be)||Te(Ps)})}V((Te,$e,at,Ut,qt,Sn)=>{M(ue,Te),M(Ie,c(Z).name),je=pe(et,1,"svelte-3q62eu",null,je,{"cell-editable":!c(be)}),tt=pe(bt,1,"mono cell-text svelte-3q62eu",null,tt,$e),M(Ye,c(Z).schedule),ls=pe(lt,1,"svelte-3q62eu",null,ls,{"cell-editable":!c(be)}),gs=pe(ss,1,"cell-text prompt-text svelte-3q62eu",null,gs,at),jt(ss,"title",c(Z).prompt),M(Ts,`${Ut??""}${c(Z).prompt.length>60?"...":""}`),Xs=pe(Ms,1,"svelte-3q62eu",null,Xs,{"cell-editable":!c(be)}),bs=pe(Ls,1,"cell-text svelte-3q62eu",null,bs,qt),M(zs,c(Z).agent_id),ct=pe(Ze,1,"svelte-3q62eu",null,ct,{"cell-editable":!c(be)}),Kt=pe(dt,1,"mono cell-text svelte-3q62eu",null,Kt,Sn),M(ut,c(Z).target_channel_id??"-")},[()=>Tt(c(Z).uid),()=>({"cell-text-hidden":A(c(Z).uid,"schedule")}),()=>({"cell-text-hidden":A(c(Z).uid,"prompt")}),()=>c(Z).prompt.slice(0,60),()=>({"cell-text-hidden":A(c(Z).uid,"agent_id")}),()=>({"cell-text-hidden":A(c(Z).uid,"target_channel_id")})]),G("click",z,Te=>y(Te,c(Z))),G("click",et,()=>E(c(Z),"schedule")),G("click",lt,()=>E(c(Z),"prompt")),G("click",Ms,()=>E(c(Z),"agent_id")),G("click",Ze,()=>E(c(Z),"target_channel_id")),G("click",Bt,()=>X(c(Z).uid)),k(_e,z)}),k(re,we)},$$slots:{toolbar:!0,default:!0}})}var Fe=f(he,2);{var Be=Xe=>{L0(Xe,{get bird(){return c(x)},onclose:()=>{b(v,null)}})};O(Fe,Xe=>{c(x)&&Xe(Be)})}k(H,ae)};O(oe,H=>{a.loading?H(de):H($,!1)})}k(t,se),nt()}_t(["click","keydown"]);function j0(t){return t>>>0}function Kr(t){return t|0}let wo="warn",Ce=()=>{},Gt=()=>{},Wt=()=>{},ot=()=>{};function Y0(t){if(typeof t>"u"?t=wo:wo=t,Ce=Gt=Wt=ot=()=>{},typeof window.console<"u")switch(t){case"debug":Ce=console.debug.bind(window.console);case"info":Gt=console.info.bind(window.console);case"warn":Wt=console.warn.bind(window.console);case"error":ot=console.error.bind(window.console);case"none":break;default:throw new window.Error("invalid logging type '"+t+"'")}}Y0();function Hi(t,e=!1){try{return decodeURIComponent(escape(t))}catch(s){if(s instanceof URIError&&e)return t;throw s}}function js(t){return unescape(encodeURIComponent(t))}const Gr={toBase64Table:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split(""),base64Pad:"=",encode(t){let e="";const s=t.length,n=s%3;for(let i=0;i<s-2;i+=3)e+=this.toBase64Table[t[i]>>2],e+=this.toBase64Table[((t[i]&3)<<4)+(t[i+1]>>4)],e+=this.toBase64Table[((t[i+1]&15)<<2)+(t[i+2]>>6)],e+=this.toBase64Table[t[i+2]&63];const a=s-n;return n===2?(e+=this.toBase64Table[t[a]>>2],e+=this.toBase64Table[((t[a]&3)<<4)+(t[a+1]>>4)],e+=this.toBase64Table[(t[a+1]&15)<<2],e+=this.toBase64Table[64]):n===1&&(e+=this.toBase64Table[t[a]>>2],e+=this.toBase64Table[(t[a]&3)<<4],e+=this.toBase64Table[64],e+=this.toBase64Table[64]),e},toBinaryTable:[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,0,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1],decode(t,e=0){let s=t.indexOf("=")-e;s<0&&(s=t.length-e);const n=(s>>2)*3+Math.floor(s%4/1.5),a=new Array(n);let i=0,r=0;for(let o=0,d=e;d<t.length;d++){const l=this.toBinaryTable[t.charCodeAt(d)&127],u=t.charAt(d)===this.base64Pad;if(l===-1){ot("Illegal character code "+t.charCodeAt(d)+" at position "+d);continue}r=r<<6|l,i+=6,i>=8&&(i-=8,u||(a[o++]=r>>i&255),r&=(1<<i)-1)}if(i){const o=new Error("Corrupted base64 string");throw o.name="Base64-Error",o}return a}};let Hc="ontouchstart"in document.documentElement||document.ontouchstart!==void 0||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;window.addEventListener("touchstart",function t(){Hc=!0,window.removeEventListener("touchstart",t,!1)},!1);let Ja=10*(window.devicePixelRatio||1),zc=!1;try{const t=document.createElement("canvas");t.style.cursor='url("data:image/x-icon;base64,AAACAAEACAgAAAIAAgA4AQAAFgAAACgAAAAIAAAAEAAAAAEAIAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAA==") 2 2, default',t.style.cursor.indexOf("url")===0?(Gt("Data URI scheme cursor supported"),zc=!0):Wt("Data URI scheme cursor not supported")}catch(t){ot("Data URI scheme cursor test exception: "+t)}const Z0=zc;let J0=!0;try{const t=document.createElement("div");t.style.visibility="hidden",t.style.overflow="scroll",document.body.appendChild(t);const e=document.createElement("div");t.appendChild(e);const s=t.offsetWidth-e.offsetWidth;t.parentNode.removeChild(t),J0=s!=0}catch(t){ot("Scrollbar test exception: "+t)}let Oc=!1;async function $0(){if(!("VideoDecoder"in window))return!1;const t={codec:"avc1.42401f",codedWidth:1920,codedHeight:1080,optimizeForLatency:!0};if(!(await VideoDecoder.isConfigSupported(t)).supported)return!1;const s=new Uint8Array(Gr.decode("AAAAAWdCwBTZnpuAgICgAAADACAAAAZB4oVNAAAAAWjJYyyAAAABBgX//4HcRem95tlIt5Ys2CDZI+7veDI2NCAtIGNvcmUgMTY0IHIzMTA4IDMxZTE5ZjkgLSBILjI2NC9NUEVHLTQgQVZDIGNvZGVjIC0gQ29weWxlZnQgMjAwMy0yMDIzIC0gaHR0cDovL3d3dy52aWRlb2xhbi5vcmcveDI2NC5odG1sIC0gb3B0aW9uczogY2FiYWM9MCByZWY9NSBkZWJsb2NrPTE6MDowIGFuYWx5c2U9MHgxOjB4MTExIG1lPWhleCBzdWJtZT04IHBzeT0xIHBzeV9yZD0xLjAwOjAuMDAgbWl4ZWRfcmVmPTEgbWVfcmFuZ2U9MTYgY2hyb21hX21lPTEgdHJlbGxpcz0yIDh4OGRjdD0wIGNxbT0wIGRlYWR6b25lPTIxLDExIGZhc3RfcHNraXA9MSBjaHJvbWFfcXBfb2Zmc2V0PS0yIHRocmVhZHM9MSBsb29rYWhlYWRfdGhyZWFkcz0xIHNsaWNlZF90aHJlYWRzPTAgbnI9MCBkZWNpbWF0ZT0xIGludGVybGFjZWQ9MCBibHVyYXlfY29tcGF0PTAgY29uc3RyYWluZWRfaW50cmE9MCBiZnJhbWVzPTAgd2VpZ2h0cD0wIGtleWludD1pbmZpbml0ZSBrZXlpbnRfbWluPTI1IHNjZW5lY3V0PTQwIGludHJhX3JlZnJlc2g9MCByY19sb29rYWhlYWQ9NTAgcmM9YWJyIG1idHJlZT0xIGJpdHJhdGU9NDAwIHJhdGV0b2w9MS4wIHFjb21wPTAuNjAgcXBtaW49MCBxcG1heD02OSBxcHN0ZXA9NCBpcF9yYXRpbz0xLjQwIGFxPTE6MS4wMACAAAABZYiEBrxmKAAPVccAAS044AA5DRJMnkycJk4TPw=="));let n=!1,a=null,i=new VideoDecoder({output:o=>{n=!0,o.close()},error:o=>{a=o}}),r=new EncodedVideoChunk({timestamp:0,type:"key",data:s});i.configure(t),i.decode(r);try{await i.flush()}catch(o){a=o}return!(!n||a!==null)}Oc=await $0();function qn(){return!!/mac/i.exec(navigator.platform)}function di(){return!!/win/i.exec(navigator.platform)}function ha(){return!!/ipad/i.exec(navigator.platform)||!!/iphone/i.exec(navigator.platform)||!!/ipod/i.exec(navigator.platform)}function fa(t,e,s){const n=s.getBoundingClientRect();let a={x:0,y:0};return t<n.left?a.x=0:t>=n.right?a.x=n.width-1:a.x=t-n.left,e<n.top?a.y=0:e>=n.bottom?a.y=n.height-1:a.y=e-n.top,a}function On(t){t.stopPropagation(),t.preventDefault()}let zi=!1,Vc=null;document.captureElement=null;function An(t){if(zi)return;const e=new t.constructor(t.type,t);zi=!0,document.captureElement?document.captureElement.dispatchEvent(e):Vc.dispatchEvent(e),zi=!1,t.stopPropagation(),e.defaultPrevented&&t.preventDefault(),t.type==="mouseup"&&Wc()}function Gc(){const t=document.getElementById("noVNC_mouse_capture_elem");t.style.cursor=window.getComputedStyle(document.captureElement).cursor}const qc=new MutationObserver(Gc);function ef(t){if(t.setCapture)t.setCapture(),document.captureElement=t;else{Wc();let e=document.getElementById("noVNC_mouse_capture_elem");e===null&&(e=document.createElement("div"),e.id="noVNC_mouse_capture_elem",e.style.position="fixed",e.style.top="0px",e.style.left="0px",e.style.width="100%",e.style.height="100%",e.style.zIndex=1e4,e.style.display="none",document.body.appendChild(e),e.addEventListener("contextmenu",An),e.addEventListener("mousemove",An),e.addEventListener("mouseup",An)),document.captureElement=t,qc.observe(t,{attributes:!0}),Gc(),e.style.display="",window.addEventListener("mousemove",An),window.addEventListener("mouseup",An)}}function Wc(){if(document.releaseCapture)document.releaseCapture(),document.captureElement=null;else{if(!document.captureElement)return;Vc=document.captureElement,document.captureElement=null,qc.disconnect();const t=document.getElementById("noVNC_mouse_capture_elem");t.style.display="none",window.removeEventListener("mousemove",An),window.removeEventListener("mouseup",An)}}class jc{constructor(){this._listeners=new Map}addEventListener(e,s){this._listeners.has(e)||this._listeners.set(e,new Set),this._listeners.get(e).add(s)}removeEventListener(e,s){this._listeners.has(e)&&this._listeners.get(e).delete(s)}dispatchEvent(e){return this._listeners.has(e.type)?(this._listeners.get(e.type).forEach(s=>s.call(this,e)),!e.defaultPrevented):!0}}class tf{constructor(e){if(this._drawCtx=null,this._renderQ=[],this._flushPromise=null,this._fbWidth=0,this._fbHeight=0,this._prevDrawStyle="",Ce(">> Display.constructor"),this._target=e,!this._target)throw new Error("Target must be set");if(typeof this._target=="string")throw new Error("target must be a DOM element");if(!this._target.getContext)throw new Error("no getContext method");this._targetCtx=this._target.getContext("2d"),this._viewportLoc={x:0,y:0,w:this._target.width,h:this._target.height},this._backbuffer=document.createElement("canvas"),this._drawCtx=this._backbuffer.getContext("2d"),this._damageBounds={left:0,top:0,right:this._backbuffer.width,bottom:this._backbuffer.height},Ce("User Agent: "+navigator.userAgent),Ce("<< Display.constructor"),this._scale=1,this._clipViewport=!1}get scale(){return this._scale}set scale(e){this._rescale(e)}get clipViewport(){return this._clipViewport}set clipViewport(e){this._clipViewport=e;const s=this._viewportLoc;this.viewportChangeSize(s.w,s.h),this.viewportChangePos(0,0)}get width(){return this._fbWidth}get height(){return this._fbHeight}viewportChangePos(e,s){const n=this._viewportLoc;e=Math.floor(e),s=Math.floor(s),this._clipViewport||(e=-n.w,s=-n.h);const a=n.x+n.w-1,i=n.y+n.h-1;e<0&&n.x+e<0&&(e=-n.x),a+e>=this._fbWidth&&(e-=a+e-this._fbWidth+1),n.y+s<0&&(s=-n.y),i+s>=this._fbHeight&&(s-=i+s-this._fbHeight+1),!(e===0&&s===0)&&(Ce("viewportChange deltaX: "+e+", deltaY: "+s),n.x+=e,n.y+=s,this._damage(n.x,n.y,n.w,n.h),this.flip())}viewportChangeSize(e,s){(!this._clipViewport||typeof e>"u"||typeof s>"u")&&(Ce("Setting viewport to full display region"),e=this._fbWidth,s=this._fbHeight),e=Math.floor(e),s=Math.floor(s),e>this._fbWidth&&(e=this._fbWidth),s>this._fbHeight&&(s=this._fbHeight);const n=this._viewportLoc;if(n.w!==e||n.h!==s){n.w=e,n.h=s;const a=this._target;a.width=e,a.height=s,this.viewportChangePos(0,0),this._damage(n.x,n.y,n.w,n.h),this.flip(),this._rescale(this._scale)}}absX(e){return this._scale===0?0:Kr(e/this._scale+this._viewportLoc.x)}absY(e){return this._scale===0?0:Kr(e/this._scale+this._viewportLoc.y)}resize(e,s){this._prevDrawStyle="",this._fbWidth=e,this._fbHeight=s;const n=this._backbuffer;if(n.width!==e||n.height!==s){let i=null;n.width>0&&n.height>0&&(i=this._drawCtx.getImageData(0,0,n.width,n.height)),n.width!==e&&(n.width=e),n.height!==s&&(n.height=s),i&&this._drawCtx.putImageData(i,0,0)}const a=this._viewportLoc;this.viewportChangeSize(a.w,a.h),this.viewportChangePos(0,0)}getImageData(){return this._drawCtx.getImageData(0,0,this.width,this.height)}toDataURL(e,s){return this._backbuffer.toDataURL(e,s)}toBlob(e,s,n){return this._backbuffer.toBlob(e,s,n)}_damage(e,s,n,a){e<this._damageBounds.left&&(this._damageBounds.left=e),s<this._damageBounds.top&&(this._damageBounds.top=s),e+n>this._damageBounds.right&&(this._damageBounds.right=e+n),s+a>this._damageBounds.bottom&&(this._damageBounds.bottom=s+a)}flip(e){if(this._renderQ.length!==0&&!e)this._renderQPush({type:"flip"});else{let s=this._damageBounds.left,n=this._damageBounds.top,a=this._damageBounds.right-s,i=this._damageBounds.bottom-n,r=s-this._viewportLoc.x,o=n-this._viewportLoc.y;r<0&&(a+=r,s-=r,r=0),o<0&&(i+=o,n-=o,o=0),r+a>this._viewportLoc.w&&(a=this._viewportLoc.w-r),o+i>this._viewportLoc.h&&(i=this._viewportLoc.h-o),a>0&&i>0&&this._targetCtx.drawImage(this._backbuffer,s,n,a,i,r,o,a,i),this._damageBounds.left=this._damageBounds.top=65535,this._damageBounds.right=this._damageBounds.bottom=0}}pending(){return this._renderQ.length>0}flush(){return this._renderQ.length===0?Promise.resolve():(this._flushPromise===null&&(this._flushPromise=new Promise(e=>{this._flushResolve=e})),this._flushPromise)}fillRect(e,s,n,a,i,r){this._renderQ.length!==0&&!r?this._renderQPush({type:"fill",x:e,y:s,width:n,height:a,color:i}):(this._setFillColor(i),this._drawCtx.fillRect(e,s,n,a),this._damage(e,s,n,a))}copyImage(e,s,n,a,i,r,o){this._renderQ.length!==0&&!o?this._renderQPush({type:"copy",oldX:e,oldY:s,x:n,y:a,width:i,height:r}):(this._drawCtx.mozImageSmoothingEnabled=!1,this._drawCtx.webkitImageSmoothingEnabled=!1,this._drawCtx.msImageSmoothingEnabled=!1,this._drawCtx.imageSmoothingEnabled=!1,this._drawCtx.drawImage(this._backbuffer,e,s,i,r,n,a,i,r),this._damage(n,a,i,r))}imageRect(e,s,n,a,i,r){if(n===0||a===0)return;const o=new Image;o.src="data: "+i+";base64,"+Gr.encode(r),this._renderQPush({type:"img",img:o,x:e,y:s,width:n,height:a})}videoFrame(e,s,n,a,i){this._renderQPush({type:"frame",frame:i,x:e,y:s,width:n,height:a})}blitImage(e,s,n,a,i,r,o){if(this._renderQ.length!==0&&!o){const d=new Uint8Array(n*a*4);d.set(new Uint8Array(i.buffer,0,d.length)),this._renderQPush({type:"blit",data:d,x:e,y:s,width:n,height:a})}else{let d=new Uint8ClampedArray(i.buffer,i.byteOffset+r,n*a*4),l=new ImageData(d,n,a);this._drawCtx.putImageData(l,e,s),this._damage(e,s,n,a)}}drawImage(e,...s){if(this._drawCtx.drawImage(e,...s),s.length<=4){const[n,a]=s;this._damage(n,a,e.width,e.height)}else{const[,,n,a,i,r]=s;this._damage(i,r,n,a)}}autoscale(e,s){let n;if(e===0||s===0)n=0;else{const a=this._viewportLoc,i=e/s;a.w/a.h>=i?n=e/a.w:n=s/a.h}this._rescale(n)}_rescale(e){this._scale=e;const s=this._viewportLoc,n=e*s.w+"px",a=e*s.h+"px";(this._target.style.width!==n||this._target.style.height!==a)&&(this._target.style.width=n,this._target.style.height=a)}_setFillColor(e){const s="rgb("+e[0]+","+e[1]+","+e[2]+")";s!==this._prevDrawStyle&&(this._drawCtx.fillStyle=s,this._prevDrawStyle=s)}_renderQPush(e){this._renderQ.push(e),this._renderQ.length===1&&this._scanRenderQ()}_resumeRenderQ(){this.removeEventListener("load",this._noVNCDisplay._resumeRenderQ),this._noVNCDisplay._scanRenderQ()}_scanRenderQ(){let e=!0;for(;e&&this._renderQ.length>0;){const s=this._renderQ[0];switch(s.type){case"flip":this.flip(!0);break;case"copy":this.copyImage(s.oldX,s.oldY,s.x,s.y,s.width,s.height,!0);break;case"fill":this.fillRect(s.x,s.y,s.width,s.height,s.color,!0);break;case"blit":this.blitImage(s.x,s.y,s.width,s.height,s.data,0,!0);break;case"img":if(s.img.complete){if(s.img.width!==s.width||s.img.height!==s.height){ot("Decoded image has incorrect dimensions. Got "+s.img.width+"x"+s.img.height+". Expected "+s.width+"x"+s.height+".");return}this.drawImage(s.img,s.x,s.y),s.img.src=""}else s.img._noVNCDisplay=this,s.img.addEventListener("load",this._resumeRenderQ),e=!1;break;case"frame":if(s.frame.ready){let n=s.frame.frame;(n.codedWidth<s.width||n.codedHeight<s.height)&&Wt("Decoded video frame does not cover its full rectangle area. Expecting at least "+s.width+"x"+s.height+" but got "+n.codedWidth+"x"+n.codedHeight);const a=0,i=0,r=s.width,o=s.height,d=s.x,l=s.y,u=r,_=o;this.drawImage(n,a,i,r,o,d,l,u,_),n.close()}else{let n=this;s.frame.promise.then(()=>{n._scanRenderQ()}),e=!1}break}e&&this._renderQ.shift()}this._renderQ.length===0&&this._flushPromise!==null&&(this._flushResolve(),this._flushPromise=null,this._flushResolve=null)}}function sn(t,e,s,n,a){if(e.subarray&&t.subarray){t.set(e.subarray(s,s+n),a);return}for(var i=0;i<n;i++)t[a+i]=e[s+i]}var gi=Uint8Array,hs=Uint16Array,xi=Int32Array;function Fr(t,e,s,n){for(var a=t&65535|0,i=t>>>16&65535|0,r=0;s!==0;){r=s>2e3?2e3:s,s-=r;do a=a+e[n++]|0,i=i+a|0;while(--r);a%=65521,i%=65521}return a|i<<16|0}function At(){for(var t,e=[],s=0;s<256;s++){t=s;for(var n=0;n<8;n++)t=t&1?3988292384^t>>>1:t>>>1;e[s]=t}return e}At();var $a=30,sf=12;function nf(t,e){var s,n,a,i,r,o,d,l,u,_,p,v,x,y,w,S,C,K,E,U,te,T,A,X,L;s=t.state,n=t.next_in,X=t.input,a=n+(t.avail_in-5),i=t.next_out,L=t.output,r=i-(e-t.avail_out),o=i+(t.avail_out-257),d=s.dmax,l=s.wsize,u=s.whave,_=s.wnext,p=s.window,v=s.hold,x=s.bits,y=s.lencode,w=s.distcode,S=(1<<s.lenbits)-1,C=(1<<s.distbits)-1;e:do{x<15&&(v+=X[n++]<<x,x+=8,v+=X[n++]<<x,x+=8),K=y[v&S];t:for(;;){if(E=K>>>24,v>>>=E,x-=E,E=K>>>16&255,E===0)L[i++]=K&65535;else if(E&16){U=K&65535,E&=15,E&&(x<E&&(v+=X[n++]<<x,x+=8),U+=v&(1<<E)-1,v>>>=E,x-=E),x<15&&(v+=X[n++]<<x,x+=8,v+=X[n++]<<x,x+=8),K=w[v&C];s:for(;;){if(E=K>>>24,v>>>=E,x-=E,E=K>>>16&255,E&16){if(te=K&65535,E&=15,x<E&&(v+=X[n++]<<x,x+=8,x<E&&(v+=X[n++]<<x,x+=8)),te+=v&(1<<E)-1,te>d){t.msg="invalid distance too far back",s.mode=$a;break e}if(v>>>=E,x-=E,E=i-r,te>E){if(E=te-E,E>u&&s.sane){t.msg="invalid distance too far back",s.mode=$a;break e}if(T=0,A=p,_===0){if(T+=l-E,E<U){U-=E;do L[i++]=p[T++];while(--E);T=i-te,A=L}}else if(_<E){if(T+=l+_-E,E-=_,E<U){U-=E;do L[i++]=p[T++];while(--E);if(T=0,_<U){E=_,U-=E;do L[i++]=p[T++];while(--E);T=i-te,A=L}}}else if(T+=_-E,E<U){U-=E;do L[i++]=p[T++];while(--E);T=i-te,A=L}for(;U>2;)L[i++]=A[T++],L[i++]=A[T++],L[i++]=A[T++],U-=3;U&&(L[i++]=A[T++],U>1&&(L[i++]=A[T++]))}else{T=i-te;do L[i++]=L[T++],L[i++]=L[T++],L[i++]=L[T++],U-=3;while(U>2);U&&(L[i++]=L[T++],U>1&&(L[i++]=L[T++]))}}else if((E&64)===0){K=w[(K&65535)+(v&(1<<E)-1)];continue s}else{t.msg="invalid distance code",s.mode=$a;break e}break}}else if((E&64)===0){K=y[(K&65535)+(v&(1<<E)-1)];continue t}else if(E&32){s.mode=sf;break e}else{t.msg="invalid literal/length code",s.mode=$a;break e}break}}while(n<a&&i<o);U=x>>3,n-=U,x-=U<<3,v&=(1<<x)-1,t.next_in=n,t.next_out=i,t.avail_in=n<a?5+(a-n):5-(n-a),t.avail_out=i<o?257+(o-i):257-(i-o),s.hold=v,s.bits=x}var Vn=15,yo=852,ko=592,So=0,Oi=1,Co=2,af=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],rf=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],of=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],lf=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];function Ka(t,e,s,n,a,i,r,o){var d=o.bits,l=0,u=0,_=0,p=0,v=0,x=0,y=0,w=0,S=0,C=0,K,E,U,te,T,A=null,X=0,L,se=new hs(Vn+1),oe=new hs(Vn+1),de=null,$=0,H,ne,ae;for(l=0;l<=Vn;l++)se[l]=0;for(u=0;u<n;u++)se[e[s+u]]++;for(v=d,p=Vn;p>=1&&se[p]===0;p--);if(v>p&&(v=p),p===0)return a[i++]=1<<24|64<<16|0,a[i++]=1<<24|64<<16|0,o.bits=1,0;for(_=1;_<p&&se[_]===0;_++);for(v<_&&(v=_),w=1,l=1;l<=Vn;l++)if(w<<=1,w-=se[l],w<0)return-1;if(w>0&&(t===So||p!==1))return-1;for(oe[1]=0,l=1;l<Vn;l++)oe[l+1]=oe[l]+se[l];for(u=0;u<n;u++)e[s+u]!==0&&(r[oe[e[s+u]]++]=u);if(t===So?(A=de=r,L=19):t===Oi?(A=af,X-=257,de=rf,$-=257,L=256):(A=of,de=lf,L=-1),C=0,u=0,l=_,T=i,x=v,y=0,U=-1,S=1<<v,te=S-1,t===Oi&&S>yo||t===Co&&S>ko)return 1;for(;;){H=l-y,r[u]<L?(ne=0,ae=r[u]):r[u]>L?(ne=de[$+r[u]],ae=A[X+r[u]]):(ne=96,ae=0),K=1<<l-y,E=1<<x,_=E;do E-=K,a[T+(C>>y)+E]=H<<24|ne<<16|ae|0;while(E!==0);for(K=1<<l-1;C&K;)K>>=1;if(K!==0?(C&=K-1,C+=K):C=0,u++,--se[l]===0){if(l===p)break;l=e[s+r[u]]}if(l>v&&(C&te)!==U){for(y===0&&(y=v),T+=_,x=l-y,w=1<<x;x+y<p&&(w-=se[x+y],!(w<=0));)x++,w<<=1;if(S+=1<<x,t===Oi&&S>yo||t===Co&&S>ko)return 1;U=C&te,a[U]=v<<24|x<<16|T-i|0}}return C!==0&&(a[T+C]=l-y<<24|64<<16|0),o.bits=v,0}var cf=0,Yc=1,Zc=2;const Eo=4,bi=0,df=1,uf=2,Hn=-2,hf=-3,ff=-4,_f=-5,Ao=8;var Jc=1,Ko=2,Fo=3,To=4,Mo=5,Xo=6,Lo=7,Po=8,Bo=9,Do=10,Ro=11,qs=12,Vi=13,Io=14,Gi=15,Qo=16,No=17,Uo=18,Ho=19,ei=20,ti=21,zo=22,Oo=23,Vo=24,Go=25,qo=26,qi=27,Wo=28,jo=29,it=30,vf=31,pf=32,gf=852,xf=592,bf=15,mf=bf;function Yo(t){return(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24)}function wf(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new hs(320),this.work=new hs(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function yf(t){var e;return!t||!t.state?Hn:(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=e.wrap&1),e.mode=Jc,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new xi(gf),e.distcode=e.distdyn=new xi(xf),e.sane=1,e.back=-1,bi)}function $c(t){var e;return!t||!t.state?Hn:(e=t.state,e.wsize=0,e.whave=0,e.wnext=0,yf(t))}function kf(t,e){var s,n;return!t||!t.state||(n=t.state,e<0?(s=0,e=-e):(s=(e>>4)+1,e<48&&(e&=15)),e&&(e<8||e>15))?Hn:(n.window!==null&&n.wbits!==e&&(n.window=null),n.wrap=s,n.wbits=e,$c(t))}function Sf(t,e){var s,n;return t?(n=new wf,t.state=n,n.window=null,s=kf(t,e),s!==bi&&(t.state=null),s):Hn}function Cf(t){return Sf(t,mf)}var Zo=!0,Wi,ji;function Ef(t){if(Zo){var e;for(Wi=new xi(512),ji=new xi(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(Ka(Yc,t.lens,0,288,Wi,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;Ka(Zc,t.lens,0,32,ji,0,t.work,{bits:5}),Zo=!1}t.lencode=Wi,t.lenbits=9,t.distcode=ji,t.distbits=5}function Af(t,e,s,n){var a,i=t.state;return i.window===null&&(i.wsize=1<<i.wbits,i.wnext=0,i.whave=0,i.window=new gi(i.wsize)),n>=i.wsize?(sn(i.window,e,s-i.wsize,i.wsize,0),i.wnext=0,i.whave=i.wsize):(a=i.wsize-i.wnext,a>n&&(a=n),sn(i.window,e,s-n,a,i.wnext),n-=a,n?(sn(i.window,e,s-n,n,0),i.wnext=n,i.whave=i.wsize):(i.wnext+=a,i.wnext===i.wsize&&(i.wnext=0),i.whave<i.wsize&&(i.whave+=a))),0}function Kf(t,e){var s,n,a,i,r,o,d,l,u,_,p,v,x,y,w=0,S,C,K,E,U,te,T,A,X=new gi(4),L,se,oe=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!t||!t.state||!t.output||!t.input&&t.avail_in!==0)return Hn;s=t.state,s.mode===qs&&(s.mode=Vi),r=t.next_out,a=t.output,d=t.avail_out,i=t.next_in,n=t.input,o=t.avail_in,l=s.hold,u=s.bits,_=o,p=d,A=bi;e:for(;;)switch(s.mode){case Jc:if(s.wrap===0){s.mode=Vi;break}for(;u<16;){if(o===0)break e;o--,l+=n[i++]<<u,u+=8}if(s.wrap&2&&l===35615){s.check=0,X[0]=l&255,X[1]=l>>>8&255,s.check=At(s.check),l=0,u=0,s.mode=Ko;break}if(s.flags=0,s.head&&(s.head.done=!1),!(s.wrap&1)||(((l&255)<<8)+(l>>8))%31){t.msg="incorrect header check",s.mode=it;break}if((l&15)!==Ao){t.msg="unknown compression method",s.mode=it;break}if(l>>>=4,u-=4,T=(l&15)+8,s.wbits===0)s.wbits=T;else if(T>s.wbits){t.msg="invalid window size",s.mode=it;break}s.dmax=1<<T,t.adler=s.check=1,s.mode=l&512?Do:qs,l=0,u=0;break;case Ko:for(;u<16;){if(o===0)break e;o--,l+=n[i++]<<u,u+=8}if(s.flags=l,(s.flags&255)!==Ao){t.msg="unknown compression method",s.mode=it;break}if(s.flags&57344){t.msg="unknown header flags set",s.mode=it;break}s.head&&(s.head.text=l>>8&1),s.flags&512&&(X[0]=l&255,X[1]=l>>>8&255,s.check=At(s.check)),l=0,u=0,s.mode=Fo;case Fo:for(;u<32;){if(o===0)break e;o--,l+=n[i++]<<u,u+=8}s.head&&(s.head.time=l),s.flags&512&&(X[0]=l&255,X[1]=l>>>8&255,X[2]=l>>>16&255,X[3]=l>>>24&255,s.check=At(s.check)),l=0,u=0,s.mode=To;case To:for(;u<16;){if(o===0)break e;o--,l+=n[i++]<<u,u+=8}s.head&&(s.head.xflags=l&255,s.head.os=l>>8),s.flags&512&&(X[0]=l&255,X[1]=l>>>8&255,s.check=At(s.check)),l=0,u=0,s.mode=Mo;case Mo:if(s.flags&1024){for(;u<16;){if(o===0)break e;o--,l+=n[i++]<<u,u+=8}s.length=l,s.head&&(s.head.extra_len=l),s.flags&512&&(X[0]=l&255,X[1]=l>>>8&255,s.check=At(s.check)),l=0,u=0}else s.head&&(s.head.extra=null);s.mode=Xo;case Xo:if(s.flags&1024&&(v=s.length,v>o&&(v=o),v&&(s.head&&(T=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Array(s.head.extra_len)),sn(s.head.extra,n,i,v,T)),s.flags&512&&(s.check=At(s.check)),o-=v,i+=v,s.length-=v),s.length))break e;s.length=0,s.mode=Lo;case Lo:if(s.flags&2048){if(o===0)break e;v=0;do T=n[i+v++],s.head&&T&&s.length<65536&&(s.head.name+=String.fromCharCode(T));while(T&&v<o);if(s.flags&512&&(s.check=At(s.check)),o-=v,i+=v,T)break e}else s.head&&(s.head.name=null);s.length=0,s.mode=Po;case Po:if(s.flags&4096){if(o===0)break e;v=0;do T=n[i+v++],s.head&&T&&s.length<65536&&(s.head.comment+=String.fromCharCode(T));while(T&&v<o);if(s.flags&512&&(s.check=At(s.check)),o-=v,i+=v,T)break e}else s.head&&(s.head.comment=null);s.mode=Bo;case Bo:if(s.flags&512){for(;u<16;){if(o===0)break e;o--,l+=n[i++]<<u,u+=8}if(l!==(s.check&65535)){t.msg="header crc mismatch",s.mode=it;break}l=0,u=0}s.head&&(s.head.hcrc=s.flags>>9&1,s.head.done=!0),t.adler=s.check=0,s.mode=qs;break;case Do:for(;u<32;){if(o===0)break e;o--,l+=n[i++]<<u,u+=8}t.adler=s.check=Yo(l),l=0,u=0,s.mode=Ro;case Ro:if(s.havedict===0)return t.next_out=r,t.avail_out=d,t.next_in=i,t.avail_in=o,s.hold=l,s.bits=u,uf;t.adler=s.check=1,s.mode=qs;case qs:case Vi:if(s.last){l>>>=u&7,u-=u&7,s.mode=qi;break}for(;u<3;){if(o===0)break e;o--,l+=n[i++]<<u,u+=8}switch(s.last=l&1,l>>>=1,u-=1,l&3){case 0:s.mode=Io;break;case 1:Ef(s),s.mode=ei;break;case 2:s.mode=No;break;case 3:t.msg="invalid block type",s.mode=it}l>>>=2,u-=2;break;case Io:for(l>>>=u&7,u-=u&7;u<32;){if(o===0)break e;o--,l+=n[i++]<<u,u+=8}if((l&65535)!==(l>>>16^65535)){t.msg="invalid stored block lengths",s.mode=it;break}s.length=l&65535,l=0,u=0,s.mode=Gi;case Gi:s.mode=Qo;case Qo:if(v=s.length,v){if(v>o&&(v=o),v>d&&(v=d),v===0)break e;sn(a,n,i,v,r),o-=v,i+=v,d-=v,r+=v,s.length-=v;break}s.mode=qs;break;case No:for(;u<14;){if(o===0)break e;o--,l+=n[i++]<<u,u+=8}if(s.nlen=(l&31)+257,l>>>=5,u-=5,s.ndist=(l&31)+1,l>>>=5,u-=5,s.ncode=(l&15)+4,l>>>=4,u-=4,s.nlen>286||s.ndist>30){t.msg="too many length or distance symbols",s.mode=it;break}s.have=0,s.mode=Uo;case Uo:for(;s.have<s.ncode;){for(;u<3;){if(o===0)break e;o--,l+=n[i++]<<u,u+=8}s.lens[oe[s.have++]]=l&7,l>>>=3,u-=3}for(;s.have<19;)s.lens[oe[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,L={bits:s.lenbits},A=Ka(cf,s.lens,0,19,s.lencode,0,s.work,L),s.lenbits=L.bits,A){t.msg="invalid code lengths set",s.mode=it;break}s.have=0,s.mode=Ho;case Ho:for(;s.have<s.nlen+s.ndist;){for(;w=s.lencode[l&(1<<s.lenbits)-1],S=w>>>24,C=w>>>16&255,K=w&65535,!(S<=u);){if(o===0)break e;o--,l+=n[i++]<<u,u+=8}if(K<16)l>>>=S,u-=S,s.lens[s.have++]=K;else{if(K===16){for(se=S+2;u<se;){if(o===0)break e;o--,l+=n[i++]<<u,u+=8}if(l>>>=S,u-=S,s.have===0){t.msg="invalid bit length repeat",s.mode=it;break}T=s.lens[s.have-1],v=3+(l&3),l>>>=2,u-=2}else if(K===17){for(se=S+3;u<se;){if(o===0)break e;o--,l+=n[i++]<<u,u+=8}l>>>=S,u-=S,T=0,v=3+(l&7),l>>>=3,u-=3}else{for(se=S+7;u<se;){if(o===0)break e;o--,l+=n[i++]<<u,u+=8}l>>>=S,u-=S,T=0,v=11+(l&127),l>>>=7,u-=7}if(s.have+v>s.nlen+s.ndist){t.msg="invalid bit length repeat",s.mode=it;break}for(;v--;)s.lens[s.have++]=T}}if(s.mode===it)break;if(s.lens[256]===0){t.msg="invalid code -- missing end-of-block",s.mode=it;break}if(s.lenbits=9,L={bits:s.lenbits},A=Ka(Yc,s.lens,0,s.nlen,s.lencode,0,s.work,L),s.lenbits=L.bits,A){t.msg="invalid literal/lengths set",s.mode=it;break}if(s.distbits=6,s.distcode=s.distdyn,L={bits:s.distbits},A=Ka(Zc,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,L),s.distbits=L.bits,A){t.msg="invalid distances set",s.mode=it;break}s.mode=ei;case ei:s.mode=ti;case ti:if(o>=6&&d>=258){t.next_out=r,t.avail_out=d,t.next_in=i,t.avail_in=o,s.hold=l,s.bits=u,nf(t,p),r=t.next_out,a=t.output,d=t.avail_out,i=t.next_in,n=t.input,o=t.avail_in,l=s.hold,u=s.bits,s.mode===qs&&(s.back=-1);break}for(s.back=0;w=s.lencode[l&(1<<s.lenbits)-1],S=w>>>24,C=w>>>16&255,K=w&65535,!(S<=u);){if(o===0)break e;o--,l+=n[i++]<<u,u+=8}if(C&&(C&240)===0){for(E=S,U=C,te=K;w=s.lencode[te+((l&(1<<E+U)-1)>>E)],S=w>>>24,C=w>>>16&255,K=w&65535,!(E+S<=u);){if(o===0)break e;o--,l+=n[i++]<<u,u+=8}l>>>=E,u-=E,s.back+=E}if(l>>>=S,u-=S,s.back+=S,s.length=K,C===0){s.mode=qo;break}if(C&32){s.back=-1,s.mode=qs;break}if(C&64){t.msg="invalid literal/length code",s.mode=it;break}s.extra=C&15,s.mode=zo;case zo:if(s.extra){for(se=s.extra;u<se;){if(o===0)break e;o--,l+=n[i++]<<u,u+=8}s.length+=l&(1<<s.extra)-1,l>>>=s.extra,u-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=Oo;case Oo:for(;w=s.distcode[l&(1<<s.distbits)-1],S=w>>>24,C=w>>>16&255,K=w&65535,!(S<=u);){if(o===0)break e;o--,l+=n[i++]<<u,u+=8}if((C&240)===0){for(E=S,U=C,te=K;w=s.distcode[te+((l&(1<<E+U)-1)>>E)],S=w>>>24,C=w>>>16&255,K=w&65535,!(E+S<=u);){if(o===0)break e;o--,l+=n[i++]<<u,u+=8}l>>>=E,u-=E,s.back+=E}if(l>>>=S,u-=S,s.back+=S,C&64){t.msg="invalid distance code",s.mode=it;break}s.offset=K,s.extra=C&15,s.mode=Vo;case Vo:if(s.extra){for(se=s.extra;u<se;){if(o===0)break e;o--,l+=n[i++]<<u,u+=8}s.offset+=l&(1<<s.extra)-1,l>>>=s.extra,u-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){t.msg="invalid distance too far back",s.mode=it;break}s.mode=Go;case Go:if(d===0)break e;if(v=p-d,s.offset>v){if(v=s.offset-v,v>s.whave&&s.sane){t.msg="invalid distance too far back",s.mode=it;break}v>s.wnext?(v-=s.wnext,x=s.wsize-v):x=s.wnext-v,v>s.length&&(v=s.length),y=s.window}else y=a,x=r-s.offset,v=s.length;v>d&&(v=d),d-=v,s.length-=v;do a[r++]=y[x++];while(--v);s.length===0&&(s.mode=ti);break;case qo:if(d===0)break e;a[r++]=s.length,d--,s.mode=ti;break;case qi:if(s.wrap){for(;u<32;){if(o===0)break e;o--,l|=n[i++]<<u,u+=8}if(p-=d,t.total_out+=p,s.total+=p,p&&(t.adler=s.check=s.flags?At(s.check):Fr(s.check,a,p,r-p)),p=d,(s.flags?l:Yo(l))!==s.check){t.msg="incorrect data check",s.mode=it;break}l=0,u=0}s.mode=Wo;case Wo:if(s.wrap&&s.flags){for(;u<32;){if(o===0)break e;o--,l+=n[i++]<<u,u+=8}if(l!==(s.total&4294967295)){t.msg="incorrect length check",s.mode=it;break}l=0,u=0}s.mode=jo;case jo:A=df;break e;case it:A=hf;break e;case vf:return ff;case pf:default:return Hn}return t.next_out=r,t.avail_out=d,t.next_in=i,t.avail_in=o,s.hold=l,s.bits=u,(s.wsize||p!==t.avail_out&&s.mode<it&&(s.mode<qi||e!==Eo))&&Af(t,t.output,t.next_out,p-t.avail_out),_-=t.avail_in,p-=t.avail_out,t.total_in+=_,t.total_out+=p,s.total+=p,s.wrap&&p&&(t.adler=s.check=s.flags?At(s.check,a,p,t.next_out-p):Fr(s.check,a,p,t.next_out-p)),t.data_type=s.bits+(s.last?64:0)+(s.mode===qs?128:0)+(s.mode===ei||s.mode===Gi?256:0),(_===0&&p===0||e===Eo)&&A===bi&&(A=_f),A}function ed(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}class Xi{constructor(){this.strm=new ed,this.chunkSize=1024*10*10,this.strm.output=new Uint8Array(this.chunkSize),Cf(this.strm)}setInput(e){e?(this.strm.input=e,this.strm.avail_in=this.strm.input.length,this.strm.next_in=0):(this.strm.input=null,this.strm.avail_in=0,this.strm.next_in=0)}inflate(e){if(e>this.chunkSize&&(this.chunkSize=e,this.strm.output=new Uint8Array(this.chunkSize)),this.strm.next_out=0,this.strm.avail_out=e,Kf(this.strm,0)<0)throw new Error("zlib inflate failed");if(this.strm.next_out!=e)throw new Error("Incomplete zlib block");return new Uint8Array(this.strm.output.buffer,0,this.strm.next_out)}reset(){$c(this.strm)}}var Ff=4,Jo=0,$o=1,Tf=2;function la(t){for(var e=t.length;--e>=0;)t[e]=0}var Mf=0,Xf=1,Lf=2,Pf=3,Bf=258,qr=29,Va=256,Xa=Va+1+qr,$n=30,Wr=19,td=2*Xa+1,Ln=15,Yi=16,Df=7,sd=256,nd=16,ad=17,id=18,Tr=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ui=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Rf=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],rd=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],If=512,cn=new Array((Xa+2)*2);la(cn);var Fa=new Array($n*2);la(Fa);var La=new Array(If);la(La);var Pa=new Array(Bf-Pf+1);la(Pa);var jr=new Array(qr);la(jr);var mi=new Array($n);la(mi);function Zi(t,e,s,n,a){this.static_tree=t,this.extra_bits=e,this.extra_base=s,this.elems=n,this.max_length=a,this.has_stree=t&&t.length}var od,ld,cd;function Ji(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function dd(t){return t<256?La[t]:La[256+(t>>>7)]}function wi(t,e){t.pending_buf[t.pending++]=e&255,t.pending_buf[t.pending++]=e>>>8&255}function rs(t,e,s){t.bi_valid>Yi-s?(t.bi_buf|=e<<t.bi_valid&65535,wi(t,t.bi_buf),t.bi_buf=e>>Yi-t.bi_valid,t.bi_valid+=s-Yi):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=s)}function Ys(t,e,s){rs(t,s[e*2],s[e*2+1])}function ud(t,e){var s=0;do s|=t&1,t>>>=1,s<<=1;while(--e>0);return s>>>1}function Qf(t,e){var s=e.dyn_tree,n=e.max_code,a=e.stat_desc.static_tree,i=e.stat_desc.has_stree,r=e.stat_desc.extra_bits,o=e.stat_desc.extra_base,d=e.stat_desc.max_length,l,u,_,p,v,x,y=0;for(p=0;p<=Ln;p++)t.bl_count[p]=0;for(s[t.heap[t.heap_max]*2+1]=0,l=t.heap_max+1;l<td;l++)u=t.heap[l],p=s[s[u*2+1]*2+1]+1,p>d&&(p=d,y++),s[u*2+1]=p,!(u>n)&&(t.bl_count[p]++,v=0,u>=o&&(v=r[u-o]),x=s[u*2],t.opt_len+=x*(p+v),i&&(t.static_len+=x*(a[u*2+1]+v)));if(y!==0){do{for(p=d-1;t.bl_count[p]===0;)p--;t.bl_count[p]--,t.bl_count[p+1]+=2,t.bl_count[d]--,y-=2}while(y>0);for(p=d;p!==0;p--)for(u=t.bl_count[p];u!==0;)_=t.heap[--l],!(_>n)&&(s[_*2+1]!==p&&(t.opt_len+=(p-s[_*2+1])*s[_*2],s[_*2+1]=p),u--)}}function hd(t,e,s){var n=new Array(Ln+1),a=0,i,r;for(i=1;i<=Ln;i++)n[i]=a=a+s[i-1]<<1;for(r=0;r<=e;r++){var o=t[r*2+1];o!==0&&(t[r*2]=ud(n[o]++,o))}}function Nf(){var t,e,s,n,a,i=new Array(Ln+1);for(s=0,n=0;n<qr-1;n++)for(jr[n]=s,t=0;t<1<<Tr[n];t++)Pa[s++]=n;for(Pa[s-1]=n,a=0,n=0;n<16;n++)for(mi[n]=a,t=0;t<1<<ui[n];t++)La[a++]=n;for(a>>=7;n<$n;n++)for(mi[n]=a<<7,t=0;t<1<<ui[n]-7;t++)La[256+a++]=n;for(e=0;e<=Ln;e++)i[e]=0;for(t=0;t<=143;)cn[t*2+1]=8,t++,i[8]++;for(;t<=255;)cn[t*2+1]=9,t++,i[9]++;for(;t<=279;)cn[t*2+1]=7,t++,i[7]++;for(;t<=287;)cn[t*2+1]=8,t++,i[8]++;for(hd(cn,Xa+1,i),t=0;t<$n;t++)Fa[t*2+1]=5,Fa[t*2]=ud(t,5);od=new Zi(cn,Tr,Va+1,Xa,Ln),ld=new Zi(Fa,ui,0,$n,Ln),cd=new Zi(new Array(0),Rf,0,Wr,Df)}function fd(t){var e;for(e=0;e<Xa;e++)t.dyn_ltree[e*2]=0;for(e=0;e<$n;e++)t.dyn_dtree[e*2]=0;for(e=0;e<Wr;e++)t.bl_tree[e*2]=0;t.dyn_ltree[sd*2]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0}function _d(t){t.bi_valid>8?wi(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function Uf(t,e,s,n){_d(t),wi(t,s),wi(t,~s),sn(t.pending_buf,t.window,e,s,t.pending),t.pending+=s}function el(t,e,s,n){var a=e*2,i=s*2;return t[a]<t[i]||t[a]===t[i]&&n[e]<=n[s]}function $i(t,e,s){for(var n=t.heap[s],a=s<<1;a<=t.heap_len&&(a<t.heap_len&&el(e,t.heap[a+1],t.heap[a],t.depth)&&a++,!el(e,n,t.heap[a],t.depth));)t.heap[s]=t.heap[a],s=a,a<<=1;t.heap[s]=n}function tl(t,e,s){var n,a,i=0,r,o;if(t.last_lit!==0)do n=t.pending_buf[t.d_buf+i*2]<<8|t.pending_buf[t.d_buf+i*2+1],a=t.pending_buf[t.l_buf+i],i++,n===0?Ys(t,a,e):(r=Pa[a],Ys(t,r+Va+1,e),o=Tr[r],o!==0&&(a-=jr[r],rs(t,a,o)),n--,r=dd(n),Ys(t,r,s),o=ui[r],o!==0&&(n-=mi[r],rs(t,n,o)));while(i<t.last_lit);Ys(t,sd,e)}function Mr(t,e){var s=e.dyn_tree,n=e.stat_desc.static_tree,a=e.stat_desc.has_stree,i=e.stat_desc.elems,r,o,d=-1,l;for(t.heap_len=0,t.heap_max=td,r=0;r<i;r++)s[r*2]!==0?(t.heap[++t.heap_len]=d=r,t.depth[r]=0):s[r*2+1]=0;for(;t.heap_len<2;)l=t.heap[++t.heap_len]=d<2?++d:0,s[l*2]=1,t.depth[l]=0,t.opt_len--,a&&(t.static_len-=n[l*2+1]);for(e.max_code=d,r=t.heap_len>>1;r>=1;r--)$i(t,s,r);l=i;do r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],$i(t,s,1),o=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=o,s[l*2]=s[r*2]+s[o*2],t.depth[l]=(t.depth[r]>=t.depth[o]?t.depth[r]:t.depth[o])+1,s[r*2+1]=s[o*2+1]=l,t.heap[1]=l++,$i(t,s,1);while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],Qf(t,e),hd(s,d,t.bl_count)}function sl(t,e,s){var n,a=-1,i,r=e[1],o=0,d=7,l=4;for(r===0&&(d=138,l=3),e[(s+1)*2+1]=65535,n=0;n<=s;n++)i=r,r=e[(n+1)*2+1],!(++o<d&&i===r)&&(o<l?t.bl_tree[i*2]+=o:i!==0?(i!==a&&t.bl_tree[i*2]++,t.bl_tree[nd*2]++):o<=10?t.bl_tree[ad*2]++:t.bl_tree[id*2]++,o=0,a=i,r===0?(d=138,l=3):i===r?(d=6,l=3):(d=7,l=4))}function nl(t,e,s){var n,a=-1,i,r=e[1],o=0,d=7,l=4;for(r===0&&(d=138,l=3),n=0;n<=s;n++)if(i=r,r=e[(n+1)*2+1],!(++o<d&&i===r)){if(o<l)do Ys(t,i,t.bl_tree);while(--o!==0);else i!==0?(i!==a&&(Ys(t,i,t.bl_tree),o--),Ys(t,nd,t.bl_tree),rs(t,o-3,2)):o<=10?(Ys(t,ad,t.bl_tree),rs(t,o-3,3)):(Ys(t,id,t.bl_tree),rs(t,o-11,7));o=0,a=i,r===0?(d=138,l=3):i===r?(d=6,l=3):(d=7,l=4)}}function Hf(t){var e;for(sl(t,t.dyn_ltree,t.l_desc.max_code),sl(t,t.dyn_dtree,t.d_desc.max_code),Mr(t,t.bl_desc),e=Wr-1;e>=3&&t.bl_tree[rd[e]*2+1]===0;e--);return t.opt_len+=3*(e+1)+5+5+4,e}function zf(t,e,s,n){var a;for(rs(t,e-257,5),rs(t,s-1,5),rs(t,n-4,4),a=0;a<n;a++)rs(t,t.bl_tree[rd[a]*2+1],3);nl(t,t.dyn_ltree,e-1),nl(t,t.dyn_dtree,s-1)}function Of(t){var e=4093624447,s;for(s=0;s<=31;s++,e>>>=1)if(e&1&&t.dyn_ltree[s*2]!==0)return Jo;if(t.dyn_ltree[18]!==0||t.dyn_ltree[20]!==0||t.dyn_ltree[26]!==0)return $o;for(s=32;s<Va;s++)if(t.dyn_ltree[s*2]!==0)return $o;return Jo}var al=!1;function Vf(t){al||(Nf(),al=!0),t.l_desc=new Ji(t.dyn_ltree,od),t.d_desc=new Ji(t.dyn_dtree,ld),t.bl_desc=new Ji(t.bl_tree,cd),t.bi_buf=0,t.bi_valid=0,fd(t)}function vd(t,e,s,n){rs(t,(Mf<<1)+(n?1:0),3),Uf(t,e,s)}function Gf(t,e,s,n){var a,i,r=0;t.level>0?(t.strm.data_type===Tf&&(t.strm.data_type=Of(t)),Mr(t,t.l_desc),Mr(t,t.d_desc),r=Hf(t),a=t.opt_len+3+7>>>3,i=t.static_len+3+7>>>3,i<=a&&(a=i)):a=i=s+5,s+4<=a&&e!==-1?vd(t,e,s,n):t.strategy===Ff||i===a?(rs(t,(Xf<<1)+(n?1:0),3),tl(t,cn,Fa)):(rs(t,(Lf<<1)+(n?1:0),3),zf(t,t.l_desc.max_code+1,t.d_desc.max_code+1,r+1),tl(t,t.dyn_ltree,t.dyn_dtree)),fd(t),n&&_d(t)}function bn(t,e,s){return t.pending_buf[t.d_buf+t.last_lit*2]=e>>>8&255,t.pending_buf[t.d_buf+t.last_lit*2+1]=e&255,t.pending_buf[t.l_buf+t.last_lit]=s&255,t.last_lit++,e===0?t.dyn_ltree[s*2]++:(t.matches++,e--,t.dyn_ltree[(Pa[s]+Va+1)*2]++,t.dyn_dtree[dd(e)*2]++),t.last_lit===t.lit_bufsize-1}const qf={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Ga=0,il=3,Ba=4,Wf=5,jn=0,ea=-2,er=-5,pd=-1,jf=1,si=2,Yf=3,Zf=4,Jf=0,$f=2,Yr=8;var e_=15,t_=8,s_=29,n_=256,Xr=n_+1+s_,a_=30,i_=19,r_=2*Xr+1,o_=15,Ue=3,hn=258,As=hn+Ue+1,l_=32,gd=42,rl=69,tr=73,sr=91,nr=103,ya=113,ni=666,Rt=1,qa=2,Da=3,Li=4,c_=3;function Yn(t,e){return t.msg=qf[e],e}function ol(t){return(t<<1)-(t>4?9:0)}function Kn(t){for(var e=t.length;--e>=0;)t[e]=0}function En(t){var e=t.state,s=e.pending;s>t.avail_out&&(s=t.avail_out),s!==0&&(sn(t.output,e.pending_buf,e.pending_out,s,t.next_out),t.next_out+=s,e.pending_out+=s,t.total_out+=s,t.avail_out-=s,e.pending-=s,e.pending===0&&(e.pending_out=0))}function Yt(t,e){Gf(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,En(t.strm)}function rt(t,e){t.pending_buf[t.pending++]=e}function ar(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=e&255}function d_(t,e,s,n){var a=t.avail_in;return a>n&&(a=n),a===0?0:(t.avail_in-=a,sn(e,t.input,t.next_in,a,s),t.state.wrap===1?t.adler=Fr(t.adler,e,a,s):t.state.wrap===2&&(t.adler=At(t.adler)),t.next_in+=a,t.total_in+=a,a)}function xd(t,e){var s=t.max_chain_length,n=t.strstart,a,i,r=t.prev_length,o=t.nice_match,d=t.strstart>t.w_size-As?t.strstart-(t.w_size-As):0,l=t.window,u=t.w_mask,_=t.prev,p=t.strstart+hn,v=l[n+r-1],x=l[n+r];t.prev_length>=t.good_match&&(s>>=2),o>t.lookahead&&(o=t.lookahead);do if(a=e,!(l[a+r]!==x||l[a+r-1]!==v||l[a]!==l[n]||l[++a]!==l[n+1])){n+=2,a++;do;while(l[++n]===l[++a]&&l[++n]===l[++a]&&l[++n]===l[++a]&&l[++n]===l[++a]&&l[++n]===l[++a]&&l[++n]===l[++a]&&l[++n]===l[++a]&&l[++n]===l[++a]&&n<p);if(i=hn-(p-n),n=p-hn,i>r){if(t.match_start=e,r=i,i>=o)break;v=l[n+r-1],x=l[n+r]}}while((e=_[e&u])>d&&--s!==0);return r<=t.lookahead?r:t.lookahead}function Wa(t){var e=t.w_size,s,n,a,i,r;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-As)){sn(t.window,t.window,e,e,0),t.match_start-=e,t.strstart-=e,t.block_start-=e,n=t.hash_size,s=n;do a=t.head[--s],t.head[s]=a>=e?a-e:0;while(--n);n=e,s=n;do a=t.prev[--s],t.prev[s]=a>=e?a-e:0;while(--n);i+=e}if(t.strm.avail_in===0)break;if(n=d_(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=n,t.lookahead+t.insert>=Ue)for(r=t.strstart-t.insert,t.ins_h=t.window[r],t.ins_h=(t.ins_h<<t.hash_shift^t.window[r+1])&t.hash_mask;t.insert&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[r+Ue-1])&t.hash_mask,t.prev[r&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=r,r++,t.insert--,!(t.lookahead+t.insert<Ue)););}while(t.lookahead<As&&t.strm.avail_in!==0)}function u_(t,e){var s=65535;for(s>t.pending_buf_size-5&&(s=t.pending_buf_size-5);;){if(t.lookahead<=1){if(Wa(t),t.lookahead===0&&e===Ga)return Rt;if(t.lookahead===0)break}t.strstart+=t.lookahead,t.lookahead=0;var n=t.block_start+s;if((t.strstart===0||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,Yt(t,!1),t.strm.avail_out===0)||t.strstart-t.block_start>=t.w_size-As&&(Yt(t,!1),t.strm.avail_out===0))return Rt}return t.insert=0,e===Ba?(Yt(t,!0),t.strm.avail_out===0?Da:Li):(t.strstart>t.block_start&&(Yt(t,!1),t.strm.avail_out===0),Rt)}function ir(t,e){for(var s,n;;){if(t.lookahead<As){if(Wa(t),t.lookahead<As&&e===Ga)return Rt;if(t.lookahead===0)break}if(s=0,t.lookahead>=Ue&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+Ue-1])&t.hash_mask,s=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),s!==0&&t.strstart-s<=t.w_size-As&&(t.match_length=xd(t,s)),t.match_length>=Ue)if(n=bn(t,t.strstart-t.match_start,t.match_length-Ue),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=Ue){t.match_length--;do t.strstart++,t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+Ue-1])&t.hash_mask,s=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart;while(--t.match_length!==0);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+1])&t.hash_mask;else n=bn(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(Yt(t,!1),t.strm.avail_out===0))return Rt}return t.insert=t.strstart<Ue-1?t.strstart:Ue-1,e===Ba?(Yt(t,!0),t.strm.avail_out===0?Da:Li):t.last_lit&&(Yt(t,!1),t.strm.avail_out===0)?Rt:qa}function Gn(t,e){for(var s,n,a;;){if(t.lookahead<As){if(Wa(t),t.lookahead<As&&e===Ga)return Rt;if(t.lookahead===0)break}if(s=0,t.lookahead>=Ue&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+Ue-1])&t.hash_mask,s=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=Ue-1,s!==0&&t.prev_length<t.max_lazy_match&&t.strstart-s<=t.w_size-As&&(t.match_length=xd(t,s),t.match_length<=5&&(t.strategy===jf||t.match_length===Ue&&t.strstart-t.match_start>4096)&&(t.match_length=Ue-1)),t.prev_length>=Ue&&t.match_length<=t.prev_length){a=t.strstart+t.lookahead-Ue,n=bn(t,t.strstart-1-t.prev_match,t.prev_length-Ue),t.lookahead-=t.prev_length-1,t.prev_length-=2;do++t.strstart<=a&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+Ue-1])&t.hash_mask,s=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart);while(--t.prev_length!==0);if(t.match_available=0,t.match_length=Ue-1,t.strstart++,n&&(Yt(t,!1),t.strm.avail_out===0))return Rt}else if(t.match_available){if(n=bn(t,0,t.window[t.strstart-1]),n&&Yt(t,!1),t.strstart++,t.lookahead--,t.strm.avail_out===0)return Rt}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=bn(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<Ue-1?t.strstart:Ue-1,e===Ba?(Yt(t,!0),t.strm.avail_out===0?Da:Li):t.last_lit&&(Yt(t,!1),t.strm.avail_out===0)?Rt:qa}function h_(t,e){for(var s,n,a,i,r=t.window;!(t.lookahead<=hn&&(Wa(t),t.lookahead<=hn,t.lookahead===0));){if(t.match_length=0,t.lookahead>=Ue&&t.strstart>0&&(a=t.strstart-1,n=r[a],n===r[++a]&&n===r[++a]&&n===r[++a])){i=t.strstart+hn;do;while(n===r[++a]&&n===r[++a]&&n===r[++a]&&n===r[++a]&&n===r[++a]&&n===r[++a]&&n===r[++a]&&n===r[++a]&&a<i);t.match_length=hn-(i-a),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=Ue?(s=bn(t,1,t.match_length-Ue),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(s=bn(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),s&&(Yt(t,!1),t.strm.avail_out===0))return Rt}return t.insert=0,t.last_lit&&(Yt(t,!1),t.strm.avail_out===0)?Rt:qa}function f_(t,e){for(var s;!(t.lookahead===0&&(Wa(t),t.lookahead===0));)if(t.match_length=0,s=bn(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,s&&(Yt(t,!1),t.strm.avail_out===0))return Rt;return t.insert=0,t.last_lit&&(Yt(t,!1),t.strm.avail_out===0)?Rt:qa}function Rs(t,e,s,n,a){this.good_length=t,this.max_lazy=e,this.nice_length=s,this.max_chain=n,this.func=a}var Zn;Zn=[new Rs(0,0,0,0,u_),new Rs(4,4,8,4,ir),new Rs(4,5,16,8,ir),new Rs(4,6,32,32,ir),new Rs(4,4,16,16,Gn),new Rs(8,16,32,32,Gn),new Rs(8,16,128,128,Gn),new Rs(8,32,128,256,Gn),new Rs(32,128,258,1024,Gn),new Rs(32,258,258,4096,Gn)];function __(t){t.window_size=2*t.w_size,Kn(t.head),t.max_lazy_match=Zn[t.level].max_lazy,t.good_match=Zn[t.level].good_length,t.nice_match=Zn[t.level].nice_length,t.max_chain_length=Zn[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=Ue-1,t.match_available=0,t.ins_h=0}function v_(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Yr,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new hs(r_*2),this.dyn_dtree=new hs((2*a_+1)*2),this.bl_tree=new hs((2*i_+1)*2),Kn(this.dyn_ltree),Kn(this.dyn_dtree),Kn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new hs(o_+1),this.heap=new hs(2*Xr+1),Kn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new hs(2*Xr+1),Kn(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function p_(t){var e;return!t||!t.state?Yn(t,ea):(t.total_in=t.total_out=0,t.data_type=$f,e=t.state,e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?gd:ya,t.adler=e.wrap===2?0:1,e.last_flush=Ga,Vf(e),jn)}function g_(t){var e=p_(t);return e===jn&&__(t.state),e}function x_(t,e,s,n,a,i){if(!t)return ea;var r=1;if(e===pd&&(e=6),e<0||e>9||i<0||i>Zf)return Yn(t,ea);var o=new v_;return t.state=o,o.strm=t,o.wrap=r,o.gzhead=null,o.w_bits=n,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=a+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+Ue-1)/Ue),o.window=new gi(o.w_size*2),o.head=new hs(o.hash_size),o.prev=new hs(o.w_size),o.lit_bufsize=1<<a+6,o.pending_buf_size=o.lit_bufsize*4,o.pending_buf=new gi(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=3*o.lit_bufsize,o.level=e,o.strategy=i,o.method=s,g_(t)}function b_(t,e){return x_(t,e,Yr,e_,t_,Jf)}function ll(t,e){var s,n,a,i;if(!t||!t.state||e>Wf||e<0)return t?Yn(t,ea):ea;if(n=t.state,!t.output||!t.input&&t.avail_in!==0||n.status===ni&&e!==Ba)return Yn(t,t.avail_out===0?er:ea);if(n.strm=t,s=n.last_flush,n.last_flush=e,n.status===gd)if(n.wrap===2)t.adler=0,rt(n,31),rt(n,139),rt(n,8),n.gzhead?(rt(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),rt(n,n.gzhead.time&255),rt(n,n.gzhead.time>>8&255),rt(n,n.gzhead.time>>16&255),rt(n,n.gzhead.time>>24&255),rt(n,n.level===9?2:n.strategy>=si||n.level<2?4:0),rt(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(rt(n,n.gzhead.extra.length&255),rt(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=At(t.adler,n.pending_buf,n.pending)),n.gzindex=0,n.status=rl):(rt(n,0),rt(n,0),rt(n,0),rt(n,0),rt(n,0),rt(n,n.level===9?2:n.strategy>=si||n.level<2?4:0),rt(n,c_),n.status=ya);else{var r=Yr+(n.w_bits-8<<4)<<8,o=-1;n.strategy>=si||n.level<2?o=0:n.level<6?o=1:n.level===6?o=2:o=3,r|=o<<6,n.strstart!==0&&(r|=l_),r+=31-r%31,n.status=ya,ar(n,r),n.strstart!==0&&(ar(n,t.adler>>>16),ar(n,t.adler&65535)),t.adler=1}if(n.status===rl)if(n.gzhead.extra){for(a=n.pending;n.gzindex<(n.gzhead.extra.length&65535)&&!(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>a&&(t.adler=At(t.adler,n.pending_buf,n.pending-a)),En(t),a=n.pending,n.pending===n.pending_buf_size));)rt(n,n.gzhead.extra[n.gzindex]&255),n.gzindex++;n.gzhead.hcrc&&n.pending>a&&(t.adler=At(t.adler,n.pending_buf,n.pending-a)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=tr)}else n.status=tr;if(n.status===tr)if(n.gzhead.name){a=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>a&&(t.adler=At(t.adler,n.pending_buf,n.pending-a)),En(t),a=n.pending,n.pending===n.pending_buf_size)){i=1;break}n.gzindex<n.gzhead.name.length?i=n.gzhead.name.charCodeAt(n.gzindex++)&255:i=0,rt(n,i)}while(i!==0);n.gzhead.hcrc&&n.pending>a&&(t.adler=At(t.adler,n.pending_buf,n.pending-a)),i===0&&(n.gzindex=0,n.status=sr)}else n.status=sr;if(n.status===sr)if(n.gzhead.comment){a=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>a&&(t.adler=At(t.adler,n.pending_buf,n.pending-a)),En(t),a=n.pending,n.pending===n.pending_buf_size)){i=1;break}n.gzindex<n.gzhead.comment.length?i=n.gzhead.comment.charCodeAt(n.gzindex++)&255:i=0,rt(n,i)}while(i!==0);n.gzhead.hcrc&&n.pending>a&&(t.adler=At(t.adler,n.pending_buf,n.pending-a)),i===0&&(n.status=nr)}else n.status=nr;if(n.status===nr&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&En(t),n.pending+2<=n.pending_buf_size&&(rt(n,t.adler&255),rt(n,t.adler>>8&255),t.adler=0,n.status=ya)):n.status=ya),n.pending!==0){if(En(t),t.avail_out===0)return n.last_flush=-1,jn}else if(t.avail_in===0&&ol(e)<=ol(s)&&e!==Ba)return Yn(t,er);if(n.status===ni&&t.avail_in!==0)return Yn(t,er);if(t.avail_in!==0||n.lookahead!==0||n.status!==ni){var d=n.strategy===si?f_(n):n.strategy===Yf?h_(n,e):Zn[n.level].func(n,e);if((d===Da||d===Li)&&(n.status=ni),d===Rt||d===Da)return t.avail_out===0&&(n.last_flush=-1),jn;if(d===qa&&(vd(n,0,0,!1),Kn(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0),En(t),t.avail_out===0))return n.last_flush=-1,jn}return jn}class m_{constructor(){this.strm=new ed,this.chunkSize=1024*10*10,this.outputBuffer=new Uint8Array(this.chunkSize),b_(this.strm,pd)}deflate(e){this.strm.input=e,this.strm.avail_in=this.strm.input.length,this.strm.next_in=0,this.strm.output=this.outputBuffer,this.strm.avail_out=this.chunkSize,this.strm.next_out=0;let s=ll(this.strm,il),n=new Uint8Array(this.strm.output.buffer,0,this.strm.next_out);if(s<0)throw new Error("zlib deflate failed");if(this.strm.avail_in>0){let a=[n],i=n.length;do{if(this.strm.output=new Uint8Array(this.chunkSize),this.strm.next_out=0,this.strm.avail_out=this.chunkSize,s=ll(this.strm,il),s<0)throw new Error("zlib deflate failed");let d=new Uint8Array(this.strm.output.buffer,0,this.strm.next_out);i+=d.length,a.push(d)}while(this.strm.avail_in>0);let r=new Uint8Array(i),o=0;for(let d=0;d<a.length;d++)r.set(a[d],o),o+=a[d].length;n=r}return this.strm.input=null,this.strm.avail_in=0,this.strm.next_in=0,n}}const m={XK_BackSpace:65288,XK_Tab:65289,XK_Clear:65291,XK_Return:65293,XK_Pause:65299,XK_Scroll_Lock:65300,XK_Escape:65307,XK_Delete:65535,XK_Multi_key:65312,XK_Codeinput:65335,XK_SingleCandidate:65340,XK_MultipleCandidate:65341,XK_PreviousCandidate:65342,XK_Kanji:65313,XK_Muhenkan:65314,XK_Henkan:65315,XK_Romaji:65316,XK_Hiragana:65317,XK_Katakana:65318,XK_Hiragana_Katakana:65319,XK_Zenkaku:65320,XK_Hankaku:65321,XK_Zenkaku_Hankaku:65322,XK_Kana_Shift:65326,XK_Eisu_toggle:65328,XK_Home:65360,XK_Left:65361,XK_Up:65362,XK_Right:65363,XK_Down:65364,XK_Prior:65365,XK_Next:65366,XK_End:65367,XK_Select:65376,XK_Print:65377,XK_Execute:65378,XK_Insert:65379,XK_Undo:65381,XK_Redo:65382,XK_Menu:65383,XK_Find:65384,XK_Cancel:65385,XK_Help:65386,XK_Mode_switch:65406,XK_Num_Lock:65407,XK_KP_Space:65408,XK_KP_Enter:65421,XK_KP_Home:65429,XK_KP_Left:65430,XK_KP_Up:65431,XK_KP_Right:65432,XK_KP_Down:65433,XK_KP_Prior:65434,XK_KP_Next:65435,XK_KP_End:65436,XK_KP_Begin:65437,XK_KP_Insert:65438,XK_KP_Delete:65439,XK_KP_Equal:65469,XK_KP_Multiply:65450,XK_KP_Add:65451,XK_KP_Separator:65452,XK_KP_Subtract:65453,XK_KP_Decimal:65454,XK_KP_Divide:65455,XK_KP_0:65456,XK_KP_1:65457,XK_KP_2:65458,XK_KP_3:65459,XK_KP_4:65460,XK_KP_5:65461,XK_KP_6:65462,XK_KP_7:65463,XK_KP_8:65464,XK_KP_9:65465,XK_F1:65470,XK_F2:65471,XK_F3:65472,XK_F4:65473,XK_F5:65474,XK_F6:65475,XK_F7:65476,XK_F8:65477,XK_F9:65478,XK_F10:65479,XK_F11:65480,XK_F12:65481,XK_F13:65482,XK_F14:65483,XK_F15:65484,XK_F16:65485,XK_F17:65486,XK_F18:65487,XK_F19:65488,XK_F20:65489,XK_F21:65490,XK_F22:65491,XK_F23:65492,XK_F24:65493,XK_F25:65494,XK_F26:65495,XK_F27:65496,XK_F28:65497,XK_F29:65498,XK_F30:65499,XK_F31:65500,XK_F32:65501,XK_F33:65502,XK_F34:65503,XK_F35:65504,XK_Shift_L:65505,XK_Shift_R:65506,XK_Control_L:65507,XK_Control_R:65508,XK_Caps_Lock:65509,XK_Meta_L:65511,XK_Meta_R:65512,XK_Alt_L:65513,XK_Alt_R:65514,XK_Super_L:65515,XK_Super_R:65516,XK_ISO_Level3_Shift:65027,XK_ISO_Next_Group:65032,XK_ISO_Prev_Group:65034,XK_ISO_First_Group:65036,XK_ISO_Last_Group:65038,XK_space:32,XK_asterisk:42,XK_plus:43,XK_comma:44,XK_minus:45,XK_period:46,XK_slash:47,XK_0:48,XK_1:49,XK_2:50,XK_3:51,XK_4:52,XK_5:53,XK_6:54,XK_7:55,XK_8:56,XK_9:57,XK_equal:61,XK_Hangul:65329,XK_Hangul_Hanja:65332,XK_Hangul_Jeonja:65336,XF86XK_MonBrightnessUp:269025026,XF86XK_MonBrightnessDown:269025027,XF86XK_Standby:269025040,XF86XK_AudioLowerVolume:269025041,XF86XK_AudioMute:269025042,XF86XK_AudioRaiseVolume:269025043,XF86XK_AudioPlay:269025044,XF86XK_AudioStop:269025045,XF86XK_AudioPrev:269025046,XF86XK_AudioNext:269025047,XF86XK_HomePage:269025048,XF86XK_Mail:269025049,XF86XK_Search:269025051,XF86XK_AudioRecord:269025052,XF86XK_Calculator:269025053,XF86XK_Calendar:269025056,XF86XK_PowerDown:269025057,XF86XK_Back:269025062,XF86XK_Forward:269025063,XF86XK_Stop:269025064,XF86XK_Refresh:269025065,XF86XK_PowerOff:269025066,XF86XK_WakeUp:269025067,XF86XK_Eject:269025068,XF86XK_ScreenSaver:269025069,XF86XK_WWW:269025070,XF86XK_Favorites:269025072,XF86XK_AudioPause:269025073,XF86XK_AudioMedia:269025074,XF86XK_MyComputer:269025075,XF86XK_BrightnessAdjust:269025083,XF86XK_AudioRewind:269025086,XF86XK_Close:269025110,XF86XK_Copy:269025111,XF86XK_Cut:269025112,XF86XK_Excel:269025116,XF86XK_LogOff:269025121,XF86XK_New:269025128,XF86XK_Open:269025131,XF86XK_Paste:269025133,XF86XK_Phone:269025134,XF86XK_Reply:269025138,XF86XK_Save:269025143,XF86XK_Send:269025147,XF86XK_Spell:269025148,XF86XK_SplitScreen:269025149,XF86XK_Word:269025161,XF86XK_ZoomIn:269025163,XF86XK_ZoomOut:269025164,XF86XK_WebCam:269025167,XF86XK_MailForward:269025168,XF86XK_Music:269025170,XF86XK_AudioForward:269025175,XF86XK_AudioRandomPlay:269025177,XF86XK_Subtitle:269025178,XF86XK_AudioCycleTrack:269025179,XF86XK_Hibernate:269025192,XF86XK_AudioMicMute:269025202,XF86XK_Next_VMode:269024802},w_={256:960,257:992,258:451,259:483,260:417,261:433,262:454,263:486,264:710,265:742,266:709,267:741,268:456,269:488,270:463,271:495,272:464,273:496,274:938,275:954,278:972,279:1004,280:458,281:490,282:460,283:492,284:728,285:760,286:683,287:699,288:725,289:757,290:939,291:955,292:678,293:694,294:673,295:689,296:933,297:949,298:975,299:1007,302:967,303:999,304:681,305:697,308:684,309:700,310:979,311:1011,312:930,313:453,314:485,315:934,316:950,317:421,318:437,321:419,322:435,323:465,324:497,325:977,326:1009,327:466,328:498,330:957,331:959,332:978,333:1010,336:469,337:501,338:5052,339:5053,340:448,341:480,342:931,343:947,344:472,345:504,346:422,347:438,348:734,349:766,350:426,351:442,352:425,353:441,354:478,355:510,356:427,357:443,358:940,359:956,360:989,361:1021,362:990,363:1022,364:733,365:765,366:473,367:505,368:475,369:507,370:985,371:1017,376:5054,377:428,378:444,379:431,380:447,381:430,382:446,402:2294,466:16777681,711:439,728:418,729:511,731:434,733:445,901:1966,902:1953,904:1954,905:1955,906:1956,908:1959,910:1960,911:1963,912:1974,913:1985,914:1986,915:1987,916:1988,917:1989,918:1990,919:1991,920:1992,921:1993,922:1994,923:1995,924:1996,925:1997,926:1998,927:1999,928:2e3,929:2001,931:2002,932:2004,933:2005,934:2006,935:2007,936:2008,937:2009,938:1957,939:1961,940:1969,941:1970,942:1971,943:1972,944:1978,945:2017,946:2018,947:2019,948:2020,949:2021,950:2022,951:2023,952:2024,953:2025,954:2026,955:2027,956:2028,957:2029,958:2030,959:2031,960:2032,961:2033,962:2035,963:2034,964:2036,965:2037,966:2038,967:2039,968:2040,969:2041,970:1973,971:1977,972:1975,973:1976,974:1979,1025:1715,1026:1713,1027:1714,1028:1716,1029:1717,1030:1718,1031:1719,1032:1720,1033:1721,1034:1722,1035:1723,1036:1724,1038:1726,1039:1727,1040:1761,1041:1762,1042:1783,1043:1767,1044:1764,1045:1765,1046:1782,1047:1786,1048:1769,1049:1770,1050:1771,1051:1772,1052:1773,1053:1774,1054:1775,1055:1776,1056:1778,1057:1779,1058:1780,1059:1781,1060:1766,1061:1768,1062:1763,1063:1790,1064:1787,1065:1789,1066:1791,1067:1785,1068:1784,1069:1788,1070:1760,1071:1777,1072:1729,1073:1730,1074:1751,1075:1735,1076:1732,1077:1733,1078:1750,1079:1754,1080:1737,1081:1738,1082:1739,1083:1740,1084:1741,1085:1742,1086:1743,1087:1744,1088:1746,1089:1747,1090:1748,1091:1749,1092:1734,1093:1736,1094:1731,1095:1758,1096:1755,1097:1757,1098:1759,1099:1753,1100:1752,1101:1756,1102:1728,1103:1745,1105:1699,1106:1697,1107:1698,1108:1700,1109:1701,1110:1702,1111:1703,1112:1704,1113:1705,1114:1706,1115:1707,1116:1708,1118:1710,1119:1711,1168:1725,1169:1709,1488:3296,1489:3297,1490:3298,1491:3299,1492:3300,1493:3301,1494:3302,1495:3303,1496:3304,1497:3305,1498:3306,1499:3307,1500:3308,1501:3309,1502:3310,1503:3311,1504:3312,1505:3313,1506:3314,1507:3315,1508:3316,1509:3317,1510:3318,1511:3319,1512:3320,1513:3321,1514:3322,1548:1452,1563:1467,1567:1471,1569:1473,1570:1474,1571:1475,1572:1476,1573:1477,1574:1478,1575:1479,1576:1480,1577:1481,1578:1482,1579:1483,1580:1484,1581:1485,1582:1486,1583:1487,1584:1488,1585:1489,1586:1490,1587:1491,1588:1492,1589:1493,1590:1494,1591:1495,1592:1496,1593:1497,1594:1498,1600:1504,1601:1505,1602:1506,1603:1507,1604:1508,1605:1509,1606:1510,1607:1511,1608:1512,1609:1513,1610:1514,1611:1515,1612:1516,1613:1517,1614:1518,1615:1519,1616:1520,1617:1521,1618:1522,3585:3489,3586:3490,3587:3491,3588:3492,3589:3493,3590:3494,3591:3495,3592:3496,3593:3497,3594:3498,3595:3499,3596:3500,3597:3501,3598:3502,3599:3503,3600:3504,3601:3505,3602:3506,3603:3507,3604:3508,3605:3509,3606:3510,3607:3511,3608:3512,3609:3513,3610:3514,3611:3515,3612:3516,3613:3517,3614:3518,3615:3519,3616:3520,3617:3521,3618:3522,3619:3523,3620:3524,3621:3525,3622:3526,3623:3527,3624:3528,3625:3529,3626:3530,3627:3531,3628:3532,3629:3533,3630:3534,3631:3535,3632:3536,3633:3537,3634:3538,3635:3539,3636:3540,3637:3541,3638:3542,3639:3543,3640:3544,3641:3545,3642:3546,3647:3551,3648:3552,3649:3553,3650:3554,3651:3555,3652:3556,3653:3557,3654:3558,3655:3559,3656:3560,3657:3561,3658:3562,3659:3563,3660:3564,3661:3565,3664:3568,3665:3569,3666:3570,3667:3571,3668:3572,3669:3573,3670:3574,3671:3575,3672:3576,3673:3577,8194:2722,8195:2721,8196:2723,8197:2724,8199:2725,8200:2726,8201:2727,8202:2728,8210:2747,8211:2730,8212:2729,8213:1967,8215:3295,8216:2768,8217:2769,8218:2813,8220:2770,8221:2771,8222:2814,8224:2801,8225:2802,8226:2790,8229:2735,8230:2734,8240:2773,8242:2774,8243:2775,8248:2812,8254:1150,8361:3839,8364:8364,8453:2744,8470:1712,8471:2811,8478:2772,8482:2761,8531:2736,8532:2737,8533:2738,8534:2739,8535:2740,8536:2741,8537:2742,8538:2743,8539:2755,8540:2756,8541:2757,8542:2758,8592:2299,8593:2300,8594:2301,8595:2302,8658:2254,8660:2253,8706:2287,8711:2245,8728:3018,8730:2262,8733:2241,8734:2242,8743:2270,8744:2271,8745:2268,8746:2269,8747:2239,8756:2240,8764:2248,8771:2249,8773:16785992,8800:2237,8801:2255,8804:2236,8805:2238,8834:2266,8835:2267,8866:3068,8867:3036,8868:3010,8869:3022,8968:3027,8970:3012,8981:2810,8992:2212,8993:2213,9109:3020,9115:2219,9117:2220,9118:2221,9120:2222,9121:2215,9123:2216,9124:2217,9126:2218,9128:2223,9132:2224,9143:2209,9146:2543,9147:2544,9148:2546,9149:2547,9225:2530,9226:2533,9227:2537,9228:2531,9229:2532,9251:2732,9252:2536,9472:2211,9474:2214,9484:2210,9488:2539,9492:2541,9496:2538,9500:2548,9508:2549,9516:2551,9524:2550,9532:2542,9618:2529,9642:2791,9643:2785,9644:2779,9645:2786,9646:2783,9647:2767,9650:2792,9651:2787,9654:2781,9655:2765,9660:2793,9661:2788,9664:2780,9665:2764,9670:2528,9675:2766,9679:2782,9702:2784,9734:2789,9742:2809,9747:2762,9756:2794,9758:2795,9792:2808,9794:2807,9827:2796,9829:2798,9830:2797,9837:2806,9839:2805,10003:2803,10007:2804,10013:2777,10016:2800,10216:2748,10217:2750,12289:1188,12290:1185,12300:1186,12301:1187,12443:1246,12444:1247,12449:1191,12450:1201,12451:1192,12452:1202,12453:1193,12454:1203,12455:1194,12456:1204,12457:1195,12458:1205,12459:1206,12461:1207,12463:1208,12465:1209,12467:1210,12469:1211,12471:1212,12473:1213,12475:1214,12477:1215,12479:1216,12481:1217,12483:1199,12484:1218,12486:1219,12488:1220,12490:1221,12491:1222,12492:1223,12493:1224,12494:1225,12495:1226,12498:1227,12501:1228,12504:1229,12507:1230,12510:1231,12511:1232,12512:1233,12513:1234,12514:1235,12515:1196,12516:1236,12517:1197,12518:1237,12519:1198,12520:1238,12521:1239,12522:1240,12523:1241,12524:1242,12525:1243,12527:1244,12530:1190,12531:1245,12539:1189,12540:1200},y_={lookup(t){if(t>=32&&t<=255)return t;const e=w_[t];return e!==void 0?e:16777216|t}},cl={8:"Backspace",9:"Tab",10:"NumpadClear",13:"Enter",16:"ShiftLeft",17:"ControlLeft",18:"AltLeft",19:"Pause",20:"CapsLock",21:"Lang1",25:"Lang2",27:"Escape",28:"Convert",29:"NonConvert",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",41:"Select",44:"PrintScreen",45:"Insert",46:"Delete",47:"Help",48:"Digit0",49:"Digit1",50:"Digit2",51:"Digit3",52:"Digit4",53:"Digit5",54:"Digit6",55:"Digit7",56:"Digit8",57:"Digit9",91:"MetaLeft",92:"MetaRight",93:"ContextMenu",95:"Sleep",96:"Numpad0",97:"Numpad1",98:"Numpad2",99:"Numpad3",100:"Numpad4",101:"Numpad5",102:"Numpad6",103:"Numpad7",104:"Numpad8",105:"Numpad9",106:"NumpadMultiply",107:"NumpadAdd",108:"NumpadDecimal",109:"NumpadSubtract",110:"NumpadDecimal",111:"NumpadDivide",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",124:"F13",125:"F14",126:"F15",127:"F16",128:"F17",129:"F18",130:"F19",131:"F20",132:"F21",133:"F22",134:"F23",135:"F24",144:"NumLock",145:"ScrollLock",166:"BrowserBack",167:"BrowserForward",168:"BrowserRefresh",169:"BrowserStop",170:"BrowserSearch",171:"BrowserFavorites",172:"BrowserHome",173:"AudioVolumeMute",174:"AudioVolumeDown",175:"AudioVolumeUp",176:"MediaTrackNext",177:"MediaTrackPrevious",178:"MediaStop",179:"MediaPlayPause",180:"LaunchMail",181:"MediaSelect",182:"LaunchApp1",183:"LaunchApp2",225:"AltRight"},dl={Backspace:"Backspace",AltLeft:"Alt",AltRight:"Alt",CapsLock:"CapsLock",ContextMenu:"ContextMenu",ControlLeft:"Control",ControlRight:"Control",Enter:"Enter",MetaLeft:"Meta",MetaRight:"Meta",ShiftLeft:"Shift",ShiftRight:"Shift",Tab:"Tab",Delete:"Delete",End:"End",Help:"Help",Home:"Home",Insert:"Insert",PageDown:"PageDown",PageUp:"PageUp",ArrowDown:"ArrowDown",ArrowLeft:"ArrowLeft",ArrowRight:"ArrowRight",ArrowUp:"ArrowUp",NumLock:"NumLock",NumpadBackspace:"Backspace",NumpadClear:"Clear",Escape:"Escape",F1:"F1",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",F10:"F10",F11:"F11",F12:"F12",F13:"F13",F14:"F14",F15:"F15",F16:"F16",F17:"F17",F18:"F18",F19:"F19",F20:"F20",F21:"F21",F22:"F22",F23:"F23",F24:"F24",F25:"F25",F26:"F26",F27:"F27",F28:"F28",F29:"F29",F30:"F30",F31:"F31",F32:"F32",F33:"F33",F34:"F34",F35:"F35",PrintScreen:"PrintScreen",ScrollLock:"ScrollLock",Pause:"Pause",BrowserBack:"BrowserBack",BrowserFavorites:"BrowserFavorites",BrowserForward:"BrowserForward",BrowserHome:"BrowserHome",BrowserRefresh:"BrowserRefresh",BrowserSearch:"BrowserSearch",BrowserStop:"BrowserStop",Eject:"Eject",LaunchApp1:"LaunchMyComputer",LaunchApp2:"LaunchCalendar",LaunchMail:"LaunchMail",MediaPlayPause:"MediaPlay",MediaStop:"MediaStop",MediaTrackNext:"MediaTrackNext",MediaTrackPrevious:"MediaTrackPrevious",Power:"Power",Sleep:"Sleep",AudioVolumeDown:"AudioVolumeDown",AudioVolumeMute:"AudioVolumeMute",AudioVolumeUp:"AudioVolumeUp",WakeUp:"WakeUp"},yn={};function I(t,e){if(e===void 0)throw new Error('Undefined keysym for key "'+t+'"');if(t in yn)throw new Error('Duplicate entry for key "'+t+'"');yn[t]=[e,e,e,e]}function Pi(t,e,s){if(e===void 0)throw new Error('Undefined keysym for key "'+t+'"');if(s===void 0)throw new Error('Undefined keysym for key "'+t+'"');if(t in yn)throw new Error('Duplicate entry for key "'+t+'"');yn[t]=[e,e,s,e]}function ze(t,e,s){if(e===void 0)throw new Error('Undefined keysym for key "'+t+'"');if(s===void 0)throw new Error('Undefined keysym for key "'+t+'"');if(t in yn)throw new Error('Duplicate entry for key "'+t+'"');yn[t]=[e,e,e,s]}Pi("Alt",m.XK_Alt_L,m.XK_Alt_R);I("AltGraph",m.XK_ISO_Level3_Shift);I("CapsLock",m.XK_Caps_Lock);Pi("Control",m.XK_Control_L,m.XK_Control_R);Pi("Meta",m.XK_Super_L,m.XK_Super_R);I("NumLock",m.XK_Num_Lock);I("ScrollLock",m.XK_Scroll_Lock);Pi("Shift",m.XK_Shift_L,m.XK_Shift_R);ze("Enter",m.XK_Return,m.XK_KP_Enter);I("Tab",m.XK_Tab);ze(" ",m.XK_space,m.XK_KP_Space);ze("ArrowDown",m.XK_Down,m.XK_KP_Down);ze("ArrowLeft",m.XK_Left,m.XK_KP_Left);ze("ArrowRight",m.XK_Right,m.XK_KP_Right);ze("ArrowUp",m.XK_Up,m.XK_KP_Up);ze("End",m.XK_End,m.XK_KP_End);ze("Home",m.XK_Home,m.XK_KP_Home);ze("PageDown",m.XK_Next,m.XK_KP_Next);ze("PageUp",m.XK_Prior,m.XK_KP_Prior);I("Backspace",m.XK_BackSpace);ze("Clear",m.XK_Clear,m.XK_KP_Begin);I("Copy",m.XF86XK_Copy);I("Cut",m.XF86XK_Cut);ze("Delete",m.XK_Delete,m.XK_KP_Delete);ze("Insert",m.XK_Insert,m.XK_KP_Insert);I("Paste",m.XF86XK_Paste);I("Redo",m.XK_Redo);I("Undo",m.XK_Undo);I("Cancel",m.XK_Cancel);I("ContextMenu",m.XK_Menu);I("Escape",m.XK_Escape);I("Execute",m.XK_Execute);I("Find",m.XK_Find);I("Help",m.XK_Help);I("Pause",m.XK_Pause);I("Select",m.XK_Select);I("ZoomIn",m.XF86XK_ZoomIn);I("ZoomOut",m.XF86XK_ZoomOut);I("BrightnessDown",m.XF86XK_MonBrightnessDown);I("BrightnessUp",m.XF86XK_MonBrightnessUp);I("Eject",m.XF86XK_Eject);I("LogOff",m.XF86XK_LogOff);I("Power",m.XF86XK_PowerOff);I("PowerOff",m.XF86XK_PowerDown);I("PrintScreen",m.XK_Print);I("Hibernate",m.XF86XK_Hibernate);I("Standby",m.XF86XK_Standby);I("WakeUp",m.XF86XK_WakeUp);I("AllCandidates",m.XK_MultipleCandidate);I("Alphanumeric",m.XK_Eisu_toggle);I("CodeInput",m.XK_Codeinput);I("Compose",m.XK_Multi_key);I("Convert",m.XK_Henkan);I("GroupFirst",m.XK_ISO_First_Group);I("GroupLast",m.XK_ISO_Last_Group);I("GroupNext",m.XK_ISO_Next_Group);I("GroupPrevious",m.XK_ISO_Prev_Group);I("NonConvert",m.XK_Muhenkan);I("PreviousCandidate",m.XK_PreviousCandidate);I("SingleCandidate",m.XK_SingleCandidate);I("HangulMode",m.XK_Hangul);I("HanjaMode",m.XK_Hangul_Hanja);I("JunjaMode",m.XK_Hangul_Jeonja);I("Eisu",m.XK_Eisu_toggle);I("Hankaku",m.XK_Hankaku);I("Hiragana",m.XK_Hiragana);I("HiraganaKatakana",m.XK_Hiragana_Katakana);I("KanaMode",m.XK_Kana_Shift);I("KanjiMode",m.XK_Kanji);I("Katakana",m.XK_Katakana);I("Romaji",m.XK_Romaji);I("Zenkaku",m.XK_Zenkaku);I("ZenkakuHankaku",m.XK_Zenkaku_Hankaku);I("F1",m.XK_F1);I("F2",m.XK_F2);I("F3",m.XK_F3);I("F4",m.XK_F4);I("F5",m.XK_F5);I("F6",m.XK_F6);I("F7",m.XK_F7);I("F8",m.XK_F8);I("F9",m.XK_F9);I("F10",m.XK_F10);I("F11",m.XK_F11);I("F12",m.XK_F12);I("F13",m.XK_F13);I("F14",m.XK_F14);I("F15",m.XK_F15);I("F16",m.XK_F16);I("F17",m.XK_F17);I("F18",m.XK_F18);I("F19",m.XK_F19);I("F20",m.XK_F20);I("F21",m.XK_F21);I("F22",m.XK_F22);I("F23",m.XK_F23);I("F24",m.XK_F24);I("F25",m.XK_F25);I("F26",m.XK_F26);I("F27",m.XK_F27);I("F28",m.XK_F28);I("F29",m.XK_F29);I("F30",m.XK_F30);I("F31",m.XK_F31);I("F32",m.XK_F32);I("F33",m.XK_F33);I("F34",m.XK_F34);I("F35",m.XK_F35);I("Close",m.XF86XK_Close);I("MailForward",m.XF86XK_MailForward);I("MailReply",m.XF86XK_Reply);I("MailSend",m.XF86XK_Send);I("MediaFastForward",m.XF86XK_AudioForward);I("MediaPause",m.XF86XK_AudioPause);I("MediaPlay",m.XF86XK_AudioPlay);I("MediaRecord",m.XF86XK_AudioRecord);I("MediaRewind",m.XF86XK_AudioRewind);I("MediaStop",m.XF86XK_AudioStop);I("MediaTrackNext",m.XF86XK_AudioNext);I("MediaTrackPrevious",m.XF86XK_AudioPrev);I("New",m.XF86XK_New);I("Open",m.XF86XK_Open);I("Print",m.XK_Print);I("Save",m.XF86XK_Save);I("SpellCheck",m.XF86XK_Spell);I("AudioVolumeDown",m.XF86XK_AudioLowerVolume);I("AudioVolumeUp",m.XF86XK_AudioRaiseVolume);I("AudioVolumeMute",m.XF86XK_AudioMute);I("MicrophoneVolumeMute",m.XF86XK_AudioMicMute);I("LaunchApplication1",m.XF86XK_MyComputer);I("LaunchApplication2",m.XF86XK_Calculator);I("LaunchCalendar",m.XF86XK_Calendar);I("LaunchMail",m.XF86XK_Mail);I("LaunchMediaPlayer",m.XF86XK_AudioMedia);I("LaunchMusicPlayer",m.XF86XK_Music);I("LaunchPhone",m.XF86XK_Phone);I("LaunchScreenSaver",m.XF86XK_ScreenSaver);I("LaunchSpreadsheet",m.XF86XK_Excel);I("LaunchWebBrowser",m.XF86XK_WWW);I("LaunchWebCam",m.XF86XK_WebCam);I("LaunchWordProcessor",m.XF86XK_Word);I("BrowserBack",m.XF86XK_Back);I("BrowserFavorites",m.XF86XK_Favorites);I("BrowserForward",m.XF86XK_Forward);I("BrowserHome",m.XF86XK_HomePage);I("BrowserRefresh",m.XF86XK_Refresh);I("BrowserSearch",m.XF86XK_Search);I("BrowserStop",m.XF86XK_Stop);I("Dimmer",m.XF86XK_BrightnessAdjust);I("MediaAudioTrack",m.XF86XK_AudioCycleTrack);I("RandomToggle",m.XF86XK_AudioRandomPlay);I("SplitScreenToggle",m.XF86XK_SplitScreen);I("Subtitle",m.XF86XK_Subtitle);I("VideoModeNext",m.XF86XK_Next_VMode);ze("=",m.XK_equal,m.XK_KP_Equal);ze("+",m.XK_plus,m.XK_KP_Add);ze("-",m.XK_minus,m.XK_KP_Subtract);ze("*",m.XK_asterisk,m.XK_KP_Multiply);ze("/",m.XK_slash,m.XK_KP_Divide);ze(".",m.XK_period,m.XK_KP_Decimal);ze(",",m.XK_comma,m.XK_KP_Separator);ze("0",m.XK_0,m.XK_KP_0);ze("1",m.XK_1,m.XK_KP_1);ze("2",m.XK_2,m.XK_KP_2);ze("3",m.XK_3,m.XK_KP_3);ze("4",m.XK_4,m.XK_KP_4);ze("5",m.XK_5,m.XK_KP_5);ze("6",m.XK_6,m.XK_KP_6);ze("7",m.XK_7,m.XK_KP_7);ze("8",m.XK_8,m.XK_KP_8);ze("9",m.XK_9,m.XK_KP_9);function Ta(t){if(t.code){switch(t.code){case"OSLeft":return"MetaLeft";case"OSRight":return"MetaRight"}return t.code}if(t.keyCode in cl){let e=cl[t.keyCode];if(qn()&&e==="ContextMenu"&&(e="MetaRight"),t.location===2)switch(e){case"ShiftLeft":return"ShiftRight";case"ControlLeft":return"ControlRight";case"AltLeft":return"AltRight"}if(t.location===3)switch(e){case"Delete":return"NumpadDecimal";case"Insert":return"Numpad0";case"End":return"Numpad1";case"ArrowDown":return"Numpad2";case"PageDown":return"Numpad3";case"ArrowLeft":return"Numpad4";case"ArrowRight":return"Numpad6";case"Home":return"Numpad7";case"ArrowUp":return"Numpad8";case"PageUp":return"Numpad9";case"Enter":return"NumpadEnter"}return e}return"Unidentified"}function k_(t){if(t.key!==void 0&&t.key!=="Unidentified"){switch(t.key){case"OS":return"Meta";case"LaunchMyComputer":return"LaunchApplication1";case"LaunchCalculator":return"LaunchApplication2"}switch(t.key){case"UIKeyInputUpArrow":return"ArrowUp";case"UIKeyInputDownArrow":return"ArrowDown";case"UIKeyInputLeftArrow":return"ArrowLeft";case"UIKeyInputRightArrow":return"ArrowRight";case"UIKeyInputEscape":return"Escape"}return t.key==="\0"&&t.code==="NumpadDecimal"?"Delete":t.key}const e=Ta(t);return e in dl?dl[e]:t.charCode?String.fromCharCode(t.charCode):"Unidentified"}function S_(t){const e=k_(t);if(e==="Unidentified")return null;if(e in yn){let n=t.location;if(e==="Meta"&&n===0&&(n=2),e==="Clear"&&n===3&&Ta(t)==="NumLock"&&(n=0),(n===void 0||n>3)&&(n=0),e==="Meta"){let a=Ta(t);if(a==="AltLeft")return m.XK_Meta_L;if(a==="AltRight")return m.XK_Meta_R}if(e==="Clear"&&Ta(t)==="NumLock")return m.XK_Num_Lock;if(di())switch(e){case"Zenkaku":case"Hankaku":return m.XK_Zenkaku_Hankaku;case"Romaji":case"KanaMode":return m.XK_Romaji}return yn[e][n]}if(e.length!==1)return null;const s=e.charCodeAt();return s?y_.lookup(s):null}class C_{constructor(e){this._target=e||null,this._keyDownList={},this._altGrArmed=!1,this._eventHandlers={keyup:this._handleKeyUp.bind(this),keydown:this._handleKeyDown.bind(this),blur:this._allKeysUp.bind(this)},this.onkeyevent=()=>{}}_sendKeyEvent(e,s,n,a=null,i=null){if(n)this._keyDownList[s]=e;else{if(!(s in this._keyDownList))return;delete this._keyDownList[s]}Ce("onkeyevent "+(n?"down":"up")+", keysym: "+e,", code: "+s+", numlock: "+a+", capslock: "+i),this.onkeyevent(e,s,n,a,i)}_getKeyCode(e){const s=Ta(e);if(s!=="Unidentified")return s;if(e.keyCode&&e.keyCode!==229)return"Platform"+e.keyCode;if(e.keyIdentifier){if(e.keyIdentifier.substr(0,2)!=="U+")return e.keyIdentifier;const n=parseInt(e.keyIdentifier.substr(2),16);return"Platform"+String.fromCharCode(n).toUpperCase().charCodeAt()}return"Unidentified"}_handleKeyDown(e){const s=this._getKeyCode(e);let n=S_(e),a=e.getModifierState("NumLock"),i=e.getModifierState("CapsLock");if((qn()||ha())&&(a=null),this._altGrArmed&&(this._altGrArmed=!1,clearTimeout(this._altGrTimeout),s==="AltRight"&&e.timeStamp-this._altGrCtrlTime<50?n=m.XK_ISO_Level3_Shift:this._sendKeyEvent(m.XK_Control_L,"ControlLeft",!0,a,i)),s==="Unidentified"){n&&(this._sendKeyEvent(n,s,!0,a,i),this._sendKeyEvent(n,s,!1,a,i)),On(e);return}if(qn()||ha())switch(n){case m.XK_Super_L:n=m.XK_Alt_L;break;case m.XK_Super_R:n=m.XK_Super_L;break;case m.XK_Alt_L:n=m.XK_Mode_switch;break;case m.XK_Alt_R:n=m.XK_ISO_Level3_Shift;break}if(s in this._keyDownList&&(n=this._keyDownList[s]),(qn()||ha())&&e.metaKey&&s!=="MetaLeft"&&s!=="MetaRight"){this._sendKeyEvent(n,s,!0,a,i),this._sendKeyEvent(n,s,!1,a,i),On(e);return}if((qn()||ha())&&s==="CapsLock"){this._sendKeyEvent(m.XK_Caps_Lock,"CapsLock",!0,a,i),this._sendKeyEvent(m.XK_Caps_Lock,"CapsLock",!1,a,i),On(e);return}const r=[m.XK_Zenkaku_Hankaku,m.XK_Eisu_toggle,m.XK_Katakana,m.XK_Hiragana,m.XK_Romaji];if(di()&&r.includes(n)){this._sendKeyEvent(n,s,!0,a,i),this._sendKeyEvent(n,s,!1,a,i),On(e);return}if(On(e),s==="ControlLeft"&&di()&&!("ControlLeft"in this._keyDownList)){this._altGrArmed=!0,this._altGrTimeout=setTimeout(this._interruptAltGrSequence.bind(this),100),this._altGrCtrlTime=e.timeStamp;return}this._sendKeyEvent(n,s,!0,a,i)}_handleKeyUp(e){On(e);const s=this._getKeyCode(e);if(this._interruptAltGrSequence(),(qn()||ha())&&s==="CapsLock"){this._sendKeyEvent(m.XK_Caps_Lock,"CapsLock",!0),this._sendKeyEvent(m.XK_Caps_Lock,"CapsLock",!1);return}this._sendKeyEvent(this._keyDownList[s],s,!1),di()&&(s==="ShiftLeft"||s==="ShiftRight")&&("ShiftRight"in this._keyDownList&&this._sendKeyEvent(this._keyDownList.ShiftRight,"ShiftRight",!1),"ShiftLeft"in this._keyDownList&&this._sendKeyEvent(this._keyDownList.ShiftLeft,"ShiftLeft",!1))}_interruptAltGrSequence(){this._altGrArmed&&(this._altGrArmed=!1,clearTimeout(this._altGrTimeout),this._sendKeyEvent(m.XK_Control_L,"ControlLeft",!0))}_allKeysUp(){Ce(">> Keyboard.allKeysUp"),this._interruptAltGrSequence();for(let e in this._keyDownList)this._sendKeyEvent(this._keyDownList[e],e,!1);Ce("<< Keyboard.allKeysUp")}grab(){this._target.addEventListener("keydown",this._eventHandlers.keydown),this._target.addEventListener("keyup",this._eventHandlers.keyup),window.addEventListener("blur",this._eventHandlers.blur)}ungrab(){this._target.removeEventListener("keydown",this._eventHandlers.keydown),this._target.removeEventListener("keyup",this._eventHandlers.keyup),window.removeEventListener("blur",this._eventHandlers.blur),this._allKeysUp()}}const Is=0,ul=1,hl=2,fl=4,_l=8,rr=16,_a=32,va=64,or=127,vl=50,E_=90,pl=250,A_=1e3,K_=1e3,F_=50;class T_{constructor(){this._target=null,this._state=or,this._tracked=[],this._ignored=[],this._waitingRelease=!1,this._releaseStart=0,this._longpressTimeoutId=null,this._twoTouchTimeoutId=null,this._boundEventHandler=this._eventHandler.bind(this)}attach(e){this.detach(),this._target=e,this._target.addEventListener("touchstart",this._boundEventHandler),this._target.addEventListener("touchmove",this._boundEventHandler),this._target.addEventListener("touchend",this._boundEventHandler),this._target.addEventListener("touchcancel",this._boundEventHandler)}detach(){this._target&&(this._stopLongpressTimeout(),this._stopTwoTouchTimeout(),this._target.removeEventListener("touchstart",this._boundEventHandler),this._target.removeEventListener("touchmove",this._boundEventHandler),this._target.removeEventListener("touchend",this._boundEventHandler),this._target.removeEventListener("touchcancel",this._boundEventHandler),this._target=null)}_eventHandler(e){let s;switch(e.stopPropagation(),e.preventDefault(),e.type){case"touchstart":s=this._touchStart;break;case"touchmove":s=this._touchMove;break;case"touchend":case"touchcancel":s=this._touchEnd;break}for(let n=0;n<e.changedTouches.length;n++){let a=e.changedTouches[n];s.call(this,a.identifier,a.clientX,a.clientY)}}_touchStart(e,s,n){if(this._hasDetectedGesture()||this._state===Is){this._ignored.push(e);return}if(this._tracked.length>0&&Date.now()-this._tracked[0].started>pl){this._state=Is,this._ignored.push(e);return}if(this._waitingRelease){this._state=Is,this._ignored.push(e);return}switch(this._tracked.push({id:e,started:Date.now(),active:!0,firstX:s,firstY:n,lastX:s,lastY:n,angle:0}),this._tracked.length){case 1:this._startLongpressTimeout();break;case 2:this._state&=-26,this._stopLongpressTimeout();break;case 3:this._state&=-99;break;default:this._state=Is}}_touchMove(e,s,n){let a=this._tracked.find(o=>o.id===e);if(a===void 0)return;a.lastX=s,a.lastY=n;let i=s-a.firstX,r=n-a.firstY;if((a.firstX!==a.lastX||a.firstY!==a.lastY)&&(a.angle=Math.atan2(r,i)*180/Math.PI),!this._hasDetectedGesture()){if(Math.hypot(i,r)<vl)return;if(this._state&=-24,this._stopLongpressTimeout(),this._tracked.length!==1&&(this._state&=~_l),this._tracked.length!==2&&(this._state&=-97),this._tracked.length===2){let o=this._tracked.find(l=>l.id!==e);if(Math.hypot(o.firstX-o.lastX,o.firstY-o.lastY)>vl){let l=Math.abs(a.angle-o.angle);l=Math.abs((l+180)%360-180),l>E_?this._state&=~_a:this._state&=~va,this._isTwoTouchTimeoutRunning()&&this._stopTwoTouchTimeout()}else this._isTwoTouchTimeoutRunning()||this._startTwoTouchTimeout()}if(!this._hasDetectedGesture())return;this._pushEvent("gesturestart")}this._pushEvent("gesturemove")}_touchEnd(e,s,n){if(this._ignored.indexOf(e)!==-1){this._ignored.splice(this._ignored.indexOf(e),1),this._ignored.length===0&&this._tracked.length===0&&(this._state=or,this._waitingRelease=!1);return}if(!this._hasDetectedGesture()&&this._isTwoTouchTimeoutRunning()&&(this._stopTwoTouchTimeout(),this._state=Is),!this._hasDetectedGesture()&&(this._state&=-105,this._state&=~rr,this._stopLongpressTimeout(),!this._waitingRelease))switch(this._releaseStart=Date.now(),this._waitingRelease=!0,this._tracked.length){case 1:this._state&=-7;break;case 2:this._state&=-6;break}if(this._waitingRelease){Date.now()-this._releaseStart>pl&&(this._state=Is),this._tracked.some(i=>Date.now()-i.started>A_)&&(this._state=Is);let a=this._tracked.find(i=>i.id===e);if(a.active=!1,this._hasDetectedGesture())this._pushEvent("gesturestart");else if(this._state!==Is)return}this._hasDetectedGesture()&&this._pushEvent("gestureend");for(let a=0;a<this._tracked.length;a++)this._tracked[a].active&&this._ignored.push(this._tracked[a].id);this._tracked=[],this._state=Is,this._ignored.indexOf(e)!==-1&&this._ignored.splice(this._ignored.indexOf(e),1),this._ignored.length===0&&(this._state=or,this._waitingRelease=!1)}_hasDetectedGesture(){return!(this._state===Is||this._state&this._state-1||this._state&(ul|hl|fl)&&this._tracked.some(e=>e.active))}_startLongpressTimeout(){this._stopLongpressTimeout(),this._longpressTimeoutId=setTimeout(()=>this._longpressTimeout(),K_)}_stopLongpressTimeout(){clearTimeout(this._longpressTimeoutId),this._longpressTimeoutId=null}_longpressTimeout(){if(this._hasDetectedGesture())throw new Error("A longpress gesture failed, conflict with a different gesture");this._state=rr,this._pushEvent("gesturestart")}_startTwoTouchTimeout(){this._stopTwoTouchTimeout(),this._twoTouchTimeoutId=setTimeout(()=>this._twoTouchTimeout(),F_)}_stopTwoTouchTimeout(){clearTimeout(this._twoTouchTimeoutId),this._twoTouchTimeoutId=null}_isTwoTouchTimeoutRunning(){return this._twoTouchTimeoutId!==null}_twoTouchTimeout(){if(this._tracked.length===0)throw new Error("A pinch or two drag gesture failed, no tracked touches");let e=this._getAverageMovement(),s=Math.abs(e.x),n=Math.abs(e.y),a=this._getAverageDistance(),i=Math.abs(Math.hypot(a.first.x,a.first.y)-Math.hypot(a.last.x,a.last.y));n<i&&s<i?this._state=va:this._state=_a,this._pushEvent("gesturestart"),this._pushEvent("gesturemove")}_pushEvent(e){let s={type:this._stateToGesture(this._state)},n=this._getPosition(),a=n.last;switch(e==="gesturestart"&&(a=n.first),this._state){case _a:case va:a=n.first;break}if(s.clientX=a.x,s.clientY=a.y,this._state===va){let r=this._getAverageDistance();e==="gesturestart"?(s.magnitudeX=r.first.x,s.magnitudeY=r.first.y):(s.magnitudeX=r.last.x,s.magnitudeY=r.last.y)}else if(this._state===_a)if(e==="gesturestart")s.magnitudeX=0,s.magnitudeY=0;else{let r=this._getAverageMovement();s.magnitudeX=r.x,s.magnitudeY=r.y}let i=new CustomEvent(e,{detail:s});this._target.dispatchEvent(i)}_stateToGesture(e){switch(e){case ul:return"onetap";case hl:return"twotap";case fl:return"threetap";case _l:return"drag";case rr:return"longpress";case _a:return"twodrag";case va:return"pinch"}throw new Error("Unknown gesture state: "+e)}_getPosition(){if(this._tracked.length===0)throw new Error("Failed to get gesture position, no tracked touches");let e=this._tracked.length,s=0,n=0,a=0,i=0;for(let r=0;r<this._tracked.length;r++)s+=this._tracked[r].firstX,n+=this._tracked[r].firstY,a+=this._tracked[r].lastX,i+=this._tracked[r].lastY;return{first:{x:s/e,y:n/e},last:{x:a/e,y:i/e}}}_getAverageMovement(){if(this._tracked.length===0)throw new Error("Failed to get gesture movement, no tracked touches");let e,s;e=s=0;let n=this._tracked.length;for(let a=0;a<this._tracked.length;a++)e+=this._tracked[a].lastX-this._tracked[a].firstX,s+=this._tracked[a].lastY-this._tracked[a].firstY;return{x:e/n,y:s/n}}_getAverageDistance(){if(this._tracked.length===0)throw new Error("Failed to get gesture distance, no tracked touches");let e=this._tracked[0],s=this._tracked[this._tracked.length-1],n=Math.abs(s.firstX-e.firstX),a=Math.abs(s.firstY-e.firstY),i=Math.abs(s.lastX-e.lastX),r=Math.abs(s.lastY-e.lastY);return{first:{x:n,y:a},last:{x:i,y:r}}}}const pa=!Z0||Hc;class M_{constructor(){this._target=null,this._canvas=document.createElement("canvas"),pa&&(this._canvas.style.position="fixed",this._canvas.style.zIndex="65535",this._canvas.style.pointerEvents="none",this._canvas.style.userSelect="none",this._canvas.style.WebkitUserSelect="none",this._canvas.style.visibility="hidden"),this._position={x:0,y:0},this._hotSpot={x:0,y:0},this._eventHandlers={mouseover:this._handleMouseOver.bind(this),mouseleave:this._handleMouseLeave.bind(this),mousemove:this._handleMouseMove.bind(this),mouseup:this._handleMouseUp.bind(this)}}attach(e){if(this._target&&this.detach(),this._target=e,pa){document.body.appendChild(this._canvas);const s={capture:!0,passive:!0};this._target.addEventListener("mouseover",this._eventHandlers.mouseover,s),this._target.addEventListener("mouseleave",this._eventHandlers.mouseleave,s),this._target.addEventListener("mousemove",this._eventHandlers.mousemove,s),this._target.addEventListener("mouseup",this._eventHandlers.mouseup,s)}this.clear()}detach(){if(this._target){if(pa){const e={capture:!0,passive:!0};this._target.removeEventListener("mouseover",this._eventHandlers.mouseover,e),this._target.removeEventListener("mouseleave",this._eventHandlers.mouseleave,e),this._target.removeEventListener("mousemove",this._eventHandlers.mousemove,e),this._target.removeEventListener("mouseup",this._eventHandlers.mouseup,e),document.contains(this._canvas)&&document.body.removeChild(this._canvas)}this._target=null}}change(e,s,n,a,i){if(a===0||i===0){this.clear();return}this._position.x=this._position.x+this._hotSpot.x-s,this._position.y=this._position.y+this._hotSpot.y-n,this._hotSpot.x=s,this._hotSpot.y=n;let r=this._canvas.getContext("2d");this._canvas.width=a,this._canvas.height=i;let o=new ImageData(new Uint8ClampedArray(e),a,i);if(r.clearRect(0,0,a,i),r.putImageData(o,0,0),pa)this._updatePosition();else{let d=this._canvas.toDataURL();this._target.style.cursor="url("+d+")"+s+" "+n+", default"}}clear(){this._target.style.cursor="none",this._canvas.width=0,this._canvas.height=0,this._position.x=this._position.x+this._hotSpot.x,this._position.y=this._position.y+this._hotSpot.y,this._hotSpot.x=0,this._hotSpot.y=0}move(e,s){if(!pa)return;window.visualViewport?(this._position.x=e+window.visualViewport.offsetLeft,this._position.y=s+window.visualViewport.offsetTop):(this._position.x=e,this._position.y=s),this._updatePosition();let n=document.elementFromPoint(e,s);this._updateVisibility(n)}_handleMouseOver(e){this._handleMouseMove(e)}_handleMouseLeave(e){this._updateVisibility(e.relatedTarget)}_handleMouseMove(e){this._updateVisibility(e.target),this._position.x=e.clientX-this._hotSpot.x,this._position.y=e.clientY-this._hotSpot.y,this._updatePosition()}_handleMouseUp(e){let s=document.elementFromPoint(e.clientX,e.clientY);this._updateVisibility(s),this._captureIsActive()&&window.setTimeout(()=>{this._target&&(s=document.elementFromPoint(e.clientX,e.clientY),this._updateVisibility(s))},0)}_showCursor(){this._canvas.style.visibility==="hidden"&&(this._canvas.style.visibility="")}_hideCursor(){this._canvas.style.visibility!=="hidden"&&(this._canvas.style.visibility="hidden")}_shouldShowCursor(e){return e?e===this._target?!0:!(!this._target.contains(e)||window.getComputedStyle(e).cursor!=="none"):!1}_updateVisibility(e){this._captureIsActive()&&(e=document.captureElement),this._shouldShowCursor(e)?this._showCursor():this._hideCursor()}_updatePosition(){this._canvas.style.left=this._position.x+"px",this._canvas.style.top=this._position.y+"px"}_captureIsActive(){return document.captureElement&&document.documentElement.contains(document.captureElement)}}const lr=40*1024*1024,ai={CONNECTING:"connecting",OPEN:"open",CLOSING:"closing",CLOSED:"closed"},ii={CONNECTING:[WebSocket.CONNECTING,ai.CONNECTING],OPEN:[WebSocket.OPEN,ai.OPEN],CLOSING:[WebSocket.CLOSING,ai.CLOSING],CLOSED:[WebSocket.CLOSED,ai.CLOSED]},gl=["send","close","binaryType","onerror","onmessage","onopen","protocol","readyState"];class X_{constructor(){this._websocket=null,this._rQi=0,this._rQlen=0,this._rQbufferSize=1024*1024*4,this._rQ=null,this._sQbufferSize=1024*10,this._sQlen=0,this._sQ=null,this._eventHandlers={message:()=>{},open:()=>{},close:()=>{},error:()=>{}}}get readyState(){let e;return this._websocket===null?"unused":(e=this._websocket.readyState,ii.CONNECTING.includes(e)?"connecting":ii.OPEN.includes(e)?"open":ii.CLOSING.includes(e)?"closing":ii.CLOSED.includes(e)?"closed":"unknown")}rQpeek8(){return this._rQ[this._rQi]}rQskipBytes(e){this._rQi+=e}rQshift8(){return this._rQshift(1)}rQshift16(){return this._rQshift(2)}rQshift32(){return this._rQshift(4)}_rQshift(e){let s=0;for(let n=e-1;n>=0;n--)s+=this._rQ[this._rQi++]<<n*8;return s>>>0}rQlen(){return this._rQlen-this._rQi}rQshiftStr(e){let s="";for(let n=0;n<e;n+=4096){let a=this.rQshiftBytes(Math.min(4096,e-n),!1);s+=String.fromCharCode.apply(null,a)}return s}rQshiftBytes(e,s=!0){return this._rQi+=e,s?this._rQ.slice(this._rQi-e,this._rQi):this._rQ.subarray(this._rQi-e,this._rQi)}rQshiftTo(e,s){e.set(new Uint8Array(this._rQ.buffer,this._rQi,s)),this._rQi+=s}rQpeekBytes(e,s=!0){return s?this._rQ.slice(this._rQi,this._rQi+e):this._rQ.subarray(this._rQi,this._rQi+e)}rQwait(e,s,n){if(this._rQlen-this._rQi<s){if(n){if(this._rQi<n)throw new Error("rQwait cannot backup "+n+" bytes");this._rQi-=n}return!0}return!1}sQpush8(e){this._sQensureSpace(1),this._sQ[this._sQlen++]=e}sQpush16(e){this._sQensureSpace(2),this._sQ[this._sQlen++]=e>>8&255,this._sQ[this._sQlen++]=e>>0&255}sQpush32(e){this._sQensureSpace(4),this._sQ[this._sQlen++]=e>>24&255,this._sQ[this._sQlen++]=e>>16&255,this._sQ[this._sQlen++]=e>>8&255,this._sQ[this._sQlen++]=e>>0&255}sQpushString(e){let s=e.split("").map(n=>n.charCodeAt(0));this.sQpushBytes(new Uint8Array(s))}sQpushBytes(e){for(let s=0;s<e.length;){this._sQensureSpace(1);let n=this._sQbufferSize-this._sQlen;n>e.length-s&&(n=e.length-s),this._sQ.set(e.subarray(s,s+n),this._sQlen),this._sQlen+=n,s+=n}}flush(){this._sQlen>0&&this.readyState==="open"&&(this._websocket.send(new Uint8Array(this._sQ.buffer,0,this._sQlen)),this._sQlen=0)}_sQensureSpace(e){this._sQbufferSize-this._sQlen<e&&this.flush()}off(e){this._eventHandlers[e]=()=>{}}on(e,s){this._eventHandlers[e]=s}_allocateBuffers(){this._rQ=new Uint8Array(this._rQbufferSize),this._sQ=new Uint8Array(this._sQbufferSize)}init(){this._allocateBuffers(),this._rQi=0,this._websocket=null}open(e,s){this.attach(new WebSocket(e,s))}attach(e){this.init();const s=[...Object.keys(e),...Object.getOwnPropertyNames(Object.getPrototypeOf(e))];for(let n=0;n<gl.length;n++){const a=gl[n];if(s.indexOf(a)<0)throw new Error("Raw channel missing property: "+a)}this._websocket=e,this._websocket.binaryType="arraybuffer",this._websocket.onmessage=this._recvMessage.bind(this),this._websocket.onopen=()=>{Ce(">> WebSock.onopen"),this._websocket.protocol&&Gt("Server choose sub-protocol: "+this._websocket.protocol),this._eventHandlers.open(),Ce("<< WebSock.onopen")},this._websocket.onclose=n=>{Ce(">> WebSock.onclose"),this._eventHandlers.close(n),Ce("<< WebSock.onclose")},this._websocket.onerror=n=>{Ce(">> WebSock.onerror: "+n),this._eventHandlers.error(n),Ce("<< WebSock.onerror: "+n)}}close(){this._websocket&&((this.readyState==="connecting"||this.readyState==="open")&&(Gt("Closing WebSocket connection"),this._websocket.close()),this._websocket.onmessage=()=>{})}_expandCompactRQ(e){const s=(this._rQlen-this._rQi+e)*8,n=this._rQbufferSize<s;if(n&&(this._rQbufferSize=Math.max(this._rQbufferSize*2,s)),this._rQbufferSize>lr&&(this._rQbufferSize=lr,this._rQbufferSize-(this._rQlen-this._rQi)<e))throw new Error("Receive queue buffer exceeded "+lr+" bytes, and the new message could not fit");if(n){const a=this._rQ.buffer;this._rQ=new Uint8Array(this._rQbufferSize),this._rQ.set(new Uint8Array(a,this._rQi,this._rQlen-this._rQi))}else this._rQ.copyWithin(0,this._rQi,this._rQlen);this._rQlen=this._rQlen-this._rQi,this._rQi=0}_recvMessage(e){this._rQlen==this._rQi&&(this._rQlen=0,this._rQi=0);const s=new Uint8Array(e.data);s.length>this._rQbufferSize-this._rQlen&&this._expandCompactRQ(s.length),this._rQ.set(s,this._rQlen),this._rQlen+=s.length,this._rQlen-this._rQi>0?this._eventHandlers.message():Ce("Ignoring empty message")}}const L_={Again:57349,AltLeft:56,AltRight:57400,ArrowDown:57424,ArrowLeft:57419,ArrowRight:57421,ArrowUp:57416,AudioVolumeDown:57390,AudioVolumeMute:57376,AudioVolumeUp:57392,Backquote:41,Backslash:43,Backspace:14,BracketLeft:26,BracketRight:27,BrowserBack:57450,BrowserFavorites:57446,BrowserForward:57449,BrowserHome:57394,BrowserRefresh:57447,BrowserSearch:57445,BrowserStop:57448,CapsLock:58,Comma:51,ContextMenu:57437,ControlLeft:29,ControlRight:57373,Convert:121,Copy:57464,Cut:57404,Delete:57427,Digit0:11,Digit1:2,Digit2:3,Digit3:4,Digit4:5,Digit5:6,Digit6:7,Digit7:8,Digit8:9,Digit9:10,Eject:57469,End:57423,Enter:28,Equal:13,Escape:1,F1:59,F10:68,F11:87,F12:88,F13:93,F14:94,F15:95,F16:85,F17:57347,F18:57463,F19:57348,F2:60,F20:90,F21:116,F22:57465,F23:109,F24:111,F3:61,F4:62,F5:63,F6:64,F7:65,F8:66,F9:67,Find:57409,Help:57461,Hiragana:119,Home:57415,Insert:57426,IntlBackslash:86,IntlRo:115,IntlYen:125,KanaMode:112,Katakana:120,KeyA:30,KeyB:48,KeyC:46,KeyD:32,KeyE:18,KeyF:33,KeyG:34,KeyH:35,KeyI:23,KeyJ:36,KeyK:37,KeyL:38,KeyM:50,KeyN:49,KeyO:24,KeyP:25,KeyQ:16,KeyR:19,KeyS:31,KeyT:20,KeyU:22,KeyV:47,KeyW:17,KeyX:45,KeyY:21,KeyZ:44,Lang1:114,Lang2:113,Lang3:120,Lang4:119,Lang5:118,LaunchApp1:57451,LaunchApp2:57377,LaunchMail:57452,MediaPlayPause:57378,MediaSelect:57453,MediaStop:57380,MediaTrackNext:57369,MediaTrackPrevious:57360,MetaLeft:57435,MetaRight:57436,Minus:12,NonConvert:123,NumLock:69,Numpad0:82,Numpad1:79,Numpad2:80,Numpad3:81,Numpad4:75,Numpad5:76,Numpad6:77,Numpad7:71,Numpad8:72,Numpad9:73,NumpadAdd:78,NumpadComma:126,NumpadDecimal:83,NumpadDivide:57397,NumpadEnter:57372,NumpadEqual:89,NumpadMultiply:55,NumpadParenLeft:57462,NumpadParenRight:57467,NumpadSubtract:74,Open:100,PageDown:57425,PageUp:57417,Paste:101,Pause:57414,Period:52,Power:57438,PrintScreen:84,Props:57350,Quote:40,ScrollLock:70,Semicolon:39,ShiftLeft:42,ShiftRight:54,Slash:53,Sleep:57439,Space:57,Suspend:57381,Tab:15,Undo:57351,WakeUp:57443},Ee={encodingRaw:0,encodingCopyRect:1,encodingRRE:2,encodingHextile:5,encodingZlib:6,encodingTight:7,encodingZRLE:16,encodingTightPNG:-260,encodingJPEG:21,encodingH264:50,pseudoEncodingQualityLevel0:-32,pseudoEncodingDesktopSize:-223,pseudoEncodingLastRect:-224,pseudoEncodingCursor:-239,pseudoEncodingQEMUExtendedKeyEvent:-258,pseudoEncodingQEMULedEvent:-261,pseudoEncodingDesktopName:-307,pseudoEncodingExtendedDesktopSize:-308,pseudoEncodingXvp:-309,pseudoEncodingFence:-312,pseudoEncodingContinuousUpdates:-313,pseudoEncodingExtendedMouseButtons:-316,pseudoEncodingCompressLevel0:-256,pseudoEncodingVMwareCursor:1464686180,pseudoEncodingExtendedClipboard:3231835598};class Zr{constructor(){this._key=null}get algorithm(){return{name:"AES-ECB"}}static async importKey(e,s,n,a){const i=new Zr;return await i._importKey(e,n,a),i}async _importKey(e,s,n){this._key=await window.crypto.subtle.importKey("raw",e,{name:"AES-CBC"},s,n)}async encrypt(e,s){const n=new Uint8Array(s);if(n.length%16!==0||this._key===null)return null;const a=n.length/16;for(let i=0;i<a;i++){const r=new Uint8Array(await window.crypto.subtle.encrypt({name:"AES-CBC",iv:new Uint8Array(16)},this._key,n.slice(i*16,i*16+16))).slice(0,16);n.set(r,i*16)}return n}}class Jr{constructor(){this._rawKey=null,this._ctrKey=null,this._cbcKey=null,this._zeroBlock=new Uint8Array(16),this._prefixBlock0=this._zeroBlock,this._prefixBlock1=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]),this._prefixBlock2=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2])}get algorithm(){return{name:"AES-EAX"}}async _encryptBlock(e){const s=await window.crypto.subtle.encrypt({name:"AES-CBC",iv:this._zeroBlock},this._cbcKey,e);return new Uint8Array(s).slice(0,16)}async _initCMAC(){const e=await this._encryptBlock(this._zeroBlock),s=new Uint8Array(16),n=e[0]>>>6;for(let i=0;i<15;i++)s[i]=e[i+1]>>6|e[i]<<2,e[i]=e[i+1]>>7|e[i]<<1;const a=[0,135,14,137];s[14]^=n>>>1,s[15]=e[15]<<2^a[n],e[15]=e[15]<<1^a[n>>1],this._k1=e,this._k2=s}async _encryptCTR(e,s){const n=await window.crypto.subtle.encrypt({name:"AES-CTR",counter:s,length:128},this._ctrKey,e);return new Uint8Array(n)}async _decryptCTR(e,s){const n=await window.crypto.subtle.decrypt({name:"AES-CTR",counter:s,length:128},this._ctrKey,e);return new Uint8Array(n)}async _computeCMAC(e,s){if(s.length!==16)return null;const n=Math.floor(e.length/16),a=Math.ceil(e.length/16),i=e.length-n*16,r=new Uint8Array((a+1)*16);if(r.set(s),r.set(e,16),i===0)for(let l=0;l<16;l++)r[n*16+l]^=this._k1[l];else{r[(n+1)*16+i]=128;for(let l=0;l<16;l++)r[(n+1)*16+l]^=this._k2[l]}let o=await window.crypto.subtle.encrypt({name:"AES-CBC",iv:this._zeroBlock},this._cbcKey,r);return o=new Uint8Array(o),o.slice(o.length-32,o.length-16)}static async importKey(e,s,n,a){const i=new Jr;return await i._importKey(e),i}async _importKey(e){this._rawKey=e,this._ctrKey=await window.crypto.subtle.importKey("raw",e,{name:"AES-CTR"},!1,["encrypt","decrypt"]),this._cbcKey=await window.crypto.subtle.importKey("raw",e,{name:"AES-CBC"},!1,["encrypt"]),await this._initCMAC()}async encrypt(e,s){const n=e.additionalData,a=e.iv,i=await this._computeCMAC(a,this._prefixBlock0),r=await this._encryptCTR(s,i),o=await this._computeCMAC(n,this._prefixBlock1),d=await this._computeCMAC(r,this._prefixBlock2);for(let u=0;u<16;u++)d[u]^=i[u]^o[u];const l=new Uint8Array(16+r.length);return l.set(r),l.set(d,r.length),l}async decrypt(e,s){const n=s.slice(0,s.length-16),a=e.additionalData,i=e.iv,r=s.slice(s.length-16),o=await this._computeCMAC(i,this._prefixBlock0),d=await this._computeCMAC(a,this._prefixBlock1),l=await this._computeCMAC(n,this._prefixBlock2);for(let _=0;_<16;_++)l[_]^=o[_]^d[_];if(l.length!==r.length)return null;for(let _=0;_<r.length;_++)if(l[_]!==r[_])return null;return await this._decryptCTR(n,o)}}const xl=[13,16,10,23,0,4,2,27,14,5,20,9,22,18,11,3,25,7,15,6,26,19,12,1,40,51,30,36,46,54,29,39,50,44,32,47,43,48,38,55,33,52,45,41,49,35,28,31],P_=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],g=0;let P,B,Q,D,R,N;P=65536;B=1<<24;Q=P|B;D=4;R=1024;N=D|R;const bl=[Q|R,g|g,P|g,Q|N,Q|D,P|N,g|D,P|g,g|R,Q|R,Q|N,g|R,B|N,Q|D,B|g,g|D,g|N,B|R,B|R,P|R,P|R,Q|g,Q|g,B|N,P|D,B|D,B|D,P|D,g|g,g|N,P|N,B|g,P|g,Q|N,g|D,Q|g,Q|R,B|g,B|g,g|R,Q|D,P|g,P|R,B|D,g|R,g|D,B|N,P|N,Q|N,P|D,Q|g,B|N,B|D,g|N,P|N,Q|R,g|N,B|R,B|R,g|g,P|D,P|R,g|g,Q|D];P=1<<20;B=1<<31;Q=P|B;D=32;R=32768;N=D|R;const ml=[Q|N,B|R,g|R,P|N,P|g,g|D,Q|D,B|N,B|D,Q|N,Q|R,B|g,B|R,P|g,g|D,Q|D,P|R,P|D,B|N,g|g,B|g,g|R,P|N,Q|g,P|D,B|D,g|g,P|R,g|N,Q|R,Q|g,g|N,g|g,P|N,Q|D,P|g,B|N,Q|g,Q|R,g|R,Q|g,B|R,g|D,Q|N,P|N,g|D,g|R,B|g,g|N,Q|R,P|g,B|D,P|D,B|N,B|D,P|D,P|R,g|g,B|R,g|N,B|g,Q|D,Q|N,P|R];P=1<<17;B=1<<27;Q=P|B;D=8;R=512;N=D|R;const wl=[g|N,Q|R,g|g,Q|D,B|R,g|g,P|N,B|R,P|D,B|D,B|D,P|g,Q|N,P|D,Q|g,g|N,B|g,g|D,Q|R,g|R,P|R,Q|g,Q|D,P|N,B|N,P|R,P|g,B|N,g|D,Q|N,g|R,B|g,Q|R,B|g,P|D,g|N,P|g,Q|R,B|R,g|g,g|R,P|D,Q|N,B|R,B|D,g|R,g|g,Q|D,B|N,P|g,B|g,Q|N,g|D,P|N,P|R,B|D,Q|g,B|N,g|N,Q|g,P|N,g|D,Q|D,P|R];P=8192;B=1<<23;Q=P|B;D=1;R=128;N=D|R;const yl=[Q|D,P|N,P|N,g|R,Q|R,B|N,B|D,P|D,g|g,Q|g,Q|g,Q|N,g|N,g|g,B|R,B|D,g|D,P|g,B|g,Q|D,g|R,B|g,P|D,P|R,B|N,g|D,P|R,B|R,P|g,Q|R,Q|N,g|N,B|R,B|D,Q|g,Q|N,g|N,g|g,g|g,Q|g,P|R,B|R,B|N,g|D,Q|D,P|N,P|N,g|R,Q|N,g|N,g|D,P|g,B|D,P|D,Q|R,B|N,P|D,P|R,B|g,Q|D,g|R,B|g,P|g,Q|R];P=1<<25;B=1<<30;Q=P|B;D=256;R=1<<19;N=D|R;const kl=[g|D,P|N,P|R,Q|D,g|R,g|D,B|g,P|R,B|N,g|R,P|D,B|N,Q|D,Q|R,g|N,B|g,P|g,B|R,B|R,g|g,B|D,Q|N,Q|N,P|D,Q|R,B|D,g|g,Q|g,P|N,P|g,Q|g,g|N,g|R,Q|D,g|D,P|g,B|g,P|R,Q|D,B|N,P|D,B|g,Q|R,P|N,B|N,g|D,P|g,Q|R,Q|N,g|N,Q|g,Q|N,P|R,g|g,B|R,Q|g,g|N,P|D,B|D,g|R,g|g,B|R,P|N,B|D];P=1<<22;B=1<<29;Q=P|B;D=16;R=16384;N=D|R;const Sl=[B|D,Q|g,g|R,Q|N,Q|g,g|D,Q|N,P|g,B|R,P|N,P|g,B|D,P|D,B|R,B|g,g|N,g|g,P|D,B|N,g|R,P|R,B|N,g|D,Q|D,Q|D,g|g,P|N,Q|R,g|N,P|R,Q|R,B|g,B|R,g|D,Q|D,P|R,Q|N,P|g,g|N,B|D,P|g,B|R,B|g,g|N,B|D,Q|N,P|R,Q|g,P|N,Q|R,g|g,Q|D,g|D,g|R,Q|g,P|N,g|R,P|D,B|N,g|g,Q|R,B|g,P|D,B|N];P=1<<21;B=1<<26;Q=P|B;D=2;R=2048;N=D|R;const Cl=[P|g,Q|D,B|N,g|g,g|R,B|N,P|N,Q|R,Q|N,P|g,g|g,B|D,g|D,B|g,Q|D,g|N,B|R,P|N,P|D,B|R,B|D,Q|g,Q|R,P|D,Q|g,g|R,g|N,Q|N,P|R,g|D,B|g,P|R,B|g,P|R,P|g,B|N,B|N,Q|D,Q|D,g|D,P|D,B|g,B|R,P|g,Q|R,g|N,P|N,Q|R,g|N,B|D,Q|N,Q|g,P|R,g|g,g|D,Q|N,g|g,P|N,Q|g,g|R,B|D,B|R,g|R,P|D];P=1<<18;B=1<<28;Q=P|B;D=64;R=4096;N=D|R;const El=[B|N,g|R,P|g,Q|N,B|g,B|N,g|D,B|g,P|D,Q|g,Q|N,P|R,Q|R,P|N,g|R,g|D,Q|g,B|D,B|R,g|N,P|R,P|D,Q|D,Q|R,g|N,g|g,g|g,Q|D,B|D,B|R,P|N,P|g,P|N,P|g,Q|R,g|R,g|D,Q|D,g|R,P|N,B|R,g|D,B|D,Q|g,Q|D,B|g,P|g,B|N,g|g,Q|N,P|D,B|D,Q|g,B|R,B|N,g|g,Q|N,P|R,P|R,g|N,g|N,P|D,B|g,Q|R];class bd{constructor(e){this.keys=[];const s=[],n=[],a=[];for(let i=0,r=56;i<56;++i,r-=8){r+=r<-5?65:r<-3?31:r<-1?63:r===27?35:0;const o=r&7;s[i]=(e[r>>>3]&1<<o)!==0?1:0}for(let i=0;i<16;++i){const r=i<<1,o=r+1;a[r]=a[o]=0;for(let d=28;d<59;d+=28)for(let l=d-28;l<d;++l){const u=l+P_[i];n[l]=u<d?s[u]:s[u-28]}for(let d=0;d<24;++d)n[xl[d]]!==0&&(a[r]|=1<<23-d),n[xl[d+24]]!==0&&(a[o]|=1<<23-d)}for(let i=0,r=0,o=0;i<16;++i){const d=a[r++],l=a[r++];this.keys[o]=(d&16515072)<<6,this.keys[o]|=(d&4032)<<10,this.keys[o]|=(l&16515072)>>>10,this.keys[o]|=(l&4032)>>>6,++o,this.keys[o]=(d&258048)<<12,this.keys[o]|=(d&63)<<16,this.keys[o]|=(l&258048)>>>4,this.keys[o]|=l&63,++o}}enc8(e){const s=e.slice();let n=0,a,i,r;a=s[n++]<<24|s[n++]<<16|s[n++]<<8|s[n++],i=s[n++]<<24|s[n++]<<16|s[n++]<<8|s[n++],r=(a>>>4^i)&252645135,i^=r,a^=r<<4,r=(a>>>16^i)&65535,i^=r,a^=r<<16,r=(i>>>2^a)&858993459,a^=r,i^=r<<2,r=(i>>>8^a)&16711935,a^=r,i^=r<<8,i=i<<1|i>>>31&1,r=(a^i)&2863311530,a^=r,i^=r,a=a<<1|a>>>31&1;for(let o=0,d=0;o<8;++o){r=i<<28|i>>>4,r^=this.keys[d++];let l=Cl[r&63];l|=kl[r>>>8&63],l|=wl[r>>>16&63],l|=bl[r>>>24&63],r=i^this.keys[d++],l|=El[r&63],l|=Sl[r>>>8&63],l|=yl[r>>>16&63],l|=ml[r>>>24&63],a^=l,r=a<<28|a>>>4,r^=this.keys[d++],l=Cl[r&63],l|=kl[r>>>8&63],l|=wl[r>>>16&63],l|=bl[r>>>24&63],r=a^this.keys[d++],l|=El[r&63],l|=Sl[r>>>8&63],l|=yl[r>>>16&63],l|=ml[r>>>24&63],i^=l}for(i=i<<31|i>>>1,r=(a^i)&2863311530,a^=r,i^=r,a=a<<31|a>>>1,r=(a>>>8^i)&16711935,i^=r,a^=r<<8,r=(a>>>2^i)&858993459,i^=r,a^=r<<2,r=(i>>>16^a)&65535,a^=r,i^=r<<16,r=(i>>>4^a)&252645135,a^=r,i^=r<<4,r=[i,a],n=0;n<8;n++)s[n]=(r[n>>>2]>>>8*(3-n%4))%256,s[n]<0&&(s[n]+=256);return s}}class $r{constructor(){this._cipher=null}get algorithm(){return{name:"DES-ECB"}}static importKey(e,s,n,a){const i=new $r;return i._importKey(e),i}_importKey(e,s,n){this._cipher=new bd(e)}encrypt(e,s){const n=new Uint8Array(s);if(n.length%8!==0||this._cipher===null)return null;const a=n.length/8;for(let i=0;i<a;i++)n.set(this._cipher.enc8(n.slice(i*8,i*8+8)),i*8);return n}}class eo{constructor(){this._cipher=null}get algorithm(){return{name:"DES-CBC"}}static importKey(e,s,n,a){const i=new eo;return i._importKey(e),i}_importKey(e){this._cipher=new bd(e)}encrypt(e,s){const n=new Uint8Array(s);let a=new Uint8Array(e.iv);if(n.length%8!==0||this._cipher===null)return null;const i=n.length/8;for(let r=0;r<i;r++){for(let o=0;o<8;o++)a[o]^=s[r*8+o];a=this._cipher.enc8(a),n.set(a,r*8)}return n}}function yi(t,e,s){let n=1n;for(t=t%s;e>0n;)(e&1n)===1n&&(n=n*t%s),e=e>>1n,t=t*t%s;return n}function ki(t,e=0){let s=t.toString(16);e===0&&(e=Math.ceil(s.length/2)),s=s.padStart(e*2,"0");const n=s.length/2,a=new Uint8Array(n);for(let i=0;i<n;i++)a[i]=parseInt(s.slice(i*2,i*2+2),16);return a}function ys(t){let e="0x";for(let s=0;s<t.length;s++)e+=t[s].toString(16).padStart(2,"0");return BigInt(e)}class Si{constructor(){this._keyLength=0,this._keyBytes=0,this._n=null,this._e=null,this._d=null,this._nBigInt=null,this._eBigInt=null,this._dBigInt=null,this._extractable=!1}get algorithm(){return{name:"RSA-PKCS1-v1_5"}}_base64urlDecode(e){return e=e.replace(/-/g,"+").replace(/_/g,"/"),e=e.padEnd(Math.ceil(e.length/4)*4,"="),Gr.decode(e)}_padArray(e,s){const n=new Uint8Array(s);return n.set(e,s-e.length),n}static async generateKey(e,s,n){const a=new Si;return await a._generateKey(e,s),{privateKey:a}}async _generateKey(e,s){this._keyLength=e.modulusLength,this._keyBytes=Math.ceil(this._keyLength/8);const n=await window.crypto.subtle.generateKey({name:"RSA-OAEP",modulusLength:e.modulusLength,publicExponent:e.publicExponent,hash:{name:"SHA-256"}},!0,["encrypt","decrypt"]),a=await window.crypto.subtle.exportKey("jwk",n.privateKey);this._n=this._padArray(this._base64urlDecode(a.n),this._keyBytes),this._nBigInt=ys(this._n),this._e=this._padArray(this._base64urlDecode(a.e),this._keyBytes),this._eBigInt=ys(this._e),this._d=this._padArray(this._base64urlDecode(a.d),this._keyBytes),this._dBigInt=ys(this._d),this._extractable=s}static async importKey(e,s,n,a){if(a.length!==1||a[0]!=="encrypt")throw new Error("only support importing RSA public key");const i=new Si;return await i._importKey(e,n),i}async _importKey(e,s){const n=e.n,a=e.e;if(n.length!==a.length)throw new Error("the sizes of modulus and public exponent do not match");this._keyBytes=n.length,this._keyLength=this._keyBytes*8,this._n=new Uint8Array(this._keyBytes),this._e=new Uint8Array(this._keyBytes),this._n.set(n),this._e.set(a),this._nBigInt=ys(this._n),this._eBigInt=ys(this._e),this._extractable=s}async encrypt(e,s){if(s.length>this._keyBytes-11)return null;const n=new Uint8Array(this._keyBytes-s.length-3);window.crypto.getRandomValues(n);for(let o=0;o<n.length;o++)n[o]=Math.floor(n[o]*254/255+1);const a=new Uint8Array(this._keyBytes);a[1]=2,a.set(n,2),a.set(s,n.length+3);const i=ys(a),r=yi(i,this._eBigInt,this._nBigInt);return ki(r,this._keyBytes)}async decrypt(e,s){if(s.length!==this._keyBytes)return null;const n=ys(s),a=yi(n,this._dBigInt,this._nBigInt),i=ki(a,this._keyBytes);if(i[0]!==0||i[1]!==2)return null;let r=2;for(;r<i.length&&i[r]!==0;r++);return r===i.length?null:i.slice(r+1,i.length)}async exportKey(){if(!this._extractable)throw new Error("key is not extractable");return{n:this._n,e:this._e,d:this._d}}}class B_{constructor(e){this._key=e}get algorithm(){return{name:"DH"}}exportKey(){return this._key}}class to{constructor(){this._g=null,this._p=null,this._gBigInt=null,this._pBigInt=null,this._privateKey=null}get algorithm(){return{name:"DH"}}static generateKey(e,s){const n=new to;return n._generateKey(e),{privateKey:n,publicKey:new B_(n._publicKey)}}_generateKey(e){const s=e.g,n=e.p;this._keyBytes=n.length,this._gBigInt=ys(s),this._pBigInt=ys(n),this._privateKey=window.crypto.getRandomValues(new Uint8Array(this._keyBytes)),this._privateKeyBigInt=ys(this._privateKey),this._publicKey=ki(yi(this._gBigInt,this._privateKeyBigInt,this._pBigInt),this._keyBytes)}deriveBits(e,s){const n=Math.ceil(s/8),a=new Uint8Array(e.public),i=n>this._keyBytes?n:this._keyBytes,r=yi(ys(a),this._privateKeyBigInt,this._pBigInt);return ki(r,i).slice(0,i)}}async function D_(t){let e="";for(let s=0;s<t.length;s++)e+=String.fromCharCode(t[s]);return R_(Q_(N_(I_(e),8*e.length)))}function R_(t){let e=new Uint8Array(t.length);for(let s=0;s<t.length;s++)e[s]=t.charCodeAt(s);return e}function I_(t){let e=Array(t.length>>2);for(let s=0;s<e.length;s++)e[s]=0;for(let s=0;s<8*t.length;s+=8)e[s>>5]|=(255&t.charCodeAt(s/8))<<s%32;return e}function Q_(t){let e="";for(let s=0;s<32*t.length;s+=8)e+=String.fromCharCode(t[s>>5]>>>s%32&255);return e}function N_(t,e){t[e>>5]|=128<<e%32,t[14+(e+64>>>9<<4)]=e;let s=1732584193,n=-271733879,a=-1732584194,i=271733878;for(let r=0;r<t.length;r+=16){let o=s,d=n,l=a,u=i;n=Vt(n=Vt(n=Vt(n=Vt(n=Ot(n=Ot(n=Ot(n=Ot(n=zt(n=zt(n=zt(n=zt(n=Ht(n=Ht(n=Ht(n=Ht(n,a=Ht(a,i=Ht(i,s=Ht(s,n,a,i,t[r+0],7,-680876936),n,a,t[r+1],12,-389564586),s,n,t[r+2],17,606105819),i,s,t[r+3],22,-1044525330),a=Ht(a,i=Ht(i,s=Ht(s,n,a,i,t[r+4],7,-176418897),n,a,t[r+5],12,1200080426),s,n,t[r+6],17,-1473231341),i,s,t[r+7],22,-45705983),a=Ht(a,i=Ht(i,s=Ht(s,n,a,i,t[r+8],7,1770035416),n,a,t[r+9],12,-1958414417),s,n,t[r+10],17,-42063),i,s,t[r+11],22,-1990404162),a=Ht(a,i=Ht(i,s=Ht(s,n,a,i,t[r+12],7,1804603682),n,a,t[r+13],12,-40341101),s,n,t[r+14],17,-1502002290),i,s,t[r+15],22,1236535329),a=zt(a,i=zt(i,s=zt(s,n,a,i,t[r+1],5,-165796510),n,a,t[r+6],9,-1069501632),s,n,t[r+11],14,643717713),i,s,t[r+0],20,-373897302),a=zt(a,i=zt(i,s=zt(s,n,a,i,t[r+5],5,-701558691),n,a,t[r+10],9,38016083),s,n,t[r+15],14,-660478335),i,s,t[r+4],20,-405537848),a=zt(a,i=zt(i,s=zt(s,n,a,i,t[r+9],5,568446438),n,a,t[r+14],9,-1019803690),s,n,t[r+3],14,-187363961),i,s,t[r+8],20,1163531501),a=zt(a,i=zt(i,s=zt(s,n,a,i,t[r+13],5,-1444681467),n,a,t[r+2],9,-51403784),s,n,t[r+7],14,1735328473),i,s,t[r+12],20,-1926607734),a=Ot(a,i=Ot(i,s=Ot(s,n,a,i,t[r+5],4,-378558),n,a,t[r+8],11,-2022574463),s,n,t[r+11],16,1839030562),i,s,t[r+14],23,-35309556),a=Ot(a,i=Ot(i,s=Ot(s,n,a,i,t[r+1],4,-1530992060),n,a,t[r+4],11,1272893353),s,n,t[r+7],16,-155497632),i,s,t[r+10],23,-1094730640),a=Ot(a,i=Ot(i,s=Ot(s,n,a,i,t[r+13],4,681279174),n,a,t[r+0],11,-358537222),s,n,t[r+3],16,-722521979),i,s,t[r+6],23,76029189),a=Ot(a,i=Ot(i,s=Ot(s,n,a,i,t[r+9],4,-640364487),n,a,t[r+12],11,-421815835),s,n,t[r+15],16,530742520),i,s,t[r+2],23,-995338651),a=Vt(a,i=Vt(i,s=Vt(s,n,a,i,t[r+0],6,-198630844),n,a,t[r+7],10,1126891415),s,n,t[r+14],15,-1416354905),i,s,t[r+5],21,-57434055),a=Vt(a,i=Vt(i,s=Vt(s,n,a,i,t[r+12],6,1700485571),n,a,t[r+3],10,-1894986606),s,n,t[r+10],15,-1051523),i,s,t[r+1],21,-2054922799),a=Vt(a,i=Vt(i,s=Vt(s,n,a,i,t[r+8],6,1873313359),n,a,t[r+15],10,-30611744),s,n,t[r+6],15,-1560198380),i,s,t[r+13],21,1309151649),a=Vt(a,i=Vt(i,s=Vt(s,n,a,i,t[r+4],6,-145523070),n,a,t[r+11],10,-1120210379),s,n,t[r+2],15,718787259),i,s,t[r+9],21,-343485551),s=fn(s,o),n=fn(n,d),a=fn(a,l),i=fn(i,u)}return Array(s,n,a,i)}function Bi(t,e,s,n,a,i){return fn(U_(fn(fn(e,t),fn(n,i)),a),s)}function Ht(t,e,s,n,a,i,r){return Bi(e&s|~e&n,t,e,a,i,r)}function zt(t,e,s,n,a,i,r){return Bi(e&n|s&~n,t,e,a,i,r)}function Ot(t,e,s,n,a,i,r){return Bi(e^s^n,t,e,a,i,r)}function Vt(t,e,s,n,a,i,r){return Bi(s^(e|~n),t,e,a,i,r)}function fn(t,e){let s=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(s>>16)<<16|65535&s}function U_(t,e){return t<<e|t>>>32-e}class H_{constructor(){this._algorithms={"AES-ECB":Zr,"AES-EAX":Jr,"DES-ECB":$r,"DES-CBC":eo,"RSA-PKCS1-v1_5":Si,DH:to,MD5:D_}}encrypt(e,s,n){if(s.algorithm.name!==e.name)throw new Error("algorithm does not match");if(typeof s.encrypt!="function")throw new Error("key does not support encryption");return s.encrypt(e,n)}decrypt(e,s,n){if(s.algorithm.name!==e.name)throw new Error("algorithm does not match");if(typeof s.decrypt!="function")throw new Error("key does not support encryption");return s.decrypt(e,n)}importKey(e,s,n,a,i){if(e!=="raw")throw new Error("key format is not supported");const r=this._algorithms[n.name];if(typeof r>"u"||typeof r.importKey!="function")throw new Error("algorithm is not supported");return r.importKey(s,n,a,i)}generateKey(e,s,n){const a=this._algorithms[e.name];if(typeof a>"u"||typeof a.generateKey!="function")throw new Error("algorithm is not supported");return a.generateKey(e,s,n)}exportKey(e,s){if(e!=="raw")throw new Error("key format is not supported");if(typeof s.exportKey!="function")throw new Error("key does not support exportKey");return s.exportKey()}digest(e,s){const n=this._algorithms[e];if(typeof n!="function")throw new Error("algorithm is not supported");return n(s)}deriveBits(e,s,n){if(s.algorithm.name!==e.name)throw new Error("algorithm does not match");if(typeof s.deriveBits!="function")throw new Error("key does not support deriveBits");return s.deriveBits(e,n)}}const pt=new H_;class Al{constructor(){this._cipher=null,this._counter=new Uint8Array(16)}async setKey(e){this._cipher=await pt.importKey("raw",e,{name:"AES-EAX"},!1,["encrypt, decrypt"])}async makeMessage(e){const s=new Uint8Array([(e.length&65280)>>>8,e.length&255]),n=await pt.encrypt({name:"AES-EAX",iv:this._counter,additionalData:s},this._cipher,e);for(let i=0;i<16&&this._counter[i]++===255;i++);const a=new Uint8Array(e.length+2+16);return a.set(s),a.set(n,2),a}async receiveMessage(e,s){const n=new Uint8Array([(e&65280)>>>8,e&255]),a=await pt.decrypt({name:"AES-EAX",iv:this._counter,additionalData:n},this._cipher,s);for(let i=0;i<16&&this._counter[i]++===255;i++);return a}}class z_ extends jc{constructor(e,s){super(),this._hasStarted=!1,this._checkSock=null,this._checkCredentials=null,this._approveServerResolve=null,this._sockReject=null,this._credentialsReject=null,this._approveServerReject=null,this._sock=e,this._getCredentials=s}_waitSockAsync(e){return new Promise((s,n)=>{const a=()=>!this._sock.rQwait("RA2",e);a()?s():(this._checkSock=()=>{a()&&(s(),this._checkSock=null,this._sockReject=null)},this._sockReject=n)})}_waitApproveKeyAsync(){return new Promise((e,s)=>{this._approveServerResolve=e,this._approveServerReject=s})}_waitCredentialsAsync(e){const s=()=>e===1&&this._getCredentials().username!==void 0&&this._getCredentials().password!==void 0?!0:e===2&&this._getCredentials().password!==void 0;return new Promise((n,a)=>{s()?n():(this._checkCredentials=()=>{s()&&(n(),this._checkCredentials=null,this._credentialsReject=null)},this._credentialsReject=a)})}checkInternalEvents(){this._checkSock!==null&&this._checkSock(),this._checkCredentials!==null&&this._checkCredentials()}approveServer(){this._approveServerResolve!==null&&(this._approveServerResolve(),this._approveServerResolve=null)}disconnect(){this._sockReject!==null&&(this._sockReject(new Error("disconnect normally")),this._sockReject=null),this._credentialsReject!==null&&(this._credentialsReject(new Error("disconnect normally")),this._credentialsReject=null),this._approveServerReject!==null&&(this._approveServerReject(new Error("disconnect normally")),this._approveServerReject=null)}async negotiateRA2neAuthAsync(){this._hasStarted=!0,await this._waitSockAsync(4);const e=this._sock.rQpeekBytes(4),s=this._sock.rQshift32();if(s<1024)throw new Error("RA2: server public key is too short: "+s);if(s>8192)throw new Error("RA2: server public key is too long: "+s);const n=Math.ceil(s/8);await this._waitSockAsync(n*2);const a=this._sock.rQshiftBytes(n),i=this._sock.rQshiftBytes(n),r=await pt.importKey("raw",{n:a,e:i},{name:"RSA-PKCS1-v1_5"},!1,["encrypt"]),o=new Uint8Array(4+n*2);o.set(e),o.set(a,4),o.set(i,4+n);let d=this._waitApproveKeyAsync();this.dispatchEvent(new CustomEvent("serververification",{detail:{type:"RSA",publickey:o}})),await d;const l=2048,u=Math.ceil(l/8),_=(await pt.generateKey({name:"RSA-PKCS1-v1_5",modulusLength:l,publicExponent:new Uint8Array([1,0,1])},!0,["encrypt"])).privateKey,p=await pt.exportKey("raw",_),v=p.n,x=p.e,y=new Uint8Array(4+u*2);y[0]=(l&4278190080)>>>24,y[1]=(l&16711680)>>>16,y[2]=(l&65280)>>>8,y[3]=l&255,y.set(v,4),y.set(x,4+u),this._sock.sQpushBytes(y),this._sock.flush();const w=new Uint8Array(16);window.crypto.getRandomValues(w);const S=await pt.encrypt({name:"RSA-PKCS1-v1_5"},r,w),C=new Uint8Array(2+n);if(C[0]=(n&65280)>>>8,C[1]=n&255,C.set(S,2),this._sock.sQpushBytes(C),this._sock.flush(),await this._waitSockAsync(2),this._sock.rQshift16()!==u)throw new Error("RA2: wrong encrypted message length");const K=this._sock.rQshiftBytes(u),E=await pt.decrypt({name:"RSA-PKCS1-v1_5"},_,K);if(E===null||E.length!==16)throw new Error("RA2: corrupted server encrypted random");let U=new Uint8Array(32),te=new Uint8Array(32);U.set(E),U.set(w,16),te.set(w),te.set(E,16),U=await window.crypto.subtle.digest("SHA-1",U),U=new Uint8Array(U).slice(0,16),te=await window.crypto.subtle.digest("SHA-1",te),te=new Uint8Array(te).slice(0,16);const T=new Al;await T.setKey(U);const A=new Al;await A.setKey(te);let X=new Uint8Array(8+n*2+u*2),L=new Uint8Array(8+n*2+u*2);if(X.set(o),X.set(y,4+n*2),L.set(y),L.set(o,4+u*2),X=await window.crypto.subtle.digest("SHA-1",X),L=await window.crypto.subtle.digest("SHA-1",L),X=new Uint8Array(X),L=new Uint8Array(L),this._sock.sQpushBytes(await T.makeMessage(L)),this._sock.flush(),await this._waitSockAsync(38),this._sock.rQshift16()!==20)throw new Error("RA2: wrong server hash");const se=await A.receiveMessage(20,this._sock.rQshiftBytes(36));if(se===null)throw new Error("RA2: failed to authenticate the message");for(let ae=0;ae<20;ae++)if(se[ae]!==X[ae])throw new Error("RA2: wrong server hash");if(await this._waitSockAsync(19),this._sock.rQshift16()!==1)throw new Error("RA2: wrong subtype");let oe=await A.receiveMessage(1,this._sock.rQshiftBytes(17));if(oe===null)throw new Error("RA2: failed to authenticate the message");oe=oe[0];let de=this._waitCredentialsAsync(oe);if(oe===1)(this._getCredentials().username===void 0||this._getCredentials().password===void 0)&&this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["username","password"]}}));else if(oe===2)this._getCredentials().password===void 0&&this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["password"]}}));else throw new Error("RA2: wrong subtype");await de;let $;oe===1?$=js(this._getCredentials().username).slice(0,255):$="";const H=js(this._getCredentials().password).slice(0,255),ne=new Uint8Array($.length+H.length+2);ne[0]=$.length,ne[$.length+1]=H.length;for(let ae=0;ae<$.length;ae++)ne[ae+1]=$.charCodeAt(ae);for(let ae=0;ae<H.length;ae++)ne[$.length+2+ae]=H.charCodeAt(ae);this._sock.sQpushBytes(await T.makeMessage(ne)),this._sock.flush()}get hasStarted(){return this._hasStarted}set hasStarted(e){this._hasStarted=e}}class O_{constructor(){this._lines=0}decodeRect(e,s,n,a,i,r,o){if(n===0||a===0)return!0;this._lines===0&&(this._lines=a);const d=o==8?1:4,l=n*d;for(;this._lines>0;){if(i.rQwait("RAW",l))return!1;const u=s+(a-this._lines);let _=i.rQshiftBytes(l,!1);if(o==8){const p=new Uint8Array(n*4);for(let v=0;v<n;v++)p[v*4+0]=(_[v]>>0&3)*255/3,p[v*4+1]=(_[v]>>2&3)*255/3,p[v*4+2]=(_[v]>>4&3)*255/3,p[v*4+3]=255;_=p}for(let p=0;p<n;p++)_[p*4+3]=255;r.blitImage(e,u,n,1,_,0),this._lines--}return!0}}class V_{decodeRect(e,s,n,a,i,r,o){if(i.rQwait("COPYRECT",4))return!1;let d=i.rQshift16(),l=i.rQshift16();return n===0||a===0||r.copyImage(d,l,e,s,n,a),!0}}class G_{constructor(){this._subrects=0}decodeRect(e,s,n,a,i,r,o){if(this._subrects===0){if(i.rQwait("RRE",8))return!1;this._subrects=i.rQshift32();let d=i.rQshiftBytes(4);r.fillRect(e,s,n,a,d)}for(;this._subrects>0;){if(i.rQwait("RRE",12))return!1;let d=i.rQshiftBytes(4),l=i.rQshift16(),u=i.rQshift16(),_=i.rQshift16(),p=i.rQshift16();r.fillRect(e+l,s+u,_,p,d),this._subrects--}return!0}}class q_{constructor(){this._tiles=0,this._lastsubencoding=0,this._tileBuffer=new Uint8Array(256*4)}decodeRect(e,s,n,a,i,r,o){for(this._tiles===0&&(this._tilesX=Math.ceil(n/16),this._tilesY=Math.ceil(a/16),this._totalTiles=this._tilesX*this._tilesY,this._tiles=this._totalTiles);this._tiles>0;){let d=1;if(i.rQwait("HEXTILE",d))return!1;let l=i.rQpeek8();if(l>30)throw new Error("Illegal hextile subencoding (subencoding: "+l+")");const u=this._totalTiles-this._tiles,_=u%this._tilesX,p=Math.floor(u/this._tilesX),v=e+_*16,x=s+p*16,y=Math.min(16,e+n-v),w=Math.min(16,s+a-x);if(l&1)d+=y*w*4;else if(l&2&&(d+=4),l&4&&(d+=4),l&8){if(d++,i.rQwait("HEXTILE",d))return!1;let S=i.rQpeekBytes(d).at(-1);l&16?d+=S*6:d+=S*2}if(i.rQwait("HEXTILE",d))return!1;if(i.rQshift8(),l===0)this._lastsubencoding&1?Ce(" Ignoring blank after RAW"):r.fillRect(v,x,y,w,this._background);else if(l&1){let S=y*w,C=i.rQshiftBytes(S*4,!1);for(let K=0;K<S;K++)C[K*4+3]=255;r.blitImage(v,x,y,w,C,0)}else{if(l&2&&(this._background=new Uint8Array(i.rQshiftBytes(4))),l&4&&(this._foreground=new Uint8Array(i.rQshiftBytes(4))),this._startTile(v,x,y,w,this._background),l&8){let S=i.rQshift8();for(let C=0;C<S;C++){let K;l&16?K=i.rQshiftBytes(4):K=this._foreground;const E=i.rQshift8(),U=E>>4,te=E&15,T=i.rQshift8(),A=(T>>4)+1,X=(T&15)+1;this._subTile(U,te,A,X,K)}}this._finishTile(r)}this._lastsubencoding=l,this._tiles--}return!0}_startTile(e,s,n,a,i){this._tileX=e,this._tileY=s,this._tileW=n,this._tileH=a;const r=i[0],o=i[1],d=i[2],l=this._tileBuffer;for(let u=0;u<n*a*4;u+=4)l[u]=r,l[u+1]=o,l[u+2]=d,l[u+3]=255}_subTile(e,s,n,a,i){const r=i[0],o=i[1],d=i[2],l=e+n,u=s+a,_=this._tileBuffer,p=this._tileW;for(let v=s;v<u;v++)for(let x=e;x<l;x++){const y=(x+v*p)*4;_[y]=r,_[y+1]=o,_[y+2]=d,_[y+3]=255}}_finishTile(e){e.blitImage(this._tileX,this._tileY,this._tileW,this._tileH,this._tileBuffer,0)}}class W_{constructor(){this._zlib=new Xi,this._length=0}decodeRect(e,s,n,a,i,r,o){if(n===0||a===0)return!0;if(this._length===0){if(i.rQwait("ZLIB",4))return!1;this._length=i.rQshift32()}if(i.rQwait("ZLIB",this._length))return!1;let d=new Uint8Array(i.rQshiftBytes(this._length,!1));this._length=0,this._zlib.setInput(d),d=this._zlib.inflate(n*a*4),this._zlib.setInput(null);for(let l=0;l<n*a;l++)d[l*4+3]=255;return r.blitImage(e,s,n,a,d,0),!0}}class md{constructor(){this._ctl=null,this._filter=null,this._numColors=0,this._palette=new Uint8Array(1024),this._len=0,this._zlibs=[];for(let e=0;e<4;e++)this._zlibs[e]=new Xi}decodeRect(e,s,n,a,i,r,o){if(this._ctl===null){if(i.rQwait("TIGHT compression-control",1))return!1;this._ctl=i.rQshift8();for(let l=0;l<4;l++)this._ctl>>l&1&&(this._zlibs[l].reset(),Gt("Reset zlib stream "+l));this._ctl=this._ctl>>4}let d;if(this._ctl===8)d=this._fillRect(e,s,n,a,i,r,o);else if(this._ctl===9)d=this._jpegRect(e,s,n,a,i,r,o);else if(this._ctl===10)d=this._pngRect(e,s,n,a,i,r,o);else if((this._ctl&8)==0)d=this._basicRect(this._ctl,e,s,n,a,i,r,o);else throw new Error("Illegal tight compression received (ctl: "+this._ctl+")");return d&&(this._ctl=null),d}_fillRect(e,s,n,a,i,r,o){if(i.rQwait("TIGHT",3))return!1;let d=i.rQshiftBytes(3);return r.fillRect(e,s,n,a,d,!1),!0}_jpegRect(e,s,n,a,i,r,o){let d=this._readData(i);return d===null?!1:(r.imageRect(e,s,n,a,"image/jpeg",d),!0)}_pngRect(e,s,n,a,i,r,o){throw new Error("PNG received in standard Tight rect")}_basicRect(e,s,n,a,i,r,o,d){if(this._filter===null)if(e&4){if(r.rQwait("TIGHT",1))return!1;this._filter=r.rQshift8()}else this._filter=0;let l=e&3,u;switch(this._filter){case 0:u=this._copyFilter(l,s,n,a,i,r,o,d);break;case 1:u=this._paletteFilter(l,s,n,a,i,r,o,d);break;case 2:u=this._gradientFilter(l,s,n,a,i,r,o,d);break;default:throw new Error("Illegal tight filter received (ctl: "+this._filter+")")}return u&&(this._filter=null),u}_copyFilter(e,s,n,a,i,r,o,d){const l=a*i*3;let u;if(l===0)return!0;if(l<12){if(r.rQwait("TIGHT",l))return!1;u=r.rQshiftBytes(l)}else{if(u=this._readData(r),u===null)return!1;this._zlibs[e].setInput(u),u=this._zlibs[e].inflate(l),this._zlibs[e].setInput(null)}let _=new Uint8Array(a*i*4);for(let p=0,v=0;p<a*i*4;p+=4,v+=3)_[p]=u[v],_[p+1]=u[v+1],_[p+2]=u[v+2],_[p+3]=255;return o.blitImage(s,n,a,i,_,0,!1),!0}_paletteFilter(e,s,n,a,i,r,o,d){if(this._numColors===0){if(r.rQwait("TIGHT palette",1))return!1;const v=r.rQpeek8()+1,x=v*3;if(r.rQwait("TIGHT palette",1+x))return!1;this._numColors=v,r.rQskipBytes(1),r.rQshiftTo(this._palette,x)}const l=this._numColors<=2?1:8,_=Math.floor((a*l+7)/8)*i;let p;if(_===0)return!0;if(_<12){if(r.rQwait("TIGHT",_))return!1;p=r.rQshiftBytes(_)}else{if(p=this._readData(r),p===null)return!1;this._zlibs[e].setInput(p),p=this._zlibs[e].inflate(_),this._zlibs[e].setInput(null)}return this._numColors==2?this._monoRect(s,n,a,i,p,this._palette,o):this._paletteRect(s,n,a,i,p,this._palette,o),this._numColors=0,!0}_monoRect(e,s,n,a,i,r,o){const d=this._getScratchBuffer(n*a*4),l=Math.floor((n+7)/8),u=Math.floor(n/8);for(let _=0;_<a;_++){let p,v,x;for(x=0;x<u;x++)for(let y=7;y>=0;y--)p=(_*n+x*8+7-y)*4,v=(i[_*l+x]>>y&1)*3,d[p]=r[v],d[p+1]=r[v+1],d[p+2]=r[v+2],d[p+3]=255;for(let y=7;y>=8-n%8;y--)p=(_*n+x*8+7-y)*4,v=(i[_*l+x]>>y&1)*3,d[p]=r[v],d[p+1]=r[v+1],d[p+2]=r[v+2],d[p+3]=255}o.blitImage(e,s,n,a,d,0,!1)}_paletteRect(e,s,n,a,i,r,o){const d=this._getScratchBuffer(n*a*4),l=n*a*4;for(let u=0,_=0;u<l;u+=4,_++){const p=i[_]*3;d[u]=r[p],d[u+1]=r[p+1],d[u+2]=r[p+2],d[u+3]=255}o.blitImage(e,s,n,a,d,0,!1)}_gradientFilter(e,s,n,a,i,r,o,d){const l=a*i*3;let u;if(l===0)return!0;if(l<12){if(r.rQwait("TIGHT",l))return!1;u=r.rQshiftBytes(l)}else{if(u=this._readData(r),u===null)return!1;this._zlibs[e].setInput(u),u=this._zlibs[e].inflate(l),this._zlibs[e].setInput(null)}let _=new Uint8Array(4*a*i),p=0,v=0,x=new Uint8Array(3);for(let C=0;C<a;C++){for(let K=0;K<3;K++){const E=x[K],U=u[v++]+E;_[p++]=U,x[K]=U}_[p++]=255}let y=0,w=new Uint8Array(3),S=new Uint8Array(3);for(let C=1;C<i;C++){x.fill(0),S.fill(0);for(let K=0;K<a;K++){for(let E=0;E<3;E++){w[E]=_[y++];let U=x[E]+w[E]-S[E];U<0?U=0:U>255&&(U=255);const te=u[v++]+U;_[p++]=te,S[E]=w[E],x[E]=te}_[p++]=255,y++}}return o.blitImage(s,n,a,i,_,0,!1),!0}_readData(e){if(this._len===0){if(e.rQwait("TIGHT",3))return null;let n;n=e.rQshift8(),this._len=n&127,n&128&&(n=e.rQshift8(),this._len|=(n&127)<<7,n&128&&(n=e.rQshift8(),this._len|=n<<14))}if(e.rQwait("TIGHT",this._len))return null;let s=e.rQshiftBytes(this._len,!1);return this._len=0,s}_getScratchBuffer(e){return(!this._scratchBuffer||this._scratchBuffer.length<e)&&(this._scratchBuffer=new Uint8Array(e)),this._scratchBuffer}}class j_ extends md{_pngRect(e,s,n,a,i,r,o){let d=this._readData(i);return d===null?!1:(r.imageRect(e,s,n,a,"image/png",d),!0)}_basicRect(e,s,n,a,i,r,o,d){throw new Error("BasicCompression received in TightPNG rect")}}const ri=64,oi=64;class Y_{constructor(){this._length=0,this._inflator=new Xi,this._pixelBuffer=new Uint8Array(ri*oi*4),this._tileBuffer=new Uint8Array(ri*oi*4)}decodeRect(e,s,n,a,i,r,o){if(this._length===0){if(i.rQwait("ZLib data length",4))return!1;this._length=i.rQshift32()}if(i.rQwait("Zlib data",this._length))return!1;const d=i.rQshiftBytes(this._length,!1);this._inflator.setInput(d);for(let l=s;l<s+a;l+=oi){let u=Math.min(oi,s+a-l);for(let _=e;_<e+n;_+=ri){let p=Math.min(ri,e+n-_);const v=p*u,x=this._inflator.inflate(1)[0];if(x===0){const y=this._readPixels(v);r.blitImage(_,l,p,u,y,0,!1)}else if(x===1){const y=this._readPixels(1);r.fillRect(_,l,p,u,[y[0],y[1],y[2]])}else if(x>=2&&x<=16){const y=this._decodePaletteTile(x,v,p,u);r.blitImage(_,l,p,u,y,0,!1)}else if(x===128){const y=this._decodeRLETile(v);r.blitImage(_,l,p,u,y,0,!1)}else if(x>=130&&x<=255){const y=this._decodeRLEPaletteTile(x-128,v);r.blitImage(_,l,p,u,y,0,!1)}else throw new Error("Unknown subencoding: "+x)}}return this._length=0,!0}_getBitsPerPixelInPalette(e){if(e<=2)return 1;if(e<=4)return 2;if(e<=16)return 4}_readPixels(e){let s=this._pixelBuffer;const n=this._inflator.inflate(3*e);for(let a=0,i=0;a<e*4;a+=4,i+=3)s[a]=n[i],s[a+1]=n[i+1],s[a+2]=n[i+2],s[a+3]=255;return s}_decodePaletteTile(e,s,n,a){const i=this._tileBuffer,r=this._readPixels(e),o=this._getBitsPerPixelInPalette(e),d=(1<<o)-1;let l=0,u=this._inflator.inflate(1)[0];for(let _=0;_<a;_++){let p=8-o;for(let v=0;v<n;v++){p<0&&(p=8-o,u=this._inflator.inflate(1)[0]);let x=u>>p&d;i[l]=r[x*4],i[l+1]=r[x*4+1],i[l+2]=r[x*4+2],i[l+3]=r[x*4+3],l+=4,p-=o}p<8-o&&_<a-1&&(u=this._inflator.inflate(1)[0])}return i}_decodeRLETile(e){const s=this._tileBuffer;let n=0;for(;n<e;){const a=this._readPixels(1),i=this._readRLELength();for(let r=0;r<i;r++)s[n*4]=a[0],s[n*4+1]=a[1],s[n*4+2]=a[2],s[n*4+3]=a[3],n++}return s}_decodeRLEPaletteTile(e,s){const n=this._tileBuffer,a=this._readPixels(e);let i=0;for(;i<s;){let r=this._inflator.inflate(1)[0],o=1;if(r>=128&&(r-=128,o=this._readRLELength()),r>e)throw new Error("Too big index in palette: "+r+", palette size: "+e);if(i+o>s)throw new Error("Too big rle length in palette mode: "+o+", allowed length is: "+(s-i));for(let d=0;d<o;d++)n[i*4]=a[r*4],n[i*4+1]=a[r*4+1],n[i*4+2]=a[r*4+2],n[i*4+3]=a[r*4+3],i++}return n}_readRLELength(){let e=0,s=0;do s=this._inflator.inflate(1)[0],e+=s;while(s===255);return e+1}}class Z_{constructor(){this._cachedQuantTables=[],this._cachedHuffmanTables=[],this._segments=[]}decodeRect(e,s,n,a,i,r,o){for(;;){let v=this._readSegment(i);if(v===null)return!1;if(this._segments.push(v),v[1]===217)break}let d=[],l=[];for(let v of this._segments){let x=v[1];x===196?d.push(v):x===219&&l.push(v)}const u=this._segments.findIndex(v=>v[1]==192||v[1]==194);if(u==-1)throw new Error("Illegal JPEG image without SOF");l.length===0&&this._segments.splice(u+1,0,...this._cachedQuantTables),d.length===0&&this._segments.splice(u+1,0,...this._cachedHuffmanTables);let _=0;for(let v of this._segments)_+=v.length;let p=new Uint8Array(_);_=0;for(let v of this._segments)p.set(v,_),_+=v.length;return r.imageRect(e,s,n,a,"image/jpeg",p),d.length!==0&&(this._cachedHuffmanTables=d),l.length!==0&&(this._cachedQuantTables=l),this._segments=[],!0}_readSegment(e){if(e.rQwait("JPEG",2))return null;let s=e.rQshift8();if(s!=255)throw new Error("Illegal JPEG marker received (byte: "+s+")");let n=e.rQshift8();if(n>=208&&n<=217||n==1)return new Uint8Array([s,n]);if(e.rQwait("JPEG",2,2))return null;let a=e.rQshift16();if(a<2)throw new Error("Illegal JPEG length received (length: "+a+")");if(e.rQwait("JPEG",a-2,4))return null;let i=0;if(n===218){if(e.rQwait("JPEG",a-2+2,4))return null;let o=e.rQlen(),d=e.rQpeekBytes(o,!1);for(;;){let l=d.indexOf(255,a-2+i);if(l===-1||l===o-1)return e.rQwait("JPEG",1/0,4),null;if(d.at(l+1)===0||d.at(l+1)>=208&&d.at(l+1)<=215){i=l+2-(a-2);continue}i=l-(a-2);break}}let r=new Uint8Array(2+a+i);return r[0]=s,r[1]=n,r[2]=a>>8,r[3]=a,r.set(e.rQshiftBytes(a-2+i,!1),4),r}}class J_{constructor(e){this._data=e,this._index=0,this.profileIdc=null,this.constraintSet=null,this.levelIdc=null}_getStartSequenceLen(e){let s=this._data;return s[e+0]==0&&s[e+1]==0&&s[e+2]==0&&s[e+3]==1?4:s[e+0]==0&&s[e+1]==0&&s[e+2]==1?3:0}_indexOfNextNalUnit(e){let s=this._data;for(let n=e;n<s.length;++n)if(this._getStartSequenceLen(n)!=0)return n;return-1}_parseSps(e){this.profileIdc=this._data[e],this.constraintSet=this._data[e+1],this.levelIdc=this._data[e+2]}_parseNalUnit(e){const s=this._data[e];if(s&128)throw new Error("H264 parsing sanity check failed, forbidden zero bit is set");const n=s&31;switch(n){case 1:return{slice:!0};case 5:return{slice:!0,key:!0};case 6:return{};case 7:return this._parseSps(e+1),{};case 8:return{};default:Wt("Unhandled unit type: ",n);break}return{}}parse(){const e=this._index;let s=!1;for(;this._index<this._data.length;){const n=this._getStartSequenceLen(this._index);if(n==0)throw new Error("Invalid start sequence in bit stream");const{slice:a,key:i}=this._parseNalUnit(this._index+n);let r=this._indexOfNextNalUnit(this._index+n);if(r==-1?this._index=this._data.length:this._index=r,i&&(s=!0),a)break}return e===this._index?null:{frame:this._data.subarray(e,this._index),key:s}}}class $_{constructor(e,s){this.lastUsed=0,this._width=e,this._height=s,this._profileIdc=null,this._constraintSet=null,this._levelIdc=null,this._decoder=null,this._pendingFrames=[]}_handleFrame(e){let s=this._pendingFrames.shift();if(s===void 0)throw new Error("Pending frame queue empty when receiving frame from decoder");if(s.timestamp!=e.timestamp)throw new Error("Video frame timestamp mismatch. Expected "+e.timestamp+" but but got "+s.timestamp);s.frame=e,s.ready=!0,s.resolve(),s.keep||e.close()}_handleError(e){throw new Error("Failed to decode frame: "+e.message)}_configureDecoder(e,s,n){(this._decoder===null||this._decoder.state==="closed")&&(this._decoder=new VideoDecoder({output:i=>this._handleFrame(i),error:i=>this._handleError(i)}));const a="avc1."+e.toString(16).padStart(2,"0")+s.toString(16).padStart(2,"0")+n.toString(16).padStart(2,"0");this._decoder.configure({codec:a,codedWidth:this._width,codedHeight:this._height,optimizeForLatency:!0})}_preparePendingFrame(e){let s={timestamp:e,promise:null,resolve:null,frame:null,ready:!1,keep:!1};return s.promise=new Promise(n=>{s.resolve=n}),this._pendingFrames.push(s),s}decode(e){let s=new J_(e),n=null,a=Math.round(window.performance.now()*1e3);for(;;){let i=s.parse();if(i===null)break;if(s.profileIdc!==null&&(self._profileIdc=s.profileIdc,self._constraintSet=s.constraintSet,self._levelIdc=s.levelIdc),this._decoder===null||this._decoder.state!=="configured"){if(!i.key){Wt("Missing key frame. Can't decode until one arrives");continue}if(self._profileIdc===null){Wt("Cannot config decoder. Have not received SPS and PPS yet.");continue}this._configureDecoder(self._profileIdc,self._constraintSet,self._levelIdc)}n=this._preparePendingFrame(a);const r=new EncodedVideoChunk({timestamp:a,type:i.key?"key":"delta",data:i.frame});try{this._decoder.decode(r)}catch(o){Wt("Failed to decode:",o)}}return n!==null&&(n.keep=!0),n}}class ev{constructor(){this._tick=0,this._contexts={}}_contextId(e,s,n,a){return[e,s,n,a].join(",")}_findOldestContextId(){let e=Number.MAX_VALUE,s;for(const[n,a]of Object.entries(this._contexts))a.lastUsed<e&&(e=a.lastUsed,s=n);return s}_createContext(e,s,n,a){if(Object.keys(this._contexts).length>=64){let o=this._findOldestContextId();delete this._contexts[o]}let r=new $_(n,a);return this._contexts[this._contextId(e,s,n,a)]=r,r}_getContext(e,s,n,a){let i=this._contexts[this._contextId(e,s,n,a)];return i!==void 0?i:this._createContext(e,s,n,a)}_resetContext(e,s,n,a){delete this._contexts[this._contextId(e,s,n,a)]}_resetAllContexts(){this._contexts={}}decodeRect(e,s,n,a,i,r,o){if(i.rQwait("h264 header",8))return!1;const u=i.rQshift32(),_=i.rQshift32();if(i.rQwait("h264 payload",u,8))return!1;_&2?this._resetAllContexts():_&1&&this._resetContext(e,s,n,a);let p=this._getContext(e,s,n,a);if(p.lastUsed=this._tick++,u!==0){let v=i.rQshiftBytes(u,!1),x=p.decode(v);x!==null&&r.videoFrame(e,s,n,a,x)}return!0}}const tv=3,sv="rgb(40, 40, 40)",Kl=17,Fl=50,Tl=19,ga=75,ln=50,nv=1e3,av=50,Ml=1,li=2,Xl=6,Ll=16,cr=19,Pl=22,Bl=30,Dl=113,Rl=129,Il=256,Qs=1,Ql=1<<24,hi=1<<25,Nl=1<<26,ka=1<<27,fi=1<<28;class Le extends jc{constructor(e,s,n){if(!e)throw new Error("Must specify target");if(!s)throw new Error("Must specify URL, WebSocket or RTCDataChannel");window.isSecureContext||ot("noVNC requires a secure context (TLS). Expect crashes!"),super(),this._target=e,typeof s=="string"?this._url=s:(this._url=null,this._rawChannel=s),n=n||{},this._rfbCredentials=n.credentials||{},this._shared="shared"in n?!!n.shared:!0,this._repeaterID=n.repeaterID||"",this._wsProtocols=n.wsProtocols||[],this._rfbConnectionState="",this._rfbInitState="",this._rfbAuthScheme=-1,this._rfbCleanDisconnect=!0,this._rfbRSAAESAuthenticationState=null,this._rfbVersion=0,this._rfbMaxVersion=3.8,this._rfbTightVNC=!1,this._rfbVeNCryptState=0,this._rfbXvpVer=0,this._fbWidth=0,this._fbHeight=0,this._fbName="",this._capabilities={power:!1},this._supportsFence=!1,this._supportsContinuousUpdates=!1,this._enabledContinuousUpdates=!1,this._supportsSetDesktopSize=!1,this._screenID=0,this._screenFlags=0,this._pendingRemoteResize=!1,this._lastResize=0,this._qemuExtKeyEventSupported=!1,this._extendedPointerEventSupported=!1,this._clipboardText=null,this._clipboardServerCapabilitiesActions={},this._clipboardServerCapabilitiesFormats={},this._sock=null,this._display=null,this._flushing=!1,this._keyboard=null,this._gestures=null,this._resizeObserver=null,this._disconnTimer=null,this._resizeTimeout=null,this._mouseMoveTimer=null,this._decoders={},this._FBU={rects:0,x:0,y:0,width:0,height:0,encoding:null},this._mousePos={},this._mouseButtonMask=0,this._mouseLastMoveTime=0,this._viewportDragging=!1,this._viewportDragPos={},this._viewportHasMoved=!1,this._accumulatedWheelDeltaX=0,this._accumulatedWheelDeltaY=0,this._gestureLastTapTime=null,this._gestureFirstDoubleTapEv=null,this._gestureLastMagnitudeX=0,this._gestureLastMagnitudeY=0,this._eventHandlers={focusCanvas:this._focusCanvas.bind(this),handleResize:this._handleResize.bind(this),handleMouse:this._handleMouse.bind(this),handleWheel:this._handleWheel.bind(this),handleGesture:this._handleGesture.bind(this),handleRSAAESCredentialsRequired:this._handleRSAAESCredentialsRequired.bind(this),handleRSAAESServerVerification:this._handleRSAAESServerVerification.bind(this)},Ce(">> RFB.constructor"),this._screen=document.createElement("div"),this._screen.style.display="flex",this._screen.style.width="100%",this._screen.style.height="100%",this._screen.style.overflow="auto",this._screen.style.background=sv,this._canvas=document.createElement("canvas"),this._canvas.style.margin="auto",this._canvas.style.outline="none",this._canvas.width=0,this._canvas.height=0,this._canvas.tabIndex=-1,this._screen.appendChild(this._canvas),this._cursor=new M_,this._cursorImage=Le.cursors.none,this._decoders[Ee.encodingRaw]=new O_,this._decoders[Ee.encodingCopyRect]=new V_,this._decoders[Ee.encodingRRE]=new G_,this._decoders[Ee.encodingHextile]=new q_,this._decoders[Ee.encodingZlib]=new W_,this._decoders[Ee.encodingTight]=new md,this._decoders[Ee.encodingTightPNG]=new j_,this._decoders[Ee.encodingZRLE]=new Y_,this._decoders[Ee.encodingJPEG]=new Z_,this._decoders[Ee.encodingH264]=new ev;try{this._display=new tf(this._canvas)}catch(a){throw ot("Display exception: "+a),a}this._keyboard=new C_(this._canvas),this._keyboard.onkeyevent=this._handleKeyEvent.bind(this),this._remoteCapsLock=null,this._remoteNumLock=null,this._gestures=new T_,this._sock=new X_,this._sock.on("open",this._socketOpen.bind(this)),this._sock.on("close",this._socketClose.bind(this)),this._sock.on("message",this._handleMessage.bind(this)),this._sock.on("error",this._socketError.bind(this)),this._expectedClientWidth=null,this._expectedClientHeight=null,this._resizeObserver=new ResizeObserver(this._eventHandlers.handleResize),this._updateConnectionState("connecting"),Ce("<< RFB.constructor"),this.dragViewport=!1,this.focusOnClick=!0,this._viewOnly=!1,this._clipViewport=!1,this._clippingViewport=!1,this._scaleViewport=!1,this._resizeSession=!1,this._showDotCursor=!1,this._qualityLevel=6,this._compressionLevel=2}get viewOnly(){return this._viewOnly}set viewOnly(e){this._viewOnly=e,(this._rfbConnectionState==="connecting"||this._rfbConnectionState==="connected")&&(e?this._keyboard.ungrab():this._keyboard.grab())}get capabilities(){return this._capabilities}get clippingViewport(){return this._clippingViewport}_setClippingViewport(e){e!==this._clippingViewport&&(this._clippingViewport=e,this.dispatchEvent(new CustomEvent("clippingviewport",{detail:this._clippingViewport})))}get touchButton(){return 0}set touchButton(e){Wt("Using old API!")}get clipViewport(){return this._clipViewport}set clipViewport(e){this._clipViewport=e,this._updateClip()}get scaleViewport(){return this._scaleViewport}set scaleViewport(e){this._scaleViewport=e,e&&this._clipViewport&&this._updateClip(),this._updateScale(),!e&&this._clipViewport&&this._updateClip()}get resizeSession(){return this._resizeSession}set resizeSession(e){this._resizeSession=e,e&&this._requestRemoteResize()}get showDotCursor(){return this._showDotCursor}set showDotCursor(e){this._showDotCursor=e,this._refreshCursor()}get background(){return this._screen.style.background}set background(e){this._screen.style.background=e}get qualityLevel(){return this._qualityLevel}set qualityLevel(e){if(!Number.isInteger(e)||e<0||e>9){ot("qualityLevel must be an integer between 0 and 9");return}this._qualityLevel!==e&&(this._qualityLevel=e,this._rfbConnectionState==="connected"&&this._sendEncodings())}get compressionLevel(){return this._compressionLevel}set compressionLevel(e){if(!Number.isInteger(e)||e<0||e>9){ot("compressionLevel must be an integer between 0 and 9");return}this._compressionLevel!==e&&(this._compressionLevel=e,this._rfbConnectionState==="connected"&&this._sendEncodings())}disconnect(){this._updateConnectionState("disconnecting"),this._sock.off("error"),this._sock.off("message"),this._sock.off("open"),this._rfbRSAAESAuthenticationState!==null&&this._rfbRSAAESAuthenticationState.disconnect()}approveServer(){this._rfbRSAAESAuthenticationState!==null&&this._rfbRSAAESAuthenticationState.approveServer()}sendCredentials(e){this._rfbCredentials=e,this._resumeAuthentication()}sendCtrlAltDel(){this._rfbConnectionState!=="connected"||this._viewOnly||(Gt("Sending Ctrl-Alt-Del"),this.sendKey(m.XK_Control_L,"ControlLeft",!0),this.sendKey(m.XK_Alt_L,"AltLeft",!0),this.sendKey(m.XK_Delete,"Delete",!0),this.sendKey(m.XK_Delete,"Delete",!1),this.sendKey(m.XK_Alt_L,"AltLeft",!1),this.sendKey(m.XK_Control_L,"ControlLeft",!1))}machineShutdown(){this._xvpOp(1,2)}machineReboot(){this._xvpOp(1,3)}machineReset(){this._xvpOp(1,4)}sendKey(e,s,n){if(this._rfbConnectionState!=="connected"||this._viewOnly)return;if(n===void 0){this.sendKey(e,s,!0),this.sendKey(e,s,!1);return}const a=L_[s];if(this._qemuExtKeyEventSupported&&a)e=e||0,Gt("Sending key ("+(n?"down":"up")+"): keysym "+e+", scancode "+a),Le.messages.QEMUExtendedKeyEvent(this._sock,e,n,a);else{if(!e)return;Gt("Sending keysym ("+(n?"down":"up")+"): "+e),Le.messages.keyEvent(this._sock,e,n?1:0)}}focus(e){this._canvas.focus(e)}blur(){this._canvas.blur()}clipboardPasteFrom(e){if(!(this._rfbConnectionState!=="connected"||this._viewOnly))if(this._clipboardServerCapabilitiesFormats[Qs]&&this._clipboardServerCapabilitiesActions[ka])this._clipboardText=e,Le.messages.extendedClipboardNotify(this._sock,[Qs]);else{let s,n,a;s=0;for(let i of e)s++;a=new Uint8Array(s),n=0;for(let i of e){let r=i.codePointAt(0);r>255&&(r=63),a[n++]=r}Le.messages.clientCutText(this._sock,a)}}getImageData(){return this._display.getImageData()}toDataURL(e,s){return this._display.toDataURL(e,s)}toBlob(e,s,n){return this._display.toBlob(e,s,n)}_connect(){if(Ce(">> RFB.connect"),this._url)Gt(`connecting to ${this._url}`),this._sock.open(this._url,this._wsProtocols);else{if(Gt(`attaching ${this._rawChannel} to Websock`),this._sock.attach(this._rawChannel),this._sock.readyState==="closed")throw Error("Cannot use already closed WebSocket/RTCDataChannel");this._sock.readyState==="open"&&this._socketOpen()}this._target.appendChild(this._screen),this._gestures.attach(this._canvas),this._cursor.attach(this._canvas),this._refreshCursor(),this._resizeObserver.observe(this._screen),this._canvas.addEventListener("mousedown",this._eventHandlers.focusCanvas),this._canvas.addEventListener("touchstart",this._eventHandlers.focusCanvas),this._canvas.addEventListener("mousedown",this._eventHandlers.handleMouse),this._canvas.addEventListener("mouseup",this._eventHandlers.handleMouse),this._canvas.addEventListener("mousemove",this._eventHandlers.handleMouse),this._canvas.addEventListener("click",this._eventHandlers.handleMouse),this._canvas.addEventListener("contextmenu",this._eventHandlers.handleMouse),this._canvas.addEventListener("wheel",this._eventHandlers.handleWheel),this._canvas.addEventListener("gesturestart",this._eventHandlers.handleGesture),this._canvas.addEventListener("gesturemove",this._eventHandlers.handleGesture),this._canvas.addEventListener("gestureend",this._eventHandlers.handleGesture),Ce("<< RFB.connect")}_disconnect(){Ce(">> RFB.disconnect"),this._cursor.detach(),this._canvas.removeEventListener("gesturestart",this._eventHandlers.handleGesture),this._canvas.removeEventListener("gesturemove",this._eventHandlers.handleGesture),this._canvas.removeEventListener("gestureend",this._eventHandlers.handleGesture),this._canvas.removeEventListener("wheel",this._eventHandlers.handleWheel),this._canvas.removeEventListener("mousedown",this._eventHandlers.handleMouse),this._canvas.removeEventListener("mouseup",this._eventHandlers.handleMouse),this._canvas.removeEventListener("mousemove",this._eventHandlers.handleMouse),this._canvas.removeEventListener("click",this._eventHandlers.handleMouse),this._canvas.removeEventListener("contextmenu",this._eventHandlers.handleMouse),this._canvas.removeEventListener("mousedown",this._eventHandlers.focusCanvas),this._canvas.removeEventListener("touchstart",this._eventHandlers.focusCanvas),this._resizeObserver.disconnect(),this._keyboard.ungrab(),this._gestures.detach(),this._sock.close();try{this._target.removeChild(this._screen)}catch(e){if(e.name!=="NotFoundError")throw e}clearTimeout(this._resizeTimeout),clearTimeout(this._mouseMoveTimer),Ce("<< RFB.disconnect")}_socketOpen(){this._rfbConnectionState==="connecting"&&this._rfbInitState===""?(this._rfbInitState="ProtocolVersion",Ce("Starting VNC handshake")):this._fail("Unexpected server connection while "+this._rfbConnectionState)}_socketClose(e){Ce("WebSocket on-close event");let s="";switch(e.code&&(s="(code: "+e.code,e.reason&&(s+=", reason: "+e.reason),s+=")"),this._rfbConnectionState){case"connecting":this._fail("Connection closed "+s);break;case"connected":this._updateConnectionState("disconnecting"),this._updateConnectionState("disconnected");break;case"disconnecting":this._updateConnectionState("disconnected");break;case"disconnected":this._fail("Unexpected server disconnect when already disconnected "+s);break;default:this._fail("Unexpected server disconnect before connecting "+s);break}this._sock.off("close"),this._rawChannel=null}_socketError(e){Wt("WebSocket on-error event")}_focusCanvas(e){this.focusOnClick&&this.focus({preventScroll:!0})}_setDesktopName(e){this._fbName=e,this.dispatchEvent(new CustomEvent("desktopname",{detail:{name:this._fbName}}))}_saveExpectedClientSize(){this._expectedClientWidth=this._screen.clientWidth,this._expectedClientHeight=this._screen.clientHeight}_currentClientSize(){return[this._screen.clientWidth,this._screen.clientHeight]}_clientHasExpectedSize(){const[e,s]=this._currentClientSize();return e==this._expectedClientWidth&&s==this._expectedClientHeight}_handleResize(){this._clientHasExpectedSize()||(window.requestAnimationFrame(()=>{this._updateClip(),this._updateScale(),this._saveExpectedClientSize()}),this._requestRemoteResize())}_updateClip(){const e=this._display.clipViewport;let s=this._clipViewport;if(this._scaleViewport&&(s=!1),e!==s&&(this._display.clipViewport=s),s){const n=this._screenSize();this._display.viewportChangeSize(n.w,n.h),this._fixScrollbars(),this._setClippingViewport(n.w<this._display.width||n.h<this._display.height)}else this._setClippingViewport(!1);e!==s&&this._saveExpectedClientSize()}_updateScale(){if(!this._scaleViewport)this._display.scale=1;else{const e=this._screenSize();this._display.autoscale(e.w,e.h)}this._fixScrollbars()}_requestRemoteResize(){if(!this._resizeSession||this._viewOnly||!this._supportsSetDesktopSize||this._pendingRemoteResize)return;if(Date.now()-this._lastResize<100){clearTimeout(this._resizeTimeout),this._resizeTimeout=setTimeout(this._requestRemoteResize.bind(this),100-(Date.now()-this._lastResize));return}this._resizeTimeout=null;const e=this._screenSize();e.w===this._fbWidth&&e.h===this._fbHeight||(this._pendingRemoteResize=!0,this._lastResize=Date.now(),Le.messages.setDesktopSize(this._sock,Math.floor(e.w),Math.floor(e.h),this._screenID,this._screenFlags),Ce("Requested new desktop size: "+e.w+"x"+e.h))}_screenSize(){let e=this._screen.getBoundingClientRect();return{w:e.width,h:e.height}}_fixScrollbars(){const e=this._screen.style.overflow;this._screen.style.overflow="hidden",this._screen.getBoundingClientRect(),this._screen.style.overflow=e}_updateConnectionState(e){const s=this._rfbConnectionState;if(e===s){Ce("Already in state '"+e+"', ignoring");return}if(s==="disconnected"){ot("Tried changing state of a disconnected RFB object");return}switch(e){case"connected":if(s!=="connecting"){ot("Bad transition to connected state, previous connection state: "+s);return}break;case"disconnected":if(s!=="disconnecting"){ot("Bad transition to disconnected state, previous connection state: "+s);return}break;case"connecting":if(s!==""){ot("Bad transition to connecting state, previous connection state: "+s);return}break;case"disconnecting":if(s!=="connected"&&s!=="connecting"){ot("Bad transition to disconnecting state, previous connection state: "+s);return}break;default:ot("Unknown connection state: "+e);return}switch(this._rfbConnectionState=e,Ce("New state '"+e+"', was '"+s+"'."),this._disconnTimer&&e!=="disconnecting"&&(Ce("Clearing disconnect timer"),clearTimeout(this._disconnTimer),this._disconnTimer=null,this._sock.off("close")),e){case"connecting":this._connect();break;case"connected":this.dispatchEvent(new CustomEvent("connect",{detail:{}}));break;case"disconnecting":this._disconnect(),this._disconnTimer=setTimeout(()=>{ot("Disconnection timed out."),this._updateConnectionState("disconnected")},tv*1e3);break;case"disconnected":this.dispatchEvent(new CustomEvent("disconnect",{detail:{clean:this._rfbCleanDisconnect}}));break}}_fail(e){switch(this._rfbConnectionState){case"disconnecting":ot("Failed when disconnecting: "+e);break;case"connected":ot("Failed while connected: "+e);break;case"connecting":ot("Failed when connecting: "+e);break;default:ot("RFB failure: "+e);break}return this._rfbCleanDisconnect=!1,this._updateConnectionState("disconnecting"),this._updateConnectionState("disconnected"),!1}_setCapability(e,s){this._capabilities[e]=s,this.dispatchEvent(new CustomEvent("capabilities",{detail:{capabilities:this._capabilities}}))}_handleMessage(){if(this._sock.rQwait("message",1)){Wt("handleMessage called on an empty receive queue");return}switch(this._rfbConnectionState){case"disconnected":ot("Got data while disconnected");break;case"connected":for(;!(this._flushing||!this._normalMsg()||this._sock.rQwait("message",1)););break;case"connecting":for(;this._rfbConnectionState==="connecting"&&this._initMsg(););break;default:ot("Got data while in an invalid state");break}}_handleKeyEvent(e,s,n,a,i){s=="CapsLock"&&n&&(this._remoteCapsLock=null),this._remoteCapsLock!==null&&i!==null&&this._remoteCapsLock!==i&&n&&(Ce("Fixing remote caps lock"),this.sendKey(m.XK_Caps_Lock,"CapsLock",!0),this.sendKey(m.XK_Caps_Lock,"CapsLock",!1),this._remoteCapsLock=null),s=="NumLock"&&n&&(this._remoteNumLock=null),this._remoteNumLock!==null&&a!==null&&this._remoteNumLock!==a&&n&&(Ce("Fixing remote num lock"),this.sendKey(m.XK_Num_Lock,"NumLock",!0),this.sendKey(m.XK_Num_Lock,"NumLock",!1),this._remoteNumLock=null),this.sendKey(e,s,n)}static _convertButtonMask(e){const s={0:1,1:4,2:2,3:128,4:256};let n=0;for(let a=0;a<5;a++)e&1<<a&&(n|=s[a]);return n}_handleMouse(e){if(e.type==="click"&&e.target!==this._canvas||(e.stopPropagation(),e.preventDefault(),e.type==="click"||e.type==="contextmenu"))return;let s=fa(e.clientX,e.clientY,this._canvas),n=Le._convertButtonMask(e.buttons),a=e.type=="mousedown";switch(e.type){case"mousedown":case"mouseup":if(this.dragViewport)if(a&&!this._viewportDragging){this._viewportDragging=!0,this._viewportDragPos={x:s.x,y:s.y},this._viewportHasMoved=!1,this._flushMouseMoveTimer(s.x,s.y),this._mouseButtonMask=n;break}else{if(this._viewportDragging=!1,this._viewportHasMoved){this._mouseButtonMask=n;break}this._sendMouse(s.x,s.y,this._mouseButtonMask)}a&&ef(this._canvas),this._handleMouseButton(s.x,s.y,n);break;case"mousemove":if(this._viewportDragging){const i=this._viewportDragPos.x-s.x,r=this._viewportDragPos.y-s.y;(this._viewportHasMoved||Math.abs(i)>Ja||Math.abs(r)>Ja)&&(this._viewportHasMoved=!0,this._viewportDragPos={x:s.x,y:s.y},this._display.viewportChangePos(i,r));break}this._handleMouseMove(s.x,s.y);break}}_handleMouseButton(e,s,n){this._flushMouseMoveTimer(e,s),this._mouseButtonMask=n,this._sendMouse(e,s,this._mouseButtonMask)}_handleMouseMove(e,s){if(this._mousePos={x:e,y:s},this._mouseMoveTimer==null){const n=Date.now()-this._mouseLastMoveTime;n>Kl?(this._sendMouse(e,s,this._mouseButtonMask),this._mouseLastMoveTime=Date.now()):this._mouseMoveTimer=setTimeout(()=>{this._handleDelayedMouseMove()},Kl-n)}}_handleDelayedMouseMove(){this._mouseMoveTimer=null,this._sendMouse(this._mousePos.x,this._mousePos.y,this._mouseButtonMask),this._mouseLastMoveTime=Date.now()}_sendMouse(e,s,n){if(this._rfbConnectionState!=="connected"||this._viewOnly)return;if(n&32768)throw new Error("Illegal mouse button mask (mask: "+n+")");let a=n&32640;this._extendedPointerEventSupported&&a?Le.messages.extendedPointerEvent(this._sock,this._display.absX(e),this._display.absY(s),n):Le.messages.pointerEvent(this._sock,this._display.absX(e),this._display.absY(s),n)}_handleWheel(e){if(this._rfbConnectionState!=="connected"||this._viewOnly)return;e.stopPropagation(),e.preventDefault();let s=fa(e.clientX,e.clientY,this._canvas),n=Le._convertButtonMask(e.buttons),a=e.deltaX,i=e.deltaY;e.deltaMode!==0&&(a*=Tl,i*=Tl),this._accumulatedWheelDeltaX+=a,this._accumulatedWheelDeltaY+=i,Math.abs(this._accumulatedWheelDeltaX)>=Fl&&(this._accumulatedWheelDeltaX<0?(this._handleMouseButton(s.x,s.y,n|32),this._handleMouseButton(s.x,s.y,n)):this._accumulatedWheelDeltaX>0&&(this._handleMouseButton(s.x,s.y,n|64),this._handleMouseButton(s.x,s.y,n)),this._accumulatedWheelDeltaX=0),Math.abs(this._accumulatedWheelDeltaY)>=Fl&&(this._accumulatedWheelDeltaY<0?(this._handleMouseButton(s.x,s.y,n|8),this._handleMouseButton(s.x,s.y,n)):this._accumulatedWheelDeltaY>0&&(this._handleMouseButton(s.x,s.y,n|16),this._handleMouseButton(s.x,s.y,n)),this._accumulatedWheelDeltaY=0)}_fakeMouseMove(e,s,n){this._handleMouseMove(s,n),this._cursor.move(e.detail.clientX,e.detail.clientY)}_handleTapEvent(e,s){let n=fa(e.detail.clientX,e.detail.clientY,this._canvas);if(this._gestureLastTapTime!==null&&Date.now()-this._gestureLastTapTime<nv&&this._gestureFirstDoubleTapEv.detail.type===e.detail.type){let a=this._gestureFirstDoubleTapEv.detail.clientX-e.detail.clientX,i=this._gestureFirstDoubleTapEv.detail.clientY-e.detail.clientY;Math.hypot(a,i)<av?n=fa(this._gestureFirstDoubleTapEv.detail.clientX,this._gestureFirstDoubleTapEv.detail.clientY,this._canvas):this._gestureFirstDoubleTapEv=e}else this._gestureFirstDoubleTapEv=e;this._gestureLastTapTime=Date.now(),this._fakeMouseMove(this._gestureFirstDoubleTapEv,n.x,n.y),this._handleMouseButton(n.x,n.y,s),this._handleMouseButton(n.x,n.y,0)}_handleGesture(e){let s,n=fa(e.detail.clientX,e.detail.clientY,this._canvas);switch(e.type){case"gesturestart":switch(e.detail.type){case"onetap":this._handleTapEvent(e,1);break;case"twotap":this._handleTapEvent(e,4);break;case"threetap":this._handleTapEvent(e,2);break;case"drag":this.dragViewport?(this._viewportHasMoved=!1,this._viewportDragging=!0,this._viewportDragPos={x:n.x,y:n.y}):(this._fakeMouseMove(e,n.x,n.y),this._handleMouseButton(n.x,n.y,1));break;case"longpress":this.dragViewport?(this._viewportHasMoved=!1,this._viewportDragPos={x:n.x,y:n.y}):(this._fakeMouseMove(e,n.x,n.y),this._handleMouseButton(n.x,n.y,4));break;case"twodrag":this._gestureLastMagnitudeX=e.detail.magnitudeX,this._gestureLastMagnitudeY=e.detail.magnitudeY,this._fakeMouseMove(e,n.x,n.y);break;case"pinch":this._gestureLastMagnitudeX=Math.hypot(e.detail.magnitudeX,e.detail.magnitudeY),this._fakeMouseMove(e,n.x,n.y);break}break;case"gesturemove":switch(e.detail.type){case"onetap":case"twotap":case"threetap":break;case"drag":case"longpress":if(this.dragViewport){this._viewportDragging=!0;const a=this._viewportDragPos.x-n.x,i=this._viewportDragPos.y-n.y;(this._viewportHasMoved||Math.abs(a)>Ja||Math.abs(i)>Ja)&&(this._viewportHasMoved=!0,this._viewportDragPos={x:n.x,y:n.y},this._display.viewportChangePos(a,i))}else this._fakeMouseMove(e,n.x,n.y);break;case"twodrag":for(this._fakeMouseMove(e,n.x,n.y);e.detail.magnitudeY-this._gestureLastMagnitudeY>ln;)this._handleMouseButton(n.x,n.y,8),this._handleMouseButton(n.x,n.y,0),this._gestureLastMagnitudeY+=ln;for(;e.detail.magnitudeY-this._gestureLastMagnitudeY<-ln;)this._handleMouseButton(n.x,n.y,16),this._handleMouseButton(n.x,n.y,0),this._gestureLastMagnitudeY-=ln;for(;e.detail.magnitudeX-this._gestureLastMagnitudeX>ln;)this._handleMouseButton(n.x,n.y,32),this._handleMouseButton(n.x,n.y,0),this._gestureLastMagnitudeX+=ln;for(;e.detail.magnitudeX-this._gestureLastMagnitudeX<-ln;)this._handleMouseButton(n.x,n.y,64),this._handleMouseButton(n.x,n.y,0),this._gestureLastMagnitudeX-=ln;break;case"pinch":if(this._fakeMouseMove(e,n.x,n.y),s=Math.hypot(e.detail.magnitudeX,e.detail.magnitudeY),Math.abs(s-this._gestureLastMagnitudeX)>ga){for(this._handleKeyEvent(m.XK_Control_L,"ControlLeft",!0);s-this._gestureLastMagnitudeX>ga;)this._handleMouseButton(n.x,n.y,8),this._handleMouseButton(n.x,n.y,0),this._gestureLastMagnitudeX+=ga;for(;s-this._gestureLastMagnitudeX<-ga;)this._handleMouseButton(n.x,n.y,16),this._handleMouseButton(n.x,n.y,0),this._gestureLastMagnitudeX-=ga}this._handleKeyEvent(m.XK_Control_L,"ControlLeft",!1);break}break;case"gestureend":switch(e.detail.type){case"onetap":case"twotap":case"threetap":case"pinch":case"twodrag":break;case"drag":this.dragViewport?this._viewportDragging=!1:(this._fakeMouseMove(e,n.x,n.y),this._handleMouseButton(n.x,n.y,0));break;case"longpress":if(this._viewportHasMoved)break;this.dragViewport&&!this._viewportHasMoved?(this._fakeMouseMove(e,n.x,n.y),this._handleMouseButton(n.x,n.y,4),this._handleMouseButton(n.x,n.y,0),this._viewportDragging=!1):(this._fakeMouseMove(e,n.x,n.y),this._handleMouseButton(n.x,n.y,0));break}break}}_flushMouseMoveTimer(e,s){this._mouseMoveTimer!==null&&(clearTimeout(this._mouseMoveTimer),this._mouseMoveTimer=null,this._sendMouse(e,s,this._mouseButtonMask))}_negotiateProtocolVersion(){if(this._sock.rQwait("version",12))return!1;const e=this._sock.rQshiftStr(12).substr(4,7);Gt("Server ProtocolVersion: "+e);let s=0;switch(e){case"000.000":s=1;break;case"003.003":case"003.006":this._rfbVersion=3.3;break;case"003.007":this._rfbVersion=3.7;break;case"003.008":case"003.889":case"004.000":case"004.001":case"005.000":this._rfbVersion=3.8;break;default:return this._fail("Invalid server version "+e)}if(s){let a="ID:"+this._repeaterID;for(;a.length<250;)a+="\0";return this._sock.sQpushString(a),this._sock.flush(),!0}this._rfbVersion>this._rfbMaxVersion&&(this._rfbVersion=this._rfbMaxVersion);const n="00"+parseInt(this._rfbVersion,10)+".00"+this._rfbVersion*10%10;this._sock.sQpushString("RFB "+n+`
|
|
3
|
-
`),this._sock.flush(),Ce("Sent ProtocolVersion: "+n),this._rfbInitState="Security"}_isSupportedSecurityType(e){return[Ml,li,Xl,Ll,cr,Pl,Bl,Dl,Il].includes(e)}_negotiateSecurity(){if(this._rfbVersion>=3.7){const e=this._sock.rQshift8();if(this._sock.rQwait("security type",e,1))return!1;if(e===0)return this._rfbInitState="SecurityReason",this._securityContext="no security types",this._securityStatus=1,!0;const s=this._sock.rQshiftBytes(e);Ce("Server security types: "+s),this._rfbAuthScheme=-1;for(let n of s)if(this._isSupportedSecurityType(n)){this._rfbAuthScheme=n;break}if(this._rfbAuthScheme===-1)return this._fail("Unsupported security types (types: "+s+")");this._sock.sQpush8(this._rfbAuthScheme),this._sock.flush()}else{if(this._sock.rQwait("security scheme",4))return!1;if(this._rfbAuthScheme=this._sock.rQshift32(),this._rfbAuthScheme==0)return this._rfbInitState="SecurityReason",this._securityContext="authentication scheme",this._securityStatus=1,!0}return this._rfbInitState="Authentication",Ce("Authenticating using scheme: "+this._rfbAuthScheme),!0}_handleSecurityReason(){if(this._sock.rQwait("reason length",4))return!1;const e=this._sock.rQshift32();let s="";if(e>0){if(this._sock.rQwait("reason",e,4))return!1;s=this._sock.rQshiftStr(e)}return s!==""?(this.dispatchEvent(new CustomEvent("securityfailure",{detail:{status:this._securityStatus,reason:s}})),this._fail("Security negotiation failed on "+this._securityContext+" (reason: "+s+")")):(this.dispatchEvent(new CustomEvent("securityfailure",{detail:{status:this._securityStatus}})),this._fail("Security negotiation failed on "+this._securityContext))}_negotiateXvpAuth(){return this._rfbCredentials.username===void 0||this._rfbCredentials.password===void 0||this._rfbCredentials.target===void 0?(this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["username","password","target"]}})),!1):(this._sock.sQpush8(this._rfbCredentials.username.length),this._sock.sQpush8(this._rfbCredentials.target.length),this._sock.sQpushString(this._rfbCredentials.username),this._sock.sQpushString(this._rfbCredentials.target),this._sock.flush(),this._rfbAuthScheme=li,this._negotiateAuthentication())}_negotiateVeNCryptAuth(){if(this._rfbVeNCryptState==0){if(this._sock.rQwait("vencrypt version",2))return!1;const e=this._sock.rQshift8(),s=this._sock.rQshift8();if(!(e==0&&s==2))return this._fail("Unsupported VeNCrypt version "+e+"."+s);this._sock.sQpush8(0),this._sock.sQpush8(2),this._sock.flush(),this._rfbVeNCryptState=1}if(this._rfbVeNCryptState==1){if(this._sock.rQwait("vencrypt ack",1))return!1;const e=this._sock.rQshift8();if(e!=0)return this._fail("VeNCrypt failure "+e);this._rfbVeNCryptState=2}if(this._rfbVeNCryptState==2){if(this._sock.rQwait("vencrypt subtypes length",1))return!1;const e=this._sock.rQshift8();if(e<1)return this._fail("VeNCrypt subtypes empty");this._rfbVeNCryptSubtypesLength=e,this._rfbVeNCryptState=3}if(this._rfbVeNCryptState==3){if(this._sock.rQwait("vencrypt subtypes",4*this._rfbVeNCryptSubtypesLength))return!1;const e=[];for(let s=0;s<this._rfbVeNCryptSubtypesLength;s++)e.push(this._sock.rQshift32());this._rfbAuthScheme=-1;for(let s of e)if(s!==cr&&this._isSupportedSecurityType(s)){this._rfbAuthScheme=s;break}return this._rfbAuthScheme===-1?this._fail("Unsupported security types (types: "+e+")"):(this._sock.sQpush32(this._rfbAuthScheme),this._sock.flush(),this._rfbVeNCryptState=4,!0)}}_negotiatePlainAuth(){if(this._rfbCredentials.username===void 0||this._rfbCredentials.password===void 0)return this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["username","password"]}})),!1;const e=js(this._rfbCredentials.username),s=js(this._rfbCredentials.password);return this._sock.sQpush32(e.length),this._sock.sQpush32(s.length),this._sock.sQpushString(e),this._sock.sQpushString(s),this._sock.flush(),this._rfbInitState="SecurityResult",!0}_negotiateStdVNCAuth(){if(this._sock.rQwait("auth challenge",16))return!1;if(this._rfbCredentials.password===void 0)return this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["password"]}})),!1;const e=Array.prototype.slice.call(this._sock.rQshiftBytes(16)),s=Le.genDES(this._rfbCredentials.password,e);return this._sock.sQpushBytes(s),this._sock.flush(),this._rfbInitState="SecurityResult",!0}_negotiateARDAuth(){if(this._rfbCredentials.username===void 0||this._rfbCredentials.password===void 0)return this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["username","password"]}})),!1;if(this._rfbCredentials.ardPublicKey!=null&&this._rfbCredentials.ardCredentials!=null)return this._sock.sQpushBytes(this._rfbCredentials.ardCredentials),this._sock.sQpushBytes(this._rfbCredentials.ardPublicKey),this._sock.flush(),this._rfbCredentials.ardCredentials=null,this._rfbCredentials.ardPublicKey=null,this._rfbInitState="SecurityResult",!0;if(this._sock.rQwait("read ard",4))return!1;let e=this._sock.rQshiftBytes(2),s=this._sock.rQshift16();if(this._sock.rQwait("read ard keylength",s*2,4))return!1;let n=this._sock.rQshiftBytes(s),a=this._sock.rQshiftBytes(s),i=pt.generateKey({name:"DH",g:e,p:n},!1,["deriveBits"]);return this._negotiateARDAuthAsync(s,a,i),!1}async _negotiateARDAuthAsync(e,s,n){const a=pt.exportKey("raw",n.publicKey),i=pt.deriveBits({name:"DH",public:s},n.privateKey,e*8),r=js(this._rfbCredentials.username).substring(0,63),o=js(this._rfbCredentials.password).substring(0,63),d=window.crypto.getRandomValues(new Uint8Array(128));for(let p=0;p<r.length;p++)d[p]=r.charCodeAt(p);d[r.length]=0;for(let p=0;p<o.length;p++)d[64+p]=o.charCodeAt(p);d[64+o.length]=0;const l=await pt.digest("MD5",i),u=await pt.importKey("raw",l,{name:"AES-ECB"},!1,["encrypt"]),_=await pt.encrypt({name:"AES-ECB"},u,d);this._rfbCredentials.ardCredentials=_,this._rfbCredentials.ardPublicKey=a,this._resumeAuthentication()}_negotiateTightUnixAuth(){return this._rfbCredentials.username===void 0||this._rfbCredentials.password===void 0?(this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["username","password"]}})),!1):(this._sock.sQpush32(this._rfbCredentials.username.length),this._sock.sQpush32(this._rfbCredentials.password.length),this._sock.sQpushString(this._rfbCredentials.username),this._sock.sQpushString(this._rfbCredentials.password),this._sock.flush(),this._rfbInitState="SecurityResult",!0)}_negotiateTightTunnels(e){const s={0:{vendor:"TGHT",signature:"NOTUNNEL"}},n={};for(let a=0;a<e;a++){const i=this._sock.rQshift32(),r=this._sock.rQshiftStr(4),o=this._sock.rQshiftStr(8);n[i]={vendor:r,signature:o}}return Ce("Server Tight tunnel types: "+n),n[1]&&n[1].vendor==="SICR"&&n[1].signature==="SCHANNEL"&&(Ce("Detected Siemens server. Assuming NOTUNNEL support."),n[0]={vendor:"TGHT",signature:"NOTUNNEL"}),n[0]?n[0].vendor!=s[0].vendor||n[0].signature!=s[0].signature?this._fail("Client's tunnel type had the incorrect vendor or signature"):(Ce("Selected tunnel type: "+s[0]),this._sock.sQpush32(0),this._sock.flush(),!1):this._fail("Server wanted tunnels, but doesn't support the notunnel type")}_negotiateTightAuth(){if(!this._rfbTightVNC){if(this._sock.rQwait("num tunnels",4))return!1;const a=this._sock.rQshift32();if(a>0&&this._sock.rQwait("tunnel capabilities",16*a,4))return!1;if(this._rfbTightVNC=!0,a>0)return this._negotiateTightTunnels(a),!1}if(this._sock.rQwait("sub auth count",4))return!1;const e=this._sock.rQshift32();if(e===0)return this._rfbInitState="SecurityResult",!0;if(this._sock.rQwait("sub auth capabilities",16*e,4))return!1;const s={STDVNOAUTH__:1,STDVVNCAUTH_:2,TGHTULGNAUTH:129},n=[];for(let a=0;a<e;a++){this._sock.rQshift32();const i=this._sock.rQshiftStr(12);n.push(i)}Ce("Server Tight authentication types: "+n);for(let a in s)if(n.indexOf(a)!=-1)switch(this._sock.sQpush32(s[a]),this._sock.flush(),Ce("Selected authentication type: "+a),a){case"STDVNOAUTH__":return this._rfbInitState="SecurityResult",!0;case"STDVVNCAUTH_":return this._rfbAuthScheme=li,!0;case"TGHTULGNAUTH":return this._rfbAuthScheme=Rl,!0;default:return this._fail("Unsupported tiny auth scheme (scheme: "+a+")")}return this._fail("No supported sub-auth types!")}_handleRSAAESCredentialsRequired(e){this.dispatchEvent(e)}_handleRSAAESServerVerification(e){this.dispatchEvent(e)}_negotiateRA2neAuth(){return this._rfbRSAAESAuthenticationState===null&&(this._rfbRSAAESAuthenticationState=new z_(this._sock,()=>this._rfbCredentials),this._rfbRSAAESAuthenticationState.addEventListener("serververification",this._eventHandlers.handleRSAAESServerVerification),this._rfbRSAAESAuthenticationState.addEventListener("credentialsrequired",this._eventHandlers.handleRSAAESCredentialsRequired)),this._rfbRSAAESAuthenticationState.checkInternalEvents(),this._rfbRSAAESAuthenticationState.hasStarted||this._rfbRSAAESAuthenticationState.negotiateRA2neAuthAsync().catch(e=>{e.message!=="disconnect normally"&&this._fail(e.message)}).then(()=>(this._rfbInitState="SecurityResult",!0)).finally(()=>{this._rfbRSAAESAuthenticationState.removeEventListener("serververification",this._eventHandlers.handleRSAAESServerVerification),this._rfbRSAAESAuthenticationState.removeEventListener("credentialsrequired",this._eventHandlers.handleRSAAESCredentialsRequired),this._rfbRSAAESAuthenticationState=null}),!1}_negotiateMSLogonIIAuth(){if(this._sock.rQwait("mslogonii dh param",24))return!1;if(this._rfbCredentials.username===void 0||this._rfbCredentials.password===void 0)return this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["username","password"]}})),!1;const e=this._sock.rQshiftBytes(8),s=this._sock.rQshiftBytes(8),n=this._sock.rQshiftBytes(8),a=pt.generateKey({name:"DH",g:e,p:s},!0,["deriveBits"]),i=pt.exportKey("raw",a.publicKey),r=pt.deriveBits({name:"DH",public:n},a.privateKey,64),o=pt.importKey("raw",r,{name:"DES-CBC"},!1,["encrypt"]),d=js(this._rfbCredentials.username).substring(0,255),l=js(this._rfbCredentials.password).substring(0,63);let u=new Uint8Array(256),_=new Uint8Array(64);window.crypto.getRandomValues(u),window.crypto.getRandomValues(_);for(let p=0;p<d.length;p++)u[p]=d.charCodeAt(p);u[d.length]=0;for(let p=0;p<l.length;p++)_[p]=l.charCodeAt(p);return _[l.length]=0,u=pt.encrypt({name:"DES-CBC",iv:r},o,u),_=pt.encrypt({name:"DES-CBC",iv:r},o,_),this._sock.sQpushBytes(i),this._sock.sQpushBytes(u),this._sock.sQpushBytes(_),this._sock.flush(),this._rfbInitState="SecurityResult",!0}_negotiateAuthentication(){switch(this._rfbAuthScheme){case Ml:return this._rfbVersion>=3.8?this._rfbInitState="SecurityResult":this._rfbInitState="ClientInitialisation",!0;case Pl:return this._negotiateXvpAuth();case Bl:return this._negotiateARDAuth();case li:return this._negotiateStdVNCAuth();case Ll:return this._negotiateTightAuth();case cr:return this._negotiateVeNCryptAuth();case Il:return this._negotiatePlainAuth();case Rl:return this._negotiateTightUnixAuth();case Xl:return this._negotiateRA2neAuth();case Dl:return this._negotiateMSLogonIIAuth();default:return this._fail("Unsupported auth scheme (scheme: "+this._rfbAuthScheme+")")}}_handleSecurityResult(){if(this._sock.rQwait("VNC auth response ",4))return!1;const e=this._sock.rQshift32();return e===0?(this._rfbInitState="ClientInitialisation",Ce("Authentication OK"),!0):this._rfbVersion>=3.8?(this._rfbInitState="SecurityReason",this._securityContext="security result",this._securityStatus=e,!0):(this.dispatchEvent(new CustomEvent("securityfailure",{detail:{status:e}})),this._fail("Security handshake failed"))}_negotiateServerInit(){if(this._sock.rQwait("server initialization",24))return!1;const e=this._sock.rQshift16(),s=this._sock.rQshift16(),n=this._sock.rQshift8(),a=this._sock.rQshift8(),i=this._sock.rQshift8(),r=this._sock.rQshift8(),o=this._sock.rQshift16(),d=this._sock.rQshift16(),l=this._sock.rQshift16(),u=this._sock.rQshift8(),_=this._sock.rQshift8(),p=this._sock.rQshift8();this._sock.rQskipBytes(3);const v=this._sock.rQshift32();if(this._sock.rQwait("server init name",v,24))return!1;let x=this._sock.rQshiftStr(v);if(x=Hi(x,!0),this._rfbTightVNC){if(this._sock.rQwait("TightVNC extended server init header",8,24+v))return!1;const y=this._sock.rQshift16(),w=this._sock.rQshift16(),S=this._sock.rQshift16();this._sock.rQskipBytes(2);const C=(y+w+S)*16;if(this._sock.rQwait("TightVNC extended server init header",C,32+v))return!1;this._sock.rQskipBytes(16*y),this._sock.rQskipBytes(16*w),this._sock.rQskipBytes(16*S)}return Gt("Screen: "+e+"x"+s+", bpp: "+n+", depth: "+a+", bigEndian: "+i+", trueColor: "+r+", redMax: "+o+", greenMax: "+d+", blueMax: "+l+", redShift: "+u+", greenShift: "+_+", blueShift: "+p),this._setDesktopName(x),this._resize(e,s),this._viewOnly||this._keyboard.grab(),this._fbDepth=24,this._fbName==="Intel(r) AMT KVM"&&(Wt("Intel AMT KVM only supports 8/16 bit depths. Using low color mode."),this._fbDepth=8),Le.messages.pixelFormat(this._sock,this._fbDepth,!0),this._sendEncodings(),Le.messages.fbUpdateRequest(this._sock,!1,0,0,this._fbWidth,this._fbHeight),this._updateConnectionState("connected"),!0}_sendEncodings(){const e=[];e.push(Ee.encodingCopyRect),this._fbDepth==24&&(Oc&&e.push(Ee.encodingH264),e.push(Ee.encodingTight),e.push(Ee.encodingTightPNG),e.push(Ee.encodingZRLE),e.push(Ee.encodingJPEG),e.push(Ee.encodingHextile),e.push(Ee.encodingRRE),e.push(Ee.encodingZlib)),e.push(Ee.encodingRaw),e.push(Ee.pseudoEncodingQualityLevel0+this._qualityLevel),e.push(Ee.pseudoEncodingCompressLevel0+this._compressionLevel),e.push(Ee.pseudoEncodingDesktopSize),e.push(Ee.pseudoEncodingLastRect),e.push(Ee.pseudoEncodingQEMUExtendedKeyEvent),e.push(Ee.pseudoEncodingQEMULedEvent),e.push(Ee.pseudoEncodingExtendedDesktopSize),e.push(Ee.pseudoEncodingXvp),e.push(Ee.pseudoEncodingFence),e.push(Ee.pseudoEncodingContinuousUpdates),e.push(Ee.pseudoEncodingDesktopName),e.push(Ee.pseudoEncodingExtendedClipboard),e.push(Ee.pseudoEncodingExtendedMouseButtons),this._fbDepth==24&&(e.push(Ee.pseudoEncodingVMwareCursor),e.push(Ee.pseudoEncodingCursor)),Le.messages.clientEncodings(this._sock,e)}_initMsg(){switch(this._rfbInitState){case"ProtocolVersion":return this._negotiateProtocolVersion();case"Security":return this._negotiateSecurity();case"Authentication":return this._negotiateAuthentication();case"SecurityResult":return this._handleSecurityResult();case"SecurityReason":return this._handleSecurityReason();case"ClientInitialisation":return this._sock.sQpush8(this._shared?1:0),this._sock.flush(),this._rfbInitState="ServerInitialisation",!0;case"ServerInitialisation":return this._negotiateServerInit();default:return this._fail("Unknown init state (state: "+this._rfbInitState+")")}}_resumeAuthentication(){setTimeout(this._initMsg.bind(this),0)}_handleSetColourMapMsg(){return Ce("SetColorMapEntries"),this._fail("Unexpected SetColorMapEntries message")}_handleServerCutText(){if(Ce("ServerCutText"),this._sock.rQwait("ServerCutText header",7,1))return!1;this._sock.rQskipBytes(3);let e=this._sock.rQshift32();if(e=Kr(e),this._sock.rQwait("ServerCutText content",Math.abs(e),8))return!1;if(e>=0){const s=this._sock.rQshiftStr(e);if(this._viewOnly)return!0;this.dispatchEvent(new CustomEvent("clipboard",{detail:{text:s}}))}else{e=Math.abs(e);const s=this._sock.rQshift32();let n=s&65535,a=s&4278190080;if(!!(a&Ql)){this._clipboardServerCapabilitiesFormats={},this._clipboardServerCapabilitiesActions={};for(let o=0;o<=15;o++){let d=1<<o;n&d&&(this._clipboardServerCapabilitiesFormats[d]=!0,this._sock.rQshift32())}for(let o=24;o<=31;o++){let d=1<<o;this._clipboardServerCapabilitiesActions[d]=!!(a&d)}let r=[Ql,hi,Nl,ka,fi];Le.messages.extendedClipboardCaps(this._sock,r,{extendedClipboardFormatText:0})}else if(a===hi){if(this._viewOnly)return!0;this._clipboardText!=null&&this._clipboardServerCapabilitiesActions[fi]&&n&Qs&&Le.messages.extendedClipboardProvide(this._sock,[Qs],[this._clipboardText])}else if(a===Nl){if(this._viewOnly)return!0;this._clipboardServerCapabilitiesActions[ka]&&(this._clipboardText!=null?Le.messages.extendedClipboardNotify(this._sock,[Qs]):Le.messages.extendedClipboardNotify(this._sock,[]))}else if(a===ka){if(this._viewOnly)return!0;this._clipboardServerCapabilitiesActions[hi]&&n&Qs&&Le.messages.extendedClipboardRequest(this._sock,[Qs])}else if(a===fi){if(this._viewOnly||!(n&Qs))return!0;this._clipboardText=null;let r=this._sock.rQshiftBytes(e-4),o=new Xi,d=null;o.setInput(r);for(let l=0;l<=15;l++){let u=1<<l;if(n&u){let _=0,p=o.inflate(4);_|=p[0]<<24,_|=p[1]<<16,_|=p[2]<<8,_|=p[3];let v=o.inflate(_);u===Qs&&(d=v)}}if(o.setInput(null),d!==null){let l="";for(let u=0;u<d.length;u++)l+=String.fromCharCode(d[u]);d=l,d=Hi(d),d.length>0&&d.charAt(d.length-1)==="\0"&&(d=d.slice(0,-1)),d=d.replaceAll(`\r
|
|
4
|
-
`,`
|
|
5
|
-
`),this.dispatchEvent(new CustomEvent("clipboard",{detail:{text:d}}))}}else return this._fail("Unexpected action in extended clipboard message: "+a)}return!0}_handleServerFenceMsg(){if(this._sock.rQwait("ServerFence header",8,1))return!1;this._sock.rQskipBytes(3);let e=this._sock.rQshift32(),s=this._sock.rQshift8();if(this._sock.rQwait("ServerFence payload",s,9))return!1;s>64&&(Wt("Bad payload length ("+s+") in fence response"),s=64);const n=this._sock.rQshiftStr(s);return this._supportsFence=!0,e&1<<31?(e&=3,Le.messages.clientFence(this._sock,e,n),!0):this._fail("Unexpected fence response")}_handleXvpMsg(){if(this._sock.rQwait("XVP version and message",3,1))return!1;this._sock.rQskipBytes(1);const e=this._sock.rQshift8(),s=this._sock.rQshift8();switch(s){case 0:ot("XVP operation failed");break;case 1:this._rfbXvpVer=e,Gt("XVP extensions enabled (version "+this._rfbXvpVer+")"),this._setCapability("power",!0);break;default:this._fail("Illegal server XVP message (msg: "+s+")");break}return!0}_normalMsg(){let e;this._FBU.rects>0?e=0:e=this._sock.rQshift8();let s,n;switch(e){case 0:return n=this._framebufferUpdate(),n&&!this._enabledContinuousUpdates&&Le.messages.fbUpdateRequest(this._sock,!0,0,0,this._fbWidth,this._fbHeight),n;case 1:return this._handleSetColourMapMsg();case 2:return Ce("Bell"),this.dispatchEvent(new CustomEvent("bell",{detail:{}})),!0;case 3:return this._handleServerCutText();case 150:return s=!this._supportsContinuousUpdates,this._supportsContinuousUpdates=!0,this._enabledContinuousUpdates=!1,s&&(this._enabledContinuousUpdates=!0,this._updateContinuousUpdates(),Gt("Enabling continuous updates.")),!0;case 248:return this._handleServerFenceMsg();case 250:return this._handleXvpMsg();default:return this._fail("Unexpected server message (type "+e+")"),Ce("sock.rQpeekBytes(30): "+this._sock.rQpeekBytes(30)),!0}}_framebufferUpdate(){if(this._FBU.rects===0){if(this._sock.rQwait("FBU header",3,1))return!1;if(this._sock.rQskipBytes(1),this._FBU.rects=this._sock.rQshift16(),this._display.pending())return this._flushing=!0,this._display.flush().then(()=>{this._flushing=!1,this._sock.rQwait("message",1)||this._handleMessage()}),!1}for(;this._FBU.rects>0;){if(this._FBU.encoding===null){if(this._sock.rQwait("rect header",12))return!1;this._FBU.x=this._sock.rQshift16(),this._FBU.y=this._sock.rQshift16(),this._FBU.width=this._sock.rQshift16(),this._FBU.height=this._sock.rQshift16(),this._FBU.encoding=this._sock.rQshift32(),this._FBU.encoding>>=0}if(!this._handleRect())return!1;this._FBU.rects--,this._FBU.encoding=null}return this._display.flip(),!0}_handleRect(){switch(this._FBU.encoding){case Ee.pseudoEncodingLastRect:return this._FBU.rects=1,!0;case Ee.pseudoEncodingVMwareCursor:return this._handleVMwareCursor();case Ee.pseudoEncodingCursor:return this._handleCursor();case Ee.pseudoEncodingQEMUExtendedKeyEvent:return this._qemuExtKeyEventSupported=!0,!0;case Ee.pseudoEncodingDesktopName:return this._handleDesktopName();case Ee.pseudoEncodingDesktopSize:return this._resize(this._FBU.width,this._FBU.height),!0;case Ee.pseudoEncodingExtendedDesktopSize:return this._handleExtendedDesktopSize();case Ee.pseudoEncodingExtendedMouseButtons:return this._extendedPointerEventSupported=!0,!0;case Ee.pseudoEncodingQEMULedEvent:return this._handleLedEvent();default:return this._handleDataRect()}}_handleVMwareCursor(){const e=this._FBU.x,s=this._FBU.y,n=this._FBU.width,a=this._FBU.height;if(this._sock.rQwait("VMware cursor encoding",1))return!1;const i=this._sock.rQshift8();this._sock.rQshift8();let r;const o=4;if(i==0){if(r=new Array(n*a*o),this._sock.rQwait("VMware cursor classic encoding",n*a*o*2,2))return!1;let l=new Array(n*a);for(let _=0;_<n*a;_++)l[_]=this._sock.rQshift32();let u=new Array(n*a);for(let _=0;_<n*a;_++)u[_]=this._sock.rQshift32();for(let _=0;_<n*a;_++)if(l[_]==0){let p=u[_],v=p>>8&255,x=p>>16&255,y=p>>24&255;r[_*o]=v,r[_*o+1]=x,r[_*o+2]=y,r[_*o+3]=255}else(l[_]&-256)==-256?u[_]==0?(r[_*o]=0,r[_*o+1]=0,r[_*o+2]=0,r[_*o+3]=0):(u[_]&-256,r[_*o]=0,r[_*o+1]=0,r[_*o+2]=0,r[_*o+3]=255):(r[_*o]=0,r[_*o+1]=0,r[_*o+2]=0,r[_*o+3]=255)}else if(i==1){if(this._sock.rQwait("VMware cursor alpha encoding",n*a*4,2))return!1;r=new Array(n*a*o);for(let d=0;d<n*a;d++){let l=this._sock.rQshift32();r[d*4]=l>>24&255,r[d*4+1]=l>>16&255,r[d*4+2]=l>>8&255,r[d*4+3]=l&255}}else return Wt("The given cursor type is not supported: "+i+" given."),!1;return this._updateCursor(r,e,s,n,a),!0}_handleCursor(){const e=this._FBU.x,s=this._FBU.y,n=this._FBU.width,a=this._FBU.height,i=n*a*4,r=Math.ceil(n/8)*a;let o=i+r;if(this._sock.rQwait("cursor encoding",o))return!1;const d=this._sock.rQshiftBytes(i),l=this._sock.rQshiftBytes(r);let u=new Uint8Array(n*a*4),_=0;for(let p=0;p<a;p++)for(let v=0;v<n;v++){let x=p*Math.ceil(n/8)+Math.floor(v/8),y=l[x]<<v%8&128?255:0;u[_]=d[_+2],u[_+1]=d[_+1],u[_+2]=d[_],u[_+3]=y,_+=4}return this._updateCursor(u,e,s,n,a),!0}_handleDesktopName(){if(this._sock.rQwait("DesktopName",4))return!1;let e=this._sock.rQshift32();if(this._sock.rQwait("DesktopName",e,4))return!1;let s=this._sock.rQshiftStr(e);return s=Hi(s,!0),this._setDesktopName(s),!0}_handleLedEvent(){if(this._sock.rQwait("LED status",1))return!1;let e=this._sock.rQshift8(),s=!!(e&2),n=!!(e&4);return this._remoteCapsLock=n,this._remoteNumLock=s,!0}_handleExtendedDesktopSize(){if(this._sock.rQwait("ExtendedDesktopSize",4))return!1;const e=this._sock.rQpeek8();let s=4+e*16;if(this._sock.rQwait("ExtendedDesktopSize",s))return!1;const n=!this._supportsSetDesktopSize;this._supportsSetDesktopSize=!0,this._sock.rQskipBytes(1),this._sock.rQskipBytes(3);for(let a=0;a<e;a+=1)a===0?(this._screenID=this._sock.rQshift32(),this._sock.rQskipBytes(2),this._sock.rQskipBytes(2),this._sock.rQskipBytes(2),this._sock.rQskipBytes(2),this._screenFlags=this._sock.rQshift32()):this._sock.rQskipBytes(16);if(this._FBU.x===1&&(this._pendingRemoteResize=!1),this._FBU.x===1&&this._FBU.y!==0){let a="";switch(this._FBU.y){case 1:a="Resize is administratively prohibited";break;case 2:a="Out of resources";break;case 3:a="Invalid screen layout";break;default:a="Unknown reason";break}Wt("Server did not accept the resize request: "+a)}else this._resize(this._FBU.width,this._FBU.height);return n&&this._requestRemoteResize(),this._FBU.x===1&&this._FBU.y===0&&this._requestRemoteResize(),!0}_handleDataRect(){let e=this._decoders[this._FBU.encoding];if(!e)return this._fail("Unsupported encoding (encoding: "+this._FBU.encoding+")"),!1;try{return e.decodeRect(this._FBU.x,this._FBU.y,this._FBU.width,this._FBU.height,this._sock,this._display,this._fbDepth)}catch(s){return this._fail("Error decoding rect: "+s),!1}}_updateContinuousUpdates(){this._enabledContinuousUpdates&&Le.messages.enableContinuousUpdates(this._sock,!0,0,0,this._fbWidth,this._fbHeight)}_resize(e,s){this._fbWidth=e,this._fbHeight=s,this._display.resize(this._fbWidth,this._fbHeight),this._updateClip(),this._updateScale(),this._updateContinuousUpdates(),this._saveExpectedClientSize()}_xvpOp(e,s){this._rfbXvpVer<e||(Gt("Sending XVP operation "+s+" (version "+e+")"),Le.messages.xvpOp(this._sock,e,s))}_updateCursor(e,s,n,a,i){this._cursorImage={rgbaPixels:e,hotx:s,hoty:n,w:a,h:i},this._refreshCursor()}_shouldShowDotCursor(){if(!this._showDotCursor)return!1;for(let e=3;e<this._cursorImage.rgbaPixels.length;e+=4)if(this._cursorImage.rgbaPixels[e])return!1;return!0}_refreshCursor(){if(this._rfbConnectionState!=="connecting"&&this._rfbConnectionState!=="connected")return;const e=this._shouldShowDotCursor()?Le.cursors.dot:this._cursorImage;this._cursor.change(e.rgbaPixels,e.hotx,e.hoty,e.w,e.h)}static genDES(e,s){const n=e.split("").map(i=>i.charCodeAt(0)),a=pt.importKey("raw",n,{name:"DES-ECB"},!1,["encrypt"]);return pt.encrypt({name:"DES-ECB"},a,s)}}Le.messages={keyEvent(t,e,s){t.sQpush8(4),t.sQpush8(s),t.sQpush16(0),t.sQpush32(e),t.flush()},QEMUExtendedKeyEvent(t,e,s,n){function a(r){const o=n>>8,d=n&255;return o===224&&d<127?d|128:r}t.sQpush8(255),t.sQpush8(0),t.sQpush16(s),t.sQpush32(e);const i=a(n);t.sQpush32(i),t.flush()},pointerEvent(t,e,s,n){t.sQpush8(5),n=n&127,t.sQpush8(n),t.sQpush16(e),t.sQpush16(s),t.flush()},extendedPointerEvent(t,e,s,n){t.sQpush8(5);let a=n>>7&255;if(a&252)throw new Error("Invalid mouse button mask: "+n);let i=n&127;i|=128,t.sQpush8(i),t.sQpush16(e),t.sQpush16(s),t.sQpush8(a),t.flush()},_buildExtendedClipboardFlags(t,e){let s=new Uint8Array(4),n=0,a=0;for(let i=0;i<t.length;i++)a|=t[i];for(let i=0;i<e.length;i++)n|=e[i];return s[0]=a>>24,s[1]=0,s[2]=0,s[3]=n,s},extendedClipboardProvide(t,e,s){let n=new m_,a=[];for(let o=0;o<e.length;o++){if(e[o]!=Qs)throw new Error("Unsupported extended clipboard format for Provide message.");s[o]=s[o].replace(/\r\n|\r|\n/gm,`\r
|
|
6
|
-
`);let d=js(s[o]+"\0");a.push(d.length>>24&255,d.length>>16&255,d.length>>8&255,d.length&255);for(let l=0;l<d.length;l++)a.push(d.charCodeAt(l))}let i=n.deflate(new Uint8Array(a)),r=new Uint8Array(4+i.length);r.set(Le.messages._buildExtendedClipboardFlags([fi],e)),r.set(i,4),Le.messages.clientCutText(t,r,!0)},extendedClipboardNotify(t,e){let s=Le.messages._buildExtendedClipboardFlags([ka],e);Le.messages.clientCutText(t,s,!0)},extendedClipboardRequest(t,e){let s=Le.messages._buildExtendedClipboardFlags([hi],e);Le.messages.clientCutText(t,s,!0)},extendedClipboardCaps(t,e,s){let n=Object.keys(s),a=new Uint8Array(4+4*n.length);n.map(r=>parseInt(r)),n.sort((r,o)=>r-o),a.set(Le.messages._buildExtendedClipboardFlags(e,[]));let i=4;for(let r=0;r<n.length;r++)a[i]=s[n[r]]>>24,a[i+1]=s[n[r]]>>16,a[i+2]=s[n[r]]>>8,a[i+3]=s[n[r]]>>0,i+=4,a[3]|=1<<n[r];Le.messages.clientCutText(t,a,!0)},clientCutText(t,e,s=!1){t.sQpush8(6),t.sQpush8(0),t.sQpush8(0),t.sQpush8(0);let n;s?n=j0(-e.length):n=e.length,t.sQpush32(n),t.sQpushBytes(e),t.flush()},setDesktopSize(t,e,s,n,a){t.sQpush8(251),t.sQpush8(0),t.sQpush16(e),t.sQpush16(s),t.sQpush8(1),t.sQpush8(0),t.sQpush32(n),t.sQpush16(0),t.sQpush16(0),t.sQpush16(e),t.sQpush16(s),t.sQpush32(a),t.flush()},clientFence(t,e,s){t.sQpush8(248),t.sQpush8(0),t.sQpush8(0),t.sQpush8(0),t.sQpush32(e),t.sQpush8(s.length),t.sQpushString(s),t.flush()},enableContinuousUpdates(t,e,s,n,a,i){t.sQpush8(150),t.sQpush8(e),t.sQpush16(s),t.sQpush16(n),t.sQpush16(a),t.sQpush16(i),t.flush()},pixelFormat(t,e,s){let n;e>16?n=32:e>8?n=16:n=8;const a=Math.floor(e/3);t.sQpush8(0),t.sQpush8(0),t.sQpush8(0),t.sQpush8(0),t.sQpush8(n),t.sQpush8(e),t.sQpush8(0),t.sQpush8(s?1:0),t.sQpush16((1<<a)-1),t.sQpush16((1<<a)-1),t.sQpush16((1<<a)-1),t.sQpush8(a*0),t.sQpush8(a*1),t.sQpush8(a*2),t.sQpush8(0),t.sQpush8(0),t.sQpush8(0),t.flush()},clientEncodings(t,e){t.sQpush8(2),t.sQpush8(0),t.sQpush16(e.length);for(let s=0;s<e.length;s++)t.sQpush32(e[s]);t.flush()},fbUpdateRequest(t,e,s,n,a,i){typeof s>"u"&&(s=0),typeof n>"u"&&(n=0),t.sQpush8(3),t.sQpush8(e?1:0),t.sQpush16(s),t.sQpush16(n),t.sQpush16(a),t.sQpush16(i),t.flush()},xvpOp(t,e,s){t.sQpush8(250),t.sQpush8(0),t.sQpush8(e),t.sQpush8(s),t.flush()}};Le.cursors={none:{rgbaPixels:new Uint8Array,w:0,h:0,hotx:0,hoty:0},dot:{rgbaPixels:new Uint8Array([255,255,255,255,0,0,0,255,255,255,255,255,0,0,0,255,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,255,255,255,255,255]),w:3,h:3,hotx:1,hoty:1}};var iv=F('<div class="loading svelte-138orkn">Loading...</div>'),rv=F('<div class="disabled-state svelte-138orkn"><div class="disabled-icon svelte-138orkn"><svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="svelte-138orkn"><rect x="2" y="3" width="20" height="14" rx="2" class="svelte-138orkn"></rect><line x1="8" y1="21" x2="16" y2="21" class="svelte-138orkn"></line><line x1="12" y1="17" x2="12" y2="21" class="svelte-138orkn"></line></svg></div> <h2 class="disabled-title svelte-138orkn">Computer Not Connected</h2> <p class="disabled-text svelte-138orkn">Enable the browser from Settings to connect to a running VM.</p> <a href="#/settings" class="btn btn-outline btn-sm svelte-138orkn">Go to Settings</a></div>'),ov=F('<div class="conn-info-popover svelte-138orkn"><div class="conn-info-row svelte-138orkn"><span class="conn-info-key svelte-138orkn">VNC port</span> <span class="mono conn-info-val svelte-138orkn"> </span></div> <div class="conn-info-row svelte-138orkn"><span class="conn-info-key svelte-138orkn">noVNC port</span> <span class="mono conn-info-val svelte-138orkn"> </span></div></div>'),lv=F('<button class="toolbar-btn toolbar-btn-danger svelte-138orkn"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svelte-138orkn"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" class="svelte-138orkn"></path><polyline points="16 17 21 12 16 7" class="svelte-138orkn"></polyline><line x1="21" y1="12" x2="9" y2="12" class="svelte-138orkn"></line></svg> Disconnect</button>'),cv=F('<div class="toolbar-right svelte-138orkn"><span class="toolbar-sep svelte-138orkn"></span> <button><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svelte-138orkn"><rect x="9" y="2" width="6" height="4" rx="1" class="svelte-138orkn"></rect><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-2" class="svelte-138orkn"></path></svg> Clipboard</button> <!></div>'),dv=F('<div class="clipboard-popover svelte-138orkn"><p class="clipboard-label svelte-138orkn">Type or paste, then use Ctrl+V inside the desktop</p> <textarea class="clipboard-textarea svelte-138orkn" placeholder="Paste text here..."></textarea></div>'),uv=F('<div class="error-overlay svelte-138orkn"><p class="error-text svelte-138orkn"> </p> <p class="error-hint svelte-138orkn">Ensure the browser stack (noVNC) is running</p> <button class="btn btn-outline btn-sm svelte-138orkn">Reconnect</button></div>'),hv=F('<div class="browser-viewer svelte-138orkn"><div class="toolbar svelte-138orkn"><div class="toolbar-left svelte-138orkn"><button class="conn-status svelte-138orkn"><span></span> <span class="toolbar-label svelte-138orkn"> </span></button> <!></div> <!></div> <div class="vnc-container svelte-138orkn"><!> <!> <div></div></div></div>');function fv(t,e){st(e,!0);let s=W(null),n=W(!0),a=W("connecting"),i=W(void 0),r=W(0),o=W(null),d=W(!1),l=W(""),u=W(!1);const _=Ae(()=>e.status?.browser.enabled??!1),p={connecting:"Connecting",connected:"Connected",disconnected:"Disconnected",failed:"Failed"},v=Ae(()=>p[c(a)]);xt(()=>{const A=new AbortController;return ke("/api/config").then(X=>{A.signal.aborted||b(s,X,!0)}).finally(()=>{A.signal.aborted||b(n,!1)}),()=>A.abort()});const x=Ae(()=>{if(!c(s)?.browser)return"";const A=Fi(),X=A?`?token=${encodeURIComponent(A)}`:"";return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/vnc${X}`});xt(()=>{if(!c(_)||!c(x)||!c(i)||c(r)<0)return;b(a,"connecting");let A=null;try{A=new Le(c(i),c(x)),A.scaleViewport=!0,A.resizeSession=!1,A.qualityLevel=5,A.compressionLevel=2,b(o,A,!0),A.addEventListener("connect",()=>{b(a,"connected")}),A.addEventListener("disconnect",X=>{const L=X.detail;b(a,L.clean?"disconnected":"failed",!0),b(o,null)})}catch{b(a,"failed"),b(o,null)}return()=>{A?.disconnect(),b(o,null)}});function y(){b(a,"connecting"),b(r,c(r)+1)}function w(){c(o)?.disconnect()}function S(){b(d,!c(d)),b(l,"")}function C(){c(o)&&c(o).clipboardPasteFrom(c(l))}var K=yt(),E=me(K);{var U=A=>{var X=iv();k(A,X)},te=A=>{var X=rv();k(A,X)},T=A=>{var X=hv(),L=h(X),se=h(L),oe=h(se),de=h(oe);let $;var H=f(de,2),ne=h(H),ae=f(oe,2);{var xe=le=>{var _e=ov(),Z=h(_e),be=f(h(Z),2),z=h(be),J=f(Z,2),ue=f(h(J),2),Se=h(ue);V(()=>{M(z,c(s).browser.vncPort),M(Se,c(s).browser.novncPort)}),k(le,_e)};O(ae,le=>{c(u)&&c(s)?.browser&&le(xe)})}var ge=f(se,2);{var he=le=>{var _e=cv(),Z=f(h(_e),2);let be;var z=f(Z,2);{var J=ue=>{var Se=lv();G("click",Se,w),k(ue,Se)};O(z,ue=>{c(a)==="connected"&&ue(J)})}V(()=>{be=pe(Z,1,"toolbar-btn svelte-138orkn",null,be,{"toolbar-btn-active":c(d)}),Z.disabled=c(a)!=="connected"}),G("click",Z,S),k(le,_e)};O(ge,le=>{c(s)?.browser&&le(he)})}var Fe=f(L,2),Be=h(Fe);{var Xe=le=>{var _e=dv(),Z=f(h(_e),2);jt(Z,"rows",4),G("input",Z,C),He(Z,()=>c(l),be=>b(l,be)),k(le,_e)};O(Be,le=>{c(d)&&le(Xe)})}var q=f(Be,2);{var re=le=>{var _e=uv(),Z=h(_e),be=h(Z),z=f(Z,4);V(()=>M(be,c(a)==="failed"?"Connection failed":"Disconnected")),G("click",z,y),k(le,_e)};O(q,le=>{(c(a)==="failed"||c(a)==="disconnected")&&le(re)})}var fe=f(q,2);let we;nh(fe,le=>b(i,le),()=>c(i)),V(()=>{$=pe(de,1,"conn-dot svelte-138orkn",null,$,{"conn-connecting":c(a)==="connecting","conn-on":c(a)==="connected","conn-off":c(a)==="disconnected"||c(a)==="failed"}),M(ne,c(v)),we=pe(fe,1,"vnc-canvas svelte-138orkn",null,we,{"vnc-hidden":c(a)!=="connected"})}),G("click",oe,()=>{b(u,!c(u))}),k(A,X)};O(E,A=>{c(n)?A(U):c(_)?A(T,!1):A(te,1)})}k(t,K),nt()}_t(["click","input"]);var _v=F('<button class="val-btn agent-name editable svelte-ys3ftv"> </button>'),vv=F('<button class="btn btn-outline btn-sm btn-danger">Delete</button>'),pv=F('<button class="val-btn mono editable"> </button>'),gv=F('<button class="val-btn mono editable"> </button>'),xv=F('<button class="val-btn mono editable"> </button>'),bv=F('<button class="val-btn mono editable"> </button>'),mv=F('<button class="val-btn mono editable"> </button>'),wv=F('<button class="prompt-block editable svelte-ys3ftv"> </button>'),yv=F('<div class="agent-card svelte-ys3ftv"><div class="agent-bar svelte-ys3ftv"></div> <div class="agent-top svelte-ys3ftv"><div class="agent-identity svelte-ys3ftv"><!> <span class="agent-id mono svelte-ys3ftv"> </span></div> <div class="agent-actions svelte-ys3ftv"><!></div></div> <div class="agent-fields svelte-ys3ftv"><div class="agent-field svelte-ys3ftv"><span class="row-label">Model</span> <!></div> <div class="agent-field svelte-ys3ftv"><span class="row-label">Fallback</span> <!></div> <div class="agent-field svelte-ys3ftv"><span class="row-label">Turns</span> <!></div> <div class="agent-field svelte-ys3ftv"><span class="row-label">Timeout</span> <!></div> <div class="agent-field svelte-ys3ftv"><span class="row-label">Channels</span> <!></div></div> <div class="agent-prompt-area svelte-ys3ftv"><span class="row-label">System Prompt</span> <!></div></div>');function kv(t,e){st(e,!0);let s=W("");function n(z,J){b(s,String(J),!0),e.editor.startEdit(`agent.${e.index}.${z}`,J)}function a(z){return e.editor.editingField===`agent.${e.index}.${z}`}var i=yv(),r=f(h(i),2),o=h(r),d=h(o);{var l=z=>{gt(z,{get saving(){return e.editor.editingSaving},onsave:J=>e.onsavefield("name",J),get oncancel(){return e.editor.cancelEdit},get value(){return c(s)},set value(J){b(s,J,!0)}})},u=Ae(()=>a("name")),_=z=>{var J=_v(),ue=h(J);V(()=>M(ue,e.agent.name)),G("click",J,()=>n("name",e.agent.name)),k(z,J)};O(d,z=>{c(u)?z(l):z(_,!1)})}var p=f(d,2),v=h(p),x=f(o,2),y=h(x);{var w=z=>{var J=vv();G("click",J,function(...ue){e.ondelete?.apply(this,ue)}),k(z,J)};O(y,z=>{e.agentCount>1&&z(w)})}var S=f(r,2),C=h(S),K=f(h(C),2);{var E=z=>{gt(z,{mono:!0,get saving(){return e.editor.editingSaving},onsave:J=>e.onsavefield("model",J),get oncancel(){return e.editor.cancelEdit},get value(){return c(s)},set value(J){b(s,J,!0)}})},U=Ae(()=>a("model")),te=z=>{var J=pv(),ue=h(J);V(()=>M(ue,e.agent.model)),G("click",J,()=>n("model",e.agent.model)),k(z,J)};O(K,z=>{c(U)?z(E):z(te,!1)})}var T=f(C,2),A=f(h(T),2);{var X=z=>{gt(z,{mono:!0,get saving(){return e.editor.editingSaving},placeholder:"none",onsave:J=>e.onsavefield("fallbackModel",J,ue=>ue.trim()||null),get oncancel(){return e.editor.cancelEdit},get value(){return c(s)},set value(J){b(s,J,!0)}})},L=Ae(()=>a("fallbackModel")),se=z=>{var J=gv(),ue=h(J);V(()=>M(ue,e.agent.fallbackModel??"none")),G("click",J,()=>n("fallbackModel",e.agent.fallbackModel??"")),k(z,J)};O(A,z=>{c(L)?z(X):z(se,!1)})}var oe=f(T,2),de=f(h(oe),2);{var $=z=>{gt(z,{mono:!0,get saving(){return e.editor.editingSaving},onsave:J=>e.onsavefield("maxTurns",J,ue=>Number(ue)),get oncancel(){return e.editor.cancelEdit},get value(){return c(s)},set value(J){b(s,J,!0)}})},H=Ae(()=>a("maxTurns")),ne=z=>{var J=xv(),ue=h(J);V(()=>M(ue,e.agent.maxTurns)),G("click",J,()=>n("maxTurns",e.agent.maxTurns)),k(z,J)};O(de,z=>{c(H)?z($):z(ne,!1)})}var ae=f(oe,2),xe=f(h(ae),2);{var ge=z=>{gt(z,{mono:!0,get saving(){return e.editor.editingSaving},placeholder:"global",onsave:J=>e.onsavefield("processTimeoutMs",J,ue=>{const Se=ue.trim();return Se?Number(Se)*1e3:null}),get oncancel(){return e.editor.cancelEdit},get value(){return c(s)},set value(J){b(s,J,!0)}})},he=Ae(()=>a("processTimeoutMs")),Fe=z=>{var J=bv(),ue=h(J);V(()=>M(ue,e.agent.processTimeoutMs?`${e.agent.processTimeoutMs/1e3}s`:"global")),G("click",J,()=>n("processTimeoutMs",e.agent.processTimeoutMs?String(e.agent.processTimeoutMs/1e3):"")),k(z,J)};O(xe,z=>{c(he)?z(ge):z(Fe,!1)})}var Be=f(ae,2),Xe=f(h(Be),2);{var q=z=>{gt(z,{mono:!0,get saving(){return e.editor.editingSaving},onsave:J=>e.onsavefield("channels",J,ue=>ue.split(",").map(Se=>Se.trim()).filter(Boolean)),get oncancel(){return e.editor.cancelEdit},get value(){return c(s)},set value(J){b(s,J,!0)}})},re=Ae(()=>a("channels")),fe=z=>{var J=mv(),ue=h(J);V(Se=>M(ue,Se),[()=>e.agent.channels.join(", ")||"*"]),G("click",J,()=>n("channels",e.agent.channels.join(", "))),k(z,J)};O(Xe,z=>{c(re)?z(q):z(fe,!1)})}var we=f(S,2),le=f(h(we),2);{var _e=z=>{gt(z,{multiline:!0,get saving(){return e.editor.editingSaving},onsave:J=>e.onsavefield("systemPrompt",J),get oncancel(){return e.editor.cancelEdit},get value(){return c(s)},set value(J){b(s,J,!0)}})},Z=Ae(()=>a("systemPrompt")),be=z=>{var J=wv(),ue=h(J);V(()=>M(ue,e.agent.systemPrompt)),G("click",J,()=>n("systemPrompt",e.agent.systemPrompt)),k(z,J)};O(le,z=>{c(Z)?z(_e):z(be,!1)})}V(()=>M(v,e.agent.id)),k(t,i),nt()}_t(["click"]);var Sv=F('<div class="agent-card agent-card-new svelte-6z0nn3"><div class="agent-bar agent-bar-new svelte-6z0nn3"></div> <div class="agent-top svelte-6z0nn3"><span class="agent-name svelte-6z0nn3" style="color: var(--color-accent)">New Agent</span> <button class="btn btn-outline btn-sm">Cancel</button></div> <div class="new-agent-form svelte-6z0nn3"><div class="form-row svelte-6z0nn3"><label class="form-lbl svelte-6z0nn3" for="new-agent-name">Name</label> <input id="new-agent-name" class="form-field svelte-6z0nn3" type="text" placeholder="Agent name"/></div> <div class="form-row svelte-6z0nn3"><label class="form-lbl svelte-6z0nn3" for="new-agent-model">Model</label> <input id="new-agent-model" class="form-field mono svelte-6z0nn3" type="text" placeholder="sonnet"/></div> <div class="form-row svelte-6z0nn3"><label class="form-lbl svelte-6z0nn3" for="new-agent-turns">Max Turns</label> <input id="new-agent-turns" class="form-field mono svelte-6z0nn3" type="text" placeholder="50"/></div> <div class="form-row svelte-6z0nn3"><label class="form-lbl svelte-6z0nn3" for="new-agent-channels">Channels</label> <input id="new-agent-channels" class="form-field mono svelte-6z0nn3" type="text" placeholder="* (comma-separated)"/></div> <div class="form-row form-row-full svelte-6z0nn3"><label class="form-lbl svelte-6z0nn3" for="new-agent-prompt">System Prompt</label> <textarea id="new-agent-prompt" class="form-field form-field-textarea svelte-6z0nn3" placeholder="Optional system prompt"></textarea></div> <div class="form-row form-row-actions svelte-6z0nn3"><button class="btn btn-primary btn-sm">Create Agent</button></div></div></div>');function Cv(t,e){st(e,!0);let s=W(Ne({name:"",model:"",maxTurns:"50",systemPrompt:"",channels:"*"}));function n(U){return U.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}async function a(){const U=n(c(s).name)||"agent",te=c(s).channels.split(",").map(X=>X.trim()).filter(Boolean),T={id:U,name:c(s).name,model:c(s).model,fallbackModel:null,maxTurns:Number(c(s).maxTurns)||50,systemPrompt:c(s).systemPrompt||"You are responding in a Slack workspace. Be concise, helpful, and natural.",channels:te.length>0?te:["*"]};await e.onsave(T)&&b(s,{name:"",model:"",maxTurns:"50",systemPrompt:"",channels:"*"},!0)}var i=Sv(),r=f(h(i),2),o=f(h(r),2),d=f(r,2),l=h(d),u=f(h(l),2),_=f(l,2),p=f(h(_),2),v=f(_,2),x=f(h(v),2),y=f(v,2),w=f(h(y),2),S=f(y,2),C=f(h(S),2),K=f(S,2),E=h(K);V(U=>E.disabled=U,[()=>!c(s).name.trim()||!c(s).model.trim()]),G("click",o,function(...U){e.oncancel?.apply(this,U)}),He(u,()=>c(s).name,U=>c(s).name=U),He(p,()=>c(s).model,U=>c(s).model=U),He(x,()=>c(s).maxTurns,U=>c(s).maxTurns=U),He(w,()=>c(s).channels,U=>c(s).channels=U),He(C,()=>c(s).systemPrompt,U=>c(s).systemPrompt=U),G("click",E,a),k(t,i),nt()}_t(["click"]);var Ev=F('<button class="btn btn-outline btn-sm">Add Agent</button>'),Av=F('<div class="section"><div class="section-header"><h2 class="section-title">Agents</h2> <!></div> <!> <!></div>');function Kv(t,e){st(e,!0);let s=W(!1);async function n(v,x,y,w){const S=e.config.agents.map(U=>({...U})),C=S[v];if(!C)return;const K=w?w(y):y;C[x]=K,await e.editor.saveConfigPatch({agents:S})&&e.editor.cancelEdit()}async function a(v){if(e.config.agents.length<=1)return;const x=e.config.agents[v];if(!x||!await Or(`Delete agent "${x.name}"?`))return;const w=e.config.agents.filter((S,C)=>C!==v);await e.editor.saveConfigPatch({agents:w})}async function i(v){const x=[...e.config.agents,v],y=await e.editor.saveConfigPatch({agents:x});return y&&b(s,!1),y}var r=Av(),o=h(r),d=f(h(o),2);{var l=v=>{var x=Ev();G("click",x,()=>{b(s,!0)}),k(v,x)};O(d,v=>{c(s)||v(l)})}var u=f(o,2);Mt(u,19,()=>e.config.agents,v=>v.id,(v,x,y)=>{kv(v,{get agent(){return c(x)},get index(){return c(y)},get agentCount(){return e.config.agents.length},get editor(){return e.editor},onsavefield:(w,S,C)=>n(c(y),w,S,C),ondelete:()=>a(c(y))})});var _=f(u,2);{var p=v=>{Cv(v,{onsave:i,oncancel:()=>{b(s,!1)}})};O(_,v=>{c(s)&&v(p)})}k(t,r),nt()}_t(["click"]);var Fv=F('<div class="row"><span class="row-label">Uptime</span> <span class="row-value mono"> </span></div>'),Tv=F('<button class="val-btn mono editable"> </button>'),Mv=F('<span class="cli-pill svelte-u0w225"><span class="dot dot-muted"></span> claude ...</span>'),Xv=F('<span class="cli-pill cli-pill-ok svelte-u0w225"><span class="dot dot-on"></span> </span>'),Lv=F('<span class="cli-pill cli-pill-err svelte-u0w225"><span class="dot dot-off"></span> claude not found</span>'),Pv=F('<div class="row"><span class="row-label">Node.js</span> <span class="row-value mono"> </span></div>'),Bv=kn('<svg viewBox="0 0 16 16" fill="none" aria-hidden="true" class="svelte-u0w225"><path d="M3 8.5l3.5 3.5L13 4.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>'),Dv=F('<div class="secret-edit svelte-u0w225"><input type="password" autocomplete="off" class="secret-input mono svelte-u0w225" placeholder="sk-ant-..."/> <button class="inline-btn inline-btn-save svelte-u0w225" title="Save"><!></button> <button class="inline-btn inline-btn-cancel svelte-u0w225" title="Cancel"><svg viewBox="0 0 16 16" fill="none" aria-hidden="true" class="svelte-u0w225"><path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg></button></div>'),Rv=F('<button class="val-btn mono editable"> </button>'),Iv=F('<span class="dim">...</span>'),Qv=F('<button class="val-btn mono editable"> </button>'),Nv=F('<button class="val-btn mono editable"> </button>'),Uv=F('<button class="val-btn mono editable"> </button>'),Hv=F("<span><span></span> </span>"),zv=kn('<svg viewBox="0 0 16 16" fill="none" aria-hidden="true" class="svelte-u0w225"><path d="M3 8.5l3.5 3.5L13 4.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>'),Ov=F('<div class="secret-edit svelte-u0w225"><input type="password" autocomplete="off" class="secret-input mono svelte-u0w225"/> <button class="inline-btn inline-btn-save svelte-u0w225" title="Save"><!></button> <button class="inline-btn inline-btn-cancel svelte-u0w225" title="Cancel"><svg viewBox="0 0 16 16" fill="none" aria-hidden="true" class="svelte-u0w225"><path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg></button></div>'),Vv=F('<button class="val-btn mono editable"> </button>'),Gv=F('<span class="dim">...</span>'),qv=F('<div class="row"><span class="row-label"> </span> <span class="row-value"><!></span></div>'),Wv=F('<button class="val-btn mono editable"> </button>'),jv=F('<button class="val-btn mono editable"> </button>'),Yv=F('<button class="val-btn mono editable"> </button>'),Zv=F('<button class="val-btn mono editable"> </button>'),Jv=F('<div class="row"><span class="row-label">Start / End</span> <span class="row-value"><!> <span class="dim">–</span> <!></span></div>'),$v=F("<span><span></span> </span>"),ep=F('<button class="val-btn mono editable"> </button>'),tp=F('<div class="row"><span class="row-label">VM Host</span> <span class="row-value"><!></span></div> <div class="row"><span class="row-label">Mode</span> <span class="row-value mono"> </span></div> <div class="row"><span class="row-label">VNC Port</span> <span class="row-value mono"> </span></div> <div class="row"><span class="row-label">noVNC Port</span> <span class="row-value mono"> </span></div>',1),sp=F('<button class="val-btn mono editable"> </button>'),np=F('<button class="val-btn mono editable"> </button>'),ap=F('<div class="config-grid svelte-u0w225"><div class="panel"><div class="panel-header"><span class="panel-title">System</span></div> <div class="panel-body"><!> <div class="row"><span class="row-label">Timezone</span> <span class="row-value"><!></span></div> <div class="row"><span class="row-label">Web Port</span> <span class="row-value mono"> </span></div> <div class="row"><span class="row-label">Agent CLI</span> <span class="row-value"><!></span></div> <!> <div class="row"><span class="row-label">API Key</span> <span class="row-value"><!></span></div></div></div> <div class="panel"><div class="panel-header"><span class="panel-title">Sessions</span></div> <div class="panel-body"><div class="row"><span class="row-label">Max Concurrent</span> <span class="row-value"><!></span></div> <div class="row"><span class="row-label">TTL</span> <span class="row-value"><!></span></div> <div class="row"><span class="row-label">Timeout</span> <span class="row-value"><!></span></div></div></div> <div class="panel"><div class="panel-header"><span class="panel-title">Slack</span> <!></div> <div class="panel-body"><!> <!> <div class="row"><span class="row-label">Require Mention</span> <span class="row-value"><!></span></div> <div class="row"><span class="row-label">Debounce</span> <span class="row-value"><!></span></div> <div class="row"><span class="row-label">Bypass DMs</span> <span class="row-value"><!></span></div> <div class="row"><span class="row-label">Channels</span> <span class="row-value"><!></span></div> <div class="row"><span class="row-label">Quiet Hours</span> <span class="row-value"><!></span></div> <!></div></div> <div class="panel"><div class="panel-header"><span class="panel-title">Browser</span> <!></div> <div class="panel-body"><div class="row"><span class="row-label">Enabled</span> <span class="row-value"><!></span></div> <!></div></div> <div class="panel"><div class="panel-header"><span class="panel-title">Birds</span></div> <div class="panel-body"><div class="row"><span class="row-label">Max Attempts</span> <span class="row-value"><!></span></div></div></div> <div class="panel"><div class="panel-header"><span class="panel-title">Database</span></div> <div class="panel-body"><div class="row"><span class="row-label">Retention</span> <span class="row-value"><!></span></div></div></div></div> <!>',1);function ip(t,e){st(e,!0);let s=W("");function n(ee,j){b(s,String(j),!0),e.editor.startEdit(ee,j)}let a=W(null),i=W(""),r=W(!1);function o(ee){b(a,ee,!0),b(i,"")}function d(){b(a,null),b(r,!1)}async function l(){if(!(!c(a)||!c(i).trim())){b(r,!0);try{if(c(a)==="slackBotToken"||c(a)==="slackAppToken"){const ee=c(a)==="slackBotToken"?{botToken:c(i).trim()}:{appToken:c(i).trim()};await ke("/api/secrets/slack",{method:"PUT",body:ee}),Me("Slack token saved","success")}else await ke("/api/secrets/anthropic",{method:"PUT",body:{apiKey:c(i).trim()}}),Me("API key saved (effective next session)","success");b(a,null),b(i,""),e.onsecretsupdate()}catch(ee){Me(ee.message,"error")}finally{b(r,!1)}}}function u(ee){ee.key==="Escape"?d():ee.key==="Enter"&&(ee.preventDefault(),l())}var _=ap(),p=me(_),v=h(p),x=f(h(v),2),y=h(x);{var w=ee=>{var j=Fv(),ce=f(h(j),2),Re=h(ce);V(vt=>M(Re,vt),[()=>Ph(e.status.uptime)]),k(ee,j)};O(y,ee=>{e.status&&ee(w)})}var S=f(y,2),C=f(h(S),2),K=h(C);{var E=ee=>{gt(ee,{mono:!0,get saving(){return e.editor.editingSaving},onsave:j=>e.editor.saveField("timezone",j),get oncancel(){return e.editor.cancelEdit},get value(){return c(s)},set value(j){b(s,j,!0)}})},U=ee=>{var j=Tv(),ce=h(j);V(()=>M(ce,e.config.timezone)),G("click",j,()=>n("timezone",e.config.timezone)),k(ee,j)};O(K,ee=>{e.editor.editingField==="timezone"?ee(E):ee(U,!1)})}var te=f(S,2),T=f(h(te),2),A=h(T),X=f(te,2),L=f(h(X),2),se=h(L);{var oe=ee=>{var j=Mv();k(ee,j)},de=ee=>{var j=yt(),ce=me(j);{var Re=St=>{var ns=Xv(),ms=f(h(ns));V(()=>M(ms,` claude ${e.doctor.claude.version??""}`)),k(St,ns)},vt=St=>{var ns=Lv();k(St,ns)};O(ce,St=>{e.doctor.claude.available?St(Re):St(vt,!1)})}k(ee,j)};O(se,ee=>{e.doctorLoading?ee(oe):e.doctor&&ee(de,1)})}var $=f(X,2);{var H=ee=>{var j=Pv(),ce=f(h(j),2),Re=h(ce);V(()=>M(Re,e.doctor.node)),k(ee,j)};O($,ee=>{e.doctor&&ee(H)})}var ne=f($,2),ae=f(h(ne),2),xe=h(ae);{var ge=ee=>{var j=Dv(),ce=h(j),Re=f(ce,2),vt=h(Re);{var St=Zt=>{var Gs=Ss("...");k(Zt,Gs)},ns=Zt=>{var Gs=Bv();k(Zt,Gs)};O(vt,Zt=>{c(r)?Zt(St):Zt(ns,!1)})}var ms=f(Re,2);V(()=>Re.disabled=c(r)||!c(i)),G("keydown",ce,u),He(ce,()=>c(i),Zt=>b(i,Zt)),G("click",Re,l),G("click",ms,d),k(ee,j)},he=ee=>{var j=Rv(),ce=h(j);V(()=>M(ce,e.secrets.anthropic.set?e.secrets.anthropic.hint:"not set")),G("click",j,()=>o("apiKey")),k(ee,j)},Fe=ee=>{var j=Iv();k(ee,j)};O(xe,ee=>{c(a)==="apiKey"?ee(ge):e.secrets?ee(he,1):ee(Fe,!1)})}var Be=f(v,2),Xe=f(h(Be),2),q=h(Xe),re=f(h(q),2),fe=h(re);{var we=ee=>{gt(ee,{mono:!0,get saving(){return e.editor.editingSaving},onsave:j=>e.editor.saveField("sessions.maxConcurrent",j,ce=>Number(ce)),get oncancel(){return e.editor.cancelEdit},get value(){return c(s)},set value(j){b(s,j,!0)}})},le=ee=>{var j=Qv(),ce=h(j);V(()=>M(ce,e.config.sessions.maxConcurrent)),G("click",j,()=>n("sessions.maxConcurrent",e.config.sessions.maxConcurrent)),k(ee,j)};O(fe,ee=>{e.editor.editingField==="sessions.maxConcurrent"?ee(we):ee(le,!1)})}var _e=f(q,2),Z=f(h(_e),2),be=h(Z);{var z=ee=>{gt(ee,{mono:!0,get saving(){return e.editor.editingSaving},onsave:j=>e.editor.saveField("sessions.ttlHours",j,ce=>Number(ce)),get oncancel(){return e.editor.cancelEdit},get value(){return c(s)},set value(j){b(s,j,!0)}})},J=ee=>{var j=Nv(),ce=h(j);V(()=>M(ce,`${e.config.sessions.ttlHours??""}h`)),G("click",j,()=>n("sessions.ttlHours",e.config.sessions.ttlHours)),k(ee,j)};O(be,ee=>{e.editor.editingField==="sessions.ttlHours"?ee(z):ee(J,!1)})}var ue=f(_e,2),Se=f(h(ue),2),Ie=h(Se);{var et=ee=>{gt(ee,{mono:!0,get saving(){return e.editor.editingSaving},onsave:j=>e.editor.saveField("sessions.processTimeoutMs",j,ce=>Math.round(Number(ce)*1e3)),get oncancel(){return e.editor.cancelEdit},get value(){return c(s)},set value(j){b(s,j,!0)}})},je=ee=>{var j=Uv(),ce=h(j);V(Re=>M(ce,`${Re??""}s`),[()=>(e.config.sessions.processTimeoutMs/1e3).toFixed(0)]),G("click",j,()=>n("sessions.processTimeoutMs",(e.config.sessions.processTimeoutMs/1e3).toFixed(0))),k(ee,j)};O(Ie,ee=>{e.editor.editingField==="sessions.processTimeoutMs"?ee(et):ee(je,!1)})}var bt=f(Be,2),tt=h(bt),Ye=f(h(tt),2);{var mt=ee=>{var j=Hv();let ce;var Re=h(j);let vt;var St=f(Re);V(()=>{ce=pe(j,1,"svc-chip",null,ce,{"svc-chip-ok":e.status.slack.connected,"svc-chip-err":!e.status.slack.connected}),vt=pe(Re,1,"dot",null,vt,{"dot-on":e.status.slack.connected,"dot-off":!e.status.slack.connected}),M(St,` ${e.status.slack.connected?"connected":"disconnected"}`)}),k(ee,j)};O(Ye,ee=>{e.status&&ee(mt)})}var ye=f(tt,2);{const ee=(j,ce=xa,Re=xa,vt=xa,St=xa)=>{var ns=qv(),ms=h(ns),Zt=h(ms),Gs=f(ms,2),Ft=h(Gs);{var Et=ws=>{var Ds=Ov(),as=h(Ds),cs=f(as,2),Ii=h(cs);{var yd=rn=>{var Qi=Ss("...");k(rn,Qi)},kd=rn=>{var Qi=zv();k(rn,Qi)};O(Ii,rn=>{c(r)?rn(yd):rn(kd,!1)})}var Sd=f(cs,2);V(()=>{jt(as,"placeholder",vt()),cs.disabled=c(r)||!c(i)}),G("keydown",as,u),He(as,()=>c(i),rn=>b(i,rn)),G("click",cs,l),G("click",Sd,d),k(ws,Ds)},Cn=ws=>{var Ds=Vv(),as=h(Ds);V(()=>M(as,St().set?St().hint:"not set")),G("click",Ds,()=>o(ce())),k(ws,Ds)},Ri=ws=>{var Ds=Gv();k(ws,Ds)};O(Ft,ws=>{c(a)===ce()?ws(Et):St()?ws(Cn,1):ws(Ri,!1)})}V(()=>M(Zt,Re())),k(j,ns)};var Oe=h(ye);ee(Oe,()=>"slackBotToken",()=>"Bot Token",()=>"xoxb-...",()=>e.secrets?.slack.botToken);var lt=f(Oe,2);ee(lt,()=>"slackAppToken",()=>"App Token",()=>"xapp-...",()=>e.secrets?.slack.appToken);var ls=f(lt,2),ss=f(h(ls),2),gs=h(ss);Xn(gs,{get active(){return e.config.slack.requireMention},onToggle:()=>e.editor.toggleField("slack.requireMention",e.config.slack.requireMention)});var Ts=f(ls,2),Ct=f(h(Ts),2),xs=h(Ct);{var Hs=j=>{gt(j,{mono:!0,get saving(){return e.editor.editingSaving},onsave:ce=>e.editor.saveField("slack.coalesce.debounceMs",ce,Re=>Number(Re)),get oncancel(){return e.editor.cancelEdit},get value(){return c(s)},set value(ce){b(s,ce,!0)}})},Ms=j=>{var ce=Wv(),Re=h(ce);V(()=>M(Re,`${e.config.slack.coalesce.debounceMs??""}ms`)),G("click",ce,()=>n("slack.coalesce.debounceMs",e.config.slack.coalesce.debounceMs)),k(j,ce)};O(xs,j=>{e.editor.editingField==="slack.coalesce.debounceMs"?j(Hs):j(Ms,!1)})}var Xs=f(Ts,2),Ls=f(h(Xs),2),bs=h(Ls);Xn(bs,{get active(){return e.config.slack.coalesce.bypassDms},onToggle:()=>e.editor.toggleField("slack.coalesce.bypassDms",e.config.slack.coalesce.bypassDms)});var zs=f(Xs,2),Os=f(h(zs),2),an=h(Os);{var Ve=j=>{gt(j,{mono:!0,get saving(){return e.editor.editingSaving},onsave:ce=>e.editor.saveField("slack.channels",ce,Re=>Re.split(",").map(vt=>vt.trim()).filter(Boolean)),get oncancel(){return e.editor.cancelEdit},get value(){return c(s)},set value(ce){b(s,ce,!0)}})},Ze=j=>{var ce=jv(),Re=h(ce);V(vt=>M(Re,vt),[()=>e.config.slack.channels.join(", ")||"*"]),G("click",ce,()=>n("slack.channels",e.config.slack.channels.join(", "))),k(j,ce)};O(an,j=>{e.editor.editingField==="slack.channels"?j(Ve):j(Ze,!1)})}var ct=f(zs,2),dt=f(h(ct),2),Kt=h(dt);Xn(Kt,{get active(){return e.config.slack.quietHours.enabled},onToggle:()=>e.editor.toggleField("slack.quietHours.enabled",e.config.slack.quietHours.enabled)});var ut=f(ct,2);{var Je=j=>{var ce=Jv(),Re=f(h(ce),2),vt=h(Re);{var St=Ft=>{gt(Ft,{mono:!0,get saving(){return e.editor.editingSaving},placeholder:"HH:MM",onsave:Et=>e.editor.saveField("slack.quietHours.start",Et),get oncancel(){return e.editor.cancelEdit},get value(){return c(s)},set value(Et){b(s,Et,!0)}})},ns=Ft=>{var Et=Yv(),Cn=h(Et);V(()=>M(Cn,e.config.slack.quietHours.start)),G("click",Et,()=>n("slack.quietHours.start",e.config.slack.quietHours.start)),k(Ft,Et)};O(vt,Ft=>{e.editor.editingField==="slack.quietHours.start"?Ft(St):Ft(ns,!1)})}var ms=f(vt,4);{var Zt=Ft=>{gt(Ft,{mono:!0,get saving(){return e.editor.editingSaving},placeholder:"HH:MM",onsave:Et=>e.editor.saveField("slack.quietHours.end",Et),get oncancel(){return e.editor.cancelEdit},get value(){return c(s)},set value(Et){b(s,Et,!0)}})},Gs=Ft=>{var Et=Zv(),Cn=h(Et);V(()=>M(Cn,e.config.slack.quietHours.end)),G("click",Et,()=>n("slack.quietHours.end",e.config.slack.quietHours.end)),k(Ft,Et)};O(ms,Ft=>{e.editor.editingField==="slack.quietHours.end"?Ft(Zt):Ft(Gs,!1)})}k(j,ce)};O(ut,j=>{e.config.slack.quietHours.enabled&&j(Je)})}}var ht=f(bt,2),Ge=h(ht),Y=f(h(Ge),2);{var ie=ee=>{var j=$v();let ce;var Re=h(j);let vt;var St=f(Re);V(()=>{ce=pe(j,1,"svc-chip",null,ce,{"svc-chip-ok":e.status.browser.connected,"svc-chip-err":!e.status.browser.connected}),vt=pe(Re,1,"dot",null,vt,{"dot-on":e.status.browser.connected,"dot-off":!e.status.browser.connected}),M(St,` ${e.status.browser.connected?"connected":"unreachable"}`)}),k(ee,j)};O(Y,ee=>{e.config.browser.enabled&&e.status&&ee(ie)})}var ve=f(Ge,2),Ke=h(ve),Qe=f(h(Ke),2),qe=h(Qe);Xn(qe,{get active(){return e.config.browser.enabled},onToggle:()=>e.editor.toggleField("browser.enabled",e.config.browser.enabled)});var ft=f(Ke,2);{var wt=ee=>{var j=tp(),ce=me(j),Re=f(h(ce),2),vt=h(Re);{var St=as=>{gt(as,{mono:!0,get saving(){return e.editor.editingSaving},onsave:cs=>e.editor.saveField("browser.novncHost",cs),get oncancel(){return e.editor.cancelEdit},get value(){return c(s)},set value(cs){b(s,cs,!0)}})},ns=as=>{var cs=ep(),Ii=h(cs);V(()=>M(Ii,e.config.browser.novncHost)),G("click",cs,()=>n("browser.novncHost",e.config.browser.novncHost)),k(as,cs)};O(vt,as=>{e.editor.editingField==="browser.novncHost"?as(St):as(ns,!1)})}var ms=f(ce,2),Zt=f(h(ms),2),Gs=h(Zt),Ft=f(ms,2),Et=f(h(Ft),2),Cn=h(Et),Ri=f(Ft,2),ws=f(h(Ri),2),Ds=h(ws);V(()=>{M(Gs,e.config.browser.mode),M(Cn,e.config.browser.vncPort),M(Ds,e.config.browser.novncPort)}),k(ee,j)};O(ft,ee=>{e.config.browser.enabled&&ee(wt)})}var Pt=f(ht,2),Bt=f(h(Pt),2),Nt=h(Bt),Ps=f(h(Nt),2),Te=h(Ps);{var $e=ee=>{gt(ee,{mono:!0,get saving(){return e.editor.editingSaving},onsave:j=>e.editor.saveField("birds.maxAttempts",j,ce=>Number(ce)),get oncancel(){return e.editor.cancelEdit},get value(){return c(s)},set value(j){b(s,j,!0)}})},at=ee=>{var j=sp(),ce=h(j);V(()=>M(ce,e.config.birds.maxAttempts)),G("click",j,()=>n("birds.maxAttempts",e.config.birds.maxAttempts)),k(ee,j)};O(Te,ee=>{e.editor.editingField==="birds.maxAttempts"?ee($e):ee(at,!1)})}var Ut=f(Pt,2),qt=f(h(Ut),2),Sn=h(qt),Vs=f(h(Sn),2),Bs=h(Vs);{var ca=ee=>{gt(ee,{mono:!0,get saving(){return e.editor.editingSaving},onsave:j=>e.editor.saveField("database.retentionDays",j,ce=>Number(ce)),get oncancel(){return e.editor.cancelEdit},get value(){return c(s)},set value(j){b(s,j,!0)}})},Di=ee=>{var j=np(),ce=h(j);V(()=>M(ce,`${e.config.database.retentionDays??""} days`)),G("click",j,()=>n("database.retentionDays",e.config.database.retentionDays)),k(ee,j)};O(Bs,ee=>{e.editor.editingField==="database.retentionDays"?ee(ca):ee(Di,!1)})}var wd=f(p,2);Kv(wd,{get config(){return e.config},get editor(){return e.editor}}),V(()=>M(A,e.config.web.port)),k(t,_),nt()}_t(["click","keydown"]);var rp=F('<span class="queue-summary mono svelte-17vayue"> </span>'),op=F('<div class="stat-row svelte-17vayue"><div class="stat-cell svelte-17vayue"><span class="stat-num svelte-17vayue"> </span> <span class="stat-lbl svelte-17vayue">pending</span></div> <div class="stat-cell svelte-17vayue"><span class="stat-num stat-num-active svelte-17vayue"> </span> <span class="stat-lbl svelte-17vayue">running</span></div> <div class="stat-cell svelte-17vayue"><span class="stat-num stat-num-ok svelte-17vayue"> </span> <span class="stat-lbl svelte-17vayue">completed</span></div> <div class="stat-cell svelte-17vayue"><span class="stat-num stat-num-err svelte-17vayue"> </span> <span class="stat-lbl svelte-17vayue">failed</span></div></div>'),lp=F('<div class="panel"><div class="panel-header"><span class="panel-title">Job Queue</span> <!></div> <div class="panel-body"><!> <div class="action-row svelte-17vayue"><button class="btn btn-outline btn-sm"> </button> <button class="btn btn-outline btn-sm"> </button> <button class="btn btn-outline btn-sm"> </button></div></div></div>');function cp(t,e){st(e,!0);let s=W(null);xt(()=>{e.initialStats!=null&&b(s,e.initialStats,!0)});let n=W(!1),a=W(!1),i=W(!1);async function r(){b(s,await ke("/api/jobs/stats"),!0)}async function o(){b(n,!0);try{const A=await ke("/api/jobs/retry-all",{method:"POST"});Me(`${A.count} failed job(s) queued for retry`,"success"),await r()}catch(A){Me(`Failed: ${A.message}`,"error")}finally{b(n,!1)}}async function d(){b(a,!0);try{const A=await ke("/api/jobs/clear?status=completed",{method:"DELETE"});Me(`${A.count} completed job(s) cleared`,"success"),await r()}catch(A){Me(`Failed: ${A.message}`,"error")}finally{b(a,!1)}}async function l(){b(i,!0);try{const A=await ke("/api/jobs/clear?status=failed",{method:"DELETE"});Me(`${A.count} failed job(s) cleared`,"success"),await r()}catch(A){Me(`Failed: ${A.message}`,"error")}finally{b(i,!1)}}var u=lp(),_=h(u),p=f(h(_),2);{var v=A=>{var X=rp(),L=h(X);V(()=>M(L,`${c(s).total??""} total`)),k(A,X)};O(p,A=>{c(s)&&A(v)})}var x=f(_,2),y=h(x);{var w=A=>{var X=op(),L=h(X),se=h(L),oe=h(se),de=f(L,2),$=h(de),H=h($),ne=f(de,2),ae=h(ne),xe=h(ae),ge=f(ne,2),he=h(ge),Fe=h(he);V(()=>{M(oe,c(s).pending),M(H,c(s).running),M(xe,c(s).completed),M(Fe,c(s).failed)}),k(A,X)};O(y,A=>{c(s)&&A(w)})}var S=f(y,2),C=h(S),K=h(C),E=f(C,2),U=h(E),te=f(E,2),T=h(te);V(()=>{C.disabled=c(n)||(c(s)?.failed??0)===0,M(K,c(n)?"Retrying...":"Retry Failed"),E.disabled=c(a)||(c(s)?.completed??0)===0,M(U,c(a)?"Clearing...":"Clear Completed"),te.disabled=c(i)||(c(s)?.failed??0)===0,M(T,c(i)?"Clearing...":"Clear Failed")}),G("click",C,o),G("click",E,d),G("click",te,l),k(t,u),nt()}_t(["click"]);var dp=F('<div class="row"><span class="dim">No system birds registered</span></div>'),up=F('<span class="bird-last-run svelte-12folcn"> <!></span>'),hp=F('<button class="btn btn-outline btn-sm">Flights</button>'),fp=F('<div class="flight-empty svelte-12folcn"><span class="dim">No flights recorded</span></div>'),_p=F('<div class="flight-row svelte-12folcn"><span class="mono flight-id svelte-12folcn"> </span> <!> <span class="mono"> </span> <span class="flight-time svelte-12folcn"> </span></div>'),vp=F('<div class="flight-list svelte-12folcn"><!></div>'),pp=F('<div><div class="bird-top svelte-12folcn"><div class="bird-info svelte-12folcn"><span class="bird-name mono svelte-12folcn"> </span> <span class="bird-schedule mono dim svelte-12folcn"> </span></div> <div class="bird-actions svelte-12folcn"><!> <!> <button class="btn btn-outline btn-sm">Fly</button></div></div> <!></div>'),gp=F('<div class="panel"><div class="panel-header"><span class="panel-title">System Birds</span> <span class="bird-count mono svelte-12folcn"> </span></div> <div class="panel-body"><!></div></div>');function xp(t,e){st(e,!0);let s=W(Ne({}));async function n(v){if(!c(s)[v])try{const x=await ke(`/api/birds/${v}/flights?perPage=5`);b(s,{...c(s),[v]:x.items},!0)}catch{b(s,{...c(s),[v]:[]},!0)}}async function a(v,x){try{const y=await ke(`/api/birds/${v}/fly`,{method:"POST"});Me(`${x} sent on a flight (job #${y.jobId})`,"success");const{[v]:w,...S}=c(s);b(s,S,!0)}catch(y){Me(`Failed: ${y.message}`,"error")}}var i=gp(),r=h(i),o=f(h(r),2),d=h(o),l=f(r,2),u=h(l);{var _=v=>{var x=dp();k(v,x)},p=v=>{var x=yt(),y=me(x);Mt(y,19,()=>e.birds,w=>w.uid,(w,S,C)=>{var K=pp();let E;var U=h(K),te=h(U),T=h(te),A=h(T),X=f(T,2),L=h(X),se=f(te,2),oe=h(se);{var de=ge=>{var he=up(),Fe=h(he),Be=f(Fe);{var Xe=q=>{xn(q,{get status(){return c(S).last_status}})};O(Be,q=>{c(S).last_status&&q(Xe)})}V(q=>M(Fe,`${q??""} `),[()=>fs(c(S).last_run)]),k(ge,he)};O(oe,ge=>{c(S).last_run&&ge(de)})}var $=f(oe,2);{var H=ge=>{var he=hp();G("click",he,()=>n(c(S).uid)),k(ge,he)};O($,ge=>{c(s)[c(S).uid]||ge(H)})}var ne=f($,2),ae=f(U,2);{var xe=ge=>{var he=vp(),Fe=h(he);{var Be=q=>{var re=fp();k(q,re)},Xe=q=>{var re=yt(),fe=me(re);Mt(fe,17,()=>c(s)[c(S).uid],we=>we.uid,(we,le)=>{var _e=_p(),Z=h(_e),be=h(Z),z=f(Z,2);xn(z,{get status(){return c(le).status}});var J=f(z,2),ue=h(J),Se=f(J,2),Ie=h(Se);V((et,je,bt)=>{M(be,et),M(ue,je),M(Ie,bt)},[()=>Tt(c(le).uid),()=>pi(c(le).started_at,c(le).finished_at),()=>fs(c(le).started_at)]),k(we,_e)}),k(q,re)};O(Fe,q=>{c(s)[c(S).uid].length===0?q(Be):q(Xe,!1)})}k(ge,he)};O(ae,ge=>{c(s)[c(S).uid]!=null&&ge(xe)})}V(()=>{E=pe(K,1,"bird-entry svelte-12folcn",null,E,{"bird-entry-border":c(C)<e.birds.length-1}),M(A,c(S).name),M(L,c(S).schedule)}),G("click",ne,()=>a(c(S).uid,c(S).name)),k(w,K)}),k(v,x)};O(u,v=>{e.birds.length===0?v(_):v(p,!1)})}V(()=>M(d,e.birds.length)),k(t,i),nt()}_t(["click"]);var bp=F('<span class="error-count svelte-ht9bxs"> </span>'),mp=F('<div class="row"><span class="dim">No errors recorded</span></div>'),wp=F('<div class="error-entry svelte-ht9bxs"><div class="error-top svelte-ht9bxs"><span class="error-source mono svelte-ht9bxs"> </span> <span class="error-time svelte-ht9bxs"> </span></div> <span class="error-message svelte-ht9bxs"> </span></div>'),yp=F('<div class="db-grid svelte-ht9bxs"><!> <div class="panel"><div class="panel-header"><span class="panel-title">Recent Errors</span> <!></div> <div class="panel-body"><!></div></div></div> <!>',1);function kp(t,e){st(e,!0);var s=yp(),n=me(s),a=h(n);cp(a,{get initialStats(){return e.jobStats}});var i=f(a,2),r=h(i),o=f(h(r),2);{var d=x=>{var y=bp(),w=h(y);V(()=>M(w,e.recentErrors.length)),k(x,y)};O(o,x=>{e.recentErrors.length>0&&x(d)})}var l=f(r,2),u=h(l);{var _=x=>{var y=mp();k(x,y)},p=x=>{var y=yt(),w=me(y);Mt(w,17,()=>e.recentErrors,S=>S.id,(S,C)=>{var K=wp(),E=h(K),U=h(E),te=h(U),T=f(U,2),A=h(T),X=f(E,2),L=h(X);V(se=>{M(te,c(C).source),M(A,se),M(L,c(C).message)},[()=>fs(c(C).created_at)]),k(S,K)}),k(x,y)};O(u,x=>{e.recentErrors.length===0?x(_):x(p,!1)})}var v=f(n,2);xp(v,{get birds(){return e.systemBirds}}),k(t,s),nt()}var Sp=F('<div class="loading">Loading...</div>'),Cp=F('<div class="tabs svelte-1ozf5k3"><button>Config</button> <button>Database</button></div> <!> <!>',1);function Ep(t,e){st(e,!0);let s=W(null),n=W(null),a=W(null),i=W(!0),r=W(Ne([])),o=W(null),d=W(Ne([])),l=W(!0),u=W("config"),_=W(null),p=W(!1);xt(()=>{const X=new AbortController;return Promise.all([ke("/api/config"),ke("/api/logs?level=error&perPage=10"),ke("/api/jobs/stats"),ke("/api/birds?system=true&perPage=100"),ke("/api/secrets")]).then(([L,se,oe,de,$])=>{X.signal.aborted||(b(s,L,!0),b(r,se.items,!0),b(o,oe,!0),b(d,de.items.filter(H=>H.name.startsWith("__bb_")),!0),b(n,$,!0))}).finally(()=>{X.signal.aborted||b(l,!1)}),()=>X.abort()}),xt(()=>{const X=new AbortController;return ke("/api/doctor").then(L=>{X.signal.aborted||b(a,L,!0)}).finally(()=>{X.signal.aborted||b(i,!1)}),()=>X.abort()}),xt(()=>Mi(X=>{X.resource==="config"&&ke("/api/config").then(L=>{b(s,L,!0)}).catch(()=>{}),X.resource==="secrets"&&v()}));function v(){ke("/api/secrets").then(X=>{b(n,X,!0)}).catch(()=>{})}function x(X,L){const se=X.split(".");let oe={};const de=oe;for(let $=0;$<se.length-1;$++){const H={};oe[se[$]]=H,oe=H}return oe[se[se.length-1]]=L,de}async function y(X){try{const L=await ke("/api/config",{method:"PATCH",body:X});return b(s,L,!0),Me("Config saved","success"),!0}catch(L){return Me(`Failed: ${L.message}`,"error"),!1}}function w(X,L){b(_,X,!0),b(p,!1)}function S(){b(_,null),b(p,!1)}async function C(X,L,se){b(p,!0);const oe=se?se(L):L;await y(x(X,oe))?S():b(p,!1)}async function K(X,L){await y(x(X,!L))}const E=Ae(()=>({editingField:c(_),editingSaving:c(p),startEdit:w,cancelEdit:S,saveField:C,toggleField:K,saveConfigPatch:y}));var U=yt(),te=me(U);{var T=X=>{var L=Sp();k(X,L)},A=X=>{var L=Cp(),se=me(L),oe=h(se);let de;var $=f(oe,2);let H;var ne=f(se,2);{var ae=he=>{ip(he,{get config(){return c(s)},get status(){return e.status},get doctor(){return c(a)},get doctorLoading(){return c(i)},get editor(){return c(E)},get secrets(){return c(n)},onsecretsupdate:v})};O(ne,he=>{c(u)==="config"&&he(ae)})}var xe=f(ne,2);{var ge=he=>{kp(he,{get jobStats(){return c(o)},get systemBirds(){return c(d)},get recentErrors(){return c(r)}})};O(xe,he=>{c(u)==="database"&&he(ge)})}V(()=>{de=pe(oe,1,"tab svelte-1ozf5k3",null,de,{"tab-active":c(u)==="config"}),H=pe($,1,"tab svelte-1ozf5k3",null,H,{"tab-active":c(u)==="database"})}),G("click",oe,()=>{b(u,"config")}),G("click",$,()=>{b(u,"database")}),k(X,L)};O(te,X=>{c(l)?X(T):c(s)&&X(A,1)})}k(t,U),nt()}_t(["click"]);var Ap=F('<div class="card-sub svelte-1tf674w"> </div>'),Kp=F('<div><div class="card-label svelte-1tf674w"> </div> <div class="card-value svelte-1tf674w"> </div> <!></div>');function dr(t,e){var s=Kp();let n;var a=h(s),i=h(a),r=f(a,2),o=h(r),d=f(r,2);{var l=u=>{var _=Ap(),p=h(_);V(()=>M(p,e.sub)),k(u,_)};O(d,u=>{e.sub&&u(l)})}V(()=>{n=pe(s,1,"stat-card svelte-1tf674w",null,n,{"stat-card-info":e.variant==="info","stat-card-warning":e.variant==="warning","stat-card-success":e.variant==="success","stat-card-error":e.variant==="error"}),M(i,e.label),M(o,e.value)}),k(t,s)}var Fp=F('<div class="error-state svelte-1lyclyh"><p> </p> <button class="btn btn-outline btn-sm">Back to Sessions</button></div>'),Tp=F('<div class="loading">Loading...</div>'),Mp=F('<div class="filter-spacer svelte-1lyclyh"></div> <span class="last-updated svelte-1lyclyh"> </span>',1),Xp=F('<tr><td><!></td><td class="mono"> </td><td class="content-cell svelte-1lyclyh"> </td><td class="mono"> </td><td class="mono"> </td><td> </td></tr>'),Lp=F('<div class="detail-header svelte-1lyclyh"><button class="btn btn-outline btn-sm"><svg class="back-icon svelte-1lyclyh" viewBox="0 0 6 10" fill="none" aria-hidden="true"><path d="M5 1L1 5L5 9" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path></svg> Sessions</button> <h2 class="session-title svelte-1lyclyh"> </h2> <span class="session-meta svelte-1lyclyh"><span class="mono"> </span> <span class="meta-sep svelte-1lyclyh"></span> <span class="meta-sep svelte-1lyclyh"></span> </span></div> <div class="stat-cards svelte-1lyclyh"><!> <!> <!></div> <!>',1);function Pp(t,e){st(e,!0);const s=Ti().get("id")??"",n=[{key:"direction",label:"Dir"},{key:"user_id",label:"User",sortable:!0},{key:"content",label:"Content"},{key:"tokens_in",label:"Tokens In"},{key:"tokens_out",label:"Tokens Out"},{key:"created_at",label:"Time",sortable:!0}];let a=W(Ne(wn())),i=W(null),r=W(null),o=W("");const d=s?Vr({endpoint:`/api/sessions/${s}`,columns:n,defaultSort:"created_at",invalidateOn:"sessions",transformResponse:y=>y.messages,onResponse:y=>{b(a,wn(),!0),b(i,y.session,!0),b(r,y.stats,!0)}}):null;d||b(o,"Invalid session ID");function l(){window.location.hash="#/sessions"}var u=yt(),_=me(u);{var p=y=>{var w=Fp(),S=h(w),C=h(S),K=f(S,2);V(()=>M(C,c(o))),G("click",K,l),k(y,w)},v=y=>{var w=Tp();k(y,w)},x=y=>{var w=Lp(),S=me(w),C=h(S),K=f(C,2),E=h(K),U=f(K,2),te=h(U),T=h(te),A=f(te,3),X=f(A,2),L=f(S,2),se=h(L);dr(se,{label:"Messages",get value(){return c(i).message_count}});var oe=f(se,2);{let H=Ae(()=>c(r).totalTokensIn.toLocaleString());dr(oe,{label:"Tokens In",get value(){return c(H)}})}var de=f(oe,2);{let H=Ae(()=>c(r).totalTokensOut.toLocaleString());dr(de,{label:"Tokens Out",get value(){return c(H)}})}var $=f(L,2);{const H=ae=>{var xe=Mp(),ge=f(me(xe),2),he=h(ge);V(()=>M(he,`Updated ${c(a)??""}`)),k(ae,xe)};let ne=Ae(()=>d.items.length===0);dn($,{get columns(){return n},get isEmpty(){return c(ne)},emptyMessage:"No messages recorded for this session",get fetching(){return d.fetching},get page(){return d.page},get totalPages(){return d.totalPages},get totalItems(){return d.totalItems},get sort(){return d.sort},get search(){return d.search},searchPlaceholder:"Search messages...",get onPageChange(){return d.setPage},get onSortChange(){return d.setSort},get onSearchChange(){return d.setSearch},toolbar:H,children:(ae,xe)=>{var ge=yt(),he=me(ge);Mt(he,17,()=>d.items,Fe=>Fe.id,(Fe,Be)=>{var Xe=Xp(),q=h(Xe),re=h(q);{let Ie=Ae(()=>c(Be).direction==="in"?"info":"success");xn(re,{get status(){return c(Ie)}})}var fe=f(q),we=h(fe),le=f(fe),_e=h(le),Z=f(le),be=h(Z),z=f(Z),J=h(z),ue=f(z),Se=h(ue);V(Ie=>{M(we,c(Be).user_id),M(_e,c(Be).content??"-"),M(be,c(Be).tokens_in??"-"),M(J,c(Be).tokens_out??"-"),M(Se,Ie)},[()=>fs(c(Be).created_at)]),k(Fe,Xe)}),k(ae,ge)},$$slots:{toolbar:!0,default:!0}})}V((H,ne)=>{M(E,`Session ${H??""}`),M(T,c(i).channel_id),M(A,` ${c(i).agent_id??""} `),M(X,` ${ne??""}`)},[()=>Tt(c(i).uid),()=>fs(c(i).last_active)]),G("click",C,l),k(y,w)};O(_,y=>{c(o)?y(p):d?.loading?y(v,1):c(i)&&c(r)&&d&&y(x,2)})}k(t,u),nt()}_t(["click"]);var Bp=F("<div></div>"),Dp=F('<div><span class="step-number svelte-dm5b3b"></span></div> <!>',1),Rp=F('<div class="step-indicator svelte-dm5b3b"></div>'),Ip=F(`<span class="form-hint svelte-dm5b3b">Already configured. Leave blank to keep current key, or enter a new one to replace
|
|
7
|
-
it.</span>`),Qp=F('<span class="form-hint svelte-dm5b3b">API key from platform.claude.com/settings/keys</span>'),Np=F('<div class="login-error svelte-dm5b3b"> </div>'),Up=F('<p class="onboarding-desc svelte-dm5b3b">Configure your first agent. You can add more agents and change settings later.</p> <form><label class="form-label">Name <input type="text" class="form-input" placeholder="BrowserBird"/></label> <div class="form-row svelte-dm5b3b"><label class="form-label">Model <input type="text" class="form-input" placeholder="sonnet"/></label></div> <label class="form-label">System Prompt <textarea class="form-textarea" rows="3"></textarea></label> <label class="form-label">Anthropic Key <input type="password" class="form-input" autocomplete="off"/> <!></label> <!> <button type="submit" class="btn btn-primary onboarding-submit svelte-dm5b3b"> </button></form>',1),Hp=F('<a target="_blank" rel="noopener" class="onboarding-link svelte-dm5b3b">Create a Slack app from the manifest</a>. You can skip this and add Slack later from Settings.',1),zp=F('<div class="login-error svelte-dm5b3b"> </div>'),Op=F(`<p class="onboarding-desc svelte-dm5b3b"><!></p> <form><label class="form-label">Bot Token <input type="password" class="form-input" placeholder="xoxb-..." autocomplete="off"/> <span class="form-hint svelte-dm5b3b">OAuth & Permissions, click "Install to Workspace", then copy the token</span></label> <label class="form-label">App Token <input type="password" class="form-input" placeholder="xapp-..." autocomplete="off"/> <span class="form-hint svelte-dm5b3b">Basic Information, click "Generate Token and Scopes", add connections:write, then copy
|
|
8
|
-
the token</span></label> <!> <div class="onboarding-actions svelte-dm5b3b"><button type="button" class="btn btn-outline">Back</button> <div class="onboarding-actions-right svelte-dm5b3b"><button type="button" class="btn btn-outline">Skip</button> <button type="submit" class="btn btn-primary"> </button></div></div></form>`,1),Vp=F('<div class="probe-result probe-ok svelte-dm5b3b">Connected</div>'),Gp=F('<div class="probe-result probe-fail svelte-dm5b3b">Not reachable. Make sure the VM container is running.</div>'),qp=F('<label class="form-label">VM Host <div class="probe-row svelte-dm5b3b"><input type="text" class="form-input svelte-dm5b3b" placeholder="vm"/> <button type="button" class="btn btn-outline btn-sm"> </button></div> <span class="form-hint svelte-dm5b3b">Hostname of the VM container (e.g. vm, vm.internal, localhost)</span></label> <!>',1),Wp=F('<div class="login-error svelte-dm5b3b"> </div>'),jp=F('<p class="onboarding-desc svelte-dm5b3b">Optionally enable browser access for your agent. You can configure this later.</p> <form><div class="browser-toggle svelte-dm5b3b"><span class="browser-toggle-label svelte-dm5b3b">Enable browser</span> <!></div> <!> <!> <div class="onboarding-actions svelte-dm5b3b"><button type="button" class="btn btn-outline">Back</button> <div class="onboarding-actions-right svelte-dm5b3b"><button type="button" class="btn btn-outline"> </button> <button type="submit" class="btn btn-primary"> </button></div></div></form>',1),Yp=F('<div class="done-tip svelte-dm5b3b"><span class="done-tip-label svelte-dm5b3b">Mention your bot</span> <span class="done-tip-detail svelte-dm5b3b"> </span></div> <div class="done-tip svelte-dm5b3b"><span class="done-tip-label svelte-dm5b3b">Direct message</span> <span class="done-tip-detail svelte-dm5b3b">Open a DM with your bot in Slack</span></div> <div class="done-tip svelte-dm5b3b"><span class="done-tip-label svelte-dm5b3b">Slash commands</span> <span class="done-tip-detail svelte-dm5b3b">Type /bird in Slack to manage scheduled tasks</span></div> <div class="done-tip svelte-dm5b3b"><span class="done-tip-label svelte-dm5b3b">Scheduled tasks</span> <span class="done-tip-detail svelte-dm5b3b">Create birds from the dashboard, via /bird create, or ask your bot in Slack</span></div>',1),Zp=F('<div class="done-tip svelte-dm5b3b"><span class="done-tip-label svelte-dm5b3b">Create birds</span> <span class="done-tip-detail svelte-dm5b3b">Schedule tasks from the Birds page or the CLI</span></div> <div class="done-tip svelte-dm5b3b"><span class="done-tip-label svelte-dm5b3b">Add Slack later</span> <span class="done-tip-detail svelte-dm5b3b">Go to Settings to connect Slack whenever you are ready</span></div>',1),Jp=F('<div class="launch-summary svelte-dm5b3b"><div class="summary-row svelte-dm5b3b"><span class="summary-label svelte-dm5b3b">Slack</span> <span class="summary-value svelte-dm5b3b"> </span></div> <div class="summary-row svelte-dm5b3b"><span class="summary-label svelte-dm5b3b">Agent</span> <span class="summary-value svelte-dm5b3b"> </span></div> <div class="summary-row svelte-dm5b3b"><span class="summary-label svelte-dm5b3b">Browser</span> <span class="summary-value svelte-dm5b3b"> </span></div></div> <div class="done-tips svelte-dm5b3b"><!></div> <button type="button" class="btn btn-primary onboarding-submit svelte-dm5b3b">Go to Dashboard</button>',1),$p=F('<div class="login-error svelte-dm5b3b"> </div>'),eg=F('<!> <div class="onboarding-actions svelte-dm5b3b"><button type="button" class="btn btn-outline">Back</button> <button type="button" class="btn btn-primary"> </button></div>',1),tg=F('<div class="login-overlay svelte-dm5b3b"><div class="onboarding-card svelte-dm5b3b"><div class="onboarding-brand svelte-dm5b3b"><img src="/logo.svg" alt="BrowserBird" class="login-logo"/></div> <!> <h2 class="onboarding-heading svelte-dm5b3b"><!></h2> <!></div></div>');function sg(t,e){st(e,!0);const s=["Agent","Slack","Browser"],n="https://api.slack.com/apps?new_app=1&manifest_json=%7B%22display_information%22%3A%7B%22name%22%3A%22BrowserBird%22%2C%22description%22%3A%22A%20self-hosted%20AI%20assistant%20in%20Slack%2C%20with%20a%20real%20browser%20and%20a%20scheduler.%22%2C%22background_color%22%3A%22%231a1a2e%22%7D%2C%22features%22%3A%7B%22assistant_view%22%3A%7B%22assistant_description%22%3A%22A%20self-hosted%20AI%20assistant%20in%20Slack%2C%20with%20a%20real%20browser%20and%20a%20scheduler.%22%7D%2C%22app_home%22%3A%7B%22home_tab_enabled%22%3Atrue%2C%22messages_tab_enabled%22%3Atrue%2C%22messages_tab_read_only_enabled%22%3Afalse%7D%2C%22bot_user%22%3A%7B%22display_name%22%3A%22BrowserBird%22%2C%22always_online%22%3Atrue%7D%2C%22slash_commands%22%3A%5B%7B%22command%22%3A%22%2Fbird%22%2C%22description%22%3A%22Manage%20BrowserBird%20birds%22%2C%22usage_hint%22%3A%22list%20%7C%20fly%20%7C%20stop%20%7C%20logs%20%7C%20enable%20%7C%20disable%20%7C%20create%20%7C%20status%22%2C%22should_escape%22%3Afalse%7D%5D%7D%2C%22oauth_config%22%3A%7B%22scopes%22%3A%7B%22bot%22%3A%5B%22app_mentions%3Aread%22%2C%22assistant%3Awrite%22%2C%22channels%3Ahistory%22%2C%22channels%3Aread%22%2C%22chat%3Awrite%22%2C%22files%3Aread%22%2C%22files%3Awrite%22%2C%22groups%3Ahistory%22%2C%22groups%3Aread%22%2C%22im%3Ahistory%22%2C%22im%3Aread%22%2C%22im%3Awrite%22%2C%22mpim%3Ahistory%22%2C%22mpim%3Aread%22%2C%22reactions%3Aread%22%2C%22reactions%3Awrite%22%2C%22users%3Aread%22%2C%22commands%22%5D%7D%7D%2C%22settings%22%3A%7B%22event_subscriptions%22%3A%7B%22bot_events%22%3A%5B%22app_mention%22%2C%22assistant_thread_context_changed%22%2C%22assistant_thread_started%22%2C%22message.channels%22%2C%22message.groups%22%2C%22message.im%22%2C%22message.mpim%22%2C%22app_home_opened%22%5D%7D%2C%22interactivity%22%3A%7B%22is_enabled%22%3Atrue%7D%2C%22org_deploy_enabled%22%3Afalse%2C%22socket_mode_enabled%22%3Atrue%2C%22token_rotation_enabled%22%3Afalse%7D%7D";let a=W(0),i=W(!1),r=W(""),o=Ne({botToken:"",appToken:"",team:"",botUser:""}),d=Ne({name:"BrowserBird",model:"sonnet",systemPrompt:"You are a helpful AI assistant. Be concise and direct.",maxTurns:50,channels:["*"],apiKey:""}),l=Ne({enabled:!1,novncHost:"localhost",novncPort:6080}),u=W("idle"),_=W(null),p=W(""),v=W(!1);xt(()=>{dh().then(q=>{b(_,q,!0),d.name=q.agent.name,d.model=q.agent.model,d.systemPrompt=q.agent.systemPrompt,d.maxTurns=q.agent.maxTurns,d.channels=q.agent.channels,l.enabled=q.browser.enabled,l.novncHost=q.browser.novncHost,l.novncPort=q.browser.novncPort,q.secrets.anthropic.set&&b(p,q.secrets.anthropic.hint,!0),q.secrets.slack.botToken.set&&q.secrets.slack.appToken.set&&b(v,!0)}).catch(()=>{})});async function x(q){if(q.preventDefault(),!(!o.botToken.trim()||!o.appToken.trim())){b(i,!0),b(r,"");try{const re=await uh(o.botToken.trim(),o.appToken.trim());o.team=re.team,o.botUser=re.botUser,b(a,2)}catch(re){b(r,re.message,!0)}finally{b(i,!1)}}}async function y(q){if(q.preventDefault(),!(!d.name.trim()||!d.model.trim())){if(!d.apiKey.trim()&&!c(p)){b(r,"API key is required");return}b(i,!0),b(r,"");try{await hh({name:d.name.trim(),model:d.model.trim(),systemPrompt:d.systemPrompt.trim(),maxTurns:d.maxTurns,channels:d.channels}),d.apiKey.trim()&&await fh({apiKey:d.apiKey.trim()}),b(a,1)}catch(re){b(r,re.message,!0)}finally{b(i,!1)}}}function w(){b(a,2)}async function S(q){q.preventDefault(),b(i,!0),b(r,"");try{await _h({enabled:l.enabled,novncHost:l.enabled?l.novncHost.trim():void 0}),await E()}catch(re){b(r,re.message,!0)}finally{b(i,!1)}}async function C(){b(i,!0),b(r,"");try{await E()}catch(q){b(r,q.message,!0)}finally{b(i,!1)}}let K=W(!1);async function E(){await ph(),b(K,!0),b(a,3)}async function U(){b(i,!0),b(r,"");try{await E()}catch(q){b(r,q.message,!0)}finally{b(i,!1)}}async function te(){const q=l.novncHost.trim();if(q){b(u,"checking");try{const re=await vh(q,l.novncPort);b(u,re.reachable?"reachable":"unreachable",!0)}catch{b(u,"unreachable")}}}function T(){b(r,""),c(a)===3&&!c(K)?b(a,2):br(a,-1)}var A=tg(),X=h(A),L=f(h(X),2);{var se=q=>{var re=Rp();Mt(re,21,()=>s,Pc,(fe,we,le)=>{var _e=Dp(),Z=me(_e);let be;var z=h(Z);z.textContent=le+1;var J=f(Z,2);{var ue=Se=>{var Ie=Bp();let et;V(()=>et=pe(Ie,1,"step-line svelte-dm5b3b",null,et,{completed:le<c(a)})),k(Se,Ie)};O(J,Se=>{le<s.length-1&&Se(ue)})}V(()=>be=pe(Z,1,"step-dot svelte-dm5b3b",null,be,{active:le===c(a),completed:le<c(a)})),k(fe,_e)}),k(q,re)};O(L,q=>{c(a)<s.length&&q(se)})}var oe=f(L,2),de=h(oe);{var $=q=>{var re=Ss("Configure Agent");k(q,re)},H=q=>{var re=Ss("Connect Slack");k(q,re)},ne=q=>{var re=Ss("Browser");k(q,re)},ae=q=>{var re=Ss();V(()=>M(re,c(K)?"You're all set":"Launching...")),k(q,re)};O(de,q=>{c(a)===0?q($):c(a)===1?q(H,1):c(a)===2?q(ne,2):q(ae,!1)})}var xe=f(oe,2);{var ge=q=>{var re=Up(),fe=f(me(re),2),we=h(fe),le=f(h(we)),_e=f(we,2),Z=h(_e),be=f(h(Z)),z=f(_e,2),J=f(h(z)),ue=f(z,2),Se=f(h(ue)),Ie=f(Se,2);{var et=ye=>{var Oe=Ip();k(ye,Oe)},je=ye=>{var Oe=Qp();k(ye,Oe)};O(Ie,ye=>{c(p)?ye(et):ye(je,!1)})}var bt=f(ue,2);{var tt=ye=>{var Oe=Np(),lt=h(Oe);V(()=>M(lt,c(r))),k(ye,Oe)};O(bt,ye=>{c(r)&&ye(tt)})}var Ye=f(bt,2),mt=h(Ye);V(()=>{jt(Se,"placeholder",c(p)?`Configured (${c(p)})`:"sk-ant-..."),Ye.disabled=c(i),M(mt,c(i)?"Saving...":"Save & Continue")}),Rn("submit",fe,y),He(le,()=>d.name,ye=>d.name=ye),He(be,()=>d.model,ye=>d.model=ye),He(J,()=>d.systemPrompt,ye=>d.systemPrompt=ye),He(Se,()=>d.apiKey,ye=>d.apiKey=ye),k(q,re)},he=q=>{var re=Op(),fe=me(re),we=h(fe);{var le=ye=>{var Oe=Ss("Slack tokens are already configured. You can skip this step or re-enter them to update.");k(ye,Oe)},_e=ye=>{var Oe=Hp(),lt=me(Oe);jt(lt,"href",n),k(ye,Oe)};O(we,ye=>{c(v)?ye(le):ye(_e,!1)})}var Z=f(fe,2),be=h(Z),z=f(h(be)),J=f(be,2),ue=f(h(J)),Se=f(J,2);{var Ie=ye=>{var Oe=zp(),lt=h(Oe);V(()=>M(lt,c(r))),k(ye,Oe)};O(Se,ye=>{c(r)&&ye(Ie)})}var et=f(Se,2),je=h(et),bt=f(je,2),tt=h(bt),Ye=f(tt,2),mt=h(Ye);V(()=>{tt.disabled=c(i),Ye.disabled=c(i),M(mt,c(i)?"Validating...":"Validate & Save")}),Rn("submit",Z,x),He(z,()=>o.botToken,ye=>o.botToken=ye),He(ue,()=>o.appToken,ye=>o.appToken=ye),G("click",je,T),G("click",tt,w),k(q,re)},Fe=q=>{var re=jp(),fe=f(me(re),2),we=h(fe),le=f(h(we),2);Xn(le,{get active(){return l.enabled},onToggle:()=>{l.enabled=!l.enabled,b(u,"idle")}});var _e=f(we,2);{var Z=tt=>{var Ye=qp(),mt=me(Ye),ye=f(h(mt)),Oe=h(ye),lt=f(Oe,2),ls=h(lt),ss=f(mt,2);{var gs=Ct=>{var xs=Vp();k(Ct,xs)},Ts=Ct=>{var xs=Gp();k(Ct,xs)};O(ss,Ct=>{c(u)==="reachable"?Ct(gs):c(u)==="unreachable"&&Ct(Ts,1)})}V(Ct=>{lt.disabled=Ct,M(ls,c(u)==="checking"?"Checking...":"Test Connection")},[()=>c(u)==="checking"||!l.novncHost.trim()]),G("input",Oe,()=>{b(u,"idle")}),He(Oe,()=>l.novncHost,Ct=>l.novncHost=Ct),G("click",lt,te),k(tt,Ye)};O(_e,tt=>{l.enabled&&tt(Z)})}var be=f(_e,2);{var z=tt=>{var Ye=Wp(),mt=h(Ye);V(()=>M(mt,c(r))),k(tt,Ye)};O(be,tt=>{c(r)&&tt(z)})}var J=f(be,2),ue=h(J),Se=f(ue,2),Ie=h(Se),et=h(Ie),je=f(Ie,2),bt=h(je);V(()=>{Ie.disabled=c(i),M(et,c(i)?"Launching...":"Skip"),je.disabled=c(i),M(bt,c(i)?"Launching...":"Save & Launch")}),Rn("submit",fe,S),G("click",ue,T),G("click",Ie,C),k(q,re)},Be=q=>{var re=Jp(),fe=me(re),we=h(fe),le=f(h(we),2),_e=h(le),Z=f(we,2),be=f(h(Z),2),z=h(be),J=f(Z,2),ue=f(h(J),2),Se=h(ue),Ie=f(fe,2),et=h(Ie);{var je=Ye=>{var mt=Yp(),ye=me(mt),Oe=f(h(ye),2),lt=h(Oe);V(()=>M(lt,`@${d.name??""} in any channel`)),k(Ye,mt)},bt=Ye=>{var mt=Zp();k(Ye,mt)};O(et,Ye=>{o.team?Ye(je):Ye(bt,!1)})}var tt=f(Ie,2);V(()=>{M(_e,o.team||"Not configured"),M(z,`${d.name??""} (${d.model??""})`),M(Se,l.enabled?"Enabled":"Disabled")}),G("click",tt,function(...Ye){e.oncomplete?.apply(this,Ye)}),k(q,re)},Xe=q=>{var re=eg(),fe=me(re);{var we=z=>{var J=$p(),ue=h(J);V(()=>M(ue,c(r))),k(z,J)};O(fe,z=>{c(r)&&z(we)})}var le=f(fe,2),_e=h(le),Z=f(_e,2),be=h(Z);V(()=>{Z.disabled=c(i),M(be,c(i)?"Launching...":"Retry")}),G("click",_e,T),G("click",Z,U),k(q,re)};O(xe,q=>{c(a)===0?q(ge):c(a)===1?q(he,1):c(a)===2?q(Fe,2):c(K)?q(Be,3):q(Xe,!1)})}k(t,A),nt()}_t(["click","input"]);var ng=F('<div class="loading">Loading...</div>'),ag=F('<div class="login-error svelte-1n46o8q"> </div>'),ig=F('<div class="login-overlay svelte-1n46o8q"><div class="login-card svelte-1n46o8q"><div class="login-brand svelte-1n46o8q"><img src="/logo.svg" alt="BrowserBird" class="login-logo"/></div> <h2 class="login-heading svelte-1n46o8q">Create your account</h2> <form><label class="form-label">Email <input type="email" class="form-input" placeholder="you@example.com" autocomplete="email"/></label> <label class="form-label">Password <input type="password" class="form-input" placeholder="At least 8 characters" autocomplete="new-password"/></label> <label class="form-label">Confirm Password <input type="password" class="form-input" placeholder="Repeat password" autocomplete="new-password"/></label> <!> <button type="submit" class="btn btn-primary login-submit svelte-1n46o8q">Create Account</button></form></div></div>'),rg=F('<div class="login-error svelte-1n46o8q"> </div>'),og=F('<div class="login-overlay svelte-1n46o8q"><div class="login-card svelte-1n46o8q"><div class="login-brand svelte-1n46o8q"><img src="/logo.svg" alt="BrowserBird" class="login-logo"/></div> <form><label class="form-label">Email <input type="email" class="form-input" placeholder="you@example.com" autocomplete="email"/></label> <label class="form-label">Password <input type="password" class="form-input" placeholder="Enter password" autocomplete="current-password"/></label> <!> <button type="submit" class="btn btn-primary login-submit svelte-1n46o8q">Sign In</button></form></div></div>'),lg=F('<div class="app svelte-1n46o8q"><!> <main class="content svelte-1n46o8q"><div class="content-header svelte-1n46o8q"><button class="hamburger svelte-1n46o8q" aria-label="Open navigation"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="18" x2="21" y2="18"></line></svg></button> <h1 class="page-title svelte-1n46o8q"> </h1> <div class="header-right svelte-1n46o8q"><!></div></div> <div class="content-body svelte-1n46o8q"><!></div></main></div>'),cg=F("<!> <!> <!>",1);function dg(t,e){st(e,!0);const s={status:"Mission Control",sessions:"Sessions","session-detail":"Session Detail",birds:"Birds",computer:"Computer",settings:"Settings"};let n=W(Ne(xo())),a=W("checking"),i=W(null),r=W("connecting"),o=W(localStorage.getItem("sidebar-collapsed")==="true"),d=W(!1),l=W(""),u=W(""),_=W(""),p=W(""),v=W(""),x=W(""),y=W("");const w=Ae(()=>s[c(n)]??"Mission Control");xt(()=>{document.title=`${c(w)} - BrowserBird`});function S(){b(o,!c(o)),localStorage.setItem("sidebar-collapsed",String(c(o)))}rh(()=>{b(a,"login")}),xt(()=>{const $=()=>{b(n,xo(),!0),b(d,!1)};return window.addEventListener("hashchange",$),()=>window.removeEventListener("hashchange",$)}),xt(()=>{if(c(n)!=="flights")return;const $=Ti().get("birdUid");window.location.hash=$?`#/birds?expand=${$}`:"#/birds"}),xt(()=>{go().then(async $=>{$.setupRequired?b(a,"setup"):$.authRequired?Fi()?await ch()?$.onboardingRequired?b(a,"onboarding"):b(a,"authenticated"):b(a,"login"):b(a,($.onboardingRequired,"login"),!0):b(a,"authenticated")})}),xt(()=>{if(c(a)!=="authenticated")return;bo(H=>{b(i,H,!0),b(r,"connected")},H=>mo(H),H=>{b(r,H,!0)});const $=setInterval(()=>{gh()||ke("/api/status").then(()=>{b(r,"connected"),bo(H=>{b(i,H,!0),b(r,"connected")},H=>mo(H),H=>{b(r,H,!0)})}).catch(()=>{b(r,"disconnected")})},3e4);return()=>{Nc(),clearInterval($)}});function C(){zr(),b(a,"login")}async function K($){$.preventDefault();const H=c(l).trim(),ne=c(u);if(!(!H||!ne))try{const ae=await oh(H,ne);po(ae.token),b(_,""),b(l,""),b(u,""),b(a,"authenticated")}catch(ae){b(_,ae.message,!0)}}async function E($){$.preventDefault();const H=c(p).trim(),ne=c(v),ae=c(x);if(!(!H||!ne)){if(ne!==ae){b(y,"Passwords do not match");return}if(ne.length<8){b(y,"Password must be at least 8 characters");return}try{const xe=await lh(H,ne);po(xe.token),b(y,""),b(p,""),b(v,""),b(x,"");const ge=await go();b(a,ge.onboardingRequired?"onboarding":"authenticated",!0)}catch(xe){b(y,xe.message,!0)}}}var U=cg(),te=me(U);Mh(te,{});var T=f(te,2);Lh(T,{});var A=f(T,2);{var X=$=>{var H=ng();k($,H)},L=$=>{var H=ig(),ne=h(H),ae=f(h(ne),4),xe=h(ae),ge=f(h(xe)),he=f(xe,2),Fe=f(h(he)),Be=f(he,2),Xe=f(h(Be)),q=f(Be,2);{var re=fe=>{var we=ag(),le=h(we);V(()=>M(le,c(y))),k(fe,we)};O(q,fe=>{c(y)&&fe(re)})}Rn("submit",ae,E),He(ge,()=>c(p),fe=>b(p,fe)),He(Fe,()=>c(v),fe=>b(v,fe)),He(Xe,()=>c(x),fe=>b(x,fe)),k($,H)},se=$=>{var H=og(),ne=h(H),ae=f(h(ne),2),xe=h(ae),ge=f(h(xe)),he=f(xe,2),Fe=f(h(he)),Be=f(he,2);{var Xe=q=>{var re=rg(),fe=h(re);V(()=>M(fe,c(_))),k(q,re)};O(Be,q=>{c(_)&&q(Xe)})}Rn("submit",ae,K),He(ge,()=>c(l),q=>b(l,q)),He(Fe,()=>c(u),q=>b(u,q)),k($,H)},oe=$=>{sg($,{oncomplete:()=>{b(a,"authenticated")}})},de=$=>{var H=lg(),ne=h(H);kh(ne,{get currentPage(){return c(n)},get collapsed(){return c(o)},get mobileOpen(){return c(d)},ontoggle:S,onmobileclose:()=>{b(d,!1)},onsignout:C});var ae=f(ne,2),xe=h(ae),ge=h(xe),he=f(ge,2),Fe=h(he),Be=f(he,2),Xe=h(Be);Ah(Xe,{get status(){return c(i)}});var q=f(xe,2),re=h(q);{var fe=z=>{c0(z,{})},we=z=>{Pp(z,{})},le=z=>{W0(z,{})},_e=z=>{fv(z,{get status(){return c(i)}})},Z=z=>{Ep(z,{get status(){return c(i)}})},be=z=>{n0(z,{get status(){return c(i)}})};O(re,z=>{c(n)==="sessions"?z(fe):c(n)==="session-detail"?z(we,1):c(n)==="birds"?z(le,2):c(n)==="computer"?z(_e,3):c(n)==="settings"?z(Z,4):z(be,!1)})}V(()=>M(Fe,c(w))),G("click",ge,()=>{b(d,!0)}),k($,H)};O(A,$=>{c(a)==="checking"?$(X):c(a)==="setup"?$(L,1):c(a)==="login"?$(se,2):c(a)==="onboarding"?$(oe,3):$(de,!1)})}k(t,U),nt()}_t(["click"]);zu(dg,{target:document.getElementById("app")});
|