1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-06-10 21:29:33 +00:00
8bitworkshop/gen/chunk-UF5OFU7K.js

49 lines
222 KiB
JavaScript

import{a as tn,b as Ko,c as Zo}from"./chunk-PP6TWFIY.js";import{a as Fs}from"./chunk-5SHCNQ2O.js";import{a as Ls,b as Rs,c as el}from"./chunk-FNKLYD54.js";import{D as ca,J as fa,l as Z,u as As,v as Ds}from"./chunk-YLYWUMYM.js";import{D as Lt,E as oa,F as Rr,I as Cs,J as la,S as ua,U as ks,a as Ft,aa as en,b as ni,ba as Ps,ca as ai,d as wt,e as sa,f as pt,g as Fe,j as Es,l as Xi,m as Qi,n as Ji,o as vr,p as Ss,s as Ki,v as _s,w as Ts,x as Zi,y as gt,z as Lr}from"./chunk-ATS7PSQG.js";import{b as ii,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,r;return function a(u,d,m){function y(W,fe){if(!d[W]){if(!u[W]){var z=typeof ii=="function"&&ii;if(!fe&&z)return z(W,!0);if(b)return b(W,!0);var H=new Error("Cannot find module '"+W+"'");throw H.code="MODULE_NOT_FOUND",H}var G=d[W]={exports:{}};u[W][0].call(G.exports,function(de){var K=u[W][1][de];return y(K||de)},G,G.exports,a,u,d,m)}return d[W].exports}for(var b=typeof ii=="function"&&ii,L=0;L<m.length;L++)y(m[L]);return y}({1:[function(a,u,d){(function(m){"use strict";var y=m.MutationObserver||m.WebKitMutationObserver,b;if(y){var L=0,W=new y(de),fe=m.document.createTextNode("");W.observe(fe,{characterData:!0}),b=function(){fe.data=L=++L%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 ye=m.document.createElement("script");ye.onreadystatechange=function(){de(),ye.onreadystatechange=null,ye.parentNode.removeChild(ye),ye=null},m.document.documentElement.appendChild(ye)}:b=function(){setTimeout(de,0)};var H,G=[];function de(){H=!0;for(var ye,Pe,be=G.length;be;){for(Pe=G,G=[],ye=-1;++ye<be;)Pe[ye]();be=G.length}H=!1}u.exports=K;function K(ye){G.push(ye)===1&&!H&&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={},L=["REJECTED"],W=["FULFILLED"],fe=["PENDING"];u.exports=z;function z(Y){if(typeof Y!="function")throw new TypeError("resolver must be a function");this.state=fe,this.queue=[],this.outcome=void 0,Y!==y&&K(this,Y)}z.prototype.catch=function(Y){return this.then(null,Y)},z.prototype.then=function(Y,ae){if(typeof Y!="function"&&this.state===W||typeof ae!="function"&&this.state===L)return this;var se=new this.constructor(y);if(this.state!==fe){var Te=this.state===W?Y:ae;G(se,Te,this.outcome)}else this.queue.push(new H(se,Y,ae));return se};function H(Y,ae,se){this.promise=Y,typeof ae=="function"&&(this.onFulfilled=ae,this.callFulfilled=this.otherCallFulfilled),typeof se=="function"&&(this.onRejected=se,this.callRejected=this.otherCallRejected)}H.prototype.callFulfilled=function(Y){b.resolve(this.promise,Y)},H.prototype.otherCallFulfilled=function(Y){G(this.promise,this.onFulfilled,Y)},H.prototype.callRejected=function(Y){b.reject(this.promise,Y)},H.prototype.otherCallRejected=function(Y){G(this.promise,this.onRejected,Y)};function G(Y,ae,se){m(function(){var Te;try{Te=ae(se)}catch(He){return b.reject(Y,He)}Te===Y?b.reject(Y,new TypeError("Cannot resolve promise with itself")):b.resolve(Y,Te)})}b.resolve=function(Y,ae){var se=ye(de,ae);if(se.status==="error")return b.reject(Y,se.value);var Te=se.value;if(Te)K(Y,Te);else{Y.state=W,Y.outcome=ae;for(var He=-1,Ie=Y.queue.length;++He<Ie;)Y.queue[He].callFulfilled(ae)}return Y},b.reject=function(Y,ae){Y.state=L,Y.outcome=ae;for(var se=-1,Te=Y.queue.length;++se<Te;)Y.queue[se].callRejected(ae);return Y};function de(Y){var ae=Y&&Y.then;if(Y&&(typeof Y=="object"||typeof Y=="function")&&typeof ae=="function")return function(){ae.apply(Y,arguments)}}function K(Y,ae){var se=!1;function Te(Xe){se||(se=!0,b.reject(Y,Xe))}function He(Xe){se||(se=!0,b.resolve(Y,Xe))}function Ie(){ae(He,Te)}var tt=ye(Ie);tt.status==="error"&&Te(tt.value)}function ye(Y,ae){var se={};try{se.value=Y(ae),se.status="success"}catch(Te){se.status="error",se.value=Te}return se}z.resolve=Pe;function Pe(Y){return Y instanceof this?Y:b.resolve(new this(y),Y)}z.reject=be;function be(Y){var ae=new this(y);return b.reject(ae,Y)}z.all=_e;function _e(Y){var ae=this;if(Object.prototype.toString.call(Y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var se=Y.length,Te=!1;if(!se)return this.resolve([]);for(var He=new Array(se),Ie=0,tt=-1,Xe=new this(y);++tt<se;)mt(Y[tt],tt);return Xe;function mt(nr,Sr){ae.resolve(nr).then(Or,function(Yt){Te||(Te=!0,b.reject(Xe,Yt))});function Or(Yt){He[Sr]=Yt,++Ie===se&&!Te&&(Te=!0,b.resolve(Xe,He))}}}z.race=o;function o(Y){var ae=this;if(Object.prototype.toString.call(Y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var se=Y.length,Te=!1;if(!se)return this.resolve([]);for(var He=-1,Ie=new this(y);++He<se;)tt(Y[He]);return Ie;function tt(Xe){ae.resolve(Xe).then(function(mt){Te||(Te=!0,b.resolve(Ie,mt))},function(mt){Te||(Te=!0,b.reject(Ie,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 L=b();function W(){try{if(!L||!L.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(T){if(T.name!=="TypeError")throw T;for(var v=typeof BlobBuilder!="undefined"?BlobBuilder:typeof MSBlobBuilder!="undefined"?MSBlobBuilder:typeof MozBlobBuilder!="undefined"?MozBlobBuilder:WebKitBlobBuilder,_=new v,P=0;P<p.length;P+=1)_.append(p[P]);return _.getBlob(S.type)}}typeof Promise=="undefined"&&a(3);var z=Promise;function H(p,S){S&&p.then(function(v){S(null,v)},function(v){S(v)})}function G(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 ye="local-forage-detect-blob-support",Pe=void 0,be={},_e=Object.prototype.toString,o="readonly",Y="readwrite";function ae(p){for(var S=p.length,v=new ArrayBuffer(S),_=new Uint8Array(v),P=0;P<S;P++)_[P]=p.charCodeAt(P);return v}function se(p){return new z(function(S){var v=p.transaction(ye,Y),_=fe([""]);v.objectStore(ye).put(_,"key"),v.onabort=function(P){P.preventDefault(),P.stopPropagation(),S(!1)},v.oncomplete=function(){var P=navigator.userAgent.match(/Chrome\/(\d+)/),T=navigator.userAgent.match(/Edge\//);S(T||!P||parseInt(P[1],10)>=43)}}).catch(function(){return!1})}function Te(p){return typeof Pe=="boolean"?z.resolve(Pe):se(p).then(function(S){return Pe=S,Pe})}function He(p){var S=be[p.name],v={};v.promise=new z(function(_,P){v.resolve=_,v.reject=P}),S.deferredOperations.push(v),S.dbReady?S.dbReady=S.dbReady.then(function(){return v.promise}):S.dbReady=v.promise}function Ie(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],_=v.deferredOperations.pop();if(_)return _.reject(S),_.promise}function Xe(p,S){return new z(function(v,_){if(be[p.name]=be[p.name]||ar(),p.db)if(S)He(p),p.db.close();else return v(p.db);var P=[p.name];S&&P.push(p.version);var T=L.open.apply(L,P);S&&(T.onupgradeneeded=function(N){var U=T.result;try{U.createObjectStore(p.storeName),N.oldVersion<=1&&U.createObjectStore(ye)}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}}),T.onerror=function(N){N.preventDefault(),_(T.error)},T.onsuccess=function(){var N=T.result;N.onversionchange=function(U){U.target.close()},v(N),Ie(p)}})}function mt(p){return Xe(p,!1)}function nr(p){return Xe(p,!0)}function Sr(p,S){if(!p.db)return!0;var v=!p.db.objectStoreNames.contains(p.storeName),_=p.version<p.db.version,P=p.version>p.db.version;if(_&&(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),P||v){if(v){var T=p.db.version+1;T>p.version&&(p.version=T)}return!0}return!1}function Or(p){return new z(function(S,v){var _=new FileReader;_.onerror=v,_.onloadend=function(P){var T=btoa(P.target.result||"");S({__local_forage_encoded_blob:!0,data:T,type:p.type})},_.readAsBinaryString(p)})}function Yt(p){var S=ae(atob(p.data));return fe([S],{type:p.type})}function $r(p){return p&&p.__local_forage_encoded_blob}function vt(p){var S=this,v=S._initReady().then(function(){var _=be[S._dbInfo.name];if(_&&_.dbReady)return _.dbReady});return G(v,p,p),v}function Tn(p){He(p);for(var S=be[p.name],v=S.forages,_=0;_<v.length;_++){var P=v[_];P._dbInfo.db&&(P._dbInfo.db.close(),P._dbInfo.db=null)}return p.db=null,mt(p).then(function(T){return p.db=T,Sr(p)?nr(p):T}).then(function(T){p.db=S.db=T;for(var N=0;N<v.length;N++)v[N]._dbInfo.db=T}).catch(function(T){throw tt(p,T),T})}function Qe(p,S,v,_){_===void 0&&(_=1);try{var P=p.db.transaction(p.storeName,S);v(null,P)}catch(T){if(_>0&&(!p.db||T.name==="InvalidStateError"||T.name==="NotFoundError"))return z.resolve().then(function(){if(!p.db||T.name==="NotFoundError"&&!p.db.objectStoreNames.contains(p.storeName)&&p.version<=p.db.version)return p.db&&(p.version=p.db.version+1),nr(p)}).then(function(){return Tn(p).then(function(){Qe(p,S,v,_-1)})}).catch(v);v(T)}}function ar(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function Ti(p){var S=this,v={db:null};if(p)for(var _ in p)v[_]=p[_];var P=be[v.name];P||(P=ar(),be[v.name]=P),P.forages.push(S),S._initReady||(S._initReady=S.ready,S.ready=vt);var T=[];function N(){return z.resolve()}for(var U=0;U<P.forages.length;U++){var V=P.forages[U];V!==S&&T.push(V._initReady().catch(N))}var q=P.forages.slice(0);return z.all(T).then(function(){return v.db=P.db,mt(v)}).then(function(X){return v.db=X,Sr(v,S._defaultConfig.version)?nr(v):X}).then(function(X){v.db=P.db=X,S._dbInfo=v;for(var te=0;te<q.length;te++){var xe=q[te];xe!==S&&(xe._dbInfo.db=v.db,xe._dbInfo.version=v.version)}})}function Cn(p,S){var v=this;p=de(p);var _=new z(function(P,T){v.ready().then(function(){Qe(v._dbInfo,o,function(N,U){if(N)return T(N);try{var V=U.objectStore(v._dbInfo.storeName),q=V.get(p);q.onsuccess=function(){var X=q.result;X===void 0&&(X=null),$r(X)&&(X=Yt(X)),P(X)},q.onerror=function(){T(q.error)}}catch(X){T(X)}})}).catch(T)});return H(_,S),_}function Wr(p,S){var v=this,_=new z(function(P,T){v.ready().then(function(){Qe(v._dbInfo,o,function(N,U){if(N)return T(N);try{var V=U.objectStore(v._dbInfo.storeName),q=V.openCursor(),X=1;q.onsuccess=function(){var te=q.result;if(te){var xe=te.value;$r(xe)&&(xe=Yt(xe));var Ce=p(xe,te.key,X++);Ce!==void 0?P(Ce):te.continue()}else P()},q.onerror=function(){T(q.error)}}catch(te){T(te)}})}).catch(T)});return H(_,S),_}function _r(p,S,v){var _=this;p=de(p);var P=new z(function(T,N){var U;_.ready().then(function(){return U=_._dbInfo,_e.call(S)==="[object Blob]"?Te(U.db).then(function(V){return V?S:Or(S)}):S}).then(function(V){Qe(_._dbInfo,Y,function(q,X){if(q)return N(q);try{var te=X.objectStore(_._dbInfo.storeName);V===null&&(V=void 0);var xe=te.put(V,p);X.oncomplete=function(){V===void 0&&(V=null),T(V)},X.onabort=X.onerror=function(){var Ce=xe.error?xe.error:xe.transaction.error;N(Ce)}}catch(Ce){N(Ce)}})}).catch(N)});return H(P,v),P}function St(p,S){var v=this;p=de(p);var _=new z(function(P,T){v.ready().then(function(){Qe(v._dbInfo,Y,function(N,U){if(N)return T(N);try{var V=U.objectStore(v._dbInfo.storeName),q=V.delete(p);U.oncomplete=function(){P()},U.onerror=function(){T(q.error)},U.onabort=function(){var X=q.error?q.error:q.transaction.error;T(X)}}catch(X){T(X)}})}).catch(T)});return H(_,S),_}function kn(p){var S=this,v=new z(function(_,P){S.ready().then(function(){Qe(S._dbInfo,Y,function(T,N){if(T)return P(T);try{var U=N.objectStore(S._dbInfo.storeName),V=U.clear();N.oncomplete=function(){_()},N.onabort=N.onerror=function(){var q=V.error?V.error:V.transaction.error;P(q)}}catch(q){P(q)}})}).catch(P)});return H(v,p),v}function Pn(p){var S=this,v=new z(function(_,P){S.ready().then(function(){Qe(S._dbInfo,o,function(T,N){if(T)return P(T);try{var U=N.objectStore(S._dbInfo.storeName),V=U.count();V.onsuccess=function(){_(V.result)},V.onerror=function(){P(V.error)}}catch(q){P(q)}})}).catch(P)});return H(v,p),v}function An(p,S){var v=this,_=new z(function(P,T){if(p<0){P(null);return}v.ready().then(function(){Qe(v._dbInfo,o,function(N,U){if(N)return T(N);try{var V=U.objectStore(v._dbInfo.storeName),q=!1,X=V.openKeyCursor();X.onsuccess=function(){var te=X.result;if(!te){P(null);return}p===0||q?P(te.key):(q=!0,te.advance(p))},X.onerror=function(){T(X.error)}}catch(te){T(te)}})}).catch(T)});return H(_,S),_}function bt(p){var S=this,v=new z(function(_,P){S.ready().then(function(){Qe(S._dbInfo,o,function(T,N){if(T)return P(T);try{var U=N.objectStore(S._dbInfo.storeName),V=U.openKeyCursor(),q=[];V.onsuccess=function(){var X=V.result;if(!X){_(q);return}q.push(X.key),X.continue()},V.onerror=function(){P(V.error)}}catch(X){P(X)}})}).catch(P)});return H(v,p),v}function sr(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 _=this,P;if(!p.name)P=z.reject("Invalid arguments");else{var T=p.name===v.name&&_._dbInfo.db,N=T?z.resolve(_._dbInfo.db):mt(p).then(function(U){var V=be[p.name],q=V.forages;V.db=U;for(var X=0;X<q.length;X++)q[X]._dbInfo.db=U;return U});p.storeName?P=N.then(function(U){if(!!U.objectStoreNames.contains(p.storeName)){var V=U.version+1;He(p);var q=be[p.name],X=q.forages;U.close();for(var te=0;te<X.length;te++){var xe=X[te];xe._dbInfo.db=null,xe._dbInfo.version=V}var Ce=new z(function(Se,We){var Me=L.open(p.name,V);Me.onerror=function(at){var Zt=Me.result;Zt.close(),We(at)},Me.onupgradeneeded=function(){var at=Me.result;at.deleteObjectStore(p.storeName)},Me.onsuccess=function(){var at=Me.result;at.close(),Se(at)}});return Ce.then(function(Se){q.db=Se;for(var We=0;We<X.length;We++){var Me=X[We];Me._dbInfo.db=Se,Ie(Me._dbInfo)}}).catch(function(Se){throw(tt(p,Se)||z.resolve()).catch(function(){}),Se})}}):P=N.then(function(U){He(p);var V=be[p.name],q=V.forages;U.close();for(var X=0;X<q.length;X++){var te=q[X];te._dbInfo.db=null}var xe=new z(function(Ce,Se){var We=L.deleteDatabase(p.name);We.onerror=function(){var Me=We.result;Me&&Me.close(),Se(We.error)},We.onblocked=function(){console.warn('dropInstance blocked for database "'+p.name+'" until all open connections are closed')},We.onsuccess=function(){var Me=We.result;Me&&Me.close(),Ce(Me)}});return xe.then(function(Ce){V.db=Ce;for(var Se=0;Se<q.length;Se++){var We=q[Se];Ie(We._dbInfo)}}).catch(function(Ce){throw(tt(p,Ce)||z.resolve()).catch(function(){}),Ce})})}return H(P,S),P}var or={_driver:"asyncStorage",_initStorage:Ti,_support:W(),iterate:Wr,getItem:Cn,setItem:_r,removeItem:St,clear:kn,length:Pn,key:An,keys:bt,dropInstance:sr};function le(){return typeof openDatabase=="function"}var $e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Dn="~~local_forage_type~",Ci=/^~~local_forage_type~([^~]+)~/,Tr="__lfsc__:",Cr=Tr.length,kr="arbf",Nt="blob",yt="si08",Dt="ui08",Ot="uic8",ki="si16",lr="si32",jr="ur16",Br="ui32",Pi="fl32",$t="fl64",Xt=Cr+kr.length,Hr=Object.prototype.toString;function Ur(p){var S=p.length*.75,v=p.length,_,P=0,T,N,U,V;p[p.length-1]==="="&&(S--,p[p.length-2]==="="&&S--);var q=new ArrayBuffer(S),X=new Uint8Array(q);for(_=0;_<v;_+=4)T=$e.indexOf(p[_]),N=$e.indexOf(p[_+1]),U=$e.indexOf(p[_+2]),V=$e.indexOf(p[_+3]),X[P++]=T<<2|N>>4,X[P++]=(N&15)<<4|U>>2,X[P++]=(U&3)<<6|V&63;return q}function Je(p){var S=new Uint8Array(p),v="",_;for(_=0;_<S.length;_+=3)v+=$e[S[_]>>2],v+=$e[(S[_]&3)<<4|S[_+1]>>4],v+=$e[(S[_+1]&15)<<2|S[_+2]>>6],v+=$e[S[_+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 Ke(p,S){var v="";if(p&&(v=Hr.call(p)),p&&(v==="[object ArrayBuffer]"||p.buffer&&Hr.call(p.buffer)==="[object ArrayBuffer]")){var _,P=Tr;p instanceof ArrayBuffer?(_=p,P+=kr):(_=p.buffer,v==="[object Int8Array]"?P+=yt:v==="[object Uint8Array]"?P+=Dt:v==="[object Uint8ClampedArray]"?P+=Ot:v==="[object Int16Array]"?P+=ki:v==="[object Uint16Array]"?P+=jr:v==="[object Int32Array]"?P+=lr:v==="[object Uint32Array]"?P+=Br:v==="[object Float32Array]"?P+=Pi:v==="[object Float64Array]"?P+=$t:S(new Error("Failed to get type for BinaryArray"))),S(P+Je(_))}else if(v==="[object Blob]"){var T=new FileReader;T.onload=function(){var N=Dn+p.type+"~"+Je(this.result);S(Tr+Nt+N)},T.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 zr(p){if(p.substring(0,Cr)!==Tr)return JSON.parse(p);var S=p.substring(Xt),v=p.substring(Cr,Xt),_;if(v===Nt&&Ci.test(S)){var P=S.match(Ci);_=P[1],S=S.substring(P[0].length)}var T=Ur(S);switch(v){case kr:return T;case Nt:return fe([T],{type:_});case yt:return new Int8Array(T);case Dt:return new Uint8Array(T);case Ot:return new Uint8ClampedArray(T);case ki:return new Int16Array(T);case jr:return new Uint16Array(T);case lr:return new Int32Array(T);case Br:return new Uint32Array(T);case Pi:return new Float32Array(T);case $t:return new Float64Array(T);default:throw new Error("Unkown type: "+v)}}var Vr={serialize:Ke,deserialize:zr,stringToBuffer:Ur,bufferToString:Je};function qr(p,S,v,_){p.executeSql("CREATE TABLE IF NOT EXISTS "+S.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],v,_)}function Ai(p){var S=this,v={db:null};if(p)for(var _ in p)v[_]=typeof p[_]!="string"?p[_].toString():p[_];var P=new z(function(T,N){try{v.db=openDatabase(v.name,String(v.version),v.description,v.size)}catch(U){return N(U)}v.db.transaction(function(U){qr(U,v,function(){S._dbInfo=v,T()},function(V,q){N(q)})},N)});return v.serializer=Vr,P}function rt(p,S,v,_,P,T){p.executeSql(v,_,P,function(N,U){U.code===U.SYNTAX_ERR?N.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[S.storeName],function(V,q){q.rows.length?T(V,U):qr(V,S,function(){V.executeSql(v,_,P,T)},T)},T):T(N,U)},T)}function Qt(p,S){var v=this;p=de(p);var _=new z(function(P,T){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function(U){rt(U,N,"SELECT * FROM "+N.storeName+" WHERE key = ? LIMIT 1",[p],function(V,q){var X=q.rows.length?q.rows.item(0).value:null;X&&(X=N.serializer.deserialize(X)),P(X)},function(V,q){T(q)})})}).catch(T)});return H(_,S),_}function Fn(p,S){var v=this,_=new z(function(P,T){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function(U){rt(U,N,"SELECT * FROM "+N.storeName,[],function(V,q){for(var X=q.rows,te=X.length,xe=0;xe<te;xe++){var Ce=X.item(xe),Se=Ce.value;if(Se&&(Se=N.serializer.deserialize(Se)),Se=p(Se,Ce.key,xe+1),Se!==void 0){P(Se);return}}P()},function(V,q){T(q)})})}).catch(T)});return H(_,S),_}function Di(p,S,v,_){var P=this;p=de(p);var T=new z(function(N,U){P.ready().then(function(){S===void 0&&(S=null);var V=S,q=P._dbInfo;q.serializer.serialize(S,function(X,te){te?U(te):q.db.transaction(function(xe){rt(xe,q,"INSERT OR REPLACE INTO "+q.storeName+" (key, value) VALUES (?, ?)",[p,X],function(){N(V)},function(Ce,Se){U(Se)})},function(xe){if(xe.code===xe.QUOTA_ERR){if(_>0){N(Di.apply(P,[p,V,v,_-1]));return}U(xe)}})})}).catch(U)});return H(T,v),T}function Gr(p,S,v){return Di.apply(this,[p,S,v,1])}function Pr(p,S){var v=this;p=de(p);var _=new z(function(P,T){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function(U){rt(U,N,"DELETE FROM "+N.storeName+" WHERE key = ?",[p],function(){P()},function(V,q){T(q)})})}).catch(T)});return H(_,S),_}function Ln(p){var S=this,v=new z(function(_,P){S.ready().then(function(){var T=S._dbInfo;T.db.transaction(function(N){rt(N,T,"DELETE FROM "+T.storeName,[],function(){_()},function(U,V){P(V)})})}).catch(P)});return H(v,p),v}function Rn(p){var S=this,v=new z(function(_,P){S.ready().then(function(){var T=S._dbInfo;T.db.transaction(function(N){rt(N,T,"SELECT COUNT(key) as c FROM "+T.storeName,[],function(U,V){var q=V.rows.item(0).c;_(q)},function(U,V){P(V)})})}).catch(P)});return H(v,p),v}function In(p,S){var v=this,_=new z(function(P,T){v.ready().then(function(){var N=v._dbInfo;N.db.transaction(function(U){rt(U,N,"SELECT key FROM "+N.storeName+" WHERE id = ? LIMIT 1",[p+1],function(V,q){var X=q.rows.length?q.rows.item(0).key:null;P(X)},function(V,q){T(q)})})}).catch(T)});return H(_,S),_}function Fi(p){var S=this,v=new z(function(_,P){S.ready().then(function(){var T=S._dbInfo;T.db.transaction(function(N){rt(N,T,"SELECT key FROM "+T.storeName,[],function(U,V){for(var q=[],X=0;X<V.rows.length;X++)q.push(V.rows.item(X).key);_(q)},function(U,V){P(V)})})}).catch(P)});return H(v,p),v}function Mn(p){return new z(function(S,v){p.transaction(function(_){_.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(P,T){for(var N=[],U=0;U<T.rows.length;U++)N.push(T.rows.item(U).name);S({db:p,storeNames:N})},function(P,T){v(T)})},function(_){v(_)})})}function Nn(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 _=this,P;return p.name?P=new z(function(T){var N;p.name===v.name?N=_._dbInfo.db:N=openDatabase(p.name,"","",0),p.storeName?T({db:N,storeNames:[p.storeName]}):T(Mn(N))}).then(function(T){return new z(function(N,U){T.db.transaction(function(V){function q(Ce){return new z(function(Se,We){V.executeSql("DROP TABLE IF EXISTS "+Ce,[],function(){Se()},function(Me,at){We(at)})})}for(var X=[],te=0,xe=T.storeNames.length;te<xe;te++)X.push(q(T.storeNames[te]));z.all(X).then(function(){N()}).catch(function(Ce){U(Ce)})},function(V){U(V)})})}):P=z.reject("Invalid arguments"),H(P,S),P}var Li={_driver:"webSQLStorage",_initStorage:Ai,_support:le(),iterate:Fn,getItem:Qt,setItem:Gr,removeItem:Pr,clear:Ln,length:Rn,key:In,keys:Fi,dropInstance:Nn};function On(){try{return typeof localStorage!="undefined"&&"setItem"in localStorage&&!!localStorage.setItem}catch(p){return!1}}function Wt(p,S){var v=p.name+"/";return p.storeName!==S.storeName&&(v+=p.storeName+"/"),v}function Ri(){var p="_localforage_support_test";try{return localStorage.setItem(p,!0),localStorage.removeItem(p),!1}catch(S){return!0}}function Yr(){return!Ri()||localStorage.length>0}function Ar(p){var S=this,v={};if(p)for(var _ in p)v[_]=p[_];return v.keyPrefix=Wt(p,S._defaultConfig),Yr()?(S._dbInfo=v,v.serializer=Vr,z.resolve()):z.reject()}function Ii(p){var S=this,v=S.ready().then(function(){for(var _=S._dbInfo.keyPrefix,P=localStorage.length-1;P>=0;P--){var T=localStorage.key(P);T.indexOf(_)===0&&localStorage.removeItem(T)}});return H(v,p),v}function $n(p,S){var v=this;p=de(p);var _=v.ready().then(function(){var P=v._dbInfo,T=localStorage.getItem(P.keyPrefix+p);return T&&(T=P.serializer.deserialize(T)),T});return H(_,S),_}function ur(p,S){var v=this,_=v.ready().then(function(){for(var P=v._dbInfo,T=P.keyPrefix,N=T.length,U=localStorage.length,V=1,q=0;q<U;q++){var X=localStorage.key(q);if(X.indexOf(T)===0){var te=localStorage.getItem(X);if(te&&(te=P.serializer.deserialize(te)),te=p(te,X.substring(N),V++),te!==void 0)return te}}});return H(_,S),_}function Mi(p,S){var v=this,_=v.ready().then(function(){var P=v._dbInfo,T;try{T=localStorage.key(p)}catch(N){T=null}return T&&(T=T.substring(P.keyPrefix.length)),T});return H(_,S),_}function Ni(p){var S=this,v=S.ready().then(function(){for(var _=S._dbInfo,P=localStorage.length,T=[],N=0;N<P;N++){var U=localStorage.key(N);U.indexOf(_.keyPrefix)===0&&T.push(U.substring(_.keyPrefix.length))}return T});return H(v,p),v}function Oi(p){var S=this,v=S.keys().then(function(_){return _.length});return H(v,p),v}function $i(p,S){var v=this;p=de(p);var _=v.ready().then(function(){var P=v._dbInfo;localStorage.removeItem(P.keyPrefix+p)});return H(_,S),_}function Wn(p,S,v){var _=this;p=de(p);var P=_.ready().then(function(){S===void 0&&(S=null);var T=S;return new z(function(N,U){var V=_._dbInfo;V.serializer.serialize(S,function(q,X){if(X)U(X);else try{localStorage.setItem(V.keyPrefix+p,q),N(T)}catch(te){(te.name==="QuotaExceededError"||te.name==="NS_ERROR_DOM_QUOTA_REACHED")&&U(te),U(te)}})})});return H(P,v),P}function Xr(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 _=this,P;return p.name?P=new z(function(T){p.storeName?T(Wt(p,_._defaultConfig)):T(p.name+"/")}).then(function(T){for(var N=localStorage.length-1;N>=0;N--){var U=localStorage.key(N);U.indexOf(T)===0&&localStorage.removeItem(U)}}):P=z.reject("Invalid arguments"),H(P,S),P}var jn={_driver:"localStorageWrapper",_initStorage:Ar,_support:On(),iterate:ur,getItem:$n,setItem:Wn,removeItem:$i,clear:Ii,length:Oi,key:Mi,keys:Ni,dropInstance:Xr},Wi=function(S,v){return S===v||typeof S=="number"&&typeof v=="number"&&isNaN(S)&&isNaN(v)},Bn=function(S,v){for(var _=S.length,P=0;P<_;){if(Wi(S[P],v))return!0;P++}return!1},Qr=Array.isArray||function(p){return Object.prototype.toString.call(p)==="[object Array]"},Jt={},Dr={},jt={INDEXEDDB:or,WEBSQL:Li,LOCALSTORAGE:jn},Ze=[jt.INDEXEDDB._driver,jt.WEBSQL._driver,jt.LOCALSTORAGE._driver],_t=["dropInstance"],Kt=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(_t),Hn={description:"",driver:Ze.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Un(p,S){p[S]=function(){var v=arguments;return p.ready().then(function(){return p[S].apply(p,v)})}}function cr(){for(var p=1;p<arguments.length;p++){var S=arguments[p];if(S)for(var v in S)S.hasOwnProperty(v)&&(Qr(S[v])?arguments[0][v]=S[v].slice():arguments[0][v]=S[v])}return arguments[0]}var ji=function(){function p(S){y(this,p);for(var v in jt)if(jt.hasOwnProperty(v)){var _=jt[v],P=_._driver;this[v]=P,Jt[P]||this.defineDriver(_)}this._defaultConfig=cr({},Hn),this._config=cr({},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 _ in v){if(_==="storeName"&&(v[_]=v[_].replace(/\W/g,"_")),_==="version"&&typeof v[_]!="number")return new Error("Database version must be a number.");this._config[_]=v[_]}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,_,P){var T=new z(function(N,U){try{var V=v._driver,q=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!v._driver){U(q);return}for(var X=Kt.concat("_initStorage"),te=0,xe=X.length;te<xe;te++){var Ce=X[te],Se=!Bn(_t,Ce);if((Se||v[Ce])&&typeof v[Ce]!="function"){U(q);return}}var We=function(){for(var Zt=function(Vn){return function(){var qn=new Error("Method "+Vn+" is not implemented by the current driver"),Bi=z.reject(qn);return H(Bi,arguments[arguments.length-1]),Bi}},Jr=0,zn=_t.length;Jr<zn;Jr++){var fr=_t[Jr];v[fr]||(v[fr]=Zt(fr))}};We();var Me=function(Zt){Jt[V]&&console.info("Redefining LocalForage driver: "+V),Jt[V]=v,Dr[V]=Zt,N()};"_support"in v?v._support&&typeof v._support=="function"?v._support().then(Me,U):Me(!!v._support):Me(!0)}catch(at){U(at)}});return G(T,_,P),T},p.prototype.driver=function(){return this._driver||null},p.prototype.getDriver=function(v,_,P){var T=Jt[v]?z.resolve(Jt[v]):z.reject(new Error("Driver not found."));return G(T,_,P),T},p.prototype.getSerializer=function(v){var _=z.resolve(Vr);return G(_,v),_},p.prototype.ready=function(v){var _=this,P=_._driverSet.then(function(){return _._ready===null&&(_._ready=_._initDriver()),_._ready});return G(P,v,v),P},p.prototype.setDriver=function(v,_,P){var T=this;Qr(v)||(v=[v]);var N=this._getSupportedDrivers(v);function U(){T._config.driver=T.driver()}function V(te){return T._extend(te),U(),T._ready=T._initStorage(T._config),T._ready}function q(te){return function(){var xe=0;function Ce(){for(;xe<te.length;){var Se=te[xe];return xe++,T._dbInfo=null,T._ready=null,T.getDriver(Se).then(V).catch(Ce)}U();var We=new Error("No available storage method found.");return T._driverSet=z.reject(We),T._driverSet}return Ce()}}var X=this._driverSet!==null?this._driverSet.catch(function(){return z.resolve()}):z.resolve();return this._driverSet=X.then(function(){var te=N[0];return T._dbInfo=null,T._ready=null,T.getDriver(te).then(function(xe){T._driver=xe._driver,U(),T._wrapLibraryMethodsWithReady(),T._initDriver=q(N)})}).catch(function(){U();var te=new Error("No available storage method found.");return T._driverSet=z.reject(te),T._driverSet}),G(this._driverSet,_,P),this._driverSet},p.prototype.supports=function(v){return!!Dr[v]},p.prototype._extend=function(v){cr(this,v)},p.prototype._getSupportedDrivers=function(v){for(var _=[],P=0,T=v.length;P<T;P++){var N=v[P];this.supports(N)&&_.push(N)}return _},p.prototype._wrapLibraryMethodsWithReady=function(){for(var v=0,_=Kt.length;v<_;v++)Un(this,Kt[v])},p.prototype.createInstance=function(v){return new p(v)},p}(),Fr=new ji;u.exports=Fr},{"3":3}]},{},[4])(4)})});var Ws=ws(($s,nn)=>{(function(l,t){"use strict";typeof nn=="object"&&typeof nn.exports=="object"?nn.exports=l.document?t(l,!0):function(r){if(!r.document)throw new Error("jQuery requires a window with a document");return t(r)}:t(l)})(typeof window!="undefined"?window:$s,function(l,t){"use strict";var r=[],a=Object.getPrototypeOf,u=r.slice,d=r.flat?function(e){return r.flat.call(e)}:function(e){return r.concat.apply([],e)},m=r.push,y=r.indexOf,b={},L=b.toString,W=b.hasOwnProperty,fe=W.toString,z=fe.call(Object),H={},G=function(i){return typeof i=="function"&&typeof i.nodeType!="number"&&typeof i.item!="function"},de=function(i){return i!=null&&i===i.window},K=l.document,ye={type:!0,src:!0,nonce:!0,noModule:!0};function Pe(e,i,n){n=n||K;var s,c,f=n.createElement("script");if(f.text=e,i)for(s in ye)c=i[s]||i.getAttribute&&i.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[L.call(e)]||"object":typeof e}var _e="3.6.0",o=function(e,i){return new o.fn.init(e,i)};o.fn=o.prototype={jquery:_e,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 i=o.merge(this.constructor(),e);return i.prevObject=this,i},each:function(e){return o.each(this,e)},map:function(e){return this.pushStack(o.map(this,function(i,n){return e.call(i,n,i)}))},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,i){return(i+1)%2}))},odd:function(){return this.pushStack(o.grep(this,function(e,i){return i%2}))},eq:function(e){var i=this.length,n=+e+(e<0?i:0);return this.pushStack(n>=0&&n<i?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:m,sort:r.sort,splice:r.splice},o.extend=o.fn.extend=function(){var e,i,n,s,c,f,h=arguments[0]||{},w=1,E=arguments.length,k=!1;for(typeof h=="boolean"&&(k=h,h=arguments[w]||{},w++),typeof h!="object"&&!G(h)&&(h={}),w===E&&(h=this,w--);w<E;w++)if((e=arguments[w])!=null)for(i in e)s=e[i],!(i==="__proto__"||h===s)&&(k&&s&&(o.isPlainObject(s)||(c=Array.isArray(s)))?(n=h[i],c&&!Array.isArray(n)?f=[]:!c&&!o.isPlainObject(n)?f={}:f=n,c=!1,h[i]=o.extend(k,f,s)):s!==void 0&&(h[i]=s));return h},o.extend({expando:"jQuery"+(_e+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var i,n;return!e||L.call(e)!=="[object Object]"?!1:(i=a(e),i?(n=W.call(i,"constructor")&&i.constructor,typeof n=="function"&&fe.call(n)===z):!0)},isEmptyObject:function(e){var i;for(i in e)return!1;return!0},globalEval:function(e,i,n){Pe(e,{nonce:i&&i.nonce},n)},each:function(e,i){var n,s=0;if(Y(e))for(n=e.length;s<n&&i.call(e[s],s,e[s])!==!1;s++);else for(s in e)if(i.call(e[s],s,e[s])===!1)break;return e},makeArray:function(e,i){var n=i||[];return e!=null&&(Y(Object(e))?o.merge(n,typeof e=="string"?[e]:e):m.call(n,e)),n},inArray:function(e,i,n){return i==null?-1:y.call(i,e,n)},merge:function(e,i){for(var n=+i.length,s=0,c=e.length;s<n;s++)e[c++]=i[s];return e.length=c,e},grep:function(e,i,n){for(var s,c=[],f=0,h=e.length,w=!n;f<h;f++)s=!i(e[f],f),s!==w&&c.push(e[f]);return c},map:function(e,i,n){var s,c,f=0,h=[];if(Y(e))for(s=e.length;f<s;f++)c=i(e[f],f,n),c!=null&&h.push(c);else for(f in e)c=i(e[f],f,n),c!=null&&h.push(c);return d(h)},guid:1,support:H}),typeof Symbol=="function"&&(o.fn[Symbol.iterator]=r[Symbol.iterator]),o.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,i){b["[object "+i+"]"]=i.toLowerCase()});function Y(e){var i=!!e&&"length"in e&&e.length,n=be(e);return G(e)||de(e)?!1:n==="array"||i===0||typeof i=="number"&&i>0&&i-1 in e}var ae=function(e){var i,n,s,c,f,h,w,E,k,R,j,F,I,ie,ve,ne,ze,Ue,ct,De="sizzle"+1*new Date,me=e.document,st=0,ke=0,je=Vi(),Zr=Vi(),Hi=Vi(),ft=Vi(),dr=function(g,x){return g===x&&(j=!0),0},hr={}.hasOwnProperty,ot=[],er=ot.pop,xt=ot.push,tr=ot.push,ds=ot.slice,pr=function(g,x){for(var C=0,M=g.length;C<M;C++)if(g[C]===x)return C;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]",gr="(?:\\\\[\\da-fA-F]{1,6}"+Ae+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",hs="\\["+Ae+"*("+gr+")(?:"+Ae+"*([*^$|!~]?=)"+Ae+`*(?:'((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)"|(`+gr+"))|)"+Ae+"*\\]",Kn=":("+gr+`)(?:\\((('((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)")|((?:\\\\.|[^\\\\()[\\]]|`+hs+")*)|.*)\\)|)",$o=new RegExp(Ae+"+","g"),Ui=new RegExp("^"+Ae+"+|((?:^|[^\\\\])(?:\\\\.)*)"+Ae+"+$","g"),Wo=new RegExp("^"+Ae+"*,"+Ae+"*"),ps=new RegExp("^"+Ae+"*([>+~]|"+Ae+")"+Ae+"*"),jo=new RegExp(Ae+"|>"),Bo=new RegExp(Kn),Ho=new RegExp("^"+gr+"$"),zi={ID:new RegExp("^#("+gr+")"),CLASS:new RegExp("^\\.("+gr+")"),TAG:new RegExp("^("+gr+"|[*])"),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")},Uo=/HTML$/i,zo=/^(?:input|select|textarea|button)$/i,Vo=/^h\d$/i,ei=/^[^{]+\{\s*\[native \w/,qo=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,Zn=/[+~]/,Bt=new RegExp("\\\\[\\da-fA-F]{1,6}"+Ae+"?|\\\\([^\\r\\n\\f])","g"),Ht=function(g,x){var C="0x"+g.slice(1)-65536;return x||(C<0?String.fromCharCode(C+65536):String.fromCharCode(C>>10|55296,C&1023|56320))},gs=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ms=function(g,x){return x?g==="\0"?"\uFFFD":g.slice(0,-1)+"\\"+g.charCodeAt(g.length-1).toString(16)+" ":"\\"+g},vs=function(){F()},Go=Gi(function(g){return g.disabled===!0&&g.nodeName.toLowerCase()==="fieldset"},{dir:"parentNode",next:"legend"});try{tr.apply(ot=ds.call(me.childNodes),me.childNodes),ot[me.childNodes.length].nodeType}catch(g){tr={apply:ot.length?function(x,C){xt.apply(x,ds.call(C))}:function(x,C){for(var M=x.length,A=0;x[M++]=C[A++];);x.length=M-1}}}function Le(g,x,C,M){var A,O,B,Q,J,ue,oe,he=x&&x.ownerDocument,we=x?x.nodeType:9;if(C=C||[],typeof g!="string"||!g||we!==1&&we!==9&&we!==11)return C;if(!M&&(F(x),x=x||I,ve)){if(we!==11&&(J=qo.exec(g)))if(A=J[1]){if(we===9)if(B=x.getElementById(A)){if(B.id===A)return C.push(B),C}else return C;else if(he&&(B=he.getElementById(A))&&ct(x,B)&&B.id===A)return C.push(B),C}else{if(J[2])return tr.apply(C,x.getElementsByTagName(g)),C;if((A=J[3])&&n.getElementsByClassName&&x.getElementsByClassName)return tr.apply(C,x.getElementsByClassName(A)),C}if(n.qsa&&!ft[g+" "]&&(!ne||!ne.test(g))&&(we!==1||x.nodeName.toLowerCase()!=="object")){if(oe=g,he=x,we===1&&(jo.test(g)||ps.test(g))){for(he=Zn.test(g)&&ta(x.parentNode)||x,(he!==x||!n.scope)&&((Q=x.getAttribute("id"))?Q=Q.replace(gs,ms):x.setAttribute("id",Q=De)),ue=h(g),O=ue.length;O--;)ue[O]=(Q?"#"+Q:":scope")+" "+qi(ue[O]);oe=ue.join(",")}try{return tr.apply(C,he.querySelectorAll(oe)),C}catch(Re){ft(g,!0)}finally{Q===De&&x.removeAttribute("id")}}}return E(g.replace(Ui,"$1"),x,C,M)}function Vi(){var g=[];function x(C,M){return g.push(C+" ")>s.cacheLength&&delete x[g.shift()],x[C+" "]=M}return x}function Tt(g){return g[De]=!0,g}function Ct(g){var x=I.createElement("fieldset");try{return!!g(x)}catch(C){return!1}finally{x.parentNode&&x.parentNode.removeChild(x),x=null}}function ea(g,x){for(var C=g.split("|"),M=C.length;M--;)s.attrHandle[C[M]]=x}function bs(g,x){var C=x&&g,M=C&&g.nodeType===1&&x.nodeType===1&&g.sourceIndex-x.sourceIndex;if(M)return M;if(C){for(;C=C.nextSibling;)if(C===x)return-1}return g?1:-1}function Yo(g){return function(x){var C=x.nodeName.toLowerCase();return C==="input"&&x.type===g}}function Xo(g){return function(x){var C=x.nodeName.toLowerCase();return(C==="input"||C==="button")&&x.type===g}}function ys(g){return function(x){return"form"in x?x.parentNode&&x.disabled===!1?"label"in x?"label"in x.parentNode?x.parentNode.disabled===g:x.disabled===g:x.isDisabled===g||x.isDisabled!==!g&&Go(x)===g:x.disabled===g:"label"in x?x.disabled===g:!1}}function mr(g){return Tt(function(x){return x=+x,Tt(function(C,M){for(var A,O=g([],C.length,x),B=O.length;B--;)C[A=O[B]]&&(C[A]=!(M[A]=C[A]))})})}function ta(g){return g&&typeof g.getElementsByTagName!="undefined"&&g}n=Le.support={},f=Le.isXML=function(g){var x=g&&g.namespaceURI,C=g&&(g.ownerDocument||g).documentElement;return!Uo.test(x||C&&C.nodeName||"HTML")},F=Le.setDocument=function(g){var x,C,M=g?g.ownerDocument||g:me;return M==I||M.nodeType!==9||!M.documentElement||(I=M,ie=I.documentElement,ve=!f(I),me!=I&&(C=I.defaultView)&&C.top!==C&&(C.addEventListener?C.addEventListener("unload",vs,!1):C.attachEvent&&C.attachEvent("onunload",vs)),n.scope=Ct(function(A){return ie.appendChild(A).appendChild(I.createElement("div")),typeof A.querySelectorAll!="undefined"&&!A.querySelectorAll(":scope fieldset div").length}),n.attributes=Ct(function(A){return A.className="i",!A.getAttribute("className")}),n.getElementsByTagName=Ct(function(A){return A.appendChild(I.createComment("")),!A.getElementsByTagName("*").length}),n.getElementsByClassName=ei.test(I.getElementsByClassName),n.getById=Ct(function(A){return ie.appendChild(A).id=De,!I.getElementsByName||!I.getElementsByName(De).length}),n.getById?(s.filter.ID=function(A){var O=A.replace(Bt,Ht);return function(B){return B.getAttribute("id")===O}},s.find.ID=function(A,O){if(typeof O.getElementById!="undefined"&&ve){var B=O.getElementById(A);return B?[B]:[]}}):(s.filter.ID=function(A){var O=A.replace(Bt,Ht);return function(B){var Q=typeof B.getAttributeNode!="undefined"&&B.getAttributeNode("id");return Q&&Q.value===O}},s.find.ID=function(A,O){if(typeof O.getElementById!="undefined"&&ve){var B,Q,J,ue=O.getElementById(A);if(ue){if(B=ue.getAttributeNode("id"),B&&B.value===A)return[ue];for(J=O.getElementsByName(A),Q=0;ue=J[Q++];)if(B=ue.getAttributeNode("id"),B&&B.value===A)return[ue]}return[]}}),s.find.TAG=n.getElementsByTagName?function(A,O){if(typeof O.getElementsByTagName!="undefined")return O.getElementsByTagName(A);if(n.qsa)return O.querySelectorAll(A)}:function(A,O){var B,Q=[],J=0,ue=O.getElementsByTagName(A);if(A==="*"){for(;B=ue[J++];)B.nodeType===1&&Q.push(B);return Q}return ue},s.find.CLASS=n.getElementsByClassName&&function(A,O){if(typeof O.getElementsByClassName!="undefined"&&ve)return O.getElementsByClassName(A)},ze=[],ne=[],(n.qsa=ei.test(I.querySelectorAll))&&(Ct(function(A){var O;ie.appendChild(A).innerHTML="<a id='"+De+"'></a><select id='"+De+"-\r\\' msallowcapture=''><option selected=''></option></select>",A.querySelectorAll("[msallowcapture^='']").length&&ne.push("[*^$]="+Ae+`*(?:''|"")`),A.querySelectorAll("[selected]").length||ne.push("\\["+Ae+"*(?:value|"+Jn+")"),A.querySelectorAll("[id~="+De+"-]").length||ne.push("~="),O=I.createElement("input"),O.setAttribute("name",""),A.appendChild(O),A.querySelectorAll("[name='']").length||ne.push("\\["+Ae+"*name"+Ae+"*="+Ae+`*(?:''|"")`),A.querySelectorAll(":checked").length||ne.push(":checked"),A.querySelectorAll("a#"+De+"+*").length||ne.push(".#.+[+~]"),A.querySelectorAll("\\\f"),ne.push("[\\r\\n\\f]")}),Ct(function(A){A.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var O=I.createElement("input");O.setAttribute("type","hidden"),A.appendChild(O).setAttribute("name","D"),A.querySelectorAll("[name=d]").length&&ne.push("name"+Ae+"*[*^$|!~]?="),A.querySelectorAll(":enabled").length!==2&&ne.push(":enabled",":disabled"),ie.appendChild(A).disabled=!0,A.querySelectorAll(":disabled").length!==2&&ne.push(":enabled",":disabled"),A.querySelectorAll("*,:x"),ne.push(",.*:")})),(n.matchesSelector=ei.test(Ue=ie.matches||ie.webkitMatchesSelector||ie.mozMatchesSelector||ie.oMatchesSelector||ie.msMatchesSelector))&&Ct(function(A){n.disconnectedMatch=Ue.call(A,"*"),Ue.call(A,"[s!='']:x"),ze.push("!=",Kn)}),ne=ne.length&&new RegExp(ne.join("|")),ze=ze.length&&new RegExp(ze.join("|")),x=ei.test(ie.compareDocumentPosition),ct=x||ei.test(ie.contains)?function(A,O){var B=A.nodeType===9?A.documentElement:A,Q=O&&O.parentNode;return A===Q||!!(Q&&Q.nodeType===1&&(B.contains?B.contains(Q):A.compareDocumentPosition&&A.compareDocumentPosition(Q)&16))}:function(A,O){if(O){for(;O=O.parentNode;)if(O===A)return!0}return!1},dr=x?function(A,O){if(A===O)return j=!0,0;var B=!A.compareDocumentPosition-!O.compareDocumentPosition;return B||(B=(A.ownerDocument||A)==(O.ownerDocument||O)?A.compareDocumentPosition(O):1,B&1||!n.sortDetached&&O.compareDocumentPosition(A)===B?A==I||A.ownerDocument==me&&ct(me,A)?-1:O==I||O.ownerDocument==me&&ct(me,O)?1:R?pr(R,A)-pr(R,O):0:B&4?-1:1)}:function(A,O){if(A===O)return j=!0,0;var B,Q=0,J=A.parentNode,ue=O.parentNode,oe=[A],he=[O];if(!J||!ue)return A==I?-1:O==I?1:J?-1:ue?1:R?pr(R,A)-pr(R,O):0;if(J===ue)return bs(A,O);for(B=A;B=B.parentNode;)oe.unshift(B);for(B=O;B=B.parentNode;)he.unshift(B);for(;oe[Q]===he[Q];)Q++;return Q?bs(oe[Q],he[Q]):oe[Q]==me?-1:he[Q]==me?1:0}),I},Le.matches=function(g,x){return Le(g,null,null,x)},Le.matchesSelector=function(g,x){if(F(g),n.matchesSelector&&ve&&!ft[x+" "]&&(!ze||!ze.test(x))&&(!ne||!ne.test(x)))try{var C=Ue.call(g,x);if(C||n.disconnectedMatch||g.document&&g.document.nodeType!==11)return C}catch(M){ft(x,!0)}return Le(x,I,null,[g]).length>0},Le.contains=function(g,x){return(g.ownerDocument||g)!=I&&F(g),ct(g,x)},Le.attr=function(g,x){(g.ownerDocument||g)!=I&&F(g);var C=s.attrHandle[x.toLowerCase()],M=C&&hr.call(s.attrHandle,x.toLowerCase())?C(g,x,!ve):void 0;return M!==void 0?M:n.attributes||!ve?g.getAttribute(x):(M=g.getAttributeNode(x))&&M.specified?M.value:null},Le.escape=function(g){return(g+"").replace(gs,ms)},Le.error=function(g){throw new Error("Syntax error, unrecognized expression: "+g)},Le.uniqueSort=function(g){var x,C=[],M=0,A=0;if(j=!n.detectDuplicates,R=!n.sortStable&&g.slice(0),g.sort(dr),j){for(;x=g[A++];)x===g[A]&&(M=C.push(A));for(;M--;)g.splice(C[M],1)}return R=null,g},c=Le.getText=function(g){var x,C="",M=0,A=g.nodeType;if(A){if(A===1||A===9||A===11){if(typeof g.textContent=="string")return g.textContent;for(g=g.firstChild;g;g=g.nextSibling)C+=c(g)}else if(A===3||A===4)return g.nodeValue}else for(;x=g[M++];)C+=c(x);return C},s=Le.selectors={cacheLength:50,createPseudo:Tt,match:zi,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]||Le.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]&&Le.error(g[0]),g},PSEUDO:function(g){var x,C=!g[6]&&g[2];return zi.CHILD.test(g[0])?null:(g[3]?g[2]=g[4]||g[5]||"":C&&Bo.test(C)&&(x=h(C,!0))&&(x=C.indexOf(")",C.length-x)-C.length)&&(g[0]=g[0].slice(0,x),g[2]=C.slice(0,x)),g.slice(0,3))}},filter:{TAG:function(g){var x=g.replace(Bt,Ht).toLowerCase();return g==="*"?function(){return!0}:function(C){return C.nodeName&&C.nodeName.toLowerCase()===x}},CLASS:function(g){var x=je[g+" "];return x||(x=new RegExp("(^|"+Ae+")"+g+"("+Ae+"|$)"))&&je(g,function(C){return x.test(typeof C.className=="string"&&C.className||typeof C.getAttribute!="undefined"&&C.getAttribute("class")||"")})},ATTR:function(g,x,C){return function(M){var A=Le.attr(M,g);return A==null?x==="!=":x?(A+="",x==="="?A===C:x==="!="?A!==C:x==="^="?C&&A.indexOf(C)===0:x==="*="?C&&A.indexOf(C)>-1:x==="$="?C&&A.slice(-C.length)===C:x==="~="?(" "+A.replace($o," ")+" ").indexOf(C)>-1:x==="|="?A===C||A.slice(0,C.length+1)===C+"-":!1):!0}},CHILD:function(g,x,C,M,A){var O=g.slice(0,3)!=="nth",B=g.slice(-4)!=="last",Q=x==="of-type";return M===1&&A===0?function(J){return!!J.parentNode}:function(J,ue,oe){var he,we,Re,ce,Ve,et,dt=O!==B?"nextSibling":"previousSibling",Ne=J.parentNode,ti=Q&&J.nodeName.toLowerCase(),ri=!oe&&!Q,ht=!1;if(Ne){if(O){for(;dt;){for(ce=J;ce=ce[dt];)if(Q?ce.nodeName.toLowerCase()===ti:ce.nodeType===1)return!1;et=dt=g==="only"&&!et&&"nextSibling"}return!0}if(et=[B?Ne.firstChild:Ne.lastChild],B&&ri){for(ce=Ne,Re=ce[De]||(ce[De]={}),we=Re[ce.uniqueID]||(Re[ce.uniqueID]={}),he=we[g]||[],Ve=he[0]===st&&he[1],ht=Ve&&he[2],ce=Ve&&Ne.childNodes[Ve];ce=++Ve&&ce&&ce[dt]||(ht=Ve=0)||et.pop();)if(ce.nodeType===1&&++ht&&ce===J){we[g]=[st,Ve,ht];break}}else if(ri&&(ce=J,Re=ce[De]||(ce[De]={}),we=Re[ce.uniqueID]||(Re[ce.uniqueID]={}),he=we[g]||[],Ve=he[0]===st&&he[1],ht=Ve),ht===!1)for(;(ce=++Ve&&ce&&ce[dt]||(ht=Ve=0)||et.pop())&&!((Q?ce.nodeName.toLowerCase()===ti:ce.nodeType===1)&&++ht&&(ri&&(Re=ce[De]||(ce[De]={}),we=Re[ce.uniqueID]||(Re[ce.uniqueID]={}),we[g]=[st,ht]),ce===J)););return ht-=A,ht===M||ht%M==0&&ht/M>=0}}},PSEUDO:function(g,x){var C,M=s.pseudos[g]||s.setFilters[g.toLowerCase()]||Le.error("unsupported pseudo: "+g);return M[De]?M(x):M.length>1?(C=[g,g,"",x],s.setFilters.hasOwnProperty(g.toLowerCase())?Tt(function(A,O){for(var B,Q=M(A,x),J=Q.length;J--;)B=pr(A,Q[J]),A[B]=!(O[B]=Q[J])}):function(A){return M(A,0,C)}):M}},pseudos:{not:Tt(function(g){var x=[],C=[],M=w(g.replace(Ui,"$1"));return M[De]?Tt(function(A,O,B,Q){for(var J,ue=M(A,null,Q,[]),oe=A.length;oe--;)(J=ue[oe])&&(A[oe]=!(O[oe]=J))}):function(A,O,B){return x[0]=A,M(x,null,B,C),x[0]=null,!C.pop()}}),has:Tt(function(g){return function(x){return Le(g,x).length>0}}),contains:Tt(function(g){return g=g.replace(Bt,Ht),function(x){return(x.textContent||c(x)).indexOf(g)>-1}}),lang:Tt(function(g){return Ho.test(g||"")||Le.error("unsupported lang: "+g),g=g.replace(Bt,Ht).toLowerCase(),function(x){var C;do if(C=ve?x.lang:x.getAttribute("xml:lang")||x.getAttribute("lang"))return C=C.toLowerCase(),C===g||C.indexOf(g+"-")===0;while((x=x.parentNode)&&x.nodeType===1);return!1}}),target:function(g){var x=e.location&&e.location.hash;return x&&x.slice(1)===g.id},root:function(g){return g===ie},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 x=g.nodeName.toLowerCase();return x==="input"&&!!g.checked||x==="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 Vo.test(g.nodeName)},input:function(g){return zo.test(g.nodeName)},button:function(g){var x=g.nodeName.toLowerCase();return x==="input"&&g.type==="button"||x==="button"},text:function(g){var x;return g.nodeName.toLowerCase()==="input"&&g.type==="text"&&((x=g.getAttribute("type"))==null||x.toLowerCase()==="text")},first:mr(function(){return[0]}),last:mr(function(g,x){return[x-1]}),eq:mr(function(g,x,C){return[C<0?C+x:C]}),even:mr(function(g,x){for(var C=0;C<x;C+=2)g.push(C);return g}),odd:mr(function(g,x){for(var C=1;C<x;C+=2)g.push(C);return g}),lt:mr(function(g,x,C){for(var M=C<0?C+x:C>x?x:C;--M>=0;)g.push(M);return g}),gt:mr(function(g,x,C){for(var M=C<0?C+x:C;++M<x;)g.push(M);return g})}},s.pseudos.nth=s.pseudos.eq;for(i in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})s.pseudos[i]=Yo(i);for(i in{submit:!0,reset:!0})s.pseudos[i]=Xo(i);function xs(){}xs.prototype=s.filters=s.pseudos,s.setFilters=new xs,h=Le.tokenize=function(g,x){var C,M,A,O,B,Q,J,ue=Zr[g+" "];if(ue)return x?0:ue.slice(0);for(B=g,Q=[],J=s.preFilter;B;){(!C||(M=Wo.exec(B)))&&(M&&(B=B.slice(M[0].length)||B),Q.push(A=[])),C=!1,(M=ps.exec(B))&&(C=M.shift(),A.push({value:C,type:M[0].replace(Ui," ")}),B=B.slice(C.length));for(O in s.filter)(M=zi[O].exec(B))&&(!J[O]||(M=J[O](M)))&&(C=M.shift(),A.push({value:C,type:O,matches:M}),B=B.slice(C.length));if(!C)break}return x?B.length:B?Le.error(g):Zr(g,Q).slice(0)};function qi(g){for(var x=0,C=g.length,M="";x<C;x++)M+=g[x].value;return M}function Gi(g,x,C){var M=x.dir,A=x.next,O=A||M,B=C&&O==="parentNode",Q=ke++;return x.first?function(J,ue,oe){for(;J=J[M];)if(J.nodeType===1||B)return g(J,ue,oe);return!1}:function(J,ue,oe){var he,we,Re,ce=[st,Q];if(oe){for(;J=J[M];)if((J.nodeType===1||B)&&g(J,ue,oe))return!0}else for(;J=J[M];)if(J.nodeType===1||B)if(Re=J[De]||(J[De]={}),we=Re[J.uniqueID]||(Re[J.uniqueID]={}),A&&A===J.nodeName.toLowerCase())J=J[M]||J;else{if((he=we[O])&&he[0]===st&&he[1]===Q)return ce[2]=he[2];if(we[O]=ce,ce[2]=g(J,ue,oe))return!0}return!1}}function ra(g){return g.length>1?function(x,C,M){for(var A=g.length;A--;)if(!g[A](x,C,M))return!1;return!0}:g[0]}function Qo(g,x,C){for(var M=0,A=x.length;M<A;M++)Le(g,x[M],C);return C}function Yi(g,x,C,M,A){for(var O,B=[],Q=0,J=g.length,ue=x!=null;Q<J;Q++)(O=g[Q])&&(!C||C(O,M,A))&&(B.push(O),ue&&x.push(Q));return B}function ia(g,x,C,M,A,O){return M&&!M[De]&&(M=ia(M)),A&&!A[De]&&(A=ia(A,O)),Tt(function(B,Q,J,ue){var oe,he,we,Re=[],ce=[],Ve=Q.length,et=B||Qo(x||"*",J.nodeType?[J]:J,[]),dt=g&&(B||!x)?Yi(et,Re,g,J,ue):et,Ne=C?A||(B?g:Ve||M)?[]:Q:dt;if(C&&C(dt,Ne,J,ue),M)for(oe=Yi(Ne,ce),M(oe,[],J,ue),he=oe.length;he--;)(we=oe[he])&&(Ne[ce[he]]=!(dt[ce[he]]=we));if(B){if(A||g){if(A){for(oe=[],he=Ne.length;he--;)(we=Ne[he])&&oe.push(dt[he]=we);A(null,Ne=[],oe,ue)}for(he=Ne.length;he--;)(we=Ne[he])&&(oe=A?pr(B,we):Re[he])>-1&&(B[oe]=!(Q[oe]=we))}}else Ne=Yi(Ne===Q?Ne.splice(Ve,Ne.length):Ne),A?A(null,Q,Ne,ue):tr.apply(Q,Ne)})}function na(g){for(var x,C,M,A=g.length,O=s.relative[g[0].type],B=O||s.relative[" "],Q=O?1:0,J=Gi(function(he){return he===x},B,!0),ue=Gi(function(he){return pr(x,he)>-1},B,!0),oe=[function(he,we,Re){var ce=!O&&(Re||we!==k)||((x=we).nodeType?J(he,we,Re):ue(he,we,Re));return x=null,ce}];Q<A;Q++)if(C=s.relative[g[Q].type])oe=[Gi(ra(oe),C)];else{if(C=s.filter[g[Q].type].apply(null,g[Q].matches),C[De]){for(M=++Q;M<A&&!s.relative[g[M].type];M++);return ia(Q>1&&ra(oe),Q>1&&qi(g.slice(0,Q-1).concat({value:g[Q-2].type===" "?"*":""})).replace(Ui,"$1"),C,Q<M&&na(g.slice(Q,M)),M<A&&na(g=g.slice(M)),M<A&&qi(g))}oe.push(C)}return ra(oe)}function Jo(g,x){var C=x.length>0,M=g.length>0,A=function(O,B,Q,J,ue){var oe,he,we,Re=0,ce="0",Ve=O&&[],et=[],dt=k,Ne=O||M&&s.find.TAG("*",ue),ti=st+=dt==null?1:Math.random()||.1,ri=Ne.length;for(ue&&(k=B==I||B||ue);ce!==ri&&(oe=Ne[ce])!=null;ce++){if(M&&oe){for(he=0,!B&&oe.ownerDocument!=I&&(F(oe),Q=!ve);we=g[he++];)if(we(oe,B||I,Q)){J.push(oe);break}ue&&(st=ti)}C&&((oe=!we&&oe)&&Re--,O&&Ve.push(oe))}if(Re+=ce,C&&ce!==Re){for(he=0;we=x[he++];)we(Ve,et,B,Q);if(O){if(Re>0)for(;ce--;)Ve[ce]||et[ce]||(et[ce]=er.call(J));et=Yi(et)}tr.apply(J,et),ue&&!O&&et.length>0&&Re+x.length>1&&Le.uniqueSort(J)}return ue&&(st=ti,k=dt),Ve};return C?Tt(A):A}return w=Le.compile=function(g,x){var C,M=[],A=[],O=Hi[g+" "];if(!O){for(x||(x=h(g)),C=x.length;C--;)O=na(x[C]),O[De]?M.push(O):A.push(O);O=Hi(g,Jo(A,M)),O.selector=g}return O},E=Le.select=function(g,x,C,M){var A,O,B,Q,J,ue=typeof g=="function"&&g,oe=!M&&h(g=ue.selector||g);if(C=C||[],oe.length===1){if(O=oe[0]=oe[0].slice(0),O.length>2&&(B=O[0]).type==="ID"&&x.nodeType===9&&ve&&s.relative[O[1].type]){if(x=(s.find.ID(B.matches[0].replace(Bt,Ht),x)||[])[0],x)ue&&(x=x.parentNode);else return C;g=g.slice(O.shift().value.length)}for(A=zi.needsContext.test(g)?0:O.length;A--&&(B=O[A],!s.relative[Q=B.type]);)if((J=s.find[Q])&&(M=J(B.matches[0].replace(Bt,Ht),Zn.test(O[0].type)&&ta(x.parentNode)||x))){if(O.splice(A,1),g=M.length&&qi(O),!g)return tr.apply(C,M),C;break}}return(ue||w(g,oe))(M,x,!ve,C,!x||Zn.test(g)&&ta(x.parentNode)||x),C},n.sortStable=De.split("").sort(dr).join("")===De,n.detectDuplicates=!!j,F(),n.sortDetached=Ct(function(g){return g.compareDocumentPosition(I.createElement("fieldset"))&1}),Ct(function(g){return g.innerHTML="<a href='#'></a>",g.firstChild.getAttribute("href")==="#"})||ea("type|href|height|width",function(g,x,C){if(!C)return g.getAttribute(x,x.toLowerCase()==="type"?1:2)}),(!n.attributes||!Ct(function(g){return g.innerHTML="<input/>",g.firstChild.setAttribute("value",""),g.firstChild.getAttribute("value")===""}))&&ea("value",function(g,x,C){if(!C&&g.nodeName.toLowerCase()==="input")return g.defaultValue}),Ct(function(g){return g.getAttribute("disabled")==null})||ea(Jn,function(g,x,C){var M;if(!C)return g[x]===!0?x.toLowerCase():(M=g.getAttributeNode(x))&&M.specified?M.value:null}),Le}(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 se=function(e,i,n){for(var s=[],c=n!==void 0;(e=e[i])&&e.nodeType!==9;)if(e.nodeType===1){if(c&&o(e).is(n))break;s.push(e)}return s},Te=function(e,i){for(var n=[];e;e=e.nextSibling)e.nodeType===1&&e!==i&&n.push(e);return n},He=o.expr.match.needsContext;function Ie(e,i){return e.nodeName&&e.nodeName.toLowerCase()===i.toLowerCase()}var tt=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function Xe(e,i,n){return G(i)?o.grep(e,function(s,c){return!!i.call(s,c,s)!==n}):i.nodeType?o.grep(e,function(s){return s===i!==n}):typeof i!="string"?o.grep(e,function(s){return y.call(i,s)>-1!==n}):o.filter(i,e,n)}o.filter=function(e,i,n){var s=i[0];return n&&(e=":not("+e+")"),i.length===1&&s.nodeType===1?o.find.matchesSelector(s,e)?[s]:[]:o.find.matches(e,o.grep(i,function(c){return c.nodeType===1}))},o.fn.extend({find:function(e){var i,n,s=this.length,c=this;if(typeof e!="string")return this.pushStack(o(e).filter(function(){for(i=0;i<s;i++)if(o.contains(c[i],this))return!0}));for(n=this.pushStack([]),i=0;i<s;i++)o.find(e,c[i],n);return s>1?o.uniqueSort(n):n},filter:function(e){return this.pushStack(Xe(this,e||[],!1))},not:function(e){return this.pushStack(Xe(this,e||[],!0))},is:function(e){return!!Xe(this,typeof e=="string"&&He.test(e)?o(e):e||[],!1).length}});var mt,nr=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,Sr=o.fn.init=function(e,i,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=nr.exec(e),s&&(s[1]||!i))if(s[1]){if(i=i instanceof o?i[0]:i,o.merge(this,o.parseHTML(s[1],i&&i.nodeType?i.ownerDocument||i:K,!0)),tt.test(s[1])&&o.isPlainObject(i))for(s in i)G(this[s])?this[s](i[s]):this.attr(s,i[s]);return this}else return c=K.getElementById(s[2]),c&&(this[0]=c,this.length=1),this;else return!i||i.jquery?(i||n).find(e):this.constructor(i).find(e);else{if(e.nodeType)return this[0]=e,this.length=1,this;if(G(e))return n.ready!==void 0?n.ready(e):e(o)}return o.makeArray(e,this)};Sr.prototype=o.fn,mt=o(K);var Or=/^(?:parents|prev(?:Until|All))/,Yt={children:!0,contents:!0,next:!0,prev:!0};o.fn.extend({has:function(e){var i=o(e,this),n=i.length;return this.filter(function(){for(var s=0;s<n;s++)if(o.contains(this,i[s]))return!0})},closest:function(e,i){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!==i;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,i){return this.pushStack(o.uniqueSort(o.merge(this.get(),o(e,i))))},addBack:function(e){return this.add(e==null?this.prevObject:this.prevObject.filter(e))}});function $r(e,i){for(;(e=e[i])&&e.nodeType!==1;);return e}o.each({parent:function(e){var i=e.parentNode;return i&&i.nodeType!==11?i:null},parents:function(e){return se(e,"parentNode")},parentsUntil:function(e,i,n){return se(e,"parentNode",n)},next:function(e){return $r(e,"nextSibling")},prev:function(e){return $r(e,"previousSibling")},nextAll:function(e){return se(e,"nextSibling")},prevAll:function(e){return se(e,"previousSibling")},nextUntil:function(e,i,n){return se(e,"nextSibling",n)},prevUntil:function(e,i,n){return se(e,"previousSibling",n)},siblings:function(e){return Te((e.parentNode||{}).firstChild,e)},children:function(e){return Te(e.firstChild)},contents:function(e){return e.contentDocument!=null&&a(e.contentDocument)?e.contentDocument:(Ie(e,"template")&&(e=e.content||e),o.merge([],e.childNodes))}},function(e,i){o.fn[e]=function(n,s){var c=o.map(this,i,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),Or.test(e)&&c.reverse()),this.pushStack(c)}});var vt=/[^\x20\t\r\n\f]+/g;function Tn(e){var i={};return o.each(e.match(vt)||[],function(n,s){i[s]=!0}),i}o.Callbacks=function(e){e=typeof e=="string"?Tn(e):o.extend({},e);var i,n,s,c,f=[],h=[],w=-1,E=function(){for(c=c||e.once,s=i=!0;h.length;w=-1)for(n=h.shift();++w<f.length;)f[w].apply(n[0],n[1])===!1&&e.stopOnFalse&&(w=f.length,n=!1);e.memory||(n=!1),i=!1,c&&(n?f=[]:f="")},k={add:function(){return f&&(n&&!i&&(w=f.length-1,h.push(n)),function R(j){o.each(j,function(F,I){G(I)?(!e.unique||!k.has(I))&&f.push(I):I&&I.length&&be(I)!=="string"&&R(I)})}(arguments),n&&!i&&E()),this},remove:function(){return o.each(arguments,function(R,j){for(var F;(F=o.inArray(j,f,F))>-1;)f.splice(F,1),F<=w&&w--}),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&&!i&&(f=n=""),this},locked:function(){return!!c},fireWith:function(R,j){return c||(j=j||[],j=[R,j.slice?j.slice():j],h.push(j),i||E()),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!s}};return k};function Qe(e){return e}function ar(e){throw e}function Ti(e,i,n,s){var c;try{e&&G(c=e.promise)?c.call(e).done(i).fail(n):e&&G(c=e.then)?c.call(e,i,n):i.apply(void 0,[e].slice(s))}catch(f){n.apply(void 0,[f])}}o.extend({Deferred:function(e){var i=[["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(i,function(w,E){var k=G(f[E[4]])&&f[E[4]];c[E[1]](function(){var R=k&&k.apply(this,arguments);R&&G(R.promise)?R.promise().progress(h.notify).done(h.resolve).fail(h.reject):h[E[0]+"With"](this,k?[R]:arguments)})}),f=null}).promise()},then:function(f,h,w){var E=0;function k(R,j,F,I){return function(){var ie=this,ve=arguments,ne=function(){var Ue,ct;if(!(R<E)){if(Ue=F.apply(ie,ve),Ue===j.promise())throw new TypeError("Thenable self-resolution");ct=Ue&&(typeof Ue=="object"||typeof Ue=="function")&&Ue.then,G(ct)?I?ct.call(Ue,k(E,j,Qe,I),k(E,j,ar,I)):(E++,ct.call(Ue,k(E,j,Qe,I),k(E,j,ar,I),k(E,j,Qe,j.notifyWith))):(F!==Qe&&(ie=void 0,ve=[Ue]),(I||j.resolveWith)(ie,ve))}},ze=I?ne:function(){try{ne()}catch(Ue){o.Deferred.exceptionHook&&o.Deferred.exceptionHook(Ue,ze.stackTrace),R+1>=E&&(F!==ar&&(ie=void 0,ve=[Ue]),j.rejectWith(ie,ve))}};R?ze():(o.Deferred.getStackHook&&(ze.stackTrace=o.Deferred.getStackHook()),l.setTimeout(ze))}}return o.Deferred(function(R){i[0][3].add(k(0,R,G(w)?w:Qe,R.notifyWith)),i[1][3].add(k(0,R,G(f)?f:Qe)),i[2][3].add(k(0,R,G(h)?h:ar))}).promise()},promise:function(f){return f!=null?o.extend(f,s):s}},c={};return o.each(i,function(f,h){var w=h[2],E=h[5];s[h[1]]=w.add,E&&w.add(function(){n=E},i[3-f][2].disable,i[3-f][3].disable,i[0][2].lock,i[0][3].lock),w.add(h[3].fire),c[h[0]]=function(){return c[h[0]+"With"](this===c?void 0:this,arguments),this},c[h[0]+"With"]=w.fireWith}),s.promise(c),e&&e.call(c,c),c},when:function(e){var i=arguments.length,n=i,s=Array(n),c=u.call(arguments),f=o.Deferred(),h=function(w){return function(E){s[w]=this,c[w]=arguments.length>1?u.call(arguments):E,--i||f.resolveWith(s,c)}};if(i<=1&&(Ti(e,f.done(h(n)).resolve,f.reject,!i),f.state()==="pending"||G(c[n]&&c[n].then)))return f.then();for(;n--;)Ti(c[n],h(n),f.reject);return f.promise()}});var Cn=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;o.Deferred.exceptionHook=function(e,i){l.console&&l.console.warn&&e&&Cn.test(e.name)&&l.console.warn("jQuery.Deferred exception: "+e.message,e.stack,i)},o.readyException=function(e){l.setTimeout(function(){throw e})};var Wr=o.Deferred();o.fn.ready=function(e){return Wr.then(e).catch(function(i){o.readyException(i)}),this},o.extend({isReady:!1,readyWait:1,ready:function(e){(e===!0?--o.readyWait:o.isReady)||(o.isReady=!0,!(e!==!0&&--o.readyWait>0)&&Wr.resolveWith(K,[o]))}}),o.ready.then=Wr.then;function _r(){K.removeEventListener("DOMContentLoaded",_r),l.removeEventListener("load",_r),o.ready()}K.readyState==="complete"||K.readyState!=="loading"&&!K.documentElement.doScroll?l.setTimeout(o.ready):(K.addEventListener("DOMContentLoaded",_r),l.addEventListener("load",_r));var St=function(e,i,n,s,c,f,h){var w=0,E=e.length,k=n==null;if(be(n)==="object"){c=!0;for(w in n)St(e,i,w,n[w],!0,f,h)}else if(s!==void 0&&(c=!0,G(s)||(h=!0),k&&(h?(i.call(e,s),i=null):(k=i,i=function(R,j,F){return k.call(o(R),F)})),i))for(;w<E;w++)i(e[w],n,h?s:s.call(e[w],w,i(e[w],n)));return c?e:k?i.call(e):E?i(e[0],n):f},kn=/^-ms-/,Pn=/-([a-z])/g;function An(e,i){return i.toUpperCase()}function bt(e){return e.replace(kn,"ms-").replace(Pn,An)}var sr=function(e){return e.nodeType===1||e.nodeType===9||!+e.nodeType};function or(){this.expando=o.expando+or.uid++}or.uid=1,or.prototype={cache:function(e){var i=e[this.expando];return i||(i={},sr(e)&&(e.nodeType?e[this.expando]=i:Object.defineProperty(e,this.expando,{value:i,configurable:!0}))),i},set:function(e,i,n){var s,c=this.cache(e);if(typeof i=="string")c[bt(i)]=n;else for(s in i)c[bt(s)]=i[s];return c},get:function(e,i){return i===void 0?this.cache(e):e[this.expando]&&e[this.expando][bt(i)]},access:function(e,i,n){return i===void 0||i&&typeof i=="string"&&n===void 0?this.get(e,i):(this.set(e,i,n),n!==void 0?n:i)},remove:function(e,i){var n,s=e[this.expando];if(s!==void 0){if(i!==void 0)for(Array.isArray(i)?i=i.map(bt):(i=bt(i),i=i in s?[i]:i.match(vt)||[]),n=i.length;n--;)delete s[i[n]];(i===void 0||o.isEmptyObject(s))&&(e.nodeType?e[this.expando]=void 0:delete e[this.expando])}},hasData:function(e){var i=e[this.expando];return i!==void 0&&!o.isEmptyObject(i)}};var le=new or,$e=new or,Dn=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,Ci=/[A-Z]/g;function Tr(e){return e==="true"?!0:e==="false"?!1:e==="null"?null:e===+e+""?+e:Dn.test(e)?JSON.parse(e):e}function Cr(e,i,n){var s;if(n===void 0&&e.nodeType===1)if(s="data-"+i.replace(Ci,"-$&").toLowerCase(),n=e.getAttribute(s),typeof n=="string"){try{n=Tr(n)}catch(c){}$e.set(e,i,n)}else n=void 0;return n}o.extend({hasData:function(e){return $e.hasData(e)||le.hasData(e)},data:function(e,i,n){return $e.access(e,i,n)},removeData:function(e,i){$e.remove(e,i)},_data:function(e,i,n){return le.access(e,i,n)},_removeData:function(e,i){le.remove(e,i)}}),o.fn.extend({data:function(e,i){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)),Cr(f,s,c[s])));le.set(f,"hasDataAttrs",!0)}return c}return typeof e=="object"?this.each(function(){$e.set(this,e)}):St(this,function(w){var E;if(f&&w===void 0)return E=$e.get(f,e),E!==void 0||(E=Cr(f,e),E!==void 0)?E:void 0;this.each(function(){$e.set(this,e,w)})},null,i,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){$e.remove(this,e)})}}),o.extend({queue:function(e,i,n){var s;if(e)return i=(i||"fx")+"queue",s=le.get(e,i),n&&(!s||Array.isArray(n)?s=le.access(e,i,o.makeArray(n)):s.push(n)),s||[]},dequeue:function(e,i){i=i||"fx";var n=o.queue(e,i),s=n.length,c=n.shift(),f=o._queueHooks(e,i),h=function(){o.dequeue(e,i)};c==="inprogress"&&(c=n.shift(),s--),c&&(i==="fx"&&n.unshift("inprogress"),delete f.stop,c.call(e,h,f)),!s&&f&&f.empty.fire()},_queueHooks:function(e,i){var n=i+"queueHooks";return le.get(e,n)||le.access(e,n,{empty:o.Callbacks("once memory").add(function(){le.remove(e,[i+"queue",n])})})}}),o.fn.extend({queue:function(e,i){var n=2;return typeof e!="string"&&(i=e,e="fx",n--),arguments.length<n?o.queue(this[0],e):i===void 0?this:this.each(function(){var s=o.queue(this,e,i);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,i){var n,s=1,c=o.Deferred(),f=this,h=this.length,w=function(){--s||c.resolveWith(f,[f])};for(typeof e!="string"&&(i=e,e=void 0),e=e||"fx";h--;)n=le.get(f[h],e+"queueHooks"),n&&n.empty&&(s++,n.empty.add(w));return w(),c.promise(i)}});var kr=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,Nt=new RegExp("^(?:([+-])=|)("+kr+")([a-z%]*)$","i"),yt=["Top","Right","Bottom","Left"],Dt=K.documentElement,Ot=function(e){return o.contains(e.ownerDocument,e)},ki={composed:!0};Dt.getRootNode&&(Ot=function(e){return o.contains(e.ownerDocument,e)||e.getRootNode(ki)===e.ownerDocument});var lr=function(e,i){return e=i||e,e.style.display==="none"||e.style.display===""&&Ot(e)&&o.css(e,"display")==="none"};function jr(e,i,n,s){var c,f,h=20,w=s?function(){return s.cur()}:function(){return o.css(e,i,"")},E=w(),k=n&&n[3]||(o.cssNumber[i]?"":"px"),R=e.nodeType&&(o.cssNumber[i]||k!=="px"&&+E)&&Nt.exec(o.css(e,i));if(R&&R[3]!==k){for(E=E/2,k=k||R[3],R=+E||1;h--;)o.style(e,i,R+k),(1-f)*(1-(f=w()/E||.5))<=0&&(h=0),R=R/f;R=R*2,o.style(e,i,R+k),n=n||[]}return n&&(R=+R||+E||0,c=n[1]?R+(n[1]+1)*n[2]:+n[2],s&&(s.unit=k,s.start=R,s.end=c)),c}var Br={};function Pi(e){var i,n=e.ownerDocument,s=e.nodeName,c=Br[s];return c||(i=n.body.appendChild(n.createElement(s)),c=o.css(i,"display"),i.parentNode.removeChild(i),c==="none"&&(c="block"),Br[s]=c,c)}function $t(e,i){for(var n,s,c=[],f=0,h=e.length;f<h;f++)s=e[f],!!s.style&&(n=s.style.display,i?(n==="none"&&(c[f]=le.get(s,"display")||null,c[f]||(s.style.display="")),s.style.display===""&&lr(s)&&(c[f]=Pi(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 $t(this,!0)},hide:function(){return $t(this)},toggle:function(e){return typeof e=="boolean"?e?this.show():this.hide():this.each(function(){lr(this)?o(this).show():o(this).hide()})}});var Xt=/^(?:checkbox|radio)$/i,Hr=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i,Ur=/^$|^module$|\/(?:java|ecma)script/i;(function(){var e=K.createDocumentFragment(),i=e.appendChild(K.createElement("div")),n=K.createElement("input");n.setAttribute("type","radio"),n.setAttribute("checked","checked"),n.setAttribute("name","t"),i.appendChild(n),H.checkClone=i.cloneNode(!0).cloneNode(!0).lastChild.checked,i.innerHTML="<textarea>x</textarea>",H.noCloneChecked=!!i.cloneNode(!0).lastChild.defaultValue,i.innerHTML="<option></option>",H.option=!!i.lastChild})();var Je={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,"",""]};Je.tbody=Je.tfoot=Je.colgroup=Je.caption=Je.thead,Je.th=Je.td,H.option||(Je.optgroup=Je.option=[1,"<select multiple='multiple'>","</select>"]);function Ke(e,i){var n;return typeof e.getElementsByTagName!="undefined"?n=e.getElementsByTagName(i||"*"):typeof e.querySelectorAll!="undefined"?n=e.querySelectorAll(i||"*"):n=[],i===void 0||i&&Ie(e,i)?o.merge([e],n):n}function zr(e,i){for(var n=0,s=e.length;n<s;n++)le.set(e[n],"globalEval",!i||le.get(i[n],"globalEval"))}var Vr=/<|&#?\w+;/;function qr(e,i,n,s,c){for(var f,h,w,E,k,R,j=i.createDocumentFragment(),F=[],I=0,ie=e.length;I<ie;I++)if(f=e[I],f||f===0)if(be(f)==="object")o.merge(F,f.nodeType?[f]:f);else if(!Vr.test(f))F.push(i.createTextNode(f));else{for(h=h||j.appendChild(i.createElement("div")),w=(Hr.exec(f)||["",""])[1].toLowerCase(),E=Je[w]||Je._default,h.innerHTML=E[1]+o.htmlPrefilter(f)+E[2],R=E[0];R--;)h=h.lastChild;o.merge(F,h.childNodes),h=j.firstChild,h.textContent=""}for(j.textContent="",I=0;f=F[I++];){if(s&&o.inArray(f,s)>-1){c&&c.push(f);continue}if(k=Ot(f),h=Ke(j.appendChild(f),"script"),k&&zr(h),n)for(R=0;f=h[R++];)Ur.test(f.type||"")&&n.push(f)}return j}var Ai=/^([^.]*)(?:\.(.+)|)/;function rt(){return!0}function Qt(){return!1}function Fn(e,i){return e===Di()==(i==="focus")}function Di(){try{return K.activeElement}catch(e){}}function Gr(e,i,n,s,c,f){var h,w;if(typeof i=="object"){typeof n!="string"&&(s=s||n,n=void 0);for(w in i)Gr(e,w,n,s,i[w],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(E){return o().off(E),h.apply(this,arguments)},c.guid=h.guid||(h.guid=o.guid++)),e.each(function(){o.event.add(this,i,c,s,n)})}o.event={global:{},add:function(e,i,n,s,c){var f,h,w,E,k,R,j,F,I,ie,ve,ne=le.get(e);if(!!sr(e))for(n.handler&&(f=n,n=f.handler,c=f.selector),c&&o.find.matchesSelector(Dt,c),n.guid||(n.guid=o.guid++),(E=ne.events)||(E=ne.events=Object.create(null)),(h=ne.handle)||(h=ne.handle=function(ze){return typeof o!="undefined"&&o.event.triggered!==ze.type?o.event.dispatch.apply(e,arguments):void 0}),i=(i||"").match(vt)||[""],k=i.length;k--;)w=Ai.exec(i[k])||[],I=ve=w[1],ie=(w[2]||"").split(".").sort(),!!I&&(j=o.event.special[I]||{},I=(c?j.delegateType:j.bindType)||I,j=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:ie.join(".")},f),(F=E[I])||(F=E[I]=[],F.delegateCount=0,(!j.setup||j.setup.call(e,s,ie,h)===!1)&&e.addEventListener&&e.addEventListener(I,h)),j.add&&(j.add.call(e,R),R.handler.guid||(R.handler.guid=n.guid)),c?F.splice(F.delegateCount++,0,R):F.push(R),o.event.global[I]=!0)},remove:function(e,i,n,s,c){var f,h,w,E,k,R,j,F,I,ie,ve,ne=le.hasData(e)&&le.get(e);if(!(!ne||!(E=ne.events))){for(i=(i||"").match(vt)||[""],k=i.length;k--;){if(w=Ai.exec(i[k])||[],I=ve=w[1],ie=(w[2]||"").split(".").sort(),!I){for(I in E)o.event.remove(e,I+i[k],n,s,!0);continue}for(j=o.event.special[I]||{},I=(s?j.delegateType:j.bindType)||I,F=E[I]||[],w=w[2]&&new RegExp("(^|\\.)"+ie.join("\\.(?:.*\\.|)")+"(\\.|$)"),h=f=F.length;f--;)R=F[f],(c||ve===R.origType)&&(!n||n.guid===R.guid)&&(!w||w.test(R.namespace))&&(!s||s===R.selector||s==="**"&&R.selector)&&(F.splice(f,1),R.selector&&F.delegateCount--,j.remove&&j.remove.call(e,R));h&&!F.length&&((!j.teardown||j.teardown.call(e,ie,ne.handle)===!1)&&o.removeEvent(e,I,ne.handle),delete E[I])}o.isEmptyObject(E)&&le.remove(e,"handle events")}},dispatch:function(e){var i,n,s,c,f,h,w=new Array(arguments.length),E=o.event.fix(e),k=(le.get(this,"events")||Object.create(null))[E.type]||[],R=o.event.special[E.type]||{};for(w[0]=E,i=1;i<arguments.length;i++)w[i]=arguments[i];if(E.delegateTarget=this,!(R.preDispatch&&R.preDispatch.call(this,E)===!1)){for(h=o.event.handlers.call(this,E,k),i=0;(c=h[i++])&&!E.isPropagationStopped();)for(E.currentTarget=c.elem,n=0;(f=c.handlers[n++])&&!E.isImmediatePropagationStopped();)(!E.rnamespace||f.namespace===!1||E.rnamespace.test(f.namespace))&&(E.handleObj=f,E.data=f.data,s=((o.event.special[f.origType]||{}).handle||f.handler).apply(c.elem,w),s!==void 0&&(E.result=s)===!1&&(E.preventDefault(),E.stopPropagation()));return R.postDispatch&&R.postDispatch.call(this,E),E.result}},handlers:function(e,i){var n,s,c,f,h,w=[],E=i.delegateCount,k=e.target;if(E&&k.nodeType&&!(e.type==="click"&&e.button>=1)){for(;k!==this;k=k.parentNode||this)if(k.nodeType===1&&!(e.type==="click"&&k.disabled===!0)){for(f=[],h={},n=0;n<E;n++)s=i[n],c=s.selector+" ",h[c]===void 0&&(h[c]=s.needsContext?o(c,this).index(k)>-1:o.find(c,this,null,[k]).length),h[c]&&f.push(s);f.length&&w.push({elem:k,handlers:f})}}return k=this,E<i.length&&w.push({elem:k,handlers:i.slice(E)}),w},addProp:function(e,i){Object.defineProperty(o.Event.prototype,e,{enumerable:!0,configurable:!0,get:G(i)?function(){if(this.originalEvent)return i(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 i=this||e;return Xt.test(i.type)&&i.click&&Ie(i,"input")&&Pr(i,"click",rt),!1},trigger:function(e){var i=this||e;return Xt.test(i.type)&&i.click&&Ie(i,"input")&&Pr(i,"click"),!0},_default:function(e){var i=e.target;return Xt.test(i.type)&&i.click&&Ie(i,"input")&&le.get(i,"click")||Ie(i,"a")}},beforeunload:{postDispatch:function(e){e.result!==void 0&&e.originalEvent&&(e.originalEvent.returnValue=e.result)}}}};function Pr(e,i,n){if(!n){le.get(e,i)===void 0&&o.event.add(e,i,rt);return}le.set(e,i,!1),o.event.add(e,i,{namespace:!1,handler:function(s){var c,f,h=le.get(this,i);if(s.isTrigger&1&&this[i]){if(h.length)(o.event.special[i]||{}).delegateType&&s.stopPropagation();else if(h=u.call(arguments),le.set(this,i,h),c=n(this,i),this[i](),f=le.get(this,i),h!==f||c?le.set(this,i,!1):f={},h!==f)return s.stopImmediatePropagation(),s.preventDefault(),f&&f.value}else h.length&&(le.set(this,i,{value:o.event.trigger(o.extend(h[0],o.Event.prototype),h.slice(1),this)}),s.stopImmediatePropagation())}})}o.removeEvent=function(e,i,n){e.removeEventListener&&e.removeEventListener(i,n)},o.Event=function(e,i){if(!(this instanceof o.Event))return new o.Event(e,i);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,i&&o.extend(this,i),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,i){o.event.special[e]={setup:function(){return Pr(this,e,Fn),!1},trigger:function(){return Pr(this,e),!0},_default:function(){return!0},delegateType:i}}),o.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(e,i){o.event.special[e]={delegateType:i,bindType:i,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=i),s}}}),o.fn.extend({on:function(e,i,n,s){return Gr(this,e,i,n,s)},one:function(e,i,n,s){return Gr(this,e,i,n,s,1)},off:function(e,i,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,i,e[c]);return this}return(i===!1||typeof i=="function")&&(n=i,i=void 0),n===!1&&(n=Qt),this.each(function(){o.event.remove(this,e,n,i)})}});var Ln=/<script|<style|<link/i,Rn=/checked\s*(?:[^=]|=\s*.checked.)/i,In=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;function Fi(e,i){return Ie(e,"table")&&Ie(i.nodeType!==11?i:i.firstChild,"tr")&&o(e).children("tbody")[0]||e}function Mn(e){return e.type=(e.getAttribute("type")!==null)+"/"+e.type,e}function Nn(e){return(e.type||"").slice(0,5)==="true/"?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Li(e,i){var n,s,c,f,h,w,E;if(i.nodeType===1){if(le.hasData(e)&&(f=le.get(e),E=f.events,E)){le.remove(i,"handle events");for(c in E)for(n=0,s=E[c].length;n<s;n++)o.event.add(i,c,E[c][n])}$e.hasData(e)&&(h=$e.access(e),w=o.extend({},h),$e.set(i,w))}}function On(e,i){var n=i.nodeName.toLowerCase();n==="input"&&Xt.test(e.type)?i.checked=e.checked:(n==="input"||n==="textarea")&&(i.defaultValue=e.defaultValue)}function Wt(e,i,n,s){i=d(i);var c,f,h,w,E,k,R=0,j=e.length,F=j-1,I=i[0],ie=G(I);if(ie||j>1&&typeof I=="string"&&!H.checkClone&&Rn.test(I))return e.each(function(ve){var ne=e.eq(ve);ie&&(i[0]=I.call(this,ve,ne.html())),Wt(ne,i,n,s)});if(j&&(c=qr(i,e[0].ownerDocument,!1,e,s),f=c.firstChild,c.childNodes.length===1&&(c=f),f||s)){for(h=o.map(Ke(c,"script"),Mn),w=h.length;R<j;R++)E=c,R!==F&&(E=o.clone(E,!0,!0),w&&o.merge(h,Ke(E,"script"))),n.call(e[R],E,R);if(w)for(k=h[h.length-1].ownerDocument,o.map(h,Nn),R=0;R<w;R++)E=h[R],Ur.test(E.type||"")&&!le.access(E,"globalEval")&&o.contains(k,E)&&(E.src&&(E.type||"").toLowerCase()!=="module"?o._evalUrl&&!E.noModule&&o._evalUrl(E.src,{nonce:E.nonce||E.getAttribute("nonce")},k):Pe(E.textContent.replace(In,""),E,k))}return e}function Ri(e,i,n){for(var s,c=i?o.filter(i,e):e,f=0;(s=c[f])!=null;f++)!n&&s.nodeType===1&&o.cleanData(Ke(s)),s.parentNode&&(n&&Ot(s)&&zr(Ke(s,"script")),s.parentNode.removeChild(s));return e}o.extend({htmlPrefilter:function(e){return e},clone:function(e,i,n){var s,c,f,h,w=e.cloneNode(!0),E=Ot(e);if(!H.noCloneChecked&&(e.nodeType===1||e.nodeType===11)&&!o.isXMLDoc(e))for(h=Ke(w),f=Ke(e),s=0,c=f.length;s<c;s++)On(f[s],h[s]);if(i)if(n)for(f=f||Ke(e),h=h||Ke(w),s=0,c=f.length;s<c;s++)Li(f[s],h[s]);else Li(e,w);return h=Ke(w,"script"),h.length>0&&zr(h,!E&&Ke(e,"script")),w},cleanData:function(e){for(var i,n,s,c=o.event.special,f=0;(n=e[f])!==void 0;f++)if(sr(n)){if(i=n[le.expando]){if(i.events)for(s in i.events)c[s]?o.event.remove(n,s):o.removeEvent(n,s,i.handle);n[le.expando]=void 0}n[$e.expando]&&(n[$e.expando]=void 0)}}}),o.fn.extend({detach:function(e){return Ri(this,e,!0)},remove:function(e){return Ri(this,e)},text:function(e){return St(this,function(i){return i===void 0?o.text(this):this.empty().each(function(){(this.nodeType===1||this.nodeType===11||this.nodeType===9)&&(this.textContent=i)})},null,e,arguments.length)},append:function(){return Wt(this,arguments,function(e){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var i=Fi(this,e);i.appendChild(e)}})},prepend:function(){return Wt(this,arguments,function(e){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var i=Fi(this,e);i.insertBefore(e,i.firstChild)}})},before:function(){return Wt(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return Wt(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,i=0;(e=this[i])!=null;i++)e.nodeType===1&&(o.cleanData(Ke(e,!1)),e.textContent="");return this},clone:function(e,i){return e=e==null?!1:e,i=i==null?e:i,this.map(function(){return o.clone(this,e,i)})},html:function(e){return St(this,function(i){var n=this[0]||{},s=0,c=this.length;if(i===void 0&&n.nodeType===1)return n.innerHTML;if(typeof i=="string"&&!Ln.test(i)&&!Je[(Hr.exec(i)||["",""])[1].toLowerCase()]){i=o.htmlPrefilter(i);try{for(;s<c;s++)n=this[s]||{},n.nodeType===1&&(o.cleanData(Ke(n,!1)),n.innerHTML=i);n=0}catch(f){}}n&&this.empty().append(i)},null,e,arguments.length)},replaceWith:function(){var e=[];return Wt(this,arguments,function(i){var n=this.parentNode;o.inArray(this,e)<0&&(o.cleanData(Ke(this)),n&&n.replaceChild(i,this))},e)}}),o.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,i){o.fn[e]=function(n){for(var s,c=[],f=o(n),h=f.length-1,w=0;w<=h;w++)s=w===h?this:this.clone(!0),o(f[w])[i](s),m.apply(c,s.get());return this.pushStack(c)}});var Yr=new RegExp("^("+kr+")(?!px)[a-z%]+$","i"),Ar=function(e){var i=e.ownerDocument.defaultView;return(!i||!i.opener)&&(i=l),i.getComputedStyle(e)},Ii=function(e,i,n){var s,c,f={};for(c in i)f[c]=e.style[c],e.style[c]=i[c];s=n.call(e);for(c in i)e.style[c]=f[c];return s},$n=new RegExp(yt.join("|"),"i");(function(){function e(){if(!!k){E.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",k.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",Dt.appendChild(E).appendChild(k);var R=l.getComputedStyle(k);n=R.top!=="1%",w=i(R.marginLeft)===12,k.style.right="60%",f=i(R.right)===36,s=i(R.width)===36,k.style.position="absolute",c=i(k.offsetWidth/3)===12,Dt.removeChild(E),k=null}}function i(R){return Math.round(parseFloat(R))}var n,s,c,f,h,w,E=K.createElement("div"),k=K.createElement("div");!k.style||(k.style.backgroundClip="content-box",k.cloneNode(!0).style.backgroundClip="",H.clearCloneStyle=k.style.backgroundClip==="content-box",o.extend(H,{boxSizingReliable:function(){return e(),s},pixelBoxStyles:function(){return e(),f},pixelPosition:function(){return e(),n},reliableMarginLeft:function(){return e(),w},scrollboxSize:function(){return e(),c},reliableTrDimensions:function(){var R,j,F,I;return h==null&&(R=K.createElement("table"),j=K.createElement("tr"),F=K.createElement("div"),R.style.cssText="position:absolute;left:-11111px;border-collapse:separate",j.style.cssText="border:1px solid",j.style.height="1px",F.style.height="9px",F.style.display="block",Dt.appendChild(R).appendChild(j).appendChild(F),I=l.getComputedStyle(j),h=parseInt(I.height,10)+parseInt(I.borderTopWidth,10)+parseInt(I.borderBottomWidth,10)===j.offsetHeight,Dt.removeChild(R)),h}}))})();function ur(e,i,n){var s,c,f,h,w=e.style;return n=n||Ar(e),n&&(h=n.getPropertyValue(i)||n[i],h===""&&!Ot(e)&&(h=o.style(e,i)),!H.pixelBoxStyles()&&Yr.test(h)&&$n.test(i)&&(s=w.width,c=w.minWidth,f=w.maxWidth,w.minWidth=w.maxWidth=w.width=h,h=n.width,w.width=s,w.minWidth=c,w.maxWidth=f)),h!==void 0?h+"":h}function Mi(e,i){return{get:function(){if(e()){delete this.get;return}return(this.get=i).apply(this,arguments)}}}var Ni=["Webkit","Moz","ms"],Oi=K.createElement("div").style,$i={};function Wn(e){for(var i=e[0].toUpperCase()+e.slice(1),n=Ni.length;n--;)if(e=Ni[n]+i,e in Oi)return e}function Xr(e){var i=o.cssProps[e]||$i[e];return i||(e in Oi?e:$i[e]=Wn(e)||e)}var jn=/^(none|table(?!-c[ea]).+)/,Wi=/^--/,Bn={position:"absolute",visibility:"hidden",display:"block"},Qr={letterSpacing:"0",fontWeight:"400"};function Jt(e,i,n){var s=Nt.exec(i);return s?Math.max(0,s[2]-(n||0))+(s[3]||"px"):i}function Dr(e,i,n,s,c,f){var h=i==="width"?1:0,w=0,E=0;if(n===(s?"border":"content"))return 0;for(;h<4;h+=2)n==="margin"&&(E+=o.css(e,n+yt[h],!0,c)),s?(n==="content"&&(E-=o.css(e,"padding"+yt[h],!0,c)),n!=="margin"&&(E-=o.css(e,"border"+yt[h]+"Width",!0,c))):(E+=o.css(e,"padding"+yt[h],!0,c),n!=="padding"?E+=o.css(e,"border"+yt[h]+"Width",!0,c):w+=o.css(e,"border"+yt[h]+"Width",!0,c));return!s&&f>=0&&(E+=Math.max(0,Math.ceil(e["offset"+i[0].toUpperCase()+i.slice(1)]-f-E-w-.5))||0),E}function jt(e,i,n){var s=Ar(e),c=!H.boxSizingReliable()||n,f=c&&o.css(e,"boxSizing",!1,s)==="border-box",h=f,w=ur(e,i,s),E="offset"+i[0].toUpperCase()+i.slice(1);if(Yr.test(w)){if(!n)return w;w="auto"}return(!H.boxSizingReliable()&&f||!H.reliableTrDimensions()&&Ie(e,"tr")||w==="auto"||!parseFloat(w)&&o.css(e,"display",!1,s)==="inline")&&e.getClientRects().length&&(f=o.css(e,"boxSizing",!1,s)==="border-box",h=E in e,h&&(w=e[E])),w=parseFloat(w)||0,w+Dr(e,i,n||(f?"border":"content"),h,s,w)+"px"}o.extend({cssHooks:{opacity:{get:function(e,i){if(i){var n=ur(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,i,n,s){if(!(!e||e.nodeType===3||e.nodeType===8||!e.style)){var c,f,h,w=bt(i),E=Wi.test(i),k=e.style;if(E||(i=Xr(w)),h=o.cssHooks[i]||o.cssHooks[w],n!==void 0){if(f=typeof n,f==="string"&&(c=Nt.exec(n))&&c[1]&&(n=jr(e,i,c),f="number"),n==null||n!==n)return;f==="number"&&!E&&(n+=c&&c[3]||(o.cssNumber[w]?"":"px")),!H.clearCloneStyle&&n===""&&i.indexOf("background")===0&&(k[i]="inherit"),(!h||!("set"in h)||(n=h.set(e,n,s))!==void 0)&&(E?k.setProperty(i,n):k[i]=n)}else return h&&"get"in h&&(c=h.get(e,!1,s))!==void 0?c:k[i]}},css:function(e,i,n,s){var c,f,h,w=bt(i),E=Wi.test(i);return E||(i=Xr(w)),h=o.cssHooks[i]||o.cssHooks[w],h&&"get"in h&&(c=h.get(e,!0,n)),c===void 0&&(c=ur(e,i,s)),c==="normal"&&i in Qr&&(c=Qr[i]),n===""||n?(f=parseFloat(c),n===!0||isFinite(f)?f||0:c):c}}),o.each(["height","width"],function(e,i){o.cssHooks[i]={get:function(n,s,c){if(s)return jn.test(o.css(n,"display"))&&(!n.getClientRects().length||!n.getBoundingClientRect().width)?Ii(n,Bn,function(){return jt(n,i,c)}):jt(n,i,c)},set:function(n,s,c){var f,h=Ar(n),w=!H.scrollboxSize()&&h.position==="absolute",E=w||c,k=E&&o.css(n,"boxSizing",!1,h)==="border-box",R=c?Dr(n,i,c,k,h):0;return k&&w&&(R-=Math.ceil(n["offset"+i[0].toUpperCase()+i.slice(1)]-parseFloat(h[i])-Dr(n,i,"border",!1,h)-.5)),R&&(f=Nt.exec(s))&&(f[3]||"px")!=="px"&&(n.style[i]=s,s=o.css(n,i)),Jt(n,s,R)}}}),o.cssHooks.marginLeft=Mi(H.reliableMarginLeft,function(e,i){if(i)return(parseFloat(ur(e,"marginLeft"))||e.getBoundingClientRect().left-Ii(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),o.each({margin:"",padding:"",border:"Width"},function(e,i){o.cssHooks[e+i]={expand:function(n){for(var s=0,c={},f=typeof n=="string"?n.split(" "):[n];s<4;s++)c[e+yt[s]+i]=f[s]||f[s-2]||f[0];return c}},e!=="margin"&&(o.cssHooks[e+i].set=Jt)}),o.fn.extend({css:function(e,i){return St(this,function(n,s,c){var f,h,w={},E=0;if(Array.isArray(s)){for(f=Ar(n),h=s.length;E<h;E++)w[s[E]]=o.css(n,s[E],!1,f);return w}return c!==void 0?o.style(n,s,c):o.css(n,s)},e,i,arguments.length>1)}});function Ze(e,i,n,s,c){return new Ze.prototype.init(e,i,n,s,c)}o.Tween=Ze,Ze.prototype={constructor:Ze,init:function(e,i,n,s,c,f){this.elem=e,this.prop=n,this.easing=c||o.easing._default,this.options=i,this.start=this.now=this.cur(),this.end=s,this.unit=f||(o.cssNumber[n]?"":"px")},cur:function(){var e=Ze.propHooks[this.prop];return e&&e.get?e.get(this):Ze.propHooks._default.get(this)},run:function(e){var i,n=Ze.propHooks[this.prop];return this.options.duration?this.pos=i=o.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=i=e,this.now=(this.end-this.start)*i+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):Ze.propHooks._default.set(this),this}},Ze.prototype.init.prototype=Ze.prototype,Ze.propHooks={_default:{get:function(e){var i;return e.elem.nodeType!==1||e.elem[e.prop]!=null&&e.elem.style[e.prop]==null?e.elem[e.prop]:(i=o.css(e.elem,e.prop,""),!i||i==="auto"?0:i)},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[Xr(e.prop)]!=null)?o.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},Ze.propHooks.scrollTop=Ze.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=Ze.prototype.init,o.fx.step={};var _t,Kt,Hn=/^(?:toggle|show|hide)$/,Un=/queueHooks$/;function cr(){Kt&&(K.hidden===!1&&l.requestAnimationFrame?l.requestAnimationFrame(cr):l.setTimeout(cr,o.fx.interval),o.fx.tick())}function ji(){return l.setTimeout(function(){_t=void 0}),_t=Date.now()}function Fr(e,i){var n,s=0,c={height:e};for(i=i?1:0;s<4;s+=2-i)n=yt[s],c["margin"+n]=c["padding"+n]=e;return i&&(c.opacity=c.width=e),c}function p(e,i,n){for(var s,c=(_.tweeners[i]||[]).concat(_.tweeners["*"]),f=0,h=c.length;f<h;f++)if(s=c[f].call(n,i,e))return s}function S(e,i,n){var s,c,f,h,w,E,k,R,j="width"in i||"height"in i,F=this,I={},ie=e.style,ve=e.nodeType&&lr(e),ne=le.get(e,"fxshow");n.queue||(h=o._queueHooks(e,"fx"),h.unqueued==null&&(h.unqueued=0,w=h.empty.fire,h.empty.fire=function(){h.unqueued||w()}),h.unqueued++,F.always(function(){F.always(function(){h.unqueued--,o.queue(e,"fx").length||h.empty.fire()})}));for(s in i)if(c=i[s],Hn.test(c)){if(delete i[s],f=f||c==="toggle",c===(ve?"hide":"show"))if(c==="show"&&ne&&ne[s]!==void 0)ve=!0;else continue;I[s]=ne&&ne[s]||o.style(e,s)}if(E=!o.isEmptyObject(i),!(!E&&o.isEmptyObject(I))){j&&e.nodeType===1&&(n.overflow=[ie.overflow,ie.overflowX,ie.overflowY],k=ne&&ne.display,k==null&&(k=le.get(e,"display")),R=o.css(e,"display"),R==="none"&&(k?R=k:($t([e],!0),k=e.style.display||k,R=o.css(e,"display"),$t([e]))),(R==="inline"||R==="inline-block"&&k!=null)&&o.css(e,"float")==="none"&&(E||(F.done(function(){ie.display=k}),k==null&&(R=ie.display,k=R==="none"?"":R)),ie.display="inline-block")),n.overflow&&(ie.overflow="hidden",F.always(function(){ie.overflow=n.overflow[0],ie.overflowX=n.overflow[1],ie.overflowY=n.overflow[2]})),E=!1;for(s in I)E||(ne?"hidden"in ne&&(ve=ne.hidden):ne=le.access(e,"fxshow",{display:k}),f&&(ne.hidden=!ve),ve&&$t([e],!0),F.done(function(){ve||$t([e]),le.remove(e,"fxshow");for(s in I)o.style(e,s,I[s])})),E=p(ve?ne[s]:0,s,F),s in ne||(ne[s]=E.start,ve&&(E.end=E.start,E.start=0))}}function v(e,i){var n,s,c,f,h;for(n in e)if(s=bt(n),c=i[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],i[n]=c)}else i[s]=c}function _(e,i,n){var s,c,f=0,h=_.prefilters.length,w=o.Deferred().always(function(){delete E.elem}),E=function(){if(c)return!1;for(var j=_t||ji(),F=Math.max(0,k.startTime+k.duration-j),I=F/k.duration||0,ie=1-I,ve=0,ne=k.tweens.length;ve<ne;ve++)k.tweens[ve].run(ie);return w.notifyWith(e,[k,ie,F]),ie<1&&ne?F:(ne||w.notifyWith(e,[k,1,0]),w.resolveWith(e,[k]),!1)},k=w.promise({elem:e,props:o.extend({},i),opts:o.extend(!0,{specialEasing:{},easing:o.easing._default},n),originalProperties:i,originalOptions:n,startTime:_t||ji(),duration:n.duration,tweens:[],createTween:function(j,F){var I=o.Tween(e,k.opts,j,F,k.opts.specialEasing[j]||k.opts.easing);return k.tweens.push(I),I},stop:function(j){var F=0,I=j?k.tweens.length:0;if(c)return this;for(c=!0;F<I;F++)k.tweens[F].run(1);return j?(w.notifyWith(e,[k,1,0]),w.resolveWith(e,[k,j])):w.rejectWith(e,[k,j]),this}}),R=k.props;for(v(R,k.opts.specialEasing);f<h;f++)if(s=_.prefilters[f].call(k,e,R,k.opts),s)return G(s.stop)&&(o._queueHooks(k.elem,k.opts.queue).stop=s.stop.bind(s)),s;return o.map(R,p,k),G(k.opts.start)&&k.opts.start.call(e,k),k.progress(k.opts.progress).done(k.opts.done,k.opts.complete).fail(k.opts.fail).always(k.opts.always),o.fx.timer(o.extend(E,{elem:e,anim:k,queue:k.opts.queue})),k}o.Animation=o.extend(_,{tweeners:{"*":[function(e,i){var n=this.createTween(e,i);return jr(n.elem,e,Nt.exec(i),n),n}]},tweener:function(e,i){G(e)?(i=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(i)},prefilters:[S],prefilter:function(e,i){i?_.prefilters.unshift(e):_.prefilters.push(e)}}),o.speed=function(e,i,n){var s=e&&typeof e=="object"?o.extend({},e):{complete:n||!n&&i||G(e)&&e,duration:e,easing:n&&i||i&&!G(i)&&i};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(){G(s.old)&&s.old.call(this),s.queue&&o.dequeue(this,s.queue)},s},o.fn.extend({fadeTo:function(e,i,n,s){return this.filter(lr).css("opacity",0).show().end().animate({opacity:i},e,n,s)},animate:function(e,i,n,s){var c=o.isEmptyObject(e),f=o.speed(i,n,s),h=function(){var w=_(this,o.extend({},e),f);(c||le.get(this,"finish"))&&w.stop(!0)};return h.finish=h,c||f.queue===!1?this.each(h):this.queue(f.queue,h)},stop:function(e,i,n){var s=function(c){var f=c.stop;delete c.stop,f(n)};return typeof e!="string"&&(n=i,i=e,e=void 0),i&&this.queue(e||"fx",[]),this.each(function(){var c=!0,f=e!=null&&e+"queueHooks",h=o.timers,w=le.get(this);if(f)w[f]&&w[f].stop&&s(w[f]);else for(f in w)w[f]&&w[f].stop&&Un.test(f)&&s(w[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 i,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),i=f.length;i--;)f[i].elem===this&&f[i].queue===e&&(f[i].anim.stop(!0),f.splice(i,1));for(i=0;i<h;i++)s[i]&&s[i].finish&&s[i].finish.call(this);delete n.finish})}}),o.each(["toggle","show","hide"],function(e,i){var n=o.fn[i];o.fn[i]=function(s,c,f){return s==null||typeof s=="boolean"?n.apply(this,arguments):this.animate(Fr(i,!0),s,c,f)}}),o.each({slideDown:Fr("show"),slideUp:Fr("hide"),slideToggle:Fr("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,i){o.fn[e]=function(n,s,c){return this.animate(i,n,s,c)}}),o.timers=[],o.fx.tick=function(){var e,i=0,n=o.timers;for(_t=Date.now();i<n.length;i++)e=n[i],!e()&&n[i]===e&&n.splice(i--,1);n.length||o.fx.stop(),_t=void 0},o.fx.timer=function(e){o.timers.push(e),o.fx.start()},o.fx.interval=13,o.fx.start=function(){Kt||(Kt=!0,cr())},o.fx.stop=function(){Kt=null},o.fx.speeds={slow:600,fast:200,_default:400},o.fn.delay=function(e,i){return e=o.fx&&o.fx.speeds[e]||e,i=i||"fx",this.queue(i,function(n,s){var c=l.setTimeout(n,e);s.stop=function(){l.clearTimeout(c)}})},function(){var e=K.createElement("input"),i=K.createElement("select"),n=i.appendChild(K.createElement("option"));e.type="checkbox",H.checkOn=e.value!=="",H.optSelected=n.selected,e=K.createElement("input"),e.value="t",e.type="radio",H.radioValue=e.value==="t"}();var P,T=o.expr.attrHandle;o.fn.extend({attr:function(e,i){return St(this,o.attr,e,i,arguments.length>1)},removeAttr:function(e){return this.each(function(){o.removeAttr(this,e)})}}),o.extend({attr:function(e,i,n){var s,c,f=e.nodeType;if(!(f===3||f===8||f===2)){if(typeof e.getAttribute=="undefined")return o.prop(e,i,n);if((f!==1||!o.isXMLDoc(e))&&(c=o.attrHooks[i.toLowerCase()]||(o.expr.match.bool.test(i)?P:void 0)),n!==void 0){if(n===null){o.removeAttr(e,i);return}return c&&"set"in c&&(s=c.set(e,n,i))!==void 0?s:(e.setAttribute(i,n+""),n)}return c&&"get"in c&&(s=c.get(e,i))!==null?s:(s=o.find.attr(e,i),s==null?void 0:s)}},attrHooks:{type:{set:function(e,i){if(!H.radioValue&&i==="radio"&&Ie(e,"input")){var n=e.value;return e.setAttribute("type",i),n&&(e.value=n),i}}}},removeAttr:function(e,i){var n,s=0,c=i&&i.match(vt);if(c&&e.nodeType===1)for(;n=c[s++];)e.removeAttribute(n)}}),P={set:function(e,i,n){return i===!1?o.removeAttr(e,n):e.setAttribute(n,n),n}},o.each(o.expr.match.bool.source.match(/\w+/g),function(e,i){var n=T[i]||o.find.attr;T[i]=function(s,c,f){var h,w,E=c.toLowerCase();return f||(w=T[E],T[E]=h,h=n(s,c,f)!=null?E:null,T[E]=w),h}});var N=/^(?:input|select|textarea|button)$/i,U=/^(?:a|area)$/i;o.fn.extend({prop:function(e,i){return St(this,o.prop,e,i,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[o.propFix[e]||e]})}}),o.extend({prop:function(e,i,n){var s,c,f=e.nodeType;if(!(f===3||f===8||f===2))return(f!==1||!o.isXMLDoc(e))&&(i=o.propFix[i]||i,c=o.propHooks[i]),n!==void 0?c&&"set"in c&&(s=c.set(e,n,i))!==void 0?s:e[i]=n:c&&"get"in c&&(s=c.get(e,i))!==null?s:e[i]},propHooks:{tabIndex:{get:function(e){var i=o.find.attr(e,"tabindex");return i?parseInt(i,10):N.test(e.nodeName)||U.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),H.optSelected||(o.propHooks.selected={get:function(e){var i=e.parentNode;return i&&i.parentNode&&i.parentNode.selectedIndex,null},set:function(e){var i=e.parentNode;i&&(i.selectedIndex,i.parentNode&&i.parentNode.selectedIndex)}}),o.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){o.propFix[this.toLowerCase()]=this});function V(e){var i=e.match(vt)||[];return i.join(" ")}function q(e){return e.getAttribute&&e.getAttribute("class")||""}function X(e){return Array.isArray(e)?e:typeof e=="string"?e.match(vt)||[]:[]}o.fn.extend({addClass:function(e){var i,n,s,c,f,h,w,E=0;if(G(e))return this.each(function(k){o(this).addClass(e.call(this,k,q(this)))});if(i=X(e),i.length){for(;n=this[E++];)if(c=q(n),s=n.nodeType===1&&" "+V(c)+" ",s){for(h=0;f=i[h++];)s.indexOf(" "+f+" ")<0&&(s+=f+" ");w=V(s),c!==w&&n.setAttribute("class",w)}}return this},removeClass:function(e){var i,n,s,c,f,h,w,E=0;if(G(e))return this.each(function(k){o(this).removeClass(e.call(this,k,q(this)))});if(!arguments.length)return this.attr("class","");if(i=X(e),i.length){for(;n=this[E++];)if(c=q(n),s=n.nodeType===1&&" "+V(c)+" ",s){for(h=0;f=i[h++];)for(;s.indexOf(" "+f+" ")>-1;)s=s.replace(" "+f+" "," ");w=V(s),c!==w&&n.setAttribute("class",w)}}return this},toggleClass:function(e,i){var n=typeof e,s=n==="string"||Array.isArray(e);return typeof i=="boolean"&&s?i?this.addClass(e):this.removeClass(e):G(e)?this.each(function(c){o(this).toggleClass(e.call(this,c,q(this),i),i)}):this.each(function(){var c,f,h,w;if(s)for(f=0,h=o(this),w=X(e);c=w[f++];)h.hasClass(c)?h.removeClass(c):h.addClass(c);else(e===void 0||n==="boolean")&&(c=q(this),c&&le.set(this,"__className__",c),this.setAttribute&&this.setAttribute("class",c||e===!1?"":le.get(this,"__className__")||""))})},hasClass:function(e){var i,n,s=0;for(i=" "+e+" ";n=this[s++];)if(n.nodeType===1&&(" "+V(q(n))+" ").indexOf(i)>-1)return!0;return!1}});var te=/\r/g;o.fn.extend({val:function(e){var i,n,s,c=this[0];return arguments.length?(s=G(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(w){return w==null?"":w+""})),i=o.valHooks[this.type]||o.valHooks[this.nodeName.toLowerCase()],(!i||!("set"in i)||i.set(this,h,"value")===void 0)&&(this.value=h))})):c?(i=o.valHooks[c.type]||o.valHooks[c.nodeName.toLowerCase()],i&&"get"in i&&(n=i.get(c,"value"))!==void 0?n:(n=c.value,typeof n=="string"?n.replace(te,""):n==null?"":n)):void 0}}),o.extend({valHooks:{option:{get:function(e){var i=o.find.attr(e,"value");return i!=null?i:V(o.text(e))}},select:{get:function(e){var i,n,s,c=e.options,f=e.selectedIndex,h=e.type==="select-one",w=h?null:[],E=h?f+1:c.length;for(f<0?s=E:s=h?f:0;s<E;s++)if(n=c[s],(n.selected||s===f)&&!n.disabled&&(!n.parentNode.disabled||!Ie(n.parentNode,"optgroup"))){if(i=o(n).val(),h)return i;w.push(i)}return w},set:function(e,i){for(var n,s,c=e.options,f=o.makeArray(i),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,i){if(Array.isArray(i))return e.checked=o.inArray(o(e).val(),i)>-1}},H.checkOn||(o.valHooks[this].get=function(e){return e.getAttribute("value")===null?"on":e.value})}),H.focusin="onfocusin"in l;var xe=/^(?:focusinfocus|focusoutblur)$/,Ce=function(e){e.stopPropagation()};o.extend(o.event,{trigger:function(e,i,n,s){var c,f,h,w,E,k,R,j,F=[n||K],I=W.call(e,"type")?e.type:e,ie=W.call(e,"namespace")?e.namespace.split("."):[];if(f=j=h=n=n||K,!(n.nodeType===3||n.nodeType===8)&&!xe.test(I+o.event.triggered)&&(I.indexOf(".")>-1&&(ie=I.split("."),I=ie.shift(),ie.sort()),E=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=ie.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+ie.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=n),i=i==null?[e]:o.makeArray(i,[e]),R=o.event.special[I]||{},!(!s&&R.trigger&&R.trigger.apply(n,i)===!1))){if(!s&&!R.noBubble&&!de(n)){for(w=R.delegateType||I,xe.test(w+I)||(f=f.parentNode);f;f=f.parentNode)F.push(f),h=f;h===(n.ownerDocument||K)&&F.push(h.defaultView||h.parentWindow||l)}for(c=0;(f=F[c++])&&!e.isPropagationStopped();)j=f,e.type=c>1?w:R.bindType||I,k=(le.get(f,"events")||Object.create(null))[e.type]&&le.get(f,"handle"),k&&k.apply(f,i),k=E&&f[E],k&&k.apply&&sr(f)&&(e.result=k.apply(f,i),e.result===!1&&e.preventDefault());return e.type=I,!s&&!e.isDefaultPrevented()&&(!R._default||R._default.apply(F.pop(),i)===!1)&&sr(n)&&E&&G(n[I])&&!de(n)&&(h=n[E],h&&(n[E]=null),o.event.triggered=I,e.isPropagationStopped()&&j.addEventListener(I,Ce),n[I](),e.isPropagationStopped()&&j.removeEventListener(I,Ce),o.event.triggered=void 0,h&&(n[E]=h)),e.result}},simulate:function(e,i,n){var s=o.extend(new o.Event,n,{type:e,isSimulated:!0});o.event.trigger(s,null,i)}}),o.fn.extend({trigger:function(e,i){return this.each(function(){o.event.trigger(e,i,this)})},triggerHandler:function(e,i){var n=this[0];if(n)return o.event.trigger(e,i,n,!0)}}),H.focusin||o.each({focus:"focusin",blur:"focusout"},function(e,i){var n=function(s){o.event.simulate(i,s.target,o.event.fix(s))};o.event.special[i]={setup:function(){var s=this.ownerDocument||this.document||this,c=le.access(s,i);c||s.addEventListener(e,n,!0),le.access(s,i,(c||0)+1)},teardown:function(){var s=this.ownerDocument||this.document||this,c=le.access(s,i)-1;c?le.access(s,i,c):(s.removeEventListener(e,n,!0),le.remove(s,i))}}});var Se=l.location,We={guid:Date.now()},Me=/\?/;o.parseXML=function(e){var i,n;if(!e||typeof e!="string")return null;try{i=new l.DOMParser().parseFromString(e,"text/xml")}catch(s){}return n=i&&i.getElementsByTagName("parsererror")[0],(!i||n)&&o.error("Invalid XML: "+(n?o.map(n.childNodes,function(s){return s.textContent}).join(`
`):e)),i};var at=/\[\]$/,Zt=/\r?\n/g,Jr=/^(?:submit|button|image|reset|file)$/i,zn=/^(?:input|select|textarea|keygen)/i;function fr(e,i,n,s){var c;if(Array.isArray(i))o.each(i,function(f,h){n||at.test(e)?s(e,h):fr(e+"["+(typeof h=="object"&&h!=null?f:"")+"]",h,n,s)});else if(!n&&be(i)==="object")for(c in i)fr(e+"["+c+"]",i[c],n,s);else s(e,i)}o.param=function(e,i){var n,s=[],c=function(f,h){var w=G(h)?h():h;s[s.length]=encodeURIComponent(f)+"="+encodeURIComponent(w==null?"":w)};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)fr(n,e[n],i,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")&&zn.test(this.nodeName)&&!Jr.test(e)&&(this.checked||!Xt.test(e))}).map(function(e,i){var n=o(this).val();return n==null?null:Array.isArray(n)?o.map(n,function(s){return{name:i.name,value:s.replace(Zt,`\r
`)}}):{name:i.name,value:n.replace(Zt,`\r
`)}}).get()}});var ss=/%20/g,Vn=/#.*$/,qn=/([?&])_=[^&]*/,Bi=/^(.*?):[ \t]*([^\r\n]*)$/mg,Ao=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Do=/^(?:GET|HEAD)$/,Fo=/^\/\//,os={},Gn={},ls="*/".concat("*"),Yn=K.createElement("a");Yn.href=Se.href;function us(e){return function(i,n){typeof i!="string"&&(n=i,i="*");var s,c=0,f=i.toLowerCase().match(vt)||[];if(G(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,i,n,s){var c={},f=e===Gn;function h(w){var E;return c[w]=!0,o.each(e[w]||[],function(k,R){var j=R(i,n,s);if(typeof j=="string"&&!f&&!c[j])return i.dataTypes.unshift(j),h(j),!1;if(f)return!(E=j)}),E}return h(i.dataTypes[0])||!c["*"]&&h("*")}function Xn(e,i){var n,s,c=o.ajaxSettings.flatOptions||{};for(n in i)i[n]!==void 0&&((c[n]?e:s||(s={}))[n]=i[n]);return s&&o.extend(!0,e,s),e}function Lo(e,i,n){for(var s,c,f,h,w=e.contents,E=e.dataTypes;E[0]==="*";)E.shift(),s===void 0&&(s=e.mimeType||i.getResponseHeader("Content-Type"));if(s){for(c in w)if(w[c]&&w[c].test(s)){E.unshift(c);break}}if(E[0]in n)f=E[0];else{for(c in n){if(!E[0]||e.converters[c+" "+E[0]]){f=c;break}h||(h=c)}f=f||h}if(f)return f!==E[0]&&E.unshift(f),n[f]}function Ro(e,i,n,s){var c,f,h,w,E,k={},R=e.dataTypes.slice();if(R[1])for(h in e.converters)k[h.toLowerCase()]=e.converters[h];for(f=R.shift();f;)if(e.responseFields[f]&&(n[e.responseFields[f]]=i),!E&&s&&e.dataFilter&&(i=e.dataFilter(i,e.dataType)),E=f,f=R.shift(),f){if(f==="*")f=E;else if(E!=="*"&&E!==f){if(h=k[E+" "+f]||k["* "+f],!h){for(c in k)if(w=c.split(" "),w[1]===f&&(h=k[E+" "+w[0]]||k["* "+w[0]],h)){h===!0?h=k[c]:k[c]!==!0&&(f=w[0],R.unshift(w[1]));break}}if(h!==!0)if(h&&e.throws)i=h(i);else try{i=h(i)}catch(j){return{state:"parsererror",error:h?j:"No conversion from "+E+" to "+f}}}}return{state:"success",data:i}}o.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Se.href,type:"GET",isLocal:Ao.test(Se.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,i){return i?Xn(Xn(e,o.ajaxSettings),i):Xn(o.ajaxSettings,e)},ajaxPrefilter:us(os),ajaxTransport:us(Gn),ajax:function(e,i){typeof e=="object"&&(i=e,e=void 0),i=i||{};var n,s,c,f,h,w,E,k,R,j,F=o.ajaxSetup({},i),I=F.context||F,ie=F.context&&(I.nodeType||I.jquery)?o(I):o.event,ve=o.Deferred(),ne=o.Callbacks("once memory"),ze=F.statusCode||{},Ue={},ct={},De="canceled",me={readyState:0,getResponseHeader:function(ke){var je;if(E){if(!f)for(f={};je=Bi.exec(c);)f[je[1].toLowerCase()+" "]=(f[je[1].toLowerCase()+" "]||[]).concat(je[2]);je=f[ke.toLowerCase()+" "]}return je==null?null:je.join(", ")},getAllResponseHeaders:function(){return E?c:null},setRequestHeader:function(ke,je){return E==null&&(ke=ct[ke.toLowerCase()]=ct[ke.toLowerCase()]||ke,Ue[ke]=je),this},overrideMimeType:function(ke){return E==null&&(F.mimeType=ke),this},statusCode:function(ke){var je;if(ke)if(E)me.always(ke[me.status]);else for(je in ke)ze[je]=[ze[je],ke[je]];return this},abort:function(ke){var je=ke||De;return n&&n.abort(je),st(0,je),this}};if(ve.promise(me),F.url=((e||F.url||Se.href)+"").replace(Fo,Se.protocol+"//"),F.type=i.method||i.type||F.method||F.type,F.dataTypes=(F.dataType||"*").toLowerCase().match(vt)||[""],F.crossDomain==null){w=K.createElement("a");try{w.href=F.url,w.href=w.href,F.crossDomain=Yn.protocol+"//"+Yn.host!=w.protocol+"//"+w.host}catch(ke){F.crossDomain=!0}}if(F.data&&F.processData&&typeof F.data!="string"&&(F.data=o.param(F.data,F.traditional)),cs(os,F,i,me),E)return me;k=o.event&&F.global,k&&o.active++==0&&o.event.trigger("ajaxStart"),F.type=F.type.toUpperCase(),F.hasContent=!Do.test(F.type),s=F.url.replace(Vn,""),F.hasContent?F.data&&F.processData&&(F.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&(F.data=F.data.replace(ss,"+")):(j=F.url.slice(s.length),F.data&&(F.processData||typeof F.data=="string")&&(s+=(Me.test(s)?"&":"?")+F.data,delete F.data),F.cache===!1&&(s=s.replace(qn,"$1"),j=(Me.test(s)?"&":"?")+"_="+We.guid+++j),F.url=s+j),F.ifModified&&(o.lastModified[s]&&me.setRequestHeader("If-Modified-Since",o.lastModified[s]),o.etag[s]&&me.setRequestHeader("If-None-Match",o.etag[s])),(F.data&&F.hasContent&&F.contentType!==!1||i.contentType)&&me.setRequestHeader("Content-Type",F.contentType),me.setRequestHeader("Accept",F.dataTypes[0]&&F.accepts[F.dataTypes[0]]?F.accepts[F.dataTypes[0]]+(F.dataTypes[0]!=="*"?", "+ls+"; q=0.01":""):F.accepts["*"]);for(R in F.headers)me.setRequestHeader(R,F.headers[R]);if(F.beforeSend&&(F.beforeSend.call(I,me,F)===!1||E))return me.abort();if(De="abort",ne.add(F.complete),me.done(F.success),me.fail(F.error),n=cs(Gn,F,i,me),!n)st(-1,"No Transport");else{if(me.readyState=1,k&&ie.trigger("ajaxSend",[me,F]),E)return me;F.async&&F.timeout>0&&(h=l.setTimeout(function(){me.abort("timeout")},F.timeout));try{E=!1,n.send(Ue,st)}catch(ke){if(E)throw ke;st(-1,ke)}}function st(ke,je,Zr,Hi){var ft,dr,hr,ot,er,xt=je;E||(E=!0,h&&l.clearTimeout(h),n=void 0,c=Hi||"",me.readyState=ke>0?4:0,ft=ke>=200&&ke<300||ke===304,Zr&&(ot=Lo(F,me,Zr)),!ft&&o.inArray("script",F.dataTypes)>-1&&o.inArray("json",F.dataTypes)<0&&(F.converters["text script"]=function(){}),ot=Ro(F,ot,me,ft),ft?(F.ifModified&&(er=me.getResponseHeader("Last-Modified"),er&&(o.lastModified[s]=er),er=me.getResponseHeader("etag"),er&&(o.etag[s]=er)),ke===204||F.type==="HEAD"?xt="nocontent":ke===304?xt="notmodified":(xt=ot.state,dr=ot.data,hr=ot.error,ft=!hr)):(hr=xt,(ke||!xt)&&(xt="error",ke<0&&(ke=0))),me.status=ke,me.statusText=(je||xt)+"",ft?ve.resolveWith(I,[dr,xt,me]):ve.rejectWith(I,[me,xt,hr]),me.statusCode(ze),ze=void 0,k&&ie.trigger(ft?"ajaxSuccess":"ajaxError",[me,F,ft?dr:hr]),ne.fireWith(I,[me,xt]),k&&(ie.trigger("ajaxComplete",[me,F]),--o.active||o.event.trigger("ajaxStop")))}return me},getJSON:function(e,i,n){return o.get(e,i,n,"json")},getScript:function(e,i){return o.get(e,void 0,i,"script")}}),o.each(["get","post"],function(e,i){o[i]=function(n,s,c,f){return G(s)&&(f=f||c,c=s,s=void 0),o.ajax(o.extend({url:n,type:i,dataType:f,data:s,success:c},o.isPlainObject(n)&&n))}}),o.ajaxPrefilter(function(e){var i;for(i in e.headers)i.toLowerCase()==="content-type"&&(e.contentType=e.headers[i]||"")}),o._evalUrl=function(e,i,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,i,n)}})},o.fn.extend({wrapAll:function(e){var i;return this[0]&&(G(e)&&(e=e.call(this[0])),i=o(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&i.insertBefore(this[0]),i.map(function(){for(var n=this;n.firstElementChild;)n=n.firstElementChild;return n}).append(this)),this},wrapInner:function(e){return G(e)?this.each(function(i){o(this).wrapInner(e.call(this,i))}):this.each(function(){var i=o(this),n=i.contents();n.length?n.wrapAll(e):i.append(e)})},wrap:function(e){var i=G(e);return this.each(function(n){o(this).wrapAll(i?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 Io={0:200,1223:204},Kr=o.ajaxSettings.xhr();H.cors=!!Kr&&"withCredentials"in Kr,H.ajax=Kr=!!Kr,o.ajaxTransport(function(e){var i,n;if(H.cors||Kr&&!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]);i=function(w){return function(){i&&(i=n=h.onload=h.onerror=h.onabort=h.ontimeout=h.onreadystatechange=null,w==="abort"?h.abort():w==="error"?typeof h.status!="number"?c(0,"error"):c(h.status,h.statusText):c(Io[h.status]||h.status,h.statusText,(h.responseType||"text")!=="text"||typeof h.responseText!="string"?{binary:h.response}:{text:h.responseText},h.getAllResponseHeaders()))}},h.onload=i(),n=h.onerror=h.ontimeout=i("error"),h.onabort!==void 0?h.onabort=n:h.onreadystatechange=function(){h.readyState===4&&l.setTimeout(function(){i&&n()})},i=i("abort");try{h.send(e.hasContent&&e.data||null)}catch(w){if(i)throw w}},abort:function(){i&&i()}}}),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 i,n;return{send:function(s,c){i=o("<script>").attr(e.scriptAttrs||{}).prop({charset:e.scriptCharset,src:e.url}).on("load error",n=function(f){i.remove(),n=null,f&&c(f.type==="error"?404:200,f.type)}),K.head.appendChild(i[0])},abort:function(){n&&n()}}}});var fs=[],Qn=/(=)\?(?=&|$)|\?\?/;o.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=fs.pop()||o.expando+"_"+We.guid++;return this[e]=!0,e}}),o.ajaxPrefilter("json jsonp",function(e,i,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=G(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,h?e[h]=e[h].replace(Qn,"$1"+s):e.jsonp!==!1&&(e.url+=(Me.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=i.jsonpCallback,fs.push(s)),f&&G(c)&&c(f[0]),f=c=void 0}),"script"}),H.createHTMLDocument=function(){var e=K.implementation.createHTMLDocument("").body;return e.innerHTML="<form></form><form></form>",e.childNodes.length===2}(),o.parseHTML=function(e,i,n){if(typeof e!="string")return[];typeof i=="boolean"&&(n=i,i=!1);var s,c,f;return i||(H.createHTMLDocument?(i=K.implementation.createHTMLDocument(""),s=i.createElement("base"),s.href=K.location.href,i.head.appendChild(s)):i=K),c=tt.exec(e),f=!n&&[],c?[i.createElement(c[1])]:(c=qr([e],i,f),f&&f.length&&o(f).remove(),o.merge([],c.childNodes))},o.fn.load=function(e,i,n){var s,c,f,h=this,w=e.indexOf(" ");return w>-1&&(s=V(e.slice(w)),e=e.slice(0,w)),G(i)?(n=i,i=void 0):i&&typeof i=="object"&&(c="POST"),h.length>0&&o.ajax({url:e,type:c||"GET",dataType:"html",data:i}).done(function(E){f=arguments,h.html(s?o("<div>").append(o.parseHTML(E)).find(s):E)}).always(n&&function(E,k){h.each(function(){n.apply(this,f||[E.responseText,k,E])})}),this},o.expr.pseudos.animated=function(e){return o.grep(o.timers,function(i){return e===i.elem}).length},o.offset={setOffset:function(e,i,n){var s,c,f,h,w,E,k,R=o.css(e,"position"),j=o(e),F={};R==="static"&&(e.style.position="relative"),w=j.offset(),f=o.css(e,"top"),E=o.css(e,"left"),k=(R==="absolute"||R==="fixed")&&(f+E).indexOf("auto")>-1,k?(s=j.position(),h=s.top,c=s.left):(h=parseFloat(f)||0,c=parseFloat(E)||0),G(i)&&(i=i.call(e,n,o.extend({},w))),i.top!=null&&(F.top=i.top-w.top+h),i.left!=null&&(F.left=i.left-w.left+c),"using"in i?i.using.call(e,F):j.css(F)}},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 i,n,s=this[0];if(!!s)return s.getClientRects().length?(i=s.getBoundingClientRect(),n=s.ownerDocument.defaultView,{top:i.top+n.pageYOffset,left:i.left+n.pageXOffset}):{top:0,left:0}},position:function(){if(!!this[0]){var e,i,n,s=this[0],c={top:0,left:0};if(o.css(s,"position")==="fixed")i=s.getBoundingClientRect();else{for(i=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:i.top-c.top-o.css(s,"marginTop",!0),left:i.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||Dt})}}),o.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,i){var n=i==="pageYOffset";o.fn[e]=function(s){return St(this,function(c,f,h){var w;if(de(c)?w=c:c.nodeType===9&&(w=c.defaultView),h===void 0)return w?w[i]:c[f];w?w.scrollTo(n?w.pageXOffset:h,n?h:w.pageYOffset):c[f]=h},e,s,arguments.length)}}),o.each(["top","left"],function(e,i){o.cssHooks[i]=Mi(H.pixelPosition,function(n,s){if(s)return s=ur(n,i),Yr.test(s)?o(n).position()[i]+"px":s})}),o.each({Height:"height",Width:"width"},function(e,i){o.each({padding:"inner"+e,content:i,"":"outer"+e},function(n,s){o.fn[s]=function(c,f){var h=arguments.length&&(n||typeof c!="boolean"),w=n||(c===!0||f===!0?"margin":"border");return St(this,function(E,k,R){var j;return de(E)?s.indexOf("outer")===0?E["inner"+e]:E.document.documentElement["client"+e]:E.nodeType===9?(j=E.documentElement,Math.max(E.body["scroll"+e],j["scroll"+e],E.body["offset"+e],j["offset"+e],j["client"+e])):R===void 0?o.css(E,k,w):o.style(E,k,R,w)},i,h?c:void 0,h)}})}),o.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,i){o.fn[i]=function(n){return this.on(i,n)}}),o.fn.extend({bind:function(e,i,n){return this.on(e,null,i,n)},unbind:function(e,i){return this.off(e,null,i)},delegate:function(e,i,n,s){return this.on(i,e,n,s)},undelegate:function(e,i,n){return arguments.length===1?this.off(e,"**"):this.off(i,e||"**",n)},hover:function(e,i){return this.mouseenter(e).mouseleave(i||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,i){o.fn[i]=function(n,s){return arguments.length>0?this.on(i,null,n,s):this.trigger(i)}});var Mo=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;o.proxy=function(e,i){var n,s,c;if(typeof i=="string"&&(n=e[i],i=e,e=n),!!G(e))return s=u.call(arguments,2),c=function(){return e.apply(i||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=Ie,o.isFunction=G,o.isWindow=de,o.camelCase=bt,o.type=be,o.now=Date.now,o.isNumeric=function(e){var i=o.type(e);return(i==="number"||i==="string")&&!isNaN(e-parseFloat(e))},o.trim=function(e){return e==null?"":(e+"").replace(Mo,"")},typeof define=="function"&&define.amd&&define("jquery",[],function(){return o});var No=l.jQuery,Oo=l.$;return o.noConflict=function(e){return l.$===o&&(l.$=Oo),e&&l.jQuery===o&&(l.jQuery=No),o},typeof t=="undefined"&&(l.jQuery=l.$=o),o})});var za=aa(ha());var rn=class{constructor(t,r){t=t||[],this.lines=t,this.text=r,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,r){if(this.offset2loc)for(var a=0;a<=r;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((r,a)=>Zi(t,r,vr(t)?"arraybuffer":"text"))}async getFileData(t){var r="presets/"+this.preset_id+"/"+t,a=await this.getRemoteFile(r);return a&&console.log("read",r,a.length,"bytes"),a}async setFileData(t,r){}};var si=class{constructor(t,r){this.basefs=t,this.overlayfs=r}async getFileData(t){var r=await this.overlayfs.getFileData(t);return r==null?this.basefs.getFileData(t):r}async setFileData(t,r){return await this.overlayfs.setFileData(t,r),this.basefs.setFileData(t,r)}},ma=class{constructor(t){this.store=t}async getFileData(t){return this.store.getItem(t)}async setFileData(t,r){return this.store.setItem(t,r)}};var va=class{constructor(t,r,a,u){this.filedata={};this.pendingWorkerMessages=0;this.tools_preloaded={};this.isCompiling=!1;this.filename2path={};this.worker=t,this.platform_id=r,this.platform=a,this.filesystem=u,t.onmessage=d=>{this.receiveWorkerMessage(d.data)}}receiveWorkerMessage(t){var r=this.pendingWorkerMessages>1;r?(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)}preloadWorker(t){var r=this.platform.getToolForFilename(t);r&&!this.tools_preloaded[r]&&(this.worker.postMessage({preload:r,platform:this.platform_id}),this.tools_preloaded[r]=!0)}pushAllFiles(t,r){t.push(r);var a=sa(this.mainPath);a.length>0&&a!="local"&&t.push(a+"/"+r)}parseIncludeDependencies(t){let r=[],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(r,a[1])}else if(this.platform_id.startsWith("verilog")){let u=/^\s*(`include|[.]include)\s+"(.+?)"/gmi;for(;a=u.exec(t);)this.pushAllFiles(r,a[2]);let d=/^\s*\$(include|\$dofile|\$write_image_in_table)\('(.+?)'/gmi;for(;a=d.exec(t);)this.pushAllFiles(r,a[2]);let m=/^\s*([.]arch)\s+(\w+)/gmi;for(;a=m.exec(t);)this.pushAllFiles(r,a[2]+".json");let y=/\$readmem[bh]\("(.+?)"/gmi;for(;a=y.exec(t);)this.pushAllFiles(r,a[1])}else{let u=/^\s*[.#%]?(include|incbin)\s+"(.+?)"/gmi;for(;a=u.exec(t);)this.pushAllFiles(r,a[2]);let d=/^\s*([;']|[/][/])#resource\s+"(.+?)"/gm;for(;a=d.exec(t);)this.pushAllFiles(r,a[2]);let m=/^\s+(USE|ASM)\s+(\S+[.]\S+)/gm;for(;a=m.exec(t);)this.pushAllFiles(r,a[2]);let y=/^\s*(import|embed)\s*"(.+?)";/gmi;for(;a=y.exec(t);)a[1]=="import"?this.pushAllFiles(r,a[2]+".wiz"):this.pushAllFiles(r,a[2]);let b=/^\s*(import)\s*"(.+?)"/gmi;for(;a=b.exec(t);)this.pushAllFiles(r,a[2])}return r}parseLinkDependencies(t){let r=[],a;if(!this.platform_id.startsWith("verilog")){let u=/^\s*([;]|[/][/])#link\s+"(.+?)"/gm;for(;a=u.exec(t);)this.pushAllFiles(r,a[2])}return r}loadFileDependencies(t){let r=this.parseIncludeDependencies(t),a=this.parseLinkDependencies(t),u=r.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,r){this.filesystem.setFileData(t,r)}buildWorkerMessage(t){this.preloadWorker(this.mainPath);var r={updates:[],buildsteps:[]},a=this.stripLocalPath(this.mainPath),u=this.getFile(this.mainPath),d=[];r.updates.push({path:a,data:u}),this.filename2path[a]=this.mainPath;for(var m of t)m.link||(r.updates.push({path:m.filename,data:m.data}),d.push(m.filename)),this.filename2path[m.filename]=m.path;r.buildsteps.push({path:a,files:[a].concat(d),platform:this.platform_id,tool:this.platform.getToolForFilename(this.mainPath),mainfile:!0});for(var m of t)m.data&&m.link&&(this.preloadWorker(m.filename),r.updates.push({path:m.filename,data:m.data}),r.buildsteps.push({path:m.filename,files:[m.filename].concat(d),platform:this.platform_id,tool:this.platform.getToolForFilename(m.path)}));return this.dataItems&&(r.setitems=this.dataItems),r}async loadFiles(t){var r=[],a=(m,y)=>{r.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 r}getFile(t){return this.filedata[t]}iterateFiles(t){for(var r in this.filedata)t(r,this.getFile(r))}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 r=typeof t=="string"?t:"";return this.loadFileDependencies(r).then(a=>{a||(a=[]);var u=this.buildWorkerMessage(a);this.worker.postMessage(u),this.isCompiling=!0})}updateFile(t,r){this.filedata[t]!=r&&(this.updateFileInStore(t,r),this.filedata[t]=r,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 r in this.listings){var a=this.listings[r];a.lines&&(a.sourcefile=new rn(a.lines,a.text)),a.asmlines&&(a.assemblyfile=new rn(a.asmlines,a.text))}}}processBuildResult(t){this.processBuildListings(t),this.processBuildSegments(t)}processBuildSegments(t){var r=this.platform.getMemoryMap&&this.platform.getMemoryMap().main||[];t.segments&&(r=r.concat(t.segments||[])),r.sort((a,u)=>a.start-u.start),this.segments=r}getListings(){return this.listings}getListingForFile(t){var r=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)==r)return a[d]}stripLocalPath(t){if(this.mainPath){var r=sa(this.mainPath);r!=""&&t.startsWith(r)&&(t=t.substring(r.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,r){this.id2window={};this.id2createfn={};this.id2showfn={};this.id2div={};this.containerdiv=t,this.project=r,this.undofiles=[]}isWindow(t){return this.id2createfn[t]!=null}setCreateFunc(t,r){this.id2createfn[t]=r}setShowFunc(t,r){this.id2showfn[t]=r}create(t){var r=this.id2window[t];r||(console.log("creating window",t),r=this.id2window[t]=this.id2createfn[t](t));var a=this.id2div[t];return a||(a=this.id2div[t]=r.createDiv(this.containerdiv),ya(a).hide()),r}createOrShow(t,r){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(r),this.activeid=t,a}put(t,r){this.id2window[t]=r}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,r){var a=this.id2window[t];a&&a.setText&&typeof r=="string"?(a.setText(r),this.undofiles.push(t)):this.project.updateFile(t,r)}undoStep(){var t=this.undofiles.pop(),r=this.id2window[t];r&&r.undoStep?r.undoStep():bootbox.alert("No more steps to undo.")}updateAllOpenWindows(t){for(var r in this.id2window){var a=this.id2window[r];a&&a.setText&&t.getItem(r).then(u=>{this.updateFile(r,u)})}}findWindowWithFilePrefix(t){t=wt(pt(t));for(var r in this.id2createfn)if(!(r.toLowerCase().endsWith(".h")||r.toLowerCase().endsWith(".inc")||r.toLowerCase().endsWith(".bas"))&&wt(pt(r))==t)return r;return null}};var tl=`$NAME
=====
[Open this project in 8bitworkshop](http://8bitworkshop.com/redir.html?platform=$PLATFORM&githubURL=$GITHUBURL&file=$MAINFILE).
`;function oi(){for(var l={},t=0;t<localStorage.length;t++){var r=localStorage.key(t);if(r.startsWith("__repo__")){var a=JSON.parse(localStorage.getItem(r)),u=r.substring("__repo__".length);l[u]=a}}return l}function an(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,r,a,u){this.githubCons=t,this.githubToken=r,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((r,a)=>{r()});var t=new firebase.auth.GithubAuthProvider;return t.addScope("repo"),firebase.auth().signInWithPopup(t).then(r=>{this.githubToken=r.credential.accessToken;var a=r.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,r)=>{t()})}isFileIgnored(t){return t=t.toUpperCase(),!!(t.startsWith("LICENSE")||t.startsWith("README")||t.startsWith("."))}async getGithubSession(t){var r=an(t);if(!r)throw new Error("Please enter a valid GitHub URL.");var a=oi()[r.repopath],u=r.branch||a&&a.branch,d=this.github.repos(r.user,r.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:r.user,reponame:r.repo,repopath:r.repopath,branch:u,subtreepath:r.subtreepath,prefix:"",repo:d,platform_id:this.project?this.project.platform_id:a?a.platform_id:null};return m}getGithubHEADTree(t){var r;return this.getGithubSession(t).then(a=>(r=a,r.repo.git.refs.heads(r.branch).fetch())).then(a=>(r.head=a,r.sha=a.object.sha,r.repo.git.trees(r.sha).fetch())).then(a=>{if(r.subtreepath){for(let u of a.tree)if(u.type=="tree"&&u.path==r.subtreepath&&u.sha)return r.repo.git.trees(u.sha).fetch();throw Error("Cannot find subtree '"+r.subtreepath+"' in tree "+a.sha)}return a}).then(a=>(r.tree=a,r))}bind(t,r){var a="__repo__"+t.repopath;if(r){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 r;return this.getGithubSession(t).then(a=>(r=a,r.repo.contents("README.md").read())).catch(a=>(console.log(a),console.log("no README.md found"),r.repo.fetch().then(u=>""))).then(a=>{var u;if(u=/8bitworkshop.com[^)]+file=([^)&]+)/.exec(a),u&&u[1]&&(console.log("main path: '"+u[1]+"'"),r.mainPath=u[1]),u=/8bitworkshop.com[^)]+platform=([A-Za-z0-9._\-]+)/.exec(a),u){if(console.log("platform id: '"+u[1]+"'"),r.platform_id&&!r.platform_id.startsWith(u[1]))throw Error("Platform mismatch: Repository is "+u[1]+", you have "+this.project.platform_id+" selected.");r.platform_id=u[1]}return this.bind(r,!0),r})}pull(t,r){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 L=a.prefix+m.path,W=m.size,fe=b.encoding,z=b.content;if(b.encoding=="base64"){var H=Xi(atob(z)),G=vr(m.path,H);z=G?H:Ji(H)}return b.size!=z.length&&(z=z.slice(0,b.size)),(r||this.store).setItem(L,z)});d.push(y)}else console.log("ignoring "+m.path)}),Promise.all(d)}).then(u=>a)}importAndPull(t){return this.import(t).then(r=>this.pull(t))}publish(t,r,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:r,private:u,auto_init:!1,license_template:a}).then(b=>{d=b;var L=tl;L=L.replace(/\$NAME/g,encodeURIComponent(t)),L=L.replace(/\$PLATFORM/g,encodeURIComponent(m)),L=L.replace(/\$GITHUBURL/g,encodeURIComponent(d.htmlUrl)),L=L.replace(/\$MAINFILE/g,encodeURIComponent(y));var W={message:"8bitworkshop: updated metadata in README.md",content:btoa(L)};return d.contents("README.md").add(W)}).then(()=>this.getGithubSession(d.htmlUrl))}commit(t,r,a){var u;return r||(r="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(Qi(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:r,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(r=>t)}deleteRepository(t){return this.getGithubSession(t).then(r=>r.repo.remove())}};var li=window.matchMedia&&window.matchMedia("only screen and (max-width: 760px)").matches;function Ut(l,t){var r=$(document.createElement("div"));return l&&r.appendTo(l),t&&r.addClass(t),r}function js(l,t){var r=l.charCoords({line:t,ch:0},"local").top,a=l.getScrollerElement().offsetHeight/2;l.scrollTo(null,r-a-5)}function Bs(l,t){var r=document.createElement("span");return r.setAttribute("class",t),r.appendChild(document.createTextNode(l)),r}var sn=64,rl=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},ui=class{constructor(t,r){this.updateTimer=null;this.dirtylisting=!0;this.errormsgs=[];this.errorwidgets=[];this.errormarks=[];this.path=t,this.mode=r}createDiv(t){var r=document.createElement("div");r.setAttribute("class","editor"),t.appendChild(r);var a=pe.getFile(this.path),u=a&&this.mode=="verilog"&&/__asm\b([\s\S]+?)\b__endasm\b/.test(a);return this.newEditor(r,u),a&&(this.setText(a),this.editor.setSelection({line:0,ch:0},{line:0,ch:0},{scroll:!0})),this.setupEditor(),r}setVisible(t){t&&this.editor.focus()}newEditor(t,r){var a=Ea[this.mode]||Ea.default,u=r||a.isAsm,d=!!a.lineWrap,m=a.theme||Ea.default.theme,y=!a.noLineNumbers&&!li;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||li)&&(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,r)=>{this.editorChanged()}),this.editor.on("cursorActivity",t=>{this.inspectUnderCursor()}),this.editor.on("gutterClick",(t,r)=>{this.toggleBreakpoint(r)}),this.editor.setOption("mode",this.mode),this.editor.on("beforeChange",(t,r)=>{Hs.input&&r.text&&(r.text=r.text.map(Hs.input))})}inspectUnderCursor(){var t=this.editor.getCursor(!0),r=this.editor.getCursor(!1);if(t.line==r.line&&t.ch<r.ch&&r.ch-t.ch<80){var a=this.editor.getSelection();this.inspect(a)}else this.inspect(null)}inspect(t){var r;if(D.inspect&&(r=D.inspect(t)),this.inspectWidget&&(this.inspectWidget.clear(),this.inspectWidget=null),r){var a=Bs(r,"tooltipinfoline"),u=this.editor.getCursor().line;this.inspectWidget=this.editor.addLineWidget(u,a,{above:!1})}}setText(t){var r,a,u=this.editor.getValue();u!=t&&(this.editor.setValue(t),u==""&&this.editor.clearHistory())}insertText(t){var r=this.editor.getCursor();this.editor.replaceRange(t,r,r)}highlightLines(t,r){var a="hilite-span",u={className:a,inclusiveLeft:!0};this.markHighlight=this.editor.markText({line:t,ch:0},{line:r,ch:0},u),this.editor.scrollIntoView({from:{line:t,ch:0},to:{line:r,ch:0}})}replaceSelection(t,r,a){this.editor.setSelection(this.editor.posFromIndex(t),this.editor.posFromIndex(r)),this.editor.replaceSelection(a)}getValue(){return this.editor.getValue()}getPath(){return this.path}addError(t){if(!t.path||this.path.endsWith(t.path)){var r=this.editor.lineCount(),a=t.line-1;if((isNaN(a)||a<0||a>=r)&&(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,r){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:r}),$(a).mouseover(u=>{this.expandErrors()})}addErrorLine(t,r){var a=Bs(r,"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,rl);for(var r of t)this.addError(r)}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 r of t)if(r.offset>=0&&this.setGutter("gutter-offset",r.line-1,Fe(r.offset&65535,4)),r.insns){var a=r.insns.length>9?"...":r.insns;if(this.setGutter("gutter-bytes",r.line-1,a),r.iscode){if(r.cycles)this.setGutter("gutter-clock",r.line-1,r.cycles+"");else if(D.getOpcodeMetadata){var u=parseInt(r.insns.split(" ")[0],16),d=D.getOpcodeMetadata(u,r.offset);if(d&&d.minCycles){var m=d.minCycles+"";this.setGutter("gutter-clock",r.line-1,m)}}}}}setGutter(t,r,a){var u=this.editor.lineInfo(r);if(!(u&&u.gutterMarkers&&u.gutterMarkers[t])){var d=document.createTextNode(a);this.editor.setGutterMarker(r,t,d)}}setGutterBytes(t,r){this.setGutter("gutter-bytes",t-1,r)}setTimingResult(t){if(this.editor.clearGutter("gutter-bytes"),this.sourcefile!=null)for(let m of Object.keys(this.sourcefile.line2offset)){var r=this.sourcefile.line2offset[m],a=t.pc2minclocks[r],u=t.pc2maxclocks[r];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,r){var a=D.isBlocked&&D.isBlocked(),u=y=>{var b=document.createElement("div"),L=a?"currentpc-marker-blocked":"currentpc-marker";b.classList.add(L),b.appendChild(document.createTextNode("\u25B6")),this.editor.setGutterMarker(y.line-1,"gutter-info",b)};if(this.clearCurrentLine(r),t){u(t),r&&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=rr&&rr.c;if(!t&&D.getCPUState&&!D.isRunning()&&(t=D.getCPUState()),t){var r=t&&(t.EPC||t.PC),a=this.sourcefile.findLineForOffset(r,sn);return a}}}refreshDebugState(t){this.clearCurrentLine(t);var r=this.getActiveLine();r&&this.setCurrentLine(r,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 r=this.sourcefile.line2offset[t];if(r>=0)return r;t--}return-1}undoStep(){this.editor.execCommand("undo")}toggleBreakpoint(t){if(this.sourcefile!=null){var r=this.sourcefile.line2offset[t+1];ci(r)}}},Sa=1024,on=class{getDisasmView(){return this.disasmview}createDiv(t){var r=document.createElement("div");return r.setAttribute("class","editor"),t.appendChild(r),this.newEditor(r),r}newEditor(t){this.disasmview=CodeMirror(t,{mode:"z80",theme:"cobalt",tabSize:8,readOnly:!0,styleActiveLine:!0})}refresh(t){let r=rr||D.saveState(),a=r.c?r.c.PC:0,u=0,d=0,m=D.debugSymbols&&D.debugSymbols.addr2symbol||{},y=(W,fe)=>{let z="",H=0;for(;H<fe;){let G=W+H|0,de=D.disassemble(G,D.readAddress.bind(D)),K="",ye="";for(let _e=0;_e<de.nbytes;_e++)K+=Fe(D.readAddress(G+_e));for(;K.length<14;)K+=" ";let Pe=de.line;if(m&&de.isaddr&&(Pe=Pe.replace(/([^#])[$]([0-9A-F]+)/,(_e,...o)=>{let Y=parseInt(o[1],16),ae=m[Y];return ae?o[0]+ae:(ae=m[Y-1],ae?o[0]+ae+"+1":_e)})),m){let _e=m[G];_e&&(ye="; "+_e)}z+=Fe(G,4)+" "+ni(K,14)+" "+ni(Pe,30)+ye+`
`,G==a&&(d=u),u++,H+=de.nbytes||1}return z};var b=a<0?a-Sa:Math.max(0,a-Sa);let L=y(b,a-b)+y(a,Sa);this.disasmview.setValue(L),t&&this.disasmview.setCursor(d,0),js(this.disasmview,d)}getCursorPC(){var t=this.disasmview.getCursor().line;if(t>=0){var r=this.disasmview.getLine(t).trim().split(/\s+/);if(r&&r.length>=1){var a=parseInt(r[0],16);if(a>=0)return a}}return-1}},_a=class extends on{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 r=this.assemblyfile.text,a=this.getDisasmView();if(a.setValue(r),!!D.saveState){var u=rr||D.saveState(),d=u.c?u.c.EPC||u.c.PC:0;if(d>=0&&this.assemblyfile){var m=this.assemblyfile.findLineForOffset(d,sn);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 ln=class{constructor(){this.recreateOnResize=!0;this.totalRows=5120}createDiv(t){var r=document.createElement("div");return r.setAttribute("class","memdump"),t.appendChild(r),this.showMemoryWindow(t,r),this.maindiv=r}showMemoryWindow(t,r){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}}),$(r).append(this.memorylist.container),this.tick(),lt&&this.dumplines&&this.scrollToAddress(lt.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,r)=>{var a=$(r),u=parseInt(a.attr("data-index")),d=a.text(),m=this.getMemoryLineAt(u);d!=m&&a.text(m)})}getMemoryLineAt(t){var r=t*16,a=0,u=16,d;if(this.getDumpLines()){var m=this.dumplines[t];if(m)r=m.a&65520,a=m.a-r,u=a+m.l,d=m.s;else return"."}for(var y=Fe(r+a,4)+" ",b=0;b<a;b++)y+=" ";a>8&&(y+=" ");for(var b=a;b<u;b++){var L=this.readAddress(r+b);b==8&&(y+=" "),y+=" "+(typeof L=="number"?Fe(L,2):"??")}for(var b=u;b<16;b++)y+=" ";return d&&(y+=" "+d),y}readAddress(t){return D.readAddress(t)}getDumpLineAt(t){var r=this.dumplines[t];if(r)return r.a+" "+r.s}getDumpLines(){var t=D.debugSymbols&&D.debugSymbols.addr2symbol||{};if(this.dumplines==null){this.dumplines=[];var r=0,a;for(let y of Object.keys(t)){var u=parseInt(y),d=t[u];if(a)for(Us(a)&&(a="");r<u&&this.dumplines.length<65536;){var m=r+16&1048560;m>u&&(m=u),this.dumplines.push({a:r,l:m-r,s:a}),r=m}a=d}}return this.dumplines}getMemorySegment(t){if(lt){if(t>=lt.data_start&&t<lt.data_start+lt.data_size)return D.getSP&&t>=D.getSP()-15?"stack":"data";if(t>=lt.code_start&&t<lt.code_start+(lt.code_size||lt.rom_size))return"code"}var r=pe.segments;if(r){for(var a of r)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 r=0;r<this.dumplines.length;r++)if(this.dumplines[r].a>=t)return r}},Ta=class extends ln{constructor(){super(...arguments);this.totalRows=2048}readAddress(t){return D.readVRAMAddress(t)}getMemorySegment(t){return"video"}getDumpLines(){return null}},Ca=class{constructor(t,r){this.recreateOnResize=!0;this.path=t,this.data=r}createDiv(t){return this.vlist=new ai(t),this.vlist.create(t,this.data.length+15>>4,this.getMemoryLineAt.bind(this)),this.vlist.maindiv}getMemoryLineAt(t){for(var r=t*16,a=0,u=16,d=Fe(r+a,4)+" ",m=0;m<a;m++)d+=" ";a>8&&(d+=" ");for(var m=a;m<u;m++){var y=this.data[r+m];m==8&&(d+=" "),d+=" "+(y>=0?Fe(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,r){if(r){var a=$('<div class="segment-offset" style="grid-column-start:1"/>');a.text("$"+Fe(t.start,4)),this.maindiv.append(a)}var u=$('<div class="segment"/>');if(r||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 r=0,a=-1;for(var u of t)u.start>r&&this.addSegment({name:"",start:r,size:u.start-r},!0),this.addSegment(u,a!=u.start),a=u.start,r=u.start+u.size}}},kt=4278190080,br=class{constructor(){this.cumulativeData=!1;var t=160,r=262;try{t=Math.ceil(D.machine.cpuCyclesPerLine)||t,r=Math.ceil(D.machine.numTotalScanlines)||r}catch(a){}this.cyclesPerLine=t,this.totalScanlines=r}addr2symbol(t){var r=D.debugSymbols&&D.debugSymbols.addr2symbol||{};return r[t]}addr2str(t){var r=this.addr2symbol(t);return typeof r=="string"?"$"+Fe(t)+" ("+r+")":"$"+Fe(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=D.startProbing(),this.probe.singleFrame=!this.cumulativeData,this.tick()):(this.probe&&(this.probe.singleFrame=!0),D.stopProbing(),this.probe=null)}redraw(t){var r=this.probe;if(!(!r||!r.idx)){var a=0,u=0,d=0;this.sp=0;for(var m=0;m<r.idx;m++){var y=r.buf[m],b=y&65535,L=y>>16&255,W=y&kt;switch(W){case Z.SCANLINE:a++,u=0;break;case Z.FRAME:a=0,u=0;break;case Z.CLOCKS:u+=b,d+=b;break;case Z.SP_PUSH:case Z.SP_POP:this.sp=b;default:t(W,b,u,a,d,L);break}}}}opToString(t,r,a){var u="";switch(t){case Z.EXECUTE:u="Exec";break;case Z.MEM_READ:u="Read";break;case Z.MEM_WRITE:u="Write";break;case Z.IO_READ:u="IO Read";break;case Z.IO_WRITE:u="IO Write";break;case Z.VRAM_READ:u="VRAM Read";break;case Z.VRAM_WRITE:u="VRAM Write";break;case Z.DMA_READ:u="DMA Read";break;case Z.DMA_WRITE:u="DMA Write";break;case Z.INTERRUPT:u="Interrupt";break;case Z.ILLEGAL:u="Error";break;case Z.WAIT:u="Wait";break;case Z.SP_PUSH:u="Stack Push";break;case Z.SP_POP:u="Stack Pop";break;default:return""}return typeof r=="number"&&(u+=" "+this.addr2str(r)),t&Z.HAS_VALUE&&typeof a=="number"&&(u+=" = $"+Fe(a,2)),u}getOpRGB(t,r){switch(t){case Z.EXECUTE:return 98305;case Z.MEM_READ:return 8388865;case Z.MEM_WRITE:return 65920;case Z.IO_READ:return 98432;case Z.IO_WRITE:return 12583296;case Z.DMA_READ:case Z.VRAM_READ:return 8421377;case Z.DMA_WRITE:case Z.VRAM_WRITE:return 4227264;case Z.INTERRUPT:return 4177727;case Z.ILLEGAL:return 4145151;case Z.WAIT:return 16727871;default:return 0}}},zs=class extends br{constructor(){super(...arguments);this.recreateOnResize=!0}createCanvas(t,r,a){var u=document.createElement("div"),d=document.createElement("canvas");return d.width=r,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=en(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,r){return null}getOpAtPos(t,r,a){t=t|0,r=r|0;let u=0;return this.redraw((d,m,y,b,L,W)=>{!u&&b==r&&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,r){t=t|0,r=r|0;var a="",u=null,d=[],m=-1;return this.redraw((y,b,L,W,fe,z)=>{switch(y){case Z.EXECUTE:u=this.addr2symbol(b)||u;break;case Z.SP_PUSH:d.push(u);break;case Z.SP_POP:u=d.pop();break}W==r&&L<=t&&(L!=m&&(a="",m=L),a==""&&u&&(a+=`
`+u),a+=`
`+this.opToString(y,b,z))}),"X: "+t+" Y: "+r+" "+a}refresh(){this.tick(),this.datau32.fill(kt)}tick(){super.tick(),this.drawImage()}drawImage(){this.ctx.putImageData(this.imageData,0,0)}clear(){this.datau32.fill(kt)}},Aa=class extends Pa{createDiv(t){return this.createCanvas(t,256,256)}initCanvas(){super.initCanvas(),this.canvas.onclick=t=>{var r=en(this.canvas,t),a=Math.floor(r.x)+Math.floor(r.y)*256,u=-1,d=-1;this.redraw((m,y)=>{d<0&&u>=0&&y==a&&(d=u),m==Z.EXECUTE&&(u=y)}),d>=0&&ci(d)}}clear(){for(var t=0;t<=65535;t++){var r=D.readAddress(t),a=r>>2|r&31;a|=a<<8|a<<16,this.datau32[t]=a|kt}}drawEvent(t,r,a,u){var d=this.getOpRGB(t,r);if(!!d){var m=r&255,y=r>>8&255,b=this.datau32[r&65535];b=b|d|kt,this.datau32[r&65535]=b}}getTooltipText(t,r){var a=(t&255)+(r<<8),u="",d=-1,m={},y=null,b=[];return this.redraw((L,W,fe,z,H,G)=>{switch(L){case Z.EXECUTE:d=W,y=this.addr2symbol(W)||y;break;case Z.SP_PUSH:b.push(y);break;case Z.SP_POP:y=b.pop();break}var de=L|d;W==a&&!m[de]&&(u==""&&y&&(u+=`
`+y),u+=`
PC `+this.addr2str(d)+" "+this.opToString(L,null,G),m[de]=1)}),this.addr2str(a)+u}},Vs=class extends Pa{initCanvas(){super.initCanvas(),this.canvas.onclick=t=>{var r=en(this.canvas,t),a=Math.floor(r.x),u=Math.floor(r.y),d=this.getOpAtPos(r.x,r.y,Z.EXECUTE);d&&(Rt("toline"),D.runEval(()=>{let m=D.getRasterScanline&&D.getRasterScanline()>=u;return m&&D.getRasterLineClock?m&&D.getRasterLineClock()>a:m}))}}drawEvent(t,r,a,u){var d=this.getOpRGB(t,r);if(!!d){var m=a+u*this.canvas.width,y=d|kt;this.datau32[m]|=y}}drawImage(){let t=kt;for(let r=0;r<this.datau32.length;r++)this.datau32[r]==kt?this.datau32[r]=t:t=this.datau32[r];super.drawImage()}},Da=class extends Vs{constructor(){super(...arguments);this.interrupt=0;this.rgb=0;this.lastpc=0}drawEvent(t,r,a,u){var d=a+u*this.canvas.width;if(t==Z.INTERRUPT&&(this.interrupt=1),this.interrupt==1&&t==Z.SP_PUSH&&(this.interrupt=r),this.interrupt>1&&this.sp>this.interrupt&&(this.interrupt=0),t==Z.MEM_WRITE&&(this.rgb|=47),t==Z.VRAM_WRITE&&(this.rgb|=16256),t==Z.IO_WRITE&&(this.rgb|=2047872),t==Z.IO_READ&&(this.rgb|=7936),t==Z.WAIT&&(this.rgb=32768),t==Z.ILLEGAL||t==Z.DMA_READ)this.datau32[d]=4279176975;else{let m=this.rgb;if(t==Z.EXECUTE){let y=this.sp&15;y>=8&&(y=16-y),Math.abs(this.lastpc)-r>16&&(y+=1),Math.abs(this.lastpc)-r>256&&(y+=1),m=this.rgb=526344*y+2105376,this.lastpc=r}this.interrupt&&(m|=8388672),this.datau32[d]==kt&&(this.datau32[d]=m|kt)}}},Fa=class extends br{constructor(){super(...arguments);this.recreateOnResize=!0}createDiv(t){return this.vlist=new ai(t),this.vlist.create(t,this.cyclesPerLine*this.totalScanlines,this.getMemoryLineAt.bind(this)),this.vlist.maindiv}getMemoryLineAt(t){var r="",a="seg_data",u=this.dumplines&&this.dumplines[t];if(u!=null){var d=u.info.join(", ");r="("+Ft(u.row,4)+", "+Ft(u.col,4)+") "+ni(u.asm||"",20)+d,d.indexOf("Write ")>=0&&(a="seg_io")}return{text:r,clas:a}}refresh(){this.tick()}tick(){let t=D instanceof fa||D instanceof ca;this.dumplines={},this.redraw((r,a,u,d,m,y)=>{t&&(m>>=2);var b=this.dumplines[m];switch(b==null&&(b={op:r,addr:a,row:d,col:u,asm:null,info:[]},this.dumplines[m]=b),r){case Z.EXECUTE:if(D.disassemble){var L=D.disassemble(a,D.readAddress.bind(D));b.asm=L&&L.line}break;default:var W=this.opToString(r,a,y);W!=""&&b.info.push(W);break}}),this.vlist.refresh()}},La=class extends br{constructor(){super(...arguments);this.recreateOnResize=!0}createDiv(t){return this.vlist=new ai(t),this.vlist.create(t,this.totalScanlines,this.getMemoryLineAt.bind(this)),this.vlist.maindiv}getMemoryLineAt(t){for(var r=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,L=L&kt;if(L==Z.EXECUTE)r+=",";else{var W=Fe(b);r+=W,m+=W.length-1}}else r+=m==d?"|":"."}return u[-1]&&(r+=" "+u[-1]),{text:r,clas:a}}refresh(){this.tick()}tick(){let t=D instanceof fa||D instanceof ca;this.dumplines={},this.redraw((r,a,u,d,m,y)=>{var b=this.dumplines[d];switch(b==null&&(this.dumplines[d]=b=[]),r){case Z.EXECUTE:var L=D.debugSymbols.addr2symbol[a];L&&(b[-1]=L);break;case Z.IO_READ:case Z.IO_WRITE:case Z.VRAM_READ:case Z.VRAM_WRITE:b[u]=r|a;break}}),this.vlist.refresh()}},Ra=class extends br{constructor(){super(...arguments);this.recreateOnResize=!0;this.cumulativeData=!0}createDiv(t){return D.debugSymbols&&D.debugSymbols.symbolmap?this.keys=Array.from(Object.keys(D.debugSymbols.symbolmap).filter(r=>!Us(r))):this.keys=["no symbols defined"],this.vlist=new ai(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 r=this.keys[t-1],a=this.dumplines&&this.dumplines[r];function u(y){var b=a[y]|0;return Ft(b?b.toString():"",8)}var d,m;return a!=null?(d=Ft(r,35)+u(Z.MEM_READ)+u(Z.MEM_WRITE),a[Z.EXECUTE]?m="seg_code":a[Z.IO_READ]||a[Z.IO_WRITE]?m="seg_io":m="seg_data"):(d=Ft(r,35),m="seg_unknown"),{text:d,clas:m}}refresh(){this.tick()}tick(){this.dumplines={},this.redraw((t,r,a,u,d,m)=>{var y=D.debugSymbols.addr2symbol[r];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 $c=Fs(),un=/([0#]?)([x$%]|\d'h)([0-9a-f]+)(?:[;].*)?|(\d'b|0b)([01]+)/gim;function il(l){return l.replace(/(\shex\s+)([0-9a-f]+)/ig,function(t,r,a){for(var u=r,d=0;d<a.length;d+=2)u+="0x"+a.substr(d,2)+",";return u})}function nl(l){for(var t=[],r;r=un.exec(l);){var a;typeof r[4]!="undefined"?a=parseInt(r[5],2):r[2].startsWith("%")||r[2].endsWith("b")?a=parseInt(r[3],2):r[2].startsWith("x")||r[2].startsWith("$")||r[2].endsWith("h")?a=parseInt(r[3],16):a=parseInt(r[3]),t.push(a)}return t}function al(l,t){for(var r="",a,u=0,d=0;a=un.exec(l);)r+=l.slice(u,un.lastIndex-a[0].length),u=un.lastIndex,typeof a[4]!="undefined"?r+=a[4]+t[d++].toString(2):a[2].startsWith("%")?r+=a[1]+"%"+t[d++].toString(2):a[2].endsWith("b")?r+=a[1]+a[2]+t[d++].toString(2):a[2].endsWith("h")?r+=a[1]+a[2]+t[d++].toString(16):a[2].startsWith("x")?r+=a[1]+"x"+Fe(t[d++]):a[2].startsWith("$")?r+=a[1]+"$"+Fe(t[d++]):r+=a[1]+t[d++].toString();return r+=l.slice(u),r=r.replace(/(\shex\s+)([,x0-9a-f]+)/ig,(m,y,b)=>{var L=y+b;return L=L.replace(/0x/ig,"").replace(/,/ig,""),L}),r}function qs(l,t){if(!t)return l;for(var r=0,a=0;a<t.length;a++){var u=t[a];u<0&&(u=-u-1,r^=1<<u),l&1<<a&&(r^=1<<u)}return r}function Gs(l,t){var r=t[l%t.length];return[r>>3,r&7]}function sl(l,t){for(var r=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(r*d/y),L=(1<<d)-1,W=t.pofs||b*a*u,fe=t.skip||0,z=t.wpimg||b*a,H=[],G=0;G<u;G++){for(var de=[],K=0;K<a;K++)for(var ye=t.flip?a-1-K:K,Pe=z*G+ye*b,be=0,_e=0;_e<r;_e++){var o=0,Y=qs(Pe,t.remap);t.reindex&&([Y,be]=Gs(_e,t.reindex),Y+=Pe);for(var ae=0;ae<m;ae++){var se=l[Y+ae*W+fe];o|=((t.brev?se>>y-be-d:se>>be)&L)<<ae*d}de.push(o),be+=d,be>=y&&!t.reindex&&(Pe+=1,be=0)}H.push(new Uint8Array(de))}return H}function ol(l,t){t.destfmt&&(t=t.destfmt);var r=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),L=(1<<d)-1,W=t.pofs||b*a*u,fe=t.skip||0,z=t.wpimg||b*a,H;m>0&&t.sl?H=new Uint8Array(z*u):y<=8?H=new Uint8Array(z*u*m):H=new Uint32Array(z*u*m);for(var G=0;G<u;G++)for(var de=l[G],K=0,ye=0;ye<a;ye++)for(var Pe=t.flip?a-1-ye:ye,be=G*z+Pe*b,_e=0,o=0;o<r;o++){var Y=de[K++],ae=qs(be,t.remap);t.reindex&&([ae,_e]=Gs(o,t.reindex),ae+=be);for(var se=0;se<m;se++){var Te=Y>>se*d&L;H[ae+se*W+fe]|=t.brev?Te<<y-_e-d:Te<<_e}_e+=d,_e>=y&&!t.reindex&&(be+=1,_e=0)}return H}function Ys(l,t,r,a,u,d,m){for(var y=[],b=0;b<l.length;b++){var L=l[b],W=4278190080;W|=(L>>t&(1<<r)-1)<<0+8-r,W|=(L>>a&(1<<u)-1)<<8+8-u,W|=(L>>d&(1<<m)-1)<<16+8-m,y.push(W)}return y}function ll(l){var t=l.pal;if(typeof t=="number"){var r=Math.floor(Math.abs(t/100)%10),a=Math.floor(Math.abs(t/10)%10),u=Math.floor(Math.abs(t)%10);return 1<<r+a+u}else{var d=Qs[t];if(d)return d.length;throw new Error("No palette named "+t)}}function Xs(l,t){var r=t.pal,a;if(typeof r=="number"){var u=Math.floor(Math.abs(r/100)%10),d=Math.floor(Math.abs(r/10)%10),m=Math.floor(Math.abs(r)%10);r>=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[r];if(y)a=new Uint32Array(l).map(b=>y[b&y.length-1]|4278190080);else throw new Error("No palette named "+r)}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]},ul={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 fi(l,t){if(l==null||t==null||l.length!==t.length)return!1;if(l===t)return!0;for(var r=0;r<l.length;r++)if(l[r]!==t[r])return!1;return!0}function cn(l,t){if(l==null||t==null||l.length!==t.length)return!1;if(l===t)return!0;for(var r=0;r<l.length;r++)if(!fi(l[r],t[r]))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{},fn=class extends Ia{constructor(t,r){super();this.project=t,this.fileid=r,this.label=r}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,r,a,u,d){super();this.project=t,this.fileid=r,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=al(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=il(t);var r=nl(t);return this.words=r,!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=ol(this.images,this.fmt),!0}updateRight(){return fi(this.words,this.left.words)?!1:(this.words=this.left.words,this.images=sl(this.words,this.fmt),!0)}},Js=class{constructor(t){this.palcols=t}indexOf(t){return this.palcols.indexOf(t)}},Ir=class extends zt{constructor(t,r){super();this.palindex=0;this.context=t,this.ncolors=1<<(r.bpp||1)*(r.np||1)}updateLeft(){this.right&&(this.rgbimgs=this.right.rgbimgs);var t=new Js(this.palette),r=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=r,!0}updateRight(){if(!this.updateRefs()&&cn(this.images,this.left.images))return!1;this.images=this.left.images;var t=this.palette.length-1;return this.rgbimgs=this.images.map(r=>{for(var a=new Uint32Array(r.length),u=0;u<r.length;u++)a[u]=this.palette[r[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])),fi(this.palette,t)?!1:(this.palette=t,!0)}};function cl(l){for(var t=new Map,r=new Uint32Array(l.length),a=0,u=0;u<l.length;u++){for(var d=l[u];t[d];)d^=++a;r[u]=d,t[d]=1}return r}var dn=class extends zt{constructor(t){super();this.palfmt=t}updateLeft(){return!0}updateRight(){return fi(this.words,this.left.words)?!1:(this.words=this.left.words,this.palette=cl(Xs(this.words,this.palfmt)),this.layout=ul[this.palfmt.layout],this.rgbimgs=[],this.palette.forEach(t=>{this.rgbimgs.push(new Uint32Array([t]))}),!0)}getAllColors(){for(var t=[],r=0;r<ll(this.palfmt);r++)t.push(r);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)),!cn(t,this.tilemap)}};var $a=class extends Ks{constructor(t){super(t)}updateLeft(){return!1}updateRight(){if(!this.updateRefs()&&fi(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 r=0,a,u=0;u<this.rows;u++)for(var d=0;d<this.cols;d++){var m=this.words[this.baseofs+r];if(typeof m=="undefined")throw Error("No name for address "+this.baseofs+" + "+r);var y=this.tilemap[m];if(!y)throw Error("No tilemap found for tile index "+m);a=r&11264|960|r&3072|r>>4&56|r>>2&7;for(var b=this.words[a],L=m^b<<9^2147483648,W=u*this.cols*8*8+d*8,fe=0,z=(d&2)+((r&64)>>4),H=(b>>z&3)<<2,G=0;G<8;G++){for(var de=0;de<8;de++){var K=y[fe++];K&&(K+=H),t[W++]=K}W+=this.cols*8-8}r++}return!0}},hn=class{recreate(t,r){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 L=new pn;L.width=this.width,L.height=this.height,L.recreate(),L.canvas.style.width=L.width*u+"px",L.canvas.title="$"+Fe(b),L.updateImage(y),$(L.canvas).addClass("asset_cell"),$(L.canvas).click(fe=>{r(b,L)}),m||(m=$("<span/>"),a.append(m)),m.append(L.canvas);var W=b%d==d-1;W&&(a.append($("<br/>")),m=null)})}};function yr(l,t){var r=$(document.createElement("div"));return l&&r.appendTo(l),t&&r.addClass(t),r}var Wa=class extends zt{constructor(t,r,a){super();this.context=t,this.parentdiv=r,this.fmt=a}updateLeft(){return!0}updateRight(){if(cn(this.rgbimgs,this.left.rgbimgs))return!1;this.rgbimgs=this.left.rgbimgs;var t=yr(this.parentdiv.empty(),"asset_dual"),r=yr(t),a=yr(t,"asset_editor").hide(),u=this.chooser=new hn;u.rgbimgs=this.rgbimgs,u.width=this.fmt.w||1,u.height=this.fmt.h||1,u.recreate(r,(y,b)=>{var L=Math.ceil(192/this.fmt.w),W=L*(this.fmt.aspect||1),fe=this.createEditor(a,b,W,L);this.context.setCurrentEditor(a,$(b.canvas),this),this.rgbimgs[y]=b.rgbdata});var d=this.left;if(d instanceof Ir&&d.paloptions.length>1){var m=$(document.createElement("select"));d.paloptions.forEach((y,b)=>{var L=$(document.createElement("option")).text(y.name).val(b).appendTo(m);b==d.palindex&&L.attr("selected","selected")}),m.appendTo(r).change(y=>{var b=$(y.target).val();d.palindex=b,d.refreshRight()})}return!0}createEditor(t,r,a,u){var d=new Zs;d.createWith(r),d.updateImage();for(var m=r.width*a,y=r.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,r,a){super();this.context=t,this.parentdiv=r,this.fmt=a}updateLeft(){return!0}updateRight(){if(cn(this.rgbimgs,this.left.rgbimgs))return!1;this.rgbimgs=this.left.rgbimgs;var t=yr(this.parentdiv.empty(),"asset_dual"),r=yr(t),a=yr(t,"asset_editor").hide(),u=new pn;return u.width=this.fmt.w,u.height=this.fmt.h,u.recreate(),u.updateImage(this.rgbimgs[0]),r.append(u.canvas),!0}},pn=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 r of this.peerviewers)r.ctx.putImageData(this.imagedata,0,0)}},Zs=class extends pn{constructor(){super(...arguments);this.curpalcol=-1;this.offscreen=new Map}getPositionFromEvent(t){var r=Math.floor(t.offsetX*this.width/$(this.canvas).width()),a=Math.floor(t.offsetY*this.height/$(this.canvas).height());return{x:r,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,r,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(L=>{$(document).off("mouseup");var W=this.getPositionFromEvent(L);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)}),r.empty(),this.createToolbarButtons(r[0]),r.append(this.canvas),r.append(this.createPaletteButtons()),this.setPaletteColor(1)}getPixel(t,r){if(t=Math.round(t),r=Math.round(r),t<0||t>=this.width||r<0||r>=this.height)return this.offscreen[t+","+r]|this.palette[0];var a=t+r*this.width;return this.rgbdata[a]}setPixel(t,r,a){if(t=Math.round(t),r=Math.round(r),t<0||t>=this.width||r<0||r>=this.height)this.offscreen[t+","+r]=a;else{var u=t+r*this.width,d=this.rgbdata[u];d!=a&&(this.rgbdata[u]=a,this.updateImage())}}createPaletteButtons(){this.palbtns=[];for(var t=yr(null,"asset_toolbar"),r=0;r<this.palette.length;r++){var a=$(document.createElement("button")).addClass("palbtn"),u=this.palette[r]&16777215,d="#"+Fe(Ki(u),6);a.click(this.setPaletteColor.bind(this,r)),a.css("backgroundColor",d).text(r.toString(16)),a.css("color",u&32768?"black":"white"),t.append(a),this.palbtns.push(a)}return t}createToolbarButtons(t){var r=new tn(t,null);r.add("ctrl+shift+h","Flip X","glyphicon-resize-horizontal",this.flipX.bind(this)),r.add("ctrl+shift+v","Flip Y","glyphicon-resize-vertical",this.flipY.bind(this)),r.add("ctrl+shift+9","Rotate","glyphicon-repeat",this.rotate90.bind(this)),r.add("ctrl+shift+left","Move Left","glyphicon-arrow-left",this.translate.bind(this,1,0)),r.add("ctrl+shift+right","Move Right","glyphicon-arrow-right",this.translate.bind(this,-1,0)),r.add("ctrl+shift+up","Move Up","glyphicon-arrow-up",this.translate.bind(this,0,1)),r.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 r=0,a=new Uint32Array(this.rgbdata.length),u=0;u<this.height;u++)for(var d=0;d<this.width;d++)a[r]=t(d,u),r++;this.rgbdata.set(a),this.commit()}rotate(t){var r=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*r+this.width/2-.5,L=y*a+m*r+this.height/2-.5;return this.getPixel(b,L)})}rotate90(){this.rotate(90)}flipX(){this.remapPixels((t,r)=>this.getPixel(this.width-1-t,r))}flipY(){this.remapPixels((t,r)=>this.getPixel(t,this.height-1-r))}translate(t,r){this.remapPixels((a,u)=>this.getPixel(a+t,u+r))}};var gn=Fs(),Ba=class{createDiv(t){return this.maindiv=Ut(t,"vertical-scroll"),this.maindiv[0]}clearAssets(){this.rootnodes=[],this.deferrednodes=[]}registerAsset(t,r,a){this.rootnodes.push(r),a?a>1?this.deferrednodes.push(r):this.deferrednodes.unshift(r):r.refreshRight()}getPalettes(t){var r=[];return this.rootnodes.forEach(a=>{for(;a!=null;){if(a instanceof dn){var u=a.palette;t==u.length&&r.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);r.push({node:a,name:d,palette:b})}else if(-y==t){var b=u.slice(m,m-y);b.reverse(),r.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),r.push({node:a,name:d,palette:b})}}});break}a=a.right}}),r}getTilemaps(t){var r=[];return this.rootnodes.forEach(a=>{for(;a!=null;){if(a instanceof Ir){var u=a.rgbimgs;u&&u.length>=t&&r.push({node:a,name:"Tilemap",images:a.images,rgbimgs:u})}a=a.right}}),r}isEditing(){return this.cureditordiv!=null}getCurrentEditNode(){return this.cureditnode}setCurrentEditor(t,r,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),r&&(this.cureditelem=r,this.cureditelem.addClass("selected"));a.left;)a=a.left;this.cureditnode=a}scanFileTextForAssets(t,r){for(var a=[],u=/[/;][*;]([{].+[}])[*;][/;]/g,d;d=u.exec(r);){var m=d.index+d[0].length,y;if(re.includes("verilog")?y=r.indexOf("end",m):d[0].startsWith(";;")?y=r.indexOf(";;",m):y=r.indexOf(";",m),y>m)try{var b=d[1].replace(/([A-Za-z]+):/g,'"$1":'),L=JSON.parse(b);a.push({fileid:t,fmt:L,start:m,end:y})}catch(_e){console.log(_e)}}for(var W=/DEF_METASPRITE_(\d+)x(\d+)[(](\w+),\s*(\w+),\s*(\w+)/gi;d=W.exec(r);){for(var fe=parseInt(d[1]),z=parseInt(d[2]),H=d[3],G=parseInt(d[4]),de=parseInt(d[5]),K=[],ye=0;ye<fe;ye++)for(var Pe=0;Pe<z;Pe++)K.push({x:ye*8,y:Pe*8,tile:G,attr:de});var be={defs:K,width:fe*8,height:z*8};a.push({fileid:t,label:H,meta:be})}return a}addPaletteEditorViews(t,r,a){var u=$('<div class="asset_dual"/>').appendTo(t),d=$('<div class="asset_editor"/>').hide(),m=[];r.getAllColors().forEach(H=>{m.push(new Uint32Array([H]))});var y=$("<table/>").appendTo(u);d.appendTo(u);var b=r.layout;if(!b){var L=r.palette.length,W=L>32?8:4;b=[];for(var fe=0;fe<L;fe+=W)b.push(["",fe,Math.min(L-fe,W)])}function z(H,G){var de=r.words[G],K=r.palette[G],ye="#"+Fe(Ki(K),6),Pe=K&32768?"black":"white";H.text(Fe(de,2)).css("background-color",ye).css("color",Pe)}b.forEach(([H,G,de])=>{if(G<r.palette.length){var K=$("<tr/>").appendTo(y);$("<td/>").text(H).appendTo(K);for(var ye=[],Pe=G;Pe<G+Math.abs(de);Pe++)ye.push(Pe);de<0&&ye.reverse(),ye.forEach(be=>{var _e=$("<td/>").addClass("asset_cell asset_editable").appendTo(K);z(_e,be),_e.click(o=>{var Y=new hn;Y.rgbimgs=m,Y.width=1,Y.height=1,Y.recreate(d,(ae,se)=>{a(be,ae),z(_e,be)}),this.setCurrentEditor(d,_e,r)})})}})}addPixelEditor(t,r,a){a.xform="scale(2)";var u=new Oa(a);r.addRight(u);var d=new Ir(this,a);u.addRight(d),d.addRight(new Wa(this,Ut(t),a))}addPaletteEditor(t,r,a){var u=new dn(a);r.addRight(u),r.refreshRight(),this.addPaletteEditorViews(t,u,(d,m)=>{console.log("set entry",d,"=",m),r.words[d]=m,u.words=null,u.updateRight(),u.refreshLeft()})}ensureFileDiv(t){var r=this.getFileDivId(t),a=$(document.getElementById(r));if(a.length===0){var u=Ut(this.maindiv,"asset_file"),d=Ut(u,"asset_file_header").text(t);a=Ut(u).attr("id",r).addClass("disable-select")}return a}refreshAssetsInFile(t,r){let a=0;if(re.startsWith("nes")&&t.endsWith(".chr")&&r instanceof Uint8Array){let u=new fn(ge,t),d={w:8,h:8,bpp:1,count:r.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(re.startsWith("nes")&&t.endsWith(".pal")&&r instanceof Uint8Array){let u=new fn(ge,t),d={pal:"nes",layout:"nes"};this.addPaletteEditor(this.ensureFileDiv(t),u,d),this.registerAsset("palette",u,0),a++}else if(typeof r=="string"){let u=this.scanFileTextForAssets(t,r);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 Ir(this,{w:8,h:8,bpp:4}));let L={w:8*(d.fmt.w||32),h:8*(d.fmt.h||30),count:1};y=y.addRight(new ja(this,Ut(this.ensureFileDiv(t)),L)),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 r of this.rootnodes)r!==this.getCurrentEditNode()&&r.refreshRight()}setVisible(t){t?gn.bind&&gn.bind("ctrl+z",ge.undoStep.bind(ge)):gn.unbind&&gn.unbind("ctrl+z")}};var di=256,eo=100,to=!1,hi=class{constructor(t,r){this.expanded=!1;this.parent=t,this.name=r,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 r="";if(t&&t.$$&&typeof t.$$=="function"&&this._content!=null&&(t=t.$$()),t==null)r=t+"";else if(typeof t=="number")t!=(t|0)?r=t.toString():r=t+" ($"+Fe(t)+")";else if(typeof t=="boolean")r=t.toString();else if(typeof t=="string")t.length<eo?r=t:r=t.substring(0,eo)+"...";else if(t.buffer&&t.length<=di)r=ks(t,0,t.length);else if(typeof t=="object"||typeof t=="function")if(this._content!=null){if(t.slice&&t.length>di){let b={},L=t;for(var a=di;t.length/a>di;)a*=2;for(let W=0;W<L.length;W+=a)b["$"+Fe(W)]={$$:()=>L.slice(W,W+a)};t=b}let m=t instanceof Array?Array.from(t.keys()):Object.getOwnPropertyNames(t);if(m.length>di){let b={},L=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]]=L[m[d]];b["["+fe+"...]"]=u}t=b,m=Object.getOwnPropertyNames(t)}let y=new Set(this.children.keys());m.forEach(b=>{var L=!to&&typeof b=="string"&&b.startsWith("$$");if(!L){let W=this.children.get(b);W==null&&(W=new hi(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 r=typeof t;this._inline.innerText!=r&&(this._inline.innerText=r)}};function ro(l,t){var r=new hi(null,null);r.view=t,r._content=l;var a=new hi(r,"/");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 D.getDebugTree()}},Ua=class extends br{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,r){return{$$SP:r,$$PC:t,count:0,startLine:null,endLine:null,calls:{}}}newRoot(t,r){this.stack.length==0?(this.graph=this.newNode(null,r),this.stack.unshift(this.graph)):r>this.stack[0].$$SP&&(this.graph=this.newNode(null,r),this.graph.calls[this.addr2str(t)]=this.stack[0],this.stack.unshift(this.graph))}getRootObject(){return this.redraw((t,r,a,u,d,m)=>{switch(t){case Z.SP_POP:this.newRoot(this.lastpc,this.lastsp);case Z.SP_PUSH:if(this.stack.length){let b=this.stack[this.stack.length-1];var y=this.lastsp-r;(y==2||y==3)&&r<b.$$SP&&(this.jsr=!0),(y==-2||y==-3)&&this.stack.length>1&&r>b.$$SP&&(this.rts=!0)}this.lastsp=r;break;case Z.EXECUTE:if(Math.abs(r-this.lastpc)>=4){if(this.jsr&&this.stack.length){let b=this.stack[this.stack.length-1],L=this.addr2str(r),W=b.calls[L];W==null?W=b.calls[L]=this.newNode(r,this.lastsp):W.$$PC==null&&(W.$$PC=r),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=r;break}}),this.graph&&(this.graph.$$Stack=this.stack),to?this.graph:this.graph&&this.graph.calls}};var Vt=aa(el()),fl=Zo(),Pt=Ko(),ee=oa(window.location.search||"?"),pi=Rr(ee.electron),it=Rr(ee.embed),mn,re,xr,Be,D,Va,gi=$("#controls_top"),qe,pe,ge,nt,qa,Ge,vn,Ye,lt,rr,mi,vi,bn=!1,Mr=!1,yn=null,no=null,Ga=!1,ao="c.PC == 0x6000",dl={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"},hl={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 bi(l,t,r,a){window.ga&&ga("send","event",l,t,r,a)}function Ee(l){Oe(!1),bootbox.alert({title:'<span class="glyphicon glyphicon-alert" aria-hidden="true"></span> Alert',message:Pt.sanitize(l)})}function It(l){Oe(!1),bootbox.alert(Pt.sanitize(l))}function pl(l){throw Ee(l),new Error(l)}function gl(){return new Worker("./gen/worker/bundle.js")}var Et=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){Et&&!it&&(Be&&re&&!pi?localStorage.setItem("__lastrepo_"+re,Be):localStorage.removeItem("__lastrepo_"+re),localStorage.setItem("__lastplatform",re),localStorage.setItem("__lastid_"+xr,t))}unsetLastPreset(){Et&&!it&&(delete ee.file,localStorage.removeItem("__lastid_"+xr))}getLastPreset(){return Et&&!it&&localStorage.getItem("__lastid_"+xr)}getLastPlatformID(){return Et&&!it&&localStorage.getItem("__lastplatform")}getLastRepoID(t){return Et&&!it&&t&&localStorage.getItem("__lastrepo_"+t)}shouldCompleteTour(){return Et&&!it&&!localStorage.getItem("8bitworkshop.hello")}completedTour(){Et&&!it&&localStorage.setItem("8bitworkshop.hello","true")}},wr=new so;function Ya(l,t){navigator.storage&&navigator.storage.persist?navigator.storage.persist().then(r=>{console.log("requestPersistPermission =",r),r?l&&!t&&It("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 ml(){return vn?vn.title||vn.name||pe.mainPath||"ROM":pe.mainPath||"ROM"}async function vl(){var l=new pa(re);return pi?(console.log("using electron with local filesystem",alternateLocalFilesystem),new si(l,alternateLocalFilesystem)):ee.localfs!=null?new si(l,await Pl(ee.localfs)):new si(l,new ma(Ye))}async function bl(){var l=await vl();pe=new va(gl(),re,D,l),ge=new xa($("#workspace")[0],pe),pe.callbackBuildResult=t=>{nu(t)},pe.callbackBuildStatus=t=>{yl(t)}}function yl(l){l?gi.addClass("is-busy"):gi.removeClass("is-busy"),$("#compile_spinner").css("visibility",l?"visible":"hidden")}function Xa(l,t){var r=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)),r.appendChild(a),{li:r,a}}function yi(){var l=$("#windowMenuList").empty(),t=!1;function r(b,L,W){t&&(l.append(document.createElement("hr")),t=!1);let{li:fe,a:z}=Xa(b,L);if(l.append(fe),W){var H=(G,de)=>{l.find("a").removeClass("dropdown-item-checked"),$(z).addClass("dropdown-item-checked")};ge.setCreateFunc(b,W),ge.setShowFunc(b,H),$(z).click(G=>{ge.createOrShow(b),yn=b})}}function a(b){var L=D.getToolForFilename(b),W=L&&dl[L];return new ui(b,W)}function u(b){r(b,wt(b),()=>{var L=pe.getFile(b);if(typeof L=="string")return a(b);if(L instanceof Uint8Array)return new Ca(b,L)})}u(pe.mainPath),pe.iterateFiles((b,L)=>{L&&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)&&r(m,wt(m),b=>new _a(b))}t=!0,D.disassemble&&D.saveState&&r("#disasm","Disassembly",()=>new on),D.readAddress&&r("#memory","Memory Browser",()=>new ln),pe.segments&&pe.segments.length&&r("#memmap","Memory Map",()=>new ka),D.readVRAMAddress&&r("#memvram","VRAM Browser",()=>new Ta),D.startProbing&&(r("#memheatmap","Memory Probe",()=>new Aa),r("#crtheatmap","CRT Probe",()=>new Da),r("#probelog","Probe Log",()=>new Fa),r("#scanlineio","Scanline I/O",()=>new La),r("#symbolprobe","Symbol Profiler",()=>new Ra),r("#callstack","Call Stack",()=>new Ua)),D.getDebugTree&&r("#debugview","Debug Tree",()=>new Ha),r("#asseteditor","Asset Editor",()=>new Ba)}function xl(l,t){if(t){var r=ee.highlight.split(","),a=parseInt(r[0])-1,u=parseInt(r[1])-1,d=ge.createOrShow(l);d.highlightLines(a,u)}}function oo(l){yi(),ge.createOrShow(l),pe.setMainFile(l),xl(l,ee.highlight)}async function wl(l){pe.mainPath=l,wr.setLastPreset(l);var t=await pe.loadFiles([l]);if(Ei=new Date,t&&t.length)oo(l);else{var r=await El(l);pe.filedata[l]=r||`
`,oo(l),ee.newfile?Ya(!0,!0):It('Could not find file "'+l+'". Loading default file.'),delete ee.newfile,_n()}}function Qa(l){if(l=="/")ee={repo:"/"};else if(l.indexOf("://")>=0){var t=an(l);t&&(ee={repo:t.repopath})}else ee.platform=re,ee.file=l;Nr()}async function El(l){var t=D.getToolForFilename(l);try{return await $.get("presets/"+gt(re)+"/skeleton."+t,"text")}catch(r){Ee("Could not load skeleton for "+re+"/"+t+"; using blank file")}}function Ja(l){return l.indexOf(" ")>=0?(Ee("No spaces in filenames, please."),!1):!0}function Sl(l){return bootbox.prompt({title:"Enter the name of your new main source file.",placeholder:"newfile"+D.getDefaultExtension(),callback:t=>{if(t&&t.trim().length>0){if(!Ja(t))return;t.indexOf(".")<0&&(t+=D.getDefaultExtension());var r=t;bi("workspace","file","new"),ee.newfile="1",Qa(r)}}}),!0}function _l(l){let t=$('<input type="file" multiple accept="*" style="display:none">'),r=t[0];t.change(a=>{Tl(r.files)}),t.click()}function Tl(l){console.log(l);var t=0;function r(){var a=l[t++];if(!a)console.log("Done uploading",t),t>2?(It("Files uploaded."),setTimeout(wi,1e3)):(ee.file=l[0].name,bootbox.confirm({message:"Open '"+Pt.sanitize(ee.file)+"' as main project file?",buttons:{confirm:{label:"Open As New Project"},cancel:{label:"Include/Link With Project Later"}},callback:m=>{m?Nr():setTimeout(wi,1e3)}})),bi("workspace","file","upload");else{var u=a.name,d=new FileReader;d.onload=function(m){var y=m.target.result,b=new Uint8Array(y);vr(u,b)||(b=Ji(b).replace(`\r
`,`
`)),ge.updateFile(u,b),console.log("Uploaded "+u+" "+b.length+" bytes"),r()},d.readAsArrayBuffer(a)}}l&&r()}async function Cl(l){var t=window.showDirectoryPicker;t||Ee("This browser can't open local files on your computer, yet. Try Chrome.");var r=await t(),a=r.name,u="__localfs__"+a,d={handle:r},m=za.createInstance({name:u,version:2});await m.setItem(u,d),ee={localfs:a},Nr(!0)}async function kl(l){return new Promise((t,r)=>{bootbox.prompt(Pt.sanitize(l),a=>{t(a)})})}async function Pl(l){let t={mode:"readwrite"};var r="__localfs__"+l,a=za.createInstance({name:r,version:2}),u=await a.getItem(r),d=u.handle;console.log(u,d);var m=await d.queryPermission(t);if(console.log(m),m!=="granted"&&(await kl("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 L=await b.getFile();console.log("getFileData",L);let W=await(vr(y)?L.binary():L.text());return console.log(b,L,W),W},setFileData:async(y,b)=>{}}}function ut(){return wt(pe.mainPath)}function Al(){return wt(ge.getActiveID())}var Ka;function lo(l){for(var t=l+"=",r=document.cookie.split(";"),a=0;a<r.length;a++){for(var u=r[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 Er(){if(!Ka){await Lt("lib/octokat.js"),await Lt("https://www.gstatic.com/firebasejs/8.8.1/firebase-app.js"),await Lt("https://www.gstatic.com/firebasejs/8.8.1/firebase-auth.js"),await Lt("https://8bitworkshop.com/config.js");var l=lo("__github_key");Ka=new wa(Octokat,l,Ye,pe),console.log("loaded github service")}return Ka}function xi(){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 r,a=an(l);if(!a){Ee("Could not parse Github URL.");return}var u=oi()[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 Er();return m.import(l).then(y=>(r=y,Gt(.75),m.pull(l,d))).then(y=>{ee={repo:r.repopath},Oe(!1),bi("sync","import",l),Nr(t)}).catch(y=>{Oe(!1),console.log(y),Ee("Could not import "+l+"."+y)})}}async function Dl(l){var t=await Er();t.login().then(()=>{It("You are signed in to Github.")}).catch(r=>{Ee("Could not sign in."+r)})}async function Fl(l){var t=await Er();t.logout().then(()=>{It("You are logged out of Github.")})}function Ll(l){var t=$("#importGithubModal"),r=$("#importGithubButton");t.modal("show"),r.off("click").on("click",()=>{var a=$("#importGithubURL").val()+"";t.modal("hide"),Za(a,!1)})}function Rl(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"),r=$("#publishGithubButton");$("#githubRepoName").val(pt(wt(pe.mainPath))),t.modal("show"),r.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 Er();b.login().then(()=>(Gt(.25),b.publish(a,u,m,d))).then(L=>(y=L,Gt(.5),Be=ee.repo=y.repopath,uo("initial import from 8bitworkshop.com"))).then(()=>{bi("sync","publish",d?"":a),Za(y.url,!1)}).catch(L=>{Oe(!1),console.log(L),Ee("Could not publish GitHub repository: "+L)})})}}function Il(l){var t=xi();if(!!t){var r=$("#pushGithubModal"),a=$("#pushGithubButton");r.modal("show"),a.off("click").on("click",()=>{var u=$("#githubCommitMsg").val()+"";r.modal("hide"),uo(u)})}}function Ml(l){var t=xi();!t||bootbox.confirm("Pull from repository and replace all local files? Any changes you've made will be overwritten.",async r=>{if(r){Oe(!0);var a=await Er();a.pull(t).then(u=>{Oe(!1),ge.updateAllOpenWindows(Ye)})}})}function Nl(l){return new Promise((t,r)=>{var a=l.commit.files;if(console.log(a),a.length==0){Oe(!1),It("No files changed.");return}var u="";for(var d of a)u+=Pt.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=xi();if(!!t){var r=[];for(var a in pe.filedata){var u=pe.stripLocalPath(a),d=pe.filedata[a];u&&d&&r.push({path:u,data:d})}if(Ge instanceof Uint8Array){let y="bin/"+ut()+".rom";r.push({path:y,data:Ge})}Oe(!0);var m=await Er();return m.login().then(()=>(Gt(.5),m.commit(t,l,r))).then(y=>Nl(y)).then(y=>m.push(y)).then(y=>(Oe(!1),It("Pushed files to "+t),y)).catch(y=>{Oe(!1),console.log(y),Ee("Could not push GitHub repository: "+y)})}}function Ol(){var l=xi();!l||bootbox.prompt("<p>Are you sure you want to delete this repository ("+Pt.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"&&$l()})}function $l(){var l=xi(),t;Oe(!0),Ye.keys().then(r=>Promise.all(r.map(a=>Ye.removeItem(a)))).then(()=>(t=Er(),t.getGithubSession(l))).then(r=>{t.bind(r,!1)}).then(()=>{Oe(!1),ee={repo:"/"},Nr()})}function Wl(l){return Ge==null?(Ee("Please fix errors before sharing."),!0):Ge instanceof Uint8Array?(jl(),Lt("lib/liblzg.js").then(()=>{var t=Ss(window.Module,Array.from(Ge));window.Module=null;var r=btoa(Qi(t)),a={p:re,r},u=$.param(a),d=Bl(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 jl(){console.log("clipboard"),import("./clipboard-JDH3YSSJ.js").then(l=>{let t=l.default;new t(".btn")})}function Bl(l,t){console.log(l);var r=window.location,a=r.pathname.replace("index.html",""),u=r.host=="8bitworkshop.com"?"https:":r.protocol,d=u+"//"+r.host+a+t+"?"+l;return d}function Hl(l){var t=lt&&lt.code_start;Lt("lib/c2t.js").then(()=>{var r="",a=function(fe){r+=fe+`
`},u=window.c2t({noInitialRun:!0,print:a,printErr:a}),d=u.FS,m=ut()+".bin",y=ut()+".wav";d.writeFile(m,Ge,{encoding:"binary"});var b=["-2bc",m+","+t.toString(16),y];u.callMain(b);var L=d.readFile(y,{encoding:"binary"});if(L){var W=new Blob([L],{type:"audio/wav"});(0,Vt.saveAs)(W,y),r+="Then connect your audio output to the cassette input, turn up the volume, and play the audio file.",It(r)}})}function Ul(l){Lt("lib/makewav.js").then(()=>{let t="",r=function(y){t+=y+`
`};var a=pt(ut());let u=a+".bin",d=a+".wav";window.makewav({noInitialRun:!1,print:r,printErr:r,arguments:["-ts","-f0","-v10",u],preRun:y=>{y.FS.writeFile(u,Ge,{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,Vt.saveAs)(fe,d),t+=`
Connect your audio output to the SuperCharger input, turn up the volume, and play the audio file.`,It(t)}})})}function zl(l){if(Ge==null)return Ee("Please fix errors before exporting."),!0;var t;switch(gt(re)){case"vcs":t=Ul;break;case"apple2":t=Hl;break}if(t===void 0)return Ee("Cassette export is not supported on this platform."),!0;t(l)}function Vl(l){var t=ge.getActive();if(t&&t.setText){var r=ge.getActiveID();$.get("presets/"+gt(re)+"/"+r,a=>{bootbox.confirm("Reset '"+Pt.sanitize(r)+"' 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 ql(l){var t=ge.getActive();if(t&&t.getPath){var r=ge.getActiveID();bootbox.confirm("Delete '"+Pt.sanitize(r)+"'?",a=>{a&&Ye.removeItem(r).then(()=>{ee.file==r?(wr.unsetLastPreset(),Nr()):(wi(),It("Deleted "+r))})})}else Ee("Cannot delete the active window.")}function Gl(l){var t=ge.getActive();if(t&&t.getPath&&pe.getFile(t.getPath())){var r=ge.getActiveID();bootbox.prompt({title:"Rename '"+Pt.sanitize(r)+"' to?",value:r,callback:a=>{var u=pe.getFile(t.getPath());if(a&&a!=r&&u){if(!Ja(a))return;Ye.removeItem(r).then(()=>Ye.setItem(a,u)).then(()=>{wi(),alert("Renamed "+r+" to "+a),r==pe.mainPath&&Qa(a)})}}})}else Ee("Cannot rename the active window.")}function Yl(l){if(Ge==null)return Ee("Please finish compiling with no errors before downloading ROM."),!0;var t=pt(ut());if(D.getDownloadFile){var r=D.getDownloadFile(),t=pt(ut());(0,Vt.saveAs)(r.blob,t+r.extension)}else if(Ge instanceof Uint8Array){var a=new Blob([Ge],{type:"application/octet-stream"}),u=D.getROMExtension&&D.getROMExtension(Ge)||"-"+gt(re)+".bin";(0,Vt.saveAs)(a,t+u)}else Ee(`The "${re}" platform doesn't have downloadable ROMs.`)}function Xl(l){var t=ge.getCurrentText();if(!t)return!1;var r=new Blob([t],{type:"text/plain;charset=utf-8"});(0,Vt.saveAs)(r,Al(),{autoBom:!1})}async function co(){let l=(await import("./jszip.min-DI47XKVW.js")).default;return new l}async function Ql(l){var t=await co();pe.iterateFiles((r,a)=>{a&&t.file(wt(r),a)}),t.generateAsync({type:"blob"}).then(r=>{(0,Vt.saveAs)(r,ut()+"-"+gt(re)+".zip")})}function Jl(l){let t=D.getDebugSymbolFile&&D.getDebugSymbolFile();if(!t){Ee("This project does not have debug information.");return}var r=pt(ut());(0,Vt.saveAs)(t.blob,r+t.extension,{autoBom:!1})}async function Kl(l){var t=await co(),r=await Ye.keys();Oe(!0);try{var a=0;await Promise.all(r.map(d=>Ye.getItem(d).then(m=>{Gt(a++/(r.length+1)),m&&t.file(d,m)})));var u=await t.generateAsync({type:"blob"});(0,Vt.saveAs)(u,gt(re)+"-all.zip")}finally{Oe(!1)}}function Zl(l){var t={};l.append($("<option />").text("--------- Examples ---------").attr("disabled","true"));for(var r=0;r<mn.length;r++){var a=mn[r],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&&(vn=a),t[a.id]=u}return t}function eu(l){if(Et&&!pi){var t=0,r=oi();if(r)for(let u in r){var a=r[u];a.platform_id&&gt(a.platform_id)==gt(re)&&(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,r,a){var u=await Ye.keys(),d=0;u||(u=[]);for(var m=0;m<u.length;m++){var y=u[m];if(y.startsWith(r)&&!a[y]){d++==0&&l.append($("<option />").text("------- "+t+" -------").attr("disabled","true"));var b=y.substring(r.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 wi(){var l=$("#preset_select").empty();if(Be)l.append($("<option />").val("/").text("Leave Repository")),$("#repo_name").text(wt(Be)+"/").show(),await fo(l,Be,"",{}),ho(l);else{eu(l);var t=Zl(l);await fo(l,"Local Files","",t),ho(l)}l.off("change").change(function(r){Qa($(this).val().toString())})}function tu(l){var t=$("<p/>");if(l.path!=null){var r=l.line?l.label?`(${l.path} @ ${l.label})`:`(${l.path}:${l.line})`:`(${l.path})`,a=$("<a/>").text(r),u=l.path;u==ut()&&(u=pe.mainPath),ge.isWindow(u)&&a.click(d=>{var m=ge.createOrShow(u);m instanceof ui&&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 r=$("#error_alert_msg").empty();for(var a of l.slice(0,10))r.append(tu(a));$("#error_alert").show(),Ga=t}function go(l,t){if(t!=null){var r={msg:t,line:0};l instanceof ua&&l.$loc&&(r=Object.create(l.$loc),r.msg=t,console.log(r)),es([r],!0)}}var ru=new Date,Ei;function iu(){if(window.ga&&Ei){var l=new Date;ga("send","timing","load",re,Ei.getTime()-ru.getTime()),ga("send","timing","build",re,l.getTime()-Ei.getTime()),Ei=null}}async function nu(l){if("errors"in l&&l.errors.length>0)gi.addClass("has-errors"),ge.setErrors(l.errors),yi(),es(l.errors,!1);else{if(gi.removeClass("has-errors"),ge.setErrors(null),po(),l==null||"unchanged"in l&&l.unchanged||!("output"in l))return;D.debugSymbols=new As(l.symbolmap,l.debuginfo),lt=l.params;var t=l.output;if(t!=null)try{_i(),wo(),await D.loadROM(ml(),t),Ge=t,qa||Mt(),iu(),Xu()}catch(r){console.log(r),gi.addClass("has-errors"),go(r,r+""),Ge=null,yi();return}yi(),ge.refresh(!1)}}async function au(){if(D.loadBIOS){var l=re+".rom",t=await Ye.getItem(l);t instanceof Uint8Array?(console.log("loading BIOS",l,t.length+" bytes"),D.loadBIOS(l,t)):console.log("BIOS file must be binary")}}function mo(){var l=$("#mem_info");l.hide(),mi=null}function Si(l){if(!!Ds(D)){var t=$("#mem_info"),r=D.getDebugCategories();r&&!vi&&(vi=r[0]);var a=l&&D.getDebugInfo(vi,l);if(a){var u=mi?Es(mi,a):a;t.show().html(u);var d=$('<div class="mem_info_links">'),m=b=>{var L=$("<a>"+b+"</a>");b==vi&&L.addClass("selected"),L.click(W=>{vi=b,mi=null,Si(rr)}),d.append(L),d.append("<span> </span>")};for(var y of r)m(y);t.append("<br>"),t.append(d),mi=a}else mo()}}function xn(l,t){$("#debug_bar, #run_bar").find("button").removeClass("btn_active").removeClass("btn_stopped"),$("#dbg_"+l).addClass("btn_"+t)}function ts(){return D&&Ge!=null}function At(){return ts()?!0:(Ee("Can't do this until build successfully completes."),!1)}function su(l){if(yn&&yn.startsWith("#")||["toline","restart","tovsync","stepover"].includes(no)||!D.disassemble)return;let t=pe.getListings(),r="#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 L=y&&y.findLineForOffset(u,sn);if(L){let W=y.lines[L.line+1];if(!W||u<W.offset){let fe=u-L.offset;fe<a&&(r=b,a=fe)}}}}}ge.createOrShow(r,!0)}function wn(l){rr=l,Si(l),su(l),ge.refresh(!0),bn=!0}function vo(l){D.setupDebug&&(D.setupDebug((t,r)=>{wn(t),xn(l||"pause","stopped"),r&&es([{msg:"STOPPED: "+r,line:0}],!0)}),no=l)}function Rt(l){!At()||(ns(),vo(l),l&&xn(l,"active"))}function qt(){D&&D.isRunning()&&(D.pause(),console.log("Paused")),xn("pause","stopped")}function ou(){!At()||(_i(),qt(),qa=!0)}function Mt(){D.isRunning()||(D.resume(),console.log("Resumed")),xn("go","active"),Ga&&po()}function bo(){!At()||(_i(),D.isRunning()||ge.refresh(!1),Mt(),qa=!1,yn=null)}function lu(){!At()||(Rt("step"),D.step())}function uu(){!At()||(Rt("stepover"),D.stepOver())}function cu(){!At()||(Rt("tovsync"),D.runToVsync())}function yo(){var l=ge.getActive();return l&&l.getCursorPC&&l.getCursorPC()}function ci(l){!At()||!(l>=0)||(Rt("toline"),console.log("Run to",l.toString(16)),D.runToPC?D.runToPC(l):D.runEval(t=>t.PC==l))}function fu(){D.restartAtPC(yo())?bo():Ee("Could not restart program at selected line.")}function du(){ci(yo())}function hu(){!At()||(Rt("stepout"),D.runUntilReturn())}function pu(){!At()||(Rt("stepback"),D.stepBack())}function _i(){rr=null,D.clearDebug&&D.clearDebug(),vo(),Si()}function rs(){D.reset(),wo()}function gu(){!At()||(_i(),rs(),Mt())}function mu(){if(!!At()){var l=Mr;ns(),D.setupDebug&&D.runEval?(_i(),Mt(),rs(),Rt("restart"),D.runEval(t=>!0)):(rs(),Mt()),l&&Eo()}}function vu(){var l=$("#debugExprModal"),t=$("#debugExprSubmit");$("#debugExprInput").val(ao),$("#debugExprExamples").text(bu()),l.modal("show"),t.off("click").on("click",()=>{var r=$("#debugExprInput").val()+"";l.modal("hide"),yu(r)})}function bu(){var l=D.saveState&&D.saveState(),t=l.c;console.log(t,l);var r="";return t.PC&&(r+="c.PC == 0x"+Fe(t.PC)+`
`),t.SP&&(r+="c.SP < 0x"+Fe(t.SP)+`
`),t.HL&&(r+=`c.HL == 0x4000
`),D.readAddress&&(r+=`this.readAddress(0x1234) == 0x0
`),D.readVRAMAddress&&(r+=`this.readVRAMAddress(0x1234) != 0x80
`),D.getRasterScanline&&(r+=`this.getRasterScanline() > 222
`),r}function yu(l){var t=new Function("c","return ("+l+");").bind(D);Rt(),D.runEval(t),ao=l}function xo(){D.isRunning()?(ge.tick(),bn=!1):bn||(ge.tick(),bn=!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 xu(){is||Lt("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 r=new GIF({workerScript:"lib/gif.worker.js",workers:4,quality:10,rotate:t}),a=$("#videoPreviewImage");r.on("progress",b=>{Gt(b)}),r.on("finished",b=>{a.attr("src",URL.createObjectURL(b)),Oe(!1),Mt(),$("#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),qt(),r.render(),is=!1):(r.addFrame(l,{delay:u,copy:!0}),setTimeout(y,u),is=!0)};y()})}function En(l){D.setFrameRate(l),l>.01?$("#fps_label").text(l.toFixed(2)):$("#fps_label").text("1/"+Math.round(1/l))}function wu(){var l=D.getFrameRate();l=l/2,l>1e-5&&En(l)}function Eu(){var l=D.getFrameRate();l=Math.min(60,l*2),En(l)}function Su(){En(60/65536)}function _u(){Mt(),En(60)}function Tu(){ge.refresh(!1);var l=ge.getActive();if(l.getSourceFile&&l.setTimingResult){var t=D.newCodeAnalyzer();t.showLoopTimingForPC(0),l.setTimingResult(t)}}function ns(){Mr&&(D.setRecorder(null),$("#dbg_record").removeClass("btn_recording"),$("#replaydiv").hide(),mo(),Mr=!1)}function wo(){Mr&&nt.reset()}function Eo(){nt.reset(),D.setRecorder(nt),$("#dbg_record").addClass("btn_recording"),$("#replaydiv").show(),Mr=!0}function Cu(){Mr?ns():Eo()}function ir(l,t,r){var a=ge.getActive();a&&a.insertText?bootbox.prompt({title:"Add "+Pt.sanitize(l)+" File to Project",value:"filename"+Pt.sanitize(t),callback:u=>{if(u&&u.trim().length>0){if(!Ja(u))return;var d=u,m=`
`+r(u)+`
`;pe.loadFiles([d]).then(y=>{y&&y.length?Ee(u+" already exists; including anyway"):pe.updateFile(d,`
`),a.insertText(m),yi()})}}}):Ee("Can't insert text in this window -- switch back to main file")}function ku(){var l=ut(),t=D.getToolForFilename(l);l.endsWith(".c")||t=="sdcc"||t=="cc65"||t=="cmoc"||t=="smlrc"?ir("Header",".h",r=>'#include "'+r+'"'):t=="dasm"||t=="zmac"?ir("Include",".inc",r=>' include "'+r+'"'):t=="ca65"||t=="sdasz80"||t=="vasm"||t=="armips"?ir("Include",".inc",r=>' .include "'+r+'"'):t=="verilator"?ir("Verilog",".v",r=>'`include "'+r+'"'):t=="wiz"?ir("Include",".wiz",r=>'import "'+r+'";'):t=="ecs"?ir("Include",".ecs",r=>'import "'+r+'"'):Ee("Can't add include file to this project type ("+t+")")}function Pu(){var l=ut(),t=D.getToolForFilename(l);l.endsWith(".c")||t=="sdcc"||t=="cc65"||t=="cmoc"||t=="smlrc"?ir("Linked C (or .s)",".c",r=>'//#link "'+r+'"'):l.endsWith("asm")||l.endsWith(".s")||t=="ca65"||t=="lwasm"?ir("Linked ASM",".inc",r=>';#link "'+r+'"'):Ee("Can't add linked file to this project type ("+t+")")}function Au(){if(qe=new tn($("#toolbar")[0],null),qe.grp.prop("id","run_bar"),qe.add("ctrl+alt+r","Reset","glyphicon-refresh",gu).prop("id","dbg_reset"),qe.add("ctrl+alt+,","Pause","glyphicon-pause",ou).prop("id","dbg_pause"),qe.add("ctrl+alt+.","Resume","glyphicon-play",bo).prop("id","dbg_go"),D.restartAtPC&&qe.add("ctrl+alt+/","Restart at Cursor","glyphicon-play-circle",fu).prop("id","dbg_restartatline"),qe.newGroup(),qe.grp.prop("id","debug_bar"),D.runEval&&qe.add("ctrl+alt+e","Reset and Debug","glyphicon-fast-backward",mu).prop("id","dbg_restart"),D.stepBack&&qe.add("ctrl+alt+b","Step Backwards","glyphicon-step-backward",pu).prop("id","dbg_stepback"),D.step&&qe.add("ctrl+alt+s","Single Step","glyphicon-step-forward",lu).prop("id","dbg_step"),D.stepOver&&qe.add("ctrl+alt+t","Step Over","glyphicon-hand-right",uu).prop("id","dbg_stepover"),D.runUntilReturn&&qe.add("ctrl+alt+o","Step Out of Subroutine","glyphicon-hand-up",hu).prop("id","dbg_stepout"),D.runToVsync&&qe.add("ctrl+alt+n","Next Frame/Interrupt","glyphicon-forward",cu).prop("id","dbg_tovsync"),(D.runEval||D.runToPC)&&!re.startsWith("verilog")&&qe.add("ctrl+alt+l","Run To Line","glyphicon-save",du).prop("id","dbg_toline"),qe.newGroup(),qe.grp.prop("id","xtra_bar"),$(".dropdown-menu").collapse({toggle:!1}),$("#item_new_file").click(Sl),$("#item_upload_file").click(_l),$("#item_open_directory").click(Cl),$("#item_github_login").click(Dl),$("#item_github_logout").click(Fl),$("#item_github_import").click(Ll),$("#item_github_publish").click(Rl),$("#item_github_push").click(Il),$("#item_github_pull").click(Ml),$("#item_repo_delete").click(Ol),$("#item_share_file").click(Wl),$("#item_reset_file").click(Vl),$("#item_rename_file").click(Gl),$("#item_delete_file").click(ql),D.runEval?$("#item_debug_expr").click(vu).show():$("#item_debug_expr").hide(),$("#item_download_rom").click(Yl),$("#item_download_file").click(Xl),$("#item_download_zip").click(Ql),$("#item_download_sym").click(Jl),$("#item_download_allzip").click(Kl),$("#item_record_video").click(xu),re.startsWith("apple2")||re.startsWith("vcs")?$("#item_export_cassette").click(zl):$("#item_export_cassette").hide(),D.setFrameRate&&D.getFrameRate&&($("#dbg_slower").click(wu),$("#dbg_faster").click(Eu),$("#dbg_slowest").click(Su),$("#dbg_fastest").click(_u)),$("#item_addfile_include").click(ku),$("#item_addfile_link").click(Pu),$("#item_request_persist").click(()=>Ya(!0,!1)),xo(),D.newCodeAnalyzer&&qe.add(null,"Analyze CPU Timing","glyphicon-time",Tu),D.setRecorder&&D.advance&&Du(),D.showHelp){let{li:r,a}=Xa("help__"+re,Va+" Help");$("#help_menu").append(r),$(a).click(()=>window.open(D.showHelp(),"_8bws_help"))}let l=D.getToolForFilename(ut()),t=hl[l];if(t){let{li:r,a}=Xa("help__"+l,l+" Help");$("#help_menu").append(r),$(a).click(()=>window.open(t,"_8bws_help"))}}function Du(){var l=$("#replayslider"),t=$("#clockslider"),r=$("#replay_frame"),a=$("#replay_clock");D.advanceFrameClock||$("#clockdiv").hide();var u=()=>{r.text(nt.lastSeekFrame+""),a.text(nt.lastSeekStep+"")},d=b=>{qt();var L=parseInt(l.val().toString()),W=parseInt(t.val().toString());nt.loadFrame(L,W)>=0&&(t.attr("min",0),t.attr("max",nt.lastStepCount),u(),wn(D.saveState()))},m=b=>{qt(),nt.loadFrame(b)>=0&&(l.val(b),u(),wn(D.saveState()))},y=b=>{qt();var L=parseInt(l.val().toString());nt.loadFrame(L,b)>=0&&(t.val(b),u(),wn(D.saveState()))};nt.callbackStateChanged=()=>{l.attr("min",0),l.attr("max",nt.numFrames()),l.val(nt.currentFrame()),t.val(nt.currentStep()),u(),Si(D.saveState())},l.on("input",d),t.on("input",d),$("#replay_min").click(()=>{m(1)}),$("#replay_max").click(()=>{m(nt.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(),qe.add("ctrl+alt+0","Start/Stop Replay Recording","glyphicon-record",Cu).prop("id","dbg_record")}function Fu(){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(r){}return window.innerWidth>window.innerHeight}async function Lu(){if(wr.shouldCompleteTour()){await Lt("lib/bootstrap-tourist.js");var l=re.startsWith("vcs"),t=[{element:"#platformsMenuButton",placement:"right",title:"Platform Selector",content:`You're currently on the "<b>`+re+'</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."}];Fu()||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!"})),pi&&(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 r=new Tour({autoscroll:!1,steps:t,onEnd:()=>{wr.completedTour()}});setTimeout(()=>{r.start()},2500)}}function Sn(l){var t=(l.message||l.error||l)+"";if(t.indexOf("QuotaExceededError")>=0)Ya(!1,!1);else{var r=l.error||l.reason;r!=null&&r instanceof ua&&Ru(r)}}function Ru(l){console.log("haltEmulation"),qt(),Yu(l)}function Iu(){window.addEventListener("error",Sn),window.addEventListener("unhandledrejection",Sn)}function So(){window.removeEventListener("error",Sn),window.removeEventListener("unhandledrejection",Sn)}function Nr(l){So(),l?window.location.replace("?"+$.param(ee)):window.location.href="?"+$.param(ee)}function _n(){re&&(ee.platform=re),delete ee[""],history.replaceState({},"","?"+$.param(ee))}function Mu(){var l=!1;document.addEventListener("visibilitychange",()=>{document.visibilityState=="hidden"&&D&&D.isRunning()?(qt(),l=!0):document.visibilityState=="visible"&&l&&(Mt(),l=!1)}),$(window).on("focus",()=>{l&&(Mt(),l=!1)}),$(window).on("blur",()=>{D&&D.isRunning()&&(qt(),l=!0)}),$(window).on("orientationchange",()=>{D&&D.resize&&setTimeout(D.resize.bind(D),200)})}function Nu(){var l=$(document).find(".emucontrols-"+Lr(re));re.endsWith(".mame")&&l.show();var t=$("#emulator").find("canvas");t&&(t.on("focus",()=>{D.isRunning()&&(l.fadeIn(200),D.resume())}),t.on("blur",()=>{l.fadeOut(200)}))}function Ou(){window.ga&&($(".dropdown-item").click(l=>{l.target&&l.target.id&&bi("menu",l.target.id)}),ga("send","pageview",location.pathname+"?platform="+re+(Be?"&repo="+Be:"&file="+ee.file)))}async function $u(){if(!la[re])throw Error("Invalid platform '"+re+"'.");let l=$("#emuscreen")[0],t=oa(ee.options||"");if(D=new la[re](l,t),zu(),nt=new Ls(D),mn=D.getPresets?D.getPresets():[],!ee.file){var r=wr.getLastPreset(),a=r||(Be?null:mn[0].id);ee.file=a||"DEFAULT",a||Ee("There is no default main file for this project. Try selecting one from the pulldown.")}re=="vcs"&&ee.file.startsWith("examples/")&&!ee.file.endsWith(".a")&&(ee.file+=".a"),_n(),Iu(),Ou(),await D.start(),await au(),await bl(),await wl(ee.file),D.sourceFileFetch=u=>pe.filedata[u],Au(),Mu(),Nu(),it?Wu():(wi(),ju(),Lu()),_o()}function Wu(){$("#dropdownMenuButton").hide(),$("#platformsMenuButton").hide(),$("#booksMenuButton").hide()}function ju(){Lr(re)=="nes"?$(".book-nes").addClass("book-active"):Lr(re)=="vcs"?$(".book-vcs").addClass("book-active"):Lr(re)=="verilog"?$(".book-verilog").addClass("book-active"):D.getToolForFilename(ut())=="sdcc"&&$(".book-arcade").addClass("book-active")}function _o(){setTimeout(()=>{$("#controls_dynamic").css("visibility","inherit")},250)}function Bu(){var l="workspace-split3-"+re;it&&(l="embed-"+l);var t;re.startsWith("vcs")?t=[0,50,50]:it||li?t=[0,55,45]:t=[12,44,44];var r=Et&&localStorage.getItem(l);if(r)try{t=JSON.parse(r)}catch(u){console.log(u)}var a=fl(["#sidebar","#workspace","#emulator"],{sizes:t,minSize:[0,250,250],onDrag:()=>{D&&D.resize&&D.resize()},onDragEnd:()=>{Et&&localStorage.setItem(l,JSON.stringify(a.getSizes())),ge&&ge.resize()}})}function Hu(l){let t=Rr(ee.ignore)||it;Oe(!0),Zi(l,async r=>{if(r){var a=wt(l);console.log("Importing "+r.length+" bytes as "+a);try{var u=await Ye.getItem(a);Oe(!1),u!=null&&t||(u==null||confirm("Replace existing file '"+a+"'?"))&&await Ye.setItem(a,r),delete ee.importURL,ee.file=a,_n(),Co()}finally{Oe(!1)}}else Ee("Could not load source code from URL: "+l),Oe(!1)},"text")}async function Uu(){var l=Rr(ee.ignore),t=Rr(ee.force);it?l=!t:t=!1;for(var r=0;r<20;r++){let u=ee["file"+r+"_name"],d=ee["file"+r+"_data"];if(u==null||d==null)break;var a=await Ye.getItem(u);if(!(l&&a)){let m=d;ee["file"+r+"_type"]=="binary"&&(m=Xi(atob(m))),(!a||t||confirm("Replace existing file '"+u+"'?"))&&await Ye.setItem(u,m)}r==0&&(ee.file=u),delete ee["file"+r+"_name"],delete ee["file"+r+"_data"],delete ee["file"+r+"_type"]}delete ee.ignore,delete ee.force,_n()}function zu(){var l=D.getPlatformName&&D.getPlatformName(),t=$('a[href="?platform='+re+'"]');t.length&&(t.addClass("dropdown-item-checked"),l=l||t.text()||l),Va=l||re,$(".platform_name").text(Va)}function Vu(){if(re=ee.platform||wr.getLastPlatformID(),Be=ee.repo,!ee.repo&&!ee.file&&(Be=wr.getLastRepoID(re)),Et&&Be&&Be!=="/"){var l=oi()[Be];l&&(console.log(re,ee,l),ee.repo=Be,l.platform_id&&!ee.platform&&(ee.platform=re=l.platform_id),!ee.file&&l.mainPath&&(ee.file=l.mainPath))}else Be="",delete ee.repo;re||(it&&pl("The 'platform' must be specified when embed=1"),re=ee.platform="vcs")}async function To(){if(ee.githubURL){Za(ee.githubURL,!0);return}if(Vu(),Bu(),xr=Be||gt(re),it&&(xr=(document.referrer||document.location.href)+xr),Ye=ba(xr),ee.importURL){Hu(ee.importURL);return}ee.file0_name&&await Uu(),Co()}async function Co(){try{var l=await Rs(Lr(re));console.log("starting platform",re),await $u(),document.title=document.title+" ["+re+"] - "+(Be?"["+Be+"] - ":"")+pe.mainPath}catch(t){console.log(t),Ee('Platform "'+re+'" failed to load.')}finally{_o()}}var as="__use_https";function ko(l){document.cookie=as+"="+l+";domain=8bitworkshop.com;path=/;max-age=315360000"}function qu(){var l=lo(as);if(typeof l=="string")return!!l;var t=Et&&!localStorage.getItem("__lastplatform")?1:0;return ko(t),!!t}function Gu(){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"&&(qu()?(So(),window.location.replace(window.location.href.replace(/^http:/,"https:"))):$("#item_switch_https").click(Gu).show())}Po();function xf(l,t){D.writeFile(l,t)}function wf(l){return D.readFile(l)}function Ef(){return D.saveState()}function Yu(l){var t=l&&l.message||t;go(l,t),ge.refresh(!1),D.saveState&&Si(D.saveState())}async function Sf(l){var t=pe.filedata[l];t!=null&&(ge.updateFile(l,await alternateLocalFilesystem.getFileData(l)),console.log("updating file",l))}function Xu(){if(pi&&Ge instanceof Uint8Array){var l=pt(ut()),t=D.getROMExtension&&D.getROMExtension(Ge)||"-"+gt(re)+".bin";alternateLocalFilesystem.setFileData(`bin/${l}${t}`,Ge)}}function _f(l){var t=ge.getActive();if(t instanceof ui){var r=t.editor.getSearchCursor(l);r.findNext()&&t.editor.setSelection(r.pos.to,r.pos.from)}}function Qu(){let l=!1;new IntersectionObserver((r,a)=>{for(var u of r)u.isIntersecting&&!l&&(To(),l=!0),u.intersectionRatio==0&&ts()&&D.isRunning()&&qt(),u.intersectionRatio>0&&ts()&&!D.isRunning()&&Mt()},{}).observe($("#emulator")[0])}typeof process=="undefined"&&(it&&typeof IntersectionObserver=="function"?Qu():To());export{Hs as a,ee as b,re as c,xr as d,Be as e,D as f,pe as g,ge as h,lt as i,rr as j,Rt as k,ci as l,_i as m,En as n,Ru as o,Bu as p,Vu as q,To as r,xf as s,wf as t,Ef as u,Yu as v,Sf as w,_f 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.0
* 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: 2021-03-02T17:08Z
*/
//# sourceMappingURL=chunk-UF5OFU7K.js.map