@owloops/browserbird 1.8.6 → 1.8.8
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.
|
@@ -0,0 +1,8 @@
|
|
|
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 pr=!1;var Rr=Array.isArray,Xd=Array.prototype.indexOf,ta=Array.prototype.includes,Fi=Array.from,Ld=Object.defineProperty,Jn=Object.getOwnPropertyDescriptor,Wo=Object.getOwnPropertyDescriptors,Pd=Object.prototype,Bd=Array.prototype,Ir=Object.getPrototypeOf,rl=Object.isExtensible;const ba=()=>{};function Dd(t){return t()}function gr(t){for(var e=0;e<t.length;e++)t[e]()}function qo(){var t,e,s=new Promise((n,a)=>{t=n,e=a});return{promise:s,resolve:t,reject:e}}const Qt=2,Ia=4,Qa=8,Yo=1<<24,cn=16,Rs=32,zn=64,br=128,ws=512,Pt=1024,Nt=2048,Ds=4096,vs=8192,sn=16384,In=32768,Qn=65536,ll=1<<17,Zo=1<<18,la=1<<19,Jo=1<<20,tn=1<<25,Nn=65536,xr=1<<21,Qr=1<<22,gn=1<<23,nn=Symbol("$state"),Rd=Symbol("legacy props"),Id=Symbol(""),Tn=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"},Qd=!!globalThis.document?.contentType&&globalThis.document.contentType.includes("xml");function Nd(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function Ud(t,e,s){throw new Error("https://svelte.dev/e/each_key_duplicate")}function Hd(t){throw new Error("https://svelte.dev/e/effect_in_teardown")}function zd(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function Od(t){throw new Error("https://svelte.dev/e/effect_orphan")}function Vd(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function Gd(t){throw new Error("https://svelte.dev/e/props_invalid_value")}function jd(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function Wd(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function qd(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function Yd(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}const Zd=1,Jd=2,$o=4,$d=8,eu=16,tu=1,su=2,nu=4,au=8,iu=16,ru=1,lu=2,Dt=Symbol(),ec="http://www.w3.org/1999/xhtml",ou="http://www.w3.org/2000/svg",cu="http://www.w3.org/1998/Math/MathML";function du(){console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function uu(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function tc(t){return t===this.v}function hu(t,e){return t!=t?e==e:t!==e||t!==null&&typeof t=="object"||typeof t=="function"}function sc(t){return!hu(t,this.v)}let Na=!1,fu=!1;function _u(){Na=!0}let Bt=null;function sa(t){Bt=t}function dt(t,e=!1,s){Bt={p:Bt,i:!1,c:null,e:null,s:t,x:null,l:Na&&!e?{s:null,u:null,$:[]}:null}}function ut(t){var e=Bt,s=e.e;if(s!==null){e.e=null;for(var n of s)wc(n)}return e.i=!0,Bt=e.p,{}}function Ua(){return!Na||Bt!==null&&Bt.l===null}let Mn=[];function nc(){var t=Mn;Mn=[],gr(t)}function an(t){if(Mn.length===0&&!Sa){var e=Mn;queueMicrotask(()=>{e===Mn&&nc()})}Mn.push(t)}function vu(){for(;Mn.length>0;)nc()}function ac(t){var e=Ze;if(e===null)return qe.f|=gn,t;if((e.f&In)===0&&(e.f&Ia)===0)throw t;_n(t,e)}function _n(t,e){for(;e!==null;){if((e.f&br)!==0){if((e.f&In)===0)throw t;try{e.b.error(t);return}catch(s){t=s}}e=e.parent}throw t}const pu=-7169;function Et(t,e){t.f=t.f&pu|e}function Nr(t){(t.f&ws)!==0||t.deps===null?Et(t,Pt):Et(t,Ds)}function ic(t){if(t!==null)for(const e of t)(e.f&Qt)===0||(e.f&Nn)===0||(e.f^=Nn,ic(e.deps))}function rc(t,e,s){(t.f&Nt)!==0?e.add(t):(t.f&Ds)!==0&&s.add(t),ic(t.deps),Et(t,Pt)}const Za=new Set;let et=null,pi=null,Ms=null,ss=[],Ti=null,mr=!1,Sa=!1;class bn{current=new Map;previous=new Map;#t=new Set;#l=new Set;#e=0;#i=0;#s=null;#r=new Set;#n=new Set;#a=new Map;is_fork=!1;#o=!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)Et(n,Nt),Ls(n);for(n of s.m)Et(n,Ds),Ls(n)}}process(e){ss=[],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)dc(a,i)}else{for(const a of this.#t)a();this.#t.clear(),this.#e===0&&this.#f(),pi=this,et=null,ol(n),ol(s),pi=null,this.#s?.resolve()}Ms=null}#c(e,s,n){e.f^=Pt;for(var a=e.first;a!==null;){var i=a.f,r=(i&(Rs|zn))!==0,o=r&&(i&Pt)!==0,d=o||(i&vs)!==0||this.#a.has(a);if(!d&&a.fn!==null){r?a.f^=Pt:(i&Ia)!==0?s.push(a):Oa(a)&&((i&cn)!==0&&this.#n.add(a),aa(a));var c=a.first;if(c!==null){a=c;continue}}for(;a!==null;){var h=a.next;if(h!==null){a=h;break}a=a.parent}}}#u(e){for(var s=0;s<e.length;s+=1)rc(e[s],this.#r,this.#n)}capture(e,s){s!==Dt&&!this.previous.has(e)&&this.previous.set(e,s),(e.f&gn)===0&&(this.current.set(e,e.v),Ms?.set(e,e.v))}activate(){et=this,this.apply()}deactivate(){et===this&&(et=null,Ms=null)}flush(){if(this.activate(),ss.length>0){if(lc(),et!==null&&et!==this)return}else this.#e===0&&this.process([]);this.deactivate()}discard(){for(const e of this.#l)e(this);this.#l.clear()}#f(){if(Za.size>1){this.previous.clear();var e=Ms,s=!0;for(const a of Za){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=ss;ss=[];const o=new Set,d=new Map;for(const c of i)oc(c,r,o,d);if(ss.length>0){et=a,a.apply();for(const c of ss)a.#c(c,[],[]);a.deactivate()}ss=n}}et=null,Ms=e}Za.delete(this)}increment(e){this.#e+=1,e&&(this.#i+=1)}decrement(e){this.#e-=1,e&&(this.#i-=1),!this.#o&&(this.#o=!0,an(()=>{this.#o=!1,this.#d()?ss.length>0&&this.flush():this.revive()}))}revive(){for(const e of this.#r)this.#n.delete(e),Et(e,Nt),Ls(e);for(const e of this.#n)Et(e,Ds),Ls(e);this.flush()}oncommit(e){this.#t.add(e)}ondiscard(e){this.#l.add(e)}settled(){return(this.#s??=qo()).promise}static ensure(){if(et===null){const e=et=new bn;Za.add(et),Sa||an(()=>{et===e&&e.flush()})}return et}apply(){}}function gu(t){var e=Sa;Sa=!0;try{for(var s;;){if(vu(),ss.length===0&&(et?.flush(),ss.length===0))return Ti=null,s;lc()}}finally{Sa=e}}function lc(){mr=!0;var t=null;try{for(var e=0;ss.length>0;){var s=bn.ensure();if(e++>1e3){var n,a;bu()}s.process(ss),xn.clear()}}finally{ss=[],mr=!1,Ti=null}}function bu(){try{Vd()}catch(t){_n(t,Ti)}}let Zs=null;function ol(t){var e=t.length;if(e!==0){for(var s=0;s<e;){var n=t[s++];if((n.f&(sn|vs))===0&&Oa(n)&&(Zs=new Set,aa(n),n.deps===null&&n.first===null&&n.nodes===null&&n.teardown===null&&n.ac===null&&Ec(n),Zs?.size>0)){xn.clear();for(const a of Zs){if((a.f&(sn|vs))!==0)continue;const i=[a];let r=a.parent;for(;r!==null;)Zs.has(r)&&(Zs.delete(r),i.push(r)),r=r.parent;for(let o=i.length-1;o>=0;o--){const d=i[o];(d.f&(sn|vs))===0&&aa(d)}}Zs.clear()}}Zs=null}}function oc(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&Qt)!==0?oc(a,e,s,n):(i&(Qr|cn))!==0&&(i&Nt)===0&&cc(a,e,n)&&(Et(a,Nt),Ls(a))}}function cc(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&Qt)!==0&&cc(a,e,s))return s.set(a,!0),!0}return s.set(t,!1),!1}function Ls(t){var e=Ti=t,s=e.b;if(s?.is_pending&&(t.f&(Ia|Qa|Yo))!==0&&(t.f&In)===0){s.defer_effect(t);return}for(;e.parent!==null;){e=e.parent;var n=e.f;if(mr&&e===Ze&&(n&cn)!==0&&(n&Zo)===0&&(n&In)!==0)return;if((n&(zn|Rs))!==0){if((n&Pt)===0)return;e.f^=Pt}}ss.push(e)}function dc(t,e){if(!((t.f&Rs)!==0&&(t.f&Pt)!==0)){(t.f&Nt)!==0?e.d.push(t):(t.f&Ds)!==0&&e.m.push(t),Et(t,Pt);for(var s=t.first;s!==null;)dc(s,e),s=s.next}}function xu(t){let e=0,s=Un(0),n;return()=>{zr()&&(l(s),Vr(()=>(e===0&&(n=Va(()=>t(()=>Ca(s)))),e+=1,()=>{an(()=>{e-=1,e===0&&(n?.(),n=void 0,Ca(s))})})))}}var mu=Qn|la;function yu(t,e,s,n){new wu(t,e,s,n)}class wu{parent;is_pending=!1;transform_error;#t;#l=null;#e;#i;#s;#r=null;#n=null;#a=null;#o=null;#d=0;#c=0;#u=!1;#f=new Set;#_=new Set;#h=null;#x=xu(()=>(this.#h=Un(this.#d),()=>{this.#h=null}));constructor(e,s,n,a){this.#t=e,this.#e=s,this.#i=i=>{var r=Ze;r.b=this,r.f|=br,n(i)},this.parent=Ze.b,this.transform_error=a??this.parent?.transform_error??(i=>i),this.#s=Xi(()=>{this.#g()},mu)}#m(){try{this.#r=ms(()=>this.#i(this.#t))}catch(e){this.error(e)}}#y(e){const s=this.#e.failed;s&&(this.#a=ms(()=>{s(this.#t,()=>e,()=>()=>{})}))}#w(){const e=this.#e.pending;e&&(this.is_pending=!0,this.#n=ms(()=>e(this.#t)),an(()=>{var s=this.#o=document.createDocumentFragment(),n=rn();s.append(n),this.#r=this.#p(()=>(bn.ensure(),ms(()=>this.#i(n)))),this.#c===0&&(this.#t.before(s),this.#o=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=ms(()=>{this.#i(this.#t)}),this.#c>0){var e=this.#o=document.createDocumentFragment();Fc(this.#r,e);const s=this.#e.pending;this.#n=ms(()=>s(this.#t))}else this.#v()}catch(s){this.error(s)}}#v(){this.is_pending=!1;for(const e of this.#f)Et(e,Nt),Ls(e);for(const e of this.#_)Et(e,Ds),Ls(e);this.#f.clear(),this.#_.clear()}defer_effect(e){rc(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=Ze,n=qe,a=Bt;Vs(this.#s),Ss(this.#s),sa(this.#s.ctx);try{return e()}catch(i){return ac(i),null}finally{Vs(s),Ss(n),sa(a)}}#b(e){if(!this.has_pending_snippet()){this.parent&&this.parent.#b(e);return}this.#c+=e,this.#c===0&&(this.#v(),this.#n&&Bn(this.#n,()=>{this.#n=null}),this.#o&&(this.#t.before(this.#o),this.#o=null))}update_pending_count(e){this.#b(e),this.#d+=e,!(!this.#h||this.#u)&&(this.#u=!0,an(()=>{this.#u=!1,this.#h&&na(this.#h,this.#d)}))}get_effect_pending(){return this.#x(),l(this.#h)}error(e){var s=this.#e.onerror;let n=this.#e.failed;if(!s&&!n)throw e;this.#r&&(is(this.#r),this.#r=null),this.#n&&(is(this.#n),this.#n=null),this.#a&&(is(this.#a),this.#a=null);var a=!1,i=!1;const r=()=>{if(a){uu();return}a=!0,i&&Yd(),this.#a!==null&&Bn(this.#a,()=>{this.#a=null}),this.#p(()=>{bn.ensure(),this.#g()})},o=d=>{try{i=!0,s?.(d,r),i=!1}catch(c){_n(c,this.#s&&this.#s.parent)}n&&(this.#a=this.#p(()=>{bn.ensure();try{return ms(()=>{var c=Ze;c.b=this,c.f|=br,n(this.#t,()=>d,()=>r)})}catch(c){return _n(c,this.#s.parent),null}}))};an(()=>{var d;try{d=this.transform_error(e)}catch(c){_n(c,this.#s&&this.#s.parent);return}d!==null&&typeof d=="object"&&typeof d.then=="function"?d.then(o,c=>_n(c,this.#s&&this.#s.parent)):o(d)})}}function ku(t,e,s,n){const a=Ua()?Ha:Ur;var i=t.filter(v=>!v.settled);if(s.length===0&&i.length===0){n(e.map(a));return}var r=Ze,o=Su(),d=i.length===1?i[0].promise:i.length>1?Promise.all(i.map(v=>v.promise)):null;function c(v){o();try{n(v)}catch(p){(r.f&sn)===0&&_n(p,r)}yr()}if(s.length===0){d.then(()=>c(e.map(a)));return}function h(){o(),Promise.all(s.map(v=>Eu(v))).then(v=>c([...e.map(a),...v])).catch(v=>_n(v,r))}d?d.then(h):h()}function Su(){var t=Ze,e=qe,s=Bt,n=et;return function(i=!0){Vs(t),Ss(e),sa(s),i&&n?.activate()}}function yr(t=!0){Vs(null),Ss(null),sa(null),t&&et?.deactivate()}function Cu(){var t=Ze.b,e=et,s=t.is_rendered();return t.update_pending_count(1),e.increment(s),()=>{t.update_pending_count(-1),e.decrement(s)}}function Ha(t){var e=Qt|Nt,s=qe!==null&&(qe.f&Qt)!==0?qe:null;return Ze!==null&&(Ze.f|=la),{ctx:Bt,deps:null,effects:null,equals:tc,f:e,fn:t,reactions:null,rv:0,v:Dt,wv:0,parent:s??Ze,ac:null}}function Eu(t,e,s){Ze===null&&Nd();var a=void 0,i=Un(Dt),r=!qe,o=new Map;return Qu(()=>{var d=qo();a=d.promise;try{Promise.resolve(t()).then(d.resolve,d.reject).finally(yr)}catch(p){d.reject(p),yr()}var c=et;if(r){var h=Cu();o.get(c)?.reject(Tn),o.delete(c),o.set(c,d)}const v=(p,_=void 0)=>{if(c.activate(),_)_!==Tn&&(i.f|=gn,na(i,_));else{(i.f&gn)!==0&&(i.f^=gn),na(i,p);for(const[b,w]of o){if(o.delete(b),b===c)break;w.reject(Tn)}}h&&h()};d.promise.then(v,p=>v(null,p||"unknown"))}),Or(()=>{for(const d of o.values())d.reject(Tn)}),new Promise(d=>{function c(h){function v(){h===a?d(i):c(a)}h.then(v,v)}c(a)})}function Ke(t){const e=Ha(t);return Tc(e),e}function Ur(t){const e=Ha(t);return e.equals=sc,e}function Au(t){var e=t.effects;if(e!==null){t.effects=null;for(var s=0;s<e.length;s+=1)is(e[s])}}function Ku(t){for(var e=t.parent;e!==null;){if((e.f&Qt)===0)return(e.f&sn)===0?e:null;e=e.parent}return null}function Hr(t){var e,s=Ze;Vs(Ku(t));try{t.f&=~Nn,Au(t),e=Pc(t)}finally{Vs(s)}return e}function uc(t){var e=Hr(t);if(!t.equals(e)&&(t.wv=Xc(),(!et?.is_fork||t.deps===null)&&(t.v=e,t.deps===null))){Et(t,Pt);return}kn||(Ms!==null?(zr()||et?.is_fork)&&Ms.set(t,e):Nr(t))}function Fu(t){if(t.effects!==null)for(const e of t.effects)(e.teardown||e.ac)&&(e.teardown?.(),e.ac?.abort(Tn),e.teardown=ba,e.ac=null,Xa(e,0),Gr(e))}function hc(t){if(t.effects!==null)for(const e of t.effects)e.teardown&&aa(e)}let wr=new Set;const xn=new Map;let fc=!1;function Un(t,e){var s={f:0,v:t,reactions:null,equals:tc,rv:0,wv:0};return s}function G(t,e){const s=Un(t);return Tc(s),s}function Tu(t,e=!1,s=!0){const n=Un(t);return e||(n.equals=sc),Na&&s&&Bt!==null&&Bt.l!==null&&(Bt.l.s??=[]).push(n),n}function g(t,e,s=!1){qe!==null&&(!Ps||(qe.f&ll)!==0)&&Ua()&&(qe.f&(Qt|cn|Qr|ll))!==0&&(ks===null||!ta.call(ks,t))&&qd();let n=s?Ye(e):e;return na(t,n)}function na(t,e){if(!t.equals(e)){var s=t.v;kn?xn.set(t,e):xn.set(t,s),t.v=e;var n=bn.ensure();if(n.capture(t,s),(t.f&Qt)!==0){const a=t;(t.f&Nt)!==0&&Hr(a),Nr(a)}t.wv=Xc(),_c(t,Nt),Ua()&&Ze!==null&&(Ze.f&Pt)!==0&&(Ze.f&(Rs|zn))===0&&(xs===null?Uu([t]):xs.push(t)),!n.is_fork&&wr.size>0&&!fc&&Mu()}return e}function Mu(){fc=!1;for(const t of wr)(t.f&Pt)!==0&&Et(t,Ds),Oa(t)&&aa(t);wr.clear()}function kr(t,e=1){var s=l(t),n=e===1?s++:s--;return g(t,s),n}function Ca(t){g(t,t.v+1)}function _c(t,e){var s=t.reactions;if(s!==null)for(var n=Ua(),a=s.length,i=0;i<a;i++){var r=s[i],o=r.f;if(!(!n&&r===Ze)){var d=(o&Nt)===0;if(d&&Et(r,e),(o&Qt)!==0){var c=r;Ms?.delete(c),(o&Nn)===0&&(o&ws&&(r.f|=Nn),_c(c,Ds))}else d&&((o&cn)!==0&&Zs!==null&&Zs.add(r),Ls(r))}}}function Ye(t){if(typeof t!="object"||t===null||nn in t)return t;const e=Ir(t);if(e!==Pd&&e!==Bd)return t;var s=new Map,n=Rr(t),a=G(0),i=Dn,r=o=>{if(Dn===i)return o();var d=qe,c=Dn;Ss(null),hl(i);var h=o();return Ss(d),hl(c),h};return n&&s.set("length",G(t.length)),new Proxy(t,{defineProperty(o,d,c){(!("value"in c)||c.configurable===!1||c.enumerable===!1||c.writable===!1)&&jd();var h=s.get(d);return h===void 0?r(()=>{var v=G(c.value);return s.set(d,v),v}):g(h,c.value,!0),!0},deleteProperty(o,d){var c=s.get(d);if(c===void 0){if(d in o){const h=r(()=>G(Dt));s.set(d,h),Ca(a)}}else g(c,Dt),Ca(a);return!0},get(o,d,c){if(d===nn)return t;var h=s.get(d),v=d in o;if(h===void 0&&(!v||Jn(o,d)?.writable)&&(h=r(()=>{var _=Ye(v?o[d]:Dt),b=G(_);return b}),s.set(d,h)),h!==void 0){var p=l(h);return p===Dt?void 0:p}return Reflect.get(o,d,c)},getOwnPropertyDescriptor(o,d){var c=Reflect.getOwnPropertyDescriptor(o,d);if(c&&"value"in c){var h=s.get(d);h&&(c.value=l(h))}else if(c===void 0){var v=s.get(d),p=v?.v;if(v!==void 0&&p!==Dt)return{enumerable:!0,configurable:!0,value:p,writable:!0}}return c},has(o,d){if(d===nn)return!0;var c=s.get(d),h=c!==void 0&&c.v!==Dt||Reflect.has(o,d);if(c!==void 0||Ze!==null&&(!h||Jn(o,d)?.writable)){c===void 0&&(c=r(()=>{var p=h?Ye(o[d]):Dt,_=G(p);return _}),s.set(d,c));var v=l(c);if(v===Dt)return!1}return h},set(o,d,c,h){var v=s.get(d),p=d in o;if(n&&d==="length")for(var _=c;_<v.v;_+=1){var b=s.get(_+"");b!==void 0?g(b,Dt):_ in o&&(b=r(()=>G(Dt)),s.set(_+"",b))}if(v===void 0)(!p||Jn(o,d)?.writable)&&(v=r(()=>G(void 0)),g(v,Ye(c)),s.set(d,v));else{p=v.v!==Dt;var w=r(()=>Ye(c));g(v,w)}var y=Reflect.getOwnPropertyDescriptor(o,d);if(y?.set&&y.set.call(h,c),!p){if(n&&typeof d=="string"){var S=s.get("length"),C=Number(d);Number.isInteger(C)&&C>=S.v&&g(S,C+1)}Ca(a)}return!0},ownKeys(o){l(a);var d=Reflect.ownKeys(o).filter(v=>{var p=s.get(v);return p===void 0||p.v!==Dt});for(var[c,h]of s)h.v!==Dt&&!(c in o)&&d.push(c);return d},setPrototypeOf(){Wd()}})}function cl(t){try{if(t!==null&&typeof t=="object"&&nn in t)return t[nn]}catch{}return t}function Xu(t,e){return Object.is(cl(t),cl(e))}var gi,vc,pc,gc;function Lu(){if(gi===void 0){gi=window,vc=/Firefox/.test(navigator.userAgent);var t=Element.prototype,e=Node.prototype,s=Text.prototype;pc=Jn(e,"firstChild").get,gc=Jn(e,"nextSibling").get,rl(t)&&(t.__click=void 0,t.__className=void 0,t.__attributes=null,t.__style=void 0,t.__e=void 0),rl(s)&&(s.__t=void 0)}}function rn(t=""){return document.createTextNode(t)}function ln(t){return pc.call(t)}function za(t){return gc.call(t)}function u(t,e){return ln(t)}function Ce(t,e=!1){{var s=ln(t);return s instanceof Comment&&s.data===""?za(s):s}}function f(t,e=1,s=!1){let n=t;for(;e--;)n=za(n);return n}function Pu(t){t.textContent=""}function bc(){return!1}function xc(t,e,s){return document.createElementNS(e??ec,t,void 0)}let dl=!1;function Bu(){dl||(dl=!0,document.addEventListener("reset",t=>{Promise.resolve().then(()=>{if(!t.defaultPrevented)for(const e of t.target.elements)e.__on_r?.()})},{capture:!0}))}function Mi(t){var e=qe,s=Ze;Ss(null),Vs(null);try{return t()}finally{Ss(e),Vs(s)}}function mc(t,e,s,n=s){t.addEventListener(e,()=>Mi(s));const a=t.__on_r;a?t.__on_r=()=>{a(),n(!0)}:t.__on_r=()=>n(!0),Bu()}function yc(t){Ze===null&&(qe===null&&Od(),zd()),kn&&Hd()}function Du(t,e){var s=e.last;s===null?e.last=e.first=t:(s.next=t,t.prev=s,e.last=t)}function js(t,e,s){var n=Ze;n!==null&&(n.f&vs)!==0&&(t|=vs);var a={ctx:Bt,deps:null,nodes:null,f:t|Nt|ws,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 is(a),o}else e!==null&&Ls(a);var i=a;if(s&&i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&(i.f&la)===0&&(i=i.first,(t&cn)!==0&&(t&Qn)!==0&&i!==null&&(i.f|=Qn)),i!==null&&(i.parent=n,n!==null&&Du(i,n),qe!==null&&(qe.f&Qt)!==0&&(t&zn)===0)){var r=qe;(r.effects??=[]).push(i)}return a}function zr(){return qe!==null&&!Ps}function Or(t){const e=js(Qa,null,!1);return Et(e,Pt),e.teardown=t,e}function xt(t){yc();var e=Ze.f,s=!qe&&(e&Rs)!==0&&(e&In)===0;if(s){var n=Bt;(n.e??=[]).push(t)}else return wc(t)}function wc(t){return js(Ia|Jo,t,!1)}function Ru(t){return yc(),js(Qa|Jo,t,!0)}function Iu(t){bn.ensure();const e=js(zn|la,t,!0);return(s={})=>new Promise(n=>{s.outro?Bn(e,()=>{is(e),n(void 0)}):(is(e),n(void 0))})}function kc(t){return js(Ia,t,!1)}function Qu(t){return js(Qr|la,t,!0)}function Vr(t,e=0){return js(Qa|e,t,!0)}function V(t,e=[],s=[],n=[]){ku(n,e,s,a=>{js(Qa,()=>t(...a.map(l)),!0)})}function Xi(t,e=0){var s=js(cn|e,t,!0);return s}function ms(t){return js(Rs|la,t,!0)}function Sc(t){var e=t.teardown;if(e!==null){const s=kn,n=qe;ul(!0),Ss(null);try{e.call(null)}finally{ul(s),Ss(n)}}}function Gr(t,e=!1){var s=t.first;for(t.first=t.last=null;s!==null;){const a=s.ac;a!==null&&Mi(()=>{a.abort(Tn)});var n=s.next;(s.f&zn)!==0?s.parent=null:is(s,e),s=n}}function Nu(t){for(var e=t.first;e!==null;){var s=e.next;(e.f&Rs)===0&&is(e),e=s}}function is(t,e=!0){var s=!1;(e||(t.f&Zo)!==0)&&t.nodes!==null&&t.nodes.end!==null&&(Cc(t.nodes.start,t.nodes.end),s=!0),Gr(t,e&&!s),Xa(t,0),Et(t,sn);var n=t.nodes&&t.nodes.t;if(n!==null)for(const i of n)i.stop();Sc(t);var a=t.parent;a!==null&&a.first!==null&&Ec(t),t.next=t.prev=t.teardown=t.ctx=t.deps=t.fn=t.nodes=t.ac=null}function Cc(t,e){for(;t!==null;){var s=t===e?null:za(t);t.remove(),t=s}}function Ec(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=[];Ac(t,n,!0);var a=()=>{s&&is(t),e&&e()},i=n.length;if(i>0){var r=()=>--i||a();for(var o of n)o.out(r)}else a()}function Ac(t,e,s){if((t.f&vs)===0){t.f^=vs;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&Rs)!==0&&(t.f&cn)!==0;Ac(a,e,r?s:!1),a=i}}}function jr(t){Kc(t,!0)}function Kc(t,e){if((t.f&vs)!==0){t.f^=vs,(t.f&Pt)===0&&(Et(t,Nt),Ls(t));for(var s=t.first;s!==null;){var n=s.next,a=(s.f&Qn)!==0||(s.f&Rs)!==0;Kc(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 Fc(t,e){if(t.nodes)for(var s=t.nodes.start,n=t.nodes.end;s!==null;){var a=s===n?null:za(s);e.append(s),s=a}}let ui=!1,kn=!1;function ul(t){kn=t}let qe=null,Ps=!1;function Ss(t){qe=t}let Ze=null;function Vs(t){Ze=t}let ks=null;function Tc(t){qe!==null&&(ks===null?ks=[t]:ks.push(t))}let ns=null,hs=0,xs=null;function Uu(t){xs=t}let Mc=1,Xn=0,Dn=Xn;function hl(t){Dn=t}function Xc(){return++Mc}function Oa(t){var e=t.f;if((e&Nt)!==0)return!0;if(e&Qt&&(t.f&=~Nn),(e&Ds)!==0){for(var s=t.deps,n=s.length,a=0;a<n;a++){var i=s[a];if(Oa(i)&&uc(i),i.wv>t.wv)return!0}(e&ws)!==0&&Ms===null&&Et(t,Pt)}return!1}function Lc(t,e,s=!0){var n=t.reactions;if(n!==null&&!(ks!==null&&ta.call(ks,t)))for(var a=0;a<n.length;a++){var i=n[a];(i.f&Qt)!==0?Lc(i,e,!1):e===i&&(s?Et(i,Nt):(i.f&Pt)!==0&&Et(i,Ds),Ls(i))}}function Pc(t){var e=ns,s=hs,n=xs,a=qe,i=ks,r=Bt,o=Ps,d=Dn,c=t.f;ns=null,hs=0,xs=null,qe=(c&(Rs|zn))===0?t:null,ks=null,sa(t.ctx),Ps=!1,Dn=++Xn,t.ac!==null&&(Mi(()=>{t.ac.abort(Tn)}),t.ac=null);try{t.f|=xr;var h=t.fn,v=h();t.f|=In;var p=t.deps,_=et?.is_fork;if(ns!==null){var b;if(_||Xa(t,hs),p!==null&&hs>0)for(p.length=hs+ns.length,b=0;b<ns.length;b++)p[hs+b]=ns[b];else t.deps=p=ns;if(zr()&&(t.f&ws)!==0)for(b=hs;b<p.length;b++)(p[b].reactions??=[]).push(t)}else!_&&p!==null&&hs<p.length&&(Xa(t,hs),p.length=hs);if(Ua()&&xs!==null&&!Ps&&p!==null&&(t.f&(Qt|Ds|Nt))===0)for(b=0;b<xs.length;b++)Lc(xs[b],t);if(a!==null&&a!==t){if(Xn++,a.deps!==null)for(let w=0;w<s;w+=1)a.deps[w].rv=Xn;if(e!==null)for(const w of e)w.rv=Xn;xs!==null&&(n===null?n=xs:n.push(...xs))}return(t.f&gn)!==0&&(t.f^=gn),v}catch(w){return ac(w)}finally{t.f^=xr,ns=e,hs=s,xs=n,qe=a,ks=i,sa(r),Ps=o,Dn=d}}function Hu(t,e){let s=e.reactions;if(s!==null){var n=Xd.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&Qt)!==0&&(ns===null||!ta.call(ns,e))){var i=e;(i.f&ws)!==0&&(i.f^=ws,i.f&=~Nn),Nr(i),Fu(i),Xa(i,0)}}function Xa(t,e){var s=t.deps;if(s!==null)for(var n=e;n<s.length;n++)Hu(t,s[n])}function aa(t){var e=t.f;if((e&sn)===0){Et(t,Pt);var s=Ze,n=ui;Ze=t,ui=!0;try{(e&(cn|Yo))!==0?Nu(t):Gr(t),Sc(t);var a=Pc(t);t.teardown=typeof a=="function"?a:null,t.wv=Mc;var i;pr&&fu&&(t.f&Nt)!==0&&t.deps}finally{ui=n,Ze=s}}}async function Bc(){await Promise.resolve(),gu()}function l(t){var e=t.f,s=(e&Qt)!==0;if(qe!==null&&!Ps){var n=Ze!==null&&(Ze.f&sn)!==0;if(!n&&(ks===null||!ta.call(ks,t))){var a=qe.deps;if((qe.f&xr)!==0)t.rv<Xn&&(t.rv=Xn,ns===null&&a!==null&&a[hs]===t?hs++:ns===null?ns=[t]:ns.push(t));else{(qe.deps??=[]).push(t);var i=t.reactions;i===null?t.reactions=[qe]:ta.call(i,qe)||i.push(qe)}}}if(kn&&xn.has(t))return xn.get(t);if(s){var r=t;if(kn){var o=r.v;return((r.f&Pt)===0&&r.reactions!==null||Rc(r))&&(o=Hr(r)),xn.set(r,o),o}var d=(r.f&ws)===0&&!Ps&&qe!==null&&(ui||(qe.f&ws)!==0),c=(r.f&In)===0;Oa(r)&&(d&&(r.f|=ws),uc(r)),d&&!c&&(hc(r),Dc(r))}if(Ms?.has(t))return Ms.get(t);if((t.f&gn)!==0)throw t.v;return t.v}function Dc(t){if(t.f|=ws,t.deps!==null)for(const e of t.deps)(e.reactions??=[]).push(t),(e.f&Qt)!==0&&(e.f&ws)===0&&(hc(e),Dc(e))}function Rc(t){if(t.v===Dt)return!0;if(t.deps===null)return!1;for(const e of t.deps)if(xn.has(e)||(e.f&Qt)!==0&&Rc(e))return!0;return!1}function Va(t){var e=Ps;try{return Ps=!0,t()}finally{Ps=e}}function zu(t){if(!(typeof t!="object"||!t||t instanceof EventTarget)){if(nn in t)Sr(t);else if(!Array.isArray(t))for(let e in t){const s=t[e];typeof s=="object"&&s&&nn in s&&Sr(s)}}}function Sr(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{Sr(t[n],e)}catch{}const s=Ir(t);if(s!==Object.prototype&&s!==Array.prototype&&s!==Map.prototype&&s!==Set.prototype&&s!==Date.prototype){const n=Wo(s);for(let a in n){const i=n[a].get;if(i)try{i.call(t)}catch{}}}}}const Ou=["touchstart","touchmove"];function Vu(t){return Ou.includes(t)}const xa=Symbol("events"),Ic=new Set,Cr=new Set;function Gu(t,e,s,n={}){function a(i){if(n.capture||Er.call(e,i),!i.cancelBubble)return Mi(()=>s?.call(this,i))}return t.startsWith("pointer")||t.startsWith("touch")||t==="wheel"?an(()=>{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=Gu(t,e,s,i);(e===document.body||e===window||e===document||e instanceof HTMLMediaElement)&&Or(()=>{e.removeEventListener(t,r,i)})}function U(t,e,s){(e[xa]??={})[t]=s}function bt(t){for(var e=0;e<t.length;e++)Ic.add(t[e]);for(var s of Cr)s(t)}let fl=null;function Er(t){var e=this,s=e.ownerDocument,n=t.type,a=t.composedPath?.()||[],i=a[0]||t.target;fl=t;var r=0,o=fl===t&&t[xa];if(o){var d=a.indexOf(o);if(d!==-1&&(e===document||e===window)){t[xa]=e;return}var c=a.indexOf(e);if(c===-1)return;d<=c&&(r=d)}if(i=a[r]||t.target,i!==e){Ld(t,"currentTarget",{configurable:!0,get(){return i||s}});var h=qe,v=Ze;Ss(null),Vs(null);try{for(var p,_=[];i!==null;){var b=i.assignedSlot||i.parentNode||i.host||null;try{var w=i[xa]?.[n];w!=null&&(!i.disabled||t.target===i)&&w.call(i,t)}catch(y){p?_.push(y):p=y}if(t.cancelBubble||b===e||b===null)break;i=b}if(p){for(let y of _)queueMicrotask(()=>{throw y});throw p}}finally{t[xa]=e,delete t.currentTarget,Ss(h),Vs(v)}}}const ju=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:t=>t});function Wu(t){return ju?.createHTML(t)??t}function Qc(t){var e=xc("template");return e.innerHTML=Wu(t.replaceAll("<!>","<!---->")),e.content}function ia(t,e){var s=Ze;s.nodes===null&&(s.nodes={start:t,end:e,a:null,t:null})}function K(t,e){var s=(e&ru)!==0,n=(e&lu)!==0,a,i=!t.startsWith("<!>");return()=>{a===void 0&&(a=Qc(i?t:"<!>"+t),s||(a=ln(a)));var r=n||vc?document.importNode(a,!0):a.cloneNode(!0);if(s){var o=ln(r),d=r.lastChild;ia(o,d)}else ia(r,r);return r}}function qu(t,e,s="svg"){var n=!t.startsWith("<!>"),a=`<${s}>${n?t:"<!>"+t}</${s}>`,i;return()=>{if(!i){var r=Qc(a),o=ln(r);i=ln(o)}var d=i.cloneNode(!0);return ia(d,d),d}}function Is(t,e){return qu(t,e,"svg")}function Xs(t=""){{var e=rn(t+"");return ia(e,e),e}}function kt(){var t=document.createDocumentFragment(),e=document.createComment(""),s=rn();return t.append(e,s),ia(e,s),t}function k(t,e){t!==null&&t.before(e)}function F(t,e){var s=e==null?"":typeof e=="object"?e+"":e;s!==(t.__t??=t.nodeValue)&&(t.__t=s,t.nodeValue=s+"")}function Yu(t,e){return Zu(t,e)}const Ja=new Map;function Zu(t,{target:e,anchor:s,props:n={},events:a,context:i,intro:r=!0,transformError:o}){Lu();var d=void 0,c=Iu(()=>{var h=s??e.appendChild(rn());yu(h,{pending:()=>{}},_=>{dt({});var b=Bt;i&&(b.c=i),a&&(n.$$events=a),d=t(_,n)||{},ut()},o);var v=new Set,p=_=>{for(var b=0;b<_.length;b++){var w=_[b];if(!v.has(w)){v.add(w);var y=Vu(w);for(const A of[e,document]){var S=Ja.get(A);S===void 0&&(S=new Map,Ja.set(A,S));var C=S.get(w);C===void 0?(A.addEventListener(w,Er,{passive:y}),S.set(w,1)):S.set(w,C+1)}}}};return p(Fi(Ic)),Cr.add(p),()=>{for(var _ of v)for(const y of[e,document]){var b=Ja.get(y),w=b.get(_);--w==0?(y.removeEventListener(_,Er),b.delete(_),b.size===0&&Ja.delete(y)):b.set(_,w)}Cr.delete(p),h!==s&&h.parentNode?.removeChild(h)}});return Ju.set(d,c),d}let Ju=new WeakMap;class Nc{anchor;#t=new Map;#l=new Map;#e=new Map;#i=new Set;#s=!0;constructor(e,s=!0){this.anchor=e,this.#s=s}#r=()=>{var e=et;if(this.#t.has(e)){var s=this.#t.get(e),n=this.#l.get(s);if(n)jr(n),this.#i.delete(s);else{var a=this.#e.get(s);a&&(this.#l.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&&(is(o.effect),this.#e.delete(r))}for(const[i,r]of this.#l){if(i===s||this.#i.has(i))continue;const o=()=>{if(Array.from(this.#t.values()).includes(i)){var c=document.createDocumentFragment();Fc(r,c),c.append(rn()),this.#e.set(i,{effect:r,fragment:c})}else is(r);this.#i.delete(i),this.#l.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)||(is(a.effect),this.#e.delete(n))};ensure(e,s){var n=et,a=bc();if(s&&!this.#l.has(e)&&!this.#e.has(e))if(a){var i=document.createDocumentFragment(),r=rn();i.append(r),this.#e.set(e,{effect:ms(()=>s(r)),fragment:i})}else this.#l.set(e,ms(()=>s(this.anchor)));if(this.#t.set(n,e),a){for(const[o,d]of this.#l)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 Nc(t),a=s?Qn:0;function i(r,o){n.ensure(r,o)}Xi(()=>{var r=!1;e((o,d=0)=>{r=!0,i(d,o)}),r||i(!1,null)},a)}function bi(t,e){return e}function $u(t,e,s){for(var n=[],a=e.length,i,r=e.length,o=0;o<a;o++){let v=e[o];Bn(v,()=>{if(i){if(i.pending.delete(v),i.done.add(v),i.pending.size===0){var p=t.outrogroups;Ar(Fi(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 c=s,h=c.parentNode;Pu(h),h.append(c),t.items.clear()}Ar(e,!d)}else i={pending:new Set(e),done:new Set},(t.outrogroups??=new Set).add(i)}function Ar(t,e=!0){for(var s=0;s<t.length;s++)is(t[s],e)}var _l;function Ct(t,e,s,n,a,i=null){var r=t,o=new Map,d=(e&$o)!==0;if(d){var c=t;r=c.appendChild(rn())}var h=null,v=Ur(()=>{var S=s();return Rr(S)?S:S==null?[]:Fi(S)}),p,_=!0;function b(){y.fallback=h,eh(y,p,r,e,n),h!==null&&(p.length===0?(h.f&tn)===0?jr(h):(h.f^=tn,ma(h,null,r)):Bn(h,()=>{h=null}))}var w=Xi(()=>{p=l(v);for(var S=p.length,C=new Set,A=et,E=bc(),H=0;H<S;H+=1){var ae=p[H],M=n(ae,H),X=_?null:o.get(M);X?(X.v&&na(X.v,ae),X.i&&na(X.i,H),E&&A.unskip_effect(X.e)):(X=th(o,_?r:_l??=rn(),ae,M,H,a,e,s),_||(X.e.f|=tn),o.set(M,X)),C.add(M)}if(S===0&&i&&!h&&(_?h=ms(()=>i(r)):(h=ms(()=>i(_l??=rn())),h.f|=tn)),S>C.size&&Ud(),!_)if(E){for(const[j,z]of o)C.has(j)||A.skip_effect(z.e);A.oncommit(b),A.ondiscard(()=>{})}else b();l(v)}),y={effect:w,items:o,outrogroups:null,fallback:h};_=!1}function da(t){for(;t!==null&&(t.f&Rs)===0;)t=t.next;return t}function eh(t,e,s,n,a){var i=(n&$d)!==0,r=e.length,o=t.items,d=da(t.effect.first),c,h=null,v,p=[],_=[],b,w,y,S;if(i)for(S=0;S<r;S+=1)b=e[S],w=a(b,S),y=o.get(w).e,(y.f&tn)===0&&(y.nodes?.a?.measure(),(v??=new Set).add(y));for(S=0;S<r;S+=1){if(b=e[S],w=a(b,S),y=o.get(w).e,t.outrogroups!==null)for(const z of t.outrogroups)z.pending.delete(y),z.done.delete(y);if((y.f&tn)!==0)if(y.f^=tn,y===d)ma(y,null,s);else{var C=h?h.next:d;y===t.effect.last&&(t.effect.last=y.prev),y.prev&&(y.prev.next=y.next),y.next&&(y.next.prev=y.prev),un(t,h,y),un(t,y,C),ma(y,C,s),h=y,p=[],_=[],d=da(h.next);continue}if((y.f&vs)!==0&&(jr(y),i&&(y.nodes?.a?.unfix(),(v??=new Set).delete(y))),y!==d){if(c!==void 0&&c.has(y)){if(p.length<_.length){var A=_[0],E;h=A.prev;var H=p[0],ae=p[p.length-1];for(E=0;E<p.length;E+=1)ma(p[E],A,s);for(E=0;E<_.length;E+=1)c.delete(_[E]);un(t,H.prev,ae.next),un(t,h,H),un(t,ae,A),d=A,h=ae,S-=1,p=[],_=[]}else c.delete(y),ma(y,d,s),un(t,y.prev,y.next),un(t,y,h===null?t.effect.first:h.next),un(t,h,y),h=y;continue}for(p=[],_=[];d!==null&&d!==y;)(c??=new Set).add(d),_.push(d),d=da(d.next);if(d===null)continue}(y.f&tn)===0&&p.push(y),h=y,d=da(y.next)}if(t.outrogroups!==null){for(const z of t.outrogroups)z.pending.size===0&&(Ar(Fi(z.done)),t.outrogroups?.delete(z));t.outrogroups.size===0&&(t.outrogroups=null)}if(d!==null||c!==void 0){var M=[];if(c!==void 0)for(y of c)(y.f&vs)===0&&M.push(y);for(;d!==null;)(d.f&vs)===0&&d!==t.fallback&&M.push(d),d=da(d.next);var X=M.length;if(X>0){var j=(n&$o)!==0&&r===0?s:null;if(i){for(S=0;S<X;S+=1)M[S].nodes?.a?.measure();for(S=0;S<X;S+=1)M[S].nodes?.a?.fix()}$u(t,M,j)}}i&&an(()=>{if(v!==void 0)for(y of v)y.nodes?.a?.apply()})}function th(t,e,s,n,a,i,r,o){var d=(r&Zd)!==0?(r&eu)===0?Tu(s,!1,!1):Un(s):null,c=(r&Jd)!==0?Un(a):null;return{v:d,i:c,e:ms(()=>(i(e,d??s,c??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&tn)===0?e.nodes.start:s;n!==null;){var r=za(n);if(i.before(n),n===a)return;n=r}}function un(t,e,s){e===null?t.effect.first=s:e.next=s,s===null?t.effect.last=e:s.prev=e}function sh(t,e,s=!1,n=!1,a=!1){var i=t,r="";V(()=>{var o=Ze;if(r!==(r=e()??"")&&(o.nodes!==null&&(Cc(o.nodes.start,o.nodes.end),o.nodes=null),r!=="")){var d=s?ou:n?cu:void 0,c=xc(s?"svg":n?"math":"template",d);c.innerHTML=r;var h=s||n?c:c.content;if(ia(ln(h),h.lastChild),s||n)for(;ln(h);)i.before(ln(h));else i.before(h)}})}function vl(t,e,...s){var n=new Nc(t);Xi(()=>{const a=e()??null;n.ensure(a,a&&(i=>a(i,...s)))},Qn)}function Uc(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=Uc(t[e]))&&(n&&(n+=" "),n+=s)}else for(s in t)t[s]&&(n&&(n+=" "),n+=s);return n}function nh(){for(var t,e,s=0,n="",a=arguments.length;s<a;s++)(t=arguments[s])&&(e=Uc(t))&&(n&&(n+=" "),n+=e);return n}function ah(t){return typeof t=="object"?nh(t):t??""}const pl=[...`
|
|
2
|
+
\r\f \v\uFEFF`];function ih(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||pl.includes(n[r-1]))&&(o===n.length||pl.includes(n[o]))?n=(r===0?"":n.substring(0,r))+n.substring(o+1):r=o}}return n===""?null:n}function me(t,e,s,n,a,i){var r=t.__className;if(r!==s||r===void 0){var o=ih(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 c=!!i[d];(a==null||c!==!!a[d])&&t.classList.toggle(d,c)}return i}function Hc(t,e,s=!1){if(t.multiple){if(e==null)return;if(!Rr(e))return du();for(var n of t.options)n.selected=e.includes(Ea(n));return}for(n of t.options){var a=Ea(n);if(Xu(a,e)){n.selected=!0;return}}(!s||e!==void 0)&&(t.selectedIndex=-1)}function rh(t){var e=new MutationObserver(()=>{Hc(t,t.__value)});e.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Or(()=>{e.disconnect()})}function gl(t,e,s=e){var n=new WeakSet,a=!0;mc(t,"change",i=>{var r=i?"[selected]":":checked",o;if(t.multiple)o=[].map.call(t.querySelectorAll(r),Ea);else{var d=t.querySelector(r)??t.querySelector("option:not([disabled])");o=d&&Ea(d)}s(o),et!==null&&n.add(et)}),kc(()=>{var i=e();if(t===document.activeElement){var r=pi??et;if(n.has(r))return}if(Hc(t,i,a),a&&i===void 0){var o=t.querySelector(":checked");o!==null&&(i=Ea(o),s(i))}t.__value=i,a=!1}),rh(t)}function Ea(t){return"__value"in t?t.__value:t.value}const lh=Symbol("is custom element"),oh=Symbol("is html"),ch=Qd?"progress":"PROGRESS";function zc(t,e){var s=Oc(t);s.value===(s.value=e??void 0)||t.value===e&&(e!==0||t.nodeName!==ch)||(t.value=e??"")}function It(t,e,s,n){var a=Oc(t);a[e]!==(a[e]=s)&&(e==="loading"&&(t[Id]=s),s==null?t.removeAttribute(e):typeof s!="string"&&dh(t).includes(e)?t[e]=s:t.setAttribute(e,s))}function Oc(t){return t.__attributes??={[lh]:t.nodeName.includes("-"),[oh]:t.namespaceURI===ec}}var bl=new Map;function dh(t){var e=t.getAttribute("is")||t.nodeName,s=bl.get(e);if(s)return s;bl.set(e,s=[]);for(var n,a=t,i=Element.prototype;i!==a;){n=Wo(a);for(var r in n)n[r].set&&s.push(r);a=Ir(a)}return s}function je(t,e,s=e){var n=new WeakSet;mc(t,"input",async a=>{var i=a?t.defaultValue:t.value;if(i=Vi(t)?Gi(i):i,s(i),et!==null&&n.add(et),await Bc(),i!==(i=e())){var r=t.selectionStart,o=t.selectionEnd,d=t.value.length;if(t.value=i??"",o!==null){var c=t.value.length;r===o&&o===d&&c>d?(t.selectionStart=c,t.selectionEnd=c):(t.selectionStart=r,t.selectionEnd=Math.min(o,c))}}}),Va(e)==null&&t.value&&(s(Vi(t)?Gi(t.value):t.value),et!==null&&n.add(et)),Vr(()=>{var a=e();if(t===document.activeElement){var i=pi??et;if(n.has(i))return}Vi(t)&&a===Gi(t.value)||t.type==="date"&&!a&&!t.value||a!==t.value&&(t.value=a??"")})}function Vi(t){var e=t.type;return e==="number"||e==="range"}function Gi(t){return t===""?null:+t}function xl(t,e){return t===e||t?.[nn]===e}function ml(t={},e,s,n){return kc(()=>{var a,i;return Vr(()=>{a=i,i=[],Va(()=>{t!==s(...i)&&(e(t,...i),a&&xl(s(...a),t)&&e(null,...a))})}),()=>{an(()=>{i&&xl(s(...i),t)&&e(null,...i)})}}),t}function Vc(t=!1){const e=Bt,s=e.l.u;if(!s)return;let n=()=>zu(e.s);if(t){let a=0,i={};const r=Ha(()=>{let o=!1;const d=e.s;for(const c in d)d[c]!==i[c]&&(i[c]=d[c],o=!0);return o&&a++,a});n=()=>l(r)}s.b.length&&Ru(()=>{yl(e,n),gr(s.b)}),xt(()=>{const a=Va(()=>s.m.map(Dd));return()=>{for(const i of a)typeof i=="function"&&i()}}),s.a.length&&xt(()=>{yl(e,n),gr(s.a)})}function yl(t,e){if(t.l.s)for(const s of t.l.s)l(s);e()}let $a=!1;function uh(t){var e=$a;try{return $a=!1,[t(),$a]}finally{$a=e}}function Wn(t,e,s,n){var a=!Na||(s&su)!==0,i=(s&au)!==0,r=(s&iu)!==0,o=n,d=!0,c=()=>(d&&(d=!1,o=r?Va(n):n),o),h;if(i){var v=nn in t||Rd in t;h=Jn(t,e)?.set??(v&&e in t?A=>t[e]=A:void 0)}var p,_=!1;i?[p,_]=uh(()=>t[e]):p=t[e],p===void 0&&n!==void 0&&(p=c(),h&&(a&&Gd(),h(p)));var b;if(a?b=()=>{var A=t[e];return A===void 0?c():(d=!0,A)}:b=()=>{var A=t[e];return A!==void 0&&(o=void 0),A===void 0?o:A},a&&(s&nu)===0)return b;if(h){var w=t.$$legacy;return(function(A,E){return arguments.length>0?((!a||!E||w||_)&&h(E?b():A),A):b()})}var y=!1,S=((s&tu)!==0?Ha:Ur)(()=>(y=!1,b()));i&&l(S);var C=Ze;return(function(A,E){if(arguments.length>0){const H=E?l(S):a&&i?Ye(A):A;return g(S,H),y=!0,o!==void 0&&(o=H),A}return kn&&y||(C.f&sn)!==0?S.v:l(S)})}const hh="5";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add(hh);const Wr="browserbird_auth_token",ra="";let Gc=null;function fh(t){Gc=t}function Li(){return localStorage.getItem(Wr)}function wl(t){localStorage.setItem(Wr,t)}function qr(){localStorage.removeItem(Wr)}async function Se(t,e){const s={},n=Li();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 qr(),Gc?.(),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 kl(){return(await fetch(`${ra}/api/auth/check`)).json()}async function _h(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 vh(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 ph(){try{return await Se("/api/auth/verify",{method:"POST"}),!0}catch{return qr(),!1}}function Sl(){const t=window.location.hash.slice(2),e=t.indexOf("?");return(e===-1?t:t.slice(0,e))||"status"}function Ga(){const t=window.location.hash.slice(2),e=t.indexOf("?");return new URLSearchParams(e===-1?"":t.slice(e+1))}async function gh(){return Se("/api/onboarding/defaults")}async function bh(t,e){return Se("/api/onboarding/slack",{method:"POST",body:{botToken:t,appToken:e}})}async function xh(t){return Se("/api/onboarding/agent",{method:"POST",body:t})}async function mh(t){return Se("/api/onboarding/auth",{method:"POST",body:t})}async function yh(t){return Se("/api/onboarding/browser",{method:"POST",body:t})}async function wh(t,e){return Se("/api/onboarding/browser/probe",{method:"POST",body:{host:t,port:e}})}async function kh(){return Se("/api/onboarding/complete",{method:"POST",body:{}})}let as=null,Kr=null,Fr=null,ya=null,Aa=null,Ka=null;function Cl(t,e,s){jc(),Kr=t,Fr=e??null,ya=s??null;const n=Li(),a=n?`${ra}/api/events?token=${encodeURIComponent(n)}`:`${ra}/api/events`;as=new EventSource(a),Aa=i=>{ya?.("connected");try{const r=JSON.parse(i.data);Kr?.(r)}catch{}},Ka=i=>{try{const r=JSON.parse(i.data);Fr?.(r)}catch{}},as.addEventListener("status",Aa),as.addEventListener("invalidate",Ka),as.onerror=()=>{ya?.("disconnected")},as.onopen=()=>{ya?.("connected")}}function jc(){as&&(Aa&&(as.removeEventListener("status",Aa),Aa=null),Ka&&(as.removeEventListener("invalidate",Ka),Ka=null),as.onerror=null,as.onopen=null,as.close(),as=null),Kr=null,Fr=null,ya=null}function Sh(){return as!==null&&as.readyState===EventSource.OPEN}const Tr=new Set;function Pi(t){return Tr.add(t),()=>Tr.delete(t)}function El(t){for(const e of Tr)e(t)}var Ch=K('<div class="drawer-backdrop svelte-181dlmc" role="presentation"></div>'),Eh=K('<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>'),Ah=Is('<path d="m9 18 6-6-6-6"></path>'),Kh=Is('<path d="m15 18-6-6 6-6"></path>'),Fh=K('<!> <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 Th(t,e){dt(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=Fh(),i=Ce(a);{var r=C=>{var A=Ch();U("click",A,function(...E){e.onmobileclose?.apply(this,E)}),k(C,A)};O(i,C=>{e.mobileOpen&&C(r)})}var o=f(i,2);let d;var c=f(u(o),2),h=u(c);Ct(h,17,()=>s,bi,(C,A)=>{var E=Eh();let H;var ae=u(E),M=u(ae);sh(M,()=>l(A).svg,!0);var X=f(ae,2),j=u(X);V(()=>{H=me(E,1,"nav-item svelte-181dlmc",null,H,{active:e.currentPage===l(A).page}),It(E,"href",`#/${(l(A).page==="status"?"":l(A).page)??""}`),It(E,"title",e.collapsed?l(A).label:void 0),F(j,l(A).label)}),U("click",E,n),k(C,E)});var v=f(h,2),p=f(c,2),_=u(p),b=u(_),w=u(b);{var y=C=>{var A=Ah();k(C,A)},S=C=>{var A=Kh();k(C,A)};O(w,C=>{e.collapsed?C(y):C(S,!1)})}V(()=>{d=me(o,1,"sidebar svelte-181dlmc",null,d,{collapsed:e.collapsed,"mobile-open":e.mobileOpen}),It(v,"title",e.collapsed?"Sign out":void 0),It(_,"title",e.collapsed?"Expand sidebar":"Collapse sidebar")}),U("click",v,function(...C){e.onsignout?.apply(this,C)}),U("click",_,function(...C){e.ontoggle?.apply(this,C)}),k(t,a),ut()}bt(["click"]);var Mh=K('<div><span></span> <span class="svc-row-label svelte-nma0bt"> </span> <span class="svc-row-detail mono svelte-nma0bt"> </span></div>'),Xh=K('<div class="svc-popover svelte-nma0bt"></div>'),Lh=K('<div class="svc-status svelte-nma0bt"><button class="svc-btn svelte-nma0bt" title="Service status"><span></span></button> <!></div>');function Ph(t,e){dt(e,!0);let s=G(!1);const n=Ke(()=>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=Ke(()=>l(n).filter(y=>y.applicable)),i=Ke(()=>l(a).length>0&&l(a).every(y=>y.ok)),r=Ke(()=>l(a).length===0||l(a).every(y=>!y.ok)),o=Ke(()=>l(i)?"ok":l(r)?"err":"warn");function d(){g(s,!l(s))}function c(y){y.target.closest(".svc-status")||g(s,!1)}xt(()=>{if(l(s))return document.addEventListener("click",c,!0),()=>document.removeEventListener("click",c,!0)});var h=Lh(),v=u(h),p=u(v);let _;var b=f(v,2);{var w=y=>{var S=Xh();Ct(S,21,()=>l(n),C=>C.label,(C,A)=>{var E=Mh();let H;var ae=u(E);let M;var X=f(ae,2),j=u(X),z=f(X,2),oe=u(z);V(()=>{H=me(E,1,"svc-row svelte-nma0bt",null,H,{"svc-row-disabled":!l(A).applicable}),M=me(ae,1,"svc-row-dot svelte-nma0bt",null,M,{"svc-ok":l(A).applicable&&l(A).ok,"svc-err":l(A).applicable&&!l(A).ok,"svc-off":!l(A).applicable}),F(j,l(A).label),F(oe,l(A).applicable?l(A).detail:"disabled")}),k(C,E)}),k(y,S)};O(b,y=>{l(s)&&y(w)})}V(()=>_=me(p,1,"svc-dot svelte-nma0bt",null,_,{"svc-ok":l(o)==="ok","svc-warn":l(o)==="warn","svc-err":l(o)==="err"})),U("click",v,d),k(t,h),ut()}bt(["click"]);_u();let Bh=0;const Mr=new Map;let xi=Ye([]);function Ae(t,e="info"){const s=Bh++;xi.push({id:s,message:t,type:e}),Mr.set(s,setTimeout(()=>Wc(s),4e3))}function Wc(t){const e=Mr.get(t);e!=null&&(clearTimeout(e),Mr.delete(t));const s=xi.findIndex(n=>n.id===t);s!==-1&&xi.splice(s,1)}var Dh=K('<div><span class="toast-message svelte-1ig2a9j"> </span> <button class="toast-close svelte-1ig2a9j" aria-label="Dismiss">×</button></div>'),Rh=K('<div class="toast-container svelte-1ig2a9j"></div>');function Ih(t,e){dt(e,!1),Vc();var s=Rh();Ct(s,5,()=>xi,n=>n.id,(n,a)=>{var i=Dh(),r=u(i),o=u(r),d=f(r,2);V(()=>{me(i,1,`toast toast-${l(a).type??""}`,"svelte-1ig2a9j"),F(o,l(a).message)}),U("click",d,()=>Wc(l(a).id)),k(n,i)}),k(t,s),ut()}bt(["click"]);const mn=Ye({pending:null});function Bi(t){return new Promise(e=>{mn.pending={message:t,resolve:e}})}function ua(t){if(mn.pending==null)return;const{resolve:e}=mn.pending;mn.pending=null,e(t)}var Qh=K('<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 Nh(t,e){dt(e,!1);function s(r){mn.pending&&(r.key==="Escape"&&ua(!1),r.key==="Enter"&&ua(!0))}Vc();var n=kt();Rn("keydown",gi,s);var a=Ce(n);{var i=r=>{var o=Qh(),d=u(o),c=f(d,2),h=u(c),v=u(h),p=f(h,2),_=u(p),b=f(_,2);V(()=>F(v,mn.pending.message)),U("click",d,()=>ua(!1)),U("click",_,()=>ua(!1)),U("click",b,()=>ua(!0)),k(r,o)};O(a,r=>{mn.pending&&r(i)})}k(t,n),ut()}bt(["click"]);function Lt(t){const e=t.indexOf("_");return e===-1?t.slice(0,10):t.slice(0,e+1+7)}function Uh(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 Gs(){return new Date().toLocaleTimeString()}function Hh(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 mi(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 zh=K('<input type="search" class="search-input svelte-b78yyc"/>'),Oh=K('<div class="table-toolbar svelte-b78yyc"><!> <!></div>'),Vh=Is('<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>'),Gh=Is('<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>'),jh=K('<button class="sort-btn svelte-b78yyc"> <!></button>'),Wh=K("<th><!></th>"),qh=K('<tr><td class="empty-state svelte-b78yyc"> </td></tr>'),Yh=K('<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>'),Zh=K('<!> <div><div class="table-scroll svelte-b78yyc"><table class="table svelte-b78yyc"><thead><tr></tr></thead><tbody><!></tbody></table></div> <!></div>',1);function $s(t,e){dt(e,!0);let s=Wn(e,"emptyMessage",3,"No data"),n=Wn(e,"searchPlaceholder",3,"Search...");const a=Ke(()=>e.page!=null&&e.totalPages!=null&&e.onPageChange!=null);function i(M){return e.sort?e.sort===`-${M}`?"desc":e.sort===M?"asc":null:null}let r;function o(M){const X=M.target.value;clearTimeout(r),r=setTimeout(()=>e.onSearchChange?.(X),300)}var d=Zh(),c=Ce(d);{var h=M=>{var X=Oh(),j=u(X);{var z=ce=>{var J=kt(),T=Ce(J);vl(T,()=>e.toolbar),k(ce,J)};O(j,ce=>{e.toolbar&&ce(z)})}var oe=f(j,2);{var re=ce=>{var J=zh();V(()=>{It(J,"placeholder",n()),zc(J,e.search??"")}),U("input",J,o),k(ce,J)};O(oe,ce=>{e.onSearchChange&&ce(re)})}k(M,X)};O(c,M=>{(e.toolbar||e.onSearchChange)&&M(h)})}var v=f(c,2);let p;var _=u(v),b=u(_),w=u(b),y=u(w);Ct(y,21,()=>e.columns,M=>M.key,(M,X)=>{var j=Wh(),z=u(j);{var oe=ce=>{const J=Ke(()=>i(l(X).key));var T=jh(),q=u(T),$=f(q);{var pe=we=>{var Xe=Vh();k(we,Xe)},ye=we=>{var Xe=Gh();k(we,Xe)};O($,we=>{l(J)==="asc"?we(pe):l(J)==="desc"&&we(ye,1)})}V(()=>F(q,`${l(X).label??""} `)),U("click",T,()=>e.onSortChange(l(X).key)),k(ce,T)},re=ce=>{var J=Xs();V(()=>F(J,l(X).label)),k(ce,J)};O(z,ce=>{l(X).sortable&&e.onSortChange?ce(oe):ce(re,!1)})}V(()=>me(j,1,ah(l(X).class??""),"svelte-b78yyc")),k(M,j)});var S=f(w),C=u(S);{var A=M=>{var X=qh(),j=u(X),z=u(j);V(()=>{It(j,"colspan",e.columns.length),F(z,s())}),k(M,X)},E=M=>{var X=kt(),j=Ce(X);vl(j,()=>e.children),k(M,X)};O(C,M=>{e.isEmpty?M(A):M(E,!1)})}var H=f(_,2);{var ae=M=>{var X=Yh(),j=u(X),z=f(j,2),oe=u(z),re=f(z,2);V(()=>{j.disabled=e.page===1,F(oe,`Page ${e.page??""} of ${e.totalPages??""}${e.totalItems!=null?` | ${e.totalItems} total`:""}`),re.disabled=e.page===e.totalPages}),U("click",j,()=>e.onPageChange(e.page-1)),U("click",re,()=>e.onPageChange(e.page+1)),k(M,X)};O(H,M=>{l(a)&&e.totalPages>1&&M(ae)})}V(()=>p=me(v,1,"table-card svelte-b78yyc",null,p,{"table-fetching":e.fetching})),k(t,d),ut()}bt(["input","click"]);var Jh=K("<span> </span>");function yn(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=Ke(()=>s[e.status]??"badge-muted");var a=Jh(),i=u(a);V(()=>{me(a,1,`badge ${l(n)??""}`,"svelte-1fmrh5r"),F(i,e.status)}),k(t,a)}var $h=K('<div class="loading">Loading...</div>'),ef=K('<div><span></span> <span class="svc-label svelte-ybr8ix">Browser</span> <span class="svc-detail mono svelte-ybr8ix"> </span></div>'),tf=K('<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>'),sf=K('<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>'),nf=K('<tr class="clickable-row svelte-ybr8ix"><td class="mono"> </td><td> </td><td><!></td><td class="mono"> </td><td> </td></tr>'),af=K('<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>'),rf=K('<tr class="clickable-row svelte-ybr8ix"><td class="mono"> </td><td> </td><td class="mono"> </td><td class="mono countdown svelte-ybr8ix"> </td></tr>'),lf=K('<div class="section svelte-ybr8ix"><div class="section-header svelte-ybr8ix"><h2 class="section-title svelte-ybr8ix">Next Up</h2></div> <!></div>'),of=K('<tr class="clickable-row svelte-ybr8ix"><td class="mono"> </td><td> </td><td><!></td><td class="mono"> </td><td> </td></tr>'),cf=K('<tr class="clickable-row svelte-ybr8ix"><td class="mono"> </td><td class="mono"> </td><td> </td><td> </td><td> </td></tr>'),df=K('<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 uf(t,e){dt(e,!0);let s=G(Ye([])),n=G(Ye([])),a=G(Ye([])),i=G(Ye([])),r=G(Ye([])),o=G(Ye(Gs())),d=G(!0);const c=[{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:""}],h=[{key:"uid",label:"ID"},{key:"name",label:"Bird"},{key:"schedule",label:"Schedule"},{key:"next_run",label:"Next Run"}],v=[{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 _(M){try{const[X,j,z,oe,re]=await Promise.all([Se("/api/birds?perPage=100"),Se("/api/birds/upcoming?limit=5"),Se("/api/flights?status=running&perPage=5"),Se("/api/flights?perPage=5"),Se("/api/sessions?perPage=5")]);if(M.aborted)return;g(s,X.items.filter(ce=>ce.failure_count>0),!0),l(s).sort((ce,J)=>J.failure_count-ce.failure_count),g(n,j,!0),g(a,z.items,!0),g(i,oe.items,!0),g(r,re.items,!0),g(o,Gs(),!0)}catch{}finally{M.aborted||g(d,!1)}}xt(()=>{const M=new AbortController;_(M.signal);const X=Pi(j=>{(j.resource==="sessions"||j.resource==="birds")&&_(M.signal)});return()=>{M.abort(),X()}});async function b(M){try{await Se(`/api/birds/${M}/fly`,{method:"POST"}),Ae(`Bird ${Lt(M)} sent on a flight`,"success")}catch(X){Ae(`Failed: ${X.message}`,"error")}}const w=Ke(()=>e.status?.slack.connected??!1),y=Ke(()=>e.status?.agent.available??!1),S=Ke(()=>e.status?.browser.enabled??!1),C=Ke(()=>e.status?.browser.connected??!1);var A=kt(),E=Ce(A);{var H=M=>{var X=$h();k(M,X)},ae=M=>{var X=df(),j=Ce(X),z=u(j);let oe;var re=u(z);let ce;var J=f(re,4),T=u(J),q=f(z,2);let $;var pe=u(q);let ye;var we=f(pe,4),Xe=u(we),Ne=f(q,2);{var ne=tt=>{var st=ef();let ht;var ft=u(st);let Pe;var Be=f(ft,4),Fe=u(Be);V(()=>{ht=me(st,1,"svc-card svelte-ybr8ix",null,ht,{"svc-ok":l(C),"svc-err":!l(C)}),Pe=me(ft,1,"svc-dot svelte-ybr8ix",null,Pe,{"dot-ok":l(C),"dot-err":!l(C)}),F(Fe,l(C)?"connected":"unreachable")}),k(tt,st)};O(Ne,tt=>{l(S)&&tt(ne)})}var R=f(j,2),se=u(R),ue=u(se),de=f(u(ue),2),ve=u(de),be=f(ue,2),Z=u(be),he=f(be,2),W=u(he),ee=u(W),ge=f(W,4),Ee=u(ge),fe=f(se,2),Re=f(u(fe),2),Te=u(Re),Je=f(Re,2),Ue=u(Je),Ve=u(Ue),it=f(fe,2),ke=f(u(it),2),He=u(ke),rt=f(ke,2),Jt=u(rt),Wt=u(Jt),rs=f(Jt,4),ls=u(rs),St=f(R,2);{var $t=tt=>{var st=sf(),ht=u(st),ft=f(u(ht),2),Pe=u(ft),Be=f(ht,2);$s(Be,{get columns(){return c},isEmpty:!1,children:(Fe,We)=>{var Ie=kt(),Y=Ce(Ie);Ct(Y,17,()=>l(s),le=>le.uid,(le,xe)=>{var De=tf(),ze=u(De),Ge=u(ze),lt=f(ze),ct=u(lt),Ft=u(ct),At=f(lt),Ut=u(At),Qs=f(At),Qe=u(Qs);{var ot=Ns=>{yn(Ns,{get status(){return l(xe).last_status}})},_t=Ns=>{var ca=Xs("-");k(Ns,ca)};O(Qe,Ns=>{l(xe).last_status?Ns(ot):Ns(_t,!1)})}var Ht=f(Qs),qt=u(Ht),Cn=f(Ht),Ws=u(Cn);V((Ns,ca,Ui)=>{F(Ge,Ns),It(ct,"href",`#/birds?search=${ca??""}`),F(Ft,l(xe).name),F(Ut,l(xe).failure_count),F(qt,Ui)},[()=>Lt(l(xe).uid),()=>encodeURIComponent(Lt(l(xe).uid)),()=>l(xe).last_run?fs(l(xe).last_run):"-"]),U("click",Ws,()=>b(l(xe).uid)),k(le,De)}),k(Fe,Ie)},$$slots:{default:!0}}),V(()=>F(Pe,`Updated ${l(o)??""}`)),k(tt,st)};O(St,tt=>{l(s).length>0&&tt($t)})}var es=f(St,2);{var os=tt=>{var st=af(),ht=f(u(st),2);$s(ht,{get columns(){return v},isEmpty:!1,children:(ft,Pe)=>{var Be=kt(),Fe=Ce(Be);Ct(Fe,17,()=>l(a),We=>We.uid,(We,Ie)=>{var Y=nf(),le=u(Y),xe=u(le),De=f(le),ze=u(De),Ge=f(De),lt=u(Ge);yn(lt,{get status(){return l(Ie).status}});var ct=f(Ge),Ft=u(ct),At=f(ct),Ut=u(At);V((Qs,Qe,ot)=>{F(xe,Qs),F(ze,l(Ie).bird_name),F(Ft,Qe),F(Ut,ot)},[()=>Lt(l(Ie).uid),()=>mi(l(Ie).started_at,l(Ie).finished_at),()=>fs(l(Ie).started_at)]),U("click",Y,()=>{window.location.hash=`#/birds?expand=${l(Ie).bird_uid}`}),k(We,Y)}),k(ft,Be)},$$slots:{default:!0}}),k(tt,st)};O(es,tt=>{l(a).length>0&&tt(os)})}var ps=f(es,2);{var gs=tt=>{var st=lf(),ht=f(u(st),2);$s(ht,{get columns(){return h},isEmpty:!1,children:(ft,Pe)=>{var Be=kt(),Fe=Ce(Be);Ct(Fe,17,()=>l(n),We=>We.uid,(We,Ie)=>{var Y=rf(),le=u(Y),xe=u(le),De=f(le),ze=u(De),Ge=f(De),lt=u(Ge),ct=f(Ge),Ft=u(ct);V((At,Ut)=>{F(xe,At),F(ze,l(Ie).name),F(lt,l(Ie).schedule),F(Ft,Ut)},[()=>Lt(l(Ie).uid),()=>Hh(l(Ie).next_run)]),U("click",Y,()=>{window.location.hash=`#/birds?search=${encodeURIComponent(Lt(l(Ie).uid))}`}),k(We,Y)}),k(ft,Be)},$$slots:{default:!0}}),k(tt,st)};O(ps,tt=>{l(n).length>0&&tt(gs)})}var cs=f(ps,2),Cs=f(u(cs),2);{let tt=Ke(()=>l(i).length===0);$s(Cs,{get columns(){return v},get isEmpty(){return l(tt)},emptyMessage:"No flights recorded",children:(st,ht)=>{var ft=kt(),Pe=Ce(ft);Ct(Pe,17,()=>l(i),Be=>Be.uid,(Be,Fe)=>{var We=of(),Ie=u(We),Y=u(Ie),le=f(Ie),xe=u(le),De=f(le),ze=u(De);yn(ze,{get status(){return l(Fe).status}});var Ge=f(De),lt=u(Ge),ct=f(Ge),Ft=u(ct);V((At,Ut,Qs)=>{F(Y,At),F(xe,l(Fe).bird_name),F(lt,Ut),F(Ft,Qs)},[()=>Lt(l(Fe).uid),()=>mi(l(Fe).started_at,l(Fe).finished_at),()=>fs(l(Fe).started_at)]),U("click",We,()=>{window.location.hash=`#/birds?expand=${l(Fe).bird_uid}`}),k(Be,We)}),k(st,ft)},$$slots:{default:!0}})}var Es=f(cs,2),As=f(u(Es),2);{let tt=Ke(()=>l(r).length===0);$s(As,{get columns(){return p},get isEmpty(){return l(tt)},emptyMessage:"No active sessions",children:(st,ht)=>{var ft=kt(),Pe=Ce(ft);Ct(Pe,17,()=>l(r),Be=>Be.uid,(Be,Fe)=>{var We=cf(),Ie=u(We),Y=u(Ie),le=f(Ie),xe=u(le),De=f(le),ze=u(De),Ge=f(De),lt=u(Ge),ct=f(Ge),Ft=u(ct);V((At,Ut)=>{F(Y,At),F(xe,l(Fe).channel_id),F(ze,l(Fe).agent_id),F(lt,l(Fe).message_count),F(Ft,Ut)},[()=>Lt(l(Fe).uid),()=>fs(l(Fe).last_active)]),U("click",We,()=>{window.location.hash=`#/session-detail?id=${l(Fe).uid}`}),k(Be,We)}),k(st,ft)},$$slots:{default:!0}})}V((tt,st,ht)=>{oe=me(z,1,"svc-card svelte-ybr8ix",null,oe,{"svc-ok":l(y),"svc-err":!l(y)}),ce=me(re,1,"svc-dot svelte-ybr8ix",null,ce,{"dot-ok":l(y),"dot-err":!l(y)}),F(T,l(y)?"ready":"unavailable"),$=me(q,1,"svc-card svelte-ybr8ix",null,$,{"svc-ok":l(w),"svc-err":!l(w)}),ye=me(pe,1,"svc-dot svelte-ybr8ix",null,ye,{"dot-ok":l(w),"dot-err":!l(w)}),F(Xe,l(w)?"connected":"disconnected"),F(ve,`${e.status.processes.active??""}/${e.status.processes.maxConcurrent??""} processes`),F(Z,e.status.flights.running),F(ee,`${e.status.flights.completed??""} done`),F(Ee,`${e.status.flights.failed??""} failed`),F(Te,e.status.messages.totalMessages),F(Ve,`${e.status.sessions.total??""} ${e.status.sessions.total===1?"session":"sessions"}`),F(He,tt),F(Wt,`${st??""} in`),F(ls,`${ht??""} out`)},[()=>(e.status.messages.totalTokensIn+e.status.messages.totalTokensOut).toLocaleString(),()=>e.status.messages.totalTokensIn.toLocaleString(),()=>e.status.messages.totalTokensOut.toLocaleString()]),k(M,X)};O(E,M=>{e.status?M(ae,!1):M(H)})}k(t,A),ut()}bt(["click"]);function hf(t){const e=Ga();return{page:Math.max(Number(e.get("page"))||1,1),sort:e.get("sort")??t,search:e.get("search")??""}}function ff(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(),c=d?`${r}?${d}`:r;c!==a&&history.replaceState(null,"",c)}function Di(t){const e=t.defaultSort??"",s=hf(e);let n=G(Ye([])),a=G(Ye(s.page)),i=G(1),r=G(0),o=G(Ye(t.defaultPerPage??15)),d=G(!0),c=G(!1),h=!1,v=G(Ye(s.sort)),p=G(Ye(s.search));xt(()=>{ff(l(a),l(v),l(p),e)}),xt(()=>{const y=l(a),S=l(v),C=l(p),A=l(o);t.watchExtras?.();const E=new AbortController,H=async()=>{const M=new URLSearchParams;M.set("page",String(y)),M.set("perPage",String(A)),S&&S!==e&&M.set("sort",S),C&&M.set("search",C);const X=t.buildParams?.();if(X)for(const[z,oe]of Object.entries(X))oe&&M.set(z,oe);const j=t.endpoint.includes("?")?"&":"?";try{const z=await Se(`${t.endpoint}${j}${M.toString()}`);if(E.signal.aborted)return;t.onResponse?.(z);const oe=t.transformResponse?t.transformResponse(z):z;g(n,oe.items,!0),g(i,oe.totalPages,!0),g(r,oe.totalItems,!0),g(o,oe.perPage,!0)}catch{}finally{E.signal.aborted||(g(d,!1),g(c,!1),h=!0)}};h||g(d,!0),g(c,!0),H();const ae=t.invalidateOn?Pi(M=>{M.resource===t.invalidateOn&&H()}):()=>{};return()=>{E.abort(),ae()}});function _(y){g(a,y,!0)}function b(y){l(v)===y?g(v,`-${y}`):l(v)===`-${y}`?g(v,y,!0):g(v,`-${y}`),g(a,1)}function w(y){g(p,y,!0),g(a,1)}return{get items(){return l(n)},get page(){return l(a)},get totalPages(){return l(i)},get totalItems(){return l(r)},get perPage(){return l(o)},get loading(){return l(d)},get fetching(){return l(c)},get sort(){return l(v)},get search(){return l(p)},setPage:_,setSort:b,setSearch:w}}var _f=K('<div class="loading">Loading...</div>'),vf=K('<div class="filter-spacer svelte-15gdqrj"></div> <span class="last-updated svelte-15gdqrj"> </span>',1),pf=K('<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 gf(t,e){dt(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=G(Ye(Gs()));const a=Di({endpoint:"/api/sessions",columns:s,defaultSort:"-last_active",invalidateOn:"sessions",onResponse:()=>{g(n,Gs(),!0)}});var i=kt(),r=Ce(i);{var o=c=>{var h=_f();k(c,h)},d=c=>{{const h=p=>{var _=vf(),b=f(Ce(_),2),w=u(b);V(()=>F(w,`Updated ${l(n)??""}`)),k(p,_)};let v=Ke(()=>a.items.length===0);$s(c,{get columns(){return s},get isEmpty(){return l(v)},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:h,children:(p,_)=>{var b=kt(),w=Ce(b);Ct(w,17,()=>a.items,y=>y.uid,(y,S)=>{var C=pf(),A=u(C),E=u(A),H=f(A),ae=u(H),M=f(H),X=u(M),j=f(M),z=u(j),oe=f(j),re=u(oe),ce=f(oe),J=u(ce);V((T,q)=>{F(E,T),F(ae,l(S).channel_id),F(X,l(S).thread_id??"-"),F(z,l(S).agent_id),F(re,l(S).message_count),F(J,q)},[()=>Lt(l(S).uid),()=>fs(l(S).last_active)]),U("click",C,()=>{window.location.hash=`#/session-detail?id=${l(S).uid}`}),k(y,C)}),k(p,b)},$$slots:{toolbar:!0,default:!0}})}};O(r,c=>{a.loading?c(o):c(d,!1)})}k(t,i),ut()}bt(["click"]);var bf=K('<div role="switch" tabindex="0"></div>');function Ln(t,e){dt(e,!0);var s=bf();let n;V(()=>{n=me(s,1,"toggle svelte-aw96os",null,n,{active:e.active}),It(s,"aria-checked",e.active)}),U("click",s,function(...a){e.onToggle?.apply(this,a)}),U("keydown",s,a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),e.onToggle())}),k(t,s),ut()}bt(["click","keydown"]);var xf=K("<textarea></textarea>"),mf=K('<input type="text"/>'),yf=Is('<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>'),wf=K('<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 wt(t,e){dt(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=wf();let d;var c=u(o);{var h=C=>{var A=xf();let E;V(()=>{E=me(A,1,"inline-input inline-textarea svelte-1npf1z3",null,E,{mono:n()}),It(A,"placeholder",e.placeholder)}),U("keydown",A,r),je(A,s),k(C,A)},v=C=>{var A=mf();let E;V(()=>{E=me(A,1,"inline-input svelte-1npf1z3",null,E,{mono:n()}),It(A,"placeholder",e.placeholder)}),U("keydown",A,r),je(A,s),k(C,A)};O(c,C=>{a()?C(h):C(v,!1)})}var p=f(c,2),_=u(p),b=u(_);{var w=C=>{var A=Xs("...");k(C,A)},y=C=>{var A=yf();k(C,A)};O(b,C=>{i()?C(w):C(y,!1)})}var S=f(_,2);V(()=>{d=me(o,1,"inline-edit svelte-1npf1z3",null,d,{"inline-edit-multiline":a()}),_.disabled=i()}),U("click",_,()=>e.onsave(s())),U("click",S,function(...C){e.oncancel?.apply(this,C)}),k(t,o),ut()}bt(["keydown","click"]);var kf=K('<div class="flight-summary svelte-1jo1oiw"> </div>'),Sf=K('<p class="detail-label error-label svelte-1jo1oiw">Error</p> <pre class="detail-pre error-pre svelte-1jo1oiw"> </pre>',1),Cf=K('<p class="detail-label svelte-1jo1oiw">Result</p> <pre class="detail-pre svelte-1jo1oiw"> </pre>',1),Ef=K('<button class="btn btn-outline btn-sm retry-btn svelte-1jo1oiw">Retry</button>'),Af=K('<div class="flight-detail svelte-1jo1oiw"><!> <!> <!></div>'),Kf=K('<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 Ff(t,e){dt(e,!0);function s(y){return y==="success"?"dot-ok":y==="error"?"dot-err":"dot-running"}function n(y){(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),e.ontoggle())}var a=Kf();let i;var r=u(a),o=u(r),d=f(o,2),c=u(d),h=f(d,2),v=u(h),p=f(r,2);{var _=y=>{var S=kf(),C=u(S);V(()=>F(C,e.flight.error??e.flight.result??"")),k(y,S)};O(p,y=>{(e.flight.error||e.flight.result)&&y(_)})}var b=f(p,2);{var w=y=>{var S=Af(),C=u(S);{var A=X=>{var j=Sf(),z=f(Ce(j),2),oe=u(z);V(()=>F(oe,e.flight.error)),k(X,j)};O(C,X=>{e.flight.error&&X(A)})}var E=f(C,2);{var H=X=>{var j=Cf(),z=f(Ce(j),2),oe=u(z);V(()=>F(oe,e.flight.result)),k(X,j)};O(E,X=>{e.flight.result&&X(H)})}var ae=f(E,2);{var M=X=>{var j=Ef();U("click",j,z=>{z.stopPropagation(),e.onretry()}),k(X,j)};O(ae,X=>{e.flight.status==="error"&&X(M)})}k(y,S)};O(b,y=>{e.expanded&&y(w)})}V((y,S,C)=>{i=me(a,1,"flight-card svelte-1jo1oiw",null,i,{"flight-expanded":e.expanded}),me(o,1,`svc-dot ${y??""}`,"svelte-1jo1oiw"),F(c,S),F(v,C)},[()=>s(e.flight.status),()=>mi(e.flight.started_at,e.flight.finished_at),()=>fs(e.flight.started_at)]),U("click",a,function(...y){e.ontoggle?.apply(this,y)}),U("keydown",a,n),k(t,a),ut()}bt(["click","keydown"]);var Tf=K("<button> </button>"),Mf=K("<button> </button>"),Xf=K("<button> </button>"),Lf=K("<button> </button>"),Pf=K('<button class="btn btn-danger btn-sm">Delete</button>'),Bf=K('<span class="flights-count mono svelte-1o8kr72"> </span>'),Df=K('<div class="flights-empty svelte-1o8kr72">Loading flights...</div>'),Rf=K('<div class="flights-empty svelte-1o8kr72"> </div>'),If=K('<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>'),Qf=K('<div class="flight-list svelte-1o8kr72"></div> <!>',1),Nf=K('<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 Uf(t,e){dt(e,!0);let s=G(Ye([])),n=G(!0),a=G(1),i=G(1),r=G(0),o=G(""),d=G(""),c=G(null),h=G(!1),v=G(null);const p=Ke(()=>l(v)??!!e.bird.enabled);xt(()=>{e.bird.enabled,g(v,null)});let _=G(null),b=G(""),w=G(!1),y,S=G("");const C=Ke(()=>e.bird.name.startsWith("__bb_"));Bc().then(()=>{g(h,!0)});function A(){g(h,!1),setTimeout(e.onclose,200)}function E(Y){if(Y.key==="Escape"){if(mn.pending)return;l(_)?z():A()}}function H(Y,le,xe,De){let ze=`/api/flights?birdUid=${Y}&perPage=10&sort=-started_at&page=${le}`;return xe&&(ze+=`&status=${xe}`),De&&(ze+=`&search=${encodeURIComponent(De)}`),ze}xt(()=>{const Y=e.bird.uid,le=l(a),xe=l(o),De=l(S),ze=new AbortController;return g(n,!0),Se(H(Y,le,xe,De)).then(Ge=>{ze.signal.aborted||(g(s,Ge.items,!0),g(i,Ge.totalPages,!0),g(r,Ge.totalItems,!0))}).catch(()=>{ze.signal.aborted||(g(s,[],!0),g(i,1),g(r,0))}).finally(()=>{ze.signal.aborted||g(n,!1)}),()=>ze.abort()}),xt(()=>{const Y=e.bird.uid;return Pi(xe=>{if(xe.resource==="birds"){const De=H(Y,l(a),l(o),l(S));Se(De).then(ze=>{g(s,ze.items,!0),g(i,ze.totalPages,!0),g(r,ze.totalItems,!0)}).catch(()=>{})}})});function ae(Y){g(o,Y,!0),g(a,1),g(c,null)}function M(Y){const le=Y.target.value;g(d,le,!0),clearTimeout(y),y=setTimeout(()=>{g(S,le,!0),g(a,1),g(c,null)},300)}async function X(){const Y=!l(p);g(v,Y);const le=Y?"enable":"disable";try{await Se(`/api/birds/${e.bird.uid}/${le}`,{method:"PATCH"}),Ae(`Bird ${Lt(e.bird.uid)} ${le}d`,"success")}catch(xe){g(v,null),Ae(`Failed: ${xe.message}`,"error")}}function j(Y){l(C)||(g(_,Y,!0),g(b,e.bird[Y]??"",!0))}function z(){g(_,null),g(b,"")}async function oe(){if(!l(_))return;const Y=l(b).trim(),le=(e.bird[l(_)]??"").trim();if(Y===le){z();return}const xe=l(_)==="target_channel_id";if(!Y&&!xe){Ae("Value cannot be empty","error");return}g(w,!0);const De={schedule:"schedule",prompt:"prompt",agent_id:"agent",target_channel_id:"channel"};try{await Se(`/api/birds/${e.bird.uid}`,{method:"PATCH",body:{[De[l(_)]]:Y||null}}),Ae(`Updated ${l(_).replace("_"," ")}`,"success"),z()}catch(ze){Ae(`Failed: ${ze.message}`,"error")}finally{g(w,!1)}}async function re(){try{const Y=await Se(`/api/birds/${e.bird.uid}/fly`,{method:"POST"});Ae(`Bird ${Lt(e.bird.uid)} sent on a flight (job #${Y.jobId})`,"success")}catch(Y){Ae(`Failed: ${Y.message}`,"error")}}async function ce(){if(await Bi(`Delete bird "${e.bird.name}"? This will also remove all flight history.`))try{await Se(`/api/birds/${e.bird.uid}`,{method:"DELETE"}),Ae(`Bird ${Lt(e.bird.uid)} deleted`,"success"),A()}catch(Y){Ae(`Failed: ${Y.message}`,"error")}}async function J(Y){try{await Se(`/api/birds/${Y.bird_uid}/fly`,{method:"POST"}),Ae(`Retrying ${Y.bird_name}`,"success")}catch(le){Ae(`Failed: ${le.message}`,"error")}}var T=Nf();Rn("keydown",gi,E);let q;var $=u(T),pe=f($,2),ye=u(pe),we=u(ye),Xe=u(we),Ne=u(Xe),ne=f(Xe,2),R=f(we,2),se=u(R);{var ue=Y=>{wt(Y,{mono:!0,get saving(){return l(w)},onsave:oe,oncancel:z,get value(){return l(b)},set value(le){g(b,le,!0)}})},de=Y=>{var le=Tf();let xe;var De=u(le);V(()=>{xe=me(le,1,"schedule-pill mono svelte-1o8kr72",null,xe,{editable:!l(C)}),F(De,e.bird.schedule)}),U("click",le,()=>j("schedule")),k(Y,le)};O(se,Y=>{l(_)==="schedule"?Y(ue):Y(de,!1)})}var ve=f(se,2),be=u(ve);Ln(be,{get active(){return l(p)},onToggle:X});var Z=f(ve,2);{var he=Y=>{yn(Y,{get status(){return e.bird.last_status}})};O(Z,Y=>{e.bird.last_status&&Y(he)})}var W=f(ye,2),ee=u(W),ge=u(ee),Ee=u(ge),fe=f(u(Ee),2);{var Re=Y=>{wt(Y,{get saving(){return l(w)},onsave:oe,oncancel:z,get value(){return l(b)},set value(le){g(b,le,!0)}})},Te=Y=>{var le=Mf();let xe;var De=u(le);V(()=>{xe=me(le,1,"config-value svelte-1o8kr72",null,xe,{editable:!l(C)}),F(De,e.bird.agent_id)}),U("click",le,()=>j("agent_id")),k(Y,le)};O(fe,Y=>{l(_)==="agent_id"?Y(Re):Y(Te,!1)})}var Je=f(Ee,2),Ue=f(u(Je),2);{var Ve=Y=>{wt(Y,{mono:!0,placeholder:"Channel ID",get saving(){return l(w)},onsave:oe,oncancel:z,get value(){return l(b)},set value(le){g(b,le,!0)}})},it=Y=>{var le=Xf();let xe;var De=u(le);V(()=>{xe=me(le,1,"config-value mono svelte-1o8kr72",null,xe,{editable:!l(C)}),F(De,e.bird.target_channel_id??"default")}),U("click",le,()=>j("target_channel_id")),k(Y,le)};O(Ue,Y=>{l(_)==="target_channel_id"?Y(Ve):Y(it,!1)})}var ke=f(ge,2),He=f(u(ke),2);{var rt=Y=>{wt(Y,{mono:!0,multiline:!0,get saving(){return l(w)},onsave:oe,oncancel:z,get value(){return l(b)},set value(le){g(b,le,!0)}})},Jt=Y=>{var le=Lf();let xe;var De=u(le);V(()=>{xe=me(le,1,"prompt-pre svelte-1o8kr72",null,xe,{editable:!l(C)}),F(De,e.bird.prompt)}),U("click",le,()=>j("prompt")),k(Y,le)};O(He,Y=>{l(_)==="prompt"?Y(rt):Y(Jt,!1)})}var Wt=f(ee,2),rs=u(Wt),ls=f(rs,2);{var St=Y=>{var le=Pf();U("click",le,ce),k(Y,le)};O(ls,Y=>{l(C)||Y(St)})}var $t=f(Wt,4),es=u($t),os=f(u(es),2);{var ps=Y=>{var le=Bf(),xe=u(le);V(()=>F(xe,l(r))),k(Y,le)};O(os,Y=>{l(r)>0&&Y(ps)})}var gs=f(es,2),cs=u(gs);let Cs;var Es=f(cs,2);let As;var tt=f(Es,2);let st;var ht=f(tt,2);let ft;var Pe=f(ht,2),Be=f(gs,2);{var Fe=Y=>{var le=Df();k(Y,le)},We=Y=>{var le=Rf(),xe=u(le);V(()=>F(xe,l(d)||l(o)?"No matching flights":"No flights yet")),k(Y,le)},Ie=Y=>{var le=Qf(),xe=Ce(le);Ct(xe,21,()=>l(s),Ge=>Ge.uid,(Ge,lt)=>{{let ct=Ke(()=>l(c)===l(lt).uid);Ff(Ge,{get flight(){return l(lt)},get expanded(){return l(ct)},ontoggle:()=>{g(c,l(c)===l(lt).uid?null:l(lt).uid,!0)},onretry:()=>J(l(lt))})}});var De=f(xe,2);{var ze=Ge=>{var lt=If(),ct=u(lt),Ft=f(ct,2),At=u(Ft),Ut=f(Ft,2);V(()=>{ct.disabled=l(a)===1,F(At,`${l(a)??""} / ${l(i)??""}`),Ut.disabled=l(a)===l(i)}),U("click",ct,()=>{kr(a,-1)}),U("click",Ut,()=>{kr(a)}),k(Ge,lt)};O(De,Ge=>{l(i)>1&&Ge(ze)})}k(Y,le)};O(Be,Y=>{l(n)?Y(Fe):l(s).length===0?Y(We,1):Y(Ie,!1)})}V(()=>{q=me(T,1,"overlay svelte-1o8kr72",null,q,{visible:l(h)}),F(Ne,e.bird.name),Cs=me(cs,1,"filter-chip svelte-1o8kr72",null,Cs,{"filter-all-active":l(o)===""}),As=me(Es,1,"filter-chip svelte-1o8kr72",null,As,{"filter-success-active":l(o)==="success"}),st=me(tt,1,"filter-chip svelte-1o8kr72",null,st,{"filter-error-active":l(o)==="error"}),ft=me(ht,1,"filter-chip svelte-1o8kr72",null,ft,{"filter-running-active":l(o)==="running"}),zc(Pe,l(d))}),U("click",$,A),U("click",ne,A),U("click",rs,re),U("click",cs,()=>ae("")),U("click",Es,()=>ae("success")),U("click",tt,()=>ae("error")),U("click",ht,()=>ae("running")),U("input",Pe,M),k(t,T),ut()}bt(["click","input"]);var Hf=K('<div class="loading">Loading...</div>'),zf=K('<span class="cell-btn-label">...</span>'),Of=Is('<svg viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M3 8.5l3.5 3.5L13 4.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>'),Vf=K('<div class="cell-edit-actions"><button class="cell-btn cell-btn-save" title="Save"><!></button> <button class="cell-btn cell-btn-cancel" title="Cancel"><svg viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg></button></div>'),Gf=K('<div class="create-form"><div class="form-title">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>'),jf=K('<button class="btn btn-primary btn-sm"> </button> <div class="filter-spacer"></div> <span class="last-updated"> </span>',1),Wf=K('<div class="cell-edit-overlay"><input class="cell-input mono" type="text"/> <!></div>'),qf=K('<div class="cell-edit-overlay"><textarea class="cell-input cell-textarea"></textarea> <!></div>'),Yf=K('<div class="cell-edit-overlay"><input class="cell-input" type="text"/> <!></div>'),Zf=K('<div class="cell-edit-overlay"><input class="cell-input mono" type="text" placeholder="Channel ID"/> <!></div>'),Jf=K('<span class="last-run-age svelte-3q62eu"> </span> <!>',1),$f=K('<button class="btn btn-danger btn-sm">Delete</button>'),e0=K('<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>'),t0=K("<!> <!> <!>",1);function s0(t,e){dt(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=G(Ye(Gs()));const a=Di({endpoint:"/api/birds",columns:s,defaultSort:"created_at",invalidateOn:"birds",onResponse:()=>{g(n,Gs(),!0)}});let i=G(!1),r=G(""),o=G(""),d=G(""),c=G(""),h=G(!1),v=G(null),p=G(!1),_=G(null);const b=Ke(()=>l(_)?a.items.find(T=>T.uid===l(_))??null:null);xt(()=>{if(a.loading)return;const T=Ga().get("expand");if(!T)return;const q=a.items.find($=>$.uid===T);if(q){g(_,q.uid,!0);const $=window.location.hash,pe=$.indexOf("?"),ye=pe===-1?$:$.slice(0,pe),we=new URLSearchParams(pe===-1?"":$.slice(pe+1));we.delete("expand");const Xe=we.toString();history.replaceState(null,"",Xe?`${ye}?${Xe}`:ye)}});function w(T,q){T.target.closest(".cell-editable, .actions-cell, .toggle-wrapper")||g(_,q.uid,!0)}async function y(T,q){const $=q?"disable":"enable";try{await Se(`/api/birds/${T}/${$}`,{method:"PATCH"}),Ae(`Bird ${Lt(T)} ${$}d`,"success")}catch(pe){Ae(`Failed: ${pe.message}`,"error")}}function S(){g(r,""),g(o,""),g(d,""),g(c,""),g(i,!0)}function C(){g(i,!1)}async function A(){if(!l(r).trim()||!l(o).trim()){Ae("Schedule and prompt are required","error");return}g(h,!0);try{const T={schedule:l(r).trim(),prompt:l(o).trim()};l(d).trim()&&(T.channel=l(d).trim()),l(c).trim()&&(T.agent=l(c).trim()),await Se("/api/birds",{method:"POST",body:T}),Ae("Bird created","success"),C()}catch(T){Ae(`Failed: ${T.message}`,"error")}finally{g(h,!1)}}function E(T,q){if(T.name.startsWith("__bb_"))return;const $=T[q]??"";g(v,{uid:T.uid,field:q,value:$,original:$},!0)}function H(){g(v,null)}async function ae(){if(l(v)==null)return;const T=l(v).value.trim();if(T===l(v).original.trim()){g(v,null);return}const q=l(v).field==="target_channel_id";if(!T&&!q){Ae("Value cannot be empty","error");return}g(p,!0);const $={schedule:"schedule",prompt:"prompt",agent_id:"agent",target_channel_id:"channel"};try{await Se(`/api/birds/${l(v).uid}`,{method:"PATCH",body:{[$[l(v).field]]:T||null}}),Ae(`Updated ${l(v).field.replace("_"," ")}`,"success"),g(v,null)}catch(pe){Ae(`Failed: ${pe.message}`,"error")}finally{g(p,!1)}}function M(T){T.key==="Escape"?H():T.key==="Enter"&&(l(v)?.field==="prompt"?T.metaKey:!T.shiftKey)&&(T.preventDefault(),ae())}function X(T,q){return l(v)!=null&&l(v).uid===T&&l(v).field===q}async function j(T){try{const q=await Se(`/api/birds/${T}/fly`,{method:"POST"});Ae(`Bird ${Lt(T)} sent on a flight (job #${q.jobId})`,"success")}catch(q){Ae(`Failed: ${q.message}`,"error")}}async function z(T,q){if(await Bi(`Delete bird "${q}"? This will also remove all flight history.`))try{await Se(`/api/birds/${T}`,{method:"DELETE"}),Ae(`Bird ${Lt(T)} deleted`,"success")}catch($){Ae(`Failed: ${$.message}`,"error")}}var oe=kt(),re=Ce(oe);{var ce=T=>{var q=Hf();k(T,q)},J=T=>{const q=ne=>{var R=Vf(),se=u(R),ue=u(se);{var de=Z=>{var he=zf();k(Z,he)},ve=Z=>{var he=Of();k(Z,he)};O(ue,Z=>{l(p)?Z(de):Z(ve,!1)})}var be=f(se,2);V(()=>se.disabled=l(p)),U("click",se,Z=>{Z.stopPropagation(),ae()}),U("click",be,Z=>{Z.stopPropagation(),H()}),k(ne,R)};var $=t0(),pe=Ce($);{var ye=ne=>{var R=Gf(),se=f(u(R),2),ue=u(se),de=f(u(ue)),ve=f(ue,2),be=f(u(ve)),Z=f(ve,2),he=f(u(Z)),W=f(se,2),ee=f(u(W)),ge=f(W,2),Ee=u(ge),fe=u(Ee),Re=f(Ee,2);V(()=>{Ee.disabled=l(h),F(fe,l(h)?"Saving...":"Create")}),je(de,()=>l(r),Te=>g(r,Te)),je(be,()=>l(d),Te=>g(d,Te)),je(he,()=>l(c),Te=>g(c,Te)),je(ee,()=>l(o),Te=>g(o,Te)),U("click",Ee,A),U("click",Re,C),k(ne,R)};O(pe,ne=>{l(i)&&ne(ye)})}var we=f(pe,2);{const ne=se=>{var ue=jf(),de=Ce(ue),ve=u(de),be=f(de,4),Z=u(be);V(()=>{F(ve,l(i)?"Cancel":"Add Bird"),F(Z,`Updated ${l(n)??""}`)}),U("click",de,()=>{l(i)?C():S()}),k(se,ue)};let R=Ke(()=>a.items.length===0);$s(we,{get columns(){return s},get isEmpty(){return l(R)},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:ne,children:(se,ue)=>{var de=kt(),ve=Ce(de);Ct(ve,17,()=>a.items,be=>be.uid,(be,Z)=>{const he=Ke(()=>l(Z).name.startsWith("__bb_"));var W=e0(),ee=u(W),ge=u(ee),Ee=f(ee),fe=u(Ee),Re=f(Ee);let Te;var Je=u(Re);let Ue;var Ve=u(Je),it=f(Je,2);{var ke=Qe=>{var ot=Wf(),_t=u(ot),Ht=f(_t,2);q(Ht),U("keydown",_t,M),je(_t,()=>l(v).value,qt=>l(v).value=qt),k(Qe,ot)},He=Ke(()=>X(l(Z).uid,"schedule"));O(it,Qe=>{l(He)&&Qe(ke)})}var rt=f(Re);let Jt;var Wt=u(rt);let rs;var ls=u(Wt),St=f(Wt,2);{var $t=Qe=>{var ot=qf(),_t=u(ot),Ht=f(_t,2);q(Ht),U("keydown",_t,M),je(_t,()=>l(v).value,qt=>l(v).value=qt),k(Qe,ot)},es=Ke(()=>X(l(Z).uid,"prompt"));O(St,Qe=>{l(es)&&Qe($t)})}var os=f(rt);let ps;var gs=u(os);let cs;var Cs=u(gs),Es=f(gs,2);{var As=Qe=>{var ot=Yf(),_t=u(ot),Ht=f(_t,2);q(Ht),U("keydown",_t,M),je(_t,()=>l(v).value,qt=>l(v).value=qt),k(Qe,ot)},tt=Ke(()=>X(l(Z).uid,"agent_id"));O(Es,Qe=>{l(tt)&&Qe(As)})}var st=f(os);let ht;var ft=u(st);let Pe;var Be=u(ft),Fe=f(ft,2);{var We=Qe=>{var ot=Zf(),_t=u(ot),Ht=f(_t,2);q(Ht),U("keydown",_t,M),je(_t,()=>l(v).value,qt=>l(v).value=qt),k(Qe,ot)},Ie=Ke(()=>X(l(Z).uid,"target_channel_id"));O(Fe,Qe=>{l(Ie)&&Qe(We)})}var Y=f(st),le=u(Y),xe=u(le);{let Qe=Ke(()=>!!l(Z).enabled);Ln(xe,{get active(){return l(Qe)},onToggle:()=>y(l(Z).uid,!!l(Z).enabled)})}var De=f(Y),ze=u(De);{var Ge=Qe=>{var ot=Jf(),_t=Ce(ot),Ht=u(_t),qt=f(_t,2);{var Cn=Ws=>{yn(Ws,{get status(){return l(Z).last_status}})};O(qt,Ws=>{l(Z).last_status&&Ws(Cn)})}V(Ws=>F(Ht,Ws),[()=>fs(l(Z).last_run)]),k(Qe,ot)},lt=Qe=>{var ot=Xs("-");k(Qe,ot)};O(ze,Qe=>{l(Z).last_run?Qe(Ge):Qe(lt,!1)})}var ct=f(De),Ft=u(ct),At=u(Ft),Ut=f(At,2);{var Qs=Qe=>{var ot=$f();U("click",ot,()=>z(l(Z).uid,l(Z).name)),k(Qe,ot)};O(Ut,Qe=>{l(he)||Qe(Qs)})}V((Qe,ot,_t,Ht,qt,Cn)=>{F(ge,Qe),F(fe,l(Z).name),Te=me(Re,1,"",null,Te,{"cell-editable":!l(he)}),Ue=me(Je,1,"mono cell-text",null,Ue,ot),F(Ve,l(Z).schedule),Jt=me(rt,1,"",null,Jt,{"cell-editable":!l(he)}),rs=me(Wt,1,"cell-text prompt-text svelte-3q62eu",null,rs,_t),It(Wt,"title",l(Z).prompt),F(ls,`${Ht??""}${l(Z).prompt.length>60?"...":""}`),ps=me(os,1,"",null,ps,{"cell-editable":!l(he)}),cs=me(gs,1,"cell-text",null,cs,qt),F(Cs,l(Z).agent_id),ht=me(st,1,"",null,ht,{"cell-editable":!l(he)}),Pe=me(ft,1,"mono cell-text",null,Pe,Cn),F(Be,l(Z).target_channel_id??"-")},[()=>Lt(l(Z).uid),()=>({"cell-text-hidden":X(l(Z).uid,"schedule")}),()=>({"cell-text-hidden":X(l(Z).uid,"prompt")}),()=>l(Z).prompt.slice(0,60),()=>({"cell-text-hidden":X(l(Z).uid,"agent_id")}),()=>({"cell-text-hidden":X(l(Z).uid,"target_channel_id")})]),U("click",W,Qe=>w(Qe,l(Z))),U("click",Re,()=>E(l(Z),"schedule")),U("click",rt,()=>E(l(Z),"prompt")),U("click",os,()=>E(l(Z),"agent_id")),U("click",st,()=>E(l(Z),"target_channel_id")),U("click",At,()=>j(l(Z).uid)),k(be,W)}),k(se,de)},$$slots:{toolbar:!0,default:!0}})}var Xe=f(we,2);{var Ne=ne=>{Uf(ne,{get bird(){return l(b)},onclose:()=>{g(_,null)}})};O(Xe,ne=>{l(b)&&ne(Ne)})}k(T,$)};O(re,T=>{a.loading?T(ce):T(J,!1)})}k(t,oe),ut()}bt(["click","keydown"]);function n0(t){return t>>>0}function Xr(t){return t|0}let Al="warn",Me=()=>{},jt=()=>{},Yt=()=>{},gt=()=>{};function a0(t){if(typeof t>"u"?t=Al:Al=t,Me=jt=Yt=gt=()=>{},typeof window.console<"u")switch(t){case"debug":Me=console.debug.bind(window.console);case"info":jt=console.info.bind(window.console);case"warn":Yt=console.warn.bind(window.console);case"error":gt=console.error.bind(window.console);case"none":break;default:throw new window.Error("invalid logging type '"+t+"'")}}a0();function ji(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 Yr={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 c=this.toBinaryTable[t.charCodeAt(d)&127],h=t.charAt(d)===this.base64Pad;if(c===-1){gt("Illegal character code "+t.charCodeAt(d)+" at position "+d);continue}r=r<<6|c,i+=6,i>=8&&(i-=8,h||(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 qc="ontouchstart"in document.documentElement||document.ontouchstart!==void 0||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;window.addEventListener("touchstart",function t(){qc=!0,window.removeEventListener("touchstart",t,!1)},!1);let ei=10*(window.devicePixelRatio||1),Yc=!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?(jt("Data URI scheme cursor supported"),Yc=!0):Yt("Data URI scheme cursor not supported")}catch(t){gt("Data URI scheme cursor test exception: "+t)}const i0=Yc;let r0=!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),r0=s!=0}catch(t){gt("Scrollbar test exception: "+t)}let Zc=!1;async function l0(){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(Yr.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)}Zc=await l0();function jn(){return!!/mac/i.exec(navigator.platform)}function hi(){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 Wi=!1,Jc=null;document.captureElement=null;function Kn(t){if(Wi)return;const e=new t.constructor(t.type,t);Wi=!0,document.captureElement?document.captureElement.dispatchEvent(e):Jc.dispatchEvent(e),Wi=!1,t.stopPropagation(),e.defaultPrevented&&t.preventDefault(),t.type==="mouseup"&&td()}function $c(){const t=document.getElementById("noVNC_mouse_capture_elem");t.style.cursor=window.getComputedStyle(document.captureElement).cursor}const ed=new MutationObserver($c);function o0(t){if(t.setCapture)t.setCapture(),document.captureElement=t;else{td();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",Kn),e.addEventListener("mousemove",Kn),e.addEventListener("mouseup",Kn)),document.captureElement=t,ed.observe(t,{attributes:!0}),$c(),e.style.display="",window.addEventListener("mousemove",Kn),window.addEventListener("mouseup",Kn)}}function td(){if(document.releaseCapture)document.releaseCapture(),document.captureElement=null;else{if(!document.captureElement)return;Jc=document.captureElement,document.captureElement=null,ed.disconnect();const t=document.getElementById("noVNC_mouse_capture_elem");t.style.display="none",window.removeEventListener("mousemove",Kn),window.removeEventListener("mouseup",Kn)}}class sd{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 c0{constructor(e){if(this._drawCtx=null,this._renderQ=[],this._flushPromise=null,this._fbWidth=0,this._fbHeight=0,this._prevDrawStyle="",Me(">> 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},Me("User Agent: "+navigator.userAgent),Me("<< 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)&&(Me("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")&&(Me("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:Xr(e/this._scale+this._viewportLoc.x)}absY(e){return this._scale===0?0:Xr(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,"+Yr.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),c=new ImageData(d,n,a);this._drawCtx.putImageData(c,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){gt("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)&&Yt("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,c=s.y,h=r,v=o;this.drawImage(n,a,i,r,o,d,c,h,v),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 on(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 yi=Uint8Array,ys=Uint16Array,wi=Int32Array;function Lr(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 Mt(){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}Mt();var ti=30,d0=12;function u0(t,e){var s,n,a,i,r,o,d,c,h,v,p,_,b,w,y,S,C,A,E,H,ae,M,X,j,z;s=t.state,n=t.next_in,j=t.input,a=n+(t.avail_in-5),i=t.next_out,z=t.output,r=i-(e-t.avail_out),o=i+(t.avail_out-257),d=s.dmax,c=s.wsize,h=s.whave,v=s.wnext,p=s.window,_=s.hold,b=s.bits,w=s.lencode,y=s.distcode,S=(1<<s.lenbits)-1,C=(1<<s.distbits)-1;e:do{b<15&&(_+=j[n++]<<b,b+=8,_+=j[n++]<<b,b+=8),A=w[_&S];t:for(;;){if(E=A>>>24,_>>>=E,b-=E,E=A>>>16&255,E===0)z[i++]=A&65535;else if(E&16){H=A&65535,E&=15,E&&(b<E&&(_+=j[n++]<<b,b+=8),H+=_&(1<<E)-1,_>>>=E,b-=E),b<15&&(_+=j[n++]<<b,b+=8,_+=j[n++]<<b,b+=8),A=y[_&C];s:for(;;){if(E=A>>>24,_>>>=E,b-=E,E=A>>>16&255,E&16){if(ae=A&65535,E&=15,b<E&&(_+=j[n++]<<b,b+=8,b<E&&(_+=j[n++]<<b,b+=8)),ae+=_&(1<<E)-1,ae>d){t.msg="invalid distance too far back",s.mode=ti;break e}if(_>>>=E,b-=E,E=i-r,ae>E){if(E=ae-E,E>h&&s.sane){t.msg="invalid distance too far back",s.mode=ti;break e}if(M=0,X=p,v===0){if(M+=c-E,E<H){H-=E;do z[i++]=p[M++];while(--E);M=i-ae,X=z}}else if(v<E){if(M+=c+v-E,E-=v,E<H){H-=E;do z[i++]=p[M++];while(--E);if(M=0,v<H){E=v,H-=E;do z[i++]=p[M++];while(--E);M=i-ae,X=z}}}else if(M+=v-E,E<H){H-=E;do z[i++]=p[M++];while(--E);M=i-ae,X=z}for(;H>2;)z[i++]=X[M++],z[i++]=X[M++],z[i++]=X[M++],H-=3;H&&(z[i++]=X[M++],H>1&&(z[i++]=X[M++]))}else{M=i-ae;do z[i++]=z[M++],z[i++]=z[M++],z[i++]=z[M++],H-=3;while(H>2);H&&(z[i++]=z[M++],H>1&&(z[i++]=z[M++]))}}else if((E&64)===0){A=y[(A&65535)+(_&(1<<E)-1)];continue s}else{t.msg="invalid distance code",s.mode=ti;break e}break}}else if((E&64)===0){A=w[(A&65535)+(_&(1<<E)-1)];continue t}else if(E&32){s.mode=d0;break e}else{t.msg="invalid literal/length code",s.mode=ti;break e}break}}while(n<a&&i<o);H=b>>3,n-=H,b-=H<<3,_&=(1<<b)-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=_,s.bits=b}var Vn=15,Kl=852,Fl=592,Tl=0,qi=1,Ml=2,h0=[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],f0=[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],_0=[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],v0=[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 Fa(t,e,s,n,a,i,r,o){var d=o.bits,c=0,h=0,v=0,p=0,_=0,b=0,w=0,y=0,S=0,C=0,A,E,H,ae,M,X=null,j=0,z,oe=new ys(Vn+1),re=new ys(Vn+1),ce=null,J=0,T,q,$;for(c=0;c<=Vn;c++)oe[c]=0;for(h=0;h<n;h++)oe[e[s+h]]++;for(_=d,p=Vn;p>=1&&oe[p]===0;p--);if(_>p&&(_=p),p===0)return a[i++]=1<<24|64<<16|0,a[i++]=1<<24|64<<16|0,o.bits=1,0;for(v=1;v<p&&oe[v]===0;v++);for(_<v&&(_=v),y=1,c=1;c<=Vn;c++)if(y<<=1,y-=oe[c],y<0)return-1;if(y>0&&(t===Tl||p!==1))return-1;for(re[1]=0,c=1;c<Vn;c++)re[c+1]=re[c]+oe[c];for(h=0;h<n;h++)e[s+h]!==0&&(r[re[e[s+h]]++]=h);if(t===Tl?(X=ce=r,z=19):t===qi?(X=h0,j-=257,ce=f0,J-=257,z=256):(X=_0,ce=v0,z=-1),C=0,h=0,c=v,M=i,b=_,w=0,H=-1,S=1<<_,ae=S-1,t===qi&&S>Kl||t===Ml&&S>Fl)return 1;for(;;){T=c-w,r[h]<z?(q=0,$=r[h]):r[h]>z?(q=ce[J+r[h]],$=X[j+r[h]]):(q=96,$=0),A=1<<c-w,E=1<<b,v=E;do E-=A,a[M+(C>>w)+E]=T<<24|q<<16|$|0;while(E!==0);for(A=1<<c-1;C&A;)A>>=1;if(A!==0?(C&=A-1,C+=A):C=0,h++,--oe[c]===0){if(c===p)break;c=e[s+r[h]]}if(c>_&&(C&ae)!==H){for(w===0&&(w=_),M+=v,b=c-w,y=1<<b;b+w<p&&(y-=oe[b+w],!(y<=0));)b++,y<<=1;if(S+=1<<b,t===qi&&S>Kl||t===Ml&&S>Fl)return 1;H=C&ae,a[H]=_<<24|b<<16|M-i|0}}return C!==0&&(a[M+C]=c-w<<24|64<<16|0),o.bits=_,0}var p0=0,nd=1,ad=2;const Xl=4,ki=0,g0=1,b0=2,Hn=-2,x0=-3,m0=-4,y0=-5,Ll=8;var id=1,Pl=2,Bl=3,Dl=4,Rl=5,Il=6,Ql=7,Nl=8,Ul=9,Hl=10,zl=11,Ys=12,Yi=13,Ol=14,Zi=15,Vl=16,Gl=17,jl=18,Wl=19,si=20,ni=21,ql=22,Yl=23,Zl=24,Jl=25,$l=26,Ji=27,eo=28,to=29,vt=30,w0=31,k0=32,S0=852,C0=592,E0=15,A0=E0;function so(t){return(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24)}function K0(){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 ys(320),this.work=new ys(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function F0(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=id,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new wi(S0),e.distcode=e.distdyn=new wi(C0),e.sane=1,e.back=-1,ki)}function rd(t){var e;return!t||!t.state?Hn:(e=t.state,e.wsize=0,e.whave=0,e.wnext=0,F0(t))}function T0(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,rd(t))}function M0(t,e){var s,n;return t?(n=new K0,t.state=n,n.window=null,s=T0(t,e),s!==ki&&(t.state=null),s):Hn}function X0(t){return M0(t,A0)}var no=!0,$i,er;function L0(t){if(no){var e;for($i=new wi(512),er=new wi(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(Fa(nd,t.lens,0,288,$i,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;Fa(ad,t.lens,0,32,er,0,t.work,{bits:5}),no=!1}t.lencode=$i,t.lenbits=9,t.distcode=er,t.distbits=5}function P0(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 yi(i.wsize)),n>=i.wsize?(on(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),on(i.window,e,s-n,a,i.wnext),n-=a,n?(on(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 B0(t,e){var s,n,a,i,r,o,d,c,h,v,p,_,b,w,y=0,S,C,A,E,H,ae,M,X,j=new yi(4),z,oe,re=[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===Ys&&(s.mode=Yi),r=t.next_out,a=t.output,d=t.avail_out,i=t.next_in,n=t.input,o=t.avail_in,c=s.hold,h=s.bits,v=o,p=d,X=ki;e:for(;;)switch(s.mode){case id:if(s.wrap===0){s.mode=Yi;break}for(;h<16;){if(o===0)break e;o--,c+=n[i++]<<h,h+=8}if(s.wrap&2&&c===35615){s.check=0,j[0]=c&255,j[1]=c>>>8&255,s.check=Mt(s.check),c=0,h=0,s.mode=Pl;break}if(s.flags=0,s.head&&(s.head.done=!1),!(s.wrap&1)||(((c&255)<<8)+(c>>8))%31){t.msg="incorrect header check",s.mode=vt;break}if((c&15)!==Ll){t.msg="unknown compression method",s.mode=vt;break}if(c>>>=4,h-=4,M=(c&15)+8,s.wbits===0)s.wbits=M;else if(M>s.wbits){t.msg="invalid window size",s.mode=vt;break}s.dmax=1<<M,t.adler=s.check=1,s.mode=c&512?Hl:Ys,c=0,h=0;break;case Pl:for(;h<16;){if(o===0)break e;o--,c+=n[i++]<<h,h+=8}if(s.flags=c,(s.flags&255)!==Ll){t.msg="unknown compression method",s.mode=vt;break}if(s.flags&57344){t.msg="unknown header flags set",s.mode=vt;break}s.head&&(s.head.text=c>>8&1),s.flags&512&&(j[0]=c&255,j[1]=c>>>8&255,s.check=Mt(s.check)),c=0,h=0,s.mode=Bl;case Bl:for(;h<32;){if(o===0)break e;o--,c+=n[i++]<<h,h+=8}s.head&&(s.head.time=c),s.flags&512&&(j[0]=c&255,j[1]=c>>>8&255,j[2]=c>>>16&255,j[3]=c>>>24&255,s.check=Mt(s.check)),c=0,h=0,s.mode=Dl;case Dl:for(;h<16;){if(o===0)break e;o--,c+=n[i++]<<h,h+=8}s.head&&(s.head.xflags=c&255,s.head.os=c>>8),s.flags&512&&(j[0]=c&255,j[1]=c>>>8&255,s.check=Mt(s.check)),c=0,h=0,s.mode=Rl;case Rl:if(s.flags&1024){for(;h<16;){if(o===0)break e;o--,c+=n[i++]<<h,h+=8}s.length=c,s.head&&(s.head.extra_len=c),s.flags&512&&(j[0]=c&255,j[1]=c>>>8&255,s.check=Mt(s.check)),c=0,h=0}else s.head&&(s.head.extra=null);s.mode=Il;case Il:if(s.flags&1024&&(_=s.length,_>o&&(_=o),_&&(s.head&&(M=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Array(s.head.extra_len)),on(s.head.extra,n,i,_,M)),s.flags&512&&(s.check=Mt(s.check)),o-=_,i+=_,s.length-=_),s.length))break e;s.length=0,s.mode=Ql;case Ql:if(s.flags&2048){if(o===0)break e;_=0;do M=n[i+_++],s.head&&M&&s.length<65536&&(s.head.name+=String.fromCharCode(M));while(M&&_<o);if(s.flags&512&&(s.check=Mt(s.check)),o-=_,i+=_,M)break e}else s.head&&(s.head.name=null);s.length=0,s.mode=Nl;case Nl:if(s.flags&4096){if(o===0)break e;_=0;do M=n[i+_++],s.head&&M&&s.length<65536&&(s.head.comment+=String.fromCharCode(M));while(M&&_<o);if(s.flags&512&&(s.check=Mt(s.check)),o-=_,i+=_,M)break e}else s.head&&(s.head.comment=null);s.mode=Ul;case Ul:if(s.flags&512){for(;h<16;){if(o===0)break e;o--,c+=n[i++]<<h,h+=8}if(c!==(s.check&65535)){t.msg="header crc mismatch",s.mode=vt;break}c=0,h=0}s.head&&(s.head.hcrc=s.flags>>9&1,s.head.done=!0),t.adler=s.check=0,s.mode=Ys;break;case Hl:for(;h<32;){if(o===0)break e;o--,c+=n[i++]<<h,h+=8}t.adler=s.check=so(c),c=0,h=0,s.mode=zl;case zl:if(s.havedict===0)return t.next_out=r,t.avail_out=d,t.next_in=i,t.avail_in=o,s.hold=c,s.bits=h,b0;t.adler=s.check=1,s.mode=Ys;case Ys:case Yi:if(s.last){c>>>=h&7,h-=h&7,s.mode=Ji;break}for(;h<3;){if(o===0)break e;o--,c+=n[i++]<<h,h+=8}switch(s.last=c&1,c>>>=1,h-=1,c&3){case 0:s.mode=Ol;break;case 1:L0(s),s.mode=si;break;case 2:s.mode=Gl;break;case 3:t.msg="invalid block type",s.mode=vt}c>>>=2,h-=2;break;case Ol:for(c>>>=h&7,h-=h&7;h<32;){if(o===0)break e;o--,c+=n[i++]<<h,h+=8}if((c&65535)!==(c>>>16^65535)){t.msg="invalid stored block lengths",s.mode=vt;break}s.length=c&65535,c=0,h=0,s.mode=Zi;case Zi:s.mode=Vl;case Vl:if(_=s.length,_){if(_>o&&(_=o),_>d&&(_=d),_===0)break e;on(a,n,i,_,r),o-=_,i+=_,d-=_,r+=_,s.length-=_;break}s.mode=Ys;break;case Gl:for(;h<14;){if(o===0)break e;o--,c+=n[i++]<<h,h+=8}if(s.nlen=(c&31)+257,c>>>=5,h-=5,s.ndist=(c&31)+1,c>>>=5,h-=5,s.ncode=(c&15)+4,c>>>=4,h-=4,s.nlen>286||s.ndist>30){t.msg="too many length or distance symbols",s.mode=vt;break}s.have=0,s.mode=jl;case jl:for(;s.have<s.ncode;){for(;h<3;){if(o===0)break e;o--,c+=n[i++]<<h,h+=8}s.lens[re[s.have++]]=c&7,c>>>=3,h-=3}for(;s.have<19;)s.lens[re[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,z={bits:s.lenbits},X=Fa(p0,s.lens,0,19,s.lencode,0,s.work,z),s.lenbits=z.bits,X){t.msg="invalid code lengths set",s.mode=vt;break}s.have=0,s.mode=Wl;case Wl:for(;s.have<s.nlen+s.ndist;){for(;y=s.lencode[c&(1<<s.lenbits)-1],S=y>>>24,C=y>>>16&255,A=y&65535,!(S<=h);){if(o===0)break e;o--,c+=n[i++]<<h,h+=8}if(A<16)c>>>=S,h-=S,s.lens[s.have++]=A;else{if(A===16){for(oe=S+2;h<oe;){if(o===0)break e;o--,c+=n[i++]<<h,h+=8}if(c>>>=S,h-=S,s.have===0){t.msg="invalid bit length repeat",s.mode=vt;break}M=s.lens[s.have-1],_=3+(c&3),c>>>=2,h-=2}else if(A===17){for(oe=S+3;h<oe;){if(o===0)break e;o--,c+=n[i++]<<h,h+=8}c>>>=S,h-=S,M=0,_=3+(c&7),c>>>=3,h-=3}else{for(oe=S+7;h<oe;){if(o===0)break e;o--,c+=n[i++]<<h,h+=8}c>>>=S,h-=S,M=0,_=11+(c&127),c>>>=7,h-=7}if(s.have+_>s.nlen+s.ndist){t.msg="invalid bit length repeat",s.mode=vt;break}for(;_--;)s.lens[s.have++]=M}}if(s.mode===vt)break;if(s.lens[256]===0){t.msg="invalid code -- missing end-of-block",s.mode=vt;break}if(s.lenbits=9,z={bits:s.lenbits},X=Fa(nd,s.lens,0,s.nlen,s.lencode,0,s.work,z),s.lenbits=z.bits,X){t.msg="invalid literal/lengths set",s.mode=vt;break}if(s.distbits=6,s.distcode=s.distdyn,z={bits:s.distbits},X=Fa(ad,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,z),s.distbits=z.bits,X){t.msg="invalid distances set",s.mode=vt;break}s.mode=si;case si:s.mode=ni;case ni:if(o>=6&&d>=258){t.next_out=r,t.avail_out=d,t.next_in=i,t.avail_in=o,s.hold=c,s.bits=h,u0(t,p),r=t.next_out,a=t.output,d=t.avail_out,i=t.next_in,n=t.input,o=t.avail_in,c=s.hold,h=s.bits,s.mode===Ys&&(s.back=-1);break}for(s.back=0;y=s.lencode[c&(1<<s.lenbits)-1],S=y>>>24,C=y>>>16&255,A=y&65535,!(S<=h);){if(o===0)break e;o--,c+=n[i++]<<h,h+=8}if(C&&(C&240)===0){for(E=S,H=C,ae=A;y=s.lencode[ae+((c&(1<<E+H)-1)>>E)],S=y>>>24,C=y>>>16&255,A=y&65535,!(E+S<=h);){if(o===0)break e;o--,c+=n[i++]<<h,h+=8}c>>>=E,h-=E,s.back+=E}if(c>>>=S,h-=S,s.back+=S,s.length=A,C===0){s.mode=$l;break}if(C&32){s.back=-1,s.mode=Ys;break}if(C&64){t.msg="invalid literal/length code",s.mode=vt;break}s.extra=C&15,s.mode=ql;case ql:if(s.extra){for(oe=s.extra;h<oe;){if(o===0)break e;o--,c+=n[i++]<<h,h+=8}s.length+=c&(1<<s.extra)-1,c>>>=s.extra,h-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=Yl;case Yl:for(;y=s.distcode[c&(1<<s.distbits)-1],S=y>>>24,C=y>>>16&255,A=y&65535,!(S<=h);){if(o===0)break e;o--,c+=n[i++]<<h,h+=8}if((C&240)===0){for(E=S,H=C,ae=A;y=s.distcode[ae+((c&(1<<E+H)-1)>>E)],S=y>>>24,C=y>>>16&255,A=y&65535,!(E+S<=h);){if(o===0)break e;o--,c+=n[i++]<<h,h+=8}c>>>=E,h-=E,s.back+=E}if(c>>>=S,h-=S,s.back+=S,C&64){t.msg="invalid distance code",s.mode=vt;break}s.offset=A,s.extra=C&15,s.mode=Zl;case Zl:if(s.extra){for(oe=s.extra;h<oe;){if(o===0)break e;o--,c+=n[i++]<<h,h+=8}s.offset+=c&(1<<s.extra)-1,c>>>=s.extra,h-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){t.msg="invalid distance too far back",s.mode=vt;break}s.mode=Jl;case Jl:if(d===0)break e;if(_=p-d,s.offset>_){if(_=s.offset-_,_>s.whave&&s.sane){t.msg="invalid distance too far back",s.mode=vt;break}_>s.wnext?(_-=s.wnext,b=s.wsize-_):b=s.wnext-_,_>s.length&&(_=s.length),w=s.window}else w=a,b=r-s.offset,_=s.length;_>d&&(_=d),d-=_,s.length-=_;do a[r++]=w[b++];while(--_);s.length===0&&(s.mode=ni);break;case $l:if(d===0)break e;a[r++]=s.length,d--,s.mode=ni;break;case Ji:if(s.wrap){for(;h<32;){if(o===0)break e;o--,c|=n[i++]<<h,h+=8}if(p-=d,t.total_out+=p,s.total+=p,p&&(t.adler=s.check=s.flags?Mt(s.check):Lr(s.check,a,p,r-p)),p=d,(s.flags?c:so(c))!==s.check){t.msg="incorrect data check",s.mode=vt;break}c=0,h=0}s.mode=eo;case eo:if(s.wrap&&s.flags){for(;h<32;){if(o===0)break e;o--,c+=n[i++]<<h,h+=8}if(c!==(s.total&4294967295)){t.msg="incorrect length check",s.mode=vt;break}c=0,h=0}s.mode=to;case to:X=g0;break e;case vt:X=x0;break e;case w0:return m0;case k0:default:return Hn}return t.next_out=r,t.avail_out=d,t.next_in=i,t.avail_in=o,s.hold=c,s.bits=h,(s.wsize||p!==t.avail_out&&s.mode<vt&&(s.mode<Ji||e!==Xl))&&P0(t,t.output,t.next_out,p-t.avail_out),v-=t.avail_in,p-=t.avail_out,t.total_in+=v,t.total_out+=p,s.total+=p,s.wrap&&p&&(t.adler=s.check=s.flags?Mt(s.check,a,p,t.next_out-p):Lr(s.check,a,p,t.next_out-p)),t.data_type=s.bits+(s.last?64:0)+(s.mode===Ys?128:0)+(s.mode===si||s.mode===Zi?256:0),(v===0&&p===0||e===Xl)&&X===ki&&(X=y0),X}function ld(){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 Ri{constructor(){this.strm=new ld,this.chunkSize=1024*10*10,this.strm.output=new Uint8Array(this.chunkSize),X0(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,B0(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(){rd(this.strm)}}var D0=4,ao=0,io=1,R0=2;function oa(t){for(var e=t.length;--e>=0;)t[e]=0}var I0=0,Q0=1,N0=2,U0=3,H0=258,Zr=29,ja=256,La=ja+1+Zr,$n=30,Jr=19,od=2*La+1,Pn=15,tr=16,z0=7,cd=256,dd=16,ud=17,hd=18,Pr=[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],fi=[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],O0=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],fd=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],V0=512,fn=new Array((La+2)*2);oa(fn);var Ta=new Array($n*2);oa(Ta);var Pa=new Array(V0);oa(Pa);var Ba=new Array(H0-U0+1);oa(Ba);var $r=new Array(Zr);oa($r);var Si=new Array($n);oa(Si);function sr(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 _d,vd,pd;function nr(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function gd(t){return t<256?Pa[t]:Pa[256+(t>>>7)]}function Ci(t,e){t.pending_buf[t.pending++]=e&255,t.pending_buf[t.pending++]=e>>>8&255}function _s(t,e,s){t.bi_valid>tr-s?(t.bi_buf|=e<<t.bi_valid&65535,Ci(t,t.bi_buf),t.bi_buf=e>>tr-t.bi_valid,t.bi_valid+=s-tr):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=s)}function en(t,e,s){_s(t,s[e*2],s[e*2+1])}function bd(t,e){var s=0;do s|=t&1,t>>>=1,s<<=1;while(--e>0);return s>>>1}function G0(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,c,h,v,p,_,b,w=0;for(p=0;p<=Pn;p++)t.bl_count[p]=0;for(s[t.heap[t.heap_max]*2+1]=0,c=t.heap_max+1;c<od;c++)h=t.heap[c],p=s[s[h*2+1]*2+1]+1,p>d&&(p=d,w++),s[h*2+1]=p,!(h>n)&&(t.bl_count[p]++,_=0,h>=o&&(_=r[h-o]),b=s[h*2],t.opt_len+=b*(p+_),i&&(t.static_len+=b*(a[h*2+1]+_)));if(w!==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]--,w-=2}while(w>0);for(p=d;p!==0;p--)for(h=t.bl_count[p];h!==0;)v=t.heap[--c],!(v>n)&&(s[v*2+1]!==p&&(t.opt_len+=(p-s[v*2+1])*s[v*2],s[v*2+1]=p),h--)}}function xd(t,e,s){var n=new Array(Pn+1),a=0,i,r;for(i=1;i<=Pn;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]=bd(n[o]++,o))}}function j0(){var t,e,s,n,a,i=new Array(Pn+1);for(s=0,n=0;n<Zr-1;n++)for($r[n]=s,t=0;t<1<<Pr[n];t++)Ba[s++]=n;for(Ba[s-1]=n,a=0,n=0;n<16;n++)for(Si[n]=a,t=0;t<1<<fi[n];t++)Pa[a++]=n;for(a>>=7;n<$n;n++)for(Si[n]=a<<7,t=0;t<1<<fi[n]-7;t++)Pa[256+a++]=n;for(e=0;e<=Pn;e++)i[e]=0;for(t=0;t<=143;)fn[t*2+1]=8,t++,i[8]++;for(;t<=255;)fn[t*2+1]=9,t++,i[9]++;for(;t<=279;)fn[t*2+1]=7,t++,i[7]++;for(;t<=287;)fn[t*2+1]=8,t++,i[8]++;for(xd(fn,La+1,i),t=0;t<$n;t++)Ta[t*2+1]=5,Ta[t*2]=bd(t,5);_d=new sr(fn,Pr,ja+1,La,Pn),vd=new sr(Ta,fi,0,$n,Pn),pd=new sr(new Array(0),O0,0,Jr,z0)}function md(t){var e;for(e=0;e<La;e++)t.dyn_ltree[e*2]=0;for(e=0;e<$n;e++)t.dyn_dtree[e*2]=0;for(e=0;e<Jr;e++)t.bl_tree[e*2]=0;t.dyn_ltree[cd*2]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0}function yd(t){t.bi_valid>8?Ci(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 W0(t,e,s,n){yd(t),Ci(t,s),Ci(t,~s),on(t.pending_buf,t.window,e,s,t.pending),t.pending+=s}function ro(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 ar(t,e,s){for(var n=t.heap[s],a=s<<1;a<=t.heap_len&&(a<t.heap_len&&ro(e,t.heap[a+1],t.heap[a],t.depth)&&a++,!ro(e,n,t.heap[a],t.depth));)t.heap[s]=t.heap[a],s=a,a<<=1;t.heap[s]=n}function lo(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?en(t,a,e):(r=Ba[a],en(t,r+ja+1,e),o=Pr[r],o!==0&&(a-=$r[r],_s(t,a,o)),n--,r=gd(n),en(t,r,s),o=fi[r],o!==0&&(n-=Si[r],_s(t,n,o)));while(i<t.last_lit);en(t,cd,e)}function Br(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,c;for(t.heap_len=0,t.heap_max=od,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;)c=t.heap[++t.heap_len]=d<2?++d:0,s[c*2]=1,t.depth[c]=0,t.opt_len--,a&&(t.static_len-=n[c*2+1]);for(e.max_code=d,r=t.heap_len>>1;r>=1;r--)ar(t,s,r);c=i;do r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],ar(t,s,1),o=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=o,s[c*2]=s[r*2]+s[o*2],t.depth[c]=(t.depth[r]>=t.depth[o]?t.depth[r]:t.depth[o])+1,s[r*2+1]=s[o*2+1]=c,t.heap[1]=c++,ar(t,s,1);while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],G0(t,e),xd(s,d,t.bl_count)}function oo(t,e,s){var n,a=-1,i,r=e[1],o=0,d=7,c=4;for(r===0&&(d=138,c=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<c?t.bl_tree[i*2]+=o:i!==0?(i!==a&&t.bl_tree[i*2]++,t.bl_tree[dd*2]++):o<=10?t.bl_tree[ud*2]++:t.bl_tree[hd*2]++,o=0,a=i,r===0?(d=138,c=3):i===r?(d=6,c=3):(d=7,c=4))}function co(t,e,s){var n,a=-1,i,r=e[1],o=0,d=7,c=4;for(r===0&&(d=138,c=3),n=0;n<=s;n++)if(i=r,r=e[(n+1)*2+1],!(++o<d&&i===r)){if(o<c)do en(t,i,t.bl_tree);while(--o!==0);else i!==0?(i!==a&&(en(t,i,t.bl_tree),o--),en(t,dd,t.bl_tree),_s(t,o-3,2)):o<=10?(en(t,ud,t.bl_tree),_s(t,o-3,3)):(en(t,hd,t.bl_tree),_s(t,o-11,7));o=0,a=i,r===0?(d=138,c=3):i===r?(d=6,c=3):(d=7,c=4)}}function q0(t){var e;for(oo(t,t.dyn_ltree,t.l_desc.max_code),oo(t,t.dyn_dtree,t.d_desc.max_code),Br(t,t.bl_desc),e=Jr-1;e>=3&&t.bl_tree[fd[e]*2+1]===0;e--);return t.opt_len+=3*(e+1)+5+5+4,e}function Y0(t,e,s,n){var a;for(_s(t,e-257,5),_s(t,s-1,5),_s(t,n-4,4),a=0;a<n;a++)_s(t,t.bl_tree[fd[a]*2+1],3);co(t,t.dyn_ltree,e-1),co(t,t.dyn_dtree,s-1)}function Z0(t){var e=4093624447,s;for(s=0;s<=31;s++,e>>>=1)if(e&1&&t.dyn_ltree[s*2]!==0)return ao;if(t.dyn_ltree[18]!==0||t.dyn_ltree[20]!==0||t.dyn_ltree[26]!==0)return io;for(s=32;s<ja;s++)if(t.dyn_ltree[s*2]!==0)return io;return ao}var uo=!1;function J0(t){uo||(j0(),uo=!0),t.l_desc=new nr(t.dyn_ltree,_d),t.d_desc=new nr(t.dyn_dtree,vd),t.bl_desc=new nr(t.bl_tree,pd),t.bi_buf=0,t.bi_valid=0,md(t)}function wd(t,e,s,n){_s(t,(I0<<1)+(n?1:0),3),W0(t,e,s)}function $0(t,e,s,n){var a,i,r=0;t.level>0?(t.strm.data_type===R0&&(t.strm.data_type=Z0(t)),Br(t,t.l_desc),Br(t,t.d_desc),r=q0(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?wd(t,e,s,n):t.strategy===D0||i===a?(_s(t,(Q0<<1)+(n?1:0),3),lo(t,fn,Ta)):(_s(t,(N0<<1)+(n?1:0),3),Y0(t,t.l_desc.max_code+1,t.d_desc.max_code+1,r+1),lo(t,t.dyn_ltree,t.dyn_dtree)),md(t),n&&yd(t)}function wn(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[(Ba[s]+ja+1)*2]++,t.dyn_dtree[gd(e)*2]++),t.last_lit===t.lit_bufsize-1}const e_={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"},Wa=0,ho=3,Da=4,t_=5,qn=0,ea=-2,ir=-5,kd=-1,s_=1,ai=2,n_=3,a_=4,i_=0,r_=2,el=8;var l_=15,o_=8,c_=29,d_=256,Dr=d_+1+c_,u_=30,h_=19,f_=2*Dr+1,__=15,nt=3,vn=258,Bs=vn+nt+1,v_=32,Sd=42,fo=69,rr=73,lr=91,or=103,wa=113,ii=666,Rt=1,qa=2,Ra=3,Ii=4,p_=3;function Yn(t,e){return t.msg=e_[e],e}function _o(t){return(t<<1)-(t>4?9:0)}function Fn(t){for(var e=t.length;--e>=0;)t[e]=0}function An(t){var e=t.state,s=e.pending;s>t.avail_out&&(s=t.avail_out),s!==0&&(on(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 Zt(t,e){$0(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,An(t.strm)}function pt(t,e){t.pending_buf[t.pending++]=e}function cr(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=e&255}function g_(t,e,s,n){var a=t.avail_in;return a>n&&(a=n),a===0?0:(t.avail_in-=a,on(e,t.input,t.next_in,a,s),t.state.wrap===1?t.adler=Lr(t.adler,e,a,s):t.state.wrap===2&&(t.adler=Mt(t.adler)),t.next_in+=a,t.total_in+=a,a)}function Cd(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-Bs?t.strstart-(t.w_size-Bs):0,c=t.window,h=t.w_mask,v=t.prev,p=t.strstart+vn,_=c[n+r-1],b=c[n+r];t.prev_length>=t.good_match&&(s>>=2),o>t.lookahead&&(o=t.lookahead);do if(a=e,!(c[a+r]!==b||c[a+r-1]!==_||c[a]!==c[n]||c[++a]!==c[n+1])){n+=2,a++;do;while(c[++n]===c[++a]&&c[++n]===c[++a]&&c[++n]===c[++a]&&c[++n]===c[++a]&&c[++n]===c[++a]&&c[++n]===c[++a]&&c[++n]===c[++a]&&c[++n]===c[++a]&&n<p);if(i=vn-(p-n),n=p-vn,i>r){if(t.match_start=e,r=i,i>=o)break;_=c[n+r-1],b=c[n+r]}}while((e=v[e&h])>d&&--s!==0);return r<=t.lookahead?r:t.lookahead}function Ya(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-Bs)){on(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=g_(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=n,t.lookahead+t.insert>=nt)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+nt-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<nt)););}while(t.lookahead<Bs&&t.strm.avail_in!==0)}function b_(t,e){var s=65535;for(s>t.pending_buf_size-5&&(s=t.pending_buf_size-5);;){if(t.lookahead<=1){if(Ya(t),t.lookahead===0&&e===Wa)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,Zt(t,!1),t.strm.avail_out===0)||t.strstart-t.block_start>=t.w_size-Bs&&(Zt(t,!1),t.strm.avail_out===0))return Rt}return t.insert=0,e===Da?(Zt(t,!0),t.strm.avail_out===0?Ra:Ii):(t.strstart>t.block_start&&(Zt(t,!1),t.strm.avail_out===0),Rt)}function dr(t,e){for(var s,n;;){if(t.lookahead<Bs){if(Ya(t),t.lookahead<Bs&&e===Wa)return Rt;if(t.lookahead===0)break}if(s=0,t.lookahead>=nt&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+nt-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-Bs&&(t.match_length=Cd(t,s)),t.match_length>=nt)if(n=wn(t,t.strstart-t.match_start,t.match_length-nt),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=nt){t.match_length--;do t.strstart++,t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+nt-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=wn(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(Zt(t,!1),t.strm.avail_out===0))return Rt}return t.insert=t.strstart<nt-1?t.strstart:nt-1,e===Da?(Zt(t,!0),t.strm.avail_out===0?Ra:Ii):t.last_lit&&(Zt(t,!1),t.strm.avail_out===0)?Rt:qa}function Gn(t,e){for(var s,n,a;;){if(t.lookahead<Bs){if(Ya(t),t.lookahead<Bs&&e===Wa)return Rt;if(t.lookahead===0)break}if(s=0,t.lookahead>=nt&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+nt-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=nt-1,s!==0&&t.prev_length<t.max_lazy_match&&t.strstart-s<=t.w_size-Bs&&(t.match_length=Cd(t,s),t.match_length<=5&&(t.strategy===s_||t.match_length===nt&&t.strstart-t.match_start>4096)&&(t.match_length=nt-1)),t.prev_length>=nt&&t.match_length<=t.prev_length){a=t.strstart+t.lookahead-nt,n=wn(t,t.strstart-1-t.prev_match,t.prev_length-nt),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+nt-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=nt-1,t.strstart++,n&&(Zt(t,!1),t.strm.avail_out===0))return Rt}else if(t.match_available){if(n=wn(t,0,t.window[t.strstart-1]),n&&Zt(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=wn(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<nt-1?t.strstart:nt-1,e===Da?(Zt(t,!0),t.strm.avail_out===0?Ra:Ii):t.last_lit&&(Zt(t,!1),t.strm.avail_out===0)?Rt:qa}function x_(t,e){for(var s,n,a,i,r=t.window;!(t.lookahead<=vn&&(Ya(t),t.lookahead<=vn,t.lookahead===0));){if(t.match_length=0,t.lookahead>=nt&&t.strstart>0&&(a=t.strstart-1,n=r[a],n===r[++a]&&n===r[++a]&&n===r[++a])){i=t.strstart+vn;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=vn-(i-a),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=nt?(s=wn(t,1,t.match_length-nt),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(s=wn(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),s&&(Zt(t,!1),t.strm.avail_out===0))return Rt}return t.insert=0,t.last_lit&&(Zt(t,!1),t.strm.avail_out===0)?Rt:qa}function m_(t,e){for(var s;!(t.lookahead===0&&(Ya(t),t.lookahead===0));)if(t.match_length=0,s=wn(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,s&&(Zt(t,!1),t.strm.avail_out===0))return Rt;return t.insert=0,t.last_lit&&(Zt(t,!1),t.strm.avail_out===0)?Rt:qa}function Hs(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 Hs(0,0,0,0,b_),new Hs(4,4,8,4,dr),new Hs(4,5,16,8,dr),new Hs(4,6,32,32,dr),new Hs(4,4,16,16,Gn),new Hs(8,16,32,32,Gn),new Hs(8,16,128,128,Gn),new Hs(8,32,128,256,Gn),new Hs(32,128,258,1024,Gn),new Hs(32,258,258,4096,Gn)];function y_(t){t.window_size=2*t.w_size,Fn(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=nt-1,t.match_available=0,t.ins_h=0}function w_(){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=el,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 ys(f_*2),this.dyn_dtree=new ys((2*u_+1)*2),this.bl_tree=new ys((2*h_+1)*2),Fn(this.dyn_ltree),Fn(this.dyn_dtree),Fn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new ys(__+1),this.heap=new ys(2*Dr+1),Fn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new ys(2*Dr+1),Fn(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 k_(t){var e;return!t||!t.state?Yn(t,ea):(t.total_in=t.total_out=0,t.data_type=r_,e=t.state,e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?Sd:wa,t.adler=e.wrap===2?0:1,e.last_flush=Wa,J0(e),qn)}function S_(t){var e=k_(t);return e===qn&&y_(t.state),e}function C_(t,e,s,n,a,i){if(!t)return ea;var r=1;if(e===kd&&(e=6),e<0||e>9||i<0||i>a_)return Yn(t,ea);var o=new w_;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+nt-1)/nt),o.window=new yi(o.w_size*2),o.head=new ys(o.hash_size),o.prev=new ys(o.w_size),o.lit_bufsize=1<<a+6,o.pending_buf_size=o.lit_bufsize*4,o.pending_buf=new yi(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,S_(t)}function E_(t,e){return C_(t,e,el,l_,o_,i_)}function vo(t,e){var s,n,a,i;if(!t||!t.state||e>t_||e<0)return t?Yn(t,ea):ea;if(n=t.state,!t.output||!t.input&&t.avail_in!==0||n.status===ii&&e!==Da)return Yn(t,t.avail_out===0?ir:ea);if(n.strm=t,s=n.last_flush,n.last_flush=e,n.status===Sd)if(n.wrap===2)t.adler=0,pt(n,31),pt(n,139),pt(n,8),n.gzhead?(pt(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)),pt(n,n.gzhead.time&255),pt(n,n.gzhead.time>>8&255),pt(n,n.gzhead.time>>16&255),pt(n,n.gzhead.time>>24&255),pt(n,n.level===9?2:n.strategy>=ai||n.level<2?4:0),pt(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(pt(n,n.gzhead.extra.length&255),pt(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=Mt(t.adler,n.pending_buf,n.pending)),n.gzindex=0,n.status=fo):(pt(n,0),pt(n,0),pt(n,0),pt(n,0),pt(n,0),pt(n,n.level===9?2:n.strategy>=ai||n.level<2?4:0),pt(n,p_),n.status=wa);else{var r=el+(n.w_bits-8<<4)<<8,o=-1;n.strategy>=ai||n.level<2?o=0:n.level<6?o=1:n.level===6?o=2:o=3,r|=o<<6,n.strstart!==0&&(r|=v_),r+=31-r%31,n.status=wa,cr(n,r),n.strstart!==0&&(cr(n,t.adler>>>16),cr(n,t.adler&65535)),t.adler=1}if(n.status===fo)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=Mt(t.adler,n.pending_buf,n.pending-a)),An(t),a=n.pending,n.pending===n.pending_buf_size));)pt(n,n.gzhead.extra[n.gzindex]&255),n.gzindex++;n.gzhead.hcrc&&n.pending>a&&(t.adler=Mt(t.adler,n.pending_buf,n.pending-a)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=rr)}else n.status=rr;if(n.status===rr)if(n.gzhead.name){a=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>a&&(t.adler=Mt(t.adler,n.pending_buf,n.pending-a)),An(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,pt(n,i)}while(i!==0);n.gzhead.hcrc&&n.pending>a&&(t.adler=Mt(t.adler,n.pending_buf,n.pending-a)),i===0&&(n.gzindex=0,n.status=lr)}else n.status=lr;if(n.status===lr)if(n.gzhead.comment){a=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>a&&(t.adler=Mt(t.adler,n.pending_buf,n.pending-a)),An(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,pt(n,i)}while(i!==0);n.gzhead.hcrc&&n.pending>a&&(t.adler=Mt(t.adler,n.pending_buf,n.pending-a)),i===0&&(n.status=or)}else n.status=or;if(n.status===or&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&An(t),n.pending+2<=n.pending_buf_size&&(pt(n,t.adler&255),pt(n,t.adler>>8&255),t.adler=0,n.status=wa)):n.status=wa),n.pending!==0){if(An(t),t.avail_out===0)return n.last_flush=-1,qn}else if(t.avail_in===0&&_o(e)<=_o(s)&&e!==Da)return Yn(t,ir);if(n.status===ii&&t.avail_in!==0)return Yn(t,ir);if(t.avail_in!==0||n.lookahead!==0||n.status!==ii){var d=n.strategy===ai?m_(n):n.strategy===n_?x_(n,e):Zn[n.level].func(n,e);if((d===Ra||d===Ii)&&(n.status=ii),d===Rt||d===Ra)return t.avail_out===0&&(n.last_flush=-1),qn;if(d===qa&&(wd(n,0,0,!1),Fn(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0),An(t),t.avail_out===0))return n.last_flush=-1,qn}return qn}class A_{constructor(){this.strm=new ld,this.chunkSize=1024*10*10,this.outputBuffer=new Uint8Array(this.chunkSize),E_(this.strm,kd)}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=vo(this.strm,ho),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=vo(this.strm,ho),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},K_={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},F_={lookup(t){if(t>=32&&t<=255)return t;const e=K_[t];return e!==void 0?e:16777216|t}},po={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"},go={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"},Sn={};function I(t,e){if(e===void 0)throw new Error('Undefined keysym for key "'+t+'"');if(t in Sn)throw new Error('Duplicate entry for key "'+t+'"');Sn[t]=[e,e,e,e]}function Qi(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 Sn)throw new Error('Duplicate entry for key "'+t+'"');Sn[t]=[e,e,s,e]}function at(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 Sn)throw new Error('Duplicate entry for key "'+t+'"');Sn[t]=[e,e,e,s]}Qi("Alt",m.XK_Alt_L,m.XK_Alt_R);I("AltGraph",m.XK_ISO_Level3_Shift);I("CapsLock",m.XK_Caps_Lock);Qi("Control",m.XK_Control_L,m.XK_Control_R);Qi("Meta",m.XK_Super_L,m.XK_Super_R);I("NumLock",m.XK_Num_Lock);I("ScrollLock",m.XK_Scroll_Lock);Qi("Shift",m.XK_Shift_L,m.XK_Shift_R);at("Enter",m.XK_Return,m.XK_KP_Enter);I("Tab",m.XK_Tab);at(" ",m.XK_space,m.XK_KP_Space);at("ArrowDown",m.XK_Down,m.XK_KP_Down);at("ArrowLeft",m.XK_Left,m.XK_KP_Left);at("ArrowRight",m.XK_Right,m.XK_KP_Right);at("ArrowUp",m.XK_Up,m.XK_KP_Up);at("End",m.XK_End,m.XK_KP_End);at("Home",m.XK_Home,m.XK_KP_Home);at("PageDown",m.XK_Next,m.XK_KP_Next);at("PageUp",m.XK_Prior,m.XK_KP_Prior);I("Backspace",m.XK_BackSpace);at("Clear",m.XK_Clear,m.XK_KP_Begin);I("Copy",m.XF86XK_Copy);I("Cut",m.XF86XK_Cut);at("Delete",m.XK_Delete,m.XK_KP_Delete);at("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);at("=",m.XK_equal,m.XK_KP_Equal);at("+",m.XK_plus,m.XK_KP_Add);at("-",m.XK_minus,m.XK_KP_Subtract);at("*",m.XK_asterisk,m.XK_KP_Multiply);at("/",m.XK_slash,m.XK_KP_Divide);at(".",m.XK_period,m.XK_KP_Decimal);at(",",m.XK_comma,m.XK_KP_Separator);at("0",m.XK_0,m.XK_KP_0);at("1",m.XK_1,m.XK_KP_1);at("2",m.XK_2,m.XK_KP_2);at("3",m.XK_3,m.XK_KP_3);at("4",m.XK_4,m.XK_KP_4);at("5",m.XK_5,m.XK_KP_5);at("6",m.XK_6,m.XK_KP_6);at("7",m.XK_7,m.XK_KP_7);at("8",m.XK_8,m.XK_KP_8);at("9",m.XK_9,m.XK_KP_9);function Ma(t){if(t.code){switch(t.code){case"OSLeft":return"MetaLeft";case"OSRight":return"MetaRight"}return t.code}if(t.keyCode in po){let e=po[t.keyCode];if(jn()&&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 T_(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=Ma(t);return e in go?go[e]:t.charCode?String.fromCharCode(t.charCode):"Unidentified"}function M_(t){const e=T_(t);if(e==="Unidentified")return null;if(e in Sn){let n=t.location;if(e==="Meta"&&n===0&&(n=2),e==="Clear"&&n===3&&Ma(t)==="NumLock"&&(n=0),(n===void 0||n>3)&&(n=0),e==="Meta"){let a=Ma(t);if(a==="AltLeft")return m.XK_Meta_L;if(a==="AltRight")return m.XK_Meta_R}if(e==="Clear"&&Ma(t)==="NumLock")return m.XK_Num_Lock;if(hi())switch(e){case"Zenkaku":case"Hankaku":return m.XK_Zenkaku_Hankaku;case"Romaji":case"KanaMode":return m.XK_Romaji}return Sn[e][n]}if(e.length!==1)return null;const s=e.charCodeAt();return s?F_.lookup(s):null}class X_{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]}Me("onkeyevent "+(n?"down":"up")+", keysym: "+e,", code: "+s+", numlock: "+a+", capslock: "+i),this.onkeyevent(e,s,n,a,i)}_getKeyCode(e){const s=Ma(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=M_(e),a=e.getModifierState("NumLock"),i=e.getModifierState("CapsLock");if((jn()||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(jn()||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]),(jn()||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((jn()||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(hi()&&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"&&hi()&&!("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(),(jn()||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),hi()&&(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(){Me(">> Keyboard.allKeysUp"),this._interruptAltGrSequence();for(let e in this._keyDownList)this._sendKeyEvent(this._keyDownList[e],e,!1);Me("<< 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 zs=0,bo=1,xo=2,mo=4,yo=8,ur=16,_a=32,va=64,hr=127,wo=50,L_=90,ko=250,P_=1e3,B_=1e3,D_=50;class R_{constructor(){this._target=null,this._state=hr,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===zs){this._ignored.push(e);return}if(this._tracked.length>0&&Date.now()-this._tracked[0].started>ko){this._state=zs,this._ignored.push(e);return}if(this._waitingRelease){this._state=zs,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=zs}}_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)<wo)return;if(this._state&=-24,this._stopLongpressTimeout(),this._tracked.length!==1&&(this._state&=~yo),this._tracked.length!==2&&(this._state&=-97),this._tracked.length===2){let o=this._tracked.find(c=>c.id!==e);if(Math.hypot(o.firstX-o.lastX,o.firstY-o.lastY)>wo){let c=Math.abs(a.angle-o.angle);c=Math.abs((c+180)%360-180),c>L_?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=hr,this._waitingRelease=!1);return}if(!this._hasDetectedGesture()&&this._isTwoTouchTimeoutRunning()&&(this._stopTwoTouchTimeout(),this._state=zs),!this._hasDetectedGesture()&&(this._state&=-105,this._state&=~ur,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>ko&&(this._state=zs),this._tracked.some(i=>Date.now()-i.started>P_)&&(this._state=zs);let a=this._tracked.find(i=>i.id===e);if(a.active=!1,this._hasDetectedGesture())this._pushEvent("gesturestart");else if(this._state!==zs)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=zs,this._ignored.indexOf(e)!==-1&&this._ignored.splice(this._ignored.indexOf(e),1),this._ignored.length===0&&(this._state=hr,this._waitingRelease=!1)}_hasDetectedGesture(){return!(this._state===zs||this._state&this._state-1||this._state&(bo|xo|mo)&&this._tracked.some(e=>e.active))}_startLongpressTimeout(){this._stopLongpressTimeout(),this._longpressTimeoutId=setTimeout(()=>this._longpressTimeout(),B_)}_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=ur,this._pushEvent("gesturestart")}_startTwoTouchTimeout(){this._stopTwoTouchTimeout(),this._twoTouchTimeoutId=setTimeout(()=>this._twoTouchTimeout(),D_)}_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 bo:return"onetap";case xo:return"twotap";case mo:return"threetap";case yo:return"drag";case ur: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=!i0||qc;class I_{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 fr=40*1024*1024,ri={CONNECTING:"connecting",OPEN:"open",CLOSING:"closing",CLOSED:"closed"},li={CONNECTING:[WebSocket.CONNECTING,ri.CONNECTING],OPEN:[WebSocket.OPEN,ri.OPEN],CLOSING:[WebSocket.CLOSING,ri.CLOSING],CLOSED:[WebSocket.CLOSED,ri.CLOSED]},So=["send","close","binaryType","onerror","onmessage","onopen","protocol","readyState"];class Q_{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,li.CONNECTING.includes(e)?"connecting":li.OPEN.includes(e)?"open":li.CLOSING.includes(e)?"closing":li.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<So.length;n++){const a=So[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=()=>{Me(">> WebSock.onopen"),this._websocket.protocol&&jt("Server choose sub-protocol: "+this._websocket.protocol),this._eventHandlers.open(),Me("<< WebSock.onopen")},this._websocket.onclose=n=>{Me(">> WebSock.onclose"),this._eventHandlers.close(n),Me("<< WebSock.onclose")},this._websocket.onerror=n=>{Me(">> WebSock.onerror: "+n),this._eventHandlers.error(n),Me("<< WebSock.onerror: "+n)}}close(){this._websocket&&((this.readyState==="connecting"||this.readyState==="open")&&(jt("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>fr&&(this._rQbufferSize=fr,this._rQbufferSize-(this._rQlen-this._rQi)<e))throw new Error("Receive queue buffer exceeded "+fr+" 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():Me("Ignoring empty message")}}const N_={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},Le={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 tl{constructor(){this._key=null}get algorithm(){return{name:"AES-ECB"}}static async importKey(e,s,n,a){const i=new tl;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 sl{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 c=0;c<16;c++)r[n*16+c]^=this._k1[c];else{r[(n+1)*16+i]=128;for(let c=0;c<16;c++)r[(n+1)*16+c]^=this._k2[c]}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 sl;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 h=0;h<16;h++)d[h]^=i[h]^o[h];const c=new Uint8Array(16+r.length);return c.set(r),c.set(d,r.length),c}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),c=await this._computeCMAC(n,this._prefixBlock2);for(let v=0;v<16;v++)c[v]^=o[v]^d[v];if(c.length!==r.length)return null;for(let v=0;v<r.length;v++)if(c[v]!==r[v])return null;return await this._decryptCTR(n,o)}}const Co=[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],U_=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],x=0;let L,P,Q,B,D,N;L=65536;P=1<<24;Q=L|P;B=4;D=1024;N=B|D;const Eo=[Q|D,x|x,L|x,Q|N,Q|B,L|N,x|B,L|x,x|D,Q|D,Q|N,x|D,P|N,Q|B,P|x,x|B,x|N,P|D,P|D,L|D,L|D,Q|x,Q|x,P|N,L|B,P|B,P|B,L|B,x|x,x|N,L|N,P|x,L|x,Q|N,x|B,Q|x,Q|D,P|x,P|x,x|D,Q|B,L|x,L|D,P|B,x|D,x|B,P|N,L|N,Q|N,L|B,Q|x,P|N,P|B,x|N,L|N,Q|D,x|N,P|D,P|D,x|x,L|B,L|D,x|x,Q|B];L=1<<20;P=1<<31;Q=L|P;B=32;D=32768;N=B|D;const Ao=[Q|N,P|D,x|D,L|N,L|x,x|B,Q|B,P|N,P|B,Q|N,Q|D,P|x,P|D,L|x,x|B,Q|B,L|D,L|B,P|N,x|x,P|x,x|D,L|N,Q|x,L|B,P|B,x|x,L|D,x|N,Q|D,Q|x,x|N,x|x,L|N,Q|B,L|x,P|N,Q|x,Q|D,x|D,Q|x,P|D,x|B,Q|N,L|N,x|B,x|D,P|x,x|N,Q|D,L|x,P|B,L|B,P|N,P|B,L|B,L|D,x|x,P|D,x|N,P|x,Q|B,Q|N,L|D];L=1<<17;P=1<<27;Q=L|P;B=8;D=512;N=B|D;const Ko=[x|N,Q|D,x|x,Q|B,P|D,x|x,L|N,P|D,L|B,P|B,P|B,L|x,Q|N,L|B,Q|x,x|N,P|x,x|B,Q|D,x|D,L|D,Q|x,Q|B,L|N,P|N,L|D,L|x,P|N,x|B,Q|N,x|D,P|x,Q|D,P|x,L|B,x|N,L|x,Q|D,P|D,x|x,x|D,L|B,Q|N,P|D,P|B,x|D,x|x,Q|B,P|N,L|x,P|x,Q|N,x|B,L|N,L|D,P|B,Q|x,P|N,x|N,Q|x,L|N,x|B,Q|B,L|D];L=8192;P=1<<23;Q=L|P;B=1;D=128;N=B|D;const Fo=[Q|B,L|N,L|N,x|D,Q|D,P|N,P|B,L|B,x|x,Q|x,Q|x,Q|N,x|N,x|x,P|D,P|B,x|B,L|x,P|x,Q|B,x|D,P|x,L|B,L|D,P|N,x|B,L|D,P|D,L|x,Q|D,Q|N,x|N,P|D,P|B,Q|x,Q|N,x|N,x|x,x|x,Q|x,L|D,P|D,P|N,x|B,Q|B,L|N,L|N,x|D,Q|N,x|N,x|B,L|x,P|B,L|B,Q|D,P|N,L|B,L|D,P|x,Q|B,x|D,P|x,L|x,Q|D];L=1<<25;P=1<<30;Q=L|P;B=256;D=1<<19;N=B|D;const To=[x|B,L|N,L|D,Q|B,x|D,x|B,P|x,L|D,P|N,x|D,L|B,P|N,Q|B,Q|D,x|N,P|x,L|x,P|D,P|D,x|x,P|B,Q|N,Q|N,L|B,Q|D,P|B,x|x,Q|x,L|N,L|x,Q|x,x|N,x|D,Q|B,x|B,L|x,P|x,L|D,Q|B,P|N,L|B,P|x,Q|D,L|N,P|N,x|B,L|x,Q|D,Q|N,x|N,Q|x,Q|N,L|D,x|x,P|D,Q|x,x|N,L|B,P|B,x|D,x|x,P|D,L|N,P|B];L=1<<22;P=1<<29;Q=L|P;B=16;D=16384;N=B|D;const Mo=[P|B,Q|x,x|D,Q|N,Q|x,x|B,Q|N,L|x,P|D,L|N,L|x,P|B,L|B,P|D,P|x,x|N,x|x,L|B,P|N,x|D,L|D,P|N,x|B,Q|B,Q|B,x|x,L|N,Q|D,x|N,L|D,Q|D,P|x,P|D,x|B,Q|B,L|D,Q|N,L|x,x|N,P|B,L|x,P|D,P|x,x|N,P|B,Q|N,L|D,Q|x,L|N,Q|D,x|x,Q|B,x|B,x|D,Q|x,L|N,x|D,L|B,P|N,x|x,Q|D,P|x,L|B,P|N];L=1<<21;P=1<<26;Q=L|P;B=2;D=2048;N=B|D;const Xo=[L|x,Q|B,P|N,x|x,x|D,P|N,L|N,Q|D,Q|N,L|x,x|x,P|B,x|B,P|x,Q|B,x|N,P|D,L|N,L|B,P|D,P|B,Q|x,Q|D,L|B,Q|x,x|D,x|N,Q|N,L|D,x|B,P|x,L|D,P|x,L|D,L|x,P|N,P|N,Q|B,Q|B,x|B,L|B,P|x,P|D,L|x,Q|D,x|N,L|N,Q|D,x|N,P|B,Q|N,Q|x,L|D,x|x,x|B,Q|N,x|x,L|N,Q|x,x|D,P|B,P|D,x|D,L|B];L=1<<18;P=1<<28;Q=L|P;B=64;D=4096;N=B|D;const Lo=[P|N,x|D,L|x,Q|N,P|x,P|N,x|B,P|x,L|B,Q|x,Q|N,L|D,Q|D,L|N,x|D,x|B,Q|x,P|B,P|D,x|N,L|D,L|B,Q|B,Q|D,x|N,x|x,x|x,Q|B,P|B,P|D,L|N,L|x,L|N,L|x,Q|D,x|D,x|B,Q|B,x|D,L|N,P|D,x|B,P|B,Q|x,Q|B,P|x,L|x,P|N,x|x,Q|N,L|B,P|B,Q|x,P|D,P|N,x|x,Q|N,L|D,L|D,x|N,x|N,L|B,P|x,Q|D];class Ed{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 c=d-28;c<d;++c){const h=c+U_[i];n[c]=h<d?s[h]:s[h-28]}for(let d=0;d<24;++d)n[Co[d]]!==0&&(a[r]|=1<<23-d),n[Co[d+24]]!==0&&(a[o]|=1<<23-d)}for(let i=0,r=0,o=0;i<16;++i){const d=a[r++],c=a[r++];this.keys[o]=(d&16515072)<<6,this.keys[o]|=(d&4032)<<10,this.keys[o]|=(c&16515072)>>>10,this.keys[o]|=(c&4032)>>>6,++o,this.keys[o]=(d&258048)<<12,this.keys[o]|=(d&63)<<16,this.keys[o]|=(c&258048)>>>4,this.keys[o]|=c&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 c=Xo[r&63];c|=To[r>>>8&63],c|=Ko[r>>>16&63],c|=Eo[r>>>24&63],r=i^this.keys[d++],c|=Lo[r&63],c|=Mo[r>>>8&63],c|=Fo[r>>>16&63],c|=Ao[r>>>24&63],a^=c,r=a<<28|a>>>4,r^=this.keys[d++],c=Xo[r&63],c|=To[r>>>8&63],c|=Ko[r>>>16&63],c|=Eo[r>>>24&63],r=a^this.keys[d++],c|=Lo[r&63],c|=Mo[r>>>8&63],c|=Fo[r>>>16&63],c|=Ao[r>>>24&63],i^=c}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 nl{constructor(){this._cipher=null}get algorithm(){return{name:"DES-ECB"}}static importKey(e,s,n,a){const i=new nl;return i._importKey(e),i}_importKey(e,s,n){this._cipher=new Ed(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 al{constructor(){this._cipher=null}get algorithm(){return{name:"DES-CBC"}}static importKey(e,s,n,a){const i=new al;return i._importKey(e),i}_importKey(e){this._cipher=new Ed(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 Ei(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 Ai(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 Ts(t){let e="0x";for(let s=0;s<t.length;s++)e+=t[s].toString(16).padStart(2,"0");return BigInt(e)}class Ki{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,"="),Yr.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 Ki;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=Ts(this._n),this._e=this._padArray(this._base64urlDecode(a.e),this._keyBytes),this._eBigInt=Ts(this._e),this._d=this._padArray(this._base64urlDecode(a.d),this._keyBytes),this._dBigInt=Ts(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 Ki;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=Ts(this._n),this._eBigInt=Ts(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=Ts(a),r=Ei(i,this._eBigInt,this._nBigInt);return Ai(r,this._keyBytes)}async decrypt(e,s){if(s.length!==this._keyBytes)return null;const n=Ts(s),a=Ei(n,this._dBigInt,this._nBigInt),i=Ai(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 H_{constructor(e){this._key=e}get algorithm(){return{name:"DH"}}exportKey(){return this._key}}class il{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 il;return n._generateKey(e),{privateKey:n,publicKey:new H_(n._publicKey)}}_generateKey(e){const s=e.g,n=e.p;this._keyBytes=n.length,this._gBigInt=Ts(s),this._pBigInt=Ts(n),this._privateKey=window.crypto.getRandomValues(new Uint8Array(this._keyBytes)),this._privateKeyBigInt=Ts(this._privateKey),this._publicKey=Ai(Ei(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=Ei(Ts(a),this._privateKeyBigInt,this._pBigInt);return Ai(r,i).slice(0,i)}}async function z_(t){let e="";for(let s=0;s<t.length;s++)e+=String.fromCharCode(t[s]);return O_(G_(j_(V_(e),8*e.length)))}function O_(t){let e=new Uint8Array(t.length);for(let s=0;s<t.length;s++)e[s]=t.charCodeAt(s);return e}function V_(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 G_(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 j_(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,c=a,h=i;n=Gt(n=Gt(n=Gt(n=Gt(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,a=zt(a,i=zt(i,s=zt(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=zt(a,i=zt(i,s=zt(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=zt(a,i=zt(i,s=zt(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=zt(a,i=zt(i,s=zt(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=Ot(a,i=Ot(i,s=Ot(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=Ot(a,i=Ot(i,s=Ot(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=Ot(a,i=Ot(i,s=Ot(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=Ot(a,i=Ot(i,s=Ot(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=Vt(a,i=Vt(i,s=Vt(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=Vt(a,i=Vt(i,s=Vt(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=Vt(a,i=Vt(i,s=Vt(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=Vt(a,i=Vt(i,s=Vt(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=Gt(a,i=Gt(i,s=Gt(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=Gt(a,i=Gt(i,s=Gt(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=Gt(a,i=Gt(i,s=Gt(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=Gt(a,i=Gt(i,s=Gt(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=pn(s,o),n=pn(n,d),a=pn(a,c),i=pn(i,h)}return Array(s,n,a,i)}function Ni(t,e,s,n,a,i){return pn(W_(pn(pn(e,t),pn(n,i)),a),s)}function zt(t,e,s,n,a,i,r){return Ni(e&s|~e&n,t,e,a,i,r)}function Ot(t,e,s,n,a,i,r){return Ni(e&n|s&~n,t,e,a,i,r)}function Vt(t,e,s,n,a,i,r){return Ni(e^s^n,t,e,a,i,r)}function Gt(t,e,s,n,a,i,r){return Ni(s^(e|~n),t,e,a,i,r)}function pn(t,e){let s=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(s>>16)<<16|65535&s}function W_(t,e){return t<<e|t>>>32-e}class q_{constructor(){this._algorithms={"AES-ECB":tl,"AES-EAX":sl,"DES-ECB":nl,"DES-CBC":al,"RSA-PKCS1-v1_5":Ki,DH:il,MD5:z_}}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 yt=new q_;class Po{constructor(){this._cipher=null,this._counter=new Uint8Array(16)}async setKey(e){this._cipher=await yt.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 yt.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 yt.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 Y_ extends sd{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 yt.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 c=2048,h=Math.ceil(c/8),v=(await yt.generateKey({name:"RSA-PKCS1-v1_5",modulusLength:c,publicExponent:new Uint8Array([1,0,1])},!0,["encrypt"])).privateKey,p=await yt.exportKey("raw",v),_=p.n,b=p.e,w=new Uint8Array(4+h*2);w[0]=(c&4278190080)>>>24,w[1]=(c&16711680)>>>16,w[2]=(c&65280)>>>8,w[3]=c&255,w.set(_,4),w.set(b,4+h),this._sock.sQpushBytes(w),this._sock.flush();const y=new Uint8Array(16);window.crypto.getRandomValues(y);const S=await yt.encrypt({name:"RSA-PKCS1-v1_5"},r,y),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()!==h)throw new Error("RA2: wrong encrypted message length");const A=this._sock.rQshiftBytes(h),E=await yt.decrypt({name:"RSA-PKCS1-v1_5"},v,A);if(E===null||E.length!==16)throw new Error("RA2: corrupted server encrypted random");let H=new Uint8Array(32),ae=new Uint8Array(32);H.set(E),H.set(y,16),ae.set(y),ae.set(E,16),H=await window.crypto.subtle.digest("SHA-1",H),H=new Uint8Array(H).slice(0,16),ae=await window.crypto.subtle.digest("SHA-1",ae),ae=new Uint8Array(ae).slice(0,16);const M=new Po;await M.setKey(H);const X=new Po;await X.setKey(ae);let j=new Uint8Array(8+n*2+h*2),z=new Uint8Array(8+n*2+h*2);if(j.set(o),j.set(w,4+n*2),z.set(w),z.set(o,4+h*2),j=await window.crypto.subtle.digest("SHA-1",j),z=await window.crypto.subtle.digest("SHA-1",z),j=new Uint8Array(j),z=new Uint8Array(z),this._sock.sQpushBytes(await M.makeMessage(z)),this._sock.flush(),await this._waitSockAsync(38),this._sock.rQshift16()!==20)throw new Error("RA2: wrong server hash");const oe=await X.receiveMessage(20,this._sock.rQshiftBytes(36));if(oe===null)throw new Error("RA2: failed to authenticate the message");for(let $=0;$<20;$++)if(oe[$]!==j[$])throw new Error("RA2: wrong server hash");if(await this._waitSockAsync(19),this._sock.rQshift16()!==1)throw new Error("RA2: wrong subtype");let re=await X.receiveMessage(1,this._sock.rQshiftBytes(17));if(re===null)throw new Error("RA2: failed to authenticate the message");re=re[0];let ce=this._waitCredentialsAsync(re);if(re===1)(this._getCredentials().username===void 0||this._getCredentials().password===void 0)&&this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["username","password"]}}));else if(re===2)this._getCredentials().password===void 0&&this.dispatchEvent(new CustomEvent("credentialsrequired",{detail:{types:["password"]}}));else throw new Error("RA2: wrong subtype");await ce;let J;re===1?J=Js(this._getCredentials().username).slice(0,255):J="";const T=Js(this._getCredentials().password).slice(0,255),q=new Uint8Array(J.length+T.length+2);q[0]=J.length,q[J.length+1]=T.length;for(let $=0;$<J.length;$++)q[$+1]=J.charCodeAt($);for(let $=0;$<T.length;$++)q[J.length+2+$]=T.charCodeAt($);this._sock.sQpushBytes(await M.makeMessage(q)),this._sock.flush()}get hasStarted(){return this._hasStarted}set hasStarted(e){this._hasStarted=e}}class Z_{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,c=n*d;for(;this._lines>0;){if(i.rQwait("RAW",c))return!1;const h=s+(a-this._lines);let v=i.rQshiftBytes(c,!1);if(o==8){const p=new Uint8Array(n*4);for(let _=0;_<n;_++)p[_*4+0]=(v[_]>>0&3)*255/3,p[_*4+1]=(v[_]>>2&3)*255/3,p[_*4+2]=(v[_]>>4&3)*255/3,p[_*4+3]=255;v=p}for(let p=0;p<n;p++)v[p*4+3]=255;r.blitImage(e,h,n,1,v,0),this._lines--}return!0}}class J_{decodeRect(e,s,n,a,i,r,o){if(i.rQwait("COPYRECT",4))return!1;let d=i.rQshift16(),c=i.rQshift16();return n===0||a===0||r.copyImage(d,c,e,s,n,a),!0}}class $_{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),c=i.rQshift16(),h=i.rQshift16(),v=i.rQshift16(),p=i.rQshift16();r.fillRect(e+c,s+h,v,p,d),this._subrects--}return!0}}class ev{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 c=i.rQpeek8();if(c>30)throw new Error("Illegal hextile subencoding (subencoding: "+c+")");const h=this._totalTiles-this._tiles,v=h%this._tilesX,p=Math.floor(h/this._tilesX),_=e+v*16,b=s+p*16,w=Math.min(16,e+n-_),y=Math.min(16,s+a-b);if(c&1)d+=w*y*4;else if(c&2&&(d+=4),c&4&&(d+=4),c&8){if(d++,i.rQwait("HEXTILE",d))return!1;let S=i.rQpeekBytes(d).at(-1);c&16?d+=S*6:d+=S*2}if(i.rQwait("HEXTILE",d))return!1;if(i.rQshift8(),c===0)this._lastsubencoding&1?Me(" Ignoring blank after RAW"):r.fillRect(_,b,w,y,this._background);else if(c&1){let S=w*y,C=i.rQshiftBytes(S*4,!1);for(let A=0;A<S;A++)C[A*4+3]=255;r.blitImage(_,b,w,y,C,0)}else{if(c&2&&(this._background=new Uint8Array(i.rQshiftBytes(4))),c&4&&(this._foreground=new Uint8Array(i.rQshiftBytes(4))),this._startTile(_,b,w,y,this._background),c&8){let S=i.rQshift8();for(let C=0;C<S;C++){let A;c&16?A=i.rQshiftBytes(4):A=this._foreground;const E=i.rQshift8(),H=E>>4,ae=E&15,M=i.rQshift8(),X=(M>>4)+1,j=(M&15)+1;this._subTile(H,ae,X,j,A)}}this._finishTile(r)}this._lastsubencoding=c,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],c=this._tileBuffer;for(let h=0;h<n*a*4;h+=4)c[h]=r,c[h+1]=o,c[h+2]=d,c[h+3]=255}_subTile(e,s,n,a,i){const r=i[0],o=i[1],d=i[2],c=e+n,h=s+a,v=this._tileBuffer,p=this._tileW;for(let _=s;_<h;_++)for(let b=e;b<c;b++){const w=(b+_*p)*4;v[w]=r,v[w+1]=o,v[w+2]=d,v[w+3]=255}}_finishTile(e){e.blitImage(this._tileX,this._tileY,this._tileW,this._tileH,this._tileBuffer,0)}}class tv{constructor(){this._zlib=new Ri,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 c=0;c<n*a;c++)d[c*4+3]=255;return r.blitImage(e,s,n,a,d,0),!0}}class Ad{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 Ri}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 c=0;c<4;c++)this._ctl>>c&1&&(this._zlibs[c].reset(),jt("Reset zlib stream "+c));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 c=e&3,h;switch(this._filter){case 0:h=this._copyFilter(c,s,n,a,i,r,o,d);break;case 1:h=this._paletteFilter(c,s,n,a,i,r,o,d);break;case 2:h=this._gradientFilter(c,s,n,a,i,r,o,d);break;default:throw new Error("Illegal tight filter received (ctl: "+this._filter+")")}return h&&(this._filter=null),h}_copyFilter(e,s,n,a,i,r,o,d){const c=a*i*3;let h;if(c===0)return!0;if(c<12){if(r.rQwait("TIGHT",c))return!1;h=r.rQshiftBytes(c)}else{if(h=this._readData(r),h===null)return!1;this._zlibs[e].setInput(h),h=this._zlibs[e].inflate(c),this._zlibs[e].setInput(null)}let v=new Uint8Array(a*i*4);for(let p=0,_=0;p<a*i*4;p+=4,_+=3)v[p]=h[_],v[p+1]=h[_+1],v[p+2]=h[_+2],v[p+3]=255;return o.blitImage(s,n,a,i,v,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 _=r.rQpeek8()+1,b=_*3;if(r.rQwait("TIGHT palette",1+b))return!1;this._numColors=_,r.rQskipBytes(1),r.rQshiftTo(this._palette,b)}const c=this._numColors<=2?1:8,v=Math.floor((a*c+7)/8)*i;let p;if(v===0)return!0;if(v<12){if(r.rQwait("TIGHT",v))return!1;p=r.rQshiftBytes(v)}else{if(p=this._readData(r),p===null)return!1;this._zlibs[e].setInput(p),p=this._zlibs[e].inflate(v),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),c=Math.floor((n+7)/8),h=Math.floor(n/8);for(let v=0;v<a;v++){let p,_,b;for(b=0;b<h;b++)for(let w=7;w>=0;w--)p=(v*n+b*8+7-w)*4,_=(i[v*c+b]>>w&1)*3,d[p]=r[_],d[p+1]=r[_+1],d[p+2]=r[_+2],d[p+3]=255;for(let w=7;w>=8-n%8;w--)p=(v*n+b*8+7-w)*4,_=(i[v*c+b]>>w&1)*3,d[p]=r[_],d[p+1]=r[_+1],d[p+2]=r[_+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),c=n*a*4;for(let h=0,v=0;h<c;h+=4,v++){const p=i[v]*3;d[h]=r[p],d[h+1]=r[p+1],d[h+2]=r[p+2],d[h+3]=255}o.blitImage(e,s,n,a,d,0,!1)}_gradientFilter(e,s,n,a,i,r,o,d){const c=a*i*3;let h;if(c===0)return!0;if(c<12){if(r.rQwait("TIGHT",c))return!1;h=r.rQshiftBytes(c)}else{if(h=this._readData(r),h===null)return!1;this._zlibs[e].setInput(h),h=this._zlibs[e].inflate(c),this._zlibs[e].setInput(null)}let v=new Uint8Array(4*a*i),p=0,_=0,b=new Uint8Array(3);for(let C=0;C<a;C++){for(let A=0;A<3;A++){const E=b[A],H=h[_++]+E;v[p++]=H,b[A]=H}v[p++]=255}let w=0,y=new Uint8Array(3),S=new Uint8Array(3);for(let C=1;C<i;C++){b.fill(0),S.fill(0);for(let A=0;A<a;A++){for(let E=0;E<3;E++){y[E]=v[w++];let H=b[E]+y[E]-S[E];H<0?H=0:H>255&&(H=255);const ae=h[_++]+H;v[p++]=ae,S[E]=y[E],b[E]=ae}v[p++]=255,w++}}return o.blitImage(s,n,a,i,v,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 sv extends Ad{_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 oi=64,ci=64;class nv{constructor(){this._length=0,this._inflator=new Ri,this._pixelBuffer=new Uint8Array(oi*ci*4),this._tileBuffer=new Uint8Array(oi*ci*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 c=s;c<s+a;c+=ci){let h=Math.min(ci,s+a-c);for(let v=e;v<e+n;v+=oi){let p=Math.min(oi,e+n-v);const _=p*h,b=this._inflator.inflate(1)[0];if(b===0){const w=this._readPixels(_);r.blitImage(v,c,p,h,w,0,!1)}else if(b===1){const w=this._readPixels(1);r.fillRect(v,c,p,h,[w[0],w[1],w[2]])}else if(b>=2&&b<=16){const w=this._decodePaletteTile(b,_,p,h);r.blitImage(v,c,p,h,w,0,!1)}else if(b===128){const w=this._decodeRLETile(_);r.blitImage(v,c,p,h,w,0,!1)}else if(b>=130&&b<=255){const w=this._decodeRLEPaletteTile(b-128,_);r.blitImage(v,c,p,h,w,0,!1)}else throw new Error("Unknown subencoding: "+b)}}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 c=0,h=this._inflator.inflate(1)[0];for(let v=0;v<a;v++){let p=8-o;for(let _=0;_<n;_++){p<0&&(p=8-o,h=this._inflator.inflate(1)[0]);let b=h>>p&d;i[c]=r[b*4],i[c+1]=r[b*4+1],i[c+2]=r[b*4+2],i[c+3]=r[b*4+3],c+=4,p-=o}p<8-o&&v<a-1&&(h=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 av{constructor(){this._cachedQuantTables=[],this._cachedHuffmanTables=[],this._segments=[]}decodeRect(e,s,n,a,i,r,o){for(;;){let _=this._readSegment(i);if(_===null)return!1;if(this._segments.push(_),_[1]===217)break}let d=[],c=[];for(let _ of this._segments){let b=_[1];b===196?d.push(_):b===219&&c.push(_)}const h=this._segments.findIndex(_=>_[1]==192||_[1]==194);if(h==-1)throw new Error("Illegal JPEG image without SOF");c.length===0&&this._segments.splice(h+1,0,...this._cachedQuantTables),d.length===0&&this._segments.splice(h+1,0,...this._cachedHuffmanTables);let v=0;for(let _ of this._segments)v+=_.length;let p=new Uint8Array(v);v=0;for(let _ of this._segments)p.set(_,v),v+=_.length;return r.imageRect(e,s,n,a,"image/jpeg",p),d.length!==0&&(this._cachedHuffmanTables=d),c.length!==0&&(this._cachedQuantTables=c),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 c=d.indexOf(255,a-2+i);if(c===-1||c===o-1)return e.rQwait("JPEG",1/0,4),null;if(d.at(c+1)===0||d.at(c+1)>=208&&d.at(c+1)<=215){i=c+2-(a-2);continue}i=c-(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 iv{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:Yt("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 rv{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 iv(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){Yt("Missing key frame. Can't decode until one arrives");continue}if(self._profileIdc===null){Yt("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){Yt("Failed to decode:",o)}}return n!==null&&(n.keep=!0),n}}class lv{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 rv(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 h=i.rQshift32(),v=i.rQshift32();if(i.rQwait("h264 payload",h,8))return!1;v&2?this._resetAllContexts():v&1&&this._resetContext(e,s,n,a);let p=this._getContext(e,s,n,a);if(p.lastUsed=this._tick++,h!==0){let _=i.rQshiftBytes(h,!1),b=p.decode(_);b!==null&&r.videoFrame(e,s,n,a,b)}return!0}}const ov=3,cv="rgb(40, 40, 40)",Bo=17,Do=50,Ro=19,ga=75,hn=50,dv=1e3,uv=50,Io=1,di=2,Qo=6,No=16,_r=19,Uo=22,Ho=30,zo=113,Oo=129,Vo=256,Os=1,Go=1<<24,_i=1<<25,jo=1<<26,ka=1<<27,vi=1<<28;class Oe extends sd{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||gt("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)},Me(">> 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=cv,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 I_,this._cursorImage=Oe.cursors.none,this._decoders[Le.encodingRaw]=new Z_,this._decoders[Le.encodingCopyRect]=new J_,this._decoders[Le.encodingRRE]=new $_,this._decoders[Le.encodingHextile]=new ev,this._decoders[Le.encodingZlib]=new tv,this._decoders[Le.encodingTight]=new Ad,this._decoders[Le.encodingTightPNG]=new sv,this._decoders[Le.encodingZRLE]=new nv,this._decoders[Le.encodingJPEG]=new av,this._decoders[Le.encodingH264]=new lv;try{this._display=new c0(this._canvas)}catch(a){throw gt("Display exception: "+a),a}this._keyboard=new X_(this._canvas),this._keyboard.onkeyevent=this._handleKeyEvent.bind(this),this._remoteCapsLock=null,this._remoteNumLock=null,this._gestures=new R_,this._sock=new Q_,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"),Me("<< 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){Yt("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){gt("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){gt("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||(jt("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=N_[s];if(this._qemuExtKeyEventSupported&&a)e=e||0,jt("Sending key ("+(n?"down":"up")+"): keysym "+e+", scancode "+a),Oe.messages.QEMUExtendedKeyEvent(this._sock,e,n,a);else{if(!e)return;jt("Sending keysym ("+(n?"down":"up")+"): "+e),Oe.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[Os]&&this._clipboardServerCapabilitiesActions[ka])this._clipboardText=e,Oe.messages.extendedClipboardNotify(this._sock,[Os]);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}Oe.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(Me(">> RFB.connect"),this._url)jt(`connecting to ${this._url}`),this._sock.open(this._url,this._wsProtocols);else{if(jt(`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),Me("<< RFB.connect")}_disconnect(){Me(">> 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),Me("<< RFB.disconnect")}_socketOpen(){this._rfbConnectionState==="connecting"&&this._rfbInitState===""?(this._rfbInitState="ProtocolVersion",Me("Starting VNC handshake")):this._fail("Unexpected server connection while "+this._rfbConnectionState)}_socketClose(e){Me("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){Yt("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(),Oe.messages.setDesktopSize(this._sock,Math.floor(e.w),Math.floor(e.h),this._screenID,this._screenFlags),Me("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){Me("Already in state '"+e+"', ignoring");return}if(s==="disconnected"){gt("Tried changing state of a disconnected RFB object");return}switch(e){case"connected":if(s!=="connecting"){gt("Bad transition to connected state, previous connection state: "+s);return}break;case"disconnected":if(s!=="disconnecting"){gt("Bad transition to disconnected state, previous connection state: "+s);return}break;case"connecting":if(s!==""){gt("Bad transition to connecting state, previous connection state: "+s);return}break;case"disconnecting":if(s!=="connected"&&s!=="connecting"){gt("Bad transition to disconnecting state, previous connection state: "+s);return}break;default:gt("Unknown connection state: "+e);return}switch(this._rfbConnectionState=e,Me("New state '"+e+"', was '"+s+"'."),this._disconnTimer&&e!=="disconnecting"&&(Me("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(()=>{gt("Disconnection timed out."),this._updateConnectionState("disconnected")},ov*1e3);break;case"disconnected":this.dispatchEvent(new CustomEvent("disconnect",{detail:{clean:this._rfbCleanDisconnect}}));break}}_fail(e){switch(this._rfbConnectionState){case"disconnecting":gt("Failed when disconnecting: "+e);break;case"connected":gt("Failed while connected: "+e);break;case"connecting":gt("Failed when connecting: "+e);break;default:gt("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)){Yt("handleMessage called on an empty receive queue");return}switch(this._rfbConnectionState){case"disconnected":gt("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:gt("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&&(Me("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&&(Me("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=Oe._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&&o0(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)>ei||Math.abs(r)>ei)&&(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>Bo?(this._sendMouse(e,s,this._mouseButtonMask),this._mouseLastMoveTime=Date.now()):this._mouseMoveTimer=setTimeout(()=>{this._handleDelayedMouseMove()},Bo-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?Oe.messages.extendedPointerEvent(this._sock,this._display.absX(e),this._display.absY(s),n):Oe.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=Oe._convertButtonMask(e.buttons),a=e.deltaX,i=e.deltaY;e.deltaMode!==0&&(a*=Ro,i*=Ro),this._accumulatedWheelDeltaX+=a,this._accumulatedWheelDeltaY+=i,Math.abs(this._accumulatedWheelDeltaX)>=Do&&(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)>=Do&&(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<dv&&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)<uv?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)>ei||Math.abs(i)>ei)&&(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>hn;)this._handleMouseButton(n.x,n.y,8),this._handleMouseButton(n.x,n.y,0),this._gestureLastMagnitudeY+=hn;for(;e.detail.magnitudeY-this._gestureLastMagnitudeY<-hn;)this._handleMouseButton(n.x,n.y,16),this._handleMouseButton(n.x,n.y,0),this._gestureLastMagnitudeY-=hn;for(;e.detail.magnitudeX-this._gestureLastMagnitudeX>hn;)this._handleMouseButton(n.x,n.y,32),this._handleMouseButton(n.x,n.y,0),this._gestureLastMagnitudeX+=hn;for(;e.detail.magnitudeX-this._gestureLastMagnitudeX<-hn;)this._handleMouseButton(n.x,n.y,64),this._handleMouseButton(n.x,n.y,0),this._gestureLastMagnitudeX-=hn;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);jt("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(),Me("Sent ProtocolVersion: "+n),this._rfbInitState="Security"}_isSupportedSecurityType(e){return[Io,di,Qo,No,_r,Uo,Ho,zo,Vo].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);Me("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",Me("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=di,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!==_r&&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=Oe.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=yt.generateKey({name:"DH",g:e,p:n},!1,["deriveBits"]);return this._negotiateARDAuthAsync(s,a,i),!1}async _negotiateARDAuthAsync(e,s,n){const a=yt.exportKey("raw",n.publicKey),i=yt.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 c=await yt.digest("MD5",i),h=await yt.importKey("raw",c,{name:"AES-ECB"},!1,["encrypt"]),v=await yt.encrypt({name:"AES-ECB"},h,d);this._rfbCredentials.ardCredentials=v,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 Me("Server Tight tunnel types: "+n),n[1]&&n[1].vendor==="SICR"&&n[1].signature==="SCHANNEL"&&(Me("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"):(Me("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)}Me("Server Tight authentication types: "+n);for(let a in s)if(n.indexOf(a)!=-1)switch(this._sock.sQpush32(s[a]),this._sock.flush(),Me("Selected authentication type: "+a),a){case"STDVNOAUTH__":return this._rfbInitState="SecurityResult",!0;case"STDVVNCAUTH_":return this._rfbAuthScheme=di,!0;case"TGHTULGNAUTH":return this._rfbAuthScheme=Oo,!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 Y_(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=yt.generateKey({name:"DH",g:e,p:s},!0,["deriveBits"]),i=yt.exportKey("raw",a.publicKey),r=yt.deriveBits({name:"DH",public:n},a.privateKey,64),o=yt.importKey("raw",r,{name:"DES-CBC"},!1,["encrypt"]),d=Js(this._rfbCredentials.username).substring(0,255),c=Js(this._rfbCredentials.password).substring(0,63);let h=new Uint8Array(256),v=new Uint8Array(64);window.crypto.getRandomValues(h),window.crypto.getRandomValues(v);for(let p=0;p<d.length;p++)h[p]=d.charCodeAt(p);h[d.length]=0;for(let p=0;p<c.length;p++)v[p]=c.charCodeAt(p);return v[c.length]=0,h=yt.encrypt({name:"DES-CBC",iv:r},o,h),v=yt.encrypt({name:"DES-CBC",iv:r},o,v),this._sock.sQpushBytes(i),this._sock.sQpushBytes(h),this._sock.sQpushBytes(v),this._sock.flush(),this._rfbInitState="SecurityResult",!0}_negotiateAuthentication(){switch(this._rfbAuthScheme){case Io:return this._rfbVersion>=3.8?this._rfbInitState="SecurityResult":this._rfbInitState="ClientInitialisation",!0;case Uo:return this._negotiateXvpAuth();case Ho:return this._negotiateARDAuth();case di:return this._negotiateStdVNCAuth();case No:return this._negotiateTightAuth();case _r:return this._negotiateVeNCryptAuth();case Vo:return this._negotiatePlainAuth();case Oo:return this._negotiateTightUnixAuth();case Qo:return this._negotiateRA2neAuth();case zo: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",Me("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(),c=this._sock.rQshift16(),h=this._sock.rQshift8(),v=this._sock.rQshift8(),p=this._sock.rQshift8();this._sock.rQskipBytes(3);const _=this._sock.rQshift32();if(this._sock.rQwait("server init name",_,24))return!1;let b=this._sock.rQshiftStr(_);if(b=ji(b,!0),this._rfbTightVNC){if(this._sock.rQwait("TightVNC extended server init header",8,24+_))return!1;const w=this._sock.rQshift16(),y=this._sock.rQshift16(),S=this._sock.rQshift16();this._sock.rQskipBytes(2);const C=(w+y+S)*16;if(this._sock.rQwait("TightVNC extended server init header",C,32+_))return!1;this._sock.rQskipBytes(16*w),this._sock.rQskipBytes(16*y),this._sock.rQskipBytes(16*S)}return jt("Screen: "+e+"x"+s+", bpp: "+n+", depth: "+a+", bigEndian: "+i+", trueColor: "+r+", redMax: "+o+", greenMax: "+d+", blueMax: "+c+", redShift: "+h+", greenShift: "+v+", blueShift: "+p),this._setDesktopName(b),this._resize(e,s),this._viewOnly||this._keyboard.grab(),this._fbDepth=24,this._fbName==="Intel(r) AMT KVM"&&(Yt("Intel AMT KVM only supports 8/16 bit depths. Using low color mode."),this._fbDepth=8),Oe.messages.pixelFormat(this._sock,this._fbDepth,!0),this._sendEncodings(),Oe.messages.fbUpdateRequest(this._sock,!1,0,0,this._fbWidth,this._fbHeight),this._updateConnectionState("connected"),!0}_sendEncodings(){const e=[];e.push(Le.encodingCopyRect),this._fbDepth==24&&(Zc&&e.push(Le.encodingH264),e.push(Le.encodingTight),e.push(Le.encodingTightPNG),e.push(Le.encodingZRLE),e.push(Le.encodingJPEG),e.push(Le.encodingHextile),e.push(Le.encodingRRE),e.push(Le.encodingZlib)),e.push(Le.encodingRaw),e.push(Le.pseudoEncodingQualityLevel0+this._qualityLevel),e.push(Le.pseudoEncodingCompressLevel0+this._compressionLevel),e.push(Le.pseudoEncodingDesktopSize),e.push(Le.pseudoEncodingLastRect),e.push(Le.pseudoEncodingQEMUExtendedKeyEvent),e.push(Le.pseudoEncodingQEMULedEvent),e.push(Le.pseudoEncodingExtendedDesktopSize),e.push(Le.pseudoEncodingXvp),e.push(Le.pseudoEncodingFence),e.push(Le.pseudoEncodingContinuousUpdates),e.push(Le.pseudoEncodingDesktopName),e.push(Le.pseudoEncodingExtendedClipboard),e.push(Le.pseudoEncodingExtendedMouseButtons),this._fbDepth==24&&(e.push(Le.pseudoEncodingVMwareCursor),e.push(Le.pseudoEncodingCursor)),Oe.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 Me("SetColorMapEntries"),this._fail("Unexpected SetColorMapEntries message")}_handleServerCutText(){if(Me("ServerCutText"),this._sock.rQwait("ServerCutText header",7,1))return!1;this._sock.rQskipBytes(3);let e=this._sock.rQshift32();if(e=Xr(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&Go)){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=[Go,_i,jo,ka,vi];Oe.messages.extendedClipboardCaps(this._sock,r,{extendedClipboardFormatText:0})}else if(a===_i){if(this._viewOnly)return!0;this._clipboardText!=null&&this._clipboardServerCapabilitiesActions[vi]&&n&Os&&Oe.messages.extendedClipboardProvide(this._sock,[Os],[this._clipboardText])}else if(a===jo){if(this._viewOnly)return!0;this._clipboardServerCapabilitiesActions[ka]&&(this._clipboardText!=null?Oe.messages.extendedClipboardNotify(this._sock,[Os]):Oe.messages.extendedClipboardNotify(this._sock,[]))}else if(a===ka){if(this._viewOnly)return!0;this._clipboardServerCapabilitiesActions[_i]&&n&Os&&Oe.messages.extendedClipboardRequest(this._sock,[Os])}else if(a===vi){if(this._viewOnly||!(n&Os))return!0;this._clipboardText=null;let r=this._sock.rQshiftBytes(e-4),o=new Ri,d=null;o.setInput(r);for(let c=0;c<=15;c++){let h=1<<c;if(n&h){let v=0,p=o.inflate(4);v|=p[0]<<24,v|=p[1]<<16,v|=p[2]<<8,v|=p[3];let _=o.inflate(v);h===Os&&(d=_)}}if(o.setInput(null),d!==null){let c="";for(let h=0;h<d.length;h++)c+=String.fromCharCode(d[h]);d=c,d=ji(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&&(Yt("Bad payload length ("+s+") in fence response"),s=64);const n=this._sock.rQshiftStr(s);return this._supportsFence=!0,e&1<<31?(e&=3,Oe.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:gt("XVP operation failed");break;case 1:this._rfbXvpVer=e,jt("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&&Oe.messages.fbUpdateRequest(this._sock,!0,0,0,this._fbWidth,this._fbHeight),n;case 1:return this._handleSetColourMapMsg();case 2:return Me("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(),jt("Enabling continuous updates.")),!0;case 248:return this._handleServerFenceMsg();case 250:return this._handleXvpMsg();default:return this._fail("Unexpected server message (type "+e+")"),Me("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 Le.pseudoEncodingLastRect:return this._FBU.rects=1,!0;case Le.pseudoEncodingVMwareCursor:return this._handleVMwareCursor();case Le.pseudoEncodingCursor:return this._handleCursor();case Le.pseudoEncodingQEMUExtendedKeyEvent:return this._qemuExtKeyEventSupported=!0,!0;case Le.pseudoEncodingDesktopName:return this._handleDesktopName();case Le.pseudoEncodingDesktopSize:return this._resize(this._FBU.width,this._FBU.height),!0;case Le.pseudoEncodingExtendedDesktopSize:return this._handleExtendedDesktopSize();case Le.pseudoEncodingExtendedMouseButtons:return this._extendedPointerEventSupported=!0,!0;case Le.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 c=new Array(n*a);for(let v=0;v<n*a;v++)c[v]=this._sock.rQshift32();let h=new Array(n*a);for(let v=0;v<n*a;v++)h[v]=this._sock.rQshift32();for(let v=0;v<n*a;v++)if(c[v]==0){let p=h[v],_=p>>8&255,b=p>>16&255,w=p>>24&255;r[v*o]=_,r[v*o+1]=b,r[v*o+2]=w,r[v*o+3]=255}else(c[v]&-256)==-256?h[v]==0?(r[v*o]=0,r[v*o+1]=0,r[v*o+2]=0,r[v*o+3]=0):(h[v]&-256,r[v*o]=0,r[v*o+1]=0,r[v*o+2]=0,r[v*o+3]=255):(r[v*o]=0,r[v*o+1]=0,r[v*o+2]=0,r[v*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 c=this._sock.rQshift32();r[d*4]=c>>24&255,r[d*4+1]=c>>16&255,r[d*4+2]=c>>8&255,r[d*4+3]=c&255}}else return Yt("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),c=this._sock.rQshiftBytes(r);let h=new Uint8Array(n*a*4),v=0;for(let p=0;p<a;p++)for(let _=0;_<n;_++){let b=p*Math.ceil(n/8)+Math.floor(_/8),w=c[b]<<_%8&128?255:0;h[v]=d[v+2],h[v+1]=d[v+1],h[v+2]=d[v],h[v+3]=w,v+=4}return this._updateCursor(h,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=ji(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}Yt("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&&Oe.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||(jt("Sending XVP operation "+s+" (version "+e+")"),Oe.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()?Oe.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=yt.importKey("raw",n,{name:"DES-ECB"},!1,["encrypt"]);return yt.encrypt({name:"DES-ECB"},a,s)}}Oe.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 A_,a=[];for(let o=0;o<e.length;o++){if(e[o]!=Os)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 c=0;c<d.length;c++)a.push(d.charCodeAt(c))}let i=n.deflate(new Uint8Array(a)),r=new Uint8Array(4+i.length);r.set(Oe.messages._buildExtendedClipboardFlags([vi],e)),r.set(i,4),Oe.messages.clientCutText(t,r,!0)},extendedClipboardNotify(t,e){let s=Oe.messages._buildExtendedClipboardFlags([ka],e);Oe.messages.clientCutText(t,s,!0)},extendedClipboardRequest(t,e){let s=Oe.messages._buildExtendedClipboardFlags([_i],e);Oe.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(Oe.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];Oe.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=n0(-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()}};Oe.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 hv=K('<div class="loading svelte-138orkn">Loading...</div>'),fv=K('<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>'),_v=K('<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>'),vv=K('<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>'),pv=K('<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="2" y="4" width="20" height="16" rx="2" class="svelte-138orkn"></rect><line x1="6" y1="8" x2="6" y2="8" class="svelte-138orkn"></line><line x1="10" y1="8" x2="10" y2="8" class="svelte-138orkn"></line><line x1="14" y1="8" x2="14" y2="8" class="svelte-138orkn"></line><line x1="18" y1="8" x2="18" y2="8" class="svelte-138orkn"></line><line x1="6" y1="12" x2="6" y2="12" class="svelte-138orkn"></line><line x1="10" y1="12" x2="10" y2="12" class="svelte-138orkn"></line><line x1="14" y1="12" x2="14" y2="12" class="svelte-138orkn"></line><line x1="18" y1="12" x2="18" y2="12" class="svelte-138orkn"></line><line x1="8" y1="16" x2="16" y2="16" class="svelte-138orkn"></line></svg> Keyboard</button> <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>'),gv=K('<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>'),bv=K('<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>'),xv=K('<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"><textarea class="kb-input svelte-138orkn" autocapitalize="off" autocomplete="off"></textarea> <!> <!> <div></div></div></div>');function mv(t,e){dt(e,!0);let s=G(null),n=G(!0),a=G("connecting"),i=G(void 0),r=G(0),o=G(null),d=G(!1),c=G(""),h=G(!1),v=G(!1),p=G(void 0);const _=Ke(()=>e.status?.browser.enabled??!1),b={connecting:"Connecting",connected:"Connected",disconnected:"Disconnected",failed:"Failed"},w=Ke(()=>b[l(a)]);xt(()=>{const T=new AbortController;return Se("/api/config").then(q=>{T.signal.aborted||g(s,q,!0)}).finally(()=>{T.signal.aborted||g(n,!1)}),()=>T.abort()});const y=Ke(()=>{if(!l(s)?.browser)return"";const T=Li(),q=T?`?token=${encodeURIComponent(T)}`:"";return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/vnc${q}`});xt(()=>{if(!l(_)||!l(y)||!l(i)||l(r)<0)return;g(a,"connecting");let T=null;try{T=new Oe(l(i),l(y)),T.scaleViewport=!0,T.resizeSession=!1,T.qualityLevel=5,T.compressionLevel=2,g(o,T,!0),T.addEventListener("connect",()=>{g(a,"connected")}),T.addEventListener("disconnect",q=>{const $=q.detail;g(a,$.clean?"disconnected":"failed",!0),g(o,null),g(v,!1),l(p)?.blur()})}catch{g(a,"failed"),g(o,null)}return()=>{T?.disconnect(),g(o,null),g(v,!1)}});function S(){g(a,"connecting"),g(r,l(r)+1)}function C(){l(o)?.disconnect()}function A(){g(d,!l(d)),g(c,"")}function E(){l(o)&&l(o).clipboardPasteFrom(l(c))}function H(T){const q=T.codePointAt(0);return q>=32&&q<=255?q:16777216|q}const ae={Backspace:65288,Enter:65293,Tab:65289,Escape:65307,ArrowUp:65362,ArrowDown:65364,ArrowLeft:65361,ArrowRight:65363,Delete:65535,Home:65360,End:65367};function M(){l(o)&&(g(v,!l(v)),l(v)?(l(o).focusOnClick=!1,l(p)?.focus()):(l(o).focusOnClick=!0,l(p)?.blur()))}function X(T){if(!l(o)||!l(p))return;const q=T.data;if(q)for(const $ of q)l(o).sendKey(H($),null);l(p).value=""}function j(T,q){if(!l(o))return;const $=ae[T.key];$&&(T.preventDefault(),l(o).sendKey($,T.code||null,q))}var z=kt(),oe=Ce(z);{var re=T=>{var q=hv();k(T,q)},ce=T=>{var q=fv();k(T,q)},J=T=>{var q=xv(),$=u(q),pe=u($),ye=u(pe),we=u(ye);let Xe;var Ne=f(we,2),ne=u(Ne),R=f(ye,2);{var se=fe=>{var Re=_v(),Te=u(Re),Je=f(u(Te),2),Ue=u(Je),Ve=f(Te,2),it=f(u(Ve),2),ke=u(it);V(()=>{F(Ue,l(s).browser.vncPort),F(ke,l(s).browser.novncPort)}),k(fe,Re)};O(R,fe=>{l(h)&&l(s)?.browser&&fe(se)})}var ue=f(pe,2);{var de=fe=>{var Re=pv(),Te=f(u(Re),2);let Je;var Ue=f(Te,2);let Ve;var it=f(Ue,2);{var ke=He=>{var rt=vv();U("click",rt,C),k(He,rt)};O(it,He=>{l(a)==="connected"&&He(ke)})}V(()=>{Je=me(Te,1,"toolbar-btn toolbar-btn-kb svelte-138orkn",null,Je,{"toolbar-btn-active":l(v)}),Te.disabled=l(a)!=="connected",Ve=me(Ue,1,"toolbar-btn svelte-138orkn",null,Ve,{"toolbar-btn-active":l(d)}),Ue.disabled=l(a)!=="connected"}),U("click",Te,M),U("click",Ue,A),k(fe,Re)};O(ue,fe=>{l(s)?.browser&&fe(de)})}var ve=f($,2),be=u(ve);It(be,"spellcheck",!1),ml(be,fe=>g(p,fe),()=>l(p));var Z=f(be,2);{var he=fe=>{var Re=gv(),Te=f(u(Re),2);It(Te,"rows",4),U("input",Te,E),je(Te,()=>l(c),Je=>g(c,Je)),k(fe,Re)};O(Z,fe=>{l(d)&&fe(he)})}var W=f(Z,2);{var ee=fe=>{var Re=bv(),Te=u(Re),Je=u(Te),Ue=f(Te,4);V(()=>F(Je,l(a)==="failed"?"Connection failed":"Disconnected")),U("click",Ue,S),k(fe,Re)};O(W,fe=>{(l(a)==="failed"||l(a)==="disconnected")&&fe(ee)})}var ge=f(W,2);let Ee;ml(ge,fe=>g(i,fe),()=>l(i)),V(()=>{Xe=me(we,1,"conn-dot svelte-138orkn",null,Xe,{"conn-connecting":l(a)==="connecting","conn-on":l(a)==="connected","conn-off":l(a)==="disconnected"||l(a)==="failed"}),F(ne,l(w)),Ee=me(ge,1,"vnc-canvas svelte-138orkn",null,Ee,{"vnc-hidden":l(a)!=="connected"})}),U("click",ye,()=>{g(h,!l(h))}),U("touchstart",ve,fe=>{l(v)&&fe.target!==l(p)&&fe.preventDefault()}),U("input",be,X),U("keydown",be,fe=>j(fe,!0)),U("keyup",be,fe=>j(fe,!1)),k(T,q)};O(oe,T=>{l(n)?T(re):l(_)?T(J,!1):T(ce,1)})}k(t,z),ut()}bt(["click","touchstart","input","keydown","keyup"]);var yv=K('<button class="val-btn agent-name editable svelte-ys3ftv"> </button>'),wv=K('<button class="btn btn-outline btn-sm btn-danger">Delete</button>'),kv=K('<button class="val-btn mono editable"> </button>'),Sv=K('<button class="val-btn mono editable"> </button>'),Cv=K('<button class="val-btn mono editable"> </button>'),Ev=K('<button class="val-btn mono editable"> </button>'),Av=K('<button class="val-btn mono editable"> </button>'),Kv=K('<button class="prompt-block editable svelte-ys3ftv"> </button>'),Fv=K('<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 Tv(t,e){dt(e,!0);let s=G("");function n(W,ee){g(s,String(ee),!0),e.editor.startEdit(`agent.${e.index}.${W}`,ee)}function a(W){return e.editor.editingField===`agent.${e.index}.${W}`}var i=Fv(),r=f(u(i),2),o=u(r),d=u(o);{var c=W=>{wt(W,{get saving(){return e.editor.editingSaving},onsave:ee=>e.onsavefield("name",ee),get oncancel(){return e.editor.cancelEdit},get value(){return l(s)},set value(ee){g(s,ee,!0)}})},h=Ke(()=>a("name")),v=W=>{var ee=yv(),ge=u(ee);V(()=>F(ge,e.agent.name)),U("click",ee,()=>n("name",e.agent.name)),k(W,ee)};O(d,W=>{l(h)?W(c):W(v,!1)})}var p=f(d,2),_=u(p),b=f(o,2),w=u(b);{var y=W=>{var ee=wv();U("click",ee,function(...ge){e.ondelete?.apply(this,ge)}),k(W,ee)};O(w,W=>{e.agentCount>1&&W(y)})}var S=f(r,2),C=u(S),A=f(u(C),2);{var E=W=>{wt(W,{mono:!0,get saving(){return e.editor.editingSaving},onsave:ee=>e.onsavefield("model",ee),get oncancel(){return e.editor.cancelEdit},get value(){return l(s)},set value(ee){g(s,ee,!0)}})},H=Ke(()=>a("model")),ae=W=>{var ee=kv(),ge=u(ee);V(()=>F(ge,e.agent.model)),U("click",ee,()=>n("model",e.agent.model)),k(W,ee)};O(A,W=>{l(H)?W(E):W(ae,!1)})}var M=f(C,2),X=f(u(M),2);{var j=W=>{wt(W,{mono:!0,get saving(){return e.editor.editingSaving},placeholder:"none",onsave:ee=>e.onsavefield("fallbackModel",ee,ge=>ge.trim()||null),get oncancel(){return e.editor.cancelEdit},get value(){return l(s)},set value(ee){g(s,ee,!0)}})},z=Ke(()=>a("fallbackModel")),oe=W=>{var ee=Sv(),ge=u(ee);V(()=>F(ge,e.agent.fallbackModel??"none")),U("click",ee,()=>n("fallbackModel",e.agent.fallbackModel??"")),k(W,ee)};O(X,W=>{l(z)?W(j):W(oe,!1)})}var re=f(M,2),ce=f(u(re),2);{var J=W=>{wt(W,{mono:!0,get saving(){return e.editor.editingSaving},onsave:ee=>e.onsavefield("maxTurns",ee,ge=>Number(ge)),get oncancel(){return e.editor.cancelEdit},get value(){return l(s)},set value(ee){g(s,ee,!0)}})},T=Ke(()=>a("maxTurns")),q=W=>{var ee=Cv(),ge=u(ee);V(()=>F(ge,e.agent.maxTurns)),U("click",ee,()=>n("maxTurns",e.agent.maxTurns)),k(W,ee)};O(ce,W=>{l(T)?W(J):W(q,!1)})}var $=f(re,2),pe=f(u($),2);{var ye=W=>{wt(W,{mono:!0,get saving(){return e.editor.editingSaving},placeholder:"global",onsave:ee=>e.onsavefield("processTimeoutMs",ee,ge=>{const Ee=ge.trim();return Ee?Number(Ee)*1e3:null}),get oncancel(){return e.editor.cancelEdit},get value(){return l(s)},set value(ee){g(s,ee,!0)}})},we=Ke(()=>a("processTimeoutMs")),Xe=W=>{var ee=Ev(),ge=u(ee);V(()=>F(ge,e.agent.processTimeoutMs?`${e.agent.processTimeoutMs/1e3}s`:"global")),U("click",ee,()=>n("processTimeoutMs",e.agent.processTimeoutMs?String(e.agent.processTimeoutMs/1e3):"")),k(W,ee)};O(pe,W=>{l(we)?W(ye):W(Xe,!1)})}var Ne=f($,2),ne=f(u(Ne),2);{var R=W=>{wt(W,{mono:!0,get saving(){return e.editor.editingSaving},onsave:ee=>e.onsavefield("channels",ee,ge=>ge.split(",").map(Ee=>Ee.trim()).filter(Boolean)),get oncancel(){return e.editor.cancelEdit},get value(){return l(s)},set value(ee){g(s,ee,!0)}})},se=Ke(()=>a("channels")),ue=W=>{var ee=Av(),ge=u(ee);V(Ee=>F(ge,Ee),[()=>e.agent.channels.join(", ")||"*"]),U("click",ee,()=>n("channels",e.agent.channels.join(", "))),k(W,ee)};O(ne,W=>{l(se)?W(R):W(ue,!1)})}var de=f(S,2),ve=f(u(de),2);{var be=W=>{wt(W,{multiline:!0,get saving(){return e.editor.editingSaving},onsave:ee=>e.onsavefield("systemPrompt",ee),get oncancel(){return e.editor.cancelEdit},get value(){return l(s)},set value(ee){g(s,ee,!0)}})},Z=Ke(()=>a("systemPrompt")),he=W=>{var ee=Kv(),ge=u(ee);V(()=>F(ge,e.agent.systemPrompt)),U("click",ee,()=>n("systemPrompt",e.agent.systemPrompt)),k(W,ee)};O(ve,W=>{l(Z)?W(be):W(he,!1)})}V(()=>F(_,e.agent.id)),k(t,i),ut()}bt(["click"]);var Mv=K('<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 Xv(t,e){dt(e,!0);let s=G(Ye({name:"",model:"",maxTurns:"50",systemPrompt:"",channels:"*"}));function n(H){return H.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}async function a(){const H=n(l(s).name)||"agent",ae=l(s).channels.split(",").map(j=>j.trim()).filter(Boolean),M={id:H,name:l(s).name,model:l(s).model,fallbackModel:null,maxTurns:Number(l(s).maxTurns)||50,systemPrompt:l(s).systemPrompt||"You are responding in a Slack workspace. Be concise, helpful, and natural.",channels:ae.length>0?ae:["*"]};await e.onsave(M)&&g(s,{name:"",model:"",maxTurns:"50",systemPrompt:"",channels:"*"},!0)}var i=Mv(),r=f(u(i),2),o=f(u(r),2),d=f(r,2),c=u(d),h=f(u(c),2),v=f(c,2),p=f(u(v),2),_=f(v,2),b=f(u(_),2),w=f(_,2),y=f(u(w),2),S=f(w,2),C=f(u(S),2),A=f(S,2),E=u(A);V(H=>E.disabled=H,[()=>!l(s).name.trim()||!l(s).model.trim()]),U("click",o,function(...H){e.oncancel?.apply(this,H)}),je(h,()=>l(s).name,H=>l(s).name=H),je(p,()=>l(s).model,H=>l(s).model=H),je(b,()=>l(s).maxTurns,H=>l(s).maxTurns=H),je(y,()=>l(s).channels,H=>l(s).channels=H),je(C,()=>l(s).systemPrompt,H=>l(s).systemPrompt=H),U("click",E,a),k(t,i),ut()}bt(["click"]);var Lv=K('<button class="btn btn-outline btn-sm">Add Agent</button>'),Pv=K('<div class="section"><div class="section-header"><h2 class="section-title">Agents</h2> <!></div> <!> <!></div>');function Bv(t,e){dt(e,!0);let s=G(!1);async function n(_,b,w,y){const S=e.config.agents.map(H=>({...H})),C=S[_];if(!C)return;const A=y?y(w):w;C[b]=A,await e.editor.saveConfigPatch({agents:S})&&e.editor.cancelEdit()}async function a(_){if(e.config.agents.length<=1)return;const b=e.config.agents[_];if(!b||!await Bi(`Delete agent "${b.name}"?`))return;const y=e.config.agents.filter((S,C)=>C!==_);await e.editor.saveConfigPatch({agents:y})}async function i(_){const b=[...e.config.agents,_],w=await e.editor.saveConfigPatch({agents:b});return w&&g(s,!1),w}var r=Pv(),o=u(r),d=f(u(o),2);{var c=_=>{var b=Lv();U("click",b,()=>{g(s,!0)}),k(_,b)};O(d,_=>{l(s)||_(c)})}var h=f(o,2);Ct(h,19,()=>e.config.agents,_=>_.id,(_,b,w)=>{Tv(_,{get agent(){return l(b)},get index(){return l(w)},get agentCount(){return e.config.agents.length},get editor(){return e.editor},onsavefield:(y,S,C)=>n(l(w),y,S,C),ondelete:()=>a(l(w))})});var v=f(h,2);{var p=_=>{Xv(_,{onsave:i,oncancel:()=>{g(s,!1)}})};O(v,_=>{l(s)&&_(p)})}k(t,r),ut()}bt(["click"]);var Dv=K('<div class="row"><span class="row-label">Uptime</span> <span class="row-value mono"> </span></div>'),Rv=K('<button class="val-btn mono editable"> </button>'),Iv=K('<span class="cli-pill svelte-u0w225"><span class="dot dot-muted"></span> claude ...</span>'),Qv=K('<span class="cli-pill cli-pill-ok svelte-u0w225"><span class="dot dot-on"></span> </span>'),Nv=K('<span class="cli-pill cli-pill-err svelte-u0w225"><span class="dot dot-off"></span> claude not found</span>'),Uv=K('<div class="row"><span class="row-label">Node.js</span> <span class="row-value mono"> </span></div>'),Hv=Is('<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>'),zv=K('<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>'),Ov=K('<button class="val-btn mono editable"> </button>'),Vv=K('<span class="dim">...</span>'),Gv=K('<button class="val-btn mono editable"> </button>'),jv=K('<button class="val-btn mono editable"> </button>'),Wv=K('<button class="val-btn mono editable"> </button>'),qv=K("<span><span></span> </span>"),Yv=Is('<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>'),Zv=K('<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>'),Jv=K('<button class="val-btn mono editable"> </button>'),$v=K('<span class="dim">...</span>'),ep=K('<div class="row"><span class="row-label"> </span> <span class="row-value"><!></span></div>'),tp=K('<button class="val-btn mono editable"> </button>'),sp=K('<button class="val-btn mono editable"> </button>'),np=K('<button class="val-btn mono editable"> </button>'),ap=K('<button class="val-btn mono editable"> </button>'),ip=K('<div class="row"><span class="row-label">Start / End</span> <span class="row-value"><!> <span class="dim">–</span> <!></span></div>'),rp=K("<span><span></span> </span>"),lp=K('<button class="val-btn mono editable"> </button>'),op=K('<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),cp=K('<button class="val-btn mono editable"> </button>'),dp=K('<button class="val-btn mono editable"> </button>'),up=K('<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 hp(t,e){dt(e,!0);let s=G("");function n(ie,te){g(s,String(te),!0),e.editor.startEdit(ie,te)}let a=G(null),i=G(""),r=G(!1);function o(ie){g(a,ie,!0),g(i,"")}function d(){g(a,null),g(r,!1)}async function c(){if(!(!l(a)||!l(i).trim())){g(r,!0);try{if(l(a)==="slackBotToken"||l(a)==="slackAppToken"){const ie=l(a)==="slackBotToken"?{botToken:l(i).trim()}:{appToken:l(i).trim()};await Se("/api/secrets/slack",{method:"PUT",body:ie}),Ae("Slack token saved","success")}else await Se("/api/secrets/anthropic",{method:"PUT",body:{apiKey:l(i).trim()}}),Ae("API key saved (effective next session)","success");g(a,null),g(i,""),e.onsecretsupdate()}catch(ie){Ae(ie.message,"error")}finally{g(r,!1)}}}function h(ie){ie.key==="Escape"?d():ie.key==="Enter"&&(ie.preventDefault(),c())}var v=up(),p=Ce(v),_=u(p),b=f(u(_),2),w=u(b);{var y=ie=>{var te=Dv(),_e=f(u(te),2),$e=u(_e);V(mt=>F($e,mt),[()=>Uh(e.status.uptime)]),k(ie,te)};O(w,ie=>{e.status&&ie(y)})}var S=f(w,2),C=f(u(S),2),A=u(C);{var E=ie=>{wt(ie,{mono:!0,get saving(){return e.editor.editingSaving},onsave:te=>e.editor.saveField("timezone",te),get oncancel(){return e.editor.cancelEdit},get value(){return l(s)},set value(te){g(s,te,!0)}})},H=ie=>{var te=Rv(),_e=u(te);V(()=>F(_e,e.config.timezone)),U("click",te,()=>n("timezone",e.config.timezone)),k(ie,te)};O(A,ie=>{e.editor.editingField==="timezone"?ie(E):ie(H,!1)})}var ae=f(S,2),M=f(u(ae),2),X=u(M),j=f(ae,2),z=f(u(j),2),oe=u(z);{var re=ie=>{var te=Iv();k(ie,te)},ce=ie=>{var te=kt(),_e=Ce(te);{var $e=Kt=>{var ds=Qv(),Ks=f(u(ds));V(()=>F(Ks,` claude ${e.doctor.claude.version??""}`)),k(Kt,ds)},mt=Kt=>{var ds=Nv();k(Kt,ds)};O(_e,Kt=>{e.doctor.claude.available?Kt($e):Kt(mt,!1)})}k(ie,te)};O(oe,ie=>{e.doctorLoading?ie(re):e.doctor&&ie(ce,1)})}var J=f(j,2);{var T=ie=>{var te=Uv(),_e=f(u(te),2),$e=u(_e);V(()=>F($e,e.doctor.node)),k(ie,te)};O(J,ie=>{e.doctor&&ie(T)})}var q=f(J,2),$=f(u(q),2),pe=u($);{var ye=ie=>{var te=zv(),_e=u(te),$e=f(_e,2),mt=u($e);{var Kt=ts=>{var qs=Xs("...");k(ts,qs)},ds=ts=>{var qs=Hv();k(ts,qs)};O(mt,ts=>{l(r)?ts(Kt):ts(ds,!1)})}var Ks=f($e,2);V(()=>$e.disabled=l(r)||!l(i)),U("keydown",_e,h),je(_e,()=>l(i),ts=>g(i,ts)),U("click",$e,c),U("click",Ks,d),k(ie,te)},we=ie=>{var te=Ov(),_e=u(te);V(()=>F(_e,e.secrets.anthropic.set?e.secrets.anthropic.hint:"not set")),U("click",te,()=>o("apiKey")),k(ie,te)},Xe=ie=>{var te=Vv();k(ie,te)};O(pe,ie=>{l(a)==="apiKey"?ie(ye):e.secrets?ie(we,1):ie(Xe,!1)})}var Ne=f(_,2),ne=f(u(Ne),2),R=u(ne),se=f(u(R),2),ue=u(se);{var de=ie=>{wt(ie,{mono:!0,get saving(){return e.editor.editingSaving},onsave:te=>e.editor.saveField("sessions.maxConcurrent",te,_e=>Number(_e)),get oncancel(){return e.editor.cancelEdit},get value(){return l(s)},set value(te){g(s,te,!0)}})},ve=ie=>{var te=Gv(),_e=u(te);V(()=>F(_e,e.config.sessions.maxConcurrent)),U("click",te,()=>n("sessions.maxConcurrent",e.config.sessions.maxConcurrent)),k(ie,te)};O(ue,ie=>{e.editor.editingField==="sessions.maxConcurrent"?ie(de):ie(ve,!1)})}var be=f(R,2),Z=f(u(be),2),he=u(Z);{var W=ie=>{wt(ie,{mono:!0,get saving(){return e.editor.editingSaving},onsave:te=>e.editor.saveField("sessions.ttlHours",te,_e=>Number(_e)),get oncancel(){return e.editor.cancelEdit},get value(){return l(s)},set value(te){g(s,te,!0)}})},ee=ie=>{var te=jv(),_e=u(te);V(()=>F(_e,`${e.config.sessions.ttlHours??""}h`)),U("click",te,()=>n("sessions.ttlHours",e.config.sessions.ttlHours)),k(ie,te)};O(he,ie=>{e.editor.editingField==="sessions.ttlHours"?ie(W):ie(ee,!1)})}var ge=f(be,2),Ee=f(u(ge),2),fe=u(Ee);{var Re=ie=>{wt(ie,{mono:!0,get saving(){return e.editor.editingSaving},onsave:te=>e.editor.saveField("sessions.processTimeoutMs",te,_e=>Math.round(Number(_e)*1e3)),get oncancel(){return e.editor.cancelEdit},get value(){return l(s)},set value(te){g(s,te,!0)}})},Te=ie=>{var te=Wv(),_e=u(te);V($e=>F(_e,`${$e??""}s`),[()=>(e.config.sessions.processTimeoutMs/1e3).toFixed(0)]),U("click",te,()=>n("sessions.processTimeoutMs",(e.config.sessions.processTimeoutMs/1e3).toFixed(0))),k(ie,te)};O(fe,ie=>{e.editor.editingField==="sessions.processTimeoutMs"?ie(Re):ie(Te,!1)})}var Je=f(Ne,2),Ue=u(Je),Ve=f(u(Ue),2);{var it=ie=>{var te=qv();let _e;var $e=u(te);let mt;var Kt=f($e);V(()=>{_e=me(te,1,"svc-chip",null,_e,{"svc-chip-ok":e.status.slack.connected,"svc-chip-err":!e.status.slack.connected}),mt=me($e,1,"dot",null,mt,{"dot-on":e.status.slack.connected,"dot-off":!e.status.slack.connected}),F(Kt,` ${e.status.slack.connected?"connected":"disconnected"}`)}),k(ie,te)};O(Ve,ie=>{e.status&&ie(it)})}var ke=f(Ue,2);{const ie=(te,_e=ba,$e=ba,mt=ba,Kt=ba)=>{var ds=ep(),Ks=u(ds),ts=u(Ks),qs=f(Ks,2),Xt=u(qs);{var Tt=Fs=>{var Us=Zv(),us=u(Us),bs=f(us,2),zi=u(bs);{var Fd=dn=>{var Oi=Xs("...");k(dn,Oi)},Td=dn=>{var Oi=Yv();k(dn,Oi)};O(zi,dn=>{l(r)?dn(Fd):dn(Td,!1)})}var Md=f(bs,2);V(()=>{It(us,"placeholder",mt()),bs.disabled=l(r)||!l(i)}),U("keydown",us,h),je(us,()=>l(i),dn=>g(i,dn)),U("click",bs,c),U("click",Md,d),k(Fs,Us)},En=Fs=>{var Us=Jv(),us=u(Us);V(()=>F(us,Kt().set?Kt().hint:"not set")),U("click",Us,()=>o(_e())),k(Fs,Us)},Hi=Fs=>{var Us=$v();k(Fs,Us)};O(Xt,Fs=>{l(a)===_e()?Fs(Tt):Kt()?Fs(En,1):Fs(Hi,!1)})}V(()=>F(ts,$e())),k(te,ds)};var He=u(ke);ie(He,()=>"slackBotToken",()=>"Bot Token",()=>"xoxb-...",()=>e.secrets?.slack.botToken);var rt=f(He,2);ie(rt,()=>"slackAppToken",()=>"App Token",()=>"xapp-...",()=>e.secrets?.slack.appToken);var Jt=f(rt,2),Wt=f(u(Jt),2),rs=u(Wt);Ln(rs,{get active(){return e.config.slack.requireMention},onToggle:()=>e.editor.toggleField("slack.requireMention",e.config.slack.requireMention)});var ls=f(Jt,2),St=f(u(ls),2),$t=u(St);{var es=te=>{wt(te,{mono:!0,get saving(){return e.editor.editingSaving},onsave:_e=>e.editor.saveField("slack.coalesce.debounceMs",_e,$e=>Number($e)),get oncancel(){return e.editor.cancelEdit},get value(){return l(s)},set value(_e){g(s,_e,!0)}})},os=te=>{var _e=tp(),$e=u(_e);V(()=>F($e,`${e.config.slack.coalesce.debounceMs??""}ms`)),U("click",_e,()=>n("slack.coalesce.debounceMs",e.config.slack.coalesce.debounceMs)),k(te,_e)};O($t,te=>{e.editor.editingField==="slack.coalesce.debounceMs"?te(es):te(os,!1)})}var ps=f(ls,2),gs=f(u(ps),2),cs=u(gs);Ln(cs,{get active(){return e.config.slack.coalesce.bypassDms},onToggle:()=>e.editor.toggleField("slack.coalesce.bypassDms",e.config.slack.coalesce.bypassDms)});var Cs=f(ps,2),Es=f(u(Cs),2),As=u(Es);{var tt=te=>{wt(te,{mono:!0,get saving(){return e.editor.editingSaving},onsave:_e=>e.editor.saveField("slack.channels",_e,$e=>$e.split(",").map(mt=>mt.trim()).filter(Boolean)),get oncancel(){return e.editor.cancelEdit},get value(){return l(s)},set value(_e){g(s,_e,!0)}})},st=te=>{var _e=sp(),$e=u(_e);V(mt=>F($e,mt),[()=>e.config.slack.channels.join(", ")||"*"]),U("click",_e,()=>n("slack.channels",e.config.slack.channels.join(", "))),k(te,_e)};O(As,te=>{e.editor.editingField==="slack.channels"?te(tt):te(st,!1)})}var ht=f(Cs,2),ft=f(u(ht),2),Pe=u(ft);Ln(Pe,{get active(){return e.config.slack.quietHours.enabled},onToggle:()=>e.editor.toggleField("slack.quietHours.enabled",e.config.slack.quietHours.enabled)});var Be=f(ht,2);{var Fe=te=>{var _e=ip(),$e=f(u(_e),2),mt=u($e);{var Kt=Xt=>{wt(Xt,{mono:!0,get saving(){return e.editor.editingSaving},placeholder:"HH:MM",onsave:Tt=>e.editor.saveField("slack.quietHours.start",Tt),get oncancel(){return e.editor.cancelEdit},get value(){return l(s)},set value(Tt){g(s,Tt,!0)}})},ds=Xt=>{var Tt=np(),En=u(Tt);V(()=>F(En,e.config.slack.quietHours.start)),U("click",Tt,()=>n("slack.quietHours.start",e.config.slack.quietHours.start)),k(Xt,Tt)};O(mt,Xt=>{e.editor.editingField==="slack.quietHours.start"?Xt(Kt):Xt(ds,!1)})}var Ks=f(mt,4);{var ts=Xt=>{wt(Xt,{mono:!0,get saving(){return e.editor.editingSaving},placeholder:"HH:MM",onsave:Tt=>e.editor.saveField("slack.quietHours.end",Tt),get oncancel(){return e.editor.cancelEdit},get value(){return l(s)},set value(Tt){g(s,Tt,!0)}})},qs=Xt=>{var Tt=ap(),En=u(Tt);V(()=>F(En,e.config.slack.quietHours.end)),U("click",Tt,()=>n("slack.quietHours.end",e.config.slack.quietHours.end)),k(Xt,Tt)};O(Ks,Xt=>{e.editor.editingField==="slack.quietHours.end"?Xt(ts):Xt(qs,!1)})}k(te,_e)};O(Be,te=>{e.config.slack.quietHours.enabled&&te(Fe)})}}var We=f(Je,2),Ie=u(We),Y=f(u(Ie),2);{var le=ie=>{var te=rp();let _e;var $e=u(te);let mt;var Kt=f($e);V(()=>{_e=me(te,1,"svc-chip",null,_e,{"svc-chip-ok":e.status.browser.connected,"svc-chip-err":!e.status.browser.connected}),mt=me($e,1,"dot",null,mt,{"dot-on":e.status.browser.connected,"dot-off":!e.status.browser.connected}),F(Kt,` ${e.status.browser.connected?"connected":"unreachable"}`)}),k(ie,te)};O(Y,ie=>{e.config.browser.enabled&&e.status&&ie(le)})}var xe=f(Ie,2),De=u(xe),ze=f(u(De),2),Ge=u(ze);Ln(Ge,{get active(){return e.config.browser.enabled},onToggle:()=>e.editor.toggleField("browser.enabled",e.config.browser.enabled)});var lt=f(De,2);{var ct=ie=>{var te=op(),_e=Ce(te),$e=f(u(_e),2),mt=u($e);{var Kt=us=>{wt(us,{mono:!0,get saving(){return e.editor.editingSaving},onsave:bs=>e.editor.saveField("browser.novncHost",bs),get oncancel(){return e.editor.cancelEdit},get value(){return l(s)},set value(bs){g(s,bs,!0)}})},ds=us=>{var bs=lp(),zi=u(bs);V(()=>F(zi,e.config.browser.novncHost)),U("click",bs,()=>n("browser.novncHost",e.config.browser.novncHost)),k(us,bs)};O(mt,us=>{e.editor.editingField==="browser.novncHost"?us(Kt):us(ds,!1)})}var Ks=f(_e,2),ts=f(u(Ks),2),qs=u(ts),Xt=f(Ks,2),Tt=f(u(Xt),2),En=u(Tt),Hi=f(Xt,2),Fs=f(u(Hi),2),Us=u(Fs);V(()=>{F(qs,e.config.browser.mode),F(En,e.config.browser.vncPort),F(Us,e.config.browser.novncPort)}),k(ie,te)};O(lt,ie=>{e.config.browser.enabled&&ie(ct)})}var Ft=f(We,2),At=f(u(Ft),2),Ut=u(At),Qs=f(u(Ut),2),Qe=u(Qs);{var ot=ie=>{wt(ie,{mono:!0,get saving(){return e.editor.editingSaving},onsave:te=>e.editor.saveField("birds.maxAttempts",te,_e=>Number(_e)),get oncancel(){return e.editor.cancelEdit},get value(){return l(s)},set value(te){g(s,te,!0)}})},_t=ie=>{var te=cp(),_e=u(te);V(()=>F(_e,e.config.birds.maxAttempts)),U("click",te,()=>n("birds.maxAttempts",e.config.birds.maxAttempts)),k(ie,te)};O(Qe,ie=>{e.editor.editingField==="birds.maxAttempts"?ie(ot):ie(_t,!1)})}var Ht=f(Ft,2),qt=f(u(Ht),2),Cn=u(qt),Ws=f(u(Cn),2),Ns=u(Ws);{var ca=ie=>{wt(ie,{mono:!0,get saving(){return e.editor.editingSaving},onsave:te=>e.editor.saveField("database.retentionDays",te,_e=>Number(_e)),get oncancel(){return e.editor.cancelEdit},get value(){return l(s)},set value(te){g(s,te,!0)}})},Ui=ie=>{var te=dp(),_e=u(te);V(()=>F(_e,`${e.config.database.retentionDays??""} days`)),U("click",te,()=>n("database.retentionDays",e.config.database.retentionDays)),k(ie,te)};O(Ns,ie=>{e.editor.editingField==="database.retentionDays"?ie(ca):ie(Ui,!1)})}var Kd=f(p,2);Bv(Kd,{get config(){return e.config},get editor(){return e.editor}}),V(()=>F(X,e.config.web.port)),k(t,v),ut()}bt(["click","keydown"]);var fp=K('<span class="queue-summary mono svelte-17vayue"> </span>'),_p=K('<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>'),vp=K('<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 pp(t,e){dt(e,!0);let s=G(null);xt(()=>{e.initialStats!=null&&g(s,e.initialStats,!0)});let n=G(!1),a=G(!1),i=G(!1);async function r(){g(s,await Se("/api/jobs/stats"),!0)}async function o(){g(n,!0);try{const X=await Se("/api/jobs/retry-all",{method:"POST"});Ae(`${X.count} failed job(s) queued for retry`,"success"),await r()}catch(X){Ae(`Failed: ${X.message}`,"error")}finally{g(n,!1)}}async function d(){g(a,!0);try{const X=await Se("/api/jobs/clear?status=completed",{method:"DELETE"});Ae(`${X.count} completed job(s) cleared`,"success"),await r()}catch(X){Ae(`Failed: ${X.message}`,"error")}finally{g(a,!1)}}async function c(){g(i,!0);try{const X=await Se("/api/jobs/clear?status=failed",{method:"DELETE"});Ae(`${X.count} failed job(s) cleared`,"success"),await r()}catch(X){Ae(`Failed: ${X.message}`,"error")}finally{g(i,!1)}}var h=vp(),v=u(h),p=f(u(v),2);{var _=X=>{var j=fp(),z=u(j);V(()=>F(z,`${l(s).total??""} total`)),k(X,j)};O(p,X=>{l(s)&&X(_)})}var b=f(v,2),w=u(b);{var y=X=>{var j=_p(),z=u(j),oe=u(z),re=u(oe),ce=f(z,2),J=u(ce),T=u(J),q=f(ce,2),$=u(q),pe=u($),ye=f(q,2),we=u(ye),Xe=u(we);V(()=>{F(re,l(s).pending),F(T,l(s).running),F(pe,l(s).completed),F(Xe,l(s).failed)}),k(X,j)};O(w,X=>{l(s)&&X(y)})}var S=f(w,2),C=u(S),A=u(C),E=f(C,2),H=u(E),ae=f(E,2),M=u(ae);V(()=>{C.disabled=l(n)||(l(s)?.failed??0)===0,F(A,l(n)?"Retrying...":"Retry Failed"),E.disabled=l(a)||(l(s)?.completed??0)===0,F(H,l(a)?"Clearing...":"Clear Completed"),ae.disabled=l(i)||(l(s)?.failed??0)===0,F(M,l(i)?"Clearing...":"Clear Failed")}),U("click",C,o),U("click",E,d),U("click",ae,c),k(t,h),ut()}bt(["click"]);var gp=K('<div class="row"><span class="dim">No system birds registered</span></div>'),bp=K('<span class="bird-last-run svelte-12folcn"> <!></span>'),xp=K('<button class="btn btn-outline btn-sm">Flights</button>'),mp=K('<div class="flight-empty svelte-12folcn"><span class="dim">No flights recorded</span></div>'),yp=K('<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>'),wp=K('<div class="flight-list svelte-12folcn"><!></div>'),kp=K('<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>'),Sp=K('<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 Cp(t,e){dt(e,!0);let s=G(Ye({}));async function n(_){if(!l(s)[_])try{const b=await Se(`/api/birds/${_}/flights?perPage=5`);g(s,{...l(s),[_]:b.items},!0)}catch{g(s,{...l(s),[_]:[]},!0)}}async function a(_,b){try{const w=await Se(`/api/birds/${_}/fly`,{method:"POST"});Ae(`${b} sent on a flight (job #${w.jobId})`,"success");const{[_]:y,...S}=l(s);g(s,S,!0)}catch(w){Ae(`Failed: ${w.message}`,"error")}}var i=Sp(),r=u(i),o=f(u(r),2),d=u(o),c=f(r,2),h=u(c);{var v=_=>{var b=gp();k(_,b)},p=_=>{var b=kt(),w=Ce(b);Ct(w,19,()=>e.birds,y=>y.uid,(y,S,C)=>{var A=kp();let E;var H=u(A),ae=u(H),M=u(ae),X=u(M),j=f(M,2),z=u(j),oe=f(ae,2),re=u(oe);{var ce=ye=>{var we=bp(),Xe=u(we),Ne=f(Xe);{var ne=R=>{yn(R,{get status(){return l(S).last_status}})};O(Ne,R=>{l(S).last_status&&R(ne)})}V(R=>F(Xe,`${R??""} `),[()=>fs(l(S).last_run)]),k(ye,we)};O(re,ye=>{l(S).last_run&&ye(ce)})}var J=f(re,2);{var T=ye=>{var we=xp();U("click",we,()=>n(l(S).uid)),k(ye,we)};O(J,ye=>{l(s)[l(S).uid]||ye(T)})}var q=f(J,2),$=f(H,2);{var pe=ye=>{var we=wp(),Xe=u(we);{var Ne=R=>{var se=mp();k(R,se)},ne=R=>{var se=kt(),ue=Ce(se);Ct(ue,17,()=>l(s)[l(S).uid],de=>de.uid,(de,ve)=>{var be=yp(),Z=u(be),he=u(Z),W=f(Z,2);yn(W,{get status(){return l(ve).status}});var ee=f(W,2),ge=u(ee),Ee=f(ee,2),fe=u(Ee);V((Re,Te,Je)=>{F(he,Re),F(ge,Te),F(fe,Je)},[()=>Lt(l(ve).uid),()=>mi(l(ve).started_at,l(ve).finished_at),()=>fs(l(ve).started_at)]),k(de,be)}),k(R,se)};O(Xe,R=>{l(s)[l(S).uid].length===0?R(Ne):R(ne,!1)})}k(ye,we)};O($,ye=>{l(s)[l(S).uid]!=null&&ye(pe)})}V(()=>{E=me(A,1,"bird-entry svelte-12folcn",null,E,{"bird-entry-border":l(C)<e.birds.length-1}),F(X,l(S).name),F(z,l(S).schedule)}),U("click",q,()=>a(l(S).uid,l(S).name)),k(y,A)}),k(_,b)};O(h,_=>{e.birds.length===0?_(v):_(p,!1)})}V(()=>F(d,e.birds.length)),k(t,i),ut()}bt(["click"]);var Ep=K('<span class="error-count svelte-ht9bxs"> </span>'),Ap=K('<div class="row"><span class="dim">No errors recorded</span></div>'),Kp=K('<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>'),Fp=K('<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 Tp(t,e){dt(e,!0);var s=Fp(),n=Ce(s),a=u(n);pp(a,{get initialStats(){return e.jobStats}});var i=f(a,2),r=u(i),o=f(u(r),2);{var d=b=>{var w=Ep(),y=u(w);V(()=>F(y,e.recentErrors.length)),k(b,w)};O(o,b=>{e.recentErrors.length>0&&b(d)})}var c=f(r,2),h=u(c);{var v=b=>{var w=Ap();k(b,w)},p=b=>{var w=kt(),y=Ce(w);Ct(y,17,()=>e.recentErrors,S=>S.id,(S,C)=>{var A=Kp(),E=u(A),H=u(E),ae=u(H),M=f(H,2),X=u(M),j=f(E,2),z=u(j);V(oe=>{F(ae,l(C).source),F(X,oe),F(z,l(C).message)},[()=>fs(l(C).created_at)]),k(S,A)}),k(b,w)};O(h,b=>{e.recentErrors.length===0?b(v):b(p,!1)})}var _=f(n,2);Cp(_,{get birds(){return e.systemBirds}}),k(t,s),ut()}var Mp=K('<span class="cell-btn-label">...</span>'),Xp=Is('<svg viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M3 8.5l3.5 3.5L13 4.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>'),Lp=K('<div class="cell-edit-actions"><button class="cell-btn cell-btn-save" title="Save"><!></button> <button class="cell-btn cell-btn-cancel" title="Cancel"><svg viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg></button></div>'),Pp=K('<div class="create-form"><div class="form-title">New Key</div> <div class="form-row svelte-2ob75j"><label class="form-label">Name <input class="form-input" type="text" placeholder="GITHUB_TOKEN"/></label> <label class="form-label">Value <input class="form-input" type="password" placeholder="secret value"/></label> <label class="form-label">Description <input class="form-input" type="text" placeholder="Optional"/></label></div> <div class="form-actions svelte-2ob75j"><button class="btn btn-primary btn-sm"> </button> <button class="btn btn-outline btn-sm">Cancel</button></div></div>'),Bp=K('<div class="loading">Loading...</div>'),Dp=K('<button class="btn btn-primary btn-sm"> </button> <div class="filter-spacer"></div> <span class="last-updated"> </span>',1),Rp=K('<div class="cell-edit-overlay"><input class="cell-input mono" type="password" placeholder="new value"/> <!></div>'),Ip=K('<div class="cell-edit-overlay"><input class="cell-input" type="text"/> <!></div>'),Qp=K('<span class="chip svelte-2ob75j"><span class="chip-type svelte-2ob75j"> </span> <span class="chip-label svelte-2ob75j"> </span> <button class="chip-remove svelte-2ob75j"><svg viewBox="0 0 16 16" fill="none" aria-hidden="true" class="svelte-2ob75j"><path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg></button></span>'),Np=Is('<svg viewBox="0 0 16 16" fill="none" aria-hidden="true" class="svelte-2ob75j"><path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg>'),Up=Is('<svg viewBox="0 0 16 16" fill="none" aria-hidden="true" class="svelte-2ob75j"><path d="M8 3v10M3 8h10" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg>'),Hp=K("<option> </option>"),zp=K('<div class="binding-picker svelte-2ob75j"><select class="inline-select"><option>Channel</option><option>Bird</option></select> <select class="inline-select binding-target svelte-2ob75j"><option> </option><!></select> <button class="btn btn-primary btn-sm">Add</button></div>'),Op=K('<tr><td class="mono key-name-cell svelte-2ob75j"> </td><td class="cell-editable"><span> </span> <!></td><td class="cell-editable"><span> </span> <!></td><td><div class="bindings-cell svelte-2ob75j"><!> <button><!></button> <!></div></td><td class="age-cell svelte-2ob75j"> </td><td><div class="actions-cell svelte-2ob75j"><button class="btn btn-danger btn-sm">Delete</button></div></td></tr>'),Vp=K("<!> <!>",1);function Gp(t,e){dt(e,!0);const s=ne=>{var R=Lp(),se=u(R),ue=u(se);{var de=Z=>{var he=Mp();k(Z,he)},ve=Z=>{var he=Xp();k(Z,he)};O(ue,Z=>{l(b)?Z(de):Z(ve,!1)})}var be=f(se,2);V(Z=>se.disabled=Z,[()=>l(b)||l(_)?.field==="value"&&!l(_)?.value.trim()]),U("click",se,Z=>{Z.stopPropagation(),X()}),U("click",be,Z=>{Z.stopPropagation(),M()}),k(ne,R)};let n=G(Ye([])),a=G(Ye(Gs()));const i=[{key:"name",label:"Name",sortable:!0},{key:"hint",label:"Value"},{key:"description",label:"Description"},{key:"bindings",label:"Bindings"},{key:"created_at",label:"Created",sortable:!0},{key:"actions",label:""}],r=Di({endpoint:"/api/keys",columns:i,defaultSort:"name",invalidateOn:"keys",onResponse(){g(a,Gs(),!0)}}),o=Ke(()=>e.config?.slack.channels??[]);let d=G(!1),c=G(""),h=G(""),v=G(""),p=G(!1),_=G(null),b=G(!1),w=G(null),y=G("channel"),S=G(""),C=G(!1);xt(()=>{const ne=new AbortController;return Se("/api/birds?perPage=100").then(R=>{ne.signal.aborted||g(n,R.items.filter(se=>!se.name.startsWith("__bb_")),!0)}).catch(()=>{}),()=>ne.abort()});function A(){g(c,""),g(h,""),g(v,""),g(d,!0)}function E(){g(d,!1)}async function H(){const ne=l(c).trim().toUpperCase();if(!(!ne||!l(h))){g(p,!0);try{await Se("/api/keys",{method:"POST",body:{name:ne,value:l(h),description:l(v).trim()||void 0}}),Ae("Key created","success"),E()}catch(R){Ae(`Failed: ${R.message}`,"error")}finally{g(p,!1)}}}function ae(ne,R){const se=R==="value"?"":ne[R]??"",ue=R==="value"?"":ne[R]??"";g(_,{uid:ne.uid,field:R,value:se,original:ue},!0)}function M(){g(_,null),g(b,!1)}async function X(){if(l(_)==null)return;const ne=l(_).value.trim();if(!(l(_).field==="value"&&!ne)){if(l(_).field!=="value"&&ne===l(_).original.trim()){g(_,null);return}g(b,!0);try{await Se(`/api/keys/${l(_).uid}`,{method:"PATCH",body:{[l(_).field]:ne}}),Ae(`Updated ${l(_).field}`,"success"),g(_,null)}catch(R){Ae(`Failed: ${R.message}`,"error")}finally{g(b,!1)}}}function j(ne){ne.key==="Escape"?M():ne.key==="Enter"&&!ne.shiftKey&&(ne.preventDefault(),X())}function z(ne,R){return l(_)!=null&&l(_).uid===ne&&l(_).field===R}async function oe(ne){if(await Bi(`Delete key "${ne.name}"?`))try{await Se(`/api/keys/${ne.uid}`,{method:"DELETE"}),Ae("Key deleted","success")}catch(se){Ae(`Failed: ${se.message}`,"error")}}function re(ne){if(l(w)===ne){g(w,null);return}g(w,ne,!0),g(y,"channel"),g(S,"")}async function ce(){if(!(!l(w)||!l(S))){g(C,!0);try{const R=r.items.find(de=>de.uid===l(w))?.bindings??[];if(R.some(de=>de.targetType===l(y)&&de.targetId===l(S))){Ae("Binding already exists","info"),g(C,!1);return}const ue=[...R,{targetType:l(y),targetId:l(S)}];await Se(`/api/keys/${l(w)}/bindings`,{method:"PUT",body:ue}),Ae("Binding added","success"),g(S,"")}catch(ne){Ae(`Failed: ${ne.message}`,"error")}finally{g(C,!1)}}}async function J(ne,R){const se=r.items.find(de=>de.uid===ne);if(!se)return;const ue=se.bindings.filter(de=>!(de.targetType===R.targetType&&de.targetId===R.targetId));try{await Se(`/api/keys/${ne}/bindings`,{method:"PUT",body:ue})}catch(de){Ae(`Failed: ${de.message}`,"error")}}function T(ne){if(ne.targetType==="bird"){const R=l(n).find(se=>se.uid===ne.targetId);return R?R.name:ne.targetId.slice(0,10)}return ne.targetId}const q=Ke(()=>l(y)==="channel"?l(o).map(ne=>({value:ne,label:ne})):l(n).map(ne=>({value:ne.uid,label:ne.name})));var $=Vp(),pe=Ce($);{var ye=ne=>{var R=Pp(),se=f(u(R),2),ue=u(se),de=f(u(ue)),ve=f(ue,2),be=f(u(ve)),Z=f(ve,2),he=f(u(Z)),W=f(se,2),ee=u(W),ge=u(ee),Ee=f(ee,2);V(()=>{ee.disabled=l(p),F(ge,l(p)?"Saving...":"Create")}),je(de,()=>l(c),fe=>g(c,fe)),je(be,()=>l(h),fe=>g(h,fe)),je(he,()=>l(v),fe=>g(v,fe)),U("click",ee,H),U("click",Ee,E),k(ne,R)};O(pe,ne=>{l(d)&&ne(ye)})}var we=f(pe,2);{var Xe=ne=>{var R=Bp();k(ne,R)},Ne=ne=>{{const R=ue=>{var de=Dp(),ve=Ce(de),be=u(ve),Z=f(ve,4),he=u(Z);V(()=>{F(be,l(d)?"Cancel":"Add Key"),F(he,`Updated ${l(a)??""}`)}),U("click",ve,()=>{l(d)?E():A()}),k(ue,de)};let se=Ke(()=>r.items.length===0);$s(ne,{get columns(){return i},get isEmpty(){return l(se)},emptyMessage:"No keys stored",get fetching(){return r.fetching},get page(){return r.page},get totalPages(){return r.totalPages},get totalItems(){return r.totalItems},get sort(){return r.sort},get search(){return r.search},searchPlaceholder:"Search keys...",get onPageChange(){return r.setPage},get onSortChange(){return r.setSort},get onSearchChange(){return r.setSearch},toolbar:R,children:(ue,de)=>{var ve=kt(),be=Ce(ve);Ct(be,17,()=>r.items,Z=>Z.uid,(Z,he)=>{var W=Op(),ee=u(W),ge=u(ee),Ee=f(ee),fe=u(Ee);let Re;var Te=u(fe),Je=f(fe,2);{var Ue=Pe=>{var Be=Rp(),Fe=u(Be),We=f(Fe,2);s(We),U("keydown",Fe,j),je(Fe,()=>l(_).value,Ie=>l(_).value=Ie),k(Pe,Be)},Ve=Ke(()=>z(l(he).uid,"value"));O(Je,Pe=>{l(Ve)&&Pe(Ue)})}var it=f(Ee),ke=u(it);let He;var rt=u(ke),Jt=f(ke,2);{var Wt=Pe=>{var Be=Ip(),Fe=u(Be),We=f(Fe,2);s(We),U("keydown",Fe,j),je(Fe,()=>l(_).value,Ie=>l(_).value=Ie),k(Pe,Be)},rs=Ke(()=>z(l(he).uid,"description"));O(Jt,Pe=>{l(rs)&&Pe(Wt)})}var ls=f(it),St=u(ls),$t=u(St);Ct($t,17,()=>l(he).bindings,bi,(Pe,Be)=>{var Fe=Qp(),We=u(Fe),Ie=u(We),Y=f(We,2),le=u(Y),xe=f(Y,2);V((De,ze)=>{F(Ie,l(Be).targetType),F(le,De),It(xe,"aria-label",ze)},[()=>T(l(Be)),()=>`Remove ${T(l(Be))}`]),U("click",xe,()=>J(l(he).uid,l(Be))),k(Pe,Fe)});var es=f($t,2);let os;var ps=u(es);{var gs=Pe=>{var Be=Np();k(Pe,Be)},cs=Pe=>{var Be=Up();k(Pe,Be)};O(ps,Pe=>{l(w)===l(he).uid?Pe(gs):Pe(cs,!1)})}var Cs=f(es,2);{var Es=Pe=>{var Be=zp(),Fe=u(Be),We=u(Fe);We.value=We.__value="channel";var Ie=f(We);Ie.value=Ie.__value="bird";var Y=f(Fe,2),le=u(Y),xe=u(le);le.value=le.__value="";var De=f(le);Ct(De,17,()=>l(q),bi,(Ge,lt)=>{var ct=Hp(),Ft=u(ct),At={};V(()=>{F(Ft,l(lt).label),At!==(At=l(lt).value)&&(ct.value=(ct.__value=l(lt).value)??"")}),k(Ge,ct)});var ze=f(Y,2);V(()=>{F(xe,`Select ${l(y)??""}...`),ze.disabled=l(C)||!l(S)}),U("change",Fe,()=>{g(S,"")}),gl(Fe,()=>l(y),Ge=>g(y,Ge)),gl(Y,()=>l(S),Ge=>g(S,Ge)),U("click",ze,ce),k(Pe,Be)};O(Cs,Pe=>{l(w)===l(he).uid&&Pe(Es)})}var As=f(ls),tt=u(As),st=f(As),ht=u(st),ft=u(ht);V((Pe,Be,Fe)=>{F(ge,l(he).name),Re=me(fe,1,"mono cell-text",null,Re,Pe),F(Te,l(he).hint),He=me(ke,1,"cell-text desc-text svelte-2ob75j",null,He,Be),F(rt,l(he).description??"-"),os=me(es,1,"chip chip-add svelte-2ob75j",null,os,{"chip-add-active":l(w)===l(he).uid}),F(tt,Fe)},[()=>({"cell-text-hidden":z(l(he).uid,"value")}),()=>({"cell-text-hidden":z(l(he).uid,"description")}),()=>fs(l(he).created_at)]),U("click",Ee,()=>ae(l(he),"value")),U("click",it,()=>ae(l(he),"description")),U("click",es,Pe=>{Pe.stopPropagation(),re(l(he).uid)}),U("click",ft,()=>oe(l(he))),k(Z,W)}),k(ue,ve)},$$slots:{toolbar:!0,default:!0}})}};O(we,ne=>{r.loading?ne(Xe):ne(Ne,!1)})}k(t,$),ut()}bt(["click","keydown","change"]);var jp=K('<div class="loading">Loading...</div>'),Wp=K('<div class="tabs svelte-1ozf5k3"><button>Config</button> <button>Database</button> <button>Keys</button></div> <!> <!> <!>',1);function qp(t,e){dt(e,!0);let s=G(null),n=G(null),a=G(null),i=G(!0),r=G(Ye([])),o=G(null),d=G(Ye([])),c=G(!0);const h=new Set(["config","database","keys"]),v=Ga().get("tab")??"config";let p=G(Ye(h.has(v)?v:"config"));function _(re){g(p,re,!0);const ce=window.location.hash,J=ce.indexOf("?"),T=J===-1?ce:ce.slice(0,J),q=new URLSearchParams(J===-1?"":ce.slice(J+1));re==="config"?q.delete("tab"):q.set("tab",re);const $=q.toString();history.replaceState(null,"",$?`${T}?${$}`:T)}let b=G(null),w=G(!1);xt(()=>{const re=new AbortController;return Promise.all([Se("/api/config"),Se("/api/logs?level=error&perPage=10"),Se("/api/jobs/stats"),Se("/api/birds?system=true&perPage=100"),Se("/api/secrets")]).then(([ce,J,T,q,$])=>{re.signal.aborted||(g(s,ce,!0),g(r,J.items,!0),g(o,T,!0),g(d,q.items.filter(pe=>pe.name.startsWith("__bb_")),!0),g(n,$,!0))}).finally(()=>{re.signal.aborted||g(c,!1)}),()=>re.abort()}),xt(()=>{const re=new AbortController;return Se("/api/doctor").then(ce=>{re.signal.aborted||g(a,ce,!0)}).finally(()=>{re.signal.aborted||g(i,!1)}),()=>re.abort()}),xt(()=>Pi(re=>{re.resource==="config"&&Se("/api/config").then(ce=>{g(s,ce,!0)}).catch(()=>{}),re.resource==="secrets"&&y()}));function y(){Se("/api/secrets").then(re=>{g(n,re,!0)}).catch(()=>{})}function S(re,ce){const J=re.split(".");let T={};const q=T;for(let $=0;$<J.length-1;$++){const pe={};T[J[$]]=pe,T=pe}return T[J[J.length-1]]=ce,q}async function C(re){try{const ce=await Se("/api/config",{method:"PATCH",body:re});return g(s,ce,!0),Ae("Config saved","success"),!0}catch(ce){return Ae(`Failed: ${ce.message}`,"error"),!1}}function A(re,ce){g(b,re,!0),g(w,!1)}function E(){g(b,null),g(w,!1)}async function H(re,ce,J){g(w,!0);const T=J?J(ce):ce;await C(S(re,T))?E():g(w,!1)}async function ae(re,ce){await C(S(re,!ce))}const M=Ke(()=>({editingField:l(b),editingSaving:l(w),startEdit:A,cancelEdit:E,saveField:H,toggleField:ae,saveConfigPatch:C}));var X=kt(),j=Ce(X);{var z=re=>{var ce=jp();k(re,ce)},oe=re=>{var ce=Wp(),J=Ce(ce),T=u(J);let q;var $=f(T,2);let pe;var ye=f($,2);let we;var Xe=f(J,2);{var Ne=de=>{hp(de,{get config(){return l(s)},get status(){return e.status},get doctor(){return l(a)},get doctorLoading(){return l(i)},get editor(){return l(M)},get secrets(){return l(n)},onsecretsupdate:y})};O(Xe,de=>{l(p)==="config"&&de(Ne)})}var ne=f(Xe,2);{var R=de=>{Tp(de,{get jobStats(){return l(o)},get systemBirds(){return l(d)},get recentErrors(){return l(r)}})};O(ne,de=>{l(p)==="database"&&de(R)})}var se=f(ne,2);{var ue=de=>{Gp(de,{get config(){return l(s)}})};O(se,de=>{l(p)==="keys"&&de(ue)})}V(()=>{q=me(T,1,"tab svelte-1ozf5k3",null,q,{"tab-active":l(p)==="config"}),pe=me($,1,"tab svelte-1ozf5k3",null,pe,{"tab-active":l(p)==="database"}),we=me(ye,1,"tab svelte-1ozf5k3",null,we,{"tab-active":l(p)==="keys"})}),U("click",T,()=>_("config")),U("click",$,()=>_("database")),U("click",ye,()=>_("keys")),k(re,ce)};O(j,re=>{l(c)?re(z):l(s)&&re(oe,1)})}k(t,X),ut()}bt(["click"]);var Yp=K('<div class="card-sub svelte-1tf674w"> </div>'),Zp=K('<div><div class="card-label svelte-1tf674w"> </div> <div class="card-value svelte-1tf674w"> </div> <!></div>');function vr(t,e){var s=Zp();let n;var a=u(s),i=u(a),r=f(a,2),o=u(r),d=f(r,2);{var c=h=>{var v=Yp(),p=u(v);V(()=>F(p,e.sub)),k(h,v)};O(d,h=>{e.sub&&h(c)})}V(()=>{n=me(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"}),F(i,e.label),F(o,e.value)}),k(t,s)}var Jp=K('<div class="error-state svelte-1lyclyh"><p> </p> <button class="btn btn-outline btn-sm">Back to Sessions</button></div>'),$p=K('<div class="loading">Loading...</div>'),eg=K('<div class="filter-spacer svelte-1lyclyh"></div> <span class="last-updated svelte-1lyclyh"> </span>',1),tg=K('<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>'),sg=K('<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 ng(t,e){dt(e,!0);const s=Ga().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=G(Ye(Gs())),i=G(null),r=G(null),o=G("");const d=s?Di({endpoint:`/api/sessions/${s}`,columns:n,defaultSort:"created_at",invalidateOn:"sessions",transformResponse:w=>w.messages,onResponse:w=>{g(a,Gs(),!0),g(i,w.session,!0),g(r,w.stats,!0)}}):null;d||g(o,"Invalid session ID");function c(){window.location.hash="#/sessions"}var h=kt(),v=Ce(h);{var p=w=>{var y=Jp(),S=u(y),C=u(S),A=f(S,2);V(()=>F(C,l(o))),U("click",A,c),k(w,y)},_=w=>{var y=$p();k(w,y)},b=w=>{var y=sg(),S=Ce(y),C=u(S),A=f(C,2),E=u(A),H=f(A,2),ae=u(H),M=u(ae),X=f(ae,3),j=f(X,2),z=f(S,2),oe=u(z);vr(oe,{label:"Messages",get value(){return l(i).message_count}});var re=f(oe,2);{let T=Ke(()=>l(r).totalTokensIn.toLocaleString());vr(re,{label:"Tokens In",get value(){return l(T)}})}var ce=f(re,2);{let T=Ke(()=>l(r).totalTokensOut.toLocaleString());vr(ce,{label:"Tokens Out",get value(){return l(T)}})}var J=f(z,2);{const T=$=>{var pe=eg(),ye=f(Ce(pe),2),we=u(ye);V(()=>F(we,`Updated ${l(a)??""}`)),k($,pe)};let q=Ke(()=>d.items.length===0);$s(J,{get columns(){return n},get isEmpty(){return l(q)},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:T,children:($,pe)=>{var ye=kt(),we=Ce(ye);Ct(we,17,()=>d.items,Xe=>Xe.id,(Xe,Ne)=>{var ne=tg(),R=u(ne),se=u(R);{let fe=Ke(()=>l(Ne).direction==="in"?"info":"success");yn(se,{get status(){return l(fe)}})}var ue=f(R),de=u(ue),ve=f(ue),be=u(ve),Z=f(ve),he=u(Z),W=f(Z),ee=u(W),ge=f(W),Ee=u(ge);V(fe=>{F(de,l(Ne).user_id),F(be,l(Ne).content??"-"),F(he,l(Ne).tokens_in??"-"),F(ee,l(Ne).tokens_out??"-"),F(Ee,fe)},[()=>fs(l(Ne).created_at)]),k(Xe,ne)}),k($,ye)},$$slots:{toolbar:!0,default:!0}})}V((T,q)=>{F(E,`Session ${T??""}`),F(M,l(i).channel_id),F(X,` ${l(i).agent_id??""} `),F(j,` ${q??""}`)},[()=>Lt(l(i).uid),()=>fs(l(i).last_active)]),U("click",C,c),k(w,y)};O(v,w=>{l(o)?w(p):d?.loading?w(_,1):l(i)&&l(r)&&d&&w(b,2)})}k(t,h),ut()}bt(["click"]);var ag=K("<div></div>"),ig=K('<div><span class="step-number svelte-dm5b3b"></span></div> <!>',1),rg=K('<div class="step-indicator svelte-dm5b3b"></div>'),lg=K(`<span class="form-hint svelte-dm5b3b">Already configured. Leave blank to keep current key, or enter a new one to replace
|
|
7
|
+
it.</span>`),og=K('<span class="form-hint svelte-dm5b3b">API key from platform.claude.com/settings/keys</span>'),cg=K('<div class="login-error svelte-dm5b3b"> </div>'),dg=K('<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),ug=K('<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),hg=K('<div class="login-error svelte-dm5b3b"> </div>'),fg=K(`<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),_g=K('<div class="probe-result probe-ok svelte-dm5b3b">Connected</div>'),vg=K('<div class="probe-result probe-fail svelte-dm5b3b">Not reachable. Make sure the VM container is running.</div>'),pg=K('<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),gg=K('<div class="login-error svelte-dm5b3b"> </div>'),bg=K('<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),xg=K('<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),mg=K('<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),yg=K('<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),wg=K('<div class="login-error svelte-dm5b3b"> </div>'),kg=K('<!> <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),Sg=K('<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 Cg(t,e){dt(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=G(0),i=G(!1),r=G(""),o=Ye({botToken:"",appToken:"",team:"",botUser:""}),d=Ye({name:"BrowserBird",model:"sonnet",systemPrompt:"You are a helpful AI assistant. Be concise and direct.",maxTurns:50,channels:["*"],apiKey:""}),c=Ye({enabled:!1,novncHost:"localhost",novncPort:6080}),h=G("idle"),v=G(null),p=G(""),_=G(!1);xt(()=>{gh().then(R=>{g(v,R,!0),d.name=R.agent.name,d.model=R.agent.model,d.systemPrompt=R.agent.systemPrompt,d.maxTurns=R.agent.maxTurns,d.channels=R.agent.channels,c.enabled=R.browser.enabled,c.novncHost=R.browser.novncHost,c.novncPort=R.browser.novncPort,R.secrets.anthropic.set&&g(p,R.secrets.anthropic.hint,!0),R.secrets.slack.botToken.set&&R.secrets.slack.appToken.set&&g(_,!0)}).catch(()=>{})});async function b(R){if(R.preventDefault(),!(!o.botToken.trim()||!o.appToken.trim())){g(i,!0),g(r,"");try{const se=await bh(o.botToken.trim(),o.appToken.trim());o.team=se.team,o.botUser=se.botUser,g(a,2)}catch(se){g(r,se.message,!0)}finally{g(i,!1)}}}async function w(R){if(R.preventDefault(),!(!d.name.trim()||!d.model.trim())){if(!d.apiKey.trim()&&!l(p)){g(r,"API key is required");return}g(i,!0),g(r,"");try{await xh({name:d.name.trim(),model:d.model.trim(),systemPrompt:d.systemPrompt.trim(),maxTurns:d.maxTurns,channels:d.channels}),d.apiKey.trim()&&await mh({apiKey:d.apiKey.trim()}),g(a,1)}catch(se){g(r,se.message,!0)}finally{g(i,!1)}}}function y(){g(a,2)}async function S(R){R.preventDefault(),g(i,!0),g(r,"");try{await yh({enabled:c.enabled,novncHost:c.enabled?c.novncHost.trim():void 0}),await E()}catch(se){g(r,se.message,!0)}finally{g(i,!1)}}async function C(){g(i,!0),g(r,"");try{await E()}catch(R){g(r,R.message,!0)}finally{g(i,!1)}}let A=G(!1);async function E(){await kh(),g(A,!0),g(a,3)}async function H(){g(i,!0),g(r,"");try{await E()}catch(R){g(r,R.message,!0)}finally{g(i,!1)}}async function ae(){const R=c.novncHost.trim();if(R){g(h,"checking");try{const se=await wh(R,c.novncPort);g(h,se.reachable?"reachable":"unreachable",!0)}catch{g(h,"unreachable")}}}function M(){g(r,""),l(a)===3&&!l(A)?g(a,2):kr(a,-1)}var X=Sg(),j=u(X),z=f(u(j),2);{var oe=R=>{var se=rg();Ct(se,21,()=>s,bi,(ue,de,ve)=>{var be=ig(),Z=Ce(be);let he;var W=u(Z);W.textContent=ve+1;var ee=f(Z,2);{var ge=Ee=>{var fe=ag();let Re;V(()=>Re=me(fe,1,"step-line svelte-dm5b3b",null,Re,{completed:ve<l(a)})),k(Ee,fe)};O(ee,Ee=>{ve<s.length-1&&Ee(ge)})}V(()=>he=me(Z,1,"step-dot svelte-dm5b3b",null,he,{active:ve===l(a),completed:ve<l(a)})),k(ue,be)}),k(R,se)};O(z,R=>{l(a)<s.length&&R(oe)})}var re=f(z,2),ce=u(re);{var J=R=>{var se=Xs("Configure Agent");k(R,se)},T=R=>{var se=Xs("Connect Slack");k(R,se)},q=R=>{var se=Xs("Browser");k(R,se)},$=R=>{var se=Xs();V(()=>F(se,l(A)?"You're all set":"Launching...")),k(R,se)};O(ce,R=>{l(a)===0?R(J):l(a)===1?R(T,1):l(a)===2?R(q,2):R($,!1)})}var pe=f(re,2);{var ye=R=>{var se=dg(),ue=f(Ce(se),2),de=u(ue),ve=f(u(de)),be=f(de,2),Z=u(be),he=f(u(Z)),W=f(be,2),ee=f(u(W)),ge=f(W,2),Ee=f(u(ge)),fe=f(Ee,2);{var Re=ke=>{var He=lg();k(ke,He)},Te=ke=>{var He=og();k(ke,He)};O(fe,ke=>{l(p)?ke(Re):ke(Te,!1)})}var Je=f(ge,2);{var Ue=ke=>{var He=cg(),rt=u(He);V(()=>F(rt,l(r))),k(ke,He)};O(Je,ke=>{l(r)&&ke(Ue)})}var Ve=f(Je,2),it=u(Ve);V(()=>{It(Ee,"placeholder",l(p)?`Configured (${l(p)})`:"sk-ant-..."),Ve.disabled=l(i),F(it,l(i)?"Saving...":"Save & Continue")}),Rn("submit",ue,w),je(ve,()=>d.name,ke=>d.name=ke),je(he,()=>d.model,ke=>d.model=ke),je(ee,()=>d.systemPrompt,ke=>d.systemPrompt=ke),je(Ee,()=>d.apiKey,ke=>d.apiKey=ke),k(R,se)},we=R=>{var se=fg(),ue=Ce(se),de=u(ue);{var ve=ke=>{var He=Xs("Slack tokens are already configured. You can skip this step or re-enter them to update.");k(ke,He)},be=ke=>{var He=ug(),rt=Ce(He);It(rt,"href",n),k(ke,He)};O(de,ke=>{l(_)?ke(ve):ke(be,!1)})}var Z=f(ue,2),he=u(Z),W=f(u(he)),ee=f(he,2),ge=f(u(ee)),Ee=f(ee,2);{var fe=ke=>{var He=hg(),rt=u(He);V(()=>F(rt,l(r))),k(ke,He)};O(Ee,ke=>{l(r)&&ke(fe)})}var Re=f(Ee,2),Te=u(Re),Je=f(Te,2),Ue=u(Je),Ve=f(Ue,2),it=u(Ve);V(()=>{Ue.disabled=l(i),Ve.disabled=l(i),F(it,l(i)?"Validating...":"Validate & Save")}),Rn("submit",Z,b),je(W,()=>o.botToken,ke=>o.botToken=ke),je(ge,()=>o.appToken,ke=>o.appToken=ke),U("click",Te,M),U("click",Ue,y),k(R,se)},Xe=R=>{var se=bg(),ue=f(Ce(se),2),de=u(ue),ve=f(u(de),2);Ln(ve,{get active(){return c.enabled},onToggle:()=>{c.enabled=!c.enabled,g(h,"idle")}});var be=f(de,2);{var Z=Ue=>{var Ve=pg(),it=Ce(Ve),ke=f(u(it)),He=u(ke),rt=f(He,2),Jt=u(rt),Wt=f(it,2);{var rs=St=>{var $t=_g();k(St,$t)},ls=St=>{var $t=vg();k(St,$t)};O(Wt,St=>{l(h)==="reachable"?St(rs):l(h)==="unreachable"&&St(ls,1)})}V(St=>{rt.disabled=St,F(Jt,l(h)==="checking"?"Checking...":"Test Connection")},[()=>l(h)==="checking"||!c.novncHost.trim()]),U("input",He,()=>{g(h,"idle")}),je(He,()=>c.novncHost,St=>c.novncHost=St),U("click",rt,ae),k(Ue,Ve)};O(be,Ue=>{c.enabled&&Ue(Z)})}var he=f(be,2);{var W=Ue=>{var Ve=gg(),it=u(Ve);V(()=>F(it,l(r))),k(Ue,Ve)};O(he,Ue=>{l(r)&&Ue(W)})}var ee=f(he,2),ge=u(ee),Ee=f(ge,2),fe=u(Ee),Re=u(fe),Te=f(fe,2),Je=u(Te);V(()=>{fe.disabled=l(i),F(Re,l(i)?"Launching...":"Skip"),Te.disabled=l(i),F(Je,l(i)?"Launching...":"Save & Launch")}),Rn("submit",ue,S),U("click",ge,M),U("click",fe,C),k(R,se)},Ne=R=>{var se=yg(),ue=Ce(se),de=u(ue),ve=f(u(de),2),be=u(ve),Z=f(de,2),he=f(u(Z),2),W=u(he),ee=f(Z,2),ge=f(u(ee),2),Ee=u(ge),fe=f(ue,2),Re=u(fe);{var Te=Ve=>{var it=xg(),ke=Ce(it),He=f(u(ke),2),rt=u(He);V(()=>F(rt,`@${d.name??""} in any channel`)),k(Ve,it)},Je=Ve=>{var it=mg();k(Ve,it)};O(Re,Ve=>{o.team?Ve(Te):Ve(Je,!1)})}var Ue=f(fe,2);V(()=>{F(be,o.team||"Not configured"),F(W,`${d.name??""} (${d.model??""})`),F(Ee,c.enabled?"Enabled":"Disabled")}),U("click",Ue,function(...Ve){e.oncomplete?.apply(this,Ve)}),k(R,se)},ne=R=>{var se=kg(),ue=Ce(se);{var de=W=>{var ee=wg(),ge=u(ee);V(()=>F(ge,l(r))),k(W,ee)};O(ue,W=>{l(r)&&W(de)})}var ve=f(ue,2),be=u(ve),Z=f(be,2),he=u(Z);V(()=>{Z.disabled=l(i),F(he,l(i)?"Launching...":"Retry")}),U("click",be,M),U("click",Z,H),k(R,se)};O(pe,R=>{l(a)===0?R(ye):l(a)===1?R(we,1):l(a)===2?R(Xe,2):l(A)?R(Ne,3):R(ne,!1)})}k(t,X),ut()}bt(["click","input"]);var Eg=K('<div class="loading">Loading...</div>'),Ag=K('<div class="login-error svelte-1n46o8q"> </div>'),Kg=K('<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>'),Fg=K('<div class="login-error svelte-1n46o8q"> </div>'),Tg=K('<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>'),Mg=K('<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>'),Xg=K("<!> <!> <!>",1);function Lg(t,e){dt(e,!0);const s={status:"Mission Control",sessions:"Sessions","session-detail":"Session Detail",birds:"Birds",computer:"Computer",settings:"Settings"};let n=G(Ye(Sl())),a=G("checking"),i=G(null),r=G("connecting"),o=G(localStorage.getItem("sidebar-collapsed")==="true"),d=G(!1),c=G(""),h=G(""),v=G(""),p=G(""),_=G(""),b=G(""),w=G("");const y=Ke(()=>s[l(n)]??"Mission Control");xt(()=>{document.title=`${l(y)} - BrowserBird`});function S(){g(o,!l(o)),localStorage.setItem("sidebar-collapsed",String(l(o)))}fh(()=>{g(a,"login")}),xt(()=>{const J=()=>{g(n,Sl(),!0),g(d,!1)};return window.addEventListener("hashchange",J),()=>window.removeEventListener("hashchange",J)}),xt(()=>{if(l(n)!=="flights")return;const J=Ga().get("birdUid");window.location.hash=J?`#/birds?expand=${J}`:"#/birds"}),xt(()=>{kl().then(async J=>{J.setupRequired?g(a,"setup"):J.authRequired?Li()?await ph()?J.onboardingRequired?g(a,"onboarding"):g(a,"authenticated"):g(a,"login"):g(a,(J.onboardingRequired,"login"),!0):g(a,"authenticated")})}),xt(()=>{if(l(a)!=="authenticated")return;Cl(T=>{g(i,T,!0),g(r,"connected")},T=>El(T),T=>{g(r,T,!0)});const J=setInterval(()=>{Sh()||Se("/api/status").then(()=>{g(r,"connected"),Cl(T=>{g(i,T,!0),g(r,"connected")},T=>El(T),T=>{g(r,T,!0)})}).catch(()=>{g(r,"disconnected")})},3e4);return()=>{jc(),clearInterval(J)}});function C(){qr(),g(a,"login")}async function A(J){J.preventDefault();const T=l(c).trim(),q=l(h);if(!(!T||!q))try{const $=await _h(T,q);wl($.token),g(v,""),g(c,""),g(h,""),g(a,"authenticated")}catch($){g(v,$.message,!0)}}async function E(J){J.preventDefault();const T=l(p).trim(),q=l(_),$=l(b);if(!(!T||!q)){if(q!==$){g(w,"Passwords do not match");return}if(q.length<8){g(w,"Password must be at least 8 characters");return}try{const pe=await vh(T,q);wl(pe.token),g(w,""),g(p,""),g(_,""),g(b,"");const ye=await kl();g(a,ye.onboardingRequired?"onboarding":"authenticated",!0)}catch(pe){g(w,pe.message,!0)}}}var H=Xg(),ae=Ce(H);Ih(ae,{});var M=f(ae,2);Nh(M,{});var X=f(M,2);{var j=J=>{var T=Eg();k(J,T)},z=J=>{var T=Kg(),q=u(T),$=f(u(q),4),pe=u($),ye=f(u(pe)),we=f(pe,2),Xe=f(u(we)),Ne=f(we,2),ne=f(u(Ne)),R=f(Ne,2);{var se=ue=>{var de=Ag(),ve=u(de);V(()=>F(ve,l(w))),k(ue,de)};O(R,ue=>{l(w)&&ue(se)})}Rn("submit",$,E),je(ye,()=>l(p),ue=>g(p,ue)),je(Xe,()=>l(_),ue=>g(_,ue)),je(ne,()=>l(b),ue=>g(b,ue)),k(J,T)},oe=J=>{var T=Tg(),q=u(T),$=f(u(q),2),pe=u($),ye=f(u(pe)),we=f(pe,2),Xe=f(u(we)),Ne=f(we,2);{var ne=R=>{var se=Fg(),ue=u(se);V(()=>F(ue,l(v))),k(R,se)};O(Ne,R=>{l(v)&&R(ne)})}Rn("submit",$,A),je(ye,()=>l(c),R=>g(c,R)),je(Xe,()=>l(h),R=>g(h,R)),k(J,T)},re=J=>{Cg(J,{oncomplete:()=>{g(a,"authenticated")}})},ce=J=>{var T=Mg(),q=u(T);Th(q,{get currentPage(){return l(n)},get collapsed(){return l(o)},get mobileOpen(){return l(d)},ontoggle:S,onmobileclose:()=>{g(d,!1)},onsignout:C});var $=f(q,2),pe=u($),ye=u(pe),we=f(ye,2),Xe=u(we),Ne=f(we,2),ne=u(Ne);Ph(ne,{get status(){return l(i)}});var R=f(pe,2),se=u(R);{var ue=W=>{gf(W,{})},de=W=>{ng(W,{})},ve=W=>{s0(W,{})},be=W=>{mv(W,{get status(){return l(i)}})},Z=W=>{qp(W,{get status(){return l(i)}})},he=W=>{uf(W,{get status(){return l(i)}})};O(se,W=>{l(n)==="sessions"?W(ue):l(n)==="session-detail"?W(de,1):l(n)==="birds"?W(ve,2):l(n)==="computer"?W(be,3):l(n)==="settings"?W(Z,4):W(he,!1)})}V(()=>F(Xe,l(y))),U("click",ye,()=>{g(d,!0)}),k(J,T)};O(X,J=>{l(a)==="checking"?J(j):l(a)==="setup"?J(z,1):l(a)==="login"?J(oe,2):l(a)==="onboarding"?J(re,3):J(ce,!1)})}k(t,H),ut()}bt(["click"]);Yu(Lg,{target:document.getElementById("app")});
|