8bitworkshop/gen/chunk-VD7T557T.js

49 lines
223 KiB
JavaScript

import{a as sn,b as el,c as tl}from"./chunk-SXEVG2WS.js";import{a as Ds}from"./chunk-5SHCNQ2O.js";import{a as Ls,b as Rs,c as rl}from"./chunk-AT7M4NIM.js";import{D as ca,J as fa,l as te,u as As,v as Fs}from"./chunk-TV4YGKI4.js";import{D as Dt,E as oa,F as Fr,I as Cs,J as la,S as ua,U as ks,a as Ft,aa as an,b as oi,ba as Ps,ca as li,d as Et,e as sa,f as pt,g as De,j as Es,l as Zi,m as en,n as tn,o as gr,p as Ss,s as rn,v as _s,w as Ts,x as nn,y as gt,z as Ar}from"./chunk-Z5CU44VP.js";import{b as si,c as ws,e as aa}from"./chunk-5XVCUSSZ.js";var ha=ws((Is,da)=>{(function(l){if(typeof Is=="object"&&typeof da!="undefined")da.exports=l();else if(typeof define=="function"&&define.amd)define([],l);else{var t;typeof window!="undefined"?t=window:typeof global!="undefined"?t=global:typeof self!="undefined"?t=self:t=this,t.localforage=l()}})(function(){var l,t,i;return function a(u,d,m){function y(W,fe){if(!d[W]){if(!u[W]){var z=typeof si=="function"&&si;if(!fe&&z)return z(W,!0);if(b)return b(W,!0);var U=new Error("Cannot find module '"+W+"'");throw U.code="MODULE_NOT_FOUND",U}var q=d[W]={exports:{}};u[W][0].call(q.exports,function(de){var K=u[W][1][de];return y(K||de)},q,q.exports,a,u,d,m)}return d[W].exports}for(var b=typeof si=="function"&&si,D=0;D<m.length;D++)y(m[D]);return y}({1:[function(a,u,d){(function(m){"use strict";var y=m.MutationObserver||m.WebKitMutationObserver,b;if(y){var D=0,W=new y(de),fe=m.document.createTextNode("");W.observe(fe,{characterData:!0}),b=function(){fe.data=D=++D%2}}else if(!m.setImmediate&&typeof m.MessageChannel!="undefined"){var z=new m.MessageChannel;z.port1.onmessage=de,b=function(){z.port2.postMessage(0)}}else"document"in m&&"onreadystatechange"in m.document.createElement("script")?b=function(){var xe=m.document.createElement("script");xe.onreadystatechange=function(){de(),xe.onreadystatechange=null,xe.parentNode.removeChild(xe),xe=null},m.document.documentElement.appendChild(xe)}:b=function(){setTimeout(de,0)};var U,q=[];function de(){U=!0;for(var xe,Ce,be=q.length;be;){for(Ce=q,q=[],xe=-1;++xe<be;)Ce[xe]();be=q.length}U=!1}u.exports=K;function K(xe){q.push(xe)===1&&!U&&b()}}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{}],2:[function(a,u,d){"use strict";var m=a(1);function y(){}var b={},D=["REJECTED"],W=["FULFILLED"],fe=["PENDING"];u.exports=z;function z(X){if(typeof X!="function")throw new TypeError("resolver must be a function");this.state=fe,this.queue=[],this.outcome=void 0,X!==y&&K(this,X)}z.prototype.catch=function(X){return this.then(null,X)},z.prototype.then=function(X,ae){if(typeof X!="function"&&this.state===W||typeof ae!="function"&&this.state===D)return this;var oe=new this.constructor(y);if(this.state!==fe){var _e=this.state===W?X:ae;q(oe,_e,this.outcome)}else this.queue.push(new U(oe,X,ae));return oe};function U(X,ae,oe){this.promise=X,typeof ae=="function"&&(this.onFulfilled=ae,this.callFulfilled=this.otherCallFulfilled),typeof oe=="function"&&(this.onRejected=oe,this.callRejected=this.otherCallRejected)}U.prototype.callFulfilled=function(X){b.resolve(this.promise,X)},U.prototype.otherCallFulfilled=function(X){q(this.promise,this.onFulfilled,X)},U.prototype.callRejected=function(X){b.reject(this.promise,X)},U.prototype.otherCallRejected=function(X){q(this.promise,this.onRejected,X)};function q(X,ae,oe){m(function(){var _e;try{_e=ae(oe)}catch(He){return b.reject(X,He)}_e===X?b.reject(X,new TypeError("Cannot resolve promise with itself")):b.resolve(X,_e)})}b.resolve=function(X,ae){var oe=xe(de,ae);if(oe.status==="error")return b.reject(X,oe.value);var _e=oe.value;if(_e)K(X,_e);else{X.state=W,X.outcome=ae;for(var He=-1,Me=X.queue.length;++He<Me;)X.queue[He].callFulfilled(ae)}return X},b.reject=function(X,ae){X.state=D,X.outcome=ae;for(var oe=-1,_e=X.queue.length;++oe<_e;)X.queue[oe].callRejected(ae);return X};function de(X){var ae=X&&X.then;if(X&&(typeof X=="object"||typeof X=="function")&&typeof ae=="function")return function(){ae.apply(X,arguments)}}function K(X,ae){var oe=!1;function _e(Qe){oe||(oe=!0,b.reject(X,Qe))}function He(Qe){oe||(oe=!0,b.resolve(X,Qe))}function Me(){ae(He,_e)}var tt=xe(Me);tt.status==="error"&&_e(tt.value)}function xe(X,ae){var oe={};try{oe.value=X(ae),oe.status="success"}catch(_e){oe.status="error",oe.value=_e}return oe}z.resolve=Ce;function Ce(X){return X instanceof this?X:b.resolve(new this(y),X)}z.reject=be;function be(X){var ae=new this(y);return b.reject(ae,X)}z.all=Se;function Se(X){var ae=this;if(Object.prototype.toString.call(X)!=="[object Array]")return this.reject(new TypeError("must be an array"));var oe=X.length,_e=!1;if(!oe)return this.resolve([]);for(var He=new Array(oe),Me=0,tt=-1,Qe=new this(y);++tt<oe;)mt(X[tt],tt);return Qe;function mt(rr,wr){ae.resolve(rr).then(Ir,function(Yt){_e||(_e=!0,b.reject(Qe,Yt))});function Ir(Yt){He[wr]=Yt,++Me===oe&&!_e&&(_e=!0,b.resolve(Qe,He))}}}z.race=o;function o(X){var ae=this;if(Object.prototype.toString.call(X)!=="[object Array]")return this.reject(new TypeError("must be an array"));var oe=X.length,_e=!1;if(!oe)return this.resolve([]);for(var He=-1,Me=new this(y);++He<oe;)tt(X[He]);return Me;function tt(Qe){ae.resolve(Qe).then(function(mt){_e||(_e=!0,b.resolve(Me,mt))},function(mt){_e||(_e=!0,b.reject(Me,mt))})}}},{"1":1}],3:[function(a,u,d){(function(m){"use strict";typeof m.Promise!="function"&&(m.Promise=a(2))}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{"2":2}],4:[function(a,u,d){"use strict";var m=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(p){return typeof p}:function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p};function y(p,S){if(!(p instanceof S))throw new TypeError("Cannot call a class as a function")}function b(){try{if(typeof indexedDB!="undefined")return indexedDB;if(typeof webkitIndexedDB!="undefined")return webkitIndexedDB;if(typeof mozIndexedDB!="undefined")return mozIndexedDB;if(typeof OIndexedDB!="undefined")return OIndexedDB;if(typeof msIndexedDB!="undefined")return msIndexedDB}catch(p){return}}var D=b();function W(){try{if(!D||!D.open)return!1;var p=typeof openDatabase!="undefined"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),S=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!p||S)&&typeof indexedDB!="undefined"&&typeof IDBKeyRange!="undefined"}catch(v){return!1}}function fe(p,S){p=p||[],S=S||{};try{return new Blob(p,S)}catch(_){if(_.name!=="TypeError")throw _;for(var v=typeof BlobBuilder!="undefined"?BlobBuilder:typeof MSBlobBuilder!="undefined"?MSBlobBuilder:typeof MozBlobBuilder!="undefined"?MozBlobBuilder:WebKitBlobBuilder,C=new v,k=0;k<p.length;k+=1)C.append(p[k]);return C.getBlob(S.type)}}typeof Promise=="undefined"&&a(3);var z=Promise;function U(p,S){S&&p.then(function(v){S(null,v)},function(v){S(v)})}function q(p,S,v){typeof S=="function"&&p.then(S),typeof v=="function"&&p.catch(v)}function de(p){return typeof p!="string"&&(console.warn(p+" used as a key, but it is not a string."),p=String(p)),p}function K(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var xe="local-forage-detect-blob-support",Ce=void 0,be={},Se=Object.prototype.toString,o="readonly",X="readwrite";function ae(p){for(var S=p.length,v=new ArrayBuffer(S),C=new Uint8Array(v),k=0;k<S;k++)C[k]=p.charCodeAt(k);return v}function oe(p){return new z(function(S){var v=p.transaction(xe,X),C=fe([""]);v.objectStore(xe).put(C,"key"),v.onabort=function(k){k.preventDefault(),k.stopPropagation(),S(!1)},v.oncomplete=function(){var k=navigator.userAgent.match(/Chrome\/(\d+)/),_=navigator.userAgent.match(/Edge\//);S(_||!k||parseInt(k[1],10)>=43)}}).catch(function(){return!1})}function _e(p){return typeof Ce=="boolean"?z.resolve(Ce):oe(p).then(function(S){return Ce=S,Ce})}function He(p){var S=be[p.name],v={};v.promise=new z(function(C,k){v.resolve=C,v.reject=k}),S.deferredOperations.push(v),S.dbReady?S.dbReady=S.dbReady.then(function(){return v.promise}):S.dbReady=v.promise}function Me(p){var S=be[p.name],v=S.deferredOperations.pop();if(v)return v.resolve(),v.promise}function tt(p,S){var v=be[p.name],C=v.deferredOperations.pop();if(C)return C.reject(S),C.promise}function Qe(p,S){return new z(function(v,C){if(be[p.name]=be[p.name]||ir(),p.db)if(S)He(p),p.db.close();else return v(p.db);var k=[p.name];S&&k.push(p.version);var _=D.open.apply(D,k);S&&(_.onupgradeneeded=function(N){var j=_.result;try{j.createObjectStore(p.storeName),N.oldVersion<=1&&j.createObjectStore(xe)}catch(V){if(V.name==="ConstraintError")console.warn('The database "'+p.name+'" has been upgraded from version '+N.oldVersion+" to version "+N.newVersion+', but the storage "'+p.storeName+'" already exists.');else throw V}}),_.onerror=function(N){N.preventDefault(),C(_.error)},_.onsuccess=function(){var N=_.result;N.onversionchange=function(j){j.target.close()},v(N),Me(p)}})}function mt(p){return Qe(p,!1)}function rr(p){return Qe(p,!0)}function wr(p,S){if(!p.db)return!0;var v=!p.db.objectStoreNames.contains(p.storeName),C=p.version<p.db.version,k=p.version>p.db.version;if(C&&(p.version!==S&&console.warn('The database "'+p.name+`" can't be downgraded from version `+p.db.version+" to version "+p.version+"."),p.version=p.db.version),k||v){if(v){var _=p.db.version+1;_>p.version&&(p.version=_)}return!0}return!1}function Ir(p){return new z(function(S,v){var C=new FileReader;C.onerror=v,C.onloadend=function(k){var _=btoa(k.target.result||"");S({__local_forage_encoded_blob:!0,data:_,type:p.type})},C.readAsBinaryString(p)})}function Yt(p){var S=ae(atob(p.data));return fe([S],{type:p.type})}function Mr(p){return p&&p.__local_forage_encoded_blob}function vt(p){var S=this,v=S._initReady().then(function(){var C=be[S._dbInfo.name];if(C&&C.dbReady)return C.dbReady});return q(v,p,p),v}function An(p){He(p);for(var S=be[p.name],v=S.forages,C=0;C<v.length;C++){var k=v[C];k._dbInfo.db&&(k._dbInfo.db.close(),k._dbInfo.db=null)}return p.db=null,mt(p).then(function(_){return p.db=_,wr(p)?rr(p):_}).then(function(_){p.db=S.db=_;for(var N=0;N<v.length;N++)v[N]._dbInfo.db=_}).catch(function(_){throw tt(p,_),_})}function Je(p,S,v,C){C===void 0&&(C=1);try{var k=p.db.transaction(p.storeName,S);v(null,k)}catch(_){if(C>0&&(!p.db||_.name==="InvalidStateError"||_.name==="NotFoundError"))return z.resolve().then(function(){if(!p.db||_.name==="NotFoundError"&&!p.db.objectStoreNames.contains(p.storeName)&&p.version<=p.db.version)return p.db&&(p.version=p.db.version+1),rr(p)}).then(function(){return An(p).then(function(){Je(p,S,v,C-1)})}).catch(v);v(_)}}function ir(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function Pi(p){var S=this,v={db:null};if(p)for(var C in p)v[C]=p[C];var k=be[v.name];k||(k=ir(),be[v.name]=k),k.forages.push(S),S._initReady||(S._initReady=S.ready,S.ready=vt);var _=[];function N(){return z.resolve()}for(var j=0;j<k.forages.length;j++){var V=k.forages[j];V!==S&&_.push(V._initReady().catch(N))}var G=k.forages.slice(0);return z.all(_).then(function(){return v.db=k.db,mt(v)}).then(function(Y){return v.db=Y,wr(v,S._defaultConfig.version)?rr(v):Y}).then(function(Y){v.db=k.db=Y,S._dbInfo=v;for(var Z=0;Z<G.length;Z++){var ye=G[Z];ye!==S&&(ye._dbInfo.db=v.db,ye._dbInfo.version=v.version)}})}function Fn(p,S){var v=this;p=de(p);var C=new z(function(k,_){v.ready().then(function(){Je(v._dbInfo,o,function(N,j){if(N)return _(N);try{var V=j.objectStore(v._dbInfo.storeName),G=V.get(p);G.onsuccess=function(){var Y=G.result;Y===void 0&&(Y=null),Mr(Y)&&(Y=Yt(Y)),k(Y)},G.onerror=function(){_(G.error)}}catch(Y){_(Y)}})}).catch(_)});return U(C,S),C}function Nr(p,S){var v=this,C=new z(function(k,_){v.ready().then(function(){Je(v._dbInfo,o,function(N,j){if(N)return _(N);try{var V=j.objectStore(v._dbInfo.storeName),G=V.openCursor(),Y=1;G.onsuccess=function(){var Z=G.result;if(Z){var ye=Z.value;Mr(ye)&&(ye=Yt(ye));var ke=p(ye,Z.key,Y++);ke!==void 0?k(ke):Z.continue()}else k()},G.onerror=function(){_(G.error)}}catch(Z){_(Z)}})}).catch(_)});return U(C,S),C}function Er(p,S,v){var C=this;p=de(p);var k=new z(function(_,N){var j;C.ready().then(function(){return j=C._dbInfo,Se.call(S)==="[object Blob]"?_e(j.db).then(function(V){return V?S:Ir(S)}):S}).then(function(V){Je(C._dbInfo,X,function(G,Y){if(G)return N(G);try{var Z=Y.objectStore(C._dbInfo.storeName);V===null&&(V=void 0);var ye=Z.put(V,p);Y.oncomplete=function(){V===void 0&&(V=null),_(V)},Y.onabort=Y.onerror=function(){var ke=ye.error?ye.error:ye.transaction.error;N(ke)}}catch(ke){N(ke)}})}).catch(N)});return U(k,v),k}function _t(p,S){var v=this;p=de(p);var C=new z(function(k,_){v.ready().then(function(){Je(v._dbInfo,X,function(N,j){if(N)return _(N);try{var V=j.objectStore(v._dbInfo.storeName),G=V.delete(p);j.oncomplete=function(){k()},j.onerror=function(){_(G.error)},j.onabort=function(){var Y=G.error?G.error:G.transaction.error;_(Y)}}catch(Y){_(Y)}})}).catch(_)});return U(C,S),C}function Dn(p){var S=this,v=new z(function(C,k){S.ready().then(function(){Je(S._dbInfo,X,function(_,N){if(_)return k(_);try{var j=N.objectStore(S._dbInfo.storeName),V=j.clear();N.oncomplete=function(){C()},N.onabort=N.onerror=function(){var G=V.error?V.error:V.transaction.error;k(G)}}catch(G){k(G)}})}).catch(k)});return U(v,p),v}function Ln(p){var S=this,v=new z(function(C,k){S.ready().then(function(){Je(S._dbInfo,o,function(_,N){if(_)return k(_);try{var j=N.objectStore(S._dbInfo.storeName),V=j.count();V.onsuccess=function(){C(V.result)},V.onerror=function(){k(V.error)}}catch(G){k(G)}})}).catch(k)});return U(v,p),v}function Rn(p,S){var v=this,C=new z(function(k,_){if(p<0){k(null);return}v.ready().then(function(){Je(v._dbInfo,o,function(N,j){if(N)return _(N);try{var V=j.objectStore(v._dbInfo.storeName),G=!1,Y=V.openKeyCursor();Y.onsuccess=function(){var Z=Y.result;if(!Z){k(null);return}p===0||G?k(Z.key):(G=!0,Z.advance(p))},Y.onerror=function(){_(Y.error)}}catch(Z){_(Z)}})}).catch(_)});return U(C,S),C}function bt(p){var S=this,v=new z(function(C,k){S.ready().then(function(){Je(S._dbInfo,o,function(_,N){if(_)return k(_);try{var j=N.objectStore(S._dbInfo.storeName),V=j.openKeyCursor(),G=[];V.onsuccess=function(){var Y=V.result;if(!Y){C(G);return}G.push(Y.key),Y.continue()},V.onerror=function(){k(V.error)}}catch(Y){k(Y)}})}).catch(k)});return U(v,p),v}function nr(p,S){S=K.apply(this,arguments);var v=this.config();p=typeof p!="function"&&p||{},p.name||(p.name=p.name||v.name,p.storeName=p.storeName||v.storeName);var C=this,k;if(!p.name)k=z.reject("Invalid arguments");else{var _=p.name===v.name&&C._dbInfo.db,N=_?z.resolve(C._dbInfo.db):mt(p).then(function(j){var V=be[p.name],G=V.forages;V.db=j;for(var Y=0;Y<G.length;Y++)G[Y]._dbInfo.db=j;return j});p.storeName?k=N.then(function(j){if(!!j.objectStoreNames.contains(p.storeName)){var V=j.version+1;He(p);var G=be[p.name],Y=G.forages;j.close();for(var Z=0;Z<Y.length;Z++){var ye=Y[Z];ye._dbInfo.db=null,ye._dbInfo.version=V}var ke=new z(function(Pe,We){var Le=D.open(p.name,V);Le.onerror=function(it){var jt=Le.result;jt.close(),We(it)},Le.onupgradeneeded=function(){var it=Le.result;it.deleteObjectStore(p.storeName)},Le.onsuccess=function(){var it=Le.result;it.close(),Pe(it)}});return ke.then(function(Pe){G.db=Pe;for(var We=0;We<Y.length;We++){var Le=Y[We];Le._dbInfo.db=Pe,Me(Le._dbInfo)}}).catch(function(Pe){throw(tt(p,Pe)||z.resolve()).catch(function(){}),Pe})}}):k=N.then(function(j){He(p);var V=be[p.name],G=V.forages;j.close();for(var Y=0;Y<G.length;Y++){var Z=G[Y];Z._dbInfo.db=null}var ye=new z(function(ke,Pe){var We=D.deleteDatabase(p.name);We.onerror=function(){var Le=We.result;Le&&Le.close(),Pe(We.error)},We.onblocked=function(){console.warn('dropInstance blocked for database "'+p.name+'" until all open connections are closed')},We.onsuccess=function(){var Le=We.result;Le&&Le.close(),ke(Le)}});return ye.then(function(ke){V.db=ke;for(var Pe=0;Pe<G.length;Pe++){var We=G[Pe];Me(We._dbInfo)}}).catch(function(ke){throw(tt(p,ke)||z.resolve()).catch(function(){}),ke})})}return U(k,S),k}var ar={_driver:"asyncStorage",_initStorage:Pi,_support:W(),iterate:Nr,getItem:Fn,setItem:Er,removeItem:_t,clear:Dn,length:Ln,key:Rn,keys:bt,dropInstance:nr};function le(){return typeof openDatabase=="function"}var $e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",In="~~local_forage_type~",Ai=/^~~local_forage_type~([^~]+)~/,Sr="__lfsc__:",_r=Sr.length,Tr="arbf",Mt="blob",yt="si08",At="ui08",Nt="uic8",Fi="si16",sr="si32",Or="ur16",$r="ui32",Di="fl32",Ot="fl64",Xt=_r+Tr.length,Wr=Object.prototype.toString;function jr(p){var S=p.length*.75,v=p.length,C,k=0,_,N,j,V;p[p.length-1]==="="&&(S--,p[p.length-2]==="="&&S--);var G=new ArrayBuffer(S),Y=new Uint8Array(G);for(C=0;C<v;C+=4)_=$e.indexOf(p[C]),N=$e.indexOf(p[C+1]),j=$e.indexOf(p[C+2]),V=$e.indexOf(p[C+3]),Y[k++]=_<<2|N>>4,Y[k++]=(N&15)<<4|j>>2,Y[k++]=(j&3)<<6|V&63;return G}function Ke(p){var S=new Uint8Array(p),v="",C;for(C=0;C<S.length;C+=3)v+=$e[S[C]>>2],v+=$e[(S[C]&3)<<4|S[C+1]>>4],v+=$e[(S[C+1]&15)<<2|S[C+2]>>6],v+=$e[S[C+2]&63];return S.length%3==2?v=v.substring(0,v.length-1)+"=":S.length%3==1&&(v=v.substring(0,v.length-2)+"=="),v}function Ze(p,S){var v="";if(p&&(v=Wr.call(p)),p&&(v==="[object ArrayBuffer]"||p.buffer&&Wr.call(p.buffer)==="[object ArrayBuffer]")){var C,k=Sr;p instanceof ArrayBuffer?(C=p,k+=Tr):(C=p.buffer,v==="[object Int8Array]"?k+=yt:v==="[object Uint8Array]"?k+=At:v==="[object Uint8ClampedArray]"?k+=Nt:v==="[object Int16Array]"?k+=Fi:v==="[object Uint16Array]"?k+=Or:v==="[object Int32Array]"?k+=sr:v==="[object Uint32Array]"?k+=$r:v==="[object Float32Array]"?k+=Di:v==="[object Float64Array]"?k+=Ot:S(new Error("Failed to get type for BinaryArray"))),S(k+Ke(C))}else if(v==="[object Blob]"){var _=new FileReader;_.onload=function(){var N=In+p.type+"~"+Ke(this.result);S(Sr+Mt+N)},_.readAsArrayBuffer(p)}else try{S(JSON.stringify(p))}catch(N){console.error("Couldn't convert value into a JSON string: ",p),S(null,N)}}function Br(p){if(p.substring(0,_r)!==Sr)return JSON.parse(p);var S=p.substring(Xt),v=p.substring(_r,Xt),C;if(v===Mt&&Ai.test(S)){var k=S.match(Ai);C=k[1],S=S.substring(k[0].length)}var _=jr(S);switch(v){case Tr:return _;case Mt:return fe([_],{type:C});case yt:return new Int8Array(_);case At:return new Uint8Array(_);case Nt:return new Uint8ClampedArray(_);case Fi:return new Int16Array(_);case Or:return new Uint16Array(_);case sr:return new Int32Array(_);case $r:return new Uint32Array(_);case Di:return new Float32Array(_);case Ot:return new Float64Array(_);default:throw new Error("Unkown type: "+v)}}var Hr={serialize:Ze,deserialize:Br,stringToBuffer:jr,bufferToString:Ke};function Ur(p,S,v,C){p.executeSql("CREATE TABLE IF NOT EXISTS "+S.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],v,C)}function Li(p){var S=this,v={db:null};if(p)for(var C in p)v[C]=typeof p[C]!="string"?p[C].toString():p[C];var k=new z(function(_,N){try{v.db=openDatabase(v.name,String(v.version),v.description,v.size)}catch(j){return N(j)}v.db.transaction(function(j){Ur(j,v,function(){S._dbInfo=v,_()},function(V,G){N(G)})},N)});return v.serializer=Hr,k}function rt(p,S,v,C,k,_){p.executeSql(v,C,k,function(N,j){j.code===j.SYNTAX_ERR?N.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[S.storeName],function(V,G){G.rows.length?_(V,j):Ur(V,S,function(){V.executeSql(v,C,k,_)},_)},_):_(N,j)},_)}function Qt(p,S){var v=this;p=de(p);var C=new z(function(k,_){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function(j){rt(j,N,"SELECT * FROM "+N.storeName+" WHERE key = ? LIMIT 1",[p],function(V,G){var Y=G.rows.length?G.rows.item(0).value:null;Y&&(Y=N.serializer.deserialize(Y)),k(Y)},function(V,G){_(G)})})}).catch(_)});return U(C,S),C}function Mn(p,S){var v=this,C=new z(function(k,_){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function(j){rt(j,N,"SELECT * FROM "+N.storeName,[],function(V,G){for(var Y=G.rows,Z=Y.length,ye=0;ye<Z;ye++){var ke=Y.item(ye),Pe=ke.value;if(Pe&&(Pe=N.serializer.deserialize(Pe)),Pe=p(Pe,ke.key,ye+1),Pe!==void 0){k(Pe);return}}k()},function(V,G){_(G)})})}).catch(_)});return U(C,S),C}function Ri(p,S,v,C){var k=this;p=de(p);var _=new z(function(N,j){k.ready().then(function(){S===void 0&&(S=null);var V=S,G=k._dbInfo;G.serializer.serialize(S,function(Y,Z){Z?j(Z):G.db.transaction(function(ye){rt(ye,G,"INSERT OR REPLACE INTO "+G.storeName+" (key, value) VALUES (?, ?)",[p,Y],function(){N(V)},function(ke,Pe){j(Pe)})},function(ye){if(ye.code===ye.QUOTA_ERR){if(C>0){N(Ri.apply(k,[p,V,v,C-1]));return}j(ye)}})})}).catch(j)});return U(_,v),_}function zr(p,S,v){return Ri.apply(this,[p,S,v,1])}function Cr(p,S){var v=this;p=de(p);var C=new z(function(k,_){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function(j){rt(j,N,"DELETE FROM "+N.storeName+" WHERE key = ?",[p],function(){k()},function(V,G){_(G)})})}).catch(_)});return U(C,S),C}function Nn(p){var S=this,v=new z(function(C,k){S.ready().then(function(){var _=S._dbInfo;_.db.transaction(function(N){rt(N,_,"DELETE FROM "+_.storeName,[],function(){C()},function(j,V){k(V)})})}).catch(k)});return U(v,p),v}function On(p){var S=this,v=new z(function(C,k){S.ready().then(function(){var _=S._dbInfo;_.db.transaction(function(N){rt(N,_,"SELECT COUNT(key) as c FROM "+_.storeName,[],function(j,V){var G=V.rows.item(0).c;C(G)},function(j,V){k(V)})})}).catch(k)});return U(v,p),v}function $n(p,S){var v=this,C=new z(function(k,_){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function(j){rt(j,N,"SELECT key FROM "+N.storeName+" WHERE id = ? LIMIT 1",[p+1],function(V,G){var Y=G.rows.length?G.rows.item(0).key:null;k(Y)},function(V,G){_(G)})})}).catch(_)});return U(C,S),C}function Ii(p){var S=this,v=new z(function(C,k){S.ready().then(function(){var _=S._dbInfo;_.db.transaction(function(N){rt(N,_,"SELECT key FROM "+_.storeName,[],function(j,V){for(var G=[],Y=0;Y<V.rows.length;Y++)G.push(V.rows.item(Y).key);C(G)},function(j,V){k(V)})})}).catch(k)});return U(v,p),v}function Wn(p){return new z(function(S,v){p.transaction(function(C){C.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(k,_){for(var N=[],j=0;j<_.rows.length;j++)N.push(_.rows.item(j).name);S({db:p,storeNames:N})},function(k,_){v(_)})},function(C){v(C)})})}function jn(p,S){S=K.apply(this,arguments);var v=this.config();p=typeof p!="function"&&p||{},p.name||(p.name=p.name||v.name,p.storeName=p.storeName||v.storeName);var C=this,k;return p.name?k=new z(function(_){var N;p.name===v.name?N=C._dbInfo.db:N=openDatabase(p.name,"","",0),p.storeName?_({db:N,storeNames:[p.storeName]}):_(Wn(N))}).then(function(_){return new z(function(N,j){_.db.transaction(function(V){function G(ke){return new z(function(Pe,We){V.executeSql("DROP TABLE IF EXISTS "+ke,[],function(){Pe()},function(Le,it){We(it)})})}for(var Y=[],Z=0,ye=_.storeNames.length;Z<ye;Z++)Y.push(G(_.storeNames[Z]));z.all(Y).then(function(){N()}).catch(function(ke){j(ke)})},function(V){j(V)})})}):k=z.reject("Invalid arguments"),U(k,S),k}var Mi={_driver:"webSQLStorage",_initStorage:Li,_support:le(),iterate:Mn,getItem:Qt,setItem:zr,removeItem:Cr,clear:Nn,length:On,key:$n,keys:Ii,dropInstance:jn};function Bn(){try{return typeof localStorage!="undefined"&&"setItem"in localStorage&&!!localStorage.setItem}catch(p){return!1}}function $t(p,S){var v=p.name+"/";return p.storeName!==S.storeName&&(v+=p.storeName+"/"),v}function Ni(){var p="_localforage_support_test";try{return localStorage.setItem(p,!0),localStorage.removeItem(p),!1}catch(S){return!0}}function qr(){return!Ni()||localStorage.length>0}function Vr(p){var S=this,v={};if(p)for(var C in p)v[C]=p[C];return v.keyPrefix=$t(p,S._defaultConfig),qr()?(S._dbInfo=v,v.serializer=Hr,z.resolve()):z.reject()}function kr(p){var S=this,v=S.ready().then(function(){for(var C=S._dbInfo.keyPrefix,k=localStorage.length-1;k>=0;k--){var _=localStorage.key(k);_.indexOf(C)===0&&localStorage.removeItem(_)}});return U(v,p),v}function Oi(p,S){var v=this;p=de(p);var C=v.ready().then(function(){var k=v._dbInfo,_=localStorage.getItem(k.keyPrefix+p);return _&&(_=k.serializer.deserialize(_)),_});return U(C,S),C}function Hn(p,S){var v=this,C=v.ready().then(function(){for(var k=v._dbInfo,_=k.keyPrefix,N=_.length,j=localStorage.length,V=1,G=0;G<j;G++){var Y=localStorage.key(G);if(Y.indexOf(_)===0){var Z=localStorage.getItem(Y);if(Z&&(Z=k.serializer.deserialize(Z)),Z=p(Z,Y.substring(N),V++),Z!==void 0)return Z}}});return U(C,S),C}function $i(p,S){var v=this,C=v.ready().then(function(){var k=v._dbInfo,_;try{_=localStorage.key(p)}catch(N){_=null}return _&&(_=_.substring(k.keyPrefix.length)),_});return U(C,S),C}function Un(p){var S=this,v=S.ready().then(function(){for(var C=S._dbInfo,k=localStorage.length,_=[],N=0;N<k;N++){var j=localStorage.key(N);j.indexOf(C.keyPrefix)===0&&_.push(j.substring(C.keyPrefix.length))}return _});return U(v,p),v}function or(p){var S=this,v=S.keys().then(function(C){return C.length});return U(v,p),v}function Wi(p,S){var v=this;p=de(p);var C=v.ready().then(function(){var k=v._dbInfo;localStorage.removeItem(k.keyPrefix+p)});return U(C,S),C}function ji(p,S,v){var C=this;p=de(p);var k=C.ready().then(function(){S===void 0&&(S=null);var _=S;return new z(function(N,j){var V=C._dbInfo;V.serializer.serialize(S,function(G,Y){if(Y)j(Y);else try{localStorage.setItem(V.keyPrefix+p,G),N(_)}catch(Z){(Z.name==="QuotaExceededError"||Z.name==="NS_ERROR_DOM_QUOTA_REACHED")&&j(Z),j(Z)}})})});return U(k,v),k}function Bi(p,S){if(S=K.apply(this,arguments),p=typeof p!="function"&&p||{},!p.name){var v=this.config();p.name=p.name||v.name,p.storeName=p.storeName||v.storeName}var C=this,k;return p.name?k=new z(function(_){p.storeName?_($t(p,C._defaultConfig)):_(p.name+"/")}).then(function(_){for(var N=localStorage.length-1;N>=0;N--){var j=localStorage.key(N);j.indexOf(_)===0&&localStorage.removeItem(j)}}):k=z.reject("Invalid arguments"),U(k,S),k}var Hi={_driver:"localStorageWrapper",_initStorage:Vr,_support:Bn(),iterate:Hn,getItem:Oi,setItem:ji,removeItem:Wi,clear:kr,length:or,key:$i,keys:Un,dropInstance:Bi},zn=function(S,v){return S===v||typeof S=="number"&&typeof v=="number"&&isNaN(S)&&isNaN(v)},Gr=function(S,v){for(var C=S.length,k=0;k<C;){if(zn(S[k],v))return!0;k++}return!1},Ui=Array.isArray||function(p){return Object.prototype.toString.call(p)==="[object Array]"},lr={},Yr={},Wt={INDEXEDDB:ar,WEBSQL:Mi,LOCALSTORAGE:Hi},Xr=[Wt.INDEXEDDB._driver,Wt.WEBSQL._driver,Wt.LOCALSTORAGE._driver],ur=["dropInstance"],Ge=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(ur),Jt={description:"",driver:Xr.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Pr(p,S){p[S]=function(){var v=arguments;return p.ready().then(function(){return p[S].apply(p,v)})}}function Qr(){for(var p=1;p<arguments.length;p++){var S=arguments[p];if(S)for(var v in S)S.hasOwnProperty(v)&&(Ui(S[v])?arguments[0][v]=S[v].slice():arguments[0][v]=S[v])}return arguments[0]}var qn=function(){function p(S){y(this,p);for(var v in Wt)if(Wt.hasOwnProperty(v)){var C=Wt[v],k=C._driver;this[v]=k,lr[k]||this.defineDriver(C)}this._defaultConfig=Qr({},Jt),this._config=Qr({},this._defaultConfig,S),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return p.prototype.config=function(v){if((typeof v=="undefined"?"undefined":m(v))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var C in v){if(C==="storeName"&&(v[C]=v[C].replace(/\W/g,"_")),C==="version"&&typeof v[C]!="number")return new Error("Database version must be a number.");this._config[C]=v[C]}return"driver"in v&&v.driver?this.setDriver(this._config.driver):!0}else return typeof v=="string"?this._config[v]:this._config},p.prototype.defineDriver=function(v,C,k){var _=new z(function(N,j){try{var V=v._driver,G=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!v._driver){j(G);return}for(var Y=Ge.concat("_initStorage"),Z=0,ye=Y.length;Z<ye;Z++){var ke=Y[Z],Pe=!Gr(ur,ke);if((Pe||v[ke])&&typeof v[ke]!="function"){j(G);return}}var We=function(){for(var jt=function(ei){return function(){var Vn=new Error("Method "+ei+" is not implemented by the current driver"),qi=z.reject(Vn);return U(qi,arguments[arguments.length-1]),qi}},Kr=0,zi=ur.length;Kr<zi;Kr++){var Zr=ur[Kr];v[Zr]||(v[Zr]=jt(Zr))}};We();var Le=function(jt){lr[V]&&console.info("Redefining LocalForage driver: "+V),lr[V]=v,Yr[V]=jt,N()};"_support"in v?v._support&&typeof v._support=="function"?v._support().then(Le,j):Le(!!v._support):Le(!0)}catch(it){j(it)}});return q(_,C,k),_},p.prototype.driver=function(){return this._driver||null},p.prototype.getDriver=function(v,C,k){var _=lr[v]?z.resolve(lr[v]):z.reject(new Error("Driver not found."));return q(_,C,k),_},p.prototype.getSerializer=function(v){var C=z.resolve(Hr);return q(C,v),C},p.prototype.ready=function(v){var C=this,k=C._driverSet.then(function(){return C._ready===null&&(C._ready=C._initDriver()),C._ready});return q(k,v,v),k},p.prototype.setDriver=function(v,C,k){var _=this;Ui(v)||(v=[v]);var N=this._getSupportedDrivers(v);function j(){_._config.driver=_.driver()}function V(Z){return _._extend(Z),j(),_._ready=_._initStorage(_._config),_._ready}function G(Z){return function(){var ye=0;function ke(){for(;ye<Z.length;){var Pe=Z[ye];return ye++,_._dbInfo=null,_._ready=null,_.getDriver(Pe).then(V).catch(ke)}j();var We=new Error("No available storage method found.");return _._driverSet=z.reject(We),_._driverSet}return ke()}}var Y=this._driverSet!==null?this._driverSet.catch(function(){return z.resolve()}):z.resolve();return this._driverSet=Y.then(function(){var Z=N[0];return _._dbInfo=null,_._ready=null,_.getDriver(Z).then(function(ye){_._driver=ye._driver,j(),_._wrapLibraryMethodsWithReady(),_._initDriver=G(N)})}).catch(function(){j();var Z=new Error("No available storage method found.");return _._driverSet=z.reject(Z),_._driverSet}),q(this._driverSet,C,k),this._driverSet},p.prototype.supports=function(v){return!!Yr[v]},p.prototype._extend=function(v){Qr(this,v)},p.prototype._getSupportedDrivers=function(v){for(var C=[],k=0,_=v.length;k<_;k++){var N=v[k];this.supports(N)&&C.push(N)}return C},p.prototype._wrapLibraryMethodsWithReady=function(){for(var v=0,C=Ge.length;v<C;v++)Pr(this,Ge[v])},p.prototype.createInstance=function(v){return new p(v)},p}(),Jr=new qn;u.exports=Jr},{"3":3}]},{},[4])(4)})});var Ws=ws(($s,ln)=>{(function(l,t){"use strict";typeof ln=="object"&&typeof ln.exports=="object"?ln.exports=l.document?t(l,!0):function(i){if(!i.document)throw new Error("jQuery requires a window with a document");return t(i)}:t(l)})(typeof window!="undefined"?window:$s,function(l,t){"use strict";var i=[],a=Object.getPrototypeOf,u=i.slice,d=i.flat?function(e){return i.flat.call(e)}:function(e){return i.concat.apply([],e)},m=i.push,y=i.indexOf,b={},D=b.toString,W=b.hasOwnProperty,fe=W.toString,z=fe.call(Object),U={},q=function(r){return typeof r=="function"&&typeof r.nodeType!="number"&&typeof r.item!="function"},de=function(r){return r!=null&&r===r.window},K=l.document,xe={type:!0,src:!0,nonce:!0,noModule:!0};function Ce(e,r,n){n=n||K;var s,c,f=n.createElement("script");if(f.text=e,r)for(s in xe)c=r[s]||r.getAttribute&&r.getAttribute(s),c&&f.setAttribute(s,c);n.head.appendChild(f).parentNode.removeChild(f)}function be(e){return e==null?e+"":typeof e=="object"||typeof e=="function"?b[D.call(e)]||"object":typeof e}var Se="3.6.3",o=function(e,r){return new o.fn.init(e,r)};o.fn=o.prototype={jquery:Se,constructor:o,length:0,toArray:function(){return u.call(this)},get:function(e){return e==null?u.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var r=o.merge(this.constructor(),e);return r.prevObject=this,r},each:function(e){return o.each(this,e)},map:function(e){return this.pushStack(o.map(this,function(r,n){return e.call(r,n,r)}))},slice:function(){return this.pushStack(u.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(o.grep(this,function(e,r){return(r+1)%2}))},odd:function(){return this.pushStack(o.grep(this,function(e,r){return r%2}))},eq:function(e){var r=this.length,n=+e+(e<0?r:0);return this.pushStack(n>=0&&n<r?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:m,sort:i.sort,splice:i.splice},o.extend=o.fn.extend=function(){var e,r,n,s,c,f,h=arguments[0]||{},E=1,x=arguments.length,F=!1;for(typeof h=="boolean"&&(F=h,h=arguments[E]||{},E++),typeof h!="object"&&!q(h)&&(h={}),E===x&&(h=this,E--);E<x;E++)if((e=arguments[E])!=null)for(r in e)s=e[r],!(r==="__proto__"||h===s)&&(F&&s&&(o.isPlainObject(s)||(c=Array.isArray(s)))?(n=h[r],c&&!Array.isArray(n)?f=[]:!c&&!o.isPlainObject(n)?f={}:f=n,c=!1,h[r]=o.extend(F,f,s)):s!==void 0&&(h[r]=s));return h},o.extend({expando:"jQuery"+(Se+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var r,n;return!e||D.call(e)!=="[object Object]"?!1:(r=a(e),r?(n=W.call(r,"constructor")&&r.constructor,typeof n=="function"&&fe.call(n)===z):!0)},isEmptyObject:function(e){var r;for(r in e)return!1;return!0},globalEval:function(e,r,n){Ce(e,{nonce:r&&r.nonce},n)},each:function(e,r){var n,s=0;if(X(e))for(n=e.length;s<n&&r.call(e[s],s,e[s])!==!1;s++);else for(s in e)if(r.call(e[s],s,e[s])===!1)break;return e},makeArray:function(e,r){var n=r||[];return e!=null&&(X(Object(e))?o.merge(n,typeof e=="string"?[e]:e):m.call(n,e)),n},inArray:function(e,r,n){return r==null?-1:y.call(r,e,n)},merge:function(e,r){for(var n=+r.length,s=0,c=e.length;s<n;s++)e[c++]=r[s];return e.length=c,e},grep:function(e,r,n){for(var s,c=[],f=0,h=e.length,E=!n;f<h;f++)s=!r(e[f],f),s!==E&&c.push(e[f]);return c},map:function(e,r,n){var s,c,f=0,h=[];if(X(e))for(s=e.length;f<s;f++)c=r(e[f],f,n),c!=null&&h.push(c);else for(f in e)c=r(e[f],f,n),c!=null&&h.push(c);return d(h)},guid:1,support:U}),typeof Symbol=="function"&&(o.fn[Symbol.iterator]=i[Symbol.iterator]),o.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,r){b["[object "+r+"]"]=r.toLowerCase()});function X(e){var r=!!e&&"length"in e&&e.length,n=be(e);return q(e)||de(e)?!1:n==="array"||r===0||typeof r=="number"&&r>0&&r-1 in e}var ae=function(e){var r,n,s,c,f,h,E,x,F,R,B,L,I,ne,ve,re,ze,Ue,ct,Fe="sizzle"+1*new Date,me=e.document,ot=0,Te=0,je=Xi(),ri=Xi(),Vi=Xi(),ft=Xi(),cr=function(g,w){return g===w&&(B=!0),0},fr={}.hasOwnProperty,lt=[],Kt=lt.pop,xt=lt.push,Zt=lt.push,ds=lt.slice,dr=function(g,w){for(var T=0,M=g.length;T<M;T++)if(g[T]===w)return T;return-1},Jn="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",Ae="[\\x20\\t\\r\\n\\f]",hr="(?:\\\\[\\da-fA-F]{1,6}"+Ae+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",hs="\\["+Ae+"*("+hr+")(?:"+Ae+"*([*^$|!~]?=)"+Ae+`*(?:'((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)"|(`+hr+"))|)"+Ae+"*\\]",Kn=":("+hr+`)(?:\\((('((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)")|((?:\\\\.|[^\\\\()[\\]]|`+hs+")*)|.*)\\)|)",jo=new RegExp(Ae+"+","g"),Gi=new RegExp("^"+Ae+"+|((?:^|[^\\\\])(?:\\\\.)*)"+Ae+"+$","g"),Bo=new RegExp("^"+Ae+"*,"+Ae+"*"),ps=new RegExp("^"+Ae+"*([>+~]|"+Ae+")"+Ae+"*"),Ho=new RegExp(Ae+"|>"),Uo=new RegExp(Kn),zo=new RegExp("^"+hr+"$"),Yi={ID:new RegExp("^#("+hr+")"),CLASS:new RegExp("^\\.("+hr+")"),TAG:new RegExp("^("+hr+"|[*])"),ATTR:new RegExp("^"+hs),PSEUDO:new RegExp("^"+Kn),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+Ae+"*(even|odd|(([+-]|)(\\d*)n|)"+Ae+"*(?:([+-]|)"+Ae+"*(\\d+)|))"+Ae+"*\\)|)","i"),bool:new RegExp("^(?:"+Jn+")$","i"),needsContext:new RegExp("^"+Ae+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+Ae+"*((?:-\\d)?\\d*)"+Ae+"*\\)|)(?=[^-]|$)","i")},qo=/HTML$/i,Vo=/^(?:input|select|textarea|button)$/i,Go=/^h\d$/i,ii=/^[^{]+\{\s*\[native \w/,Yo=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,Zn=/[+~]/,Bt=new RegExp("\\\\[\\da-fA-F]{1,6}"+Ae+"?|\\\\([^\\r\\n\\f])","g"),Ht=function(g,w){var T="0x"+g.slice(1)-65536;return w||(T<0?String.fromCharCode(T+65536):String.fromCharCode(T>>10|55296,T&1023|56320))},gs=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ms=function(g,w){return w?g==="\0"?"\uFFFD":g.slice(0,-1)+"\\"+g.charCodeAt(g.length-1).toString(16)+" ":"\\"+g},vs=function(){L()},Xo=Ji(function(g){return g.disabled===!0&&g.nodeName.toLowerCase()==="fieldset"},{dir:"parentNode",next:"legend"});try{Zt.apply(lt=ds.call(me.childNodes),me.childNodes),lt[me.childNodes.length].nodeType}catch(g){Zt={apply:lt.length?function(w,T){xt.apply(w,ds.call(T))}:function(w,T){for(var M=w.length,P=0;w[M++]=T[P++];);w.length=M-1}}}function Re(g,w,T,M){var P,O,H,Q,J,ue,se,he=w&&w.ownerDocument,we=w?w.nodeType:9;if(T=T||[],typeof g!="string"||!g||we!==1&&we!==9&&we!==11)return T;if(!M&&(L(w),w=w||I,ve)){if(we!==11&&(J=Yo.exec(g)))if(P=J[1]){if(we===9)if(H=w.getElementById(P)){if(H.id===P)return T.push(H),T}else return T;else if(he&&(H=he.getElementById(P))&&ct(w,H)&&H.id===P)return T.push(H),T}else{if(J[2])return Zt.apply(T,w.getElementsByTagName(g)),T;if((P=J[3])&&n.getElementsByClassName&&w.getElementsByClassName)return Zt.apply(T,w.getElementsByClassName(P)),T}if(n.qsa&&!ft[g+" "]&&(!re||!re.test(g))&&(we!==1||w.nodeName.toLowerCase()!=="object")){if(se=g,he=w,we===1&&(Ho.test(g)||ps.test(g))){for(he=Zn.test(g)&&ta(w.parentNode)||w,(he!==w||!n.scope)&&((Q=w.getAttribute("id"))?Q=Q.replace(gs,ms):w.setAttribute("id",Q=Fe)),ue=h(g),O=ue.length;O--;)ue[O]=(Q?"#"+Q:":scope")+" "+Qi(ue[O]);se=ue.join(",")}try{if(n.cssSupportsSelector&&!CSS.supports("selector(:is("+se+"))"))throw new Error;return Zt.apply(T,he.querySelectorAll(se)),T}catch(Ie){ft(g,!0)}finally{Q===Fe&&w.removeAttribute("id")}}}return x(g.replace(Gi,"$1"),w,T,M)}function Xi(){var g=[];function w(T,M){return g.push(T+" ")>s.cacheLength&&delete w[g.shift()],w[T+" "]=M}return w}function Tt(g){return g[Fe]=!0,g}function wt(g){var w=I.createElement("fieldset");try{return!!g(w)}catch(T){return!1}finally{w.parentNode&&w.parentNode.removeChild(w),w=null}}function ea(g,w){for(var T=g.split("|"),M=T.length;M--;)s.attrHandle[T[M]]=w}function bs(g,w){var T=w&&g,M=T&&g.nodeType===1&&w.nodeType===1&&g.sourceIndex-w.sourceIndex;if(M)return M;if(T){for(;T=T.nextSibling;)if(T===w)return-1}return g?1:-1}function Qo(g){return function(w){var T=w.nodeName.toLowerCase();return T==="input"&&w.type===g}}function Jo(g){return function(w){var T=w.nodeName.toLowerCase();return(T==="input"||T==="button")&&w.type===g}}function ys(g){return function(w){return"form"in w?w.parentNode&&w.disabled===!1?"label"in w?"label"in w.parentNode?w.parentNode.disabled===g:w.disabled===g:w.isDisabled===g||w.isDisabled!==!g&&Xo(w)===g:w.disabled===g:"label"in w?w.disabled===g:!1}}function pr(g){return Tt(function(w){return w=+w,Tt(function(T,M){for(var P,O=g([],T.length,w),H=O.length;H--;)T[P=O[H]]&&(T[P]=!(M[P]=T[P]))})})}function ta(g){return g&&typeof g.getElementsByTagName!="undefined"&&g}n=Re.support={},f=Re.isXML=function(g){var w=g&&g.namespaceURI,T=g&&(g.ownerDocument||g).documentElement;return!qo.test(w||T&&T.nodeName||"HTML")},L=Re.setDocument=function(g){var w,T,M=g?g.ownerDocument||g:me;return M==I||M.nodeType!==9||!M.documentElement||(I=M,ne=I.documentElement,ve=!f(I),me!=I&&(T=I.defaultView)&&T.top!==T&&(T.addEventListener?T.addEventListener("unload",vs,!1):T.attachEvent&&T.attachEvent("onunload",vs)),n.scope=wt(function(P){return ne.appendChild(P).appendChild(I.createElement("div")),typeof P.querySelectorAll!="undefined"&&!P.querySelectorAll(":scope fieldset div").length}),n.cssSupportsSelector=wt(function(){return CSS.supports("selector(*)")&&I.querySelectorAll(":is(:jqfake)")&&!CSS.supports("selector(:is(*,:jqfake))")}),n.attributes=wt(function(P){return P.className="i",!P.getAttribute("className")}),n.getElementsByTagName=wt(function(P){return P.appendChild(I.createComment("")),!P.getElementsByTagName("*").length}),n.getElementsByClassName=ii.test(I.getElementsByClassName),n.getById=wt(function(P){return ne.appendChild(P).id=Fe,!I.getElementsByName||!I.getElementsByName(Fe).length}),n.getById?(s.filter.ID=function(P){var O=P.replace(Bt,Ht);return function(H){return H.getAttribute("id")===O}},s.find.ID=function(P,O){if(typeof O.getElementById!="undefined"&&ve){var H=O.getElementById(P);return H?[H]:[]}}):(s.filter.ID=function(P){var O=P.replace(Bt,Ht);return function(H){var Q=typeof H.getAttributeNode!="undefined"&&H.getAttributeNode("id");return Q&&Q.value===O}},s.find.ID=function(P,O){if(typeof O.getElementById!="undefined"&&ve){var H,Q,J,ue=O.getElementById(P);if(ue){if(H=ue.getAttributeNode("id"),H&&H.value===P)return[ue];for(J=O.getElementsByName(P),Q=0;ue=J[Q++];)if(H=ue.getAttributeNode("id"),H&&H.value===P)return[ue]}return[]}}),s.find.TAG=n.getElementsByTagName?function(P,O){if(typeof O.getElementsByTagName!="undefined")return O.getElementsByTagName(P);if(n.qsa)return O.querySelectorAll(P)}:function(P,O){var H,Q=[],J=0,ue=O.getElementsByTagName(P);if(P==="*"){for(;H=ue[J++];)H.nodeType===1&&Q.push(H);return Q}return ue},s.find.CLASS=n.getElementsByClassName&&function(P,O){if(typeof O.getElementsByClassName!="undefined"&&ve)return O.getElementsByClassName(P)},ze=[],re=[],(n.qsa=ii.test(I.querySelectorAll))&&(wt(function(P){var O;ne.appendChild(P).innerHTML="<a id='"+Fe+"'></a><select id='"+Fe+"-\r\\' msallowcapture=''><option selected=''></option></select>",P.querySelectorAll("[msallowcapture^='']").length&&re.push("[*^$]="+Ae+`*(?:''|"")`),P.querySelectorAll("[selected]").length||re.push("\\["+Ae+"*(?:value|"+Jn+")"),P.querySelectorAll("[id~="+Fe+"-]").length||re.push("~="),O=I.createElement("input"),O.setAttribute("name",""),P.appendChild(O),P.querySelectorAll("[name='']").length||re.push("\\["+Ae+"*name"+Ae+"*="+Ae+`*(?:''|"")`),P.querySelectorAll(":checked").length||re.push(":checked"),P.querySelectorAll("a#"+Fe+"+*").length||re.push(".#.+[+~]"),P.querySelectorAll("\\\f"),re.push("[\\r\\n\\f]")}),wt(function(P){P.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var O=I.createElement("input");O.setAttribute("type","hidden"),P.appendChild(O).setAttribute("name","D"),P.querySelectorAll("[name=d]").length&&re.push("name"+Ae+"*[*^$|!~]?="),P.querySelectorAll(":enabled").length!==2&&re.push(":enabled",":disabled"),ne.appendChild(P).disabled=!0,P.querySelectorAll(":disabled").length!==2&&re.push(":enabled",":disabled"),P.querySelectorAll("*,:x"),re.push(",.*:")})),(n.matchesSelector=ii.test(Ue=ne.matches||ne.webkitMatchesSelector||ne.mozMatchesSelector||ne.oMatchesSelector||ne.msMatchesSelector))&&wt(function(P){n.disconnectedMatch=Ue.call(P,"*"),Ue.call(P,"[s!='']:x"),ze.push("!=",Kn)}),n.cssSupportsSelector||re.push(":has"),re=re.length&&new RegExp(re.join("|")),ze=ze.length&&new RegExp(ze.join("|")),w=ii.test(ne.compareDocumentPosition),ct=w||ii.test(ne.contains)?function(P,O){var H=P.nodeType===9&&P.documentElement||P,Q=O&&O.parentNode;return P===Q||!!(Q&&Q.nodeType===1&&(H.contains?H.contains(Q):P.compareDocumentPosition&&P.compareDocumentPosition(Q)&16))}:function(P,O){if(O){for(;O=O.parentNode;)if(O===P)return!0}return!1},cr=w?function(P,O){if(P===O)return B=!0,0;var H=!P.compareDocumentPosition-!O.compareDocumentPosition;return H||(H=(P.ownerDocument||P)==(O.ownerDocument||O)?P.compareDocumentPosition(O):1,H&1||!n.sortDetached&&O.compareDocumentPosition(P)===H?P==I||P.ownerDocument==me&&ct(me,P)?-1:O==I||O.ownerDocument==me&&ct(me,O)?1:R?dr(R,P)-dr(R,O):0:H&4?-1:1)}:function(P,O){if(P===O)return B=!0,0;var H,Q=0,J=P.parentNode,ue=O.parentNode,se=[P],he=[O];if(!J||!ue)return P==I?-1:O==I?1:J?-1:ue?1:R?dr(R,P)-dr(R,O):0;if(J===ue)return bs(P,O);for(H=P;H=H.parentNode;)se.unshift(H);for(H=O;H=H.parentNode;)he.unshift(H);for(;se[Q]===he[Q];)Q++;return Q?bs(se[Q],he[Q]):se[Q]==me?-1:he[Q]==me?1:0}),I},Re.matches=function(g,w){return Re(g,null,null,w)},Re.matchesSelector=function(g,w){if(L(g),n.matchesSelector&&ve&&!ft[w+" "]&&(!ze||!ze.test(w))&&(!re||!re.test(w)))try{var T=Ue.call(g,w);if(T||n.disconnectedMatch||g.document&&g.document.nodeType!==11)return T}catch(M){ft(w,!0)}return Re(w,I,null,[g]).length>0},Re.contains=function(g,w){return(g.ownerDocument||g)!=I&&L(g),ct(g,w)},Re.attr=function(g,w){(g.ownerDocument||g)!=I&&L(g);var T=s.attrHandle[w.toLowerCase()],M=T&&fr.call(s.attrHandle,w.toLowerCase())?T(g,w,!ve):void 0;return M!==void 0?M:n.attributes||!ve?g.getAttribute(w):(M=g.getAttributeNode(w))&&M.specified?M.value:null},Re.escape=function(g){return(g+"").replace(gs,ms)},Re.error=function(g){throw new Error("Syntax error, unrecognized expression: "+g)},Re.uniqueSort=function(g){var w,T=[],M=0,P=0;if(B=!n.detectDuplicates,R=!n.sortStable&&g.slice(0),g.sort(cr),B){for(;w=g[P++];)w===g[P]&&(M=T.push(P));for(;M--;)g.splice(T[M],1)}return R=null,g},c=Re.getText=function(g){var w,T="",M=0,P=g.nodeType;if(P){if(P===1||P===9||P===11){if(typeof g.textContent=="string")return g.textContent;for(g=g.firstChild;g;g=g.nextSibling)T+=c(g)}else if(P===3||P===4)return g.nodeValue}else for(;w=g[M++];)T+=c(w);return T},s=Re.selectors={cacheLength:50,createPseudo:Tt,match:Yi,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(g){return g[1]=g[1].replace(Bt,Ht),g[3]=(g[3]||g[4]||g[5]||"").replace(Bt,Ht),g[2]==="~="&&(g[3]=" "+g[3]+" "),g.slice(0,4)},CHILD:function(g){return g[1]=g[1].toLowerCase(),g[1].slice(0,3)==="nth"?(g[3]||Re.error(g[0]),g[4]=+(g[4]?g[5]+(g[6]||1):2*(g[3]==="even"||g[3]==="odd")),g[5]=+(g[7]+g[8]||g[3]==="odd")):g[3]&&Re.error(g[0]),g},PSEUDO:function(g){var w,T=!g[6]&&g[2];return Yi.CHILD.test(g[0])?null:(g[3]?g[2]=g[4]||g[5]||"":T&&Uo.test(T)&&(w=h(T,!0))&&(w=T.indexOf(")",T.length-w)-T.length)&&(g[0]=g[0].slice(0,w),g[2]=T.slice(0,w)),g.slice(0,3))}},filter:{TAG:function(g){var w=g.replace(Bt,Ht).toLowerCase();return g==="*"?function(){return!0}:function(T){return T.nodeName&&T.nodeName.toLowerCase()===w}},CLASS:function(g){var w=je[g+" "];return w||(w=new RegExp("(^|"+Ae+")"+g+"("+Ae+"|$)"))&&je(g,function(T){return w.test(typeof T.className=="string"&&T.className||typeof T.getAttribute!="undefined"&&T.getAttribute("class")||"")})},ATTR:function(g,w,T){return function(M){var P=Re.attr(M,g);return P==null?w==="!=":w?(P+="",w==="="?P===T:w==="!="?P!==T:w==="^="?T&&P.indexOf(T)===0:w==="*="?T&&P.indexOf(T)>-1:w==="$="?T&&P.slice(-T.length)===T:w==="~="?(" "+P.replace(jo," ")+" ").indexOf(T)>-1:w==="|="?P===T||P.slice(0,T.length+1)===T+"-":!1):!0}},CHILD:function(g,w,T,M,P){var O=g.slice(0,3)!=="nth",H=g.slice(-4)!=="last",Q=w==="of-type";return M===1&&P===0?function(J){return!!J.parentNode}:function(J,ue,se){var he,we,Ie,ce,qe,et,dt=O!==H?"nextSibling":"previousSibling",Ne=J.parentNode,ni=Q&&J.nodeName.toLowerCase(),ai=!se&&!Q,ht=!1;if(Ne){if(O){for(;dt;){for(ce=J;ce=ce[dt];)if(Q?ce.nodeName.toLowerCase()===ni:ce.nodeType===1)return!1;et=dt=g==="only"&&!et&&"nextSibling"}return!0}if(et=[H?Ne.firstChild:Ne.lastChild],H&&ai){for(ce=Ne,Ie=ce[Fe]||(ce[Fe]={}),we=Ie[ce.uniqueID]||(Ie[ce.uniqueID]={}),he=we[g]||[],qe=he[0]===ot&&he[1],ht=qe&&he[2],ce=qe&&Ne.childNodes[qe];ce=++qe&&ce&&ce[dt]||(ht=qe=0)||et.pop();)if(ce.nodeType===1&&++ht&&ce===J){we[g]=[ot,qe,ht];break}}else if(ai&&(ce=J,Ie=ce[Fe]||(ce[Fe]={}),we=Ie[ce.uniqueID]||(Ie[ce.uniqueID]={}),he=we[g]||[],qe=he[0]===ot&&he[1],ht=qe),ht===!1)for(;(ce=++qe&&ce&&ce[dt]||(ht=qe=0)||et.pop())&&!((Q?ce.nodeName.toLowerCase()===ni:ce.nodeType===1)&&++ht&&(ai&&(Ie=ce[Fe]||(ce[Fe]={}),we=Ie[ce.uniqueID]||(Ie[ce.uniqueID]={}),we[g]=[ot,ht]),ce===J)););return ht-=P,ht===M||ht%M==0&&ht/M>=0}}},PSEUDO:function(g,w){var T,M=s.pseudos[g]||s.setFilters[g.toLowerCase()]||Re.error("unsupported pseudo: "+g);return M[Fe]?M(w):M.length>1?(T=[g,g,"",w],s.setFilters.hasOwnProperty(g.toLowerCase())?Tt(function(P,O){for(var H,Q=M(P,w),J=Q.length;J--;)H=dr(P,Q[J]),P[H]=!(O[H]=Q[J])}):function(P){return M(P,0,T)}):M}},pseudos:{not:Tt(function(g){var w=[],T=[],M=E(g.replace(Gi,"$1"));return M[Fe]?Tt(function(P,O,H,Q){for(var J,ue=M(P,null,Q,[]),se=P.length;se--;)(J=ue[se])&&(P[se]=!(O[se]=J))}):function(P,O,H){return w[0]=P,M(w,null,H,T),w[0]=null,!T.pop()}}),has:Tt(function(g){return function(w){return Re(g,w).length>0}}),contains:Tt(function(g){return g=g.replace(Bt,Ht),function(w){return(w.textContent||c(w)).indexOf(g)>-1}}),lang:Tt(function(g){return zo.test(g||"")||Re.error("unsupported lang: "+g),g=g.replace(Bt,Ht).toLowerCase(),function(w){var T;do if(T=ve?w.lang:w.getAttribute("xml:lang")||w.getAttribute("lang"))return T=T.toLowerCase(),T===g||T.indexOf(g+"-")===0;while((w=w.parentNode)&&w.nodeType===1);return!1}}),target:function(g){var w=e.location&&e.location.hash;return w&&w.slice(1)===g.id},root:function(g){return g===ne},focus:function(g){return g===I.activeElement&&(!I.hasFocus||I.hasFocus())&&!!(g.type||g.href||~g.tabIndex)},enabled:ys(!1),disabled:ys(!0),checked:function(g){var w=g.nodeName.toLowerCase();return w==="input"&&!!g.checked||w==="option"&&!!g.selected},selected:function(g){return g.parentNode&&g.parentNode.selectedIndex,g.selected===!0},empty:function(g){for(g=g.firstChild;g;g=g.nextSibling)if(g.nodeType<6)return!1;return!0},parent:function(g){return!s.pseudos.empty(g)},header:function(g){return Go.test(g.nodeName)},input:function(g){return Vo.test(g.nodeName)},button:function(g){var w=g.nodeName.toLowerCase();return w==="input"&&g.type==="button"||w==="button"},text:function(g){var w;return g.nodeName.toLowerCase()==="input"&&g.type==="text"&&((w=g.getAttribute("type"))==null||w.toLowerCase()==="text")},first:pr(function(){return[0]}),last:pr(function(g,w){return[w-1]}),eq:pr(function(g,w,T){return[T<0?T+w:T]}),even:pr(function(g,w){for(var T=0;T<w;T+=2)g.push(T);return g}),odd:pr(function(g,w){for(var T=1;T<w;T+=2)g.push(T);return g}),lt:pr(function(g,w,T){for(var M=T<0?T+w:T>w?w:T;--M>=0;)g.push(M);return g}),gt:pr(function(g,w,T){for(var M=T<0?T+w:T;++M<w;)g.push(M);return g})}},s.pseudos.nth=s.pseudos.eq;for(r in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})s.pseudos[r]=Qo(r);for(r in{submit:!0,reset:!0})s.pseudos[r]=Jo(r);function xs(){}xs.prototype=s.filters=s.pseudos,s.setFilters=new xs,h=Re.tokenize=function(g,w){var T,M,P,O,H,Q,J,ue=ri[g+" "];if(ue)return w?0:ue.slice(0);for(H=g,Q=[],J=s.preFilter;H;){(!T||(M=Bo.exec(H)))&&(M&&(H=H.slice(M[0].length)||H),Q.push(P=[])),T=!1,(M=ps.exec(H))&&(T=M.shift(),P.push({value:T,type:M[0].replace(Gi," ")}),H=H.slice(T.length));for(O in s.filter)(M=Yi[O].exec(H))&&(!J[O]||(M=J[O](M)))&&(T=M.shift(),P.push({value:T,type:O,matches:M}),H=H.slice(T.length));if(!T)break}return w?H.length:H?Re.error(g):ri(g,Q).slice(0)};function Qi(g){for(var w=0,T=g.length,M="";w<T;w++)M+=g[w].value;return M}function Ji(g,w,T){var M=w.dir,P=w.next,O=P||M,H=T&&O==="parentNode",Q=Te++;return w.first?function(J,ue,se){for(;J=J[M];)if(J.nodeType===1||H)return g(J,ue,se);return!1}:function(J,ue,se){var he,we,Ie,ce=[ot,Q];if(se){for(;J=J[M];)if((J.nodeType===1||H)&&g(J,ue,se))return!0}else for(;J=J[M];)if(J.nodeType===1||H)if(Ie=J[Fe]||(J[Fe]={}),we=Ie[J.uniqueID]||(Ie[J.uniqueID]={}),P&&P===J.nodeName.toLowerCase())J=J[M]||J;else{if((he=we[O])&&he[0]===ot&&he[1]===Q)return ce[2]=he[2];if(we[O]=ce,ce[2]=g(J,ue,se))return!0}return!1}}function ra(g){return g.length>1?function(w,T,M){for(var P=g.length;P--;)if(!g[P](w,T,M))return!1;return!0}:g[0]}function Ko(g,w,T){for(var M=0,P=w.length;M<P;M++)Re(g,w[M],T);return T}function Ki(g,w,T,M,P){for(var O,H=[],Q=0,J=g.length,ue=w!=null;Q<J;Q++)(O=g[Q])&&(!T||T(O,M,P))&&(H.push(O),ue&&w.push(Q));return H}function ia(g,w,T,M,P,O){return M&&!M[Fe]&&(M=ia(M)),P&&!P[Fe]&&(P=ia(P,O)),Tt(function(H,Q,J,ue){var se,he,we,Ie=[],ce=[],qe=Q.length,et=H||Ko(w||"*",J.nodeType?[J]:J,[]),dt=g&&(H||!w)?Ki(et,Ie,g,J,ue):et,Ne=T?P||(H?g:qe||M)?[]:Q:dt;if(T&&T(dt,Ne,J,ue),M)for(se=Ki(Ne,ce),M(se,[],J,ue),he=se.length;he--;)(we=se[he])&&(Ne[ce[he]]=!(dt[ce[he]]=we));if(H){if(P||g){if(P){for(se=[],he=Ne.length;he--;)(we=Ne[he])&&se.push(dt[he]=we);P(null,Ne=[],se,ue)}for(he=Ne.length;he--;)(we=Ne[he])&&(se=P?dr(H,we):Ie[he])>-1&&(H[se]=!(Q[se]=we))}}else Ne=Ki(Ne===Q?Ne.splice(qe,Ne.length):Ne),P?P(null,Q,Ne,ue):Zt.apply(Q,Ne)})}function na(g){for(var w,T,M,P=g.length,O=s.relative[g[0].type],H=O||s.relative[" "],Q=O?1:0,J=Ji(function(he){return he===w},H,!0),ue=Ji(function(he){return dr(w,he)>-1},H,!0),se=[function(he,we,Ie){var ce=!O&&(Ie||we!==F)||((w=we).nodeType?J(he,we,Ie):ue(he,we,Ie));return w=null,ce}];Q<P;Q++)if(T=s.relative[g[Q].type])se=[Ji(ra(se),T)];else{if(T=s.filter[g[Q].type].apply(null,g[Q].matches),T[Fe]){for(M=++Q;M<P&&!s.relative[g[M].type];M++);return ia(Q>1&&ra(se),Q>1&&Qi(g.slice(0,Q-1).concat({value:g[Q-2].type===" "?"*":""})).replace(Gi,"$1"),T,Q<M&&na(g.slice(Q,M)),M<P&&na(g=g.slice(M)),M<P&&Qi(g))}se.push(T)}return ra(se)}function Zo(g,w){var T=w.length>0,M=g.length>0,P=function(O,H,Q,J,ue){var se,he,we,Ie=0,ce="0",qe=O&&[],et=[],dt=F,Ne=O||M&&s.find.TAG("*",ue),ni=ot+=dt==null?1:Math.random()||.1,ai=Ne.length;for(ue&&(F=H==I||H||ue);ce!==ai&&(se=Ne[ce])!=null;ce++){if(M&&se){for(he=0,!H&&se.ownerDocument!=I&&(L(se),Q=!ve);we=g[he++];)if(we(se,H||I,Q)){J.push(se);break}ue&&(ot=ni)}T&&((se=!we&&se)&&Ie--,O&&qe.push(se))}if(Ie+=ce,T&&ce!==Ie){for(he=0;we=w[he++];)we(qe,et,H,Q);if(O){if(Ie>0)for(;ce--;)qe[ce]||et[ce]||(et[ce]=Kt.call(J));et=Ki(et)}Zt.apply(J,et),ue&&!O&&et.length>0&&Ie+w.length>1&&Re.uniqueSort(J)}return ue&&(ot=ni,F=dt),qe};return T?Tt(P):P}return E=Re.compile=function(g,w){var T,M=[],P=[],O=Vi[g+" "];if(!O){for(w||(w=h(g)),T=w.length;T--;)O=na(w[T]),O[Fe]?M.push(O):P.push(O);O=Vi(g,Zo(P,M)),O.selector=g}return O},x=Re.select=function(g,w,T,M){var P,O,H,Q,J,ue=typeof g=="function"&&g,se=!M&&h(g=ue.selector||g);if(T=T||[],se.length===1){if(O=se[0]=se[0].slice(0),O.length>2&&(H=O[0]).type==="ID"&&w.nodeType===9&&ve&&s.relative[O[1].type]){if(w=(s.find.ID(H.matches[0].replace(Bt,Ht),w)||[])[0],w)ue&&(w=w.parentNode);else return T;g=g.slice(O.shift().value.length)}for(P=Yi.needsContext.test(g)?0:O.length;P--&&(H=O[P],!s.relative[Q=H.type]);)if((J=s.find[Q])&&(M=J(H.matches[0].replace(Bt,Ht),Zn.test(O[0].type)&&ta(w.parentNode)||w))){if(O.splice(P,1),g=M.length&&Qi(O),!g)return Zt.apply(T,M),T;break}}return(ue||E(g,se))(M,w,!ve,T,!w||Zn.test(g)&&ta(w.parentNode)||w),T},n.sortStable=Fe.split("").sort(cr).join("")===Fe,n.detectDuplicates=!!B,L(),n.sortDetached=wt(function(g){return g.compareDocumentPosition(I.createElement("fieldset"))&1}),wt(function(g){return g.innerHTML="<a href='#'></a>",g.firstChild.getAttribute("href")==="#"})||ea("type|href|height|width",function(g,w,T){if(!T)return g.getAttribute(w,w.toLowerCase()==="type"?1:2)}),(!n.attributes||!wt(function(g){return g.innerHTML="<input/>",g.firstChild.setAttribute("value",""),g.firstChild.getAttribute("value")===""}))&&ea("value",function(g,w,T){if(!T&&g.nodeName.toLowerCase()==="input")return g.defaultValue}),wt(function(g){return g.getAttribute("disabled")==null})||ea(Jn,function(g,w,T){var M;if(!T)return g[w]===!0?w.toLowerCase():(M=g.getAttributeNode(w))&&M.specified?M.value:null}),Re}(l);o.find=ae,o.expr=ae.selectors,o.expr[":"]=o.expr.pseudos,o.uniqueSort=o.unique=ae.uniqueSort,o.text=ae.getText,o.isXMLDoc=ae.isXML,o.contains=ae.contains,o.escapeSelector=ae.escape;var oe=function(e,r,n){for(var s=[],c=n!==void 0;(e=e[r])&&e.nodeType!==9;)if(e.nodeType===1){if(c&&o(e).is(n))break;s.push(e)}return s},_e=function(e,r){for(var n=[];e;e=e.nextSibling)e.nodeType===1&&e!==r&&n.push(e);return n},He=o.expr.match.needsContext;function Me(e,r){return e.nodeName&&e.nodeName.toLowerCase()===r.toLowerCase()}var tt=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function Qe(e,r,n){return q(r)?o.grep(e,function(s,c){return!!r.call(s,c,s)!==n}):r.nodeType?o.grep(e,function(s){return s===r!==n}):typeof r!="string"?o.grep(e,function(s){return y.call(r,s)>-1!==n}):o.filter(r,e,n)}o.filter=function(e,r,n){var s=r[0];return n&&(e=":not("+e+")"),r.length===1&&s.nodeType===1?o.find.matchesSelector(s,e)?[s]:[]:o.find.matches(e,o.grep(r,function(c){return c.nodeType===1}))},o.fn.extend({find:function(e){var r,n,s=this.length,c=this;if(typeof e!="string")return this.pushStack(o(e).filter(function(){for(r=0;r<s;r++)if(o.contains(c[r],this))return!0}));for(n=this.pushStack([]),r=0;r<s;r++)o.find(e,c[r],n);return s>1?o.uniqueSort(n):n},filter:function(e){return this.pushStack(Qe(this,e||[],!1))},not:function(e){return this.pushStack(Qe(this,e||[],!0))},is:function(e){return!!Qe(this,typeof e=="string"&&He.test(e)?o(e):e||[],!1).length}});var mt,rr=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,wr=o.fn.init=function(e,r,n){var s,c;if(!e)return this;if(n=n||mt,typeof e=="string")if(e[0]==="<"&&e[e.length-1]===">"&&e.length>=3?s=[null,e,null]:s=rr.exec(e),s&&(s[1]||!r))if(s[1]){if(r=r instanceof o?r[0]:r,o.merge(this,o.parseHTML(s[1],r&&r.nodeType?r.ownerDocument||r:K,!0)),tt.test(s[1])&&o.isPlainObject(r))for(s in r)q(this[s])?this[s](r[s]):this.attr(s,r[s]);return this}else return c=K.getElementById(s[2]),c&&(this[0]=c,this.length=1),this;else return!r||r.jquery?(r||n).find(e):this.constructor(r).find(e);else{if(e.nodeType)return this[0]=e,this.length=1,this;if(q(e))return n.ready!==void 0?n.ready(e):e(o)}return o.makeArray(e,this)};wr.prototype=o.fn,mt=o(K);var Ir=/^(?:parents|prev(?:Until|All))/,Yt={children:!0,contents:!0,next:!0,prev:!0};o.fn.extend({has:function(e){var r=o(e,this),n=r.length;return this.filter(function(){for(var s=0;s<n;s++)if(o.contains(this,r[s]))return!0})},closest:function(e,r){var n,s=0,c=this.length,f=[],h=typeof e!="string"&&o(e);if(!He.test(e)){for(;s<c;s++)for(n=this[s];n&&n!==r;n=n.parentNode)if(n.nodeType<11&&(h?h.index(n)>-1:n.nodeType===1&&o.find.matchesSelector(n,e))){f.push(n);break}}return this.pushStack(f.length>1?o.uniqueSort(f):f)},index:function(e){return e?typeof e=="string"?y.call(o(e),this[0]):y.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,r){return this.pushStack(o.uniqueSort(o.merge(this.get(),o(e,r))))},addBack:function(e){return this.add(e==null?this.prevObject:this.prevObject.filter(e))}});function Mr(e,r){for(;(e=e[r])&&e.nodeType!==1;);return e}o.each({parent:function(e){var r=e.parentNode;return r&&r.nodeType!==11?r:null},parents:function(e){return oe(e,"parentNode")},parentsUntil:function(e,r,n){return oe(e,"parentNode",n)},next:function(e){return Mr(e,"nextSibling")},prev:function(e){return Mr(e,"previousSibling")},nextAll:function(e){return oe(e,"nextSibling")},prevAll:function(e){return oe(e,"previousSibling")},nextUntil:function(e,r,n){return oe(e,"nextSibling",n)},prevUntil:function(e,r,n){return oe(e,"previousSibling",n)},siblings:function(e){return _e((e.parentNode||{}).firstChild,e)},children:function(e){return _e(e.firstChild)},contents:function(e){return e.contentDocument!=null&&a(e.contentDocument)?e.contentDocument:(Me(e,"template")&&(e=e.content||e),o.merge([],e.childNodes))}},function(e,r){o.fn[e]=function(n,s){var c=o.map(this,r,n);return e.slice(-5)!=="Until"&&(s=n),s&&typeof s=="string"&&(c=o.filter(s,c)),this.length>1&&(Yt[e]||o.uniqueSort(c),Ir.test(e)&&c.reverse()),this.pushStack(c)}});var vt=/[^\x20\t\r\n\f]+/g;function An(e){var r={};return o.each(e.match(vt)||[],function(n,s){r[s]=!0}),r}o.Callbacks=function(e){e=typeof e=="string"?An(e):o.extend({},e);var r,n,s,c,f=[],h=[],E=-1,x=function(){for(c=c||e.once,s=r=!0;h.length;E=-1)for(n=h.shift();++E<f.length;)f[E].apply(n[0],n[1])===!1&&e.stopOnFalse&&(E=f.length,n=!1);e.memory||(n=!1),r=!1,c&&(n?f=[]:f="")},F={add:function(){return f&&(n&&!r&&(E=f.length-1,h.push(n)),function R(B){o.each(B,function(L,I){q(I)?(!e.unique||!F.has(I))&&f.push(I):I&&I.length&&be(I)!=="string"&&R(I)})}(arguments),n&&!r&&x()),this},remove:function(){return o.each(arguments,function(R,B){for(var L;(L=o.inArray(B,f,L))>-1;)f.splice(L,1),L<=E&&E--}),this},has:function(R){return R?o.inArray(R,f)>-1:f.length>0},empty:function(){return f&&(f=[]),this},disable:function(){return c=h=[],f=n="",this},disabled:function(){return!f},lock:function(){return c=h=[],!n&&!r&&(f=n=""),this},locked:function(){return!!c},fireWith:function(R,B){return c||(B=B||[],B=[R,B.slice?B.slice():B],h.push(B),r||x()),this},fire:function(){return F.fireWith(this,arguments),this},fired:function(){return!!s}};return F};function Je(e){return e}function ir(e){throw e}function Pi(e,r,n,s){var c;try{e&&q(c=e.promise)?c.call(e).done(r).fail(n):e&&q(c=e.then)?c.call(e,r,n):r.apply(void 0,[e].slice(s))}catch(f){n.apply(void 0,[f])}}o.extend({Deferred:function(e){var r=[["notify","progress",o.Callbacks("memory"),o.Callbacks("memory"),2],["resolve","done",o.Callbacks("once memory"),o.Callbacks("once memory"),0,"resolved"],["reject","fail",o.Callbacks("once memory"),o.Callbacks("once memory"),1,"rejected"]],n="pending",s={state:function(){return n},always:function(){return c.done(arguments).fail(arguments),this},catch:function(f){return s.then(null,f)},pipe:function(){var f=arguments;return o.Deferred(function(h){o.each(r,function(E,x){var F=q(f[x[4]])&&f[x[4]];c[x[1]](function(){var R=F&&F.apply(this,arguments);R&&q(R.promise)?R.promise().progress(h.notify).done(h.resolve).fail(h.reject):h[x[0]+"With"](this,F?[R]:arguments)})}),f=null}).promise()},then:function(f,h,E){var x=0;function F(R,B,L,I){return function(){var ne=this,ve=arguments,re=function(){var Ue,ct;if(!(R<x)){if(Ue=L.apply(ne,ve),Ue===B.promise())throw new TypeError("Thenable self-resolution");ct=Ue&&(typeof Ue=="object"||typeof Ue=="function")&&Ue.then,q(ct)?I?ct.call(Ue,F(x,B,Je,I),F(x,B,ir,I)):(x++,ct.call(Ue,F(x,B,Je,I),F(x,B,ir,I),F(x,B,Je,B.notifyWith))):(L!==Je&&(ne=void 0,ve=[Ue]),(I||B.resolveWith)(ne,ve))}},ze=I?re:function(){try{re()}catch(Ue){o.Deferred.exceptionHook&&o.Deferred.exceptionHook(Ue,ze.stackTrace),R+1>=x&&(L!==ir&&(ne=void 0,ve=[Ue]),B.rejectWith(ne,ve))}};R?ze():(o.Deferred.getStackHook&&(ze.stackTrace=o.Deferred.getStackHook()),l.setTimeout(ze))}}return o.Deferred(function(R){r[0][3].add(F(0,R,q(E)?E:Je,R.notifyWith)),r[1][3].add(F(0,R,q(f)?f:Je)),r[2][3].add(F(0,R,q(h)?h:ir))}).promise()},promise:function(f){return f!=null?o.extend(f,s):s}},c={};return o.each(r,function(f,h){var E=h[2],x=h[5];s[h[1]]=E.add,x&&E.add(function(){n=x},r[3-f][2].disable,r[3-f][3].disable,r[0][2].lock,r[0][3].lock),E.add(h[3].fire),c[h[0]]=function(){return c[h[0]+"With"](this===c?void 0:this,arguments),this},c[h[0]+"With"]=E.fireWith}),s.promise(c),e&&e.call(c,c),c},when:function(e){var r=arguments.length,n=r,s=Array(n),c=u.call(arguments),f=o.Deferred(),h=function(E){return function(x){s[E]=this,c[E]=arguments.length>1?u.call(arguments):x,--r||f.resolveWith(s,c)}};if(r<=1&&(Pi(e,f.done(h(n)).resolve,f.reject,!r),f.state()==="pending"||q(c[n]&&c[n].then)))return f.then();for(;n--;)Pi(c[n],h(n),f.reject);return f.promise()}});var Fn=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;o.Deferred.exceptionHook=function(e,r){l.console&&l.console.warn&&e&&Fn.test(e.name)&&l.console.warn("jQuery.Deferred exception: "+e.message,e.stack,r)},o.readyException=function(e){l.setTimeout(function(){throw e})};var Nr=o.Deferred();o.fn.ready=function(e){return Nr.then(e).catch(function(r){o.readyException(r)}),this},o.extend({isReady:!1,readyWait:1,ready:function(e){(e===!0?--o.readyWait:o.isReady)||(o.isReady=!0,!(e!==!0&&--o.readyWait>0)&&Nr.resolveWith(K,[o]))}}),o.ready.then=Nr.then;function Er(){K.removeEventListener("DOMContentLoaded",Er),l.removeEventListener("load",Er),o.ready()}K.readyState==="complete"||K.readyState!=="loading"&&!K.documentElement.doScroll?l.setTimeout(o.ready):(K.addEventListener("DOMContentLoaded",Er),l.addEventListener("load",Er));var _t=function(e,r,n,s,c,f,h){var E=0,x=e.length,F=n==null;if(be(n)==="object"){c=!0;for(E in n)_t(e,r,E,n[E],!0,f,h)}else if(s!==void 0&&(c=!0,q(s)||(h=!0),F&&(h?(r.call(e,s),r=null):(F=r,r=function(R,B,L){return F.call(o(R),L)})),r))for(;E<x;E++)r(e[E],n,h?s:s.call(e[E],E,r(e[E],n)));return c?e:F?r.call(e):x?r(e[0],n):f},Dn=/^-ms-/,Ln=/-([a-z])/g;function Rn(e,r){return r.toUpperCase()}function bt(e){return e.replace(Dn,"ms-").replace(Ln,Rn)}var nr=function(e){return e.nodeType===1||e.nodeType===9||!+e.nodeType};function ar(){this.expando=o.expando+ar.uid++}ar.uid=1,ar.prototype={cache:function(e){var r=e[this.expando];return r||(r={},nr(e)&&(e.nodeType?e[this.expando]=r:Object.defineProperty(e,this.expando,{value:r,configurable:!0}))),r},set:function(e,r,n){var s,c=this.cache(e);if(typeof r=="string")c[bt(r)]=n;else for(s in r)c[bt(s)]=r[s];return c},get:function(e,r){return r===void 0?this.cache(e):e[this.expando]&&e[this.expando][bt(r)]},access:function(e,r,n){return r===void 0||r&&typeof r=="string"&&n===void 0?this.get(e,r):(this.set(e,r,n),n!==void 0?n:r)},remove:function(e,r){var n,s=e[this.expando];if(s!==void 0){if(r!==void 0)for(Array.isArray(r)?r=r.map(bt):(r=bt(r),r=r in s?[r]:r.match(vt)||[]),n=r.length;n--;)delete s[r[n]];(r===void 0||o.isEmptyObject(s))&&(e.nodeType?e[this.expando]=void 0:delete e[this.expando])}},hasData:function(e){var r=e[this.expando];return r!==void 0&&!o.isEmptyObject(r)}};var le=new ar,$e=new ar,In=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,Ai=/[A-Z]/g;function Sr(e){return e==="true"?!0:e==="false"?!1:e==="null"?null:e===+e+""?+e:In.test(e)?JSON.parse(e):e}function _r(e,r,n){var s;if(n===void 0&&e.nodeType===1)if(s="data-"+r.replace(Ai,"-$&").toLowerCase(),n=e.getAttribute(s),typeof n=="string"){try{n=Sr(n)}catch(c){}$e.set(e,r,n)}else n=void 0;return n}o.extend({hasData:function(e){return $e.hasData(e)||le.hasData(e)},data:function(e,r,n){return $e.access(e,r,n)},removeData:function(e,r){$e.remove(e,r)},_data:function(e,r,n){return le.access(e,r,n)},_removeData:function(e,r){le.remove(e,r)}}),o.fn.extend({data:function(e,r){var n,s,c,f=this[0],h=f&&f.attributes;if(e===void 0){if(this.length&&(c=$e.get(f),f.nodeType===1&&!le.get(f,"hasDataAttrs"))){for(n=h.length;n--;)h[n]&&(s=h[n].name,s.indexOf("data-")===0&&(s=bt(s.slice(5)),_r(f,s,c[s])));le.set(f,"hasDataAttrs",!0)}return c}return typeof e=="object"?this.each(function(){$e.set(this,e)}):_t(this,function(E){var x;if(f&&E===void 0)return x=$e.get(f,e),x!==void 0||(x=_r(f,e),x!==void 0)?x:void 0;this.each(function(){$e.set(this,e,E)})},null,r,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){$e.remove(this,e)})}}),o.extend({queue:function(e,r,n){var s;if(e)return r=(r||"fx")+"queue",s=le.get(e,r),n&&(!s||Array.isArray(n)?s=le.access(e,r,o.makeArray(n)):s.push(n)),s||[]},dequeue:function(e,r){r=r||"fx";var n=o.queue(e,r),s=n.length,c=n.shift(),f=o._queueHooks(e,r),h=function(){o.dequeue(e,r)};c==="inprogress"&&(c=n.shift(),s--),c&&(r==="fx"&&n.unshift("inprogress"),delete f.stop,c.call(e,h,f)),!s&&f&&f.empty.fire()},_queueHooks:function(e,r){var n=r+"queueHooks";return le.get(e,n)||le.access(e,n,{empty:o.Callbacks("once memory").add(function(){le.remove(e,[r+"queue",n])})})}}),o.fn.extend({queue:function(e,r){var n=2;return typeof e!="string"&&(r=e,e="fx",n--),arguments.length<n?o.queue(this[0],e):r===void 0?this:this.each(function(){var s=o.queue(this,e,r);o._queueHooks(this,e),e==="fx"&&s[0]!=="inprogress"&&o.dequeue(this,e)})},dequeue:function(e){return this.each(function(){o.dequeue(this,e)})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,r){var n,s=1,c=o.Deferred(),f=this,h=this.length,E=function(){--s||c.resolveWith(f,[f])};for(typeof e!="string"&&(r=e,e=void 0),e=e||"fx";h--;)n=le.get(f[h],e+"queueHooks"),n&&n.empty&&(s++,n.empty.add(E));return E(),c.promise(r)}});var Tr=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,Mt=new RegExp("^(?:([+-])=|)("+Tr+")([a-z%]*)$","i"),yt=["Top","Right","Bottom","Left"],At=K.documentElement,Nt=function(e){return o.contains(e.ownerDocument,e)},Fi={composed:!0};At.getRootNode&&(Nt=function(e){return o.contains(e.ownerDocument,e)||e.getRootNode(Fi)===e.ownerDocument});var sr=function(e,r){return e=r||e,e.style.display==="none"||e.style.display===""&&Nt(e)&&o.css(e,"display")==="none"};function Or(e,r,n,s){var c,f,h=20,E=s?function(){return s.cur()}:function(){return o.css(e,r,"")},x=E(),F=n&&n[3]||(o.cssNumber[r]?"":"px"),R=e.nodeType&&(o.cssNumber[r]||F!=="px"&&+x)&&Mt.exec(o.css(e,r));if(R&&R[3]!==F){for(x=x/2,F=F||R[3],R=+x||1;h--;)o.style(e,r,R+F),(1-f)*(1-(f=E()/x||.5))<=0&&(h=0),R=R/f;R=R*2,o.style(e,r,R+F),n=n||[]}return n&&(R=+R||+x||0,c=n[1]?R+(n[1]+1)*n[2]:+n[2],s&&(s.unit=F,s.start=R,s.end=c)),c}var $r={};function Di(e){var r,n=e.ownerDocument,s=e.nodeName,c=$r[s];return c||(r=n.body.appendChild(n.createElement(s)),c=o.css(r,"display"),r.parentNode.removeChild(r),c==="none"&&(c="block"),$r[s]=c,c)}function Ot(e,r){for(var n,s,c=[],f=0,h=e.length;f<h;f++)s=e[f],!!s.style&&(n=s.style.display,r?(n==="none"&&(c[f]=le.get(s,"display")||null,c[f]||(s.style.display="")),s.style.display===""&&sr(s)&&(c[f]=Di(s))):n!=="none"&&(c[f]="none",le.set(s,"display",n)));for(f=0;f<h;f++)c[f]!=null&&(e[f].style.display=c[f]);return e}o.fn.extend({show:function(){return Ot(this,!0)},hide:function(){return Ot(this)},toggle:function(e){return typeof e=="boolean"?e?this.show():this.hide():this.each(function(){sr(this)?o(this).show():o(this).hide()})}});var Xt=/^(?:checkbox|radio)$/i,Wr=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i,jr=/^$|^module$|\/(?:java|ecma)script/i;(function(){var e=K.createDocumentFragment(),r=e.appendChild(K.createElement("div")),n=K.createElement("input");n.setAttribute("type","radio"),n.setAttribute("checked","checked"),n.setAttribute("name","t"),r.appendChild(n),U.checkClone=r.cloneNode(!0).cloneNode(!0).lastChild.checked,r.innerHTML="<textarea>x</textarea>",U.noCloneChecked=!!r.cloneNode(!0).lastChild.defaultValue,r.innerHTML="<option></option>",U.option=!!r.lastChild})();var Ke={thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};Ke.tbody=Ke.tfoot=Ke.colgroup=Ke.caption=Ke.thead,Ke.th=Ke.td,U.option||(Ke.optgroup=Ke.option=[1,"<select multiple='multiple'>","</select>"]);function Ze(e,r){var n;return typeof e.getElementsByTagName!="undefined"?n=e.getElementsByTagName(r||"*"):typeof e.querySelectorAll!="undefined"?n=e.querySelectorAll(r||"*"):n=[],r===void 0||r&&Me(e,r)?o.merge([e],n):n}function Br(e,r){for(var n=0,s=e.length;n<s;n++)le.set(e[n],"globalEval",!r||le.get(r[n],"globalEval"))}var Hr=/<|&#?\w+;/;function Ur(e,r,n,s,c){for(var f,h,E,x,F,R,B=r.createDocumentFragment(),L=[],I=0,ne=e.length;I<ne;I++)if(f=e[I],f||f===0)if(be(f)==="object")o.merge(L,f.nodeType?[f]:f);else if(!Hr.test(f))L.push(r.createTextNode(f));else{for(h=h||B.appendChild(r.createElement("div")),E=(Wr.exec(f)||["",""])[1].toLowerCase(),x=Ke[E]||Ke._default,h.innerHTML=x[1]+o.htmlPrefilter(f)+x[2],R=x[0];R--;)h=h.lastChild;o.merge(L,h.childNodes),h=B.firstChild,h.textContent=""}for(B.textContent="",I=0;f=L[I++];){if(s&&o.inArray(f,s)>-1){c&&c.push(f);continue}if(F=Nt(f),h=Ze(B.appendChild(f),"script"),F&&Br(h),n)for(R=0;f=h[R++];)jr.test(f.type||"")&&n.push(f)}return B}var Li=/^([^.]*)(?:\.(.+)|)/;function rt(){return!0}function Qt(){return!1}function Mn(e,r){return e===Ri()==(r==="focus")}function Ri(){try{return K.activeElement}catch(e){}}function zr(e,r,n,s,c,f){var h,E;if(typeof r=="object"){typeof n!="string"&&(s=s||n,n=void 0);for(E in r)zr(e,E,n,s,r[E],f);return e}if(s==null&&c==null?(c=n,s=n=void 0):c==null&&(typeof n=="string"?(c=s,s=void 0):(c=s,s=n,n=void 0)),c===!1)c=Qt;else if(!c)return e;return f===1&&(h=c,c=function(x){return o().off(x),h.apply(this,arguments)},c.guid=h.guid||(h.guid=o.guid++)),e.each(function(){o.event.add(this,r,c,s,n)})}o.event={global:{},add:function(e,r,n,s,c){var f,h,E,x,F,R,B,L,I,ne,ve,re=le.get(e);if(!!nr(e))for(n.handler&&(f=n,n=f.handler,c=f.selector),c&&o.find.matchesSelector(At,c),n.guid||(n.guid=o.guid++),(x=re.events)||(x=re.events=Object.create(null)),(h=re.handle)||(h=re.handle=function(ze){return typeof o!="undefined"&&o.event.triggered!==ze.type?o.event.dispatch.apply(e,arguments):void 0}),r=(r||"").match(vt)||[""],F=r.length;F--;)E=Li.exec(r[F])||[],I=ve=E[1],ne=(E[2]||"").split(".").sort(),!!I&&(B=o.event.special[I]||{},I=(c?B.delegateType:B.bindType)||I,B=o.event.special[I]||{},R=o.extend({type:I,origType:ve,data:s,handler:n,guid:n.guid,selector:c,needsContext:c&&o.expr.match.needsContext.test(c),namespace:ne.join(".")},f),(L=x[I])||(L=x[I]=[],L.delegateCount=0,(!B.setup||B.setup.call(e,s,ne,h)===!1)&&e.addEventListener&&e.addEventListener(I,h)),B.add&&(B.add.call(e,R),R.handler.guid||(R.handler.guid=n.guid)),c?L.splice(L.delegateCount++,0,R):L.push(R),o.event.global[I]=!0)},remove:function(e,r,n,s,c){var f,h,E,x,F,R,B,L,I,ne,ve,re=le.hasData(e)&&le.get(e);if(!(!re||!(x=re.events))){for(r=(r||"").match(vt)||[""],F=r.length;F--;){if(E=Li.exec(r[F])||[],I=ve=E[1],ne=(E[2]||"").split(".").sort(),!I){for(I in x)o.event.remove(e,I+r[F],n,s,!0);continue}for(B=o.event.special[I]||{},I=(s?B.delegateType:B.bindType)||I,L=x[I]||[],E=E[2]&&new RegExp("(^|\\.)"+ne.join("\\.(?:.*\\.|)")+"(\\.|$)"),h=f=L.length;f--;)R=L[f],(c||ve===R.origType)&&(!n||n.guid===R.guid)&&(!E||E.test(R.namespace))&&(!s||s===R.selector||s==="**"&&R.selector)&&(L.splice(f,1),R.selector&&L.delegateCount--,B.remove&&B.remove.call(e,R));h&&!L.length&&((!B.teardown||B.teardown.call(e,ne,re.handle)===!1)&&o.removeEvent(e,I,re.handle),delete x[I])}o.isEmptyObject(x)&&le.remove(e,"handle events")}},dispatch:function(e){var r,n,s,c,f,h,E=new Array(arguments.length),x=o.event.fix(e),F=(le.get(this,"events")||Object.create(null))[x.type]||[],R=o.event.special[x.type]||{};for(E[0]=x,r=1;r<arguments.length;r++)E[r]=arguments[r];if(x.delegateTarget=this,!(R.preDispatch&&R.preDispatch.call(this,x)===!1)){for(h=o.event.handlers.call(this,x,F),r=0;(c=h[r++])&&!x.isPropagationStopped();)for(x.currentTarget=c.elem,n=0;(f=c.handlers[n++])&&!x.isImmediatePropagationStopped();)(!x.rnamespace||f.namespace===!1||x.rnamespace.test(f.namespace))&&(x.handleObj=f,x.data=f.data,s=((o.event.special[f.origType]||{}).handle||f.handler).apply(c.elem,E),s!==void 0&&(x.result=s)===!1&&(x.preventDefault(),x.stopPropagation()));return R.postDispatch&&R.postDispatch.call(this,x),x.result}},handlers:function(e,r){var n,s,c,f,h,E=[],x=r.delegateCount,F=e.target;if(x&&F.nodeType&&!(e.type==="click"&&e.button>=1)){for(;F!==this;F=F.parentNode||this)if(F.nodeType===1&&!(e.type==="click"&&F.disabled===!0)){for(f=[],h={},n=0;n<x;n++)s=r[n],c=s.selector+" ",h[c]===void 0&&(h[c]=s.needsContext?o(c,this).index(F)>-1:o.find(c,this,null,[F]).length),h[c]&&f.push(s);f.length&&E.push({elem:F,handlers:f})}}return F=this,x<r.length&&E.push({elem:F,handlers:r.slice(x)}),E},addProp:function(e,r){Object.defineProperty(o.Event.prototype,e,{enumerable:!0,configurable:!0,get:q(r)?function(){if(this.originalEvent)return r(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[e]},set:function(n){Object.defineProperty(this,e,{enumerable:!0,configurable:!0,writable:!0,value:n})}})},fix:function(e){return e[o.expando]?e:new o.Event(e)},special:{load:{noBubble:!0},click:{setup:function(e){var r=this||e;return Xt.test(r.type)&&r.click&&Me(r,"input")&&Cr(r,"click",rt),!1},trigger:function(e){var r=this||e;return Xt.test(r.type)&&r.click&&Me(r,"input")&&Cr(r,"click"),!0},_default:function(e){var r=e.target;return Xt.test(r.type)&&r.click&&Me(r,"input")&&le.get(r,"click")||Me(r,"a")}},beforeunload:{postDispatch:function(e){e.result!==void 0&&e.originalEvent&&(e.originalEvent.returnValue=e.result)}}}};function Cr(e,r,n){if(!n){le.get(e,r)===void 0&&o.event.add(e,r,rt);return}le.set(e,r,!1),o.event.add(e,r,{namespace:!1,handler:function(s){var c,f,h=le.get(this,r);if(s.isTrigger&1&&this[r]){if(h.length)(o.event.special[r]||{}).delegateType&&s.stopPropagation();else if(h=u.call(arguments),le.set(this,r,h),c=n(this,r),this[r](),f=le.get(this,r),h!==f||c?le.set(this,r,!1):f={},h!==f)return s.stopImmediatePropagation(),s.preventDefault(),f&&f.value}else h.length&&(le.set(this,r,{value:o.event.trigger(o.extend(h[0],o.Event.prototype),h.slice(1),this)}),s.stopImmediatePropagation())}})}o.removeEvent=function(e,r,n){e.removeEventListener&&e.removeEventListener(r,n)},o.Event=function(e,r){if(!(this instanceof o.Event))return new o.Event(e,r);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.defaultPrevented===void 0&&e.returnValue===!1?rt:Qt,this.target=e.target&&e.target.nodeType===3?e.target.parentNode:e.target,this.currentTarget=e.currentTarget,this.relatedTarget=e.relatedTarget):this.type=e,r&&o.extend(this,r),this.timeStamp=e&&e.timeStamp||Date.now(),this[o.expando]=!0},o.Event.prototype={constructor:o.Event,isDefaultPrevented:Qt,isPropagationStopped:Qt,isImmediatePropagationStopped:Qt,isSimulated:!1,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=rt,e&&!this.isSimulated&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=rt,e&&!this.isSimulated&&e.stopPropagation()},stopImmediatePropagation:function(){var e=this.originalEvent;this.isImmediatePropagationStopped=rt,e&&!this.isSimulated&&e.stopImmediatePropagation(),this.stopPropagation()}},o.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,char:!0,code:!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:!0},o.event.addProp),o.each({focus:"focusin",blur:"focusout"},function(e,r){o.event.special[e]={setup:function(){return Cr(this,e,Mn),!1},trigger:function(){return Cr(this,e),!0},_default:function(n){return le.get(n.target,e)},delegateType:r}}),o.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(e,r){o.event.special[e]={delegateType:r,bindType:r,handle:function(n){var s,c=this,f=n.relatedTarget,h=n.handleObj;return(!f||f!==c&&!o.contains(c,f))&&(n.type=h.origType,s=h.handler.apply(this,arguments),n.type=r),s}}}),o.fn.extend({on:function(e,r,n,s){return zr(this,e,r,n,s)},one:function(e,r,n,s){return zr(this,e,r,n,s,1)},off:function(e,r,n){var s,c;if(e&&e.preventDefault&&e.handleObj)return s=e.handleObj,o(e.delegateTarget).off(s.namespace?s.origType+"."+s.namespace:s.origType,s.selector,s.handler),this;if(typeof e=="object"){for(c in e)this.off(c,r,e[c]);return this}return(r===!1||typeof r=="function")&&(n=r,r=void 0),n===!1&&(n=Qt),this.each(function(){o.event.remove(this,e,n,r)})}});var Nn=/<script|<style|<link/i,On=/checked\s*(?:[^=]|=\s*.checked.)/i,$n=/^\s*<!\[CDATA\[|\]\]>\s*$/g;function Ii(e,r){return Me(e,"table")&&Me(r.nodeType!==11?r:r.firstChild,"tr")&&o(e).children("tbody")[0]||e}function Wn(e){return e.type=(e.getAttribute("type")!==null)+"/"+e.type,e}function jn(e){return(e.type||"").slice(0,5)==="true/"?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Mi(e,r){var n,s,c,f,h,E,x;if(r.nodeType===1){if(le.hasData(e)&&(f=le.get(e),x=f.events,x)){le.remove(r,"handle events");for(c in x)for(n=0,s=x[c].length;n<s;n++)o.event.add(r,c,x[c][n])}$e.hasData(e)&&(h=$e.access(e),E=o.extend({},h),$e.set(r,E))}}function Bn(e,r){var n=r.nodeName.toLowerCase();n==="input"&&Xt.test(e.type)?r.checked=e.checked:(n==="input"||n==="textarea")&&(r.defaultValue=e.defaultValue)}function $t(e,r,n,s){r=d(r);var c,f,h,E,x,F,R=0,B=e.length,L=B-1,I=r[0],ne=q(I);if(ne||B>1&&typeof I=="string"&&!U.checkClone&&On.test(I))return e.each(function(ve){var re=e.eq(ve);ne&&(r[0]=I.call(this,ve,re.html())),$t(re,r,n,s)});if(B&&(c=Ur(r,e[0].ownerDocument,!1,e,s),f=c.firstChild,c.childNodes.length===1&&(c=f),f||s)){for(h=o.map(Ze(c,"script"),Wn),E=h.length;R<B;R++)x=c,R!==L&&(x=o.clone(x,!0,!0),E&&o.merge(h,Ze(x,"script"))),n.call(e[R],x,R);if(E)for(F=h[h.length-1].ownerDocument,o.map(h,jn),R=0;R<E;R++)x=h[R],jr.test(x.type||"")&&!le.access(x,"globalEval")&&o.contains(F,x)&&(x.src&&(x.type||"").toLowerCase()!=="module"?o._evalUrl&&!x.noModule&&o._evalUrl(x.src,{nonce:x.nonce||x.getAttribute("nonce")},F):Ce(x.textContent.replace($n,""),x,F))}return e}function Ni(e,r,n){for(var s,c=r?o.filter(r,e):e,f=0;(s=c[f])!=null;f++)!n&&s.nodeType===1&&o.cleanData(Ze(s)),s.parentNode&&(n&&Nt(s)&&Br(Ze(s,"script")),s.parentNode.removeChild(s));return e}o.extend({htmlPrefilter:function(e){return e},clone:function(e,r,n){var s,c,f,h,E=e.cloneNode(!0),x=Nt(e);if(!U.noCloneChecked&&(e.nodeType===1||e.nodeType===11)&&!o.isXMLDoc(e))for(h=Ze(E),f=Ze(e),s=0,c=f.length;s<c;s++)Bn(f[s],h[s]);if(r)if(n)for(f=f||Ze(e),h=h||Ze(E),s=0,c=f.length;s<c;s++)Mi(f[s],h[s]);else Mi(e,E);return h=Ze(E,"script"),h.length>0&&Br(h,!x&&Ze(e,"script")),E},cleanData:function(e){for(var r,n,s,c=o.event.special,f=0;(n=e[f])!==void 0;f++)if(nr(n)){if(r=n[le.expando]){if(r.events)for(s in r.events)c[s]?o.event.remove(n,s):o.removeEvent(n,s,r.handle);n[le.expando]=void 0}n[$e.expando]&&(n[$e.expando]=void 0)}}}),o.fn.extend({detach:function(e){return Ni(this,e,!0)},remove:function(e){return Ni(this,e)},text:function(e){return _t(this,function(r){return r===void 0?o.text(this):this.empty().each(function(){(this.nodeType===1||this.nodeType===11||this.nodeType===9)&&(this.textContent=r)})},null,e,arguments.length)},append:function(){return $t(this,arguments,function(e){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var r=Ii(this,e);r.appendChild(e)}})},prepend:function(){return $t(this,arguments,function(e){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var r=Ii(this,e);r.insertBefore(e,r.firstChild)}})},before:function(){return $t(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return $t(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,r=0;(e=this[r])!=null;r++)e.nodeType===1&&(o.cleanData(Ze(e,!1)),e.textContent="");return this},clone:function(e,r){return e=e==null?!1:e,r=r==null?e:r,this.map(function(){return o.clone(this,e,r)})},html:function(e){return _t(this,function(r){var n=this[0]||{},s=0,c=this.length;if(r===void 0&&n.nodeType===1)return n.innerHTML;if(typeof r=="string"&&!Nn.test(r)&&!Ke[(Wr.exec(r)||["",""])[1].toLowerCase()]){r=o.htmlPrefilter(r);try{for(;s<c;s++)n=this[s]||{},n.nodeType===1&&(o.cleanData(Ze(n,!1)),n.innerHTML=r);n=0}catch(f){}}n&&this.empty().append(r)},null,e,arguments.length)},replaceWith:function(){var e=[];return $t(this,arguments,function(r){var n=this.parentNode;o.inArray(this,e)<0&&(o.cleanData(Ze(this)),n&&n.replaceChild(r,this))},e)}}),o.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,r){o.fn[e]=function(n){for(var s,c=[],f=o(n),h=f.length-1,E=0;E<=h;E++)s=E===h?this:this.clone(!0),o(f[E])[r](s),m.apply(c,s.get());return this.pushStack(c)}});var qr=new RegExp("^("+Tr+")(?!px)[a-z%]+$","i"),Vr=/^--/,kr=function(e){var r=e.ownerDocument.defaultView;return(!r||!r.opener)&&(r=l),r.getComputedStyle(e)},Oi=function(e,r,n){var s,c,f={};for(c in r)f[c]=e.style[c],e.style[c]=r[c];s=n.call(e);for(c in r)e.style[c]=f[c];return s},Hn=new RegExp(yt.join("|"),"i"),$i="[\\x20\\t\\r\\n\\f]",Un=new RegExp("^"+$i+"+|((?:^|[^\\\\])(?:\\\\.)*)"+$i+"+$","g");(function(){function e(){if(!!F){x.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",F.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",At.appendChild(x).appendChild(F);var R=l.getComputedStyle(F);n=R.top!=="1%",E=r(R.marginLeft)===12,F.style.right="60%",f=r(R.right)===36,s=r(R.width)===36,F.style.position="absolute",c=r(F.offsetWidth/3)===12,At.removeChild(x),F=null}}function r(R){return Math.round(parseFloat(R))}var n,s,c,f,h,E,x=K.createElement("div"),F=K.createElement("div");!F.style||(F.style.backgroundClip="content-box",F.cloneNode(!0).style.backgroundClip="",U.clearCloneStyle=F.style.backgroundClip==="content-box",o.extend(U,{boxSizingReliable:function(){return e(),s},pixelBoxStyles:function(){return e(),f},pixelPosition:function(){return e(),n},reliableMarginLeft:function(){return e(),E},scrollboxSize:function(){return e(),c},reliableTrDimensions:function(){var R,B,L,I;return h==null&&(R=K.createElement("table"),B=K.createElement("tr"),L=K.createElement("div"),R.style.cssText="position:absolute;left:-11111px;border-collapse:separate",B.style.cssText="border:1px solid",B.style.height="1px",L.style.height="9px",L.style.display="block",At.appendChild(R).appendChild(B).appendChild(L),I=l.getComputedStyle(B),h=parseInt(I.height,10)+parseInt(I.borderTopWidth,10)+parseInt(I.borderBottomWidth,10)===B.offsetHeight,At.removeChild(R)),h}}))})();function or(e,r,n){var s,c,f,h,E=Vr.test(r),x=e.style;return n=n||kr(e),n&&(h=n.getPropertyValue(r)||n[r],E&&h&&(h=h.replace(Un,"$1")||void 0),h===""&&!Nt(e)&&(h=o.style(e,r)),!U.pixelBoxStyles()&&qr.test(h)&&Hn.test(r)&&(s=x.width,c=x.minWidth,f=x.maxWidth,x.minWidth=x.maxWidth=x.width=h,h=n.width,x.width=s,x.minWidth=c,x.maxWidth=f)),h!==void 0?h+"":h}function Wi(e,r){return{get:function(){if(e()){delete this.get;return}return(this.get=r).apply(this,arguments)}}}var ji=["Webkit","Moz","ms"],Bi=K.createElement("div").style,Hi={};function zn(e){for(var r=e[0].toUpperCase()+e.slice(1),n=ji.length;n--;)if(e=ji[n]+r,e in Bi)return e}function Gr(e){var r=o.cssProps[e]||Hi[e];return r||(e in Bi?e:Hi[e]=zn(e)||e)}var Ui=/^(none|table(?!-c[ea]).+)/,lr={position:"absolute",visibility:"hidden",display:"block"},Yr={letterSpacing:"0",fontWeight:"400"};function Wt(e,r,n){var s=Mt.exec(r);return s?Math.max(0,s[2]-(n||0))+(s[3]||"px"):r}function Xr(e,r,n,s,c,f){var h=r==="width"?1:0,E=0,x=0;if(n===(s?"border":"content"))return 0;for(;h<4;h+=2)n==="margin"&&(x+=o.css(e,n+yt[h],!0,c)),s?(n==="content"&&(x-=o.css(e,"padding"+yt[h],!0,c)),n!=="margin"&&(x-=o.css(e,"border"+yt[h]+"Width",!0,c))):(x+=o.css(e,"padding"+yt[h],!0,c),n!=="padding"?x+=o.css(e,"border"+yt[h]+"Width",!0,c):E+=o.css(e,"border"+yt[h]+"Width",!0,c));return!s&&f>=0&&(x+=Math.max(0,Math.ceil(e["offset"+r[0].toUpperCase()+r.slice(1)]-f-x-E-.5))||0),x}function ur(e,r,n){var s=kr(e),c=!U.boxSizingReliable()||n,f=c&&o.css(e,"boxSizing",!1,s)==="border-box",h=f,E=or(e,r,s),x="offset"+r[0].toUpperCase()+r.slice(1);if(qr.test(E)){if(!n)return E;E="auto"}return(!U.boxSizingReliable()&&f||!U.reliableTrDimensions()&&Me(e,"tr")||E==="auto"||!parseFloat(E)&&o.css(e,"display",!1,s)==="inline")&&e.getClientRects().length&&(f=o.css(e,"boxSizing",!1,s)==="border-box",h=x in e,h&&(E=e[x])),E=parseFloat(E)||0,E+Xr(e,r,n||(f?"border":"content"),h,s,E)+"px"}o.extend({cssHooks:{opacity:{get:function(e,r){if(r){var n=or(e,"opacity");return n===""?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,r,n,s){if(!(!e||e.nodeType===3||e.nodeType===8||!e.style)){var c,f,h,E=bt(r),x=Vr.test(r),F=e.style;if(x||(r=Gr(E)),h=o.cssHooks[r]||o.cssHooks[E],n!==void 0){if(f=typeof n,f==="string"&&(c=Mt.exec(n))&&c[1]&&(n=Or(e,r,c),f="number"),n==null||n!==n)return;f==="number"&&!x&&(n+=c&&c[3]||(o.cssNumber[E]?"":"px")),!U.clearCloneStyle&&n===""&&r.indexOf("background")===0&&(F[r]="inherit"),(!h||!("set"in h)||(n=h.set(e,n,s))!==void 0)&&(x?F.setProperty(r,n):F[r]=n)}else return h&&"get"in h&&(c=h.get(e,!1,s))!==void 0?c:F[r]}},css:function(e,r,n,s){var c,f,h,E=bt(r),x=Vr.test(r);return x||(r=Gr(E)),h=o.cssHooks[r]||o.cssHooks[E],h&&"get"in h&&(c=h.get(e,!0,n)),c===void 0&&(c=or(e,r,s)),c==="normal"&&r in Yr&&(c=Yr[r]),n===""||n?(f=parseFloat(c),n===!0||isFinite(f)?f||0:c):c}}),o.each(["height","width"],function(e,r){o.cssHooks[r]={get:function(n,s,c){if(s)return Ui.test(o.css(n,"display"))&&(!n.getClientRects().length||!n.getBoundingClientRect().width)?Oi(n,lr,function(){return ur(n,r,c)}):ur(n,r,c)},set:function(n,s,c){var f,h=kr(n),E=!U.scrollboxSize()&&h.position==="absolute",x=E||c,F=x&&o.css(n,"boxSizing",!1,h)==="border-box",R=c?Xr(n,r,c,F,h):0;return F&&E&&(R-=Math.ceil(n["offset"+r[0].toUpperCase()+r.slice(1)]-parseFloat(h[r])-Xr(n,r,"border",!1,h)-.5)),R&&(f=Mt.exec(s))&&(f[3]||"px")!=="px"&&(n.style[r]=s,s=o.css(n,r)),Wt(n,s,R)}}}),o.cssHooks.marginLeft=Wi(U.reliableMarginLeft,function(e,r){if(r)return(parseFloat(or(e,"marginLeft"))||e.getBoundingClientRect().left-Oi(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),o.each({margin:"",padding:"",border:"Width"},function(e,r){o.cssHooks[e+r]={expand:function(n){for(var s=0,c={},f=typeof n=="string"?n.split(" "):[n];s<4;s++)c[e+yt[s]+r]=f[s]||f[s-2]||f[0];return c}},e!=="margin"&&(o.cssHooks[e+r].set=Wt)}),o.fn.extend({css:function(e,r){return _t(this,function(n,s,c){var f,h,E={},x=0;if(Array.isArray(s)){for(f=kr(n),h=s.length;x<h;x++)E[s[x]]=o.css(n,s[x],!1,f);return E}return c!==void 0?o.style(n,s,c):o.css(n,s)},e,r,arguments.length>1)}});function Ge(e,r,n,s,c){return new Ge.prototype.init(e,r,n,s,c)}o.Tween=Ge,Ge.prototype={constructor:Ge,init:function(e,r,n,s,c,f){this.elem=e,this.prop=n,this.easing=c||o.easing._default,this.options=r,this.start=this.now=this.cur(),this.end=s,this.unit=f||(o.cssNumber[n]?"":"px")},cur:function(){var e=Ge.propHooks[this.prop];return e&&e.get?e.get(this):Ge.propHooks._default.get(this)},run:function(e){var r,n=Ge.propHooks[this.prop];return this.options.duration?this.pos=r=o.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=r=e,this.now=(this.end-this.start)*r+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):Ge.propHooks._default.set(this),this}},Ge.prototype.init.prototype=Ge.prototype,Ge.propHooks={_default:{get:function(e){var r;return e.elem.nodeType!==1||e.elem[e.prop]!=null&&e.elem.style[e.prop]==null?e.elem[e.prop]:(r=o.css(e.elem,e.prop,""),!r||r==="auto"?0:r)},set:function(e){o.fx.step[e.prop]?o.fx.step[e.prop](e):e.elem.nodeType===1&&(o.cssHooks[e.prop]||e.elem.style[Gr(e.prop)]!=null)?o.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},Ge.propHooks.scrollTop=Ge.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},o.easing={linear:function(e){return e},swing:function(e){return .5-Math.cos(e*Math.PI)/2},_default:"swing"},o.fx=Ge.prototype.init,o.fx.step={};var Jt,Pr,Qr=/^(?:toggle|show|hide)$/,qn=/queueHooks$/;function Jr(){Pr&&(K.hidden===!1&&l.requestAnimationFrame?l.requestAnimationFrame(Jr):l.setTimeout(Jr,o.fx.interval),o.fx.tick())}function p(){return l.setTimeout(function(){Jt=void 0}),Jt=Date.now()}function S(e,r){var n,s=0,c={height:e};for(r=r?1:0;s<4;s+=2-r)n=yt[s],c["margin"+n]=c["padding"+n]=e;return r&&(c.opacity=c.width=e),c}function v(e,r,n){for(var s,c=(_.tweeners[r]||[]).concat(_.tweeners["*"]),f=0,h=c.length;f<h;f++)if(s=c[f].call(n,r,e))return s}function C(e,r,n){var s,c,f,h,E,x,F,R,B="width"in r||"height"in r,L=this,I={},ne=e.style,ve=e.nodeType&&sr(e),re=le.get(e,"fxshow");n.queue||(h=o._queueHooks(e,"fx"),h.unqueued==null&&(h.unqueued=0,E=h.empty.fire,h.empty.fire=function(){h.unqueued||E()}),h.unqueued++,L.always(function(){L.always(function(){h.unqueued--,o.queue(e,"fx").length||h.empty.fire()})}));for(s in r)if(c=r[s],Qr.test(c)){if(delete r[s],f=f||c==="toggle",c===(ve?"hide":"show"))if(c==="show"&&re&&re[s]!==void 0)ve=!0;else continue;I[s]=re&&re[s]||o.style(e,s)}if(x=!o.isEmptyObject(r),!(!x&&o.isEmptyObject(I))){B&&e.nodeType===1&&(n.overflow=[ne.overflow,ne.overflowX,ne.overflowY],F=re&&re.display,F==null&&(F=le.get(e,"display")),R=o.css(e,"display"),R==="none"&&(F?R=F:(Ot([e],!0),F=e.style.display||F,R=o.css(e,"display"),Ot([e]))),(R==="inline"||R==="inline-block"&&F!=null)&&o.css(e,"float")==="none"&&(x||(L.done(function(){ne.display=F}),F==null&&(R=ne.display,F=R==="none"?"":R)),ne.display="inline-block")),n.overflow&&(ne.overflow="hidden",L.always(function(){ne.overflow=n.overflow[0],ne.overflowX=n.overflow[1],ne.overflowY=n.overflow[2]})),x=!1;for(s in I)x||(re?"hidden"in re&&(ve=re.hidden):re=le.access(e,"fxshow",{display:F}),f&&(re.hidden=!ve),ve&&Ot([e],!0),L.done(function(){ve||Ot([e]),le.remove(e,"fxshow");for(s in I)o.style(e,s,I[s])})),x=v(ve?re[s]:0,s,L),s in re||(re[s]=x.start,ve&&(x.end=x.start,x.start=0))}}function k(e,r){var n,s,c,f,h;for(n in e)if(s=bt(n),c=r[s],f=e[n],Array.isArray(f)&&(c=f[1],f=e[n]=f[0]),n!==s&&(e[s]=f,delete e[n]),h=o.cssHooks[s],h&&"expand"in h){f=h.expand(f),delete e[s];for(n in f)n in e||(e[n]=f[n],r[n]=c)}else r[s]=c}function _(e,r,n){var s,c,f=0,h=_.prefilters.length,E=o.Deferred().always(function(){delete x.elem}),x=function(){if(c)return!1;for(var B=Jt||p(),L=Math.max(0,F.startTime+F.duration-B),I=L/F.duration||0,ne=1-I,ve=0,re=F.tweens.length;ve<re;ve++)F.tweens[ve].run(ne);return E.notifyWith(e,[F,ne,L]),ne<1&&re?L:(re||E.notifyWith(e,[F,1,0]),E.resolveWith(e,[F]),!1)},F=E.promise({elem:e,props:o.extend({},r),opts:o.extend(!0,{specialEasing:{},easing:o.easing._default},n),originalProperties:r,originalOptions:n,startTime:Jt||p(),duration:n.duration,tweens:[],createTween:function(B,L){var I=o.Tween(e,F.opts,B,L,F.opts.specialEasing[B]||F.opts.easing);return F.tweens.push(I),I},stop:function(B){var L=0,I=B?F.tweens.length:0;if(c)return this;for(c=!0;L<I;L++)F.tweens[L].run(1);return B?(E.notifyWith(e,[F,1,0]),E.resolveWith(e,[F,B])):E.rejectWith(e,[F,B]),this}}),R=F.props;for(k(R,F.opts.specialEasing);f<h;f++)if(s=_.prefilters[f].call(F,e,R,F.opts),s)return q(s.stop)&&(o._queueHooks(F.elem,F.opts.queue).stop=s.stop.bind(s)),s;return o.map(R,v,F),q(F.opts.start)&&F.opts.start.call(e,F),F.progress(F.opts.progress).done(F.opts.done,F.opts.complete).fail(F.opts.fail).always(F.opts.always),o.fx.timer(o.extend(x,{elem:e,anim:F,queue:F.opts.queue})),F}o.Animation=o.extend(_,{tweeners:{"*":[function(e,r){var n=this.createTween(e,r);return Or(n.elem,e,Mt.exec(r),n),n}]},tweener:function(e,r){q(e)?(r=e,e=["*"]):e=e.match(vt);for(var n,s=0,c=e.length;s<c;s++)n=e[s],_.tweeners[n]=_.tweeners[n]||[],_.tweeners[n].unshift(r)},prefilters:[C],prefilter:function(e,r){r?_.prefilters.unshift(e):_.prefilters.push(e)}}),o.speed=function(e,r,n){var s=e&&typeof e=="object"?o.extend({},e):{complete:n||!n&&r||q(e)&&e,duration:e,easing:n&&r||r&&!q(r)&&r};return o.fx.off?s.duration=0:typeof s.duration!="number"&&(s.duration in o.fx.speeds?s.duration=o.fx.speeds[s.duration]:s.duration=o.fx.speeds._default),(s.queue==null||s.queue===!0)&&(s.queue="fx"),s.old=s.complete,s.complete=function(){q(s.old)&&s.old.call(this),s.queue&&o.dequeue(this,s.queue)},s},o.fn.extend({fadeTo:function(e,r,n,s){return this.filter(sr).css("opacity",0).show().end().animate({opacity:r},e,n,s)},animate:function(e,r,n,s){var c=o.isEmptyObject(e),f=o.speed(r,n,s),h=function(){var E=_(this,o.extend({},e),f);(c||le.get(this,"finish"))&&E.stop(!0)};return h.finish=h,c||f.queue===!1?this.each(h):this.queue(f.queue,h)},stop:function(e,r,n){var s=function(c){var f=c.stop;delete c.stop,f(n)};return typeof e!="string"&&(n=r,r=e,e=void 0),r&&this.queue(e||"fx",[]),this.each(function(){var c=!0,f=e!=null&&e+"queueHooks",h=o.timers,E=le.get(this);if(f)E[f]&&E[f].stop&&s(E[f]);else for(f in E)E[f]&&E[f].stop&&qn.test(f)&&s(E[f]);for(f=h.length;f--;)h[f].elem===this&&(e==null||h[f].queue===e)&&(h[f].anim.stop(n),c=!1,h.splice(f,1));(c||!n)&&o.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var r,n=le.get(this),s=n[e+"queue"],c=n[e+"queueHooks"],f=o.timers,h=s?s.length:0;for(n.finish=!0,o.queue(this,e,[]),c&&c.stop&&c.stop.call(this,!0),r=f.length;r--;)f[r].elem===this&&f[r].queue===e&&(f[r].anim.stop(!0),f.splice(r,1));for(r=0;r<h;r++)s[r]&&s[r].finish&&s[r].finish.call(this);delete n.finish})}}),o.each(["toggle","show","hide"],function(e,r){var n=o.fn[r];o.fn[r]=function(s,c,f){return s==null||typeof s=="boolean"?n.apply(this,arguments):this.animate(S(r,!0),s,c,f)}}),o.each({slideDown:S("show"),slideUp:S("hide"),slideToggle:S("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,r){o.fn[e]=function(n,s,c){return this.animate(r,n,s,c)}}),o.timers=[],o.fx.tick=function(){var e,r=0,n=o.timers;for(Jt=Date.now();r<n.length;r++)e=n[r],!e()&&n[r]===e&&n.splice(r--,1);n.length||o.fx.stop(),Jt=void 0},o.fx.timer=function(e){o.timers.push(e),o.fx.start()},o.fx.interval=13,o.fx.start=function(){Pr||(Pr=!0,Jr())},o.fx.stop=function(){Pr=null},o.fx.speeds={slow:600,fast:200,_default:400},o.fn.delay=function(e,r){return e=o.fx&&o.fx.speeds[e]||e,r=r||"fx",this.queue(r,function(n,s){var c=l.setTimeout(n,e);s.stop=function(){l.clearTimeout(c)}})},function(){var e=K.createElement("input"),r=K.createElement("select"),n=r.appendChild(K.createElement("option"));e.type="checkbox",U.checkOn=e.value!=="",U.optSelected=n.selected,e=K.createElement("input"),e.value="t",e.type="radio",U.radioValue=e.value==="t"}();var N,j=o.expr.attrHandle;o.fn.extend({attr:function(e,r){return _t(this,o.attr,e,r,arguments.length>1)},removeAttr:function(e){return this.each(function(){o.removeAttr(this,e)})}}),o.extend({attr:function(e,r,n){var s,c,f=e.nodeType;if(!(f===3||f===8||f===2)){if(typeof e.getAttribute=="undefined")return o.prop(e,r,n);if((f!==1||!o.isXMLDoc(e))&&(c=o.attrHooks[r.toLowerCase()]||(o.expr.match.bool.test(r)?N:void 0)),n!==void 0){if(n===null){o.removeAttr(e,r);return}return c&&"set"in c&&(s=c.set(e,n,r))!==void 0?s:(e.setAttribute(r,n+""),n)}return c&&"get"in c&&(s=c.get(e,r))!==null?s:(s=o.find.attr(e,r),s==null?void 0:s)}},attrHooks:{type:{set:function(e,r){if(!U.radioValue&&r==="radio"&&Me(e,"input")){var n=e.value;return e.setAttribute("type",r),n&&(e.value=n),r}}}},removeAttr:function(e,r){var n,s=0,c=r&&r.match(vt);if(c&&e.nodeType===1)for(;n=c[s++];)e.removeAttribute(n)}}),N={set:function(e,r,n){return r===!1?o.removeAttr(e,n):e.setAttribute(n,n),n}},o.each(o.expr.match.bool.source.match(/\w+/g),function(e,r){var n=j[r]||o.find.attr;j[r]=function(s,c,f){var h,E,x=c.toLowerCase();return f||(E=j[x],j[x]=h,h=n(s,c,f)!=null?x:null,j[x]=E),h}});var V=/^(?:input|select|textarea|button)$/i,G=/^(?:a|area)$/i;o.fn.extend({prop:function(e,r){return _t(this,o.prop,e,r,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[o.propFix[e]||e]})}}),o.extend({prop:function(e,r,n){var s,c,f=e.nodeType;if(!(f===3||f===8||f===2))return(f!==1||!o.isXMLDoc(e))&&(r=o.propFix[r]||r,c=o.propHooks[r]),n!==void 0?c&&"set"in c&&(s=c.set(e,n,r))!==void 0?s:e[r]=n:c&&"get"in c&&(s=c.get(e,r))!==null?s:e[r]},propHooks:{tabIndex:{get:function(e){var r=o.find.attr(e,"tabindex");return r?parseInt(r,10):V.test(e.nodeName)||G.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),U.optSelected||(o.propHooks.selected={get:function(e){var r=e.parentNode;return r&&r.parentNode&&r.parentNode.selectedIndex,null},set:function(e){var r=e.parentNode;r&&(r.selectedIndex,r.parentNode&&r.parentNode.selectedIndex)}}),o.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){o.propFix[this.toLowerCase()]=this});function Y(e){var r=e.match(vt)||[];return r.join(" ")}function Z(e){return e.getAttribute&&e.getAttribute("class")||""}function ye(e){return Array.isArray(e)?e:typeof e=="string"?e.match(vt)||[]:[]}o.fn.extend({addClass:function(e){var r,n,s,c,f,h;return q(e)?this.each(function(E){o(this).addClass(e.call(this,E,Z(this)))}):(r=ye(e),r.length?this.each(function(){if(s=Z(this),n=this.nodeType===1&&" "+Y(s)+" ",n){for(f=0;f<r.length;f++)c=r[f],n.indexOf(" "+c+" ")<0&&(n+=c+" ");h=Y(n),s!==h&&this.setAttribute("class",h)}}):this)},removeClass:function(e){var r,n,s,c,f,h;return q(e)?this.each(function(E){o(this).removeClass(e.call(this,E,Z(this)))}):arguments.length?(r=ye(e),r.length?this.each(function(){if(s=Z(this),n=this.nodeType===1&&" "+Y(s)+" ",n){for(f=0;f<r.length;f++)for(c=r[f];n.indexOf(" "+c+" ")>-1;)n=n.replace(" "+c+" "," ");h=Y(n),s!==h&&this.setAttribute("class",h)}}):this):this.attr("class","")},toggleClass:function(e,r){var n,s,c,f,h=typeof e,E=h==="string"||Array.isArray(e);return q(e)?this.each(function(x){o(this).toggleClass(e.call(this,x,Z(this),r),r)}):typeof r=="boolean"&&E?r?this.addClass(e):this.removeClass(e):(n=ye(e),this.each(function(){if(E)for(f=o(this),c=0;c<n.length;c++)s=n[c],f.hasClass(s)?f.removeClass(s):f.addClass(s);else(e===void 0||h==="boolean")&&(s=Z(this),s&&le.set(this,"__className__",s),this.setAttribute&&this.setAttribute("class",s||e===!1?"":le.get(this,"__className__")||""))}))},hasClass:function(e){var r,n,s=0;for(r=" "+e+" ";n=this[s++];)if(n.nodeType===1&&(" "+Y(Z(n))+" ").indexOf(r)>-1)return!0;return!1}});var ke=/\r/g;o.fn.extend({val:function(e){var r,n,s,c=this[0];return arguments.length?(s=q(e),this.each(function(f){var h;this.nodeType===1&&(s?h=e.call(this,f,o(this).val()):h=e,h==null?h="":typeof h=="number"?h+="":Array.isArray(h)&&(h=o.map(h,function(E){return E==null?"":E+""})),r=o.valHooks[this.type]||o.valHooks[this.nodeName.toLowerCase()],(!r||!("set"in r)||r.set(this,h,"value")===void 0)&&(this.value=h))})):c?(r=o.valHooks[c.type]||o.valHooks[c.nodeName.toLowerCase()],r&&"get"in r&&(n=r.get(c,"value"))!==void 0?n:(n=c.value,typeof n=="string"?n.replace(ke,""):n==null?"":n)):void 0}}),o.extend({valHooks:{option:{get:function(e){var r=o.find.attr(e,"value");return r!=null?r:Y(o.text(e))}},select:{get:function(e){var r,n,s,c=e.options,f=e.selectedIndex,h=e.type==="select-one",E=h?null:[],x=h?f+1:c.length;for(f<0?s=x:s=h?f:0;s<x;s++)if(n=c[s],(n.selected||s===f)&&!n.disabled&&(!n.parentNode.disabled||!Me(n.parentNode,"optgroup"))){if(r=o(n).val(),h)return r;E.push(r)}return E},set:function(e,r){for(var n,s,c=e.options,f=o.makeArray(r),h=c.length;h--;)s=c[h],(s.selected=o.inArray(o.valHooks.option.get(s),f)>-1)&&(n=!0);return n||(e.selectedIndex=-1),f}}}}),o.each(["radio","checkbox"],function(){o.valHooks[this]={set:function(e,r){if(Array.isArray(r))return e.checked=o.inArray(o(e).val(),r)>-1}},U.checkOn||(o.valHooks[this].get=function(e){return e.getAttribute("value")===null?"on":e.value})}),U.focusin="onfocusin"in l;var Pe=/^(?:focusinfocus|focusoutblur)$/,We=function(e){e.stopPropagation()};o.extend(o.event,{trigger:function(e,r,n,s){var c,f,h,E,x,F,R,B,L=[n||K],I=W.call(e,"type")?e.type:e,ne=W.call(e,"namespace")?e.namespace.split("."):[];if(f=B=h=n=n||K,!(n.nodeType===3||n.nodeType===8)&&!Pe.test(I+o.event.triggered)&&(I.indexOf(".")>-1&&(ne=I.split("."),I=ne.shift(),ne.sort()),x=I.indexOf(":")<0&&"on"+I,e=e[o.expando]?e:new o.Event(I,typeof e=="object"&&e),e.isTrigger=s?2:3,e.namespace=ne.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+ne.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=n),r=r==null?[e]:o.makeArray(r,[e]),R=o.event.special[I]||{},!(!s&&R.trigger&&R.trigger.apply(n,r)===!1))){if(!s&&!R.noBubble&&!de(n)){for(E=R.delegateType||I,Pe.test(E+I)||(f=f.parentNode);f;f=f.parentNode)L.push(f),h=f;h===(n.ownerDocument||K)&&L.push(h.defaultView||h.parentWindow||l)}for(c=0;(f=L[c++])&&!e.isPropagationStopped();)B=f,e.type=c>1?E:R.bindType||I,F=(le.get(f,"events")||Object.create(null))[e.type]&&le.get(f,"handle"),F&&F.apply(f,r),F=x&&f[x],F&&F.apply&&nr(f)&&(e.result=F.apply(f,r),e.result===!1&&e.preventDefault());return e.type=I,!s&&!e.isDefaultPrevented()&&(!R._default||R._default.apply(L.pop(),r)===!1)&&nr(n)&&x&&q(n[I])&&!de(n)&&(h=n[x],h&&(n[x]=null),o.event.triggered=I,e.isPropagationStopped()&&B.addEventListener(I,We),n[I](),e.isPropagationStopped()&&B.removeEventListener(I,We),o.event.triggered=void 0,h&&(n[x]=h)),e.result}},simulate:function(e,r,n){var s=o.extend(new o.Event,n,{type:e,isSimulated:!0});o.event.trigger(s,null,r)}}),o.fn.extend({trigger:function(e,r){return this.each(function(){o.event.trigger(e,r,this)})},triggerHandler:function(e,r){var n=this[0];if(n)return o.event.trigger(e,r,n,!0)}}),U.focusin||o.each({focus:"focusin",blur:"focusout"},function(e,r){var n=function(s){o.event.simulate(r,s.target,o.event.fix(s))};o.event.special[r]={setup:function(){var s=this.ownerDocument||this.document||this,c=le.access(s,r);c||s.addEventListener(e,n,!0),le.access(s,r,(c||0)+1)},teardown:function(){var s=this.ownerDocument||this.document||this,c=le.access(s,r)-1;c?le.access(s,r,c):(s.removeEventListener(e,n,!0),le.remove(s,r))}}});var Le=l.location,it={guid:Date.now()},jt=/\?/;o.parseXML=function(e){var r,n;if(!e||typeof e!="string")return null;try{r=new l.DOMParser().parseFromString(e,"text/xml")}catch(s){}return n=r&&r.getElementsByTagName("parsererror")[0],(!r||n)&&o.error("Invalid XML: "+(n?o.map(n.childNodes,function(s){return s.textContent}).join(`
`):e)),r};var Kr=/\[\]$/,zi=/\r?\n/g,Zr=/^(?:submit|button|image|reset|file)$/i,ss=/^(?:input|select|textarea|keygen)/i;function ei(e,r,n,s){var c;if(Array.isArray(r))o.each(r,function(f,h){n||Kr.test(e)?s(e,h):ei(e+"["+(typeof h=="object"&&h!=null?f:"")+"]",h,n,s)});else if(!n&&be(r)==="object")for(c in r)ei(e+"["+c+"]",r[c],n,s);else s(e,r)}o.param=function(e,r){var n,s=[],c=function(f,h){var E=q(h)?h():h;s[s.length]=encodeURIComponent(f)+"="+encodeURIComponent(E==null?"":E)};if(e==null)return"";if(Array.isArray(e)||e.jquery&&!o.isPlainObject(e))o.each(e,function(){c(this.name,this.value)});else for(n in e)ei(n,e[n],r,c);return s.join("&")},o.fn.extend({serialize:function(){return o.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=o.prop(this,"elements");return e?o.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!o(this).is(":disabled")&&ss.test(this.nodeName)&&!Zr.test(e)&&(this.checked||!Xt.test(e))}).map(function(e,r){var n=o(this).val();return n==null?null:Array.isArray(n)?o.map(n,function(s){return{name:r.name,value:s.replace(zi,`\r
`)}}):{name:r.name,value:n.replace(zi,`\r
`)}}).get()}});var Vn=/%20/g,qi=/#.*$/,Ao=/([?&])_=[^&]*/,Fo=/^(.*?):[ \t]*([^\r\n]*)$/mg,Do=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Lo=/^(?:GET|HEAD)$/,Ro=/^\/\//,os={},Gn={},ls="*/".concat("*"),Yn=K.createElement("a");Yn.href=Le.href;function us(e){return function(r,n){typeof r!="string"&&(n=r,r="*");var s,c=0,f=r.toLowerCase().match(vt)||[];if(q(n))for(;s=f[c++];)s[0]==="+"?(s=s.slice(1)||"*",(e[s]=e[s]||[]).unshift(n)):(e[s]=e[s]||[]).push(n)}}function cs(e,r,n,s){var c={},f=e===Gn;function h(E){var x;return c[E]=!0,o.each(e[E]||[],function(F,R){var B=R(r,n,s);if(typeof B=="string"&&!f&&!c[B])return r.dataTypes.unshift(B),h(B),!1;if(f)return!(x=B)}),x}return h(r.dataTypes[0])||!c["*"]&&h("*")}function Xn(e,r){var n,s,c=o.ajaxSettings.flatOptions||{};for(n in r)r[n]!==void 0&&((c[n]?e:s||(s={}))[n]=r[n]);return s&&o.extend(!0,e,s),e}function Io(e,r,n){for(var s,c,f,h,E=e.contents,x=e.dataTypes;x[0]==="*";)x.shift(),s===void 0&&(s=e.mimeType||r.getResponseHeader("Content-Type"));if(s){for(c in E)if(E[c]&&E[c].test(s)){x.unshift(c);break}}if(x[0]in n)f=x[0];else{for(c in n){if(!x[0]||e.converters[c+" "+x[0]]){f=c;break}h||(h=c)}f=f||h}if(f)return f!==x[0]&&x.unshift(f),n[f]}function Mo(e,r,n,s){var c,f,h,E,x,F={},R=e.dataTypes.slice();if(R[1])for(h in e.converters)F[h.toLowerCase()]=e.converters[h];for(f=R.shift();f;)if(e.responseFields[f]&&(n[e.responseFields[f]]=r),!x&&s&&e.dataFilter&&(r=e.dataFilter(r,e.dataType)),x=f,f=R.shift(),f){if(f==="*")f=x;else if(x!=="*"&&x!==f){if(h=F[x+" "+f]||F["* "+f],!h){for(c in F)if(E=c.split(" "),E[1]===f&&(h=F[x+" "+E[0]]||F["* "+E[0]],h)){h===!0?h=F[c]:F[c]!==!0&&(f=E[0],R.unshift(E[1]));break}}if(h!==!0)if(h&&e.throws)r=h(r);else try{r=h(r)}catch(B){return{state:"parsererror",error:h?B:"No conversion from "+x+" to "+f}}}}return{state:"success",data:r}}o.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Le.href,type:"GET",isLocal:Do.test(Le.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":ls,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":o.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,r){return r?Xn(Xn(e,o.ajaxSettings),r):Xn(o.ajaxSettings,e)},ajaxPrefilter:us(os),ajaxTransport:us(Gn),ajax:function(e,r){typeof e=="object"&&(r=e,e=void 0),r=r||{};var n,s,c,f,h,E,x,F,R,B,L=o.ajaxSetup({},r),I=L.context||L,ne=L.context&&(I.nodeType||I.jquery)?o(I):o.event,ve=o.Deferred(),re=o.Callbacks("once memory"),ze=L.statusCode||{},Ue={},ct={},Fe="canceled",me={readyState:0,getResponseHeader:function(Te){var je;if(x){if(!f)for(f={};je=Fo.exec(c);)f[je[1].toLowerCase()+" "]=(f[je[1].toLowerCase()+" "]||[]).concat(je[2]);je=f[Te.toLowerCase()+" "]}return je==null?null:je.join(", ")},getAllResponseHeaders:function(){return x?c:null},setRequestHeader:function(Te,je){return x==null&&(Te=ct[Te.toLowerCase()]=ct[Te.toLowerCase()]||Te,Ue[Te]=je),this},overrideMimeType:function(Te){return x==null&&(L.mimeType=Te),this},statusCode:function(Te){var je;if(Te)if(x)me.always(Te[me.status]);else for(je in Te)ze[je]=[ze[je],Te[je]];return this},abort:function(Te){var je=Te||Fe;return n&&n.abort(je),ot(0,je),this}};if(ve.promise(me),L.url=((e||L.url||Le.href)+"").replace(Ro,Le.protocol+"//"),L.type=r.method||r.type||L.method||L.type,L.dataTypes=(L.dataType||"*").toLowerCase().match(vt)||[""],L.crossDomain==null){E=K.createElement("a");try{E.href=L.url,E.href=E.href,L.crossDomain=Yn.protocol+"//"+Yn.host!=E.protocol+"//"+E.host}catch(Te){L.crossDomain=!0}}if(L.data&&L.processData&&typeof L.data!="string"&&(L.data=o.param(L.data,L.traditional)),cs(os,L,r,me),x)return me;F=o.event&&L.global,F&&o.active++==0&&o.event.trigger("ajaxStart"),L.type=L.type.toUpperCase(),L.hasContent=!Lo.test(L.type),s=L.url.replace(qi,""),L.hasContent?L.data&&L.processData&&(L.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&(L.data=L.data.replace(Vn,"+")):(B=L.url.slice(s.length),L.data&&(L.processData||typeof L.data=="string")&&(s+=(jt.test(s)?"&":"?")+L.data,delete L.data),L.cache===!1&&(s=s.replace(Ao,"$1"),B=(jt.test(s)?"&":"?")+"_="+it.guid+++B),L.url=s+B),L.ifModified&&(o.lastModified[s]&&me.setRequestHeader("If-Modified-Since",o.lastModified[s]),o.etag[s]&&me.setRequestHeader("If-None-Match",o.etag[s])),(L.data&&L.hasContent&&L.contentType!==!1||r.contentType)&&me.setRequestHeader("Content-Type",L.contentType),me.setRequestHeader("Accept",L.dataTypes[0]&&L.accepts[L.dataTypes[0]]?L.accepts[L.dataTypes[0]]+(L.dataTypes[0]!=="*"?", "+ls+"; q=0.01":""):L.accepts["*"]);for(R in L.headers)me.setRequestHeader(R,L.headers[R]);if(L.beforeSend&&(L.beforeSend.call(I,me,L)===!1||x))return me.abort();if(Fe="abort",re.add(L.complete),me.done(L.success),me.fail(L.error),n=cs(Gn,L,r,me),!n)ot(-1,"No Transport");else{if(me.readyState=1,F&&ne.trigger("ajaxSend",[me,L]),x)return me;L.async&&L.timeout>0&&(h=l.setTimeout(function(){me.abort("timeout")},L.timeout));try{x=!1,n.send(Ue,ot)}catch(Te){if(x)throw Te;ot(-1,Te)}}function ot(Te,je,ri,Vi){var ft,cr,fr,lt,Kt,xt=je;x||(x=!0,h&&l.clearTimeout(h),n=void 0,c=Vi||"",me.readyState=Te>0?4:0,ft=Te>=200&&Te<300||Te===304,ri&&(lt=Io(L,me,ri)),!ft&&o.inArray("script",L.dataTypes)>-1&&o.inArray("json",L.dataTypes)<0&&(L.converters["text script"]=function(){}),lt=Mo(L,lt,me,ft),ft?(L.ifModified&&(Kt=me.getResponseHeader("Last-Modified"),Kt&&(o.lastModified[s]=Kt),Kt=me.getResponseHeader("etag"),Kt&&(o.etag[s]=Kt)),Te===204||L.type==="HEAD"?xt="nocontent":Te===304?xt="notmodified":(xt=lt.state,cr=lt.data,fr=lt.error,ft=!fr)):(fr=xt,(Te||!xt)&&(xt="error",Te<0&&(Te=0))),me.status=Te,me.statusText=(je||xt)+"",ft?ve.resolveWith(I,[cr,xt,me]):ve.rejectWith(I,[me,xt,fr]),me.statusCode(ze),ze=void 0,F&&ne.trigger(ft?"ajaxSuccess":"ajaxError",[me,L,ft?cr:fr]),re.fireWith(I,[me,xt]),F&&(ne.trigger("ajaxComplete",[me,L]),--o.active||o.event.trigger("ajaxStop")))}return me},getJSON:function(e,r,n){return o.get(e,r,n,"json")},getScript:function(e,r){return o.get(e,void 0,r,"script")}}),o.each(["get","post"],function(e,r){o[r]=function(n,s,c,f){return q(s)&&(f=f||c,c=s,s=void 0),o.ajax(o.extend({url:n,type:r,dataType:f,data:s,success:c},o.isPlainObject(n)&&n))}}),o.ajaxPrefilter(function(e){var r;for(r in e.headers)r.toLowerCase()==="content-type"&&(e.contentType=e.headers[r]||"")}),o._evalUrl=function(e,r,n){return o.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(s){o.globalEval(s,r,n)}})},o.fn.extend({wrapAll:function(e){var r;return this[0]&&(q(e)&&(e=e.call(this[0])),r=o(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&r.insertBefore(this[0]),r.map(function(){for(var n=this;n.firstElementChild;)n=n.firstElementChild;return n}).append(this)),this},wrapInner:function(e){return q(e)?this.each(function(r){o(this).wrapInner(e.call(this,r))}):this.each(function(){var r=o(this),n=r.contents();n.length?n.wrapAll(e):r.append(e)})},wrap:function(e){var r=q(e);return this.each(function(n){o(this).wrapAll(r?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){o(this).replaceWith(this.childNodes)}),this}}),o.expr.pseudos.hidden=function(e){return!o.expr.pseudos.visible(e)},o.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},o.ajaxSettings.xhr=function(){try{return new l.XMLHttpRequest}catch(e){}};var No={0:200,1223:204},ti=o.ajaxSettings.xhr();U.cors=!!ti&&"withCredentials"in ti,U.ajax=ti=!!ti,o.ajaxTransport(function(e){var r,n;if(U.cors||ti&&!e.crossDomain)return{send:function(s,c){var f,h=e.xhr();if(h.open(e.type,e.url,e.async,e.username,e.password),e.xhrFields)for(f in e.xhrFields)h[f]=e.xhrFields[f];e.mimeType&&h.overrideMimeType&&h.overrideMimeType(e.mimeType),!e.crossDomain&&!s["X-Requested-With"]&&(s["X-Requested-With"]="XMLHttpRequest");for(f in s)h.setRequestHeader(f,s[f]);r=function(E){return function(){r&&(r=n=h.onload=h.onerror=h.onabort=h.ontimeout=h.onreadystatechange=null,E==="abort"?h.abort():E==="error"?typeof h.status!="number"?c(0,"error"):c(h.status,h.statusText):c(No[h.status]||h.status,h.statusText,(h.responseType||"text")!=="text"||typeof h.responseText!="string"?{binary:h.response}:{text:h.responseText},h.getAllResponseHeaders()))}},h.onload=r(),n=h.onerror=h.ontimeout=r("error"),h.onabort!==void 0?h.onabort=n:h.onreadystatechange=function(){h.readyState===4&&l.setTimeout(function(){r&&n()})},r=r("abort");try{h.send(e.hasContent&&e.data||null)}catch(E){if(r)throw E}},abort:function(){r&&r()}}}),o.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),o.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return o.globalEval(e),e}}}),o.ajaxPrefilter("script",function(e){e.cache===void 0&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),o.ajaxTransport("script",function(e){if(e.crossDomain||e.scriptAttrs){var r,n;return{send:function(s,c){r=o("<script>").attr(e.scriptAttrs||{}).prop({charset:e.scriptCharset,src:e.url}).on("load error",n=function(f){r.remove(),n=null,f&&c(f.type==="error"?404:200,f.type)}),K.head.appendChild(r[0])},abort:function(){n&&n()}}}});var fs=[],Qn=/(=)\?(?=&|$)|\?\?/;o.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=fs.pop()||o.expando+"_"+it.guid++;return this[e]=!0,e}}),o.ajaxPrefilter("json jsonp",function(e,r,n){var s,c,f,h=e.jsonp!==!1&&(Qn.test(e.url)?"url":typeof e.data=="string"&&(e.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&Qn.test(e.data)&&"data");if(h||e.dataTypes[0]==="jsonp")return s=e.jsonpCallback=q(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,h?e[h]=e[h].replace(Qn,"$1"+s):e.jsonp!==!1&&(e.url+=(jt.test(e.url)?"&":"?")+e.jsonp+"="+s),e.converters["script json"]=function(){return f||o.error(s+" was not called"),f[0]},e.dataTypes[0]="json",c=l[s],l[s]=function(){f=arguments},n.always(function(){c===void 0?o(l).removeProp(s):l[s]=c,e[s]&&(e.jsonpCallback=r.jsonpCallback,fs.push(s)),f&&q(c)&&c(f[0]),f=c=void 0}),"script"}),U.createHTMLDocument=function(){var e=K.implementation.createHTMLDocument("").body;return e.innerHTML="<form></form><form></form>",e.childNodes.length===2}(),o.parseHTML=function(e,r,n){if(typeof e!="string")return[];typeof r=="boolean"&&(n=r,r=!1);var s,c,f;return r||(U.createHTMLDocument?(r=K.implementation.createHTMLDocument(""),s=r.createElement("base"),s.href=K.location.href,r.head.appendChild(s)):r=K),c=tt.exec(e),f=!n&&[],c?[r.createElement(c[1])]:(c=Ur([e],r,f),f&&f.length&&o(f).remove(),o.merge([],c.childNodes))},o.fn.load=function(e,r,n){var s,c,f,h=this,E=e.indexOf(" ");return E>-1&&(s=Y(e.slice(E)),e=e.slice(0,E)),q(r)?(n=r,r=void 0):r&&typeof r=="object"&&(c="POST"),h.length>0&&o.ajax({url:e,type:c||"GET",dataType:"html",data:r}).done(function(x){f=arguments,h.html(s?o("<div>").append(o.parseHTML(x)).find(s):x)}).always(n&&function(x,F){h.each(function(){n.apply(this,f||[x.responseText,F,x])})}),this},o.expr.pseudos.animated=function(e){return o.grep(o.timers,function(r){return e===r.elem}).length},o.offset={setOffset:function(e,r,n){var s,c,f,h,E,x,F,R=o.css(e,"position"),B=o(e),L={};R==="static"&&(e.style.position="relative"),E=B.offset(),f=o.css(e,"top"),x=o.css(e,"left"),F=(R==="absolute"||R==="fixed")&&(f+x).indexOf("auto")>-1,F?(s=B.position(),h=s.top,c=s.left):(h=parseFloat(f)||0,c=parseFloat(x)||0),q(r)&&(r=r.call(e,n,o.extend({},E))),r.top!=null&&(L.top=r.top-E.top+h),r.left!=null&&(L.left=r.left-E.left+c),"using"in r?r.using.call(e,L):B.css(L)}},o.fn.extend({offset:function(e){if(arguments.length)return e===void 0?this:this.each(function(c){o.offset.setOffset(this,e,c)});var r,n,s=this[0];if(!!s)return s.getClientRects().length?(r=s.getBoundingClientRect(),n=s.ownerDocument.defaultView,{top:r.top+n.pageYOffset,left:r.left+n.pageXOffset}):{top:0,left:0}},position:function(){if(!!this[0]){var e,r,n,s=this[0],c={top:0,left:0};if(o.css(s,"position")==="fixed")r=s.getBoundingClientRect();else{for(r=this.offset(),n=s.ownerDocument,e=s.offsetParent||n.documentElement;e&&(e===n.body||e===n.documentElement)&&o.css(e,"position")==="static";)e=e.parentNode;e&&e!==s&&e.nodeType===1&&(c=o(e).offset(),c.top+=o.css(e,"borderTopWidth",!0),c.left+=o.css(e,"borderLeftWidth",!0))}return{top:r.top-c.top-o.css(s,"marginTop",!0),left:r.left-c.left-o.css(s,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var e=this.offsetParent;e&&o.css(e,"position")==="static";)e=e.offsetParent;return e||At})}}),o.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,r){var n=r==="pageYOffset";o.fn[e]=function(s){return _t(this,function(c,f,h){var E;if(de(c)?E=c:c.nodeType===9&&(E=c.defaultView),h===void 0)return E?E[r]:c[f];E?E.scrollTo(n?E.pageXOffset:h,n?h:E.pageYOffset):c[f]=h},e,s,arguments.length)}}),o.each(["top","left"],function(e,r){o.cssHooks[r]=Wi(U.pixelPosition,function(n,s){if(s)return s=or(n,r),qr.test(s)?o(n).position()[r]+"px":s})}),o.each({Height:"height",Width:"width"},function(e,r){o.each({padding:"inner"+e,content:r,"":"outer"+e},function(n,s){o.fn[s]=function(c,f){var h=arguments.length&&(n||typeof c!="boolean"),E=n||(c===!0||f===!0?"margin":"border");return _t(this,function(x,F,R){var B;return de(x)?s.indexOf("outer")===0?x["inner"+e]:x.document.documentElement["client"+e]:x.nodeType===9?(B=x.documentElement,Math.max(x.body["scroll"+e],B["scroll"+e],x.body["offset"+e],B["offset"+e],B["client"+e])):R===void 0?o.css(x,F,E):o.style(x,F,R,E)},r,h?c:void 0,h)}})}),o.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,r){o.fn[r]=function(n){return this.on(r,n)}}),o.fn.extend({bind:function(e,r,n){return this.on(e,null,r,n)},unbind:function(e,r){return this.off(e,null,r)},delegate:function(e,r,n,s){return this.on(r,e,n,s)},undelegate:function(e,r,n){return arguments.length===1?this.off(e,"**"):this.off(r,e||"**",n)},hover:function(e,r){return this.mouseenter(e).mouseleave(r||e)}}),o.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,r){o.fn[r]=function(n,s){return arguments.length>0?this.on(r,null,n,s):this.trigger(r)}});var Oo=/^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;o.proxy=function(e,r){var n,s,c;if(typeof r=="string"&&(n=e[r],r=e,e=n),!!q(e))return s=u.call(arguments,2),c=function(){return e.apply(r||this,s.concat(u.call(arguments)))},c.guid=e.guid=e.guid||o.guid++,c},o.holdReady=function(e){e?o.readyWait++:o.ready(!0)},o.isArray=Array.isArray,o.parseJSON=JSON.parse,o.nodeName=Me,o.isFunction=q,o.isWindow=de,o.camelCase=bt,o.type=be,o.now=Date.now,o.isNumeric=function(e){var r=o.type(e);return(r==="number"||r==="string")&&!isNaN(e-parseFloat(e))},o.trim=function(e){return e==null?"":(e+"").replace(Oo,"$1")},typeof define=="function"&&define.amd&&define("jquery",[],function(){return o});var $o=l.jQuery,Wo=l.$;return o.noConflict=function(e){return l.$===o&&(l.$=Wo),e&&l.jQuery===o&&(l.jQuery=$o),o},typeof t=="undefined"&&(l.jQuery=l.$=o),o})});var za=aa(ha());var on=class{constructor(t,i){t=t||[],this.lines=t,this.text=i,this.offset2loc=new Map,this.line2offset=new Map;for(var a of t)a.offset>=0&&(this.offset2loc[a.offset]||(this.offset2loc[a.offset]=a),this.line2offset[a.line]||(this.line2offset[a.line]=a.offset))}findLineForOffset(t,i){if(this.offset2loc)for(var a=0;a<=i;a++){var u=this.offset2loc[t];if(u)return u;t--}return null}lineCount(){return this.lines.length}};function Ms(l){return"errors"in l}function Ns(l){return"output"in l}var Os=aa(ha()),pa=class{constructor(t){this.preset_id=gt(t)}async getRemoteFile(t){return new Promise((i,a)=>nn(t,i,gr(t)?"arraybuffer":"text"))}async getFileData(t){var i="presets/"+this.preset_id+"/"+t,a=await this.getRemoteFile(i);return a&&console.log("read",i,a.length,"bytes"),a}async setFileData(t,i){}};var ui=class{constructor(t,i){this.basefs=t,this.overlayfs=i}async getFileData(t){var i=await this.overlayfs.getFileData(t);return i==null?this.basefs.getFileData(t):i}async setFileData(t,i){return await this.overlayfs.setFileData(t,i),this.basefs.setFileData(t,i)}},ma=class{constructor(t){this.store=t}async getFileData(t){return this.store.getItem(t)}async setFileData(t,i){return this.store.setItem(t,i)}};var va=class{constructor(t,i,a,u){this.filedata={};this.pendingWorkerMessages=0;this.tools_preloaded={};this.isCompiling=!1;this.filename2path={};this.worker=t,this.platform_id=i,this.platform=a,this.filesystem=u,t.onmessage=d=>{this.receiveWorkerMessage(d.data)}}receiveWorkerMessage(t){var i=this.pendingWorkerMessages>1;i?(this.sendBuild(),this.pendingWorkerMessages=1):(this.callbackBuildStatus&&this.callbackBuildStatus(!1),this.isCompiling||(console.log(this.pendingWorkerMessages),console.trace()),this.isCompiling=!1,this.pendingWorkerMessages=0),t&&Ns(t)?this.processBuildResult(t):Ms(t)&&this.processBuildListings(t),this.callbackBuildResult(t)}getToolForFilename(t){return this.remoteTool?"remote:"+this.remoteTool:this.platform.getToolForFilename(t)}preloadWorker(t){var i=this.getToolForFilename(t);i&&!this.tools_preloaded[i]&&(this.worker.postMessage({preload:i,platform:this.platform_id}),this.tools_preloaded[i]=!0)}pushAllFiles(t,i){t.push(i);var a=sa(this.mainPath);a.length>0&&a!="local"&&t.push(a+"/"+i)}parseIncludeDependencies(t){let i=[],a;if(this.platform_id.startsWith("script")){let u=/\b\w+[.]read\(["'](.+?)["']/gmi;for(;a=u.exec(t);)a[1]&&a[1].indexOf(":/")<0&&this.pushAllFiles(i,a[1])}else if(this.platform_id.startsWith("verilog")){let u=/^\s*(`include|[.]include)\s+"(.+?)"/gmi;for(;a=u.exec(t);)this.pushAllFiles(i,a[2]);let d=/^\s*\$(include|\$dofile|\$write_image_in_table)\('(.+?)'/gmi;for(;a=d.exec(t);)this.pushAllFiles(i,a[2]);let m=/^\s*([.]arch)\s+(\w+)/gmi;for(;a=m.exec(t);)this.pushAllFiles(i,a[2]+".json");let y=/\$readmem[bh]\("(.+?)"/gmi;for(;a=y.exec(t);)this.pushAllFiles(i,a[1])}else{let u=/^\s*[.#%]?(include|incbin)\s+"(.+?)"/gmi;for(;a=u.exec(t);)this.pushAllFiles(i,a[2]);let d=/^\s*([;']|[/][/])#resource\s+"(.+?)"/gm;for(;a=d.exec(t);)this.pushAllFiles(i,a[2]);let m=/^\s+(USE|ASM)\s+(\S+[.]\S+)/gm;for(;a=m.exec(t);)this.pushAllFiles(i,a[2]);let y=/^\s*(import|embed)\s*"(.+?)";/gmi;for(;a=y.exec(t);)a[1]=="import"?this.pushAllFiles(i,a[2]+".wiz"):this.pushAllFiles(i,a[2]);let b=/^\s*(import)\s*"(.+?)"/gmi;for(;a=b.exec(t);)this.pushAllFiles(i,a[2])}return i}parseLinkDependencies(t){let i=[],a;if(!this.platform_id.startsWith("verilog")){let u=/^\s*([;]|[/][/])#link\s+"(.+?)"/gm;for(;a=u.exec(t);)this.pushAllFiles(i,a[2])}return i}loadFileDependencies(t){let i=this.parseIncludeDependencies(t),a=this.parseLinkDependencies(t),u=i.concat(a);return this.loadFiles(u).then(d=>{if(d)for(let m of d)m.link=a.indexOf(m.path)>=0;return d})}okToSend(){return this.pendingWorkerMessages++==0&&this.mainPath!=null}updateFileInStore(t,i){this.filesystem.setFileData(t,i)}buildWorkerMessage(t){this.preloadWorker(this.mainPath);var i={updates:[],buildsteps:[]},a=this.stripLocalPath(this.mainPath),u=this.getFile(this.mainPath),d=[];i.updates.push({path:a,data:u}),this.filename2path[a]=this.mainPath;for(var m of t)m.link||(i.updates.push({path:m.filename,data:m.data}),d.push(m.filename)),this.filename2path[m.filename]=m.path;i.buildsteps.push({path:a,files:[a].concat(d),platform:this.platform_id,tool:this.getToolForFilename(this.mainPath),mainfile:!0});for(var m of t)m.data&&m.link&&(this.preloadWorker(m.filename),i.updates.push({path:m.filename,data:m.data}),i.buildsteps.push({path:m.filename,files:[m.filename].concat(d),platform:this.platform_id,tool:this.getToolForFilename(m.path)}));return this.dataItems&&(i.setitems=this.dataItems),i}async loadFiles(t){var i=[],a=(m,y)=>{i.push({path:m,filename:this.stripLocalPath(m),link:!0,data:y})};for(var u of t)if(u in this.filedata){var d=this.filedata[u];d&&a(u,d)}else{var d=await this.filesystem.getFileData(u);d?(this.filedata[u]=d,a(u,d)):this.filedata[u]=null}return i}getFile(t){return this.filedata[t]}iterateFiles(t){for(var i in this.filedata)t(i,this.getFile(i))}sendBuild(){if(!this.mainPath)throw Error("need to call setMainFile first");var t=this.getFile(this.mainPath);if(t instanceof Uint8Array){this.isCompiling=!0,this.receiveWorkerMessage({output:t,errors:[],listings:null,symbolmap:null,params:{}});return}var i=typeof t=="string"?t:"";return this.loadFileDependencies(i).then(a=>{a||(a=[]);var u=this.buildWorkerMessage(a);this.worker.postMessage(u),this.isCompiling=!0})}updateFile(t,i){this.filedata[t]!=i&&(this.updateFileInStore(t,i),this.filedata[t]=i,this.okToSend()&&(this.callbackBuildStatus&&this.callbackBuildStatus(!0),this.sendBuild()))}setMainFile(t){this.mainPath=t,this.callbackBuildStatus&&this.callbackBuildStatus(!0),this.sendBuild()}processBuildListings(t){if(t.listings){this.listings=t.listings;for(var i in this.listings){var a=this.listings[i];a.lines&&(a.sourcefile=new on(a.lines,a.text)),a.asmlines&&(a.assemblyfile=new on(a.asmlines,a.text))}}}processBuildResult(t){this.processBuildListings(t),this.processBuildSegments(t)}processBuildSegments(t){var i=this.platform.getMemoryMap&&this.platform.getMemoryMap().main||[];t.segments&&(i=i.concat(t.segments||[])),i.sort((a,u)=>a.start-u.start),this.segments=i}getListings(){return this.listings}getListingForFile(t){var i=pt(this.stripLocalPath(t)),a=this.getListings(),u=null;for(var d in a)if(d==t)return a[d];for(var d in a)if(u=d,pt(d)==i)return a[d]}stripLocalPath(t){if(this.mainPath){var i=sa(this.mainPath);i!=""&&t.startsWith(i+"/")&&(t=t.substring(i.length+1))}return t}updateDataItems(t){this.dataItems=t,this.okToSend()&&this.sendBuild()}};function ba(l){var t=Os.default.createInstance({name:"__"+l,version:2});return t}var ya=Ws(),xa=class{constructor(t,i){this.id2window={};this.id2createfn={};this.id2showfn={};this.id2div={};this.containerdiv=t,this.project=i,this.undofiles=[]}isWindow(t){return this.id2createfn[t]!=null}setCreateFunc(t,i){this.id2createfn[t]=i}setShowFunc(t,i){this.id2showfn[t]=i}create(t){var i=this.id2window[t];i||(console.log("creating window",t),i=this.id2window[t]=this.id2createfn[t](t));var a=this.id2div[t];return a||(a=this.id2div[t]=i.createDiv(this.containerdiv),ya(a).hide()),i}createOrShow(t,i){var a=this.create(t),u=this.id2div[t];return this.activewnd!=a?(this.activediv&&ya(this.activediv).hide(),this.activewnd&&this.activewnd.setVisible&&this.activewnd.setVisible(!1),this.activediv=u,this.activewnd=a,ya(u).show(),this.refresh(!0),this.refreshErrors(),a.setVisible&&a.setVisible(!0),this.id2showfn[t]&&this.id2showfn[t](t,a)):this.refresh(i),this.activeid=t,a}put(t,i){this.id2window[t]=i}refresh(t){this.activewnd&&this.activewnd.refresh&&this.activewnd.refresh(t)}tick(){this.activewnd&&this.activewnd.tick&&this.activewnd.tick()}setErrors(t){this.lasterrors=t,this.refreshErrors()}refreshErrors(){this.activewnd&&this.activewnd.markErrors&&(this.lasterrors&&this.lasterrors.length?this.activewnd.markErrors(this.lasterrors):this.activewnd.clearErrors())}getActive(){return this.activewnd}getActiveID(){return this.activeid}getCurrentText(){if(this.activewnd&&this.activewnd.getValue)return this.activewnd.getValue();bootbox.alert("Please switch to an editor window.")}resize(){this.activeid&&this.activewnd&&this.activewnd.recreateOnResize&&(this.activewnd=null,this.id2window[this.activeid]=null,this.id2div[this.activeid]=null,this.createOrShow(this.activeid))}updateFile(t,i){var a=this.id2window[t];a&&a.setText&&typeof i=="string"?(a.setText(i),this.undofiles.push(t)):this.project.updateFile(t,i)}undoStep(){var t=this.undofiles.pop(),i=this.id2window[t];i&&i.undoStep?i.undoStep():bootbox.alert("No more steps to undo.")}updateAllOpenWindows(t){for(var i in this.id2window){var a=this.id2window[i];a&&a.setText&&t.getItem(i).then(u=>{this.updateFile(i,u)})}}findWindowWithFilePrefix(t){t=Et(pt(t));for(var i in this.id2createfn)if(!(i.toLowerCase().endsWith(".h")||i.toLowerCase().endsWith(".inc")||i.toLowerCase().endsWith(".bas"))&&Et(pt(i))==t)return i;return null}};var il=`$NAME
=====
[Open this project in 8bitworkshop](http://8bitworkshop.com/redir.html?platform=$PLATFORM&githubURL=$GITHUBURL&file=$MAINFILE).
`;function ci(){for(var l={},t=0;t<localStorage.length;t++){var i=localStorage.key(t);if(i.startsWith("__repo__")){var a=JSON.parse(localStorage.getItem(i)),u=i.substring("__repo__".length);l[u]=a}}return l}function un(l){var t=l.split("/",8);return t.length<5||t[0]!="https:"||t[2]!="github.com"||t[5]&&t[5]!="tree"?null:{user:t[3],repo:t[4],repopath:t[3]+"/"+t[4],branch:t[6],subtreepath:t[7]}}var wa=class{constructor(t,i,a,u){this.githubCons=t,this.githubToken=i,this.store=a,this.project=u,this.recreateGithub()}recreateGithub(){this.github=new this.githubCons({token:this.githubToken})}login(){if(this.githubToken&&this.githubToken.length)return new Promise((i,a)=>{i()});var t=new firebase.auth.GithubAuthProvider;return t.addScope("repo"),firebase.auth().signInWithPopup(t).then(i=>{this.githubToken=i.credential.accessToken;var a=i.user;this.recreateGithub(),document.cookie="__github_key="+this.githubToken+";path=/;max-age=31536000",console.log("Stored GitHub OAUTH key")})}logout(){return this.githubToken&&this.githubToken.length?firebase.auth().signOut().then(()=>{document.cookie="__github_key=;path=/;max-age=0",this.githubToken=null,this.recreateGithub()}):new Promise((t,i)=>{t()})}isFileIgnored(t){return t=t.toUpperCase(),!!(t.startsWith("LICENSE")||t.startsWith("README")||t.startsWith("."))}async getGithubSession(t){var i=un(t);if(!i)throw new Error("Please enter a valid GitHub URL.");var a=ci()[i.repopath],u=i.branch||a&&a.branch,d=this.github.repos(i.user,i.repo);try{u=(await d.fetch()).defaultBranch||"master"}catch(y){console.log("could not fetch default branch: "+y),u="main"}console.log("branch =",u);var m={url:t,user:i.user,reponame:i.repo,repopath:i.repopath,branch:u,subtreepath:i.subtreepath,prefix:"",repo:d,platform_id:this.project?this.project.platform_id:a?a.platform_id:null};return m}getGithubHEADTree(t){var i;return this.getGithubSession(t).then(a=>(i=a,i.repo.git.refs.heads(i.branch).fetch())).then(a=>(i.head=a,i.sha=a.object.sha,i.repo.git.trees(i.sha).fetch())).then(a=>{if(i.subtreepath){for(let u of a.tree)if(u.type=="tree"&&u.path==i.subtreepath&&u.sha)return i.repo.git.trees(u.sha).fetch();throw Error("Cannot find subtree '"+i.subtreepath+"' in tree "+a.sha)}return a}).then(a=>(i.tree=a,i))}bind(t,i){var a="__repo__"+t.repopath;if(i){var u={url:t.url,branch:t.branch,platform_id:t.platform_id,mainPath:t.mainPath,sha:t.sha};console.log("storing",u),localStorage.setItem(a,JSON.stringify(u))}else localStorage.removeItem(a)}import(t){var i;return this.getGithubSession(t).then(a=>(i=a,i.repo.contents("README.md").read())).catch(a=>(console.log(a),console.log("no README.md found"),i.repo.fetch().then(u=>""))).then(a=>{var u;if(u=/8bitworkshop.com[^)]+file=([^)&]+)/.exec(a),u&&u[1]&&(console.log("main path: '"+u[1]+"'"),i.mainPath=u[1]),u=/8bitworkshop.com[^)]+platform=([A-Za-z0-9._\-]+)/.exec(a),u){if(console.log("platform id: '"+u[1]+"'"),i.platform_id&&!i.platform_id.startsWith(u[1]))throw Error("Platform mismatch: Repository is "+u[1]+", you have "+i.platform_id+" selected.");i.platform_id=u[1]}return this.bind(i,!0),i})}pull(t,i){var a;return this.getGithubHEADTree(t).then(u=>{a=u;let d=[];return a.paths=[],a.tree.tree.forEach(m=>{if(console.log(m.path,m.type,m.size),a.paths.push(m.path),m.type=="blob"&&!this.isFileIgnored(m.path)){var y=a.repo.git.blobs(m.sha).fetch().then(b=>{var D=a.prefix+m.path,W=m.size,fe=b.encoding,z=b.content;if(b.encoding=="base64"){var U=Zi(atob(z)),q=gr(m.path,U);z=q?U:tn(U)}return b.size!=z.length&&(z=z.slice(0,b.size)),(i||this.store).setItem(D,z)});d.push(y)}else console.log("ignoring "+m.path)}),Promise.all(d)}).then(u=>a)}importAndPull(t){return this.import(t).then(i=>this.pull(t))}publish(t,i,a,u){var d,m=this.project.platform_id,y=this.project.stripLocalPath(this.project.mainPath);return this.github.user.repos.create({name:t,description:i,private:u,auto_init:!1,license_template:a}).then(b=>{d=b;var D=il;D=D.replace(/\$NAME/g,encodeURIComponent(t)),D=D.replace(/\$PLATFORM/g,encodeURIComponent(m)),D=D.replace(/\$GITHUBURL/g,encodeURIComponent(d.htmlUrl)),D=D.replace(/\$MAINFILE/g,encodeURIComponent(y));var W={message:"8bitworkshop: updated metadata in README.md",content:btoa(D)};return d.contents("README.md").add(W)}).then(()=>this.getGithubSession(d.htmlUrl))}commit(t,i,a){var u;return i||(i="updated from 8bitworkshop.com"),this.getGithubHEADTree(t).then(d=>{if(u=d,u.subtreepath)throw Error("Sorry, right now you can only commit files to the root directory of a repository.");return Promise.all(a.map(m=>typeof m.data=="string"?u.repo.git.blobs.create({content:m.data,encoding:"utf-8"}):u.repo.git.blobs.create({content:btoa(en(m.data)),encoding:"base64"})))}).then(d=>u.repo.git.trees.create({tree:a.map((m,y)=>({path:m.path,mode:"100644",type:"blob",sha:d[y].sha})),base_tree:u.tree.sha})).then(d=>u.repo.git.commits.create({message:i,tree:d.sha,parents:[u.head.object.sha]})).then(d=>u.repo.commits(d.sha).fetch()).then(d=>(u.commit=d,u))}push(t){return t.head.update({sha:t.commit.sha}).then(i=>t)}deleteRepository(t){return this.getGithubSession(t).then(i=>i.repo.remove())}};var fi=window.matchMedia&&window.matchMedia("only screen and (max-width: 760px)").matches;function Ut(l,t){var i=$(document.createElement("div"));return l&&i.appendTo(l),t&&i.addClass(t),i}function js(l,t){var i=l.charCoords({line:t,ch:0},"local").top,a=l.getScrollerElement().offsetHeight/2;l.scrollTo(null,i-a-5)}function Bs(l,t){var i=document.createElement("span");return i.setAttribute("class",t),i.appendChild(document.createTextNode(l)),i}var cn=64,nl=200,Ea={default:{theme:"mbo"},"6502":{isAsm:!0},z80:{isAsm:!0},jsasm:{isAsm:!0},gas:{isAsm:!0},vasm:{isAsm:!0},inform6:{theme:"cobalt"},markdown:{lineWrap:!0},fastbasic:{noGutters:!0},basic:{noLineNumbers:!0,noGutters:!0},ecs:{theme:"mbo",isAsm:!0}},Hs={input:null},di=class{constructor(t,i){this.updateTimer=null;this.dirtylisting=!0;this.errormsgs=[];this.errorwidgets=[];this.errormarks=[];this.path=t,this.mode=i}createDiv(t){var i=document.createElement("div");i.setAttribute("class","editor"),t.appendChild(i);var a=pe.getFile(this.path),u=a&&this.mode=="verilog"&&/__asm\b([\s\S]+?)\b__endasm\b/.test(a);return this.newEditor(i,u),a&&(this.setText(a),this.editor.setSelection({line:0,ch:0},{line:0,ch:0},{scroll:!0})),this.setupEditor(),i}setVisible(t){t&&this.editor.focus()}newEditor(t,i){var a=Ea[this.mode]||Ea.default,u=i||a.isAsm,d=!!a.lineWrap,m=a.theme||Ea.default.theme,y=!a.noLineNumbers&&!fi;ee.embed&&(y=!1,u=!1);var b=["CodeMirror-linenumbers","gutter-offset","gutter-info"];u&&(b=["CodeMirror-linenumbers","gutter-offset","gutter-bytes","gutter-clock","gutter-info"]),(a.noGutters||fi)&&(b=["gutter-info"]),this.editor=CodeMirror(t,{theme:m,lineNumbers:y,matchBrackets:!0,tabSize:8,indentAuto:!0,lineWrapping:d,gutters:b})}editorChanged(){clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{pe.updateFile(this.path,this.editor.getValue())},300),this.markHighlight&&(this.markHighlight.clear(),this.markHighlight=null)}setupEditor(){this.editor.on("changes",(t,i)=>{this.editorChanged()}),this.editor.on("cursorActivity",t=>{this.inspectUnderCursor()}),this.editor.on("gutterClick",(t,i)=>{this.toggleBreakpoint(i)}),this.editor.setOption("mode",this.mode),this.editor.on("beforeChange",(t,i)=>{Hs.input&&i.text&&(i.text=i.text.map(Hs.input))})}inspectUnderCursor(){var t=this.editor.getCursor(!0),i=this.editor.getCursor(!1);if(t.line==i.line&&t.ch<i.ch&&i.ch-t.ch<80){var a=this.editor.getSelection();this.inspect(a)}else this.inspect(null)}inspect(t){var i;if(A.inspect&&(i=A.inspect(t)),this.inspectWidget&&(this.inspectWidget.clear(),this.inspectWidget=null),i){var a=Bs(i,"tooltipinfoline"),u=this.editor.getCursor().line;this.inspectWidget=this.editor.addLineWidget(u,a,{above:!1})}}setText(t){var i,a,u=this.editor.getValue();u!=t&&(this.editor.setValue(t),u==""&&this.editor.clearHistory())}insertText(t){var i=this.editor.getCursor();this.editor.replaceRange(t,i,i)}highlightLines(t,i){var a="hilite-span",u={className:a,inclusiveLeft:!0};this.markHighlight=this.editor.markText({line:t,ch:0},{line:i,ch:0},u),this.editor.scrollIntoView({from:{line:t,ch:0},to:{line:i,ch:0}})}replaceSelection(t,i,a){this.editor.setSelection(this.editor.posFromIndex(t),this.editor.posFromIndex(i)),this.editor.replaceSelection(a)}getValue(){return this.editor.getValue()}getPath(){return this.path}addError(t){if(!t.path||this.path.endsWith(t.path)){var i=this.editor.lineCount(),a=t.line-1;if((isNaN(a)||a<0||a>=i)&&(a=0),this.addErrorMarker(a,t.msg),t.start!=null){var u={className:"mark-error",inclusiveLeft:!0},d={line:a,ch:t.end?t.start:t.start-1},m={line:a,ch:t.end?t.end:t.start},y=this.editor.markText(d,m,u);this.errormarks.push(y)}}}addErrorMarker(t,i){var a=document.createElement("div");a.setAttribute("class","tooltipbox tooltiperror"),a.appendChild(document.createTextNode("\u24CD")),this.editor.setGutterMarker(t,"gutter-info",a),this.errormsgs.push({line:t,msg:i}),$(a).mouseover(u=>{this.expandErrors()})}addErrorLine(t,i){var a=Bs(i,"tooltiperrorline");this.errorwidgets.push(this.editor.addLineWidget(t,a))}expandErrors(){for(var t;t=this.errormsgs.shift();)this.addErrorLine(t.line,t.msg)}markErrors(t){this.clearErrors(),t=t.slice(0,nl);for(var i of t)this.addError(i)}clearErrors(){for(this.dirtylisting=!0,this.editor.clearGutter("gutter-info"),this.errormsgs=[];this.errorwidgets.length;)this.errorwidgets.shift().clear();for(;this.errormarks.length;)this.errormarks.shift().clear()}getSourceFile(){return this.sourcefile}updateListing(){this.clearErrors(),this.editor.clearGutter("gutter-bytes"),this.editor.clearGutter("gutter-offset"),this.editor.clearGutter("gutter-clock");var t=this.sourcefile.lines||[];for(var i of t)if(i.offset>=0&&this.setGutter("gutter-offset",i.line-1,De(i.offset&65535,4)),i.insns){var a=i.insns.length>9?"...":i.insns;if(this.setGutter("gutter-bytes",i.line-1,a),i.iscode){if(i.cycles)this.setGutter("gutter-clock",i.line-1,i.cycles+"");else if(A.getOpcodeMetadata){var u=parseInt(i.insns.split(" ")[0],16),d=A.getOpcodeMetadata(u,i.offset);if(d&&d.minCycles){var m=d.minCycles+"";this.setGutter("gutter-clock",i.line-1,m)}}}}}setGutter(t,i,a){var u=this.editor.lineInfo(i);if(!(u&&u.gutterMarkers&&u.gutterMarkers[t])){var d=document.createTextNode(a);this.editor.setGutterMarker(i,t,d)}}setGutterBytes(t,i){this.setGutter("gutter-bytes",t-1,i)}setTimingResult(t){if(this.editor.clearGutter("gutter-bytes"),this.sourcefile!=null)for(let m of Object.keys(this.sourcefile.line2offset)){var i=this.sourcefile.line2offset[m],a=t.pc2minclocks[i],u=t.pc2maxclocks[i];if(a>=0&&u>=0){var d;u==a?d=a+"":d=a+"-"+u,u==t.MAX_CLOCKS&&(d+="+"),this.setGutterBytes(parseInt(m),d)}}}setCurrentLine(t,i){var a=A.isBlocked&&A.isBlocked(),u=y=>{var b=document.createElement("div"),D=a?"currentpc-marker-blocked":"currentpc-marker";b.classList.add(D),b.appendChild(document.createTextNode("\u25B6")),this.editor.setGutterMarker(y.line-1,"gutter-info",b)};if(this.clearCurrentLine(i),t){u(t),i&&this.editor.setCursor({line:t.line-1,ch:t.start||0},{scroll:!0});var d=a?"currentpc-span-blocked":"currentpc-span",m={className:d,inclusiveLeft:!0};t.start||t.end?this.markCurrentPC=this.editor.markText({line:t.line-1,ch:t.start},{line:t.line-1,ch:t.end||t.start+1},m):this.markCurrentPC=this.editor.markText({line:t.line-1,ch:0},{line:t.line,ch:0},m),this.currentDebugLine=t}}clearCurrentLine(t){this.currentDebugLine&&(this.editor.clearGutter("gutter-info"),t&&this.editor.setSelection(this.editor.getCursor()),this.currentDebugLine=null),this.markCurrentPC&&(this.markCurrentPC.clear(),this.markCurrentPC=null)}getActiveLine(){if(this.sourcefile){var t=er&&er.c;if(!t&&A.getCPUState&&!A.isRunning()&&(t=A.getCPUState()),t){var i=t&&(t.EPC||t.PC),a=this.sourcefile.findLineForOffset(i,cn);return a}}}refreshDebugState(t){this.clearCurrentLine(t);var i=this.getActiveLine();i&&this.setCurrentLine(i,t)}refreshListing(){var t=pe.getListingForFile(this.path);t&&t.sourcefile&&t.sourcefile!==this.sourcefile&&(this.sourcefile=t.sourcefile,this.dirtylisting=!0),!(!this.sourcefile||!this.dirtylisting)&&(this.updateListing(),this.dirtylisting=!1)}refresh(t){this.refreshListing(),this.refreshDebugState(t)}tick(){this.refreshDebugState(!1)}getLine(t){return this.editor.getLine(t-1)}getCurrentLine(){return this.editor.getCursor().line+1}getCursorPC(){for(var t=this.getCurrentLine();this.sourcefile&&t>=0;){var i=this.sourcefile.line2offset[t];if(i>=0)return i;t--}return-1}undoStep(){this.editor.execCommand("undo")}toggleBreakpoint(t){if(this.sourcefile!=null){var i=this.sourcefile.line2offset[t+1];hi(i)}}},Sa=1024,fn=class{getDisasmView(){return this.disasmview}createDiv(t){var i=document.createElement("div");return i.setAttribute("class","editor"),t.appendChild(i),this.newEditor(i),i}newEditor(t){this.disasmview=CodeMirror(t,{mode:"z80",theme:"cobalt",tabSize:8,readOnly:!0,styleActiveLine:!0})}refresh(t){let i=er||A.saveState(),a=i.c?i.c.PC:0,u=0,d=0,m=A.debugSymbols&&A.debugSymbols.addr2symbol||{},y=(W,fe)=>{let z="",U=0;for(;U<fe;){let q=W+U|0,de=A.disassemble(q,A.readAddress.bind(A)),K="",xe="";for(let Se=0;Se<de.nbytes;Se++)K+=De(A.readAddress(q+Se));for(;K.length<14;)K+=" ";let Ce=de.line;if(m&&de.isaddr&&(Ce=Ce.replace(/([^#])[$]([0-9A-F]+)/,(Se,...o)=>{let X=parseInt(o[1],16),ae=m[X];return ae?o[0]+ae:(ae=m[X-1],ae?o[0]+ae+"+1":Se)})),m){let Se=m[q];Se&&(xe="; "+Se)}z+=De(q,4)+" "+oi(K,14)+" "+oi(Ce,30)+xe+`
`,q==a&&(d=u),u++,U+=de.nbytes||1}return z};var b=a<0?a-Sa:Math.max(0,a-Sa);let D=y(b,a-b)+y(a,Sa);this.disasmview.setValue(D),t&&this.disasmview.setCursor(d,0),js(this.disasmview,d)}getCursorPC(){var t=this.disasmview.getCursor().line;if(t>=0){var i=this.disasmview.getLine(t).trim().split(/\s+/);if(i&&i.length>=1){var a=parseInt(i[0],16);if(a>=0)return a}}return-1}},_a=class extends fn{constructor(t){super();this.path=t}refreshListing(){var t=pe.getListingForFile(this.path);this.assemblyfile=t&&(t.assemblyfile||t.sourcefile)}refresh(t){if(this.refreshListing(),!!this.assemblyfile){var i=this.assemblyfile.text,a=this.getDisasmView();if(a.setValue(i),!!A.saveState){var u=er||A.saveState(),d=u.c?u.c.EPC||u.c.PC:0;if(d>=0&&this.assemblyfile){var m=this.assemblyfile.findLineForOffset(d,cn);m&&(t&&a.setCursor(m.line-1,0),js(a,m.line-1))}}}}};function Us(l){return l.endsWith("_SIZE__")||l.endsWith("_LAST__")||l.endsWith("STACKSIZE__")||l.endsWith("FILEOFFS__")||l.startsWith("l__")||l.startsWith("s__")||l.startsWith(".__.")}var dn=class{constructor(){this.recreateOnResize=!0;this.totalRows=5120}createDiv(t){var i=document.createElement("div");return i.setAttribute("class","memdump"),t.appendChild(i),this.showMemoryWindow(t,i),this.maindiv=i}showMemoryWindow(t,i){this.memorylist=new Cs({w:$(t).width(),h:$(t).height(),itemHeight:Ps(),totalRows:this.totalRows,generatorFn:a=>{var u=this.getMemoryLineAt(a),d=document.createElement("div");if(this.dumplines){var m=this.dumplines[a];m&&d.classList.add("seg_"+this.getMemorySegment(this.dumplines[a].a))}return d.appendChild(document.createTextNode(u)),d}}),$(i).append(this.memorylist.container),this.tick(),ut&&this.dumplines&&this.scrollToAddress(ut.data_start)}scrollToAddress(t){this.dumplines&&this.memorylist.scrollToItem(this.findMemoryWindowLine(t))}refresh(){this.dumplines=null,this.tick()}tick(){this.memorylist&&$(this.maindiv).find("[data-index]").each((t,i)=>{var a=$(i),u=parseInt(a.attr("data-index")),d=a.text(),m=this.getMemoryLineAt(u);d!=m&&a.text(m)})}getMemoryLineAt(t){var i=t*16,a=0,u=16,d;if(this.getDumpLines()){var m=this.dumplines[t];if(m)i=m.a&65520,a=m.a-i,u=a+m.l,d=m.s;else return"."}for(var y=De(i+a,4)+" ",b=0;b<a;b++)y+=" ";a>8&&(y+=" ");for(var b=a;b<u;b++){var D=this.readAddress(i+b);b==8&&(y+=" "),y+=" "+(typeof D=="number"?De(D,2):"??")}for(var b=u;b<16;b++)y+=" ";return d&&(y+=" "+d),y}readAddress(t){return A.readAddress(t)}getDumpLineAt(t){var i=this.dumplines[t];if(i)return i.a+" "+i.s}getDumpLines(){var t=A.debugSymbols&&A.debugSymbols.addr2symbol||{};if(this.dumplines==null){this.dumplines=[];var i=0,a;for(let y of Object.keys(t)){var u=parseInt(y),d=t[u];if(a)for(Us(a)&&(a="");i<u&&this.dumplines.length<65536;){var m=i+16&1048560;m>u&&(m=u),this.dumplines.push({a:i,l:m-i,s:a}),i=m}a=d}}return this.dumplines}getMemorySegment(t){if(ut){if(t>=ut.data_start&&t<ut.data_start+ut.data_size)return A.getSP&&t>=A.getSP()-15?"stack":"data";if(t>=ut.code_start&&t<ut.code_start+(ut.code_size||ut.rom_size))return"code"}var i=pe.segments;if(i){for(var a of i)if(t>=a.start&&t<a.start+a.size){if(a.type=="rom")return"code";if(a.type=="ram")return"data";if(a.type=="io")return"io"}}return"unknown"}findMemoryWindowLine(t){for(var i=0;i<this.dumplines.length;i++)if(this.dumplines[i].a>=t)return i}},Ta=class extends dn{constructor(){super(...arguments);this.totalRows=2048}readAddress(t){return A.readVRAMAddress(t)}getMemorySegment(t){return"video"}getDumpLines(){return null}},Ca=class{constructor(t,i){this.recreateOnResize=!0;this.path=t,this.data=i}createDiv(t){return this.vlist=new li(t),this.vlist.create(t,this.data.length+15>>4,this.getMemoryLineAt.bind(this)),this.vlist.maindiv}getMemoryLineAt(t){for(var i=t*16,a=0,u=16,d=De(i+a,4)+" ",m=0;m<a;m++)d+=" ";a>8&&(d+=" ");for(var m=a;m<u;m++){var y=this.data[i+m];m==8&&(d+=" "),d+=" "+(y>=0?De(y,2):" ")}return{text:d}}refresh(){this.vlist.refresh()}getPath(){return this.path}},ka=class{createDiv(t){return this.maindiv=Ut(t,"vertical-scroll"),this.maindiv.css("display","grid"),this.maindiv.css("grid-template-columns","5em 40% 40%"),this.maindiv[0]}addSegment(t,i){if(i){var a=$('<div class="segment-offset" style="grid-column-start:1"/>');a.text("$"+De(t.start,4)),this.maindiv.append(a)}var u=$('<div class="segment"/>');if(i||u.css("grid-column-start",3),t.last?u.text(t.name+" ("+(t.last-t.start)+" / "+t.size+" bytes used)"):u.text(t.name+" ("+t.size+" bytes)"),t.size>=256){var d=(Math.log(t.size)-Math.log(256))*.5;u.css("padding-top",d+"em"),u.css("padding-bottom",d+"em")}t.type&&u.addClass("segment-"+t.type),this.maindiv.append(u),u.click(()=>{var m=ge.createOrShow("#memory");m.scrollToAddress(t.start)})}refresh(){this.maindiv.empty();var t=pe.segments;if(t){var i=0,a=-1;for(var u of t)u.start>i&&this.addSegment({name:"",start:i,size:u.start-i},!0),this.addSegment(u,a!=u.start),a=u.start,i=u.start+u.size}}},Ct=4278190080,mr=class{constructor(){this.cumulativeData=!1;var t=160,i=262;try{t=Math.ceil(A.machine.cpuCyclesPerLine)||t,i=Math.ceil(A.machine.numTotalScanlines)||i}catch(a){}this.cyclesPerLine=t,this.totalScanlines=i}addr2symbol(t){var i=A.debugSymbols&&A.debugSymbols.addr2symbol||{};return i[t]}addr2str(t){var i=this.addr2symbol(t);return typeof i=="string"?"$"+De(t)+" ("+i+")":"$"+De(t)}showTooltip(t){t?(this.tooldiv||(this.tooldiv=document.createElement("div"),this.tooldiv.setAttribute("class","tooltiptrack"),document.body.appendChild(this.tooldiv)),$(this.tooldiv).text(t).show()):$(this.tooldiv).hide()}setVisible(t){t?(this.probe=A.startProbing(),this.probe.singleFrame=!this.cumulativeData,this.tick()):(this.probe&&(this.probe.singleFrame=!0),A.stopProbing(),this.probe=null)}redraw(t){var i=this.probe;if(!(!i||!i.idx)){var a=0,u=0,d=0;this.sp=0;for(var m=0;m<i.idx;m++){var y=i.buf[m],b=y&65535,D=y>>16&255,W=y&Ct;switch(W){case te.SCANLINE:a++,u=0;break;case te.FRAME:a=0,u=0;break;case te.CLOCKS:u+=b,d+=b;break;case te.SP_PUSH:case te.SP_POP:this.sp=b;default:t(W,b,u,a,d,D);break}}}}opToString(t,i,a){var u="";switch(t){case te.EXECUTE:u="Exec";break;case te.MEM_READ:u="Read";break;case te.MEM_WRITE:u="Write";break;case te.IO_READ:u="IO Read";break;case te.IO_WRITE:u="IO Write";break;case te.VRAM_READ:u="VRAM Read";break;case te.VRAM_WRITE:u="VRAM Write";break;case te.DMA_READ:u="DMA Read";break;case te.DMA_WRITE:u="DMA Write";break;case te.INTERRUPT:u="Interrupt";break;case te.ILLEGAL:u="Error";break;case te.WAIT:u="Wait";break;case te.SP_PUSH:u="Stack Push";break;case te.SP_POP:u="Stack Pop";break;default:return""}return typeof i=="number"&&(u+=" "+this.addr2str(i)),t&te.HAS_VALUE&&typeof a=="number"&&(u+=" = $"+De(a,2)),u}getOpRGB(t,i){switch(t){case te.EXECUTE:return 98305;case te.MEM_READ:return 8388865;case te.MEM_WRITE:return 65920;case te.IO_READ:return 98432;case te.IO_WRITE:return 12583296;case te.DMA_READ:case te.VRAM_READ:return 8421377;case te.DMA_WRITE:case te.VRAM_WRITE:return 4227264;case te.INTERRUPT:return 4177727;case te.ILLEGAL:return 4145151;case te.WAIT:return 16727871;default:return 0}}},zs=class extends mr{constructor(){super(...arguments);this.recreateOnResize=!0}createCanvas(t,i,a){var u=document.createElement("div"),d=document.createElement("canvas");return d.width=i,d.height=a,d.classList.add("pixelated"),d.style.width="100%",d.style.height="90vh",d.style.backgroundColor="black",d.style.cursor="crosshair",d.onmousemove=m=>{var y=an(d,m);this.showTooltip(this.getTooltipText(y.x,y.y)),$(this.tooldiv).css("left",m.pageX+10).css("top",m.pageY-30)},d.onmouseout=m=>{$(this.tooldiv).hide()},t.appendChild(u),u.appendChild(d),this.canvas=d,this.ctx=d.getContext("2d"),this.initCanvas(),this.maindiv=u}initCanvas(){}getTooltipText(t,i){return null}getOpAtPos(t,i,a){t=t|0,i=i|0;let u=0;return this.redraw((d,m,y,b,D,W)=>{!u&&b==i&&y>=t&&(d&a)!=0&&(u=d|m)}),u}clear(){}tick(){this.clear(),this.redraw(this.drawEvent.bind(this))}},Pa=class extends zs{constructor(){super(...arguments);this.recreateOnResize=!1}createDiv(t){return this.createCanvas(t,this.cyclesPerLine,this.totalScanlines)}initCanvas(){this.imageData=this.ctx.createImageData(this.canvas.width,this.canvas.height),this.datau32=new Uint32Array(this.imageData.data.buffer)}getTooltipText(t,i){t=t|0,i=i|0;var a="",u=null,d=[],m=-1;return this.redraw((y,b,D,W,fe,z)=>{switch(y){case te.EXECUTE:u=this.addr2symbol(b)||u;break;case te.SP_PUSH:d.push(u);break;case te.SP_POP:u=d.pop();break}W==i&&D<=t&&(D!=m&&(a="",m=D),a==""&&u&&(a+=`
`+u),a+=`
`+this.opToString(y,b,z))}),"X: "+t+" Y: "+i+" "+a}refresh(){this.tick(),this.datau32.fill(Ct)}tick(){super.tick(),this.drawImage()}drawImage(){this.ctx.putImageData(this.imageData,0,0)}clear(){this.datau32.fill(Ct)}},Aa=class extends Pa{createDiv(t){return this.createCanvas(t,256,256)}initCanvas(){super.initCanvas(),this.canvas.onclick=t=>{var i=an(this.canvas,t),a=Math.floor(i.x)+Math.floor(i.y)*256,u=-1,d=-1;this.redraw((m,y)=>{d<0&&u>=0&&y==a&&(d=u),m==te.EXECUTE&&(u=y)}),d>=0&&hi(d)}}clear(){for(var t=0;t<=65535;t++){var i=A.readAddress(t),a=i>>2|i&31;a|=a<<8|a<<16,this.datau32[t]=a|Ct}}drawEvent(t,i,a,u){var d=this.getOpRGB(t,i);if(!!d){var m=i&255,y=i>>8&255,b=this.datau32[i&65535];b=b|d|Ct,this.datau32[i&65535]=b}}getTooltipText(t,i){var a=(t&255)+(i<<8),u="",d=-1,m={},y=null,b=[];return this.redraw((D,W,fe,z,U,q)=>{switch(D){case te.EXECUTE:d=W,y=this.addr2symbol(W)||y;break;case te.SP_PUSH:b.push(y);break;case te.SP_POP:y=b.pop();break}var de=D|d;W==a&&!m[de]&&(u==""&&y&&(u+=`
`+y),u+=`
PC `+this.addr2str(d)+" "+this.opToString(D,null,q),m[de]=1)}),this.addr2str(a)+u}},qs=class extends Pa{initCanvas(){super.initCanvas(),this.canvas.onclick=t=>{var i=an(this.canvas,t),a=Math.floor(i.x),u=Math.floor(i.y),d=this.getOpAtPos(i.x,i.y,te.EXECUTE);d&&(Lt("toline"),A.runEval(()=>{let m=A.getRasterScanline&&A.getRasterScanline()>=u;return m&&A.getRasterLineClock?m&&A.getRasterLineClock()>a:m}))}}drawEvent(t,i,a,u){var d=this.getOpRGB(t,i);if(!!d){var m=a+u*this.canvas.width,y=d|Ct;this.datau32[m]|=y}}drawImage(){let t=Ct;for(let i=0;i<this.datau32.length;i++)this.datau32[i]==Ct?this.datau32[i]=t:t=this.datau32[i];super.drawImage()}},Fa=class extends qs{constructor(){super(...arguments);this.interrupt=0;this.rgb=0;this.lastpc=0}drawEvent(t,i,a,u){var d=a+u*this.canvas.width;if(t==te.INTERRUPT&&(this.interrupt=1),this.interrupt==1&&t==te.SP_PUSH&&(this.interrupt=i),this.interrupt>1&&this.sp>this.interrupt&&(this.interrupt=0),t==te.MEM_WRITE&&(this.rgb|=47),t==te.VRAM_WRITE&&(this.rgb|=16256),t==te.IO_WRITE&&(this.rgb|=2047872),t==te.IO_READ&&(this.rgb|=7936),t==te.WAIT&&(this.rgb=32768),t==te.ILLEGAL||t==te.DMA_READ)this.datau32[d]=4279176975;else{let m=this.rgb;if(t==te.EXECUTE){let y=this.sp&15;y>=8&&(y=16-y),Math.abs(this.lastpc)-i>16&&(y+=1),Math.abs(this.lastpc)-i>256&&(y+=1),m=this.rgb=526344*y+2105376,this.lastpc=i}this.interrupt&&(m|=8388672),this.datau32[d]==Ct&&(this.datau32[d]=m|Ct)}}},Da=class extends mr{constructor(){super(...arguments);this.recreateOnResize=!0}createDiv(t){return this.vlist=new li(t),this.vlist.create(t,this.cyclesPerLine*this.totalScanlines,this.getMemoryLineAt.bind(this)),this.vlist.maindiv}getMemoryLineAt(t){var i="",a="seg_data",u=this.dumplines&&this.dumplines[t];if(u!=null){var d=u.info.join(", ");i="("+Ft(u.row,4)+", "+Ft(u.col,4)+") "+oi(u.asm||"",20)+d,d.indexOf("Write ")>=0&&(a="seg_io")}return{text:i,clas:a}}refresh(){this.tick()}tick(){let t=A instanceof fa||A instanceof ca;this.dumplines={},this.redraw((i,a,u,d,m,y)=>{t&&(m>>=2);var b=this.dumplines[m];switch(b==null&&(b={op:i,addr:a,row:d,col:u,asm:null,info:[]},this.dumplines[m]=b),i){case te.EXECUTE:if(A.disassemble){var D=A.disassemble(a,A.readAddress.bind(A));b.asm=D&&D.line}break;default:var W=this.opToString(i,a,y);W!=""&&b.info.push(W);break}}),this.vlist.refresh()}},La=class extends mr{constructor(){super(...arguments);this.recreateOnResize=!0}createDiv(t){return this.vlist=new li(t),this.vlist.create(t,this.totalScanlines,this.getMemoryLineAt.bind(this)),this.vlist.maindiv}getMemoryLineAt(t){for(var i=Ft(t+"",3)+" ",a="seg_code",u=this.dumplines&&this.dumplines[t]||[],d=Math.round(this.cyclesPerLine/3.3),m=0;m<this.cyclesPerLine;m++){var y=u[m];if(y!==void 0){var b=y&65535,D=D&Ct;if(D==te.EXECUTE)i+=",";else{var W=De(b);i+=W,m+=W.length-1}}else i+=m==d?"|":"."}return u[-1]&&(i+=" "+u[-1]),{text:i,clas:a}}refresh(){this.tick()}tick(){let t=A instanceof fa||A instanceof ca;this.dumplines={},this.redraw((i,a,u,d,m,y)=>{var b=this.dumplines[d];switch(b==null&&(this.dumplines[d]=b=[]),i){case te.EXECUTE:var D=A.debugSymbols.addr2symbol[a];D&&(b[-1]=D);break;case te.IO_READ:case te.IO_WRITE:case te.VRAM_READ:case te.VRAM_WRITE:b[u]=i|a;break}}),this.vlist.refresh()}},Ra=class extends mr{constructor(){super(...arguments);this.recreateOnResize=!0;this.cumulativeData=!0}createDiv(t){return A.debugSymbols&&A.debugSymbols.symbolmap?this.keys=Array.from(Object.keys(A.debugSymbols.symbolmap).filter(i=>!Us(i))):this.keys=["no symbols defined"],this.vlist=new li(t),this.vlist.create(t,this.keys.length+1,this.getMemoryLineAt.bind(this)),this.vlist.maindiv}getMemoryLineAt(t){if(t==0)return{text:Ft("Symbol",35)+Ft("Reads",8)+Ft("Writes",8)};var i=this.keys[t-1],a=this.dumplines&&this.dumplines[i];function u(y){var b=a[y]|0;return Ft(b?b.toString():"",8)}var d,m;return a!=null?(d=Ft(i,35)+u(te.MEM_READ)+u(te.MEM_WRITE),a[te.EXECUTE]?m="seg_code":a[te.IO_READ]||a[te.IO_WRITE]?m="seg_io":m="seg_data"):(d=Ft(i,35),m="seg_unknown"),{text:d,clas:m}}refresh(){this.tick()}tick(){this.dumplines={},this.redraw((t,i,a,u,d,m)=>{var y=A.debugSymbols.addr2symbol[i];if(y!=null){var b=this.dumplines[y];b==null&&(b={},this.dumplines[y]=b),b[t]=(b[t]|0)+1}}),this.vlist.refresh(),this.probe&&this.probe.clear()}};var jc=Ds(),hn=/([0#]?)([x$%]|\d'h)([0-9a-f]+)(?:[;].*)?|(\d'b|0b)([01]+)/gim;function al(l){return l.replace(/(\shex\s+)([0-9a-f]+)/ig,function(t,i,a){for(var u=i,d=0;d<a.length;d+=2)u+="0x"+a.substr(d,2)+",";return u})}function sl(l){for(var t=[],i;i=hn.exec(l);){var a;typeof i[4]!="undefined"?a=parseInt(i[5],2):i[2].startsWith("%")||i[2].endsWith("b")?a=parseInt(i[3],2):i[2].startsWith("x")||i[2].startsWith("$")||i[2].endsWith("h")?a=parseInt(i[3],16):a=parseInt(i[3]),t.push(a)}return t}function ol(l,t){for(var i="",a,u=0,d=0;a=hn.exec(l);)i+=l.slice(u,hn.lastIndex-a[0].length),u=hn.lastIndex,typeof a[4]!="undefined"?i+=a[4]+t[d++].toString(2):a[2].startsWith("%")?i+=a[1]+"%"+t[d++].toString(2):a[2].endsWith("b")?i+=a[1]+a[2]+t[d++].toString(2):a[2].endsWith("h")?i+=a[1]+a[2]+t[d++].toString(16):a[2].startsWith("x")?i+=a[1]+"x"+De(t[d++]):a[2].startsWith("$")?i+=a[1]+"$"+De(t[d++]):i+=a[1]+t[d++].toString();return i+=l.slice(u),i=i.replace(/(\shex\s+)([,x0-9a-f]+)/ig,(m,y,b)=>{var D=y+b;return D=D.replace(/0x/ig,"").replace(/,/ig,""),D}),i}function Vs(l,t){if(!t)return l;for(var i=0,a=0;a<t.length;a++){var u=t[a];u<0&&(u=-u-1,i^=1<<u),l&1<<a&&(i^=1<<u)}return i}function Gs(l,t){var i=t[l%t.length];return[i>>3,i&7]}function ll(l,t){for(var i=t.w,a=t.h,u=t.count||1,d=t.bpp||1,m=t.np||1,y=t.bpw||8,b=t.sl||Math.ceil(i*d/y),D=(1<<d)-1,W=t.pofs||b*a*u,fe=t.skip||0,z=t.wpimg||b*a,U=[],q=0;q<u;q++){for(var de=[],K=0;K<a;K++)for(var xe=t.flip?a-1-K:K,Ce=z*q+xe*b,be=0,Se=0;Se<i;Se++){var o=0,X=Vs(Ce,t.remap);t.reindex&&([X,be]=Gs(Se,t.reindex),X+=Ce);for(var ae=0;ae<m;ae++){var oe=l[X+ae*W+fe];o|=((t.brev?oe>>y-be-d:oe>>be)&D)<<ae*d}de.push(o),be+=d,be>=y&&!t.reindex&&(Ce+=1,be=0)}U.push(new Uint8Array(de))}return U}function ul(l,t){t.destfmt&&(t=t.destfmt);var i=t.w,a=t.h,u=t.count||1,d=t.bpp||1,m=t.np||1,y=t.bpw||8,b=t.sl||Math.ceil(t.w*d/y),D=(1<<d)-1,W=t.pofs||b*a*u,fe=t.skip||0,z=t.wpimg||b*a,U;m>0&&t.sl?U=new Uint8Array(z*u):y<=8?U=new Uint8Array(z*u*m):U=new Uint32Array(z*u*m);for(var q=0;q<u;q++)for(var de=l[q],K=0,xe=0;xe<a;xe++)for(var Ce=t.flip?a-1-xe:xe,be=q*z+Ce*b,Se=0,o=0;o<i;o++){var X=de[K++],ae=Vs(be,t.remap);t.reindex&&([ae,Se]=Gs(o,t.reindex),ae+=be);for(var oe=0;oe<m;oe++){var _e=X>>oe*d&D;U[ae+oe*W+fe]|=t.brev?_e<<y-Se-d:_e<<Se}Se+=d,Se>=y&&!t.reindex&&(be+=1,Se=0)}return U}function Ys(l,t,i,a,u,d,m){for(var y=[],b=0;b<l.length;b++){var D=l[b],W=4278190080;W|=(D>>t&(1<<i)-1)<<0+8-i,W|=(D>>a&(1<<u)-1)<<8+8-u,W|=(D>>d&(1<<m)-1)<<16+8-m,y.push(W)}return y}function cl(l){var t=l.pal;if(typeof t=="number"){var i=Math.floor(Math.abs(t/100)%10),a=Math.floor(Math.abs(t/10)%10),u=Math.floor(Math.abs(t)%10);return 1<<i+a+u}else{var d=Qs[t];if(d)return d.length;throw new Error("No palette named "+t)}}function Xs(l,t){var i=t.pal,a;if(typeof i=="number"){var u=Math.floor(Math.abs(i/100)%10),d=Math.floor(Math.abs(i/10)%10),m=Math.floor(Math.abs(i)%10);i>=0?a=Ys(l,0,u,u,d,u+d,m):a=Ys(l,u+d,m,u,d,0,u)}else{var y=Qs[i];if(y)a=new Uint32Array(l).map(b=>y[b&y.length-1]|4278190080);else throw new Error("No palette named "+i)}return a}var Qs={nes:[5395026,11796480,10485760,11599933,7602281,91,95,6208,12048,543240,26368,1196544,7153664,0,0,0,12899815,16728064,14421538,16729963,14090399,6818519,6588,21681,27227,35843,43776,2918400,10777088,0,0,0,16316664,16755516,16742785,16735173,16730354,14633471,4681215,46327,57599,58229,259115,7911470,15065624,7895160,0,0,16777215,16773822,16300216,16300248,16758527,16761855,13095423,10148607,8973816,8650717,12122296,16119980,16777136,16308472,0,0],ap2lores:[0,16711935,127,8323199,32512,8355711,191,255,12549888,16760576,12566463,16744319,65280,16776960,49023,16777215],vcs:[0,0,4210752,4210752,7105644,7105644,9474192,9474192,11579568,11579568,13158600,13158600,14474460,14474460,16053492,16053492,17476,17476,1074276,1074276,2393220,2393220,3448992,3448992,4241592,4241592,5296336,5296336,6088936,6088936,6880508,6880508,10352,10352,1328260,1328260,2645144,2645144,3963052,3963052,5016764,5016764,6070476,6070476,6862044,6862044,7915756,7915756,6276,6276,1586328,1586328,3166380,3166380,4745408,4745408,6062288,6062288,7378144,7378144,8431852,8431852,9747708,9747708,136,136,2105500,2105500,3947696,3947696,5789888,5789888,7368912,7368912,8947936,8947936,10526956,10526956,11842812,11842812,6029432,6029432,7610508,7610508,8928416,8928416,10246320,10246320,11563200,11563200,12616912,12616912,13671644,13671644,14725356,14725356,7864392,7864392,9445472,9445472,10763384,10763384,12081292,12081292,13398176,13398176,14451892,14451892,15506628,15506628,16560340,16560340,8650772,8650772,9969712,9969712,11287628,11287628,12605544,12605544,13660284,13660284,14715028,14715028,15507624,15507624,16561340,16561340,8912896,8912896,10231836,10231836,11550776,11550776,12606544,12606544,13661288,13661288,14716028,14716028,15508624,15508624,16562340,16562340,8132608,8132608,9451548,9451548,11031608,11031608,12349520,12349520,13404264,13404264,14457980,14457980,15512720,15512720,16566436,16566436,6040576,6040576,7883804,7883804,9463864,9463864,11306064,11306064,12622952,12622952,13939836,13939836,15256720,15256720,16572580,16572580,2898944,2898944,4742172,4742172,6585400,6585400,8428624,8428624,9745512,9745512,11325564,11325564,12641424,12641424,13958308,13958308,15360,15360,2120736,2120736,4226112,4226112,6069340,6069340,7648372,7648372,9228428,9228428,10806436,10806436,12123320,12123320,14356,14356,1858612,1858612,3701840,3701840,5281900,5281900,6861956,6861956,8178844,8178844,9495732,9495732,10812616,10812616,12332,12332,1855564,1855564,3436648,3436648,5016708,5016708,6596764,6596764,7913652,7913652,8967372,8967372,10284256,10284256,10308,10308,1591396,1591396,3172484,3172484,4490400,4490400,5807288,5807288,7124176,7124176,8178920,8178920,9232636,9232636],astrocade:[0,2368548,4737096,7171437,9539985,11974326,14342874,16777215,12255269,14680137,16716142,16725394,16734903,16744155,16753663,16762879,11534409,13959277,16318866,16721334,16730842,16740095,16749311,16758783,10420330,12779662,15138995,16718039,16727291,16736767,16745983,16755199,8847495,11206827,13631696,15994612,16724735,16733951,16743423,16752639,6946975,9306307,11731175,14092287,16461055,16732415,16741631,16751103,4784304,7143637,9568505,11929087,14297599,16731647,16741119,16750335,2425019,4784352,7209215,9570047,12004095,14372863,16741375,16750847,191,2359523,4718847,7146495,9515263,11949311,14318079,16752127,187,224,2294015,4658431,7092735,9461247,11895551,14264063,176,213,249,2367999,4736511,7105279,9539327,11908095,159,195,3303,209151,2577919,4946431,7380735,9749247,135,171,7888,17140,681983,3050495,5484543,7853311,106,3470,12723,22231,31483,1548031,3916799,6285311,73,8557,17810,27318,36570,373759,2742271,5176575,4389,13641,23150,32402,41911,51163,2026495,4456447,9472,18724,27976,37485,46737,56246,1834970,4194303,14080,23296,32803,42055,51564,60816,2031541,4456409,18176,27648,36864,46116,55624,392556,2752401,5177269,21760,30976,40192,49667,58919,1572683,3932016,6291348,24320,33536,43008,52224,716810,3079982,5504851,7864183,25856,35328,44544,250368,2619136,4980503,7405371,9764703,26624,35840,45312,2413824,4782336,7143173,9568041,11927374,26112,35584,2338560,4707328,7141376,9502464,11927326,14286659,24832,2393344,4762112,7196160,9564928,11992832,14352155,16711487,2447360,4815872,7250176,9618688,12052992,14417664,16776990,16777027,4803328,7172096,9606144,11974912,14343424,16776965,16777001,16777038,6962176,9330688,11764992,14133504,16502272,16773655,16777019,16777055,8858112,11226880,13660928,16029440,16759818,16769070,16777043,16777079,10426112,12794624,15163392,16745475,16754727,16764235,16773488,16777108,11534848,13969152,16337664,16740388,16749640,16759148,16768401,16777141,12255232,14684928,16725795,16735047,16744556,16753808,16763317,16772569],c64:[0,16777215,2832232,11707504,8797551,4427096,7940149,7325624,2445167,14659,5859226,4473924,7105644,8704666,11886188,9803157]},fl={nes:[["Screen Color",0,1],["Background 0",1,3],["Background 1",5,3],["Background 2",9,3],["Background 3",13,3],["Sprite 0",17,3],["Sprite 1",21,3],["Sprite 2",25,3],["Sprite 3",29,3]],astrocade:[["Left",0,-4],["Right",4,-4]]};function pi(l,t){if(l==null||t==null||l.length!==t.length)return!1;if(l===t)return!0;for(var i=0;i<l.length;i++)if(l[i]!==t[i])return!1;return!0}function pn(l,t){if(l==null||t==null||l.length!==t.length)return!1;if(l===t)return!0;for(var i=0;i<l.length;i++)if(!pi(l[i],t[i]))return!1;return!0}var zt=class{refreshLeft(){for(var t=this;t;)t.updateLeft(),t=t.left}refreshRight(){for(var t=this;t;)t.updateRight(),t=t.right}addRight(t){return this.right=t,t.left=this,t}addLeft(t){return this.left=t,t.right=this,t}},Ia=class extends zt{},gn=class extends Ia{constructor(t,i){super();this.project=t,this.fileid=i,this.label=i}updateLeft(){return this.words=this.right.words,this.project&&this.project.updateFile(this.fileid,this.words),!0}updateRight(){return this.project&&(this.words=this.project.project.getFile(this.fileid)),!0}},Ma=class extends Ia{constructor(t,i,a,u,d){super();this.project=t,this.fileid=i,this.label=a,this.start=u,this.end=d}updateLeft(){if(this.right.words.length!=this.words.length)throw Error("Cannot put "+this.right.words.length+" image bytes into array of "+this.words.length+" bytes");this.words=this.right.words;var t=this.text.substring(this.start,this.end);return t=ol(t,this.words),this.text=this.text.substring(0,this.start)+t+this.text.substring(this.end),this.project&&this.project.updateFile(this.fileid,this.text),!0}updateRight(){this.project&&(this.text=this.project.project.getFile(this.fileid));var t=this.text.substring(this.start,this.end);t=al(t);var i=sl(t);return this.words=i,!0}},Na=class extends zt{updateLeft(){return!1}updateRight(){return this.words=Ts(new Uint8Array(this.left.words)),!0}},Oa=class extends zt{constructor(t){super();this.fmt=t}updateLeft(){return this.images=this.right.images,this.words=ul(this.images,this.fmt),!0}updateRight(){return pi(this.words,this.left.words)?!1:(this.words=this.left.words,this.images=ll(this.words,this.fmt),!0)}},Js=class{constructor(t){this.palcols=t}indexOf(t){return this.palcols.indexOf(t)}},Dr=class extends zt{constructor(t,i){super();this.palindex=0;this.context=t,this.ncolors=1<<(i.bpp||1)*(i.np||1)}updateLeft(){this.right&&(this.rgbimgs=this.right.rgbimgs);var t=new Js(this.palette),i=this.rgbimgs.map(a=>{for(var u=new Uint8Array(a.length),d=0;d<a.length;d++)u[d]=t.indexOf(a[d]);return u});return this.images=i,!0}updateRight(){if(!this.updateRefs()&&pn(this.images,this.left.images))return!1;this.images=this.left.images;var t=this.palette.length-1;return this.rgbimgs=this.images.map(i=>{for(var a=new Uint32Array(i.length),u=0;u<i.length;u++)a[u]=this.palette[i[u]&t];return a}),!0}updateRefs(){var t;return this.context!=null&&(this.paloptions=this.context.getPalettes(this.ncolors),this.paloptions&&this.paloptions.length>0&&(t=this.paloptions[this.palindex].palette)),t==null&&(this.ncolors<=2?t=new Uint32Array([4278190080,4294967295]):t=new Uint32Array([4278190080,4294902015,4294967040,4294967295])),pi(this.palette,t)?!1:(this.palette=t,!0)}};function dl(l){for(var t=new Map,i=new Uint32Array(l.length),a=0,u=0;u<l.length;u++){for(var d=l[u];t[d];)d^=++a;i[u]=d,t[d]=1}return i}var mn=class extends zt{constructor(t){super();this.palfmt=t}updateLeft(){return!0}updateRight(){return pi(this.words,this.left.words)?!1:(this.words=this.left.words,this.palette=dl(Xs(this.words,this.palfmt)),this.layout=fl[this.palfmt.layout],this.rgbimgs=[],this.palette.forEach(t=>{this.rgbimgs.push(new Uint32Array([t]))}),!0)}getAllColors(){for(var t=[],i=0;i<cl(this.palfmt);i++)t.push(i);return Xs(t,this.palfmt)}},Ks=class extends zt{constructor(t){super();this.tileindex=0;this.context=t}updateRefs(){var t=this.tilemap;return this.context!=null&&(this.tileoptions=this.context.getTilemaps(256),this.tileoptions&&this.tileoptions.length>0&&(this.tilemap=this.tileoptions[this.tileindex].images)),!pn(t,this.tilemap)}};var $a=class extends Ks{constructor(t){super(t)}updateLeft(){return!1}updateRight(){if(!this.updateRefs()&&pi(this.words,this.left.words))return!1;this.words=this.left.words,this.cols=32,this.rows=30,this.width=this.cols*8,this.height=this.rows*8,this.baseofs=0;var t=new Uint8Array(this.width*this.height);this.images=[t];for(var i=0,a,u=0;u<this.rows;u++)for(var d=0;d<this.cols;d++){var m=this.words[this.baseofs+i];if(typeof m=="undefined")throw Error("No name for address "+this.baseofs+" + "+i);var y=this.tilemap[m];if(!y)throw Error("No tilemap found for tile index "+m);a=i&11264|960|i&3072|i>>4&56|i>>2&7;for(var b=this.words[a],D=m^b<<9^2147483648,W=u*this.cols*8*8+d*8,fe=0,z=(d&2)+((i&64)>>4),U=(b>>z&3)<<2,q=0;q<8;q++){for(var de=0;de<8;de++){var K=y[fe++];K&&(K+=U),t[W++]=K}W+=this.cols*8-8}i++}return!0}},vn=class{recreate(t,i){var a=$('<div class="asset_grid"/>');t.empty().append(a);var u=Math.max(2,Math.ceil(16/this.width)),d=this.width<=8?16:8,m=null;this.rgbimgs.forEach((y,b)=>{var D=new bn;D.width=this.width,D.height=this.height,D.recreate(),D.canvas.style.width=D.width*u+"px",D.canvas.title="$"+De(b),D.updateImage(y),$(D.canvas).addClass("asset_cell"),$(D.canvas).click(fe=>{i(b,D)}),m||(m=$("<span/>"),a.append(m)),m.append(D.canvas);var W=b%d==d-1;W&&(a.append($("<br/>")),m=null)})}};function vr(l,t){var i=$(document.createElement("div"));return l&&i.appendTo(l),t&&i.addClass(t),i}var Wa=class extends zt{constructor(t,i,a){super();this.context=t,this.parentdiv=i,this.fmt=a}updateLeft(){return!0}updateRight(){if(pn(this.rgbimgs,this.left.rgbimgs))return!1;this.rgbimgs=this.left.rgbimgs;var t=vr(this.parentdiv.empty(),"asset_dual"),i=vr(t),a=vr(t,"asset_editor").hide(),u=this.chooser=new vn;u.rgbimgs=this.rgbimgs,u.width=this.fmt.w||1,u.height=this.fmt.h||1,u.recreate(i,(y,b)=>{var D=Math.ceil(256/this.fmt.w),W=D*(this.fmt.aspect||1),fe=this.createEditor(a,b,W,D);this.context.setCurrentEditor(a,$(b.canvas),this),this.rgbimgs[y]=b.rgbdata});var d=this.left;if(d instanceof Dr&&d.paloptions.length>1){var m=$(document.createElement("select"));d.paloptions.forEach((y,b)=>{var D=$(document.createElement("option")).text(y.name).val(b).appendTo(m);b==d.palindex&&D.attr("selected","selected")}),m.appendTo(i).change(y=>{var b=$(y.target).val();d.palindex=b,d.refreshRight()})}return!0}createEditor(t,i,a,u){var d=new Zs;d.createWith(i),d.updateImage();for(var m=i.width*a,y=i.height*u;m>500||y>500;)m/=2,y/=2;return d.canvas.style.width=m+"px",d.canvas.style.height=y+"px",d.makeEditable(this,t,this.left.palette),d}},ja=class extends zt{constructor(t,i,a){super();this.context=t,this.parentdiv=i,this.fmt=a}updateLeft(){return!0}updateRight(){if(pn(this.rgbimgs,this.left.rgbimgs))return!1;this.rgbimgs=this.left.rgbimgs;var t=vr(this.parentdiv.empty(),"asset_dual"),i=vr(t),a=vr(t,"asset_editor").hide(),u=new bn;return u.width=this.fmt.w,u.height=this.fmt.h,u.recreate(),u.updateImage(this.rgbimgs[0]),i.append(u.canvas),!0}},bn=class{recreate(){this.canvas=this.newCanvas(),this.imagedata=this.ctx.createImageData(this.width,this.height),this.rgbdata=new Uint32Array(this.imagedata.data.buffer),this.peerviewers=[this]}createWith(t){this.width=t.width,this.height=t.height,this.imagedata=t.imagedata,this.rgbdata=t.rgbdata,this.canvas=this.newCanvas(),this.peerviewers=[this,t]}newCanvas(){var t=document.createElement("canvas");return t.width=this.width,t.height=this.height,t.classList.add("pixels"),t.classList.add("pixelated"),this.ctx=t.getContext("2d"),t}updateImage(t){t&&this.rgbdata.set(t);for(let i of this.peerviewers)i.ctx.putImageData(this.imagedata,0,0)}},Zs=class extends bn{constructor(){super(...arguments);this.curpalcol=-1;this.offscreen=new Map}getPositionFromEvent(t){var i=Math.floor(t.offsetX*this.width/$(this.canvas).width()),a=Math.floor(t.offsetY*this.height/$(this.canvas).height());return{x:i,y:a}}setPaletteColor(t){t&=this.palette.length-1,this.curpalcol!=t&&(this.curpalcol>=0&&this.palbtns[this.curpalcol].removeClass("selected"),this.curpalcol=t,this.currgba=this.palette[t&this.palette.length-1],this.palbtns[t].addClass("selected"))}makeEditable(t,i,a){this.left=t,this.palette=a;var u,d=!1,m=$(this.canvas);m.mousedown(y=>{var b=this.getPositionFromEvent(y);u=this.getPixel(b.x,b.y)==this.currgba?this.palette[0]:this.currgba,this.setPixel(b.x,b.y,this.currgba),d=!0,$(document).mouseup(D=>{$(document).off("mouseup");var W=this.getPositionFromEvent(D);this.setPixel(W.x,W.y,u),d=!1,this.commit()})}).mousemove(y=>{var b=this.getPositionFromEvent(y);d&&this.setPixel(b.x,b.y,u)}),i.empty(),this.createToolbarButtons(i[0]),i.append(this.canvas),i.append(this.createPaletteButtons()),this.setPaletteColor(1)}getPixel(t,i){if(t=Math.round(t),i=Math.round(i),t<0||t>=this.width||i<0||i>=this.height)return this.offscreen[t+","+i]|this.palette[0];var a=t+i*this.width;return this.rgbdata[a]}setPixel(t,i,a){if(t=Math.round(t),i=Math.round(i),t<0||t>=this.width||i<0||i>=this.height)this.offscreen[t+","+i]=a;else{var u=t+i*this.width,d=this.rgbdata[u];d!=a&&(this.rgbdata[u]=a,this.updateImage())}}createPaletteButtons(){this.palbtns=[];for(var t=vr(null,"asset_toolbar"),i=0;i<this.palette.length;i++){var a=$(document.createElement("button")).addClass("palbtn"),u=this.palette[i]&16777215,d="#"+De(rn(u),6);a.click(this.setPaletteColor.bind(this,i)),a.css("backgroundColor",d).text(i.toString(16)),a.css("color",u&32768?"black":"white"),t.append(a),this.palbtns.push(a)}return t}createToolbarButtons(t){var i=new sn(t,null);i.add("ctrl+shift+h","Flip X","glyphicon-resize-horizontal",this.flipX.bind(this)),i.add("ctrl+shift+v","Flip Y","glyphicon-resize-vertical",this.flipY.bind(this)),i.add("ctrl+shift+9","Rotate","glyphicon-repeat",this.rotate90.bind(this)),i.add("ctrl+shift+left","Move Left","glyphicon-arrow-left",this.translate.bind(this,1,0)),i.add("ctrl+shift+right","Move Right","glyphicon-arrow-right",this.translate.bind(this,-1,0)),i.add("ctrl+shift+up","Move Up","glyphicon-arrow-up",this.translate.bind(this,0,1)),i.add("ctrl+shift+down","Move Down","glyphicon-arrow-down",this.translate.bind(this,0,-1))}commit(){this.updateImage();try{this.left.refreshLeft()}catch(t){console.log(t),alert(`Could not update source code. ${t}`)}}remapPixels(t){for(var i=0,a=new Uint32Array(this.rgbdata.length),u=0;u<this.height;u++)for(var d=0;d<this.width;d++)a[i]=t(d,u),i++;this.rgbdata.set(a),this.commit()}rotate(t){var i=Math.sin(t*Math.PI/180),a=Math.cos(t*Math.PI/180);this.remapPixels((u,d)=>{var m=u+.5-this.width/2,y=d+.5-this.height/2,b=m*a-y*i+this.width/2-.5,D=y*a+m*i+this.height/2-.5;return this.getPixel(b,D)})}rotate90(){this.rotate(90)}flipX(){this.remapPixels((t,i)=>this.getPixel(this.width-1-t,i))}flipY(){this.remapPixels((t,i)=>this.getPixel(t,this.height-1-i))}translate(t,i){this.remapPixels((a,u)=>this.getPixel(a+t,u+i))}};var yn=Ds(),Ba=class{createDiv(t){return this.maindiv=Ut(t,"vertical-scroll"),this.maindiv[0]}clearAssets(){this.rootnodes=[],this.deferrednodes=[]}registerAsset(t,i,a){this.rootnodes.push(i),a?a>1?this.deferrednodes.push(i):this.deferrednodes.unshift(i):i.refreshRight()}getPalettes(t){var i=[];return this.rootnodes.forEach(a=>{for(;a!=null;){if(a instanceof mn){var u=a.palette;t==u.length&&i.push({node:a,name:"Palette",palette:u}),a.layout&&a.layout.forEach(([d,m,y])=>{if(m<u.length){if(y==t){var b=u.slice(m,m+y);i.push({node:a,name:d,palette:b})}else if(-y==t){var b=u.slice(m,m-y);b.reverse(),i.push({node:a,name:d,palette:b})}else if(y+1==t){var b=new Uint32Array(t);b[0]=u[0],b.set(u.slice(m,m+y),1),i.push({node:a,name:d,palette:b})}}});break}a=a.right}}),i}getTilemaps(t){var i=[];return this.rootnodes.forEach(a=>{for(;a!=null;){if(a instanceof Dr){var u=a.rgbimgs;u&&u.length>=t&&i.push({node:a,name:"Tilemap",images:a.images,rgbimgs:u})}a=a.right}}),i}isEditing(){return this.cureditordiv!=null}getCurrentEditNode(){return this.cureditnode}setCurrentEditor(t,i,a){let u=250;for(this.cureditordiv!=t&&(this.cureditordiv&&(this.cureditordiv.hide(u),this.cureditordiv=null),t&&(this.cureditordiv=t,this.cureditordiv.show(),this.cureditordiv[0].scrollIntoView({behavior:"smooth",block:"center"}))),this.cureditelem&&(this.cureditelem.removeClass("selected"),this.cureditelem=null),i&&(this.cureditelem=i,this.cureditelem.addClass("selected"));a.left;)a=a.left;this.cureditnode=a}scanFileTextForAssets(t,i){for(var a=[],u=/[/;][*;]([{].+[}])[*;][/;]/g,d;d=u.exec(i);){var m=d.index+d[0].length,y;if(ie.includes("verilog")?y=i.indexOf("end",m):d[0].startsWith(";;")?y=i.indexOf(";;",m):y=i.indexOf(";",m),y>m)try{var b=d[1].replace(/([A-Za-z]+):/g,'"$1":'),D=JSON.parse(b);a.push({fileid:t,fmt:D,start:m,end:y})}catch(Se){console.log(Se)}}for(var W=/DEF_METASPRITE_(\d+)x(\d+)[(](\w+),\s*(\w+),\s*(\w+)/gi;d=W.exec(i);){for(var fe=parseInt(d[1]),z=parseInt(d[2]),U=d[3],q=parseInt(d[4]),de=parseInt(d[5]),K=[],xe=0;xe<fe;xe++)for(var Ce=0;Ce<z;Ce++)K.push({x:xe*8,y:Ce*8,tile:q,attr:de});var be={defs:K,width:fe*8,height:z*8};a.push({fileid:t,label:U,meta:be})}return a}addPaletteEditorViews(t,i,a){var u=$('<div class="asset_dual"/>').appendTo(t),d=$('<div class="asset_editor"/>').hide(),m=[];i.getAllColors().forEach(U=>{m.push(new Uint32Array([U]))});var y=$("<table/>").appendTo(u);d.appendTo(u);var b=i.layout;if(!b){var D=i.palette.length,W=D>32?8:4;b=[];for(var fe=0;fe<D;fe+=W)b.push(["",fe,Math.min(D-fe,W)])}function z(U,q){var de=i.words[q],K=i.palette[q],xe="#"+De(rn(K),6),Ce=K&32768?"black":"white";U.text(De(de,2)).css("background-color",xe).css("color",Ce)}b.forEach(([U,q,de])=>{if(q<i.palette.length){var K=$("<tr/>").appendTo(y);$("<td/>").text(U).appendTo(K);for(var xe=[],Ce=q;Ce<q+Math.abs(de);Ce++)xe.push(Ce);de<0&&xe.reverse(),xe.forEach(be=>{var Se=$("<td/>").addClass("asset_cell asset_editable").appendTo(K);z(Se,be),Se.click(o=>{var X=new vn;X.rgbimgs=m,X.width=1,X.height=1,X.recreate(d,(ae,oe)=>{a(be,ae),z(Se,be)}),this.setCurrentEditor(d,Se,i)})})}})}addPixelEditor(t,i,a){a.xform="scale(2)";var u=new Oa(a);i.addRight(u);var d=new Dr(this,a);u.addRight(d),d.addRight(new Wa(this,Ut(t),a))}addPaletteEditor(t,i,a){var u=new mn(a);i.addRight(u),i.refreshRight(),this.addPaletteEditorViews(t,u,(d,m)=>{console.log("set entry",d,"=",m),i.words[d]=m,u.words=null,u.updateRight(),u.refreshLeft()})}ensureFileDiv(t){var i=this.getFileDivId(t),a=$(document.getElementById(i));if(a.length===0){var u=Ut(this.maindiv,"asset_file"),d=Ut(u,"asset_file_header").text(t);a=Ut(u).attr("id",i).addClass("disable-select")}return a}refreshAssetsInFile(t,i){let a=0;if(ie.startsWith("nes")&&t.endsWith(".chr")&&i instanceof Uint8Array){let u=new gn(ge,t),d={w:8,h:8,bpp:1,count:i.length>>4,brev:!0,np:2,pofs:8,remap:[0,1,2,4,5,6,7,8,9,10,11,12]};this.addPixelEditor(this.ensureFileDiv(t),u,d),this.registerAsset("charmap",u,1),a++}else if(ie.startsWith("nes")&&t.endsWith(".pal")&&i instanceof Uint8Array){let u=new gn(ge,t),d={pal:"nes",layout:"nes"};this.addPaletteEditor(this.ensureFileDiv(t),u,d),this.registerAsset("palette",u,0),a++}else if(typeof i=="string"){let u=this.scanFileTextForAssets(t,i);for(let d of u)if(d.fmt){let m=t,y=new Ma(ge,t,m,d.start,d.end),b=y;if(d.fmt.comp=="rletag"&&(y=y.addRight(new Na)),d.fmt.map=="nesnt"){y=y.addRight(new $a(this)),y=y.addRight(new Dr(this,{w:8,h:8,bpp:4}));let D={w:8*(d.fmt.w||32),h:8*(d.fmt.h||30),count:1};y=y.addRight(new ja(this,Ut(this.ensureFileDiv(t)),D)),this.registerAsset("nametable",b,2),a++}else d.fmt.w>0&&d.fmt.h>0?(this.addPixelEditor(this.ensureFileDiv(t),y,d.fmt),this.registerAsset("charmap",b,1),a++):d.fmt.pal&&(this.addPaletteEditor(this.ensureFileDiv(t),y,d.fmt),this.registerAsset("palette",b,0),a++)}}return a}getFileDivId(t){return"__asset__"+_s(t)}refresh(t){if(t)this.maindiv.empty(),this.clearAssets(),pe.iterateFiles((a,u)=>{try{var d=this.refreshAssetsInFile(a,u)}catch(m){console.log(m),this.ensureFileDiv(a).text(m+"")}}),console.log("Found "+this.rootnodes.length+" assets"),this.deferrednodes.forEach(a=>{try{a.refreshRight()}catch(u){console.log(u),alert(u+"")}}),this.deferrednodes=[];else for(var i of this.rootnodes)i!==this.getCurrentEditNode()&&i.refreshRight()}setVisible(t){t?yn.bind&&yn.bind("ctrl+z",ge.undoStep.bind(ge)):yn.unbind&&yn.unbind("ctrl+z")}};var gi=256,eo=100,to=!1,mi=class{constructor(t,i){this.expanded=!1;this.parent=t,this.name=i,this.children=new Map,this.level=t?t.level+1:-1,this.view=t?t.view:null}getDiv(){return this._div==null&&(this._div=document.createElement("div"),this._div.classList.add("vertical-scroll"),this._div.classList.add("tree-content"),this._header=document.createElement("div"),this._header.classList.add("tree-header"),this._header.classList.add("tree-level-"+this.level),this._header.append(this.name),this._inline=document.createElement("span"),this._inline.classList.add("tree-value"),this._header.append(this._inline),this._div.append(this._header),this.parent._content.append(this._div),this._header.onclick=t=>{this.toggleExpanded()}),this.expanded&&this._content==null?(this._content=document.createElement("div"),this._div.append(this._content)):!this.expanded&&this._content!=null&&(this._content.remove(),this._content=null,this.children.clear()),this._div}toggleExpanded(){this.expanded=!this.expanded,this.view.tick()}remove(){this._div.remove(),this._div=null}update(t){this.getDiv();var i="";if(t&&t.$$&&typeof t.$$=="function"&&this._content!=null&&(t=t.$$()),t==null)i=t+"";else if(typeof t=="number")t!=(t|0)?i=t.toString():i=t+" ($"+De(t)+")";else if(typeof t=="boolean")i=t.toString();else if(typeof t=="string")t.length<eo?i=t:i=t.substring(0,eo)+"...";else if(t.buffer&&t.length<=gi)i=ks(t,0,t.length);else if(typeof t=="object"||typeof t=="function")if(this._content!=null){if(t.slice&&t.length>gi){let b={},D=t;for(var a=gi;t.length/a>gi;)a*=2;for(let W=0;W<D.length;W+=a)b["$"+De(W)]={$$:()=>D.slice(W,W+a)};t=b}if(t instanceof Map){let b={};for(let[D,W]of t.entries())b[D]=W;t=b}let m=t instanceof Array?Array.from(t.keys()):Object.getOwnPropertyNames(t);if(m.length>gi){let b={},D=t;for(var a=100;m.length/a>100;)a*=2;for(let fe=0;fe<m.length;fe+=a){for(var u={},d=fe;d<fe+a;d++)u[m[d]]=D[m[d]];b["["+fe+"...]"]=u}t=b,m=Object.getOwnPropertyNames(t)}let y=new Set(this.children.keys());m.forEach(b=>{var D=!to&&typeof b=="string"&&b.startsWith("$$");if(!D){let W=this.children.get(b);W==null&&(W=new mi(this,b),this.children.set(b,W)),W.update(t[b])}y.delete(b)}),y.forEach(b=>{this.children.get(b).remove(),this.children.delete(b)}),this._header.classList.add("tree-expanded"),this._header.classList.remove("tree-collapsed")}else this._header.classList.add("tree-collapsed"),this._header.classList.remove("tree-expanded");else i=typeof t;this._inline.innerText!=i&&(this._inline.innerText=i)}};function ro(l,t){var i=new mi(null,null);i.view=t,i._content=l;var a=new mi(i,"/");return a.expanded=!0,a.getDiv(),a._div.style.padding="0px",a}var io=class{createDiv(t){return this.root=ro(t,this),this.root.getDiv()}refresh(){this.tick()}tick(){this.root.update(this.getRootObject())}};var Ha=class extends io{getRootObject(){return A.getDebugTree()}},Ua=class extends mr{constructor(){super(...arguments);this.cumulativeData=!0}createDiv(t){return this.clear(),this.treeroot=ro(t,this),this.treeroot.getDiv()}refresh(){this.tick()}tick(){this.treeroot.update(this.getRootObject()),this.probe&&this.probe.clear()}clear(){this.graph=null,this.reset()}reset(){this.stack=[],this.lastsp=-1,this.lastpc=0,this.jsr=!1,this.rts=!1}newNode(t,i){return{$$SP:i,$$PC:t,count:0,startLine:null,endLine:null,calls:{}}}newRoot(t,i){this.stack.length==0?(this.graph=this.newNode(null,i),this.stack.unshift(this.graph)):i>this.stack[0].$$SP&&(this.graph=this.newNode(null,i),this.graph.calls[this.addr2str(t)]=this.stack[0],this.stack.unshift(this.graph))}getRootObject(){return this.redraw((t,i,a,u,d,m)=>{switch(t){case te.SP_POP:this.newRoot(this.lastpc,this.lastsp);case te.SP_PUSH:if(this.stack.length){let b=this.stack[this.stack.length-1];var y=this.lastsp-i;(y==2||y==3)&&i<b.$$SP&&(this.jsr=!0),(y==-2||y==-3)&&this.stack.length>1&&i>b.$$SP&&(this.rts=!0)}this.lastsp=i;break;case te.EXECUTE:if(Math.abs(i-this.lastpc)>=4){if(this.jsr&&this.stack.length){let b=this.stack[this.stack.length-1],D=this.addr2str(i),W=b.calls[D];W==null?W=b.calls[D]=this.newNode(i,this.lastsp):W.$$PC==null&&(W.$$PC=i),this.stack.push(W),W.count++,W.startLine=u}this.jsr=!1,this.rts&&this.stack.length&&(this.stack.pop().endLine=u),this.rts=!1}this.lastpc=i;break}}),this.graph&&(this.graph.$$Stack=this.stack),to?this.graph:this.graph&&this.graph.calls}};var qt=aa(rl()),hl=tl(),kt=el(),ee=oa(window.location.search||"?"),vi=Fr(ee.electron),nt=Fr(ee.embed),xn,ie,br,Be,A,qa,bi=$("#controls_top"),Ve,pe,ge,at,Va,Ye,wn,Xe,ut,er,yi,xi,En=!1,Lr=!1,Sn=null,no=null,Ga=!1,ao="c.PC == 0x6000",pl={dasm:"6502",acme:"6502",cc65:"text/x-csrc",ca65:"6502",nesasm:"6502",z80asm:"z80",sdasz80:"z80",sdcc:"text/x-csrc",verilator:"verilog",jsasm:"z80",zmac:"z80",bataribasic:"bataribasic",markdown:"markdown",js:"javascript",xasm6809:"z80",cmoc:"text/x-csrc",yasm:"gas",smlrc:"text/x-csrc",inform6:"inform6",fastbasic:"fastbasic",basic:"basic",silice:"verilog",wiz:"text/x-wiz",vasmarm:"vasm",armips:"vasm",ecs:"ecs"},gl={dasm:"https://raw.githubusercontent.com/sehugg/dasm/master/doc/dasm.txt",cc65:"https://cc65.github.io/doc/cc65.html",ca65:"https://cc65.github.io/doc/ca65.html",sdcc:"http://sdcc.sourceforge.net/doc/sdccman.pdf",verilator:"https://www.veripool.org/ftp/verilator_doc.pdf",fastbasic:"https://github.com/dmsc/fastbasic/blob/master/manual.md",bataribasic:"help/bataribasic/manual.html",wiz:"https://github.com/wiz-lang/wiz/blob/master/readme.md#wiz",silice:"https://github.com/sylefeb/Silice",zmac:"https://raw.githubusercontent.com/sehugg/zmac/master/doc.txt",cmoc:"http://perso.b2b2c.ca/~sarrazip/dev/cmoc.html"};function wi(l,t,i,a){window.ga&&ga("send","event",l,t,i,a)}function Ee(l){Oe(!1),bootbox.alert({title:'<span class="glyphicon glyphicon-alert" aria-hidden="true"></span> Alert',message:kt.sanitize(l)})}function Rt(l){Oe(!1),bootbox.alert(kt.sanitize(l))}function ml(l){throw Ee(l),new Error(l)}function vl(){return new Worker("./gen/worker/bundle.js")}var St=function(){try{let t="__some_random_key_you_are_not_going_to_use__";localStorage.setItem(t,t);var l=localStorage.getItem(t)==t;return localStorage.removeItem(t),l}catch(t){return!1}}(),so=class{setLastPreset(t){St&&!nt&&(Be&&ie&&!vi?localStorage.setItem("__lastrepo_"+ie,Be):localStorage.removeItem("__lastrepo_"+ie),localStorage.setItem("__lastplatform",ie),localStorage.setItem("__lastid_"+br,t))}unsetLastPreset(){St&&!nt&&(delete ee.file,localStorage.removeItem("__lastid_"+br))}getLastPreset(){return St&&!nt&&localStorage.getItem("__lastid_"+br)}getLastPlatformID(){return St&&!nt&&localStorage.getItem("__lastplatform")}getLastRepoID(t){return St&&!nt&&t&&localStorage.getItem("__lastrepo_"+t)}shouldCompleteTour(){return St&&!nt&&!localStorage.getItem("8bitworkshop.hello")}completedTour(){St&&!nt&&localStorage.setItem("8bitworkshop.hello","true")}},yr=new so;function Ya(l,t){navigator.storage&&navigator.storage.persist?navigator.storage.persist().then(i=>{console.log("requestPersistPermission =",i),i?l&&!t&&Rt("Your browser says it will persist your local file edits, but you may want to back up your work anyway."):l&&Ee("Your browser refused to expand the peristent storage quota. Your edits may not be preserved after closing the page.")}):l&&Ee("Your browser may not persist edits after closing the page. Try a different browser.")}function bl(){return wn?wn.title||wn.name||pe.mainPath||"ROM":pe.mainPath||"ROM"}async function yl(){var l=new pa(ie);return vi?(console.log("using electron with local filesystem",alternateLocalFilesystem),new ui(l,alternateLocalFilesystem)):ee.localfs!=null?new ui(l,await Fl(ee.localfs)):new ui(l,new ma(Xe))}async function xl(){var l=await yl();pe=new va(vl(),ie,A,l),pe.remoteTool=ee.tool||null,ge=new xa($("#workspace")[0],pe),pe.callbackBuildResult=t=>{su(t)},pe.callbackBuildStatus=t=>{wl(t)}}function wl(l){l?bi.addClass("is-busy"):bi.removeClass("is-busy"),$("#compile_spinner").css("visibility",l?"visible":"hidden")}function Xa(l,t){var i=document.createElement("li"),a=document.createElement("a");return a.setAttribute("class","dropdown-item"),a.setAttribute("href","#"),a.setAttribute("data-wndid",l),l==ge.getActiveID()&&$(a).addClass("dropdown-item-checked"),a.appendChild(document.createTextNode(t)),i.appendChild(a),{li:i,a}}function Ei(){var l=$("#windowMenuList").empty(),t=!1;function i(b,D,W){t&&(l.append(document.createElement("hr")),t=!1);let{li:fe,a:z}=Xa(b,D);if(l.append(fe),W){var U=(q,de)=>{l.find("a").removeClass("dropdown-item-checked"),$(z).addClass("dropdown-item-checked")};ge.setCreateFunc(b,W),ge.setShowFunc(b,U),$(z).click(q=>{ge.createOrShow(b),Sn=b})}}function a(b){var D=A.getToolForFilename(b);D=="dasm"&&b.endsWith(".h")&&st().endsWith(".c")&&(D="cc65");var W=D&&pl[D];return new di(b,W)}function u(b){i(b,Et(b),()=>{var D=pe.getFile(b);if(typeof D=="string")return a(b);if(D instanceof Uint8Array)return new Ca(b,D)})}u(pe.mainPath),pe.iterateFiles((b,D)=>{D&&b!=pe.mainPath&&u(b)}),t=!0;var d=pe.getListings();if(d)for(var m in d){var y=d[m];(y.assemblyfile&&y.assemblyfile.text||y.sourcefile&&y.sourcefile.text||y.text)&&i(m,Et(m),b=>new _a(b))}t=!0,A.disassemble&&A.saveState&&i("#disasm","Disassembly",()=>new fn),A.readAddress&&i("#memory","Memory Browser",()=>new dn),pe.segments&&pe.segments.length&&i("#memmap","Memory Map",()=>new ka),A.readVRAMAddress&&i("#memvram","VRAM Browser",()=>new Ta),A.startProbing&&(i("#memheatmap","Memory Probe",()=>new Aa),i("#crtheatmap","CRT Probe",()=>new Fa),i("#probelog","Probe Log",()=>new Da),i("#scanlineio","Scanline I/O",()=>new La),i("#symbolprobe","Symbol Profiler",()=>new Ra),i("#callstack","Call Stack",()=>new Ua)),A.getDebugTree&&i("#debugview","Debug Tree",()=>new Ha),i("#asseteditor","Asset Editor",()=>new Ba)}function El(l,t){if(t){var i=ee.highlight.split(","),a=parseInt(i[0])-1,u=parseInt(i[1])-1,d=ge.createOrShow(l);d.highlightLines(a,u)}}function oo(l){Ei(),ge.createOrShow(l),pe.setMainFile(l),El(l,ee.highlight)}async function Sl(l){pe.mainPath=l,yr.setLastPreset(l);var t=await pe.loadFiles([l]);if(Ti=new Date,t&&t.length)oo(l);else{var i=await _l(l);pe.filedata[l]=i||`
`,oo(l),ee.newfile?Ya(!0,!0):Rt('Could not find file "'+l+'". Loading default file.'),delete ee.newfile,Pn()}}function Qa(l){if(l=="/")ee={repo:"/"};else if(l.indexOf("://")>=0){var t=un(l);t&&(ee={repo:t.repopath})}else ee.platform=ie,ee.file=l;Rr()}async function _l(l){var t=A.getToolForFilename(l);try{return await $.get("presets/"+gt(ie)+"/skeleton."+t,"text")}catch(i){Ee("Could not load skeleton for "+ie+"/"+t+"; using blank file")}}function Ja(l){return l.indexOf(" ")>=0?(Ee("No spaces in filenames, please."),!1):!0}function Tl(l){return bootbox.prompt({title:"Enter the name of your new main source file.",placeholder:"newfile"+A.getDefaultExtension(),callback:t=>{if(t&&t.trim().length>0){if(!Ja(t))return;t.indexOf(".")<0&&(t+=A.getDefaultExtension());var i=t;wi("workspace","file","new"),ee.newfile="1",Qa(i)}}}),!0}function Cl(l){let t=$('<input type="file" multiple accept="*" style="display:none">'),i=t[0];t.change(a=>{kl(i.files)}),t.click()}function kl(l){console.log(l);var t=0;function i(){var a=l[t++];if(!a)console.log("Done uploading",t),t>2?(Rt("Files uploaded."),setTimeout(_i,1e3)):(ee.file=l[0].name,bootbox.confirm({message:"Open '"+kt.sanitize(ee.file)+"' as main project file?",buttons:{confirm:{label:"Open As New Project"},cancel:{label:"Include/Link With Project Later"}},callback:m=>{m?Rr():setTimeout(_i,1e3)}})),wi("workspace","file","upload");else{var u=a.name,d=new FileReader;d.onload=function(m){var y=m.target.result,b=new Uint8Array(y);gr(u,b)||(b=tn(b).replace(`\r
`,`
`)),ge.updateFile(u,b),console.log("Uploaded "+u+" "+b.length+" bytes"),i()},d.readAsArrayBuffer(a)}}l&&i()}async function Pl(l){var t=window.showDirectoryPicker;t||Ee("This browser can't open local files on your computer, yet. Try Chrome.");var i=await t(),a=i.name,u="__localfs__"+a,d={handle:i},m=za.createInstance({name:u,version:2});await m.setItem(u,d),ee={localfs:a},Rr(!0)}async function Al(l){return new Promise((t,i)=>{bootbox.prompt(kt.sanitize(l),a=>{t(a)})})}async function Fl(l){let t={mode:"readwrite"};var i="__localfs__"+l,a=za.createInstance({name:i,version:2}),u=await a.getItem(i),d=u.handle;console.log(u,d);var m=await d.queryPermission(t);if(console.log(m),m!=="granted"&&(await Al("Request permissions to access filesystem?"),m=await d.requestPermission(t)),m!=="granted"){Ee("Could not get permission to access filesystem.");return}return{getFileData:async y=>{console.log("getFileData",y);let b=await d.getFileHandle(y,{create:!1});console.log("getFileData",b);let D=await b.getFile();console.log("getFileData",D);let W=await(gr(y)?D.binary():D.text());return console.log(b,D,W),W},setFileData:async(y,b)=>{}}}function st(){return Et(pe.mainPath)}function Dl(){return Et(ge.getActiveID())}var Ka;function lo(l){for(var t=l+"=",i=document.cookie.split(";"),a=0;a<i.length;a++){for(var u=i[a];u.charAt(0)==" ";)u=u.substring(1,u.length);if(u.indexOf(t)==0)return u.substring(t.length,u.length)}return null}async function xr(){if(!Ka){await Dt("lib/octokat.js"),await Dt("https://www.gstatic.com/firebasejs/8.8.1/firebase-app.js"),await Dt("https://www.gstatic.com/firebasejs/8.8.1/firebase-auth.js"),await Dt("https://8bitworkshop.com/config.js");var l=lo("__github_key");Ka=new wa(Octokat,l,Xe,pe),console.log("loaded github service")}return Ka}function Si(){var l=(Be||"").split("/");return l.length!=2?(Ee("You are not in a GitHub repository. Choose one from the pulldown, or Import or Publish one."),null):"https://github.com/"+l[0]+"/"+l[1]}async function Za(l,t){var i,a=un(l);if(!a){Ee("Could not parse Github URL.");return}var u=ci()[a.repopath];if(!(u&&!confirm("You've already imported "+a.repopath+" -- do you want to replace all local files?"))){Oe(!0);var d=ba(a.repopath);Gt(.25);var m=await xr();return m.import(l).then(y=>(i=y,Gt(.75),m.pull(l,d))).then(y=>{ee={repo:i.repopath},Oe(!1),wi("sync","import",l),Rr(t)}).catch(y=>{Oe(!1),console.log(y),Ee("Could not import "+l+"."+y)})}}async function Ll(l){var t=await xr();t.login().then(()=>{Rt("You are signed in to Github.")}).catch(i=>{Ee("Could not sign in."+i)})}async function Rl(l){var t=await xr();t.logout().then(()=>{Rt("You are logged out of Github.")})}function Il(l){var t=$("#importGithubModal"),i=$("#importGithubButton");t.modal("show"),i.off("click").on("click",()=>{var a=$("#importGithubURL").val()+"";t.modal("hide"),Za(a,!1)})}function Ml(l){if(!(Be&&!confirm("This project ("+pe.mainPath+") is already bound to a Github repository. Do you want to re-publish to a new repository? (You can instead choose 'Push Changes' to update files in the existing repository.)"))){var t=$("#publishGithubModal"),i=$("#publishGithubButton");$("#githubRepoName").val(pt(Et(pe.mainPath))),t.modal("show"),i.off("click").on("click",async()=>{var a=$("#githubRepoName").val()+"",u=$("#githubRepoDesc").val()+"",d=$("#githubRepoPrivate").val()=="private",m=$("#githubRepoLicense").val()+"",y;if(!a){Ee("You did not enter a project name.");return}t.modal("hide"),Oe(!0);var b=await xr();b.login().then(()=>(Gt(.25),b.publish(a,u,m,d))).then(D=>(y=D,Gt(.5),Be=ee.repo=y.repopath,uo("initial import from 8bitworkshop.com"))).then(()=>{wi("sync","publish",d?"":a),Za(y.url,!1)}).catch(D=>{Oe(!1),console.log(D),Ee("Could not publish GitHub repository: "+D)})})}}function Nl(l){var t=Si();if(!!t){var i=$("#pushGithubModal"),a=$("#pushGithubButton");i.modal("show"),a.off("click").on("click",()=>{var u=$("#githubCommitMsg").val()+"";i.modal("hide"),uo(u)})}}function Ol(l){var t=Si();!t||bootbox.confirm("Pull from repository and replace all local files? Any changes you've made will be overwritten.",async i=>{if(i){Oe(!0);var a=await xr();a.pull(t).then(u=>{Oe(!1),ge.updateAllOpenWindows(Xe)})}})}function $l(l){return new Promise((t,i)=>{var a=l.commit.files;if(console.log(a),a.length==0){Oe(!1),Rt("No files changed.");return}var u="";for(var d of a)u+=kt.sanitize(d.filename)+": "+d.status,(d.additions||d.deletions||d.changes)&&(u+=" ("+d.additions+" additions, "+d.deletions+" deletions, "+d.changes+" changes)"),u+="<br/>";bootbox.confirm(u,m=>{m?t(l):Oe(!1)})})}async function uo(l){var t=Si();if(!!t){var i=[];for(var a in pe.filedata){var u=pe.stripLocalPath(a),d=pe.filedata[a];u&&d&&i.push({path:u,data:d})}if(Ye instanceof Uint8Array){let y="bin/"+st()+".rom";i.push({path:y,data:Ye})}Oe(!0);var m=await xr();return m.login().then(()=>(Gt(.5),m.commit(t,l,i))).then(y=>$l(y)).then(y=>m.push(y)).then(y=>(Oe(!1),Rt("Pushed files to "+t),y)).catch(y=>{Oe(!1),console.log(y),Ee("Could not push GitHub repository: "+y)})}}function Wl(){var l=Si();!l||bootbox.prompt("<p>Are you sure you want to delete this repository ("+kt.sanitize(l)+") from browser storage?</p><p>All changes since last commit will be lost.</p><p>Type DELETE to proceed.<p>",t=>{t.trim().toUpperCase()=="DELETE"&&jl()})}async function jl(){var l=Si();Oe(!0);let t=await xr(),i=await t.getGithubSession(l);t.bind(i,!1),await Xe.keys().then(a=>Promise.all(a.map(u=>Xe.removeItem(u)))),Oe(!1),ee={repo:"/"},Rr()}function Bl(l){return Ye==null?(Ee("Please fix errors before sharing."),!0):Ye instanceof Uint8Array?(Hl(),Dt("lib/liblzg.js").then(()=>{var t=Ss(window.Module,Array.from(Ye));window.Module=null;var i=btoa(en(t)),a={p:ie,r:i},u=$.param(a),d=Ul(u,"player.html"),m='<iframe width=640 height=600 src="'+d+'">';$("#embedLinkTextarea").text(d),$("#embedIframeTextarea").text(m),$("#embedLinkModal").modal("show"),$("#embedAdviceWarnAll").hide(),$("#embedAdviceWarnIE").hide(),d.length>=65536?$("#embedAdviceWarnAll").show():d.length>=5120&&$("#embedAdviceWarnIE").show()}),!0):(Ee("Can't share a Verilog executable yet. (It's not actually a ROM...)"),!0)}function Hl(){console.log("clipboard"),import("./clipboard-IV56MLOR.js").then(l=>{let t=l.default;new t(".btn")})}function Ul(l,t){console.log(l);var i=window.location,a=i.pathname.replace("index.html",""),u=i.host=="8bitworkshop.com"?"https:":i.protocol,d=u+"//"+i.host+a+t+"?"+l;return d}function zl(l){var t=ut&&ut.code_start;Dt("lib/c2t.js").then(()=>{var i="",a=function(fe){i+=fe+`
`},u=window.c2t({noInitialRun:!0,print:a,printErr:a}),d=u.FS,m=st()+".bin",y=st()+".wav";d.writeFile(m,Ye,{encoding:"binary"});var b=["-2bc",m+","+t.toString(16),y];u.callMain(b);var D=d.readFile(y,{encoding:"binary"});if(D){var W=new Blob([D],{type:"audio/wav"});(0,qt.saveAs)(W,y),i+="Then connect your audio output to the cassette input, turn up the volume, and play the audio file.",Rt(i)}})}function ql(l){Dt("lib/makewav.js").then(()=>{let t="",i=function(y){t+=y+`
`};var a=pt(st());let u=a+".bin",d=a+".wav";window.makewav({noInitialRun:!1,print:i,printErr:i,arguments:["-ts","-f0","-v10",u],preRun:y=>{y.FS.writeFile(u,Ye,{encoding:"binary"})}}).ready.then(y=>{let b=[u];y.run(b),console.log(t);let W=y.FS.readFile(d,{encoding:"binary"});if(W){let fe=new Blob([W],{type:"audio/wav"});(0,qt.saveAs)(fe,d),t+=`
Connect your audio output to the SuperCharger input, turn up the volume, and play the audio file.`,Rt(t)}})})}function Vl(l){if(Ye==null)return Ee("Please fix errors before exporting."),!0;var t;switch(gt(ie)){case"vcs":t=ql;break;case"apple2":t=zl;break}if(t===void 0)return Ee("Cassette export is not supported on this platform."),!0;t(l)}function Gl(l){var t=ge.getActive();if(t&&t.setText){var i=ge.getActiveID();$.get("presets/"+gt(ie)+"/"+i,a=>{bootbox.confirm("Reset '"+kt.sanitize(i)+"' to default?",u=>{u&&t.setText(a)})},"text").fail(()=>{Ee(Be?"Can only revert built-in examples. If you want to revert all files, You can pull from the repository.":"Can only revert built-in examples.")})}else Ee("Cannot revert the active window. Please choose a text file.")}function Yl(l){var t=ge.getActive();if(t&&t.getPath){var i=ge.getActiveID();bootbox.confirm("Delete '"+kt.sanitize(i)+"'?",a=>{a&&Xe.removeItem(i).then(()=>{ee.file==i?(yr.unsetLastPreset(),Rr()):(_i(),Rt("Deleted "+i))})})}else Ee("Cannot delete the active window.")}function Xl(l){var t=ge.getActive();if(t&&t.getPath&&pe.getFile(t.getPath())){var i=ge.getActiveID();bootbox.prompt({title:"Rename '"+kt.sanitize(i)+"' to?",value:i,callback:a=>{var u=pe.getFile(t.getPath());if(a&&a!=i&&u){if(!Ja(a))return;Xe.removeItem(i).then(()=>Xe.setItem(a,u)).then(()=>{_i(),alert("Renamed "+i+" to "+a),i==pe.mainPath&&Qa(a)})}}})}else Ee("Cannot rename the active window.")}function Ql(l){if(Ye==null)return Ee("Please finish compiling with no errors before downloading ROM."),!0;var t=pt(st());if(A.getDownloadFile){var i=A.getDownloadFile(),t=pt(st());(0,qt.saveAs)(i.blob,t+i.extension)}else if(Ye instanceof Uint8Array){var a=new Blob([Ye],{type:"application/octet-stream"}),u=A.getROMExtension&&A.getROMExtension(Ye)||"-"+gt(ie)+".bin";(0,qt.saveAs)(a,t+u)}else Ee(`The "${ie}" platform doesn't have downloadable ROMs.`)}function Jl(l){var t=ge.getCurrentText();if(!t)return!1;var i=new Blob([t],{type:"text/plain;charset=utf-8"});(0,qt.saveAs)(i,Dl(),{autoBom:!1})}async function co(){let l=(await import("./jszip.min-DI47XKVW.js")).default;return new l}async function Kl(l){var t=await co();pe.iterateFiles((i,a)=>{a&&t.file(Et(i),a)}),t.generateAsync({type:"blob"}).then(i=>{(0,qt.saveAs)(i,st()+"-"+gt(ie)+".zip")})}function Zl(l){let t=A.getDebugSymbolFile&&A.getDebugSymbolFile();if(!t){Ee("This project does not have debug information.");return}var i=pt(st());(0,qt.saveAs)(t.blob,i+t.extension,{autoBom:!1})}async function eu(l){var t=await co(),i=await Xe.keys();Oe(!0);try{var a=0;await Promise.all(i.map(d=>Xe.getItem(d).then(m=>{Gt(a++/(i.length+1)),m&&t.file(d,m)})));var u=await t.generateAsync({type:"blob"});(0,qt.saveAs)(u,gt(ie)+"-all.zip")}finally{Oe(!1)}}function tu(l){var t={};l.append($("<option />").text("--------- Examples ---------").attr("disabled","true"));for(var i=0;i<xn.length;i++){var a=xn[i],u=a.chapter?a.chapter+". "+a.name:a.name,d=a.id==pe.mainPath;l.append($("<option />").val(a.id).text(u).attr("selected",d?"selected":null)),d&&(wn=a),t[a.id]=u}return t}function ru(l){if(St&&!vi){var t=0,i=ci();if(i)for(let u in i){var a=i[u];a.platform_id&&gt(a.platform_id)==gt(ie)&&(t++==0&&l.append($("<option />").text("------ Repositories ------").attr("disabled","true")),l.append($("<option />").val(a.url).text(a.url.substring(a.url.indexOf("/")))))}}}async function fo(l,t,i,a){var u=await Xe.keys(),d=0;u||(u=[]);for(var m=0;m<u.length;m++){var y=u[m];if(y.startsWith(i)&&!a[y]){d++==0&&l.append($("<option />").text("------- "+t+" -------").attr("disabled","true"));var b=y.substring(i.length);l.append($("<option />").val(y).text(b).attr("selected",y==pe.mainPath?"selected":null))}}}function ho(l){l.css("visibility","visible");var t=pe.mainPath;l.val()!=t&&l.append($("<option />").val(t).text(t).attr("selected","selected"))}async function _i(){var l=$("#preset_select").empty();if(Be)l.append($("<option />").val("/").text("Leave Repository")),$("#repo_name").text(Et(Be)+"/").show(),await fo(l,Be,"",{}),ho(l);else{ru(l);var t=tu(l);await fo(l,"Local Files","",t),ho(l)}l.off("change").change(function(i){Qa($(this).val().toString())})}function iu(l){var t=$("<p/>");if(l.path!=null){var i=l.line?l.label?`(${l.path} @ ${l.label})`:`(${l.path}:${l.line})`:`(${l.path})`,a=$("<a/>").text(i),u=l.path;u==st()&&(u=pe.mainPath),ge.isWindow(u)&&a.click(d=>{var m=ge.createOrShow(u);m instanceof di&&m.setCurrentLine(l,!0)}),t.append(a),t.append("&nbsp;")}return t.append($("<span/>").text(l.msg)),t}function po(){$("#error_alert").hide(),Ga=!1}function es(l,t){var i=$("#error_alert_msg").empty();for(var a of l.slice(0,10))i.append(iu(a));$("#error_alert").show(),Ga=t}function go(l,t){if(t!=null){var i={msg:t,line:0};l instanceof ua&&l.$loc&&(i=Object.create(l.$loc),i.msg=t,console.log(i)),es([i],!0)}}var nu=new Date,Ti;function au(){if(window.ga&&Ti){var l=new Date;ga("send","timing","load",ie,Ti.getTime()-nu.getTime()),ga("send","timing","build",ie,l.getTime()-Ti.getTime()),Ti=null}}async function su(l){if("errors"in l&&l.errors.length>0)bi.addClass("has-errors"),ge.setErrors(l.errors),Ei(),es(l.errors,!1);else{if(bi.removeClass("has-errors"),ge.setErrors(null),po(),l==null||"unchanged"in l&&l.unchanged||!("output"in l))return;A.debugSymbols=new As(l.symbolmap,l.debuginfo),ut=l.params;var t=l.output;if(t!=null)try{ki(),wo(),await A.loadROM(bl(),t),Ye=t,Va||It(),au(),Ju()}catch(i){console.log(i),bi.addClass("has-errors"),go(i,i+""),Ye=null,Ei();return}Ei(),ge.refresh(!1)}}async function ou(){if(A.loadBIOS){var l=ie+".rom",t=await Xe.getItem(l);t instanceof Uint8Array?(console.log("loading BIOS",l,t.length+" bytes"),A.loadBIOS(l,t)):console.log("BIOS file must be binary")}}function mo(){var l=$("#mem_info");l.hide(),yi=null}function Ci(l){if(!!Fs(A)){var t=$("#mem_info"),i=A.getDebugCategories();i&&!xi&&(xi=i[0]);var a=l&&A.getDebugInfo(xi,l);if(a){var u=yi?Es(yi,a):a;t.show().html(u);var d=$('<div class="mem_info_links">'),m=b=>{var D=$("<a>"+b+"</a>");b==xi&&D.addClass("selected"),D.click(W=>{xi=b,yi=null,Ci(er)}),d.append(D),d.append("<span> </span>")};for(var y of i)m(y);t.append("<br>"),t.append(d),yi=a}else mo()}}function _n(l,t){$("#debug_bar, #run_bar").find("button").removeClass("btn_active").removeClass("btn_stopped"),$("#dbg_"+l).addClass("btn_"+t)}function ts(){return A&&Ye!=null}function Pt(){return ts()?!0:(Ee("Can't do this until build successfully completes."),!1)}function lu(l){if(Sn&&Sn.startsWith("#")||["toline","restart","tovsync","stepover"].includes(no)||!A.disassemble)return;let t=pe.getListings(),i="#disasm",a=256;if(t){let u=l.c?l.c.EPC||l.c.PC:0;for(let d in t){let m=t[d],y=m.assemblyfile||m.sourcefile,b=pe.filename2path[d]||d;if(y==m.sourcefile&&(b=ge.findWindowWithFilePrefix(d)),ge.isWindow(b)){let D=y&&y.findLineForOffset(u,cn);if(D){let W=y.lines[D.line+1];if(!W||u<W.offset){let fe=u-D.offset;fe<a&&(i=b,a=fe)}}}}}ge.createOrShow(i,!0)}function Tn(l){er=l,Ci(l),lu(l),ge.refresh(!0),En=!0}function vo(l){A.setupDebug&&(A.setupDebug((t,i)=>{Tn(t),_n(l||"pause","stopped"),i&&es([{msg:"STOPPED: "+i,line:0}],!0)}),no=l)}function Lt(l){!Pt()||(ns(),vo(l),l&&_n(l,"active"))}function Vt(){A&&A.isRunning()&&(A.pause(),console.log("Paused")),_n("pause","stopped")}function uu(){!Pt()||(ki(),Vt(),Va=!0)}function It(){A.isRunning()||(A.resume(),console.log("Resumed")),_n("go","active"),Ga&&po()}function bo(){!Pt()||(ki(),A.isRunning()||ge.refresh(!1),It(),Va=!1,Sn=null)}function cu(){!Pt()||(Lt("step"),A.step())}function fu(){!Pt()||(Lt("stepover"),A.stepOver())}function du(){!Pt()||(Lt("tovsync"),A.runToVsync())}function yo(){var l=ge.getActive();return l&&l.getCursorPC&&l.getCursorPC()}function hi(l){!Pt()||!(l>=0)||(Lt("toline"),console.log("Run to",l.toString(16)),A.runToPC?A.runToPC(l):A.runEval(t=>t.PC==l))}function hu(){A.restartAtPC(yo())?bo():Ee("Could not restart program at selected line.")}function pu(){hi(yo())}function gu(){!Pt()||(Lt("stepout"),A.runUntilReturn())}function mu(){!Pt()||(Lt("stepback"),A.stepBack())}function ki(){er=null,A.clearDebug&&A.clearDebug(),vo(),Ci()}function rs(){A.reset(),wo()}function vu(){!Pt()||(ki(),rs(),It())}function bu(){if(!!Pt()){var l=Lr;ns(),A.setupDebug&&A.runEval?(ki(),It(),rs(),Lt("restart"),A.runEval(t=>!0)):(rs(),It()),l&&Eo()}}function yu(){var l=$("#debugExprModal"),t=$("#debugExprSubmit");$("#debugExprInput").val(ao),$("#debugExprExamples").text(xu()),l.modal("show"),t.off("click").on("click",()=>{var i=$("#debugExprInput").val()+"";l.modal("hide"),wu(i)})}function xu(){var l=A.saveState&&A.saveState(),t=l.c;console.log(t,l);var i="";return t.PC&&(i+="c.PC == 0x"+De(t.PC)+`
`),t.SP&&(i+="c.SP < 0x"+De(t.SP)+`
`),t.HL&&(i+=`c.HL == 0x4000
`),A.readAddress&&(i+=`this.readAddress(0x1234) == 0x0
`),A.readVRAMAddress&&(i+=`this.readVRAMAddress(0x1234) != 0x80
`),A.getRasterScanline&&(i+=`this.getRasterScanline() > 222
`),i}function wu(l){var t=new Function("c","return ("+l+");").bind(A);Lt(),A.runEval(t),ao=l}function xo(){A.isRunning()?(ge.tick(),En=!1):En||(ge.tick(),En=!0),setTimeout(xo,100)}function Oe(l){l?(Gt(0),$("#pleaseWaitModal").modal("show")):(Gt(1),$("#pleaseWaitModal").modal("hide"))}function Gt(l){$("#pleaseWaitProgressBar").css("width",l*100+"%").show()}var is=!1;function Eu(){is||Dt("lib/gif.js").then(()=>{var l=$("#emulator").find("canvas")[0];if(!l){Ee("Could not find canvas element to record video!");return}var t=0;l.style&&l.style.transform&&(l.style.transform.indexOf("rotate(-90deg)")>=0?t=-1:l.style.transform.indexOf("rotate(90deg)")>=0&&(t=1));var i=new GIF({workerScript:"lib/gif.worker.js",workers:4,quality:10,rotate:t}),a=$("#videoPreviewImage");i.on("progress",b=>{Gt(b)}),i.on("finished",b=>{a.attr("src",URL.createObjectURL(b)),Oe(!1),It(),$("#videoPreviewModal").modal("show")});var u=20,d=300,m=0;console.log("Recording video",l),$("#emulator").css("backgroundColor","#cc3333");var y=()=>{m++>d?(console.log("Rendering video"),$("#emulator").css("backgroundColor","inherit"),Oe(!0),Vt(),i.render(),is=!1):(i.addFrame(l,{delay:u,copy:!0}),setTimeout(y,u),is=!0)};y()})}function Cn(l){A.setFrameRate(l),l>.01?$("#fps_label").text(l.toFixed(2)):$("#fps_label").text("1/"+Math.round(1/l))}function Su(){var l=A.getFrameRate();l=l/2,l>1e-5&&Cn(l)}function _u(){var l=A.getFrameRate();l=Math.min(60,l*2),Cn(l)}function Tu(){Cn(60/65536)}function Cu(){It(),Cn(60)}function ku(){ge.refresh(!1);var l=ge.getActive();if(l.getSourceFile&&l.setTimingResult){var t=A.newCodeAnalyzer();t.showLoopTimingForPC(0),l.setTimingResult(t)}}function ns(){Lr&&(A.setRecorder(null),$("#dbg_record").removeClass("btn_recording"),$("#replaydiv").hide(),mo(),Lr=!1)}function wo(){Lr&&at.reset()}function Eo(){at.reset(),A.setRecorder(at),$("#dbg_record").addClass("btn_recording"),$("#replaydiv").show(),Lr=!0}function Pu(){Lr?ns():Eo()}function tr(l,t,i){var a=ge.getActive();a&&a.insertText?bootbox.prompt({title:"Add "+kt.sanitize(l)+" File to Project",value:"filename"+kt.sanitize(t),callback:u=>{if(u&&u.trim().length>0){if(!Ja(u))return;var d=u,m=`
`+i(u)+`
`;pe.loadFiles([d]).then(y=>{y&&y.length?Ee(u+" already exists; including anyway"):pe.updateFile(d,`
`),a.insertText(m),Ei()})}}}):Ee("Can't insert text in this window -- switch back to main file")}function Au(){var l=st(),t=A.getToolForFilename(l);l.endsWith(".c")||t=="sdcc"||t=="cc65"||t=="cmoc"||t=="smlrc"?tr("Header",".h",i=>'#include "'+i+'"'):t=="dasm"||t=="zmac"?tr("Include",".inc",i=>' include "'+i+'"'):t=="ca65"||t=="sdasz80"||t=="vasm"||t=="armips"?tr("Include",".inc",i=>' .include "'+i+'"'):t=="verilator"?tr("Verilog",".v",i=>'`include "'+i+'"'):t=="wiz"?tr("Include",".wiz",i=>'import "'+i+'";'):t=="ecs"?tr("Include",".ecs",i=>'import "'+i+'"'):Ee("Can't add include file to this project type ("+t+")")}function Fu(){var l=st(),t=A.getToolForFilename(l);l.endsWith(".c")||t=="sdcc"||t=="cc65"||t=="cmoc"||t=="smlrc"?tr("Linked C (or .s)",".c",i=>'//#link "'+i+'"'):l.endsWith("asm")||l.endsWith(".s")||t=="ca65"||t=="lwasm"?tr("Linked ASM",".inc",i=>';#link "'+i+'"'):Ee("Can't add linked file to this project type ("+t+")")}function Du(){if(Ve=new sn($("#toolbar")[0],null),Ve.grp.prop("id","run_bar"),Ve.add("ctrl+alt+r","Reset","glyphicon-refresh",vu).prop("id","dbg_reset"),Ve.add("ctrl+alt+,","Pause","glyphicon-pause",uu).prop("id","dbg_pause"),Ve.add("ctrl+alt+.","Resume","glyphicon-play",bo).prop("id","dbg_go"),A.restartAtPC&&Ve.add("ctrl+alt+/","Restart at Cursor","glyphicon-play-circle",hu).prop("id","dbg_restartatline"),Ve.newGroup(),Ve.grp.prop("id","debug_bar"),A.runEval&&Ve.add("ctrl+alt+e","Reset and Debug","glyphicon-fast-backward",bu).prop("id","dbg_restart"),A.stepBack&&Ve.add("ctrl+alt+b","Step Backwards","glyphicon-step-backward",mu).prop("id","dbg_stepback"),A.step&&Ve.add("ctrl+alt+s","Single Step","glyphicon-step-forward",cu).prop("id","dbg_step"),A.stepOver&&Ve.add("ctrl+alt+t","Step Over","glyphicon-hand-right",fu).prop("id","dbg_stepover"),A.runUntilReturn&&Ve.add("ctrl+alt+o","Step Out of Subroutine","glyphicon-hand-up",gu).prop("id","dbg_stepout"),A.runToVsync&&Ve.add("ctrl+alt+n","Next Frame/Interrupt","glyphicon-forward",du).prop("id","dbg_tovsync"),(A.runEval||A.runToPC)&&!ie.startsWith("verilog")&&Ve.add("ctrl+alt+l","Run To Line","glyphicon-save",pu).prop("id","dbg_toline"),Ve.newGroup(),Ve.grp.prop("id","xtra_bar"),$(".dropdown-menu").collapse({toggle:!1}),$("#item_new_file").click(Tl),$("#item_upload_file").click(Cl),$("#item_open_directory").click(Pl),$("#item_github_login").click(Ll),$("#item_github_logout").click(Rl),$("#item_github_import").click(Il),$("#item_github_publish").click(Ml),$("#item_github_push").click(Nl),$("#item_github_pull").click(Ol),$("#item_repo_delete").click(Wl),$("#item_share_file").click(Bl),$("#item_reset_file").click(Gl),$("#item_rename_file").click(Xl),$("#item_delete_file").click(Yl),A.runEval?$("#item_debug_expr").click(yu).show():$("#item_debug_expr").hide(),$("#item_download_rom").click(Ql),$("#item_download_file").click(Jl),$("#item_download_zip").click(Kl),A.getDebugSymbolFile?$("#item_download_sym").click(Zl):$("#item_download_sym").hide(),$("#item_download_allzip").click(eu),$("#item_record_video").click(Eu),ie.startsWith("apple2")||ie.startsWith("vcs")?$("#item_export_cassette").click(Vl):$("#item_export_cassette").hide(),A.setFrameRate&&A.getFrameRate&&($("#dbg_slower").click(Su),$("#dbg_faster").click(_u),$("#dbg_slowest").click(Tu),$("#dbg_fastest").click(Cu)),$("#item_addfile_include").click(Au),$("#item_addfile_link").click(Fu),$("#item_request_persist").click(()=>Ya(!0,!1)),xo(),A.newCodeAnalyzer&&Ve.add(null,"Analyze CPU Timing","glyphicon-time",ku),A.setRecorder&&A.advance&&Lu(),A.showHelp){let{li:i,a}=Xa("help__"+ie,qa+" Help");$("#help_menu").append(i),$(a).click(()=>window.open(A.showHelp(),"_8bws_help"))}let l=A.getToolForFilename(st()),t=gl[l];if(t){let{li:i,a}=Xa("help__"+l,l+" Help");$("#help_menu").append(i),$(a).click(()=>window.open(t,"_8bws_help"))}}function Lu(){var l=$("#replayslider"),t=$("#clockslider"),i=$("#replay_frame"),a=$("#replay_clock");A.advanceFrameClock||$("#clockdiv").hide();var u=()=>{i.text(at.lastSeekFrame+""),a.text(at.lastSeekStep+"")},d=b=>{Vt();var D=parseInt(l.val().toString()),W=parseInt(t.val().toString());at.loadFrame(D,W)>=0&&(t.attr("min",0),t.attr("max",at.lastStepCount),u(),Tn(A.saveState()))},m=b=>{Vt(),at.loadFrame(b)>=0&&(l.val(b),u(),Tn(A.saveState()))},y=b=>{Vt();var D=parseInt(l.val().toString());at.loadFrame(D,b)>=0&&(t.val(b),u(),Tn(A.saveState()))};at.callbackStateChanged=()=>{l.attr("min",0),l.attr("max",at.numFrames()),l.val(at.currentFrame()),t.val(at.currentStep()),u(),Ci(A.saveState())},l.on("input",d),t.on("input",d),$("#replay_min").click(()=>{m(1)}),$("#replay_max").click(()=>{m(at.numFrames())}),$("#replay_back").click(()=>{m(parseInt(l.val().toString())-1)}),$("#replay_fwd").click(()=>{m(parseInt(l.val().toString())+1)}),$("#clock_back").click(()=>{y(parseInt(t.val().toString())-1)}),$("#clock_fwd").click(()=>{y(parseInt(t.val().toString())+1)}),$("#replay_bar").show(),Ve.add("ctrl+alt+0","Start/Stop Replay Recording","glyphicon-record",Pu).prop("id","dbg_record")}function Ru(){try{var l=window.screen.orientation||window.screen.msOrientation||window.screen.mozOrientation||null;if(l){if(l.type.indexOf("landscape")!==-1)return!0;if(l.type.indexOf("portrait")!==-1)return!1}if("orientation"in window){var t=window.orientation;if(t===0||t===180)return!1;if(t===90||t===270)return!0}}catch(i){}return window.innerWidth>window.innerHeight}async function Iu(){if(yr.shouldCompleteTour()){await Dt("lib/bootstrap-tourist.js");var l=ie.startsWith("vcs"),t=[{element:"#platformsMenuButton",placement:"right",title:"Platform Selector",content:`You're currently on the "<b>`+ie+'</b>" platform. You can choose a different one from the menu.'},{element:"#preset_select",title:"Project Selector",content:"You can choose different code examples, create your own files, or import projects from GitHub."},{element:"#workspace",title:"Code Editor",content:l?"Type your 6502 assembly code into the editor, and it'll be assembled in real-time.":"Type your source code into the editor, and it'll be compiled in real-time."},{element:"#emulator",placement:"left",title:"Emulator",content:"We'll load your compiled code into the emulator whenever you make changes."},{element:"#debug_bar",placement:"bottom",title:"Debug Tools",content:"Use these buttons to set breakpoints, single step through code, pause/resume, and use debugging tools."},{element:"#dropdownMenuButton",title:"Main Menu",content:"Click the menu to create new files, download your code, or share your work with others."},{element:"#sidebar",title:"Sidebar",content:"Pull right to expose the sidebar. It lets you switch between source files, view assembly listings, and use other tools like Disassembler, Memory Browser, and Asset Editor."}];Ru()||t.unshift({element:"#controls_top",placement:"bottom",title:"Portrait mode detected",content:"This site works best on desktop browsers. For best results, rotate your device to landscape orientation."}),window.location.host.endsWith("8bitworkshop.com")&&(t.unshift({element:"#dropdownMenuButton",placement:"right",title:"Cookie Consent",content:'Before we start, we should tell you that this website stores cookies and other data in your browser. You can review our <a href="/privacy.html" target="_new">privacy policy</a>.'}),t.push({element:"#booksMenuButton",placement:"left",title:"Books",content:"Get some books that explain how to program all of this stuff, and write some games!"})),vi&&(t.unshift({element:"#dropdownMenuButton",placement:"right",title:"Developer Analytics",content:"BTW, we send stack traces to sentry.io when exceptions are thrown. Hope that's ok."}),t.unshift({element:"#dropdownMenuButton",placement:"right",title:"Welcome to 8bitworkshop Desktop!",content:'The directory "~/8bitworkshop" contains all of your file edits and built ROM images. You can create new projects under the platform directories (e.g. "c64/myproject")'}));var i=new Tour({autoscroll:!1,steps:t,onEnd:()=>{yr.completedTour()}});setTimeout(()=>{i.start()},2500)}}function kn(l){var t=(l.message||l.error||l)+"";if(t.indexOf("QuotaExceededError")>=0)Ya(!1,!1);else{var i=l.error||l.reason;i!=null&&i instanceof ua&&Mu(i)}}function Mu(l){console.log("haltEmulation"),Vt(),Qu(l)}function Nu(){window.addEventListener("error",kn),window.addEventListener("unhandledrejection",kn)}function So(){window.removeEventListener("error",kn),window.removeEventListener("unhandledrejection",kn)}function Rr(l){So(),l?window.location.replace("?"+$.param(ee)):window.location.href="?"+$.param(ee)}function Pn(){ie&&(ee.platform=ie),delete ee[""],history.replaceState({},"","?"+$.param(ee))}function Ou(){var l=!1;document.addEventListener("visibilitychange",()=>{document.visibilityState=="hidden"&&A&&A.isRunning()?(Vt(),l=!0):document.visibilityState=="visible"&&l&&(It(),l=!1)}),$(window).on("focus",()=>{l&&(It(),l=!1)}),$(window).on("blur",()=>{A&&A.isRunning()&&(Vt(),l=!0)}),$(window).on("orientationchange",()=>{A&&A.resize&&setTimeout(A.resize.bind(A),200)})}function $u(){var l=$(document).find(".emucontrols-"+Ar(ie));ie.endsWith(".mame")&&l.show();var t=$("#emulator").find("canvas");t&&(t.on("focus",()=>{A.isRunning()&&(l.fadeIn(200),A.pause(),A.resume())}),t.on("blur",()=>{l.fadeOut(200)}))}function Wu(){window.ga&&($(".dropdown-item").click(l=>{l.target&&l.target.id&&wi("menu",l.target.id)}),ga("send","pageview",location.pathname+"?platform="+ie+(Be?"&repo="+Be:"&file="+ee.file)))}async function ju(){if(!la[ie])throw Error("Invalid platform '"+ie+"'.");let l=$("#emuscreen")[0],t=oa(ee.options||"");if(A=new la[ie](l,t),Vu(),at=new Ls(A),xn=A.getPresets?A.getPresets():[],!ee.file){var i=yr.getLastPreset(),a=i||(Be?null:xn[0].id);ee.file=a||"DEFAULT",a||Ee("There is no default main file for this project. Try selecting one from the pulldown.")}ie=="vcs"&&ee.file.startsWith("examples/")&&!ee.file.endsWith(".a")&&(ee.file+=".a"),Pn(),Nu(),Wu(),await A.start(),await ou(),await xl(),await Sl(ee.file),A.sourceFileFetch=u=>pe.filedata[u],Du(),Ou(),$u(),nt?Bu():(_i(),Hu(),Iu()),_o()}function Bu(){$("#dropdownMenuButton").hide(),$("#platformsMenuButton").hide(),$("#booksMenuButton").hide()}function Hu(){Ar(ie)=="nes"?$(".book-nes").addClass("book-active"):Ar(ie)=="vcs"?$(".book-vcs").addClass("book-active"):Ar(ie)=="verilog"?$(".book-verilog").addClass("book-active"):A.getToolForFilename(st())=="sdcc"&&$(".book-arcade").addClass("book-active")}function _o(){setTimeout(()=>{$("#controls_dynamic").css("visibility","inherit")},250)}function Uu(){var l="workspace-split3-"+ie;nt&&(l="embed-"+l);var t;ie.startsWith("vcs")?t=[0,50,50]:nt||fi?t=[0,55,45]:t=[12,44,44];var i=St&&localStorage.getItem(l);if(i)try{t=JSON.parse(i)}catch(u){console.log(u)}var a=hl(["#sidebar","#workspace","#emulator"],{sizes:t,minSize:[0,250,250],onDrag:()=>{A&&A.resize&&A.resize()},onDragEnd:()=>{St&&localStorage.setItem(l,JSON.stringify(a.getSizes())),ge&&ge.resize()}})}function zu(l){let t=Fr(ee.ignore)||nt;Oe(!0),nn(l,async i=>{if(i){var a=Et(l);console.log("Importing "+i.length+" bytes as "+a);try{var u=await Xe.getItem(a);Oe(!1),u!=null&&t||(u==null||confirm("Replace existing file '"+a+"'?"))&&await Xe.setItem(a,i),delete ee.importURL,ee.file=a,Pn(),Co()}finally{Oe(!1)}}else Ee("Could not load source code from URL: "+l),Oe(!1)},"text")}async function qu(){var l=Fr(ee.ignore),t=Fr(ee.force);nt?l=!t:t=!1;for(var i=0;i<20;i++){let u=ee["file"+i+"_name"],d=ee["file"+i+"_data"];if(u==null||d==null)break;var a=await Xe.getItem(u);if(!(l&&a)){let m=d;ee["file"+i+"_type"]=="binary"&&(m=Zi(atob(m))),(!a||t||confirm("Replace existing file '"+u+"'?"))&&await Xe.setItem(u,m)}i==0&&(ee.file=u),delete ee["file"+i+"_name"],delete ee["file"+i+"_data"],delete ee["file"+i+"_type"]}delete ee.ignore,delete ee.force,Pn()}function Vu(){var l=A.getPlatformName&&A.getPlatformName(),t=$('a[href="?platform='+ie+'"]');t.length&&(t.addClass("dropdown-item-checked"),l=l||t.text()||l),qa=l||ie,$(".platform_name").text(qa)}function Gu(){if(ie=ee.platform||yr.getLastPlatformID(),Be=ee.repo,!ee.repo&&!ee.file&&(Be=yr.getLastRepoID(ie)),St&&Be&&Be!=="/"){var l=ci()[Be];l&&(console.log(ie,ee,l),ee.repo=Be,l.platform_id&&!ee.platform&&(ee.platform=ie=l.platform_id),l.mainPath&&!ee.file&&(ee.file=l.mainPath))}else Be="",delete ee.repo;ie||(nt&&ml("The 'platform' must be specified when embed=1"),ie=ee.platform="vcs")}async function To(){if(ee.githubURL){Za(ee.githubURL,!0);return}if(Gu(),Uu(),br=Be||gt(ie),nt&&(br=(document.referrer||document.location.href)+br),Xe=ba(br),ee.importURL){zu(ee.importURL);return}ee.file0_name&&await qu(),Co()}async function Co(){try{var l=await Rs(Ar(ie));console.log("starting platform",ie),await ju(),document.title=document.title+" ["+ie+"] - "+(Be?"["+Be+"] - ":"")+pe.mainPath}catch(t){console.log(t),Ee('Platform "'+ie+'" failed to load.')}finally{_o()}}var as="__use_https";function ko(l){document.cookie=as+"="+l+";domain=8bitworkshop.com;path=/;max-age=315360000"}function Yu(){var l=lo(as);if(typeof l=="string")return!!l;var t=St&&!localStorage.getItem("__lastplatform")?1:0;return ko(t),!!t}function Xu(){bootbox.confirm('<p>Do you want to force the browser to use HTTPS from now on?</p><p>WARNING: This will make all of your local files unavailable, so you should "Download All Changes" first for each platform where you have done work.</p><p>You can go back to HTTP by setting the "'+as+'" cookie to 0.</p>',l=>{l&&(ko(1),Po())})}function Po(){window.location.protocol=="http:"&&window.location.host=="8bitworkshop.com"&&(Yu()?(So(),window.location.replace(window.location.href.replace(/^http:/,"https:"))):$("#item_switch_https").click(Xu).show())}Po();function Ef(l,t){A.writeFile(l,t)}function Sf(l){return A.readFile(l)}function _f(){return A.saveState()}function Qu(l){var t=l&&l.message||t;go(l,t),ge.refresh(!1),A.saveState&&Ci(A.saveState())}async function Tf(l){var t=pe.filedata[l];t!=null&&(ge.updateFile(l,await alternateLocalFilesystem.getFileData(l)),console.log("updating file",l))}function Ju(){if(vi&&Ye instanceof Uint8Array){var l=pt(st()),t=A.getROMExtension&&A.getROMExtension(Ye)||"-"+gt(ie)+".bin";alternateLocalFilesystem.setFileData(`bin/${l}${t}`,Ye)}}function Cf(l){var t=ge.getActive();if(t instanceof di){var i=t.editor.getSearchCursor(l);i.findNext()&&t.editor.setSelection(i.pos.to,i.pos.from)}}function Ku(){let l=!1;new IntersectionObserver((i,a)=>{for(var u of i)u.isIntersecting&&!l&&(To(),l=!0),u.intersectionRatio==0&&ts()&&A.isRunning()&&Vt(),u.intersectionRatio>0&&ts()&&!A.isRunning()&&It()},{}).observe($("#emulator")[0])}typeof process=="undefined"&&(nt&&typeof IntersectionObserver=="function"?Ku():To());export{Hs as a,ee as b,ie as c,br as d,Be as e,A as f,pe as g,ge as h,ut as i,er as j,Lt as k,hi as l,ki as m,Cn as n,Mu as o,Uu as p,Gu as q,To as r,Ef as s,Sf as t,_f as u,Qu as v,Tf as w,Cf as x};
/*!
localForage -- Offline Storage, Improved
Version 1.10.0
https://localforage.github.io/localForage
(c) 2013-2017 Mozilla, Apache License 2.0
*/
/*!
* jQuery JavaScript Library v3.6.3
* https://jquery.com/
*
* Includes Sizzle.js
* https://sizzlejs.com/
*
* Copyright OpenJS Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*
* Date: 2022-12-20T21:28Z
*/
//# sourceMappingURL=chunk-VD7T557T.js.map