/*! For license information please see main.js.LICENSE.txt */ (()=>{"use strict";var t={679:(t,e,i)=>{var n=i(864),r={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},s={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},o={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},a={};function l(t){return n.isMemo(t)?o:a[t.$$typeof]||r}a[n.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},a[n.Memo]=o;var h=Object.defineProperty,c=Object.getOwnPropertyNames,u=Object.getOwnPropertySymbols,d=Object.getOwnPropertyDescriptor,f=Object.getPrototypeOf,p=Object.prototype;t.exports=function t(e,i,n){if("string"!=typeof i){if(p){var r=f(i);r&&r!==p&&t(e,r,n)}var o=c(i);u&&(o=o.concat(u(i)));for(var a=l(e),g=l(i),m=0;m{var e=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;t.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},i=0;i<10;i++)e["_"+String.fromCharCode(i)]=i;if("0123456789"!==Object.getOwnPropertyNames(e).map((function(t){return e[t]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(t){n[t]=t})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(t){return!1}}()?Object.assign:function(t,r){for(var s,o,a=function(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),l=1;l{var i="function"==typeof Symbol&&Symbol.for,n=i?Symbol.for("react.element"):60103,r=i?Symbol.for("react.portal"):60106,s=i?Symbol.for("react.fragment"):60107,o=i?Symbol.for("react.strict_mode"):60108,a=i?Symbol.for("react.profiler"):60114,l=i?Symbol.for("react.provider"):60109,h=i?Symbol.for("react.context"):60110,c=i?Symbol.for("react.async_mode"):60111,u=i?Symbol.for("react.concurrent_mode"):60111,d=i?Symbol.for("react.forward_ref"):60112,f=i?Symbol.for("react.suspense"):60113,p=i?Symbol.for("react.suspense_list"):60120,g=i?Symbol.for("react.memo"):60115,m=i?Symbol.for("react.lazy"):60116,b=i?Symbol.for("react.block"):60121,y=i?Symbol.for("react.fundamental"):60117,v=i?Symbol.for("react.responder"):60118,w=i?Symbol.for("react.scope"):60119;function _(t){if("object"==typeof t&&null!==t){var e=t.$$typeof;switch(e){case n:switch(t=t.type){case c:case u:case s:case a:case o:case f:return t;default:switch(t=t&&t.$$typeof){case h:case d:case m:case g:case l:return t;default:return e}}case r:return e}}}function x(t){return _(t)===u}e.AsyncMode=c,e.ConcurrentMode=u,e.ContextConsumer=h,e.ContextProvider=l,e.Element=n,e.ForwardRef=d,e.Fragment=s,e.Lazy=m,e.Memo=g,e.Portal=r,e.Profiler=a,e.StrictMode=o,e.Suspense=f,e.isAsyncMode=function(t){return x(t)||_(t)===c},e.isConcurrentMode=x,e.isContextConsumer=function(t){return _(t)===h},e.isContextProvider=function(t){return _(t)===l},e.isElement=function(t){return"object"==typeof t&&null!==t&&t.$$typeof===n},e.isForwardRef=function(t){return _(t)===d},e.isFragment=function(t){return _(t)===s},e.isLazy=function(t){return _(t)===m},e.isMemo=function(t){return _(t)===g},e.isPortal=function(t){return _(t)===r},e.isProfiler=function(t){return _(t)===a},e.isStrictMode=function(t){return _(t)===o},e.isSuspense=function(t){return _(t)===f},e.isValidElementType=function(t){return"string"==typeof t||"function"==typeof t||t===s||t===u||t===a||t===o||t===f||t===p||"object"==typeof t&&null!==t&&(t.$$typeof===m||t.$$typeof===g||t.$$typeof===l||t.$$typeof===h||t.$$typeof===d||t.$$typeof===y||t.$$typeof===v||t.$$typeof===w||t.$$typeof===b)},e.typeOf=_},864:(t,e,i)=>{t.exports=i(921)},408:(t,e,i)=>{var n=i(418),r="function"==typeof Symbol&&Symbol.for,s=r?Symbol.for("react.element"):60103,o=r?Symbol.for("react.portal"):60106,a=r?Symbol.for("react.fragment"):60107,l=r?Symbol.for("react.strict_mode"):60108,h=r?Symbol.for("react.profiler"):60114,c=r?Symbol.for("react.provider"):60109,u=r?Symbol.for("react.context"):60110,d=r?Symbol.for("react.forward_ref"):60112,f=r?Symbol.for("react.suspense"):60113,p=r?Symbol.for("react.memo"):60115,g=r?Symbol.for("react.lazy"):60116,m="function"==typeof Symbol&&Symbol.iterator;function b(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,i=1;iM.length&&M.push(t)}function B(t,e,i,n){var r=typeof t;"undefined"!==r&&"boolean"!==r||(t=null);var a=!1;if(null===t)a=!0;else switch(r){case"string":case"number":a=!0;break;case"object":switch(t.$$typeof){case s:case o:a=!0}}if(a)return i(n,t,""===e?"."+F(t,0):e),1;if(a=0,e=""===e?".":e+":",Array.isArray(t))for(var l=0;l{t.exports=i(408)}},e={};function i(n){var r=e[n];if(void 0!==r)return r.exports;var s=e[n]={exports:{}};return t[n](s,s.exports,i),s.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t={};i.r(t);var e,n,r,s,o,a,l,h,c,u=i(294),d=i(679),f=i.n(d);!function(t){t[t.V1=0]="V1",t[t.V2=1]="V2",t[t.V3=2]="V3",t[t.V4=3]="V4",t[t.V5=4]="V5"}(e||(e={})),function(t){t[t.Sparse=0]="Sparse",t[t.Dense=1]="Dense"}(n||(n={})),function(t){t[t.HALF=0]="HALF",t[t.SINGLE=1]="SINGLE",t[t.DOUBLE=2]="DOUBLE"}(r||(r={})),function(t){t[t.DAY=0]="DAY",t[t.MILLISECOND=1]="MILLISECOND"}(s||(s={})),function(t){t[t.SECOND=0]="SECOND",t[t.MILLISECOND=1]="MILLISECOND",t[t.MICROSECOND=2]="MICROSECOND",t[t.NANOSECOND=3]="NANOSECOND"}(o||(o={})),function(t){t[t.YEAR_MONTH=0]="YEAR_MONTH",t[t.DAY_TIME=1]="DAY_TIME",t[t.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"}(a||(a={})),function(t){t[t.NONE=0]="NONE",t[t.Schema=1]="Schema",t[t.DictionaryBatch=2]="DictionaryBatch",t[t.RecordBatch=3]="RecordBatch",t[t.Tensor=4]="Tensor",t[t.SparseTensor=5]="SparseTensor"}(l||(l={})),function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.Float=3]="Float",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct=13]="Struct",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Dictionary=-1]="Dictionary",t[t.Int8=-2]="Int8",t[t.Int16=-3]="Int16",t[t.Int32=-4]="Int32",t[t.Int64=-5]="Int64",t[t.Uint8=-6]="Uint8",t[t.Uint16=-7]="Uint16",t[t.Uint32=-8]="Uint32",t[t.Uint64=-9]="Uint64",t[t.Float16=-10]="Float16",t[t.Float32=-11]="Float32",t[t.Float64=-12]="Float64",t[t.DateDay=-13]="DateDay",t[t.DateMillisecond=-14]="DateMillisecond",t[t.TimestampSecond=-15]="TimestampSecond",t[t.TimestampMillisecond=-16]="TimestampMillisecond",t[t.TimestampMicrosecond=-17]="TimestampMicrosecond",t[t.TimestampNanosecond=-18]="TimestampNanosecond",t[t.TimeSecond=-19]="TimeSecond",t[t.TimeMillisecond=-20]="TimeMillisecond",t[t.TimeMicrosecond=-21]="TimeMicrosecond",t[t.TimeNanosecond=-22]="TimeNanosecond",t[t.DenseUnion=-23]="DenseUnion",t[t.SparseUnion=-24]="SparseUnion",t[t.IntervalDayTime=-25]="IntervalDayTime",t[t.IntervalYearMonth=-26]="IntervalYearMonth"}(h||(h={})),function(t){t[t.OFFSET=0]="OFFSET",t[t.DATA=1]="DATA",t[t.VALIDITY=2]="VALIDITY",t[t.TYPE=3]="TYPE"}(c||(c={}));const[p,g]=(()=>{const t=()=>{throw new Error("BigInt is not available in this environment")};function e(){throw t()}return e.asIntN=()=>{throw t()},e.asUintN=()=>{throw t()},"undefined"!=typeof BigInt?[BigInt,!0]:[e,!1]})(),[m,b]=(()=>{const t=()=>{throw new Error("BigInt64Array is not available in this environment")};return"undefined"!=typeof BigInt64Array?[BigInt64Array,!0]:[class{static get BYTES_PER_ELEMENT(){return 8}static of(){throw t()}static from(){throw t()}constructor(){throw t()}},!1]})(),[y,v]=(()=>{const t=()=>{throw new Error("BigUint64Array is not available in this environment")};return"undefined"!=typeof BigUint64Array?[BigUint64Array,!0]:[class{static get BYTES_PER_ELEMENT(){return 8}static of(){throw t()}static from(){throw t()}constructor(){throw t()}},!1]})(),w=t=>"boolean"==typeof t,_=t=>"function"==typeof t,x=t=>null!=t&&Object(t)===t,k=t=>x(t)&&_(t.then),S=t=>x(t)&&_(t[Symbol.iterator]),C=t=>x(t)&&_(t[Symbol.asyncIterator]),A=t=>x(t)&&x(t.schema),T=t=>x(t)&&"done"in t&&"value"in t,I=t=>x(t)&&_(t.stat)&&(t=>"number"==typeof t)(t.fd),E=t=>x(t)&&R(t.body),M=t=>"_getDOMStream"in t&&"_getNodeStream"in t,R=t=>x(t)&&_(t.cancel)&&_(t.getReader)&&!M(t),L=t=>x(t)&&_(t.read)&&_(t.pipe)&&w(t.readable)&&!M(t),B=t=>x(t)&&_(t.clear)&&_(t.bytes)&&_(t.position)&&_(t.setPosition)&&_(t.capacity)&&_(t.getBufferIdentifier)&&_(t.createLong);function N(t){if(null===t)return"null";if(void 0===t)return"undefined";switch(typeof t){case"number":case"bigint":return`${t}`;case"string":return`"${t}"`}return"function"==typeof t[Symbol.toPrimitive]?t[Symbol.toPrimitive]("string"):ArrayBuffer.isView(t)?t instanceof m||t instanceof y?`[${[...t].map((t=>N(t)))}]`:`[${t}]`:ArrayBuffer.isView(t)?`[${t}]`:JSON.stringify(t,((t,e)=>"bigint"==typeof e?`${e}`:e))}function F(t,e,i,n){return new(i||(i=Promise))((function(r,s){function o(t){try{l(n.next(t))}catch(t){s(t)}}function a(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}l((n=n.apply(t,e||[])).next())}))}function O(t){return this instanceof O?(this.v=t,this):new O(t)}function D(t,e,i){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,r=i.apply(t,e||[]),s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(t){r[t]&&(n[t]=function(e){return new Promise((function(i,n){s.push([t,e,i,n])>1||a(t,e)}))})}function a(t,e){try{(i=r[t](e)).value instanceof O?Promise.resolve(i.value.v).then(l,h):c(s[0][2],i)}catch(t){c(s[0][3],t)}var i}function l(t){a("next",t)}function h(t){a("throw",t)}function c(t,e){t(e),s.shift(),s.length&&a(s[0][0],s[0][1])}}function P(t){var e,i;return e={},n("next"),n("throw",(function(t){throw t})),n("return"),e[Symbol.iterator]=function(){return this},e;function n(n,r){e[n]=t[n]?function(e){return(i=!i)?{value:O(t[n](e)),done:!1}:r?r(e):e}:r}}function z(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,i=t[Symbol.asyncIterator];return i?i.call(t):(t=function(t){var e="function"==typeof Symbol&&Symbol.iterator,i=e&&t[e],n=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(i){e[i]=t[i]&&function(e){return new Promise((function(n,r){!function(t,e,i,n){Promise.resolve(n).then((function(e){t({value:e,done:i})}),e)}(n,r,(e=t[i](e)).done,e.value)}))}}}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;const U=new TextDecoder("utf-8"),V=t=>U.decode(t),H=new TextEncoder,j=t=>H.encode(t),$="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;function q(t,e,i=0,n=e.byteLength){const r=t.byteLength,s=new Uint8Array(t.buffer,t.byteOffset,r),o=new Uint8Array(e.buffer,e.byteOffset,Math.min(n,r));return s.set(o,i),t}function W(t,e){const i=function(t){const e=t[0]?[t[0]]:[];let i,n,r,s;for(let o,a,l=0,h=0,c=t.length;++lt+e.byteLength),0);let r,s,o,a=0,l=-1;const h=Math.min(e||Number.POSITIVE_INFINITY,n);for(const t=i.length;++lG(Int32Array,t),Y=t=>G(Uint8Array,t),Q=t=>(t.next(),t);function X(t,e){return D(this,arguments,(function*(){if(k(e))return yield O(yield O(yield*P(z(X(t,yield O(e))))));const i=function(t){return D(this,arguments,(function*(){yield yield O(yield O(t))}))},n="string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof $?i(e):S(e)?function(t){return D(this,arguments,(function*(){yield O(yield*P(z(Q(function*(t){let e=null;do{e=t.next(yield null==e?void 0:e.value)}while(!e.done)}(t[Symbol.iterator]())))))}))}(e):C(e)?e:i(e);return yield O(yield*P(z(Q(function(e){return D(this,arguments,(function*(){let i=null;do{i=yield O(e.next(yield yield O(G(t,i))))}while(!i.done)}))}(n[Symbol.asyncIterator]()))))),yield O(new t)}))}function K(t,e,i){if(0!==t){i=i.slice(0,e+1);for(let n=-1;++n<=e;)i[n]+=t}return i}const J=Symbol.for("isArrowBigNum");function tt(t,...e){return 0===e.length?Object.setPrototypeOf(G(this.TypedArray,t),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(t,...e),this.constructor.prototype)}function et(...t){return tt.apply(this,t)}function it(...t){return tt.apply(this,t)}function nt(...t){return tt.apply(this,t)}function rt(t){const{buffer:e,byteOffset:i,length:n,signed:r}=t,s=new y(e,i,n),o=r&&s[s.length-1]&BigInt(1)<8===t.byteLength?new t.BigIntArray(t.buffer,t.byteOffset,1)[0]:at(t),st=t=>8===t.byteLength?`${new t.BigIntArray(t.buffer,t.byteOffset,1)[0]}`:at(t)):(st=at,ot=st);class lt{static new(t,e){switch(e){case!0:return new et(t);case!1:return new it(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case m:return new et(t)}return 16===t.byteLength?new nt(t):new it(t)}static signed(t){return new et(t)}static unsigned(t){return new it(t)}static decimal(t){return new nt(t)}constructor(t,e){return lt.new(t,e)}}var ht,ct,ut,dt,ft,pt,gt,mt,bt,yt,vt,wt,_t,xt,kt,St,Ct,At,Tt,It;class Et{static isNull(t){return(null==t?void 0:t.typeId)===h.Null}static isInt(t){return(null==t?void 0:t.typeId)===h.Int}static isFloat(t){return(null==t?void 0:t.typeId)===h.Float}static isBinary(t){return(null==t?void 0:t.typeId)===h.Binary}static isUtf8(t){return(null==t?void 0:t.typeId)===h.Utf8}static isBool(t){return(null==t?void 0:t.typeId)===h.Bool}static isDecimal(t){return(null==t?void 0:t.typeId)===h.Decimal}static isDate(t){return(null==t?void 0:t.typeId)===h.Date}static isTime(t){return(null==t?void 0:t.typeId)===h.Time}static isTimestamp(t){return(null==t?void 0:t.typeId)===h.Timestamp}static isInterval(t){return(null==t?void 0:t.typeId)===h.Interval}static isList(t){return(null==t?void 0:t.typeId)===h.List}static isStruct(t){return(null==t?void 0:t.typeId)===h.Struct}static isUnion(t){return(null==t?void 0:t.typeId)===h.Union}static isFixedSizeBinary(t){return(null==t?void 0:t.typeId)===h.FixedSizeBinary}static isFixedSizeList(t){return(null==t?void 0:t.typeId)===h.FixedSizeList}static isMap(t){return(null==t?void 0:t.typeId)===h.Map}static isDictionary(t){return(null==t?void 0:t.typeId)===h.Dictionary}static isDenseUnion(t){return Et.isUnion(t)&&t.mode===n.Dense}static isSparseUnion(t){return Et.isUnion(t)&&t.mode===n.Sparse}get typeId(){return h.NONE}}ht=Symbol.toStringTag,Et[ht]=((It=Et.prototype).children=null,It.ArrayType=Array,It[Symbol.toStringTag]="DataType");class Mt extends Et{toString(){return"Null"}get typeId(){return h.Null}}ct=Symbol.toStringTag,Mt[ct]=(t=>t[Symbol.toStringTag]="Null")(Mt.prototype);class Rt extends Et{constructor(t,e){super(),this.isSigned=t,this.bitWidth=e}get typeId(){return h.Int}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?m:y}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}ut=Symbol.toStringTag,Rt[ut]=(t=>(t.isSigned=null,t.bitWidth=null,t[Symbol.toStringTag]="Int"))(Rt.prototype);class Lt extends Rt{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(class extends Rt{constructor(){super(!0,8)}get ArrayType(){return Int8Array}}.prototype,"ArrayType",{value:Int8Array}),Object.defineProperty(class extends Rt{constructor(){super(!0,16)}get ArrayType(){return Int16Array}}.prototype,"ArrayType",{value:Int16Array}),Object.defineProperty(Lt.prototype,"ArrayType",{value:Int32Array}),Object.defineProperty(class extends Rt{constructor(){super(!0,64)}get ArrayType(){return m}}.prototype,"ArrayType",{value:m}),Object.defineProperty(class extends Rt{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}}.prototype,"ArrayType",{value:Uint8Array}),Object.defineProperty(class extends Rt{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}}.prototype,"ArrayType",{value:Uint16Array}),Object.defineProperty(class extends Rt{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}}.prototype,"ArrayType",{value:Uint32Array}),Object.defineProperty(class extends Rt{constructor(){super(!1,64)}get ArrayType(){return y}}.prototype,"ArrayType",{value:y});class Bt extends Et{constructor(t){super(),this.precision=t}get typeId(){return h.Float}get ArrayType(){switch(this.precision){case r.HALF:return Uint16Array;case r.SINGLE:return Float32Array;case r.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}dt=Symbol.toStringTag,Bt[dt]=(t=>(t.precision=null,t[Symbol.toStringTag]="Float"))(Bt.prototype),Object.defineProperty(class extends Bt{constructor(){super(r.HALF)}}.prototype,"ArrayType",{value:Uint16Array}),Object.defineProperty(class extends Bt{constructor(){super(r.SINGLE)}}.prototype,"ArrayType",{value:Float32Array}),Object.defineProperty(class extends Bt{constructor(){super(r.DOUBLE)}}.prototype,"ArrayType",{value:Float64Array});class Nt extends Et{constructor(){super()}get typeId(){return h.Binary}toString(){return"Binary"}}ft=Symbol.toStringTag,Nt[ft]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Binary"))(Nt.prototype);class Ft extends Et{constructor(){super()}get typeId(){return h.Utf8}toString(){return"Utf8"}}pt=Symbol.toStringTag,Ft[pt]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Utf8"))(Ft.prototype);class Ot extends Et{constructor(){super()}get typeId(){return h.Bool}toString(){return"Bool"}}gt=Symbol.toStringTag,Ot[gt]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Bool"))(Ot.prototype);class Dt extends Et{constructor(t,e,i=128){super(),this.scale=t,this.precision=e,this.bitWidth=i}get typeId(){return h.Decimal}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}mt=Symbol.toStringTag,Dt[mt]=(t=>(t.scale=null,t.precision=null,t.ArrayType=Uint32Array,t[Symbol.toStringTag]="Decimal"))(Dt.prototype);class Pt extends Et{constructor(t){super(),this.unit=t}get typeId(){return h.Date}toString(){return`Date${32*(this.unit+1)}<${s[this.unit]}>`}}bt=Symbol.toStringTag,Pt[bt]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Date"))(Pt.prototype);class zt extends Et{constructor(t,e){super(),this.unit=t,this.bitWidth=e}get typeId(){return h.Time}toString(){return`Time${this.bitWidth}<${o[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return m}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}yt=Symbol.toStringTag,zt[yt]=(t=>(t.unit=null,t.bitWidth=null,t[Symbol.toStringTag]="Time"))(zt.prototype);class Ut extends Et{constructor(t,e){super(),this.unit=t,this.timezone=e}get typeId(){return h.Timestamp}toString(){return`Timestamp<${o[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}vt=Symbol.toStringTag,Ut[vt]=(t=>(t.unit=null,t.timezone=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Timestamp"))(Ut.prototype);class Vt extends Et{constructor(t){super(),this.unit=t}get typeId(){return h.Interval}toString(){return`Interval<${a[this.unit]}>`}}wt=Symbol.toStringTag,Vt[wt]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Interval"))(Vt.prototype);class Ht extends Et{constructor(t){super(),this.children=[t]}get typeId(){return h.List}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}_t=Symbol.toStringTag,Ht[_t]=(t=>(t.children=null,t[Symbol.toStringTag]="List"))(Ht.prototype);class jt extends Et{constructor(t){super(),this.children=t}get typeId(){return h.Struct}toString(){return`Struct<{${this.children.map((t=>`${t.name}:${t.type}`)).join(", ")}}>`}}xt=Symbol.toStringTag,jt[xt]=(t=>(t.children=null,t[Symbol.toStringTag]="Struct"))(jt.prototype);class $t extends Et{constructor(t,e,i){super(),this.mode=t,this.children=i,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce(((t,e,i)=>(t[e]=i)&&t||t),Object.create(null))}get typeId(){return h.Union}toString(){return`${this[Symbol.toStringTag]}<${this.children.map((t=>`${t.type}`)).join(" | ")}>`}}kt=Symbol.toStringTag,$t[kt]=(t=>(t.mode=null,t.typeIds=null,t.children=null,t.typeIdToChildIndex=null,t.ArrayType=Int8Array,t[Symbol.toStringTag]="Union"))($t.prototype);class qt extends Et{constructor(t){super(),this.byteWidth=t}get typeId(){return h.FixedSizeBinary}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}St=Symbol.toStringTag,qt[St]=(t=>(t.byteWidth=null,t.ArrayType=Uint8Array,t[Symbol.toStringTag]="FixedSizeBinary"))(qt.prototype);class Wt extends Et{constructor(t,e){super(),this.listSize=t,this.children=[e]}get typeId(){return h.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}Ct=Symbol.toStringTag,Wt[Ct]=(t=>(t.children=null,t.listSize=null,t[Symbol.toStringTag]="FixedSizeList"))(Wt.prototype);class Gt extends Et{constructor(t,e=!1){super(),this.children=[t],this.keysSorted=e}get typeId(){return h.Map}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map((t=>`${t.name}:${t.type}`)).join(", ")}}>`}}At=Symbol.toStringTag,Gt[At]=(t=>(t.children=null,t.keysSorted=null,t[Symbol.toStringTag]="Map_"))(Gt.prototype);const Zt=(Yt=-1,()=>++Yt);var Yt;class Qt extends Et{constructor(t,e,i,n){super(),this.indices=e,this.dictionary=t,this.isOrdered=n||!1,this.id=null==i?Zt():"number"==typeof i?i:i.low}get typeId(){return h.Dictionary}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}function Xt(t){const e=t;switch(t.typeId){case h.Decimal:return t.bitWidth/32;case h.Timestamp:return 2;case h.Date:case h.Interval:return 1+e.unit;case h.FixedSizeList:return e.listSize;case h.FixedSizeBinary:return e.byteWidth;default:return 1}}Tt=Symbol.toStringTag,Qt[Tt]=(t=>(t.id=null,t.indices=null,t.isOrdered=null,t.dictionary=null,t[Symbol.toStringTag]="Dictionary"))(Qt.prototype);class Kt{visitMany(t,...e){return t.map(((t,i)=>this.visit(t,...e.map((t=>t[i])))))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,e=!0){return function(t,e,i=!0){return"number"==typeof e?Jt(t,e,i):"string"==typeof e&&e in h?Jt(t,h[e],i):e&&e instanceof Et?Jt(t,te(e),i):(null==e?void 0:e.type)&&e.type instanceof Et?Jt(t,te(e.type),i):Jt(t,h.NONE,i)}(this,t,e)}getVisitFnByTypeId(t,e=!0){return Jt(this,t,e)}visitNull(t,...e){return null}visitBool(t,...e){return null}visitInt(t,...e){return null}visitFloat(t,...e){return null}visitUtf8(t,...e){return null}visitBinary(t,...e){return null}visitFixedSizeBinary(t,...e){return null}visitDate(t,...e){return null}visitTimestamp(t,...e){return null}visitTime(t,...e){return null}visitDecimal(t,...e){return null}visitList(t,...e){return null}visitStruct(t,...e){return null}visitUnion(t,...e){return null}visitDictionary(t,...e){return null}visitInterval(t,...e){return null}visitFixedSizeList(t,...e){return null}visitMap(t,...e){return null}}function Jt(t,e,i=!0){let n=null;switch(e){case h.Null:n=t.visitNull;break;case h.Bool:n=t.visitBool;break;case h.Int:n=t.visitInt;break;case h.Int8:n=t.visitInt8||t.visitInt;break;case h.Int16:n=t.visitInt16||t.visitInt;break;case h.Int32:n=t.visitInt32||t.visitInt;break;case h.Int64:n=t.visitInt64||t.visitInt;break;case h.Uint8:n=t.visitUint8||t.visitInt;break;case h.Uint16:n=t.visitUint16||t.visitInt;break;case h.Uint32:n=t.visitUint32||t.visitInt;break;case h.Uint64:n=t.visitUint64||t.visitInt;break;case h.Float:n=t.visitFloat;break;case h.Float16:n=t.visitFloat16||t.visitFloat;break;case h.Float32:n=t.visitFloat32||t.visitFloat;break;case h.Float64:n=t.visitFloat64||t.visitFloat;break;case h.Utf8:n=t.visitUtf8;break;case h.Binary:n=t.visitBinary;break;case h.FixedSizeBinary:n=t.visitFixedSizeBinary;break;case h.Date:n=t.visitDate;break;case h.DateDay:n=t.visitDateDay||t.visitDate;break;case h.DateMillisecond:n=t.visitDateMillisecond||t.visitDate;break;case h.Timestamp:n=t.visitTimestamp;break;case h.TimestampSecond:n=t.visitTimestampSecond||t.visitTimestamp;break;case h.TimestampMillisecond:n=t.visitTimestampMillisecond||t.visitTimestamp;break;case h.TimestampMicrosecond:n=t.visitTimestampMicrosecond||t.visitTimestamp;break;case h.TimestampNanosecond:n=t.visitTimestampNanosecond||t.visitTimestamp;break;case h.Time:n=t.visitTime;break;case h.TimeSecond:n=t.visitTimeSecond||t.visitTime;break;case h.TimeMillisecond:n=t.visitTimeMillisecond||t.visitTime;break;case h.TimeMicrosecond:n=t.visitTimeMicrosecond||t.visitTime;break;case h.TimeNanosecond:n=t.visitTimeNanosecond||t.visitTime;break;case h.Decimal:n=t.visitDecimal;break;case h.List:n=t.visitList;break;case h.Struct:n=t.visitStruct;break;case h.Union:n=t.visitUnion;break;case h.DenseUnion:n=t.visitDenseUnion||t.visitUnion;break;case h.SparseUnion:n=t.visitSparseUnion||t.visitUnion;break;case h.Dictionary:n=t.visitDictionary;break;case h.Interval:n=t.visitInterval;break;case h.IntervalDayTime:n=t.visitIntervalDayTime||t.visitInterval;break;case h.IntervalYearMonth:n=t.visitIntervalYearMonth||t.visitInterval;break;case h.FixedSizeList:n=t.visitFixedSizeList;break;case h.Map:n=t.visitMap}if("function"==typeof n)return n;if(!i)return()=>null;throw new Error(`Unrecognized type '${h[e]}'`)}function te(t){switch(t.typeId){case h.Null:return h.Null;case h.Int:{const{bitWidth:e,isSigned:i}=t;switch(e){case 8:return i?h.Int8:h.Uint8;case 16:return i?h.Int16:h.Uint16;case 32:return i?h.Int32:h.Uint32;case 64:return i?h.Int64:h.Uint64}return h.Int}case h.Float:switch(t.precision){case r.HALF:return h.Float16;case r.SINGLE:return h.Float32;case r.DOUBLE:return h.Float64}return h.Float;case h.Binary:return h.Binary;case h.Utf8:return h.Utf8;case h.Bool:return h.Bool;case h.Decimal:return h.Decimal;case h.Time:switch(t.unit){case o.SECOND:return h.TimeSecond;case o.MILLISECOND:return h.TimeMillisecond;case o.MICROSECOND:return h.TimeMicrosecond;case o.NANOSECOND:return h.TimeNanosecond}return h.Time;case h.Timestamp:switch(t.unit){case o.SECOND:return h.TimestampSecond;case o.MILLISECOND:return h.TimestampMillisecond;case o.MICROSECOND:return h.TimestampMicrosecond;case o.NANOSECOND:return h.TimestampNanosecond}return h.Timestamp;case h.Date:switch(t.unit){case s.DAY:return h.DateDay;case s.MILLISECOND:return h.DateMillisecond}return h.Date;case h.Interval:switch(t.unit){case a.DAY_TIME:return h.IntervalDayTime;case a.YEAR_MONTH:return h.IntervalYearMonth}return h.Interval;case h.Map:return h.Map;case h.List:return h.List;case h.Struct:return h.Struct;case h.Union:switch(t.mode){case n.Dense:return h.DenseUnion;case n.Sparse:return h.SparseUnion}return h.Union;case h.FixedSizeBinary:return h.FixedSizeBinary;case h.FixedSizeList:return h.FixedSizeList;case h.Dictionary:return h.Dictionary}throw new Error(`Unrecognized type '${h[t.typeId]}'`)}Kt.prototype.visitInt8=null,Kt.prototype.visitInt16=null,Kt.prototype.visitInt32=null,Kt.prototype.visitInt64=null,Kt.prototype.visitUint8=null,Kt.prototype.visitUint16=null,Kt.prototype.visitUint32=null,Kt.prototype.visitUint64=null,Kt.prototype.visitFloat16=null,Kt.prototype.visitFloat32=null,Kt.prototype.visitFloat64=null,Kt.prototype.visitDateDay=null,Kt.prototype.visitDateMillisecond=null,Kt.prototype.visitTimestampSecond=null,Kt.prototype.visitTimestampMillisecond=null,Kt.prototype.visitTimestampMicrosecond=null,Kt.prototype.visitTimestampNanosecond=null,Kt.prototype.visitTimeSecond=null,Kt.prototype.visitTimeMillisecond=null,Kt.prototype.visitTimeMicrosecond=null,Kt.prototype.visitTimeNanosecond=null,Kt.prototype.visitDenseUnion=null,Kt.prototype.visitSparseUnion=null,Kt.prototype.visitIntervalDayTime=null,Kt.prototype.visitIntervalYearMonth=null;const ee=new Float64Array(1),ie=new Uint32Array(ee.buffer);function ne(t){const e=(31744&t)>>10,i=(1023&t)/1024,n=Math.pow(-1,(32768&t)>>15);switch(e){case 31:return n*(i?Number.NaN:1/0);case 0:return n*(i?6103515625e-14*i:0)}return n*Math.pow(2,e-15)*(1+i)}class re extends Kt{}function se(t){return(e,i,n)=>{if(e.setValid(i,null!=n))return t(e,i,n)}}const oe=(t,e,i)=>{t[e]=Math.trunc(i%4294967296),t[e+1]=Math.trunc(i/4294967296)},ae=(t,e,i,n)=>{if(i+1{t[e]=i},he=({values:t},e,i)=>{t[e]=i},ce=({values:t},e,i)=>{t[e]=function(t){if(t!=t)return 32256;ee[0]=t;const e=(2147483648&ie[1])>>16&65535;let i=2146435072&ie[1],n=0;return i>=1089470464?ie[0]>0?i=31744:(i=(2080374784&i)>>16,n=(1048575&ie[1])>>10):i<=1056964608?(n=1048576+(1048575&ie[1]),n=1048576+(n<<(i>>20)-998)>>21,i=0):(i=i-1056964608>>10,n=512+(1048575&ie[1])>>10),e|i|65535&n}(i)},ue=({values:t},e,i)=>{((t,e,i)=>{t[e]=Math.trunc(i/864e5)})(t,e,i.valueOf())},de=({values:t},e,i)=>{oe(t,2*e,i.valueOf())},fe=({values:t},e,i)=>oe(t,2*e,i/1e3),pe=({values:t},e,i)=>oe(t,2*e,i),ge=({values:t},e,i)=>((t,e,i)=>{t[e]=Math.trunc(1e3*i%4294967296),t[e+1]=Math.trunc(1e3*i/4294967296)})(t,2*e,i),me=({values:t},e,i)=>((t,e,i)=>{t[e]=Math.trunc(1e6*i%4294967296),t[e+1]=Math.trunc(1e6*i/4294967296)})(t,2*e,i),be=({values:t},e,i)=>{t[e]=i},ye=({values:t},e,i)=>{t[e]=i},ve=({values:t},e,i)=>{t[e]=i},we=({values:t},e,i)=>{t[e]=i},_e=(t,e,i)=>{const n=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[n];Ce.visit(r,t.valueOffsets[e],i)},xe=(t,e,i)=>{const n=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[n];Ce.visit(r,e,i)},ke=({values:t},e,i)=>{t.set(i.subarray(0,2),2*e)},Se=({values:t},e,i)=>{t[e]=12*i[0]+i[1]%12};re.prototype.visitBool=se((({offset:t,values:e},i,n)=>{const r=t+i;n?e[r>>3]|=1<>3]&=~(1<{switch(t.type.precision){case r.HALF:return ce(t,e,i);case r.SINGLE:case r.DOUBLE:return he(t,e,i)}})),re.prototype.visitFloat16=se(ce),re.prototype.visitFloat32=se(he),re.prototype.visitFloat64=se(he),re.prototype.visitUtf8=se((({values:t,valueOffsets:e},i,n)=>{ae(t,e,i,j(n))})),re.prototype.visitBinary=se((({values:t,valueOffsets:e},i,n)=>ae(t,e,i,n))),re.prototype.visitFixedSizeBinary=se((({stride:t,values:e},i,n)=>{e.set(n.subarray(0,t),t*i)})),re.prototype.visitDate=se(((t,e,i)=>{t.type.unit===s.DAY?ue(t,e,i):de(t,e,i)})),re.prototype.visitDateDay=se(ue),re.prototype.visitDateMillisecond=se(de),re.prototype.visitTimestamp=se(((t,e,i)=>{switch(t.type.unit){case o.SECOND:return fe(t,e,i);case o.MILLISECOND:return pe(t,e,i);case o.MICROSECOND:return ge(t,e,i);case o.NANOSECOND:return me(t,e,i)}})),re.prototype.visitTimestampSecond=se(fe),re.prototype.visitTimestampMillisecond=se(pe),re.prototype.visitTimestampMicrosecond=se(ge),re.prototype.visitTimestampNanosecond=se(me),re.prototype.visitTime=se(((t,e,i)=>{switch(t.type.unit){case o.SECOND:return be(t,e,i);case o.MILLISECOND:return ye(t,e,i);case o.MICROSECOND:return ve(t,e,i);case o.NANOSECOND:return we(t,e,i)}})),re.prototype.visitTimeSecond=se(be),re.prototype.visitTimeMillisecond=se(ye),re.prototype.visitTimeMicrosecond=se(ve),re.prototype.visitTimeNanosecond=se(we),re.prototype.visitDecimal=se((({values:t,stride:e},i,n)=>{t.set(n.subarray(0,e),e*i)})),re.prototype.visitList=se(((t,e,i)=>{const n=t.children[0],r=t.valueOffsets,s=Ce.getVisitFn(n);if(Array.isArray(i))for(let t=-1,o=r[e],a=r[e+1];o{const n=t.type.children.map((t=>Ce.getVisitFn(t.type))),r=i instanceof Map?(s=e,o=i,(t,e,i,n)=>e&&t(e,s,o.get(i.name))):i instanceof Hi?((t,e)=>(i,n,r,s)=>n&&i(n,t,e.get(s)))(e,i):Array.isArray(i)?((t,e)=>(i,n,r,s)=>n&&i(n,t,e[s]))(e,i):((t,e)=>(i,n,r,s)=>n&&i(n,t,e[r.name]))(e,i);var s,o;t.type.children.forEach(((e,i)=>r(n[i],t.children[i],e,i)))})),re.prototype.visitUnion=se(((t,e,i)=>{t.type.mode===n.Dense?_e(t,e,i):xe(t,e,i)})),re.prototype.visitDenseUnion=se(_e),re.prototype.visitSparseUnion=se(xe),re.prototype.visitDictionary=se(((t,e,i)=>{var n;null===(n=t.dictionary)||void 0===n||n.set(t.values[e],i)})),re.prototype.visitInterval=se(((t,e,i)=>{t.type.unit===a.DAY_TIME?ke(t,e,i):Se(t,e,i)})),re.prototype.visitIntervalDayTime=se(ke),re.prototype.visitIntervalYearMonth=se(Se),re.prototype.visitFixedSizeList=se(((t,e,i)=>{const{stride:n}=t,r=t.children[0],s=Ce.getVisitFn(r);if(Array.isArray(i))for(let t=-1,o=e*n;++t{const n=t.children[0],{valueOffsets:r}=t,s=Ce.getVisitFn(n);let{[e]:o,[e+1]:a}=r;const l=i instanceof Map?i.entries():Object.entries(i);for(const t of l)if(s(n,o,t),++o>=a)break}));const Ce=new re,Ae=Symbol.for("parent"),Te=Symbol.for("rowIndex");class Ie{constructor(t,e){return this[Ae]=t,this[Te]=e,new Proxy(this,new Me)}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[Te],e=this[Ae],i=e.type.children,n={};for(let r=-1,s=i.length;++r`${N(t)}: ${N(e)}`)).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new Ee(this[Ae],this[Te])}}class Ee{constructor(t,e){this.childIndex=0,this.children=t.children,this.rowIndex=e,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const t=this.childIndex;return tt.name))}has(t,e){return-1!==t[Ae].type.children.findIndex((t=>t.name===e))}getOwnPropertyDescriptor(t,e){if(-1!==t[Ae].type.children.findIndex((t=>t.name===e)))return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const i=t[Ae].type.children.findIndex((t=>t.name===e));if(-1!==i){const n=Ke.visit(t[Ae].children[i],t[Te]);return Reflect.set(t,e,n),n}}set(t,e,i){const n=t[Ae].type.children.findIndex((t=>t.name===e));return-1!==n?(Ce.visit(t[Ae].children[n],t[Te],i),Reflect.set(t,e,i)):!(!Reflect.has(t,e)&&"symbol"!=typeof e)&&Reflect.set(t,e,i)}}class Re extends Kt{}function Le(t){return(e,i)=>e.getValid(i)?t(e,i):null}const Be=(t,e)=>4294967296*t[e+1]+(t[e]>>>0),Ne=t=>new Date(t),Fe=(t,e,i)=>{if(i+1>=e.length)return null;const n=e[i],r=e[i+1];return t.subarray(n,r)},Oe=({values:t},e)=>((t,e)=>Ne(((t,e)=>864e5*t[e])(t,e)))(t,e),De=({values:t},e)=>((t,e)=>Ne(Be(t,e)))(t,2*e),Pe=({stride:t,values:e},i)=>e[t*i],ze=({values:t},e)=>t[e],Ue=({values:t},e)=>1e3*Be(t,2*e),Ve=({values:t},e)=>Be(t,2*e),He=({values:t},e)=>((t,e)=>t[e+1]/1e3*4294967296+(t[e]>>>0)/1e3)(t,2*e),je=({values:t},e)=>((t,e)=>t[e+1]/1e6*4294967296+(t[e]>>>0)/1e6)(t,2*e),$e=({values:t},e)=>t[e],qe=({values:t},e)=>t[e],We=({values:t},e)=>t[e],Ge=({values:t},e)=>t[e],Ze=(t,e)=>{const i=t.type.typeIdToChildIndex[t.typeIds[e]],n=t.children[i];return Ke.visit(n,t.valueOffsets[e])},Ye=(t,e)=>{const i=t.type.typeIdToChildIndex[t.typeIds[e]],n=t.children[i];return Ke.visit(n,e)},Qe=({values:t},e)=>t.subarray(2*e,2*(e+1)),Xe=({values:t},e)=>{const i=t[e],n=new Int32Array(2);return n[0]=Math.trunc(i/12),n[1]=Math.trunc(i%12),n};Re.prototype.visitNull=Le(((t,e)=>null)),Re.prototype.visitBool=Le((({offset:t,values:e},i)=>{const n=t+i;return 0!=(e[n>>3]&1<t[e])),Re.prototype.visitInt8=Le(Pe),Re.prototype.visitInt16=Le(Pe),Re.prototype.visitInt32=Le(Pe),Re.prototype.visitInt64=Le(ze),Re.prototype.visitUint8=Le(Pe),Re.prototype.visitUint16=Le(Pe),Re.prototype.visitUint32=Le(Pe),Re.prototype.visitUint64=Le(ze),Re.prototype.visitFloat=Le((({type:t,values:e},i)=>t.precision!==r.HALF?e[i]:ne(e[i]))),Re.prototype.visitFloat16=Le((({stride:t,values:e},i)=>ne(e[t*i]))),Re.prototype.visitFloat32=Le(Pe),Re.prototype.visitFloat64=Le(Pe),Re.prototype.visitUtf8=Le((({values:t,valueOffsets:e},i)=>{const n=Fe(t,e,i);return null!==n?V(n):null})),Re.prototype.visitBinary=Le((({values:t,valueOffsets:e},i)=>Fe(t,e,i))),Re.prototype.visitFixedSizeBinary=Le((({stride:t,values:e},i)=>e.subarray(t*i,t*(i+1)))),Re.prototype.visitDate=Le(((t,e)=>t.type.unit===s.DAY?Oe(t,e):De(t,e))),Re.prototype.visitDateDay=Le(Oe),Re.prototype.visitDateMillisecond=Le(De),Re.prototype.visitTimestamp=Le(((t,e)=>{switch(t.type.unit){case o.SECOND:return Ue(t,e);case o.MILLISECOND:return Ve(t,e);case o.MICROSECOND:return He(t,e);case o.NANOSECOND:return je(t,e)}})),Re.prototype.visitTimestampSecond=Le(Ue),Re.prototype.visitTimestampMillisecond=Le(Ve),Re.prototype.visitTimestampMicrosecond=Le(He),Re.prototype.visitTimestampNanosecond=Le(je),Re.prototype.visitTime=Le(((t,e)=>{switch(t.type.unit){case o.SECOND:return $e(t,e);case o.MILLISECOND:return qe(t,e);case o.MICROSECOND:return We(t,e);case o.NANOSECOND:return Ge(t,e)}})),Re.prototype.visitTimeSecond=Le($e),Re.prototype.visitTimeMillisecond=Le(qe),Re.prototype.visitTimeMicrosecond=Le(We),Re.prototype.visitTimeNanosecond=Le(Ge),Re.prototype.visitDecimal=Le((({values:t,stride:e},i)=>lt.decimal(t.subarray(e*i,e*(i+1))))),Re.prototype.visitList=Le(((t,e)=>{const{valueOffsets:i,stride:n,children:r}=t,{[e*n]:s,[e*n+1]:o}=i,a=r[0].slice(s,o-s);return new Hi([a])})),Re.prototype.visitStruct=Le(((t,e)=>new Ie(t,e))),Re.prototype.visitUnion=Le(((t,e)=>t.type.mode===n.Dense?Ze(t,e):Ye(t,e))),Re.prototype.visitDenseUnion=Le(Ze),Re.prototype.visitSparseUnion=Le(Ye),Re.prototype.visitDictionary=Le(((t,e)=>{var i;return null===(i=t.dictionary)||void 0===i?void 0:i.get(t.values[e])})),Re.prototype.visitInterval=Le(((t,e)=>t.type.unit===a.DAY_TIME?Qe(t,e):Xe(t,e))),Re.prototype.visitIntervalDayTime=Le(Qe),Re.prototype.visitIntervalYearMonth=Le(Xe),Re.prototype.visitFixedSizeList=Le(((t,e)=>{const{stride:i,children:n}=t,r=n[0].slice(e*i,i);return new Hi([r])})),Re.prototype.visitMap=Le(((t,e)=>{const{valueOffsets:i,children:n}=t,{[e]:r,[e+1]:s}=i,o=n[0];return new ei(o.slice(r,s-r))}));const Ke=new Re,Je=Symbol.for("keys"),ti=Symbol.for("vals");class ei{constructor(t){return this[Je]=new Hi([t.children[0]]).memoize(),this[ti]=t.children[1],new Proxy(this,new ni)}[Symbol.iterator](){return new ii(this[Je],this[ti])}get size(){return this[Je].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[Je],e=this[ti],i={};for(let n=-1,r=t.length;++n`${N(t)}: ${N(e)}`)).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class ii{constructor(t,e){this.keys=t,this.vals=e,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){const t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),Ke.visit(this.vals,t)]})}}class ni{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[Je].toArray().map(String)}has(t,e){return t[Je].includes(e)}getOwnPropertyDescriptor(t,e){if(-1!==t[Je].indexOf(e))return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const i=t[Je].indexOf(e);if(-1!==i){const n=Ke.visit(Reflect.get(t,ti),i);return Reflect.set(t,e,n),n}}set(t,e,i){const n=t[Je].indexOf(e);return-1!==n?(Ce.visit(Reflect.get(t,ti),n,i),Reflect.set(t,e,i)):!!Reflect.has(t,e)&&Reflect.set(t,e,i)}}let ri;function si(t,e,i,n){const{length:r=0}=t;let s="number"!=typeof e?0:e,o="number"!=typeof i?r:i;return s<0&&(s=(s%r+r)%r),o<0&&(o=(o%r+r)%r),or&&(o=r),n?n(t,s,o):[s,o]}Object.defineProperties(ei.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Je]:{writable:!0,enumerable:!1,configurable:!1,value:null},[ti]:{writable:!0,enumerable:!1,configurable:!1,value:null}});const oi=t=>t!=t;function ai(t){if("object"!=typeof t||null===t)return oi(t)?oi:e=>e===t;if(t instanceof Date){const e=t.valueOf();return t=>t instanceof Date&&t.valueOf()===e}return ArrayBuffer.isView(t)?e=>!!e&&function(t,e){let i=0;const n=t.length;if(n!==e.length)return!1;if(n>0)do{if(t[i]!==e[i])return!1}while(++i!1;const n=[];for(let e=-1,r=i.length;++e{if(!i||"object"!=typeof i)return!1;switch(i.constructor){case Array:return function(t,e){const i=t.length;if(e.length!==i)return!1;for(let n=-1;++nt+e.nullCount),0)}function di(t){return t.reduce(((t,e,i)=>(t[i+1]=t[i]+e.length,t)),new Uint32Array(t.length+1))}function fi(t,e,i,n){const r=[];for(let s=-1,o=t.length;++s=n)break;if(i>=a+l)continue;if(a>=i&&a+l<=n){r.push(o);continue}const h=Math.max(0,i-a),c=Math.min(n-a,l);r.push(o.slice(h,c-h))}return 0===r.length&&r.push(t[0].slice(0,0)),r}function pi(t,e,i,n){let r=0,s=0,o=e.length-1;do{if(r>=o-1)return i>n}function _i(t,e,i){const n=i.byteLength+7&-8;if(t>0||i.byteLength>3):xi(new ki(i,t,e,null,vi)).subarray(0,n)),r}return i}function xi(t){const e=[];let i=0,n=0,r=0;for(const s of t)s&&(r|=1<0)&&(e[i++]=r);const s=new Uint8Array(e.length+7&-8);return s.set(e),s}class ki{constructor(t,e,i,n,r){this.bytes=t,this.length=i,this.context=n,this.get=r,this.bit=e%8,this.byteIndex=e>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index>3<<3,r=e+(e%8==0?0:8-e%8);return Si(t,e,r)+Si(t,n,i)+function(t,e,i){let n=0,r=Math.trunc(e);const s=new DataView(t.buffer,t.byteOffset,t.byteLength),o=void 0===i?t.byteLength:r+i;for(;o-r>=4;)n+=Ci(s.getUint32(r)),r+=4;for(;o-r>=2;)n+=Ci(s.getUint16(r)),r+=2;for(;o-r>=1;)n+=Ci(s.getUint8(r)),r+=1;return n}(t,r>>3,n-r>>3)}function Ci(t){let e=Math.trunc(t);return e-=e>>>1&1431655765,e=(858993459&e)+(e>>>2&858993459),16843009*(e+(e>>>4)&252645135)>>>24}class Ai extends Kt{}function Ti(t,e,i){if(void 0===e)return-1;if(null===e)return function(t,e){const{nullBitmap:i}=t;if(!i||t.nullCount<=0)return-1;let n=0;for(const r of new ki(i,t.offset+(e||0),t.length,i,vi)){if(!r)return n;++n}return-1}(t,i);const n=Ke.getVisitFn(t),r=ai(e);for(let e=(i||0)-1,s=t.length;++e0?0:-1},Ai.prototype.visitBool=Ti,Ai.prototype.visitInt=Ti,Ai.prototype.visitInt8=Ti,Ai.prototype.visitInt16=Ti,Ai.prototype.visitInt32=Ti,Ai.prototype.visitInt64=Ti,Ai.prototype.visitUint8=Ti,Ai.prototype.visitUint16=Ti,Ai.prototype.visitUint32=Ti,Ai.prototype.visitUint64=Ti,Ai.prototype.visitFloat=Ti,Ai.prototype.visitFloat16=Ti,Ai.prototype.visitFloat32=Ti,Ai.prototype.visitFloat64=Ti,Ai.prototype.visitUtf8=Ti,Ai.prototype.visitBinary=Ti,Ai.prototype.visitFixedSizeBinary=Ti,Ai.prototype.visitDate=Ti,Ai.prototype.visitDateDay=Ti,Ai.prototype.visitDateMillisecond=Ti,Ai.prototype.visitTimestamp=Ti,Ai.prototype.visitTimestampSecond=Ti,Ai.prototype.visitTimestampMillisecond=Ti,Ai.prototype.visitTimestampMicrosecond=Ti,Ai.prototype.visitTimestampNanosecond=Ti,Ai.prototype.visitTime=Ti,Ai.prototype.visitTimeSecond=Ti,Ai.prototype.visitTimeMillisecond=Ti,Ai.prototype.visitTimeMicrosecond=Ti,Ai.prototype.visitTimeNanosecond=Ti,Ai.prototype.visitDecimal=Ti,Ai.prototype.visitList=Ti,Ai.prototype.visitStruct=Ti,Ai.prototype.visitUnion=Ti,Ai.prototype.visitDenseUnion=Ii,Ai.prototype.visitSparseUnion=Ii,Ai.prototype.visitDictionary=Ti,Ai.prototype.visitInterval=Ti,Ai.prototype.visitIntervalDayTime=Ti,Ai.prototype.visitIntervalYearMonth=Ti,Ai.prototype.visitFixedSizeList=Ti,Ai.prototype.visitMap=Ti;const Ei=new Ai;class Mi extends Kt{}function Ri(t){const{type:e}=t;if(0===t.nullCount&&1===t.stride&&(e.typeId===h.Timestamp||e instanceof Rt&&64!==e.bitWidth||e instanceof zt&&64!==e.bitWidth||e instanceof Bt&&e.precision!==r.HALF))return new ci(t.data.length,(e=>{const i=t.data[e];return i.values.subarray(0,i.length)[Symbol.iterator]()}));let i=0;return new ci(t.data.length,(e=>{const n=t.data[e].length,r=t.slice(i,i+n);return i+=n,new Li(r)}))}class Li{constructor(t){this.vector=t,this.index=0}next(){return this.indext+e;class Fi extends Kt{visitNull(t,e){return 0}visitInt(t,e){return t.type.bitWidth/8}visitFloat(t,e){return t.type.ArrayType.BYTES_PER_ELEMENT}visitBool(t,e){return 1/8}visitDecimal(t,e){return t.type.bitWidth/8}visitDate(t,e){return 4*(t.type.unit+1)}visitTime(t,e){return t.type.bitWidth/8}visitTimestamp(t,e){return t.type.unit===o.SECOND?4:8}visitInterval(t,e){return 4*(t.type.unit+1)}visitStruct(t,e){return t.children.reduce(((t,i)=>t+Pi.visit(i,e)),0)}visitFixedSizeBinary(t,e){return t.type.byteWidth}visitMap(t,e){return 8+t.children.reduce(((t,i)=>t+Pi.visit(i,e)),0)}visitDictionary(t,e){var i;return t.type.indices.bitWidth/8+((null===(i=t.dictionary)||void 0===i?void 0:i.getByteLength(t.values[e]))||0)}}const Oi=({type:t,children:e,typeIds:i,valueOffsets:n},r)=>{const s=t.typeIdToChildIndex[i[r]];return 8+Pi.visit(e[s],n[r])},Di=({children:t},e)=>4+Pi.visitMany(t,t.map((()=>e))).reduce(Ni,0);Fi.prototype.visitUtf8=({valueOffsets:t},e)=>t[e+1]-t[e]+8,Fi.prototype.visitBinary=({valueOffsets:t},e)=>t[e+1]-t[e]+8,Fi.prototype.visitList=({valueOffsets:t,stride:e,children:i},n)=>{const r=i[0],{[n*e]:s}=t,{[n*e+1]:o}=t,a=Pi.getVisitFn(r.type),l=r.slice(s,o-s);let h=8;for(let t=-1,e=o-s;++t{const n=e[0],r=n.slice(i*t,t),s=Pi.getVisitFn(n.type);let o=0;for(let t=-1,e=r.length;++tt.type.mode===n.Dense?Oi(t,e):Di(t,e),Fi.prototype.visitDenseUnion=Oi,Fi.prototype.visitSparseUnion=Di;const Pi=new Fi;var zi;const Ui={},Vi={};class Hi{constructor(t){var e,i,n;const r=t[0]instanceof Hi?t.flatMap((t=>t.data)):t;if(0===r.length||r.some((t=>!(t instanceof $i))))throw new TypeError("Vector constructor expects an Array of Data instances.");const s=null===(e=r[0])||void 0===e?void 0:e.type;switch(r.length){case 0:this._offsets=[0];break;case 1:{const{get:t,set:e,indexOf:i,byteLength:n}=Ui[s.typeId],o=r[0];this.isValid=t=>gi(o,t),this.get=e=>t(o,e),this.set=(t,i)=>e(o,t,i),this.indexOf=t=>i(o,t),this.getByteLength=t=>n(o,t),this._offsets=[0,o.length];break}default:Object.setPrototypeOf(this,Vi[s.typeId]),this._offsets=di(r)}this.data=r,this.type=s,this.stride=Xt(s),this.numChildren=null!==(n=null===(i=s.children)||void 0===i?void 0:i.length)&&void 0!==n?n:0,this.length=this._offsets[this._offsets.length-1]}get byteLength(){return-1===this._byteLength&&(this._byteLength=this.data.reduce(((t,e)=>t+e.byteLength),0)),this._byteLength}get nullCount(){return-1===this._nullCount&&(this._nullCount=ui(this.data)),this._nullCount}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${h[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>0}getByteLength(t){return 0}[Symbol.iterator](){return Bi.visit(this)}concat(...t){return new Hi(this.data.concat(t.flatMap((t=>t.data)).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new Hi(si(this,t,e,(({data:t,_offsets:e},i,n)=>fi(t,e,i,n))))}toJSON(){return[...this]}toArray(){const{type:t,data:e,length:i,stride:n,ArrayType:r}=this;switch(t.typeId){case h.Int:case h.Float:case h.Decimal:case h.Time:case h.Timestamp:switch(e.length){case 0:return new r;case 1:return e[0].values.subarray(0,i*n);default:return e.reduce(((t,{values:e,length:i})=>(t.array.set(e.subarray(0,i*n),t.offset),t.offset+=i*n,t)),{array:new r(i*n),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(t){var e;return this.getChildAt(null===(e=this.type.children)||void 0===e?void 0:e.findIndex((e=>e.name===t)))}getChildAt(t){return t>-1&&te[t]))):null}get isMemoized(){return!!Et.isDictionary(this.type)&&this.data[0].dictionary.isMemoized}memoize(){if(Et.isDictionary(this.type)){const t=new ji(this.data[0].dictionary),e=this.data.map((e=>{const i=e.clone();return i.dictionary=t,i}));return new Hi(e)}return new ji(this)}unmemoize(){if(Et.isDictionary(this.type)&&this.isMemoized){const t=this.data[0].dictionary.unmemoize(),e=this.data.map((e=>{const i=e.clone();return i.dictionary=t,i}));return new Hi(e)}return this}}zi=Symbol.toStringTag,Hi[zi]=(t=>{t.type=Et.prototype,t.data=[],t.length=0,t.stride=1,t.numChildren=0,t._nullCount=-1,t._byteLength=-1,t._offsets=new Uint32Array([0]),t[Symbol.isConcatSpreadable]=!0;const e=Object.keys(h).map((t=>h[t])).filter((t=>"number"==typeof t&&t!==h.NONE));for(const i of e){const e=Ke.getVisitFnByTypeId(i),n=Ce.getVisitFnByTypeId(i),r=Ei.getVisitFnByTypeId(i),s=Pi.getVisitFnByTypeId(i);Ui[i]={get:e,set:n,indexOf:r,byteLength:s},Vi[i]=Object.create(t,{isValid:{value:mi(gi)},get:{value:mi(Ke.getVisitFnByTypeId(i))},set:{value:bi(Ce.getVisitFnByTypeId(i))},indexOf:{value:yi(Ei.getVisitFnByTypeId(i))},getByteLength:{value:mi(Pi.getVisitFnByTypeId(i))}})}return"Vector"})(Hi.prototype);class ji extends Hi{constructor(t){super(t.data);const e=this.get,i=this.set,n=this.slice,r=new Array(this.length);Object.defineProperty(this,"get",{value(t){const i=r[t];if(void 0!==i)return i;const n=e.call(this,t);return r[t]=n,n}}),Object.defineProperty(this,"set",{value(t,e){i.call(this,t,e),r[t]=e}}),Object.defineProperty(this,"slice",{value:(t,e)=>new ji(n.call(this,t,e))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Hi(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class $i{constructor(t,e,i,n,r,s=[],o){let a;this.type=t,this.children=s,this.dictionary=o,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(i||0,0)),this._nullCount=Math.floor(Math.max(n||0,-1)),r instanceof $i?(this.stride=r.stride,this.values=r.values,this.typeIds=r.typeIds,this.nullBitmap=r.nullBitmap,this.valueOffsets=r.valueOffsets):(this.stride=Xt(t),r&&((a=r[0])&&(this.valueOffsets=a),(a=r[1])&&(this.values=a),(a=r[2])&&(this.nullBitmap=a),(a=r[3])&&(this.typeIds=a))),this.nullable=0!==this._nullCount&&this.nullBitmap&&this.nullBitmap.byteLength>0}get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get byteLength(){let t=0;const{valueOffsets:e,values:i,nullBitmap:n,typeIds:r}=this;return e&&(t+=e.byteLength),i&&(t+=i.byteLength),n&&(t+=n.byteLength),r&&(t+=r.byteLength),this.children.reduce(((t,e)=>t+e.byteLength),t)}get nullCount(){let t,e=this._nullCount;return e<=-1&&(t=this.nullBitmap)&&(this._nullCount=e=this.length-Si(t,this.offset,this.offset+this.length)),e}getValid(t){if(this.nullable&&this.nullCount>0){const e=this.offset+t;return 0!=(this.nullBitmap[e>>3]&1<>3){const{nullBitmap:t}=this._changeLengthAndBackfillNullBitmap(this.length);Object.assign(this,{nullBitmap:t,_nullCount:0})}const{nullBitmap:i,offset:n}=this,r=n+t>>3,s=(n+t)%8,o=i[r]>>s&1;return e?0===o&&(i[r]|=1<>3).fill(255,0,e>>3);n[e>>3]=(1<0&&n.set(_i(this.offset,e,this.nullBitmap),0);const r=this.buffers;return r[c.VALIDITY]=n,this.clone(this.type,0,t,i+(t-e),r)}_sliceBuffers(t,e,i,n){let r;const{buffers:s}=this;return(r=s[c.TYPE])&&(s[c.TYPE]=r.subarray(t,t+e)),(r=s[c.OFFSET])&&(s[c.OFFSET]=r.subarray(t,t+e+1))||(r=s[c.DATA])&&(s[c.DATA]=6===n?r:r.subarray(i*t,i*(t+e))),s}_sliceChildren(t,e,i){return t.map((t=>t.slice(e,i)))}}$i.prototype.children=Object.freeze([]);class qi extends Kt{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){const{type:e,offset:i=0,length:n=0}=t;return new $i(e,i,n,0)}visitBool(t){const{type:e,offset:i=0}=t,n=Y(t.nullBitmap),r=G(e.ArrayType,t.data),{length:s=r.length>>3,nullCount:o=(t.nullBitmap?-1:0)}=t;return new $i(e,i,s,o,[void 0,r,n])}visitInt(t){const{type:e,offset:i=0}=t,n=Y(t.nullBitmap),r=G(e.ArrayType,t.data),{length:s=r.length,nullCount:o=(t.nullBitmap?-1:0)}=t;return new $i(e,i,s,o,[void 0,r,n])}visitFloat(t){const{type:e,offset:i=0}=t,n=Y(t.nullBitmap),r=G(e.ArrayType,t.data),{length:s=r.length,nullCount:o=(t.nullBitmap?-1:0)}=t;return new $i(e,i,s,o,[void 0,r,n])}visitUtf8(t){const{type:e,offset:i=0}=t,n=Y(t.data),r=Y(t.nullBitmap),s=Z(t.valueOffsets),{length:o=s.length-1,nullCount:a=(t.nullBitmap?-1:0)}=t;return new $i(e,i,o,a,[s,n,r])}visitBinary(t){const{type:e,offset:i=0}=t,n=Y(t.data),r=Y(t.nullBitmap),s=Z(t.valueOffsets),{length:o=s.length-1,nullCount:a=(t.nullBitmap?-1:0)}=t;return new $i(e,i,o,a,[s,n,r])}visitFixedSizeBinary(t){const{type:e,offset:i=0}=t,n=Y(t.nullBitmap),r=G(e.ArrayType,t.data),{length:s=r.length/Xt(e),nullCount:o=(t.nullBitmap?-1:0)}=t;return new $i(e,i,s,o,[void 0,r,n])}visitDate(t){const{type:e,offset:i=0}=t,n=Y(t.nullBitmap),r=G(e.ArrayType,t.data),{length:s=r.length/Xt(e),nullCount:o=(t.nullBitmap?-1:0)}=t;return new $i(e,i,s,o,[void 0,r,n])}visitTimestamp(t){const{type:e,offset:i=0}=t,n=Y(t.nullBitmap),r=G(e.ArrayType,t.data),{length:s=r.length/Xt(e),nullCount:o=(t.nullBitmap?-1:0)}=t;return new $i(e,i,s,o,[void 0,r,n])}visitTime(t){const{type:e,offset:i=0}=t,n=Y(t.nullBitmap),r=G(e.ArrayType,t.data),{length:s=r.length/Xt(e),nullCount:o=(t.nullBitmap?-1:0)}=t;return new $i(e,i,s,o,[void 0,r,n])}visitDecimal(t){const{type:e,offset:i=0}=t,n=Y(t.nullBitmap),r=G(e.ArrayType,t.data),{length:s=r.length/Xt(e),nullCount:o=(t.nullBitmap?-1:0)}=t;return new $i(e,i,s,o,[void 0,r,n])}visitList(t){const{type:e,offset:i=0,child:n}=t,r=Y(t.nullBitmap),s=Z(t.valueOffsets),{length:o=s.length-1,nullCount:a=(t.nullBitmap?-1:0)}=t;return new $i(e,i,o,a,[s,void 0,r],[n])}visitStruct(t){const{type:e,offset:i=0,children:n=[]}=t,r=Y(t.nullBitmap),{length:s=n.reduce(((t,{length:e})=>Math.max(t,e)),0),nullCount:o=(t.nullBitmap?-1:0)}=t;return new $i(e,i,s,o,[void 0,void 0,r],n)}visitUnion(t){const{type:e,offset:i=0,children:n=[]}=t,r=Y(t.nullBitmap),s=G(e.ArrayType,t.typeIds),{length:o=s.length,nullCount:a=(t.nullBitmap?-1:0)}=t;if(Et.isSparseUnion(e))return new $i(e,i,o,a,[void 0,void 0,r,s],n);const l=Z(t.valueOffsets);return new $i(e,i,o,a,[l,void 0,r,s],n)}visitDictionary(t){const{type:e,offset:i=0}=t,n=Y(t.nullBitmap),r=G(e.indices.ArrayType,t.data),{dictionary:s=new Hi([(new qi).visit({type:e.dictionary})])}=t,{length:o=r.length,nullCount:a=(t.nullBitmap?-1:0)}=t;return new $i(e,i,o,a,[void 0,r,n],[],s)}visitInterval(t){const{type:e,offset:i=0}=t,n=Y(t.nullBitmap),r=G(e.ArrayType,t.data),{length:s=r.length/Xt(e),nullCount:o=(t.nullBitmap?-1:0)}=t;return new $i(e,i,s,o,[void 0,r,n])}visitFixedSizeList(t){const{type:e,offset:i=0,child:n=(new qi).visit({type:e.valueType})}=t,r=Y(t.nullBitmap),{length:s=n.length/Xt(e),nullCount:o=(t.nullBitmap?-1:0)}=t;return new $i(e,i,s,o,[void 0,void 0,r],[n])}visitMap(t){const{type:e,offset:i=0,child:n=(new qi).visit({type:e.childType})}=t,r=Y(t.nullBitmap),s=Z(t.valueOffsets),{length:o=s.length-1,nullCount:a=(t.nullBitmap?-1:0)}=t;return new $i(e,i,o,a,[s,void 0,r],[n])}}function Wi(t){return(new qi).visit(t)}class Gi{constructor(t=[],e,i){this.fields=t||[],this.metadata=e||new Map,i||(i=Qi(t)),this.dictionaries=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map((t=>t.name))}toString(){return`Schema<{ ${this.fields.map(((t,e)=>`${e}: ${t}`)).join(", ")} }>`}select(t){const e=new Set(t),i=this.fields.filter((t=>e.has(t.name)));return new Gi(i,this.metadata)}selectAt(t){const e=t.map((t=>this.fields[t])).filter(Boolean);return new Gi(e,this.metadata)}assign(...t){const e=t[0]instanceof Gi?t[0]:Array.isArray(t[0])?new Gi(t[0]):new Gi(t),i=[...this.fields],n=Yi(Yi(new Map,this.metadata),e.metadata),r=e.fields.filter((t=>{const e=i.findIndex((e=>e.name===t.name));return!~e||(i[e]=t.clone({metadata:Yi(Yi(new Map,i[e].metadata),t.metadata)}))&&!1})),s=Qi(r,new Map);return new Gi([...i,...r],n,new Map([...this.dictionaries,...s]))}}Gi.prototype.fields=null,Gi.prototype.metadata=null,Gi.prototype.dictionaries=null;class Zi{constructor(t,e,i=!1,n){this.name=t,this.type=e,this.nullable=i,this.metadata=n||new Map}static new(...t){let[e,i,n,r]=t;return t[0]&&"object"==typeof t[0]&&(({name:e}=t[0]),void 0===i&&(i=t[0].type),void 0===n&&(n=t[0].nullable),void 0===r&&(r=t[0].metadata)),new Zi(`${e}`,i,n,r)}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[e,i,n,r]=t;return t[0]&&"object"==typeof t[0]?({name:e=this.name,type:i=this.type,nullable:n=this.nullable,metadata:r=this.metadata}=t[0]):[e=this.name,i=this.type,n=this.nullable,r=this.metadata]=t,Zi.new(e,i,n,r)}}function Yi(t,e){return new Map([...t||new Map,...e||new Map])}function Qi(t,e=new Map){for(let i=-1,n=t.length;++i0&&Qi(n.children,e)}return e}Zi.prototype.type=null,Zi.prototype.name=null,Zi.prototype.nullable=null,Zi.prototype.metadata=null;class Xi extends Kt{compareSchemas(t,e){return t===e||e instanceof t.constructor&&this.compareManyFields(t.fields,e.fields)}compareManyFields(t,e){return t===e||Array.isArray(t)&&Array.isArray(e)&&t.length===e.length&&t.every(((t,i)=>this.compareFields(t,e[i])))}compareFields(t,e){return t===e||e instanceof t.constructor&&t.name===e.name&&t.nullable===e.nullable&&this.visit(t.type,e.type)}}function Ki(t,e){return e instanceof t.constructor}function Ji(t,e){return t===e||Ki(t,e)}function tn(t,e){return t===e||Ki(t,e)&&t.bitWidth===e.bitWidth&&t.isSigned===e.isSigned}function en(t,e){return t===e||Ki(t,e)&&t.precision===e.precision}function nn(t,e){return t===e||Ki(t,e)&&t.unit===e.unit}function rn(t,e){return t===e||Ki(t,e)&&t.unit===e.unit&&t.timezone===e.timezone}function sn(t,e){return t===e||Ki(t,e)&&t.unit===e.unit&&t.bitWidth===e.bitWidth}function on(t,e){return t===e||Ki(t,e)&&t.mode===e.mode&&t.typeIds.every(((t,i)=>t===e.typeIds[i]))&&ln.compareManyFields(t.children,e.children)}function an(t,e){return t===e||Ki(t,e)&&t.unit===e.unit}Xi.prototype.visitNull=Ji,Xi.prototype.visitBool=Ji,Xi.prototype.visitInt=tn,Xi.prototype.visitInt8=tn,Xi.prototype.visitInt16=tn,Xi.prototype.visitInt32=tn,Xi.prototype.visitInt64=tn,Xi.prototype.visitUint8=tn,Xi.prototype.visitUint16=tn,Xi.prototype.visitUint32=tn,Xi.prototype.visitUint64=tn,Xi.prototype.visitFloat=en,Xi.prototype.visitFloat16=en,Xi.prototype.visitFloat32=en,Xi.prototype.visitFloat64=en,Xi.prototype.visitUtf8=Ji,Xi.prototype.visitBinary=Ji,Xi.prototype.visitFixedSizeBinary=function(t,e){return t===e||Ki(t,e)&&t.byteWidth===e.byteWidth},Xi.prototype.visitDate=nn,Xi.prototype.visitDateDay=nn,Xi.prototype.visitDateMillisecond=nn,Xi.prototype.visitTimestamp=rn,Xi.prototype.visitTimestampSecond=rn,Xi.prototype.visitTimestampMillisecond=rn,Xi.prototype.visitTimestampMicrosecond=rn,Xi.prototype.visitTimestampNanosecond=rn,Xi.prototype.visitTime=sn,Xi.prototype.visitTimeSecond=sn,Xi.prototype.visitTimeMillisecond=sn,Xi.prototype.visitTimeMicrosecond=sn,Xi.prototype.visitTimeNanosecond=sn,Xi.prototype.visitDecimal=Ji,Xi.prototype.visitList=function(t,e){return t===e||Ki(t,e)&&t.children.length===e.children.length&&ln.compareManyFields(t.children,e.children)},Xi.prototype.visitStruct=function(t,e){return t===e||Ki(t,e)&&t.children.length===e.children.length&&ln.compareManyFields(t.children,e.children)},Xi.prototype.visitUnion=on,Xi.prototype.visitDenseUnion=on,Xi.prototype.visitSparseUnion=on,Xi.prototype.visitDictionary=function(t,e){return t===e||Ki(t,e)&&t.id===e.id&&t.isOrdered===e.isOrdered&&ln.visit(t.indices,e.indices)&&ln.visit(t.dictionary,e.dictionary)},Xi.prototype.visitInterval=an,Xi.prototype.visitIntervalDayTime=an,Xi.prototype.visitIntervalYearMonth=an,Xi.prototype.visitFixedSizeList=function(t,e){return t===e||Ki(t,e)&&t.listSize===e.listSize&&t.children.length===e.children.length&&ln.compareManyFields(t.children,e.children)},Xi.prototype.visitMap=function(t,e){return t===e||Ki(t,e)&&t.keysSorted===e.keysSorted&&t.children.length===e.children.length&&ln.compareManyFields(t.children,e.children)};const ln=new Xi;function hn(t,e){return ln.compareSchemas(t,e)}var cn,un;class dn{constructor(...t){switch(t.length){case 2:if([this.schema]=t,!(this.schema instanceof Gi))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=Wi({nullCount:0,type:new jt(this.schema.fields),children:this.schema.fields.map((t=>Wi({type:t.type,nullCount:0})))})]=t,!(this.data instanceof $i))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=fn(this.schema,this.data.children);break;case 1:{const[e]=t,{fields:i,children:n,length:r}=Object.keys(e).reduce(((t,i,n)=>(t.children[n]=e[i],t.length=Math.max(t.length,e[i].length),t.fields[n]=Zi.new({name:i,type:e[i].type,nullable:!0}),t)),{length:0,fields:new Array,children:new Array}),s=new Gi(i),o=Wi({type:new jt(i),length:r,children:n,nullCount:0});[this.schema,this.data]=fn(s,o.children,r);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=pn(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return Ke.visit(this.data,t)}set(t,e){return Ce.visit(this.data,t,e)}indexOf(t,e){return Ei.visit(this.data,t,e)}getByteLength(t){return Pi.visit(this.data,t)}[Symbol.iterator](){return Bi.visit(new Hi([this.data]))}toArray(){return[...this]}concat(...t){return new yn(this.schema,[this,...t])}slice(t,e){const[i]=new Hi([this.data]).slice(t,e).data;return new dn(this.schema,i)}getChild(t){var e;return this.getChildAt(null===(e=this.schema.fields)||void 0===e?void 0:e.findIndex((e=>e.name===t)))}getChildAt(t){return t>-1&&te.name===t)),e)}setChildAt(t,e){let i=this.schema,n=this.data;if(t>-1&&tt.name===e));~t&&(n[t]=this.data.children[t])}return new dn(e,Wi({type:i,length:this.numRows,children:n}))}selectAt(t){const e=this.schema.selectAt(t),i=t.map((t=>this.data.children[t])).filter(Boolean),n=Wi({type:new jt(e.fields),length:this.numRows,children:i});return new dn(e,n)}}function fn(t,e,i=e.reduce(((t,e)=>Math.max(t,e.length)),0)){var n;const r=[...t.fields],s=[...e],o=(i+63&-64)>>3;for(const[a,l]of t.fields.entries()){const t=e[a];t&&t.length===i||(r[a]=l.clone({nullable:!0}),s[a]=null!==(n=null==t?void 0:t._changeLengthAndBackfillNullBitmap(i))&&void 0!==n?n:Wi({type:l.type,length:i,nullCount:i,nullBitmap:new Uint8Array(o)}))}return[t.assign(r),Wi({type:new jt(r),length:i,children:s})]}function pn(t,e,i=new Map){for(let n=-1,r=t.length;++n0&&pn(r.children,s.children,i)}return i}cn=Symbol.toStringTag,dn[cn]=(t=>(t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(dn.prototype);class gn extends dn{constructor(t){const e=t.fields.map((t=>Wi({type:t.type})));super(t,Wi({type:new jt(t.fields),nullCount:0,children:e}))}}function mn(t,e){return function(t,e){const i=[...t.fields],n=[],r={numBatches:e.reduce(((t,e)=>Math.max(t,e.length)),0)};let s=0,o=0,a=-1;const l=e.length;let h,c=[];for(;r.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a0&&(n[s++]=Wi({type:new jt(i),length:o,nullCount:0,children:c.slice()})))}return[t=t.assign(i),n.map((e=>new dn(t,e)))]}(t,e.map((t=>t.data.concat())))}function bn(t,e,i,n,r){var s;const o=(e+63&-64)>>3;for(let a=-1,l=n.length;++a=e)h===e?i[a]=l:(i[a]=l.slice(0,e),r.numBatches=Math.max(r.numBatches,n[a].unshift(l.slice(e,h-e))));else{const n=t[a];t[a]=n.clone({nullable:!0}),i[a]=null!==(s=null==l?void 0:l._changeLengthAndBackfillNullBitmap(e))&&void 0!==s?s:Wi({type:n.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)})}}return i}class yn{constructor(...t){var e,i;if(0===t.length)return this.batches=[],this.schema=new Gi([]),this._offsets=[0],this;let n,r;t[0]instanceof Gi&&(n=t.shift()),t[t.length-1]instanceof Uint32Array&&(r=t.pop());const s=t=>{if(t){if(t instanceof dn)return[t];if(t instanceof yn)return t.batches;if(t instanceof $i){if(t.type instanceof jt)return[new dn(new Gi(t.type.children),t)]}else{if(Array.isArray(t))return t.flatMap((t=>s(t)));if("function"==typeof t[Symbol.iterator])return[...t].flatMap((t=>s(t)));if("object"==typeof t){const e=Object.keys(t),i=e.map((e=>new Hi([t[e]]))),n=new Gi(e.map(((t,e)=>new Zi(String(t),i[e].type)))),[,r]=mn(n,i);return 0===r.length?[new dn(t)]:r}}}return[]},o=t.flatMap((t=>s(t)));if(n=null!==(i=null!=n?n:null===(e=o[0])||void 0===e?void 0:e.schema)&&void 0!==i?i:new Gi([]),!(n instanceof Gi))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const t of o){if(!(t instanceof dn))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!hn(n,t.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=n,this.batches=o,this._offsets=null!=r?r:di(this.data)}get data(){return this.batches.map((({data:t})=>t))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce(((t,e)=>t+e.length),0)}get nullCount(){return-1===this._nullCount&&(this._nullCount=ui(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}set(t,e){}indexOf(t,e){return-1}getByteLength(t){return 0}[Symbol.iterator](){return this.batches.length>0?Bi.visit(new Hi(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[\n ${this.toArray().join(",\n ")}\n]`}concat(...t){const e=this.schema,i=this.data.concat(t.flatMap((({data:t})=>t)));return new yn(e,i.map((t=>new dn(e,t))))}slice(t,e){const i=this.schema;[t,e]=si({length:this.numRows},t,e);const n=fi(this.data,this._offsets,t,e);return new yn(i,n.map((t=>new dn(i,t))))}getChild(t){return this.getChildAt(this.schema.fields.findIndex((e=>e.name===t)))}getChildAt(t){if(t>-1&&te.children[t]));if(0===e.length){const{type:i}=this.schema.fields[t],n=Wi({type:i,length:0,nullCount:0});e.push(n._changeLengthAndBackfillNullBitmap(this.numRows))}return new Hi(e)}return null}setChild(t,e){var i;return this.setChildAt(null===(i=this.schema.fields)||void 0===i?void 0:i.findIndex((e=>e.name===t)),e)}setChildAt(t,e){let i=this.schema,n=[...this.batches];if(t>-1&&tthis.getChildAt(e)));[r[t],o[t]]=[s,e],[i,n]=mn(i,o)}return new yn(i,n)}select(t){const e=this.schema.fields.reduce(((t,e,i)=>t.set(e.name,i)),new Map);return this.selectAt(t.map((t=>e.get(t))).filter((t=>t>-1)))}selectAt(t){const e=this.schema.selectAt(t),i=this.batches.map((e=>e.selectAt(t)));return new yn(e,i)}assign(t){const e=this.schema.fields,[i,n]=t.schema.fields.reduce(((t,i,n)=>{const[r,s]=t,o=e.findIndex((t=>t.name===i.name));return~o?s[o]=n:r.push(n),t}),[[],[]]),r=this.schema.assign(t.schema),s=[...e.map(((t,e)=>[e,n[e]])).map((([e,i])=>void 0===i?this.getChildAt(e):t.getChildAt(i))),...i.map((e=>t.getChildAt(e)))].filter(Boolean);return new yn(...mn(r,s))}}un=Symbol.toStringTag,yn[un]=(t=>(t.schema=null,t.batches=[],t._offsets=new Uint32Array([0]),t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,t.isValid=mi(gi),t.get=mi(Ke.getVisitFn(h.Struct)),t.set=bi(Ce.getVisitFn(h.Struct)),t.indexOf=yi(Ei.getVisitFn(h.Struct)),t.getByteLength=mi(Pi.getVisitFn(h.Struct)),"Table"))(yn.prototype);class vn{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(t,e,i,n){return t.prep(8,24),t.writeInt64(n),t.pad(4),t.writeInt32(i),t.writeInt64(e),t.offset()}}const wn=new Int32Array(2),_n=new Float32Array(wn.buffer),xn=new Float64Array(wn.buffer),kn=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0];class Sn{constructor(t,e){this.low=0|t,this.high=0|e}static create(t,e){return 0==t&&0==e?Sn.ZERO:new Sn(t,e)}toFloat64(){return(this.low>>>0)+4294967296*this.high}equals(t){return this.low==t.low&&this.high==t.high}}var Cn,An,Tn,In,En;Sn.ZERO=new Sn(0,0),function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"}(Cn||(Cn={}));class Mn{constructor(t){this.bytes_=t,this.position_=0}static allocate(t){return new Mn(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return new Sn(this.readInt32(t),this.readInt32(t+4))}readUint64(t){return new Sn(this.readUint32(t),this.readUint32(t+4))}readFloat32(t){return wn[0]=this.readInt32(t),_n[0]}readFloat64(t){return wn[kn?0:1]=this.readInt32(t),wn[kn?1:0]=this.readInt32(t+4),xn[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)}writeUint64(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)}writeFloat32(t,e){_n[0]=e,this.writeInt32(t,wn[0])}writeFloat64(t,e){xn[0]=e,this.writeInt32(t,wn[kn?0:1]),this.writeInt32(t+4,wn[kn?1:0])}getBufferIdentifier(){if(this.bytes_.length>10),56320+(1023&e)))}return n}__union_with_string(t,e){return"string"==typeof t?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+4}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(4!=t.length)throw new Error("FlatBuffers: file identifier must be length 4");for(let e=0;e<4;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+4+e))return!1;return!0}createLong(t,e){return Sn.create(t,e)}createScalarList(t,e){const i=[];for(let n=0;nthis.minalign&&(this.minalign=t);const i=1+~(this.bb.capacity()-this.space+e)&t-1;for(;this.space=0&&0==this.vtable[e];e--);const i=e+1;for(;e>=0;e--)this.addInt16(0!=this.vtable[e]?t-this.vtable[e]:0);this.addInt16(t-this.object_start);const n=2*(i+2);this.addInt16(n);let r=0;const s=this.space;t:for(e=0;e=0;e--)this.writeInt8(t.charCodeAt(e))}this.prep(this.minalign,4+n),this.addOffset(t),n&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const i=this.bb.capacity()-t,n=i-this.bb.readInt32(i);if(0==this.bb.readInt16(n+e))throw new Error("FlatBuffers: field "+e+" must be set")}startVector(t,e,i){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(i,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);const e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(!t)return 0;let e;if(t instanceof Uint8Array)e=t;else{e=[];let i=0;for(;i=56320?r:(r<<10)+t.charCodeAt(i++)+-56613888,n<128?e.push(n):(n<2048?e.push(n>>6&31|192):(n<65536?e.push(n>>12&15|224):e.push(n>>18&7|240,n>>12&63|128),e.push(n>>6&63|128)),e.push(63&n|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);for(let t=0,i=this.space,n=this.bb.bytes();t=0;i--)t.addOffset(e[i]);return t.endVector()}static startChildrenVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(6,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endField(t){return t.endObject()}}class On{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSchema(t,e){return(e||new On).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,e){return t.setPosition(t.position()+4),(e||new On).__init(t.readInt32(t.position())+t.position(),t)}endianness(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Tn.Little}fields(t,e){const i=this.bb.__offset(this.bb_pos,6);return i?(e||new Fn).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*t),this.bb):null}fieldsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const i=this.bb.__offset(this.bb_pos,8);return i?(e||new Ln).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*t),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}featuresLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSchema(t){t.startObject(4)}static addEndianness(t,e){t.addFieldInt16(0,e,Tn.Little)}static addFields(t,e){t.addFieldOffset(1,e,0)}static createFieldsVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startFieldsVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(2,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static addFeatures(t,e){t.addFieldOffset(3,e,0)}static createFeaturesVector(t,e){t.startVector(8,e.length,8);for(let i=e.length-1;i>=0;i--)t.addInt64(e[i]);return t.endVector()}static startFeaturesVector(t,e){t.startVector(8,e,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,e){t.finish(e)}static finishSizePrefixedSchemaBuffer(t,e){t.finish(e,void 0,!0)}static createSchema(t,e,i,n,r){return On.startSchema(t),On.addEndianness(t,e),On.addFields(t,i),On.addCustomMetadata(t,n),On.addFeatures(t,r),On.endSchema(t)}}class Dn{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFooter(t,e){return(e||new Dn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+4),(e||new Dn).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):An.V1}schema(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new On).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dictionaries(t,e){const i=this.bb.__offset(this.bb_pos,8);return i?(e||new vn).__init(this.bb.__vector(this.bb_pos+i)+24*t,this.bb):null}dictionariesLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,e){const i=this.bb.__offset(this.bb_pos,10);return i?(e||new vn).__init(this.bb.__vector(this.bb_pos+i)+24*t,this.bb):null}recordBatchesLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){const i=this.bb.__offset(this.bb_pos,12);return i?(e||new Ln).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*t),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFooter(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,An.V1)}static addSchema(t,e){t.addFieldOffset(1,e,0)}static addDictionaries(t,e){t.addFieldOffset(2,e,0)}static startDictionariesVector(t,e){t.startVector(24,e,8)}static addRecordBatches(t,e){t.addFieldOffset(3,e,0)}static startRecordBatchesVector(t,e){t.startVector(24,e,8)}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,e){t.finish(e)}static finishSizePrefixedFooterBuffer(t,e){t.finish(e,void 0,!0)}}var Pn=Sn,zn=Rn,Un=Mn;class Vn{constructor(t,i=e.V4,n,r){this.schema=t,this.version=i,n&&(this._recordBatches=n),r&&(this._dictionaryBatches=r)}static decode(t){t=new Un(Y(t));const e=Dn.getRootAsFooter(t),i=Gi.decode(e.schema());return new Hn(i,e)}static encode(t){const i=new zn,n=Gi.encode(i,t.schema);Dn.startRecordBatchesVector(i,t.numRecordBatches);for(const e of[...t.recordBatches()].slice().reverse())jn.encode(i,e);const r=i.endVector();Dn.startDictionariesVector(i,t.numDictionaries);for(const e of[...t.dictionaryBatches()].slice().reverse())jn.encode(i,e);const s=i.endVector();return Dn.startFooter(i),Dn.addSchema(i,n),Dn.addVersion(i,e.V4),Dn.addRecordBatches(i,r),Dn.addDictionaries(i,s),Dn.finishFooterBuffer(i,Dn.endFooter(i)),i.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}*recordBatches(){for(let t,e=-1,i=this.numRecordBatches;++e=0&&t=0&&t=0&&t=0&&tqn(function*(t){let e,i,n,r,s=!1,o=[],a=0;({cmd:n,size:r}=yield null);const l=(h=t,function*(t,e){const i=function*(t){yield t},n="string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof $?i(e):S(e)?e:i(e);return yield*Q(function*(e){let i=null;do{i=e.next(yield G(t,i))}while(!i.done)}(n[Symbol.iterator]())),new t}(Uint8Array,h))[Symbol.iterator]();var h;try{do{if(({done:e,value:i}=Number.isNaN(r-a)?l.next():l.next(r-a)),!e&&i.byteLength>0&&(o.push(i),a+=i.byteLength),e||r<=a)do{({cmd:n,size:r}=yield"peek"===n?W(o,r)[0]:([i,o,a]=W(o,r),i))}while(rqn(function(t){return D(this,arguments,(function*(){let e,i,n,r,s=!1,o=[],a=0;({cmd:n,size:r}=yield yield O(null));const l=(h=t,X(Uint8Array,h))[Symbol.asyncIterator]();var h;try{do{if(({done:e,value:i}=Number.isNaN(r-a)?yield O(l.next()):yield O(l.next(r-a))),!e&&i.byteLength>0&&(o.push(i),a+=i.byteLength),e||r<=a)do{({cmd:n,size:r}=yield yield O("peek"===n?W(o,r)[0]:([i,o,a]=W(o,r),i)))}while(rqn(function(t){return D(this,arguments,(function*(){let e,i,n,r=!1,s=!1,o=[],a=0;({cmd:i,size:n}=yield yield O(null));const l=new Wn(t);try{do{if(({done:r,value:e}=Number.isNaN(n-a)?yield O(l.read()):yield O(l.read(n-a))),!r&&e.byteLength>0&&(o.push(Y(e)),a+=e.byteLength),r||n<=a)do{({cmd:i,size:n}=yield yield O("peek"===i?W(o,n)[0]:([e,o,a]=W(o,n),e)))}while(nqn(function(t){return D(this,arguments,(function*(){const e=[];let i,n,r,s="error",o=!1,a=null,l=0,h=[];if(({cmd:i,size:n}=yield yield O(null)),t.isTTY)return yield yield O(new Uint8Array(0)),yield O(null);try{e[0]=Gn(t,"end"),e[1]=Gn(t,"error");do{if(e[2]=Gn(t,"readable"),[s,a]=yield O(Promise.race(e.map((t=>t[2])))),"error"===s)break;if((o="end"===s)||(Number.isFinite(n-l)?(r=Y(t.read(n-l)),r.byteLength0&&(h.push(r),l+=r.byteLength)),o||n<=l)do{({cmd:i,size:n}=yield yield O("peek"===i?W(h,n)[0]:([r,h,l]=W(h,n),r)))}while(n{for(const[i,n]of e)t.off(i,n);try{const e=t.destroy;e&&e.call(t,i),i=void 0}catch(t){i=t||i}finally{null!=i?r(i):n()}}))}(e,"error"===s?a:null))}return yield O(null)}))}(t)),toDOMStream(t,e){throw new Error('"toDOMStream" not available in this environment')},toNodeStream(t,e){throw new Error('"toNodeStream" not available in this environment')}},qn=t=>(t.next(),t);class Wn{constructor(t){this.source=t,this.reader=null,this.reader=this.source.getReader(),this.reader.closed.catch((()=>{}))}get closed(){return this.reader?this.reader.closed.catch((()=>{})):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return F(this,void 0,void 0,(function*(){const{reader:e,source:i}=this;e&&(yield e.cancel(t).catch((()=>{}))),i&&i.locked&&this.releaseLock()}))}read(t){return F(this,void 0,void 0,(function*(){if(0===t)return{done:null==this.reader,value:new Uint8Array(0)};const e=yield this.reader.read();return!e.done&&(e.value=Y(e)),e}))}}const Gn=(t,e)=>{const i=t=>n([e,t]);let n;return[e,i,new Promise((r=>(n=r)&&t.once(e,i)))]},Zn=Object.freeze({done:!0,value:void 0});class Yn{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}}class Qn{tee(){return this._getDOMStream().tee()}pipe(t,e){return this._getNodeStream().pipe(t,e)}pipeTo(t,e){return this._getDOMStream().pipeTo(t,e)}pipeThrough(t,e){return this._getDOMStream().pipeThrough(t,e)}_getDOMStream(){return this._DOMStream||(this._DOMStream=this.toDOMStream())}_getNodeStream(){return this._nodeStream||(this._nodeStream=this.toNodeStream())}}class Xn extends Qn{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise((t=>this._closedPromiseResolve=t))}get closed(){return this._closedPromise}cancel(t){return F(this,void 0,void 0,(function*(){yield this.return(t)}))}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){const{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(Zn);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return $n.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return $n.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return F(this,void 0,void 0,(function*(){return yield this.abort(t),Zn}))}return(t){return F(this,void 0,void 0,(function*(){return yield this.close(),Zn}))}read(t){return F(this,void 0,void 0,(function*(){return(yield this.next(t,"read")).value}))}peek(t){return F(this,void 0,void 0,(function*(){return(yield this.next(t,"peek")).value}))}next(...t){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise(((t,e)=>{this.resolvers.push({resolve:t,reject:e})})):Promise.resolve(Zn)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class Kn extends Xn{write(t){if((t=Y(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?V(this.toUint8Array(!0)):this.toUint8Array(!1).then(V)}toUint8Array(t=!1){return t?W(this._values)[0]:(()=>F(this,void 0,void 0,(function*(){var t,e;const i=[];let n=0;try{for(var r,s=z(this);!(r=yield s.next()).done;){const t=r.value;i.push(t),n+=t.byteLength}}catch(e){t={error:e}}finally{try{r&&!r.done&&(e=s.return)&&(yield e.call(s))}finally{if(t)throw t.error}}return W(i,n)[0]})))()}}class Jn{constructor(t){t&&(this.source=new er($n.fromIterable(t)))}[Symbol.iterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class tr{constructor(t){t instanceof tr?this.source=t.source:t instanceof Kn?this.source=new ir($n.fromAsyncIterable(t)):L(t)?this.source=new ir($n.fromNodeStream(t)):R(t)?this.source=new ir($n.fromDOMStream(t)):E(t)?this.source=new ir($n.fromDOMStream(t.body)):S(t)?this.source=new ir($n.fromIterable(t)):(k(t)||C(t))&&(this.source=new ir($n.fromAsyncIterable(t)))}[Symbol.asyncIterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}get closed(){return this.source.closed}cancel(t){return this.source.cancel(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class er{constructor(t){this.source=t}cancel(t){this.return(t)}peek(t){return this.next(t,"peek").value}read(t){return this.next(t,"read").value}next(t,e="read"){return this.source.next({cmd:e,size:t})}throw(t){return Object.create(this.source.throw&&this.source.throw(t)||Zn)}return(t){return Object.create(this.source.return&&this.source.return(t)||Zn)}}class ir{constructor(t){this.source=t,this._closedPromise=new Promise((t=>this._closedPromiseResolve=t))}cancel(t){return F(this,void 0,void 0,(function*(){yield this.return(t)}))}get closed(){return this._closedPromise}read(t){return F(this,void 0,void 0,(function*(){return(yield this.next(t,"read")).value}))}peek(t){return F(this,void 0,void 0,(function*(){return(yield this.next(t,"peek")).value}))}next(t,e="read"){return F(this,void 0,void 0,(function*(){return yield this.source.next({cmd:e,size:t})}))}throw(t){return F(this,void 0,void 0,(function*(){const e=this.source.throw&&(yield this.source.throw(t))||Zn;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)}))}return(t){return F(this,void 0,void 0,(function*(){const e=this.source.return&&(yield this.source.return(t))||Zn;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)}))}}class nr extends Jn{constructor(t,e){super(),this.position=0,this.buffer=Y(t),this.size=void 0===e?this.buffer.byteLength:e}readInt32(t){const{buffer:e,byteOffset:i}=this.readAt(t,4);return new DataView(e,i).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),tF(this,void 0,void 0,(function*(){this.size=(yield t.stat()).size,delete this._pending})))()}readInt32(t){return F(this,void 0,void 0,(function*(){const{buffer:e,byteOffset:i}=yield this.readAt(t,4);return new DataView(e,i).getInt32(0,!0)}))}seek(t){return F(this,void 0,void 0,(function*(){return this._pending&&(yield this._pending),this.position=Math.min(t,this.size),t>>16,65535&this.buffer[1],this.buffer[0]>>>16,65535&this.buffer[0]]),i=new Uint32Array([t.buffer[1]>>>16,65535&t.buffer[1],t.buffer[0]>>>16,65535&t.buffer[0]]);let n=e[3]*i[3];this.buffer[0]=65535&n;let r=n>>>16;return n=e[2]*i[3],r+=n,n=e[3]*i[2]>>>0,r+=n,this.buffer[0]+=r<<16,this.buffer[1]=r>>>0>>16,this.buffer[1]+=e[1]*i[3]+e[2]*i[2]+e[3]*i[1],this.buffer[1]+=e[0]*i[3]+e[1]*i[2]+e[2]*i[1]+e[3]*i[0]<<16,this}_plus(t){const e=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],e>>0&&++this.buffer[1],this.buffer[0]=e}lessThan(t){return this.buffer[1]>>0,e[2]=this.buffer[2]+t.buffer[2]>>>0,e[1]=this.buffer[1]+t.buffer[1]>>>0,e[0]=this.buffer[0]+t.buffer[0]>>>0,e[0]>>0&&++e[1],e[1]>>0&&++e[2],e[2]>>0&&++e[3],this.buffer[3]=e[3],this.buffer[2]=e[2],this.buffer[1]=e[1],this.buffer[0]=e[0],this}hex(){return`${sr(this.buffer[3])} ${sr(this.buffer[2])} ${sr(this.buffer[1])} ${sr(this.buffer[0])}`}static multiply(t,e){return new cr(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new cr(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return cr.fromString("string"==typeof t?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return cr.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){const i=t.startsWith("-"),n=t.length,r=new cr(e);for(let e=i?1:0;e0&&this.readData(t,i)||new Uint8Array(0)}readOffsets(t,e){return this.readData(t,e)}readTypeIds(t,e){return this.readData(t,e)}readData(t,{length:e,offset:i}=this.nextBufferRange()){return this.bytes.subarray(i,i+e)}readDictionary(t){return this.dictionaries.get(t.id)}}class dr extends ur{constructor(t,e,i,n){super(new Uint8Array(0),e,i,n),this.sources=t}readNullBitmap(t,e,{offset:i}=this.nextBufferRange()){return e<=0?new Uint8Array(0):xi(this.sources[i])}readOffsets(t,{offset:e}=this.nextBufferRange()){return G(Uint8Array,G(Int32Array,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return G(Uint8Array,G(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){const{sources:i}=this;return Et.isTimestamp(t)||(Et.isInt(t)||Et.isTime(t))&&64===t.bitWidth||Et.isDate(t)&&t.unit===s.MILLISECOND?G(Uint8Array,hr.convertArray(i[e])):Et.isDecimal(t)?G(Uint8Array,cr.convertArray(i[e])):Et.isBinary(t)||Et.isFixedSizeBinary(t)?function(t){const e=t.join(""),i=new Uint8Array(e.length/2);for(let t=0;t>1]=Number.parseInt(e.slice(t,t+2),16);return i}(i[e]):Et.isBool(t)?xi(i[e]):Et.isUtf8(t)?j(i[e].join("")):G(Uint8Array,G(t.ArrayType,i[e].map((t=>+t))))}}var fr,pr,gr,mr,br,yr,vr,wr;!function(t){t[t.BUFFER=0]="BUFFER"}(fr||(fr={})),function(t){t[t.LZ4_FRAME=0]="LZ4_FRAME",t[t.ZSTD=1]="ZSTD"}(pr||(pr={}));class _r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBodyCompression(t,e){return(e||new _r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+4),(e||new _r).__init(t.readInt32(t.position())+t.position(),t)}codec(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):pr.LZ4_FRAME}method(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):fr.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,pr.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,fr.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,i){return _r.startBodyCompression(t),_r.addCodec(t,e),_r.addMethod(t,i),_r.endBodyCompression(t)}}class xr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,e,i){return t.prep(8,16),t.writeInt64(i),t.writeInt64(e),t.offset()}}class kr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(t,e,i){return t.prep(8,16),t.writeInt64(i),t.writeInt64(e),t.offset()}}class Sr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsRecordBatch(t,e){return(e||new Sr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,e){return t.setPosition(t.position()+4),(e||new Sr).__init(t.readInt32(t.position())+t.position(),t)}length(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}nodes(t,e){const i=this.bb.__offset(this.bb_pos,6);return i?(e||new kr).__init(this.bb.__vector(this.bb_pos+i)+16*t,this.bb):null}nodesLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,e){const i=this.bb.__offset(this.bb_pos,8);return i?(e||new xr).__init(this.bb.__vector(this.bb_pos+i)+16*t,this.bb):null}buffersLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){const e=this.bb.__offset(this.bb_pos,10);return e?(t||new _r).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startRecordBatch(t){t.startObject(4)}static addLength(t,e){t.addFieldInt64(0,e,t.createLong(0,0))}static addNodes(t,e){t.addFieldOffset(1,e,0)}static startNodesVector(t,e){t.startVector(16,e,8)}static addBuffers(t,e){t.addFieldOffset(2,e,0)}static startBuffersVector(t,e){t.startVector(16,e,8)}static addCompression(t,e){t.addFieldOffset(3,e,0)}static endRecordBatch(t){return t.endObject()}}class Cr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryBatch(t,e){return(e||new Cr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,e){return t.setPosition(t.position()+4),(e||new Cr).__init(t.readInt32(t.position())+t.position(),t)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}data(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new Sr).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isDelta(){const t=this.bb.__offset(this.bb_pos,8);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}static startDictionaryBatch(t){t.startObject(3)}static addId(t,e){t.addFieldInt64(0,e,t.createLong(0,0))}static addData(t,e){t.addFieldOffset(1,e,0)}static addIsDelta(t,e){t.addFieldInt8(2,+e,0)}static endDictionaryBatch(t){return t.endObject()}}!function(t){t[t.HALF=0]="HALF",t[t.SINGLE=1]="SINGLE",t[t.DOUBLE=2]="DOUBLE"}(gr||(gr={}));class Ar{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFloatingPoint(t,e){return(e||new Ar).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,e){return t.setPosition(t.position()+4),(e||new Ar).__init(t.readInt32(t.position())+t.position(),t)}precision(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):gr.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,e){t.addFieldInt16(0,e,gr.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,e){return Ar.startFloatingPoint(t),Ar.addPrecision(t,e),Ar.endFloatingPoint(t)}}class Tr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDecimal(t,e){return(e||new Tr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,e){return t.setPosition(t.position()+4),(e||new Tr).__init(t.readInt32(t.position())+t.position(),t)}precision(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}scale(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}bitWidth(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):128}static startDecimal(t){t.startObject(3)}static addPrecision(t,e){t.addFieldInt32(0,e,0)}static addScale(t,e){t.addFieldInt32(1,e,0)}static addBitWidth(t,e){t.addFieldInt32(2,e,128)}static endDecimal(t){return t.endObject()}static createDecimal(t,e,i,n){return Tr.startDecimal(t),Tr.addPrecision(t,e),Tr.addScale(t,i),Tr.addBitWidth(t,n),Tr.endDecimal(t)}}!function(t){t[t.DAY=0]="DAY",t[t.MILLISECOND=1]="MILLISECOND"}(mr||(mr={}));class Ir{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDate(t,e){return(e||new Ir).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,e){return t.setPosition(t.position()+4),(e||new Ir).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):mr.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,mr.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,e){return Ir.startDate(t),Ir.addUnit(t,e),Ir.endDate(t)}}!function(t){t[t.SECOND=0]="SECOND",t[t.MILLISECOND=1]="MILLISECOND",t[t.MICROSECOND=2]="MICROSECOND",t[t.NANOSECOND=3]="NANOSECOND"}(br||(br={}));class Er{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTime(t,e){return(e||new Er).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,e){return t.setPosition(t.position()+4),(e||new Er).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):br.MILLISECOND}bitWidth(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):32}static startTime(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,br.MILLISECOND)}static addBitWidth(t,e){t.addFieldInt32(1,e,32)}static endTime(t){return t.endObject()}static createTime(t,e,i){return Er.startTime(t),Er.addUnit(t,e),Er.addBitWidth(t,i),Er.endTime(t)}}class Mr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTimestamp(t,e){return(e||new Mr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,e){return t.setPosition(t.position()+4),(e||new Mr).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):br.SECOND}timezone(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startTimestamp(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,br.SECOND)}static addTimezone(t,e){t.addFieldOffset(1,e,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,e,i){return Mr.startTimestamp(t),Mr.addUnit(t,e),Mr.addTimezone(t,i),Mr.endTimestamp(t)}}!function(t){t[t.YEAR_MONTH=0]="YEAR_MONTH",t[t.DAY_TIME=1]="DAY_TIME",t[t.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"}(yr||(yr={}));class Rr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInterval(t,e){return(e||new Rr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,e){return t.setPosition(t.position()+4),(e||new Rr).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):yr.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,yr.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,e){return Rr.startInterval(t),Rr.addUnit(t,e),Rr.endInterval(t)}}!function(t){t[t.Sparse=0]="Sparse",t[t.Dense=1]="Dense"}(vr||(vr={}));class Lr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUnion(t,e){return(e||new Lr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,e){return t.setPosition(t.position()+4),(e||new Lr).__init(t.readInt32(t.position())+t.position(),t)}mode(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):vr.Sparse}typeIds(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt32(this.bb.__vector(this.bb_pos+e)+4*t):0}typeIdsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}typeIdsArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startUnion(t){t.startObject(2)}static addMode(t,e){t.addFieldInt16(0,e,vr.Sparse)}static addTypeIds(t,e){t.addFieldOffset(1,e,0)}static createTypeIdsVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addInt32(e[i]);return t.endVector()}static startTypeIdsVector(t,e){t.startVector(4,e,4)}static endUnion(t){return t.endObject()}static createUnion(t,e,i){return Lr.startUnion(t),Lr.addMode(t,e),Lr.addTypeIds(t,i),Lr.endUnion(t)}}class Br{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFixedSizeBinary(t,e){return(e||new Br).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,e){return t.setPosition(t.position()+4),(e||new Br).__init(t.readInt32(t.position())+t.position(),t)}byteWidth(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeBinary(t){t.startObject(1)}static addByteWidth(t,e){t.addFieldInt32(0,e,0)}static endFixedSizeBinary(t){return t.endObject()}static createFixedSizeBinary(t,e){return Br.startFixedSizeBinary(t),Br.addByteWidth(t,e),Br.endFixedSizeBinary(t)}}class Nr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFixedSizeList(t,e){return(e||new Nr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,e){return t.setPosition(t.position()+4),(e||new Nr).__init(t.readInt32(t.position())+t.position(),t)}listSize(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeList(t){t.startObject(1)}static addListSize(t,e){t.addFieldInt32(0,e,0)}static endFixedSizeList(t){return t.endObject()}static createFixedSizeList(t,e){return Nr.startFixedSizeList(t),Nr.addListSize(t,e),Nr.endFixedSizeList(t)}}class Fr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMap(t,e){return(e||new Fr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,e){return t.setPosition(t.position()+4),(e||new Fr).__init(t.readInt32(t.position())+t.position(),t)}keysSorted(){const t=this.bb.__offset(this.bb_pos,4);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}static startMap(t){t.startObject(1)}static addKeysSorted(t,e){t.addFieldInt8(0,+e,0)}static endMap(t){return t.endObject()}static createMap(t,e){return Fr.startMap(t),Fr.addKeysSorted(t,e),Fr.endMap(t)}}!function(t){t[t.NONE=0]="NONE",t[t.Schema=1]="Schema",t[t.DictionaryBatch=2]="DictionaryBatch",t[t.RecordBatch=3]="RecordBatch",t[t.Tensor=4]="Tensor",t[t.SparseTensor=5]="SparseTensor"}(wr||(wr={}));class Or{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(t,e){return(e||new Or).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+4),(e||new Or).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):An.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):wr.NONE}header(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):this.bb.createLong(0,0)}customMetadata(t,e){const i=this.bb.__offset(this.bb_pos,12);return i?(e||new Ln).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*t),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,An.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,wr.NONE)}static addHeader(t,e){t.addFieldOffset(2,e,0)}static addBodyLength(t,e){t.addFieldInt64(3,e,t.createLong(0,0))}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,e){t.finish(e)}static finishSizePrefixedMessageBuffer(t,e){t.finish(e,void 0,!0)}static createMessage(t,e,i,n,r,s){return Or.startMessage(t),Or.addVersion(t,e),Or.addHeaderType(t,i),Or.addHeader(t,n),Or.addBodyLength(t,r),Or.addCustomMetadata(t,s),Or.endMessage(t)}}class Dr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsNull(t,e){return(e||new Dr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,e){return t.setPosition(t.position()+4),(e||new Dr).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return Dr.startNull(t),Dr.endNull(t)}}class Pr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBinary(t,e){return(e||new Pr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,e){return t.setPosition(t.position()+4),(e||new Pr).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return Pr.startBinary(t),Pr.endBinary(t)}}class zr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBool(t,e){return(e||new zr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,e){return t.setPosition(t.position()+4),(e||new zr).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return zr.startBool(t),zr.endBool(t)}}class Ur{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUtf8(t,e){return(e||new Ur).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+4),(e||new Ur).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return Ur.startUtf8(t),Ur.endUtf8(t)}}class Vr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsList(t,e){return(e||new Vr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,e){return t.setPosition(t.position()+4),(e||new Vr).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return Vr.startList(t),Vr.endList(t)}}class Hr{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsStruct_(t,e){return(e||new Hr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,e){return t.setPosition(t.position()+4),(e||new Hr).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return Hr.startStruct_(t),Hr.endStruct_(t)}}var jr=Sn;const $r=new class extends Kt{visit(t,e){return null==t||null==e?void 0:super.visit(t,e)}visitNull(t,e){return Dr.startNull(e),Dr.endNull(e)}visitInt(t,e){return Bn.startInt(e),Bn.addBitWidth(e,t.bitWidth),Bn.addIsSigned(e,t.isSigned),Bn.endInt(e)}visitFloat(t,e){return Ar.startFloatingPoint(e),Ar.addPrecision(e,t.precision),Ar.endFloatingPoint(e)}visitBinary(t,e){return Pr.startBinary(e),Pr.endBinary(e)}visitBool(t,e){return zr.startBool(e),zr.endBool(e)}visitUtf8(t,e){return Ur.startUtf8(e),Ur.endUtf8(e)}visitDecimal(t,e){return Tr.startDecimal(e),Tr.addScale(e,t.scale),Tr.addPrecision(e,t.precision),Tr.addBitWidth(e,t.bitWidth),Tr.endDecimal(e)}visitDate(t,e){return Ir.startDate(e),Ir.addUnit(e,t.unit),Ir.endDate(e)}visitTime(t,e){return Er.startTime(e),Er.addUnit(e,t.unit),Er.addBitWidth(e,t.bitWidth),Er.endTime(e)}visitTimestamp(t,e){const i=t.timezone&&e.createString(t.timezone)||void 0;return Mr.startTimestamp(e),Mr.addUnit(e,t.unit),void 0!==i&&Mr.addTimezone(e,i),Mr.endTimestamp(e)}visitInterval(t,e){return Rr.startInterval(e),Rr.addUnit(e,t.unit),Rr.endInterval(e)}visitList(t,e){return Vr.startList(e),Vr.endList(e)}visitStruct(t,e){return Hr.startStruct_(e),Hr.endStruct_(e)}visitUnion(t,e){Lr.startTypeIdsVector(e,t.typeIds.length);const i=Lr.createTypeIdsVector(e,t.typeIds);return Lr.startUnion(e),Lr.addMode(e,t.mode),Lr.addTypeIds(e,i),Lr.endUnion(e)}visitDictionary(t,e){const i=this.visit(t.indices,e);return Nn.startDictionaryEncoding(e),Nn.addId(e,new jr(t.id,0)),Nn.addIsOrdered(e,t.isOrdered),void 0!==i&&Nn.addIndexType(e,i),Nn.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return Br.startFixedSizeBinary(e),Br.addByteWidth(e,t.byteWidth),Br.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return Nr.startFixedSizeList(e),Nr.addListSize(e,t.listSize),Nr.endFixedSizeList(e)}visitMap(t,e){return Fr.startMap(e),Fr.addKeysSorted(e,t.keysSorted),Fr.endMap(e)}};function qr(t){return new is(t.count,Gr(t.columns),Zr(t.columns))}function Wr(t,e){return(t.children||[]).filter(Boolean).map((t=>Zi.fromJSON(t,e)))}function Gr(t){return(t||[]).reduce(((t,e)=>{return[...t,new ss(e.count,(i=e.VALIDITY,(i||[]).reduce(((t,e)=>t+ +(0===e)),0))),...Gr(e.children)];var i}),[])}function Zr(t,e=[]){for(let i=-1,n=(t||[]).length;++in),this._bodyLength="number"==typeof t?t:t.low}static fromJSON(t,i){const n=new es(0,e.V4,i);return n._createHeader=function(t,e){return()=>{switch(e){case l.Schema:return Gi.fromJSON(t);case l.RecordBatch:return is.fromJSON(t);case l.DictionaryBatch:return ns.fromJSON(t)}throw new Error(`Unrecognized Message type: { name: ${l[e]}, type: ${e} }`)}}(t,i),n}static decode(t){t=new ts(Y(t));const e=Or.getRootAsMessage(t),i=e.bodyLength(),n=e.version(),r=e.headerType(),s=new es(i,n,r);return s._createHeader=function(t,e){return()=>{switch(e){case l.Schema:return Gi.decode(t.header(new On));case l.RecordBatch:return is.decode(t.header(new Sr),t.version());case l.DictionaryBatch:return ns.decode(t.header(new Cr),t.version())}throw new Error(`Unrecognized Message type: { name: ${l[e]}, type: ${e} }`)}}(e,r),s}static encode(t){const i=new Jr;let n=-1;return t.isSchema()?n=Gi.encode(i,t.header()):t.isRecordBatch()?n=is.encode(i,t.header()):t.isDictionaryBatch()&&(n=ns.encode(i,t.header())),Or.startMessage(i),Or.addVersion(i,e.V4),Or.addHeader(i,n),Or.addHeaderType(i,t.headerType),Or.addBodyLength(i,new Kr(t.bodyLength,0)),Or.finishMessageBuffer(i,Or.endMessage(i)),i.asUint8Array()}static from(t,i=0){if(t instanceof Gi)return new es(0,e.V4,l.Schema,t);if(t instanceof is)return new es(i,e.V4,l.RecordBatch,t);if(t instanceof ns)return new es(i,e.V4,l.DictionaryBatch,t);throw new Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===l.Schema}isRecordBatch(){return this.headerType===l.RecordBatch}isDictionaryBatch(){return this.headerType===l.DictionaryBatch}}class is{constructor(t,e,i){this._nodes=e,this._buffers=i,this._length="number"==typeof t?t:t.low}get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}}class ns{constructor(t,e,i=!1){this._data=t,this._isDelta=i,this._id="number"==typeof e?e:e.low}get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}}class rs{constructor(t,e){this.offset="number"==typeof t?t:t.low,this.length="number"==typeof e?e:e.low}}class ss{constructor(t,e){this.length="number"==typeof t?t:t.low,this.nullCount="number"==typeof e?e:e.low}}function os(t,e){const i=[];for(let n,r=-1,s=-1,o=t.childrenLength();++rZi.encode(t,e))),l=Fn.createChildrenVector(t,a),h=e.metadata&&e.metadata.size>0?Fn.createCustomMetadataVector(t,[...e.metadata].map((([e,i])=>{const n=t.createString(`${e}`),r=t.createString(`${i}`);return Ln.startKeyValue(t),Ln.addKey(t,n),Ln.addValue(t,r),Ln.endKeyValue(t)}))):-1;return e.name&&(i=t.createString(e.name)),Fn.startField(t),Fn.addType(t,n),Fn.addTypeType(t,o),Fn.addChildren(t,l),Fn.addNullable(t,!!e.nullable),-1!==i&&Fn.addName(t,i),-1!==r&&Fn.addDictionary(t,r),-1!==h&&Fn.addCustomMetadata(t,h),Fn.endField(t)},Zi.decode=function(t,e){let i,n,r,s,o,a;return e&&(a=t.dictionary())?e.has(i=a.id().low)?(s=(s=a.indexType())?ls(s):new Lt,o=new Qt(e.get(i),s,i,a.isOrdered()),n=new Zi(t.name(),o,t.nullable(),as(t))):(s=(s=a.indexType())?ls(s):new Lt,e.set(i,r=hs(t,os(t,e))),o=new Qt(r,s,i,a.isOrdered()),n=new Zi(t.name(),o,t.nullable(),as(t))):(r=hs(t,os(t,e)),n=new Zi(t.name(),r,t.nullable(),as(t))),n||null},Zi.fromJSON=function(t,e){let i,n,r,s,o,a;return e&&(s=t.dictionary)?e.has(i=s.id)?(n=(n=s.indexType)?Qr(n):new Lt,a=new Qt(e.get(i),n,i,s.isOrdered),r=new Zi(t.name,a,t.nullable,Yr(t.customMetadata))):(n=(n=s.indexType)?Qr(n):new Lt,e.set(i,o=Xr(t,Wr(t,e))),a=new Qt(o,n,i,s.isOrdered),r=new Zi(t.name,a,t.nullable,Yr(t.customMetadata))):(o=Xr(t,Wr(t,e)),r=new Zi(t.name,o,t.nullable,Yr(t.customMetadata))),r||null},Gi.encode=function(t,e){const i=e.fields.map((e=>Zi.encode(t,e)));On.startFieldsVector(t,i.length);const n=On.createFieldsVector(t,i),r=e.metadata&&e.metadata.size>0?On.createCustomMetadataVector(t,[...e.metadata].map((([e,i])=>{const n=t.createString(`${e}`),r=t.createString(`${i}`);return Ln.startKeyValue(t),Ln.addKey(t,n),Ln.addValue(t,r),Ln.endKeyValue(t)}))):-1;return On.startSchema(t),On.addFields(t,n),On.addEndianness(t,cs?Tn.Little:Tn.Big),-1!==r&&On.addCustomMetadata(t,r),On.endSchema(t)},Gi.decode=function(t,e=new Map){const i=function(t,e){const i=[];for(let n,r=-1,s=-1,o=t.fieldsLength();++rZi.fromJSON(t,e)))}(t,e),Yr(t.customMetadata),e)},is.encode=function(t,e){const i=e.nodes||[],n=e.buffers||[];Sr.startNodesVector(t,i.length);for(const e of i.slice().reverse())ss.encode(t,e);const r=t.endVector();Sr.startBuffersVector(t,n.length);for(const e of n.slice().reverse())rs.encode(t,e);const s=t.endVector();return Sr.startRecordBatch(t),Sr.addLength(t,new Kr(e.length,0)),Sr.addNodes(t,r),Sr.addBuffers(t,s),Sr.endRecordBatch(t)},is.decode=function(t,i=e.V4){if(null!==t.compression())throw new Error("Record batch compression not implemented");return new is(t.length(),function(t){const e=[];for(let i,n=-1,r=-1,s=t.nodesLength();++n{const t=new ArrayBuffer(2);return new DataView(t).setInt16(0,256,!0),256===new Int16Array(t)[0]})(),us=t=>`Expected ${l[t]} Message in stream, but was null or length 0.`,ds=t=>`Header pointer of flatbuffer-encoded ${l[t]} Message is null or length 0.`,fs=(t,e)=>`Expected to read ${t} metadata bytes, but only read ${e}.`,ps=(t,e)=>`Expected to read ${t} bytes for message body, but only read ${e}.`;class gs{constructor(t){this.source=t instanceof Jn?t:new Jn(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done||-1===t.value&&(t=this.readMetadataLength()).done||(t=this.readMetadata(t.value)).done?Zn:t}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}readMessage(t){let e;if((e=this.next()).done)return null;if(null!=t&&e.value.headerType!==t)throw new Error(us(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);const e=Y(this.source.read(t));if(e.byteLength[...e,...i.VALIDITY&&[i.VALIDITY]||[],...i.TYPE&&[i.TYPE]||[],...i.OFFSET&&[i.OFFSET]||[],...i.DATA&&[i.DATA]||[],...t(i.children)]),[])}(this._body)}readMessage(t){let e;if((e=this.next()).done)return null;if(null!=t&&e.value.headerType!==t)throw new Error(us(t));return e.value}readSchema(){const t=l.Schema,e=this.readMessage(t),i=null==e?void 0:e.header();if(!e||!i)throw new Error(ds(t));return i}}const ys=4,vs=new Uint8Array(6);for(let t=0;t<6;t+=1)vs[t]="ARROW1".codePointAt(t);function ws(t,e=0){for(let i=-1,n=vs.length;++ithis)):this}readRecordBatch(t){return this._impl.isFile()?this._impl.readRecordBatch(t):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return $n.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return $n.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof Ss?t:A(t)?function(t){return new Cs(new Ns(t))}(t):I(t)?function(t){return F(this,void 0,void 0,(function*(){const{size:e}=yield t.stat(),i=new rr(t,e);return e>=ks&&ws(yield i.readAt(0,_s+7&-8))?new Is(new Bs(i)):new As(new Rs(i))}))}(t):k(t)?(()=>F(this,void 0,void 0,(function*(){return yield Ss.from(yield t)})))():E(t)||R(t)||L(t)||C(t)?function(t){return F(this,void 0,void 0,(function*(){const e=yield t.peek(_s+7&-8);return e&&e.byteLength>=4?ws(e)?new Ts(new Ls(yield t.read())):new As(new Rs(t)):new As(new Rs(function(){return D(this,arguments,(function*(){}))}()))}))}(new tr(t)):function(t){const e=t.peek(_s+7&-8);return e&&e.byteLength>=4?ws(e)?new Ts(new Ls(t.read())):new Cs(new Ms(t)):new Cs(new Ms(function*(){}()))}(new Jn(t))}static readAll(t){return t instanceof Ss?t.isSync()?Os(t):Ds(t):A(t)||ArrayBuffer.isView(t)||S(t)||T(t)?Os(t):Ds(t)}}class Cs extends Ss{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return D(this,arguments,(function*(){yield O(yield*P(z(this[Symbol.iterator]())))}))}}class As extends Ss{constructor(t){super(t),this._impl=t}readAll(){var t,e;return F(this,void 0,void 0,(function*(){const i=new Array;try{for(var n,r=z(this);!(n=yield r.next()).done;){const t=n.value;i.push(t)}}catch(e){t={error:e}}finally{try{n&&!n.done&&(e=r.return)&&(yield e.call(r))}finally{if(t)throw t.error}}return i}))}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class Ts extends Cs{constructor(t){super(t),this._impl=t}}class Is extends As{constructor(t){super(t),this._impl=t}}class Es{constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,e){const i=this._loadVectors(t,e,this.schema.fields),n=Wi({type:new jt(this.schema.fields),length:t.length,children:i});return new dn(this.schema,n)}_loadDictionaryBatch(t,e){const{id:i,isDelta:n}=t,{dictionaries:r,schema:s}=this,o=r.get(i);if(n||!o){const r=s.dictionaries.get(i),a=this._loadVectors(t.data,e,[r]);return(o&&n?o.concat(new Hi(a)):new Hi(a)).memoize()}return o.memoize()}_loadVectors(t,e,i){return new ur(e,t.nodes,t.buffers,this.dictionaries).visitMany(i)}}class Ms extends Es{constructor(t,e){super(e),this._reader=A(t)?new bs(this._handle=t):new gs(this._handle=t)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(t){return this.closed||(this.autoDestroy=Fs(this,t),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(t):Zn}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):Zn}next(){if(this.closed)return Zn;let t;const{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else{if(t.isRecordBatch()){this._recordBatchIndex++;const i=t.header(),n=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(i,n)}}if(t.isDictionaryBatch()){this._dictionaryIndex++;const i=t.header(),n=e.readMessageBody(t.bodyLength),r=this._loadDictionaryBatch(i,n);this.dictionaries.set(i.id,r)}}return this.schema&&0===this._recordBatchIndex?(this._recordBatchIndex++,{done:!1,value:new gn(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class Rs extends Es{constructor(t,e){super(e),this._reader=new ms(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return F(this,void 0,void 0,(function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}))}open(t){return F(this,void 0,void 0,(function*(){return this.closed||(this.autoDestroy=Fs(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this}))}throw(t){return F(this,void 0,void 0,(function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):Zn}))}return(t){return F(this,void 0,void 0,(function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):Zn}))}next(){return F(this,void 0,void 0,(function*(){if(this.closed)return Zn;let t;const{_reader:e}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else{if(t.isRecordBatch()){this._recordBatchIndex++;const i=t.header(),n=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(i,n)}}if(t.isDictionaryBatch()){this._dictionaryIndex++;const i=t.header(),n=yield e.readMessageBody(t.bodyLength),r=this._loadDictionaryBatch(i,n);this.dictionaries.set(i.id,r)}}return this.schema&&0===this._recordBatchIndex?(this._recordBatchIndex++,{done:!1,value:new gn(this.schema)}):yield this.return()}))}_readNextMessageAndValidate(t){return F(this,void 0,void 0,(function*(){return yield this._reader.readMessage(t)}))}}class Ls extends Ms{constructor(t,e){super(t instanceof nr?t:new nr(t),e)}get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const t of this._footer.dictionaryBatches())t&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();const i=null===(e=this._footer)||void 0===e?void 0:e.getRecordBatch(t);if(i&&this._handle.seek(i.offset)){const t=this._reader.readMessage(l.RecordBatch);if(null==t?void 0:t.isRecordBatch()){const e=t.header(),i=this._reader.readMessageBody(t.bodyLength);return this._loadRecordBatch(e,i)}}return null}_readDictionaryBatch(t){var e;const i=null===(e=this._footer)||void 0===e?void 0:e.getDictionaryBatch(t);if(i&&this._handle.seek(i.offset)){const t=this._reader.readMessage(l.DictionaryBatch);if(null==t?void 0:t.isDictionaryBatch()){const e=t.header(),i=this._reader.readMessageBody(t.bodyLength),n=this._loadDictionaryBatch(e,i);this.dictionaries.set(e.id,n)}}}_readFooter(){const{_handle:t}=this,e=t.size-xs,i=t.readInt32(e),n=t.readAt(e-i,i);return Vn.decode(n)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return F(this,void 0,void 0,(function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const t of this._footer.dictionaryBatches())t&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)}))}readRecordBatch(t){var e;return F(this,void 0,void 0,(function*(){if(this.closed)return null;this._footer||(yield this.open());const i=null===(e=this._footer)||void 0===e?void 0:e.getRecordBatch(t);if(i&&(yield this._handle.seek(i.offset))){const t=yield this._reader.readMessage(l.RecordBatch);if(null==t?void 0:t.isRecordBatch()){const e=t.header(),i=yield this._reader.readMessageBody(t.bodyLength);return this._loadRecordBatch(e,i)}}return null}))}_readDictionaryBatch(t){var e;return F(this,void 0,void 0,(function*(){const i=null===(e=this._footer)||void 0===e?void 0:e.getDictionaryBatch(t);if(i&&(yield this._handle.seek(i.offset))){const t=yield this._reader.readMessage(l.DictionaryBatch);if(null==t?void 0:t.isDictionaryBatch()){const e=t.header(),i=yield this._reader.readMessageBody(t.bodyLength),n=this._loadDictionaryBatch(e,i);this.dictionaries.set(e.id,n)}}}))}_readFooter(){return F(this,void 0,void 0,(function*(){const{_handle:t}=this;t._pending&&(yield t._pending);const e=t.size-xs,i=yield t.readInt32(e),n=yield t.readAt(e-i,i);return Vn.decode(n)}))}_readNextMessageAndValidate(t){return F(this,void 0,void 0,(function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndext.flatMap((t=>Array.isArray(t)?e(t):t instanceof dn?t.data.children:t.data)),i=new Ps;return i.visitMany(e(t)),i}visit(t){if(t instanceof Hi)return this.visitMany(t.data),this;const{type:e}=t;if(!Et.isDictionary(e)){const{length:i,nullCount:n}=t;if(i>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");Et.isNull(e)||zs.call(this,n<=0?new Uint8Array(0):_i(t.offset,i,t.nullBitmap)),this.nodes.push(new ss(i,n))}return super.visit(t)}visitNull(t){return this}visitDictionary(t){return this.visit(t.clone(t.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}}function zs(t){const e=t.byteLength+7&-8;return this.buffers.push(t),this.bufferRegions.push(new rs(this._byteLength,e)),this._byteLength+=e,this}function Us(t){return zs.call(this,t.values.subarray(0,t.length*t.stride))}function Vs(t){const{length:e,values:i,valueOffsets:n}=t,r=n[0],s=n[e],o=Math.min(s-r,i.byteLength-r);return zs.call(this,K(-n[0],e,n)),zs.call(this,i.subarray(r,r+o)),this}function Hs(t){const{length:e,valueOffsets:i}=t;return i&&zs.call(this,K(i[0],e,i)),this.visit(t.children[0])}function js(t){return this.visitMany(t.type.children.map(((e,i)=>t.children[i])).filter(Boolean))[0]}Ps.prototype.visitBool=function(t){let e;return t.nullCount>=t.length?zs.call(this,new Uint8Array(0)):(e=t.values)instanceof Uint8Array?zs.call(this,_i(t.offset,t.length,e)):zs.call(this,xi(t.values))},Ps.prototype.visitInt=Us,Ps.prototype.visitFloat=Us,Ps.prototype.visitUtf8=Vs,Ps.prototype.visitBinary=Vs,Ps.prototype.visitFixedSizeBinary=Us,Ps.prototype.visitDate=Us,Ps.prototype.visitTimestamp=Us,Ps.prototype.visitTime=Us,Ps.prototype.visitDecimal=Us,Ps.prototype.visitList=Hs,Ps.prototype.visitStruct=js,Ps.prototype.visitUnion=function(t){const{type:e,length:i,typeIds:r,valueOffsets:s}=t;if(zs.call(this,r),e.mode===n.Sparse)return js.call(this,t);if(e.mode===n.Dense){if(t.offset<=0)return zs.call(this,s),js.call(this,t);{const n=r.reduce(((t,e)=>Math.max(t,e)),r[0]),o=new Int32Array(n+1),a=new Int32Array(n+1).fill(-1),l=new Int32Array(i),h=K(-s[0],i,s);for(let t,e,n=-1;++nthis.writeAll(t))):C(t)?Zs(this,t):Gs(this,t)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(t){return this._sink.toDOMStream(t)}toNodeStream(t){return this._sink.toNodeStream(t)}close(){return this.reset()._sink.close()}abort(t){return this.reset()._sink.abort(t)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(t=this._sink,e=null){var i;return t===this._sink||t instanceof Kn?this._sink=t:(this._sink=new Kn,t&&x(i=t)&&_(i.abort)&&_(i.getWriter)&&!M(i)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&(t=>x(t)&&_(t.end)&&_(t.write)&&w(t.writable)&&!M(t))(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._dictionaryDeltaOffsets=new Map,e&&hn(e,this._schema)||(null==e?(this._position=0,this._schema=null):(this._started=!0,this._schema=e,this._writeSchema(e))),this}write(t){let e=null;if(!this._sink)throw new Error("RecordBatchWriter is closed");if(null==t)return this.finish()&&void 0;if(t instanceof yn&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof dn&&!(e=t.schema))return this.finish()&&void 0;if(e&&!hn(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof dn?t instanceof gn||this._writeRecordBatch(t):t instanceof yn?this.writeAll(t.batches):S(t)&&this.writeAll(t)}_writeMessage(t,e=8){const i=e-1,n=es.encode(t),r=n.byteLength,s=this._writeLegacyIpcFormat?4:8,o=r+s+i&~i,a=o-r-s;return t.headerType===l.RecordBatch?this._recordBatchBlocks.push(new jn(o,t.bodyLength,this._position)):t.headerType===l.DictionaryBatch&&this._dictionaryBlocks.push(new jn(o,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(o-s)),r>0&&this._write(n),this._writePadding(a)}_write(t){if(this._started){const e=Y(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(es.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(vs)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){const{byteLength:e,nodes:i,bufferRegions:n,buffers:r}=Ps.assemble(t),s=new is(t.numRows,i,n),o=es.from(s,e);return this._writeDictionaries(t)._writeMessage(o)._writeBodyBuffers(r)}_writeDictionaryBatch(t,e,i=!1){this._dictionaryDeltaOffsets.set(e,t.length+(this._dictionaryDeltaOffsets.get(e)||0));const{byteLength:n,nodes:r,bufferRegions:s,buffers:o}=Ps.assemble(new Hi([t])),a=new is(t.length,r,s),l=new ns(a,e,i),h=es.from(l,n);return this._writeMessage(h)._writeBodyBuffers(o)}_writeBodyBuffers(t){let e,i,n;for(let r=-1,s=t.length;++r0&&(this._write(e),(n=(i+7&-8)-i)>0&&this._writePadding(n));return this}_writeDictionaries(t){for(let[e,i]of t.dictionaries){let t=this._dictionaryDeltaOffsets.get(e)||0;if(0===t||(i=null==i?void 0:i.slice(t)).length>0)for(const n of i.data)this._writeDictionaryBatch(n,e,t>0),t+=n.length}return this}}class qs extends $s{static writeAll(t,e){const i=new qs(e);return k(t)?t.then((t=>i.writeAll(t))):C(t)?Zs(i,t):Gs(i,t)}}class Ws extends $s{static writeAll(t){const e=new Ws;return k(t)?t.then((t=>e.writeAll(t))):C(t)?Zs(e,t):Gs(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeFooter(t){const i=Vn.encode(new Vn(t,e.V4,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(i)._write(Int32Array.of(i.byteLength))._writeMagic()}}function Gs(t,e){let i=e;e instanceof yn&&(i=e.batches,t.reset(void 0,e.schema));for(const e of i)t.write(e);return t.finish()}function Zs(t,e){var i,n,r,s;return F(this,void 0,void 0,(function*(){try{for(i=z(e);!(n=yield i.next()).done;){const e=n.value;t.write(e)}}catch(t){r={error:t}}finally{try{n&&!n.done&&(s=i.return)&&(yield s.call(i))}finally{if(r)throw r.error}}return t.finish()}))}function Ys(t){const e=Ss.from(t);return k(e)?e.then((t=>Ys(t))):e.isAsync()?e.readAll().then((t=>new yn(t))):new yn(e.readAll())}function Qs(t,e="stream"){return("stream"===e?qs:Ws).writeAll(t).toUint8Array(!0)}var Xs,Ks=function(){function t(t,e,i,n){var r=this;this.getCell=function(t,e){var i=t=r.headerRows&&e=r.headerColumns;if(i){var o=["blank"];return e>0&&o.push("level"+t),{type:"blank",classNames:o.join(" "),content:""}}if(s)return{type:"columns",classNames:(o=["col_heading","level"+t,"col"+(l=e-r.headerColumns)]).join(" "),content:r.getContent(r.columnsTable,l,t)};if(n)return o=["row_heading","level"+e,"row"+(a=t-r.headerRows)],{type:"index",id:"T_".concat(r.uuid,"level").concat(e,"_row").concat(a),classNames:o.join(" "),content:r.getContent(r.indexTable,a,e)};o=["data","row"+(a=t-r.headerRows),"col"+(l=e-r.headerColumns)];var a,l,h=r.styler?r.getContent(r.styler.displayValuesTable,a,l):r.getContent(r.dataTable,a,l);return{type:"data",id:"T_".concat(r.uuid,"row").concat(a,"_col").concat(l),classNames:o.join(" "),content:h}},this.getContent=function(t,e,i){var n=t.getChildAt(i);return null===n?"":r.getColumnTypeId(t,i)===h.Timestamp?r.nanosToDate(n.get(e)):n.get(e)},this.dataTable=Ys(t),this.indexTable=Ys(e),this.columnsTable=Ys(i),this.styler=n?{caption:n.caption,displayValuesTable:Ys(n.displayValues),styles:n.styles,uuid:n.uuid}:void 0}return Object.defineProperty(t.prototype,"rows",{get:function(){return this.indexTable.numRows+this.columnsTable.numCols},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"columns",{get:function(){return this.indexTable.numCols+this.columnsTable.numRows},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"headerRows",{get:function(){return this.rows-this.dataRows},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"headerColumns",{get:function(){return this.columns-this.dataColumns},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dataRows",{get:function(){return this.dataTable.numRows},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dataColumns",{get:function(){return this.dataTable.numCols},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"uuid",{get:function(){return this.styler&&this.styler.uuid},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"caption",{get:function(){return this.styler&&this.styler.caption},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"styles",{get:function(){return this.styler&&this.styler.styles},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"table",{get:function(){return this.dataTable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"index",{get:function(){return this.indexTable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"columnTable",{get:function(){return this.columnsTable},enumerable:!1,configurable:!0}),t.prototype.serialize=function(){return{data:Qs(this.dataTable),index:Qs(this.indexTable),columns:Qs(this.columnsTable)}},t.prototype.getColumnTypeId=function(t,e){return t.schema.fields[e].type.typeId},t.prototype.nanosToDate=function(t){return new Date(t/1e6)},t}(),Js=function(){return Js=Object.assign||function(t){for(var e,i=1,n=arguments.length;i0?t.argsDataframeToObject(e.dfs):{};i=Js(Js({},i),n);var r=Boolean(e.disabled),s=e.theme;s&&io(s);var o={disabled:r,args:i,theme:s},a=new CustomEvent(t.RENDER_EVENT,{detail:o});t.events.dispatchEvent(a)},t.argsDataframeToObject=function(e){var i=e.map((function(e){var i=e.key,n=e.value;return[i,t.toArrowTable(n)]}));return Object.fromEntries(i)},t.toArrowTable=function(t){var e,i=(e=t.data).data,n=e.index,r=e.columns,s=e.styler;return new Ks(i,n,r,s)},t.sendBackMsg=function(t,e){window.parent.postMessage(Js({isStreamlitMessage:!0,type:t},e),"*")},t}(),io=function(t){var e=document.createElement("style");document.head.appendChild(e),e.innerHTML="\n :root {\n --primary-color: ".concat(t.primaryColor,";\n --background-color: ").concat(t.backgroundColor,";\n --secondary-background-color: ").concat(t.secondaryBackgroundColor,";\n --text-color: ").concat(t.textColor,";\n --font: ").concat(t.font,";\n }\n\n body {\n background-color: var(--background-color);\n color: var(--text-color);\n }\n ")},no=(to=function(t,e){return to=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},to(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}to(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)});function ro(t){return ro="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ro(t)}function so(t,e){for(var i=0;i0&&e-1 in t)}v.fn=v.prototype={jquery:y,constructor:v,length:0,toArray:function(){return n.call(this)},get:function(t){return null==t?n.call(this):t<0?this[t+this.length]:this[t]},pushStack:function(t){var e=v.merge(this.constructor(),t);return e.prevObject=this,e},each:function(t){return v.each(this,t)},map:function(t){return this.pushStack(v.map(this,(function(e,i){return t.call(e,i,e)})))},slice:function(){return this.pushStack(n.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(t){var e=this.length,i=+t+(t<0?e:0);return this.pushStack(i>=0&&i+~]|"+O+")"+O+"*"),$=new RegExp("="+O+"*([^\\]'\"]*?)"+O+"*\\]","g"),q=new RegExp(z),W=new RegExp("^"+D+"$"),G={ID:new RegExp("^#("+D+")"),CLASS:new RegExp("^\\.("+D+")"),TAG:new RegExp("^("+D+"|[*])"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+z),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+O+"*(even|odd|(([+-]|)(\\d*)n|)"+O+"*(?:([+-]|)"+O+"*(\\d+)|))"+O+"*\\)|)","i"),bool:new RegExp("^(?:"+F+")$","i"),needsContext:new RegExp("^"+O+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+O+"*((?:-\\d)?\\d*)"+O+"*\\)|)(?=[^-]|$)","i")},Z=/^(?:input|select|textarea|button)$/i,Y=/^h\d$/i,Q=/^[^{]+\{\s*\[native \w/,X=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,K=/[+~]/,J=new RegExp("\\\\([\\da-f]{1,6}"+O+"?|("+O+")|.)","ig"),tt=function(t,e,i){var n="0x"+e-65536;return n!=n||i?e:n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320)},et=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,it=function(t,e){return e?"\0"===t?"�":t.slice(0,-1)+"\\"+t.charCodeAt(t.length-1).toString(16)+" ":"\\"+t},nt=function(){d()},rt=bt((function(t){return!0===t.disabled&&("form"in t||"label"in t)}),{dir:"parentNode",next:"legend"});try{L.apply(E=B.call(_.childNodes),_.childNodes),E[_.childNodes.length].nodeType}catch(t){L={apply:E.length?function(t,e){R.apply(t,B.call(e))}:function(t,e){for(var i=t.length,n=0;t[i++]=e[n++];);t.length=i-1}}}function st(t,e,n,r){var s,a,h,c,u,p,b,y=e&&e.ownerDocument,x=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==x&&9!==x&&11!==x)return n;if(!r&&((e?e.ownerDocument||e:_)!==f&&d(e),e=e||f,g)){if(11!==x&&(u=X.exec(t)))if(s=u[1]){if(9===x){if(!(h=e.getElementById(s)))return n;if(h.id===s)return n.push(h),n}else if(y&&(h=y.getElementById(s))&&v(e,h)&&h.id===s)return n.push(h),n}else{if(u[2])return L.apply(n,e.getElementsByTagName(t)),n;if((s=u[3])&&i.getElementsByClassName&&e.getElementsByClassName)return L.apply(n,e.getElementsByClassName(s)),n}if(i.qsa&&!A[t+" "]&&(!m||!m.test(t))){if(1!==x)y=e,b=t;else if("object"!==e.nodeName.toLowerCase()){for((c=e.getAttribute("id"))?c=c.replace(et,it):e.setAttribute("id",c=w),a=(p=o(t)).length;a--;)p[a]="#"+c+" "+mt(p[a]);b=p.join(","),y=K.test(t)&&pt(e.parentNode)||e}if(b)try{return L.apply(n,y.querySelectorAll(b)),n}catch(t){}finally{c===w&&e.removeAttribute("id")}}}return l(t.replace(V,"$1"),e,n,r)}function ot(){var t=[];return function e(i,r){return t.push(i+" ")>n.cacheLength&&delete e[t.shift()],e[i+" "]=r}}function at(t){return t[w]=!0,t}function lt(t){var e=f.createElement("fieldset");try{return!!t(e)}catch(t){return!1}finally{e.parentNode&&e.parentNode.removeChild(e),e=null}}function ht(t,e){var i=e&&t,n=i&&1===t.nodeType&&1===e.nodeType&&t.sourceIndex-e.sourceIndex;if(n)return n;if(i)for(;i=i.nextSibling;)if(i===e)return-1;return t?1:-1}function ct(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function ut(t){return function(e){var i=e.nodeName.toLowerCase();return("input"===i||"button"===i)&&e.type===t}}function dt(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&rt(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ft(t){return at((function(e){return e=+e,at((function(i,n){for(var r,s=t([],i.length,e),o=s.length;o--;)i[r=s[o]]&&(i[r]=!(n[r]=i[r]))}))}))}function pt(t){return t&&void 0!==t.getElementsByTagName&&t}for(e in i=st.support={},s=st.isXML=function(t){var e=t&&(t.ownerDocument||t).documentElement;return!!e&&"HTML"!==e.nodeName},d=st.setDocument=function(t){var e,r,o=t?t.ownerDocument||t:_;return o!==f&&9===o.nodeType&&o.documentElement?(p=(f=o).documentElement,g=!s(f),_!==f&&(r=f.defaultView)&&r.top!==r&&(r.addEventListener?r.addEventListener("unload",nt,!1):r.attachEvent&&r.attachEvent("onunload",nt)),i.attributes=lt((function(t){return t.className="i",!t.getAttribute("className")})),i.getElementsByTagName=lt((function(t){return t.appendChild(f.createComment("")),!t.getElementsByTagName("*").length})),i.getElementsByClassName=Q.test(f.getElementsByClassName),i.getById=lt((function(t){return p.appendChild(t).id=w,!f.getElementsByName||!f.getElementsByName(w).length})),i.getById?(n.filter.ID=function(t){var e=t.replace(J,tt);return function(t){return t.getAttribute("id")===e}},n.find.ID=function(t,e){if(void 0!==e.getElementById&&g){var i=e.getElementById(t);return i?[i]:[]}}):(n.filter.ID=function(t){var e=t.replace(J,tt);return function(t){var i=void 0!==t.getAttributeNode&&t.getAttributeNode("id");return i&&i.value===e}},n.find.ID=function(t,e){if(void 0!==e.getElementById&&g){var i,n,r,s=e.getElementById(t);if(s){if((i=s.getAttributeNode("id"))&&i.value===t)return[s];for(r=e.getElementsByName(t),n=0;s=r[n++];)if((i=s.getAttributeNode("id"))&&i.value===t)return[s]}return[]}}),n.find.TAG=i.getElementsByTagName?function(t,e){return void 0!==e.getElementsByTagName?e.getElementsByTagName(t):i.qsa?e.querySelectorAll(t):void 0}:function(t,e){var i,n=[],r=0,s=e.getElementsByTagName(t);if("*"===t){for(;i=s[r++];)1===i.nodeType&&n.push(i);return n}return s},n.find.CLASS=i.getElementsByClassName&&function(t,e){if(void 0!==e.getElementsByClassName&&g)return e.getElementsByClassName(t)},b=[],m=[],(i.qsa=Q.test(f.querySelectorAll))&&(lt((function(t){p.appendChild(t).innerHTML="",t.querySelectorAll("[msallowcapture^='']").length&&m.push("[*^$]="+O+"*(?:''|\"\")"),t.querySelectorAll("[selected]").length||m.push("\\["+O+"*(?:value|"+F+")"),t.querySelectorAll("[id~="+w+"-]").length||m.push("~="),t.querySelectorAll(":checked").length||m.push(":checked"),t.querySelectorAll("a#"+w+"+*").length||m.push(".#.+[+~]")})),lt((function(t){t.innerHTML="";var e=f.createElement("input");e.setAttribute("type","hidden"),t.appendChild(e).setAttribute("name","D"),t.querySelectorAll("[name=d]").length&&m.push("name"+O+"*[*^$|!~]?="),2!==t.querySelectorAll(":enabled").length&&m.push(":enabled",":disabled"),p.appendChild(t).disabled=!0,2!==t.querySelectorAll(":disabled").length&&m.push(":enabled",":disabled"),t.querySelectorAll("*,:x"),m.push(",.*:")}))),(i.matchesSelector=Q.test(y=p.matches||p.webkitMatchesSelector||p.mozMatchesSelector||p.oMatchesSelector||p.msMatchesSelector))&<((function(t){i.disconnectedMatch=y.call(t,"*"),y.call(t,"[s!='']:x"),b.push("!=",z)})),m=m.length&&new RegExp(m.join("|")),b=b.length&&new RegExp(b.join("|")),e=Q.test(p.compareDocumentPosition),v=e||Q.test(p.contains)?function(t,e){var i=9===t.nodeType?t.documentElement:t,n=e&&e.parentNode;return t===n||!(!n||1!==n.nodeType||!(i.contains?i.contains(n):t.compareDocumentPosition&&16&t.compareDocumentPosition(n)))}:function(t,e){if(e)for(;e=e.parentNode;)if(e===t)return!0;return!1},T=e?function(t,e){if(t===e)return u=!0,0;var n=!t.compareDocumentPosition-!e.compareDocumentPosition;return n||(1&(n=(t.ownerDocument||t)===(e.ownerDocument||e)?t.compareDocumentPosition(e):1)||!i.sortDetached&&e.compareDocumentPosition(t)===n?t===f||t.ownerDocument===_&&v(_,t)?-1:e===f||e.ownerDocument===_&&v(_,e)?1:c?N(c,t)-N(c,e):0:4&n?-1:1)}:function(t,e){if(t===e)return u=!0,0;var i,n=0,r=t.parentNode,s=e.parentNode,o=[t],a=[e];if(!r||!s)return t===f?-1:e===f?1:r?-1:s?1:c?N(c,t)-N(c,e):0;if(r===s)return ht(t,e);for(i=t;i=i.parentNode;)o.unshift(i);for(i=e;i=i.parentNode;)a.unshift(i);for(;o[n]===a[n];)n++;return n?ht(o[n],a[n]):o[n]===_?-1:a[n]===_?1:0},f):f},st.matches=function(t,e){return st(t,null,null,e)},st.matchesSelector=function(t,e){if((t.ownerDocument||t)!==f&&d(t),e=e.replace($,"='$1']"),i.matchesSelector&&g&&!A[e+" "]&&(!b||!b.test(e))&&(!m||!m.test(e)))try{var n=y.call(t,e);if(n||i.disconnectedMatch||t.document&&11!==t.document.nodeType)return n}catch(t){}return st(e,f,null,[t]).length>0},st.contains=function(t,e){return(t.ownerDocument||t)!==f&&d(t),v(t,e)},st.attr=function(t,e){(t.ownerDocument||t)!==f&&d(t);var r=n.attrHandle[e.toLowerCase()],s=r&&I.call(n.attrHandle,e.toLowerCase())?r(t,e,!g):void 0;return void 0!==s?s:i.attributes||!g?t.getAttribute(e):(s=t.getAttributeNode(e))&&s.specified?s.value:null},st.escape=function(t){return(t+"").replace(et,it)},st.error=function(t){throw new Error("Syntax error, unrecognized expression: "+t)},st.uniqueSort=function(t){var e,n=[],r=0,s=0;if(u=!i.detectDuplicates,c=!i.sortStable&&t.slice(0),t.sort(T),u){for(;e=t[s++];)e===t[s]&&(r=n.push(s));for(;r--;)t.splice(n[r],1)}return c=null,t},r=st.getText=function(t){var e,i="",n=0,s=t.nodeType;if(s){if(1===s||9===s||11===s){if("string"==typeof t.textContent)return t.textContent;for(t=t.firstChild;t;t=t.nextSibling)i+=r(t)}else if(3===s||4===s)return t.nodeValue}else for(;e=t[n++];)i+=r(e);return i},n=st.selectors={cacheLength:50,createPseudo:at,match:G,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(t){return t[1]=t[1].replace(J,tt),t[3]=(t[3]||t[4]||t[5]||"").replace(J,tt),"~="===t[2]&&(t[3]=" "+t[3]+" "),t.slice(0,4)},CHILD:function(t){return t[1]=t[1].toLowerCase(),"nth"===t[1].slice(0,3)?(t[3]||st.error(t[0]),t[4]=+(t[4]?t[5]+(t[6]||1):2*("even"===t[3]||"odd"===t[3])),t[5]=+(t[7]+t[8]||"odd"===t[3])):t[3]&&st.error(t[0]),t},PSEUDO:function(t){var e,i=!t[6]&&t[2];return G.CHILD.test(t[0])?null:(t[3]?t[2]=t[4]||t[5]||"":i&&q.test(i)&&(e=o(i,!0))&&(e=i.indexOf(")",i.length-e)-i.length)&&(t[0]=t[0].slice(0,e),t[2]=i.slice(0,e)),t.slice(0,3))}},filter:{TAG:function(t){var e=t.replace(J,tt).toLowerCase();return"*"===t?function(){return!0}:function(t){return t.nodeName&&t.nodeName.toLowerCase()===e}},CLASS:function(t){var e=S[t+" "];return e||(e=new RegExp("(^|"+O+")"+t+"("+O+"|$)"))&&S(t,(function(t){return e.test("string"==typeof t.className&&t.className||void 0!==t.getAttribute&&t.getAttribute("class")||"")}))},ATTR:function(t,e,i){return function(n){var r=st.attr(n,t);return null==r?"!="===e:!e||(r+="","="===e?r===i:"!="===e?r!==i:"^="===e?i&&0===r.indexOf(i):"*="===e?i&&r.indexOf(i)>-1:"$="===e?i&&r.slice(-i.length)===i:"~="===e?(" "+r.replace(U," ")+" ").indexOf(i)>-1:"|="===e&&(r===i||r.slice(0,i.length+1)===i+"-"))}},CHILD:function(t,e,i,n,r){var s="nth"!==t.slice(0,3),o="last"!==t.slice(-4),a="of-type"===e;return 1===n&&0===r?function(t){return!!t.parentNode}:function(e,i,l){var h,c,u,d,f,p,g=s!==o?"nextSibling":"previousSibling",m=e.parentNode,b=a&&e.nodeName.toLowerCase(),y=!l&&!a,v=!1;if(m){if(s){for(;g;){for(d=e;d=d[g];)if(a?d.nodeName.toLowerCase()===b:1===d.nodeType)return!1;p=g="only"===t&&!p&&"nextSibling"}return!0}if(p=[o?m.firstChild:m.lastChild],o&&y){for(v=(f=(h=(c=(u=(d=m)[w]||(d[w]={}))[d.uniqueID]||(u[d.uniqueID]={}))[t]||[])[0]===x&&h[1])&&h[2],d=f&&m.childNodes[f];d=++f&&d&&d[g]||(v=f=0)||p.pop();)if(1===d.nodeType&&++v&&d===e){c[t]=[x,f,v];break}}else if(y&&(v=f=(h=(c=(u=(d=e)[w]||(d[w]={}))[d.uniqueID]||(u[d.uniqueID]={}))[t]||[])[0]===x&&h[1]),!1===v)for(;(d=++f&&d&&d[g]||(v=f=0)||p.pop())&&((a?d.nodeName.toLowerCase()!==b:1!==d.nodeType)||!++v||(y&&((c=(u=d[w]||(d[w]={}))[d.uniqueID]||(u[d.uniqueID]={}))[t]=[x,v]),d!==e)););return(v-=r)===n||v%n==0&&v/n>=0}}},PSEUDO:function(t,e){var i,r=n.pseudos[t]||n.setFilters[t.toLowerCase()]||st.error("unsupported pseudo: "+t);return r[w]?r(e):r.length>1?(i=[t,t,"",e],n.setFilters.hasOwnProperty(t.toLowerCase())?at((function(t,i){for(var n,s=r(t,e),o=s.length;o--;)t[n=N(t,s[o])]=!(i[n]=s[o])})):function(t){return r(t,0,i)}):r}},pseudos:{not:at((function(t){var e=[],i=[],n=a(t.replace(V,"$1"));return n[w]?at((function(t,e,i,r){for(var s,o=n(t,null,r,[]),a=t.length;a--;)(s=o[a])&&(t[a]=!(e[a]=s))})):function(t,r,s){return e[0]=t,n(e,null,s,i),e[0]=null,!i.pop()}})),has:at((function(t){return function(e){return st(t,e).length>0}})),contains:at((function(t){return t=t.replace(J,tt),function(e){return(e.textContent||e.innerText||r(e)).indexOf(t)>-1}})),lang:at((function(t){return W.test(t||"")||st.error("unsupported lang: "+t),t=t.replace(J,tt).toLowerCase(),function(e){var i;do{if(i=g?e.lang:e.getAttribute("xml:lang")||e.getAttribute("lang"))return(i=i.toLowerCase())===t||0===i.indexOf(t+"-")}while((e=e.parentNode)&&1===e.nodeType);return!1}})),target:function(e){var i=t.location&&t.location.hash;return i&&i.slice(1)===e.id},root:function(t){return t===p},focus:function(t){return t===f.activeElement&&(!f.hasFocus||f.hasFocus())&&!!(t.type||t.href||~t.tabIndex)},enabled:dt(!1),disabled:dt(!0),checked:function(t){var e=t.nodeName.toLowerCase();return"input"===e&&!!t.checked||"option"===e&&!!t.selected},selected:function(t){return t.parentNode&&t.parentNode.selectedIndex,!0===t.selected},empty:function(t){for(t=t.firstChild;t;t=t.nextSibling)if(t.nodeType<6)return!1;return!0},parent:function(t){return!n.pseudos.empty(t)},header:function(t){return Y.test(t.nodeName)},input:function(t){return Z.test(t.nodeName)},button:function(t){var e=t.nodeName.toLowerCase();return"input"===e&&"button"===t.type||"button"===e},text:function(t){var e;return"input"===t.nodeName.toLowerCase()&&"text"===t.type&&(null==(e=t.getAttribute("type"))||"text"===e.toLowerCase())},first:ft((function(){return[0]})),last:ft((function(t,e){return[e-1]})),eq:ft((function(t,e,i){return[i<0?i+e:i]})),even:ft((function(t,e){for(var i=0;i=0;)t.push(n);return t})),gt:ft((function(t,e,i){for(var n=i<0?i+e:i;++n1?function(e,i,n){for(var r=t.length;r--;)if(!t[r](e,i,n))return!1;return!0}:t[0]}function vt(t,e,i,n,r){for(var s,o=[],a=0,l=t.length,h=null!=e;a-1&&(s[h]=!(o[h]=u))}}else b=vt(b===o?b.splice(p,b.length):b),r?r(null,o,b,l):L.apply(o,b)}))}function _t(t){for(var e,i,r,s=t.length,o=n.relative[t[0].type],a=o||n.relative[" "],l=o?1:0,c=bt((function(t){return t===e}),a,!0),u=bt((function(t){return N(e,t)>-1}),a,!0),d=[function(t,i,n){var r=!o&&(n||i!==h)||((e=i).nodeType?c(t,i,n):u(t,i,n));return e=null,r}];l1&&yt(d),l>1&&mt(t.slice(0,l-1).concat({value:" "===t[l-2].type?"*":""})).replace(V,"$1"),i,l0,r=t.length>0,s=function(s,o,a,l,c){var u,p,m,b=0,y="0",v=s&&[],w=[],_=h,k=s||r&&n.find.TAG("*",c),S=x+=null==_?1:Math.random()||.1,C=k.length;for(c&&(h=o===f||o||c);y!==C&&null!=(u=k[y]);y++){if(r&&u){for(p=0,o||u.ownerDocument===f||(d(u),a=!g);m=t[p++];)if(m(u,o||f,a)){l.push(u);break}c&&(x=S)}i&&((u=!m&&u)&&b--,s&&v.push(u))}if(b+=y,i&&y!==b){for(p=0;m=e[p++];)m(v,w,o,a);if(s){if(b>0)for(;y--;)v[y]||w[y]||(w[y]=M.call(l));w=vt(w)}L.apply(l,w),c&&!s&&w.length>0&&b+e.length>1&&st.uniqueSort(l)}return c&&(x=S,h=_),v};return i?at(s):s}(s,r)),a.selector=t}return a},l=st.select=function(t,e,i,r){var s,l,h,c,u,d="function"==typeof t&&t,f=!r&&o(t=d.selector||t);if(i=i||[],1===f.length){if((l=f[0]=f[0].slice(0)).length>2&&"ID"===(h=l[0]).type&&9===e.nodeType&&g&&n.relative[l[1].type]){if(!(e=(n.find.ID(h.matches[0].replace(J,tt),e)||[])[0]))return i;d&&(e=e.parentNode),t=t.slice(l.shift().value.length)}for(s=G.needsContext.test(t)?0:l.length;s--&&(h=l[s],!n.relative[c=h.type]);)if((u=n.find[c])&&(r=u(h.matches[0].replace(J,tt),K.test(l[0].type)&&pt(e.parentNode)||e))){if(l.splice(s,1),!(t=r.length&&mt(l)))return L.apply(i,r),i;break}}return(d||a(t,f))(r,e,!g,i,!e||K.test(t)&&pt(e.parentNode)||e),i},i.sortStable=w.split("").sort(T).join("")===w,i.detectDuplicates=!!u,d(),st}(window);v.find=x,v.expr=x.selectors,v.expr[":"]=v.expr.pseudos,v.uniqueSort=v.unique=x.uniqueSort,v.text=x.getText,v.isXMLDoc=x.isXML,v.contains=x.contains,v.escapeSelector=x.escape;var k=function(t,e,i){for(var n=[],r=void 0!==i;(t=t[e])&&9!==t.nodeType;)if(1===t.nodeType){if(r&&v(t).is(i))break;n.push(t)}return n},S=function(t,e){for(var i=[];t;t=t.nextSibling)1===t.nodeType&&t!==e&&i.push(t);return i},C=v.expr.match.needsContext;function A(t,e){return t.nodeName&&t.nodeName.toLowerCase()===e.toLowerCase()}var T=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function I(t,e,i){return f(e)?v.grep(t,(function(t,n){return!!e.call(t,n,t)!==i})):e.nodeType?v.grep(t,(function(t){return t===e!==i})):"string"!=typeof e?v.grep(t,(function(t){return o.call(e,t)>-1!==i})):v.filter(e,t,i)}v.filter=function(t,e,i){var n=e[0];return i&&(t=":not("+t+")"),1===e.length&&1===n.nodeType?v.find.matchesSelector(n,t)?[n]:[]:v.find.matches(t,v.grep(e,(function(t){return 1===t.nodeType})))},v.fn.extend({find:function(t){var e,i,n=this.length,r=this;if("string"!=typeof t)return this.pushStack(v(t).filter((function(){for(e=0;e1?v.uniqueSort(i):i},filter:function(t){return this.pushStack(I(this,t||[],!1))},not:function(t){return this.pushStack(I(this,t||[],!0))},is:function(t){return!!I(this,"string"==typeof t&&C.test(t)?v(t):t||[],!1).length}});var E,M=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(v.fn.init=function(t,i,n){var r,s;if(!t)return this;if(n=n||E,"string"==typeof t){if(!(r="<"===t[0]&&">"===t[t.length-1]&&t.length>=3?[null,t,null]:M.exec(t))||!r[1]&&i)return!i||i.jquery?(i||n).find(t):this.constructor(i).find(t);if(r[1]){if(i=i instanceof v?i[0]:i,v.merge(this,v.parseHTML(r[1],i&&i.nodeType?i.ownerDocument||i:e,!0)),T.test(r[1])&&v.isPlainObject(i))for(r in i)f(this[r])?this[r](i[r]):this.attr(r,i[r]);return this}return(s=e.getElementById(r[2]))&&(this[0]=s,this.length=1),this}return t.nodeType?(this[0]=t,this.length=1,this):f(t)?void 0!==n.ready?n.ready(t):t(v):v.makeArray(t,this)}).prototype=v.fn,E=v(e);var R=/^(?:parents|prev(?:Until|All))/,L={children:!0,contents:!0,next:!0,prev:!0};function B(t,e){for(;(t=t[e])&&1!==t.nodeType;);return t}v.fn.extend({has:function(t){var e=v(t,this),i=e.length;return this.filter((function(){for(var t=0;t-1:1===i.nodeType&&v.find.matchesSelector(i,t))){s.push(i);break}return this.pushStack(s.length>1?v.uniqueSort(s):s)},index:function(t){return t?"string"==typeof t?o.call(v(t),this[0]):o.call(this,t.jquery?t[0]:t):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(t,e){return this.pushStack(v.uniqueSort(v.merge(this.get(),v(t,e))))},addBack:function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}}),v.each({parent:function(t){var e=t.parentNode;return e&&11!==e.nodeType?e:null},parents:function(t){return k(t,"parentNode")},parentsUntil:function(t,e,i){return k(t,"parentNode",i)},next:function(t){return B(t,"nextSibling")},prev:function(t){return B(t,"previousSibling")},nextAll:function(t){return k(t,"nextSibling")},prevAll:function(t){return k(t,"previousSibling")},nextUntil:function(t,e,i){return k(t,"nextSibling",i)},prevUntil:function(t,e,i){return k(t,"previousSibling",i)},siblings:function(t){return S((t.parentNode||{}).firstChild,t)},children:function(t){return S(t.firstChild)},contents:function(t){return A(t,"iframe")?t.contentDocument:(A(t,"template")&&(t=t.content||t),v.merge([],t.childNodes))}},(function(t,e){v.fn[t]=function(i,n){var r=v.map(this,e,i);return"Until"!==t.slice(-5)&&(n=i),n&&"string"==typeof n&&(r=v.filter(n,r)),this.length>1&&(L[t]||v.uniqueSort(r),R.test(t)&&r.reverse()),this.pushStack(r)}}));var N=/[^\x20\t\r\n\f]+/g;function F(t){return t}function O(t){throw t}function D(t,e,i,n){var r;try{t&&f(r=t.promise)?r.call(t).done(e).fail(i):t&&f(r=t.then)?r.call(t,e,i):e.apply(void 0,[t].slice(n))}catch(t){i.apply(void 0,[t])}}v.Callbacks=function(t){t="string"==typeof t?function(t){var e={};return v.each(t.match(N)||[],(function(t,i){e[i]=!0})),e}(t):v.extend({},t);var e,i,n,r,s=[],o=[],a=-1,l=function(){for(r=r||t.once,n=e=!0;o.length;a=-1)for(i=o.shift();++a-1;)s.splice(i,1),i<=a&&a--})),this},has:function(t){return t?v.inArray(t,s)>-1:s.length>0},empty:function(){return s&&(s=[]),this},disable:function(){return r=o=[],s=i="",this},disabled:function(){return!s},lock:function(){return r=o=[],i||e||(s=i=""),this},locked:function(){return!!r},fireWith:function(t,i){return r||(i=[t,(i=i||[]).slice?i.slice():i],o.push(i),e||l()),this},fire:function(){return h.fireWith(this,arguments),this},fired:function(){return!!n}};return h},v.extend({Deferred:function(t){var e=[["notify","progress",v.Callbacks("memory"),v.Callbacks("memory"),2],["resolve","done",v.Callbacks("once memory"),v.Callbacks("once memory"),0,"resolved"],["reject","fail",v.Callbacks("once memory"),v.Callbacks("once memory"),1,"rejected"]],i="pending",n={state:function(){return i},always:function(){return r.done(arguments).fail(arguments),this},catch:function(t){return n.then(null,t)},pipe:function(){var t=arguments;return v.Deferred((function(i){v.each(e,(function(e,n){var s=f(t[n[4]])&&t[n[4]];r[n[1]]((function(){var t=s&&s.apply(this,arguments);t&&f(t.promise)?t.promise().progress(i.notify).done(i.resolve).fail(i.reject):i[n[0]+"With"](this,s?[t]:arguments)}))})),t=null})).promise()},then:function(t,i,n){var r=0;function s(t,e,i,n){return function(){var o=this,a=arguments,l=function(){var l,h;if(!(t=r&&(i!==O&&(o=void 0,a=[n]),e.rejectWith(o,a))}};t?h():(v.Deferred.getStackHook&&(h.stackTrace=v.Deferred.getStackHook()),window.setTimeout(h))}}return v.Deferred((function(r){e[0][3].add(s(0,r,f(n)?n:F,r.notifyWith)),e[1][3].add(s(0,r,f(t)?t:F)),e[2][3].add(s(0,r,f(i)?i:O))})).promise()},promise:function(t){return null!=t?v.extend(t,n):n}},r={};return v.each(e,(function(t,s){var o=s[2],a=s[5];n[s[1]]=o.add,a&&o.add((function(){i=a}),e[3-t][2].disable,e[3-t][3].disable,e[0][2].lock,e[0][3].lock),o.add(s[3].fire),r[s[0]]=function(){return r[s[0]+"With"](this===r?void 0:this,arguments),this},r[s[0]+"With"]=o.fireWith})),n.promise(r),t&&t.call(r,r),r},when:function(t){var e=arguments.length,i=e,r=Array(i),s=n.call(arguments),o=v.Deferred(),a=function(t){return function(i){r[t]=this,s[t]=arguments.length>1?n.call(arguments):i,--e||o.resolveWith(r,s)}};if(e<=1&&(D(t,o.done(a(i)).resolve,o.reject,!e),"pending"===o.state()||f(s[i]&&s[i].then)))return o.then();for(;i--;)D(s[i],a(i),o.reject);return o.promise()}});var P=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;v.Deferred.exceptionHook=function(t,e){window.console&&window.console.warn&&t&&P.test(t.name)&&window.console.warn("jQuery.Deferred exception: "+t.message,t.stack,e)},v.readyException=function(t){window.setTimeout((function(){throw t}))};var z=v.Deferred();function U(){e.removeEventListener("DOMContentLoaded",U),window.removeEventListener("load",U),v.ready()}v.fn.ready=function(t){return z.then(t).catch((function(t){v.readyException(t)})),this},v.extend({isReady:!1,readyWait:1,ready:function(t){(!0===t?--v.readyWait:v.isReady)||(v.isReady=!0,!0!==t&&--v.readyWait>0||z.resolveWith(e,[v]))}}),v.ready.then=z.then,"complete"===e.readyState||"loading"!==e.readyState&&!e.documentElement.doScroll?window.setTimeout(v.ready):(e.addEventListener("DOMContentLoaded",U),window.addEventListener("load",U));var V=function(t,e,i,n,r,s,o){var a=0,l=t.length,h=null==i;if("object"===b(i))for(a in r=!0,i)V(t,e,a,i[a],!0,s,o);else if(void 0!==n&&(r=!0,f(n)||(o=!0),h&&(o?(e.call(t,n),e=null):(h=e,e=function(t,e,i){return h.call(v(t),i)})),e))for(;a1,null,!0)},removeData:function(t){return this.each((function(){Y.remove(this,t)}))}}),v.extend({queue:function(t,e,i){var n;if(t)return e=(e||"fx")+"queue",n=Z.get(t,e),i&&(!n||Array.isArray(i)?n=Z.access(t,e,v.makeArray(i)):n.push(i)),n||[]},dequeue:function(t,e){e=e||"fx";var i=v.queue(t,e),n=i.length,r=i.shift(),s=v._queueHooks(t,e);"inprogress"===r&&(r=i.shift(),n--),r&&("fx"===e&&i.unshift("inprogress"),delete s.stop,r.call(t,(function(){v.dequeue(t,e)}),s)),!n&&s&&s.empty.fire()},_queueHooks:function(t,e){var i=e+"queueHooks";return Z.get(t,i)||Z.access(t,i,{empty:v.Callbacks("once memory").add((function(){Z.remove(t,[e+"queue",i])}))})}}),v.fn.extend({queue:function(t,e){var i=2;return"string"!=typeof t&&(e=t,t="fx",i--),arguments.length\x20\t\r\n\f]+)/i,ht=/^$|^module$|\/(?:java|ecma)script/i,ct={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ut(t,e){var i;return i=void 0!==t.getElementsByTagName?t.getElementsByTagName(e||"*"):void 0!==t.querySelectorAll?t.querySelectorAll(e||"*"):[],void 0===e||e&&A(t,e)?v.merge([t],i):i}function dt(t,e){for(var i=0,n=t.length;i-1)r&&r.push(s);else if(h=v.contains(s.ownerDocument,s),o=ut(u.appendChild(s),"script"),h&&dt(o),i)for(c=0;s=o[c++];)ht.test(s.type||"")&&i.push(s);return u}!function(){var t=e.createDocumentFragment().appendChild(e.createElement("div")),i=e.createElement("input");i.setAttribute("type","radio"),i.setAttribute("checked","checked"),i.setAttribute("name","t"),t.appendChild(i),d.checkClone=t.cloneNode(!0).cloneNode(!0).lastChild.checked,t.innerHTML="",d.noCloneChecked=!!t.cloneNode(!0).lastChild.defaultValue}();var gt=e.documentElement,mt=/^key/,bt=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,yt=/^([^.]*)(?:\.(.+)|)/;function vt(){return!0}function wt(){return!1}function _t(){try{return e.activeElement}catch(t){}}function xt(t,e,i,n,r,s){var o,a;if("object"==typeof e){for(a in"string"!=typeof i&&(n=n||i,i=void 0),e)xt(t,a,i,n,e[a],s);return t}if(null==n&&null==r?(r=i,n=i=void 0):null==r&&("string"==typeof i?(r=n,n=void 0):(r=n,n=i,i=void 0)),!1===r)r=wt;else if(!r)return t;return 1===s&&(o=r,r=function(t){return v().off(t),o.apply(this,arguments)},r.guid=o.guid||(o.guid=v.guid++)),t.each((function(){v.event.add(this,e,r,n,i)}))}v.event={global:{},add:function(t,e,i,n,r){var s,o,a,l,h,c,u,d,f,p,g,m=Z.get(t);if(m)for(i.handler&&(i=(s=i).handler,r=s.selector),r&&v.find.matchesSelector(gt,r),i.guid||(i.guid=v.guid++),(l=m.events)||(l=m.events={}),(o=m.handle)||(o=m.handle=function(e){return void 0!==v&&v.event.triggered!==e.type?v.event.dispatch.apply(t,arguments):void 0}),h=(e=(e||"").match(N)||[""]).length;h--;)f=g=(a=yt.exec(e[h])||[])[1],p=(a[2]||"").split(".").sort(),f&&(u=v.event.special[f]||{},f=(r?u.delegateType:u.bindType)||f,u=v.event.special[f]||{},c=v.extend({type:f,origType:g,data:n,handler:i,guid:i.guid,selector:r,needsContext:r&&v.expr.match.needsContext.test(r),namespace:p.join(".")},s),(d=l[f])||((d=l[f]=[]).delegateCount=0,u.setup&&!1!==u.setup.call(t,n,p,o)||t.addEventListener&&t.addEventListener(f,o)),u.add&&(u.add.call(t,c),c.handler.guid||(c.handler.guid=i.guid)),r?d.splice(d.delegateCount++,0,c):d.push(c),v.event.global[f]=!0)},remove:function(t,e,i,n,r){var s,o,a,l,h,c,u,d,f,p,g,m=Z.hasData(t)&&Z.get(t);if(m&&(l=m.events)){for(h=(e=(e||"").match(N)||[""]).length;h--;)if(f=g=(a=yt.exec(e[h])||[])[1],p=(a[2]||"").split(".").sort(),f){for(u=v.event.special[f]||{},d=l[f=(n?u.delegateType:u.bindType)||f]||[],a=a[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),o=s=d.length;s--;)c=d[s],!r&&g!==c.origType||i&&i.guid!==c.guid||a&&!a.test(c.namespace)||n&&n!==c.selector&&("**"!==n||!c.selector)||(d.splice(s,1),c.selector&&d.delegateCount--,u.remove&&u.remove.call(t,c));o&&!d.length&&(u.teardown&&!1!==u.teardown.call(t,p,m.handle)||v.removeEvent(t,f,m.handle),delete l[f])}else for(f in l)v.event.remove(t,f+e[h],i,n,!0);v.isEmptyObject(l)&&Z.remove(t,"handle events")}},dispatch:function(t){var e,i,n,r,s,o,a=v.event.fix(t),l=new Array(arguments.length),h=(Z.get(this,"events")||{})[a.type]||[],c=v.event.special[a.type]||{};for(l[0]=a,e=1;e=1))for(;h!==this;h=h.parentNode||this)if(1===h.nodeType&&("click"!==t.type||!0!==h.disabled)){for(s=[],o={},i=0;i-1:v.find(r,this,null,[h]).length),o[r]&&s.push(n);s.length&&a.push({elem:h,handlers:s})}return h=this,l\x20\t\r\n\f]*)[^>]*)\/>/gi,St=/\s*$/g;function Tt(t,e){return A(t,"table")&&A(11!==e.nodeType?e:e.firstChild,"tr")&&v(t).children("tbody")[0]||t}function It(t){return t.type=(null!==t.getAttribute("type"))+"/"+t.type,t}function Et(t){return"true/"===(t.type||"").slice(0,5)?t.type=t.type.slice(5):t.removeAttribute("type"),t}function Mt(t,e){var i,n,r,s,o,a,l,h;if(1===e.nodeType){if(Z.hasData(t)&&(s=Z.access(t),o=Z.set(e,s),h=s.events))for(r in delete o.handle,o.events={},h)for(i=0,n=h[r].length;i1&&"string"==typeof b&&!d.checkClone&&Ct.test(b))return t.each((function(r){var s=t.eq(r);y&&(e[0]=b.call(this,r,s.html())),Lt(s,e,i,n)}));if(p&&(o=(s=pt(e,t[0].ownerDocument,!1,t,n)).firstChild,1===s.childNodes.length&&(s=o),o||n)){for(l=(a=v.map(ut(s,"script"),It)).length;u")},clone:function(t,e,i){var n,r,s,o,a=t.cloneNode(!0),l=v.contains(t.ownerDocument,t);if(!(d.noCloneChecked||1!==t.nodeType&&11!==t.nodeType||v.isXMLDoc(t)))for(o=ut(a),n=0,r=(s=ut(t)).length;n0&&dt(o,!l&&ut(t,"script")),a},cleanData:function(t){for(var e,i,n,r=v.event.special,s=0;void 0!==(i=t[s]);s++)if(W(i)){if(e=i[Z.expando]){if(e.events)for(n in e.events)r[n]?v.event.remove(i,n):v.removeEvent(i,n,e.handle);i[Z.expando]=void 0}i[Y.expando]&&(i[Y.expando]=void 0)}}}),v.fn.extend({detach:function(t){return Bt(this,t,!0)},remove:function(t){return Bt(this,t)},text:function(t){return V(this,(function(t){return void 0===t?v.text(this):this.empty().each((function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=t)}))}),null,t,arguments.length)},append:function(){return Lt(this,arguments,(function(t){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||Tt(this,t).appendChild(t)}))},prepend:function(){return Lt(this,arguments,(function(t){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var e=Tt(this,t);e.insertBefore(t,e.firstChild)}}))},before:function(){return Lt(this,arguments,(function(t){this.parentNode&&this.parentNode.insertBefore(t,this)}))},after:function(){return Lt(this,arguments,(function(t){this.parentNode&&this.parentNode.insertBefore(t,this.nextSibling)}))},empty:function(){for(var t,e=0;null!=(t=this[e]);e++)1===t.nodeType&&(v.cleanData(ut(t,!1)),t.textContent="");return this},clone:function(t,e){return t=null!=t&&t,e=null==e?t:e,this.map((function(){return v.clone(this,t,e)}))},html:function(t){return V(this,(function(t){var e=this[0]||{},i=0,n=this.length;if(void 0===t&&1===e.nodeType)return e.innerHTML;if("string"==typeof t&&!St.test(t)&&!ct[(lt.exec(t)||["",""])[1].toLowerCase()]){t=v.htmlPrefilter(t);try{for(;i=0&&(l+=Math.max(0,Math.ceil(t["offset"+e[0].toUpperCase()+e.slice(1)]-s-l-a-.5))),l}function Qt(t,e,i){var n=Ft(t),r=Dt(t,e,n),s="border-box"===v.css(t,"boxSizing",!1,n),o=s;if(Nt.test(r)){if(!i)return r;r="auto"}return o=o&&(d.boxSizingReliable()||r===t.style[e]),("auto"===r||!parseFloat(r)&&"inline"===v.css(t,"display",!1,n))&&(r=t["offset"+e[0].toUpperCase()+e.slice(1)],o=!0),(r=parseFloat(r)||0)+Yt(t,e,i||(s?"border":"content"),o,n,r)+"px"}v.extend({cssHooks:{opacity:{get:function(t,e){if(e){var i=Dt(t,"opacity");return""===i?"1":i}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(t,e,i,n){if(t&&3!==t.nodeType&&8!==t.nodeType&&t.style){var r,s,o,a=q(e),l=Ht.test(e),h=t.style;if(l||(e=Gt(a)),o=v.cssHooks[e]||v.cssHooks[a],void 0===i)return o&&"get"in o&&void 0!==(r=o.get(t,!1,n))?r:h[e];"string"==(s=typeof i)&&(r=tt.exec(i))&&r[1]&&(i=function(t,e,i,n){var r,s,o=20,a=function(){return v.css(t,e,"")},l=a(),h=i&&i[3]||(v.cssNumber[e]?"":"px"),c=(v.cssNumber[e]||"px"!==h&&+l)&&tt.exec(v.css(t,e));if(c&&c[3]!==h){for(l/=2,h=h||c[3],c=+l||1;o--;)v.style(t,e,c+h),(1-s)*(1-(s=a()/l||.5))<=0&&(o=0),c/=s;c*=2,v.style(t,e,c+h),i=i||[]}return i&&(c=+c||+l||0,r=i[1]?c+(i[1]+1)*i[2]:+i[2]),r}(t,e,r),s="number"),null!=i&&i==i&&("number"===s&&(i+=r&&r[3]||(v.cssNumber[a]?"":"px")),d.clearCloneStyle||""!==i||0!==e.indexOf("background")||(h[e]="inherit"),o&&"set"in o&&void 0===(i=o.set(t,i,n))||(l?h.setProperty(e,i):h[e]=i))}},css:function(t,e,i,n){var r,s,o,a=q(e);return Ht.test(e)||(e=Gt(a)),(o=v.cssHooks[e]||v.cssHooks[a])&&"get"in o&&(r=o.get(t,!0,i)),void 0===r&&(r=Dt(t,e,n)),"normal"===r&&e in $t&&(r=$t[e]),""===i||i?(s=parseFloat(r),!0===i||isFinite(s)?s||0:r):r}}),v.each(["height","width"],(function(t,e){v.cssHooks[e]={get:function(t,i,n){if(i)return!Vt.test(v.css(t,"display"))||t.getClientRects().length&&t.getBoundingClientRect().width?Qt(t,e,n):nt(t,jt,(function(){return Qt(t,e,n)}))},set:function(t,i,n){var r,s=Ft(t),o="border-box"===v.css(t,"boxSizing",!1,s),a=n&&Yt(t,e,n,o,s);return o&&d.scrollboxSize()===s.position&&(a-=Math.ceil(t["offset"+e[0].toUpperCase()+e.slice(1)]-parseFloat(s[e])-Yt(t,e,"border",!1,s)-.5)),a&&(r=tt.exec(i))&&"px"!==(r[3]||"px")&&(t.style[e]=i,i=v.css(t,e)),Zt(0,i,a)}}})),v.cssHooks.marginLeft=Pt(d.reliableMarginLeft,(function(t,e){if(e)return(parseFloat(Dt(t,"marginLeft"))||t.getBoundingClientRect().left-nt(t,{marginLeft:0},(function(){return t.getBoundingClientRect().left})))+"px"})),v.each({margin:"",padding:"",border:"Width"},(function(t,e){v.cssHooks[t+e]={expand:function(i){for(var n=0,r={},s="string"==typeof i?i.split(" "):[i];n<4;n++)r[t+et[n]+e]=s[n]||s[n-2]||s[0];return r}},"margin"!==t&&(v.cssHooks[t+e].set=Zt)})),v.fn.extend({css:function(t,e){return V(this,(function(t,e,i){var n,r,s={},o=0;if(Array.isArray(e)){for(n=Ft(t),r=e.length;o1)}}),v.fn.delay=function(t,e){return t=v.fx&&v.fx.speeds[t]||t,e=e||"fx",this.queue(e,(function(e,i){var n=window.setTimeout(e,t);i.stop=function(){window.clearTimeout(n)}}))},zt=e.createElement("input"),Ut=e.createElement("select").appendChild(e.createElement("option")),zt.type="checkbox",d.checkOn=""!==zt.value,d.optSelected=Ut.selected,(zt=e.createElement("input")).value="t",zt.type="radio",d.radioValue="t"===zt.value;var Xt,Kt=v.expr.attrHandle;v.fn.extend({attr:function(t,e){return V(this,v.attr,t,e,arguments.length>1)},removeAttr:function(t){return this.each((function(){v.removeAttr(this,t)}))}}),v.extend({attr:function(t,e,i){var n,r,s=t.nodeType;if(3!==s&&8!==s&&2!==s)return void 0===t.getAttribute?v.prop(t,e,i):(1===s&&v.isXMLDoc(t)||(r=v.attrHooks[e.toLowerCase()]||(v.expr.match.bool.test(e)?Xt:void 0)),void 0!==i?null===i?void v.removeAttr(t,e):r&&"set"in r&&void 0!==(n=r.set(t,i,e))?n:(t.setAttribute(e,i+""),i):r&&"get"in r&&null!==(n=r.get(t,e))?n:null==(n=v.find.attr(t,e))?void 0:n)},attrHooks:{type:{set:function(t,e){if(!d.radioValue&&"radio"===e&&A(t,"input")){var i=t.value;return t.setAttribute("type",e),i&&(t.value=i),e}}}},removeAttr:function(t,e){var i,n=0,r=e&&e.match(N);if(r&&1===t.nodeType)for(;i=r[n++];)t.removeAttribute(i)}}),Xt={set:function(t,e,i){return!1===e?v.removeAttr(t,i):t.setAttribute(i,i),i}},v.each(v.expr.match.bool.source.match(/\w+/g),(function(t,e){var i=Kt[e]||v.find.attr;Kt[e]=function(t,e,n){var r,s,o=e.toLowerCase();return n||(s=Kt[o],Kt[o]=r,r=null!=i(t,e,n)?o:null,Kt[o]=s),r}}));var Jt=/^(?:input|select|textarea|button)$/i,te=/^(?:a|area)$/i;function ee(t){return(t.match(N)||[]).join(" ")}function ie(t){return t.getAttribute&&t.getAttribute("class")||""}function ne(t){return Array.isArray(t)?t:"string"==typeof t&&t.match(N)||[]}v.fn.extend({prop:function(t,e){return V(this,v.prop,t,e,arguments.length>1)},removeProp:function(t){return this.each((function(){delete this[v.propFix[t]||t]}))}}),v.extend({prop:function(t,e,i){var n,r,s=t.nodeType;if(3!==s&&8!==s&&2!==s)return 1===s&&v.isXMLDoc(t)||(e=v.propFix[e]||e,r=v.propHooks[e]),void 0!==i?r&&"set"in r&&void 0!==(n=r.set(t,i,e))?n:t[e]=i:r&&"get"in r&&null!==(n=r.get(t,e))?n:t[e]},propHooks:{tabIndex:{get:function(t){var e=v.find.attr(t,"tabindex");return e?parseInt(e,10):Jt.test(t.nodeName)||te.test(t.nodeName)&&t.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),d.optSelected||(v.propHooks.selected={get:function(t){var e=t.parentNode;return e&&e.parentNode&&e.parentNode.selectedIndex,null},set:function(t){var e=t.parentNode;e&&(e.selectedIndex,e.parentNode&&e.parentNode.selectedIndex)}}),v.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],(function(){v.propFix[this.toLowerCase()]=this})),v.fn.extend({addClass:function(t){var e,i,n,r,s,o,a,l=0;if(f(t))return this.each((function(e){v(this).addClass(t.call(this,e,ie(this)))}));if((e=ne(t)).length)for(;i=this[l++];)if(r=ie(i),n=1===i.nodeType&&" "+ee(r)+" "){for(o=0;s=e[o++];)n.indexOf(" "+s+" ")<0&&(n+=s+" ");r!==(a=ee(n))&&i.setAttribute("class",a)}return this},removeClass:function(t){var e,i,n,r,s,o,a,l=0;if(f(t))return this.each((function(e){v(this).removeClass(t.call(this,e,ie(this)))}));if(!arguments.length)return this.attr("class","");if((e=ne(t)).length)for(;i=this[l++];)if(r=ie(i),n=1===i.nodeType&&" "+ee(r)+" "){for(o=0;s=e[o++];)for(;n.indexOf(" "+s+" ")>-1;)n=n.replace(" "+s+" "," ");r!==(a=ee(n))&&i.setAttribute("class",a)}return this},toggleClass:function(t,e){var i=typeof t,n="string"===i||Array.isArray(t);return"boolean"==typeof e&&n?e?this.addClass(t):this.removeClass(t):f(t)?this.each((function(i){v(this).toggleClass(t.call(this,i,ie(this),e),e)})):this.each((function(){var e,r,s,o;if(n)for(r=0,s=v(this),o=ne(t);e=o[r++];)s.hasClass(e)?s.removeClass(e):s.addClass(e);else void 0!==t&&"boolean"!==i||((e=ie(this))&&Z.set(this,"__className__",e),this.setAttribute&&this.setAttribute("class",e||!1===t?"":Z.get(this,"__className__")||""))}))},hasClass:function(t){var e,i,n=0;for(e=" "+t+" ";i=this[n++];)if(1===i.nodeType&&(" "+ee(ie(i))+" ").indexOf(e)>-1)return!0;return!1}});var re=/\r/g;v.fn.extend({val:function(t){var e,i,n,r=this[0];return arguments.length?(n=f(t),this.each((function(i){var r;1===this.nodeType&&(null==(r=n?t.call(this,i,v(this).val()):t)?r="":"number"==typeof r?r+="":Array.isArray(r)&&(r=v.map(r,(function(t){return null==t?"":t+""}))),(e=v.valHooks[this.type]||v.valHooks[this.nodeName.toLowerCase()])&&"set"in e&&void 0!==e.set(this,r,"value")||(this.value=r))}))):r?(e=v.valHooks[r.type]||v.valHooks[r.nodeName.toLowerCase()])&&"get"in e&&void 0!==(i=e.get(r,"value"))?i:"string"==typeof(i=r.value)?i.replace(re,""):null==i?"":i:void 0}}),v.extend({valHooks:{option:{get:function(t){var e=v.find.attr(t,"value");return null!=e?e:ee(v.text(t))}},select:{get:function(t){var e,i,n,r=t.options,s=t.selectedIndex,o="select-one"===t.type,a=o?null:[],l=o?s+1:r.length;for(n=s<0?l:o?s:0;n-1)&&(i=!0);return i||(t.selectedIndex=-1),s}}}}),v.each(["radio","checkbox"],(function(){v.valHooks[this]={set:function(t,e){if(Array.isArray(e))return t.checked=v.inArray(v(t).val(),e)>-1}},d.checkOn||(v.valHooks[this].get=function(t){return null===t.getAttribute("value")?"on":t.value})})),d.focusin="onfocusin"in window;var se=/^(?:focusinfocus|focusoutblur)$/,oe=function(t){t.stopPropagation()};v.extend(v.event,{trigger:function(t,i,n,r){var s,o,a,l,c,u,d,g,m=[n||e],b=h.call(t,"type")?t.type:t,y=h.call(t,"namespace")?t.namespace.split("."):[];if(o=g=a=n=n||e,3!==n.nodeType&&8!==n.nodeType&&!se.test(b+v.event.triggered)&&(b.indexOf(".")>-1&&(y=b.split("."),b=y.shift(),y.sort()),c=b.indexOf(":")<0&&"on"+b,(t=t[v.expando]?t:new v.Event(b,"object"==typeof t&&t)).isTrigger=r?2:3,t.namespace=y.join("."),t.rnamespace=t.namespace?new RegExp("(^|\\.)"+y.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=void 0,t.target||(t.target=n),i=null==i?[t]:v.makeArray(i,[t]),d=v.event.special[b]||{},r||!d.trigger||!1!==d.trigger.apply(n,i))){if(!r&&!d.noBubble&&!p(n)){for(l=d.delegateType||b,se.test(l+b)||(o=o.parentNode);o;o=o.parentNode)m.push(o),a=o;a===(n.ownerDocument||e)&&m.push(a.defaultView||a.parentWindow||window)}for(s=0;(o=m[s++])&&!t.isPropagationStopped();)g=o,t.type=s>1?l:d.bindType||b,(u=(Z.get(o,"events")||{})[t.type]&&Z.get(o,"handle"))&&u.apply(o,i),(u=c&&o[c])&&u.apply&&W(o)&&(t.result=u.apply(o,i),!1===t.result&&t.preventDefault());return t.type=b,r||t.isDefaultPrevented()||d._default&&!1!==d._default.apply(m.pop(),i)||!W(n)||c&&f(n[b])&&!p(n)&&((a=n[c])&&(n[c]=null),v.event.triggered=b,t.isPropagationStopped()&&g.addEventListener(b,oe),n[b](),t.isPropagationStopped()&&g.removeEventListener(b,oe),v.event.triggered=void 0,a&&(n[c]=a)),t.result}},simulate:function(t,e,i){var n=v.extend(new v.Event,i,{type:t,isSimulated:!0});v.event.trigger(n,null,e)}}),v.fn.extend({trigger:function(t,e){return this.each((function(){v.event.trigger(t,e,this)}))},triggerHandler:function(t,e){var i=this[0];if(i)return v.event.trigger(t,e,i,!0)}}),d.focusin||v.each({focus:"focusin",blur:"focusout"},(function(t,e){var i=function(t){v.event.simulate(e,t.target,v.event.fix(t))};v.event.special[e]={setup:function(){var n=this.ownerDocument||this,r=Z.access(n,e);r||n.addEventListener(t,i,!0),Z.access(n,e,(r||0)+1)},teardown:function(){var n=this.ownerDocument||this,r=Z.access(n,e)-1;r?Z.access(n,e,r):(n.removeEventListener(t,i,!0),Z.remove(n,e))}}}));var ae,le=/\[\]$/,he=/\r?\n/g,ce=/^(?:submit|button|image|reset|file)$/i,ue=/^(?:input|select|textarea|keygen)/i;function de(t,e,i,n){var r;if(Array.isArray(e))v.each(e,(function(e,r){i||le.test(t)?n(t,r):de(t+"["+("object"==typeof r&&null!=r?e:"")+"]",r,i,n)}));else if(i||"object"!==b(e))n(t,e);else for(r in e)de(t+"["+r+"]",e[r],i,n)}v.param=function(t,e){var i,n=[],r=function(t,e){var i=f(e)?e():e;n[n.length]=encodeURIComponent(t)+"="+encodeURIComponent(null==i?"":i)};if(Array.isArray(t)||t.jquery&&!v.isPlainObject(t))v.each(t,(function(){r(this.name,this.value)}));else for(i in t)de(i,t[i],e,r);return n.join("&")},v.fn.extend({serialize:function(){return v.param(this.serializeArray())},serializeArray:function(){return this.map((function(){var t=v.prop(this,"elements");return t?v.makeArray(t):this})).filter((function(){var t=this.type;return this.name&&!v(this).is(":disabled")&&ue.test(this.nodeName)&&!ce.test(t)&&(this.checked||!at.test(t))})).map((function(t,e){var i=v(this).val();return null==i?null:Array.isArray(i)?v.map(i,(function(t){return{name:e.name,value:t.replace(he,"\r\n")}})):{name:e.name,value:i.replace(he,"\r\n")}})).get()}}),v.fn.extend({wrapAll:function(t){var e;return this[0]&&(f(t)&&(t=t.call(this[0])),e=v(t,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&e.insertBefore(this[0]),e.map((function(){for(var t=this;t.firstElementChild;)t=t.firstElementChild;return t})).append(this)),this},wrapInner:function(t){return f(t)?this.each((function(e){v(this).wrapInner(t.call(this,e))})):this.each((function(){var e=v(this),i=e.contents();i.length?i.wrapAll(t):e.append(t)}))},wrap:function(t){var e=f(t);return this.each((function(i){v(this).wrapAll(e?t.call(this,i):t)}))},unwrap:function(t){return this.parent(t).not("body").each((function(){v(this).replaceWith(this.childNodes)})),this}}),v.expr.pseudos.hidden=function(t){return!v.expr.pseudos.visible(t)},v.expr.pseudos.visible=function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)},d.createHTMLDocument=((ae=e.implementation.createHTMLDocument("").body).innerHTML="
",2===ae.childNodes.length),v.parseHTML=function(t,i,n){return"string"!=typeof t?[]:("boolean"==typeof i&&(n=i,i=!1),i||(d.createHTMLDocument?((r=(i=e.implementation.createHTMLDocument("")).createElement("base")).href=e.location.href,i.head.appendChild(r)):i=e),o=!n&&[],(s=T.exec(t))?[i.createElement(s[1])]:(s=pt([t],i,o),o&&o.length&&v(o).remove(),v.merge([],s.childNodes)));var r,s,o},v.offset={setOffset:function(t,e,i){var n,r,s,o,a,l,h=v.css(t,"position"),c=v(t),u={};"static"===h&&(t.style.position="relative"),a=c.offset(),s=v.css(t,"top"),l=v.css(t,"left"),("absolute"===h||"fixed"===h)&&(s+l).indexOf("auto")>-1?(o=(n=c.position()).top,r=n.left):(o=parseFloat(s)||0,r=parseFloat(l)||0),f(e)&&(e=e.call(t,i,v.extend({},a))),null!=e.top&&(u.top=e.top-a.top+o),null!=e.left&&(u.left=e.left-a.left+r),"using"in e?e.using.call(t,u):c.css(u)}},v.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each((function(e){v.offset.setOffset(this,t,e)}));var e,i,n=this[0];return n?n.getClientRects().length?(e=n.getBoundingClientRect(),i=n.ownerDocument.defaultView,{top:e.top+i.pageYOffset,left:e.left+i.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var t,e,i,n=this[0],r={top:0,left:0};if("fixed"===v.css(n,"position"))e=n.getBoundingClientRect();else{for(e=this.offset(),i=n.ownerDocument,t=n.offsetParent||i.documentElement;t&&(t===i.body||t===i.documentElement)&&"static"===v.css(t,"position");)t=t.parentNode;t&&t!==n&&1===t.nodeType&&((r=v(t).offset()).top+=v.css(t,"borderTopWidth",!0),r.left+=v.css(t,"borderLeftWidth",!0))}return{top:e.top-r.top-v.css(n,"marginTop",!0),left:e.left-r.left-v.css(n,"marginLeft",!0)}}},offsetParent:function(){return this.map((function(){for(var t=this.offsetParent;t&&"static"===v.css(t,"position");)t=t.offsetParent;return t||gt}))}}),v.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},(function(t,e){var i="pageYOffset"===e;v.fn[t]=function(n){return V(this,(function(t,n,r){var s;if(p(t)?s=t:9===t.nodeType&&(s=t.defaultView),void 0===r)return s?s[e]:t[n];s?s.scrollTo(i?s.pageXOffset:r,i?r:s.pageYOffset):t[n]=r}),t,n,arguments.length)}})),v.each(["top","left"],(function(t,e){v.cssHooks[e]=Pt(d.pixelPosition,(function(t,i){if(i)return i=Dt(t,e),Nt.test(i)?v(t).position()[e]+"px":i}))})),v.each({Height:"height",Width:"width"},(function(t,e){v.each({padding:"inner"+t,content:e,"":"outer"+t},(function(i,n){v.fn[n]=function(r,s){var o=arguments.length&&(i||"boolean"!=typeof r),a=i||(!0===r||!0===s?"margin":"border");return V(this,(function(e,i,r){var s;return p(e)?0===n.indexOf("outer")?e["inner"+t]:e.document.documentElement["client"+t]:9===e.nodeType?(s=e.documentElement,Math.max(e.body["scroll"+t],s["scroll"+t],e.body["offset"+t],s["offset"+t],s["client"+t])):void 0===r?v.css(e,i,a):v.style(e,i,r,a)}),e,o?r:void 0,o)}}))})),v.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(t,e){v.fn[e]=function(t,i){return arguments.length>0?this.on(e,null,t,i):this.trigger(e)}})),v.fn.extend({hover:function(t,e){return this.mouseenter(t).mouseleave(e||t)}}),v.fn.extend({bind:function(t,e,i){return this.on(t,null,e,i)},unbind:function(t,e){return this.off(t,null,e)},delegate:function(t,e,i,n){return this.on(e,t,i,n)},undelegate:function(t,e,i){return 1===arguments.length?this.off(t,"**"):this.off(e,t||"**",i)}}),v.proxy=function(t,e){var i,r,s;if("string"==typeof e&&(i=t[e],e=t,t=i),f(t))return r=n.call(arguments,2),s=function(){return t.apply(e||this,r.concat(n.call(arguments)))},s.guid=t.guid=t.guid||v.guid++,s},v.holdReady=function(t){t?v.readyWait++:v.ready(!0)},v.isArray=Array.isArray,v.parseJSON=JSON.parse,v.nodeName=A,v.isFunction=f,v.isWindow=p,v.camelCase=q,v.type=b,v.now=Date.now,v.isNumeric=function(t){var e=v.type(t);return("number"===e||"string"===e)&&!isNaN(t-parseFloat(t))};const fe=v;function pe(t){return ge("div",t)}function ge(t,e){const i=document.createElement(t);return e&&(e.class&&i.classList.add(e.class),e.id&&(i.id=e.id),e.style&&ye(i,e.style)),i}function me(t){const e=getComputedStyle(t);"none"!==e.display&&(t._initialDisplay=e.display),t.style.display="none"}function be(t){if("none"===getComputedStyle(t).display){const e=t._initialDisplay||"block";t.style.display=e}}function ye(t,e){for(let i of Object.keys(e))t.style[i]=e[i]}let ve=(t,{clientX:e,clientY:i})=>{const{left:n,top:r,width:s,height:o}=t.getBoundingClientRect(),a=e-n,l=i-r;return{x:a,y:l,xNormalized:a/s,yNormalized:l/o,width:s,height:o}};function we(t,e){const{clientX:i,clientY:n}=t;return ve(e,{clientX:i,clientY:n})}var _e=Object.freeze({__proto__:null,applyStyle:ye,create:ge,div:pe,empty:function(t){for(;t.firstChild;)t.removeChild(t.firstChild)},guid:function(){return("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)},hide:me,hideAll:function(t){document.querySelectorAll(t).forEach((t=>{me(t)}))},offset:function(t){if(!t.getClientRects().length)return{top:0,left:0};const e=t.getBoundingClientRect(),i=t.ownerDocument.defaultView;return{top:e.top+i.pageYOffset,left:e.left+i.pageXOffset}},pageCoordinates:function(t){if(t.type.startsWith("touch")){const e=t.touches[0];return{x:e.pageX,y:e.pageY}}return{x:t.pageX,y:t.pageY}},relativeDOMBBox:(t,e)=>{const{x:i,y:n,width:r,height:s}=t.getBoundingClientRect(),{x:o,y:a,width:l,height:h}=e.getBoundingClientRect();return{x:o-i,y:a-n,width:l,height:h}},show:be,translateMouseCoordinates:we});const{entries:xe,setPrototypeOf:ke,isFrozen:Se,getPrototypeOf:Ce,getOwnPropertyDescriptor:Ae}=Object;let{freeze:Te,seal:Ie,create:Ee}=Object,{apply:Me,construct:Re}="undefined"!=typeof Reflect&&Reflect;Me||(Me=function(t,e,i){return t.apply(e,i)}),Te||(Te=function(t){return t}),Ie||(Ie=function(t){return t}),Re||(Re=function(t,e){return new t(...e)});const Le=$e(Array.prototype.forEach),Be=$e(Array.prototype.pop),Ne=$e(Array.prototype.push),Fe=$e(String.prototype.toLowerCase),Oe=$e(String.prototype.toString),De=$e(String.prototype.match),Pe=$e(String.prototype.replace),ze=$e(String.prototype.indexOf),Ue=$e(String.prototype.trim),Ve=$e(RegExp.prototype.test),He=(je=TypeError,function(){for(var t=arguments.length,e=new Array(t),i=0;i1?i-1:0),r=1;r/gm),ai=Ie(/\${[\w\W]*}/gm),li=Ie(/^data-[\-\w.\u00B7-\uFFFF]/),hi=Ie(/^aria-[\-\w]+$/),ci=Ie(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ui=Ie(/^(?:\w+script|data):/i),di=Ie(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),fi=Ie(/^html$/i);var pi=Object.freeze({__proto__:null,MUSTACHE_EXPR:si,ERB_EXPR:oi,TMPLIT_EXPR:ai,DATA_ATTR:li,ARIA_ATTR:hi,IS_ALLOWED_URI:ci,IS_SCRIPT_OR_DATA:ui,ATTR_WHITESPACE:di,DOCTYPE_NAME:fi});const gi=()=>"undefined"==typeof window?null:window;var mi=function t(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:gi();const i=e=>t(e);if(i.version="3.0.5",i.removed=[],!e||!e.document||9!==e.document.nodeType)return i.isSupported=!1,i;const n=e.document,r=n.currentScript;let{document:s}=e;const{DocumentFragment:o,HTMLTemplateElement:a,Node:l,Element:h,NodeFilter:c,NamedNodeMap:u=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:f,trustedTypes:p}=e,g=h.prototype,m=Ge(g,"cloneNode"),b=Ge(g,"nextSibling"),y=Ge(g,"childNodes"),v=Ge(g,"parentNode");if("function"==typeof a){const t=s.createElement("template");t.content&&t.content.ownerDocument&&(s=t.content.ownerDocument)}let w,_="";const{implementation:x,createNodeIterator:k,createDocumentFragment:S,getElementsByTagName:C}=s,{importNode:A}=n;let T={};i.isSupported="function"==typeof xe&&"function"==typeof v&&x&&void 0!==x.createHTMLDocument;const{MUSTACHE_EXPR:I,ERB_EXPR:E,TMPLIT_EXPR:M,DATA_ATTR:R,ARIA_ATTR:L,IS_SCRIPT_OR_DATA:B,ATTR_WHITESPACE:N}=pi;let{IS_ALLOWED_URI:F}=pi,O=null;const D=qe({},[...Ze,...Ye,...Qe,...Ke,...ti]);let P=null;const z=qe({},[...ei,...ii,...ni,...ri]);let U=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),V=null,H=null,j=!0,$=!0,q=!1,W=!0,G=!1,Z=!1,Y=!1,Q=!1,X=!1,K=!1,J=!1,tt=!0,et=!1,it=!0,nt=!1,rt={},st=null;const ot=qe({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let at=null;const lt=qe({},["audio","video","img","source","image","track"]);let ht=null;const ct=qe({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ut="http://www.w3.org/1998/Math/MathML",dt="http://www.w3.org/2000/svg",ft="http://www.w3.org/1999/xhtml";let pt=ft,gt=!1,mt=null;const bt=qe({},[ut,dt,ft],Oe);let yt;const vt=["application/xhtml+xml","text/html"];let wt,_t=null;const xt=s.createElement("form"),kt=function(t){return t instanceof RegExp||t instanceof Function},St=function(t){if(!_t||_t!==t){if(t&&"object"==typeof t||(t={}),t=We(t),yt=yt=-1===vt.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,wt="application/xhtml+xml"===yt?Oe:Fe,O="ALLOWED_TAGS"in t?qe({},t.ALLOWED_TAGS,wt):D,P="ALLOWED_ATTR"in t?qe({},t.ALLOWED_ATTR,wt):z,mt="ALLOWED_NAMESPACES"in t?qe({},t.ALLOWED_NAMESPACES,Oe):bt,ht="ADD_URI_SAFE_ATTR"in t?qe(We(ct),t.ADD_URI_SAFE_ATTR,wt):ct,at="ADD_DATA_URI_TAGS"in t?qe(We(lt),t.ADD_DATA_URI_TAGS,wt):lt,st="FORBID_CONTENTS"in t?qe({},t.FORBID_CONTENTS,wt):ot,V="FORBID_TAGS"in t?qe({},t.FORBID_TAGS,wt):{},H="FORBID_ATTR"in t?qe({},t.FORBID_ATTR,wt):{},rt="USE_PROFILES"in t&&t.USE_PROFILES,j=!1!==t.ALLOW_ARIA_ATTR,$=!1!==t.ALLOW_DATA_ATTR,q=t.ALLOW_UNKNOWN_PROTOCOLS||!1,W=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,G=t.SAFE_FOR_TEMPLATES||!1,Z=t.WHOLE_DOCUMENT||!1,X=t.RETURN_DOM||!1,K=t.RETURN_DOM_FRAGMENT||!1,J=t.RETURN_TRUSTED_TYPE||!1,Q=t.FORCE_BODY||!1,tt=!1!==t.SANITIZE_DOM,et=t.SANITIZE_NAMED_PROPS||!1,it=!1!==t.KEEP_CONTENT,nt=t.IN_PLACE||!1,F=t.ALLOWED_URI_REGEXP||ci,pt=t.NAMESPACE||ft,U=t.CUSTOM_ELEMENT_HANDLING||{},t.CUSTOM_ELEMENT_HANDLING&&kt(t.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(U.tagNameCheck=t.CUSTOM_ELEMENT_HANDLING.tagNameCheck),t.CUSTOM_ELEMENT_HANDLING&&kt(t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(U.attributeNameCheck=t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),t.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(U.allowCustomizedBuiltInElements=t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),G&&($=!1),K&&(X=!0),rt&&(O=qe({},[...ti]),P=[],!0===rt.html&&(qe(O,Ze),qe(P,ei)),!0===rt.svg&&(qe(O,Ye),qe(P,ii),qe(P,ri)),!0===rt.svgFilters&&(qe(O,Qe),qe(P,ii),qe(P,ri)),!0===rt.mathMl&&(qe(O,Ke),qe(P,ni),qe(P,ri))),t.ADD_TAGS&&(O===D&&(O=We(O)),qe(O,t.ADD_TAGS,wt)),t.ADD_ATTR&&(P===z&&(P=We(P)),qe(P,t.ADD_ATTR,wt)),t.ADD_URI_SAFE_ATTR&&qe(ht,t.ADD_URI_SAFE_ATTR,wt),t.FORBID_CONTENTS&&(st===ot&&(st=We(st)),qe(st,t.FORBID_CONTENTS,wt)),it&&(O["#text"]=!0),Z&&qe(O,["html","head","body"]),O.table&&(qe(O,["tbody"]),delete V.tbody),t.TRUSTED_TYPES_POLICY){if("function"!=typeof t.TRUSTED_TYPES_POLICY.createHTML)throw He('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof t.TRUSTED_TYPES_POLICY.createScriptURL)throw He('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');w=t.TRUSTED_TYPES_POLICY,_=w.createHTML("")}else void 0===w&&(w=function(t,e){if("object"!=typeof t||"function"!=typeof t.createPolicy)return null;let i=null;const n="data-tt-policy-suffix";e&&e.hasAttribute(n)&&(i=e.getAttribute(n));const r="dompurify"+(i?"#"+i:"");try{return t.createPolicy(r,{createHTML:t=>t,createScriptURL:t=>t})}catch(t){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(p,r)),null!==w&&"string"==typeof _&&(_=w.createHTML(""));Te&&Te(t),_t=t}},Ct=qe({},["mi","mo","mn","ms","mtext"]),At=qe({},["foreignobject","desc","title","annotation-xml"]),Tt=qe({},["title","style","font","a","script"]),It=qe({},Ye);qe(It,Qe),qe(It,Xe);const Et=qe({},Ke);qe(Et,Je);const Mt=function(t){Ne(i.removed,{element:t});try{t.parentNode.removeChild(t)}catch(e){t.remove()}},Rt=function(t,e){try{Ne(i.removed,{attribute:e.getAttributeNode(t),from:e})}catch(t){Ne(i.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t&&!P[t])if(X||K)try{Mt(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},Lt=function(t){let e,i;if(Q)t=""+t;else{const e=De(t,/^[\r\n\t ]+/);i=e&&e[0]}"application/xhtml+xml"===yt&&pt===ft&&(t=''+t+"");const n=w?w.createHTML(t):t;if(pt===ft)try{e=(new f).parseFromString(n,yt)}catch(t){}if(!e||!e.documentElement){e=x.createDocument(pt,"template",null);try{e.documentElement.innerHTML=gt?_:n}catch(t){}}const r=e.body||e.documentElement;return t&&i&&r.insertBefore(s.createTextNode(i),r.childNodes[0]||null),pt===ft?C.call(e,Z?"html":"body")[0]:Z?e.documentElement:r},Bt=function(t){return k.call(t.ownerDocument||t,t,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT,null,!1)},Nt=function(t){return"object"==typeof l?t instanceof l:t&&"object"==typeof t&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName},Ft=function(t,e,n){T[t]&&Le(T[t],(t=>{t.call(i,e,n,_t)}))},Ot=function(t){let e;if(Ft("beforeSanitizeElements",t,null),(n=t)instanceof d&&("string"!=typeof n.nodeName||"string"!=typeof n.textContent||"function"!=typeof n.removeChild||!(n.attributes instanceof u)||"function"!=typeof n.removeAttribute||"function"!=typeof n.setAttribute||"string"!=typeof n.namespaceURI||"function"!=typeof n.insertBefore||"function"!=typeof n.hasChildNodes))return Mt(t),!0;var n;const r=wt(t.nodeName);if(Ft("uponSanitizeElement",t,{tagName:r,allowedTags:O}),t.hasChildNodes()&&!Nt(t.firstElementChild)&&(!Nt(t.content)||!Nt(t.content.firstElementChild))&&Ve(/<[/\w]/g,t.innerHTML)&&Ve(/<[/\w]/g,t.textContent))return Mt(t),!0;if(!O[r]||V[r]){if(!V[r]&&Pt(r)){if(U.tagNameCheck instanceof RegExp&&Ve(U.tagNameCheck,r))return!1;if(U.tagNameCheck instanceof Function&&U.tagNameCheck(r))return!1}if(it&&!st[r]){const e=v(t)||t.parentNode,i=y(t)||t.childNodes;if(i&&e)for(let n=i.length-1;n>=0;--n)e.insertBefore(m(i[n],!0),b(t))}return Mt(t),!0}return t instanceof h&&!function(t){let e=v(t);e&&e.tagName||(e={namespaceURI:pt,tagName:"template"});const i=Fe(t.tagName),n=Fe(e.tagName);return!!mt[t.namespaceURI]&&(t.namespaceURI===dt?e.namespaceURI===ft?"svg"===i:e.namespaceURI===ut?"svg"===i&&("annotation-xml"===n||Ct[n]):Boolean(It[i]):t.namespaceURI===ut?e.namespaceURI===ft?"math"===i:e.namespaceURI===dt?"math"===i&&At[n]:Boolean(Et[i]):t.namespaceURI===ft?!(e.namespaceURI===dt&&!At[n])&&!(e.namespaceURI===ut&&!Ct[n])&&!Et[i]&&(Tt[i]||!It[i]):!("application/xhtml+xml"!==yt||!mt[t.namespaceURI]))}(t)?(Mt(t),!0):"noscript"!==r&&"noembed"!==r&&"noframes"!==r||!Ve(/<\/no(script|embed|frames)/i,t.innerHTML)?(G&&3===t.nodeType&&(e=t.textContent,e=Pe(e,I," "),e=Pe(e,E," "),e=Pe(e,M," "),t.textContent!==e&&(Ne(i.removed,{element:t.cloneNode()}),t.textContent=e)),Ft("afterSanitizeElements",t,null),!1):(Mt(t),!0)},Dt=function(t,e,i){if(tt&&("id"===e||"name"===e)&&(i in s||i in xt))return!1;if($&&!H[e]&&Ve(R,e));else if(j&&Ve(L,e));else if(!P[e]||H[e]){if(!(Pt(t)&&(U.tagNameCheck instanceof RegExp&&Ve(U.tagNameCheck,t)||U.tagNameCheck instanceof Function&&U.tagNameCheck(t))&&(U.attributeNameCheck instanceof RegExp&&Ve(U.attributeNameCheck,e)||U.attributeNameCheck instanceof Function&&U.attributeNameCheck(e))||"is"===e&&U.allowCustomizedBuiltInElements&&(U.tagNameCheck instanceof RegExp&&Ve(U.tagNameCheck,i)||U.tagNameCheck instanceof Function&&U.tagNameCheck(i))))return!1}else if(ht[e]);else if(Ve(F,Pe(i,N,"")));else if("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==ze(i,"data:")||!at[t])if(q&&!Ve(B,Pe(i,N,"")));else if(i)return!1;return!0},Pt=function(t){return t.indexOf("-")>0},zt=function(t){let e,n,r,s;Ft("beforeSanitizeAttributes",t,null);const{attributes:o}=t;if(!o)return;const a={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:P};for(s=o.length;s--;){e=o[s];const{name:l,namespaceURI:h}=e;if(n="value"===l?e.value:Ue(e.value),r=wt(l),a.attrName=r,a.attrValue=n,a.keepAttr=!0,a.forceKeepAttr=void 0,Ft("uponSanitizeAttribute",t,a),n=a.attrValue,a.forceKeepAttr)continue;if(Rt(l,t),!a.keepAttr)continue;if(!W&&Ve(/\/>/i,n)){Rt(l,t);continue}G&&(n=Pe(n,I," "),n=Pe(n,E," "),n=Pe(n,M," "));const c=wt(t.nodeName);if(Dt(c,r,n)){if(!et||"id"!==r&&"name"!==r||(Rt(l,t),n="user-content-"+n),w&&"object"==typeof p&&"function"==typeof p.getAttributeType)if(h);else switch(p.getAttributeType(c,r)){case"TrustedHTML":n=w.createHTML(n);break;case"TrustedScriptURL":n=w.createScriptURL(n)}try{h?t.setAttributeNS(h,l,n):t.setAttribute(l,n),Be(i.removed)}catch(t){}}}Ft("afterSanitizeAttributes",t,null)},Ut=function t(e){let i;const n=Bt(e);for(Ft("beforeSanitizeShadowDOM",e,null);i=n.nextNode();)Ft("uponSanitizeShadowNode",i,null),Ot(i)||(i.content instanceof o&&t(i.content),zt(i));Ft("afterSanitizeShadowDOM",e,null)};return i.sanitize=function(t){let e,r,s,a,h=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(gt=!t,gt&&(t="\x3c!--\x3e"),"string"!=typeof t&&!Nt(t)){if("function"!=typeof t.toString)throw He("toString is not a function");if("string"!=typeof(t=t.toString()))throw He("dirty is not a string, aborting")}if(!i.isSupported)return t;if(Y||St(h),i.removed=[],"string"==typeof t&&(nt=!1),nt){if(t.nodeName){const e=wt(t.nodeName);if(!O[e]||V[e])throw He("root node is forbidden and cannot be sanitized in-place")}}else if(t instanceof l)e=Lt("\x3c!----\x3e"),r=e.ownerDocument.importNode(t,!0),1===r.nodeType&&"BODY"===r.nodeName||"HTML"===r.nodeName?e=r:e.appendChild(r);else{if(!X&&!G&&!Z&&-1===t.indexOf("<"))return w&&J?w.createHTML(t):t;if(e=Lt(t),!e)return X?null:J?_:""}e&&Q&&Mt(e.firstChild);const c=Bt(nt?t:e);for(;s=c.nextNode();)Ot(s)||(s.content instanceof o&&Ut(s.content),zt(s));if(nt)return t;if(X){if(K)for(a=S.call(e.ownerDocument);e.firstChild;)a.appendChild(e.firstChild);else a=e;return(P.shadowroot||P.shadowrootmode)&&(a=A.call(n,a,!0)),a}let u=Z?e.outerHTML:e.innerHTML;return Z&&O["!doctype"]&&e.ownerDocument&&e.ownerDocument.doctype&&e.ownerDocument.doctype.name&&Ve(fi,e.ownerDocument.doctype.name)&&(u="\n"+u),G&&(u=Pe(u,I," "),u=Pe(u,E," "),u=Pe(u,M," ")),w&&J?w.createHTML(u):u},i.setConfig=function(t){St(t),Y=!0},i.clearConfig=function(){_t=null,Y=!1},i.isValidAttribute=function(t,e,i){_t||St({});const n=wt(t),r=wt(e);return Dt(n,r,i)},i.addHook=function(t,e){"function"==typeof e&&(T[t]=T[t]||[],Ne(T[t],e))},i.removeHook=function(t){if(T[t])return Be(T[t])},i.removeHooks=function(t){T[t]&&(T[t]=[])},i.removeAllHooks=function(){T={}},i}();function bi(t,e){const i=pe({class:"igv-ui-trackgear-popover-check-container"}),n=vi("check",!0===e?"#444":"transparent");n.style.borderColor="gray",n.style.borderWidth="1px",n.style.borderStyle="solid",i.appendChild(n);let r=pe();return r.textContent=t,i.appendChild(r),i}function yi(t,e){return vi(t,e)}function vi(t,e){e=e||"currentColor";let i=wi[t];i||(console.error(`No icon named: ${t}`),i=wi.question);const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttributeNS(null,"viewBox","0 0 "+i[0]+" "+i[1]);const r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttributeNS(null,"fill",e),r.setAttributeNS(null,"d",i[4]),n.appendChild(r),n}const wi={check:[512,512,[],"f00c","M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"],cog:[512,512,[],"f013","M444.788 291.1l42.616 24.599c4.867 2.809 7.126 8.618 5.459 13.985-11.07 35.642-29.97 67.842-54.689 94.586a12.016 12.016 0 0 1-14.832 2.254l-42.584-24.595a191.577 191.577 0 0 1-60.759 35.13v49.182a12.01 12.01 0 0 1-9.377 11.718c-34.956 7.85-72.499 8.256-109.219.007-5.49-1.233-9.403-6.096-9.403-11.723v-49.184a191.555 191.555 0 0 1-60.759-35.13l-42.584 24.595a12.016 12.016 0 0 1-14.832-2.254c-24.718-26.744-43.619-58.944-54.689-94.586-1.667-5.366.592-11.175 5.459-13.985L67.212 291.1a193.48 193.48 0 0 1 0-70.199l-42.616-24.599c-4.867-2.809-7.126-8.618-5.459-13.985 11.07-35.642 29.97-67.842 54.689-94.586a12.016 12.016 0 0 1 14.832-2.254l42.584 24.595a191.577 191.577 0 0 1 60.759-35.13V25.759a12.01 12.01 0 0 1 9.377-11.718c34.956-7.85 72.499-8.256 109.219-.007 5.49 1.233 9.403 6.096 9.403 11.723v49.184a191.555 191.555 0 0 1 60.759 35.13l42.584-24.595a12.016 12.016 0 0 1 14.832 2.254c24.718 26.744 43.619 58.944 54.689 94.586 1.667 5.366-.592 11.175-5.459 13.985L444.788 220.9a193.485 193.485 0 0 1 0 70.2zM336 256c0-44.112-35.888-80-80-80s-80 35.888-80 80 35.888 80 80 80 80-35.888 80-80z"],exclamation:[192,512,[],"f12a","M176 432c0 44.112-35.888 80-80 80s-80-35.888-80-80 35.888-80 80-80 80 35.888 80 80zM25.26 25.199l13.6 272C39.499 309.972 50.041 320 62.83 320h66.34c12.789 0 23.331-10.028 23.97-22.801l13.6-272C167.425 11.49 156.496 0 142.77 0H49.23C35.504 0 24.575 11.49 25.26 25.199z"],"exclamation-circle":[512,512,[],"f06a","M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"],"exclamation-triangle":[576,512,[],"f071","M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"],minus:[448,512,[],"f068","M424 318.2c13.3 0 24-10.7 24-24v-76.4c0-13.3-10.7-24-24-24H24c-13.3 0-24 10.7-24 24v76.4c0 13.3 10.7 24 24 24h400z"],"minus-circle":[512,512,[],"f056","M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zM124 296c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h264c6.6 0 12 5.4 12 12v56c0 6.6-5.4 12-12 12H124z"],"minus-square":[448,512,[],"f146","M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zM92 296c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h264c6.6 0 12 5.4 12 12v56c0 6.6-5.4 12-12 12H92z"],plus:[448,512,[],"f067","M448 294.2v-76.4c0-13.3-10.7-24-24-24H286.2V56c0-13.3-10.7-24-24-24h-76.4c-13.3 0-24 10.7-24 24v137.8H24c-13.3 0-24 10.7-24 24v76.4c0 13.3 10.7 24 24 24h137.8V456c0 13.3 10.7 24 24 24h76.4c13.3 0 24-10.7 24-24V318.2H424c13.3 0 24-10.7 24-24z"],"plus-circle":[512,512,[],"f055","M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm144 276c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92h-92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z"],"plus-square":[448,512,[],"f0fe","M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zm-32 252c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92H92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z"],question:[384,512,[],"f128","M202.021 0C122.202 0 70.503 32.703 29.914 91.026c-7.363 10.58-5.093 25.086 5.178 32.874l43.138 32.709c10.373 7.865 25.132 6.026 33.253-4.148 25.049-31.381 43.63-49.449 82.757-49.449 30.764 0 68.816 19.799 68.816 49.631 0 22.552-18.617 34.134-48.993 51.164-35.423 19.86-82.299 44.576-82.299 106.405V320c0 13.255 10.745 24 24 24h72.471c13.255 0 24-10.745 24-24v-5.773c0-42.86 125.268-44.645 125.268-160.627C377.504 66.256 286.902 0 202.021 0zM192 373.459c-38.196 0-69.271 31.075-69.271 69.271 0 38.195 31.075 69.27 69.271 69.27s69.271-31.075 69.271-69.271-31.075-69.27-69.271-69.27z"],save:[448,512,[],"f0c7","M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z"],search:[512,512,[],"f002","M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z"],share:[512,512,[],"f064","M503.691 189.836L327.687 37.851C312.281 24.546 288 35.347 288 56.015v80.053C127.371 137.907 0 170.1 0 322.326c0 61.441 39.581 122.309 83.333 154.132 13.653 9.931 33.111-2.533 28.077-18.631C66.066 312.814 132.917 274.316 288 272.085V360c0 20.7 24.3 31.453 39.687 18.164l176.004-152c11.071-9.562 11.086-26.753 0-36.328z"],spinner:[512,512,[],"f110","M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z"],square:[448,512,[],"f0c8","M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48z"],"square-full":[512,512,[],"f45c","M512 512H0V0h512v512z"],times:[384,512,[],"f00d","M323.1 441l53.9-53.9c9.4-9.4 9.4-24.5 0-33.9L279.8 256l97.2-97.2c9.4-9.4 9.4-24.5 0-33.9L323.1 71c-9.4-9.4-24.5-9.4-33.9 0L192 168.2 94.8 71c-9.4-9.4-24.5-9.4-33.9 0L7 124.9c-9.4 9.4-9.4 24.5 0 33.9l97.2 97.2L7 353.2c-9.4 9.4-9.4 24.5 0 33.9L60.9 441c9.4 9.4 24.5 9.4 33.9 0l97.2-97.2 97.2 97.2c9.3 9.3 24.5 9.3 33.9 0z"],"times-circle":[512,512,[],"f057","M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z"],wrench:[512,512,[],"f0ad","M481.156 200c9.3 0 15.12 10.155 10.325 18.124C466.295 259.992 420.419 288 368 288c-79.222 0-143.501-63.974-143.997-143.079C223.505 65.469 288.548-.001 368.002 0c52.362.001 98.196 27.949 123.4 69.743C496.24 77.766 490.523 88 481.154 88H376l-40 56 40 56h105.156zm-171.649 93.003L109.255 493.255c-24.994 24.993-65.515 24.994-90.51 0-24.993-24.994-24.993-65.516 0-90.51L218.991 202.5c16.16 41.197 49.303 74.335 90.516 90.503zM104 432c0-13.255-10.745-24-24-24s-24 10.745-24 24 10.745 24 24 24 24-10.745 24-24z"]};var _i=Object.freeze({__proto__:null,createCheckbox:bi,createIcon:yi});function xi(t,e){var i=document.createElement("div");t.appendChild(i),i.appendChild(yi("times")),i.addEventListener("click",(function(t){t.preventDefault(),t.stopPropagation(),e()}))}var ki=Object.freeze({__proto__:null,attachDialogCloseHandlerWithParent:xi});let Si;function Ci(t,e,i){e.addEventListener("mousedown",function(t){t.stopPropagation(),t.preventDefault();const e=Ai.bind(this),n=Ti.bind(this),r=getComputedStyle(this);Si={constraint:i,dragFunction:e,dragEndFunction:n,screenX:t.screenX,screenY:t.screenY,top:parseInt(r.top.replace("px","")),left:parseInt(r.left.replace("px",""))},document.addEventListener("mousemove",e),document.addEventListener("mouseup",n),document.addEventListener("mouseleave",n),document.addEventListener("mouseexit",n)}.bind(t))}function Ai(t){if(!Si)return void console.error("No drag data!");t.stopPropagation(),t.preventDefault();const e=t.screenX-Si.screenX,i=t.screenY-Si.screenY,n=Si.left+e,r=Si.constraint?Math.max(Si.constraint.minY,Si.top+i):Si.top+i;this.style.left=`${n}px`,this.style.top=`${r}px`}function Ti(t){if(!Si)return void console.error("No drag data!");t.stopPropagation(),t.preventDefault();const e=Si.dragFunction,i=Si.dragEndFunction;document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",i),document.removeEventListener("mouseleave",i),document.removeEventListener("mouseexit",i),Si=void 0}const Ii={401:"Access unauthorized",403:"Access forbidden",404:"Not found"};class Ei{constructor(t,e){this.alertProps=Object.assign({shouldFocus:!0,preventScroll:!1},e),this.container=pe({class:"igv-ui-alert-dialog-container"}),t.appendChild(this.container),this.container.setAttribute("tabIndex","-1");const i=pe();this.container.appendChild(i),this.errorHeadline=pe(),i.appendChild(this.errorHeadline),this.errorHeadline.textContent="";let n=pe({class:"igv-ui-alert-dialog-body"});this.container.appendChild(n),this.body=pe({class:"igv-ui-alert-dialog-body-copy"}),n.appendChild(this.body);let r=pe();this.container.appendChild(r),this.ok=pe(),r.appendChild(this.ok),this.ok.textContent="OK";const s=()=>{"function"==typeof this.callback&&(this.callback("OK"),this.callback=void 0),this.body.innerHTML="",me(this.container)};this.ok.addEventListener("click",(t=>{t.stopPropagation(),s()})),this.container.addEventListener("keypress",(t=>{t.stopPropagation(),"Enter"===t.key&&s()})),Ci(this.container,i),me(this.container)}present(t,e){this.errorHeadline.textContent=t.message?"ERROR":"";let i=t.message||t;Ii.hasOwnProperty(i)&&(i=Ii[i]);const n=mi.sanitize(i);this.body.innerHTML=n,this.callback=e,be(this.container),this.alertProps.shouldFocus&&this.container.focus({preventScroll:this.alertProps.preventScroll})}}class Mi{constructor(t){this.parent=t,this.container=pe({class:"igv-ui-generic-dialog-container"}),t.appendChild(this.container);const e=pe({class:"igv-ui-generic-dialog-header"});this.container.appendChild(e),this.label=pe({class:"igv-ui-generic-dialog-one-liner"}),this.container.appendChild(this.label),this.label.text="Unlabeled",this.input_container=pe({class:"igv-ui-generic-dialog-input"}),this.container.appendChild(this.input_container),this.input=document.createElement("input"),this.input_container.appendChild(this.input);const i=pe({class:"igv-ui-generic-dialog-ok-cancel"});this.container.appendChild(i),this.ok=pe(),i.appendChild(this.ok),this.ok.textContent="OK",this.cancel=pe(),i.appendChild(this.cancel),this.cancel.textContent="Cancel",me(this.container),this.input.addEventListener("keyup",(t=>{13===t.keyCode&&("function"==typeof this.callback&&(this.callback(this.input.value),this.callback=void 0),this.input.value=void 0,me(this.container))})),this.ok.addEventListener("click",(()=>{"function"==typeof this.callback&&(this.callback(this.input.value),this.callback=void 0),this.input.value=void 0,me(this.container)}));const n=()=>{this.input.value="",me(this.container)};this.cancel.addEventListener("click",n),xi(e,n),Ci(this.container,e)}get value(){return mi.sanitize(this.input.value)}present(t,e){this.label.textContent=t.label,this.input.value=t.value,this.callback=t.callback||t.click,be(this.container),this.clampLocation(e.clientX,e.clientY)}clampLocation(t,e){const{width:i,height:n}=this.container.getBoundingClientRect(),r=window.innerHeight,s=window.innerWidth,o=Math.min(r-n,e),a=Math.min(s-i,t);this.container.style.left=`${a}px`,this.container.style.top=`${o}px`}}const Ri={licorice:"#000000",lead:"#1e1e1e",tungsten:"#3a3a3a",iron:"#545453",steel:"#6e6e6e",tin:"#878687",nickel:"#888787",aluminum:"#a09fa0",magnesium:"#b8b8b8",silver:"#d0d0d0",mercury:"#e8e8e8",snow:"#ffffff",cayenne:"#891100",mocha:"#894800",aspargus:"#888501",fern:"#458401",clover:"#028401",moss:"#018448",teal:"#008688",ocean:"#004a88",midnight:"#001888",eggplant:"#491a88",plum:"#891e88",maroon:"#891648",maraschino:"#ff2101",tangerine:"#ff8802",lemon:"#fffa03",lime:"#83f902",spring:"#05f802",seam_foam:"#03f987",turquoise:"#00fdff",aqua:"#008cff",blueberry:"#002eff",grape:"#8931ff",magenta:"#ff39ff",strawberry:"#ff2987",salmon:"#ff726e",cantaloupe:"#ffce6e",banana:"#fffb6d",honeydew:"#cefa6e",flora:"#68f96e",spindrift:"#68fbd0",ice:"#68fdff",sky:"#6acfff",orchid:"#6e76ff",lavender:"#d278ff",bubblegum:"#ff7aff",carnation:"#ff7fd3"};class Li{constructor({parent:t,top:e,left:i,width:n,height:r,border:s,closeHandler:o}){let a=pe({class:"igv-ui-generic-container"});t.appendChild(a),me(a),this.container=a,void 0!==e&&(this.container.style.top=`${e}px`),void 0!==i&&(this.container.style.left=`${i}px`),void 0!==n&&(this.container.style.width=`${n}px`),void 0!==r&&(this.container.style.height=`${r}px`),s&&(this.container.style.border=s);const l=pe();this.container.appendChild(l),xi(l,(t=>{me(this.container),"function"==typeof o&&o(t)})),Ci(this.container,l)}show(){be(this.container)}hide(){me(this.container)}dispose(){this.container.parent&&this.container.parent.removeChild(this.container)}}class Bi extends Li{constructor({parent:t,top:e,left:i,width:n,height:r,defaultColors:s,colorHandler:o}){super({parent:t,top:e,left:i,width:n,height:r,border:"1px solid gray"}),Ni(this.container,o,s)}}const Ni=(t,e,i)=>{const n=Object.values(Ri);for(let i of n){const n=pe({class:"igv-ui-color-swatch"});t.appendChild(n),Fi(n,i,e)}if(i)for(let n of i){const i=pe({class:"igv-ui-color-swatch"});t.appendChild(i),Fi(i,n,e)}},Fi=(t,e,i)=>{t.style.backgroundColor=e,t.addEventListener("mouseenter",(i=>t.style.borderColor=e)),t.addEventListener("mouseleave",(e=>t.style.borderColor="white")),t.addEventListener("click",(t=>{t.stopPropagation(),i(e)})),t.addEventListener("touchend",(t=>{t.stopPropagation(),i(e)}))};class Oi{constructor(t,e){this.parent=t,this.popover=pe({class:"igv-ui-popover"}),t.appendChild(this.popover);const i=pe();this.popover.appendChild(i);const n=pe();i.appendChild(n),e&&(n.textContent=e),xi(i,(()=>this.hide())),Ci(this.popover,i),this.popoverContent=pe(),this.popover.appendChild(this.popoverContent),this.popover.style.display="none"}presentContentWithEvent(t,e){this.popover.style.display="block",this.popoverContent.innerHTML=e,Di(t,this.popover,this.popoverContent)}presentMenu(t,e){if(0===e.length)return;this.popover.style.display="block";const i=function(t,e){const i=t.map((function(t,i){let n;if("string"==typeof t)n=pe(),n.innerHTML=t;else if("Node"==typeof t)n=t;else{if("function"==typeof t.init&&t.init(),"checkbox"===t.type)n=bi("Show all bases",t.value);else if("color"===t.type){const r=new Bi({parent:e.parentElement,width:364,colorHandler:e=>t.click(e)});n=pe(),"string"==typeof t.label&&(n.innerHTML=t.label);const s=t=>{r.show(),me(e),t.preventDefault(),t.stopPropagation()};n.addEventListener("click",s),n.addEventListener("touchend",s),n.addEventListener("mouseup",(function(t){t.preventDefault(),t.stopPropagation()}))}else n=pe(),"string"==typeof t.label&&(n.innerHTML=t.label);if(t.click&&"color"!==t.type){function o(i){t.click(),me(e),i.preventDefault(),i.stopPropagation()}n.addEventListener("click",o),n.addEventListener("touchend",o),n.addEventListener("mouseup",(function(t){t.preventDefault(),t.stopPropagation()}))}}return{object:n,init:t.init}}));return i}(e,this.popover);for(let t of i)this.popoverContent.appendChild(t.object);Di(t,this.popover,this.popoverContent)}hide(){this.popover.style.display="none",this.dispose()}dispose(){this.popover&&this.popover.parentNode.removeChild(this.popover);const t=Object.keys(this);for(let e of t)this[e]=void 0}}function Di(t,e,i){const{x:n,y:r,width:s}=we(t,e.parentNode);e.style.top=`${r}px`;const{width:o}=e.getBoundingClientRect(),a=n+o,l=a-s;e.style.left=`${a>s?n-l:n}px`,i.style.maxWidth=`${Math.min(o,s)}px`}class Pi extends Li{constructor({parent:t,width:e}){super({parent:t,width:e,border:"1px solid gray"})}configure(t,e){this.colorHandlers=e,this.setActiveColorHandler("color"),this.createSwatches(t)}setActiveColorHandler(t){this.activeColorHandler=this.colorHandlers[t]}createSwatches(t){this.container.querySelectorAll(".igv-ui-color-swatch").forEach((t=>t.remove()));const e=Object.values(Ri);for(let t of e){const e=pe({class:"igv-ui-color-swatch"});this.container.appendChild(e),this.decorateSwatch(e,t)}if(t)for(let e of t){const t=pe({class:"igv-ui-color-swatch"});this.container.appendChild(t),this.decorateSwatch(t,e)}}decorateSwatch(t,e){t.style.backgroundColor=e,t.addEventListener("mouseenter",(()=>t.style.borderColor=e)),t.addEventListener("mouseleave",(()=>t.style.borderColor="white")),t.addEventListener("click",(t=>{t.stopPropagation(),this.activeColorHandler(e)})),t.addEventListener("touchend",(t=>{t.stopPropagation(),this.activeColorHandler(e)}))}}if("undefined"!=typeof document){function py(t){for(let e of document.styleSheets)if(e=e.href?e.href.replace(/^.*[\\\/]/,""):"",e===t)return!0;return!1}py("igv-ui.css")||function(){const t=document.createElement("style");t.setAttribute("type","text/css"),t.setAttribute("title","igv-ui.css"),t.innerHTML='.igv-ui-popover {\n cursor: default;\n position: absolute;\n z-index: 2048;\n border-color: #7F7F7F;\n border-radius: 4px;\n border-style: solid;\n border-width: 1px;\n font-family: "Open Sans", sans-serif;\n font-size: small;\n background-color: white;\n}\n.igv-ui-popover > div:first-child {\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n width: 100%;\n height: 24px;\n cursor: move;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-color: #7F7F7F;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n}\n.igv-ui-popover > div:first-child > div:first-child {\n margin-left: 4px;\n}\n.igv-ui-popover > div:first-child > div:last-child {\n margin-right: 4px;\n height: 12px;\n width: 12px;\n color: #7F7F7F;\n}\n.igv-ui-popover > div:first-child > div:last-child:hover {\n cursor: pointer;\n color: #444;\n}\n.igv-ui-popover > div:last-child {\n overflow-y: auto;\n overflow-x: hidden;\n max-height: 400px;\n max-width: 800px;\n background-color: white;\n}\n.igv-ui-popover > div:last-child > div {\n user-select: all;\n margin-left: 4px;\n margin-right: 4px;\n min-width: 220px;\n overflow-x: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.igv-ui-popover > div:last-child > div > span {\n font-weight: bolder;\n}\n.igv-ui-popover > div:last-child hr {\n width: 100%;\n}\n\n.igv-ui-alert-dialog-container {\n box-sizing: content-box;\n position: absolute;\n z-index: 2048;\n top: 50%;\n left: 50%;\n width: 400px;\n height: 200px;\n border-color: #7F7F7F;\n border-radius: 4px;\n border-style: solid;\n border-width: thin;\n outline: none;\n font-family: "Open Sans", sans-serif;\n font-size: 15px;\n font-weight: 400;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n}\n.igv-ui-alert-dialog-container > div:first-child {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n width: 100%;\n height: 24px;\n cursor: move;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-color: #7F7F7F;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n}\n.igv-ui-alert-dialog-container > div:first-child div:first-child {\n padding-left: 8px;\n}\n.igv-ui-alert-dialog-container .igv-ui-alert-dialog-body {\n -webkit-user-select: text;\n -moz-user-select: text;\n -ms-user-select: text;\n user-select: text;\n color: #373737;\n width: 100%;\n height: calc(100% - 24px - 64px);\n overflow-y: scroll;\n}\n.igv-ui-alert-dialog-container .igv-ui-alert-dialog-body .igv-ui-alert-dialog-body-copy {\n margin: 16px;\n width: auto;\n height: auto;\n overflow-wrap: break-word;\n word-break: break-word;\n background-color: white;\n border: unset;\n}\n.igv-ui-alert-dialog-container > div:last-child {\n width: 100%;\n margin-bottom: 10px;\n background-color: white;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: center;\n align-items: center;\n}\n.igv-ui-alert-dialog-container > div:last-child div {\n margin: unset;\n width: 40px;\n height: 30px;\n line-height: 30px;\n text-align: center;\n color: white;\n font-family: "Open Sans", sans-serif;\n font-size: small;\n font-weight: 400;\n border-color: #2B81AF;\n border-style: solid;\n border-width: thin;\n border-radius: 4px;\n background-color: #2B81AF;\n}\n.igv-ui-alert-dialog-container > div:last-child div:hover {\n cursor: pointer;\n border-color: #25597f;\n background-color: #25597f;\n}\n\n.igv-ui-color-swatch {\n position: relative;\n box-sizing: content-box;\n display: flex;\n flex-flow: row;\n flex-wrap: wrap;\n justify-content: center;\n align-items: center;\n width: 32px;\n height: 32px;\n border-style: solid;\n border-width: 2px;\n border-color: white;\n border-radius: 4px;\n}\n\n.igv-ui-color-swatch:hover {\n border-color: dimgray;\n}\n\n.igv-ui-colorpicker-menu-close-button {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n width: 100%;\n height: 32px;\n margin-top: 4px;\n margin-bottom: 4px;\n padding-right: 8px;\n}\n.igv-ui-colorpicker-menu-close-button i.fa {\n display: block;\n margin-left: 4px;\n margin-right: 4px;\n color: #5f5f5f;\n}\n.igv-ui-colorpicker-menu-close-button i.fa:hover,\n.igv-ui-colorpicker-menu-close-button i.fa:focus,\n.igv-ui-colorpicker-menu-close-button i.fa:active {\n cursor: pointer;\n color: #0f0f0f;\n}\n\n.igv-ui-generic-dialog-container {\n box-sizing: content-box;\n position: fixed;\n top: 0;\n left: 0;\n width: 300px;\n height: 200px;\n border-color: #7F7F7F;\n border-radius: 4px;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n z-index: 2048;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-header {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n width: 100%;\n height: 24px;\n cursor: move;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-color: #7F7F7F;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-header div {\n margin-right: 4px;\n margin-bottom: 2px;\n height: 12px;\n width: 12px;\n color: #7F7F7F;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-header div:hover {\n cursor: pointer;\n color: #444;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-one-liner {\n color: #373737;\n width: 95%;\n height: 24px;\n line-height: 24px;\n text-align: left;\n margin-top: 8px;\n padding-left: 8px;\n overflow-wrap: break-word;\n background-color: white;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input {\n margin-top: 8px;\n width: 95%;\n height: 24px;\n color: #373737;\n line-height: 24px;\n padding-left: 8px;\n background-color: white;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input div {\n width: 30%;\n height: 100%;\n font-size: 16px;\n text-align: right;\n padding-right: 8px;\n background-color: white;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input input {\n display: block;\n height: 100%;\n width: 100%;\n padding-left: 4px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n color: #373737;\n text-align: left;\n outline: none;\n border-style: solid;\n border-width: thin;\n border-color: #7F7F7F;\n background-color: white;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-label-input input {\n width: 50%;\n font-size: 16px;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input {\n margin-top: 8px;\n width: calc(100% - 16px);\n height: 24px;\n color: #373737;\n line-height: 24px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input input {\n display: block;\n height: 100%;\n width: 100%;\n padding-left: 4px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n color: #373737;\n text-align: left;\n outline: none;\n border-style: solid;\n border-width: thin;\n border-color: #7F7F7F;\n background-color: white;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-input input {\n font-size: 16px;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel {\n width: 100%;\n height: 28px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel div {\n margin-top: 32px;\n color: white;\n font-family: "Open Sans", sans-serif;\n font-size: 14px;\n font-weight: 400;\n width: 75px;\n height: 28px;\n line-height: 28px;\n text-align: center;\n border-color: transparent;\n border-style: solid;\n border-width: thin;\n border-radius: 2px;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel div:first-child {\n margin-left: 32px;\n margin-right: 0;\n background-color: #5ea4e0;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel div:last-child {\n margin-left: 0;\n margin-right: 32px;\n background-color: #c4c4c4;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel div:first-child:hover {\n cursor: pointer;\n background-color: #3b5c7f;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok-cancel div:last-child:hover {\n cursor: pointer;\n background-color: #7f7f7f;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok {\n width: 100%;\n height: 36px;\n margin-top: 32px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok div {\n width: 98px;\n height: 36px;\n line-height: 36px;\n text-align: center;\n color: white;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n border-color: white;\n border-style: solid;\n border-width: thin;\n border-radius: 4px;\n background-color: #2B81AF;\n}\n.igv-ui-generic-dialog-container .igv-ui-generic-dialog-ok div:hover {\n cursor: pointer;\n background-color: #25597f;\n}\n\n.igv-ui-generic-container {\n box-sizing: content-box;\n position: absolute;\n z-index: 2048;\n background-color: white;\n cursor: pointer;\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-ui-generic-container > div:first-child {\n cursor: move;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n height: 24px;\n width: 100%;\n background-color: #dddddd;\n}\n.igv-ui-generic-container > div:first-child > div {\n display: block;\n color: #5f5f5f;\n cursor: pointer;\n width: 14px;\n height: 14px;\n margin-right: 8px;\n margin-bottom: 4px;\n}\n\n.igv-ui-dialog {\n z-index: 2048;\n position: fixed;\n width: fit-content;\n height: fit-content;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n background-color: white;\n border-color: #7F7F7F;\n border-radius: 4px;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n}\n.igv-ui-dialog .igv-ui-dialog-header {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n width: 100%;\n height: 24px;\n cursor: move;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-color: #7F7F7F;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n}\n.igv-ui-dialog .igv-ui-dialog-header div {\n margin-right: 4px;\n margin-bottom: 2px;\n height: 12px;\n width: 12px;\n color: #7F7F7F;\n}\n.igv-ui-dialog .igv-ui-dialog-header div:hover {\n cursor: pointer;\n color: #444;\n}\n.igv-ui-dialog .igv-ui-dialog-one-liner {\n width: 95%;\n height: 24px;\n line-height: 24px;\n text-align: left;\n margin: 8px;\n overflow-wrap: break-word;\n background-color: white;\n font-weight: bold;\n}\n.igv-ui-dialog .igv-ui-dialog-ok-cancel {\n width: 100%;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div {\n margin: 16px;\n margin-top: 32px;\n color: white;\n font-family: "Open Sans", sans-serif;\n font-size: 14px;\n font-weight: 400;\n width: 75px;\n height: 28px;\n line-height: 28px;\n text-align: center;\n border-color: transparent;\n border-style: solid;\n border-width: thin;\n border-radius: 2px;\n}\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:first-child {\n background-color: #5ea4e0;\n}\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:last-child {\n background-color: #c4c4c4;\n}\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:first-child:hover {\n cursor: pointer;\n background-color: #3b5c7f;\n}\n.igv-ui-dialog .igv-ui-dialog-ok-cancel div:last-child:hover {\n cursor: pointer;\n background-color: #7f7f7f;\n}\n.igv-ui-dialog .igv-ui-dialog-ok {\n width: 100%;\n height: 36px;\n margin-top: 32px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n.igv-ui-dialog .igv-ui-dialog-ok div {\n width: 98px;\n height: 36px;\n line-height: 36px;\n text-align: center;\n color: white;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n border-color: white;\n border-style: solid;\n border-width: thin;\n border-radius: 4px;\n background-color: #2B81AF;\n}\n.igv-ui-dialog .igv-ui-dialog-ok div:hover {\n cursor: pointer;\n background-color: #25597f;\n}\n\n.igv-ui-panel, .igv-ui-panel-row, .igv-ui-panel-column {\n z-index: 2048;\n background-color: white;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n display: flex;\n justify-content: flex-start;\n align-items: flex-start;\n}\n\n.igv-ui-panel-column {\n display: flex;\n flex-direction: column;\n}\n\n.igv-ui-panel-row {\n display: flex;\n flex-direction: row;\n}\n\n.igv-ui-textbox {\n background-color: white;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n display: flex;\n justify-content: flex-start;\n align-items: flex-start;\n}\n\n.igv-ui-table {\n background-color: white;\n}\n\n.igv-ui-table thead {\n position: sticky;\n top: 0;\n}\n\n.igv-ui-table th {\n text-align: left;\n}\n\n.igv-ui-table td {\n padding-right: 20px;\n}\n\n.igv-ui-table tr:hover {\n background-color: lightblue;\n}\n\n/*# sourceMappingURL=igv-ui.css.map */\n',document.head.append(t)}()}function zi(t,e){const i=_e.div({class:"igv-menu-popup-check-container"}),n=_e.div();i.appendChild(n);const r=_i.createIcon("check",!0===e?"#444":"transparent");n.appendChild(r);const s=_e.div();return s.innerText=t,i.appendChild(s),i}const Ui={trackMenuItemList:function(t){const e=new Set(["alignment","annotation","variant","eqtl","snp"]),i=t.track.config&&void 0!==t.track.config.visibilityWindow;let n=[];return"sequence"!==t.track.config.type&&(n.push(function(t){const e=fe("
");return e.text("Set track name"),{object:e,click:e=>{const i={label:"Track Name",value:(n=t.track,n.trackView.viewports[0].$trackLabel.text()||"unnamed"),callback:function(){let e=t.browser.inputDialog.value;e=""===e||void 0===e?"untitled":e.trim(),t.track.name=e}};var n;t.browser.inputDialog.present(i,e)}}}(t)),n.push(function(t){const e=fe("
");return e.text("Set track height"),{object:e,click:e=>{const i={label:"Track Height",value:t.track.height,callback:()=>{const e=Number(t.browser.inputDialog.value,10);void 0!==e&&(void 0!==t.track.minHeight&&t.track.minHeight>e&&(t.track.minHeight=e),void 0!==t.track.maxHeight&&t.track.maxHeight"),n.push(Vi({trackView:t,label:"Set track color",option:"color"})),n.push(function({trackView:t,label:e}){const i=fe("
");return i.text(e),{object:i,click:()=>{t.track.color=void 0,t.repaintViews()}}}({trackView:t,label:"Unset track color"})),"wig"!==t.track.config.type&&"annotation"!==t.track.config.type||(n.push(Vi({trackView:t,label:"Set alt color",option:"altColor"})),n.push(function({trackView:t,label:e}){const i=fe("
");return i.text(e),{object:i,click:()=>{t.track.altColor=void 0,t.repaintViews()}}}({trackView:t,label:"Unset alt color"})))),t.track.menuItemList&&(n=n.concat(t.track.menuItemList())),(i||e.has(t.track.type))&&(n.push("
"),n.push(function(t){const e=fe("
");return e.text("Set visibility window"),{object:e,click:e=>{const i={label:"Visibility Window",value:t.track.visibilityWindow,callback:()=>{let e=t.browser.inputDialog.value;e=""===e||void 0===e?-1:e.trim(),t.track.visibilityWindow=Number.parseInt(e),t.track.config.visibilityWindow=Number.parseInt(e),t.updateViews()}};t.browser.inputDialog.present(i,e)}}}(t))),!1!==t.track.removable&&(n.push("
"),n.push(function(t){const e=fe("
");return e.text("Remove track"),{object:e,click:()=>t.browser.removeTrack(t.track)}}(t))),n},numericDataMenuItems:function(t){const e=[];e.push("
");const i=fe("
");return i.text("Set data range"),e.push({object:i,click:()=>{t.browser.dataRangeDialog.configure(t),t.browser.dataRangeDialog.present(fe(t.browser.columnContainer))}}),void 0!==t.track.logScale&&e.push({object:fe(zi("Log scale",t.track.logScale)),click:()=>{t.track.logScale=!t.track.logScale,t.repaintViews()}}),e.push({object:fe(zi("Autoscale",t.track.autoscale)),click:()=>{t.track.autoscale=!t.track.autoscale,t.updateViews()}}),e},trackMenuItemListHelper:function(t,e){var i=[];return t.length>0&&(i=t.map((function(t,i){var n;if(t.name?(n=fe("
")).text(t.name):t.object?n=t.object:"string"==typeof t.label?(n=fe("
")).html(t.label):"string"==typeof t&&(n=t.startsWith("<")?fe(t):fe("
"+t+"
")),0===i&&n.addClass("igv-track-menu-border-top"),t.click){function r(i){t.click(i),e.hide(),i.preventDefault(),i.stopPropagation()}n.on("click",r),n.on("touchend",(function(t){r(t)})),n.on("mouseup",(function(t){t.preventDefault(),t.stopPropagation()}))}return{object:n,init:t.init||void 0}}))),i},showColorPicker:t=>void 0===t.type||"bedtype"===t.type||"alignment"===t.type||"annotation"===t.type||"variant"===t.type||"wig"===t.type||"interact"===t.type,createMenuItem(t,e){const i=fe("
");return i.text(t),{object:i,click:e}}};function Vi({trackView:t,label:e,option:i}){const n=fe("
");return n.text(e),{object:n,click:()=>t.presentColorPicker(i)}}class Hi{constructor(t,e,i){this.browser=t,this.$container=fe("
",{class:"igv-generic-dialog-container"}),e.append(this.$container),this.$container.offset({left:0,top:0});const n=fe("
",{class:"igv-generic-dialog-header"});this.$container.append(n),ki.attachDialogCloseHandlerWithParent(n[0],(()=>{this.$minimum_input.val(void 0),this.$maximum_input.val(void 0),this.$container.offset({left:0,top:0}),this.$container.hide()})),this.$minimum=fe("
",{class:"igv-generic-dialog-label-input"}),this.$container.append(this.$minimum);const r=fe("
");r.text("Minimum"),this.$minimum.append(r),this.$minimum_input=fe(""),this.$minimum.append(this.$minimum_input),this.$maximum=fe("
",{class:"igv-generic-dialog-label-input"}),this.$container.append(this.$maximum);const s=fe("
");s.text("Maximum"),this.$maximum.append(s),this.$maximum_input=fe(""),this.$maximum.append(this.$maximum_input);const o=fe("
",{class:"igv-generic-dialog-ok-cancel"});this.$container.append(o),this.$ok=fe("
"),o.append(this.$ok),this.$ok.text("OK"),this.$cancel=fe("
"),o.append(this.$cancel),this.$cancel.text("Cancel"),this.$cancel.on("click",(()=>{this.$minimum_input.val(void 0),this.$maximum_input.val(void 0),this.$container.offset({left:0,top:0}),this.$container.hide()})),Ci(this.$container.get(0),n.get(0)),this.$container.hide()}configure(t){const e=t.dataRange();let i,n;e?(i=e.min,n=e.max):(i=0,n=100),this.$minimum_input.val(i),this.$maximum_input.val(n),this.$minimum_input.unbind(),this.$minimum_input.on("keyup",(e=>{13===e.keyCode&&this.processResults(t)})),this.$maximum_input.unbind(),this.$maximum_input.on("keyup",(e=>{13===e.keyCode&&this.processResults(t)})),this.$ok.unbind(),this.$ok.on("click",(e=>{this.processResults(t)}))}processResults(t){const e=Number(this.$minimum_input.val()),i=Number(this.$maximum_input.val());isNaN(e)||isNaN(i)?this.browser.alert.present(new Error("Must input numeric values"),void 0):t.setDataRange(e,i),this.$minimum_input.val(void 0),this.$maximum_input.val(void 0),this.$container.offset({left:0,top:0}),this.$container.hide()}present(t){const e=t.offset().top,i=fe("body").scrollTop();this.$container.offset({left:t.width()-this.$container.width(),top:e+i}),this.$container.show()}}function ji(t){return"string"==typeof t||t instanceof String}function $i(t){var e=String(t).split(/[.,]/);return e[0].split("").reverse().reduce((function(t,e,i){return i%3==0?t+","+e:t+e})).split("").reverse().join("")+(e[1]?"."+e[1]:"")}const qi=function(t){return t.split(/\n|\r\n|\r/g)};function Wi(t,e){var i,n,r=[],s=t.length,o=0,a=!1;if(s>0)for(r[o]=t.charAt(0),i=1;i0?t.charAt(0).toUpperCase()+t.slice(1):t}function Zi(t){if(void 0!==t.name)return t.name;if(ji(t)){let e=t.lastIndexOf("/"),i=e<0?t:t.substr(e+1);return e=i.indexOf("?"),e>0&&(i=i.substr(0,e)),i}throw Error("Expected File or string, got "+typeof t)}function Yi(t){return!!t&&"function"!=typeof t&&(t instanceof File||t.hasOwnProperty("name")&&"function"==typeof t.slice&&"function"==typeof t.arrayBuffer)}function Qi(t,e){const i=document.createElement("a");i.setAttribute("href",e),i.setAttribute("download",t),i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i)}function Xi(t){for(var e=Ki,i=e.parser.loose.exec(t),n={},r=14;r--;)n[e.key[r]]=i[r]||"";return n[e.q.name]={},n[e.key[12]].replace(e.q.parser,(function(t,i,r){i&&(n[e.q.name][i]=r)})),n}"object"==typeof process&&"undefined"==typeof window&&(global.atob=function(t){return Buffer.from(t,"base64").toString("binary")});const Ki={strictMode:!1,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};function Ji(t){let e=t.length;for(;--e>=0;)t[e]=0}const tn=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),en=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),nn=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),rn=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),sn=new Array(576);Ji(sn);const on=new Array(60);Ji(on);const an=new Array(512);Ji(an);const ln=new Array(256);Ji(ln);const hn=new Array(29);Ji(hn);const cn=new Array(30);function un(t,e,i,n,r){this.static_tree=t,this.extra_bits=e,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=t&&t.length}let dn,fn,pn;function gn(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}Ji(cn);const mn=t=>t<256?an[t]:an[256+(t>>>7)],bn=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},yn=(t,e,i)=>{t.bi_valid>16-i?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=i-16):(t.bi_buf|=e<{yn(t,i[2*e],i[2*e+1])},wn=(t,e)=>{let i=0;do{i|=1&t,t>>>=1,i<<=1}while(--e>0);return i>>>1},_n=(t,e,i)=>{const n=new Array(16);let r,s,o=0;for(r=1;r<=15;r++)o=o+i[r-1]<<1,n[r]=o;for(s=0;s<=e;s++){let e=t[2*s+1];0!==e&&(t[2*s]=wn(n[e]++,e))}},xn=t=>{let e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},kn=t=>{t.bi_valid>8?bn(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},Sn=(t,e,i,n)=>{const r=2*e,s=2*i;return t[r]{const n=t.heap[i];let r=i<<1;for(;r<=t.heap_len&&(r{let n,r,s,o,a=0;if(0!==t.sym_next)do{n=255&t.pending_buf[t.sym_buf+a++],n+=(255&t.pending_buf[t.sym_buf+a++])<<8,r=t.pending_buf[t.sym_buf+a++],0===n?vn(t,r,e):(s=ln[r],vn(t,s+256+1,e),o=tn[s],0!==o&&(r-=hn[s],yn(t,r,o)),n--,s=mn(n),vn(t,s,i),o=en[s],0!==o&&(n-=cn[s],yn(t,n,o)))}while(a{const i=e.dyn_tree,n=e.stat_desc.static_tree,r=e.stat_desc.has_stree,s=e.stat_desc.elems;let o,a,l,h=-1;for(t.heap_len=0,t.heap_max=573,o=0;o>1;o>=1;o--)Cn(t,i,o);l=s;do{o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],Cn(t,i,1),a=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=a,i[2*l]=i[2*o]+i[2*a],t.depth[l]=(t.depth[o]>=t.depth[a]?t.depth[o]:t.depth[a])+1,i[2*o+1]=i[2*a+1]=l,t.heap[1]=l++,Cn(t,i,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const i=e.dyn_tree,n=e.max_code,r=e.stat_desc.static_tree,s=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,l=e.stat_desc.max_length;let h,c,u,d,f,p,g=0;for(d=0;d<=15;d++)t.bl_count[d]=0;for(i[2*t.heap[t.heap_max]+1]=0,h=t.heap_max+1;h<573;h++)c=t.heap[h],d=i[2*i[2*c+1]+1]+1,d>l&&(d=l,g++),i[2*c+1]=d,c>n||(t.bl_count[d]++,f=0,c>=a&&(f=o[c-a]),p=i[2*c],t.opt_len+=p*(d+f),s&&(t.static_len+=p*(r[2*c+1]+f)));if(0!==g){do{for(d=l-1;0===t.bl_count[d];)d--;t.bl_count[d]--,t.bl_count[d+1]+=2,t.bl_count[l]--,g-=2}while(g>0);for(d=l;0!==d;d--)for(c=t.bl_count[d];0!==c;)u=t.heap[--h],u>n||(i[2*u+1]!==d&&(t.opt_len+=(d-i[2*u+1])*i[2*u],i[2*u+1]=d),c--)}})(t,e),_n(i,h,t.bl_count)},In=(t,e,i)=>{let n,r,s=-1,o=e[1],a=0,l=7,h=4;for(0===o&&(l=138,h=3),e[2*(i+1)+1]=65535,n=0;n<=i;n++)r=o,o=e[2*(n+1)+1],++a{let n,r,s=-1,o=e[1],a=0,l=7,h=4;for(0===o&&(l=138,h=3),n=0;n<=i;n++)if(r=o,o=e[2*(n+1)+1],!(++a{yn(t,0+(n?1:0),3),kn(t),bn(t,i),bn(t,~i),i&&t.pending_buf.set(t.window.subarray(e,e+i),t.pending),t.pending+=i};var Ln={_tr_init:t=>{Mn||((()=>{let t,e,i,n,r;const s=new Array(16);for(i=0,n=0;n<28;n++)for(hn[n]=i,t=0;t<1<>=7;n<30;n++)for(cn[n]=r<<7,t=0;t<1<{let r,s,o=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,i=4093624447;for(e=0;e<=31;e++,i>>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),Tn(t,t.l_desc),Tn(t,t.d_desc),o=(t=>{let e;for(In(t,t.dyn_ltree,t.l_desc.max_code),In(t,t.dyn_dtree,t.d_desc.max_code),Tn(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*rn[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),r=t.opt_len+3+7>>>3,s=t.static_len+3+7>>>3,s<=r&&(r=s)):r=s=i+5,i+4<=r&&-1!==e?Rn(t,e,i,n):4===t.strategy||s===r?(yn(t,2+(n?1:0),3),An(t,sn,on)):(yn(t,4+(n?1:0),3),((t,e,i,n)=>{let r;for(yn(t,e-257,5),yn(t,i-1,5),yn(t,n-4,4),r=0;r(t.pending_buf[t.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=i,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(ln[i]+256+1)]++,t.dyn_dtree[2*mn(e)]++),t.sym_next===t.sym_end),_tr_align:t=>{yn(t,2,3),vn(t,256,sn),(t=>{16===t.bi_valid?(bn(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}},Bn=(t,e,i,n)=>{let r=65535&t|0,s=t>>>16&65535|0,o=0;for(;0!==i;){o=i>2e3?2e3:i,i-=o;do{r=r+e[n++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16|0};const Nn=new Uint32Array((()=>{let t,e=[];for(var i=0;i<256;i++){t=i;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e})());var Fn=(t,e,i,n)=>{const r=Nn,s=n+i;t^=-1;for(let i=n;i>>8^r[255&(t^e[i])];return-1^t},On={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Dn={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Pn,_tr_stored_block:zn,_tr_flush_block:Un,_tr_tally:Vn,_tr_align:Hn}=Ln,{Z_NO_FLUSH:jn,Z_PARTIAL_FLUSH:$n,Z_FULL_FLUSH:qn,Z_FINISH:Wn,Z_BLOCK:Gn,Z_OK:Zn,Z_STREAM_END:Yn,Z_STREAM_ERROR:Qn,Z_DATA_ERROR:Xn,Z_BUF_ERROR:Kn,Z_DEFAULT_COMPRESSION:Jn,Z_FILTERED:tr,Z_HUFFMAN_ONLY:er,Z_RLE:ir,Z_FIXED:nr,Z_DEFAULT_STRATEGY:rr,Z_UNKNOWN:sr,Z_DEFLATED:or}=Dn,ar=258,lr=262,hr=42,cr=113,ur=666,dr=(t,e)=>(t.msg=On[e],e),fr=t=>2*t-(t>4?9:0),pr=t=>{let e=t.length;for(;--e>=0;)t[e]=0},gr=t=>{let e,i,n,r=t.w_size;e=t.hash_size,n=e;do{i=t.head[--n],t.head[n]=i>=r?i-r:0}while(--e);e=r,n=e;do{i=t.prev[--n],t.prev[n]=i>=r?i-r:0}while(--e)};let mr=(t,e,i)=>(e<{const e=t.state;let i=e.pending;i>t.avail_out&&(i=t.avail_out),0!==i&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+i),t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,0===e.pending&&(e.pending_out=0))},yr=(t,e)=>{Un(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,br(t.strm)},vr=(t,e)=>{t.pending_buf[t.pending++]=e},wr=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},_r=(t,e,i,n)=>{let r=t.avail_in;return r>n&&(r=n),0===r?0:(t.avail_in-=r,e.set(t.input.subarray(t.next_in,t.next_in+r),i),1===t.state.wrap?t.adler=Bn(t.adler,e,r,i):2===t.state.wrap&&(t.adler=Fn(t.adler,e,r,i)),t.next_in+=r,t.total_in+=r,r)},xr=(t,e)=>{let i,n,r=t.max_chain_length,s=t.strstart,o=t.prev_length,a=t.nice_match;const l=t.strstart>t.w_size-lr?t.strstart-(t.w_size-lr):0,h=t.window,c=t.w_mask,u=t.prev,d=t.strstart+ar;let f=h[s+o-1],p=h[s+o];t.prev_length>=t.good_match&&(r>>=2),a>t.lookahead&&(a=t.lookahead);do{if(i=e,h[i+o]===p&&h[i+o-1]===f&&h[i]===h[s]&&h[++i]===h[s+1]){s+=2,i++;do{}while(h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&so){if(t.match_start=e,o=n,n>=a)break;f=h[s+o-1],p=h[s+o]}}}while((e=u[e&c])>l&&0!=--r);return o<=t.lookahead?o:t.lookahead},kr=t=>{const e=t.w_size;let i,n,r;do{if(n=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-lr)&&(t.window.set(t.window.subarray(e,e+e-n),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),gr(t),n+=e),0===t.strm.avail_in)break;if(i=_r(t.strm,t.window,t.strstart+t.lookahead,n),t.lookahead+=i,t.lookahead+t.insert>=3)for(r=t.strstart-t.insert,t.ins_h=t.window[r],t.ins_h=mr(t,t.ins_h,t.window[r+1]);t.insert&&(t.ins_h=mr(t,t.ins_h,t.window[r+3-1]),t.prev[r&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=r,r++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead{let i,n,r,s=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,o=0,a=t.strm.avail_in;do{if(i=65535,r=t.bi_valid+42>>3,t.strm.avail_outn+t.strm.avail_in&&(i=n+t.strm.avail_in),i>r&&(i=r),i>8,t.pending_buf[t.pending-2]=~i,t.pending_buf[t.pending-1]=~i>>8,br(t.strm),n&&(n>i&&(n=i),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+n),t.strm.next_out),t.strm.next_out+=n,t.strm.avail_out-=n,t.strm.total_out+=n,t.block_start+=n,i-=n),i&&(_r(t.strm,t.strm.output,t.strm.next_out,i),t.strm.next_out+=i,t.strm.avail_out-=i,t.strm.total_out+=i)}while(0===o);return a-=t.strm.avail_in,a&&(a>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=a&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-a,t.strm.next_in),t.strstart),t.strstart+=a,t.insert+=a>t.w_size-t.insert?t.w_size-t.insert:a),t.block_start=t.strstart),t.high_waterr&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,r+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),r>t.strm.avail_in&&(r=t.strm.avail_in),r&&(_r(t.strm,t.window,t.strstart,r),t.strstart+=r,t.insert+=r>t.w_size-t.insert?t.w_size-t.insert:r),t.high_water>3,r=t.pending_buf_size-r>65535?65535:t.pending_buf_size-r,s=r>t.w_size?t.w_size:r,n=t.strstart-t.block_start,(n>=s||(n||e===Wn)&&e!==jn&&0===t.strm.avail_in&&n<=r)&&(i=n>r?r:n,o=e===Wn&&0===t.strm.avail_in&&i===n?1:0,zn(t,t.block_start,i,o),t.block_start+=i,br(t.strm)),o?3:1)},Cr=(t,e)=>{let i,n;for(;;){if(t.lookahead=3&&(t.ins_h=mr(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==i&&t.strstart-i<=t.w_size-lr&&(t.match_length=xr(t,i)),t.match_length>=3)if(n=Vn(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=mr(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=mr(t,t.ins_h,t.window[t.strstart+1]);else n=Vn(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(yr(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===Wn?(yr(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(yr(t,!1),0===t.strm.avail_out)?1:2},Ar=(t,e)=>{let i,n,r;for(;;){if(t.lookahead=3&&(t.ins_h=mr(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==i&&t.prev_length4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){r=t.strstart+t.lookahead-3,n=Vn(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=r&&(t.ins_h=mr(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(yr(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(n=Vn(t,0,t.window[t.strstart-1]),n&&yr(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=Vn(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===Wn?(yr(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(yr(t,!1),0===t.strm.avail_out)?1:2};function Tr(t,e,i,n,r){this.good_length=t,this.max_lazy=e,this.nice_length=i,this.max_chain=n,this.func=r}const Ir=[new Tr(0,0,0,0,Sr),new Tr(4,4,8,4,Cr),new Tr(4,5,16,8,Cr),new Tr(4,6,32,32,Cr),new Tr(4,4,16,16,Ar),new Tr(8,16,32,32,Ar),new Tr(8,16,128,128,Ar),new Tr(8,32,128,256,Ar),new Tr(32,128,258,1024,Ar),new Tr(32,258,258,4096,Ar)];function Er(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=or,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),pr(this.dyn_ltree),pr(this.dyn_dtree),pr(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),pr(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),pr(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Mr=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.status!==hr&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&e.status!==cr&&e.status!==ur?1:0},Rr=t=>{if(Mr(t))return dr(t,Qn);t.total_in=t.total_out=0,t.data_type=sr;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=2===e.wrap?57:e.wrap?hr:cr,t.adler=2===e.wrap?0:1,e.last_flush=-2,Pn(e),Zn},Lr=t=>{const e=Rr(t);var i;return e===Zn&&((i=t.state).window_size=2*i.w_size,pr(i.head),i.max_lazy_match=Ir[i.level].max_lazy,i.good_match=Ir[i.level].good_length,i.nice_match=Ir[i.level].nice_length,i.max_chain_length=Ir[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),e},Br=(t,e,i,n,r,s)=>{if(!t)return Qn;let o=1;if(e===Jn&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),r<1||r>9||i!==or||n<8||n>15||e<0||e>9||s<0||s>nr||8===n&&1!==o)return dr(t,Qn);8===n&&(n=9);const a=new Er;return t.state=a,a.strm=t,a.status=hr,a.wrap=o,a.gzhead=null,a.w_bits=n,a.w_size=1<Br(t,e,or,15,8,rr),deflateInit2:Br,deflateReset:Lr,deflateResetKeep:Rr,deflateSetHeader:(t,e)=>Mr(t)||2!==t.state.wrap?Qn:(t.state.gzhead=e,Zn),deflate:(t,e)=>{if(Mr(t)||e>Gn||e<0)return t?dr(t,Qn):Qn;const i=t.state;if(!t.output||0!==t.avail_in&&!t.input||i.status===ur&&e!==Wn)return dr(t,0===t.avail_out?Kn:Qn);const n=i.last_flush;if(i.last_flush=e,0!==i.pending){if(br(t),0===t.avail_out)return i.last_flush=-1,Zn}else if(0===t.avail_in&&fr(e)<=fr(n)&&e!==Wn)return dr(t,Kn);if(i.status===ur&&0!==t.avail_in)return dr(t,Kn);if(i.status===hr&&0===i.wrap&&(i.status=cr),i.status===hr){let e=or+(i.w_bits-8<<4)<<8,n=-1;if(n=i.strategy>=er||i.level<2?0:i.level<6?1:6===i.level?2:3,e|=n<<6,0!==i.strstart&&(e|=32),e+=31-e%31,wr(i,e),0!==i.strstart&&(wr(i,t.adler>>>16),wr(i,65535&t.adler)),t.adler=1,i.status=cr,br(t),0!==i.pending)return i.last_flush=-1,Zn}if(57===i.status)if(t.adler=0,vr(i,31),vr(i,139),vr(i,8),i.gzhead)vr(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),vr(i,255&i.gzhead.time),vr(i,i.gzhead.time>>8&255),vr(i,i.gzhead.time>>16&255),vr(i,i.gzhead.time>>24&255),vr(i,9===i.level?2:i.strategy>=er||i.level<2?4:0),vr(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(vr(i,255&i.gzhead.extra.length),vr(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=Fn(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69;else if(vr(i,0),vr(i,0),vr(i,0),vr(i,0),vr(i,0),vr(i,9===i.level?2:i.strategy>=er||i.level<2?4:0),vr(i,3),i.status=cr,br(t),0!==i.pending)return i.last_flush=-1,Zn;if(69===i.status){if(i.gzhead.extra){let e=i.pending,n=(65535&i.gzhead.extra.length)-i.gzindex;for(;i.pending+n>i.pending_buf_size;){let r=i.pending_buf_size-i.pending;if(i.pending_buf.set(i.gzhead.extra.subarray(i.gzindex,i.gzindex+r),i.pending),i.pending=i.pending_buf_size,i.gzhead.hcrc&&i.pending>e&&(t.adler=Fn(t.adler,i.pending_buf,i.pending-e,e)),i.gzindex+=r,br(t),0!==i.pending)return i.last_flush=-1,Zn;e=0,n-=r}let r=new Uint8Array(i.gzhead.extra);i.pending_buf.set(r.subarray(i.gzindex,i.gzindex+n),i.pending),i.pending+=n,i.gzhead.hcrc&&i.pending>e&&(t.adler=Fn(t.adler,i.pending_buf,i.pending-e,e)),i.gzindex=0}i.status=73}if(73===i.status){if(i.gzhead.name){let e,n=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>n&&(t.adler=Fn(t.adler,i.pending_buf,i.pending-n,n)),br(t),0!==i.pending)return i.last_flush=-1,Zn;n=0}e=i.gzindexn&&(t.adler=Fn(t.adler,i.pending_buf,i.pending-n,n)),i.gzindex=0}i.status=91}if(91===i.status){if(i.gzhead.comment){let e,n=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>n&&(t.adler=Fn(t.adler,i.pending_buf,i.pending-n,n)),br(t),0!==i.pending)return i.last_flush=-1,Zn;n=0}e=i.gzindexn&&(t.adler=Fn(t.adler,i.pending_buf,i.pending-n,n))}i.status=103}if(103===i.status){if(i.gzhead.hcrc){if(i.pending+2>i.pending_buf_size&&(br(t),0!==i.pending))return i.last_flush=-1,Zn;vr(i,255&t.adler),vr(i,t.adler>>8&255),t.adler=0}if(i.status=cr,br(t),0!==i.pending)return i.last_flush=-1,Zn}if(0!==t.avail_in||0!==i.lookahead||e!==jn&&i.status!==ur){let n=0===i.level?Sr(i,e):i.strategy===er?((t,e)=>{let i;for(;;){if(0===t.lookahead&&(kr(t),0===t.lookahead)){if(e===jn)return 1;break}if(t.match_length=0,i=Vn(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(yr(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Wn?(yr(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(yr(t,!1),0===t.strm.avail_out)?1:2})(i,e):i.strategy===ir?((t,e)=>{let i,n,r,s;const o=t.window;for(;;){if(t.lookahead<=ar){if(kr(t),t.lookahead<=ar&&e===jn)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(r=t.strstart-1,n=o[r],n===o[++r]&&n===o[++r]&&n===o[++r])){s=t.strstart+ar;do{}while(n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&n===o[++r]&&rt.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(i=Vn(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=Vn(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(yr(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Wn?(yr(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(yr(t,!1),0===t.strm.avail_out)?1:2})(i,e):Ir[i.level].func(i,e);if(3!==n&&4!==n||(i.status=ur),1===n||3===n)return 0===t.avail_out&&(i.last_flush=-1),Zn;if(2===n&&(e===$n?Hn(i):e!==Gn&&(zn(i,0,0,!1),e===qn&&(pr(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),br(t),0===t.avail_out))return i.last_flush=-1,Zn}return e!==Wn?Zn:i.wrap<=0?Yn:(2===i.wrap?(vr(i,255&t.adler),vr(i,t.adler>>8&255),vr(i,t.adler>>16&255),vr(i,t.adler>>24&255),vr(i,255&t.total_in),vr(i,t.total_in>>8&255),vr(i,t.total_in>>16&255),vr(i,t.total_in>>24&255)):(wr(i,t.adler>>>16),wr(i,65535&t.adler)),br(t),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?Zn:Yn)},deflateEnd:t=>{if(Mr(t))return Qn;const e=t.state.status;return t.state=null,e===cr?dr(t,Xn):Zn},deflateSetDictionary:(t,e)=>{let i=e.length;if(Mr(t))return Qn;const n=t.state,r=n.wrap;if(2===r||1===r&&n.status!==hr||n.lookahead)return Qn;if(1===r&&(t.adler=Bn(t.adler,e,i,0)),n.wrap=0,i>=n.w_size){0===r&&(pr(n.head),n.strstart=0,n.block_start=0,n.insert=0);let t=new Uint8Array(n.w_size);t.set(e.subarray(i-n.w_size,i),0),e=t,i=n.w_size}const s=t.avail_in,o=t.next_in,a=t.input;for(t.avail_in=i,t.next_in=0,t.input=e,kr(n);n.lookahead>=3;){let t=n.strstart,e=n.lookahead-2;do{n.ins_h=mr(n,n.ins_h,n.window[t+3-1]),n.prev[t&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=t,t++}while(--e);n.strstart=t,n.lookahead=2,kr(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=o,t.input=a,t.avail_in=s,n.wrap=r,Zn},deflateInfo:"pako deflate (from Nodeca project)"};const Fr=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Or={assign:function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const e in i)Fr(i,e)&&(t[e]=i[e])}}return t},flattenChunks:t=>{let e=0;for(let i=0,n=t.length;i=252?6:my>=248?5:my>=240?4:my>=224?3:my>=192?2:1;Pr[254]=Pr[254]=1;var zr={string2buf:t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,i,n,r,s,o=t.length,a=0;for(r=0;r>>6,e[s++]=128|63&i):i<65536?(e[s++]=224|i>>>12,e[s++]=128|i>>>6&63,e[s++]=128|63&i):(e[s++]=240|i>>>18,e[s++]=128|i>>>12&63,e[s++]=128|i>>>6&63,e[s++]=128|63&i);return e},buf2string:(t,e)=>{const i=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let n,r;const s=new Array(2*i);for(r=0,n=0;n4)s[r++]=65533,n+=o-1;else{for(e&=2===o?31:3===o?15:7;o>1&&n1?s[r++]=65533:e<65536?s[r++]=e:(e-=65536,s[r++]=55296|e>>10&1023,s[r++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Dr)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let i="";for(let n=0;n{(e=e||t.length)>t.length&&(e=t.length);let i=e-1;for(;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+Pr[t[i]]>e?i:e}},Ur=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Vr=Object.prototype.toString,{Z_NO_FLUSH:Hr,Z_SYNC_FLUSH:jr,Z_FULL_FLUSH:$r,Z_FINISH:qr,Z_OK:Wr,Z_STREAM_END:Gr,Z_DEFAULT_COMPRESSION:Zr,Z_DEFAULT_STRATEGY:Yr,Z_DEFLATED:Qr}=Dn;function Xr(t){this.options=Or.assign({level:Zr,method:Qr,chunkSize:16384,windowBits:15,memLevel:8,strategy:Yr},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ur,this.strm.avail_out=0;let i=Nr.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(i!==Wr)throw new Error(On[i]);if(e.header&&Nr.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?zr.string2buf(e.dictionary):"[object ArrayBuffer]"===Vr.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,i=Nr.deflateSetDictionary(this.strm,t),i!==Wr)throw new Error(On[i]);this._dict_set=!0}}function Kr(t,e){const i=new Xr(e);if(i.push(t,!0),i.err)throw i.msg||On[i.err];return i.result}Xr.prototype.push=function(t,e){const i=this.strm,n=this.options.chunkSize;let r,s;if(this.ended)return!1;for(s=e===~~e?e:!0===e?qr:Hr,"string"==typeof t?i.input=zr.string2buf(t):"[object ArrayBuffer]"===Vr.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),(s===jr||s===$r)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(r=Nr.deflate(i,s),r===Gr)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=Nr.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===Wr;if(0!==i.avail_out){if(s>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},Xr.prototype.onData=function(t){this.chunks.push(t)},Xr.prototype.onEnd=function(t){t===Wr&&(this.result=Or.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Jr={Deflate:Xr,deflate:Kr,deflateRaw:function(t,e){return(e=e||{}).raw=!0,Kr(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,Kr(t,e)},constants:Dn};const ts=16209;var es=function(t,e){let i,n,r,s,o,a,l,h,c,u,d,f,p,g,m,b,y,v,w,_,x,k,S,C;const A=t.state;i=t.next_in,S=t.input,n=i+(t.avail_in-5),r=t.next_out,C=t.output,s=r-(e-t.avail_out),o=r+(t.avail_out-257),a=A.dmax,l=A.wsize,h=A.whave,c=A.wnext,u=A.window,d=A.hold,f=A.bits,p=A.lencode,g=A.distcode,m=(1<>>24,d>>>=v,f-=v,v=y>>>16&255,0===v)C[r++]=65535&y;else{if(!(16&v)){if(0==(64&v)){y=p[(65535&y)+(d&(1<>>=v,f-=v),f<15&&(d+=S[i++]<>>24,d>>>=v,f-=v,v=y>>>16&255,!(16&v)){if(0==(64&v)){y=g[(65535&y)+(d&(1<a){t.msg="invalid distance too far back",A.mode=ts;break t}if(d>>>=v,f-=v,v=r-s,_>v){if(v=_-v,v>h&&A.sane){t.msg="invalid distance too far back",A.mode=ts;break t}if(x=0,k=u,0===c){if(x+=l-v,v2;)C[r++]=k[x++],C[r++]=k[x++],C[r++]=k[x++],w-=3;w&&(C[r++]=k[x++],w>1&&(C[r++]=k[x++]))}else{x=r-_;do{C[r++]=C[x++],C[r++]=C[x++],C[r++]=C[x++],w-=3}while(w>2);w&&(C[r++]=C[x++],w>1&&(C[r++]=C[x++]))}break}}break}}while(i>3,i-=w,f-=w<<3,d&=(1<{const l=a.bits;let h,c,u,d,f,p,g=0,m=0,b=0,y=0,v=0,w=0,_=0,x=0,k=0,S=0,C=null;const A=new Uint16Array(16),T=new Uint16Array(16);let I,E,M,R=null;for(g=0;g<=15;g++)A[g]=0;for(m=0;m=1&&0===A[y];y--);if(v>y&&(v=y),0===y)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(b=1;b0&&(0===t||1!==y))return-1;for(T[1]=0,g=1;g<15;g++)T[g+1]=T[g]+A[g];for(m=0;m852||2===t&&k>592)return 1;for(;;){I=g-_,o[m]+1=p?(E=R[o[m]-p],M=C[o[m]-p]):(E=96,M=0),h=1<>_)+c]=I<<24|E<<16|M|0}while(0!==c);for(h=1<>=1;if(0!==h?(S&=h-1,S+=h):S=0,m++,0==--A[g]){if(g===y)break;g=e[i+o[m]]}if(g>v&&(S&d)!==u){for(0===_&&(_=v),f+=b,w=g-_,x=1<852||2===t&&k>592)return 1;u=S&d,r[u]=v<<24|w<<16|f-s|0}}return 0!==S&&(r[f+S]=g-_<<24|64<<16|0),a.bits=v,0};const{Z_FINISH:as,Z_BLOCK:ls,Z_TREES:hs,Z_OK:cs,Z_STREAM_END:us,Z_NEED_DICT:ds,Z_STREAM_ERROR:fs,Z_DATA_ERROR:ps,Z_MEM_ERROR:gs,Z_BUF_ERROR:ms,Z_DEFLATED:bs}=Dn,ys=16180,vs=16190,ws=16191,_s=16192,xs=16194,ks=16199,Ss=16200,Cs=16206,As=16209,Ts=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function Is(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Es=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode16211?1:0},Ms=t=>{if(Es(t))return fs;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=ys,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,cs},Rs=t=>{if(Es(t))return fs;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,Ms(t)},Ls=(t,e)=>{let i;if(Es(t))return fs;const n=t.state;return e<0?(i=0,e=-e):(i=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?fs:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=i,n.wbits=e,Rs(t))},Bs=(t,e)=>{if(!t)return fs;const i=new Is;t.state=i,i.strm=t,i.window=null,i.mode=ys;const n=Ls(t,e);return n!==cs&&(t.state=null),n};let Ns,Fs,Os=!0;const Ds=t=>{if(Os){Ns=new Int32Array(512),Fs=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(os(1,t.lens,0,288,Ns,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;os(2,t.lens,0,32,Fs,0,t.work,{bits:5}),Os=!1}t.lencode=Ns,t.lenbits=9,t.distcode=Fs,t.distbits=5},Ps=(t,e,i,n)=>{let r;const s=t.state;return null===s.window&&(s.wsize=1<=s.wsize?(s.window.set(e.subarray(i-s.wsize,i),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>n&&(r=n),s.window.set(e.subarray(i-n,i-n+r),s.wnext),(n-=r)?(s.window.set(e.subarray(i-n,i),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whaveBs(t,15),inflateInit2:Bs,inflate:(t,e)=>{let i,n,r,s,o,a,l,h,c,u,d,f,p,g,m,b,y,v,w,_,x,k,S=0;const C=new Uint8Array(4);let A,T;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Es(t)||!t.output||!t.input&&0!==t.avail_in)return fs;i=t.state,i.mode===ws&&(i.mode=_s),o=t.next_out,r=t.output,l=t.avail_out,s=t.next_in,n=t.input,a=t.avail_in,h=i.hold,c=i.bits,u=a,d=l,k=cs;t:for(;;)switch(i.mode){case ys:if(0===i.wrap){i.mode=_s;break}for(;c<16;){if(0===a)break t;a--,h+=n[s++]<>>8&255,i.check=Fn(i.check,C,2,0),h=0,c=0,i.mode=16181;break}if(i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&h)<<8)+(h>>8))%31){t.msg="incorrect header check",i.mode=As;break}if((15&h)!==bs){t.msg="unknown compression method",i.mode=As;break}if(h>>>=4,c-=4,x=8+(15&h),0===i.wbits&&(i.wbits=x),x>15||x>i.wbits){t.msg="invalid window size",i.mode=As;break}i.dmax=1<>8&1),512&i.flags&&4&i.wrap&&(C[0]=255&h,C[1]=h>>>8&255,i.check=Fn(i.check,C,2,0)),h=0,c=0,i.mode=16182;case 16182:for(;c<32;){if(0===a)break t;a--,h+=n[s++]<>>8&255,C[2]=h>>>16&255,C[3]=h>>>24&255,i.check=Fn(i.check,C,4,0)),h=0,c=0,i.mode=16183;case 16183:for(;c<16;){if(0===a)break t;a--,h+=n[s++]<>8),512&i.flags&&4&i.wrap&&(C[0]=255&h,C[1]=h>>>8&255,i.check=Fn(i.check,C,2,0)),h=0,c=0,i.mode=16184;case 16184:if(1024&i.flags){for(;c<16;){if(0===a)break t;a--,h+=n[s++]<>>8&255,i.check=Fn(i.check,C,2,0)),h=0,c=0}else i.head&&(i.head.extra=null);i.mode=16185;case 16185:if(1024&i.flags&&(f=i.length,f>a&&(f=a),f&&(i.head&&(x=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(s,s+f),x)),512&i.flags&&4&i.wrap&&(i.check=Fn(i.check,n,f,s)),a-=f,s+=f,i.length-=f),i.length))break t;i.length=0,i.mode=16186;case 16186:if(2048&i.flags){if(0===a)break t;f=0;do{x=n[s+f++],i.head&&x&&i.length<65536&&(i.head.name+=String.fromCharCode(x))}while(x&&f>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=ws;break;case 16189:for(;c<32;){if(0===a)break t;a--,h+=n[s++]<>>=7&c,c-=7&c,i.mode=Cs;break}for(;c<3;){if(0===a)break t;a--,h+=n[s++]<>>=1,c-=1,3&h){case 0:i.mode=16193;break;case 1:if(Ds(i),i.mode=ks,e===hs){h>>>=2,c-=2;break t}break;case 2:i.mode=16196;break;case 3:t.msg="invalid block type",i.mode=As}h>>>=2,c-=2;break;case 16193:for(h>>>=7&c,c-=7&c;c<32;){if(0===a)break t;a--,h+=n[s++]<>>16^65535)){t.msg="invalid stored block lengths",i.mode=As;break}if(i.length=65535&h,h=0,c=0,i.mode=xs,e===hs)break t;case xs:i.mode=16195;case 16195:if(f=i.length,f){if(f>a&&(f=a),f>l&&(f=l),0===f)break t;r.set(n.subarray(s,s+f),o),a-=f,s+=f,l-=f,o+=f,i.length-=f;break}i.mode=ws;break;case 16196:for(;c<14;){if(0===a)break t;a--,h+=n[s++]<>>=5,c-=5,i.ndist=1+(31&h),h>>>=5,c-=5,i.ncode=4+(15&h),h>>>=4,c-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=As;break}i.have=0,i.mode=16197;case 16197:for(;i.have>>=3,c-=3}for(;i.have<19;)i.lens[I[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,A={bits:i.lenbits},k=os(0,i.lens,0,19,i.lencode,0,i.work,A),i.lenbits=A.bits,k){t.msg="invalid code lengths set",i.mode=As;break}i.have=0,i.mode=16198;case 16198:for(;i.have>>24,b=S>>>16&255,y=65535&S,!(m<=c);){if(0===a)break t;a--,h+=n[s++]<>>=m,c-=m,i.lens[i.have++]=y;else{if(16===y){for(T=m+2;c>>=m,c-=m,0===i.have){t.msg="invalid bit length repeat",i.mode=As;break}x=i.lens[i.have-1],f=3+(3&h),h>>>=2,c-=2}else if(17===y){for(T=m+3;c>>=m,c-=m,x=0,f=3+(7&h),h>>>=3,c-=3}else{for(T=m+7;c>>=m,c-=m,x=0,f=11+(127&h),h>>>=7,c-=7}if(i.have+f>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=As;break}for(;f--;)i.lens[i.have++]=x}}if(i.mode===As)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=As;break}if(i.lenbits=9,A={bits:i.lenbits},k=os(1,i.lens,0,i.nlen,i.lencode,0,i.work,A),i.lenbits=A.bits,k){t.msg="invalid literal/lengths set",i.mode=As;break}if(i.distbits=6,i.distcode=i.distdyn,A={bits:i.distbits},k=os(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,A),i.distbits=A.bits,k){t.msg="invalid distances set",i.mode=As;break}if(i.mode=ks,e===hs)break t;case ks:i.mode=Ss;case Ss:if(a>=6&&l>=258){t.next_out=o,t.avail_out=l,t.next_in=s,t.avail_in=a,i.hold=h,i.bits=c,es(t,d),o=t.next_out,r=t.output,l=t.avail_out,s=t.next_in,n=t.input,a=t.avail_in,h=i.hold,c=i.bits,i.mode===ws&&(i.back=-1);break}for(i.back=0;S=i.lencode[h&(1<>>24,b=S>>>16&255,y=65535&S,!(m<=c);){if(0===a)break t;a--,h+=n[s++]<>v)],m=S>>>24,b=S>>>16&255,y=65535&S,!(v+m<=c);){if(0===a)break t;a--,h+=n[s++]<>>=v,c-=v,i.back+=v}if(h>>>=m,c-=m,i.back+=m,i.length=y,0===b){i.mode=16205;break}if(32&b){i.back=-1,i.mode=ws;break}if(64&b){t.msg="invalid literal/length code",i.mode=As;break}i.extra=15&b,i.mode=16201;case 16201:if(i.extra){for(T=i.extra;c>>=i.extra,c-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=16202;case 16202:for(;S=i.distcode[h&(1<>>24,b=S>>>16&255,y=65535&S,!(m<=c);){if(0===a)break t;a--,h+=n[s++]<>v)],m=S>>>24,b=S>>>16&255,y=65535&S,!(v+m<=c);){if(0===a)break t;a--,h+=n[s++]<>>=v,c-=v,i.back+=v}if(h>>>=m,c-=m,i.back+=m,64&b){t.msg="invalid distance code",i.mode=As;break}i.offset=y,i.extra=15&b,i.mode=16203;case 16203:if(i.extra){for(T=i.extra;c>>=i.extra,c-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=As;break}i.mode=16204;case 16204:if(0===l)break t;if(f=d-l,i.offset>f){if(f=i.offset-f,f>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=As;break}f>i.wnext?(f-=i.wnext,p=i.wsize-f):p=i.wnext-f,f>i.length&&(f=i.length),g=i.window}else g=r,p=o-i.offset,f=i.length;f>l&&(f=l),l-=f,i.length-=f;do{r[o++]=g[p++]}while(--f);0===i.length&&(i.mode=Ss);break;case 16205:if(0===l)break t;r[o++]=i.length,l--,i.mode=Ss;break;case Cs:if(i.wrap){for(;c<32;){if(0===a)break t;a--,h|=n[s++]<{if(Es(t))return fs;let e=t.state;return e.window&&(e.window=null),t.state=null,cs},inflateGetHeader:(t,e)=>{if(Es(t))return fs;const i=t.state;return 0==(2&i.wrap)?fs:(i.head=e,e.done=!1,cs)},inflateSetDictionary:(t,e)=>{const i=e.length;let n,r,s;return Es(t)?fs:(n=t.state,0!==n.wrap&&n.mode!==vs?fs:n.mode===vs&&(r=1,r=Bn(r,e,i,0),r!==n.check)?ps:(s=Ps(t,e,i,i),s?(n.mode=16210,gs):(n.havedict=1,cs)))},inflateInfo:"pako inflate (from Nodeca project)"},Us=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Vs=Object.prototype.toString,{Z_NO_FLUSH:Hs,Z_FINISH:js,Z_OK:$s,Z_STREAM_END:qs,Z_NEED_DICT:Ws,Z_STREAM_ERROR:Gs,Z_DATA_ERROR:Zs,Z_MEM_ERROR:Ys}=Dn;function Qs(t){this.options=Or.assign({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ur,this.strm.avail_out=0;let i=zs.inflateInit2(this.strm,e.windowBits);if(i!==$s)throw new Error(On[i]);if(this.header=new Us,zs.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=zr.string2buf(e.dictionary):"[object ArrayBuffer]"===Vs.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(i=zs.inflateSetDictionary(this.strm,e.dictionary),i!==$s)))throw new Error(On[i])}function Xs(t,e){const i=new Qs(e);if(i.push(t),i.err)throw i.msg||On[i.err];return i.result}Qs.prototype.push=function(t,e){const i=this.strm,n=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=e===~~e?e:!0===e?js:Hs,"[object ArrayBuffer]"===Vs.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),s=zs.inflate(i,o),s===Ws&&r&&(s=zs.inflateSetDictionary(i,r),s===$s?s=zs.inflate(i,o):s===Zs&&(s=Ws));i.avail_in>0&&s===qs&&i.state.wrap>0&&0!==t[i.next_in];)zs.inflateReset(i),s=zs.inflate(i,o);switch(s){case Gs:case Zs:case Ws:case Ys:return this.onEnd(s),this.ended=!0,!1}if(a=i.avail_out,i.next_out&&(0===i.avail_out||s===qs))if("string"===this.options.to){let t=zr.utf8border(i.output,i.next_out),e=i.next_out-t,r=zr.buf2string(i.output,t);i.next_out=e,i.avail_out=n-e,e&&i.output.set(i.output.subarray(t,t+e),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(s!==$s||0!==a){if(s===qs)return s=zs.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Qs.prototype.onData=function(t){this.chunks.push(t)},Qs.prototype.onEnd=function(t){t===$s&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Or.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Ks={Inflate:Qs,inflate:Xs,inflateRaw:function(t,e){return(e=e||{}).raw=!0,Xs(t,e)},ungzip:Xs,constants:Dn};const{Deflate:Js,deflate:to,deflateRaw:eo,gzip:io}=Jr,{Inflate:no,inflate:ro,inflateRaw:so,ungzip:oo}=Ks;var ao=eo,lo=ro,ho=so,co=oo;function uo(t,e){const i=[];let n=0,r=0;for(e=e||t.byteLength-18;n100?mo(new Uint8Array(t.buffer,t.byteOffset+e,r),i,n):function(t,e,i,n,r){for(let s=0;s=0){r=atob(r);const t=new Uint8Array(r.length);for(let e=0;e0?co(t):t,i}return decodeURIComponent(r)}const yo=function(t,e,i){return Math.min(Math.max(t,e),i)},vo=function(t){return Math.log(t)/Math.LN2};function wo(){this.content=[]}function _o(t,e){return Math.random()*(e-t)+t}wo.prototype={push:function(t){this.content.push(t),this.bubbleUp(this.content.length-1)},pop:function(){var t=this.content[0],e=this.content.pop();return this.content.length>0&&(this.content[0]=e,this.sinkDown(0)),t},remove:function(t){for(var e=this.content.length,i=0;i0;){var n=Math.floor((t+1)/2)-1,r=this.content[n];if(i>=r)break;this.content[n]=e,this.content[t]=r,t=n}},sinkDown:function(t){for(var e=this.content.length,i=this.content[t],n=i;;){var r=2*(t+1),s=r-1,o=null;if(s{let t=[];for(let e=1;e>=.5;e-=.1)for(let i=0;i<1;i+=1/28){const n="rgb("+xo.hsvToRgb(i,1,e).join(",")+")";t.push(n)}return t.pop(),t.push(xo.rgbColor(16,16,16)),t},rgbToHex:function(t){return(t=t.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i))&&4===t.length?"#"+("0"+parseInt(t[1],10).toString(16)).slice(-2)+("0"+parseInt(t[2],10).toString(16)).slice(-2)+("0"+parseInt(t[3],10).toString(16)).slice(-2):""},hexToRgb:function(t){var e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);if(null!==e)return"rgb("+parseInt(e[1],16)+","+parseInt(e[2],16)+","+parseInt(e[3],16)+")"},hsvToRgb:function(t,e,i){var n,r,s,o=Math.floor(6*t),a=6*t-o,l=i*(1-e),h=i*(1-a*e),c=i*(1-(1-a)*e);switch(o%6){case 0:n=i,r=c,s=l;break;case 1:n=h,r=i,s=l;break;case 2:n=l,r=i,s=c;break;case 3:n=l,r=h,s=i;break;case 4:n=c,r=l,s=i;break;case 5:n=i,r=l,s=h}return[Math.floor(255*n),Math.floor(255*r),Math.floor(255*s)]},hslToRgb:function(t,e,i){var n,r,s;if(0===e)n=r=s=i;else{var o=i<.5?i*(1+e):i+e-i*e,a=2*i-o;n=xo.hue2rgb(a,o,t+1/3),r=xo.hue2rgb(a,o,t),s=xo.hue2rgb(a,o,t-1/3)}return[255*n,255*r,255*s]},hue2rgb:(t,e,i)=>(i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t),rgbaColor:function(t,e,i,n){return"rgba("+(t=yo(t,0,255))+","+(e=yo(e,0,255))+","+(i=yo(i,0,255))+","+(n=yo(n,0,1))+")"},rgbColor:function(t,e,i){return"rgb("+(t=yo(t,0,255))+","+(e=yo(e,0,255))+","+(i=yo(i,0,255))+")"},greyScale:function(t){var e=yo(t,0,255);return"rgb("+e+","+e+","+e+")"},randomGrey:function(t,e){t=yo(t,0,255),e=yo(e,0,255);var i=Math.round(_o(t,e)).toString(10);return"rgb("+i+","+i+","+i+")"},randomRGB:function(t,e){return t=yo(t,0,255),e=yo(e,0,255),"rgb("+Math.round(_o(t,e)).toString(10)+","+Math.round(_o(t,e)).toString(10)+","+Math.round(_o(t,e)).toString(10)+")"},randomRGBConstantAlpha:function(t,e,i){return t=yo(t,0,255),e=yo(e,0,255),"rgba("+Math.round(_o(t,e)).toString(10)+","+Math.round(_o(t,e)).toString(10)+","+Math.round(_o(t,e)).toString(10)+","+i+")"},addAlpha:function(t,e){if("0"===t||"."===t)t="rgb(0,0,0)";else{const e=this.colorNameToHex(t);e&&(t=e)}var i=/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t);if(t.startsWith("rgba")){const i=t.lastIndexOf(",");return t.substring(0,i+1)+e.toString()+")"}return i&&(t=xo.hexToRgb(t)),t.startsWith("rgb")?t.replace("rgb","rgba").replace(")",", "+e+")"):(console.log(t+" is not an rgb style string"),t)},rgbComponents:function(t){if("0"===t||"."===t)return[0,0,0];if(/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t))t=xo.hexToRgb(t);else if(!t.startsWith("rgb")){const e=this.colorNameToHex(t);t=this.hexToRgb(e)}if(t.startsWith("rgb("))return t.substring(4,t.length-1).split(",").map((t=>Number.parseInt(t.trim())));if(t.startsWith("rgba("))return t.substring(5,t.length-1).split(",").map(((t,e)=>(t=t.trim(),3===e?Number.parseFloat(t):Number.parseInt(t))));throw Error("Unrecognized color string: color")},getCompositeColor:function(t,e,i){return"rgb("+Math.floor(i*e[0]+(1-i)*t[0])+","+Math.floor(i*e[1]+(1-i)*t[1])+","+Math.floor(i*e[2]+(1-i)*t[2])+")"},createColorString:function(t){return(t=function(t){return void 0===t||((t.startsWith("'")||t.startsWith('"'))&&(t=t.substring(1)),(t.endsWith("'")||t.endsWith('"'))&&(t=t.substring(0,t.length-1))),t}(t)).includes(",")?t.startsWith("rgb")?t:"rgb("+t+")":t},darkenLighten:function(t,e){let i,n=this.colorNameToHex(t);i=n?xo.hexToRgb(n):t.startsWith("rgb(")?t:xo.hexToRgb(t);const r=i.replace(")","").substring(4).split(","),s=Math.max(0,Math.min(255,Number.parseInt(r[0].trim())+e)),o=Math.max(0,Math.min(255,Number.parseInt(r[1].trim())+e)),a=Math.max(0,Math.min(255,Number.parseInt(r[2].trim())+e));return"rgb("+s.toString()+","+o.toString()+","+a.toString()+")"},colorNameToHex:function(t){return{aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c","indigo ":"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32",darkgrey:"#a9a9a9",darkslategrey:"#2f4f4f",dimgrey:"#696969",grey:"#808080",lightgray:"#d3d3d3",lightslategrey:"#778899",slategrey:"#708090"}[t]}},ko="googleapis";class So{constructor(){this.oauthTokens={}}setToken(t,e){e=e||ko,this.oauthTokens[e]=t}getToken(t){let e;t=t||ko;for(let i of Object.keys(this.oauthTokens))if(Co(i).test(t)){e=this.oauthTokens[i];break}return e}removeToken(t){t=t||ko;for(let e of Object.keys(this.oauthTokens))Co(e).test(t)&&(this.oauthTokens[e]=void 0)}}function Co(t){return new RegExp("^"+t.split(/\*+/).map(Ao).join(".*")+"$")}function Ao(t){return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")}function To(t){return t.includes("googleapis")&&!t.includes("urlshortener")||Io(t)||Eo(t)}function Io(t){return t.startsWith("gs://")||t.startsWith("https://www.googleapis.com/storage")||t.startsWith("https://storage.cloud.google.com")||t.startsWith("https://storage.googleapis.com")}function Eo(t){return t.indexOf("drive.google.com")>=0||t.indexOf("www.googleapis.com/drive")>0}const Mo=new Map;function Ro(){return window.google&&window.google.igv}async function Lo(t){if(!Ro())throw Error("Google oAuth has not been initialized");if(google.igv.tokenResponse&&Date.now(){try{e.callback=t=>{void 0!==t.error&&n(t),google.igv.tokenResponse=t,google.igv.tokenExpiresAt=Date.now()+1e3*t.expires_in,i(t.access_token)},e.requestAccessToken({scope:t})}catch(t){console.log(t)}}))}}function Bo(){return google.igv.apiKey}function No(t){var e=Fo(t);return e?"https://www.googleapis.com/drive/v3/files/"+e+"?alt=media&supportsTeamDrives=true":t}function Fo(t){if(t.includes("/open?id=")){const e=t.indexOf("/open?id=")+9,i=t.indexOf("&");if(e>0&&i>e)return t.substring(e,i);if(e>0)return t.substring(e)}else{if(t.includes("/file/d/")){const e=t.indexOf("/file/d/")+8,i=t.lastIndexOf("/");return t.substring(e,i)}if(t.startsWith("https://www.googleapis.com/drive")){let e=t.indexOf("/files/");const i=t.indexOf("?");if(e>0)return e+=7,i>0?t.substring(e,i):t.substring(e)}}throw Error("Unknown Google Drive url format: "+t)}Mo.set("!","%21"),Mo.set("#","%23"),Mo.set("$","%24"),Mo.set("%","%25"),Mo.set("&","%26"),Mo.set("'","%27"),Mo.set("(","%28"),Mo.set(")","%29"),Mo.set("*","%2A"),Mo.set("+","%2B"),Mo.set(",","%2C"),Mo.set("/","%2F"),Mo.set(":","%3A"),Mo.set(";","%3B"),Mo.set("=","%3D"),Mo.set("?","%3F"),Mo.set("@","%40"),Mo.set("[","%5B"),Mo.set("]","%5D"),Mo.set(" ","%20");class Oo{constructor(t){this.requestsPerSecond=t.requestsPerSecond||10,this.lastStartTime=0,this.queued=[]}add(t,e){var i=this;return new Promise((function(e,n){i.queued.push({resolve:e,reject:n,asyncFunction:t}),i.dequeue()}))}addAll(t,e){var i=t.map(function(t){return this.add(t,e)}.bind(this));return Promise.all(i)}dequeue(){if(this.queued.length>0){var t=new Date,e=1e3/this.requestsPerSecond+1,i=t-this.lastStartTime;i>=e?this._execute():setTimeout(function(){this.dequeue()}.bind(this),e-i)}}async _execute(){this.lastStartTime=new Date;var t=this.queued.shift();const e=t.asyncFunction;try{const i=await e();t.resolve(i)}catch(e){t.reject(e)}}}function Do(){if(Ro())return Ro()&&google.igv.tokenResponse&&Date.now()0)for(var o=0;othis._loadURL(t,e))):this._loadURL(t,e)}throw Error(`url must be either a 'File', 'string', 'function', or 'Promise'. Actual type: ${i}`)}async _loadURL(t,e){const i=this,n=t;t=function(t){return t.startsWith("https://www.dropbox.com")?t.replace("//www.dropbox.com","//dl.dropboxusercontent.com"):t.startsWith("https://drive.google.com")?No(t):t.includes("//www.broadinstitute.org/igvdata")?t.replace("//www.broadinstitute.org/igvdata","//data.broadinstitute.org/igvdata"):t.includes("//igvdata.broadinstitute.org")?t.replace("//igvdata.broadinstitute.org","//s3.amazonaws.com/igv.broadinstitute.org"):t.includes("//igv.genepattern.org")?t.replace("//igv.genepattern.org","//igv-genepattern-org.s3.amazonaws.com"):t.startsWith("ftp://ftp.ncbi.nlm.nih.gov/geo")?t.replace("ftp://","https://"):t}(t);let r=(e=e||{}).oauthToken||this.getOauthToken(t);return r&&(r=await("function"==typeof r?r():r)),new Promise((function(s,o){To(t)&&!function(t){return t.indexOf("X-Goog-Signature")>-1}(t)&&(Io(t)&&(t=function(t){let{bucket:e,object:i}=function(t){let e,i;if(t.startsWith("gs://")){const n=t.indexOf("/",5);if(n>=0){e=t.substring(5,n);const r=t.indexOf("?");i=r<0?t.substring(n+1):t.substring(n+1,r)}}else if(t.startsWith("https://storage.googleapis.com")||t.startsWith("https://storage.cloud.google.com")){const n=t.indexOf("/v1/b/",8);if(n>0){const r=t.indexOf("/o/",n);if(r>0){const s=t.indexOf("?",r);e=t.substring(n+6,r),i=s>0?t.substring(r+3,s):t.substring(r+3)}}else{const n=t.indexOf("/",8),r=t.indexOf("/",n+1),s=t.indexOf("?",r);r>0&&(e=t.substring(n+1,r),i=s<0?t.substring(r+1):t.substring(r+1,s))}}else if(t.startsWith("https://www.googleapis.com/storage/v1/b")){const n=t.indexOf("/v1/b/",8),r=t.indexOf("/o/",n);if(r>0){const s=t.indexOf("?",r);e=t.substring(n+6,r),i=s>0?t.substring(r+3,s):t.substring(r+3)}}if(e&&i)return{bucket:e,object:i};throw Error(`Unrecognized Google Storage URI: ${t}`)}(t);i=function(t){let e="";return t.split("").forEach((function(t){Mo.has(t)?e+=Mo.get(t):e+=t})),e}(i);const n=t.indexOf("?");return`https://storage.googleapis.com/storage/v1/b/${e}/o/${i}${n>0?t.substring(n)+"&alt=media":"?alt=media"}`}(t)),t=function(t){let e=zo.apiKey;if(e||"undefined"==typeof gapi||(e=gapi.apiKey),void 0!==e&&!t.includes("key=")){const i=t.includes("?")?"&":"?";t=t+i+"key="+e}return t}(t),Eo(t)&&function(t){if(t.includes("supportsTeamDrive"))return t;{const e=t.includes("?")?"&":"?";t=t+e+"supportsTeamDrive=true"}}(t),r||(r=Do()));const a=e.headers||{};r&&function(t,e){e&&(t["Cache-Control"]="no-cache",t.Authorization="Bearer "+e)}(a,r);const l=e.range,h=new XMLHttpRequest,c=e.sendData||e.body,u=e.method||(c?"POST":"GET"),d=e.responseType,f=e.contentType,p=e.mimeType;if(h.open(u,t),e.timeout&&(h.timeout=e.timeout),l){let t="";l.size&&(t=l.start+l.size-1),h.setRequestHeader("Range","bytes="+l.start+"-"+t)}if(f&&h.setRequestHeader("Content-Type",f),p&&h.overrideMimeType(p),d&&(h.responseType=d),a)for(let t of Object.keys(a)){const e=a[t];h.setRequestHeader(t,e)}!0===e.withCredentials&&(h.withCredentials=!0),h.onload=async function(n){if(0===h.status||h.status>=200&&h.status<=300)if("HEAD"===e.method){const t=e.requestedHeaders||["content-length"],i={};for(let e of t)i[e]=h.getResponseHeader(e);s(i)}else l&&206!==h.status&&0!==l.start?(h.response.length>1e5&&!i.RANGE_WARNING_GIVEN&&alert(`Warning: Range header ignored for URL: ${t}. This can have severe performance impacts.`),s(h.response.slice(l.start,l.start+l.size))):s(h.response);else 416===h.status?g(Error("416 Unsatisfiable Range")):"undefined"==typeof gapi||404!==h.status&&401!==h.status&&403!==h.status||!To(t)||e.retries?403===h.status?g("Access forbidden: "+t):g(h.status):m()},h.onerror=function(i){To(t)&&!e.retries?m():g("Error accessing resource: "+t+" Status: "+h.status)},h.ontimeout=function(t){g("Timed out")},h.onabort=function(t){console.log("Aborted"),o(t)};try{h.send(c)}catch(i){To(t)&&!e.retries?m():g(i)}function g(t){if(!o)throw t;o(t)}async function m(){try{const t=await async function(t){if(Ro()){const e=function(t){return Eo(t)?"https://www.googleapis.com/auth/drive.readonly":Io(t)?"https://www.googleapis.com/auth/devstorage.read_only":"https://www.googleapis.com/auth/userinfo.profile"}(t);return await Lo(e)}throw Error("Authorization is required, but Google oAuth has not been initalized. Contact your site administrator for assistance.")}(n);e.retries=1,e.oauthToken=t;const r=await i.load(n,e);s(r)}catch(t){if(t.error){const e=t.error.startsWith("popup_blocked")?"Google login popup blocked by browser.":t.error;alert(e)}else g(t)}}}))}async _loadFileSlice(t,e){let i=e&&e.range?t.slice(e.range.start,e.range.start+e.range.size):t;const n=await i.arrayBuffer();return"arraybuffer"===e.responseType?n:Po(n)}async _loadStringFromFile(t,e){const i=e.range?t.slice(e.range.start,e.range.start+e.range.size):t;return Po(await i.arrayBuffer())}async _loadStringFromUrl(t,e){return(e=e||{}).responseType="arraybuffer",Po(await this.load(t,e))}setOauthToken(t,e){this.oauth.setToken(t,e)}getOauthToken(t){const e=To(t)?void 0:Xi(t).host;let i=this.oauth.getToken(e);if(i)return i;if(void 0===e){const t=Do();if(t&&t.expires_at>Date.now())return t.access_token}}async getContentLength(t,e){(e=e||{}).method="HEAD",e.requestedHeaders=["content-length"];const i=(await this._loadURL(t,e))["content-length"];return i?Number.parseInt(i):0}};var Uo={color:1};Uo.parent=Uo,Uo.left=Uo,Uo.right=Uo;class Vo{constructor(){this.root=Uo}insert(t,e,i){var n=new Go(new Wo(t,e,i));for(this.treeInsert(n),n.color=2;n!==this.root&&2===n.parent.color;)if(n.parent===n.parent.parent.left){let t=n.parent.parent.right;2===t.color?(n.parent.color=1,t.color=1,n.parent.parent.color=2,n=n.parent.parent):(n===n.parent.right&&(n=n.parent,jo.call(this,n)),n.parent.color=1,n.parent.parent.color=2,$o.call(this,n.parent.parent))}else{let t=n.parent.parent.left;2===t.color?(n.parent.color=1,t.color=1,n.parent.parent.color=2,n=n.parent.parent):(n===n.parent.left&&(n=n.parent,$o.call(this,n)),n.parent.color=1,n.parent.parent.color=2,jo.call(this,n.parent.parent))}this.root.color=1}findOverlapping(t,e){var i=new Wo(t,e,0);if(this.root===Uo)return[];var n=Ho.call(this,i,this.root,[]);return n.length>1&&n.sort((function(t,e){return t.low-e.low})),n}logIntervals(){!function t(e,i){for(var n="",r=0;r=t.low&&Ho.call(this,t,e.left,i),e.right!==Uo&&e.right.min<=t.high&&Ho.call(this,t,e.right,i),i}function jo(t){var e=t.right;t.right=e.left,e.left!==Uo&&(e.left.parent=t),e.parent=t.parent,t.parent===Uo?this.root=e:t.parent.left===t?t.parent.left=e:t.parent.right=e,e.left=t,t.parent=e,qo.call(this,t)}function $o(t){var e=t.left;t.left=e.right,e.right!==Uo&&(e.right.parent=t),e.parent=t.parent,t.parent===Uo?this.root=e:t.parent.right===t?t.parent.right=e:t.parent.left=e,e.right=t,t.parent=e,qo.call(this,t)}function qo(t){for(;t!==Uo;){var e=t.left.max>t.right.max?t.left.max:t.right.max,i=t.interval.high;t.max=e>i?e:i;var n=t.left.mint.low?1:this.hight.high?1:0}overlaps(t){return this.low<=t.high&&t.low<=this.high}}function Go(t){this.parent=Uo,this.left=Uo,this.right=Uo,this.interval=t,this.color=2}class Zo{constructor(t,e,i){t=t||[],this.treeMap=this.buildTreeMap(t,e),this.range=i,this.count=t.length}containsRange(t){return void 0===this.range||this.range.contains(t.chr,t.start,t.end)}queryFeatures(t,e,i){const n=this.treeMap[t];if(!n)return[];const r=n.findOverlapping(e,i);if(0===r.length)return[];{const n=[],s=this.allFeatures[t];if(s){for(let t of r){const r=t.value;for(let t=r.start;ti)break;r.end>=e&&n.push(r)}}n.sort((function(t,e){return t.start-e.start}))}return n}}getAllFeatures(){return this.allFeatures}buildTreeMap(t,e){const i={},n=[];if(this.allFeatures={},t){for(let i of t){let t=i.chr;e&&(t=e.getChromosomeName(t));let r=this.allFeatures[t];r||(n.push(t),r=[],this.allFeatures[t]=r),r.push(i)}for(let t of n){const e=this.allFeatures[t];e.sort((function(t,e){return t.start===e.start?0:t.start>e.start?1:-1})),i[t]=Yo(e)}}return i}}function Yo(t){const e=new Vo,i=t.length,n=Math.max(10,Math.round(i/10));for(let r=0;re.start?1:-1}));for(let r=0;ri)break;s.end>e&&t.push(s)}})),t.sort((function(t,e){return t.start-e.start})),t)}return[]},Ko={cantaloupe:{r:255,g:206,b:110},honeydew:{r:206,g:250,b:110},spindrift:{r:104,g:251,b:208},sky:{r:106,g:207,b:255},lavender:{r:210,g:120,b:255},carnation:{r:255,g:127,b:211},licorice:{r:0,g:0,b:0},snow:{r:255,g:255,b:255},salmon:{r:255,g:114,b:110},banana:{r:255,g:251,b:109},flora:{r:104,g:249,b:110},ice:{r:104,g:253,b:255},orchid:{r:110,g:118,b:255},bubblegum:{r:255,g:122,b:255},lead:{r:30,g:30,b:30},mercury:{r:232,g:232,b:232},tangerine:{r:255,g:136,b:2},lime:{r:131,g:249,b:2},sea_foam:{r:3,g:249,b:135},aqua:{r:0,g:140,b:255},grape:{r:137,g:49,b:255},strawberry:{r:255,g:41,b:135},tungsten:{r:58,g:58,b:58},silver:{r:208,g:208,b:208},maraschino:{r:255,g:33,b:1},lemon:{r:255,g:250,b:3},spring:{r:5,g:248,b:2},turquoise:{r:0,g:253,b:255},blueberry:{r:0,g:46,b:255},magenta:{r:255,g:57,b:255},iron:{r:84,g:84,b:83},magnesium:{r:184,g:184,b:184},mocha:{r:137,g:72,b:0},fern:{r:69,g:132,b:1},moss:{r:1,g:132,b:72},ocean:{r:0,g:74,b:136},eggplant:{r:73,g:26,b:136},maroon:{r:137,g:22,b:72},steel:{r:110,g:110,b:110},aluminum:{r:160,g:159,b:160},cayenne:{r:137,g:17,b:0},aspargus:{r:136,g:133,b:1},clover:{r:2,g:132,b:1},teal:{r:0,g:134,b:136},midnight:{r:0,g:24,b:136},plum:{r:137,g:30,b:136},tin:{r:135,g:134,b:135},nickel:{r:136,g:135,b:135}},Jo={Set1:["rgb(228,26,28)","rgb(55,126,184)","rgb(77,175,74)","rgb(166,86,40)","rgb(152,78,163)","rgb(255,127,0)","rgb(247,129,191)","rgb(153,153,153)","rgb(255,255,51)"],Dark2:["rgb(27,158,119)","rgb(217,95,2)","rgb(117,112,179)","rgb(231,41,138)","rgb(102,166,30)","rgb(230,171,2)","rgb(166,118,29)","rgb(102,102,102)"],Set2:["rgb(102, 194,165)","rgb(252,141,98)","rgb(141,160,203)","rgb(231,138,195)","rgb(166,216,84)","rgb(255,217,47)","rgb(229,196,148)","rgb(179,179,179)"],Set3:["rgb(141,211,199)","rgb(255,255,179)","rgb(190,186,218)","rgb(251,128,114)","rgb(128,177,211)","rgb(253,180,98)","rgb(179,222,105)","rgb(252,205,229)","rgb(217,217,217)","rgb(188,128,189)","rgb(204,235,197)","rgb(255,237,111)"],Pastel1:["rgb(251,180,174)","rgb(179,205,227)","rgb(204,235,197)","rgb(222,203,228)","rgb(254,217,166)","rgb(255,255,204)","rgb(229,216,189)","rgb(253,218,236)"],Pastel2:["rgb(173,226,207)","rgb(253,205,172)","rgb(203,213,232)","rgb(244,202,228)","rgb(230,245,201)","rgb(255,242,174)","rgb(243,225,206)"],Accent:["rgb(127,201,127)","rgb(190,174,212)","rgb(253,192,134)","rgb(255,255,153)","rgb(56,108,176)","rgb(240,2,127)","rgb(191,91,23)"]};class ta{constructor(t){this.colors=Jo[t],Array.isArray(this.colors)||(this.colors=[]),this.colorTable={},this.nextIdx=0,this.colorGenerator=new ia}getColor(t){return this.colorTable.hasOwnProperty(t)||(this.nextIdxthis.hexwidth?t:new Array(this.hexwidth-t.length+1).join("0")+t},ia.prototype.get=function(t,e){this.hue+=this.goldenRatio,this.hue%=1,"number"!=typeof t&&(t=.5),"number"!=typeof e&&(e=.95);var i=this.hsvToRgb(this.hue,t,e);return"#"+this.padHex(i[0].toString(16))+this.padHex(i[1].toString(16))+this.padHex(i[2].toString(16))},new ia;const na={configureHighDPICanvas:function(t,e,i){const n=window.devicePixelRatio;t.canvas.style.width=`${e}px`,t.canvas.width=Math.floor(n*e),t.canvas.style.height=`${i}px`,t.canvas.height=Math.floor(n*i),t.scale(n,n)},setProperties:function(t,e){for(var i in e)if(e.hasOwnProperty(i)){var n=e[i];t[i]=n}},strokeLine:function(t,e,i,n,r,s){e=Math.floor(e)+.5,i=Math.floor(i)+.5,n=Math.floor(n)+.5,r=Math.floor(r)+.5,s&&(t.save(),na.setProperties(t,s)),t.beginPath(),t.moveTo(e,i),t.lineTo(n,r),t.stroke(),s&&t.restore()},fillRect:function(t,e,i,n,r,s){e=Math.round(e),i=Math.round(i),s&&(t.save(),na.setProperties(t,s)),t.fillRect(e,i,n,r),s&&t.restore()},fillPolygon:function(t,e,i,n){n&&(t.save(),na.setProperties(t,n)),ra(t,e,i),t.fill(),n&&t.restore()},strokePolygon:function(t,e,i,n){n&&(t.save(),na.setProperties(t,n)),ra(t,e,i),t.stroke(),n&&t.restore()},fillText:function(t,e,i,n,r,s){if((r||s)&&t.save(),r&&na.setProperties(t,r),s){for(var o in t.translate(i,n),s){var a=s[o];"translate"===o&&t.translate(a.x,a.y),"rotate"===o&&t.rotate(a.angle*Math.PI/180)}t.fillText(e,0,0)}else t.fillText(e,i,n);(r||s)&&t.restore()},strokeText:function(t,e,i,n,r,s){if((r||s)&&t.save(),r&&na.setProperties(t,r),s){for(var o in t.translate(i,n),s){var a=s[o];"translate"===o&&t.translate(a.x,a.y),"rotate"===o&&t.rotate(a.angle*Math.PI/180)}t.strokeText(e,0,0)}else t.strokeText(e,i,n);(r||s)&&t.restore()},strokeCircle:function(t,e,i,n,r){r&&(t.save(),na.setProperties(t,r)),t.beginPath(),t.arc(e,i,n,0,2*Math.PI),t.stroke(),r&&t.restore()},fillCircle:function(t,e,i,n,r){r&&(t.save(),na.setProperties(t,r)),t.beginPath(),t.arc(e,i,n,0,2*Math.PI),t.fill(),r&&t.restore()},drawArrowhead:function(t,e,i,n,r){t.save(),n||(n=5),r&&(t.lineWidth=r),t.beginPath(),t.moveTo(e,i-n/2),t.lineTo(e,i+n/2),t.lineTo(e+n,i),t.lineTo(e,i-n/2),t.closePath(),t.fill(),t.restore()},dashedLine:function(t,e,i,n,r,s,o={}){void 0===s&&(s=2),t.setLineDash([s,s]),na.strokeLine(t,e,i,n,r,o),t.setLineDash([])},roundRect:function(t,e,i,n,r,s,o,a){void 0===a&&(a=!0),void 0===s&&(s=5),t.beginPath(),t.moveTo(e+s,i),t.lineTo(e+n-s,i),t.quadraticCurveTo(e+n,i,e+n,i+s),t.lineTo(e+n,i+r-s),t.quadraticCurveTo(e+n,i+r,e+n-s,i+r),t.lineTo(e+s,i+r),t.quadraticCurveTo(e,i+r,e,i+r-s),t.lineTo(e,i+s),t.quadraticCurveTo(e,i,e+s,i),t.closePath(),a&&t.stroke(),o&&t.fill()},polygon:function(t,e,i,n,r){void 0===r&&(r=!0),t.beginPath();var s=e.length;t.moveTo(e[0],i[0]);for(var o=1;o{for(let n=0;n{t.translate(e,0),t.scale(-1,1),t.translate(-e,0)}};function ra(t,e,i){var n,r=e.length;for(n=0;n0){e=Number.MAX_VALUE,i=-Number.MAX_VALUE;for(let n of t)Number.isNaN(n.value)||(e=Math.min(e,n.value),i=Math.max(i,n.value));i>0&&(e=Math.min(0,e)),i<0&&(i=0)}else e=0,i=100;return{min:e,max:i}},ca=function(t,e,i){let n=e.start,r=e.end;if(void 0===r)n-=i/2,r=n+i,r>t?(r=t,n=r-i):n<0&&(n=0,r=i);else if(r-nt?(r=t,n=r-i):(n=e-i/2,r=n+i)}e.start=Math.ceil(n),e.end=Math.floor(r)};async function ua(t){if(ji(t)&&t.startsWith("https://drive.google.com")){if(void 0===Bo())throw Error("Google drive is referenced, but API key is not defined. An API key is required for Google Drive access");const e=await async function(t){let e="https://www.googleapis.com/drive/v3/files/"+Fo(t)+"?supportsTeamDrives=true";const i=Bo();i&&(e+="&key="+i);const n=await fetch(e);let r=await n.json();if(r.error&&404===r.error.code){let t="https://www.googleapis.com/auth/drive.readonly";const i=await Lo(t);if(!i)throw Error(r.error);{const t=await fetch(e,{headers:{Authorization:`Bearer ${i}`}});if(r=await t.json(),r.error)throw Error(r.error)}}return r}(t);return e.originalFileName||e.name}return Zi(t)}function da(t){var e,i;return t>1e7?(e=" mb",i=t/1e6,Math.floor(i).toString()+e):t>1e4?(e=" kb",i=t/1e3,$i(Math.floor(i))+e):$i(t)+" bp"}function fa(t){return ji(t)&&t.startsWith("data:")}function pa(t,e){const i=_e.div({class:e});t.appendChild(i)}function ga(t,e){e.parentNode.insertBefore(t,e)}function ma(t,e){e.parentNode.insertBefore(t,e.nextSibling)}function ba(){return"https:"===window.location.protocol||"localhost"===window.location.hostname}function ya(t,e){if(t.length<6)return void console.log("Skipping line: "+t.join(" "));var i={chr1:t[0],start1:Number.parseInt(t[1]),end1:Number.parseInt(t[2]),chr2:t[3],start2:Number.parseInt(t[4]),end2:Number.parseInt(t[5])};if(isNaN(i.start1)||isNaN(i.end1)||isNaN(i.start2)||isNaN(i.end2))return;e&&void 0===e.hiccups&&(e.hiccups=!!e.columnNames&&wa(e.columnNames));const n=e&&e.hiccups,r=n?6:10;if(n||(t.length>6&&"."!==t[6]&&(i.name=t[6]),t.length>7&&"."!==t[7]&&(i.score=Number(t[7])),t.length>8&&"."!==t[8]&&(i.strand1=t[8]),t.length>9&&"."!==t[9]&&(i.strand2=t[9])),e){const n=e.colorColumn;n&&nr&&e.columnNames&&e.columnNames.length===t.length&&(i.extras=t.slice(r))}return i.chr1===i.chr2&&(i.chr=i.chr1,i.start=Math.min(i.start1,i.start2),i.end=Math.max(i.end1,i.end2)),i}function va(t,e){if(!(t.length<8))return{chr:t[0],start:Number.parseInt(t[1]),end:Number.parseInt(t[2]),color:xo.createColorString(t[6]),value:Number(t[7])}}function wa(t){return t&&(t.includes("fdrDonut")||t.includes("fdr_donut"))}const _a=new Set(["narrowpeak","broadpeak","regionpeak","peaks","bedgraph","wig","gff3","gff","gtf","fusionjuncspan","refflat","seg","aed","bed","vcf","bb","bigbed","biginteract","biggenepred","bignarrowpeak","bw","bigwig","bam","tdf","refgene","genepred","genepredext","bedpe","bp","snp","rmsk","cram","gwas","maf","mut","tsv","hiccups","fasta","fa","fna","pytor"]);function xa(t){return oa&&oa[t]?function(t){const e=t.fields,i=["chr","start","end"];for(let n=0;n0&&(t=t.substr(0,e)),t.endsWith(".gz")&&(t=t.substr(0,t.length-3)),(t.endsWith(".txt")||t.endsWith(".tab")||t.endsWith(".bgz"))&&(t=t.substr(0,t.length-4)),i=(e=t.lastIndexOf("."))<0?t:t.substr(e+1)){case"bw":return"bigwig";case"bb":return"bigbed";case"fasta":case"fa":case"fna":return"fasta";default:return _a.has(i)?i:void 0}}function Sa(t,e){if(ji(t)){if(t.includes("?")){const i=t.indexOf("?");return t.substring(0,i)+"."+e+t.substring(i)}return t+"."+e}}function Ca(t){if(function(t){t.featureType&&(t.type=t.type||t.featureType,t.featureType=void 0),"junctions"===t.type?t.type="junction":"bed"===t.type?(t.type="annotation",t.format=t.format||"bed"):"annotations"===t.type?t.type="annotation":"alignments"===t.type?t.type="alignment":"bam"===t.type?(t.type="alignment",t.format="bam"):"vcf"===t.type?(t.type="variant",t.format="vcf"):"t2d"===t.type?t.type="gwas":"FusionJuncSpan"!==t.type||t.format?"aed"===t.type&&(t.type="annotation",t.format=t.format||"aed"):t.format="fusionjuncspan"}(t),t.type)return t.type;if(t.format)switch(t.format.toLowerCase()){case"bw":case"bigwig":case"wig":case"bedgraph":case"tdf":return"wig";case"vcf":return"variant";case"seg":return"seg";case"mut":case"maf":return"mut";case"bam":case"cram":return"alignment";case"hiccups":case"bedpe":case"bedpe-loop":case"biginteract":return"interact";case"bp":return"arc";case"gwas":return"gwas";case"bed":case"bigbed":case"bb":case"biggenepred":case"bignarrowpeak":return"bedtype";case"fasta":return"sequence";case"pytor":return"cnvpytor";default:return"annotation"}}async function Aa(t){if(t.url){const e=await zo.loadString(t.url,la(t,{range:{start:0,size:1e3}}));if(e&&wa(e.split("\n")[0].split("\t")))return"hiccups"}}function Ta(t,e){oa[t]={fields:e}}var Ia=Object.freeze({__proto__:null,knownFileExtensions:_a,getFormat:xa,inferFileFormat:ka,inferFileFormatFromHeader:Aa,inferTrackType:Ca,inferIndexPath:Sa,registerFileFormats:Ta});const Ea=[["A","T"],["G","C"],["Y","R"],["W","S"],["K","M"],["D","H"],["B","V"]],Ma=new Map;for(let by of Ea){const yy=by[0],vy=by[1];Ma.set(yy,vy),Ma.set(vy,yy),Ma.set(yy.toLowerCase(),vy.toLowerCase()),Ma.set(vy.toLowerCase(),yy.toLowerCase())}function Ra(t){let e="",i=t.length;for(;i-- >0;){const n=t[i];e+=Ma.has(n)?Ma.get(n):n}return e}class La{constructor(t,e,i){this.name=t,this.order=e,this.bpLength=i}}const Ba=qi,Na=new Set(["fastaURL","indexURL","cytobandURL","indexed"]);class Fa{constructor(t){this.fastaURL=t.fastaURL,this.withCredentials=t.withCredentials,this.chromosomeNames=[],this.chromosomes={},this.sequences=new Map;const e={};for(let i in t)t.hasOwnProperty(i)&&!Na.has(i)&&(e[i]=t[i]);this.config=e}async init(){return this.loadAll()}async getSequence(t,e,i){if(!this.sequences.has(t))return;let n=this.sequences.get(t).find((t=>t.contains(e,i)));if(!n&&(n=this.sequences.get(t).find((t=>t.overlaps(e,i))),!n))return;e-=n.offset,i-=n.offset;let r="";if(e<0)for(let t=e;t")){a&&a.seq&&l.call(this,a,o++);const t=r.substr(1).split(/\s+/),e=t[0].split(":");if(a.chr=e[0],a.seq="",a.offset=0,e.length>1&&e[1].indexOf("-")>0){const i=e[1].split("-");2===i.length&&/^[0-9]+$/.test(i[0])&&/^[0-9]+$/.test(i[1]);const n=Number.parseInt(i[0]);if(Number.parseInt(i[1])>n&&(a.offset=n-1),t.length>1&&t[1].startsWith("@len="))try{a.length=parseInt(t[1].trim().substring(5))}catch(t){a.length=void 0,console.error(`Error parsing sequence length for ${r}`)}else a.length=void 0}}else a.seq+=r;a&&a.seq&&l.call(this,a,o)}function l(t,i){const n=t.length||t.offset+t.seq.length;if(e.has(t.chr)){const e=this.chromosomes[t.chr];e.bpLength=Math.max(e.bpLength,n)}else this.chromosomeNames.push(t.chr),this.sequences.set(t.chr,[]),this.chromosomes[t.chr]=new La(t.chr,i,n),e.add(t.chr);this.sequences.get(t.chr).push(new Oa(t.offset,t.seq))}}}class Oa{constructor(t,e){this.offset=t,this.sequence=e}contains(t,e){return this.offset<=t&&this.end>=e}overlaps(t,e){return this.offsett}get end(){return this.offset+this.sequence.length}}const Da=function(t,e,i,n){this.chr=t,this.start=e,this.end=i,this.features=n};Da.prototype.contains=function(t,e,i){return this.chr===t&&this.start<=e&&this.end>=i},Da.prototype.containsRange=function(t){return this.chr===t.chr&&this.start<=t.start&&this.end>=t.end};const Pa=qi,za=new Set(["fastaURL","indexURL","compressedIndexURL","cytobandURL","indexed"]);class Ua{constructor(t){this.file=t.fastaURL,this.indexFile=t.indexURL||t.indexFile||this.file+".fai",this.compressedIndexFile=t.compressedIndexURL||!1,this.withCredentials=t.withCredentials,this.chromosomeNames=[],this.chromosomes={},this.sequences={},this.offsets={};const e={};for(let i in t)t.hasOwnProperty(i)&&!za.has(i)&&(e[i]=t[i]);this.config=e}async init(){return this.getIndex()}async getSequence(t,e,i){if(!this.interval||!this.interval.contains(t,e,i)){let n=e,r=i;if(i-e<5e4){const t=i-e,s=Math.round(e+t/2);n=Math.max(0,s-25e3),r=s+25e3}const s=await this.readSequence(t,n,r);this.interval=new Da(t,n,r,s)}const n=e-this.interval.start,r=i-e;return this.interval.features?this.interval.features.substr(n,r):null}async getIndex(){if(this.index)return this.index;{const t=await zo.load(this.indexFile,la(this.config)),e=Pa(t),i=e.length;let n=0,r=0;for(this.index={};nthis.compressedIndex[n][1])return[n];let r=0,s=n,o=Math.floor(this.compressedIndex.length/2),a=this.compressedIndex.length+1,l=!1;for(let e=0;et){l=!0;break}e=e));t++);const h=i[i.length-1];return h===this.compressedIndex.length-1&&this.compressedIndex[h][1]0&&(b=Math.min(s-r,a-d),y+=m.substr(v,b),v+=b+h);v{this.reversed=!this.reversed,this.trackView.repaintViews()}},{name:this.frameTranslate?"Close Translation":"Three-frame Translate",click:()=>{if(this.frameTranslate=!this.frameTranslate,this.frameTranslate){for(let t of this.trackView.viewports)t.setContentHeight(Qa);this.trackView.setTrackHeight(Qa)}else{for(let t of this.trackView.viewports)t.setContentHeight(25);this.trackView.setTrackHeight(25)}this.trackView.repaintViews()}}]}contextMenuItemList(t){const e=t.viewport;if(e.referenceFrame.bpPerPixel<=1){const t=e.getWidth()*e.referenceFrame.bpPerPixel,i=e.referenceFrame.chr,n=Math.floor(e.referenceFrame.start),r=Math.ceil(n+t),s=[{label:this.reversed?"View visible sequence (reversed)...":"View visible sequence...",click:async()=>{let t=await this.browser.genome.sequence.getSequence(i,n,r);t?this.reversed&&(t=Ra(t)):t="Unknown sequence",this.browser.alert.present(t)}}];return ba()&&s.push({label:"Copy visible sequence",click:async()=>{let t=await this.browser.genome.sequence.getSequence(i,n,r);t?this.reversed&&(t=Ra(t)):t="Unknown sequence";try{await navigator.clipboard.writeText(t)}catch(t){console.error(t),this.browser.alert.present(`error copying sequence to clipboard ${t}`)}}}),s.push("
"),s}}translateSequence(t){const e=[[],[],[]];for(let i of[0,1,2]){let n=i;for(;t.length-n>=3;){let r=t.slice(n,n+3);this.reversed&&(r=r.split("").reverse().join(""));const s=Wa[r.toUpperCase()]||"";e[i].push({codons:r,aminoA:s}),n+=3}}return e}async getSequenceSource(){return this.config.fastaURL?(this.fasta||(this.fasta=new Ka(this.config,this.browser.genome),await this.fasta.init()),this.fasta):this.browser.genome.sequence}async getFeatures(t,e,i,n){if(e=Math.floor(e),i=Math.floor(i),n&&n>10)return null;{const n=await this.getSequenceSource();return{bpStart:e,sequence:await n.getSequence(t,e,i)}}}draw(t){const e=t.context;if(t.features){let i=t.features.sequence;if(!i)return;this.reversed&&(i=i.split("").map((function(t){return Ga[t]})).join(""));const n=t.features.bpStart,r=1+t.bpStart+t.pixelWidth*t.bpPerPixel;for(let s=Math.floor(t.bpStart);s<=r;s++){const r=Math.floor(s-n);if(r>=0&&r.1)na.fillRect(e,n,5,o,10,{fillStyle:l});else{const i=n+.5*(o-e.measureText(a).width);"y"===t.axis?(e.save(),na.labelTransformWithContext(e,i),na.strokeText(e,a,i,15,{strokeStyle:l}),e.restore()):na.strokeText(e,a,i,15,{strokeStyle:l})}}}if(this.frameTranslate){let r=25;const s=this.translateSequence(i);for(let i=0;it.pixelWidth)break;let f=l.aminoA;l.aminoA.indexOf("STOP")>-1?(a="rgb(255, 0, 0)",f="STOP"):"M"===l.aminoA&&(a="rgb(0, 153, 0)",f="START"),na.fillRect(e,c,r,u-c,25,{fillStyle:a}),t.bpPerPixel<=.1&&na.strokeText(e,f,d-e.measureText(f).width/2,r+15)}r+=30}}}}get supportsWholeGenome(){return!1}computePixelHeight(t){return this.height=this.frameTranslate?Qa:25,this.height}fillColor(t){return this.color?this.color:"dna"===this.sequenceType?$a[t]||"gray":"rgb(0, 0, 150)"}getState(){const t={type:"sequence"};return this.order!==qa&&(t.order=this.order),this.reversed&&(t.revealed=!0),t}}class Ka{constructor(t,e){this.config=t,this.genome=e}async init(){this.fasta=await ja(this.config),this.chrNameMap=new Map;for(let t of this.fasta.chromosomeNames)this.chrNameMap.set(this.genome.getChromosomeName(t),t)}async getSequence(t,e,i){const n=this.chrNameMap.has(t)?this.chrNameMap.get(t):t;return this.fasta.getSequence(n,e,i)}}class Ja{constructor(t,e,i,n){this.guid=_e.guid(),this.trackView=t,this.referenceFrame=i,this.browser=t.browser,this.$viewport=fe('
'),e.appendChild(this.$viewport.get(0)),t.track.height&&(this.$viewport.get(0).style.height=`${t.track.height}px`),t.track instanceof Xa&&(this.alert=new Ei(this.$viewport.get(0))),this.contentTop=0,this.contentHeight=this.$viewport.height(),this.$viewport.width(n),this.initializationHelper()}initializationHelper(){}showMessage(t){this.messageDiv||(this.messageDiv=document.createElement("div"),this.messageDiv.className="igv-viewport-message",this.$viewport.append(fe(this.messageDiv))),this.messageDiv.textContent=t,this.messageDiv.style.display="inline-block"}hideMessage(t){this.messageDiv&&(this.messageDiv.style.display="none")}setTrackLabel(t){}startSpinner(){}stopSpinner(){}checkZoomIn(){return!0}shift(){}setTop(t){this.contentTop=t,this.$viewport.height()}async loadFeatures(){}clearCache(){}async repaint(){}draw(t,e,i){console.log("Viewport - draw(drawConfiguration, features, roiFeatures)")}checkContentHeight(t){let e=this.trackView.track;if(t=t||this.cachedFeatures,"FILL"===e.displayMode)this.setContentHeight(this.$viewport.height());else if("function"==typeof e.computePixelHeight&&t&&t.length>0){let i=e.computePixelHeight(t);i!==this.contentHeight&&this.setContentHeight(i)}}getContentHeight(){return this.contentHeight}setContentHeight(t){this.contentHeight=t}isLoading(){return!1}saveSVG(){}isVisible(){return this.$viewport.width()}setWidth(t){this.$viewport.width(t)}getWidth(){return this.$viewport.width()}getContentTop(){return this.contentTop}containsPosition(t,e){console.log("Viewport - containsPosition(chr, position)")}addMouseHandlers(){}removeMouseHandlers(){}dispose(){this.popover&&this.popover.dispose(),this.$viewport.get(0).remove();for(let t of Object.keys(this))this[t]=void 0}}function tl(t,e){var i,n=Object.keys(e);for(i=0;i0){"path"===this.__currentElement.nodeName&&(this.__currentElementsToStyle||(this.__currentElementsToStyle={element:e,children:[]}),this.__currentElementsToStyle.children.push(this.__currentElement),this.__applyCurrentDefaultPath());var i=this.__createElement("g");e.appendChild(i),this.__currentElement=i}var n=this.__currentElement.getAttribute("transform");n?n+=" ":n="",n+=t,this.__currentElement.setAttribute("transform",n)}addTrackGroupWithTranslationAndClipRect(t,e,i,n,r,s){const o=t+"_clip_rect";let a=this.__createElement("clipPath",{id:o});this.__defs.appendChild(a),a.appendChild(this.__createElement("rect",{x:"0",y:s.toString(),width:n.toString(),height:r.toString()}));let l=this.__createElement("g");this.__rootGroup.appendChild(l),l.setAttribute("transform",tl("translate({x},{y})",{x:e,y:i})),l.setAttribute("id",t+"_group"),l.setAttribute("clip-path",tl("url(#{id})",{id:o})),this.__currentElement=l}scale(t,e){void 0===e&&(e=t),this.__addTransform(tl("scale({x},{y})",{x:t,y:e}))}rotate(t){var e=180*t/Math.PI;this.__addTransform(tl("rotate({angle},{cx},{cy})",{angle:e,cx:0,cy:0}))}translate(t,e){this.__addTransform(tl("translate({x},{y})",{x:t,y:e}))}transform(t,e,i,n,r,s){this.__addTransform(tl("matrix({a},{b},{c},{d},{e},{f})",{a:t,b:e,c:i,d:n,e:r,f:s}))}beginPath(){var t;this.__currentDefaultPath="",this.__currentPosition={},t=this.__createElement("path",{},!0),this.__closestGroupOrSvg().appendChild(t),this.__currentElement=t}__applyCurrentDefaultPath(){var t=this.__currentElement;"path"===t.nodeName?t.setAttribute("d",this.__currentDefaultPath):console.error("Attempted to apply path command to node",t.nodeName)}__addPathCommand(t){this.__currentDefaultPath+=" ",this.__currentDefaultPath+=t}moveTo(t,e){"path"!==this.__currentElement.nodeName&&this.beginPath(),this.__currentPosition={x:t,y:e},this.__addPathCommand(tl("M {x} {y}",{x:t,y:e}))}closePath(){this.__currentDefaultPath&&this.__addPathCommand("Z")}lineTo(t,e){this.__currentPosition={x:t,y:e},this.__currentDefaultPath&&this.__currentDefaultPath.indexOf("M")>-1?this.__addPathCommand(tl("L {x} {y}",{x:t,y:e})):this.__addPathCommand(tl("M {x} {y}",{x:t,y:e}))}bezierCurveTo(t,e,i,n,r,s){this.__currentPosition={x:r,y:s},this.__addPathCommand(tl("C {cp1x} {cp1y} {cp2x} {cp2y} {x} {y}",{cp1x:t,cp1y:e,cp2x:i,cp2y:n,x:r,y:s}))}quadraticCurveTo(t,e,i,n){this.__currentPosition={x:i,y:n},this.__addPathCommand(tl("Q {cpx} {cpy} {x} {y}",{cpx:t,cpy:e,x:i,y:n}))}arcTo(t,e,i,n,r){var s=this.__currentPosition&&this.__currentPosition.x,o=this.__currentPosition&&this.__currentPosition.y;if(void 0!==s&&void 0!==o){if(r<0)throw new Error("IndexSizeError: The radius provided ("+r+") is negative.");if(s===t&&o===e||t===i&&e===n||0===r)this.lineTo(t,e);else{var a=nl([s-t,o-e]),l=nl([i-t,n-e]);if(a[0]*l[1]!=a[1]*l[0]){var h=a[0]*l[0]+a[1]*l[1],c=Math.acos(Math.abs(h)),u=nl([a[0]+l[0],a[1]+l[1]]),d=r/Math.sin(c/2),f=t+d*u[0],p=e+d*u[1],g=[-a[1],a[0]],m=[l[1],-l[0]],b=function(t){var e=t[0];return t[1]>=0?Math.acos(e):-Math.acos(e)},y=b(g),v=b(m);this.lineTo(f+g[0]*r,p+g[1]*r),this.arc(f,p,r,y,v)}else this.lineTo(t,e)}}}stroke(){"path"===this.__currentElement.nodeName&&this.__currentElement.setAttribute("paint-order","fill stroke markers"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement("stroke")}fill(){"path"===this.__currentElement.nodeName&&this.__currentElement.setAttribute("paint-order","stroke fill markers"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement("fill")}rect(t,e,i,n){"path"!==this.__currentElement.nodeName&&this.beginPath(),this.moveTo(t,e),this.lineTo(t+i,e),this.lineTo(t+i,e+n),this.lineTo(t,e+n),this.lineTo(t,e),this.closePath()}fillRect(t,e,i,n){n<0&&(e+=n,n=-n),i<0&&(t+=i,i=-i);var r,s,o,a={x:t,y:e,width:i,height:n};(!this.viewbox||(s=a,(r=this.viewbox).xs.x&&r.ys.y))&&(o=this.__createElement("rect",a,!0),this.__closestGroupOrSvg().appendChild(o),this.__currentElement=o,this.__applyStyleToCurrentElement("fill"))}strokeRect(t,e,i,n){var r;r=this.__createElement("rect",{x:t,y:e,width:i,height:n},!0),this.__closestGroupOrSvg().appendChild(r),this.__currentElement=r,this.__applyStyleToCurrentElement("stroke")}strokeEllipse(t,e,i,n,r,s,o,a){this.__ellipse(t,e,i,n,r,s,o,a,"stroke")}fillEllipse(t,e,i,n,r,s,o,a){this.__ellipse(t,e,i,n,r,s,o,a,"fill")}__ellipse(t,e,i,n,r,s,o,a,l){const h={cx:t,cy:e,rx:i,ry:n},c=this.__createElement("ellipse",h,!0);this.__closestGroupOrSvg().appendChild(c),this.__currentElement=c,this.__applyStyleToCurrentElement(l)}__clearCanvas(){for(var t=this.__closestGroupOrSvg().getAttribute("transform"),e=this.__root.childNodes[1],i=e.childNodes,n=i.length-1;n>=0;n--)i[n]&&e.removeChild(i[n]);this.__currentElement=e,this.__groupStack=[],t&&this.__addTransform(t)}clearRect(t,e,i,n){if(0!==t||0!==e||i!==this.width||n!==this.height){var r,s=this.__closestGroupOrSvg();r=this.__createElement("rect",{x:t,y:e,width:i,height:n,fill:"#FFFFFF"},!0),s.appendChild(r)}else this.__clearCanvas()}createLinearGradient(t,e,i,n){var r=this.__createElement("linearGradient",{id:el(this.__ids),x1:t+"px",x2:i+"px",y1:e+"px",y2:n+"px",gradientUnits:"userSpaceOnUse"},!1);return this.__defs.appendChild(r),new ol(r,this)}createRadialGradient(t,e,i,n,r,s){var o=this.__createElement("radialGradient",{id:el(this.__ids),cx:n+"px",cy:r+"px",r:s+"px",fx:t+"px",fy:e+"px",gradientUnits:"userSpaceOnUse"},!1);return this.__defs.appendChild(o),new ol(o,this)}__parseFont(){var t=/^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-,\'\"\sa-z0-9]+?)\s*$/i.exec(this.font),e={style:t[1]||"normal",size:t[4]||"10px",family:t[6]||"sans-serif",weight:t[3]||"normal",decoration:t[2]||"normal",href:null};return"underline"===this.__fontUnderline&&(e.decoration="underline"),this.__fontHref&&(e.href=this.__fontHref),e}__wrapTextLink(t,e){if(t.href){var i=this.__createElement("a");return i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t.href),i.appendChild(e),i}return e}__applyText(t,e,i,n){var r,s,o=this.__parseFont(),a=this.__closestGroupOrSvg(),l=this.__createElement("text",{"font-family":o.family,"font-size":o.size,"font-style":o.style,"font-weight":o.weight,"text-decoration":o.decoration,x:e,y:i,"text-anchor":(r=this.textAlign,s={left:"start",right:"end",center:"middle",start:"start",end:"end"},s[r]||s.start),"dominant-baseline":il(this.textBaseline)},!0);l.appendChild(this.__document.createTextNode(t)),this.__currentElement=l,this.__applyStyleToCurrentElement(n),a.appendChild(this.__wrapTextLink(o,l))}fillText(t,e,i){this.__applyText(t,e,i,"fill")}strokeText(t,e,i){this.__applyText(t,e,i,"stroke")}measureText(t){return this.__ctx.font=this.font,this.__ctx.measureText(t)}arc(t,e,i,n,r,s){if(n!==r){(n%=2*Math.PI)==(r%=2*Math.PI)&&(r=(r+2*Math.PI-.001*(s?-1:1))%(2*Math.PI));var o,a=t+i*Math.cos(r),l=e+i*Math.sin(r),h=t+i*Math.cos(n),c=e+i*Math.sin(n),u=s?0:1,d=r-n;d<0&&(d+=2*Math.PI),o=s?d>Math.PI?0:1:d>Math.PI?1:0,this.lineTo(h,c),this.__addPathCommand(tl("A {rx} {ry} {xAxisRotation} {largeArcFlag} {sweepFlag} {endX} {endY}",{rx:i,ry:i,xAxisRotation:0,largeArcFlag:o,sweepFlag:u,endX:a,endY:l})),this.__currentPosition={x:a,y:l}}}clip(){var t=this.__closestGroupOrSvg(),e=this.__createElement("clipPath"),i=el(this.__ids),n=this.__createElement("g");this.__applyCurrentDefaultPath(),t.removeChild(this.__currentElement),e.setAttribute("id",i),e.appendChild(this.__currentElement),this.__defs.appendChild(e),t.setAttribute("clip-path",tl("url(#{id})",{id:i})),t.appendChild(n),this.__currentElement=n}drawImage(){var t,e,i,n,r,s,o,a,l,h,c,u,d,f=Array.prototype.slice.call(arguments),p=f[0],g=0,m=0;if(3===f.length)t=f[1],e=f[2],i=r=p.width,n=s=p.height;else if(5===f.length)t=f[1],e=f[2],i=f[3],n=f[4],r=p.width,s=p.height;else{if(9!==f.length)throw new Error("Invalid number of arguments passed to drawImage: "+arguments.length);g=f[1],m=f[2],r=f[3],s=f[4],t=f[5],e=f[6],i=f[7],n=f[8]}o=this.__closestGroupOrSvg(),this.__currentElement;var b="translate("+t+", "+e+")";if(p instanceof ll){if((a=p.getSvg().cloneNode(!0)).childNodes&&a.childNodes.length>1){for(l=a.childNodes[0];l.childNodes.length;)d=l.childNodes[0].getAttribute("id"),this.__ids[d]=d,this.__defs.appendChild(l.childNodes[0]);if(h=a.childNodes[1]){var y,v=h.getAttribute("transform");y=v?v+" "+b:b,h.setAttribute("transform",y),o.appendChild(h)}}}else"CANVAS"!==p.nodeName&&"IMG"!==p.nodeName||((c=this.__createElement("image")).setAttribute("width",i),c.setAttribute("height",n),c.setAttribute("preserveAspectRatio","none"),(g||m||r!==p.width||s!==p.height)&&((u=this.__document.createElement("canvas")).width=i,u.height=n,u.getContext("2d").drawImage(p,g,m,r,s,0,0,i,n),p=u),c.setAttribute("transform",b),c.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href","CANVAS"===p.nodeName?p.toDataURL():p.getAttribute("src")),o.appendChild(c))}createPattern(t,e){let i,n=this.__document.__createElement("pattern"),r=el(this.__ids);return n.setAttribute("id",r),n.setAttribute("width",t.width),n.setAttribute("height",t.height),"CANVAS"===t.nodeName||"IMG"===t.nodeName?(i=this.__createElement("image"),i.setAttribute("width",t.width),i.setAttribute("height",t.height),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href","CANVAS"===t.nodeName?t.toDataURL():t.getAttribute("src")),n.appendChild(i),this.__defs.appendChild(n)):t instanceof ll&&(n.appendChild(t.__root.childNodes[1]),this.__defs.appendChild(n)),new al(n,this)}setLineDash(t){t&&t.length>0?this.lineDash=t.join(","):this.lineDash=null}drawFocusRing(){}createImageData(){}getImageData(){}putImageData(){}globalCompositeOperation(){}setTransform(){}}const hl=function(t,e,i,n){this.start=t,this.end=e,this.name=i,this.stain=0,"acen"===n?this.type="c":(this.type=n.charAt(1),"p"===this.type&&(this.stain=parseInt(n.substring(4))))};const cl=qi,ul={loadGenome:async function(t){const e=t.cytobandURL,i=t.aliasURL,n=await ja(t);let r;i&&(r=await function(t,e){return zo.loadString(t,la(e)).then((function(t){var e=cl(t),i=[];return e.forEach((function(t){!t.startsWith("#")&&t.length>0&&i.push(t.split("\t"))})),i}))}(i,n.config));const s=new dl(t,n,r);return e&&(s.cytobands=await async function(t,e,i){let n;if(fa(t)){const e=bo(t);n="";const i=e.length;for(let t=0;t1?function(t,e){let i;if(e.chromosomeOrder)Array.isArray(e.chromosomeOrder)?t.wgChromosomeNames=e.chromosomeOrder:t.wgChromosomeNames=e.chromosomeOrder.split(",").map((t=>t.trim())),i=t.wgChromosomeNames.map((e=>t.chromosomes[e])).filter((t=>void 0!==t));else{const e=Object.keys(t.chromosomes).map((e=>t.chromosomes[e].bpLength)).reduce(((t,e)=>Math.max(t,e)))/50;i=Object.values(t.chromosomes).filter((t=>t.bpLength>e));const n=i.filter((t=>r(t.name.replace("chr","")))),s=i.filter((t=>!r(t.name.replace("chr",""))));n.sort(((t,e)=>Number.parseInt(t.name.replace("chr",""))-Number.parseInt(e.name.replace("chr",""))));const o=n.map((t=>t.name));for(let t of s)o.push(t.name);t.wgChromosomeNames=o}const n=i.reduce(((t,e)=>t+e.bpLength),0);function r(t){return/^\d+$/.test(t)}t.chromosomes.all={name:"all",bpLength:n}}(this,t):this.wgChromosomeNames=e.chromosomeNames;var n={},r=this;n.all="all",this.chromosomeNames.forEach((function(t){var e=t.startsWith("chr")?t.substring(3):"chr"+t;n[e.toLowerCase()]=t,"chrM"===t&&(n.mt="chrM"),"MT"===t&&(n.chrm="MT"),n[t.toLowerCase()]=t})),i&&i.forEach((function(t){var e,i;for(i=0;it.bpLength)&&(t=i)}return t}}getChromosomes(){return this.chromosomes}getGenomeCoordinate(t,e){var i=this.getCumulativeOffset(t);if(void 0!==i)return i+e}getChromosomeCoordinate(t){let e;void 0===this.cumulativeOffsets&&(this.cumulativeOffsets=computeCumulativeOffsets.call(this));let i=0;for(let n of this.wgChromosomeNames){const r=this.cumulativeOffsets[n];if(r>t)return{chr:e,position:t-i};e=n,i=r}return{chr:this.wgChromosomeNames[this.wgChromosomeNames.length-1],position:0}}getCumulativeOffset(t){void 0===this.cumulativeOffsets&&(this.cumulativeOffsets=function(){let t=this,e={},i=0;for(let n of t.wgChromosomeNames)e[n]=Math.floor(i),i+=t.getChromosome(n).bpLength;return e}.call(this));const e=this.getChromosomeName(t);return this.cumulativeOffsets[e]}getGenomeLength(){let t=this;if(!this.bpLength){let e=0;t.wgChromosomeNames.forEach((function(i){let n=t.chromosomes[i];e+=n.bpLength})),this.bpLength=e}return this.bpLength}async getSequence(t,e,i){return t=this.getChromosomeName(t),this.sequence.getSequence(t,e,i)}addFeaturesToDB(t,e){const i=(t,e)=>{const i=this.featureDB.get(t);i&&(e=e.end-e.start>i.end-i.start?e:i),this.featureDB.set(t,e)};for(let n of t)if(n.name&&i(n.name.toUpperCase(),n),n.gene&&n.gene.name&&i(n.gene.name.toUpperCase(),n),e.searchableFields)for(let t of e.searchableFields){const e=n.getAttributeValue(t);e&&(e.indexOf(" ")>0?i(e.replaceAll(" ","+").toUpperCase(),n):i(e.toUpperCase(),n))}}}let fl,pl=0,gl=0;class ml extends Ja{constructor(t,e,i,n){super(t,e,i,n)}initializationHelper(){this.$spinner=fe("
",{class:"igv-loading-spinner-container"}),this.$viewport.append(this.$spinner),this.$spinner.append(fe("
"));const t=this.trackView.track;"sequence"!==t.type&&(this.$zoomInNotice=this.createZoomInNotice(this.$viewport)),t.name&&"sequence"!==t.id&&(this.$trackLabel=fe('
'),this.$viewport.append(this.$trackLabel),this.setTrackLabel(t.name),!1===this.browser.trackLabelsVisible&&this.$trackLabel.hide()),this.stopSpinner(),this.addMouseHandlers()}setContentHeight(t){super.setContentHeight(t),this.featureCache&&(this.featureCache.redraw=!0)}setTrackLabel(t){this.$trackLabel.empty(),this.$trackLabel.html(t);const e=this.$trackLabel.text();this.$trackLabel.attr("title",e)}startSpinner(){this.$spinner.show()}stopSpinner(){this.$spinner&&this.$spinner.hide()}checkZoomIn(){if(this.trackView.track&&"sequence"===this.trackView.track.type&&this.referenceFrame.bpPerPixel>10)return fe(this.canvas).remove(),this.canvas=void 0,!1;if(!this.viewIsReady())return!1;if((()=>{if("all"!==this.referenceFrame.chr.toLowerCase()||this.trackView.track.supportsWholeGenome){const t=this.trackView.track.visibilityWindow;return void 0!==t&&t>0&&this.referenceFrame.bpPerPixel*this.$viewport.width()>t}return!0})()){if(this.canvas&&(fe(this.canvas).remove(),this.canvas=void 0),this.trackView.track.autoHeight){const t=this.trackView.minHeight||0;this.setContentHeight(t)}return this.$zoomInNotice&&this.$zoomInNotice.show(),!1}return this.$zoomInNotice&&this.$zoomInNotice.hide(),!0}shift(){const t=this.referenceFrame;if(this.canvas&&this.canvas._data&&this.canvas._data.referenceFrame.chr===this.referenceFrame.chr&&this.canvas._data.bpPerPixel===t.bpPerPixel){const e=Math.round((this.canvas._data.bpStart-t.start)/t.bpPerPixel);this.canvas.style.left=e+"px"}}setTop(t){if(super.setTop(t),this.canvas){const e=this.$viewport.height(),i=t+this.canvas._data.pixelTop,n=i+this.canvas._data.pixelHeight;(i>0||n0)for(let n of i.roiSets){const i=await n.getFeatures(e,r,s,t.bpPerPixel);o.push({track:n,features:i})}const a=i&&("wig"===i.type||"merged"===i.type);return this.featureCache=new bl(e,r,s,t.bpPerPixel,n,o,a),this.loading=!1,this.hideMessage(),this.stopSpinner(),this.featureCache}}catch(t){this.trackView&&!0!==this.trackView.disposed&&(this.showMessage("Error loading track data"),this.browser.alert.present(t),console.error(t))}finally{this.loading=!1,this.stopSpinner()}}}repaintDimensions(){const t=ul.isWholeGenomeView(this.referenceFrame.chr),e=t?this.$viewport.width():3*this.$viewport.width(),i=this.referenceFrame.bpPerPixel;return{bpStart:this.referenceFrame.start-(t?0:e/3*i),bpEnd:this.referenceFrame.end+(t?0:e/3*i),pixelWidth:e}}repaint(){if(void 0===this.featureCache)return;const{features:t,roiFeatures:e}=this.featureCache,{bpStart:i,bpEnd:n,pixelWidth:r}=this.repaintDimensions(),s=this.$viewport.height(),o=this.getContentHeight(),a=e?Math.max(o,s):o,l=Math.min(a,3*s);if(0===r||0===l)return void(this.canvas&&fe(this.canvas).remove());const h=Math.max(0,-this.contentTop-Math.floor(l/3)),c=this.referenceFrame.bpPerPixel,u=Math.round((i-this.referenceFrame.start)/c),d=(this.contentTop||0)+h,f=document.createElement("canvas");f.style.position="relative",f.style.display="block",f.style.width=r+"px",f.style.height=l+"px",f.style.left=u+"px",f.style.top=d+"px";const p="FILL"===this.trackView.track.displayMode||!1!==this.trackView.track.supportHiDPI?window.devicePixelRatio:1;f.width=p*r,f.height=p*l;const g=f.getContext("2d");g.scale(p,p),g.translate(0,-h);const m={context:g,pixelXOffset:u,pixelWidth:r,pixelHeight:l,pixelTop:h,bpStart:i,bpEnd:n,bpPerPixel:c,referenceFrame:this.referenceFrame,selection:this.selection,viewport:this,viewportWidth:this.$viewport.width()};this.draw(m,t,e),this.canvas&&fe(this.canvas).remove(),f._data=m,this.canvas=f,this.$viewport.append(fe(f))}refresh(){if(!this.canvas||!this.featureCache)return;const t=this.canvas._data;t.context.clearRect(0,0,this.canvas.width,this.canvas.height);const{features:e,roiFeatures:i}=this.featureCache;this.draw(t,e,i)}draw(t,e,i){if(e&&(t.features=e,this.trackView.track.draw(t)),i&&i.length>0)for(let e of i)t.features=e.features,e.track.draw(t)}containsPosition(t,e){return this.referenceFrame.chr===t&&e>=this.referenceFrame.start&&e<=this.referenceFrame.calculateEnd(this.getWidth())}isLoading(){return this.loading}savePNG(){if(!this.canvas)return;const t=this.canvas._data,e=t?t.pixelTop:0,i=window.devicePixelRatio,n=this.$viewport.width()*i,r=this.$viewport.height()*i,s=-fe(this.canvas).position().left*i,o=(-this.contentTop-e)*i,a=this.canvas.getContext("2d").getImageData(s,o,n,r),l=document.createElement("canvas"),h=l.getContext("2d");l.width=a.width,l.height=a.height,h.putImageData(a,0,0),Qi((this.$trackLabel.text()?this.$trackLabel.text():"image")+".png",l.toDataURL("image/png"))}saveSVG(){let{width:t,height:e}=this.browser.columnContainer.getBoundingClientRect();const i=new ll({width:t,height:8e3,backdropColor:"white",multiLocusGap:0,viewbox:{x:0,y:0,width:t,height:8e3}});this.renderViewportToSVG(i,{deltaX:32,deltaY:32}),i.setHeight(e);const n=(this.trackView.track.name||this.trackView.track.id).replace(/\W/g,""),r=this.browser.referenceFrameList.indexOf(this.referenceFrame),s=i.getSerializedSvg(!0),o=URL.createObjectURL(new Blob([s],{type:"application/octet-stream"}));Qi(`${n}_referenceFrame_${r}_guid_${_e.guid()}.svg`,o)}renderViewportToSVG(t,{deltaX:e,deltaY:i}){if(this.$zoomInNotice&&this.$zoomInNotice.is(":visible"))return;const{width:n,height:r}=this.$viewport.get(0).getBoundingClientRect(),s=`${(this.trackView.track.name||this.trackView.track.id).replace(/\W/g,"")}_referenceFrame_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}_guid_${_e.guid()}`;this.drawSVGWithContext(t,n,r,s,e,i+this.contentTop,-this.contentTop)}renderSVGContext(t,{deltaX:e,deltaY:i}){if(this.renderViewportToSVG(t,{deltaX:e,deltaY:i}),(!this.$zoomInNotice||!this.$zoomInNotice.is(":visible"))&&this.$trackLabel&&!0===this.browser.trackLabelsVisible){const{x:n,y:r,width:s,height:o}=_e.relativeDOMBBox(this.$viewport.get(0),this.$trackLabel.get(0));this.renderTrackLabelSVG(t,e+n,i+r,s,o)}}renderTrackLabelSVG(t,e,i,n,r){const s=`${(this.trackView.track.name||this.trackView.track.id).replace(/\W/g,"")}_track_label_guid_${_e.guid()}`;t.saveWithTranslationAndClipRect(s,e,i,n,r,0),t.fillStyle="white",t.fillRect(0,0,n,r),t.font="12px Arial",t.fillStyle="rgb(68, 68, 68)";const{width:o}=t.measureText(this.$trackLabel.text()),a=.25*(n-o),l=.7*(r-12);t.fillText(this.$trackLabel.text(),a,r-l),t.strokeStyle="rgb(68, 68, 68)",t.strokeRect(0,0,n,r),t.restore()}drawSVGWithContext(t,e,i,n,r,s,o){t.saveWithTranslationAndClipRect(n,r,s,e,i,o);let{start:a,bpPerPixel:l}=this.referenceFrame;const h={context:t,viewport:this,referenceFrame:this.referenceFrame,top:o,pixelTop:o,pixelWidth:e,pixelHeight:i,bpStart:a,bpEnd:a+e*l,bpPerPixel:l,viewportWidth:e,selection:this.selection},c=this.featureCache?this.featureCache.features:void 0,u=this.featureCache?this.featureCache.roiFeatures:void 0;this.draw(h,c,u),t.restore()}get cachedFeatures(){return this.featureCache?this.featureCache.features:[]}clearCache(){this.featureCache=void 0,this.canvas&&(this.canvas._data=void 0)}async getFeatures(t,e,i,n,r){if(this.featureCache&&this.featureCache.containsRange(e,i,n,r))return this.featureCache.features;if("function"==typeof t.getFeatures){const s=await t.getFeatures(e,i,n,r,this);return this.checkContentHeight(s),s}}needsRepaint(){if(!this.canvas)return!0;const t=this.canvas._data;return!t||this.referenceFrame.startt.bpEnd||this.referenceFrame.chr!==t.referenceFrame.chr||this.referenceFrame.bpPerPixel!=t.bpPerPixel}needsReload(){if(!this.featureCache)return!0;const{chr:t,bpPerPixel:e}=this.referenceFrame,{bpStart:i,bpEnd:n}=this.repaintDimensions();return!this.featureCache.containsRange(t,i,n,e)}createZoomInNotice(t){const e=fe("
",{class:"igv-zoom-in-notice-container"});t.append(e);const i=fe("
");return e.append(i),i.text("Zoom in to see features"),e.hide(),e}viewIsReady(){return this.browser&&this.browser.referenceFrameList&&this.referenceFrame}addMouseHandlers(){const t=this.$viewport.get(0);this.addViewportContextMenuHandler(t);const e=t=>{this.enableClick=!0,this.browser.mouseDownOnViewport(t,this),_e.pageCoordinates(t)};t.addEventListener("mousedown",e),t.addEventListener("touchstart",e);const i=t=>{this.browser.dragObject||this.browser.isScrolling?(this.browser.cancelTrackPan(),this.enableClick=!1):(this.browser.cancelTrackPan(),this.browser.endTrackDrag())};t.addEventListener("mouseup",i),t.addEventListener("touchend",i),"function"==typeof this.trackView.track.hoverText&&t.addEventListener("mousemove",(t=>{if(0===t.buttons&&Date.now()-gl>100){gl=Date.now();const e=this.createClickState(t);if(e){const t=this.trackView.track.hoverText(e);t?this.$viewport[0].setAttribute("title",t):this.$viewport[0].removeAttribute("title")}}})),this.addViewportClickHandler(this.$viewport.get(0)),this.trackView.track.name&&"sequence"!==this.trackView.track.config.type&&this.addTrackLabelClickHandler(this.$trackLabel.get(0))}addViewportContextMenuHandler(t){t.addEventListener("contextmenu",(t=>{if(this.browser.dragObject)return!1;const e=this.createClickState(t);if(void 0===e)return!1;t.preventDefault();let i=[];if("function"==typeof this.trackView.track.contextMenuItemList){const t=this.trackView.track.contextMenuItemList(e);t&&(i=t)}i.length>0&&i.push({label:fe("
")}),i.push({label:"Save Image (PNG)",click:()=>this.savePNG()}),i.push({label:"Save Image (SVG)",click:()=>this.saveSVG()}),this.browser.menuPopup.presentTrackContextMenu(t,i)}))}addViewportClickHandler(t){t.addEventListener("click",(t=>{if(this.enableClick&&this.canvas){if(3===t.which||t.ctrlKey)return;if(fe(".igv-popover").hide(),this.browser.dragObject||this.browser.isScrolling)return;t.preventDefault();const e=_e.translateMouseCoordinates(t,this.$viewport.get(0)).x,i=_e.translateMouseCoordinates(t,this.canvas).x,n=this.referenceFrame,r=Math.floor(n.start+n.toBP(i)),s=Date.now();if(s-plt));t[this.browser.referenceFrameList.indexOf(this.referenceFrame)]=e,i=t.join(" ")}this.browser.search(i)}else this.browser.zoomWithScaleFactor(.5,t,this.referenceFrame)}else t.shiftKey&&"function"==typeof this.trackView.track.shiftClick?this.trackView.track.shiftClick(r,t):"function"==typeof this.trackView.track.popupData&&(fl=setTimeout((()=>{const e=this.getPopupContent(t);e&&(this.popover&&this.popover.dispose(),this.popover=new Oi(this.browser.columnContainer),this.popover.presentContentWithEvent(t,e)),window.clearTimeout(fl),fl=void 0}),this.browser.constants.doubleClickDelay));pl=s}}))}addTrackLabelClickHandler(t){t.addEventListener("click",(t=>{t.stopPropagation();const{track:e}=this.trackView;let i;"function"==typeof e.description?i=e.description():e.description&&(i=`
${e.description}
`),i&&(this.popover&&this.popover.dispose(),this.popover=new Oi(this.browser.columnContainer,e.name||""),this.popover.presentContentWithEvent(t,i))}))}createClickState(t){if(!this.canvas)return;const e=this.referenceFrame,i=_e.translateMouseCoordinates(t,this.$viewport.get(0)),n=_e.translateMouseCoordinates(t,this.canvas),r=e.start+e.toBP(i.x);return{event:t,viewport:this,referenceFrame:e,genomicLocation:r,y:i.y-this.contentTop,canvasX:n.x,canvasY:n.y}}getPopupContent(t){const e=this.createClickState(t);if(void 0===e)return;let i=this.trackView.track;const n=i.popupData(e),r=this.browser.fireEvent("trackclick",[i,n]);let s;return void 0===r||!0===r?n&&n.length>0&&(s=n.map((t=>{if(t.name){const e=`${t.name}   ${t.value}`;return`
${e}
`}return"
"===t?t:t.html?t.html:`
${t}
`})).join("")):"string"==typeof r&&(s=r),s}}class bl{constructor(t,e,i,n,r,s,o){this.chr=t,this.bpStart=e,this.bpEnd=i,this.bpPerPixel=n,this.features=r,this.roiFeatures=s,this.multiresolution=o}containsRange(t,e,i,n){const r=this.multiresolution?this.bpPerPixel/n:1;return e>=this.bpStart&&i<=this.bpEnd&&t===this.chr&&r>.5&&r<2}overlapsRange(t,e,i){return this.chr===t&&i>=this.bpStart&&e<=this.bpEnd}}function yl(t,e){if(!(t.length<6))return{chr:t[0],start:t[1],end:t[2],chr1:t[8],start1:Number.parseInt(t[9]),end1:Number.parseInt(t[10]),chr2:t[13],start2:Number.parseInt(t[14]),end2:Number.parseInt(t[15]),name:t[3],score:Number(t[4]),value:Number(t[5]),color:"."===t[7]?void 0:"0"===t[7]?"rgb(0,0,0)":t[7]};console.log("Skipping line: "+t.join(" "))}const vl=new Set(["transcript","primary_transcript","processed_transcript","mRNA","mrna","lnc_RNA","miRNA","ncRNA","rRNA","scRNA","snRNA","snoRNA","tRNA"]),wl=new Set(["CDS","cds"]),_l=new Set(["start_codon","stop_codon"]),xl=new Set(["5UTR","3UTR","UTR","five_prime_UTR","three_prime_UTR","3'-UTR","5'-UTR"]),kl=new Set(["exon","coding-exon"]),Sl=new Set;for(let _y of[wl,_l,xl,kl])for(let xy of _y)Sl.add(xy);function Cl(t){return t.includes("intron")}function Al(t){return wl.has(t)||_l.has(t)}function Tl(t){return xl.has(t)}function Il(t){return vl.has(t)||t.endsWith("RNA")||t.endsWith("transcript")}function El(t){return Sl.has(t)||t.endsWith("RNA")||Cl(t)}const Ml=new Set(["id","parent","name"]);class Rl{constructor(t){Object.assign(this,t)}popupData(t){const e=this.geneObject?this.geneObject.popupData():[];if(this.geneObject&&e.push("
"),this.name&&e.push({name:"Name",value:this.name}),e.push({name:"Type",value:this.type}),e.push({name:"Source",value:this.source}),void 0!==this.score&&e.push({name:"Score",value:this.score}),this.attributeString){const t=Ol(this.attributeString,this.delim);for(let[i,n]of t)void 0!==n&&n.length>0&&!Ml.has(i.toLowerCase())&&e.push({name:i+":",value:n})}return e.push({name:"Location",value:`${this.chr}:${$i(this.start+1)}-${$i(this.end)}`}),e}getAttributeValue(t){if(this.hasOwnProperty(t))return this[t];if(this._attributeCache||(this._attributeCache=new Map),this._attributeCache.has(t))return this._attributeCache.get(t);{const e=Ol(this.attributeString,this.delim);let i;for(let[n,r]of e)if(n===t){i=r;break}return this._attributeCache.set(t,i),i}}}class Ll extends Rl{constructor(t){super(t),this.exons=[],this.parts=[]}addExon(t){this.exons.push(t),this.start=Math.min(this.start,t.start),this.end=Math.max(this.end,t.end)}addPart(t){this.parts.push(t)}assembleParts(){if(0===this.parts.length)return;this.parts.sort((function(t,e){return t.start-e.start}));let t=this.parts[0].start,e=this.parts[0].end;for(let i=1;i=e&&i.start<=t)return i}addCDS(t){let e;const i=this.exons;for(let n of i)if(n.start<=t.start&&n.end>=t.end){e=n;break}e?(e.cdStart=e.cdStart?Math.min(t.start,e.cdStart):t.start,e.cdEnd=e.cdEnd?Math.max(t.end,e.cdEnd):t.end):console.error("No exon found spanning "+t.start+"-"+t.end),this.cdStart=this.cdStart?Math.min(t.start,this.cdStart):t.start,this.cdEnd=this.cdEnd?Math.max(t.end,this.cdEnd):t.end}addUTR(t){let e;const i=this.exons;for(let n=0;n=t.end){e=i[n];break}e?t.start===e.start&&t.end===e.end?e.utr=!0:(t.ende.start&&(e.cdEnd=t.start)):console.error("No exon found spanning "+cds.start+"-"+cds.end)}finish(){this.assembleParts();var t=this.cdStart,e=this.cdEnd;this.exons.sort((function(t,e){return t.start-e.start})),t&&this.exons.forEach((function(i){(i.ende)&&(i.utr=!0)}))}popupData(t){const e=super.popupData(t);for(let i of this.exons)if(!i.pseudo&&t>=i.start&&t");const n=i.popupData(t);for(let t of n)e.push(t)}for(let i of this.parts)if(t>=i.start&&t");const n=i.popupData(t);for(let t of n)e.push(t)}return e}}function Bl(t,e){const i=e.format;if(t.length<9)return;const n="gff3"===i?"=":" ";return new Rl({source:zl(t[1]),type:t[2],chr:t[0],start:parseInt(t[3])-1,end:parseInt(t[4]),score:"."===t[5]?void 0:Number(t[5]),strand:t[6],phase:"."===t[7]?0:parseInt(t[7]),attributeString:t[8],delim:n})}function Nl(t,e){const i=Bl(t,e);if(!i)return;const n=Ol(i.attributeString,i.delim);for(let[t,e]of n){const n=t.toLowerCase();"color"===n||"colour"===n?i.color=xo.createColorString(e):"ID"===t?i.id=e:"Parent"===t&&(i.parent=e)}return i}function Fl(t,e){const i=Bl(t,e);if(!i)return;const n=Ol(i.attributeString,i.delim);let r,s;switch(i.type){case"gene":r="gene_id";break;case"transcript":r="transcript_id",s="gene_id";break;default:s="transcript_id"}for(let[t,e]of n){const n=t.toLowerCase();"color"===n||"colour"===n?i.color=xo.createColorString(e):t===r?i.id=e:t===s&&(i.parent=e)}return i}function Ol(t,e,i=!1){var n=[];for(let r of t.split(";")){r=r.trim();const t=r.indexOf(e);if(t>0&&t2?parseInt(t[2]):n+1;if(isNaN(n)||isNaN(r))return new Ul("Unparsable bed record.");const s=new Jl({chr:i,start:n,end:r,score:1e3});try{if(t.length>3){if(t[3].indexOf(";")>0&&t[3].indexOf("=")>0){const i=Ol(t[3],"=",!0);s.attributes={};for(let t of i)s.attributes[t[0]]=t[1],null!=e.nameField&&t[0]===e.nameField&&(s.name=t[1])}s.name||(s.name="."===t[3]?"":t[3])}if(t.length>4&&(s.score="."===t[4]?0:Number(t[4]),isNaN(s.score)))return s;if(t.length>5&&(s.strand=t[5],"."!==s.strand&&"+"!==s.strand&&"-"!==s.strand))return s;if(t.length>6&&(s.cdStart=parseInt(t[6]),isNaN(s.cdStart)))return s;if(t.length>7&&(s.cdEnd=parseInt(t[7]),isNaN(s.cdEnd)))return s;if(t.length>8&&"."!==t[8]&&"0"!==t[8]&&(s.color=xo.createColorString(t[8])),t.length>11){const e=parseInt(t[9]);if(e>1e3)return s;const i=t[10].replace(/,$/,"").split(","),r=t[11].replace(/,$/,"").split(",");if(i.length!==r.length||e!==i.length)return s;const o=[];for(let t=0;t0&&(Zl(o,s.cdStart,s.cdEnd),s.exons=o)}if(e){let i=e.thicknessColumn,n=e.colorColumn;n&&ni?n.utr=!0:(e>=r&&e<=t&&(n.cdStart=e),i>=r&&i<=t&&(n.cdEnd=i))}}function Yl(t,e){var i,n,r,s,o,a,l;if(!(t.length<9))return i=t[0],n=parseInt(t[1]),r=parseInt(t[2]),o=t[3],a=Number(t[4]),s=t[5].trim(),l=Number(t[6]),0===a&&(a=l),{chr:i,start:n,end:r,name:o,score:a,strand:s,signal:l,pValue:Number(t[7]),qValue:Number(t[8])}}function Ql(t,e){if(t.length<=3)return;const i={chr:t[0],start:parseInt(t[1]),end:parseInt(t[2]),value:Number(t[3])};if(e){let n=e.colorColumn;n&&n0)for(var d=l.split(","),f=0;fu&&(u=m),h.spanning_frag_coords.push({left:g,right:m})}return h.start=c,h.end=u,h}}function ih(t,e){if(t.length<7)return null;const i={chr:t[0],start:parseInt(t[1])-1,end:parseInt(t[2]),"Strongest SNP-risk allele":t[3],"Disease/Phenotype":t[4],"P-value":t[5],"Odds ratio or beta":t[6]};return t.length>6&&(i.PUBMEDID=`${t[7]}`),i}function nh(t,e){const i=e.customFormat;if(t.length1&&(e=t)}else{this.setDecoder(n.format);const t=i.split(this.delimiter||"\t");try{const i=Object.assign({columnNames:e},n);if(this.decode(t,i))break;t.length>1&&(e=t)}catch(i){t.length>1&&(e=t)}}}if(e){n.columnNames=e;for(let t=0;t0&&console.error(`Error parsing line '${s}': ${l.message}`)):l&&e.push(l)}return i===ya&&function(t){if(0==t.length)return;const e=t[0];if(void 0===e.score&&void 0!==e.name){for(let e of t)if(!("number"==typeof(i=e.name)?i-i==0:"string"==typeof i&&""!==i.trim()&&(Number.isFinite?Number.isFinite(+i):isFinite(+i)))&&"."!==e.name)return;for(let e of t)e.score=Number(e.name),delete e.name}var i;const n=t.filter((t=>t.chr1!==t.chr2));for(let e of n){const i=Object.assign({},e);i.dup=!0,t.push(i),e.chr=e.chr1,e.start=e.start1,e.end=e.end1,i.chr=i.chr2,i.start=i.start2,i.end=i.end2}}(e),e}setDecoder(t){switch(t){case"narrowpeak":case"broadpeak":case"regionpeak":case"peaks":this.decode=Yl,this.delimiter=this.config.delimiter||/\s+/;break;case"bedgraph":this.decode=Ql,this.delimiter=/\s+/;break;case"wig":this.decode=Xl,this.delimiter=this.config.delimiter||/\s+/;break;case"gff3":case"gff":this.decode=Nl,this.delimiter="\t";break;case"gtf":this.decode=Fl,this.delimiter="\t";break;case"fusionjuncspan":this.decode=eh,this.delimiter=this.config.delimiter||/\s+/;break;case"gtexgwas":this.skipRows=1,this.decode=ih,this.delimiter="\t";break;case"refflat":this.decode=ql,this.delimiter=this.config.delimiter||/\s+/;break;case"genepred":this.decode=jl,this.delimiter=this.config.delimiter||/\s+/;break;case"genepredext":this.decode=$l,this.delimiter=this.config.delimiter||/\s+/;break;case"ensgene":this.decode=jl,this.header.shift=1,this.delimiter=this.config.delimiter||/\s+/;break;case"refgene":this.decode=$l,this.delimiter=this.config.delimiter||/\s+/,this.header.shift=1;break;case"bed":this.decode=Vl,this.delimiter=this.config.delimiter||/\s+/;break;case"bedpe":case"hiccups":this.decode=ya,this.delimiter=this.config.delimiter||"\t";break;case"bedpe-domain":this.decode=va,this.headerLine=!0,this.delimiter=this.config.delimiter||"\t";break;case"bedpe-loop":this.decode=ya,this.delimiter=this.config.delimiter||"\t",this.header={colorColumn:7};break;case"interact":this.decode=yl,this.delimiter=this.config.delimiter||/\s+/;break;case"snp":this.decode=Kl,this.delimiter="\t";break;case"rmsk":this.decode=Hl,this.delimiter="\t";break;case"gcnv":this.decode=rh,this.delimiter="\t";break;default:const e=xa(t);void 0!==e?(this.decode=nh,this.header.customFormat=e,this.delimiter=e.delimiter||"\t"):(this.decode=Vl,this.delimiter=this.config.delimiter||/\s+/)}}}function oh(t){const e={},i=t.split(/(?:")([^"]+)(?:")|([^\s"]+)(?=\s+|$)/g);let n;const r=[];for(let t of i)t&&0!==t.trim().length&&(t.endsWith("=")?n=t:n?(r.push(n+t),n=void 0):r.push(t));for(let t of r){if(!t)return;var s=t.split("=",2);if(2===s.length){const t=s[0].trim(),i=s[1].trim();if(e.hasOwnProperty(t)){let n=e[t];Array.isArray(n)?n.push(i):e[t]=[n,i]}else e[t]=i}}return"interact"==e.type?e.format="interact":"gcnv"===e.type&&(e.format="gcnv"),e}function ah(t){let e={},i=t.split(/\s+/);return 2===i.length&&i[1].split(";").forEach((function(t){let i=t.split("=");"color"===i[0]?e.colorColumn=Number.parseInt(i[1])-1:"thickness"===i[0]&&(e.thicknessColumn=Number.parseInt(i[1])-1)})),e}function lh(t){const e=t.split(/\s+/);return{format:"fixedStep",chrom:e[1].split("=")[1],start:parseInt(e[2].split("=")[1],10)-1,step:parseInt(e[3].split("=")[1],10),span:e.length>4?parseInt(e[4].split("=")[1],10):1,index:0}}function hh(t){const e=t.split(/\s+/);return{format:"variableStep",chrom:e[1].split("=")[1],span:e.length>2?parseInt(e[2].split("=")[1],10):1}}class ch{static defaults={height:50,autoHeight:!1,visibilityWindow:void 0,color:void 0,altColor:void 0,supportHiDPI:!0};constructor(t,e){this.browser=e,this.init(t)}init(t){this.config=t,t.displayMode&&(t.displayMode=t.displayMode.toUpperCase());const e=Object.assign({},ch.defaults);if(this.constructor.defaults)for(let t of Object.keys(this.constructor.defaults))e[t]=this.constructor.defaults[t];for(let n of Object.keys(e))this[n]=t.hasOwnProperty(n)?t[n]:e[n],"color"!==n&&"altColor"!==n||(this[n]=ji(i=this[n])&&i.indexOf(",")>0&&!i.startsWith("rgb(")&&!i.startsWith("rgba(")?`rgb(${i})`:i);var i;t.name||t.label?this.name=t.name||t.label:Yi(t.url)?this.name=t.url.name:ji(t.url)&&!t.url.startsWith("data:")&&(this.name=Zi(t.url)),this.url=t.url,this.config.type&&(this.type=this.config.type),this.id=void 0===this.config.id?this.name:this.config.id,this.order=t.order,this.autoscaleGroup=t.autoscaleGroup,this.removable=void 0===t.removable||t.removable,this.minHeight=t.minHeight||Math.min(25,this.height),this.maxHeight=t.maxHeight||Math.max(1e3,this.height),t.onclick&&(this.onclick=t.onclick,t.onclick=void 0),t.description&&("function"==typeof t.description?this.description=t.description:this.description=()=>t.description),t.hoverTextFields?this.hoverText=uh.bind(this):"function"==typeof this.config.hoverText&&(this.hoverText=this.config.hoverText)}get name(){return this._name}set name(t){this._name=t,this.trackView&&this.trackView.setTrackLabelName(t)}updateConfig(t){this.init(t)}clearCachedFeatures(){this.trackView&&this.trackView.clearCachedFeatures()}updateViews(){this.trackView&&this.trackView.updateViews()}getState(){const t={};for(let i of Object.keys(this.config))i.startsWith("_")||void 0===(e=this.config[i])||"function"==typeof e||e instanceof File||e instanceof Promise||(t[i]=this.config[i]);var e;for(let e of Object.keys(t)){if(e.startsWith("_"))continue;const i=this[e];i&&(aa(i)||"boolean"==typeof i||"metadata"===e)&&(t[e]=i)}const i=ch.defaults;if(this.constructor.defaults)for(let t of Object.keys(this.constructor.defaults))i[t]=this.constructor.defaults[t];for(let e of Object.keys(i))void 0!==this[e]&&i[e]!==this[e]&&(t[e]=this[e]);return!this.autoscale&&this.dataRange&&(t.min=this.dataRange.min,t.max=this.dataRange.max),t}get supportsWholeGenome(){return!0===this.config.supportsWholeGenome}hasSamples(){return!1}getGenomeId(){return this.browser.genome?this.browser.genome.id:void 0}setTrackProperties(t){if(this.disposed)return;const e={};let i;for(let n of Object.keys(t))switch(n.toLowerCase()){case"usescore":e.useScore=1===t[n]||"1"===t[n]||"on"===t[n]||!0===t[n];break;case"visibility":switch(t[n]){case"2":case"3":case"pack":case"full":e.displayMode="EXPANDED";break;case"4":case"squish":e.displayMode="SQUISHED";break;case"1":case"dense":e.displayMode="COLLAPSED"}break;case"color":case"altcolor":e[n]=t[n].startsWith("rgb(")?t[n]:"rgb("+t[n]+")";break;case"featurevisiblitywindow":case"visibilitywindow":e.visibilityWindow=Number.parseInt(t[n]);break;case"maxheightpixels":i=t[n].split(":"),3===i.length&&(e.minHeight=Number.parseInt(i[2]),e.height=Number.parseInt(i[1]),e.maxHeight=Number.parseInt(i[0]));break;case"viewlimits":if(!this.config.autoscale){i=t[n].split(":");let r,s=0;1==i.length?r=Number(i[0]):2==i.length&&(s=Number(i[0]),r=Number(i[1])),e.autoscale=!1,e.dataRange={min:s,max:r},this.viewLimitMin=s,this.viewLimitMax=r}case"name":e[n]=t[n];break;case"url":e.infoURL=t[n];break;case"type":const r=t[n];dh.has(r)?e[n]=dh.get(r):e[n]=r;break;case"graphtype":e.graphType=t[n];break;default:e[n]=t[n]}for(let t of Object.keys(e))if(!this.config.hasOwnProperty(t)||"name"===t&&this.config._derivedName){let i=e[t];if("true"===i&&(i=!0),"false"===i&&(i=!1),this[t]=i,"height"===t&&this.trackView)try{const t=Number.parseInt(i);this.trackView.setTrackHeight(t)}catch(t){console.error(t)}}}clickedFeatures(t){const e=t.viewport.cachedFeatures;if(!e||!Array.isArray(e)||0===e.length)return[];const i=t.genomicLocation,n=t.referenceFrame.bpPerPixel>.2?3*t.referenceFrame.bpPerPixel:.2;return Xo(e,i-n,i+n)}extractPopupData(t,e){const i=new Set(["row","color","chr","start","end","cdStart","cdEnd","strand","alpha"]),n=[];let r,s;for(let e in t)if(t.hasOwnProperty(e)&&!i.has(e)&&aa(t[e])){let i=t[e];n.push({name:Gi(e),value:i}),"alleles"===e?r=t[e]:"alleleFreqs"===e&&(s=t[e])}if(r&&s){r.endsWith(",")&&(r=r.substr(0,r.length-1)),s.endsWith(",")&&(s=s.substr(0,s.length-1));let i=r.split(","),o=s.split(",");if(o.length>1){let r=[];for(let t=0;t=0;i--){let o=r[i].a;if(1===o.length){e||(e=this.getGenomeId());const i=ch.getCravatLink(t.chr,t.start+1,s,o,e);console.log(i),i&&(n.push("
"),n.push({html:i}),n.push("
"))}}}}if(t.attributes)for(let e of Object.keys(t.attributes))n.push({name:e,value:t.attributes[e]});let o=`${t.chr}:${$i(t.start+1)}-${$i(t.end)}`;return t.strand&&(o+=` (${t.strand})`),n.push({name:"Location",value:o}),n}description(){const t=(t,e)=>`
${t}: ${e}
`;let e='
';if(this.url?Yi(this.url)?e+=t("Filename",this.url.name):e+=t("URL",this.url):e=this.name,this.config){if(this.config.metadata)for(let i of Object.keys(this.config.metadata))e+=t(i,this.config.metadata[i]);for(let i of Object.keys(this.config)){if(i.startsWith("_"))continue;let n=i.substr(0,1);if(n!==n.toLowerCase()){const n=this.config[i];n&&aa(n)&&(e+=t(i,n))}}}return e+="
",e}getColorForFeature(t){return"function"==typeof this.color?this.color(feature):this.color}dispose(){this.disposed=!0;for(let t of Object.keys(this))this[t]=void 0}static getCravatLink(t,e,i,n,r){if("hg38"===r||"GRCh38"===r)return`Cravat ${i}->${n}`}}function uh(t){if(!this.hoverTextFields)return;const e=this.clickedFeatures(t);if(e&&e.length>0){let t="";for(let i=0;i0&&(t+="\n"),t="";for(let e of this.hoverTextFields)t.length>0&&(t+="\n"),n.hasOwnProperty(e)?t+=n[e]:"function"==typeof n.getAttribute&&(t+=n.getAttribute(e))}return t}}const dh=new Map([["wiggle_0","wig"],["bed","bed"],["bigBed","bigBed"],["bigWig","bigWig"]]);class fh{constructor(t){switch(this.type=t||"seg",this.type){case"mut":this.sampleColumn=3,this.chrColumn=0,this.startColumn=1,this.endColumn=2,this.dataColumn=4;break;case"maf":this.sampleColumn=15,this.chrColumn=4,this.startColumn=5,this.endColumn=6,this.dataColumn=8;break;default:this.sampleColumn=0,this.chrColumn=1,this.startColumn=2,this.endColumn=3}}async parseHeader(t){let e;for(;void 0!==(e=await t.nextLine());)if(!e.startsWith("#")){const t=e.split("\t");this.header={headings:t};break}return this.header}async parseFeatures(t){const e=[];let i;this.header||(this.header=await this.parseHeader(t)),"seg"===this.type&&(this.dataColumn=this.header.headings.length-1),this.header.headings.length>5&&(i=this.extractExtraColumns(this.header.headings));const n=this.header.headings[this.dataColumn];let r;for(;void 0!==(r=await t.nextLine());){const t=r.split("\t"),s="seg"===this.type?Number(t[this.dataColumn]):t[this.dataColumn];if(t.length>this.dataColumn){const r=new ph({sample:t[this.sampleColumn],chr:t[this.chrColumn],start:parseInt(t[this.startColumn])-1,end:parseInt(t[this.endColumn]),value:s,valueColumnName:n});if(i){const e=this.extractExtraColumns(t);r.setAttributes({names:i,values:e})}e.push(r)}}return e}extractExtraColumns(t){const e=[];for(let i=0;i=0)return this.attributeValues[e]}}popupData(t,e){const i=new Set(["chr","start","end","sample","value","row","color","sampleKey","uniqueSampleKey","sampleId","chromosome","uniquePatientKey"]),n=this.chr+":"+$i(this.start+1)+"-"+$i(this.end),r=[{name:"Sample",value:this.sample},{name:"Location",value:n},{name:this.valueColumnName?Gi(this.valueColumnName):"Value",value:this.value}];if("mut"===t&&"hg38"===e){const t=this.extractCravatLink(e);t&&(r.push("
"),r.push({html:t}),r.push("
"))}if(this.attributeNames&&this.attributeNames.length>0)for(let t=0;t0)for(let n=0;n"===e||"<*>"===e||"."===e)return"NONVARIANT";{const t=e.split(",").map((function(t){return 1===i&&1===t.length?"SNP":""===t?"NONVARIANT":"OTHER"}));let n=t[0];for(let e of t)if(e!==n)return"MIXED";return n}}(t,e)),"NONVARIANT"===this.type&&(this.heterozygosity=0),this.info.END)this.start=this.pos-1,this.info.CHR2&&this.info.CHR2!==this.chr?this.end=this.start+1:this.end=Number.parseInt(this.info.END);else if("NONVARIANT"===this.type)this.start=this.pos-1,this.end=this.start+t.length;else{const i=e.split(",").filter((t=>t.length>0));this.alleles=[],this.start=void 0,this.end=void 0;for(let e of i)if(this.alleles.push(e),"SV"!==this.type&&yh(e)){let i=e.length,n=t.length;const r=Math.min(i,n);let s=0;for(;s0&&n>0;){const r=s+i-1,o=s+n-1;if(e.charCodeAt(r)!==t.charCodeAt(o))break;i--,n--}for(;i>0&&n>0;){const r=s,o=s;if(e.charCodeAt(r)!==t.charCodeAt(o))break;s++,i--,n--}const o=this.pos+s-1,a=o+n;this.start=void 0===this.start?o:Math.min(this.start,o),this.end=void 0===this.end?a:Math.max(this.end,a)}void 0===this.start&&(this.start=this.pos-1,this.end=this.pos)}}popupData(t,e){const i=`${$i(this.pos)}`,n=this.start===this.end?`${$i(this.start)} | ${$i(this.start+1)}`:`${$i(this.start+1)}-${$i(this.end)}`,r=[{name:"Chr",value:this.chr},{name:"Pos",value:i},{name:"Loc",value:n},{name:"ID",value:this.names?this.names:""},{name:"Ref",value:this.referenceBases},{name:"Alt",value:this.alternateBases.replace("<","<")},{name:"Qual",value:this.quality},{name:"Filter",value:this.filter}];if("SNP"===this.type){let t=this.referenceBases;if(1===t.length){let i=this.alternateBases.split(",");for(let n of i)if(1===n.length){let i=ch.getCravatLink(this.chr,this.pos,t,n,e);i&&(r.push("
"),r.push({html:i}))}}}if(this.hasOwnProperty("heterozygosity")&&r.push({name:"Heterozygosity",value:this.heterozygosity}),this.info){r.push({html:'
'});for(let t of Object.keys(this.info))r.push({name:t,value:vh(decodeURIComponent(this.info[t]))})}return r}getInfo(t){return this.info?this.info[t]:void 0}isRefBlock(){return"NONVARIANT"===this.type}}const bh=new Set(["A","C","T","G"].map((t=>t.charCodeAt(0))));function yh(t){for(let e=0;e");if(!(e>2&&o>0)){console.log("Malformed VCF header line: "+n);continue}const a=n.substring(2,e-1);i[a]||(i[a]={});const l=Wi(n.substring(e+1,o-1),",");for(let e of l){var r=e.split("=");r.length>1&&("ID"===r[0]?t=r[1]:s[r[0]]=r[1])}t&&(i[a][t]=s)}else if(n.startsWith("##contig")&&e){const t=n.indexOf("",t));const s=n.substring(t+4,r),o=e.getChromosomeName(s);i.chrAliasTable.set(o,s)}}else if(n.startsWith("#CHROM")){const t=n.split("\t");if(t.length>8){i.callSets=[];for(let e=9;e9){const e=_h(t[8].split(":"));n.calls={};for(let r=9;r0?n=t:n?(r.push(n+t),n=void 0):r.push(t));for(let t of r){if(!t)return;var s=t.split("=",2);if(2===s.length){const t=s[0].trim(),i=s[1].trim();e[t]=i}}return e}function Rh(t){let e={},i=t.split(/\s+/);return 2===i.length&&i[1].split(";").forEach((function(t){let i=t.split("=");"color"===i[0]?e.colorColumn=Number.parseInt(i[1])-1:"thickness"===i[0]&&(e.thicknessColumn=Number.parseInt(i[1])-1)})),e}function Lh(t,e){var i,n,r=t.columns;this.aed=t,this.allColumns=e,this.chr=null,this.start=null,this.end=null,this.score=1e3,this.strand=".",this.cdStart=null,this.cdEnd=null,this.name=null,this.color=null;for(let t=0;t0)for(let t=0;t=0;i--)e=256*e+t[i];else for(let i=0;i0&&(n+=String.fromCharCode(i));return n}getFixedLengthTrimmedString(t){var e,i,n="";for(e=0;e32&&(n+=String.fromCharCode(i));return n}getFloat(){var t=this.view.getFloat32(this.position,this.littleEndian);return this.position+=4,t}getDouble(){var t=this.view.getFloat64(this.position,this.littleEndian);return this.position+=8,t}skip(t){return this.position+=t,this.position}getVPointer(){var t=this.position,e=this.view.getUint8(t+1)<<8|this.view.getUint8(t),i=4294967296*(255&this.view.getUint8(t+6))+16777216*(255&this.view.getUint8(t+5))+65536*(255&this.view.getUint8(t+4))+256*(255&this.view.getUint8(t+3))+(255&this.view.getUint8(t+2));return this.position+=8,new Fh(i,e)}}class Fh{constructor(t,e){this.block=t,this.offset=e}isLessThan(t){return this.blockt.block||this.block===t.block&&this.offset>t.offset}isEqualTo(t){return this.block===t.block&&this.offset===t.offset}print(){return this.block+":"+this.offset}}function Oh(t,e){if(0===t.length)return t;if(t.sort((function(t,e){const i=t.minv.block-e.minv.block;return 0!==i?i:t.minv.offset-e.minv.offset})),t.length<=1)return t;e&&(t=t.filter((t=>t.maxv.isGreaterThan(e))));const i=[];let n;for(let e of t)n&&Dh(n,e)?e.maxv.isGreaterThan(n.maxv)&&(n.maxv=e.maxv):(i.push(e),n=e);return i}function Dh(t,e){return e.minv.block,t.maxv.block,t.maxv.block-t.minv.block<5e6}class Ph{constructor(t){this.tabix=!0}parse(t,e){const i=new Nh(new DataView(t)),n=i.getInt();if(21582659!==n)throw 38359875===n?Error("CSI version 2 is not supported. Please enter an issue at https://github.com/igvteam/igv.js"):Error("Not a CSI index");this.indices=[],this.blockMin=Number.MAX_SAFE_INTEGER,this.lastBlockPosition=[],this.sequenceIndexMap={},this.minShift=i.getInt(),this.depth=i.getInt();const r=[];let s=0;if(i.getInt()>=28){i.getInt(),i.getInt(),i.getInt(),i.getInt(),i.getInt(),i.getInt();const t=i.getInt(),n=i.position+t;let s=0;for(;i.positiono)i.getInt(),i.getVPointer(),i.getVPointer(),i.getLong(),i.getLong();else{e[t]=[];const n=i.getInt();for(let r=0;rs&&(s=r.block),e[t].push([n,r]))}}}r>0&&(this.indices[t]={binIndex:e,loffset:n})}this.lastBlockPosition=s}get chromosomeNames(){return Object.keys(this.sequenceIndexMap)}chunksForRange(t,e,i){const n=this.indices[t];if(n){const t=this.reg2bins(e,i);if(0==t.length)return[];const r=[];for(let e of t)for(let t=e[0];t<=e[1];t++)if(n.binIndex[t]){const e=n.binIndex[t];for(let i of e){const e=i[0],n=i[1];r.push({minv:e,maxv:n,bin:t})}}return Oh(r,n.loffset[t[0]])}return[]}reg2bins(t,e){(t-=1)<1&&(t=1),e>2**34&&(e=2**34),e-=1;let i=0,n=0,r=this.minShift+3*this.depth;const s=[];for(;i<=this.depth;r-=3,n+=1<<3*i,i+=1){const i=n+(t>>r),o=n+(e>>r);s.push([i,o])}return s}bin_limit(){return((1<<3*(this.depth+1))-1)/7}}class zh{constructor(){}async parse(t,e,i){const n=[];let r=Number.MAX_SAFE_INTEGER,s=0;const o=new Nh(new DataView(t)),a=o.getInt(),l={};if(!(21578050===a||e&&21578324===a))throw new Error(indexURL+" is not a "+(e?"tabix":"bai")+" file");{const t=o.getInt();if(e){o.getInt(),o.getInt(),o.getInt(),o.getInt(),o.getInt(),o.getInt(),o.getInt();for(let e=0;es&&(s=n.block),t[e].push([i,n]))}}}const l=o.getInt();for(let t=0;t0&&(n[e]={binIndex:t,linearIndex:i})}this.firstBlockPosition=r,this.lastBlockPosition=s,this.indices=n,this.sequenceIndexMap=l,this.tabix=e}}get chromosomeNames(){return Object.keys(this.sequenceIndexMap)}chunksForRange(t,e,i){const n=this.indices[t];if(n){const t=function(t,e){const i=[];return e>=1<<29&&(e=1<<29),--e,i.push([0,0]),i.push([1+(t>>26),1+(e>>26)]),i.push([9+(t>>23),9+(e>>23)]),i.push([73+(t>>20),73+(e>>20)]),i.push([585+(t>>17),585+(e>>17)]),i.push([4681+(t>>14),4681+(e>>14)]),i}(e,i),r=[];for(let e of t)for(let t=e[0];t<=e[1];t++)if(n.binIndex[t]){const e=n.binIndex[t];for(let t of e){const e=t[0],i=t[1];r.push({minv:e,maxv:i})}}const s=n.linearIndex.length;let o;const a=Math.min(e>>14,s-1),l=Math.min(i>>14,s-1);for(let t=a;t<=l;t++){const e=n.linearIndex[t];if(e){o=e;break}}return Oh(r,o)}return[]}}class Uh{constructor(){}async parse(t,e){let i=0;this.chrIndex={},this.lastBlockPosition=[];const n=new Nh(new DataView(t));!function(t){t.getInt(),t.getInt();const e=t.getInt();if(t.getString(),t.getLong(),t.getLong(),t.getString(),t.getInt(),e>=3){let e=t.getInt();for(;e-- >0;)t.getString(),t.getString()}}(n);let r=n.getInt();for(;r-- >0;){let t=n.getString();e&&(t=e.getChromosomeName(t));const r=n.getInt(),s=n.getInt(),o=n.getInt();n.getInt(),n.getInt();let a=n.getLong();const l=[];for(let t=0;ti&&(i=t)}this.chrIndex[t]={chr:t,blocks:l,longestFeature:o,binWidth:r}}this.lastBlockPosition=i}get chromosomeNames(){return Object.keys(this.chrIndex)}chunksForRange(t,e,i){const n=this.chrIndex[t];if(n){const t=n.blocks,r=n.longestFeature,s=n.binWidth,o=Math.max(e-r,0),a=Math.floor(o/s);if(a>=t.length)return[];{const e=Math.min(Math.floor((i-1)/s),t.length-1),n=t[a].min,r=t[e].max;return 0==r-n?[]:[{minv:{block:n,offset:0},maxv:{block:r,offset:0}}]}}}}async function Vh(t,e,i){let n=await zo.loadArrayBuffer(t,la(e)),r=new DataView(n);switch(31===r.getUint8(0)&&139===r.getUint8(1)&&(n=uo(n).buffer,r=new DataView(n)),r.getInt32(0,!0)){case 21578050:return async function(t,e){const i=new zh;return await i.parse(t,!1,e),i}(n,i);case 21578324:return async function(t,e){const i=new zh;return await i.parse(t,!0,e),i}(n,i);case 21582659:return async function(t,e){const i=new Ph;return i.parse(t,e),i}(n,i);case 1480870228:return async function(t,e){const i=new Uh;return i.parse(t,e),i}(n,i);case 38359875:throw Error("CSI version 2 is not supported.");default:throw Error(`Unrecognized index type: ${t}`)}}function Hh(t){return"string"==typeof t||t instanceof String?new jh(t):new $h(t)}class jh{constructor(t){this.data=t,this.ptr=0}nextLine(){var t=this.ptr,e=this.data.indexOf("\n",t),i=this.data;if(e>0)return this.ptr=e+1,e>t&&"\r"===i.charAt(e-1)?i.substring(t,e-1):i.substring(t,e);var n=i.length;return this.ptr=n,t>=n?void 0:i.substring(t)}}class $h{constructor(t){this.data=t,this.length=this.data.length,this.ptr=0}nextLine(){var t,e;if(e="",!(this.ptr>=this.length)){for(var i=this.ptr;i{const e=ArrayBuffer.isView(t)?t:new Uint8Array(t);return 1+(e[17]<<8|e[16])};class Gh{constructor(t){this.config=t,this.cacheBlocks=0!=t.cacheBlocks,this.cache=void 0}async getData(t,e){const i=t.block,n=e.block,r=0===e.offset,s=await this.getInflatedBlocks(i,n,r);if(1===s.length)return s[0];let o=0;for(const t of s)o+=t.byteLength;const a=new Uint8Array(o);let l=0;for(const t of s)a.set(t,l),l+=t.byteLength;return a}async getInflatedBlocks(t,e,i){if(this.cacheBlocks){const n=this.cache;if(n&&n.startBlock<=t&&(n.endBlock>=e||i&&n.nextEndBlock===e)){const i=t-n.startBlock,r=e-n.startBlock;return Yh(n.buffer,i,r)}{let r;if(!n||n.startBlock>e||n.endBlock=n.endBlock)o=n.buffer;else{const i=Math.max(0,t-n.startBlock);let r;if(e>=n.endBlock)r=n.buffer.byteLength;else{const t=Zh(n.buffer);for(let i=0;in.endBlock){const t=await this.loadBLockData(n.endBlock,e,{skipStart:!0,skipEnd:i});s.push(t)}r=function(t){if(1===t.length)return t[0];let e=0;for(const i of t)e+=i.byteLength;const i=new Uint8Array(e);let n=0;for(const e of t)i.set(new Uint8Array(e),n),n+=e.byteLength;return i.buffer}(s)}let s=e;if(i){const t=Zh(r);e=t[t.length-1]}return this.cache={startBlock:t,endBlock:e,nextEndBlock:s,buffer:r},Yh(r)}}return Yh(await this.loadBLockData(t,e,{skipEnd:i}))}async loadBLockData(t,e,i){const n=this.config,r=i&&i.skipStart;let s=0;if(!i||!i.skipEnd){const t=la(n,{range:{start:e,size:26}}),i=await zo.loadArrayBuffer(n.url,t);s=Wh(i)}if(r){const e=la(n,{range:{start:t,size:26}}),i=await zo.loadArrayBuffer(n.url,e);t+=Wh(i)}const o=la(n,{range:{start:t,size:e+s-t}});return zo.loadArrayBuffer(n.url,o)}}function Zh(t){const e=t.byteLength;let i=0;const n=[0];for(;it.blocks)).map((t=>t.max)).reduce(((t,e)=>Math.min(t,e)),Number.MAX_SAFE_INTEGER),n=la(this.config,{bgz:t.tabix,range:{start:0,size:i}});e=Hh(await zo.loadString(this.config.url,n))}return this.header=await this.parser.parseHeader(e),this.header}{const t=la(this.config),e=await zo.loadString(this.config.url,t);let i=Hh(e);return this.header=await this.parser.parseHeader(i),i=Hh(e),this.features=await this.parser.parseFeatures(i),this.header}}getParser(t){switch(t.format){case"vcf":return new wh(t);case"seg":return new fh("seg");case"mut":return new fh("mut");case"maf":return new fh("maf");case"gwas":return new kh(t);case"aed":return new Th(t);default:return new sh(t)}}async loadFeaturesNoIndex(){if(this.features){const t=this.features;return delete this.features,t}{const t=la(this.config),e=await zo.loadString(this.config.url,t);if(!this.header){const t=Hh(e);this.header=await this.parser.parseHeader(t)}const i=Hh(e);return await this.parser.parseFeatures(i)}}async loadFeaturesWithIndex(t,e,i){this.dataURI||this.header||await this.readHeader();const n=this.config,r=this.parser,s=this.index.tabix,o=s?this.index.sequenceIndexMap[t]:t;if(void 0===o)return[];const a=this.genome,l=this.index.chunksForRange(o,e,i);if(l&&0!==l.length){const o=[];for(let h of l){let l;if(s)l=await this._blockLoader.getData(h.minv,h.maxv);else{const t=la(n,{range:{start:h.minv.block,size:h.maxv.block-h.minv.block+1}});l=await zo.loadString(n.url,t)}const c=Hh(h.minv.offset?l.slice(h.minv.offset):l);let u=await r.parseFeatures(c);u=u.filter((t=>void 0===t._f));let d=!1;for(let n=0;ni){o.push(r);break}r.end>=e&&r.start<=i&&(d||(d=!0,n>0&&o.push(u[n-1])),o.push(r))}}return o.sort((function(t,e){return t.start-e.start})),o}return[]}async getIndex(){return this.index?this.index:this.config.indexURL?(this.index=await this.loadIndex(),this.index):void 0}async loadIndex(){return Vh(this.config.indexURL,this.config,this.genome)}async loadFeaturesFromDataURI(){if(this.features){const t=this.features;return delete this.features,t}{const t=bo(this.dataURI);let e=Hh(t);return this.header=await this.parser.parseHeader(e),this.header instanceof String&&this.header.startsWith("##gff-version 3")&&(this.format="gff3"),e=Hh(t),this.features=await this.parser.parseFeatures(e),this.features}}}const Xh=ji;class Kh{constructor(t){this.config=t}async readFeatures(t,e,i){let n;n="function"==typeof this.config.url?this.config.url({chr:t,start:e,end:i}):this.config.url.replace("$CHR",t).replace("$START",e).replace("$END",i);let r,s=Object.assign({},this.config);void 0!==this.config.body&&("function"==typeof this.config.body?s.body=this.config.body({chr:t,start:e,end:i}):s.body=this.config.body.replace("$CHR",t).replace("$START",e).replace("$END",i));const o=await zo.load(n,s);if(o&&(r="function"==typeof this.config.parser?this.config.parser(o):Xh(o)?JSON.parse(o):o),this.config.mappings){let t=Object.keys(this.config.mappings);for(let e of r)for(let i of t)e[i]=e[this.config.mappings[i]]}return r}}const Jh=function(t,e){this.config=t,this.genome=e,this.expandQueryInterval=!1};Jh.prototype.readFeatures=function(t,e,i){const n=Math.max(0,Math.floor(e));let r=Math.ceil(i);if(this.genome){const e=this.genome.getChromosome(t);e&&r>e.bpLength&&(r=e.bpLength)}const s=this.config.url+"?db="+this.config.db+"&table="+this.config.tableName+"&chr="+t+"&start="+n+"&end="+r;return zo.loadJson(s,this.config).then((function(t){return t?(t.forEach((function(t){t.hasOwnProperty("exonStarts")&&t.hasOwnProperty("exonEnds")&&t.hasOwnProperty("exonCount")&&t.hasOwnProperty("cdsStart")&&t.hasOwnProperty("cdsEnd")&&function(t){var e,i,n,r,s,o;e=t.exonCount,i=t.exonStarts.split(","),n=t.exonEnds.split(","),r=[];for(var a=0;ao||t.cdsEnd=s&&t.cdsStart<=o&&(l.cdStart=t.cdsStart),t.cdsEnd>=s&&t.cdsEnd<=o&&(l.cdEnd=t.cdsEnd),r.push(l)}t.exons=r}(t)})),t):null}))};const tc=["Name","gene_name","gene","gene_id","alias","locus","name"];class ec{constructor(t){this.format=t.format,this.nameField=t.nameField,this.filterTypes=void 0===t.filterTypes?new Set(["chromosome"]):new Set(t.filterTypes)}combineFeatures(t,e){let i;const n=this.filterTypes;if(t=t.filter((t=>void 0===n||!n.has(t.type))),"gff3"===this.format){const e=this.combineFeaturesById(t);i=this.combineFeaturesByType(e)}else i=this.combineFeaturesByType(t);return i.sort((function(t,e){return t.start-e.start})),this.numberExons(i,e),this.nameFeatures(i),i}combineFeaturesById(t){const e=new Map,i=[];for(let n of t)if(El(n.type)||Il(n.type)||!n.id)i.push(n);else{let t=e.get(n.chr);t||(t=new Map,e.set(n.chr,t));let i=t.get(n.id);i?i.push(n):t.set(n.id,[n])}for(let t of e.values())for(let e of t.values())if(e.length>1){const t=e[0];t.exons=[];for(let i of e)t.start=Math.min(t.start,i.start),t.end=Math.max(t.end,i.end),t.exons.push({start:i.start,end:i.end});i.push(t)}else i.push(e[0]);return i}combineFeaturesByType(t){const e=t.filter((t=>"gene"===t.type||t.type.endsWith("_gene"))),i=Object.create(null);for(let t of e)i[t.id]=t;const n=Object.create(null),r=[],s=new Set,o=this.filterTypes;t=t.filter((t=>void 0===o||!o.has(t.type)));for(let e of t)if("biological_region"===e.type&&console.log(),Il(e.type)){const t=e.id;if(void 0!==t){const o=new Ll(e);n[t]=o,r.push(o),s.add(e);const a=i[e.parent];a&&(o.geneObject=a,s.add(a))}}for(let e of t)if(El(e.type)){const t=h(e);if(t)for(let i of t){let o=n[i];if(!o&&"gtf"===this.format){const t=Object.assign({},e);t.type="transcript",o=new Ll(t),n[i]=o,r.push(o)}if(void 0!==o){if(a=e.type,kl.has(a))if(t.length>1){const t=new Rl(e);o.addExon(t)}else o.addExon(e);else o.addPart(e);s.add(e)}}}var a;r.forEach((function(t){"function"==typeof t.finish&&t.finish()}));const l=t.filter((t=>!s.has(t)));for(let t of l)r.push(t);return r;function h(t){return t.parent&&""!==t.parent.trim()?t.parent.trim().split(","):null}}numberExons(t,e){for(let i of t)if(i.exons&&(!e||i.end<=e.end&&i.start>e.start))for(let t=0;t0){const t=1===this.variant_types.length?"Type":"Types";let i;for(let t of this.variant_types)i?i+=", "+t.display_name:i=t.display_name;e.push({name:t,value:i})}return e.push({name:"Actionability",value:this.actionabilityScore}),e.push({name:"Location",value:this.locationString}),e;function i(t,e){return""+t+""}}}class cc{constructor(t,e){if(this.config=t,this.genome=e,this.format=t.format?t.format.toUpperCase():"BAM","BAM"!==this.format&&"VCF"!==this.format)throw Error(`htsget format ${t.format} is not supported`)}async readHeaderData(){const t=`${uc(this.config)}?class=header&format=${this.format}`,e=await zo.loadJson(t,la(this.config));return await this.loadUrls(e.htsget.urls)}async readData(t,e,i){const n=`${uc(this.config)}?format=${this.format}&referenceName=${t}&start=${Math.floor(e)}&end=${Math.ceil(i)}`,r=await zo.loadJson(n,la(this.config));return this.loadUrls(r.htsget.urls)}async loadUrls(t){const e=[];for(let i of t)if(i.url.startsWith("data:"))e.push(Promise.resolve(dc(i.url)));else{const t=la(this.config||{});i.headers&&(t.headers=Object.assign(t.headers||{},i.headers)),e.push(zo.loadArrayBuffer(i.url,t))}return function(t){let e=0;for(let i of t)e+=i.byteLength;let i=0;const n=new Uint8Array(e);for(let e of t){const t=new Uint8Array(e);n.set(t,i),i+=t.length}return n}(await Promise.all(e))}static async inferFormat(t){try{const e=uc(t),i=`${e}${e.includes("?")?"&":"?"}class=header`,n=await zo.loadJson(i,la(t));if(n.htsget){const e=n.htsget.format;if("BAM"!==e&&"VCF"!==e)throw Error(`htsget format ${e} is not supported`);t.format=e.toLowerCase(),t.sourceType="htsget",t.name||(t.name=await ua(t.url))}}catch(t){}}}function uc(t){if(t.url&&t.endpoint&&t.id)return t.url+t.endpoint+t.id;if(t.endpoint&&t.id)return t.endpoint+t.id;if(t.url)return t.url.startsWith("htsget://")?t.url.replace("htsget://","https://"):t.url;throw Error("Must specify either 'url', or 'endpoint' and 'id")}function dc(t){const e=t.split(","),i=e[0].split(":")[1];let n=e[1];n=i.indexOf("base64")>=0?atob(n):decodeURI(n);const r=new Uint8Array(n.length);for(var s=0;s=i[t]){n.row=t,i[t]=n.end;break}n.row=t,i[t]=n.end}}function gc(t,e,i){const n=i||1e4,r=t=>{const i=Object.assign({},t);return i.chr="all",i.start=e.getGenomeCoordinate(t.chr,t.start),i.end=e.getGenomeCoordinate(t.chr,t.end),i._f=t,i.exons&&delete i.exons,i},s=new Set(e.wgChromosomeNames),o=[];let a=0;for(let i of e.wgChromosomeNames){if(Array.isArray(t)){const i={};for(let n of t){const t=e.getChromosomeName(n.chr);i.hasOwnProperty(t)||(i[t]=[]),i[t].push(n)}t=i}const l=t[i];if(l)for(let t of l){let i=e.getChromosomeName(t.chr);if(s.has(i))if(o.lengthi-e&&!1!==this.config.expandQuery){const t=Math.min(4.1*(i-e),n);s=Math.max(0,(e+i)/2-t),o=e+t}let a=await r.readFeatures(t,s,o);void 0===this.queryable&&(this.queryable=r.indexed);const l=this.queryable?new Da(t,s,o):void 0;a?(!1===this.config.assembleGFF||"gtf"!==this.config.format&&"gff3"!==this.config.format&&"gff"!==this.config.format||(a=new ec(this.config).combineFeatures(a,l)),"wig"!==this.config.format&&"junctions"!==this.config.type&&mc(a,this.config.maxRows||Number.MAX_SAFE_INTEGER),this.featureCache=new Zo(a,this.genome,l),this.searchable&&this.genome.addFeaturesToDB(a,this.config)):this.featureCache=new Zo([],l)}}class yc{constructor(t,e,i){this.path=t.url,this.bufferSize=i||512e3,this.range={start:-1,size:-1},this.config=t}async dataViewForRange(t,e,i=0){try{if(!(this.data&&this.range.start<=t.start&&this.range.start+this.range.size>=t.start+t.size)){let e;e=t.size?Math.max(this.bufferSize,t.size):this.bufferSize,this.contentLength&&(e=Math.min(e,this.contentLength-t.start));const i={start:t.start,size:e},n=await zo.loadArrayBuffer(this.path,la(this.config,{range:i}));this.data=n,this.range=i}const i=this.data.byteLength,n=t.start-this.range.start;return e?new Uint8Array(this.data,n,i-n):new DataView(this.data,n,i-n)}catch(n){if(0===i&&n.message&&n.message.startsWith("416")){try{return this.contentLength=await zo.getContentLength(this.path,la(this.config)),this.dataViewForRange(t,e,++i)}catch(t){console.error(t)}throw n}}}}let vc=512e3;class wc{constructor(t,e){this.path=t.url,this.format=t.format||"bigwig",this.genome=e,this.rpTreeCache={},this.config=t,this.loader=fa(this.path)?new Rc(this.path):zo}async readWGFeatures(t,e){await this.loadHeader();const i=this.chromTree.idToChrom.length-1,n=this.chromTree.idToChrom[0],r=this.chromTree.idToChrom[i];return this.readFeatures(n,0,r,Number.MAX_VALUE,t,e)}async readFeatures(t,e,i,n,r,s){await this.loadHeader();const o=this.chromTree.chromToID[t],a=this.chromTree.chromToID[i];if(void 0===o||void 0===a)return[];let l,h;if("bigwig"===this.type){const t=await this.getZoomHeaders();let e=r?function(t,e){let i;for(let n=0;n0?lo(r):r,h.call(this,new DataView(u.buffer),o,e,a,n,c,this.chromTree.idToChrom,s)}return c.sort((function(t,e){return t.start-e.start})),c}return[]}async getZoomHeaders(){return this.zoomLevelHeaders||await this.loadHeader(),this.zoomLevelHeaders}async loadHeader(){if(this.header)return this.header;{let t,e=await this.loader.loadArrayBuffer(this.path,la(this.config,{range:{start:0,size:64}}));this.littleEndian=!0;let i=new Nh(new DataView(e)),n=i.getUInt();if(2291137574===n)this.type="bigwig";else if(2273964779===n)this.type="bigbed";else{this.littleEndian=!1,i.littleEndian=!1,i.position=0;let t=i.getUInt();654085990===t?this.type="bigwig":3958540679===t&&(this.type="bigbed")}t={bwVersion:i.getUShort(),nZoomLevels:i.getUShort(),chromTreeOffset:i.getLong(),fullDataOffset:i.getLong(),fullIndexOffset:i.getLong(),fieldCount:i.getUShort(),definedFieldCount:i.getUShort(),autoSqlOffset:i.getLong(),totalSummaryOffset:i.getLong(),uncompressBuffSize:i.getInt(),extensionOffset:i.getLong()};const r=64;let s={start:r,size:t.fullDataOffset-r+5};e=await this.loader.loadArrayBuffer(this.path,la(this.config,{range:s}));const o=t.nZoomLevels;i=new Nh(new DataView(e)),this.zoomLevelHeaders=[],this.firstZoomDataOffset=Number.MAX_SAFE_INTEGER;for(let t=1;t<=o;t++){const e=o-t,n=new _c(e,i);this.firstZoomDataOffset=Math.min(n.dataOffset,this.firstZoomDataOffset),this.zoomLevelHeaders[e]=n}if(t.autoSqlOffset>0){i.position=t.autoSqlOffset-r;const e=i.getString();e&&(this.autoSql=function(t){let e;const i=[];let n=!1;const r=t.trim().split(/\s*[\r\n]+\s*/g);for(let t of r)if(t.startsWith("table"))e=t.split(/\s+/)[1].trim();else if(t.startsWith("("))n=!0;else if(t.startsWith(")"));else if(n&&t.length>0){const e=t.indexOf(";"),n=t.substr(0,e).split(/\s+/),r=t.substr(e+1).replace(/"/g,"").trim();i.push({type:n[0],name:n[1],description:r})}return{table:e,fields:i}}(e))}if(t.totalSummaryOffset>0&&(i.position=t.totalSummaryOffset-r,this.totalSummary=new Ac(i)),!(t.chromTreeOffset>0))throw"BigWig chromosome tree offset <= 0";return i.position=t.chromTreeOffset-r,this.chromTree=new Sc(i,r,this.genome),i.position=t.fullDataOffset-r,t.dataCount=i.getInt(),this.setDefaultVisibilityWindow(t),this.header=t,this.header}}async loadRPTree(t){let e=this.rpTreeCache[t];return e||(e=new xc(t,this.config,this.littleEndian,this.loader),await e.load(),this.rpTreeCache[t]=e,e)}async getType(){return await this.loadHeader(),this.type}async getTrackType(){return await this.loadHeader(),"bigwig"===this.type?"wig":this.autoSql&&"chromatinInteract"===this.autoSql.table?"interact":"annotation"}setDefaultVisibilityWindow(t){if("bigwig"===this.type)this.visibilityWindow=-1;else{let e=this.genome?this.genome.getGenomeLength():3088286401;this.visibilityWindow=t.dataCount<1e3?-1:e/t.dataCount*1e3}}}class _c{constructor(t,e){this.index=t,this.reductionLevel=e.getInt(),this.reserved=e.getInt(),this.dataOffset=e.getLong(),this.indexOffset=e.getLong()}}class xc{constructor(t,e,i,n){this.config=e,this.loader=n,this.fileOffset=t,this.path=e.url,this.littleEndian=i}async load(){const t=this.fileOffset+48,e=fa(this.path)?this.loader:new yc(this.config,vc);return this.rootNode=await this.readNode(t,e),this}async readNode(t,e){let i=await e.dataViewForRange({start:t,size:4},!1),n=new Nh(i,this.littleEndian);const r=1===n.getByte();n.getByte();const s=n.getUShort();let o={start:t+=4,size:s*(r?32:24)};i=await e.dataViewForRange(o,!1);const a=new Array(s);if(n=new Nh(i),r){for(let t=0;t=0&&(n.position=r);let o=n.getByte();n.getByte();let a,l,u,d,f,p,g=n.getUShort();if(1===o)for(a=0;at.startChrom||n===t.startChrom&&r>=t.startBase)&&(e0){this.mean=this.sumData/t,this.stddev=Math.sqrt(this.sumSquares/(t-1));let e=this.minVal<0?this.mean-2*this.stddev:0,i=this.maxVal>0?this.mean+2*this.stddev:0;this.defaultRange={min:e,max:i}}}function Ic(t,e,i,n,r,s,o){const a=new Nh(t),l=a.getInt(),h=a.getInt();let c=h,u=a.getInt();const d=a.getInt(),f=a.getInt(),p=a.getByte();a.getByte();let g=a.getUShort();if(l>=e&&l<=n){let t=0;for(;g-- >0;){let g;switch(p){case 1:c=a.getInt(),u=a.getInt(),g=a.getFloat();break;case 2:c=a.getInt(),g=a.getFloat(),u=c+f;break;case 3:g=a.getFloat(),c=h+t*d,u=c+f,t++}if(!(ln||l===n&&c>=r)break;if(Number.isFinite(g)){const t=o[l];s.push({chr:t,start:c,end:u,value:g})}}}}}function Ec(){const t=function(t,e,i,n){if("biginteract"===n||i&&"chromatinInteract"===i.table||"interact"===i.table)return function(t,e){return t.chr1=e[5],t.start1=Number.parseInt(e[6]),t.end1=Number.parseInt(e[7]),t.chr2=e[10],t.start2=Number.parseInt(e[11]),t.end2=Number.parseInt(e[12]),t.name=e[0],t.score=Number(e[1]),t.value=Number(e[2]),t.color="."===e[4]?void 0:"0"===e[4]?"rgb(0,0,0)":e[4],t};{const n=t-3;return function(r,s){if(n>0&&(r.name=s[0]),n>1&&(r.score=Number(s[1])),n>2&&(r.strand=s[2]),n>3&&(r.cdStart=parseInt(s[3])),n>4&&(r.cdEnd=parseInt(s[4])),n>5&&"."!==s[5]&&"0"!==s[5]&&"-1"!==s[5]){const t=xo.createColorString(s[5]);r.color=t.startsWith("rgb")?t:void 0}if(n>8){const t=parseInt(s[6]),e=s[7].split(","),i=s[8].split(","),n=[];for(let s=0;si?n.utr=!0:(e>=r&&e<=t&&(n.cdStart=e),i>=r&&i<=t&&(n.cdEnd=i))}}(n,r.cdStart,r.cdEnd),r.exons=n}if(i)for(let n=t;n=13;){const e=l.getInt(),h=a[e],c=l.getInt(),u=l.getInt(),d=l.getString();if(!(er||e===r&&c>=s)break;if(u>0){const e={chr:h,start:c,end:u};o.push(e);const i=d.split("\t");t(e,i)}}}}}function Mc(t,e,i,n,r,s,o,a){const l=new Nh(t);for(;l.remLength()>=32;){const t=l.getInt(),h=o[t],c=l.getInt(),u=l.getInt(),d=l.getInt(),f=l.getFloat(),p=l.getFloat(),g=l.getFloat();let m;switch(l.getFloat(),a){case"min":m=f;break;case"max":m=p;break;default:m=0===d?0:g/d}if(!(tn||t===n&&c>=r)break;Number.isFinite(m)&&s.push({chr:h,start:c,end:u,value:m})}}}class Rc{constructor(t){this.data=bo(t).buffer}loadArrayBuffer(t,e){const i=e.range;return i?this.data.slice(i.start,i.start+i.size):this.data}async dataViewForRange(t,e){const i=Math.min(this.data.byteLength-t.start,t.size);return e?new Uint8Array(this.data,t.start,i):new DataView(this.data,t.start,i)}}class Lc{constructor(t,e){this.reader=new wc(t,e),this.genome=e,this.format=t.format||"bigwig",this.wgValues={},this.queryable=!0}async getFeatures({chr:t,start:e,end:i,bpPerPixel:n,windowFunction:r}){const s="bigwig"===this.reader.type,o="all"===t.toLowerCase()?s?await this.getWGValues(r):[]:await this.reader.readFeatures(t,e,t,i,n,r);return s||pc(o),o}async getHeader(){return this.reader.loadHeader()}getDefaultRange(){return void 0!==this.reader.totalSummary?this.reader.totalSummary.defaultRange:void 0}async defaultVisibilityWindow(){return this.reader.defaultVisibilityWindow}async getWGValues(t){const e=this.genome;if(this.wgValues[t])return this.wgValues[t];{const i=e.getGenomeLength()/1e3,n=await this.reader.readWGFeatures(i,t);let r=[];for(let t of n){const i=t.chr,n=e.getCumulativeOffset(i),s=Object.assign({},t);s.chr="all",s.start=n+t.start,s.end=n+t.end,r.push(s)}return this.wgValues[t]=r,r}}supportsWholeGenome(){return"bigwig"===this.reader.type}async trackType(){return this.reader.getTrackType()}}class Bc{constructor(t,e){this.config=t,this.genome=e,this.path=t.url,this.groupCache={},this.datasetCache={}}async readHeader(){if(void 0!==this.magic)return this;let t=await zo.loadArrayBuffer(this.path,la(this.config,{range:{start:0,size:64e3}})),e=new Nh(new DataView(t));if(this.magic=e.getInt(),this.version=e.getInt(),this.indexPos=e.getLong(),this.indexSize=e.getInt(),e.getInt(),this.version>=2){let t=e.getInt();for(this.windowFunctions=[];t-- >0;)this.windowFunctions.push(e.getString())}this.trackType=e.getString(),this.trackLine=e.getString();let i=e.getInt();for(this.trackNames=[];i-- >0;)this.trackNames.push(e.getString());this.genomeID=e.getString(),this.flags=e.getInt(),this.compressed=0!=(1&this.flags),t=await zo.loadArrayBuffer(this.path,la(this.config,{range:{start:this.indexPos,size:this.indexSize}})),e=new Nh(new DataView(t)),this.datasetIndex={};let n=e.getInt();for(;n-- >0;){const t=e.getString(),i=e.getLong(),n=e.getInt();this.datasetIndex[t]={position:i,size:n}}for(this.groupIndex={},n=e.getInt();n-- >0;){const t=e.getString(),i=e.getLong(),n=e.getInt();this.groupIndex[t]={position:i,size:n}}return this}async readDataset(t,e,i){const n=t+"_"+e+"_"+i;if(this.datasetCache[n])return this.datasetCache[n];{await this.readHeader();const r=this.version<2?"":"/"+e,s="all"===t.toLowerCase()||void 0===i?"0":i.toString();let o;o="raw"===e?"/"+t+"/raw":"/"+t+"/z"+s+r;const a=this.datasetIndex[o];if(void 0===a)return;const l=await zo.loadArrayBuffer(this.path,la(this.config,{range:{start:a.position,size:a.size}}));if(!l)return;const h=new Nh(new DataView(l));let c=h.getInt();const u={};for(;c-- >0;)u[h.getString()]=h.getString();const d=h.getString(),f=h.getFloat();let p=h.getInt();const g=[];for(;p-- >0;)g.push({position:h.getLong(),size:h.getInt()});const m={name:o,attributes:u,dataType:d,tileWidth:f,tiles:g};return this.datasetCache[n]=m,m}}async readRootGroup(){const t=this.genome,e=this.groupCache["/"];if(e)return e;{const e=await this.readGroup("/"),i=e.chromosomes,n=e.maxZoom;n&&(this.maxZoom=Number(n));const r=e.totalCount;r&&(e.totalCount=Number(r));const s={};return i&&i.split(",").forEach((function(e){const i=t.getChromosomeName(e);s[i]=e})),this.chrAliasTable=s,this.groupCache["/"]=e,e}}async readGroup(t){const e=this.groupCache[t];if(e)return e;{await this.readHeader();const e=this.groupIndex[t];if(void 0===e)return;const i=await zo.loadArrayBuffer(this.path,la(this.config,{range:{start:e.position,size:e.size}}));if(!i)return;const n=new Nh(new DataView(i)),r={name:t};let s=n.getInt();for(;s-- >0;){const t=n.getString(),e=n.getString();r[t]=e}return this.groupCache[t]=r,r}}async readTiles(t,e){if(t.sort((function(t,e){return t.position-e.position})),0===(t=t.filter((function(t){return t.size>0}))).length)return Promise.resolve([]);const i=t[0],n=t[t.length-1],r=i.position,s=n.position+n.size-r,o=await zo.loadArrayBuffer(this.path,la(this.config,{range:{start:r,size:s}})),a=[];for(let i of t){const t=i.position-r,n=i.size;if(n>0){let i;i=this.compressed?lo(o.slice(t,t+n)).buffer:o.slice(t,t+n);const r=new Nh(new DataView(i)),s=r.getString();let l;switch(s){case"fixedStep":l=Nc(r,e);break;case"variableStep":l=Fc(r,e);break;case"bed":case"bedWithName":l=Oc(r,e,s);break;default:throw"Unknown tile type: "+s}a.push(l)}}return a}async readTile(t,e){let i=await zo.loadArrayBuffer(this.path,la(this.config,{range:{start:t.position,size:t.size}}));this.compressed&&(i=lo(i).buffer);const n=new Nh(new DataView(i)),r=n.getString();switch(r){case"fixedStep":return Nc(n,e);case"variableStep":return Fc(n,e);case"bed":case"bedWithName":return Oc(n,e,r);default:throw"Unknown tile type: "+r}}}function Nc(t,e){const i=t.getInt(),n=t.getInt(),r=t.getFloat(),s=[];let o=e;for(;o-- >0;){let e=i;const n=[];for(;e-- >0;)n.push(t.getFloat());s.push(n)}return{type:"fixedStep",start:n,span:r,data:s,nTracks:e,nPositions:i}}function Fc(t,e){const i=t.getInt(),n=t.getFloat(),r=t.getInt(),s=[];let o=r;for(;o-- >0;)s.push(t.getInt());t.getInt();const a=[];let l=e;for(;l-- >0;){o=r;const e=[];for(;o-- >0;)e.push(t.getFloat());a.push(e)}return{type:"variableStep",tileStart:i,span:n,start:s,data:a,nTracks:e,nPositions:r}}function Oc(t,e,i){const n=t.getInt();let r=n;const s=[];for(;r-- >0;)s.push(t.getInt());r=n;const o=[];for(;r-- >0;)o.push(t.getInt());t.getInt();const a=[];let l=e;for(;l-- >0;){let e=n;const i=[];for(;e-- >0;)i.push(t.getFloat());a.push(i)}if("bedWithName"===i){r=n;const e=[];for(;r-- >0;)e.push(t.getString())}return{type:i,start:s,end:o,data:a,nTracks:e,nPositions:n}}class Dc{constructor(t,e){this.genome=e,this.windowFunction=t.windowFunction||"mean",this.reader=new Bc(t,e),this.queryable=!0}async getFeatures({chr:t,start:e,end:i,bpPerPixel:n}){if("all"===t.toLowerCase()){const t=[],e=this.genome;if(this.genome.wgChromosomeNames)for(let i of e.wgChromosomeNames){const r=e.getChromosome(i).bpLength;n=r/1e3;const s=await this._getFeatures(i,0,r,n);if(s)for(let i of s){const n=Object.assign({},i);n.chr="all",n.start=e.getGenomeCoordinate(i.chr,i.start),n.end=e.getGenomeCoordinate(i.chr,i.end),n._f=i,t.push(n)}}return t}return this._getFeatures(t,e,i,n)}async _getFeatures(t,e,i,n){const r=new Da(t,e,i),s=this.genome;if(!this.rootGroup&&(this.rootGroup=await this.reader.readRootGroup(),!this.normalizationFactor)){const t=this.rootGroup.totalCount;t&&(this.normalizationFactor=1e6/t)}r.bpPerPixel=n;const o=function(t,e,i){var n=i.getChromosome(t).bpLength;return Math.ceil(Math.log(Math.max(0,n/(700*e)))/Vc)}(t,n,s);let a=this.reader.chrAliasTable[t],l=this.reader.maxZoom;void 0===a&&(a=t),void 0===l&&(l=-1);const h=o>l?"raw":this.windowFunction,c=await this.reader.readDataset(a,h,o);if(null==c)return[];const u=c.tileWidth,d=Math.floor(e/u),f=Math.floor(i/u),p=await this.reader.readTiles(c.tiles.slice(d,f+1),1),g=[];for(let n of p)switch(n.type){case"bed":Pc(n,t,e,i,0,g);break;case"variableStep":zc(n,t,e,i,0,g);break;case"fixedStep":Uc(n,t,e,i,0,g);break;default:throw"Unknown tile type: "+n.type}return g.sort((function(t,e){return t.start-e.start})),g}get supportsWholeGenome(){return!0}}function Pc(t,e,i,n,r,s){const o=t.nPositions,a=t.start,l=t.end,h=t.data[0];for(let t=0;tn)break;s.push({chr:e,start:r,end:o,value:h[t]})}}}function zc(t,e,i,n,r,s){const o=t.nPositions,a=t.start,l=t.span,h=t.data[0];for(let t=0;tn)break;s.push({chr:e,start:r,end:o,value:h[t]})}}}function Uc(t,e,i,n,r,s){const o=t.nPositions;let a=t.start;const l=t.span,h=t.data[0];for(let t=0;tn)break;r>=i&&(Number.isNaN(h[t])||s.push({chr:e,start:a,end:r,value:h[t]})),a=r}}var Vc=Math.log(2);class Hc{constructor(t,e){this.config=t,this.genome=e,this.queryable=!1,this.searchable=!1!==t.searchable,this.updateFeatures(t.features)}updateFeatures(t){mc(t=function(t,e){if(e)for(let i of t)i.chr=e.getChromosomeName(i.chr);return t}(t,this.genome)),this.config.mappings&&function(t,e){let i=Object.keys(e);t.forEach((function(t){i.forEach((function(i){t[i]=t[e[i]]}))}))}(t,this.config.mappings),this.featureCache=new Zo(t,this.genome),(this.searchable||this.config.searchableFields)&&this.genome.addFeaturesToDB(t,this.config)}async getFeatures({chr:t,start:e,end:i,bpPerPixel:n,visibilityWindow:r}){const s=this.genome,o=s?s.getChromosomeName(t):t;return"all"===o.toLowerCase()?gc(this.featureCache.getAllFeatures(),this.genome,this.maxWGCount):this.featureCache.queryFeatures(o,e,i)}getAllFeatures(){return this.featureCache.getAllFeatures()}supportsWholeGenome(){return!0}}const jc=new Set(["bigwig","bw","bigbed","bb","biginteract","biggenepred","bignarrowpeak"]);function $c(t,e){const i=t.format?t.format.toLowerCase():void 0;return t.features?new Hc(t,e):jc.has(i)?new Lc(t,e):"tdf"===i?new Dc(t,e):new bc(t,e)}const qc=function(t,e){const{r:i,g:n,b:r}=Ko.nickel;return`rgba(${i},${n},${r},0.125)`}(),Wc=qc;class Gc{constructor(t,e){if(this.url=t.url,t.name?this.name=t.name:t.url&&Yi(t.url)?this.name=t.url.name:t.url&&ji(t.url)&&!t.url.startsWith("data:")&&(this.name=Zi(t.url)),this.isUserDefined=t.isUserDefined,t.features)this.featureSource=new Yc(t.features,e);else{if(t.format)t.format=t.format.toLowerCase();else{const e=Zi(t.url);t.format=ka(e)}this.featureSource=t.featureSource||$c(t,e)}!0===this.isUserDefined?(this.color=t.color||Wc,this.headerColor="rgba(155,185,129)"):(this.color=t.color||qc,this.headerColor="rgb(190,190,190)")}async getFeatures(t,e,i){return this.featureSource.getFeatures({chr:t,start:e,end:i})}async getAllFeatures(){return"function"==typeof this.featureSource.getAllFeatures?await this.featureSource.getAllFeatures():{}}addFeature(t){this.isUserDefined?this.featureSource.addFeature(t):console.error("Attempt to add ROI to non user-defined set")}removeFeature(t){this.isUserDefined?this.featureSource.removeFeature(t):console.error("Attempt to remove ROI from non user-defined set")}toJSON(){if(this.url)return{name:this.name,color:this.color,url:this.url,isUserDefined:this.isUserDefined};{const t=this.featureSource.getAllFeatures(),e=[];for(let i of Object.keys(t))for(let n of t[i])e.push(n);return{name:this.name,color:this.color,features:e,isUserDefined:this.isUserDefined}}}dispose(){for(let t of Object.keys(this))this[t]=void 0}}function Zc(t,e,i,n){let r=Math.round((t-i)/n),s=Math.round((e-i)/n)-r;return s<3&&(s=3,r-=1),{x:r,width:s}}class Yc{constructor(t,e){this.featureMap={},this.genome=e;for(let i of t){const t=e?e.getChromosomeName(i.chr):i.chr;let n=this.featureMap[t];n||(n=[],this.featureMap[t]=n),n.push(i)}for(let t of Object.keys(this.featureMap))this.featureMap[t].sort(((t,e)=>t.start-e.start))}getFeatures({chr:t,start:e,end:i}){if("all"===t.toLowerCase())return gc(this.featureMap,this.genome);{const n=this.featureMap[t];return n?n.filter((t=>t.end>e&&t.startt.start-e.start))}removeFeature({chr:t,start:e,end:i}){if(this.featureMap[t]){const n=`${t}-${e}-${i}`;this.featureMap[t]=this.featureMap[t].filter((t=>n!==`${t.chr}-${t.start}-${t.end}`))}}}class Qc{constructor(t,e,i,n){this.rulerViewport=t,this.rulerSweeper=_e.div({class:"igv-ruler-sweeper"}),e.appendChild(this.rulerSweeper),this.browser=i,this.referenceFrame=n,this.isMouseHandlers=void 0,this.addBrowserObserver()}addBrowserObserver(){this.boundObserverHandler=(()=>{this.referenceFrame&&(ul.isWholeGenomeView(this.referenceFrame.chr)?this.removeMouseHandlers():this.addMouseHandlers())}).bind(this),this.browser.on("locuschange",this.boundObserverHandler)}removeBrowserObserver(){this.browser.off("locuschange",this.boundObserverHandler)}addMouseHandlers(){if(!0===this.isMouseHandlers)return;let t,e,i,n,r,s;this.boundContentMouseDownHandler=function(s){t=!0,e=!0;const{x:o}=_e.translateMouseCoordinates(s,this.rulerViewport.contentDiv);n=i=o,r=1,this.rulerSweeper.style.display="block",this.rulerSweeper.style.backgroundColor=!0===s.shiftKey?Wc:"rgba(68, 134, 247, 0.25)",this.rulerSweeper.style.left=`${n}px`,this.rulerSweeper.style.width=`${r}px`}.bind(this),this.rulerViewport.contentDiv.addEventListener("mousedown",this.boundContentMouseDownHandler),this.boundDocumentMouseMoveHandler=function(o){let a;if(t&&e){const{x:t}=_e.translateMouseCoordinates(o,this.rulerViewport.contentDiv);a=Math.max(Math.min(t,this.rulerViewport.contentDiv.clientWidth),0),s=a-i,r=Math.abs(s),this.rulerSweeper.style.width=`${r}px`,s<0&&(n=i+s,this.rulerSweeper.style.left=`${n}px`)}}.bind(this),document.addEventListener("mousemove",this.boundDocumentMouseMoveHandler),this.boundDocumentMouseUpHandler=function(i){let s;!0===t&&!0===e&&(t=e=void 0,this.rulerSweeper.style.display="none",r>1)&&(s={start:Math.floor(this.referenceFrame.calculateEnd(n)),end:Math.floor(this.referenceFrame.calculateEnd(n+r))},!0===i.shiftKey?this.browser.roiManager.updateUserDefinedROISet(Object.assign({chr:this.referenceFrame.chr},s)):(ca(this.browser.genome.getChromosome(this.referenceFrame.chr).bpLength,s,this.browser.minimumBases()),function(t,e,i){t.start=Math.round(e.start),t.end=Math.round(e.end),t.bpPerPixel=(t.end-t.start)/i}(this.referenceFrame,s,this.rulerViewport.contentDiv.clientWidth),this.browser.updateViews(this.referenceFrame)))}.bind(this),document.addEventListener("mouseup",this.boundDocumentMouseUpHandler),this.isMouseHandlers=!0}removeMouseHandlers(){this.rulerViewport.contentDiv.removeEventListener("mousedown",this.boundContentMouseDownHandler),document.removeEventListener("mousemove",this.boundDocumentMouseMoveHandler),document.removeEventListener("mouseup",this.boundDocumentMouseUpHandler),this.isMouseHandlers=!1}dispose(){this.removeBrowserObserver(),this.removeMouseHandlers(),this.rulerSweeper.remove()}}class Xc{constructor(t){this.paired=!0,this.firstAlignment=t,this.chr=t.chr,this.readName=t.readName,t.starte.start?this.connectingEnd=t.start:this.connectingStart=t.start+t.lengthOnRef,this.start=Math.min(e.start,t.start),this.end=Math.max(e.start+e.lengthOnRef,t.start+t.lengthOnRef),this.lengthOnRef=this.end-this.start,this.scStart=Math.min(e.scStart,t.scStart);const i=Math.max(e.scStart+e.scLengthOnRef,t.scStart+t.scLengthOnRef);this.scLengthOnRef=i-this.scStart}containsLocation(t,e){const i=e?this.scStart:this.start,n=e?this.scLengthOnRef:this.lengthOnRef;return t>=i&&t<=i+n}alignmentContaining(t,e){return this.firstAlignment.containsLocation(t,e)?this.firstAlignment:this.secondAlignment&&this.secondAlignment.containsLocation(t,e)?this.secondAlignment:void 0}popupData(t){let e=this.firstAlignment.popupData(t);return this.secondAlignment&&(e.push("-------------------------------"),e=e.concat(this.secondAlignment.popupData(t))),e}isPaired(){return!0}isMateMapped(){return!0}isProperPair(){return this.firstAlignment.isProperPair()}get fragmentLength(){return Math.abs(this.firstAlignment.fragmentLength)}firstOfPairStrand(){return this.firstAlignment.isFirstOfPair()?this.firstAlignment.strand:this.secondAlignment&&this.secondAlignment.isFirstOfPair()?this.secondAlignment.strand:this.firstAlignment.mate.strand}hasTag(t){return this.firstAlignment.hasTag(t)||this.secondAlignment&&this.secondAlignment.hasTag(t)}}class Kc{constructor(){this.alignments=[],this.score=void 0}findAlignment(t){const e=(t,e)=>e>=t.start&&e=r.start&&t0?c-=t:0===c&&(c=1)}return c}(r,n,t);case"STRAND":return r.strand?1:-1;case"START":return r.start;case"TAG":return r.tags()[i];case"READ_NAME":return r.readName;case"INSERT_SIZE":return-Math.abs(r.fragmentLength);case"GAP_SIZE":return-r.gapSizeAt(t);case"MATE_CHR":return r.mate;case"MQ":return void 0===r.mq?Number.MAX_VALUE:-r.mq;case"ALIGNED_READ_LENGTH":return-r.lengthOnRef;default:return Number.MAX_VALUE}}}function Jc(t){return t.isPaired()&&t.mate&&t.isMateMapped()&&t.chr===t.mate.chr&&(t.isFirstOfPair()||t.isSecondOfPair())&&!(t.isSecondary()||t.isSupplementary())}function tu(t){const e=[];for(let i of t)for(let t of i.alignments)t instanceof Xc?(t.firstAlignment&&e.push(t.firstAlignment),t.secondAlignment&&e.push(t.secondAlignment)):e.push(t);return e}function eu(t,e,i,n){if(t){if(0===t.length)return[];{t.sort((function(t,e){return n?t.scStart-e.scStart:t.start-e.start}));const e=[];let i,r=0,s=0;const o=new Set,a=()=>{i=new Kc,e.push(i),r=0,s=0,o.clear()};for(a();t.length>0;)if(s>=0&&s(n?t.scStart:t.start)>r),s)}else t=t.filter((t=>!o.has(t))),a();return e}}}function iu(t,e,i){let n=i-1,r=t.length;for(;1+n>1);e(t[i])?r=i:n=i}return r}class nu{constructor(t,e,i,{samplingWindowSize:n,samplingDepth:r,pairsSupported:s,alleleFreqThreshold:o}){this.chr=t,this.start=Math.floor(e),this.end=Math.ceil(i),this.length=i-e,this.alleleFreqThreshold=void 0===o?.2:o,this.coverageMap=new su(t,e,i,this.alleleFreqThreshold),this.alignments=[],this.downsampledIntervals=[],this.samplingWindowSize=void 0===n?100:n,this.samplingDepth=void 0===r?1e3:r,this.pairsSupported=void 0===s||s,this.paired=!1,this.pairsCache={},this.downsampledReads=new Set,this.currentBucket=new ru(this.start,this.start+this.samplingWindowSize,this),this.filter=function(t){return t.isMapped()&&!t.isFailsVendorQualityCheck()}}push(t){!1!==this.filter(t)&&(this.coverageMap.incCounts(t),this.pairsSupported&&this.downsampledReads.has(t.readName)||(t.start>=this.currentBucket.end&&(this.finishBucket(),this.currentBucket=new ru(t.start,t.start+this.samplingWindowSize,this)),this.currentBucket.addAlignment(t)))}forEach(t){this.alignments.forEach(t)}finish(){void 0!==this.currentBucket&&this.finishBucket(),this.alignments.sort((function(t,e){return t.start-e.start})),this.pairsCache=void 0,this.downsampledReads=void 0}contains(t,e,i){return this.chr===t&&this.start<=e&&this.end>=i}hasDownsampledIntervals(){return this.downsampledIntervals&&this.downsampledIntervals.length>0}finishBucket(){this.alignments=this.alignments.concat(this.currentBucket.alignments),this.currentBucket.downsampledCount>0&&this.downsampledIntervals.push(new au(this.currentBucket.start,this.currentBucket.end,this.currentBucket.downsampledCount)),this.paired=this.paired||this.currentBucket.paired}setViewAsPairs(t){let e;e=t?function(t){const e={},i=[];for(let n of t)for(let t of n.alignments)if(Jc(t)){let n=e[t.readName];n?(n.setSecondAlignment(t),e[t.readName]=void 0):(n=new Xc(t),e[t.readName]=n,i.push(n))}else i.push(t);return i}(this.packedAlignmentRows):tu(this.packedAlignmentRows),this.packedAlignmentRows=eu(e,this.start,this.end)}setShowSoftClips(t){const e=this.allAlignments();this.packedAlignmentRows=eu(e,this.start,this.end,t)}repack(t,e){const i=this.allAlignments();this.packedAlignmentRows=eu(i,this.start,this.end,e)}allAlignments(){const t=[];for(let e of this.packedAlignmentRows)for(let i of e.alignments)t.push(i);return t}getMax(t,e){return this.coverageMap.getMax(t,e)}sortRows(t){const e=[],i=[];for(let n of this.packedAlignmentRows)void 0!==n.findAlignment(t.position)?e.push(n):i.push(n);e.sort(((e,i)=>{const n=t.direction,r=e.getSortValue(t,this),s=i.getSortValue(t,this);if(void 0===s&&void 0!==s)return 1;if(void 0!==r&&void 0===s)return-1;const o=r>s?1:re)break;const s=this.coverage[r];n>=t&&s&&(i=Math.max(i,s.total))}return i}incCounts(t){var e=this;if(void 0===t.blocks?i(t):t.blocks.forEach((function(t){i(t)})),t.gaps)for(let i of t.gaps)if("D"===i.type){const t=i.start-e.bpStart;for(let n=t;n=e}}class au{constructor(t,e,i){this.start=t,this.end=e,this.counts=i}popupData(t){return[{name:"start",value:this.start+1},{name:"end",value:this.end},{name:"# downsampled:",value:this.counts}]}}class lu{constructor(t){const e=t.split(",");this.chr=e[0],this.start=parseInt(e[1]),this.strand=e[2].charAt(0),this.mapQ=parseInt(e[4]),this.numMismatches=parseInt(e[5]),this.lenOnRef=Cu.computeLengthOnReference(e[3])}printString(){return this.chr+":"+$i(this.start)+"-"+$i(this.start+this.lenOnRef)+" ("+this.strand+") = "+$i(this.lenOnRef)+"bp @MAPQ: "+this.mapQ+" NM: "+this.numMismatches}}function hu(t){return t.split(";").filter((t=>t.length>0)).map((t=>new lu(t)))}const cu={c:1,C:1,s:2,S:2,i:4,I:4,f:4};class uu{constructor(){this.hidden=!1}isMapped(){return 0==(4&this.flags)}isPaired(){return 0!=(1&this.flags)}isProperPair(){return 0!=(2&this.flags)}isFirstOfPair(){return 0!=(64&this.flags)}isSecondOfPair(){return 0!=(128&this.flags)}isSecondary(){return 0!=(256&this.flags)}isSupplementary(){return 0!=(2048&this.flags)}isFailsVendorQualityCheck(){return 0!=(512&this.flags)}isDuplicate(){return 0!=(1024&this.flags)}isMateMapped(){return 0==(8&this.flags)}isNegativeStrand(){return 0!=(16&this.flags)}isMateNegativeStrand(){return 0!=(32&this.flags)}hasTag(t){return(this.tagDict||fu(this.tagBA)).hasOwnProperty(t)}tags(){return this.tagDict||(this.tagBA?(this.tagDict=fu(this.tagBA),this.tagBA=void 0):this.tagDict={}),this.tagDict}containsLocation(t,e){const i=e?this.scStart:this.start,n=e?this.scLengthOnRef:this.lengthOnRef;return t>=i&&t<=i+n}popupData(t){const e=[];if(t=Math.floor(t),this.insertions){const n=this.seq;for(let r of this.insertions){var i=r.start;if(t===i||t===i-1)return e.push({name:"Insertion",value:n.substr(r.seqOffset,r.len)}),e.push({name:"Location",value:i}),e}}e.push({name:"Read Name",value:this.readName}),e.push("
"),e.push({name:"Alignment Start",value:$i(1+this.start),borderTop:!0}),e.push({name:"Read Strand",value:!0===this.strand?"(+)":"(-)",borderTop:!0});let n=this.cigar;if(n&&n.length>50){const t=25;n=`${n.substring(0,t-2)} ... ${n.substring(n.length-t+2)}`}e.push({name:"Cigar",value:n}),e.push({name:"Mapping Quality",value:this.mq}),e.push({name:"Secondary",value:o(this.isSecondary())}),e.push({name:"Supplementary",value:o(this.isSupplementary())}),e.push({name:"Duplicate",value:o(this.isDuplicate())}),e.push({name:"Failed QC",value:o(this.isFailsVendorQualityCheck())}),this.isPaired()&&(e.push("
"),e.push({name:"First in Pair",value:!this.isSecondOfPair(),borderTop:!0}),e.push({name:"Mate is Mapped",value:o(this.isMateMapped())}),this.pairOrientation&&e.push({name:"Pair Orientation",value:this.pairOrientation}),this.isMateMapped()&&(e.push({name:"Mate Chromosome",value:this.mate.chr}),e.push({name:"Mate Start",value:this.mate.position+1}),e.push({name:"Mate Strand",value:!0===this.mate.strand?"(+)":"(-)"}),e.push({name:"Insert Size",value:this.fragmentLength})));const r=this.tags();if(r.hasOwnProperty("SA")){e.push("
"),e.push({name:"Supplementary Alignments",value:""});const t=hu(r.SA);if(t){e.push("
    ");for(let i of t)e.push(`
  • ${i.printString()}
  • `);e.push("
")}}const s=new Set(["SA","MD"]);e.push("
");for(let t in r)s.has(t)||e.push({name:t,value:r[t]});return e.push({name:"Hidden Tags",value:"SA, MD"}),e.push("
"),e.push({name:"Genomic Location: ",value:$i(1+t)}),e.push({name:"Read Base:",value:this.readBaseAt(t)}),e.push({name:"Base Quality:",value:this.readBaseQualityAt(t)}),e;function o(t){return t?"Yes":"No"}}readBaseAt(t){const e=du(this.blocks,t);if(e){if("*"===this.seq)return"*";{const i=e.seqIndexAt(t);return this.seq[i]}}}readBaseQualityAt(t){const e=du(this.blocks,t);if(e){if("*"===this.qual)return 30;{const i=e.seqIndexAt(t);return i>=0&&this.qual&&i=e.start&&t=n.start&&e>1)+n;a+4=e)return!1;if("B"!==String.fromCharCode(t[a+2])||"I"!==String.fromCharCode(t[a+3]))return!1;var h=Tu(t,a+4),c=a+8;if(c+4*h>e)return!1;var u="",d=0;s.length=0,a=c;for(var f=0;f>4,m=xu[15&p];"M"!==m&&"EQ"!==m&&"X"!==m&&"D"!==m&&"N"!==m&&"="!==m||(d+=g),u=u+g+m,s.push({len:g,ltr:m})}return r.cigar=u,r.lengthOnRef=d,!0},decodeBamRecords:function(t,e,i,n,r,s,o,a){for(;et.length)return;if(p<0){e=d;continue}if(void 0!==r&&(p>r||g>o))return!0;if(void 0!==r&&p>8,y=255&m,v=Tu(t,e+16),w=(4294901760&v)>>16,_=65535&v,x=Tu(t,e+20),k=Tu(t,e+24),S=Tu(t,e+28),C=Tu(t,e+32);let A=[];for(let i=0;i>4,c=xu[15&l];"M"!==c&&"EQ"!==c&&"X"!==c&&"D"!==c&&"N"!==c&&"="!==c||(T+=h),I=I+h+c,E+=4,R={len:h,ltr:c},M.push(R)}if(f.chr=n[p],f.start=g,f.flags=w,f.strand=!(16&w),f.readName=A,f.cigar=I,f.lengthOnRef=T,f.fragmentLength=C,f.mq=b,Cu.bam_tag2cigar(t,d,E,x,f,M),f.end=f.start+f.lengthOnRef,f.end>1;for(let e=0;e>4]),L.push(_u[15&u])}L=L.slice(0,x).join(""),E+=B;const N=[];for(let e=0;e=0&&(f.mate={chr:n[k],position:S,strand:!(32&w)}),f.seq=L,f.qual=N,f.tagBA=new Uint8Array(t.buffer.slice(E,d)),this.setPairOrientation(f),(void 0===a||a.pass(f))&&(Au(f,M),i.push(f)),e=d}},decodeSamRecords:function(t,e,i,n,r,s){var o,a,l,h,c,u,d,f,p,g;for(h=(o=qi(t)).length,a=0;ar)break;if(f=0,(g=Iu(p.cigar)).forEach((function(t){var e=t.len,i=t.ltr;"M"!==i&&"EQ"!==i&&"X"!==i&&"D"!==i&&"N"!==i&&"="!==i||(f+=e)})),p.lengthOnRef=f,!(p.start+fSu&&(console.log("Warning: attempt to set sampling depth > maximum value of "+Su),t.samplingDepth=Su),e.viewAsPairs?t.pairsSupported=!0:t.pairsSupported=void 0===e.pairsSupported||e.pairsSupported},setPairOrientation:function(t){if(t.isMapped()&&t.mate&&t.isMateMapped()&&t.mate.chr===t.chr){var e=t.strand?"F":"R",i=t.mate,n=i.strand?"F":"R",r=" ",s=" ";t.isFirstOfPair()?(r="1",s="2"):t.isSecondOfPair()&&(r="2",s="1");var o=[],a=t.fragmentLength,l=t.end-t.start;0===a&&(a=(t.start0?(o[0]=e,o[1]=r,o[2]=n,o[3]=s):(o[2]=e,o[3]=r,o[0]=n,o[1]=s),t.pairOrientation=o.join("")}},computeLengthOnReference:function(t){let e=0,i="";for(let n=0;n47&&r<58)i+=t.charAt(n);else{switch(r){case 78:case 68:case 77:case 61:case 88:e+=parseInt(i.toString())}i=""}}return e}};function Au(t,e){const i=[];let n,r,s=0,o=t.start;t.scStart=t.start,t.scLengthOnRef=t.lengthOnRef;for(let a of e){let e;switch(a.ltr){case"H":case"P":break;case"S":e=o,t.scLengthOnRef+=a.len,0===i.length&&(t.scStart-=a.len,e-=a.len),i.push(new vu({start:e,seqOffset:s,len:a.len,type:"S"})),s+=a.len;break;case"N":case"D":void 0===r&&(r=[]),r.push({start:o,len:a.len,type:a.ltr}),o+=a.len;break;case"I":void 0===n&&(n=[]),n.push(new vu({start:o,len:a.len,seqOffset:s,type:"I"})),s+=a.len;break;case"M":case"EQ":case"=":case"X":i.push(new vu({start:o,seqOffset:s,len:a.len,type:"M"})),s+=a.len,o+=a.len;break;default:console.log("Error processing cigar element: "+a.len+a.ltr)}}t.blocks=i,t.insertions=n,t.gaps=r}function Tu(t,e){return t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}function Iu(t){var e,i,n,r,s,o,a,l,h;for(e=[],i=[],s=null,r=t.length,n=0;n=48&&h<=57?i.push(o):(a=o,l=Number.parseInt(i.join("")),i=[],null!==s&&s.ltr===a?s.len+=l:(s={len:l,ltr:a},e.push(s)));return e}function Eu(t){var e={};return t.forEach((function(t){var i=t.split(":");e[i[0]]=i[2]})),e}class Mu{constructor(t,e){this.config=t,this.genome=e,this.bamPath=t.url,this.isDataUri=fa(t.url),Cu.setReaderDefaults(this,t)}async readAlignments(t,e,i){if(this.alignmentCache){const n=this.header,r=n.chrAliasTable.hasOwnProperty(t)?n.chrAliasTable[t]:t,s=this.alignmentCache.queryFeatures(r,e,i),o=new nu(t,e,i,this.config);for(let t of s)o.push(t);return o.finish(),o}if(this.isDataUri){const n=uo(function(t){const e=t.split(","),i=e[0].split(":")[1];let n=e[1];n=i.indexOf("base64")>=0?atob(n):decodeURI(n);const r=new Uint8Array(n.length);for(var s=0;s{var t={368:function(t,e,i){var n=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function o(t){try{l(n.next(t))}catch(t){s(t)}}function a(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}l((n=n.apply(t,e||[])).next())}))},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const s=r(i(4105)),o=r(i(1269)),a=i(597),l=i(3427),h=i(8577);function c(t,e){if(e.some((t=>void 0===t)))throw new h.CramMalformedError("invalid .crai index file");const[i,n,r,s,o,a]=e;t[i]||(t[i]=[]),t[i].push({start:n,span:r,containerStart:s,sliceStart:o,sliceBytes:a})}e.default=class{constructor(t){this.filehandle=(0,l.open)(t.url,t.path,t.filehandle),this._parseCache=new s.default({cache:new o.default({maxSize:1}),fill:(t,e)=>this.parseIndex()})}parseIndex(){const t={};return this.filehandle.readFile().then((t=>31===t[0]&&139===t[1]?(0,a.unzip)(t):t)).then((e=>{if(e.length>4&&21578050===e.readUInt32LE(0))throw new h.CramMalformedError("invalid .crai index file. note: file appears to be a .bai index. this is technically legal but please open a github issue if you need support");let i=[],n="";for(let r=0;r=48&&s<=57||!n&&45===s)n+=String.fromCharCode(s);else if(9===s)i.push(Number.parseInt(n,10)),n="";else if(10===s)i.push(Number.parseInt(n,10)),n="",c(t,i),i=[];else if(13!==s&&32!==s)throw new h.CramMalformedError("invalid .crai index file")}return n&&i.push(Number.parseInt(n,10)),6===i.length&&c(t,i),Object.entries(t).forEach((([e,i])=>{t[e]=i.sort(((t,e)=>t.start-e.start||t.span-e.span))})),t}))}getIndex(t={}){return this._parseCache.get("index",null,t.signal)}hasDataForReferenceSequence(t){return n(this,void 0,void 0,(function*(){return!!(yield this.getIndex())[t]}))}getEntriesForRange(t,e,i){return n(this,void 0,void 0,(function*(){const n=(yield this.getIndex())[t];if(!n)return[];const r=t=>{const n=t.start,r=t.start+t.span;return n>i?-1:r<=e?1:0},s=[];for(let t=0;t{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class{constructor(t,e){this.parameters=t,this.dataType=e}}},4863:function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(8577),s=n(i(1050)),o=i(1074);class a extends s.default{constructor(t,e){if(super(t,e),"int"!==this.dataType)throw new r.CramUnimplementedError(`${this.dataType} decoding not yet implemented by BETA codec`)}decode(t,e,i,n){return(0,o.getBits)(e.content,n.coreBlock,this.parameters.length)-this.parameters.offset}}e.default=a},1738:function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(9488),s=n(i(1050));class o extends s.default{constructor(t,e,i){if(super(t,e),this.instantiateCodec=i,"byteArray"!==e)throw new TypeError(`byteArrayLength does not support data type ${e}`)}decode(t,e,i,n){const r=this._getLengthCodec().decode(t,e,i,n),s=this._getDataCodec(),o=new Uint8Array(r);for(let a=0;a(0,r.tinyMemoize)(o,t)))},1405:function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(8577),s=n(i(1050)),o=i(1074);class a extends s.default{constructor(t,e){if(super(t,e),"byteArray"!==e)throw new TypeError(`byteArrayStop codec does not support data type ${e}`)}decode(t,e,i,n){const{blockContentId:s}=this.parameters,o=i[s];if(!o)throw new r.CramMalformedError(`no block found with content ID ${s}`);const a=n.externalBlocks.getCursor(s);return this._decodeByteArray(o,a)}_decodeByteArray(t,e){const i=t.content,{stopByte:n}=this.parameters,r=e.bytePosition;let s=e.bytePosition;for(;i[s]!==n&&s=t.content.length)throw new a.CramBufferOverrunError("attempted to read beyond end of block. this file seems truncated.");return t.content[e.bytePosition++]}}e.default=l},4229:function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(8577),s=n(i(1050)),o=i(1074);class a extends s.default{constructor(t,e){if(super(t,e),"int"!==this.dataType)throw new r.CramUnimplementedError(`${this.dataType} decoding not yet implemented by GAMMA codec`)}decode(t,e,i,n){let r=1;for(;0===(0,o.getBits)(e.content,n.coreBlock,1);)r+=1;return((0,o.getBits)(e.content,n.coreBlock,r-1)|1<{Object.defineProperty(e,"__esModule",{value:!0}),e.getBits=e.CramBufferOverrunError=void 0;class i extends Error{}e.CramBufferOverrunError=i,e.getBits=function(t,e,n){let r=0;if(e.bytePosition+(7-e.bitPosition+n)/8>t.length)throw new i("read error during decoding. the file seems to be truncated.");for(let i=n;i;i--)r<<=1,r|=t[e.bytePosition]>>e.bitPosition&1,e.bitPosition-=1,e.bitPosition<0&&(e.bytePosition+=1),e.bitPosition&=7;return r}},2082:function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(8577),s=n(i(1050)),o=i(1074);class a extends s.default{constructor(t,e){if(super(t,e),this.codes={},this.codeBook={},this.sortedByValue=[],this.sortedCodes=[],this.sortedValuesByBitCode=[],this.sortedBitCodes=[],this.sortedBitLengthsByBitCode=[],this.bitCodeToValue=[],!["byte","int"].includes(this.dataType))throw new TypeError(`${this.dataType} decoding not yet implemented by HUFFMAN_INT codec`);this.buildCodeBook(),this.buildCodes(),this.buildCaches(),0===this.sortedCodes[0].bitLength&&(this._decode=this._decodeZeroLengthCode)}buildCodeBook(){let t=new Array(this.parameters.numCodes);for(let e=0;et.bitLength-e.bitLength||t.symbol-e.symbol)),this.codeBook={},t.forEach((t=>{this.codeBook[t.bitLength]||(this.codeBook[t.bitLength]=[]),this.codeBook[t.bitLength].push(t.symbol)}))}buildCodes(){this.codes={};let t=0,e=-1;Object.entries(this.codeBook).forEach((([i,n])=>{const s=parseInt(i,10);n.forEach((i=>{const n={bitLength:s,value:i,bitCode:0};e+=1;const o=s-t;if(e<<=o,n.bitCode=e,t+=o,function(t){let e=t-(t>>1)&1431655765;return e=(858993459&e)+(e>>2&858993459),16843009*(e+(e>>4)&252645135)>>24}(e)>s)throw new r.CramMalformedError("Symbol out of range");this.codes[i]=n}))}))}buildCaches(){this.sortedCodes=Object.values(this.codes).sort(((t,e)=>t.bitLength-e.bitLength||t.bitCode-e.bitCode)),this.sortedByValue=Object.values(this.codes).sort(((t,e)=>t.value-e.value)),this.sortedValuesByBitCode=this.sortedCodes.map((t=>t.value)),this.sortedBitCodes=this.sortedCodes.map((t=>t.bitCode)),this.sortedBitLengthsByBitCode=this.sortedCodes.map((t=>t.bitLength));const t=Math.max(...this.sortedBitCodes);this.bitCodeToValue=new Array(t+1).fill(-1);for(let t=0;t-1&&this.sortedBitLengthsByBitCode[i]===e)return this.sortedValuesByBitCode[i];for(let i=t;this.sortedCodes[i+1].bitLength===e&&i{Object.defineProperty(e,"__esModule",{value:!0}),e.default={CRAM_FLAG_PRESERVE_QUAL_SCORES:1,CRAM_FLAG_DETACHED:2,CRAM_FLAG_MATE_DOWNSTREAM:4,CRAM_FLAG_NO_SEQ:8,CRAM_FLAG_MASK:15,CRAM_M_REVERSE:1,CRAM_M_UNMAP:2,BAM_FPAIRED:1,BAM_FPROPER_PAIR:2,BAM_FUNMAP:4,BAM_FMUNMAP:8,BAM_FREVERSE:16,BAM_FMREVERSE:32,BAM_FREAD1:64,BAM_FREAD2:128,BAM_FSECONDARY:256,BAM_FQCFAIL:512,BAM_FDUP:1024,BAM_FSUPPLEMENTARY:2048,BAM_CMATCH:0,BAM_CINS:1,BAM_CDEL:2,BAM_CREF_SKIP:3,BAM_CSOFT_CLIP:4,BAM_CHARD_CLIP:5,BAM_CPAD:6,BAM_CEQUAL:7,BAM_CDIFF:8,BAM_CBACK:9,BAM_CIGAR_STR:"MIDNSHP:XB",BAM_CIGAR_SHIFT:4,BAM_CIGAR_MASK:15,BAM_CIGAR_TYPE:246183}},8543:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0});const n=i(8772),r=i(8577),s={BF:"int",CF:"int",RI:"int",RL:"int",AP:"int",RG:"int",MF:"int",NS:"int",NP:"int",TS:"int",NF:"int",TC:"byte",TN:"int",FN:"int",FC:"byte",FP:"int",BS:"byte",IN:"byteArray",SC:"byteArray",DL:"int",BA:"byte",BB:"byteArray",RS:"int",PD:"int",HC:"int",MQ:"int",RN:"byteArray",QS:"byte",QQ:"byteArray",TL:"int"};e.default=class{constructor(t){this.dataSeriesCodecCache={},this.tagCodecCache={},this.tagEncoding={},this.readNamesIncluded=t.preservation.RN,this.APdelta=t.preservation.AP,this.referenceRequired=!!t.preservation.RR,this.tagIdsDictionary=t.preservation.TD,this.substitutionMatrix=function(t){const e=new Array(5);for(let t=0;t<5;t+=1)e[t]=new Array(4);return e[0][t[0]>>6&3]="C",e[0][t[0]>>4&3]="G",e[0][t[0]>>2&3]="T",e[0][t[0]>>0&3]="N",e[1][t[1]>>6&3]="A",e[1][t[1]>>4&3]="G",e[1][t[1]>>2&3]="T",e[1][t[1]>>0&3]="N",e[2][t[2]>>6&3]="A",e[2][t[2]>>4&3]="C",e[2][t[2]>>2&3]="T",e[2][t[2]>>0&3]="N",e[3][t[3]>>6&3]="A",e[3][t[3]>>4&3]="C",e[3][t[3]>>2&3]="G",e[3][t[3]>>0&3]="N",e[4][t[4]>>6&3]="A",e[4][t[4]>>4&3]="C",e[4][t[4]>>2&3]="G",e[4][t[4]>>0&3]="T",e}(t.preservation.SM),this.dataSeriesEncoding=t.dataSeriesEncoding,this.tagEncoding=t.tagEncoding,this.preservation=t.preservation,this._size=t._size,this._endPosition=t._endPosition}getCodecForTag(t){if(!this.tagCodecCache[t]){const e=this.tagEncoding[t];e&&(this.tagCodecCache[t]=(0,n.instantiateCodec)(e,"byteArray"))}return this.tagCodecCache[t]}getTagNames(t){return this.tagIdsDictionary[t]}getCodecForDataSeries(t){let e=this.dataSeriesCodecCache[t];if(void 0===e){const i=this.dataSeriesEncoding[t];if(i){const o=s[t];if(!o)throw new r.CramMalformedError(`data series name ${t} not defined in file compression header`);e=(0,n.instantiateCodec)(i,o),this.dataSeriesCodecCache[t]=e}}return e}toJSON(){const t={};return Object.keys(this).forEach((e=>{/Cache$/.test(e)||(t[e]=this[e])})),t}}},6284:function(t,e,i){var n=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function o(t){try{l(n.next(t))}catch(t){s(t)}}function a(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}l((n=n.apply(t,e||[])).next())}))},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const s=i(8577),o=i(9488),a=r(i(6601)),l=r(i(8543));class h{constructor(t,e){this.file=t,this.filePosition=e}getHeader(){return this._readContainerHeader(this.filePosition)}getCompressionHeaderBlock(){return n(this,void 0,void 0,(function*(){if(!(yield this.getHeader()).numRecords)return null;const t=yield this.file.getSectionParsers(),e=yield this.getFirstBlock();if(void 0===e)return;if("COMPRESSION_HEADER"!==e.contentType)throw new s.CramMalformedError(`invalid content type ${e.contentType} in what is supposed to be the compression header block`);const i=(0,o.parseItem)(e.content,t.cramCompressionHeader.parser,0,e.contentPosition);return Object.assign(Object.assign({},e),{parsedContent:i})}))}getFirstBlock(){return n(this,void 0,void 0,(function*(){const t=yield this.getHeader();return this.file.readBlock(t._endPosition)}))}getCompressionScheme(){return n(this,void 0,void 0,(function*(){const t=yield this.getCompressionHeaderBlock();if(t)return new l.default(t.parsedContent)}))}getSlice(t,e){return new a.default(this,t,e)}_readContainerHeader(t){return n(this,void 0,void 0,(function*(){const e=yield this.file.getSectionParsers(),{cramContainerHeader1:i,cramContainerHeader2:n}=e,{size:r}=yield this.file.stat();if(t>=r)return;const s=Buffer.allocUnsafe(i.maxLength);yield this.file.read(s,0,i.maxLength,t);const a=(0,o.parseItem)(s,i.parser),l=(0,o.itf8Size)(a.numLandmarks);if(t+a.length>=r)return void console.warn(`${this.file}: container header at ${t} indicates that the container has length ${a.length}, which extends beyond the length of the file. Skipping this container.`);const h=Buffer.allocUnsafe(n.maxLength(a.numLandmarks));yield this.file.read(h,0,n.maxLength(a.numLandmarks),t+a._size-l);const c=(0,o.parseItem)(h,n.parser);return this.file.validateChecksums&&void 0!==c.crc32&&(yield this.file.checkCrc32(t,a._size+c._size-l-4,c.crc32,`container header beginning at position ${t}`)),Object.assign(a,c,{_size:a._size+c._size-l,_endPosition:a._size+c._size-l+t})}))}}e.default=h,"getHeader getCompressionHeaderBlock getCompressionScheme".split(" ").forEach((t=>(0,o.tinyMemoize)(h,t)))},5457:function(t,e,i){var n=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function o(t){try{l(n.next(t))}catch(t){s(t)}}function a(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}l((n=n.apply(t,e||[])).next())}))},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const s=i(597),o=r(i(2779)),a=r(i(1269)),l=i(8577),h=r(i(9675)),c=i(6141),u=r(i(3498)),d=r(i(6284)),f=i(3427),p=i(9488),g=i(7578);class m{constructor(t){var e;if(this.file=(0,f.open)(t.url,t.path,t.filehandle),this.validateChecksums=!0,this.fetchReferenceSequenceCallback=t.seqFetch,this.options={checkSequenceMD5:t.checkSequenceMD5,cacheSize:null!==(e=t.cacheSize)&&void 0!==e?e:2e4},this.featureCache=new a.default({maxSize:this.options.cacheSize}),function(){const t=new Uint32Array([287454020]),e=new Uint8Array(t.buffer);return 68===e[0]?0:17===e[0]?1:2}()>0)throw new Error("Detected big-endian machine, may be unable to run")}read(t,e,i,n){return this.file.read(t,e,i,n)}stat(){return this.file.stat()}getDefinition(){return n(this,void 0,void 0,(function*(){const t=Buffer.allocUnsafe(c.cramFileDefinition.maxLength);yield this.file.read(t,0,c.cramFileDefinition.maxLength,0);const e=c.cramFileDefinition.parser.parse(t).result;if(2!==e.majorVersion&&3!==e.majorVersion)throw new l.CramUnimplementedError(`CRAM version ${e.majorVersion} not supported`);return e}))}getSamHeader(){return n(this,void 0,void 0,(function*(){const t=yield this.getContainerById(0);if(!t)throw new l.CramMalformedError("file contains no containers");const e=yield t.getFirstBlock();if(void 0===e)return(0,g.parseHeaderText)("");const i=e.content,n=i.readInt32LE(0),r=i.toString("utf8",4,4+n);return this.header=r,(0,g.parseHeaderText)(r)}))}getHeaderText(){return n(this,void 0,void 0,(function*(){return yield this.getSamHeader(),this.header}))}getSectionParsers(){return n(this,void 0,void 0,(function*(){const{majorVersion:t}=yield this.getDefinition();return(0,c.getSectionParsers)(t)}))}getContainerById(t){return n(this,void 0,void 0,(function*(){const e=yield this.getSectionParsers();let i=e.cramFileDefinition.maxLength;const{size:n}=yield this.file.stat(),{cramContainerHeader1:r}=e;let s;for(let e=0;e<=t;e+=1){if(i+r.maxLength+8>=n)return;s=this.getContainerAtPosition(i);const o=yield s.getHeader();if(!o)throw new l.CramMalformedError(`container ${t} not found in file`);if(0===e){i=o._endPosition;for(let t=0;t=n)return;const r=Buffer.allocUnsafe(i.maxLength);return yield this.file.read(r,0,i.maxLength,t),(0,p.parseItem)(r,i.parser,0,t)}))}_parseSection(t,e,i=t.maxLength,r){return n(this,void 0,void 0,(function*(){let n;if(r)n=r;else{const{size:t}=yield this.file.stat();if(e+i>=t)return;n=Buffer.allocUnsafe(i),yield this.file.read(n,0,i,e)}const s=(0,p.parseItem)(n,t.parser,0,e);if(s._size!==i)throw new l.CramMalformedError(`section read error: requested size ${i} does not equal parsed size ${s._size}`);return s}))}_uncompress(t,e,i){if("gzip"===t)(0,s.unzip)(e).copy(i);else if("bzip2"===t){const t=bzip2.array(e);let n,r=bzip2.header(t),s=0;do{n=bzip2.decompress(t,r),-1!=n&&(Buffer.from(n).copy(i,s),s+=n.length,r-=n.length)}while(-1!=n)}else if("rans"===t)(0,h.default)(e,i);else if("rans4x16"===t)u.default.r4x16_uncompress(e,i);else if("arith"===t)u.default.arith_uncompress(e,i);else if("fqzcomp"===t)u.default.fqzcomp_uncompress(e,i);else{if("tok3"!==t)throw new l.CramUnimplementedError(`${t} decompression not yet implemented`);u.default.tok3_uncompress(e,i)}}readBlock(t){return n(this,void 0,void 0,(function*(){const{majorVersion:e}=yield this.getDefinition(),i=yield this.getSectionParsers(),n=yield this.readBlockHeader(t);if(void 0===n)return;const r=n._endPosition,s=Buffer.allocUnsafe(n.uncompressedSize),o=Object.assign(Object.assign({},n),{_endPosition:r,contentPosition:r,content:s});if("raw"!==n.compressionMethod){const t=Buffer.allocUnsafe(n.compressedSize);yield this.read(t,0,n.compressedSize,r),this._uncompress(n.compressionMethod,t,s)}else yield this.read(s,0,n.uncompressedSize,r);if(e>=3){const e=yield this._parseSection(i.cramBlockCrc32,r+n.compressedSize);if(void 0===e)return;o.crc32=e.crc32,this.validateChecksums&&(yield this.checkCrc32(t,n._size+n.compressedSize,e.crc32,"block data")),o._endPosition=e._endPosition,o._size=o.compressedSize+i.cramBlockCrc32.maxLength}else o._endPosition=r+o.compressedSize,o._size=o.compressedSize;return o}))}}e.default=m,"getDefinition getSectionParsers getSamHeader".split(" ").forEach((t=>(0,p.tinyMemoize)(m,t)))},8222:function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.CramRecord=void 0;const r=n(i(5457));var s=i(8631);Object.defineProperty(e,"CramRecord",{enumerable:!0,get:function(){return n(s).default}}),e.default=r.default},8631:function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.MateFlagsDecoder=e.CramFlagsDecoder=e.BamFlagsDecoder=e.MateFlags=e.CramFlags=e.BamFlags=void 0;const r=n(i(2615)),s={a:0,A:0,c:1,C:1,g:2,G:2,t:3,T:3,n:4,N:4};function o(t){const e={};for(const[i,n]of t)e["is"+n]=t=>!!(t&i),e["set"+n]=t=>t|i;return e}e.BamFlags=[[1,"Paired"],[2,"ProperlyPaired"],[4,"SegmentUnmapped"],[8,"MateUnmapped"],[16,"ReverseComplemented"],[32,"MateReverseComplemented"],[64,"Read1"],[128,"Read2"],[256,"Secondary"],[512,"FailedQc"],[1024,"Duplicate"],[2048,"Supplementary"]],e.CramFlags=[[1,"PreservingQualityScores"],[2,"Detached"],[4,"WithMateDownstream"],[8,"DecodeSequenceAsStar"]],e.MateFlags=[[1,"OnNegativeStrand"],[2,"Unmapped"]],e.BamFlagsDecoder=o(e.BamFlags),e.CramFlagsDecoder=o(e.CramFlags),e.MateFlagsDecoder=o(e.MateFlags),e.default=class{constructor({flags:t,cramFlags:e,readLength:i,mappingQuality:n,lengthOnRef:r,qualityScores:s,mateRecordNumber:o,readBases:a,readFeatures:l,mateToUse:h,readGroupId:c,readName:u,sequenceId:d,uniqueId:f,templateSize:p,alignmentStart:g,tags:m}){this.flags=t,this.cramFlags=e,this.readLength=i,this.mappingQuality=n,this.lengthOnRef=r,this.qualityScores=s,a&&(this.readBases=a),this.readGroupId=c,this.readName=u,this.sequenceId=d,this.uniqueId=f,this.templateSize=p,this.alignmentStart=g,this.tags=m,l&&(this.readFeatures=l),h&&(this.mate={flags:h.mateFlags,readName:h.mateReadName,sequenceId:h.mateSequenceId,alignmentStart:h.mateAlignmentStart}),o&&(this.mateRecordNumber=o)}isPaired(){return!!(this.flags&r.default.BAM_FPAIRED)}isProperlyPaired(){return!!(this.flags&r.default.BAM_FPROPER_PAIR)}isSegmentUnmapped(){return!!(this.flags&r.default.BAM_FUNMAP)}isMateUnmapped(){return!!(this.flags&r.default.BAM_FMUNMAP)}isReverseComplemented(){return!!(this.flags&r.default.BAM_FREVERSE)}isMateReverseComplemented(){return!!(this.flags&r.default.BAM_FMREVERSE)}isRead1(){return!!(this.flags&r.default.BAM_FREAD1)}isRead2(){return!!(this.flags&r.default.BAM_FREAD2)}isSecondary(){return!!(this.flags&r.default.BAM_FSECONDARY)}isFailedQc(){return!!(this.flags&r.default.BAM_FQCFAIL)}isDuplicate(){return!!(this.flags&r.default.BAM_FDUP)}isSupplementary(){return!!(this.flags&r.default.BAM_FSUPPLEMENTARY)}isDetached(){return!!(this.cramFlags&r.default.CRAM_FLAG_DETACHED)}hasMateDownStream(){return!!(this.cramFlags&r.default.CRAM_FLAG_MATE_DOWNSTREAM)}isPreservingQualityScores(){return!!(this.cramFlags&r.default.CRAM_FLAG_PRESERVE_QUAL_SCORES)}isUnknownBases(){return!!(this.cramFlags&r.default.CRAM_FLAG_NO_SEQ)}getReadBases(){if(!this.readBases&&this._refRegion){const t=function(t,e){if(!t.lengthOnRef&&!t.readLength)return null;if(t.isUnknownBases())return null;const i=t.alignmentStart-e.start;if(!t.readFeatures)return e.seq.substr(i,t.lengthOnRef).toUpperCase();let n="",r=i,s=0;for(;n.lengththis.mate.alignmentStart&&s>0&&(s=-s),s>0?(r[0]=t,r[1]=i,r[2]=e,r[3]=n):(r[2]=t,r[3]=i,r[0]=e,r[1]=n),r.join("")}return null}addReferenceSequence(t,e){this.readFeatures&&this.readFeatures.forEach((i=>{"X"===i.code&&function(t,e,i,n){if(!e)return;const r=n.refPos-e.start,o=e.seq.charAt(r);o&&(n.ref=o);let a=s[o];void 0===a&&(a=4);const l=i.substitutionMatrix[a][n.data];l&&(n.sub=l)}(0,t,e,i)})),!this.readBases&&t.start<=this.alignmentStart&&t.end>=this.alignmentStart+(this.lengthOnRef||this.readLength)-1&&(this._refRegion=t)}toJSON(){const t={};return Object.keys(this).forEach((e=>{"_"!==e.charAt(0)&&(t[e]=this[e])})),t.readBases=this.getReadBases(),t}}},6141:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getSectionParsers=e.cramFileDefinition=e.isMappedSliceHeader=void 0;const n=i(9996),r=(new n.Parser).itf8(),s={parser:(new n.Parser).string("magic",{length:4}).uint8("majorVersion").uint8("minorVersion").string("fileId",{length:20,stripNull:!0}),maxLength:26};e.cramFileDefinition=s;const o={parser:(new n.Parser).uint8("compressionMethod",{formatter:t=>{const e=["raw","gzip","bzip2","lzma","rans","rans4x16","arith","fqzcomp","tok3"][t];if(!e)throw new Error(`compression method number ${t} not implemented`);return e}}).uint8("contentType",{formatter:t=>{const e=["FILE_HEADER","COMPRESSION_HEADER","MAPPED_SLICE_HEADER","UNMAPPED_SLICE_HEADER","EXTERNAL_DATA","CORE_DATA"][t];if(!e)throw new Error(`invalid block content type id ${t}`);return e}}).itf8("contentId").itf8("compressedSize").itf8("uncompressedSize"),maxLength:17},a={parser:(new n.Parser).uint32("crc32"),maxLength:4},l=(new n.Parser).itf8("size").buffer("ents",{length:"size",formatter:t=>{function e(e,i){const n=t.toString("utf8",e,i),r=[];for(let t=0;tr&&n.push(e(r,i)),n}}),h=(new n.Parser).uint8(null,{formatter:t=>!!t}),c=(new n.Parser).itf8("mapSize").itf8("mapCount").array("ents",{length:"mapCount",type:(new n.Parser).string("key",{length:2,stripNull:!1}).choice("value",{tag:"key",choices:{MI:h,UI:h,PI:h,RN:h,AP:h,RR:h,SM:(new n.Parser).array(null,{type:"uint8",length:5}),TD:(new n.Parser).nest(null,{type:l,formatter:t=>t.ents})}})});function u(t){const e={};for(let i=0;i=3?(i=i.ltf8("recordCounter"),e+=9):2===t&&(i=i.itf8("recordCounter"),e+=5),i=i.itf8("numBlocks").itf8("numContentIds").array("contentIds",{type:r,length:"numContentIds"}),e+=10,t>=2&&(i=i.array("md5",{type:"uint8",length:16}),e+=16),{parser:i,maxLength:t=>e+5*t}},cramMappedSliceHeader(t){let e=(new n.Parser).itf8("refSeqId").itf8("refSeqStart").itf8("refSeqSpan").itf8("numRecords"),i=20;return t>=3?(e=e.ltf8("recordCounter"),i+=9):2===t&&(e=e.itf8("recordCounter"),i+=5),e=e.itf8("numBlocks").itf8("numContentIds").array("contentIds",{type:r,length:"numContentIds"}).itf8("refBaseBlockId"),i+=15,t>=2&&(e=e.array("md5",{type:"uint8",length:16}),i+=16),{parser:e,maxLength:t=>i+5*t}},cramEncoding:t=>({parser:(new n.Parser).namely("cramEncoding").itf8("codecId").itf8("parametersBytes").choice("parameters",{tag:"codecId",choices:{0:new n.Parser,1:(new n.Parser).itf8("blockContentId"),2:(new n.Parser).itf8("offset").itf8("M"),3:n.Parser.start().itf8("numCodes").array("symbols",{length:"numCodes",type:r}).itf8("numLengths").array("bitLengths",{length:"numLengths",type:r}),4:n.Parser.start().nest("lengthsEncoding",{type:"cramEncoding"}).nest("valuesEncoding",{type:"cramEncoding"}),5:(new n.Parser).uint8("stopByte").itf8("blockContentId"),6:(new n.Parser).itf8("offset").itf8("length"),7:(new n.Parser).itf8("offset").itf8("K"),8:(new n.Parser).itf8("offset").itf8("log2m"),9:(new n.Parser).itf8("offset")}})}),cramDataSeriesEncodingMap(t){return(new n.Parser).itf8("mapSize").itf8("mapCount").array("ents",{length:"mapCount",type:(new n.Parser).string("key",{length:2,stripNull:!1}).nest("value",{type:this.cramEncoding(t).parser})})},cramTagEncodingMap(t){return(new n.Parser).itf8("mapSize").itf8("mapCount").array("ents",{length:"mapCount",type:(new n.Parser).itf8("key",{formatter:t=>String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(255&t)}).nest("value",{type:this.cramEncoding(t).parser})})},cramCompressionHeader(t){let e=new n.Parser;return e=e.nest("preservation",{type:c,formatter:u}).nest("dataSeriesEncoding",{type:this.cramDataSeriesEncodingMap(t),formatter:u}).nest("tagEncoding",{type:this.cramTagEncodingMap(t),formatter:u}),{parser:e}},cramContainerHeader1(t){let e=(new n.Parser).int32("length").itf8("refSeqId").itf8("refSeqStart").itf8("alignmentSpan").itf8("numRecords"),i=24;return t>=3?(e=e.ltf8("recordCounter"),i+=9):2===t&&(e=e.itf8("recordCounter"),i+=5),t>1&&(e=e.ltf8("numBases"),i+=9),e=e.itf8("numBlocks").itf8("numLandmarks"),i+=10,{parser:e,maxLength:i}},cramContainerHeader2(t){let e=(new n.Parser).itf8("numLandmarks").array("landmarks",{type:(new n.Parser).itf8(),length:"numLandmarks"}),i=0;return t>=3&&(e=e.uint32("crc32"),i=4),{parser:e,maxLength:t=>5+5*t+i}}};e.getSectionParsers=function(t){const e=Object.assign({},d);return Object.keys(f).forEach((i=>{e[i]=f[i](t)})),e}},3757:function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=n(i(3720)),s=i(8577),o=i(8631),a=i(6141);function l(t){let e="";for(let i=0;i1&&-2===n.parsedContent.refSeqId?e("RI"):n.parsedContent.refSeqId;const b=e("RL");let y=e("AP");i.APdelta&&(y+=u.lastAlignmentStart),u.lastAlignmentStart=y;const v=e("RG");let w,_,x,k;if(i.readNamesIncluded&&(w=l(e("RN"))),o.CramFlagsDecoder.isDetached(g)){const t=e("MF");let n;i.readNamesIncluded||(n=l(e("RN")),w=n);const r=e("NS"),s=e("NP");(t||r>-1)&&(_={mateFlags:t,mateSequenceId:r,mateAlignmentStart:s,mateReadName:n}),x=e("TS"),o.MateFlagsDecoder.isUnmapped(t)&&(p=o.BamFlagsDecoder.setMateUnmapped(p)),o.MateFlagsDecoder.isOnNegativeStrand(t)&&(p=o.BamFlagsDecoder.setMateReverseComplemented(p))}else o.CramFlagsDecoder.isWithMateDownstream(g)&&(k=e("NF")+f+1);const S=e("TL");if(S<0)throw new s.CramMalformedError("invalid TL index");const C={},A=i.getTagNames(S),T=A.length;for(let e=0;e1?"SC":"IN"],X:["number","BS"],D:["number","DL"],I:["string","IN"],i:["character","BA"],b:["string","BB"],q:["numArray","QQ"],Q:["number","QS"],H:["number","HC"],P:["number","PD"],N:["number","RS"]}[e];if(!c)throw new s.CramMalformedError(`invalid read feature code "${e}"`);let u=h(c);const d={B:["number","QS"]}[e];d&&(u=[u,h(d)]),o+=n;const f=o;a+=n;const p=a;"D"===e||"N"===e?a+=u:"I"===e||"S"===e?a-=u.length:"i"===e&&(a-=1),l[t]={code:e,pos:f,refPos:p,data:u}}return l}(y,t,e,0,d)),E=b,I)for(const{code:t,data:e}of I)"D"===t||"N"===t?E+=e:"I"===t||"S"===t?E-=e.length:"i"===t&&(E-=1);if(Number.isNaN(E)&&(console.warn(`${w||`${m}:${y}`} record has invalid read features`),E=b),M=e("MQ"),o.CramFlagsDecoder.isPreservingQualityScores(g)){R=new Array(b);for(let t=0;t=0){const r=t[i.mateRecordNumber];if(!r)throw new s.CramMalformedError("intra-slice mate record not found, this file seems malformed");n.push(...e(r))}return n}(i),r=n.map((t=>t.alignmentStart)),o=n.map((t=>t.alignmentStart+t.readLength-1)),a=Math.max(...o)-Math.min(...r)+1;a>=0&&n.forEach((t=>{if(void 0!==t.templateLength)throw new s.CramMalformedError("mate pair group has some members that have template lengths already, this file seems malformed");t.templateLength=a}))}(t,0,i):function(t,e){const i=Math.min(t.alignmentStart,e.alignmentStart),n=Math.max(t.alignmentStart+t.readLength-1,e.alignmentStart+e.readLength-1)-i+1;t.templateLength=n,e.templateLength=n}(i,n)),delete i.mateRecordNumber}class f{constructor(t,e,i){this.container=t,this.containerPosition=e,this.file=t.file}getHeader(){return n(this,void 0,void 0,(function*(){const t=yield this.file.getSectionParsers(),e=yield this.container.getHeader(),i=yield this.file.readBlock(e._endPosition+this.containerPosition);if(void 0===i)throw new Error;if("MAPPED_SLICE_HEADER"===i.contentType){const n=(0,o.parseItem)(i.content,t.cramMappedSliceHeader.parser,0,e._endPosition);return Object.assign(Object.assign({},i),{parsedContent:n})}if("UNMAPPED_SLICE_HEADER"===i.contentType){const n=(0,o.parseItem)(i.content,t.cramUnmappedSliceHeader.parser,0,e._endPosition);return Object.assign(Object.assign({},i),{parsedContent:n})}throw new s.CramMalformedError(`error reading slice header block, invalid content type ${i.contentType}`)}))}getBlocks(){return n(this,void 0,void 0,(function*(){const t=yield this.getHeader();let e=t._endPosition;const i=new Array(t.parsedContent.numBlocks);for(let t=0;t{"EXTERNAL_DATA"===t.contentType&&(e[t.contentId]=t)})),e}))}getBlockByContentId(t){return n(this,void 0,void 0,(function*(){return(yield this._getBlocksContentIdIndex())[t]}))}getReferenceRegion(){return n(this,void 0,void 0,(function*(){const t=(yield this.getHeader()).parsedContent;if(!(0,c.isMappedSliceHeader)(t))throw new Error;if(t.refSeqId<0)return;const e=yield this.container.getCompressionScheme();if(void 0===e)throw new Error;if(t.refBaseBlockId>=0){const e=yield this.getBlockByContentId(t.refBaseBlockId);if(!e)throw new s.CramMalformedError("embedded reference specified, but reference block does not exist");return{seq:e.data.toString("utf8"),start:t.refSeqStart,end:t.refSeqStart+t.refSeqSpan-1,span:t.refSeqSpan}}if(e.referenceRequired||this.file.fetchReferenceSequenceCallback){if(!this.file.fetchReferenceSequenceCallback)throw new Error("reference sequence not embedded, and seqFetch callback not provided, cannot fetch reference sequence");const e=yield this.file.fetchReferenceSequenceCallback(t.refSeqId,t.refSeqStart,t.refSeqStart+t.refSeqSpan-1);if(e.length!==t.refSeqSpan)throw new s.CramArgumentError("seqFetch callback returned a reference sequence of the wrong length");return{seq:e,start:t.refSeqStart,end:t.refSeqStart+t.refSeqSpan-1,span:t.refSeqSpan}}}))}getAllRecords(){return this.getRecords((()=>!0))}_fetchRecords(){return n(this,void 0,void 0,(function*(){const{majorVersion:t}=yield this.file.getDefinition(),e=yield this.container.getCompressionScheme();if(void 0===e)throw new Error;const i=yield this.getHeader();if(void 0===i)throw new Error;const n=yield this._getBlocksContentIdIndex();if(t>1&&this.file.options.checkSequenceMD5&&(0,c.isMappedSliceHeader)(i.parsedContent)&&i.parsedContent.refSeqId>=0&&"0000000000000000"!==i.parsedContent.md5.join("")){const t=yield this.getReferenceRegion();if(t){const{seq:e,start:n,end:r}=t,a=(0,o.sequenceMD5)(e),l=i.parsedContent.md5.map((t=>(t<16?"0":"")+t.toString(16))).join("");if(a!==l)throw new s.CramMalformedError(`MD5 checksum reference mismatch for ref ${i.parsedContent.refSeqId} pos ${n}..${r}. recorded MD5: ${l}, calculated MD5: ${a}`)}}const r=yield this.getCoreDataBlock(),a={lastAlignmentStart:(0,c.isMappedSliceHeader)(i.parsedContent)?i.parsedContent.refSeqStart:0,coreBlock:{bitPosition:7,bytePosition:0},externalBlocks:{map:new Map,getCursor(t){let e=this.map.get(t);return void 0===e&&(e={bitPosition:7,bytePosition:0},this.map.set(t,e)),e}}},f=t=>{const i=e.getCodecForDataSeries(t);if(!i)throw new s.CramMalformedError(`no codec defined for ${t} data series`);return i.decode(this,r,n,a)};let p=new Array(i.parsedContent.numRecords);for(let s=0;s!!t));break}throw t}for(let t=0;t=0&&d(p,t,p[t],p[e])}return p}))}getRecords(t){return n(this,void 0,void 0,(function*(){const e=this.container.filePosition+this.containerPosition;let i=this.file.featureCache.get(e.toString());i||(i=this._fetchRecords(),this.file.featureCache.set(e.toString(),i));const r=(yield i).filter(t);if(r.length&&this.file.fetchReferenceSequenceCallback){const t=yield this.getHeader();if((0,c.isMappedSliceHeader)(t.parsedContent)&&(t.parsedContent.refSeqId>=0||-2===t.parsedContent.refSeqId)){const e=t.parsedContent.refSeqId>=0?t.parsedContent.refSeqId:void 0,i=yield this.container.getCompressionScheme();if(void 0===i)throw new Error;const s={};for(let t=0;tn.end&&(n.end=o),r[t].alignmentStartn(this,void 0,void 0,(function*(){-1!==t.id&&t.start<=t.end&&(t.seq=yield this.file.fetchReferenceSequenceCallback(t.id,t.start,t.end))})))));for(let t=0;t(0,o.tinyMemoize)(f,t)))},9488:function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.sequenceMD5=e.tinyMemoize=e.parseItem=e.parseItf8=e.itf8Size=void 0;const r=n(i(2568)),s=i(1074);e.itf8Size=function(t){return-128&t?-16384&t?-2097152&t?-268435456&t?5:4:3:2:1},e.parseItf8=function(t,e){let i=e;const n=t[i];let r;if(n<128?(r=n,i+=1):n<192?(r=16383&(n<<8|t[i+1]),i+=2):n<224?(r=2097151&(n<<16|t[i+1]<<8|t[i+2]),i+=3):n<240?(r=268435455&(n<<24|t[i+1]<<16|t[i+2]<<8|t[i+3]),i+=4):(r=(15&n)<<28|t[i+1]<<20|t[i+2]<<12|t[i+3]<<4|15&t[i+4],i+=5),i>t.length)throw new s.CramBufferOverrunError("Attempted to read beyond end of buffer; this file seems truncated.");return[r,i-e]},e.parseItem=function(t,e,i=0,n=0){const{offset:r,result:s}=e.parse(t);return Object.assign(Object.assign({},s),{_endPosition:r+n,_size:r-i})},e.tinyMemoize=function(t,e){const i=t.prototype[e],n=`_memo_${e}`;t.prototype[e]=function(){if(!(n in this)){const t=i.call(this);this[n]=t,Promise.resolve(t).catch((()=>{delete this[n]}))}return this[n]}},e.sequenceMD5=function(t){return(0,r.default)(t.toUpperCase().replace(/[^\x21-\x7e]/g,""))}},8577:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CramArgumentError=e.CramSizeLimitError=e.CramMalformedError=e.CramUnimplementedError=e.CramError=void 0;class i extends Error{}e.CramError=i;class n extends Error{}e.CramUnimplementedError=n,e.CramMalformedError=class extends i{},e.CramSizeLimitError=class extends i{},e.CramArgumentError=class extends i{}},5590:function(t,e,i){var n=this&&this.__createBinding||(Object.create?function(t,e,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(e,i);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[i]}}),Object.defineProperty(t,n,r)}:function(t,e,i,n){void 0===n&&(n=i),t[n]=e[i]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var i in t)"default"!==i&&Object.prototype.hasOwnProperty.call(t,i)&&n(e,t,i);return r(e,t),e},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.CramRecord=e.CraiIndex=e.IndexedCramFile=e.CramFile=void 0;const a=s(i(8222));e.CramFile=a.default,Object.defineProperty(e,"CramRecord",{enumerable:!0,get:function(){return a.CramRecord}});const l=o(i(946));e.IndexedCramFile=l.default;const h=o(i(368));e.CraiIndex=h.default},946:function(t,e,i){var n=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))((function(r,s){function o(t){try{l(n.next(t))}catch(t){s(t)}}function a(t){try{l(n.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}l((n=n.apply(t,e||[])).next())}))},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const s=i(8577),o=r(i(8222));e.default=class{constructor(t){if(t.cram?this.cram=t.cram:this.cram=new o.default({url:t.cramUrl,path:t.cramPath,filehandle:t.cramFilehandle,seqFetch:t.seqFetch,checkSequenceMD5:t.checkSequenceMD5,cacheSize:t.cacheSize}),!(this.cram instanceof o.default))throw new Error("invalid arguments: no cramfile");if(this.index=t.index,!this.index.getEntriesForRange)throw new Error("invalid arguments: not an index");this.fetchSizeLimit=t.fetchSizeLimit||3e6}getRecordsForRange(t,e,i,r={}){return n(this,void 0,void 0,(function*(){if(r.viewAsPairs=r.viewAsPairs||!1,r.pairAcrossChr=r.pairAcrossChr||!1,r.maxInsertSize=r.maxInsertSize||2e5,"string"==typeof t)throw new s.CramUnimplementedError("string sequence names not yet supported");const n=t,o=yield this.index.getEntriesForRange(n,e,i),a=o.map((t=>t.sliceBytes)).reduce(((t,e)=>t+e),0);if(a>this.fetchSizeLimit)throw new s.CramSizeLimitError(`data size of ${a.toLocaleString()} bytes exceeded fetch size limit of ${this.fetchSizeLimit.toLocaleString()} bytes`);const l=n=>n.sequenceId===t&&n.alignmentStart<=i&&void 0!==n.lengthOnRef&&n.alignmentStart+n.lengthOnRef-1>=e,h=yield Promise.all(o.map((t=>this.getRecordsInSlice(t,l))));let c=Array.prototype.concat(...h);if(r.viewAsPairs){const t={},e={};for(let i=0;i{1===e&&(i[t]=!0)}));const s=[];for(let t=0;tt.toString().localeCompare(e.toString()))).filter(((t,e,i)=>!e||t.toString()!==i[e-1].toString()));const l=[],h=a.map((t=>t.sliceBytes)).reduce(((t,e)=>t+e),0);if(h>this.fetchSizeLimit)throw new Error(`mate data size of ${h.toLocaleString()} bytes exceeded fetch size limit of ${this.fetchSizeLimit.toLocaleString()} bytes`);a.forEach((t=>{let n=this.cram.featureCache.get(t.toString());n||(n=this.getRecordsInSlice(t,(()=>!0)),this.cram.featureCache.set(t.toString(),n));const r=n.then((t=>{const n=[];for(let r=0;rt.concat(e)));c=c.concat(t)}}return c}))}getRecordsInSlice({containerStart:t,sliceStart:e,sliceBytes:i},n){return this.cram.getContainerAtPosition(t).getSlice(e,i).getRecords(n)}hasDataForReferenceSequence(t){return this.index.hasDataForReferenceSequence(t)}}},3427:function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.open=e.fromUrl=e.RemoteFile=e.LocalFile=void 0;const r=n(i(8575)),s=i(4319),o=i(2949);function a(t){const{protocol:e,pathname:i}=r.default.parse(t);return"file:"===e?new o.LocalFile(unescape((0,s.ensureNotNullish)(i))):new o.RemoteFile(t)}Object.defineProperty(e,"LocalFile",{enumerable:!0,get:function(){return o.LocalFile}}),Object.defineProperty(e,"RemoteFile",{enumerable:!0,get:function(){return o.RemoteFile}}),e.fromUrl=a,e.open=function(t,e,i){if(i)return i;if(t)return a(t);if(e)return new o.LocalFile(e);throw new Error("no url, path, or filehandle provided, cannot open")}},5702:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RANS_BYTE_L=e.TOTFREQ=e.TF_SHIFT=void 0,e.TF_SHIFT=12,e.TOTFREQ=4096,e.RANS_BYTE_L=1<<23},6484:function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(8577),s=i(5702),o=n(i(7634));e.default=function(t,e,i,n){let a=t.getInt(),l=t.getInt(),h=t.getInt(),c=t.getInt();const u=n.remaining(),d=-4&u;for(let r=0;r>2;let d=0,f=u,p=2*u,g=3*u,m=0,b=0,y=0,v=0;for(;d{Object.defineProperty(e,"__esModule",{value:!0});const n=i(8577),r=i(5702);class s{constructor(){this.F=void 0,this.C=void 0}}function o(t,e,i,n){return i*(t>>n)+(t&(1<>s)+(t&(1<=128&&(e.fc[l].F&=-129,e.fc[l].F=(127&e.fc[l].F)<<8|255&t.get()),e.fc[l].C=r,o.default.symbolInit(i[l],e.fc[l].C,e.fc[l].F),e.R||(e.R=new Array(s.TOTFREQ)),e.R.fill(l,r,r+e.fc[l].F),r+=e.fc[l].F,0===n&&l+1===(255&t.getByteAt(t.position()))?(l=255&t.get(),n=255&t.get()):0!==n?(n-=1,l+=1):l=255&t.get()}while(0!==l);a(r=128&&(e[r].fc[c].F&=-129,e[r].fc[c].F=(127&e[r].fc[c].F)<<8|255&t.get()),e[r].fc[c].C=h,0===e[r].fc[c].F&&(e[r].fc[c].F=s.TOTFREQ),null==i[r][c]&&(i[r][c]=new o.default.RansDecSymbol),o.default.symbolInit(i[r][c],e[r].fc[c].C,e[r].fc[c].F),null==e[r].R&&(e[r].R=new Array(s.TOTFREQ)),e[r].R.fill(c,h,h+e[r].fc[c].F),h+=e[r].fc[c].F,a(h<=s.TOTFREQ),0===l&&c+1===(255&t.getByteAt(t.position()))?(c=255&t.get(),l=255&t.get()):0!==l?(l-=1,c+=1):c=255&t.get()}while(0!==c);0===n&&r+1===(255&t.getByteAt(t.position()))?(r=255&t.get(),n=255&t.get()):0!==n?(n-=1,r+=1):r=255&t.get()}while(0!==r)}},9675:function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=i(8577),s=n(i(7634)),o=i(696),a=n(i(6484)),l=n(i(7121));class h{constructor(t,e=0){this._buffer=t,this._position=e,this.length=t.length}get(){const t=this._buffer[this._position];return this._position+=1,t}getByte(){return this.get()}getByteAt(t){return this._buffer[t]}position(){return this._position}put(t){return this._buffer[this._position]=t,this._position+=1,t}putAt(t,e){return this._buffer[t]=e,e}setPosition(t){return this._position=t,t}getInt(){const t=this._buffer.readInt32LE(this._position);return this._position+=4,t}remaining(){return this._buffer.length-this._position}}e.default=function(t,e,i=0){if(0===t.length)return e.fill(0),e;const n=new h(t,i),c=n.get();if(0!==c&&1!==c)throw new r.CramMalformedError(`Invalid rANS order ${c}`);if(n.getInt()!==n.remaining()-4)throw new r.CramMalformedError("Incorrect input length.");const u=n.getInt(),d=new h(e||Buffer.allocUnsafe(u));if(d.length{Object.defineProperty(e,"__esModule",{value:!0}),e.parseHeaderText=void 0,e.parseHeaderText=function(t){const e=t.split(/\r?\n/),i=[];return e.forEach((t=>{const[e,...n]=t.split(/\t/),r=n.map((t=>{const[e,i]=t.split(":",2);return{tag:e,value:i}}));e&&i.push({tag:e.substr(1),data:r})})),i}},4319:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ensureNotNullish=void 0,e.ensureNotNullish=function(t){if(null==t)throw new Error("Value must not be nullish.");return t}},597:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.unzip=void 0;const n=i(9591);e.unzip=function(t){return Buffer.from((0,n.inflate)(t))}},9996:(t,e,i)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}var r=i(8764).Buffer,s=i(22),o=i(2961)._,a=i(3720);"undefined"!=typeof window&&(window.Buffer=r),"undefined"!=typeof self&&(self.Buffer=r);var l={UInt8:1,UInt16LE:2,UInt16BE:2,UInt32LE:4,UInt32BE:4,Int8:1,Int16LE:2,Int16BE:2,Int32LE:4,Int32BE:4,FloatLE:4,FloatBE:4,DoubleLE:8,DoubleBE:8,UInt64:8,Int64:8},h={},c="___parser_",u=[];!function(){var t;for(t=1;t<=32;t++)u.push(t)}();var d={};Object.keys(l).concat(Object.keys({String:null,Buffer:null,Array:null,Skip:null,Choice:null,Nest:null,Bit:null,Itf8:null,Ltf8:null})).forEach((function(t){d[t.toLowerCase()]=t}));var f=function(){this.varName="",this.type="",this.options={},this.next=null,this.head=null,this.compiled=null,this.endian="le",this.constructorFn=null,this.alias=null};f.start=function(){return new f},Object.keys(l).forEach((function(t){f.prototype[t.toLowerCase()]=function(e,i){return this.setNextParser(t.toLowerCase(),e,i)};var e=t.replace(/BE|LE/,"").toLowerCase();e in f.prototype||(f.prototype[e]=function(t,i){return this[e+this.endian](t,i)})})),u.forEach((function(t){f.prototype["bit".concat(t.toString())]=function(e,i){return i||(i={}),i.length=t,this.setNextParser("bit",e,i)}})),f.prototype.namely=function(t){return h[t]=this,this.alias=t,this},f.prototype.skip=function(t,e){if(e&&e.assert)throw new Error("assert option on skip is not allowed.");return this.setNextParser("skip","",{length:t})},f.prototype.string=function(t,e){if(!e.zeroTerminated&&!e.length&&!e.greedy)throw new Error("Neither length, zeroTerminated, nor greedy is defined for string.");if((e.zeroTerminated||e.length)&&e.greedy)throw new Error("greedy is mutually exclusive with length and zeroTerminated for string.");if(e.stripNull&&!e.length&&!e.greedy)throw new Error("Length or greedy must be defined if stripNull is defined.");return e.encoding=e.encoding||"utf8",this.setNextParser("string",t,e)},f.prototype.buffer=function(t,e){if(!e.length&&!e.readUntil)throw new Error("Length nor readUntil is defined in buffer parser");return this.setNextParser("buffer",t,e)},f.prototype.array=function(t,e){if(!e.readUntil&&!e.length&&!e.lengthInBytes)throw new Error("Length option of array is not defined.");if(!e.type)throw new Error("Type option of array is not defined.");if("string"==typeof e.type&&!h[e.type]&&Object.keys(l).indexOf(d[e.type])<0)throw new Error('Specified primitive type "'.concat(e.type,'" is not supported.'));return this.setNextParser("array",t,e)},f.prototype.choice=function(t,e){if(1===arguments.length&&"object"===n(t)&&(e=t,t=null),!e.tag)throw new Error("Tag option of array is not defined.");if(!e.choices)throw new Error("Choices option of array is not defined.");return Object.keys(e.choices).forEach((function(i){if(!e.choices[i])throw new Error("Choice Case ".concat(i," of ").concat(t," is not valid."));if("string"==typeof e.choices[i]&&!h[e.choices[i]]&&Object.keys(l).indexOf(d[e.choices[i]])<0)throw new Error('Specified primitive type "'.concat(e.choices[i],'" is not supported.'))}),this),this.setNextParser("choice",t,e)},f.prototype.nest=function(t,e){if(1===arguments.length&&"object"===n(t)&&(e=t,t=null),!e.type)throw new Error("Type option of nest is not defined.");if(!(e.type instanceof f||h[e.type]))throw new Error("Type option of nest must be a Parser object.");if(!(e.type instanceof f||t))throw new Error("options.type must be a object if variable name is omitted.");return this.setNextParser("nest",t,e)},f.prototype.endianess=function(t){switch(t.toLowerCase()){case"little":this.endian="le";break;case"big":this.endian="be";break;default:throw new Error("Invalid endianess: ".concat(t))}return this},f.prototype.create=function(t){if(!(t instanceof Function))throw new Error("Constructor must be a Function object.");return this.constructorFn=t,this},f.prototype.getCode=function(){var t=new o;return t.pushCode("if (!Buffer.isBuffer(buffer)) {"),t.generateError('"argument buffer is not a Buffer object"'),t.pushCode("}"),this.alias?this.addAliasedCode(t):this.addRawCode(t),this.alias?t.pushCode("return {0}(0)",c+this.alias):t.pushCode("return { offset: offset, result: vars };"),t.code},f.prototype.addRawCode=function(t){t.pushCode("var offset = 0;"),this.constructorFn?t.pushCode("var vars = new constructorFn();"):t.pushCode("var vars = {};"),this.generate(t),this.resolveReferences(t),t.pushCode("return { offset: offset, result: vars };")},f.prototype.addAliasedCode=function(t){return t.pushCode("function {0}(offset) {",c+this.alias),this.constructorFn?t.pushCode("var vars = new constructorFn();"):t.pushCode("var vars = {};"),this.generate(t),t.markResolved(this.alias),this.resolveReferences(t),t.pushCode("return { offset: offset, result: vars };"),t.pushCode("}"),t},f.prototype.resolveReferences=function(t){var e=t.getUnresolvedReferences();t.markRequested(e),e.forEach((function(e){h[e].addAliasedCode(t)}))},f.prototype.compile=function(){var t="(function(buffer, constructorFn, Long) { ".concat(this.getCode()," })");this.compiled=s.runInThisContext(t)},f.prototype.sizeOf=function(){var t=NaN;if(Object.keys(l).indexOf(this.type)>=0)t=l[this.type];else if("String"===this.type&&"number"==typeof this.options.length)t=this.options.length;else if("Buffer"===this.type&&"number"==typeof this.options.length)t=this.options.length;else if("Array"===this.type&&"number"==typeof this.options.length){var e=NaN;"string"==typeof this.options.type?e=l[d[this.options.type]]:this.options.type instanceof f&&(e=this.options.type.sizeOf()),t=this.options.length*e}else"Skip"===this.type?t=this.options.length:"Nest"===this.type?t=this.options.type.sizeOf():this.type||(t=0);return this.next&&(t+=this.next.sizeOf()),t},f.prototype.parse=function(t){return this.compiled||this.compile(),this.compiled(t,this.constructorFn,a)},f.prototype.setNextParser=function(t,e,i){var n=new f;return n.type=d[t],n.varName=e,n.options=i||n.options,n.endian=this.endian,this.head?this.head.next=n:this.next=n,this.head=n,this},f.prototype.generate=function(t){this.type&&(this["generate".concat(this.type)](t),this.generateAssert(t));var e=t.generateVariable(this.varName);return this.options.formatter&&this.generateFormatter(t,e,this.options.formatter),this.generateNext(t)},f.prototype.generateAssert=function(t){if(this.options.assert){var e=t.generateVariable(this.varName);switch(n(this.options.assert)){case"function":t.pushCode("if (!({0}).call(vars, {1})) {",this.options.assert,e);break;case"number":t.pushCode("if ({0} !== {1}) {",this.options.assert,e);break;case"string":t.pushCode('if ("{0}" !== {1}) {',this.options.assert,e);break;default:throw new Error("Assert option supports only strings, numbers and assert functions.")}t.generateError('"Assert error: {0} is " + {0}',e),t.pushCode("}")}},f.prototype.generateNext=function(t){return this.next&&(t=this.next.generate(t)),t},Object.keys(l).forEach((function(t){f.prototype["generate".concat(t)]=function(e){"UInt64"===t?e.pushCode("{0} = Long.fromBytes(buffer.slice(offset,offset+8), true, this.endian === 'le').toNumber();",e.generateVariable(this.varName),t):"Int64"===t?e.pushCode("{0} = Long.fromBytes(buffer.slice(offset,offset+8), false, this.endian === 'le').toNumber();",e.generateVariable(this.varName),t):e.pushCode("{0} = buffer.read{1}(offset);",e.generateVariable(this.varName),t),e.pushCode("offset += {0};",l[t])}})),f.prototype.generateBit=function(t){var e=JSON.parse(JSON.stringify(this));if(e.varName=t.generateVariable(e.varName),t.bitFields.push(e),!this.next||this.next&&["Bit","Nest"].indexOf(this.next.type)<0){var i=0;t.bitFields.forEach((function(t){i+=t.options.length}));var n=t.generateTmpVariable();if(i<=8)t.pushCode("var {0} = buffer.readUInt8(offset);",n),i=8;else if(i<=16)t.pushCode("var {0} = buffer.readUInt16BE(offset);",n),i=16;else if(i<=24){var r=t.generateTmpVariable(),s=t.generateTmpVariable();t.pushCode("var {0} = buffer.readUInt16BE(offset);",r),t.pushCode("var {0} = buffer.readUInt8(offset + 2);",s),t.pushCode("var {2} = ({0} << 8) | {1};",r,s,n),i=24}else{if(!(i<=32))throw new Error("Currently, bit field sequence longer than 4-bytes is not supported.");t.pushCode("var {0} = buffer.readUInt32BE(offset);",n),i=32}t.pushCode("offset += {0};",i/8);var o=0,a="be"===this.endian;t.bitFields.forEach((function(e){t.pushCode("{0} = {1} >> {2} & {3};",e.varName,n,a?i-o-e.options.length:o,(1< offset++);"),t.pushCode("{0} = buffer.toString('{1}', {2}, offset);",e,this.options.encoding,i)),this.options.stripNull&&t.pushCode("{0} = {0}.replace(/\\x00+$/g, '')",e)},f.prototype.generateBuffer=function(t){"eof"===this.options.readUntil?t.pushCode("{0} = buffer.slice(offset);",t.generateVariable(this.varName)):(t.pushCode("{0} = buffer.slice(offset, offset + {1});",t.generateVariable(this.varName),t.generateOption(this.options.length)),t.pushCode("offset += {0};",t.generateOption(this.options.length))),this.options.clone&&t.pushCode("{0} = Buffer.from({0});",t.generateVariable(this.varName))},f.prototype.generateArray=function(t){var e=t.generateOption(this.options.length),i=t.generateOption(this.options.lengthInBytes),n=this.options.type,r=t.generateTmpVariable(),s=t.generateVariable(this.varName),o=t.generateTmpVariable(),a=this.options.key,u="string"==typeof a;if(u?t.pushCode("{0} = {};",s):t.pushCode("{0} = [];",s),"function"==typeof this.options.readUntil?t.pushCode("do {"):"eof"===this.options.readUntil?t.pushCode("for (var {0} = 0; offset < buffer.length; {0}++) {",r):void 0!==i?t.pushCode("for (var {0} = offset; offset - {0} < {1}; ) {",r,i):t.pushCode("for (var {0} = 0; {0} < {1}; {0}++) {",r,e),"string"==typeof n)if(h[n]){var p=t.generateTmpVariable();t.pushCode("var {0} = {1}(offset);",p,c+n),t.pushCode("var {0} = {1}.result; offset = {1}.offset;",o,p),n!==this.alias&&t.addReference(n)}else t.pushCode("var {0} = buffer.read{1}(offset);",o,d[n]),t.pushCode("offset += {0};",l[d[n]]);else n instanceof f&&(t.pushCode("var {0} = {};",o),t.pushScope(o),n.generate(t),t.popScope());u?t.pushCode("{0}[{2}.{1}] = {2};",s,a,o):t.pushCode("{0}.push({1});",s,o),t.pushCode("}"),"function"==typeof this.options.readUntil&&t.pushCode(" while (!({0}).call(this, {1}, buffer.slice(offset)));",this.options.readUntil,o)},f.prototype.generateChoiceCase=function(t,e,i){if("string"==typeof i)if(h[i]){var n=t.generateTmpVariable();t.pushCode("var {0} = {1}(offset);",n,c+i),t.pushCode("{0} = {1}.result; offset = {1}.offset;",t.generateVariable(this.varName),n),i!==this.alias&&t.addReference(i)}else t.pushCode("{0} = buffer.read{1}(offset);",t.generateVariable(this.varName),d[i]),t.pushCode("offset += {0};",l[d[i]]);else i instanceof f&&(t.pushPath(e),i.generate(t),t.popPath(e))},f.prototype.generateChoice=function(t){var e=t.generateOption(this.options.tag);this.varName&&t.pushCode("{0} = {};",t.generateVariable(this.varName)),t.pushCode("switch({0}) {",e),Object.keys(this.options.choices).forEach((function(e){var i=this.options.choices[e];Number.isNaN(parseInt(e,10))?t.pushCode("case '{0}':",e):t.pushCode("case {0}:",e),this.generateChoiceCase(t,this.varName,i),t.pushCode("break;")}),this),t.pushCode("default:"),this.options.defaultChoice?this.generateChoiceCase(t,this.varName,this.options.defaultChoice):t.generateError('"Met undefined tag value " + {0} + " at choice"',e),t.pushCode("}")},f.prototype.generateNest=function(t){var e=t.generateVariable(this.varName);if(this.options.type instanceof f)this.varName&&t.pushCode("{0} = {};",e),t.pushPath(this.varName),this.options.type.generate(t),t.popPath(this.varName);else if(h[this.options.type]){var i=t.generateTmpVariable();t.pushCode("var {0} = {1}(offset);",i,c+this.options.type),t.pushCode("{0} = {1}.result; offset = {1}.offset;",e,i),this.options.type!==this.alias&&t.addReference(this.options.type)}},f.prototype.generateFormatter=function(t,e,i){"function"==typeof i&&t.pushCode("{0} = ({1}).call(this, {0});",e,i)},f.prototype.isInteger=function(){return!!this.type.match(/U?Int[8|16|32][BE|LE]?|Bit\d+/)},f.prototype.itf8=function(t,e){return this.setNextParser("itf8",t,e)},f.prototype.itf8=function(t,e){return this.setNextParser("itf8",t,e)},f.prototype.generateItf8=function(t){var e=t.generateVariable(this.varName),i=t.generateTmpVariable();t.pushCode("\n var ".concat(i," = buffer[offset];\n if (").concat(i," < 0x80) {\n ").concat(e," = ").concat(i,";\n offset += 1;\n } else if (").concat(i," < 0xc0) {\n ").concat(e," = ((").concat(i,"<<8) | buffer[offset+1]) & 0x3fff;\n offset += 2;\n } else if (").concat(i," < 0xe0) {\n ").concat(e," = ((").concat(i,"<<16) | (buffer[offset+1]<< 8) | buffer[offset+2]) & 0x1fffff;\n offset += 3;\n } else if (").concat(i," < 0xf0) {\n ").concat(e," = ((").concat(i,"<<24) | (buffer[offset+1]<<16) | (buffer[offset+2]<<8) | buffer[offset+3]) & 0x0fffffff;\n offset += 4\n } else {\n ").concat(e," = ((").concat(i," & 0x0f)<<28) | (buffer[offset+1]<<20) | (buffer[offset+2]<<12) | (buffer[offset+3]<<4) | (buffer[offset+4] & 0x0f);\n // x=((0xff & 0x0f)<<28) | (0xff<<20) | (0xff<<12) | (0xff<<4) | (0x0f & 0x0f);\n // TODO *val_p = uv < 0x80000000UL ? uv : -((int32_t) (0xffffffffUL - uv)) - 1;\n offset += 5\n }\n "))},f.prototype.ltf8=function(t,e){return this.setNextParser("ltf8",t,e)},f.prototype.generateLtf8=function(t){var e=t.generateVariable(this.varName),i=t.generateTmpVariable();t.pushCode("\n var ".concat(i," = buffer[offset];\n if (").concat(i," < 0x80) {\n ").concat(e," = ").concat(i,";\n offset += 1;\n } else if (").concat(i," < 0xc0) {\n ").concat(e," = ((buffer[offset]<<8) | buffer[offset+1]) & 0x3fff;\n offset += 2;\n } else if (").concat(i," < 0xe0) {\n ").concat(e," = ((buffer[offset]<<16) | (buffer[offset+1]<<8) | buffer[offset+2]) & 0x1fffff;\n ").concat(e," = (((").concat(i," & 63) << 16) | buffer.readUInt16LE(offset + 1));\n offset += 3;\n } else if (").concat(i," < 0xf0) {\n ").concat(e," = ((buffer[offset]<<24) | (buffer[offset+1]<<16) | (buffer[offset+2]<<8) | buffer[offset+3]) & 0x0fffffff;\n offset += 4;\n } else if (").concat(i," < 0xf8) {\n ").concat(e," = (((buffer[offset] & 15) * Math.pow(2,32))) +\n (buffer[offset+1]<<24) | (buffer[offset+2]<<16 | buffer[offset+3]<<8 | buffer[offset+4])\n // TODO *val_p = uv < 0x80000000UL ? uv : -((int32_t) (0xffffffffUL - uv)) - 1;\n offset += 5;\n } else if (").concat(i," < 0xfc) {\n ").concat(e," = ((((buffer[offset] & 7) << 8) | buffer[offset+1] )) * Math.pow(2,32) +\n (buffer[offset+2]<<24) | (buffer[offset+3]<<16 | buffer[offset+4]<<8 | buffer[offset+5])\n offset += 6;\n } else if (").concat(i," < 0xfe) {\n ").concat(e," = ((((buffer[offset] & 3) << 16) | buffer[offset+1]<<8 | buffer[offset+2])) * Math.pow(2,32) +\n (buffer[offset+3]<<24) | (buffer[offset+4]<<16 | buffer[offset+5]<<8 | buffer[offset+6])\n offset += 7;\n } else if (").concat(i," < 0xff) {\n ").concat(e," = Long.fromBytesBE(buffer.slice(offset+1,offset+8));\n if (").concat(e,".greaterThan(Number.MAX_SAFE_INTEGER) || ").concat(e,".lessThan(Number.MIN_SAFE_INTEGER))\n throw new Error('integer overflow')\n ").concat(e," = ").concat(e,".toNumber()\n offset += 8;\n } else {\n ").concat(e," = Long.fromBytesBE(buffer.slice(offset+1,offset+9));\n if (").concat(e,".greaterThan(Number.MAX_SAFE_INTEGER) || ").concat(e,".lessThan(Number.MIN_SAFE_INTEGER))\n throw new Error('integer overflow')\n ").concat(e," = ").concat(e,".toNumber()\n offset += 9;\n }\n "))},e.Parser=f},2961:(t,e)=>{function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}var n=function(){this.code="",this.scopes=[["vars"]],this.isAsync=!1,this.bitFields=[],this.tmpVariableCount=0,this.references={}};n.prototype.generateVariable=function(t){var e=[];for(Array.prototype.push.apply(e,this.scopes[this.scopes.length-1]);/^\$parent\./.test(t);)e.pop(),t=t.replace(/^\$parent\./,"");return t&&e.push(t),e.join(".")},n.prototype.generateOption=function(t){switch(i(t)){case"number":return t.toString();case"string":return this.generateVariable(t);case"function":return"(".concat(t,").call(").concat(this.generateVariable(),", vars)");default:return}},n.prototype.generateError=function(){var t=Array.prototype.slice.call(arguments),e=n.interpolate.apply(this,t);this.isAsync?this.pushCode("return process.nextTick(function() { callback(new Error(".concat(e,"), vars); });")):this.pushCode("throw new Error(".concat(e,");"))},n.prototype.generateTmpVariable=function(){return"$tmp".concat(this.tmpVariableCount++)},n.prototype.pushCode=function(){var t=Array.prototype.slice.call(arguments);this.code+="".concat(n.interpolate.apply(this,t),"\n")},n.prototype.pushPath=function(t){t&&this.scopes[this.scopes.length-1].push(t)},n.prototype.popPath=function(t){t&&this.scopes[this.scopes.length-1].pop()},n.prototype.pushScope=function(t){this.scopes.push([t])},n.prototype.popScope=function(){this.scopes.pop()},n.prototype.addReference=function(t){this.references[t]||(this.references[t]={resolved:!1,requested:!1})},n.prototype.markResolved=function(t){this.references[t].resolved=!0},n.prototype.markRequested=function(t){t.forEach(function(t){this.references[t].requested=!0}.bind(this))},n.prototype.getUnresolvedReferences=function(){var t=this.references;return Object.keys(this.references).filter((function(e){return!t[e].resolved&&!t[e].requested}))},n.interpolate=function(t){var e=t.match(/{\d+}/g),i=Array.prototype.slice.call(arguments,1);return e&&e.forEach((function(e){var n=parseInt(e.substr(1,e.length-2),10);t=t.replace(e,i[n].toString())})),t},e._=n},22:t=>{t.exports.runInThisContext=function(t){return new Function("code","return eval(code);").call(globalThis,t)}},445:(t,e,i)=>{const n=i(7381),r=i(9260),s=i(576),o=i(4693),a=128;t.exports=class{decode(t){return this.stream=new r(t),this.decodeStream(this.stream)}decodeStream(t,e=0){var i=this.stream.ReadByte();16&i||(e=this.stream.ReadUint7());var n,r=e,s=1&i;if(8&i)return this.decodeStripe(this.stream,e);if(i&a&&([n,r]=this.decodePackMeta(this.stream)),32&i)var o=this.decodeCat(this.stream,r);else o=4&i?this.decodeExt(this.stream,r):64&i?s?this.decodeRLE1(this.stream,r):this.decodeRLE0(this.stream,r):s?this.decode1(this.stream,r):this.decode0(this.stream,r);return i&a&&(o=this.decodePack(o,n,e)),o}encode(t,e){if(this.stream=new r("",0,1.1*t.length+100),this.stream.WriteByte(e),16&e||this.stream.WriteUint7(t.length),8&e)return Buffer.concat([this.stream.buf.slice(0,this.stream.pos),this.encodeStripe(this.stream,t,e>>8)]);var i,n=1&e,s=t.length;return e&a&&([i,t,s]=this.encodePack(t)),e&a&&this.stream.WriteStream(i),64&e?n?this.encodeRLE1(t,s,this.stream):this.encodeRLE0(t,s,this.stream):n?this.encode1(t,s,this.stream):this.encode0(t,s,this.stream)}decode0(t,e){var i=new Buffer.allocUnsafe(e),r=t.ReadByte();0==r&&(r=256);var o=new s(r),a=new n(t);a.RangeStartDecode(t);for(var l=0;l=3?3:c;for(l[u].ModelEncode(i,h,d),c-=d,u=256;3==d;)d=c>=3?3:c,l[u].ModelEncode(i,h,d),u=257,c-=d}return h.RangeFinishEncode(i),i.buf.slice(0,i.pos)}decodeRLE1(t,e){var i=new Buffer.allocUnsafe(e),r=t.ReadByte();0==r&&(r=256);for(var o=new Array(r),a=0;a=3?3:u;for(l[d].ModelEncode(i,h,f),u-=f,d=256;3==f;)f=u>=3?3:u,l[d].ModelEncode(i,h,f),d=257,u-=f}return h.RangeFinishEncode(i),i.buf.slice(0,i.pos)}decodePackMeta(t){this.nsym=t.ReadByte();for(var e=new Array(this.nsym),i=0;i>=1}}else if(this.nsym<=4)for(r=0,s=0;r>=2;else{if(!(this.nsym<=16))return t;for(r=0,s=0;r>=4}return n}packMeta(t){for(var e=new r("",0,1024),i=new Array(256),n=0;no),n[o]=new Array(s[o]);for(var a=0,l=0;ls),o[s]=this.decodeStream(t,r[s]);var a=new Buffer.allocUnsafe(e);for(s=0;s{t.exports=class{constructor(t){this.low=0,this.range=4294967295,this.code=0,this.FFnum=0,this.carry=0,this.cache=0}RangeStartDecode(t){for(var e=0;e<5;e++)this.code=(this.code<<8)+t.ReadByte();this.code&=4294967295,this.code>>>=0}RangeGetFrequency(t){return this.range=Math.floor(this.range/t),Math.floor(this.code/this.range)}RangeDecode(t,e,i,n){for(this.code-=e*this.range,this.range*=i;this.range<1<<24;)this.range*=256,this.code=256*this.code+t.ReadByte()}RangeShiftLow(t){if(this.low<4278190080|this.carry){for(t.WriteByte(this.cache+this.carry);this.FFnum;)t.WriteByte(this.carry-1),this.FFnum--;this.cache=this.low>>>24,this.carry=0}else this.FFnum++;this.low<<=8,this.low>>>=0}RangeEncode(t,e,i,n){var r=this.low;for(this.range=Math.floor(this.range/n),this.low+=e*this.range,this.low>>>=0,this.range*=i,this.low{t.exports=class{constructor(t=256){this.total_freq=t,this.max_sym=t-1,this.S=new Array,this.F=new Array;for(var e=0;e<=this.max_sym;e++)this.S[e]=e,this.F[e]=1}ModelDecode(t,e){for(var i=e.RangeGetFrequency(this.total_freq),n=0,r=0;n+this.F[r]<=i;)n+=this.F[r++];e.RangeDecode(t,n,this.F[r],this.total_freq),this.F[r]+=16,this.total_freq+=16,this.total_freq>65519&&this.ModelRenormalise();var s=this.S[r];if(r>0&&this.F[r]>this.F[r-1]){var o=this.F[r];this.F[r]=this.F[r-1],this.F[r-1]=o,o=this.S[r],this.S[r]=this.S[r-1],this.S[r-1]=o}return s}ModelRenormalise(){this.total_freq=0;for(var t=0;t<=this.max_sym;t++)this.F[t]-=Math.floor(this.F[t]/2),this.total_freq+=this.F[t]}ModelEncode(t,e,i){for(var n=0,r=0;this.S[r]!=i;r++)n+=this.F[r];if(e.RangeEncode(t,n,this.F[r],this.total_freq),this.F[r]+=16,this.total_freq+=16,this.total_freq>65519&&this.ModelRenormalise(),i=this.S[r],r>0&&this.F[r]>this.F[r-1]){var s=this.F[r];this.F[r]=this.F[r-1],this.F[r-1]=s,s=this.S[r],this.S[r]=this.S[r-1],this.S[r-1]=s}}}},5260:(t,e,i)=>{const n=i(9260),r=i(576),s=i(7381);function o(t,e,i){for(var n=0,r=0,s=-1,o=new Array(1024);r>4,e.qshift=15&i,i=t.ReadByte(),e.qloc=i>>4,e.sloc=15&i,i=t.ReadByte(),e.ploc=i>>4,e.dloc=15&i,e.qmap=new Array(256),16&e.pflags)for(var n=0;n0&&128&e.pflags)o(t,e.qtab,256);else for(n=0;n<256;n++)e.qtab[n]=n;return e.ptab=new Array(1024),32&e.pflags&&o(t,e.ptab,1024),e.dtab=new Array(256),64&e.pflags&&o(t,e.dtab,256),e}function h(t,e,i,n,r,s){i.max_sel>0?r.s=n.sel.ModelDecode(t,e):r.s=0,r.x=i.stab[r.s];var o=i.params[r.x];if(o.fixed_len>=0){var a=n.len[0].ModelDecode(t,e);a|=n.len[1].ModelDecode(t,e)<<8,a|=n.len[2].ModelDecode(t,e)<<16,a|=n.len[3].ModelDecode(t,e)<<24,o.fixed_len>0&&(o.fixed_len=-a)}else a=-o.fixed_len;r.len=a,i.do_rev&&(s[r.rec]=n.rev.ModelDecode(t,e)),r.is_dup=0,2&o.pflags&&n.dup.ModelDecode(t,e)&&(r.is_dup=1),r.p=a,r.delta=0,r.qctx=0,r.prevq=0,r.rec++}function c(t,e,i){for(var n=0,r=0,s=new Array(2*i),o=0;n1?i.nparam-1:0,s=new Array(256);if(2&i)r=t.ReadByte(),o(t,s,256);else{for(var a=0;a0&&(e.sel=new r(t.max_sel+1)),e}(n),f=new s(t);f.RangeStartDecode(t);for(var p=new Buffer.allocUnsafe(i),g={qctx:0,prevq:0,delta:0,p:0,s:0,x:0,len:0,is_dup:0,rec:0},m=0;m0&&d.dup.ModelDecode(t,f)){for(var b=0;b4),qshift:u,qloc:7,pbits:7,pshift:e[0]>128?1:0,ploc:0,dbits:u>4?0:1,dshift:3,dloc:15,sbits:0,sloc:15,do_stab:0,context:0,max_sym:l,nsym:a,do_qmap:d,do_dedup:0,fixed_len:1==e.length?1:0,do_sel:0,do_rev:0,do_pos:1,do_delta:u<=4?1:0,do_qtab:0,qbits:8+(u>4)-(0==o),sbits:1,sloc:15-(u<=4),do_stab:1,do_sel:1}]}(t,e,i,o),p=function(t,e,i,n,r,s,o){for(var a=[0,1,1,1,2,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7],l=0;l1?1:0)|(e[0].do_stab?2:0);if(t.WriteByte(h),1&h&&t.WriteByte(e.length),2&h){var u=1<0&&u--,t.WriteByte(u),c(t,o,256)}for(var d=0;d0){for(l=0;l<256;l++)n[d][l]=l;e[d].do_qtab&&c(t,n[d],256)}if(e[d].pbits>0){for(l=0;l<1024;l++)r[d][l]=Math.min((1<>e[d].pshift);c(t,r[d],1024)}if(e[d].dbits>0){for(l=0;l<256;l++)a[l]>(1<>e[d].dshift)];c(t,s[d],256)}}return t}(p,f,o,a,l,h,u);return function(t,e,i,n,o,a,l,h,c,u){var d=1<0&&d--;for(var f=e.length,p=0,g=0;g0&&v.ModelEncode(t,w,x);var k=u[x],S=i[Math.min(i.length-1,_++)];o[k].fixed_len?o[k].fixed_len>0&&(y[0].ModelEncode(t,w,255&S),y[1].ModelEncode(t,w,S>>8&255),y[2].ModelEncode(t,w,S>>16&255),y[3].ModelEncode(t,w,S>>24&255),o[k].fixed_len=-1):(y[0].ModelEncode(t,w,255&S),y[1].ModelEncode(t,w,S>>8&255),y[2].ModelEncode(t,w,S>>16&255),y[3].ModelEncode(t,w,S>>24&255)),o[k].do_dedup&&process.exit(1),g=S;var C=0,A=o[k].context,T=0,I=0}var E=e[b++],M=a[k][E];m[A].ModelEncode(t,w,M),T=(T<0&&(A+=h[k][Math.min(g,1023)]<0&&(A+=c[k][Math.min(C,255)]<{var n=i(4459),r=i(594),s=i(445),o=i(5260),a=i(2881);t.exports={r4x8_uncompress:function(t,e){n.decode(t).copy(e,0,0)},r4x16_uncompress:function(t,e){r.decode(t).copy(e,0,0)},arith_uncompress:function(t,e){s.decode(t).copy(e,0,0)},fqzcomp_uncompress:function(t,e){var i=new Array;o.decode(t,i).copy(e,0,0)},tok3_uncompress:function(t,e){var i=a.decode(t,0,"\0");Buffer.from(i,"binary").copy(e,0,0)}}},9260:t=>{t.exports=class{constructor(t,e=0,i=0){0!=i?(this.buf=Buffer.allocUnsafe(i),this.length=i):(this.buf=t,this.length=t.length),this.pos=e}EOF(){return this.pos>=this.length}ReadData(t){var e=this.buf.slice(this.pos,this.pos+t);return this.pos+=t,e}ReadByte(){const t=this.buf[this.pos];return this.pos++,t}ReadChar(){const t=this.buf[this.pos];return this.pos++,String.fromCharCode(t)}ReadUint16(){return this.ReadByte()|this.ReadByte()<<8}ReadUint32(){const t=this.buf.readInt32LE(this.pos);return this.pos+=4,t}ReadString(){var t="";do{var e=this.buf[this.pos++];e&&(t+=String.fromCharCode(e))}while(e);return t}ReadUint7(){var t=0;do{var e=this.ReadByte();t=t<<7|127&e}while(128&e);return t}ReadITF8(){var t=this.buf[this.pos];return this.pos++,t>=240?(t=(15&t)<<28,t+=(this.buf[this.pos+0]<<20)+(this.buf[this.pos+1]<<12)+(this.buf[this.pos+2]<<4)+(this.buf[this.pos+3]>>4),this.pos+=4):t>=224?(t=(15&t)<<24,t+=(this.buf[this.pos+0]<<16)+(this.buf[this.pos+1]<<8)+(this.buf[this.pos+2]<<0),this.pos+=3):t>=192?(t=(31&t)<<16,t+=(this.buf[this.pos+0]<<8)+(this.buf[this.pos+1]<<0),this.pos+=2):t>=128&&(t=(63&t)<<8,t+=this.buf[this.pos],this.pos++),t}WriteByte(t){this.buf[this.pos++]=t}WriteChar(t){this.buf[this.pos++]=t.charCodeAt(0)}WriteString(t){for(var e=0;e>8&255)}WriteUint32(t){this.buf.writeInt32LE(t,this.pos),this.pos+=4}WriteUint7(t){var e=0,i=t;do{e+=7,i>>=7}while(i>0);do{e-=7,this.WriteByte((t>>e&127)+((e>0)<<7))}while(e>0)}WriteITF8(t){t<0&&(t=1+t),t<=127?this.buf[this.pos++]=t:t<=16383?(this.buf[this.pos++]=128|Math.floor(t/256),this.buf[this.pos++]=255&t):t<131071?(this.buf[this.pos++]=192|Math.floor(t/65536),this.buf[this.pos++]=255&Math.floor(t/256),this.buf[this.pos++]=255&t):t<268435455?(this.buf[this.pos++]=224|Math.floor(t/16777216),this.buf[this.pos++]=255&Math.floor(t/65536),this.buf[this.pos++]=255&Math.floor(t/256),this.buf[this.pos++]=255&t):(this.buf[this.pos++]=240|Math.floor(t/268435456),this.buf[this.pos++]=255&Math.floor(t/1048576),this.buf[this.pos++]=255&Math.floor(t/4096),this.buf[this.pos++]=255&Math.floor(t/4),this.buf[this.pos++]=15&t)}WriteByteNeg(t){this.buf[--this.pos]=t}}},4459:(t,e,i)=>{const n=i(9260);function r(t){return 4095&t}function s(t,e){for(var i=0;e>=t[i+1];)i++;return i}function o(t){for(var e=new Array(4096),i=0,n=0;n<4096;n++){for(;n>=t[i+1];)i++;e[n]=i}return e}function a(t,e,i){return i*(t>>12)+(4095&t)-e}function l(t,e){for(;e<1<<23;)e=(e<<8)+t.ReadByte();return e}function h(t,e){e.WriteByteNeg(t>>24&255),e.WriteByteNeg(t>>16&255),e.WriteByteNeg(t>>8&255),e.WriteByteNeg(t>>0&255)}function c(t,e,i,n,r){return t=function(t,e,i,n){for(var r=(1<<23>>n<<8)*i;t>=r;)e.WriteByteNeg(255&t),t>>=8;return t}(t,e,n,r),(Math.floor(t/n)<0?(o--,r++):(r=t.ReadByte())==s+1&&(o=t.ReadByte()),s=r}while(0!=r);for(i[0]=0,n=0;n<=255;n++)i[n+1]=i[n]+e[n]}function d(t){for(var e=0,i=0;i<256;i++)e+=t[i];const n=4096;var r=n/e;do{var s=0,o=0,a=0;for(e=0,i=0;i<256;i++)0!=t[i]&&(s2?t[o]-=e-n:e!=n&&(r*=.99,a=1)}while(a)}function f(t,e){for(var i=0,n=0;n<256;n++)if(e[n]){if(i>0)i--;else if(t.WriteByte(n),n>0&&e[n-1]>0){for(i=n+1;i<256&&e[i];i++);i-=n+1,t.WriteByte(i)}t.WriteITF8(e[n])}t.WriteByte(0)}t.exports={decode:function(t){var e=new n(t),i=e.ReadByte(),h=(e.ReadUint32(),e.ReadUint32());return 0==i?function(t,e){var i=new Array(256),n=new Array(256);u(t,i,n);for(var s=o(n),h=new Array(4),c=0;c<4;c++)h[c]=t.ReadUint32();var d=new Buffer.allocUnsafe(e);for(c=0;c0?(a--,s++):(s=t.ReadByte())==o+1&&(a=t.ReadByte()),o=s}while(0!=s)}(t,i,n);for(var h=new Array(256),c=0;c<256;c++)h[c]=o(n[c]);for(var d=new Array(4),f=new Array(4),p=0;p<4;p++)d[p]=t.ReadUint32(),f[p]=0;var g=new Buffer.allocUnsafe(e),m=Math.floor(e/4);for(c=0;c=0;o--)a[o%4]=c(a[o%4],u,s[t[o]],r[t[o]],12);for(o=3;o>=0;o--)h(a[o],u);var p=i.pos;return i.buf.writeInt32LE(p-9+(u.length-u.pos),1),i.buf.writeInt32LE(e,5),Buffer.concat([i.buf.slice(0,i.pos),u.buf.slice(u.pos,u.length)],i.pos+u.length-u.pos)}(t):function(t){const e=t.length;var i=new n("",0,198156);i.WriteByte(1),i.WriteUint32(0),i.WriteUint32(0);for(var r=new Array(256),s=new Array(256),o=new Array(256),a=0;a<256;a++)s[a]=new Array(256),o[a]=new Array(256);for(function(t,e,i){for(var n=0;n<256;n++){i[n]=0;for(var r=0;r<256;r++)e[n][r]=0}var s=0;for(n=0;n>2)]]++,e[0][t[2*(t.length>>2)]]++,e[0][t[3*(t.length>>2)]]++,i[0]+=3}(t,s,r),function(t,e){for(var i=0;i<256;i++)e[i]&&d(t[i])}(s,r),function(t,e,i){for(var n=0,r=0;r<256;r++)if(i[r]){if(n>0)n--;else if(t.WriteByte(r),r>0&&i[r-1]>0){for(n=r+1;n<256&&i[n];n++);n-=r+1,t.WriteByte(n)}f(t,e[r])}t.WriteByte(0)}(i,s,r),a=0;a<256;a++)if(r[a]){o[a][0]=0;for(var l=1;l<256;l++)o[a][l]=o[a][l-1]+s[a][l-1]}var u=new Array(4),p=new Array(4);for(l=0;l<4;l++)u[l]=1<<23,p[l]=0;var g=new n("",e,e),m=Math.floor(e/4),b=new Array(4),y=new Array(4);for(l=0;l<4;l++)b[l]=(l+1)*m-2,y[l]=t[b[l]+1];for(y[3]=t[e-1],a=e-2;a>4*m-2;a--)u[3]=c(u[3],g,o[t[a]][y[3]],s[t[a]][y[3]],12),y[3]=t[a];for(;b[0]>=0;)for(l=3;l>=0;l--){var v=t[b[l]];u[l]=c(u[l],g,o[v][y[l]],s[v][y[l]],12),y[l]=v,b[l]--}for(l=3;l>=0;l--)u[l]=c(u[l],g,o[0][y[l]],s[0][y[l]],12);for(a=3;a>=0;a--)h(u[a],g);var w=i.pos;return i.buf.writeInt32LE(w-9+(g.length-g.pos),1),i.buf.writeInt32LE(e,5),Buffer.concat([i.buf.slice(0,i.pos),g.buf.slice(g.pos,g.length)],i.pos+g.length-g.pos)}(t)}}},594:(t,e,i)=>{const n=i(9260);function r(t,e){return t&(1<=t[i+1];)i++;return i}function o(t,e){for(var i=1<=t[r+1];)r++;n[s]=r}return n}function a(t,e,i,n){return i*(t>>n)+(t&(1<>24&255),e.WriteByteNeg(t>>16&255),e.WriteByteNeg(t>>8&255),e.WriteByteNeg(t>>0&255)}function c(t,e,i,n,r){return t=function(t,e,i,n){for(var r=(1<<31-n)*i;t>=r;)e.WriteByteNeg(t>>8&255),e.WriteByteNeg(255&t),t>>=16;return t}(t,e,n,r),(Math.floor(t/n)<o),r[o]=new Array(s[o]);for(var a=0,l=0;ls),o[s]=d(t,r[s]);var a=new Buffer.allocUnsafe(e);for(s=0;s>4,h=t;if(1&d){var c=t.ReadUint7(),u=t.ReadUint7(),d=new n(t.ReadData(u));h=new n(g(d,c))}var f=new Array(256),m=new Array(256);!function(t,e,i,n){for(var r=0;r<256;r++){e[r]=new Array(256),i[r]=new Array(256);for(var s=0;s<256;s++)e[r][s]=0}var o=p(t);for(r=0;r<256;r++)if(o[r]){var a=0;for(s=0;s<256;s++)o[s]&&(a>0?a--:(e[r][s]=t.ReadUint7(),0==e[r][s]&&(a=t.ReadByte())));for(b(e[r],n),i[r][0]=0,s=0;s<256;s++)i[r][s+1]=i[r][s]+e[r][s]}}(h,f,m,i);for(var y=new Array(256),v=0;v<256;v++)y[v]=o(m[v],i);for(var w=new Array(4),_=new Array(4),x=0;x<4;x++)w[x]=t.ReadUint32(),_[x]=0;var k=new Buffer.allocUnsafe(e),S=Math.floor(e/4);for(v=0;v>=1}else if(i<=4)for(o=0;o>=2;else if(i<=16)for(o=0;o>=4;return r}(S,v,w,y)),S}function f(t,e){var i=new n("",0,10);i.WriteByte(e);var r=1&e,s=8&e,o=32&e,a=64&e,l=128&e,d=e>>8;if(16&e||i.WriteUint7(t.length),s)return Buffer.concat([i.buf.slice(0,i.pos),u(0,t,d)]);var f=new Buffer.alloc(0);l&&([f,t]=function(t){for(var e=new Array(256),i=0;i<256;i++)e[i]=0;for(i=0;i0&&(r[i]=s++);if(!(s>16)){if(s<=1)var o=new Buffer.allocUnsafe(0);else if(s<=2){o=new Buffer.allocUnsafe(Math.ceil(t.length/8));var a=-1;for(i=0;i0&&(e[i]=a++,l.WriteByte(i));return l.WriteUint7(o.length),[l.buf.slice(0,l.pos),o]}}(t));var p=new Buffer.alloc(0);if(a&&([p,t]=function(t){for(var e=new Array(256),i=0;i<256;i++)e[i]=0;var r=-1;for(i=0;i0&&s++;for(s||(s=1,e[0]=1),(h=new n("",0,s+1+t.length)).WriteByte(s),i=0;i<256;i++)e[i]>0&&h.WriteByte(i);var o=new Buffer.allocUnsafe(t.length),a=0;for(i=0;i0){r=t[i];for(var l=0;i+l+1>2)]]++,e[0][t[2*(t.length>>2)]]++,e[0][t[3*(t.length>>2)]]++,i[0]+=3})(t,s,r),function(t,e,i){for(var n=0;n<256;n++)if(e[n]){var r=Math.ceil(Math.log2(e[n]));r>12&&(r=12),m(t[n],r)}}(s,r);var l=new n("",0,198156);!function(t,e,i){y(t,i);for(var n=0;n<256;n++)if(i[n])for(var r=0,s=0;s<256;s++)if(i[s])if(r)r--;else if(t.WriteUint7(e[n][s]),!e[n][s]){for(var o=s+1;o<256;o++)if(i[o]){if(0!=e[n][o])break;r++}t.WriteByte(r)}}(l,s,r);var u=v(l.buf.slice(0,l.pos));for(u.length>0,1.05*e+100>>0),w=Math.floor(e/4),_=new Array(4),x=new Array(4);for(d=0;d<4;d++)_[d]=(d+1)*w-2,x[d]=t[_[d]+1];for(x[3]=t[e-1],a=e-2;a>4*w-2;a--)f[3]=c(f[3],g,o[t[a]][x[3]],s[t[a]][x[3]],12),x[3]=t[a];for(;_[0]>=0;)for(d=3;d>=0;d--){var k=t[_[d]];f[d]=c(f[d],g,o[k][x[d]],s[k][x[d]],12),x[d]=k,_[d]--}for(d=3;d>=0;d--)f[d]=c(f[d],g,o[0][x[d]],s[0][x[d]],12);for(a=3;a>=0;a--)h(f[a],g);return Buffer.concat([i.buf.slice(0,i.pos),g.buf.slice(g.pos,g.length)],i.pos+g.length-g.pos)}(t);return Buffer.concat([i.buf.slice(0,i.pos),f,p,g])}function p(t){for(var e=new Array(256),i=0;i<256;i++)e[i]=0;var n=0,r=t.ReadByte(),s=r;do{e[r]=1,n>0?(n--,r++):(r=t.ReadByte())==s+1&&(n=t.ReadByte()),s=r}while(0!=r);return e}function g(t,e){var i=new Array(256),n=new Array(256);!function(t,e,i){for(var n=0;n<256;n++)e[n]=0;var r=p(t);for(n=0;n<256;n++)r[n]>0&&(e[n]=t.ReadUint7());for(b(e,12),i[0]=0,n=0;n<=255;n++)i[n+1]=i[n]+e[n]}(t,i,n);for(var s=o(n,12),h=new Array(4),c=0;c<4;c++)h[c]=t.ReadUint32();var u=new Buffer.allocUnsafe(e);for(c=0;c2?t[a]-=i-r:i!=r&&(s=r/i,l=1)}while(l)}function b(t,e){for(var i=0,n=0;n<256;n++)i+=t[n];if(0!=i&&i!=1<0)i--;else if(t.WriteByte(n),n>0&&e[n-1]>0){for(i=n+1;i<256&&e[i];i++);i-=n+1,t.WriteByte(i)}t.WriteByte(0)}function v(t){const e=t.length;var i=new n("",0,780),r=new Array(256);!function(t,e){for(var i=0;i<256;i++)e[i]=0;for(i=0;i12&&(s=12),m(r,s),function(t,e){y(t,e);for(var i=0;i<256;i++)e[i]&&t.WriteUint7(e[i])}(i,r),m(r,12);var o=new Array(256);o[0]=0;for(var a=1;a<256;a++)o[a]=o[a-1]+r[a-1];var l=new Array(4);for(a=0;a<4;a++)l[a]=32768;var u=new n("",1.05*e+100>>0,1.05*e+100>>0);for(a=e-1;a>=0;a--)l[a%4]=c(l[a%4],u,o[t[a]],r[t[a]],12);for(a=3;a>=0;a--)h(l[a],u);return Buffer.concat([i.buf.slice(0,i.pos),u.buf.slice(u.pos,u.length)],i.pos+u.length-u.pos)}t.exports={decode:function(t){return d(new n(t),0)},encode:f}},2881:(t,e,i)=>{const n=i(9260),r=i(594);var s=new(i(445));function o(t,e){for(var i=t+"";i.length>0)+t[a][8].ReadByte();break;case 9:l=(i[s][a]>>0)+t[a][9].ReadByte(),h=i[s][a].length,i[n][a]=o(l,h);break;case 10:i[n][a]=i[s][a];break;default:i[n][a]=""}e[n]+=i[n][a++]}while(12!=r);return e[n]}function l(t,e,i,n,r,s){for(var o=0;o0&&5==e[o][0].type)&&e[o][i])switch(t[0].WriteByte(e[o][i].type),e[o][i].type){case 6:t[6].WriteUint32(e[o][i].val);break;case 5:t[5].WriteUint32(e[o][i].val);break;case 1:t[1].WriteString(e[o][i].val);break;case 2:t[2].WriteChar(e[o][i].val);break;case 7:t[7].WriteUint32(e[o][i].val);break;case 3:t[3].WriteUint32(e[o][i].val),t[4].WriteByte(e[o][i].val.length);break;case 8:case 9:t[e[o][i].type].WriteByte(e[o][i].val)}}function h(t,e,i,n){for(var r=0;r<=12;r++)if(!(t[r].pos<=0)){n.WriteByte(r+(0==r?128:0)),t[r]=t[r].buf.slice(0,t[r].pos);var s=c(t[r],i);n.WriteUint7(s.length),n.WriteData(s,s.length)}}function c(t,e){var i,n=1<<30,o=[0,1,64,65,128,129,201];for(var a in o){var l=o[a];if(!(1&l&&t.length<100||8&l&&t.length%4!=0)){try{var h=e?s.encode(t,l):r.encode(t,l)}catch(t){h=0}h&&n>h.length&&(n=h.length,i=h)}}return i}function u(t,e,i,n,r){var s=0,o=r-1;t[r]=new Array(256),e[n]?t[r][0]={type:5,val:r-e[n]}:t[r][0]={type:6,val:0==r?0:1},e[n]=r;for(var a=n.match(/([a-zA-Z0-9]{1,9})|([^a-zA-Z0-9]+)/g),l=0;l=0&&t[o][h])if(t[o][h].str==a[l])c=10,u="";else if(7==t[o][h].type||8==t[o][h].type){var d=u-t[o][h].str;i[h]++,d>=0&&d<256&&i[h]>r/2&&(c=8,u=d)}else 3!=t[o][h].type&&9!=t[o][h].type||t[o][h].str.length!=u.length||(d=u-t[o][h].str,i[h]++,d>=0&&d<256&&i[h]>r/2&&(c=9,u=d));t[r][h]={str:a[l],val:u,type:c},s{a.callback(t)})),settled:!1,statusReporter:a,get aborted(){return this.aborter.signal.aborted}};l.aborter.addSignal(i),l.aborter.signal.addEventListener("abort",(()=>{l.settled||this.evict(t,l)})),l.promise.then((()=>{l.settled=!0}),(()=>{l.settled=!0,this.evict(t,l)})).catch((t=>{throw console.error(t),t})),this.cache.set(t,l)}static checkSinglePromise(t,e){function i(){if(e&&e.aborted)throw Object.assign(new Error("aborted"),{code:"ERR_ABORTED"})}return t.then((t=>(i(),t)),(t=>{throw i(),t}))}has(t){return this.cache.has(t)}get(t,e,i,n){if(!i&&e instanceof r.AbortSignal)throw new TypeError("second get argument appears to be an AbortSignal, perhaps you meant to pass `null` for the fill data?");const s=this.cache.get(t);return s?s.aborted&&!s.settled?(this.evict(t,s),this.get(t,e,i,n)):s.settled?s.promise:(s.aborter.addSignal(i),s.statusReporter.addCallback(n),a.checkSinglePromise(s.promise,i)):(this.fill(t,e,i,n),a.checkSinglePromise(this.cache.get(t).promise,i))}delete(t){const e=this.cache.get(t);e&&(e.settled||e.aborter.abort(),this.cache.delete(t))}clear(){const t=this.cache.keys();let e=0;for(let i=t.next();!i.done;i=t.next())this.delete(i.value),e+=1;return e}}e.default=a},9049:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0});const n=i(8904);class r{}e.default=class{constructor(){this.signals=new Set,this.abortController=new n.AbortController}addSignal(t=new r){if(this.signal.aborted)throw new Error("cannot add a signal, already aborted!");this.signals.add(t),t.aborted?this.handleAborted(t):"function"==typeof t.addEventListener&&t.addEventListener("abort",(()=>{this.handleAborted(t)}))}handleAborted(t){this.signals.delete(t),0===this.signals.size&&this.abortController.abort()}get signal(){return this.abortController.signal}abort(){this.abortController.abort()}}},450:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class{constructor(){this.callbacks=new Set}addCallback(t=(()=>{})){this.callbacks.add(t),t(this.currentMessage)}callback(t){this.currentMessage=t,this.callbacks.forEach((e=>{e(t)}))}}},8904:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AbortSignal=e.AbortController=void 0;const n=i(5988);var r=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==i.g)return i.g;throw new Error("unable to locate global object")};let s=void 0===r().AbortController?n.AbortController:r().AbortController;e.AbortController=s;let o=void 0===r().AbortController?n.AbortSignal:r().AbortSignal;e.AbortSignal=o},4105:function(t,e,i){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const r=n(i(1422));e.default=r.default},5988:(t,e)=>{function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var i=0;i{e.byteLength=function(t){var e=a(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){var e,i,s=a(t),o=s[0],l=s[1],h=new r(function(t,e,i){return 3*(e+i)/4-i}(0,o,l)),c=0,u=l>0?o-4:o;for(i=0;i>16&255,h[c++]=e>>8&255,h[c++]=255&e;return 2===l&&(e=n[t.charCodeAt(i)]<<2|n[t.charCodeAt(i+1)]>>4,h[c++]=255&e),1===l&&(e=n[t.charCodeAt(i)]<<10|n[t.charCodeAt(i+1)]<<4|n[t.charCodeAt(i+2)]>>2,h[c++]=e>>8&255,h[c++]=255&e),h},e.fromByteArray=function(t){for(var e,n=t.length,r=n%3,s=[],o=16383,a=0,h=n-r;ah?h:a+o));return 1===r?(e=t[n-1],s.push(i[e>>2]+i[e<<4&63]+"==")):2===r&&(e=(t[n-2]<<8)+t[n-1],s.push(i[e>>10]+i[e>>4&63]+i[e<<2&63]+"=")),s.join("")};for(var i=[],n=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0;o<64;++o)i[o]=s[o],n[s.charCodeAt(o)]=o;function a(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function l(t,e,n){for(var r,s,o=[],a=e;a>18&63]+i[s>>12&63]+i[s>>6&63]+i[63&s]);return o.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},2779:(t,e,i)=>{var n=i(8764).Buffer,r=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];function s(t){if(n.isBuffer(t))return t;var e="function"==typeof n.alloc&&"function"==typeof n.from;if("number"==typeof t)return e?n.alloc(t):new n(t);if("string"==typeof t)return e?n.from(t):new n(t);throw new Error("input must be buffer, number, or string, received "+typeof t)}function o(t,e){t=s(t),n.isBuffer(e)&&(e=e.readUInt32BE(0));for(var i=-1^~~e,o=0;o>>8;return-1^i}function a(){return function(t){var e=s(4);return e.writeInt32BE(t,0),e}(o.apply(null,arguments))}"undefined"!=typeof Int32Array&&(r=new Int32Array(r)),a.signed=function(){return o.apply(null,arguments)},a.unsigned=function(){return o.apply(null,arguments)>>>0},t.exports=a},8764:(t,e,i)=>{const n=i(9742),r=i(645),s="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=l,e.SlowBuffer=function(t){return+t!=t&&(t=0),l.alloc(+t)},e.INSPECT_MAX_BYTES=50;const o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,l.prototype),e}function l(t,e,i){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return h(t,e,i)}function h(t,e,i){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!l.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const i=0|g(t,e);let n=a(i);const r=n.write(t,e);return r!==i&&(n=n.slice(0,r)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Y(t,Uint8Array)){const e=new Uint8Array(t);return f(e.buffer,e.byteOffset,e.byteLength)}return d(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Y(t,ArrayBuffer)||t&&Y(t.buffer,ArrayBuffer))return f(t,e,i);if("undefined"!=typeof SharedArrayBuffer&&(Y(t,SharedArrayBuffer)||t&&Y(t.buffer,SharedArrayBuffer)))return f(t,e,i);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return l.from(n,e,i);const r=function(t){if(l.isBuffer(t)){const e=0|p(t.length),i=a(e);return 0===i.length||t.copy(i,0,0,e),i}return void 0!==t.length?"number"!=typeof t.length||Q(t.length)?a(0):d(t):"Buffer"===t.type&&Array.isArray(t.data)?d(t.data):void 0}(t);if(r)return r;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return l.from(t[Symbol.toPrimitive]("string"),e,i);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function u(t){return c(t),a(t<0?0:0|p(t))}function d(t){const e=t.length<0?0:0|p(t.length),i=a(e);for(let n=0;n=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function g(t,e){if(l.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Y(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const i=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===i)return 0;let r=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return G(t).length;default:if(r)return n?-1:W(t).length;e=(""+e).toLowerCase(),r=!0}}function m(t,e,i){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return M(this,e,i);case"utf8":case"utf-8":return A(this,e,i);case"ascii":return I(this,e,i);case"latin1":case"binary":return E(this,e,i);case"base64":return C(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function b(t,e,i){const n=t[e];t[e]=t[i],t[i]=n}function y(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),Q(i=+i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=l.from(e,n)),l.isBuffer(e))return 0===e.length?-1:v(t,e,i,n,r);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):v(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function v(t,e,i,n,r){let s,o=1,a=t.length,l=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,l/=2,i/=2}function h(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){let n=-1;for(s=i;sa&&(i=a-l),s=i;s>=0;s--){let i=!0;for(let n=0;nr&&(n=r):n=r;const s=e.length;let o;for(n>s/2&&(n=s/2),o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(e,t.length-i),t,i,n)}function C(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function A(t,e,i){i=Math.min(t.length,i);const n=[];let r=e;for(;r239?4:e>223?3:e>191?2:1;if(r+o<=i){let i,n,a,l;switch(o){case 1:e<128&&(s=e);break;case 2:i=t[r+1],128==(192&i)&&(l=(31&e)<<6|63&i,l>127&&(s=l));break;case 3:i=t[r+1],n=t[r+2],128==(192&i)&&128==(192&n)&&(l=(15&e)<<12|(63&i)<<6|63&n,l>2047&&(l<55296||l>57343)&&(s=l));break;case 4:i=t[r+1],n=t[r+2],a=t[r+3],128==(192&i)&&128==(192&n)&&128==(192&a)&&(l=(15&e)<<18|(63&i)<<12|(63&n)<<6|63&a,l>65535&&l<1114112&&(s=l))}}null===s?(s=65533,o=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),r+=o}return function(t){const e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);let i="",n=0;for(;nn.length?(l.isBuffer(e)||(e=l.from(e)),e.copy(n,r)):Uint8Array.prototype.set.call(n,e,r);else{if(!l.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,r)}r+=e.length}return n},l.byteLength=g,l.prototype._isBuffer=!0,l.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;ei&&(t+=" ... "),""},s&&(l.prototype[s]=l.prototype.inspect),l.prototype.compare=function(t,e,i,n,r){if(Y(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),!l.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(this===t)return 0;let s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(e>>>=0);const a=Math.min(s,o),h=this.slice(n,r),c=t.slice(e,i);for(let t=0;t>>=0,isFinite(i)?(i>>>=0,void 0===n&&(n="utf8")):(n=i,i=void 0)}const r=this.length-e;if((void 0===i||i>r)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let s=!1;for(;;)switch(n){case"hex":return w(this,t,e,i);case"utf8":case"utf-8":return _(this,t,e,i);case"ascii":case"latin1":case"binary":return x(this,t,e,i);case"base64":return k(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const T=4096;function I(t,e,i){let n="";i=Math.min(t.length,i);for(let r=e;rn)&&(i=n);let r="";for(let n=e;ni)throw new RangeError("Trying to access beyond buffer length")}function B(t,e,i,n,r,s){if(!l.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function N(t,e,i,n,r){H(e,n,r,t,i,7);let s=Number(e&BigInt(4294967295));t[i++]=s,s>>=8,t[i++]=s,s>>=8,t[i++]=s,s>>=8,t[i++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[i++]=o,o>>=8,t[i++]=o,o>>=8,t[i++]=o,o>>=8,t[i++]=o,i}function F(t,e,i,n,r){H(e,n,r,t,i,7);let s=Number(e&BigInt(4294967295));t[i+7]=s,s>>=8,t[i+6]=s,s>>=8,t[i+5]=s,s>>=8,t[i+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[i+3]=o,o>>=8,t[i+2]=o,o>>=8,t[i+1]=o,o>>=8,t[i]=o,i+8}function O(t,e,i,n,r,s){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function D(t,e,i,n,s){return e=+e,i>>>=0,s||O(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function P(t,e,i,n,s){return e=+e,i>>>=0,s||O(t,0,i,8),r.write(t,e,i,n,52,8),i+8}l.prototype.slice=function(t,e){const i=this.length;(t=~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),(e=void 0===e?i:~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),e>>=0,e>>>=0,i||L(t,e,this.length);let n=this[t],r=1,s=0;for(;++s>>=0,e>>>=0,i||L(t,e,this.length);let n=this[t+--e],r=1;for(;e>0&&(r*=256);)n+=this[t+--e]*r;return n},l.prototype.readUint8=l.prototype.readUInt8=function(t,e){return t>>>=0,e||L(t,1,this.length),this[t]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(t,e){return t>>>=0,e||L(t,2,this.length),this[t]|this[t+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(t,e){return t>>>=0,e||L(t,2,this.length),this[t]<<8|this[t+1]},l.prototype.readUint32LE=l.prototype.readUInt32LE=function(t,e){return t>>>=0,e||L(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},l.prototype.readUint32BE=l.prototype.readUInt32BE=function(t,e){return t>>>=0,e||L(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},l.prototype.readBigUInt64LE=K((function(t){j(t>>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||$(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,r=this[++t]+256*this[++t]+65536*this[++t]+i*2**24;return BigInt(n)+(BigInt(r)<>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||$(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],r=this[++t]*2**24+65536*this[++t]+256*this[++t]+i;return(BigInt(n)<>>=0,e>>>=0,i||L(t,e,this.length);let n=this[t],r=1,s=0;for(;++s=r&&(n-=Math.pow(2,8*e)),n},l.prototype.readIntBE=function(t,e,i){t>>>=0,e>>>=0,i||L(t,e,this.length);let n=e,r=1,s=this[t+--n];for(;n>0&&(r*=256);)s+=this[t+--n]*r;return r*=128,s>=r&&(s-=Math.pow(2,8*e)),s},l.prototype.readInt8=function(t,e){return t>>>=0,e||L(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},l.prototype.readInt16LE=function(t,e){t>>>=0,e||L(t,2,this.length);const i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},l.prototype.readInt16BE=function(t,e){t>>>=0,e||L(t,2,this.length);const i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},l.prototype.readInt32LE=function(t,e){return t>>>=0,e||L(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},l.prototype.readInt32BE=function(t,e){return t>>>=0,e||L(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},l.prototype.readBigInt64LE=K((function(t){j(t>>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||$(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(i<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],i=this[t+7];void 0!==e&&void 0!==i||$(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||L(t,4,this.length),r.read(this,t,!0,23,4)},l.prototype.readFloatBE=function(t,e){return t>>>=0,e||L(t,4,this.length),r.read(this,t,!1,23,4)},l.prototype.readDoubleLE=function(t,e){return t>>>=0,e||L(t,8,this.length),r.read(this,t,!0,52,8)},l.prototype.readDoubleBE=function(t,e){return t>>>=0,e||L(t,8,this.length),r.read(this,t,!1,52,8)},l.prototype.writeUintLE=l.prototype.writeUIntLE=function(t,e,i,n){t=+t,e>>>=0,i>>>=0,n||B(this,t,e,i,Math.pow(2,8*i)-1,0);let r=1,s=0;for(this[e]=255&t;++s>>=0,i>>>=0,n||B(this,t,e,i,Math.pow(2,8*i)-1,0);let r=i-1,s=1;for(this[e+r]=255&t;--r>=0&&(s*=256);)this[e+r]=t/s&255;return e+i},l.prototype.writeUint8=l.prototype.writeUInt8=function(t,e,i){return t=+t,e>>>=0,i||B(this,t,e,1,255,0),this[e]=255&t,e+1},l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(t,e,i){return t=+t,e>>>=0,i||B(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(t,e,i){return t=+t,e>>>=0,i||B(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(t,e,i){return t=+t,e>>>=0,i||B(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(t,e,i){return t=+t,e>>>=0,i||B(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},l.prototype.writeBigUInt64LE=K((function(t,e=0){return N(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),l.prototype.writeBigUInt64BE=K((function(t,e=0){return F(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),l.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*i-1);B(this,t,e,i,n-1,-n)}let r=0,s=1,o=0;for(this[e]=255&t;++r>0)-o&255;return e+i},l.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*i-1);B(this,t,e,i,n-1,-n)}let r=i-1,s=1,o=0;for(this[e+r]=255&t;--r>=0&&(s*=256);)t<0&&0===o&&0!==this[e+r+1]&&(o=1),this[e+r]=(t/s>>0)-o&255;return e+i},l.prototype.writeInt8=function(t,e,i){return t=+t,e>>>=0,i||B(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},l.prototype.writeInt16LE=function(t,e,i){return t=+t,e>>>=0,i||B(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},l.prototype.writeInt16BE=function(t,e,i){return t=+t,e>>>=0,i||B(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},l.prototype.writeInt32LE=function(t,e,i){return t=+t,e>>>=0,i||B(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},l.prototype.writeInt32BE=function(t,e,i){return t=+t,e>>>=0,i||B(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},l.prototype.writeBigInt64LE=K((function(t,e=0){return N(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),l.prototype.writeBigInt64BE=K((function(t,e=0){return F(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),l.prototype.writeFloatLE=function(t,e,i){return D(this,t,e,!0,i)},l.prototype.writeFloatBE=function(t,e,i){return D(this,t,e,!1,i)},l.prototype.writeDoubleLE=function(t,e,i){return P(this,t,e,!0,i)},l.prototype.writeDoubleBE=function(t,e,i){return P(this,t,e,!1,i)},l.prototype.copy=function(t,e,i,n){if(!l.isBuffer(t))throw new TypeError("argument should be a Buffer");if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(r=e;r=n+4;i-=3)e=`_${t.slice(i-3,i)}${e}`;return`${t.slice(0,i)}${e}`}function H(t,e,i,n,r,s){if(t>i||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(s+1)}${n}`:`>= -(2${n} ** ${8*(s+1)-1}${n}) and < 2 ** ${8*(s+1)-1}${n}`:`>= ${e}${n} and <= ${i}${n}`,new z.ERR_OUT_OF_RANGE("value",r,t)}!function(t,e,i){j(e,"offset"),void 0!==t[e]&&void 0!==t[e+i]||$(e,t.length-(i+1))}(n,r,s)}function j(t,e){if("number"!=typeof t)throw new z.ERR_INVALID_ARG_TYPE(e,"number",t)}function $(t,e,i){if(Math.floor(t)!==t)throw j(t,i),new z.ERR_OUT_OF_RANGE(i||"offset","an integer",t);if(e<0)throw new z.ERR_BUFFER_OUT_OF_BOUNDS;throw new z.ERR_OUT_OF_RANGE(i||"offset",`>= ${i?1:0} and <= ${e}`,t)}U("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),U("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),U("ERR_OUT_OF_RANGE",(function(t,e,i){let n=`The value of "${t}" is out of range.`,r=i;return Number.isInteger(i)&&Math.abs(i)>2**32?r=V(String(i)):"bigint"==typeof i&&(r=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(r=V(r)),r+="n"),n+=` It must be ${e}. Received ${r}`,n}),RangeError);const q=/[^+/0-9A-Za-z-_]/g;function W(t,e){let i;e=e||1/0;const n=t.length;let r=null;const s=[];for(let o=0;o55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function G(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(q,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Z(t,e,i,n){let r;for(r=0;r=e.length||r>=t.length);++r)e[r+i]=t[r];return r}function Y(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Q(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let i=0;i<16;++i){const n=16*i;for(let r=0;r<16;++r)e[n+r]=t[i]+t[r]}return e}();function K(t){return"undefined"==typeof BigInt?J:t}function J(){throw new Error("BigInt not supported")}},4693:t=>{var e={array:function(t){var e=0,i=0,n=[0,1,3,7,15,31,63,127,255];return function(r){for(var s=0;r>0;){var o=8-e;r>=o?(s<<=o,s|=n[o]&t[i++],e=0,r-=o):(s<<=r,s|=(t[i]&n[r]<<8-r-e)>>8-r-e,e+=r,r=0)}return s}},simple:function(t){var i,n,r=e.header(t),s=[],o=0;do{-1!=(n=e.decompress(t,r))&&(s.push(n),o+=n.byteLength)}while(-1!=n);i=new Uint8Array(o),o=0;for(var a=0;a9)throw"Not a BZIP archive";return e},decompress:function(t,e,i){for(var n=9e5,r="",s=0;s<6;s++)r+=t(8).toString(16);if("177245385090"==r)return-1;if("314159265359"!=r)throw"eek not valid bzip data";if(t(32),t(1))throw"unsupported obsolete version";var o=t(24);if(o>n)throw"Initial position larger than buffer size";var a=t(16),l=new Uint8Array(256),h=0;for(s=0;s<16;s++)if(a&1<<15-s){var c=t(16);for(g=0;g<16;g++)c&1<<15-g&&(l[h++]=16*s+g)}var u=t(3);if(u<2||u>6)throw"another error";var d=t(15);if(0==d)throw"meh";var f=[];for(s=0;s=u)throw"whoops another error";var m=f[g];f.splice(g,1),f.splice(0,0,m),p[s]=m}var b=h+2,y=[];for(g=0;g20)throw"I gave up a while ago on writing error messages";if(!t(1))break;t(1)?a--:a++}x[s]=a}for(v=w=x[0],s=1;sw?w=x[s]:x[s]=d)throw"meow i'm a kitty, that's an error";S=(_=y[p[E++]]).base.subarray(1),C=_.limit.subarray(1)}for(g=t(s=_.minLen);;){if(s>_.maxLen)throw"rawr i'm a dinosaur";if(g<=C[s])break;s++,g=g<<1|t(1)}if((g-=S[s])<0||g>=258)throw"moo i'm a cow";var L=_.permute[g];if(0!=L&&1!=L){if(T){if(T=0,I+a>=n)throw"Boom.";for(M[m=l[f[0]]]+=a;a--;)R[I++]=m}if(L>h)break;if(I>=n)throw"I can't think of anything. Error";m=f[s=L-1],f.splice(s,1),f.splice(0,0,m),M[m=l[m]]++,R[I++]=m}else T||(T=1,a=0),a+=0==L?T:2*T,T<<=1}if(o<0||o>=I)throw"I'm a monkey and I'm throwing something at someone, namely you";for(g=0,s=0;s<256;s++)c=g+M[s],M[s]=g,g=c;for(s=0;s>=8,F=-1);var O,D,P,z=new Uint8Array(n),U=0;for(i||(i=1/0);I;){for(I--,D=N,N=255&(B=R[B]),B>>=8,3==F++?(O=N,P=D,N=-1):(O=1,P=N);O--;)if(z[U++]=P,! --i)return z;N!=D&&(F=0)}return z.subarray(0,U)}};t.exports=e},487:t=>{var e={utf8:{stringToBytes:function(t){return e.bin.stringToBytes(unescape(encodeURIComponent(t)))},bytesToString:function(t){return decodeURIComponent(escape(e.bin.bytesToString(t)))}},bin:{stringToBytes:function(t){for(var e=[],i=0;i{var e,i;e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i={rotl:function(t,e){return t<>>32-e},rotr:function(t,e){return t<<32-e|t>>>e},endian:function(t){if(t.constructor==Number)return 16711935&i.rotl(t,8)|4278255360&i.rotl(t,24);for(var e=0;e0;t--)e.push(Math.floor(256*Math.random()));return e},bytesToWords:function(t){for(var e=[],i=0,n=0;i>>5]|=t[i]<<24-n%32;return e},wordsToBytes:function(t){for(var e=[],i=0;i<32*t.length;i+=8)e.push(t[i>>>5]>>>24-i%32&255);return e},bytesToHex:function(t){for(var e=[],i=0;i>>4).toString(16)),e.push((15&t[i]).toString(16));return e.join("")},hexToBytes:function(t){for(var e=[],i=0;i>>6*(3-s)&63)):i.push("=");return i.join("")},base64ToBytes:function(t){t=t.replace(/[^A-Z0-9+\/]/gi,"");for(var i=[],n=0,r=0;n>>6-2*r);return i}},t.exports=i},2949:(t,e,i)=>{i.r(e),i.d(e,{BlobFile:()=>h,LocalFile:()=>r(),RemoteFile:()=>a,fromUrl:()=>c,open:()=>u});var n=i(7067),r=i.n(n),s=i(8764);const o="undefined"!=typeof window?window:"undefined"!=typeof self?self:{fetch:void 0};class a{constructor(t,e={}){this.baseOverrides={},this.url=t;const i=e.fetch||o.fetch&&o.fetch.bind(o);if(!i)throw new TypeError("no fetch function supplied, and none found in global environment");e.overrides&&(this.baseOverrides=e.overrides),this.fetchImplementation=i}async getBufferFromResponse(t){if("function"==typeof t.buffer)return t.buffer();if("function"==typeof t.arrayBuffer){const e=await t.arrayBuffer();return s.Buffer.from(e)}throw new TypeError("invalid HTTP response object, has no buffer method, and no arrayBuffer method")}async fetch(t,e){let i;try{i=await this.fetchImplementation(t,e)}catch(n){if(!`${n}`.includes("Failed to fetch"))throw n;console.warn(`generic-filehandle: refetching ${t} to attempt to work around chrome CORS header caching bug`),i=await this.fetchImplementation(t,{...e,cache:"reload"})}return i}async read(t,e=0,i,n=0,r={}){const{headers:s={},signal:o,overrides:a={}}=r;i<1/0?s.range=`bytes=${n}-${n+i}`:i===1/0&&0!==n&&(s.range=`bytes=${n}-`);const l={...this.baseOverrides,...a,headers:{...s,...a.headers,...this.baseOverrides.headers},method:"GET",redirect:"follow",mode:"cors",signal:o},h=await this.fetch(this.url,l);if(!h.ok)throw new Error(`HTTP ${h.status} ${h.statusText} ${this.url}`);if(200===h.status&&0===n||206===h.status){const n=await this.getBufferFromResponse(h),r=n.copy(t,e,0,Math.min(i,n.length)),s=h.headers.get("content-range"),o=/\/(\d+)$/.exec(s||"");return o&&o[1]&&(this._stat={size:parseInt(o[1],10)}),{bytesRead:r,buffer:t}}if(200===h.status)throw new Error("${this.url} fetch returned status 200, expected 206");throw new Error(`HTTP ${h.status} fetching ${this.url}`)}async readFile(t={}){let e,i;"string"==typeof t?(e=t,i={}):(e=t.encoding,i=t,delete i.encoding);const{headers:n={},signal:r,overrides:s={}}=i,o={headers:n,method:"GET",redirect:"follow",mode:"cors",signal:r,...this.baseOverrides,...s},a=await this.fetch(this.url,o);if(!a)throw new Error("generic-filehandle failed to fetch");if(200!==a.status)throw Object.assign(new Error(`HTTP ${a.status} fetching ${this.url}`),{status:a.status});if("utf8"===e)return a.text();if(e)throw new Error(`unsupported encoding: ${e}`);return this.getBufferFromResponse(a)}async stat(){if(!this._stat){const t=s.Buffer.allocUnsafe(10);if(await this.read(t,0,10,0),!this._stat)throw new Error(`unable to determine size of file at ${this.url}`)}return this._stat}async close(){}}function l(t){const e=new FileReader;return new Promise(((i,n)=>{e.onerror=()=>{e.abort(),n(new Error("problem reading blob"))},e.onabort=()=>{n(new Error("blob reading was aborted"))},e.onload=()=>{e.result&&"string"!=typeof e.result?i(e.result):n(new Error("unknown error reading blob"))},e.readAsArrayBuffer(t)}))}class h{constructor(t){this.blob=t,this.size=t.size}async read(t,e=0,i,n=0){if(!i)return{bytesRead:0,buffer:t};const r=n,o=r+i,a=await l(this.blob.slice(r,o)),h=s.Buffer.from(a);return{bytesRead:h.copy(t,e),buffer:h}}async readFile(t){let e;if(e="string"==typeof t?t:t&&t.encoding,"utf8"===e)return function(t){const e=new FileReader;return new Promise(((i,n)=>{e.onerror=()=>{e.abort(),n(new Error("problem reading blob"))},e.onabort=()=>{n(new Error("blob reading was aborted"))},e.onload=()=>{e.result&&"string"==typeof e.result?i(e.result):n(new Error("unknown error reading blob"))},e.readAsText(t)}))}(this.blob);if(e)throw new Error(`unsupported encoding: ${e}`);const i=await l(this.blob);return s.Buffer.from(i)}async stat(){return{size:this.size}}async close(){}}function c(t,e={}){return new a(t,e)}function u(t,e,i,n={}){if(void 0!==i)return i;if(void 0!==t)return c(t,n);if(void 0!==e)return new(r())(e,n);throw new Error("no url, path, or filehandle provided, cannot open")}},645:(t,e)=>{e.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,l=(1<>1,c=-7,u=i?r-1:0,d=i?-1:1,f=t[e+u];for(u+=d,s=f&(1<<-c)-1,f>>=-c,c+=a;c>0;s=256*s+t[e+u],u+=d,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+u],u+=d,c-=8);if(0===s)s=1-h;else{if(s===l)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,n),s-=h}return(f?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,i,n,r,s){var o,a,l,h=8*s-r-1,c=(1<>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,p=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+u>=1?d/l:d*Math.pow(2,1-u))*l>=2&&(o++,l/=2),o+u>=c?(a=0,o=c):o+u>=1?(a=(e*l-1)*Math.pow(2,r),o+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),o=0));r>=8;t[i+f]=255&a,f+=p,a/=256,r-=8);for(o=o<0;t[i+f]=255&o,f+=p,o/=256,h-=8);t[i+f-p]|=128*g}},8738:t=>{function e(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}t.exports=function(t){return null!=t&&(e(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&e(t.slice(0,0))}(t)||!!t._isBuffer)}},3720:t=>{t.exports=i;var e=null;try{e=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(t){}function i(t,e,i){this.low=0|t,this.high=0|e,this.unsigned=!!i}function n(t){return!0===(t&&t.__isLong__)}i.prototype.__isLong__,Object.defineProperty(i.prototype,"__isLong__",{value:!0}),i.isLong=n;var r={},s={};function o(t,e){var i,n,o;return e?(o=0<=(t>>>=0)&&t<256)&&(n=s[t])?n:(i=l(t,(0|t)<0?-1:0,!0),o&&(s[t]=i),i):(o=-128<=(t|=0)&&t<128)&&(n=r[t])?n:(i=l(t,t<0?-1:0,!1),o&&(r[t]=i),i)}function a(t,e){if(isNaN(t))return e?b:m;if(e){if(t<0)return b;if(t>=f)return x}else{if(t<=-p)return k;if(t+1>=p)return _}return t<0?a(-t,e).neg():l(t%d|0,t/d|0,e)}function l(t,e,n){return new i(t,e,n)}i.fromInt=o,i.fromNumber=a,i.fromBits=l;var h=Math.pow;function c(t,e,i){if(0===t.length)throw Error("empty string");if("NaN"===t||"Infinity"===t||"+Infinity"===t||"-Infinity"===t)return m;if("number"==typeof e?(i=e,e=!1):e=!!e,(i=i||10)<2||360)throw Error("interior hyphen");if(0===n)return c(t.substring(1),e,i).neg();for(var r=a(h(i,8)),s=m,o=0;o>>0:this.low},S.toNumber=function(){return this.unsigned?(this.high>>>0)*d+(this.low>>>0):this.high*d+(this.low>>>0)},S.toString=function(t){if((t=t||10)<2||36>>0).toString(t);if((s=l).isZero())return c+o;for(;c.length<6;)c="0"+c;o=""+c+o}},S.getHighBits=function(){return this.high},S.getHighBitsUnsigned=function(){return this.high>>>0},S.getLowBits=function(){return this.low},S.getLowBitsUnsigned=function(){return this.low>>>0},S.getNumBitsAbs=function(){if(this.isNegative())return this.eq(k)?64:this.neg().getNumBitsAbs();for(var t=0!=this.high?this.high:this.low,e=31;e>0&&0==(t&1<=0},S.isOdd=function(){return 1==(1&this.low)},S.isEven=function(){return 0==(1&this.low)},S.equals=function(t){return n(t)||(t=u(t)),(this.unsigned===t.unsigned||this.high>>>31!=1||t.high>>>31!=1)&&this.high===t.high&&this.low===t.low},S.eq=S.equals,S.notEquals=function(t){return!this.eq(t)},S.neq=S.notEquals,S.ne=S.notEquals,S.lessThan=function(t){return this.comp(t)<0},S.lt=S.lessThan,S.lessThanOrEqual=function(t){return this.comp(t)<=0},S.lte=S.lessThanOrEqual,S.le=S.lessThanOrEqual,S.greaterThan=function(t){return this.comp(t)>0},S.gt=S.greaterThan,S.greaterThanOrEqual=function(t){return this.comp(t)>=0},S.gte=S.greaterThanOrEqual,S.ge=S.greaterThanOrEqual,S.compare=function(t){if(n(t)||(t=u(t)),this.eq(t))return 0;var e=this.isNegative(),i=t.isNegative();return e&&!i?-1:!e&&i?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1},S.comp=S.compare,S.negate=function(){return!this.unsigned&&this.eq(k)?k:this.not().add(y)},S.neg=S.negate,S.add=function(t){n(t)||(t=u(t));var e=this.high>>>16,i=65535&this.high,r=this.low>>>16,s=65535&this.low,o=t.high>>>16,a=65535&t.high,h=t.low>>>16,c=0,d=0,f=0,p=0;return f+=(p+=s+(65535&t.low))>>>16,d+=(f+=r+h)>>>16,c+=(d+=i+a)>>>16,c+=e+o,l((f&=65535)<<16|(p&=65535),(c&=65535)<<16|(d&=65535),this.unsigned)},S.subtract=function(t){return n(t)||(t=u(t)),this.add(t.neg())},S.sub=S.subtract,S.multiply=function(t){if(this.isZero())return m;if(n(t)||(t=u(t)),e)return l(e.mul(this.low,this.high,t.low,t.high),e.get_high(),this.unsigned);if(t.isZero())return m;if(this.eq(k))return t.isOdd()?k:m;if(t.eq(k))return this.isOdd()?k:m;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(g)&&t.lt(g))return a(this.toNumber()*t.toNumber(),this.unsigned);var i=this.high>>>16,r=65535&this.high,s=this.low>>>16,o=65535&this.low,h=t.high>>>16,c=65535&t.high,d=t.low>>>16,f=65535&t.low,p=0,b=0,y=0,v=0;return y+=(v+=o*f)>>>16,b+=(y+=s*f)>>>16,y&=65535,b+=(y+=o*d)>>>16,p+=(b+=r*f)>>>16,b&=65535,p+=(b+=s*d)>>>16,b&=65535,p+=(b+=o*c)>>>16,p+=i*f+r*d+s*c+o*h,l((y&=65535)<<16|(v&=65535),(p&=65535)<<16|(b&=65535),this.unsigned)},S.mul=S.multiply,S.divide=function(t){if(n(t)||(t=u(t)),t.isZero())throw Error("division by zero");var i,r,s;if(e)return this.unsigned||-2147483648!==this.high||-1!==t.low||-1!==t.high?l((this.unsigned?e.div_u:e.div_s)(this.low,this.high,t.low,t.high),e.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?b:m;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return b;if(t.gt(this.shru(1)))return v;s=b}else{if(this.eq(k))return t.eq(y)||t.eq(w)?k:t.eq(k)?y:(i=this.shr(1).div(t).shl(1)).eq(m)?t.isNegative()?y:w:(r=this.sub(t.mul(i)),s=i.add(r.div(t)));if(t.eq(k))return this.unsigned?b:m;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();s=m}for(r=this;r.gte(t);){i=Math.max(1,Math.floor(r.toNumber()/t.toNumber()));for(var o=Math.ceil(Math.log(i)/Math.LN2),c=o<=48?1:h(2,o-48),d=a(i),f=d.mul(t);f.isNegative()||f.gt(r);)f=(d=a(i-=c,this.unsigned)).mul(t);d.isZero()&&(d=y),s=s.add(d),r=r.sub(f)}return s},S.div=S.divide,S.modulo=function(t){return n(t)||(t=u(t)),e?l((this.unsigned?e.rem_u:e.rem_s)(this.low,this.high,t.low,t.high),e.get_high(),this.unsigned):this.sub(this.div(t).mul(t))},S.mod=S.modulo,S.rem=S.modulo,S.not=function(){return l(~this.low,~this.high,this.unsigned)},S.and=function(t){return n(t)||(t=u(t)),l(this.low&t.low,this.high&t.high,this.unsigned)},S.or=function(t){return n(t)||(t=u(t)),l(this.low|t.low,this.high|t.high,this.unsigned)},S.xor=function(t){return n(t)||(t=u(t)),l(this.low^t.low,this.high^t.high,this.unsigned)},S.shiftLeft=function(t){return n(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?l(this.low<>>32-t,this.unsigned):l(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):l(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},S.shr=S.shiftRight,S.shiftRightUnsigned=function(t){if(n(t)&&(t=t.toInt()),0==(t&=63))return this;var e=this.high;return t<32?l(this.low>>>t|e<<32-t,e>>>t,this.unsigned):l(32===t?e:e>>>t-32,0,this.unsigned)},S.shru=S.shiftRightUnsigned,S.shr_u=S.shiftRightUnsigned,S.toSigned=function(){return this.unsigned?l(this.low,this.high,!1):this},S.toUnsigned=function(){return this.unsigned?this:l(this.low,this.high,!0)},S.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},S.toBytesLE=function(){var t=this.high,e=this.low;return[255&e,e>>>8&255,e>>>16&255,e>>>24,255&t,t>>>8&255,t>>>16&255,t>>>24]},S.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24,t>>>16&255,t>>>8&255,255&t,e>>>24,e>>>16&255,e>>>8&255,255&e]},i.fromBytes=function(t,e,n){return n?i.fromBytesLE(t,e):i.fromBytesBE(t,e)},i.fromBytesLE=function(t,e){return new i(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,e)},i.fromBytesBE=function(t,e){return new i(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],e)}},2568:(t,e,i)=>{var n,r,s,o,a;n=i(1012),r=i(487).utf8,s=i(8738),o=i(487).bin,(a=function(t,e){t.constructor==String?t=e&&"binary"===e.encoding?o.stringToBytes(t):r.stringToBytes(t):s(t)?t=Array.prototype.slice.call(t,0):Array.isArray(t)||t.constructor===Uint8Array||(t=t.toString());for(var i=n.bytesToWords(t),l=8*t.length,h=1732584193,c=-271733879,u=-1732584194,d=271733878,f=0;f>>24)|4278255360&(i[f]<<24|i[f]>>>8);i[l>>>5]|=128<>>9<<4)]=l;var p=a._ff,g=a._gg,m=a._hh,b=a._ii;for(f=0;f>>0,c=c+v>>>0,u=u+w>>>0,d=d+_>>>0}return n.endian([h,c,u,d])})._ff=function(t,e,i,n,r,s,o){var a=t+(e&i|~e&n)+(r>>>0)+o;return(a<>>32-s)+e},a._gg=function(t,e,i,n,r,s,o){var a=t+(e&n|i&~n)+(r>>>0)+o;return(a<>>32-s)+e},a._hh=function(t,e,i,n,r,s,o){var a=t+(e^i^n)+(r>>>0)+o;return(a<>>32-s)+e},a._ii=function(t,e,i,n,r,s,o){var a=t+(i^(e|~n))+(r>>>0)+o;return(a<>>32-s)+e},a._blocksize=16,a._digestsize=16,t.exports=function(t,e){if(null==t)throw new Error("Illegal argument "+t);var i=n.wordsToBytes(a(t,e));return e&&e.asBytes?i:e&&e.asString?o.bytesToString(i):n.bytesToHex(i)}},9591:(t,e,i)=>{var n={};(0,i(4236).assign)(n,i(4555),i(8843),i(1619)),t.exports=n},4555:(t,e,i)=>{var n=i(405),r=i(4236),s=i(9373),o=i(8898),a=i(2292),l=Object.prototype.toString;function h(t){if(!(this instanceof h))return new h(t);this.options=r.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var i=n.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(0!==i)throw new Error(o[i]);if(e.header&&n.deflateSetHeader(this.strm,e.header),e.dictionary){var c;if(c="string"==typeof e.dictionary?s.string2buf(e.dictionary):"[object ArrayBuffer]"===l.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,0!==(i=n.deflateSetDictionary(this.strm,c)))throw new Error(o[i]);this._dict_set=!0}}function c(t,e){var i=new h(e);if(i.push(t,!0),i.err)throw i.msg||o[i.err];return i.result}h.prototype.push=function(t,e){var i,o,a=this.strm,h=this.options.chunkSize;if(this.ended)return!1;o=e===~~e?e:!0===e?4:0,"string"==typeof t?a.input=s.string2buf(t):"[object ArrayBuffer]"===l.call(t)?a.input=new Uint8Array(t):a.input=t,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new r.Buf8(h),a.next_out=0,a.avail_out=h),1!==(i=n.deflate(a,o))&&0!==i)return this.onEnd(i),this.ended=!0,!1;0!==a.avail_out&&(0!==a.avail_in||4!==o&&2!==o)||("string"===this.options.to?this.onData(s.buf2binstring(r.shrinkBuf(a.output,a.next_out))):this.onData(r.shrinkBuf(a.output,a.next_out)))}while((a.avail_in>0||0===a.avail_out)&&1!==i);return 4===o?(i=n.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,0===i):2!==o||(this.onEnd(0),a.avail_out=0,!0)},h.prototype.onData=function(t){this.chunks.push(t)},h.prototype.onEnd=function(t){0===t&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},e.Deflate=h,e.deflate=c,e.deflateRaw=function(t,e){return(e=e||{}).raw=!0,c(t,e)},e.gzip=function(t,e){return(e=e||{}).gzip=!0,c(t,e)}},8843:(t,e,i)=>{var n=i(7948),r=i(4236),s=i(9373),o=i(1619),a=i(8898),l=i(2292),h=i(2401),c=Object.prototype.toString;function u(t){if(!(this instanceof u))return new u(t);this.options=r.assign({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var i=n.inflateInit2(this.strm,e.windowBits);if(i!==o.Z_OK)throw new Error(a[i]);if(this.header=new h,n.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=s.string2buf(e.dictionary):"[object ArrayBuffer]"===c.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(i=n.inflateSetDictionary(this.strm,e.dictionary))!==o.Z_OK))throw new Error(a[i])}function d(t,e){var i=new u(e);if(i.push(t,!0),i.err)throw i.msg||a[i.err];return i.result}u.prototype.push=function(t,e){var i,a,l,h,u,d=this.strm,f=this.options.chunkSize,p=this.options.dictionary,g=!1;if(this.ended)return!1;a=e===~~e?e:!0===e?o.Z_FINISH:o.Z_NO_FLUSH,"string"==typeof t?d.input=s.binstring2buf(t):"[object ArrayBuffer]"===c.call(t)?d.input=new Uint8Array(t):d.input=t,d.next_in=0,d.avail_in=d.input.length;do{if(0===d.avail_out&&(d.output=new r.Buf8(f),d.next_out=0,d.avail_out=f),(i=n.inflate(d,o.Z_NO_FLUSH))===o.Z_NEED_DICT&&p&&(i=n.inflateSetDictionary(this.strm,p)),i===o.Z_BUF_ERROR&&!0===g&&(i=o.Z_OK,g=!1),i!==o.Z_STREAM_END&&i!==o.Z_OK)return this.onEnd(i),this.ended=!0,!1;d.next_out&&(0!==d.avail_out&&i!==o.Z_STREAM_END&&(0!==d.avail_in||a!==o.Z_FINISH&&a!==o.Z_SYNC_FLUSH)||("string"===this.options.to?(l=s.utf8border(d.output,d.next_out),h=d.next_out-l,u=s.buf2string(d.output,l),d.next_out=h,d.avail_out=f-h,h&&r.arraySet(d.output,d.output,l,h,0),this.onData(u)):this.onData(r.shrinkBuf(d.output,d.next_out)))),0===d.avail_in&&0===d.avail_out&&(g=!0)}while((d.avail_in>0||0===d.avail_out)&&i!==o.Z_STREAM_END);return i===o.Z_STREAM_END&&(a=o.Z_FINISH),a===o.Z_FINISH?(i=n.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===o.Z_OK):a!==o.Z_SYNC_FLUSH||(this.onEnd(o.Z_OK),d.avail_out=0,!0)},u.prototype.onData=function(t){this.chunks.push(t)},u.prototype.onEnd=function(t){t===o.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},e.Inflate=u,e.inflate=d,e.inflateRaw=function(t,e){return(e=e||{}).raw=!0,d(t,e)},e.ungzip=d},4236:(t,e)=>{var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(var r in i)n(i,r)&&(t[r]=i[r])}}return t},e.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var r={arraySet:function(t,e,i,n,r){if(e.subarray&&t.subarray)t.set(e.subarray(i,i+n),r);else for(var s=0;s{var n=i(4236),r=!0,s=!0;try{String.fromCharCode.apply(null,[0])}catch(t){r=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){s=!1}for(var o=new n.Buf8(256),a=0;a<256;a++)o[a]=a>=252?6:a>=248?5:a>=240?4:a>=224?3:a>=192?2:1;function l(t,e){if(e<65534&&(t.subarray&&s||!t.subarray&&r))return String.fromCharCode.apply(null,n.shrinkBuf(t,e));for(var i="",o=0;o>>6,e[o++]=128|63&i):i<65536?(e[o++]=224|i>>>12,e[o++]=128|i>>>6&63,e[o++]=128|63&i):(e[o++]=240|i>>>18,e[o++]=128|i>>>12&63,e[o++]=128|i>>>6&63,e[o++]=128|63&i);return e},e.buf2binstring=function(t){return l(t,t.length)},e.binstring2buf=function(t){for(var e=new n.Buf8(t.length),i=0,r=e.length;i4)h[n++]=65533,i+=s-1;else{for(r&=2===s?31:3===s?15:7;s>1&&i1?h[n++]=65533:r<65536?h[n++]=r:(r-=65536,h[n++]=55296|r>>10&1023,h[n++]=56320|1023&r)}return l(h,n)},e.utf8border=function(t,e){var i;for((e=e||t.length)>t.length&&(e=t.length),i=e-1;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+o[t[i]]>e?i:e}},6069:t=>{t.exports=function(t,e,i,n){for(var r=65535&t|0,s=t>>>16&65535|0,o=0;0!==i;){i-=o=i>2e3?2e3:i;do{s=s+(r=r+e[n++]|0)|0}while(--o);r%=65521,s%=65521}return r|s<<16|0}},1619:t=>{t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},2869:t=>{var e=function(){for(var t,e=[],i=0;i<256;i++){t=i;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e}();t.exports=function(t,i,n,r){var s=e,o=r+n;t^=-1;for(var a=r;a>>8^s[255&(t^i[a])];return-1^t}},405:(t,e,i)=>{var n,r=i(4236),s=i(342),o=i(6069),a=i(2869),l=i(8898),h=-2,c=258,u=262,d=103,f=113,p=666;function g(t,e){return t.msg=l[e],e}function m(t){return(t<<1)-(t>4?9:0)}function b(t){for(var e=t.length;--e>=0;)t[e]=0}function y(t){var e=t.state,i=e.pending;i>t.avail_out&&(i=t.avail_out),0!==i&&(r.arraySet(t.output,e.pending_buf,e.pending_out,i,t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,0===e.pending&&(e.pending_out=0))}function v(t,e){s._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,y(t.strm)}function w(t,e){t.pending_buf[t.pending++]=e}function _(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function x(t,e,i,n){var s=t.avail_in;return s>n&&(s=n),0===s?0:(t.avail_in-=s,r.arraySet(e,t.input,t.next_in,s,i),1===t.state.wrap?t.adler=o(t.adler,e,s,i):2===t.state.wrap&&(t.adler=a(t.adler,e,s,i)),t.next_in+=s,t.total_in+=s,s)}function k(t,e){var i,n,r=t.max_chain_length,s=t.strstart,o=t.prev_length,a=t.nice_match,l=t.strstart>t.w_size-u?t.strstart-(t.w_size-u):0,h=t.window,d=t.w_mask,f=t.prev,p=t.strstart+c,g=h[s+o-1],m=h[s+o];t.prev_length>=t.good_match&&(r>>=2),a>t.lookahead&&(a=t.lookahead);do{if(h[(i=e)+o]===m&&h[i+o-1]===g&&h[i]===h[s]&&h[++i]===h[s+1]){s+=2,i++;do{}while(h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&so){if(t.match_start=e,o=n,n>=a)break;g=h[s+o-1],m=h[s+o]}}}while((e=f[e&d])>l&&0!=--r);return o<=t.lookahead?o:t.lookahead}function S(t){var e,i,n,s,o,a=t.w_size;do{if(s=t.window_size-t.lookahead-t.strstart,t.strstart>=a+(a-u)){r.arraySet(t.window,t.window,a,a,0),t.match_start-=a,t.strstart-=a,t.block_start-=a,e=i=t.hash_size;do{n=t.head[--e],t.head[e]=n>=a?n-a:0}while(--i);e=i=a;do{n=t.prev[--e],t.prev[e]=n>=a?n-a:0}while(--i);s+=a}if(0===t.strm.avail_in)break;if(i=x(t.strm,t.window,t.strstart+t.lookahead,s),t.lookahead+=i,t.lookahead+t.insert>=3)for(o=t.strstart-t.insert,t.ins_h=t.window[o],t.ins_h=(t.ins_h<=3&&(t.ins_h=(t.ins_h<=3)if(n=s._tr_tally(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=(t.ins_h<=3&&(t.ins_h=(t.ins_h<4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){r=t.strstart+t.lookahead-3,n=s._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=r&&(t.ins_h=(t.ins_h<15&&(a=2,n-=16),s<1||s>9||8!==i||n<8||n>15||e<0||e>9||o<0||o>4)return g(t,h);8===n&&(n=9);var l=new I;return t.state=l,l.strm=t,l.wrap=a,l.gzhead=null,l.w_bits=n,l.w_size=1<t.pending_buf_size-5&&(i=t.pending_buf_size-5);;){if(t.lookahead<=1){if(S(t),0===t.lookahead&&0===e)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var n=t.block_start+i;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,v(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-u&&(v(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(v(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(v(t,!1),t.strm.avail_out),1)})),new T(4,4,8,4,C),new T(4,5,16,8,C),new T(4,6,32,32,C),new T(4,4,16,16,A),new T(8,16,32,32,A),new T(8,16,128,128,A),new T(8,32,128,256,A),new T(32,128,258,1024,A),new T(32,258,258,4096,A)],e.deflateInit=function(t,e){return R(t,e,8,15,8,0)},e.deflateInit2=R,e.deflateReset=M,e.deflateResetKeep=E,e.deflateSetHeader=function(t,e){return t&&t.state?2!==t.state.wrap?h:(t.state.gzhead=e,0):h},e.deflate=function(t,e){var i,r,o,l;if(!t||!t.state||e>5||e<0)return t?g(t,h):h;if(r=t.state,!t.output||!t.input&&0!==t.avail_in||r.status===p&&4!==e)return g(t,0===t.avail_out?-5:h);if(r.strm=t,i=r.last_flush,r.last_flush=e,42===r.status)if(2===r.wrap)t.adler=0,w(r,31),w(r,139),w(r,8),r.gzhead?(w(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),w(r,255&r.gzhead.time),w(r,r.gzhead.time>>8&255),w(r,r.gzhead.time>>16&255),w(r,r.gzhead.time>>24&255),w(r,9===r.level?2:r.strategy>=2||r.level<2?4:0),w(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(w(r,255&r.gzhead.extra.length),w(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=a(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69):(w(r,0),w(r,0),w(r,0),w(r,0),w(r,0),w(r,9===r.level?2:r.strategy>=2||r.level<2?4:0),w(r,3),r.status=f);else{var u=8+(r.w_bits-8<<4)<<8;u|=(r.strategy>=2||r.level<2?0:r.level<6?1:6===r.level?2:3)<<6,0!==r.strstart&&(u|=32),u+=31-u%31,r.status=f,_(r,u),0!==r.strstart&&(_(r,t.adler>>>16),_(r,65535&t.adler)),t.adler=1}if(69===r.status)if(r.gzhead.extra){for(o=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>o&&(t.adler=a(t.adler,r.pending_buf,r.pending-o,o)),y(t),o=r.pending,r.pending!==r.pending_buf_size));)w(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>o&&(t.adler=a(t.adler,r.pending_buf,r.pending-o,o)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=73)}else r.status=73;if(73===r.status)if(r.gzhead.name){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(t.adler=a(t.adler,r.pending_buf,r.pending-o,o)),y(t),o=r.pending,r.pending===r.pending_buf_size)){l=1;break}l=r.gzindexo&&(t.adler=a(t.adler,r.pending_buf,r.pending-o,o)),0===l&&(r.gzindex=0,r.status=91)}else r.status=91;if(91===r.status)if(r.gzhead.comment){o=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>o&&(t.adler=a(t.adler,r.pending_buf,r.pending-o,o)),y(t),o=r.pending,r.pending===r.pending_buf_size)){l=1;break}l=r.gzindexo&&(t.adler=a(t.adler,r.pending_buf,r.pending-o,o)),0===l&&(r.status=d)}else r.status=d;if(r.status===d&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&y(t),r.pending+2<=r.pending_buf_size&&(w(r,255&t.adler),w(r,t.adler>>8&255),t.adler=0,r.status=f)):r.status=f),0!==r.pending){if(y(t),0===t.avail_out)return r.last_flush=-1,0}else if(0===t.avail_in&&m(e)<=m(i)&&4!==e)return g(t,-5);if(r.status===p&&0!==t.avail_in)return g(t,-5);if(0!==t.avail_in||0!==r.lookahead||0!==e&&r.status!==p){var x=2===r.strategy?function(t,e){for(var i;;){if(0===t.lookahead&&(S(t),0===t.lookahead)){if(0===e)return 1;break}if(t.match_length=0,i=s._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(v(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(v(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(v(t,!1),0===t.strm.avail_out)?1:2}(r,e):3===r.strategy?function(t,e){for(var i,n,r,o,a=t.window;;){if(t.lookahead<=c){if(S(t),t.lookahead<=c&&0===e)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=a[r=t.strstart-1])===a[++r]&&n===a[++r]&&n===a[++r]){o=t.strstart+c;do{}while(n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&n===a[++r]&&rt.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(i=s._tr_tally(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=s._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(v(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(v(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(v(t,!1),0===t.strm.avail_out)?1:2}(r,e):n[r.level].func(r,e);if(3!==x&&4!==x||(r.status=p),1===x||3===x)return 0===t.avail_out&&(r.last_flush=-1),0;if(2===x&&(1===e?s._tr_align(r):5!==e&&(s._tr_stored_block(r,0,0,!1),3===e&&(b(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),y(t),0===t.avail_out))return r.last_flush=-1,0}return 4!==e?0:r.wrap<=0?1:(2===r.wrap?(w(r,255&t.adler),w(r,t.adler>>8&255),w(r,t.adler>>16&255),w(r,t.adler>>24&255),w(r,255&t.total_in),w(r,t.total_in>>8&255),w(r,t.total_in>>16&255),w(r,t.total_in>>24&255)):(_(r,t.adler>>>16),_(r,65535&t.adler)),y(t),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?0:1)},e.deflateEnd=function(t){var e;return t&&t.state?42!==(e=t.state.status)&&69!==e&&73!==e&&91!==e&&e!==d&&e!==f&&e!==p?g(t,h):(t.state=null,e===f?g(t,-3):0):h},e.deflateSetDictionary=function(t,e){var i,n,s,a,l,c,u,d,f=e.length;if(!t||!t.state)return h;if(2===(a=(i=t.state).wrap)||1===a&&42!==i.status||i.lookahead)return h;for(1===a&&(t.adler=o(t.adler,e,f,0)),i.wrap=0,f>=i.w_size&&(0===a&&(b(i.head),i.strstart=0,i.block_start=0,i.insert=0),d=new r.Buf8(i.w_size),r.arraySet(d,e,f-i.w_size,i.w_size,0),e=d,f=i.w_size),l=t.avail_in,c=t.next_in,u=t.input,t.avail_in=f,t.next_in=0,t.input=e,S(i);i.lookahead>=3;){n=i.strstart,s=i.lookahead-2;do{i.ins_h=(i.ins_h<{t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},4264:t=>{t.exports=function(t,e){var i,n,r,s,o,a,l,h,c,u,d,f,p,g,m,b,y,v,w,_,x,k,S,C,A;i=t.state,n=t.next_in,C=t.input,r=n+(t.avail_in-5),s=t.next_out,A=t.output,o=s-(e-t.avail_out),a=s+(t.avail_out-257),l=i.dmax,h=i.wsize,c=i.whave,u=i.wnext,d=i.window,f=i.hold,p=i.bits,g=i.lencode,m=i.distcode,b=(1<>>=w=v>>>24,p-=w,0==(w=v>>>16&255))A[s++]=65535&v;else{if(!(16&w)){if(0==(64&w)){v=g[(65535&v)+(f&(1<>>=w,p-=w),p<15&&(f+=C[n++]<>>=w=v>>>24,p-=w,!(16&(w=v>>>16&255))){if(0==(64&w)){v=m[(65535&v)+(f&(1<l){t.msg="invalid distance too far back",i.mode=30;break t}if(f>>>=w,p-=w,x>(w=s-o)){if((w=x-w)>c&&i.sane){t.msg="invalid distance too far back",i.mode=30;break t}if(k=0,S=d,0===u){if(k+=h-w,w<_){_-=w;do{A[s++]=d[k++]}while(--w);k=s-x,S=A}}else if(u2;)A[s++]=S[k++],A[s++]=S[k++],A[s++]=S[k++],_-=3;_&&(A[s++]=S[k++],_>1&&(A[s++]=S[k++]))}else{k=s-x;do{A[s++]=A[k++],A[s++]=A[k++],A[s++]=A[k++],_-=3}while(_>2);_&&(A[s++]=A[k++],_>1&&(A[s++]=A[k++]))}break}}break}}while(n>3,f&=(1<<(p-=_<<3))-1,t.next_in=n,t.next_out=s,t.avail_in=n{var n=i(4236),r=i(6069),s=i(2869),o=i(4264),a=i(9241),l=-2,h=12,c=30;function u(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function d(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new n.Buf32(852),e.distcode=e.distdyn=new n.Buf32(592),e.sane=1,e.back=-1,0):l}function p(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,f(t)):l}function g(t,e){var i,n;return t&&t.state?(n=t.state,e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?l:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=i,n.wbits=e,p(t))):l}function m(t,e){var i,n;return t?(n=new d,t.state=n,n.window=null,0!==(i=g(t,e))&&(t.state=null),i):l}var b,y,v=!0;function w(t){if(v){var e;for(b=new n.Buf32(512),y=new n.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(a(1,t.lens,0,288,b,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;a(2,t.lens,0,32,y,0,t.work,{bits:5}),v=!1}t.lencode=b,t.lenbits=9,t.distcode=y,t.distbits=5}function _(t,e,i,r){var s,o=t.state;return null===o.window&&(o.wsize=1<=o.wsize?(n.arraySet(o.window,e,i-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((s=o.wsize-o.wnext)>r&&(s=r),n.arraySet(o.window,e,i-r,s,o.wnext),(r-=s)?(n.arraySet(o.window,e,i-r,r,0),o.wnext=r,o.whave=o.wsize):(o.wnext+=s,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,i.check=s(i.check,P,2,0),y=0,v=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&y)<<8)+(y>>8))%31){t.msg="incorrect header check",i.mode=c;break}if(8!=(15&y)){t.msg="unknown compression method",i.mode=c;break}if(v-=4,B=8+(15&(y>>>=4)),0===i.wbits)i.wbits=B;else if(B>i.wbits){t.msg="invalid window size",i.mode=c;break}i.dmax=1<>8&1),512&i.flags&&(P[0]=255&y,P[1]=y>>>8&255,i.check=s(i.check,P,2,0)),y=0,v=0,i.mode=3;case 3:for(;v<32;){if(0===m)break t;m--,y+=d[p++]<>>8&255,P[2]=y>>>16&255,P[3]=y>>>24&255,i.check=s(i.check,P,4,0)),y=0,v=0,i.mode=4;case 4:for(;v<16;){if(0===m)break t;m--,y+=d[p++]<>8),512&i.flags&&(P[0]=255&y,P[1]=y>>>8&255,i.check=s(i.check,P,2,0)),y=0,v=0,i.mode=5;case 5:if(1024&i.flags){for(;v<16;){if(0===m)break t;m--,y+=d[p++]<>>8&255,i.check=s(i.check,P,2,0)),y=0,v=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&((S=i.length)>m&&(S=m),S&&(i.head&&(B=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),n.arraySet(i.head.extra,d,p,S,B)),512&i.flags&&(i.check=s(i.check,d,S,p)),m-=S,p+=S,i.length-=S),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===m)break t;S=0;do{B=d[p+S++],i.head&&B&&i.length<65536&&(i.head.name+=String.fromCharCode(B))}while(B&&S>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=h;break;case 10:for(;v<32;){if(0===m)break t;m--,y+=d[p++]<>>=7&v,v-=7&v,i.mode=27;break}for(;v<3;){if(0===m)break t;m--,y+=d[p++]<>>=1)){case 0:i.mode=14;break;case 1:if(w(i),i.mode=20,6===e){y>>>=2,v-=2;break t}break;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=c}y>>>=2,v-=2;break;case 14:for(y>>>=7&v,v-=7&v;v<32;){if(0===m)break t;m--,y+=d[p++]<>>16^65535)){t.msg="invalid stored block lengths",i.mode=c;break}if(i.length=65535&y,y=0,v=0,i.mode=15,6===e)break t;case 15:i.mode=16;case 16:if(S=i.length){if(S>m&&(S=m),S>b&&(S=b),0===S)break t;n.arraySet(f,d,p,S,g),m-=S,p+=S,b-=S,g+=S,i.length-=S;break}i.mode=h;break;case 17:for(;v<14;){if(0===m)break t;m--,y+=d[p++]<>>=5,v-=5,i.ndist=1+(31&y),y>>>=5,v-=5,i.ncode=4+(15&y),y>>>=4,v-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=c;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,v-=3}for(;i.have<19;)i.lens[z[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,F={bits:i.lenbits},N=a(0,i.lens,0,19,i.lencode,0,i.work,F),i.lenbits=F.bits,N){t.msg="invalid code lengths set",i.mode=c;break}i.have=0,i.mode=19;case 19:for(;i.have>>16&255,E=65535&D,!((T=D>>>24)<=v);){if(0===m)break t;m--,y+=d[p++]<>>=T,v-=T,i.lens[i.have++]=E;else{if(16===E){for(O=T+2;v>>=T,v-=T,0===i.have){t.msg="invalid bit length repeat",i.mode=c;break}B=i.lens[i.have-1],S=3+(3&y),y>>>=2,v-=2}else if(17===E){for(O=T+3;v>>=T)),y>>>=3,v-=3}else{for(O=T+7;v>>=T)),y>>>=7,v-=7}if(i.have+S>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=c;break}for(;S--;)i.lens[i.have++]=B}}if(i.mode===c)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=c;break}if(i.lenbits=9,F={bits:i.lenbits},N=a(1,i.lens,0,i.nlen,i.lencode,0,i.work,F),i.lenbits=F.bits,N){t.msg="invalid literal/lengths set",i.mode=c;break}if(i.distbits=6,i.distcode=i.distdyn,F={bits:i.distbits},N=a(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,F),i.distbits=F.bits,N){t.msg="invalid distances set",i.mode=c;break}if(i.mode=20,6===e)break t;case 20:i.mode=21;case 21:if(m>=6&&b>=258){t.next_out=g,t.avail_out=b,t.next_in=p,t.avail_in=m,i.hold=y,i.bits=v,o(t,k),g=t.next_out,f=t.output,b=t.avail_out,p=t.next_in,d=t.input,m=t.avail_in,y=i.hold,v=i.bits,i.mode===h&&(i.back=-1);break}for(i.back=0;I=(D=i.lencode[y&(1<>>16&255,E=65535&D,!((T=D>>>24)<=v);){if(0===m)break t;m--,y+=d[p++]<>M)])>>>16&255,E=65535&D,!(M+(T=D>>>24)<=v);){if(0===m)break t;m--,y+=d[p++]<>>=M,v-=M,i.back+=M}if(y>>>=T,v-=T,i.back+=T,i.length=E,0===I){i.mode=26;break}if(32&I){i.back=-1,i.mode=h;break}if(64&I){t.msg="invalid literal/length code",i.mode=c;break}i.extra=15&I,i.mode=22;case 22:if(i.extra){for(O=i.extra;v>>=i.extra,v-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;I=(D=i.distcode[y&(1<>>16&255,E=65535&D,!((T=D>>>24)<=v);){if(0===m)break t;m--,y+=d[p++]<>M)])>>>16&255,E=65535&D,!(M+(T=D>>>24)<=v);){if(0===m)break t;m--,y+=d[p++]<>>=M,v-=M,i.back+=M}if(y>>>=T,v-=T,i.back+=T,64&I){t.msg="invalid distance code",i.mode=c;break}i.offset=E,i.extra=15&I,i.mode=24;case 24:if(i.extra){for(O=i.extra;v>>=i.extra,v-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=c;break}i.mode=25;case 25:if(0===b)break t;if(S=k-b,i.offset>S){if((S=i.offset-S)>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=c;break}S>i.wnext?(S-=i.wnext,C=i.wsize-S):C=i.wnext-S,S>i.length&&(S=i.length),A=i.window}else A=f,C=g-i.offset,S=i.length;S>b&&(S=b),b-=S,i.length-=S;do{f[g++]=A[C++]}while(--S);0===i.length&&(i.mode=21);break;case 26:if(0===b)break t;f[g++]=i.length,b--,i.mode=21;break;case 27:if(i.wrap){for(;v<32;){if(0===m)break t;m--,y|=d[p++]<{var n=i(4236),r=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],s=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],o=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],a=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(t,e,i,l,h,c,u,d){var f,p,g,m,b,y,v,w,_,x=d.bits,k=0,S=0,C=0,A=0,T=0,I=0,E=0,M=0,R=0,L=0,B=null,N=0,F=new n.Buf16(16),O=new n.Buf16(16),D=null,P=0;for(k=0;k<=15;k++)F[k]=0;for(S=0;S=1&&0===F[A];A--);if(T>A&&(T=A),0===A)return h[c++]=20971520,h[c++]=20971520,d.bits=1,0;for(C=1;C0&&(0===t||1!==A))return-1;for(O[1]=0,k=1;k<15;k++)O[k+1]=O[k]+F[k];for(S=0;S852||2===t&&R>592)return 1;for(;;){v=k-E,u[S]y?(w=D[P+u[S]],_=B[N+u[S]]):(w=96,_=0),f=1<>E)+(p-=f)]=v<<24|w<<16|_|0}while(0!==p);for(f=1<>=1;if(0!==f?(L&=f-1,L+=f):L=0,S++,0==--F[k]){if(k===A)break;k=e[i+u[S]]}if(k>T&&(L&m)!==g){for(0===E&&(E=T),b+=C,M=1<<(I=k-E);I+E852||2===t&&R>592)return 1;h[g=L&m]=T<<24|I<<16|b-c|0}}return 0!==L&&(h[b+L]=k-E<<24|64<<16|0),d.bits=T,0}},8898:t=>{t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},342:(t,e,i)=>{var n=i(4236);function r(t){for(var e=t.length;--e>=0;)t[e]=0}var s=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],o=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],l=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],h=new Array(576);r(h);var c=new Array(60);r(c);var u=new Array(512);r(u);var d=new Array(256);r(d);var f=new Array(29);r(f);var p,g,m,b=new Array(30);function y(t,e,i,n,r){this.static_tree=t,this.extra_bits=e,this.extra_base=i,this.elems=n,this.max_length=r,this.has_stree=t&&t.length}function v(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function w(t){return t<256?u[t]:u[256+(t>>>7)]}function _(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function x(t,e,i){t.bi_valid>16-i?(t.bi_buf|=e<>16-t.bi_valid,t.bi_valid+=i-16):(t.bi_buf|=e<>>=1,i<<=1}while(--e>0);return i>>>1}function C(t,e,i){var n,r,s=new Array(16),o=0;for(n=1;n<=15;n++)s[n]=o=o+i[n-1]<<1;for(r=0;r<=e;r++){var a=t[2*r+1];0!==a&&(t[2*r]=S(s[a]++,a))}}function A(t){var e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0}function T(t){t.bi_valid>8?_(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function I(t,e,i,n){var r=2*e,s=2*i;return t[r]>1;i>=1;i--)E(t,s,i);r=l;do{i=t.heap[1],t.heap[1]=t.heap[t.heap_len--],E(t,s,1),n=t.heap[1],t.heap[--t.heap_max]=i,t.heap[--t.heap_max]=n,s[2*r]=s[2*i]+s[2*n],t.depth[r]=(t.depth[i]>=t.depth[n]?t.depth[i]:t.depth[n])+1,s[2*i+1]=s[2*n+1]=r,t.heap[1]=r++,E(t,s,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var i,n,r,s,o,a,l=e.dyn_tree,h=e.max_code,c=e.stat_desc.static_tree,u=e.stat_desc.has_stree,d=e.stat_desc.extra_bits,f=e.stat_desc.extra_base,p=e.stat_desc.max_length,g=0;for(s=0;s<=15;s++)t.bl_count[s]=0;for(l[2*t.heap[t.heap_max]+1]=0,i=t.heap_max+1;i<573;i++)(s=l[2*l[2*(n=t.heap[i])+1]+1]+1)>p&&(s=p,g++),l[2*n+1]=s,n>h||(t.bl_count[s]++,o=0,n>=f&&(o=d[n-f]),a=l[2*n],t.opt_len+=a*(s+o),u&&(t.static_len+=a*(c[2*n+1]+o)));if(0!==g){do{for(s=p-1;0===t.bl_count[s];)s--;t.bl_count[s]--,t.bl_count[s+1]+=2,t.bl_count[p]--,g-=2}while(g>0);for(s=p;0!==s;s--)for(n=t.bl_count[s];0!==n;)(r=t.heap[--i])>h||(l[2*r+1]!==s&&(t.opt_len+=(s-l[2*r+1])*l[2*r],l[2*r+1]=s),n--)}}(t,e),C(s,h,t.bl_count)}function L(t,e,i){var n,r,s=-1,o=e[1],a=0,l=7,h=4;for(0===o&&(l=138,h=3),e[2*(i+1)+1]=65535,n=0;n<=i;n++)r=o,o=e[2*(n+1)+1],++a>=7;n<30;n++)for(b[n]=r<<7,t=0;t<1<0?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,i=4093624447;for(e=0;e<=31;e++,i>>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0}(t)),R(t,t.l_desc),R(t,t.d_desc),o=function(t){var e;for(L(t,t.dyn_ltree,t.l_desc.max_code),L(t,t.dyn_dtree,t.d_desc.max_code),R(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*l[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),r=t.opt_len+3+7>>>3,(s=t.static_len+3+7>>>3)<=r&&(r=s)):r=s=i+5,i+4<=r&&-1!==e?F(t,e,i,n):4===t.strategy||s===r?(x(t,2+(n?1:0),3),M(t,h,c)):(x(t,4+(n?1:0),3),function(t,e,i,n){var r;for(x(t,e-257,5),x(t,i-1,5),x(t,n-4,4),r=0;r>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&i,t.last_lit++,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(d[i]+256+1)]++,t.dyn_dtree[2*w(e)]++),t.last_lit===t.lit_bufsize-1},e._tr_align=function(t){x(t,2,3),k(t,256,h),function(t){16===t.bi_valid?(_(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},2292:t=>{t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},2587:t=>{function e(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,i,n,r){i=i||"&",n=n||"=";var s={};if("string"!=typeof t||0===t.length)return s;var o=/\+/g;t=t.split(i);var a=1e3;r&&"number"==typeof r.maxKeys&&(a=r.maxKeys);var l=t.length;a>0&&l>a&&(l=a);for(var h=0;h=0?(c=p.substr(0,g),u=p.substr(g+1)):(c=p,u=""),d=decodeURIComponent(c),f=decodeURIComponent(u),e(s,d)?Array.isArray(s[d])?s[d].push(f):s[d]=[s[d],f]:s[d]=f}return s}},2361:t=>{var e=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,i,n,r){return i=i||"&",n=n||"=",null===t&&(t=void 0),"object"==typeof t?Object.keys(t).map((function(r){var s=encodeURIComponent(e(r))+n;return Array.isArray(t[r])?t[r].map((function(t){return s+encodeURIComponent(e(t))})).join(i):s+encodeURIComponent(e(t[r]))})).join(i):r?encodeURIComponent(e(r))+n+encodeURIComponent(e(t)):""}},7673:(t,e,i)=>{e.decode=e.parse=i(2587),e.encode=e.stringify=i(2361)},1269:t=>{class e{constructor(t={}){if(!(t.maxSize&&t.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=t.maxSize,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(t,e){this.cache.set(t,e),this._size++,this._size>=this.maxSize&&(this._size=0,this.oldCache=this.cache,this.cache=new Map)}get(t){if(this.cache.has(t))return this.cache.get(t);if(this.oldCache.has(t)){const e=this.oldCache.get(t);return this.oldCache.delete(t),this._set(t,e),e}}set(t,e){return this.cache.has(t)?this.cache.set(t,e):this._set(t,e),this}has(t){return this.cache.has(t)||this.oldCache.has(t)}peek(t){return this.cache.has(t)?this.cache.get(t):this.oldCache.has(t)?this.oldCache.get(t):void 0}delete(t){const e=this.cache.delete(t);return e&&this._size--,this.oldCache.delete(t)||e}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(const[t]of this)yield t}*values(){for(const[,t]of this)yield t}*[Symbol.iterator](){for(const t of this.cache)yield t;for(const t of this.oldCache){const[e]=t;this.cache.has(e)||(yield t)}}get size(){let t=0;for(const e of this.oldCache.keys())this.cache.has(e)||t++;return this._size+t}}t.exports=e},2511:function(t,e,i){var n;t=i.nmd(t),function(r){e&&e.nodeType,t&&t.nodeType;var s="object"==typeof i.g&&i.g;s.global!==s&&s.window!==s&&s.self;var o,a=2147483647,l=36,h=/^xn--/,c=/[^\x20-\x7E]/,u=/[\x2E\u3002\uFF0E\uFF61]/g,d={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},f=Math.floor,p=String.fromCharCode;function g(t){throw RangeError(d[t])}function m(t,e){for(var i=t.length,n=[];i--;)n[i]=e(t[i]);return n}function b(t,e){var i=t.split("@"),n="";return i.length>1&&(n=i[0]+"@",t=i[1]),n+m((t=t.replace(u,".")).split("."),e).join(".")}function y(t){for(var e,i,n=[],r=0,s=t.length;r=55296&&e<=56319&&r65535&&(e+=p((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+p(t)})).join("")}function w(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function _(t,e,i){var n=0;for(t=i?f(t/700):t>>1,t+=f(t/e);t>455;n+=l)t=f(t/35);return f(n+36*t/(t+38))}function x(t){var e,i,n,r,s,o,h,c,u,d,p,m=[],b=t.length,y=0,w=128,x=72;for((i=t.lastIndexOf("-"))<0&&(i=0),n=0;n=128&&g("not-basic"),m.push(t.charCodeAt(n));for(r=i>0?i+1:0;r=b&&g("invalid-input"),((c=(p=t.charCodeAt(r++))-48<10?p-22:p-65<26?p-65:p-97<26?p-97:l)>=l||c>f((a-y)/o))&&g("overflow"),y+=c*o,!(c<(u=h<=x?1:h>=x+26?26:h-x));h+=l)o>f(a/(d=l-u))&&g("overflow"),o*=d;x=_(y-s,e=m.length+1,0==s),f(y/e)>a-w&&g("overflow"),w+=f(y/e),y%=e,m.splice(y++,0,w)}return v(m)}function k(t){var e,i,n,r,s,o,h,c,u,d,m,b,v,x,k,S=[];for(b=(t=y(t)).length,e=128,i=0,s=72,o=0;o=e&&mf((a-i)/(v=n+1))&&g("overflow"),i+=(h-e)*v,e=h,o=0;oa&&g("overflow"),m==e){for(c=i,u=l;!(c<(d=u<=s?1:u>=s+26?26:u-s));u+=l)k=c-d,x=l-d,S.push(p(w(d+k%x,0))),c=f(k/x);S.push(p(w(c,0))),s=_(i,v,n==r),i=0,++n}++i,++e}return S.join("")}o={version:"1.3.2",ucs2:{decode:y,encode:v},decode:x,encode:k,toASCII:function(t){return b(t,(function(t){return c.test(t)?"xn--"+k(t):t}))},toUnicode:function(t){return b(t,(function(t){return h.test(t)?x(t.slice(4).toLowerCase()):t}))}},void 0===(n=function(){return o}.call(e,i,e,t))||(t.exports=n)}()},8575:(t,e,i)=>{var n=i(2511),r=i(2502);function s(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}e.parse=v,e.resolve=function(t,e){return v(t,!1,!0).resolve(e)},e.resolveObject=function(t,e){return t?v(t,!1,!0).resolveObject(e):e},e.format=function(t){return r.isString(t)&&(t=v(t)),t instanceof s?t.format():s.prototype.format.call(t)},e.Url=s;var o=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,l=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,h=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),c=["'"].concat(h),u=["%","/","?",";","#"].concat(c),d=["/","?","#"],f=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},m={javascript:!0,"javascript:":!0},b={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},y=i(7673);function v(t,e,i){if(t&&r.isObject(t)&&t instanceof s)return t;var n=new s;return n.parse(t,e,i),n}s.prototype.parse=function(t,e,i){if(!r.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var s=t.indexOf("?"),a=-1!==s&&s127?B+="x":B+=L[N];if(!B.match(f)){var O=M.slice(0,T),D=M.slice(T+1),P=L.match(p);P&&(O.push(P[1]),D.unshift(P[2])),D.length&&(v="/"+D.join(".")+v),this.hostname=O.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),E||(this.hostname=n.toASCII(this.hostname));var z=this.port?":"+this.port:"",U=this.hostname||"";this.host=U+z,this.href+=this.host,E&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==v[0]&&(v="/"+v))}if(!g[x])for(T=0,R=c.length;T0)&&i.host.split("@"))&&(i.auth=E.shift(),i.host=i.hostname=E.shift())),i.search=t.search,i.query=t.query,r.isNull(i.pathname)&&r.isNull(i.search)||(i.path=(i.pathname?i.pathname:"")+(i.search?i.search:"")),i.href=i.format(),i;if(!k.length)return i.pathname=null,i.search?i.path="/"+i.search:i.path=null,i.href=i.format(),i;for(var C=k.slice(-1)[0],A=(i.host||t.host||k.length>1)&&("."===C||".."===C)||""===C,T=0,I=k.length;I>=0;I--)"."===(C=k[I])?k.splice(I,1):".."===C?(k.splice(I,1),T++):T&&(k.splice(I,1),T--);if(!_&&!x)for(;T--;T)k.unshift("..");!_||""===k[0]||k[0]&&"/"===k[0].charAt(0)||k.unshift(""),A&&"/"!==k.join("/").substr(-1)&&k.push("");var E,M=""===k[0]||k[0]&&"/"===k[0].charAt(0);return S&&(i.hostname=i.host=M?"":k.length?k.shift():"",(E=!!(i.host&&i.host.indexOf("@")>0)&&i.host.split("@"))&&(i.auth=E.shift(),i.host=i.hostname=E.shift())),(_=_||i.host&&k.length)&&!M&&k.unshift(""),k.length?i.pathname=k.join("/"):(i.pathname=null,i.path=null),r.isNull(i.pathname)&&r.isNull(i.search)||(i.path=(i.pathname?i.pathname:"")+(i.search?i.search:"")),i.auth=t.auth||i.auth,i.slashes=i.slashes||t.slashes,i.href=i.format(),i},s.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},2502:t=>{t.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},7067:()=>{}},e={};function i(n){var r=e[n];if(void 0!==r)return r.exports;var s=e[n]={id:n,loaded:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.loaded=!0,s.exports}return i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),i(5590)})();class Du{constructor(t,e,i){this.config=t,this.browser=i,this.genome=e,this.cramFile=new Ou.CramFile({filehandle:new Pu(t.url,t),seqFetch:t.seqFetch||function(t,e,i){const n=this.genome.sequence,r=this.genome;return this.getHeader().then((function(s){const o=r.getChromosomeName(s.chrNames[t]);return n.getSequence(o,e-1,i)}))}.bind(this),checkSequenceMD5:void 0===t.checkSequenceMD5||t.checkSequenceMD5});const n=new Pu(t.indexURL,t);this.indexedCramFile=new Ou.IndexedCramFile({cram:this.cramFile,index:new Ou.CraiIndex({filehandle:n}),fetchSizeLimit:3e7}),Cu.setReaderDefaults(this,t)}async getHeader(){if(!this.header){const t=this.genome,e=await this.cramFile.getSamHeader(),i={},n=[],r={},s=[];for(let o of e)if("SQ"===o.tag){for(let e of o.data)if("SN"===e.tag){const s=e.value;i[s]=n.length,n.push(s),t&&(r[t.getChromosomeName(s)]=s);break}}else"RG"===o.tag&&s.push(o.data);this.header={chrNames:n,chrToIndex:i,chrAliasTable:r,readGroups:s}}return this.header}async readAlignments(t,e,i){this.browser;const n=await this.getHeader(),r=n.chrAliasTable.hasOwnProperty(t)?n.chrAliasTable[t]:t,s=n.chrToIndex[r],o=new nu(t,e,i,this.config);if(void 0===s)return o;try{const t=await this.indexedCramFile.getRecordsForRange(s,e,i);for(let r of t){const t=r.sequenceId,l=r.alignmentStart,h=l+r.lengthOnRef;if(t<0)continue;if(t>s||l>i)return;if(t=0&&(e="Sequence mismatch. Is this the correct genome for the loaded CRAM?"),this.browser.alert.present(new Error(e)),t}function a(t,e){const i=new uu;if(i.chr=e[t.sequenceId],i.start=t.alignmentStart-1,i.lengthOnRef=t.lengthOnRef,i.flags=t.flags,i.strand=!(16&t.flags),i.fragmentLength=t.templateLength||t.templateSize,i.mq=t.mappingQuality,i.end=t.alignmentStart+t.lengthOnRef,i.readGroupId=t.readGroupId,t.mate&&void 0!==t.mate.sequenceId){const n=void 0!==t.mate.flags?!(1&t.mate.flags):!(32&t.flags);i.mate={chr:e[t.mate.sequenceId],position:t.mate.alignmentStart,strand:n}}return i.seq=t.getReadBases(),i.qual=t.qualityScores,i.tagDict=t.tags,i.readName=t.readName,function(t,e){const i=[];let n,r,s=0,o="";if(e.scStart=e.start,e.scLengthOnRef=e.lengthOnRef,t.readFeatures)for(let a of t.readFeatures){const t=a.code,l=a.data,h=a.pos-1,c=a.refPos-1;switch(t){case"S":case"I":case"i":case"N":case"D":if(h>s){const t=h-s;i.push(new vu({start:c-t,seqOffset:s,len:t,type:"M"})),s+=t,o+=t+"M"}if("S"===t){let n=c;e.scLengthOnRef+=l.length,0===h&&(e.scStart-=l.length,n-=l.length);const r=l.length;i.push(new vu({start:n,seqOffset:s,len:r,type:"S"})),s+=r,o+=r+t}else if("I"===t||"i"===t){void 0===n&&(n=[]);const e="i"===t?1:l.length;n.push(new vu({start:c,len:e,seqOffset:s,type:"I"})),s+=e,o+=e+t}else"D"!==t&&"N"!==t||(r||(r=[]),r.push({start:c,len:l,type:t}),o+=l+t);break;case"H":case"P":o+=l+t}}const a=t.readLength-s;a>0&&(i.push(new vu({start:t.alignmentStart+t.lengthOnRef-a-1,seqOffset:s,len:a,type:"M"})),o+=a+"M"),e.blocks=i,e.insertions=n,e.gaps=r,e.cigar=o}(t,i),i.mate&&i.start>i.mate.position&&i.fragmentLength>0&&(i.fragmentLength=-i.fragmentLength),Cu.setPairOrientation(i),i}}}class Pu{constructor(t,e){this.position=0,this.url=t,this.config=e,this.cache=new zu({fetch:(t,e)=>this._fetch(t,e)})}async _fetch(t,e){const i={start:t,size:e};this._stat={size:void 0};const n=await zo.loadArrayBuffer(this.url,la(this.config,{range:i}));return Buffer.from(n)}async read(t,e=0,i=1/0,n=0){let r=n;return null===n&&(r=this.position,this.position+=i),this.cache.get(t,e,i,n)}async readFile(){const t=await zo.loadArrayBuffer(this.url,la(this.config));return Buffer.from(t)}async stat(){if(!this._stat){const t=Buffer.allocUnsafe(10);if(await this.read(t,0,10,0),!this._stat)throw new Error(`unable to determine size of file at ${this.url}`)}return this._stat}}class zu{constructor({fetch:t,size:e=1e7,chunkSize:i=32768}){this.fetch=t,this.chunkSize=i,this.lruCache=new Uu({maxSize:Math.floor(e/i)})}async get(t,e,i,n){if(t.length({data:e,chunkNumber:t})));const a=await Promise.all(o),l=n-a[0].chunkNumber*this.chunkSize;a.forEach((({data:o,chunkNumber:a})=>{const h=a*this.chunkSize;let c=0,u=this.chunkSize,d=e+(a-r)*this.chunkSize-l;a===r&&(d=e,c=l),a===s&&(u=n+i-h),o.copy(t,d,c,u)}))}_getChunk(t){const e=this.lruCache.get(t);if(e)return e;const i=this.fetch(t*this.chunkSize,this.chunkSize);return this.lruCache.set(t,i),i}}class Uu{constructor(t={}){if(!(t.maxSize&&t.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=t.maxSize,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(t,e){this.cache.set(t,e),this._size++,this._size>=this.maxSize&&(this._size=0,this.oldCache=this.cache,this.cache=new Map)}get(t){if(this.cache.has(t))return this.cache.get(t);if(this.oldCache.has(t)){const e=this.oldCache.get(t);return this._set(t,e),e}}set(t,e){return this.cache.has(t)?this.cache.set(t,e):this._set(t,e),this}has(t){return this.cache.has(t)||this.oldCache.has(t)}peek(t){return this.cache.has(t)?this.cache.get(t):this.oldCache.has(t)?this.oldCache.get(t):void 0}delete(t){const e=this.cache.delete(t);return e&&this._size--,this.oldCache.delete(t)||e}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(const[t]of this)yield t}*values(){for(const[,t]of this)yield t}*[Symbol.iterator](){for(const t of this.cache)yield t;for(const t of this.oldCache){const[e]=t;this.cache.has(e)||(yield t)}}get size(){let t=0;for(const e of this.oldCache.keys())this.cache.has(e)||t++;return this._size+t}}var Vu={ALIGNMENT_MATCH:"M",INSERT:"I",DELETE:"D",SKIP:"N",CLIP_SOFT:"S",CLIP_HARD:"H",PAD:"P",SEQUENCE_MATCH:"=",SEQUENCE_MISMATCH:"X"};const Hu=function(t,e){this.config=t,this.genome=e,this.url=t.url,this.filter=new wu(t.filter),this.readGroupSetIds=t.readGroupSetIds,this.authKey=t.authKey,this.samplingWindowSize=void 0===t.samplingWindowSize?100:t.samplingWindowSize,this.samplingDepth=void 0===t.samplingDepth?1e3:t.samplingDepth,t.viewAsPairs?this.pairsSupported=!0:this.pairsSupported=void 0===t.pairsSupported||t.pairsSupported};Hu.prototype.readAlignments=function(t,e,i){const n=this.genome,r=this;return(r.chrAliasTable?Promise.resolve(r.chrAliasTable):r.readMetadata().then((function(t){if(r.chrAliasTable={},n&&t.readGroups&&t.readGroups.length>0){var e=t.readGroups[0].referenceSetId;return e?oc({url:r.url+"/references/search",body:{referenceSetId:e},decode:function(t){return t.references}}).then((function(t){return t.forEach((function(t){var e=t.name,i=n.getChromosomeName(e);r.chrAliasTable[i]=e})),r.chrAliasTable})):(function(t,e){var i;if("461916304629"===e||"337315832689"===e){for(i=1;i<23;i++)t["chr"+i]=i;t.chrX="X",t.chrY="Y",t.chrM="MT"}}(r.chrAliasTable,r.config.datasetId),r.chrAliasTable)}return r.chrAliasTable}))).then((function(n){var o=n.hasOwnProperty(t)?n[t]:t;return oc({url:r.url+"/reads/search",body:{readGroupSetIds:[r.readGroupSetIds],referenceName:o,start:e,end:i,pageSize:"10000"},decode:s,results:new nu(t,e,i,r.config)})}));function s(t){var e,i,s,o,a,l=t.alignments,h=l.length,c=[];for(e=0;e0;if(s.packedAlignmentRows=eu(o,s.start,s.end,r),this.alignmentContainer=s,a){const e=await n.sequence.getSequence(t,s.start,s.end);if(e)return s.coverageMap.refSeq=e,s.sequence=e,s;console.error("No sequence for: "+t+":"+s.start+"-"+s.end)}return s}}function $u(t,e,i){var n,r,s,o,a,l,h,c={font:"normal 10px Arial",textAlign:"right",strokeStyle:"black"};if(void 0===this.dataRange||void 0===this.dataRange.max||void 0===this.dataRange.min)return;let u=void 0!==this.flipAxis&&this.flipAxis;function d(t){return 0===t?"0":Math.abs(t)>=10?t.toFixed():Math.abs(t)>=1?t.toFixed(1):t.toFixed(2)}na.fillRect(t,0,0,e,i,{fillStyle:"rgb(255, 255, 255)"}),n=(h=.95*e)-8,a={x:r=h,y:s=o=.01*i},na.strokeLine(t,n,s,r,o,c),na.fillText(t,d(u?this.dataRange.min:this.dataRange.max),n+4,s+12,c),l={x:r,y:s=o=.99*i},na.strokeLine(t,n,s,r,o,c),na.fillText(t,d(u?this.dataRange.max:this.dataRange.min),n+4,s-4,c),na.strokeLine(t,a.x,a.y,l.x,l.y,c)}class qu{constructor({chr:t,start:e,end:i}){this.chr=t,this.start=e,this.end=i}contains(t){return t.chr===this.chr&&t.start>=this.start&&t.end<=this.end}overlaps(t){return t.chr===this.chr&&!(t.endthis.end)}extend(t){t.chr===this.chr&&(this.start=Math.min(t.start,this.start),this.end=Math.max(t.end,this.end))}getLocusString(){if("all"===this.chr)return"all";{const t=$i(Math.floor(this.start)+1),e=$i(Math.round(this.end));return`${this.chr}:${t}-${e}`}}static fromLocusString(t){if("all"===t)return new qu({chr:"all"});const e=t.split(":"),i=e[0],n=e[1].split("-"),r=Number.parseInt(n[0].replace(/,/g,""))-1,s=Number.parseInt(n[1].replace(/,/g,""));return new qu({chr:i,start:r,end:s})}}var Wu=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},Gu=function(){function t(t,e){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:1;return(e>0?t.toFixed(e).replace(/0+$/,"").replace(/\.$/,""):t.toString())||"0"}var Xu=function(){function t(e,i,n,r){Wu(this,t);var s=this;if(void 0===e);else if(Array.isArray(e))this.rgba=e;else if(void 0===n){var o=e&&""+e;o&&function(e){if(e.startsWith("hsl")){var i=e.match(/([\-\d\.e]+)/g).map(Number),n=Zu(i,4),r=n[0],o=n[1],a=n[2],l=n[3];void 0===l&&(l=1),r/=360,o/=100,a/=100,s.hsla=[r,o,a,l]}else if(e.startsWith("rgb")){var h=e.match(/([\-\d\.e]+)/g).map(Number),c=Zu(h,4),u=c[0],d=c[1],f=c[2],p=c[3];void 0===p&&(p=1),s.rgba=[u,d,f,p]}else e.startsWith("#")?s.rgba=t.hexToRgb(e):s.rgba=t.nameToRgb(e)||t.hexToRgb(e)}(o.toLowerCase())}else this.rgba=[e,i,n,void 0===r?1:r]}return Gu(t,[{key:"printRGB",value:function(t){var e=(t?this.rgba:this.rgba.slice(0,3)).map((function(t,e){return Qu(t,3===e?3:0)}));return t?"rgba("+e+")":"rgb("+e+")"}},{key:"printHSL",value:function(t){var e=[360,100,100,1],i=["","%","%",""],n=(t?this.hsla:this.hsla.slice(0,3)).map((function(t,n){return Qu(t*e[n],3===n?3:1)+i[n]}));return t?"hsla("+n+")":"hsl("+n+")"}},{key:"printHex",value:function(t){var e=this.hex;return t?e:e.substring(0,7)}},{key:"rgba",get:function(){if(this._rgba)return this._rgba;if(!this._hsla)throw new Error("No color is set");return this._rgba=t.hslToRgb(this._hsla)},set:function(t){3===t.length&&(t[3]=1),this._rgba=t,this._hsla=null}},{key:"rgbString",get:function(){return this.printRGB()}},{key:"rgbaString",get:function(){return this.printRGB(!0)}},{key:"hsla",get:function(){if(this._hsla)return this._hsla;if(!this._rgba)throw new Error("No color is set");return this._hsla=t.rgbToHsl(this._rgba)},set:function(t){3===t.length&&(t[3]=1),this._hsla=t,this._rgba=null}},{key:"hslString",get:function(){return this.printHSL()}},{key:"hslaString",get:function(){return this.printHSL(!0)}},{key:"hex",get:function(){return"#"+this.rgba.map((function(t,e){return e<3?t.toString(16):Math.round(255*t).toString(16)})).map((function(t){return t.padStart(2,"0")})).join("")},set:function(e){this.rgba=t.hexToRgb(e)}}],[{key:"hexToRgb",value:function(t){var e=(t.startsWith("#")?t.slice(1):t).replace(/^(\w{3})$/,"$1F").replace(/^(\w)(\w)(\w)(\w)$/,"$1$1$2$2$3$3$4$4").replace(/^(\w{6})$/,"$1FF");if(!e.match(/^([0-9a-fA-F]{8})$/))throw new Error("Unknown hex color; "+t);var i=e.match(/^(\w\w)(\w\w)(\w\w)(\w\w)$/).slice(1).map((function(t){return parseInt(t,16)}));return i[3]=i[3]/255,i}},{key:"nameToRgb",value:function(e){var i=e.toLowerCase().replace("at","T").replace(/[aeiouyldf]/g,"").replace("ght","L").replace("rk","D").slice(-5,4),n=Yu[i];return void 0===n?n:t.hexToRgb(n.replace(/\-/g,"00").padStart(6,"f"))}},{key:"rgbToHsl",value:function(t){var e=Zu(t,4),i=e[0],n=e[1],r=e[2],s=e[3];i/=255,n/=255,r/=255;var o=Math.max(i,n,r),a=Math.min(i,n,r),l=void 0,h=void 0,c=(o+a)/2;if(o===a)l=h=0;else{var u=o-a;switch(h=c>.5?u/(2-o-a):u/(o+a),o){case i:l=(n-r)/u+(n1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t},c=r<.5?r*(1+n):r+n-r*n,u=2*r-c;o=h(u,c,i+1/3),a=h(u,c,i),l=h(u,c,i-1/3)}var d=[255*o,255*a,255*l].map(Math.round);return d[3]=s,d}}]),t}(),Ku=function(){function t(){Wu(this,t),this._events=[]}return Gu(t,[{key:"add",value:function(t,e,i){t.addEventListener(e,i,!1),this._events.push({target:t,type:e,handler:i})}},{key:"remove",value:function(e,i,n){this._events=this._events.filter((function(r){var s=!0;return e&&e!==r.target&&(s=!1),i&&i!==r.type&&(s=!1),n&&n!==r.handler&&(s=!1),s&&t._doRemove(r.target,r.type,r.handler),!s}))}},{key:"destroy",value:function(){this._events.forEach((function(e){return t._doRemove(e.target,e.type,e.handler)})),this._events=[]}}],[{key:"_doRemove",value:function(t,e,i){t.removeEventListener(e,i,!1)}}]),t}();function Ju(t,e,i){var n=!1;function r(t,e,i){return Math.max(e,Math.min(t,i))}function s(t,s,o){if(o&&(n=!0),n){t.preventDefault();var a=e.getBoundingClientRect(),l=a.width,h=a.height,c=s.clientX,u=s.clientY,d=r(c-a.left,0,l),f=r(u-a.top,0,h);i(d/l,f/h)}}function o(t,e){1===(void 0===t.buttons?t.which:t.buttons)?s(t,t,e):n=!1}function a(t,e){1===t.touches.length?s(t,t.touches[0],e):n=!1}t.add(e,"mousedown",(function(t){o(t,!0)})),t.add(e,"touchstart",(function(t){a(t,!0)})),t.add(window,"mousemove",o),t.add(e,"touchmove",a),t.add(window,"mouseup",(function(t){n=!1})),t.add(e,"touchend",(function(t){n=!1})),t.add(e,"touchcancel",(function(t){n=!1}))}var td="keydown",ed="mousedown",id="focusin";function nd(t,e){return(e||document).querySelector(t)}function rd(t){t.preventDefault(),t.stopPropagation()}function sd(t,e,i,n,r){t.add(e,td,(function(t){i.indexOf(t.key)>=0&&(r&&rd(t),n(t))}))}var od=function(){function t(e){Wu(this,t),this.settings={popup:"right",layout:"default",alpha:!0,editor:!0,editorFormat:"hex",cancelButton:!1,defaultColor:"#0cf"},this._events=new Ku,this.onChange=null,this.onDone=null,this.onOpen=null,this.onClose=null,this.setOptions(e)}return Gu(t,[{key:"setOptions",value:function(t){var e=this;if(t){var i=this.settings;if(t instanceof HTMLElement)i.parent=t;else{i.parent&&t.parent&&i.parent!==t.parent&&(this._events.remove(i.parent),this._popupInited=!1),function(t,e,i){for(var n in t)e[n]=t[n]}(t,i),t.onChange&&(this.onChange=t.onChange),t.onDone&&(this.onDone=t.onDone),t.onOpen&&(this.onOpen=t.onOpen),t.onClose&&(this.onClose=t.onClose);var n=t.color||t.colour;n&&this._setColor(n)}var r=i.parent;if(r&&i.popup&&!this._popupInited){var s=function(t){return e.openHandler(t)};this._events.add(r,"click",s),sd(this._events,r,[" ","Spacebar","Enter"],s),this._popupInited=!0}else t.parent&&!i.popup&&this.show()}}},{key:"openHandler",value:function(t){if(this.show()){t&&t.preventDefault(),this.settings.parent.style.pointerEvents="none";var e=t&&t.type===td?this._domEdit:this.domElement;setTimeout((function(){return e.focus()}),100),this.onOpen&&this.onOpen(this.colour)}}},{key:"closeHandler",value:function(t){var e=t&&t.type,i=!1;if(t)if(e===ed||e===id){var n=(this.__containedEvent||0)+100;t.timeStamp>n&&(i=!0)}else rd(t),i=!0;else i=!0;i&&this.hide()&&(this.settings.parent.style.pointerEvents="",e!==ed&&this.settings.parent.focus(),this.onClose&&this.onClose(this.colour))}},{key:"movePopup",value:function(t,e){this.closeHandler(),this.setOptions(t),e&&this.openHandler()}},{key:"setColor",value:function(t,e){this._setColor(t,{silent:e})}},{key:"_setColor",value:function(t,e){if("string"==typeof t&&(t=t.trim()),t){e=e||{};var i=void 0;try{i=new Xu(t)}catch(t){if(e.failSilently)return;throw t}if(!this.settings.alpha){var n=i.hsla;n[3]=1,i.hsla=n}this.colour=this.color=i,this._setHSLA(null,null,null,null,e)}}},{key:"setColour",value:function(t,e){this.setColor(t,e)}},{key:"show",value:function(){if(!this.settings.parent)return!1;if(this.domElement){var t=this._toggleDOM(!0);return this._setPosition(),t}var e=function(t){var e=document.createElement("div");return e.innerHTML=t,e.firstElementChild}(this.settings.template||'
');return this.domElement=e,this._domH=nd(".picker_hue",e),this._domSL=nd(".picker_sl",e),this._domA=nd(".picker_alpha",e),this._domEdit=nd(".picker_editor input",e),this._domSample=nd(".picker_sample",e),this._domOkay=nd(".picker_done button",e),this._domCancel=nd(".picker_cancel button",e),e.classList.add("layout_"+this.settings.layout),this.settings.alpha||e.classList.add("no_alpha"),this.settings.editor||e.classList.add("no_editor"),this.settings.cancelButton||e.classList.add("no_cancel"),this._ifPopup((function(){return e.classList.add("popup")})),this._setPosition(),this.colour?this._updateUI():this._setColor(this.settings.defaultColor),this._bindEvents(),!0}},{key:"hide",value:function(){return this._toggleDOM(!1)}},{key:"destroy",value:function(){this._events.destroy(),this.domElement&&this.settings.parent.removeChild(this.domElement)}},{key:"_bindEvents",value:function(){var t=this,e=this,i=this.domElement,n=this._events;function r(t,e,i){n.add(t,e,i)}r(i,"click",(function(t){return t.preventDefault()})),Ju(n,this._domH,(function(t,i){return e._setHSLA(t)})),Ju(n,this._domSL,(function(t,i){return e._setHSLA(null,t,1-i)})),this.settings.alpha&&Ju(n,this._domA,(function(t,i){return e._setHSLA(null,null,null,1-i)}));var s=this._domEdit;r(s,"input",(function(t){e._setColor(this.value,{fromEditor:!0,failSilently:!0})})),r(s,"focus",(function(t){var e=this;e.selectionStart===e.selectionEnd&&e.select()})),this._ifPopup((function(){var e=function(e){return t.closeHandler(e)};r(window,ed,e),r(window,id,e),sd(n,i,["Esc","Escape"],e);var s=function(e){t.__containedEvent=e.timeStamp};r(i,ed,s),r(i,id,s),r(t._domCancel,"click",e)}));var o=function(e){t._ifPopup((function(){return t.closeHandler(e)})),t.onDone&&t.onDone(t.colour)};r(this._domOkay,"click",o),sd(n,i,["Enter"],o)}},{key:"_setPosition",value:function(){var t=this.settings.parent,e=this.domElement;t!==e.parentNode&&t.appendChild(e),this._ifPopup((function(i){"static"===getComputedStyle(t).position&&(t.style.position="relative");var n=!0===i?"popup_right":"popup_"+i;["popup_top","popup_bottom","popup_left","popup_right"].forEach((function(t){t===n?e.classList.add(t):e.classList.remove(t)})),e.classList.add(n)}))}},{key:"_setHSLA",value:function(t,e,i,n,r){r=r||{};var s=this.colour,o=s.hsla;[t,e,i,n].forEach((function(t,e){(t||0===t)&&(o[e]=t)})),s.hsla=o,this._updateUI(r),this.onChange&&!r.silent&&this.onChange(s)}},{key:"_updateUI",value:function(t){if(this.domElement){t=t||{};var e=this.colour,i=e.hsla,n="hsl("+360*i[0]+", 100%, 50%)",r=e.hslString,s=e.hslaString,o=this._domH,a=this._domSL,l=this._domA,h=nd(".picker_selector",o),c=nd(".picker_selector",a),u=nd(".picker_selector",l);y(0,h,i[0]),this._domSL.style.backgroundColor=this._domH.style.color=n,y(0,c,i[1]),v(0,c,1-i[2]),a.style.color=r,v(0,u,1-i[3]);var d=r,f=d.replace("hsl","hsla").replace(")",", 0)"),p="linear-gradient("+[d,f]+")";if(this._domA.style.background=p+", linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%) 0 0 / 2em 2em,\n linear-gradient(45deg, lightgrey 25%, white 25%, white 75%, lightgrey 75%) 1em 1em / 2em 2em",!t.fromEditor){var g=this.settings.editorFormat,m=this.settings.alpha,b=void 0;switch(g){case"rgb":b=e.printRGB(m);break;case"hsl":b=e.printHSL(m);break;default:b=e.printHex(m)}this._domEdit.value=b}this._domSample.style.color=s}function y(t,e,i){e.style.left=100*i+"%"}function v(t,e,i){e.style.top=100*i+"%"}}},{key:"_ifPopup",value:function(t,e){this.settings.parent&&this.settings.popup?t&&t(this.settings.popup):e&&e()}},{key:"_toggleDOM",value:function(t){var e=this.domElement;if(!e)return!1;var i=t?"":"none",n=e.style.display!==i;return n&&(e.style.display=i),n}}]),t}(),ad=document.createElement("style");function ld(t){if(hd[t])return hd[t];if(hd["chr"+t]){const e=hd["chr"+t];return hd[t]=e,e}{const e="rgb("+Math.round(255*Math.random()).toString(10)+","+Math.round(255*Math.random()).toString(10)+","+Math.round(255*Math.random()).toString(10)+")";return hd[t]=e,e}}ad.textContent='.picker_wrapper.no_alpha .picker_alpha{display:none}.picker_wrapper.no_editor .picker_editor{position:absolute;z-index:-1;opacity:0}.picker_wrapper.no_cancel .picker_cancel{display:none}.layout_default.picker_wrapper{display:flex;flex-flow:row wrap;justify-content:space-between;align-items:stretch;font-size:10px;width:25em;padding:.5em}.layout_default.picker_wrapper input,.layout_default.picker_wrapper button{font-size:1rem}.layout_default.picker_wrapper>*{margin:.5em}.layout_default.picker_wrapper::before{content:"";display:block;width:100%;height:0;order:1}.layout_default .picker_slider,.layout_default .picker_selector{padding:1em}.layout_default .picker_hue{width:100%}.layout_default .picker_sl{flex:1 1 auto}.layout_default .picker_sl::before{content:"";display:block;padding-bottom:100%}.layout_default .picker_editor{order:1;width:6.5rem}.layout_default .picker_editor input{width:100%;height:100%}.layout_default .picker_sample{order:1;flex:1 1 auto}.layout_default .picker_done,.layout_default .picker_cancel{order:1}.picker_wrapper{box-sizing:border-box;background:#f2f2f2;box-shadow:0 0 0 1px silver;cursor:default;font-family:sans-serif;color:#444;pointer-events:auto}.picker_wrapper:focus{outline:none}.picker_wrapper button,.picker_wrapper input{box-sizing:border-box;border:none;box-shadow:0 0 0 1px silver;outline:none}.picker_wrapper button:focus,.picker_wrapper button:active,.picker_wrapper input:focus,.picker_wrapper input:active{box-shadow:0 0 2px 1px #1e90ff}.picker_wrapper button{padding:.4em .6em;cursor:pointer;background-color:#f5f5f5;background-image:linear-gradient(0deg, gainsboro, transparent)}.picker_wrapper button:active{background-image:linear-gradient(0deg, transparent, gainsboro)}.picker_wrapper button:hover{background-color:#fff}.picker_selector{position:absolute;z-index:1;display:block;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%);border:2px solid #fff;border-radius:100%;box-shadow:0 0 3px 1px #67b9ff;background:currentColor;cursor:pointer}.picker_slider .picker_selector{border-radius:2px}.picker_hue{position:relative;background-image:linear-gradient(90deg, red, yellow, lime, cyan, blue, magenta, red);box-shadow:0 0 0 1px silver}.picker_sl{position:relative;box-shadow:0 0 0 1px silver;background-image:linear-gradient(180deg, white, rgba(255, 255, 255, 0) 50%),linear-gradient(0deg, black, rgba(0, 0, 0, 0) 50%),linear-gradient(90deg, #808080, rgba(128, 128, 128, 0))}.picker_alpha,.picker_sample{position:relative;background:linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%) 0 0/2em 2em,linear-gradient(45deg, lightgrey 25%, white 25%, white 75%, lightgrey 75%) 1em 1em/2em 2em;box-shadow:0 0 0 1px silver}.picker_alpha .picker_selector,.picker_sample .picker_selector{background:none}.picker_editor input{font-family:monospace;padding:.2em .4em}.picker_sample::before{content:"";position:absolute;display:block;width:100%;height:100%;background:currentColor}.picker_arrow{position:absolute;z-index:-1}.picker_wrapper.popup{position:absolute;z-index:2;margin:1.5em}.picker_wrapper.popup,.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{background:#f2f2f2;box-shadow:0 0 10px 1px rgba(0,0,0,.4)}.picker_wrapper.popup .picker_arrow{width:3em;height:3em;margin:0}.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{content:"";display:block;position:absolute;top:0;left:0;z-index:-99}.picker_wrapper.popup .picker_arrow::before{width:100%;height:100%;-webkit-transform:skew(45deg);transform:skew(45deg);-webkit-transform-origin:0 100%;transform-origin:0 100%}.picker_wrapper.popup .picker_arrow::after{width:150%;height:150%;box-shadow:none}.popup.popup_top{bottom:100%;left:0}.popup.popup_top .picker_arrow{bottom:0;left:0;-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}.popup.popup_bottom{top:100%;left:0}.popup.popup_bottom .picker_arrow{top:0;left:0;-webkit-transform:rotate(90deg) scale(1, -1);transform:rotate(90deg) scale(1, -1)}.popup.popup_left{top:0;right:100%}.popup.popup_left .picker_arrow{top:0;right:0;-webkit-transform:scale(-1, 1);transform:scale(-1, 1)}.popup.popup_right{top:0;left:100%}.popup.popup_right .picker_arrow{top:0;left:0}',document.documentElement.firstElementChild.appendChild(ad),od.StyleElement=ad;const hd={chrX:"rgb(204, 153, 0)",chrY:"rgb(153, 204, 0",chrUn:"rgb(50, 50, 50)",chr1:"rgb(80, 80, 255)",chrI:"rgb(139, 155, 187)",chr2:"rgb(206, 61, 50)",chrII:"rgb(206, 61, 50)",chr2a:"rgb(216, 71, 60)",chr2b:"rgb(226, 81, 70)",chr3:"rgb(116, 155, 88)",chrIII:"rgb(116, 155, 88)",chr4:"rgb(240, 230, 133)",chrIV:"rgb(240, 230, 133)",chr5:"rgb(70, 105, 131)",chr6:"rgb(186, 99, 56)",chr7:"rgb(93, 177, 221)",chr8:"rgb(128, 34, 104)",chr9:"rgb(107, 215, 107)",chr10:"rgb(213, 149, 167)",chr11:"rgb(146, 72, 34)",chr12:"rgb(131, 123, 141)",chr13:"rgb(199, 81, 39)",chr14:"rgb(213, 143, 92)",chr15:"rgb(122, 101, 165)",chr16:"rgb(228, 175, 105)",chr17:"rgb(59, 27, 83)",chr18:"rgb(205, 222, 183)",chr19:"rgb(97, 42, 121)",chr20:"rgb(174, 31, 99)",chr21:"rgb(231, 199, 111)",chr22:"rgb(90, 101, 94)",chr23:"rgb(204, 153, 0)",chr24:"rgb(153, 204, 0)",chr25:"rgb(51, 204, 0)",chr26:"rgb(0, 204, 51)",chr27:"rgb(0, 204, 153)",chr28:"rgb(0, 153, 204)",chr29:"rgb(10, 71, 255)",chr30:"rgb(71, 117, 255)",chr31:"rgb(255, 194, 10)",chr32:"rgb(255, 209, 71)",chr33:"rgb(153, 0, 51)",chr34:"rgb(153, 26, 0)",chr35:"rgb(153, 102, 0)",chr36:"rgb(128, 153, 0)",chr37:"rgb(51, 153, 0)",chr38:"rgb(0, 153, 26)",chr39:"rgb(0, 153, 102)",chr40:"rgb(0, 128, 153)",chr41:"rgb(0, 51, 153)",chr42:"rgb(26, 0, 153)",chr43:"rgb(102, 0, 153)",chr44:"rgb(153, 0, 128)",chr45:"rgb(214, 0, 71)",chr46:"rgb(255, 20, 99)",chr47:"rgb(0, 214, 143)",chr48:"rgb(20, 255, 177)"};class cd{constructor(t){this.tracks=[],this.chordSets=[]}addChordSet(t){this.chordSets=this.chordSets.filter((e=>e.name!==t.name)),this.chordSets.push(t);let e=this.tracks.find((e=>t.trackName===e.name));e&&(e.chordSets=e.chordSets.filter((e=>e.name!==t.name)),e.chordSets.push(t)),e||(e=new ud(t),this.tracks.push(e))}clearChords(){this.tracks=[],this.chordSets=[]}getTrack(t){return this.tracks.find((e=>t===e.name))}getChordSet(t){return this.chordSets.find((e=>t===e.name))}}class ud{constructor(t){this.name=t.trackName,this.color=t.trackColor,this.visible=!0,this.chordSets=[t],this.id=("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)}get chords(){if(1===this.chordSets.length)return this.chordSets[0].chords;const t=[];for(let e of this.chordSets)for(let i of e.chords)t.push(i);return t}}const dd=Math.exp(5);class fd{static isInstalled(){return void 0!==window.JBrowseReactCircularGenomeView&&void 0!==window.React&&void 0!==window.ReactDOM}constructor(t,e){if(e=e||{},this.config=e,fd.isInstalled()){this.parent=t,this.groupByTrack=!0===e.groupByTrack,this.chordManager=new cd(e);const i=document.createElement("div");i.className="igv-circview-container",t.appendChild(i),this.createControls(i),this.resetControlPanel();const n=document.createElement("div");n.className="igv-circview-circular-genome-view",i.appendChild(n),this.container=n,e.assembly&&this.setAssembly(e.assembly),this.width=e.width||500,this.height=e.height||500,this.setSize(this.width,this.height)}else console.error("JBrowse circular view is not installed")}createControls(t){const e=document.createElement("div");e.className="igv-circview-toolbar",t.appendChild(e),this.toolbar=e;const i=document.createElement("div");i.className="igv-circview-track-panel",t.appendChild(i),this.controlPanel=i,this.controlPanel.style.display="none";const n=document.createElement("div");n.className="igv-circview-toolbar-button-container",this.toolbar.appendChild(n),this.showControlsButton=document.createElement("div"),this.showControlsButton.className="igv-circview-button",n.appendChild(this.showControlsButton),this.showControlsButton.innerText="none"===this.controlPanel.style.display?"Show Controls":"Hide Controls",this.showControlsButton.addEventListener("click",(t=>{this.controlPanel.querySelectorAll("div").length>0&&("none"===this.controlPanel.style.display?(this.controlPanel.style.display="flex",t.target.innerText="Hide Controls"):(this.controlPanel.style.display="none",t.target.innerText="Show Controls"))}));let r=document.createElement("div");r.className="igv-circview-button",n.appendChild(r),r.innerText="Clear All",r.addEventListener("click",(()=>{this.clearChords()})),!1!==this.config.showCloseButton&&(r=document.createElement("div"),r.className="igv-circview-button",n.appendChild(r),r.innerText="Close",r.addEventListener("click",(()=>{this.visible=!1})))}resetControlPanel(){this.controlPanel.innerHTML="",this.controlPanel.appendChild(this.createGroupByCB());const t=this.groupByTrack?this.chordManager.tracks:this.chordManager.chordSets;for(let e of t)this.addToControlPanel(e)}createGroupByCB(){const t=document.createElement("input");t.type="checkbox",t.id="groupByCB",t.style.width="1.4em",t.style.height="1.4em",t.checked=this.groupByTrack,t.onclick=t=>{this.groupByTrack=t.target.checked,this.resetControlPanel(),this.render()};const e=document.createElement("label");e.for="groupByCB",e.innerText="Group by track",e.style.color="black",e.style.paddingLeft="10px";const i=document.createElement("div");return i.style.width="100%",i.style.paddingTop="5px",i.style.paddingBottom="5px",i.style.background="rgb(216, 230, 234)",i.appendChild(t),i.appendChild(e),i}addToControlPanel(t){const e=document.createElement("div");this.controlPanel.appendChild(e);const i=document.createElement("div");i.className="igv-circview-button",e.appendChild(i),i.innerText=!0===t.visible?"Hide":"Show",i.addEventListener("click",(e=>{!0===t.visible?(this.hideChordSet(t.name),e.target.innerText="Show"):(this.showChordSet(t.name),e.target.innerText="Hide")}));const n=document.createElement("input"),r=t=>200*Math.log(t*dd),s=document.createElement("div");s.className="igv-circview-button",s.innerHTML="    ",e.appendChild(s),s.style.backgroundColor=pd(t.color,1);const o={parent:s,popup:"right",editorFormat:"rgb",color:t.color,onChange:({rgbaString:e})=>{s.style.backgroundColor=pd(e,1),this.setColor(t.name,e),n.value=r(gd(t.color))}},a=new od(o);n.setAttribute("title","Adjust transparency of arcs"),n.type="range",n.style.width="100px",n.style.marginRight="10px",n.setAttribute("class","range"),n.setAttribute("min","0"),n.setAttribute("max","1000"),n.value=r(gd(t.color)),n.oninput=()=>{const e=(i=n.value,Math.exp(i/200)/dd);var i;this.setColor(t.name,pd(t.color,e)),a.setColor(t.color)},e.appendChild(n);const l=document.createElement("div");l.style.color="black",e.appendChild(l),l.innerText=l.title=t.name}setAssembly(t){const e=this.genomeId||yd();if(this.genomeId===e)return;this.chordManager.clearChords(),this.genomeId=e,this.chrNames=new Set(t.chromosomes.map((t=>md(t.name))));const i=[],n=[];for(let e of t.chromosomes){const t=md(e.name);n.push(e.color||ld(t)),i.push({refName:t,uniqueId:t,start:0,end:e.bpLength})}this.assembly={name:t.name,sequence:{trackId:e,type:"ReferenceSequenceTrack",adapter:{type:"FromConfigSequenceAdapter",features:i}},refNameColors:n},this.render()}addChords(t,e={}){const i=e.name||e.track||"*",n=i.split(" ")[0].replaceAll("%20"," "),r={name:i.replaceAll("%20"," "),trackName:n,chords:t,color:e.color||"black",trackColor:e.trackColor||e.color||"black",visible:!0,id:e.id||yd()};this.chordManager.addChordSet(r),this.resetControlPanel(),this.render()}setSize(t,e){if(e=e||t,this.width=t,this.height=e,this.viewState){const i=this.viewState.session.view;i.setWidth(t),i.setHeight(e),i.setBpPerPx(i.minBpPerPx)}}getSize(){return Math.min(this.width,this.height)}clearChords(){this.chordManager.clearChords(),this.resetControlPanel(),this.render()}clearSelection(){this.viewState.pluginManager.rootModel.session.clearSelection()}show(){this.parent.style.display="block"}hide(){this.parent.style.display="none"}get visible(){return"none"!==this.parent.style.display}set visible(t){this.parent.style.display=t?"block":"none"}hideChordSet(t){let e=this.getChordSet(t);e?(e.visible=!1,this.render()):console.warn(`No track with name: ${name}`)}showChordSet(t){let e=this.getChordSet(t);e?(e.visible=!0,this.render()):console.warn(`No track with name: ${t}`)}deleteTrack(t){let e=this.tracks.findIndex((e=>t===e.name));e>=0&&this.tracks.splice(e,1),this.render()}getChordSet(t){return this.groupByTrack?this.chordManager.getTrack(t):this.chordManager.getChordSet(t)}setColor(t,e){const i=this.getChordSet(t);if(i){i.color=e;const t=i.id;for(let i of this.viewState.config.tracks)if(t===i.trackId){i.displays[0].renderer.strokeColor.set(e);break}}}render(){const{createViewState:t,JBrowseCircularGenomeView:e}=JBrowseReactCircularGenomeView;ReactDOM.unmountComponentAtNode(this.container);const i=(this.groupByTrack?this.chordManager.tracks:this.chordManager.chordSets).filter((t=>t.visible)),n=[],r=[];for(let t of i)n.push({trackId:t.id,name:t.name,assemblyNames:["forIGV"],type:"VariantTrack",adapter:{type:"FromConfigAdapter",features:t.chords}}),r.push(t.color);this.viewState=t({assembly:this.assembly,tracks:n});for(let t=0;t div {\n margin: 4px;\n}\n\n.igv-circview-track-panel {\n z-index: 1024;\n position: absolute;\n top: 33px;\n left: 0;\n width: 100%;\n height: fit-content;\n border-bottom-style: solid;\n border-bottom-color: dimgray;\n border-bottom-width: thin;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n}\n.igv-circview-track-panel > div {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-circview-track-panel > div > div {\n margin: 4px;\n}\n\n.igv-circview-swatch-button {\n cursor: pointer;\n padding: 5px;\n width: 8px;\n height: 8px;\n border: 1px solid #8d8b8b;\n border-radius: 16px;\n}\n\n.igv-circview-button {\n cursor: pointer;\n padding: 5px;\n color: #444;\n vertical-align: middle;\n text-align: center;\n font-family: "Open Sans", sans-serif;\n font-size: 12px;\n border: 1px solid #8d8b8b;\n border-radius: 4px;\n background: #efefef;\n box-shadow: 0 0 5px -1px rgba(0, 0, 0, 0.2);\n}\n\n.igv-circview-button:hover {\n background: #efefef;\n box-shadow: 0 0 5px -1px rgba(0, 0, 0, 0.6);\n}\n\n.igv-circview-button:active {\n color: #007bff;\n box-shadow: 0 0 5px -1px rgba(0, 0, 0, 0.6);\n}\n\n/*# sourceMappingURL=circular-view.css.map */\n',document.head.insertBefore(t,document.head.childNodes[document.head.childNodes.length-1])}()}const vd=t=>t.startsWith("chr")?t.substring(3):t;function wd(t){const e=[],i=[];for(let n of t.wgChromosomeNames){const r=t.getChromosome(n);i.push(Zd(r.name)),e.push({name:r.name,bpLength:r.bpLength})}return e}function _d(t,e,i,n){const r=e.color||"rgb(0,0,255)",s=xo.addAlpha("all"===i.chr?r:Zd(i.chr),n),o=xo.addAlpha(r,n),a=e.name.replaceAll(" ","%20"),l="all"===i.chr?a:`${a} ${i.chr}:${i.start}-${i.end}`;e.browser.circularView.addChords(t,{track:l,color:s,trackColor:o}),e.browser.circularViewVisible||(e.browser.circularViewVisible=!0)}class xd{constructor(t,{minTLENPercentile:e,maxTLENPercentile:i}){this.totalCount=0,this.frCount=0,this.rfCount=0,this.ffCount=0,this.sumF=0,this.sumF2=0,this.lp=void 0===e?.1:e,this.up=void 0===i?99.5:i,this.isizes=[],this.compute(t)}compute(t){for(let n of t)if(n.isProperPair()){var e=Math.abs(n.fragmentLength);this.sumF+=e,this.sumF2+=e*e,this.isizes.push(e);var i=n.pairOrientation;if("string"==typeof i&&4===i.length)switch(""+i.charAt(0)+i.charAt(2)){case"FF":case"RR":this.ffCount++;break;case"FR":this.frCount++;break;case"RF":this.rfCount++}this.totalCount++}this.ffCount/this.totalCount>.9?this.orienation="ff":this.frCount/this.totalCount>.9?this.orienation="fr":this.rfCount/this.totalCount>.9&&(this.orienation="rf"),this.minTLEN=0===this.lp?0:kd(this.isizes,this.lp),this.maxTLEN=kd(this.isizes,this.up)}}function kd(t,e){if(0!==t.length){var i=Math.floor(t.length*(e/100));return t.sort((function(t,e){return t-e})),t[i]}}const Sd={getTissueInfo:function(t,e){let i=(e=e||"https://gtexportal.org/rest/v1")+"/dataset/tissueInfo?datasetId="+(t=t||"gtex_v8");return zo.loadJson(i,{})},trackConfiguration:function(t,e){return{type:"eqtl",sourceType:"gtex-ws",url:(e=e||"https://gtexportal.org/rest/v1")+"/association/singleTissueEqtlByLocation",tissueSiteDetailId:t.tissueSiteDetailId,name:t.tissueSiteDetailId.split("_").join(" "),visibilityWindow:25e4}}};function Cd(t,e,i){let n=(t.start-e)/i,r=(t.end-e)/i,s=r-n;return s<3&&(s=3,n-=1.5),{px:n,px1:r,pw:s}}function Ad(t,e,i,n,r,s){try{r.save(),r.fillStyle=this.color,r.strokeStyle=this.color;const n=this.getColorForFeature(t);let o,a;r.fillStyle=n,r.strokeStyle=n,"SQUISHED"===this.displayMode&&void 0!==t.row?(o=this.featureHeight/2,a=this.margin+this.squishedRowHeight*t.row):"EXPANDED"===this.displayMode&&void 0!==t.row?(o=this.featureHeight,a=this.margin+this.expandedRowHeight*t.row):(o=this.featureHeight,a=this.margin);const l=s.pixelWidth,h=a+o/2,c=o/2,u=h-c/2,d=t.exons?t.exons.length:0,f=Cd(t,e,i),p=this.arrowSpacing,g="+"===t.strand?1:"-"===t.strand?-1:0;if(0===d){const t=Math.max(0,f.px),e=Math.min(l,f.px1),i=e-t;if(r.fillRect(t,a,i,o),0!==g){r.fillStyle="white",r.strokeStyle="white";for(let i=t+p/2;il)break;if(d.utr)r.fillRect(m,u,y,c);else if(d.cdStart&&(f=Math.round((d.cdStart-e)/i),r.fillRect(m,u,f-m,c),y-=f-m,m=f),d.cdEnd&&(f=Math.round((d.cdEnd-e)/i),r.fillRect(f,u,b-f,c),y-=b-f,b=f),y=Math.max(y,1),r.fillRect(m,a,y,o),y>p+5&&0!==g){r.fillStyle="white",r.strokeStyle="white";for(let t=m+p/2;tv||p)&&(o.rowLastLabelX[e.row]=y,"y"===o.axis?(t.save(),na.labelTransformWithContext(t,c),na.fillText(t,a,c,u,g,h),t.restore()):na.fillText(t,a,c,u,g,h))}finally{t.restore()}}const Id=new Set(["nonsense","missense","stop-loss","frameshift","cds-indel"]),Ed=new Set(["coding-synon"]),Md=new Set(["splice-3","splice-5"]),Rd=new Set(["untranslated-5","untranslated-3"]);function Ld(t,e,i,n,r){var s,o,a,l,h=Cd(t,e,i),c=this.margin,u=this.snpColors.length;switch(s="squished"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight,this.colorBy){case"function":l=t.func.split(",").map((function(t){return Id.has(t)||Md.has(t)?u-1:Ed.has(t)?u-2:Rd.has(t)?u-3:0})),o=l.reduce((function(t,e){return Math.max(t,e)}));break;case"class":o="deletion"===(a=t.class)?u-1:"mnp"===a?u-2:"microsatellite"===a||"named"===a?u-3:0}r.fillStyle=this.snpColors[o],r.fillRect(h.px,c,h.pw,s)}function Bd(t,e,i,n,r){const s="EXPANDED"===this.displayMode?this.expandedRowHeight:this.squishedRowHeight;let o=this.margin;"COLLAPSED"!==this.displayMode&&void 0!==t.row&&(o+=t.row*s);const a=o+.5*s,l=a-.5*s,h=a+.5*s,c=Math.round((t.junction_left-e)/i),u=Math.round((t.junction_right-e)/i);r.beginPath(),r.moveTo(c,a),r.bezierCurveTo(c,l,u,l,u,a),r.lineWidth=1+Math.log(t.num_junction_reads)/Math.log(2),r.strokeStyle="blue",r.stroke();const d=t.spanning_frag_coords;for(let t=0;te&&(e=i.row);return this.margin+(e+1)*("SQUISHED"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight)}}draw(t){const e=t.features,i=t.context,n=t.bpPerPixel,r=t.bpStart,s=t.pixelWidth,o=t.pixelHeight,a=r+s*n+1;if(this.config.isMergedTrack||na.fillRect(i,0,t.pixelTop,s,o,{fillStyle:"rgb(255, 255, 255)"}),e){const l=[];t.rowLastX=[],t.rowLastLabelX=[];for(let i of e)if(i.start>r&&i.enda)break;const e="COLLAPSED"===this.displayMode?0:s.row;t.drawLabel=t.labelAllFeatures||h>10;const l=Math.ceil((s.end-r)/n),u=c[e];if(!u||l>u){this.render.call(this,s,r,n,o,i,t);const a=Math.floor((s.start-r)/n);u&&a-u<=0&&(i.globalAlpha=.5,na.strokeLine(i,a,0,a,o,{strokeStyle:"rgb(255, 255, 255)"}),i.globalAlpha=1),c[e]=l}}}else console.log("No feature list")}clickedFeatures(t){const e=t.y-this.margin,i=super.clickedFeatures(t);let n;switch(this.displayMode){case"SQUISHED":n=Math.floor(e/this.squishedRowHeight);break;case"EXPANDED":n=Math.floor(e/this.expandedRowHeight);break;default:n=void 0}return i.filter((function(t){return void 0===n||void 0===t.row||n===t.row}))}popupData(t,e){void 0===e&&(e=this.clickedFeatures(t));const i=t.genomicLocation,n=[];for(let t of e){const e=t._f||t,r="function"==typeof e.popupData?e.popupData(i):this.extractPopupData(e);if(r){n.length>0&&n.push("

");const s=this.infoURL||this.config.infoURL;for(let e of r)if(n.push(e),s&&e.name&&"name"===e.name.toLowerCase()&&e.value&&ji(e.value)&&!e.value.startsWith("<")){const i=s.replace("$$",t.name);e.value=`${e.value}`}const o="gff"===this.config.format||"gff3"===this.config.format||"gtf"===this.config.format;if(e.exons)for(let t=0;t=r.start&&i<=r.end){const i=o?r.number:"-"===e.strand?e.exons.length-t:t+1;i&&(n.push("
"),n.push({name:"Exon Number",value:i}));break}}}}return n}menuItemList(){const t=[];if(this.render===Ld){t.push("
");for(let e of["function","class"])t.push({object:fe(zi("Color by "+e,e===this.colorBy)),click:()=>{this.colorBy=e,this.trackView.repaintViews()}})}t.push("
");for(let e of["COLLAPSED","SQUISHED","EXPANDED"]){const i={COLLAPSED:"Collapse",SQUISHED:"Squish",EXPANDED:"Expand"};t.push({object:fe(zi(i[e],e===this.displayMode)),click:()=>{this.displayMode=e,this.config.displayMode=e,this.trackView.checkContentHeight(),this.trackView.repaintViews()}})}return t}contextMenuItemList(t){const e=this.clickedFeatures(t);if(void 0===e||0===e.length)return;e.length>1&&e.sort(((t,e)=>e.end-e.start-(t.end-t.start)));const i=e[0];if(i.end-i.start<=1e6){const t=[{label:"View feature sequence",click:async()=>{let t=await this.browser.genome.getSequence(i.chr,i.start,i.end);t?"-"===i.strand&&(t=Ra(t)):t="Unknown sequence",this.browser.alert.present(t)}}];return ba()&&void 0!==navigator.clipboard&&t.push({label:"Copy feature sequence",click:async()=>{let t=await this.browser.genome.getSequence(i.chr,i.start,i.end);t?"-"===i.strand&&(t=Ra(t)):t="Unknown sequence";try{await navigator.clipboard.writeText(t)}catch(t){console.error(t),this.browser.alert.present(`error copying sequence to clipboard ${t}`)}}}),t.push("
"),t}}description(){if(Ld===this.render){let t=""+this.name+"
";return t+="Color By Function:
",t+='Red: Coding-Non-Synonymous, Splice Site
',t+='Green: Coding-Synonymous
',t+='Blue: Untranslated
',t+='Black: Intron, Locus, Unknown

',t+="Color By Class:
",t+='Red: Deletion
',t+='Green: MNP
',t+='Blue: Microsatellite, Named
',t+='Black: Indel, Insertion, SNP',t+="",t}return super.description()}getColorForFeature(t){let e;if(this.altColor&&"-"===t.strand)e="function"==typeof this.altColor?this.altColor(t):this.altColor;else if(this.color)e="function"==typeof this.color?this.color(t):this.color;else if(this.colorBy){const i=t.getAttributeValue?t.getAttributeValue(this.colorBy):t[this.colorBy];e=this.colorTable.getColor(i)}else t.color&&(e=t.color);if(e||(e="rgb(0, 0, 150)"),t.alpha&&1!==t.alpha)e=xo.addAlpha(e,t.alpha);else if(this.useScore&&t.score&&!Number.isNaN(t.score)){const i=function(t,e,i){const n=(e-t)/9,r=Math.floor((i-t)/n);return Math.min(1,.2+.8*r/9)}(this.config.min?this.config.min:this.viewLimitMin?this.viewLimitMin:0,this.config.max?this.config.max:this.viewLimitMax?this.viewLimitMax:1e3,t.score);t.alpha=i,e=xo.addAlpha(e,i)}return e}dispose(){this.trackView=void 0}}class Fd{constructor(t){this.config=t,this.browser=t.browser,this.columnFormat=t.columnFormat,this.tableRowSelectionList=[],this.tableDOM=_e.div({class:"igv-roi-table"}),t.parent.appendChild(this.tableDOM),this.headerDOM=t,this.tableColumnTitles=this.tableDOM,this.tableRowContainer=this.tableDOM,this.footerDOM=t.gotoButtonHandler}set headerDOM({browser:t,parent:e,headerTitle:i,dismissHandler:n}){const r=_e.div();this.tableDOM.appendChild(r);const s=_e.div();r.appendChild(s),s.innerHTML=i;const o=_e.div();r.appendChild(o),o.appendChild(_i.createIcon("times")),this.boundDismissHandler=function(t){t.stopPropagation(),n()}.bind(this),o.addEventListener("click",this.boundDismissHandler);const{y:a}=t.root.getBoundingClientRect(),{y:l}=e.getBoundingClientRect(),h=-(l-a);Ci(this.tableDOM,r,{minX:0,minY:h}),this.tableDOM.style.display="none",this._headerDOM=r}set tableColumnTitles(t){const e=_e.div({class:"igv-roi-table-column-titles"});t.appendChild(e);for(const{label:t,width:i}of this.columnFormat){const n=_e.div();e.appendChild(n),n.style.width=i,n.innerText=t}this._tableColumnTitlesDOM=e}get tableColumnTitles(){return this._tableColumnTitlesDOM}set tableRowContainer(t){const e=_e.div({class:"igv-roi-table-row-container"});t.appendChild(e),this._tableRowContainerDOM=e}get tableRowContainer(){return this._tableRowContainerDOM}set footerDOM(t){const e=_e.div();this.tableDOM.appendChild(e);const i=_e.div({class:"igv-roi-table-button"});e.appendChild(i),i.id="igv-roi-table-view-button",i.textContent="Go To",i.style.pointerEvents="none",this._footerDOM=e,this.gotoButton=i,this.boundGotoButtonHandler=t.bind(this),this.gotoButton.addEventListener("click",this.boundGotoButtonHandler)}tableRowDOMHelper(t){t.addEventListener("mousedown",(e=>{e.stopPropagation(),t.classList.toggle("igv-roi-table-row-selected"),t.classList.contains("igv-roi-table-row-selected")?t.classList.remove("igv-roi-table-row-hover"):t.classList.add("igv-roi-table-row-hover"),this.setTableRowSelectionState(t.classList.contains("igv-roi-table-row-selected"))})),t.addEventListener("mouseover",(e=>{t.classList.contains("igv-roi-table-row-selected")?t.classList.remove("igv-roi-table-row-hover"):t.classList.add("igv-roi-table-row-hover")})),t.addEventListener("mouseout",(e=>{t.classList.remove("igv-roi-table-row-hover")}))}clearTable(){const t=this.tableRowContainer.querySelectorAll(".igv-roi-table-row");for(let e of t)e.remove()}setTableRowSelectionState(t){t?this.tableRowSelectionList.push(1):this.tableRowSelectionList.pop(),this.gotoButton.style.pointerEvents=this.tableRowSelectionList.length>0?"auto":"none"}present(){this.tableDOM.style.left="0px";const{y:t}=this.browser.root.getBoundingClientRect(),{y:e}=this.config.parent.getBoundingClientRect();this.tableDOM.style.top=t-e+"px",this.tableDOM.style.display="flex"}dismiss(){this.tableDOM.style.display="none"}dispose(){this.tableDOM.innerHTML="",this.tableDOM.remove();for(const t of Object.keys(this))this[t]=void 0;document.removeEventListener("click",this.boundDismissHandler)}}class Od extends Fd{constructor(t){super(Object.assign({width:"1024px"},t)),this.descriptionDOM=t}set descriptionDOM(t){if(t.description){let e;e=_e.div({class:"igv-roi-table-description"}),this.tableDOM.insertBefore(e,this.tableColumnTitles),e.style.height="auto",e.innerHTML="BLAT result for query sequence:",e=_e.div({class:"igv-roi-table-description"}),this.tableDOM.insertBefore(e,this.tableColumnTitles),e.style.height="auto",e.style.maxHeight="128px",e.innerHTML=t.description,e=_e.div({class:"igv-roi-table-goto-explainer"}),this.tableDOM.insertBefore(e,this.tableColumnTitles),e.innerHTML="Select one or more rows and click Go To to view the regions"}}tableRowDOM(t){const e=_e.div({class:"igv-roi-table-row"}),i=t.map((t=>isFinite(t)?$i(t):t));for(let t=0;tt.remove())),t.length>0)for(let e of t){const t=this.tableRowDOM(e);this.tableRowContainer.appendChild(t)}}static getColumnFormatConfiguration(){return[{label:"chr",width:"7%"},{label:"start",width:"12%"},{label:"end",width:"12%"},{label:"strand",width:"5%"},{label:"score",width:"5%"},{label:"match",width:"5%"},{label:"mis-match",width:"7%"},{label:"rep. match",width:"7%"},{label:"N's",width:"3%"},{label:"Q gap count",width:"9%"},{label:"Q gap bases",width:"9%"},{label:"T gap count",width:"9%"},{label:"T gap bases",width:"9%"}]}static gotoButtonHandler(t){t.stopPropagation();const e=this.tableDOM.querySelectorAll(".igv-roi-table-row-selected"),i=[];for(const t of e){const e=[];t.querySelectorAll("div").forEach((t=>e.push(t.innerText)));const[n,r,s]=e;i.push(`${n}:${r}-${s}`)}for(const t of this.tableDOM.querySelectorAll(".igv-roi-table-row"))t.classList.remove("igv-roi-table-row-selected");this.setTableRowSelectionState(!1),this.browser.search(i.join(" "))}}const Dd="https://igv.org/services/blatUCSC.php";async function Pd({url:t,userSeq:e,db:i}){t=t||Dd;const n=await async function(t="",e,i){const n=new URLSearchParams;n.append("userSeq",e),n.append("db",i);return(await fetch(t,{method:"post",body:n})).json()}(t,e,i);return n.fields,n.blat.map(Wl)}const zd=25e3;class Ud extends Nd{constructor(t,e){super(t,e),this.name||(this.name="Blat Results"),this.sequence=t.sequence,this.table=void 0}openTableView(){if(void 0===this.table){const t=this.config.features.map((t=>[t.chr,t.start+1,t.end,t.strand,t.score,t.matches,t.misMatches,t.repMatches,t.nCount,t.qNumInsert,t.qBaseInsert,t.tNumInsert,t.tBaseInsert])),e={browser:this.browser,parent:this.browser.parent,headerTitle:this.config.title,description:this.sequence,dismissHandler:()=>{this.table.dismiss(),this.table.dispose(),this.table=void 0},columnFormat:Od.getColumnFormatConfiguration(),gotoButtonHandler:Od.gotoButtonHandler};this.table=new Od(e),this.table.renderTable(t)}this.table.present()}menuItemList(){const t=super.menuItemList();return t.push("
"),t.push({label:"Open table view",click:()=>this.openTableView()}),t}dispose(){super.dispose(),this.table&&this.table.popover.parentElement.removeChild(this.table.popover)}}async function Vd({sequence:t,browser:e,name:i,title:n}){if(t.length>zd)return void e.alert.present(`Sequence size exceeds maximum allowed length (${t.length} > 25000)`);const r=e.genome.id,s=e.config.blatServerURL;try{const o={type:"blat",name:i||"blat results",title:n||"blat results",sequence:t,altColor:"rgb(176, 176, 236)",color:"rgb(236, 176, 176)",features:await Pd({url:s,userSeq:t,db:r})};(await e.loadTrack(o)).openTableView()}catch(t){e.alert.present(`Error performing blat search: ${t}`)}}const Hd="rgb(185, 185, 185)";class jd extends ch{static defaults={alleleFreqThreshold:.2,visibilityWindow:3e4,showCoverage:!0,showAlignments:!0,viewAsPairs:!1,pairsSupported:!0,showSoftClips:!1,showAllBases:!1,showInsertions:!0,showMismatches:!0,height:300,coverageTrackHeight:50};constructor(t,e){super(t,e)}init(t){this.type="alignment",this.featureSource=new ju(t,this.browser),this.coverageTrack=new $d(t,this),this.alignmentTrack=new qd(t,this),super.init(t),this.alignmentTrack.setTop(this.coverageTrack,this.showCoverage),this.showAlignments||(this._height=this.coverageTrackHeight),t.sort&&(Array.isArray(t.sort)?this.assignSort(t.sort[0]):this.assignSort(t.sort))}set height(t){this._height=t,this.showAlignments&&(this.alignmentTrack.height=this.showCoverage?t-this.coverageTrackHeight:t)}get height(){return this._height}get minTemplateLength(){const t=void 0!==this.config.minTLEN?this.config.minTLEN:this.config.minFragmentLength;return void 0!==t?t:this._pairedEndStats?this._pairedEndStats.minTLEN:0}get maxTemplateLength(){const t=void 0!==this.config.maxTLEN?this.config.maxTLEN:this.config.maxFragmentLength;return void 0!==t?t:this._pairedEndStats?this._pairedEndStats.maxTLEN:1e3}sort(t){t=this.assignSort(t);for(let e of this.trackView.viewports)if(e.containsPosition(t.chr,t.position)){const i=e.cachedFeatures;i&&(i.sortRows(t),e.repaint())}}assignSort(t){if(t.locus){const e=function(t){const e=t.split(":"),i=e[1].split("-"),n={chr:e[0],start:Number.parseInt(i[0].replace(/,/g,""))-1};return i.length>1?n.end=Number.parseInt(i[1].replace(/,/g,"")):n.end=n.start+1,n}(t.locus);t.chr=e.chr,t.position=e.start}else t.position--;return t.direction="ASC"===t.direction||!0===t.direction,t.chr=this.browser.genome.getChromosomeName(t.chr),this.sortObject=t,this.sortObject}async getFeatures(t,e,i,n,r){const s=await this.featureSource.getAlignments(t,e,i);if(s.paired&&!this._pairedEndStats&&!this.config.maxFragmentLength){const t=new xd(s.alignments,this.config);t.totalCount>99&&(this._pairedEndStats=t)}s.alignments=void 0;const o=this.sortObject;return o&&o.chr===t&&o.position>=e&&o.position<=i&&s.sortRows(o),s}computePixelHeight(t){return(this.showCoverage?this.coverageTrackHeight:0)+(this.showAlignments?this.alignmentTrack.computePixelHeight(t):0)}draw(t){na.fillRect(t.context,0,t.pixelTop,t.pixelWidth,t.pixelHeight,{fillStyle:"rgb(255, 255, 255)"}),!0===this.showCoverage&&this.coverageTrackHeight>0?(this.trackView.axisCanvas.style.display="block",this.coverageTrack.draw(t)):this.trackView.axisCanvas.style.display="none",!0===this.showAlignments&&(this.alignmentTrack.setTop(this.coverageTrack,this.showCoverage),this.alignmentTrack.draw(t))}paintAxis(t,e,i){this.coverageTrack.paintAxis(t,e,this.coverageTrackHeight)}contextMenuItemList(t){return this.alignmentTrack.contextMenuItemList(t)}popupData(t){return!0===this.showCoverage&&t.y>=this.coverageTrack.top&&t.y=this.coverageTrack.top&&t.y=this.coverageTrack.top&&t.y");const e=fe('
');e.text("Color by:"),t.push({name:void 0,object:e,click:void 0,init:void 0});const i=[{key:"strand",label:"read strand"}];this.alignmentTrack.hasPairs&&(i.push({key:"firstOfPairStrand",label:"first-of-pair strand"}),i.push({key:"pairOrientation",label:"pair orientation"}),i.push({key:"tlen",label:"insert size (TLEN)"}),i.push({key:"unexpectedPair",label:"pair orientation & insert size (TLEN)"}));const n="tag"+(this.alignmentTrack.colorByTag?" ("+this.alignmentTrack.colorByTag+")":"");i.push({key:"tag",label:n});for(let e of i){const i=this.alignmentTrack.colorBy===e.key;t.push(this.colorByCB(e,i))}const r=()=>{if(!this.autoHeight){const t=(this.showCoverage?this.coverageTrackHeight:0)+(this.showAlignments?this.alignmentTrack.height:0);this.trackView.setTrackHeight(t)}};t.push("
"),t.push({object:fe(zi("Show Coverage",this.showCoverage)),click:()=>{this.showCoverage=!this.showCoverage,r(),this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),t.push({object:fe(zi("Show Alignments",this.showAlignments)),click:()=>{this.showAlignments=!this.showAlignments,r(),this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),t.push("
"),t.push({object:fe(zi("Show all bases",this.showAllBases)),click:()=>{this.showAllBases=!this.showAllBases,this.config.showAllBases=this.showAllBases,this.trackView.repaintViews()}}),t.push("
"),t.push({object:fe(zi("Show mismatches",this.showMismatches)),click:()=>{this.showMismatches=!this.showMismatches,this.config.showMismatches=this.showMismatches,this.trackView.repaintViews()}}),t.push({object:fe(zi("Show insertions",this.showInsertions)),click:()=>{this.showInsertions=!this.showInsertions,this.config.showInsertions=this.showInsertions,this.getCachedAlignmentContainers(),this.trackView.repaintViews()}}),t.push({object:fe(zi("Show soft clips",this.showSoftClips)),click:()=>{this.showSoftClips=!this.showSoftClips,this.config.showSoftClips=this.showSoftClips,this.featureSource.setShowSoftClips(this.showSoftClips);const t=this.getCachedAlignmentContainers();for(let e of t)e.setShowSoftClips(this.showSoftClips);this.trackView.repaintViews()}}),this.pairsSupported&&this.alignmentTrack.hasPairs&&(t.push("
"),t.push({object:fe(zi("View as pairs",this.viewAsPairs)),click:()=>{this.viewAsPairs=!this.viewAsPairs,this.config.viewAsPairs=this.viewAsPairs,this.featureSource.setViewAsPairs(this.viewAsPairs);const t=this.getCachedAlignmentContainers();for(let e of t)e.setViewAsPairs(this.viewAsPairs);this.trackView.repaintViews()}})),this.browser.circularView&&(this.alignmentTrack.hasPairs||this.alignmentTrack.hasSupplemental)&&(t.push("
"),this.alignmentTrack.hasPairs&&t.push({label:"Add discordant pairs to circular view",click:()=>{for(let t of this.trackView.viewports)this.addPairedChordsForViewport(t)}}),this.alignmentTrack.hasSupplemental&&t.push({label:"Add split reads to circular view",click:()=>{for(let t of this.trackView.viewports)this.addSplitChordsForViewport(t)}})),t.push("
");const s=fe('
');return s.text("Display mode:"),t.push({name:void 0,object:s,click:void 0,init:void 0}),t.push({object:fe(zi("expand","EXPANDED"===this.alignmentTrack.displayMode)),click:()=>{this.alignmentTrack.displayMode="EXPANDED",this.config.displayMode="EXPANDED",this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),t.push({object:fe(zi("squish","SQUISHED"===this.alignmentTrack.displayMode)),click:()=>{this.alignmentTrack.displayMode="SQUISHED",this.config.displayMode="SQUISHED",this.trackView.checkContentHeight(),this.trackView.repaintViews()}}),t}colorByCB(t,e){return{name:void 0,object:fe(zi(t.label,e)),click:e=>{"tag"!==t.key?t.key===this.alignmentTrack.colorBy?(this.alignmentTrack.colorBy="none",this.config.colorBy="none",this.trackView.repaintViews()):(this.alignmentTrack.colorBy=t.key,this.config.colorBy=t.key,this.trackView.repaintViews()):this.browser.inputDialog.present({label:"Tag Name",value:this.alignmentTrack.colorByTag?this.alignmentTrack.colorByTag:"",callback:t=>{t?(this.alignmentTrack.colorBy="tag",this.alignmentTrack.colorByTag=t,this.alignmentTrack.tagColors||(this.alignmentTrack.tagColors=new ta("Set1"))):(this.alignmentTrack.colorBy="none",this.alignmentTrack.colorByTag=""),this.trackView.repaintViews()}},e)},init:void 0}}getState(){const t=super.getState();return this.sortObject&&(t.sort={chr:this.sortObject.chr,position:this.sortObject.position+1,option:this.sortObject.option,direction:this.sortObject.direction?"ASC":"DESC"}),t}getCachedAlignmentContainers(){return this.trackView.viewports.map((t=>t.cachedFeatures))}get dataRange(){return this.coverageTrack.dataRange}set dataRange(t){this.coverageTrack.dataRange=t}get logScale(){return this.coverageTrack.logScale}set logScale(t){this.coverageTrack.logScale=t}get autoscale(){return this.coverageTrack.autoscale}set autoscale(t){this.coverageTrack.autoscale=t}addPairedChordsForViewport(t){const e=this.maxTemplateLength,i=[],n=t.referenceFrame;for(let r of t.cachedFeatures.allAlignments())r.end>=n.start&&r.start<=n.end&&(r.paired?r.end-r.start>e&&i.push(r):r.mate&&r.mate.chr&&(r.mate.chr!==r.chr||Math.max(r.fragmentLength)>e)&&i.push(r));_d((t=>{const e=[];for(let i of t)if(i.paired)i.firstAlignment&&i.secondAlignment&&e.push({uniqueId:i.readName,refName:vd(i.firstAlignment.chr),start:i.firstAlignment.start,end:i.firstAlignment.end,mate:{refName:vd(i.secondAlignment.chr),start:i.secondAlignment.start,end:i.secondAlignment.end}});else{const t=i.mate;t&&t.chr&&t.position&&e.push({uniqueId:i.readName,refName:vd(i.chr),start:i.start,end:i.end,mate:{refName:vd(t.chr),start:t.position-1,end:t.position}})}return e})(i),this,n,.02)}addSplitChordsForViewport(t){const e=[],i=t.referenceFrame;for(let n of t.cachedFeatures.allAlignments()){const t=n.hasTag("SA");n.end>=i.start&&n.start<=i.end&&t&&e.push(n)}_d((t=>{const e=t=>{const e=hu(t.tags().SA);let n=0;for(let r of e)r.start!==t.start&&i.push({uniqueId:`${t.readName}_${n++}`,refName:vd(t.chr),start:t.start,end:t.end,mate:{refName:vd(r.chr),start:r.start,end:r.start+r.lenOnRef}})},i=[];for(let i of t)i.paired?(e(i.firstAlignment),i.secondAlignment&&e(i.secondAlignment)):e(i);return i})(e),this,i,.02)}}class $d{constructor(t,e){this.parent=e,this.featureSource=e.featureSource,this.paintAxis=$u,this.top=0,this.autoscale=t.autoscale||void 0===t.max,this.autoscale||(this.dataRange={min:t.min||0,max:t.max})}get height(){return this.parent.coverageTrackHeight}draw(t){const e=t.pixelTop;t.pixelHeight;const i=this.parent.browser.nucleotideColors;if(e>this.height)return;const n=t.context,r=t.features.coverageMap;let s;r.refSeq&&(s=r.refSeq.toUpperCase());const o=t.bpPerPixel,a=t.bpStart,l=a+t.pixelWidth*o+1;let h;h=this.parent.coverageColor?this.parent.coverageColor:this.parent.color&&"function"!=typeof this.parent.color?xo.darkenLighten(this.parent.color,-35):"rgb(150, 150, 150)",na.setProperties(n,{fillStyle:h,strokeStyle:h});const c=Math.max(1,Math.ceil(1/o));for(let t=0,e=r.coverage.length;tl)break;const i=r.coverage[t];if(!i)continue;const s=Math.round(i.total/this.dataRange.max*this.height),h=this.height-s,u=Math.floor((e-a)/o);na.fillRect(n,u,h,c,s)}if(s)for(let t=0,e=r.coverage.length;tl)break;const h=r.coverage[t];if(!h)continue;const u=h.total/this.dataRange.max*this.height;let d=this.height-u;const f=Math.floor((e-a)/o),p=s[t];if(h.isMismatch(p)){na.setProperties(n,{fillStyle:i[p]}),na.fillRect(n,f,d,c,u);let t=0;for(let e of["A","C","T","G"]){const r=(h["pos"+e]+h["neg"+e])/this.dataRange.max*this.height;d=this.height-r-t,t+=r,na.setProperties(n,{fillStyle:i[e]}),na.fillRect(n,f,d,c,r)}}}}getClickedObject(t){let e=t.viewport.cachedFeatures;if(!e||0===e.length)return;const i=Math.floor(t.genomicLocation),n=e.coverageMap,r=Math.floor(i-n.bpStart);return n.coverage[r]}popupData(t){const e=[],i=this.getClickedObject(t);if(i){const n=Math.floor(t.genomicLocation),r=t.viewport.referenceFrame;e.push(r.chr+":"+$i(1+n)),e.push({name:"Total Count",value:i.total});let s=i.posA+i.negA;s>0&&(s=s.toString()+" ("+Math.round(s/i.total*100)+"%, "+i.posA+"+, "+i.negA+"- )"),e.push({name:"A",value:s}),s=i.posC+i.negC,s>0&&(s=s.toString()+" ("+Math.round(s/i.total*100)+"%, "+i.posC+"+, "+i.negC+"- )"),e.push({name:"C",value:s}),s=i.posG+i.negG,s>0&&(s=s.toString()+" ("+Math.round(s/i.total*100)+"%, "+i.posG+"+, "+i.negG+"- )"),e.push({name:"G",value:s}),s=i.posT+i.negT,s>0&&(s=s.toString()+" ("+Math.round(s/i.total*100)+"%, "+i.posT+"+, "+i.negT+"- )"),e.push({name:"T",value:s}),s=i.posN+i.negN,s>0&&(s=s.toString()+" ("+Math.round(s/i.total*100)+"%, "+i.posN+"+, "+i.negN+"- )"),e.push({name:"N",value:s}),e.push("
"),e.push({name:"DEL",value:i.del.toString()}),e.push({name:"INS",value:i.ins.toString()})}return e}}class qd{constructor(t,e){this.parent=e,this.browser=e.browser,this.featureSource=e.featureSource,this.top=0===t.coverageTrackHeight?0:t.coverageTrackHeight+5,this.displayMode=t.displayMode||"EXPANDED",this.alignmentRowHeight=t.alignmentRowHeight||14,this.squishedRowHeight=t.squishedRowHeight||3,this.negStrandColor=t.negStrandColor||"rgba(150, 150, 230, 0.75)",this.posStrandColor=t.posStrandColor||"rgba(230, 150, 150, 0.75)",this.insertionColor=t.insertionColor||"rgb(138, 94, 161)",this.insertionTextColor=t.insertionTextColor||"white",this.showInsertionText=void 0!==t.showInsertionText&&!!t.showInsertionText,this.deletionColor=t.deletionColor||"black",this.deletionTextColor=t.deletionTextColor||"black",this.showDeletionText=void 0!==t.showDeletionText&&!!t.showDeletionText,this.skippedColor=t.skippedColor||"rgb(150, 170, 170)",this.pairConnectorColor=t.pairConnectorColor,this.smallTLENColor=t.smallTLENColor||t.smallFragmentLengthColor||"rgb(0, 0, 150)",this.largeTLENColor=t.largeTLENColor||t.largeFragmentLengthColor||"rgb(200, 0, 0)",this.pairOrientation=t.pairOrienation||"fr",this.pairColors={},this.pairColors.RL=t.rlColor||"rgb(0, 150, 0)",this.pairColors.RR=t.rrColor||"rgb(20, 50, 200)",this.pairColors.LL=t.llColor||"rgb(0, 150, 150)",this.colorBy=t.colorBy||"unexpectedPair",this.colorByTag=t.colorByTag?t.colorByTag.toUpperCase():void 0,this.bamColorTag=void 0===t.bamColorTag?"YC":t.bamColorTag,this.hideSmallIndels=t.hideSmallIndels,this.indelSizeThreshold=t.indelSizeThreshold||1,this.hasPairs=!1,this.hasSupplemental=!1}setTop(t,e){this.top=0===t.height||!1===e?0:5+t.height}computePixelHeight(t){return t.packedAlignmentRows?(t.hasDownsampledIntervals()?10:0)+("SQUISHED"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight)*t.packedAlignmentRows.length+5:0}draw(t){const e=t.features,i=t.context,n=t.bpPerPixel,r=t.bpStart,s=t.pixelWidth,o=r+s*n+1,a=this.parent.showSoftClips,l=this.parent.showAllBases,h=this.browser.nucleotideColors,c=e.packedAlignmentRows;i.save();let u=e.sequence;u&&(u=u.toUpperCase());let d=0,f=t.pixelTop;this.top&&i.translate(0,this.top);const p=f+t.pixelHeight;e.hasDownsampledIntervals()?(d=10,e.downsampledIntervals.forEach((function(t){var e=(t.start-r)/n,s=(t.end-r)/n;s-e>5&&(e+=1,s-=1),na.fillRect(i,e,2,s-e,3,{fillStyle:"black"})}))):d=0,this.alignmentsYOffset=d;const g="SQUISHED"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight;if(c){const t=c.length;for(let e=0;ep)break;if(!(i+no)break;!0!==e.hidden&&(e instanceof Xc?(m.call(this,e,i,n),b.call(this,e.firstAlignment,i,n),e.secondAlignment&&b.call(this,e.secondAlignment,i,n)):b.call(this,e,i,n))}}}function m(t,e,s){var a=this.getConnectorColor(t.firstAlignment),l=(t.connectingStart-r)/n,h=(t.connectingEnd-r)/n,c=e+s/2;t.connectingEndo||(t.mq<=0&&(a=xo.addAlpha(a,.15)),na.setProperties(i,{fillStyle:a,strokeStyle:a}),na.strokeLine(i,l,c,h,c))}function b(t,c,d){if(t.start+t.lengthOnRefo)return;const f=a?t.blocks:t.blocks.filter((t=>"S"!==t.type));let p=this.getAlignmentColor(t);const m=p;t.mq<=0&&(p=xo.addAlpha(p,.15)),na.setProperties(i,{fillStyle:p,strokeStyle:m});const b=[];for(let t=0;to))break}if(t.gaps){const e=c+d/2;for(let s of t.gaps){const t=(s.start-r)/n,o=(s.start+s.len-r)/n,a=o-t,l=s.len.toString(),h=6*l.length,u=t+a/2,d="D"===s.type?this.deletionColor:this.skippedColor;if(na.strokeLine(i,t,e,o,e,{strokeStyle:d,lineWidth:2}),this.showDeletionText&&s.len>1&&a>=h+8){const t=u-h/2;na.fillRect(i,t-1,c-1,h+2,12,{fillStyle:"white"}),na.fillText(i,l,t,c+10,{font:"normal 10px monospace",fillStyle:this.deletionTextColor})}}}if(t.insertions&&this.parent.showInsertions){let e=-1;for(let s of t.insertions){if(this.hideSmallIndels&&s.len<=this.indelSizeThreshold)continue;if(s.starto)break;const t=s.start-r,a=s.len.toString(),l=2+6*a.length,h=this.showInsertionText&&1!==s.len?Math.round(s.len/n):2,u=Math.max(Math.min(l,h),2),f=t/n-u/2;if(f-e>2){const t={fillStyle:this.insertionColor};na.fillRect(i,f-2,c,u+4,2,t),na.fillRect(i,f,c+2,u,d-4,t),na.fillRect(i,f-2,c+d-2,u+4,2,t),this.showInsertionText&&s.len>1&&h>l&&na.fillText(i,a,f+1,c+10,{font:"normal 10px monospace",fillStyle:this.insertionTextColor}),e=f}}}function y(o,a){const b=[],y=o.start-e.start,v=(o.start-r)/n,w=(o.start+o.len-r)/n,_=Math.max(1,w-v),x=100/n,k=Math.min(g/2,x/6),S="S"===o.type,C=t.mq<=0||this.highlightedAlignmentReadNamed===t.readName||S;let A=m;this.highlightedAlignmentReadNamed===t.readName?A="red":S&&(A="rgb(50,50,50)");const T=!0===t.strand&&a===f.length-1,I=!1===t.strand&&0===a;if(T|I){let t,e;T?(t=[v,w,w+k,w,v,v],e=[c,c,c+d/2,c+d,c+d,c]):I&&(t=[w,v,v-k,v,w,w],e=[c,c,c+d/2,c+d,c+d,c]),na.fillPolygon(i,t,e,{fillStyle:p}),C&&na.strokePolygon(i,t,e,{strokeStyle:A})}else na.fillRect(i,v,c,_,d,{fillStyle:p}),C&&(i.save(),i.strokeStyle=A,i.strokeRect(v,c,_,d),i.restore());if(S||l||this.parent.showMismatches&&u&&t.seq&&"*"!==t.seq){const e=t.seq?t.seq.toUpperCase():void 0,i=t.qual,a=o.seqOffset,f=Math.max(1,1/n);for(let t=0,p=o.len;ts)break;let g=e?e.charAt(a+t):"";const m=y+t>=0?u.charAt(y+t):"";if("="===g&&(g=m),"X"===g||m!==g||S||l){let e;e=!S&&void 0!==i&&i.length>a+t?Wd(i[a+t],h[g]):h[g],e&&b.push({bbox:{x:p,y:c,width:f,height:d},baseColor:e,readChar:g})}}}return b}b.forEach((({bbox:t,baseColor:e,readChar:r})=>{!function(t,e,i,n,r){var s;if(e<=.1&&i.height>=8){const e=Math.min(10,i.height);t.font=e+"px sans-serif",s=i.x+i.width/2,na.strokeText(t,r,s-t.measureText(r).width/2,e-1+i.y,{strokeStyle:n})}else na.fillRect(t,i.x,i.y,i.width,i.height,{fillStyle:n})}(i,n,t,e,r)}))}i.restore()}popupData(t){const e=this.getClickedObject(t);return e?e.popupData(t.genomicLocation):void 0}contextMenuItemList(t){const e=t.viewport,i=[],n=i=>{const n=this.parent.sortObject,r=!n||n.position!==Math.floor(t.genomicLocation)||!n.direction,s={chr:e.referenceFrame.chr,position:Math.floor(t.genomicLocation),option:i,direction:r};this.parent.sortObject=s,e.cachedFeatures.sortRows(s),e.repaint()};i.push("Sort by..."),i.push({label:"  base",click:()=>n("BASE")}),i.push({label:"  read strand",click:()=>n("STRAND")}),i.push({label:"  insert size",click:()=>n("INSERT_SIZE")}),i.push({label:"  gap size",click:()=>n("GAP_SIZE")}),i.push({label:"  chromosome of mate",click:()=>n("MATE_CHR")}),i.push({label:"  mapping quality",click:()=>n("MQ")}),i.push({label:"  read name",click:()=>n("READ_NAME")}),i.push({label:"  aligned read length",click:()=>n("ALIGNED_READ_LENGTH")}),i.push({label:"  tag",click:()=>{const i=this.parent.sortObject,n=!i||i.position!==Math.floor(t.genomicLocation)||!i.direction,r={label:"Tag Name",value:this.sortByTag?this.sortByTag:"",callback:i=>{if(i){const r={chr:e.referenceFrame.chr,position:Math.floor(t.genomicLocation),option:"TAG",tag:i,direction:n};this.sortByTag=i,this.parent.sortObject=r,e.cachedFeatures.sortRows(r),e.repaint()}}};this.browser.inputDialog.present(r,t.event)}}),i.push("
");const r=this.getClickedObject(t);if(r){const e=this.parent.showSoftClips,n="function"==typeof r.alignmentContaining?r.alignmentContaining(t.genomicLocation,e):r;if(n){n.isPaired()&&n.isMateMapped()&&i.push({label:"View mate in split screen",click:()=>{if(n.mate){const e=t.viewport.referenceFrame;if(this.browser.genome.getChromosome(n.mate.chr)){this.highlightedAlignmentReadNamed=n.readName;const t=e.end-e.start,i=n.mate.position-t/2,r=n.mate.position+t/2;this.browser.addMultiLocusPanel(n.mate.chr,i,r,e)}else this.browser.alert.present(`Reference does not contain chromosome: ${n.mate.chr}`)}},init:void 0}),i.push({label:"View read sequence",click:()=>{const t=n.seq;t&&"*"!==t?this.browser.alert.present(t):this.browser.alert.present("Read sequence: *")}}),ba()&&i.push({label:"Copy read sequence",click:async()=>{const t=n.seq;try{await navigator.clipboard.writeText(t)}catch(t){console.error(t),this.browser.alert.present(`error copying sequence to clipboard ${t}`)}}});const e=n.seq;if(e&&"*"!=e){e.length{const t=n.isNegativeStrand()?Ra(e):e,i=`${n.readName} - blat`,r=`${this.parent.name} - ${i}`;Vd({sequence:t,browser:this.browser,name:i,title:r})}});const t=n.softClippedBlocks();t.left&&t.left.len>20&&t.left.len{const i=e.substr(t.left.seqOffset,t.left.len),r=n.isNegativeStrand()?Ra(i):i,s=`${n.readName} - blat left clip`,o=`${this.parent.name} - ${s}`;Vd({sequence:r,browser:this.browser,name:s,title:o})}}),t.right&&t.right.len>20&&t.right.len{const i=e.substr(t.right.seqOffset,t.right.len),r=n.isNegativeStrand()?Ra(i):i,s=`${n.readName} - blat right clip`,o=`${this.parent.name} - ${s}`;Vd({sequence:r,browser:this.browser,name:s,title:o})}})}i.push("
")}}return this.browser.circularView&&(this.hasPairs||this.hasSupplemental)&&(this.hasPairs&&i.push({label:"Add discordant pairs to circular view",click:()=>{this.parent.addPairedChordsForViewport(e)}}),this.hasSupplemental&&i.push({label:"Add split reads to circular view",click:()=>{this.parent.addSplitChordsForViewport(e)}}),i.push("
")),i}getClickedObject(t){const e=t.viewport,i=t.y,n=t.genomicLocation,r=this.parent.showSoftClips;let s=e.cachedFeatures;if(!s||0===s.length)return;let o=s.packedAlignmentRows,a=s.downsampledIntervals;const l="SQUISHED"===this.displayMode?this.squishedRowHeight:this.alignmentRowHeight;let h=Math.floor((i-this.top-this.alignmentsYOffset)/l);if(h<0){for(let t=0;t=n)return a[t]}else if(ht.containsLocation(n,r)));if(t.length>0)return t[0]}}getConnectorColor(t){if(this.pairConnectorColor)return this.pairConnectorColor;switch(this.colorBy){case"strand":case"firstOfPairStrand":case"pairOrientation":case"tag":return this.parent.color?"function"==typeof this.parent.color?this.parent.color(t):this.parent.color:"rgb(200, 200, 200)";default:return this.getAlignmentColor(t)}}getAlignmentColor(t){let e=Hd;e=this.parent.color?"function"==typeof this.parent.color?this.parent.color(t):this.parent.color:Hd;const i=this.colorBy;switch(i){case"strand":e=t.strand?this.posStrandColor:this.negStrandColor;break;case"firstOfPairStrand":t instanceof Xc?e=t.firstOfPairStrand()?this.posStrandColor:this.negStrandColor:t.isPaired()&&(t.isFirstOfPair()?e=t.strand?this.posStrandColor:this.negStrandColor:t.isSecondOfPair()?e=t.strand?this.negStrandColor:this.posStrandColor:console.error("ERROR. Paired alignments are either first or second."));break;case"unexpectedPair":case"pairOrientation":if(this.pairOrientation&&t.pairOrientation){const i=Gd[this.pairOrientation];if(i){const n=this.pairColors[i[t.pairOrientation]];if(n){e=n;break}}}if("pairOrientation"===i)break;case"tlen":case"fragmentLength":t.mate&&t.isMateMapped()&&(t.mate.chr!==t.chr?e=Zd(t.mate.chr):this.parent.minTemplateLength&&Math.abs(t.fragmentLength)this.parent.maxTemplateLength&&(e=this.largeTLENColor));break;case"tag":const n=t.tags()[this.colorByTag];void 0!==n&&(this.bamColorTag===this.colorByTag?e="rgb("+n+")":(this.tagColors||(this.tagColors=new ta("Set1")),e=this.tagColors.getColor(n)))}return e}}function Wd(t,e){let i;return i=t<5?.1:Math.max(.1,Math.min(1,.1+.9*(t-5)/15)),i=Math.round(10*i)/10,i<1&&(e=xo.addAlpha(e,i)),e}const Gd={fr:{F1R2:"LR",F2R1:"LR",F1F2:"LL",F2F1:"LL",R1R2:"RR",R2R1:"RR",R1F2:"RL",R2F1:"RL"},rf:{R1F2:"LR",R2F1:"LR",R1R2:"LL",R2R1:"LL",F1F2:"RR",F2F1:"RR",F1R2:"RL",F2R1:"RL"},ff:{F2F1:"LR",R1R2:"LR",F2R1:"LL",R1F2:"LL",R2F1:"RR",F1R2:"RR",R2R1:"RL",F1F2:"RL"}};function Zd(t){if(Yd[t])return Yd[t];if(Yd["chr"+t]){const e=Yd["chr"+t];return Yd[t]=e,e}{const e=xo.randomRGB(0,255);return Yd[t]=e,e}}const Yd={chrX:"rgb(204, 153, 0)",chrY:"rgb(153, 204, 0)",chrUn:"rgb(50, 50, 50)",chr1:"rgb(80, 80, 255)",chrI:"rgb(139, 155, 187)",chr2:"rgb(206, 61, 50)",chrII:"rgb(206, 61, 50)",chr2a:"rgb(216, 71, 60)",chr2b:"rgb(226, 81, 70)",chr3:"rgb(116, 155, 88)",chrIII:"rgb(116, 155, 88)",chr4:"rgb(240, 230, 133)",chrIV:"rgb(240, 230, 133)",chr5:"rgb(70, 105, 131)",chr6:"rgb(186, 99, 56)",chr7:"rgb(93, 177, 221)",chr8:"rgb(128, 34, 104)",chr9:"rgb(107, 215, 107)",chr10:"rgb(213, 149, 167)",chr11:"rgb(146, 72, 34)",chr12:"rgb(131, 123, 141)",chr13:"rgb(199, 81, 39)",chr14:"rgb(213, 143, 92)",chr15:"rgb(122, 101, 165)",chr16:"rgb(228, 175, 105)",chr17:"rgb(59, 27, 83)",chr18:"rgb(205, 222, 183)",chr19:"rgb(97, 42, 121)",chr20:"rgb(174, 31, 99)",chr21:"rgb(231, 199, 111)",chr22:"rgb(90, 101, 94)",chr23:"rgb(204, 153, 0)",chr24:"rgb(153, 204, 0)",chr25:"rgb(51, 204, 0)",chr26:"rgb(0, 204, 51)",chr27:"rgb(0, 204, 153)",chr28:"rgb(0, 153, 204)",chr29:"rgb(10, 71, 255)",chr30:"rgb(71, 117, 255)",chr31:"rgb(255, 194, 10)",chr32:"rgb(255, 209, 71)",chr33:"rgb(153, 0, 51)",chr34:"rgb(153, 26, 0)",chr35:"rgb(153, 102, 0)",chr36:"rgb(128, 153, 0)",chr37:"rgb(51, 153, 0)",chr38:"rgb(0, 153, 26)",chr39:"rgb(0, 153, 102)",chr40:"rgb(0, 128, 153)",chr41:"rgb(0, 51, 153)",chr42:"rgb(26, 0, 153)",chr43:"rgb(102, 0, 153)",chr44:"rgb(153, 0, 128)",chr45:"rgb(214, 0, 71)",chr46:"rgb(255, 20, 99)",chr47:"rgb(0, 214, 143)",chr48:"rgb(20, 255, 177)"};let Qd,Xd;class Kd extends ml{constructor(t,e,i,n){super(t,e,i,n)}get contentDiv(){return this.$viewport.get(0)}initializationHelper(){let t;this.$multiLocusCloseButton=fe("
",{class:"igv-multi-locus-close-button"}),this.$viewport.append(this.$multiLocusCloseButton),this.$multiLocusCloseButton.get(0).appendChild(_i.createIcon("times-circle")),this.$multiLocusCloseButton.click((()=>{this.browser.removeMultiLocusPanel(this.referenceFrame)})),this.$rulerLabel=fe("
",{class:"igv-multi-locus-ruler-label"}),this.$viewport.append(this.$rulerLabel),t=document.createElement("div"),this.$rulerLabel.append(fe(t)),this.$rulerLabel.get(0).addEventListener("click",(async t=>{t.stopPropagation(),await this.browser.gotoMultilocusPanel(this.referenceFrame)})),this.$tooltip=fe("
",{class:"igv-ruler-tooltip"}),this.$tooltip.height(this.$viewport.height()),this.$viewport.append(this.$tooltip),this.$tooltipContent=fe("
"),this.$tooltip.append(this.$tooltipContent),this.rulerSweeper=new Qc(this,this.$viewport.get(0).parentElement,this.browser,this.referenceFrame),this.attachMouseHandlers(ul.isWholeGenomeView(this.referenceFrame.chr)),this.$tooltip.hide(),this.dismissLocusLabel()}presentLocusLabel(t){this.$multiLocusCloseButton.show(),this.$rulerLabel.show(),this.$rulerLabel.get(0).style.backgroundColor=Zd(this.referenceFrame.chr);const e=this.$rulerLabel.get(0).querySelector("div"),{width:i}=this.$rulerLabel.get(0).getBoundingClientRect();e.innerHTML=`${this.referenceFrame.getMultiLocusLabel(t)}`;const{width:n}=e.getBoundingClientRect();n/i>.5&&(e.innerHTML=`${this.referenceFrame.getMultiLocusLabelBPLengthOnly(t)}`)}dismissLocusLabel(){this.$rulerLabel.hide(),this.$multiLocusCloseButton.hide()}attachMouseHandlers(t){if(this.namespace=`.ruler_track_viewport_${this.browser.referenceFrameList.indexOf(this.referenceFrame)}`,this.$viewport.off(this.namespace),!0===t){const t=this.browser.referenceFrameList.indexOf(this.referenceFrame),e=`click${this.namespace}`;this.$viewport.on(e,(e=>{const{x:i}=_e.translateMouseCoordinates(e,this.$viewport.get(0)),n=Math.round(this.referenceFrame.start+this.referenceFrame.toBP(i));let r;const{chr:s}=this.browser.genome.getChromosomeCoordinate(n);if(1===this.browser.referenceFrameList.length)r=s;else{let e=this.browser.referenceFrameList.map((({locusSearchString:t})=>t));e[t]=s,r=e.join(" ")}this.browser.search(r)})),this.$viewport.get(0).style.cursor="pointer"}else this.$viewport.get(0).style.cursor="default"}mouseMove(t){if(!0===this.browser.cursorGuideVisible){if(void 0===Xd?(Xd=this,this.$tooltip.show()):Xd.guid!==this.guid?(Xd.$tooltip&&Xd.$tooltip.hide(),this.$tooltip.show(),Xd=this):this.$tooltip.show(),this.browser.isMultiLocusWholeGenomeView()||ul.isWholeGenomeView(this.referenceFrame.chr))return void this.$tooltip.hide();const{x:e}=_e.translateMouseCoordinates(t,this.$viewport.get(0)),{start:i,bpPerPixel:n}=this.referenceFrame,r=Math.round(.5+i+Math.max(0,e)*n);this.$tooltipContent.text($i(r));const{width:s}=this.$tooltipContent.get(0).getBoundingClientRect(),{width:o}=this.$viewport.get(0).getBoundingClientRect();this.$tooltip.css({left:`${yo(e,0,o-s)}px`}),clearTimeout(Qd),Qd=setTimeout((()=>{this.$tooltip&&this.$tooltip.hide()}),1e4)}}startSpinner(){}stopSpinner(){}dispose(){this.rulerSweeper.dispose(),super.dispose()}}class Jd extends ml{constructor(t,e,i,n){super(t,e,i,n)}initializationHelper(){this.canvas=document.createElement("canvas"),this.canvas.className="igv-ideogram-canvas",this.$viewport.append(fe(this.canvas)),this.ideogram_ctx=this.canvas.getContext("2d"),this.addMouseHandlers()}addMouseHandlers(){this.addViewportClickHandler(this.$viewport.get(0))}addViewportClickHandler(t){this.boundClickHandler=function(t){const{xNormalized:e,width:i}=_e.translateMouseCoordinates(t,this.ideogram_ctx.canvas),{bpLength:n}=this.browser.genome.getChromosome(this.referenceFrame.chr),r=this.referenceFrame.bpPerPixel*i/n;let s=e;s-r/2<0&&(s=r/2),s+r/2>1&&(s=1-r/2);const o=Math.round((s-r/2)*n),a=Math.round((s+r/2)*n);this.referenceFrame.start=o,this.referenceFrame.end=a,this.referenceFrame.bpPerPixel=(a-o)/i,this.browser.updateViews(this.referenceFrame,this.browser.trackViews,!0)}.bind(this),t.addEventListener("click",this.boundClickHandler)}setWidth(t){this.$viewport.width(t)}drawSVGWithContext(t,e,i,n,r,s,o){t.saveWithTranslationAndClipRect(n,r,s,e,i,o),this.trackView.track.draw({context:t,referenceFrame:this.referenceFrame,pixelWidth:e,pixelHeight:i}),t.restore()}repaint(){this.draw({referenceFrame:this.referenceFrame})}draw({referenceFrame:t}){na.configureHighDPICanvas(this.ideogram_ctx,this.$viewport.width(),this.$viewport.height()),this.trackView.track.draw({context:this.ideogram_ctx,referenceFrame:t,pixelWidth:this.$viewport.width(),pixelHeight:this.$viewport.height()})}startSpinner(){}stopSpinner(){}}function tf(t,e,i,n){return"ruler"===t.track.type?new Kd(t,e,i,n):"ideogram"===t.track.id?new Jd(t,e,i,n):new ml(t,e,i,n)}const ef={textAlign:"start",textBaseline:"bottom",strokeStyle:"black",fillStyle:"black"};class nf{constructor(t,e,i,n){this.guid=_e.guid(),this.trackView=t,this.browser=t.browser,this.viewport=_e.div({class:"igv-viewport"}),e.appendChild(this.viewport),t.track.height&&(this.viewport.style.height=`${t.track.height}px`),this.canvas=document.createElement("canvas"),this.viewport.appendChild(this.canvas),this.ctx=this.canvas.getContext("2d"),this.trackScrollDelta=0,this.contentTop=0,this.setWidth(n),!1===this.browser.showSampleNames&&this.hide(),this.addMouseHandlers()}checkCanvas(){const t=window.devicePixelRatio,e=this.viewport.clientHeight,i=this.browser.sampleNameViewportWidth;if(this.canvas.width!==i*t||this.canvas.height!==e*t){const n=this.canvas;n.width=i*t,n.height=e*t,n.style.width=`${i}px`,n.style.height=`${e}px`,this.ctx=this.canvas.getContext("2d"),this.ctx.scale(t,t)}}setTop(t){if("function"==typeof this.trackView.track.getSamples){this.contentTop=t;const e=this.trackView.track.getSamples();this.repaint(e)}}setWidth(t){this.viewport.innerWidth=t,this.checkCanvas()}show(){this.viewport.style.display="block"}hide(){this.viewport.style.display="none"}async repaint(t){this.checkCanvas(),this.draw({context:this.ctx,samples:t})}draw({context:t,samples:e}){if(!e||0===e.names.length)return;!function(t,{textAlign:e,textBaseline:i,strokeStyle:n,fillStyle:r},s){const o=Math.min(s,10);t.font=`${o}px sans-serif`,t.textAlign=e,t.textBaseline=i,t.fillStyle=r}(t,ef,e.height),t.clearRect(0,0,t.canvas.width,t.canvas.height),t.fillStyle=function(t){const{r:e,g:i,b:n}=Ko.lead;return`rgb(${e},${i},${n})`}();const i=this.viewport.getBoundingClientRect().height;let n=(e.yOffset||0)+this.contentTop;for(let r of e.names){if(n>i)break;if(n+e.height>0){const i=r,s=rf(t,i,n,e.height);t.fillText(i,4,s)}n+=e.height}}renderSVGContext(t,{deltaX:e,deltaY:i}){if("function"==typeof this.trackView.track.getSamples){const n=this.trackView.track.getSamples(),r=0,{width:s,height:o}=this.viewport.getBoundingClientRect(),a=`${(this.trackView.track.name||this.trackView.track.id).replace(/\W/g,"")}_sample_names_guid_${_e.guid()}`;t.saveWithTranslationAndClipRect(a,e,i+r,s,o,-r),this.draw({context:t,samples:n}),t.restore()}}addMouseHandlers(){this.addViewportContextMenuHandler(this.viewport)}removeMouseHandlers(){this.removeViewportContextMenuHandler(this.viewport)}addViewportContextMenuHandler(t){this.boundContextMenuHandler=function(t){t.preventDefault(),t.stopPropagation();const e={label:"Name Panel Width",value:this.browser.sampleNameViewportWidth,callback:t=>{this.browser.sampleNameViewportWidth=parseInt(t);for(let{sampleNameViewport:t}of this.browser.trackViews)t.setWidth(this.browser.sampleNameViewportWidth);this.browser.layoutChange()}};this.browser.inputDialog.present(e,t)}.bind(this),t.addEventListener("contextmenu",this.boundContextMenuHandler)}removeViewportContextMenuHandler(t){t.removeEventListener("contextmenu",this.boundContextMenuHandler)}dispose(){this.removeMouseHandlers(),this.viewport.remove()}}function rf(t,e,i,n){return i+n-function(t,e,i){const{actualBoundingBoxAscent:n,actualBoundingBoxDescent:r}=t.measureText(e);return(i-(n+r))/2}(t,e,n)}const sf=function(t){this.popover=_e.div({class:"igv-menu-popup"}),t.appendChild(this.popover);const e=_e.div({class:"igv-menu-popup-header"});this.popover.appendChild(e),ki.attachDialogCloseHandlerWithParent(e,(()=>this.hide())),this.popoverContent=_e.div(),this.popover.appendChild(this.popoverContent),Ci(this.popover,e),e.addEventListener("click",(t=>{t.stopPropagation(),t.preventDefault()})),this.hide()};sf.prototype.hide=function(){this.popover.style.display="none"},sf.prototype.presentMenuList=function(t){if(of(),t.length>0){this.popoverContent.innerHTML="",t=Ui.trackMenuItemListHelper(t,this);for(let e of t){e.init&&e.init();let i=e.object;0===t.indexOf(e)&&i.removeClass("igv-track-menu-border-top"),i.hasClass("igv-track-menu-border-top")||i.hasClass("igv-menu-popup-check-container")||i.is("div")&&i.addClass("igv-menu-popup-shim"),this.popoverContent.appendChild(i.get(0))}this.popover.style.display="flex";const{width:e}=this.popover.getBoundingClientRect();this.popover.style.left=-e+"px",this.popover.style.top="0px"}},sf.prototype.presentTrackContextMenu=function(t,e){this.popoverContent.innerHTML="";const i=(n=e,r=this.popover,n.map((t=>{let e;if("string"==typeof t&&"
"===t)e=document.createElement("hr");else if("string"==typeof t)e=_e.div({class:"context-menu"}),e.innerHTML=t;else if("Node"==typeof t)e=t;else{if("function"==typeof t.init&&t.init(),"checkbox"===t.type)e=zi("Show all bases",t.value);else if("color"===t.type){const i=new Pi({parent:r.parentElement,width:364});i.configure(void 0,{color:e=>t.click(e)}),e=_e.div({class:"context-menu"}),"string"==typeof t.label&&(e.innerHTML=t.label);const n=t=>{i.show(),_e.hide(r),t.preventDefault(),t.stopPropagation()};e.addEventListener("click",n),e.addEventListener("touchend",n),e.addEventListener("mouseup",(function(t){t.preventDefault(),t.stopPropagation()}))}else e=_e.div({class:"context-menu"}),"string"==typeof t.label&&(e.innerHTML=t.label);if(t.click&&"color"!==t.type){function s(e){t.click(),_e.hide(r),e.preventDefault(),e.stopPropagation()}e.addEventListener("click",s),e.addEventListener("touchend",s),e.addEventListener("mouseup",(function(t){t.preventDefault(),t.stopPropagation()}))}}return{el:e,init:t.init}})));var n,r;for(let{el:t}of i)this.popoverContent.appendChild(t);!function(t,e){e.style.display="flex";const{x:i,y:n}=_e.translateMouseCoordinates(t,e.parentNode),{width:r}=e.getBoundingClientRect(),s=i+r,{width:o}=e.parentNode.getBoundingClientRect();e.style.left=`${s>o?i-(s-o):i}px`,e.style.top=`${n}px`}(t,this.popover)},sf.prototype.dispose=function(){this.popoverContent.innerHTML="",this.popover.innerHTML="",Object.keys(this).forEach((function(t){this[t]=void 0}))};const of=()=>{const t=document.querySelectorAll(".igv-menu-popup");for(let e=0;e0&&this.viewports[0].startSpinner()}stopSpinner(){this.viewports&&this.viewports.length>0&&this.viewports[0].stopSpinner()}addDOMToColumnContainer(t,e,i){this.axis=this.createAxis(t,this.track),this.viewports=[];const n=t.calculateViewportWidth(i.length),r=e.querySelectorAll(".igv-column");for(let t=0;t{t.dataRangeDialog.configure(this),t.dataRangeDialog.present(fe(t.columnContainer))}));const{width:n,height:r}=i.getBoundingClientRect();this.axisCanvas=document.createElement("canvas"),this.axisCanvas.style.width=`${n}px`,this.axisCanvas.style.height=`${r}px`,i.appendChild(this.axisCanvas)}return i}resizeAxisCanvas(t,e){this.axis.style.width=`${t}px`,this.axis.style.height=`${e}px`,"function"==typeof this.track.paintAxis&&(this.axisCanvas.style.width=`${t}px`,this.axisCanvas.style.height=`${e}px`)}removeDOMFromColumnContainer(){this.boundAxisClickHander&&this.removeAxisEventListener(this.axis),this.axis.remove();for(let t of this.viewports)t.$viewport.remove();this.sampleNameViewport.dispose(),this.removeTrackScrollMouseHandlers(),this.outerScroll.remove(),this.removeTrackDragMouseHandlers(),this.dragHandle.remove(),this.removeTrackGearMouseHandlers(),this.gearContainer.remove()}renderSVGContext(t,{deltaX:e,deltaY:i}){!function(t,e,i,n,r){if("function"==typeof e.paintAxis){const{y:s,width:o,height:a}=i.getBoundingClientRect(),l=`${(e.name||e.id).replace(/\W/g,"")}_axis_guid_${_e.guid()}`;t.saveWithTranslationAndClipRect(l,n,s+r,o,a,0),e.paintAxis(t,o,a),t.restore()}}(t,this.track,this.axisCanvas,e,i);const{width:n}=this.axis.getBoundingClientRect(),{y:r}=this.viewports[0].$viewport.get(0).getBoundingClientRect();let s={deltaX:n+e,deltaY:r+i};for(let e of this.viewports){e.renderSVGContext(t,s);const{width:i}=e.$viewport.get(0).getBoundingClientRect();s.deltaX+=i}!0===this.browser.showSampleNames&&this.sampleNameViewport.renderSVGContext(t,s)}dataRange(){return this.track.dataRange?this.track.dataRange:void 0}setDataRange(t,e){void 0!==t&&(this.track.dataRange.min=t),void 0!==e&&(this.track.dataRange.max=e),this.track.autoscale=!1,this.repaintViews()}presentColorPicker(t){if(!1===lf.has(this.track.type)){const e=[],i=this.track.color||this.track.defaultColor;ji(i)&&e.push(i),this.track.altColor&&ji(this.track.altColor)&&e.push(this.track.altColor);const n=e.map((t=>t.startsWith("#")?t:t.startsWith("rgb(")?xo.rgbToHex(t):xo.colorNameToHex(t))),r={color:t=>{this.track.color=t,this.repaintViews()},altColor:t=>{this.track.altColor=t,this.repaintViews()}};this.browser.genericColorPicker.configure(n,r),this.browser.genericColorPicker.setActiveColorHandler(t),this.browser.genericColorPicker.show()}}setTrackHeight(t,e){e||(this.track.minHeight&&(t=Math.max(this.track.minHeight,t)),this.track.maxHeight&&(t=Math.min(this.track.maxHeight,t))),this.track.height=t,this.resizeAxisCanvas(this.axis.clientWidth,this.track.height),"function"==typeof this.track.paintAxis&&this.paintAxis();for(let{$viewport:e}of this.viewports)e.height(t);if(this.sampleNameViewport.viewport.style.height=`${t}px`,"function"!=typeof this.track.computePixelHeight)for(let e of this.viewports)e.setContentHeight(t);this.repaintViews(),!1===af.has(this.track.type)&&this.updateScrollbar(),this.dragHandle.style.height=`${t}px`,this.gearContainer.style.height=`${t}px`}updateScrollbar(){const t=this.viewports[0].$viewport.height();this.outerScroll.style.height=`${t}px`;const e=this.maxViewportContentHeight(),i=Math.round(t/e*t);e>t?(this.innerScroll.style.display="block",this.innerScroll.style.height=`${i}px`):this.innerScroll.style.display="none"}moveScroller(t){const e=fe(this.innerScroll).position().top+t,i=Math.min(Math.max(0,e),this.outerScroll.clientHeight-this.innerScroll.clientHeight);fe(this.innerScroll).css("top",`${i}px`);const n=this.maxViewportContentHeight(),r=-Math.round(i*(n/this.viewports[0].$viewport.height()));for(let t of this.viewports)t.setTop(r);this.sampleNameViewport.trackScrollDelta=t,this.sampleNameViewport.setTop(r)}isLoading(){for(let t of this.viewports)if(t.isLoading())return!0}repaintViews(){for(let t of this.viewports)t.isVisible()&&t.repaint();"function"==typeof this.track.paintAxis&&this.paintAxis(),this.repaintSamples()}repaintSamples(){if("function"==typeof this.track.getSamples){const t=this.track.getSamples();this.sampleNameViewport.repaint(t)}}setTrackLabelName(t){this.viewports.forEach((e=>e.setTrackLabel(t)))}resize(t){for(let e of this.viewports)e.setWidth(t)}async updateViews(){if(!this.browser||!this.browser.referenceFrameList)return;const t=this.viewports.filter((t=>t.isVisible()));if(t.forEach((t=>t.shift())),this.browser.dragObject)return;const e=t.filter((t=>t.needsRepaint())).filter((t=>t.checkZoomIn())),i=e.filter((t=>t.needsReload()));for(let t of i)await t.loadFeatures();if(this.disposed)return;if(this.track&&"function"==typeof this.track.variantRowCount&&i.length>0){let t=0;for(let e of this.viewports)e.featureCache&&e.featureCache.features&&(t=Math.max(t,e.featureCache.features.reduce(((t,e)=>Math.max(t,e.row||0)),0)));if(this.track.nVariantRows!==t+1){this.track.variantRowCount(t+1);for(let t of this.viewports)t.checkContentHeight()}}if(this.track.autoscale){let e=[];for(let i of t){const t=i.referenceFrame,n=t.start,r=n+t.toBP(i.getWidth());if(i.featureCache&&i.featureCache.features)if("function"==typeof i.featureCache.features.getMax){const t=i.featureCache.features.getMax(n,r);e.push({value:t})}else{const t=Xo(i.featureCache.features,n,r);for(let i of t)e.push(i)}}"function"==typeof this.track.doAutoscale?this.track.dataRange=this.track.doAutoscale(e):this.track.dataRange=ha(e)}const n=this.track.autoscale||this.track.autoscaleGroup||"ruler"===this.track.type;for(let i of t)e.includes(i)?i.repaint():n&&i.refresh();this.adjustTrackHeight(),this.repaintSamples(),this.updateRulerViewportLabels()}clearCachedFeatures(){for(let t of this.viewports)t.clearCache()}updateRulerViewportLabels(){const t=this.browser.calculateViewportWidth(this.viewports.length);for(let e of this.viewports)"ruler"===this.track.type&&(this.viewports.length>1?e.presentLocusLabel(t):e.dismissLocusLabel())}async getInViewFeatures(){if(!this.browser||!this.browser.referenceFrameList)return[];let t=[];const e=this.viewports.filter((t=>t.isVisible()));for(let i of e){const e=i.referenceFrame,{chr:n,start:r,bpPerPixel:s}=i.referenceFrame,o=r+e.toBP(i.getWidth());if((!i.featureCache||!i.featureCache.containsRange(n,r,o,s))&&await i.loadFeatures(),i.featureCache&&i.featureCache.features)if("function"==typeof i.featureCache.features.getMax){const e=i.featureCache.features.getMax(r,o);t.push({value:e})}else{const e="function"==typeof i.featureCache.queryFeatures?i.featureCache.queryFeatures(n,r,o):Xo(i.featureCache.features,r,o);t=t.concat(e)}}return t}checkContentHeight(){for(let t of this.viewports)t.checkContentHeight();this.adjustTrackHeight()}adjustTrackHeight(){var t=this.maxViewportContentHeight();if(this.track.autoHeight?this.setTrackHeight(t,!1):this.track.paintAxis&&this.paintAxis(),!1===af.has(this.track.type)){const e=this.viewports[0].getContentTop(),i=this.viewports[0].$viewport.height(),n=Math.min(0,i-t);if(e{t.preventDefault(),void 0===e&&t.target.classList.remove("igv-track-drag-handle-hover")})),this.boundTrackDragMouseOutHandler=s.bind(this),this.dragHandle.addEventListener("mouseout",this.boundTrackDragMouseOutHandler)}}removeTrackDragMouseHandlers(){"ideogram"===this.track.id||"ruler"===this.track.id||(this.dragHandle.removeEventListener("mousedown",this.boundTrackDragMouseDownHandler),document.removeEventListener("mouseup",this.boundDocumentTrackDragMouseUpHandler),this.dragHandle.removeEventListener("mouseup",this.boundTrackDragMouseEnterHandler),this.dragHandle.removeEventListener("mouseout",this.boundTrackDragMouseOutHandler))}addTrackGearMouseHandlers(){if(!0===this.track.ignoreTrackMenu);else{function t(t){t.preventDefault(),t.stopPropagation(),this.trackGearPopup.presentMenuList(Ui.trackMenuItemList(this))}this.boundTrackGearClickHandler=t.bind(this),this.gear.addEventListener("click",this.boundTrackGearClickHandler)}}removeTrackGearMouseHandlers(){!0===this.track.ignoreTrackMenu||this.gear.removeEventListener("click",this.boundTrackGearClickHandler)}dispose(){this.removeAxisEventListener(this.axis),this.axis.remove();for(let t of this.viewports)t.dispose();this.sampleNameViewport.dispose(),this.removeTrackScrollMouseHandlers(),this.outerScroll.remove(),this.removeTrackDragMouseHandlers(),this.dragHandle.remove(),this.removeTrackGearMouseHandlers(),this.gearContainer.remove(),"function"==typeof this.track.dispose&&this.track.dispose();for(let t of Object.keys(this))this[t]=void 0;this.alert&&this.alert.container.remove(),this.disposed=!0}paintAxis(){if("function"==typeof this.track.paintAxis){const{width:t,height:e}=this.axisCanvas.getBoundingClientRect(),i=window.devicePixelRatio||1;this.axisCanvas.height=i*e,this.axisCanvas.width=i*t;const n=this.axisCanvas.getContext("2d");n.scale(i,i),this.track.paintAxis(n,t,e)}}maxViewportContentHeight(){return Math.max(this.viewports.map((t=>t.getContentHeight())))}}const cf="rgb(150, 150, 150)";class uf extends ch{static defaults={height:50,flipAxis:!1,logScale:!1,windowFunction:"mean",graphType:"bar",autoscale:!0,normalize:void 0,scaleFactor:void 0};constructor(t,e){super(t,e)}init(t){super.init(t),this.type="wig",this.featureType="numeric",this.paintAxis=$u;const e=t.format?t.format.toLowerCase():t.format;t.featureSource?(this.featureSource=t.featureSource,delete t.featureSource):this.featureSource="bigwig"===e?new Lc(t,this.browser.genome):"tdf"===e?new Dc(t,this.browser.genome):$c(t,this.browser.genome),void 0===t.max||!0===t.autoscale?this.autoscale=!0:this.dataRange={min:t.min||0,max:t.max}}async postInit(){const t=await this.getHeader();this.disposed||t&&this.setTrackProperties(t)}async getFeatures(t,e,i,n){const r=await this.featureSource.getFeatures({chr:t,start:e,end:i,bpPerPixel:n,visibilityWindow:this.visibilityWindow,windowFunction:this.windowFunction});if(this.normalize&&this.featureSource.normalizationFactor){const t=this.featureSource.normalizationFactor;for(let e of r)e.value*=t}if(this.scaleFactor){const t=this.scaleFactor;for(let e of r)e.value*=t}return r}menuItemList(){let t=[];return void 0!==this.flipAxis&&(t.push("
"),t.push({label:"Flip y-axis",click:()=>{this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}})),t=t.concat(Ui.numericDataMenuItems(this.trackView)),t}async getHeader(){return"function"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader()),this.header}getScaleFactor(t,e,i,n){return n?i/(Math.log10(e+1)-(t<=0?0:Math.log10(t+1))):i/(e-t)}computeYPixelValue(t,e){return(this.flipAxis?t-this.dataRange.min:this.dataRange.max-t)*e}computeYPixelValueInLogScale(t,e){let i=this.dataRange.max,n=this.dataRange.min;return i<=0?0:(n<=-1&&(n=0),n=n<=0?0:Math.log10(n+1),i=Math.log10(i+1),t=Math.log10(t+1),(this.flipAxis?t-n:i-t)*e)}draw(t){const e=t.features,i=t.context,n=t.bpPerPixel,r=t.bpStart,s=t.pixelWidth;t.pixelHeight;const o=r+s*n+1,a=this.color||cf;let l;"string"==typeof a&&a.startsWith("rgb(")&&(l=xo.addAlpha(a,.1));const h=this.getScaleFactor(this.dataRange.min,this.dataRange.max,t.pixelHeight,this.logScale),c=t=>this.logScale?this.computeYPixelValueInLogScale(t,h):this.computeYPixelValue(t,h);if(e&&e.length>0&&(void 0===this.dataRange.min&&(this.dataRange.min=0),this.dataRange.max>this.dataRange.min)){let s,a=-1;const h=c(0);for(let t of e){if(t.endo)break;const e=Math.floor((t.start-r)/n);if(isNaN(e))continue;let l=c(t.value);const u=Math.ceil((t.end-r)/n),d=Math.max(1,u-e),f=this.getColorForFeature(t);if("points"===this.graphType){const t=this.config.pointSize||3,n=e+d/2;na.fillCircle(i,n,l,t/2,{fillStyle:f,strokeStyle:f})}else if("line"===this.graphType)null!=s&&na.strokeLine(i,a,s,e,l,{fillStyle:f,strokeStyle:f}),na.strokeLine(i,e,l,e+d,l,{fillStyle:f,strokeStyle:f});else{const t=l-h;na.fillRect(i,e,h,d,t,{fillStyle:f})}a=e+d,s=l}if(this.dataRange.min<0){const e=this.dataRange.max/(this.dataRange.max-this.dataRange.min)*t.pixelHeight;na.strokeLine(i,0,e,t.pixelWidth,e,{strokeStyle:l})}}if(this.config.hasOwnProperty("guideLines"))for(let e of this.config.guideLines)if(e.hasOwnProperty("color")&&e.hasOwnProperty("y")&&e.hasOwnProperty("dotted")){let i=c(e.y),n={strokeStyle:e.color,strokeWidth:2};e.dotted?na.dashedLine(t.context,0,i,t.pixelWidth,i,5,n):na.strokeLine(t.context,0,i,t.pixelWidth,i,n)}}popupData(t,e){if(void 0===e&&(e=this.clickedFeatures(t)),e&&e.length>0){const i=t.genomicLocation,n=[];e.sort((function(t,e){return Math.abs((t.start+t.end)/2-i)-Math.abs((e.start+e.end)/2-i)}));const r=e.length>10?e.slice(0,10):e;r.sort((function(t,e){return t.start-e.start}));for(let t of r)if(t){n.length>0&&n.push("
");let e=t.end-t.start==1?$i(t.start+1):$i(t.start+1)+"-"+$i(t.end);n.push({name:"Position:",value:e}),n.push({name:"Value:     ",value:$i(t.value)})}return r.length..."),n}return[]}get supportsWholeGenome(){return!this.config.indexURL&&!1!==this.config.supportsWholeGenome}getColorForFeature(t){let e=t.value<0&&this.altColor?this.altColor:this.color||cf;return"function"==typeof e?e(t.value):e}dispose(){this.trackView=void 0}}function df(t){this.thresholds=t.thresholds,this.colors=t.colors}function ff(t){this.scale=t,this.lowColor="rgb("+t.lowR+","+t.lowG+","+t.lowB+")",this.highColor="rgb("+t.highR+","+t.highG+","+t.highB+")",this.diff=t.high-t.low}df.prototype.getColor=function(t){for(let e of this.thresholds)if(t=i.high?this.highColor:(e=(t-i.low)/this.diff,"rgb("+Math.floor(i.lowR+e*(i.highR-i.lowR))+","+Math.floor(i.lowG+e*(i.highG-i.lowG))+","+Math.floor(i.lowB+e*(i.highB-i.lowB))+")")};class pf{constructor(t){this.color=t}getColor(){return this.color}}class gf extends ch{constructor(t,e){super(t,e)}init(t){if(super.init(t),this.type=t.type||"seg","maf"===this.type&&(this.type="mut"),this.isLog=t.isLog,this.displayMode=t.displayMode||"EXPANDED",this.height=t.height||300,this.maxHeight=t.maxHeight||500,this.squishedRowHeight=t.sampleSquishHeight||t.squishedRowHeight||2,this.expandedRowHeight=t.sampleExpandHeight||t.expandedRowHeight||13,this.sampleHeight=this.squishedRowHeight,t.color?this.color=t.color:(this.posColorScale=t.posColorScale||new ff({low:.1,lowR:255,lowG:255,lowB:255,high:1.5,highR:255,highG:0,highB:0}),this.negColorScale=t.negColorScale||new ff({low:-1.5,lowR:0,lowG:0,lowB:255,high:-.1,highR:255,highG:255,highB:255}),"mut"===this.type&&(this.colorTable=new ea(t.colorTable||mf))),this.sampleKeys=[],this.sampleNames=new Map,t.samples){for(let e of t.samples)this.sampleKeys.push(e),this.sampleNames.set(e,e);this.explicitSamples=!0}const e=Object.assign({},this.config);e.maxWGCount=e.maxWGCount||Number.MAX_SAFE_INTEGER,this.featureSource=$c(e,this.browser.genome),this.initialSort=t.sort}async postInit(){"function"==typeof this.featureSource.getHeader&&(this.header=await this.featureSource.getHeader(),this.disposed)||this.header&&this.setTrackProperties(this.header)}menuItemList(){const t=[],e={SQUISHED:"Squish",EXPANDED:"Expand",FILL:"Fill"};t.push("
"),t.push("DisplayMode:");const i="seg"===this.type?["SQUISHED","EXPANDED","FILL"]:["SQUISHED","EXPANDED"];for(let n of i){const i=zi(e[n],n===this.displayMode);t.push({object:fe(i),click:()=>{this.displayMode=n,this.config.displayMode=n,this.trackView.checkContentHeight(),this.trackView.repaintViews(),this.trackView.moveScroller(this.trackView.sampleNameViewport.trackScrollDelta)}})}return t}hasSamples(){return!0}getSamples(){return{names:this.sampleKeys.map((t=>this.sampleNames.get(t))),height:this.sampleHeight,yOffset:0}}async getFeatures(t,e,i){const n=await this.featureSource.getFeatures({chr:t,start:e,end:i});if(this.initialSort){const t=this.initialSort;this.sortSamples(t.chr,t.start,t.end,t.direction,n),this.initialSort=void 0}return n}draw({context:t,renderSVG:e,pixelTop:i,pixelWidth:n,pixelHeight:r,features:s,bpPerPixel:o,bpStart:a}){if(na.fillRect(t,0,i,n,r,{fillStyle:"rgb(255, 255, 255)"}),s&&s.length>0){this.checkForLog(s),this.updateSampleKeys(s);const e={};let l;switch(this.sampleKeys.forEach((function(t,i){e[t]=i})),this.displayMode){case"FILL":this.sampleHeight=r/this.sampleKeys.length,l=0;break;case"SQUISHED":this.sampleHeight=this.squishedRowHeight,l=0;break;default:this.sampleHeight=this.expandedRowHeight,l=1}const h=this.sampleHeight;for(let t of s)t.pixelRect=void 0;const c=i+r,u=a+n*o+1,d=o;this.sampleYStart=void 0;for(let n of s){if(n.endu)break;const r=n.sampleKey||n.sample;n.row=e[r];const s=n.row*h+l;if(void 0===this.sampleYStart&&(this.sampleYStart=s),s+hc)continue;const o=Math.max(n.start,a);let f=Math.round((o-a)/d);const p=Math.min(n.end,u),g=Math.round((p-a)/d);let m,b,y=Math.max(1,g-f);if(this.color?m="function"==typeof this.color?this.color(n):this.color:this.colorTable&&(m=this.colorTable.getColor(n.value.toLowerCase())),"mut"===this.type)b=h-2*l,y<3&&(y=3,f-=1);else{let t=n.value;this.isLog||(t=vo(t/2)),m=t<-.1?this.negColorScale.getColor(t):t>.1?this.posColorScale.getColor(t):"white";let e=h;if(h<.25){const i=.1+2*Math.abs(t);e=Math.min(1,i*h)}b=e-2*l}n.pixelRect={x:f,y:s,w:y,h:b},t.fillStyle=m,t.fillRect(f,s,y,b)}}}checkForLog(t){if(void 0===this.isLog){this.isLog=!1;for(let e of t)if(e.value<0)return void(this.isLog=!0)}}computePixelHeight(t){if(!t)return 0;const e="SQUISHED"===this.displayMode?this.squishedRowHeight:this.expandedRowHeight;return this.updateSampleKeys(t),this.sampleKeys.length*e}async sortSamples(t,e,i,n,r){if(r||(r=await this.featureSource.getFeatures({chr:t,start:e,end:i})),!r)return;this.updateSampleKeys(r);const s={},o="ASC"===n?1:-1;"mut"===this.type?(()=>{for(let t of r){if(t.endi)break;const n=t.sampleKey||t.sample;(!s.hasOwnProperty(n)||t.value.localeCompare(s[n])>0)&&(s[n]=t.value)}this.sampleKeys.sort((function(t,e){let i=s[t]||"",n=s[e]||"";return o*i.localeCompare(n)}))})():(()=>{const t=i-e+1;for(let n of r){if(n.endi)break;const r=Math.max(e,n.start),o=(Math.min(i,n.end)-r)/t,a=n.sampleKey||n.sample,l=s[a]||0;s[a]=l+o*n.value}this.sampleKeys.sort((function(t,e){let i=s[t],n=s[e];return i||(i=o*Number.MAX_VALUE),n||(n=o*Number.MAX_VALUE),i===n?0:i>n?o:-1*o}))})(),this.trackView.repaintViews()}clickedFeatures(t){const e=super.clickedFeatures(t),i=t.y;return e.filter((function(t){const e=t.pixelRect;return e&&i>=e.y&&i<=e.y+e.h}))}hoverText(t){const e=this.clickedFeatures(t);if(e&&e.length>0)return`${e[0].sample}: ${e[0].value}`}popupData(t,e){void 0===e&&(e=this.clickedFeatures(t));const i=[];for(let t of e){i.length>0&&(i.push("
"),i.push("
"));const e=t._f||t,n="function"==typeof e.popupData?e.popupData(this.type,this.browser.genome.id):this.extractPopupData(e);Array.prototype.push.apply(i,n)}return i}contextMenuItemList(t){const e=t.viewport.referenceFrame,i=t.genomicLocation,n=this.config.sort?"ASC"===this.config.sort.direction?"DESC":"ASC":"DESC",r=e.toBP(2.5),s=e=>{const i=t.viewport.cachedFeatures;this.sortSamples(e.chr,e.start,e.end,e.direction,i)};return[{label:"seg"===this.type?"Sort by value":"Sort by type",click:e=>{const o={direction:n,chr:t.viewport.referenceFrame.chr,start:i-r,end:i+r};s(o),this.config.sort=o}}]}get supportsWholeGenome(){return(!1===this.config.indexed||!this.config.indexURL)&&!1!==this.config.supportsWholeGenome}updateSampleKeys(t){if(!this.explicitSamples)for(let e of t){const t=e.sampleKey||e.sample;this.sampleNames.has(t)||(this.sampleNames.set(t,e.sample),this.sampleKeys.push(t))}}}const mf={indel:"rgb(0,200,0)","targeted region":"rgb(236,155,43)",truncating:"rgb(\t150,0,0)","non-coding transcript":"rgb(0,0,150)",synonymous:"rgb(109,165,95)",silent:"rgb(109,135,80)",missense_mutation:"rgb(72,130,187)",missense:"rgb(72,130,187)","splice site":"rgb(143,83,155)",splice_region:"rgb(143,83,155)",nonsense:"rgb(216, 57,81)",nonsense_mutation:"rgb(216, 57,81)",frame_shift_del:"rgb(226,135,65)",frame_shift_ins:"rgb(226,135,65)",in_frame_del:"rgb(247,235,94)",in_frame_ins:"rgb(247,235,94)","*other*":"rgb(159,91,50)"};class bf extends ch{constructor(t,e){super(t,e),this.type="merged",this.featureType="numeric",this.paintAxis=$u,this.graphType=t.graphType}init(t){if(!t.tracks)throw Error("Error: no tracks defined for merged track"+t);super.init(t)}async postInit(){this.tracks=[];const t=[];for(let e of this.config.tracks){e.isMergedTrack=!0;const i=await this.browser.createTrack(e);i?(i.autoscale=!1,this.tracks.push(i)):console.warn("Could not create track "+e),"function"==typeof i.postInit&&t.push(i.postInit())}this.flipAxis=!!this.config.flipAxis&&this.config.flipAxis,this.logScale=!!this.config.logScale&&this.config.logScale,this.autoscale=this.config.autoscale||void 0===this.config.max,this.autoscale||(this.dataRange={min:this.config.min||0,max:this.config.max});for(let t of this.tracks)t.autoscale=!1,t.dataRange=this.dataRange;return this.height=this.config.height||50,Promise.all(t)}get height(){return this._height}set height(t){if(this._height=t,this.tracks)for(let e of this.tracks)e.height=t,e.config.height=t}menuItemList(){let t=[];return void 0!==this.flipAxis&&t.push({label:"Flip y-axis",click:()=>{this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}}),t=t.concat(Ui.numericDataMenuItems(this.trackView)),t}async getFeatures(t,e,i,n){const r=this.tracks.map((r=>r.getFeatures(t,e,i,n))),s=await Promise.all(r);return new yf(s)}draw(t){const e=t.features;for(let i=0,n=this.tracks.length;i0&&i.push("
"),i.push(`
${this.tracks[n].name}
`);const r=this.tracks[n].popupData(t,e[n]);i.push(...r)}return i}}}clickedFeatures(t){const e=t.viewport.cachedFeatures;if(!e)return[];const i=t.genomicLocation,n=[];for(let r of e.featureArrays){const e=t.referenceFrame.bpPerPixel>.2?3*t.referenceFrame.bpPerPixel:.2,s=Xo(r,i-e,i+e);for(let t of s)n.push(t)}return n}get supportsWholeGenome(){return this.tracks.every((t=>t.supportsWholeGenome))}}class yf{constructor(t){this.featureArrays=t}getMax(t,e){let i=-Number.MAX_VALUE;for(let n of this.featureArrays)for(let r of n)if(void 0!==r.value&&!Number.isNaN(r.value)){if(r.ende)break;i=Math.max(i,r.value)}return i}}class vf extends ch{static defaults={height:250,theta:Math.PI/4,arcOrientation:!0,showBlocks:!0,blockHeight:3,thickness:1,alpha:.02,logScale:!0};constructor(t,e){super(t,e)}init(t){super.init(t),this.sinTheta=Math.sin(this.theta),this.cosTheta=Math.cos(this.theta),this.arcType=function(t){if(!t.arcType)return"nested";switch(t.arcType){case"chiapet":return"inView";case"chiapetoutbound":return"partialInView";default:return t.arcType}}(t),this.alpha=t.alpha||.02,this.painter={flipAxis:!this.arcOrientation,dataRange:this.dataRange,paintAxis:$u},t.valueColumn?(this.valueColumn=t.valueColumn,this.hasValue=!0):t.useScore&&(this.hasValue=!0,this.valueColumn="score"),t.max?(this.dataRange={min:t.min||0,max:t.max},this.autoscale=!1):this.autoscale=!0,t.featureSource?(this.featureSource=t.featureSource,delete t._featureSource):(this.featureSource=$c(t,this.browser.genome),this.featureSource.getWGFeatures=Sf)}async postInit(){if("function"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),void 0===this.visibilityWindow&&"function"==typeof this.featureSource.defaultVisibilityWindow&&(this.visibilityWindow=await this.featureSource.defaultVisibilityWindow(),this.featureSource.visibilityWindow=this.visibilityWindow),this}get supportsWholeGenome(){return!0}async getFeatures(t,e,i){const n=this.visibilityWindow,r=await this.featureSource.getFeatures({chr:t,start:e,end:i,visibilityWindow:n});return void 0===this.hasValue&&r&&r.length>0&&(this.hasValue=void 0!==r[0].score),r}draw(t){"proportional"===this.arcType||"inView"===this.arcType||"partialInView"===this.arcType?this.drawProportional(t):this.drawNested(t)}drawNested(t){const e=t.context,i=t.pixelWidth,n=t.pixelHeight,r=t.viewportWidth,s=t.bpPerPixel,o=t.bpStart,a=s;na.fillRect(e,0,t.pixelTop,i,n,{fillStyle:"rgb(255, 255, 255)"});const l=t.features;if(l){(function(){let t=0;for(let e of l){let n=(e.start-o)/a,r=(e.end-o)/a;n>=0&&r<=i&&(t=Math.max(t,r-n))}let e=Math.min(r,t)/2;if(t>0){let t=(n-10)/e;this.theta=function(t){let e,i=[.01570925532366355,.15838444032453644,.3249196962329063,.5095254494944288,.7265425280053609,.9999999999999999],n=[.031415926535897934,.3141592653589793,.6283185307179586,.9424777960769379,1.2566370614359172,1.5707963267948966];for(e=0;et);e++);let r=0===e?0:i[e-1],s=(t-r)/((ei)continue;let f=d-u;f<3&&(f=3,u--);const p=f/2,g=p/this.sinTheta,m=this.cosTheta*g,b=u+p;let y,v,w;if(c?(y=this.height+m,v=Math.PI+Math.PI/2-this.theta,w=Math.PI+Math.PI/2+this.theta):(y=-m,v=Math.PI/2-this.theta,w=Math.PI/2+this.theta),this.showBlocks&&"all"!==t.chr){const i=(t.start1-o)/a,n=(t.end1-o)/a,r=(t.start2-o)/a,l=(t.end2-o)/a,h=this.arcOrientation?-this.blockHeight:this.blockHeight;e.fillRect(i,s,n-i,h),e.fillRect(r,s,l-r,h)}n&&!this.config.useScore&&f>r&&(n=kf(n,this.alpha)),e.strokeStyle=n,e.fillStyle=n,e.beginPath(),e.arc(b,y,g,v,w,!1),e.stroke(),t.drawState={xc:b,yc:y,r:g}}else{let r=Math.round((t.start-o)/a),s=Math.round((t.end-o)/a);if(s<0||r>i)continue;let l=s-r;l<3&&(l=3,r--);const h=t.chr===t.chr1?t.chr2:t.chr1;e.strokeStyle=n,e.fillStyle=kf(Zd(h),.5),c?(e.fillRect(r,this.height/2,l,this.height/2),e.fillText(h,r+l/2,this.height/2-5),t.drawState={x:r,y:this.height/2,w:l,h:this.height/2}):(e.fillRect(r,0,l,this.height/2),e.fillText(h,r+l/2,this.height/2+13),t.drawState={x:r,y:0,w:l,h:this.height/2})}}}var h}getScaleFactor(t,e,i,n){return n?i/(Math.log10(e+1)-(t<=0?0:Math.log10(t+1))):i/(e-t)}drawProportional(t){const e=t.context,i=t.pixelWidth,n=t.pixelHeight,r=t.bpPerPixel,s=t.bpStart,o=r,a=t.referenceFrame.start,l=t.referenceFrame.end;na.fillRect(e,0,t.pixelTop,i,n,{fillStyle:"rgb(255, 255, 255)"});const h=t.features;if(h&&h.length>0){const n=0,r=this.getScaleFactor(n,this.dataRange.max,t.pixelHeight-1,this.logScale),c=this.arcOrientation?t.pixelHeight:0;for(let t of h){t.drawState=void 0;const n=this.valueColumn?t[this.valueColumn]:t.score;if(void 0===n||Number.isNaN(n))continue;const h=Math.round((this.logScale?Math.log10(n+1):n)*r);if(t.chr1===t.chr2||"all"===t.chr){const{m1:i,m2:r}=wf(t,this.browser.genome);let u=Math.round((i-s)/o),d=Math.round((r-s)/o)-u;if(d<3&&(d=3,u--),nthis.dataRange.max)continue;if("proportional"!==this.arcType){const t="partialInView"===this.arcType,e=i>=a&&r<=l;let n=!1,s=!1;if(!e&&t&&(n=a<=i&&i<=l,n||(s=a<=r&&r<=l)),!(e||n||s))continue}const f=d/2,p=u+d/2;t.drawState={xc:p,yc:c,radiusX:f,radiusY:h};const g=!!this.arcOrientation,m=t.color||this.color;if(e.strokeStyle=m,e.lineWidth=t.thickness||this.thickness||1,!0===e.isSVG?e.strokeEllipse(p,c,f,h,0,0,Math.PI,g):(e.beginPath(),e.ellipse(p,c,f,h,0,0,Math.PI,g),e.stroke()),this.alpha&&(e.fillStyle=kf(m,this.alpha),!0===e.isSVG?e.fillEllipse(p,c,f,h,0,0,Math.PI,g):e.fill()),this.showBlocks&&"all"!==t.chr){e.fillStyle=m;const i=(t.start1-s)/o,n=(t.end1-s)/o,r=(t.start2-s)/o,a=(t.end2-s)/o,l=this.arcOrientation?-this.blockHeight:this.blockHeight;e.fillRect(i,c,n-i,l),e.fillRect(r,c,a-r,l)}}else{let r=Math.round((t.start-s)/o),a=Math.round((t.end-s)/o);if(a<0||r>i||nthis.dataRange.max)continue;const l=Math.min(h,this.height-13);let c=a-r;c<3&&(c=3,r--);const u=t.chr===t.chr1?t.chr2:t.chr1;if(e.font="8px sans-serif",e.textAlign="center",e.fillStyle=kf(Zd(u),.5),this.arcOrientation){const i=this.height-l;e.fillRect(r,i,c,l),e.fillText(u,r+c/2,i-5),t.drawState={x:r,y:i,w:c,h:l}}else e.fillRect(r,0,c,l),e.fillText(u,r+c/2,l+13),t.drawState={x:r,y:0,w:c,h:l}}}}}clearAxis(t,e,i){na.fillRect(t,0,0,e,i,{fillStyle:"rgb(255, 255, 255)"})}paintAxis(t,e,i){const n={min:0,max:this.dataRange.max};"proportional"===this.arcType||"inView"===this.arcType||"partialInView"===this.arcType?(this.painter.flipAxis=!this.arcOrientation,this.painter.dataRange=n,this.painter.paintAxis(t,e,i)):this.clearAxis(t,e,i)}menuItemList(){let t=[];if(this.hasValue){t.push("
");const e={nested:"Nested",proportional:"Proportional - All",inView:"Proportional - Both Ends in View",partialInView:"Proportional - One End in View"};t.push("Arc Type");for(let i of["nested","proportional","inView","partialInView"])t.push({object:fe(zi(e[i],i===this.arcType)),click:()=>{this.arcType=i,this.trackView.repaintViews()}})}return t.push("
"),t.push({name:"Toggle arc direction",click:()=>{this.arcOrientation=!this.arcOrientation,this.trackView.repaintViews()}}),t.push({name:this.showBlocks?"Hide Blocks":"Show Blocks",click:()=>{this.showBlocks=!this.showBlocks,this.trackView.repaintViews()}}),"proportional"!==this.arcType&&"inView"!==this.arcType&&"partialInView"!==this.arcType||(t=t.concat(Ui.numericDataMenuItems(this.trackView))),this.browser.circularView&&(t.push("
"),t.push({label:"Add interactions to circular view",click:()=>{for(let t of this.trackView.viewports)this.addChordsForViewport(t.referenceFrame)}})),t}contextMenuItemList(t){if(this.browser.circularView){const e=t.viewport,i=[];return i.push({label:"Add interactions to circular view",click:()=>{const t=e.referenceFrame;this.addChordsForViewport(t)}}),i.push("
"),i}}addChordsForViewport(t){const e=("all"===t.chr?this.featureSource.getAllFeatures():this.featureSource.featureCache.queryFeatures(t.chr,t.start,t.end)).filter((t=>t.drawState));0!==e.length&&_d(e.map((t=>{const e=t._f||t;return{uniqueId:`${e.chr1}:${e.start1}-${e.end1}_${e.chr2}:${e.start2}-${e.end2}`,refName:vd(e.chr1),start:e.start1,end:e.end1,mate:{refName:vd(e.chr2),start:e.start2,end:e.end2}}})),this,t,.5)}doAutoscale(t){let e=0;if(t)for(let i of t){const t=this.valueColumn?i[this.valueColumn]:i.score;Number.isNaN(t)||(e=Math.max(e,t))}return{min:0,max:e}}popupData(t,e){void 0===e&&(e=this.clickedFeatures(t));const i=[];for(let t of e){const e=t._||t;if(i.push({name:"Region 1",value:_f(e.chr1,e.start1,e.end1,e.strand1)}),i.push({name:"Region 2",value:_f(e.chr2,e.start2,e.end2,e.strand2)}),e.name&&i.push({name:"Name",value:e.name}),void 0!==e.value&&i.push({name:"Value",value:e.value}),void 0!==e.score&&i.push({name:"Score",value:e.score}),e.extras&&this.header&&this.header.columnNames){const t=this.header.columnNames,n=this.header.hiccups?6:10;for(let r=n;r=e-a&&t.canvasX<=e+s+a&&t.canvasY>=n&&t.canvasY<=n+o){const n=-Math.abs(t.canvasX-(e+s/2));i.push({score:n,feature:r});break}}}return i.length>1&&i.sort(((t,e)=>t.score-e.score)),i.map((t=>t.feature))}}function wf(t,e){let i=(t.start1+t.end1)/2,n=(t.start2+t.end2)/2;if("all"===t.chr&&(i=e.getGenomeCoordinate(t.chr1,i),n=e.getGenomeCoordinate(t.chr2,n)),i>n){const t=i;i=n,n=t}return{m1:i,m2:n}}function _f(t,e,i,n){return n&&"."!==n?`${t}:${$i(e+1)}-${$i(i)} (${n})`:`${t}:${$i(e+1)}-${$i(i)}`}const xf=new Map;function kf(t,e){const i=`${t}_${e}`;let n=xf.get(i);return n||(n=xo.addAlpha(t,e),xf.set(i,n)),n}function Sf(t){const e=t=>{const e=Object.assign({},t);return e.chr="all",e.start=i.getGenomeCoordinate(t.chr1,t.start1),e.end=i.getGenomeCoordinate(t.chr2,t.end2),e},i=this.genome;let n,r=0;for(let e of i.wgChromosomeNames){let i=t[e];if(i)for(let t of i)t.dup||(r++,t.score&&(!n||t.score>n.score)&&(n=t))}const s=this.maxWGCount,o=n&&n.score>0&&r>s?5:1,a=Math.floor(s/o),l=n&&n.score>0?Math.log(n.score)/o:Number.MAX_SAFE_INTEGER;let h,c=[],u=[];for(let t=0;tt.name)):[]}return this.header}getCallsetsLength(){return this.callSets?this.callSets.length:0}async getFeatures(t,e,i,n){return void 0===this.header&&(this.header=await this.getHeader()),this.featureSource.getFeatures({chr:t,start:e,end:i,bpPerPixel:n,visibilityWindow:this.visibilityWindow})}hasSamples(){return this.getCallsetsLength()>0}getSamples(){return{yOffset:this.sampleYOffset,names:this.sampleNames,height:this.sampleHeight}}computePixelHeight(t){if(!t||0==t.length)return 10;const e="COLLAPSED"===this.displayMode?1:this.nVariantRows,i="SQUISHED"===this.displayMode?this.squishedVGap:this.expandedVGap,n="SQUISHED"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,r="SQUISHED"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight;return 10+e*(n+i)+i+(1+(!1===this.showGenotypes?0:this.getCallsetsLength()*e))*(r+i)}variantRowCount(t){this.nVariantRows=t}draw({context:t,pixelWidth:e,pixelHeight:i,bpPerPixel:n,bpStart:r,pixelTop:s,features:o}){na.fillRect(t,0,s,e,i,{fillStyle:"rgb(255, 255, 255)"});const a="SQUISHED"===this.displayMode?this.squishedVGap:this.expandedVGap,l="COLLAPSED"===this.displayMode?1:this.nVariantRows,h="SQUISHED"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight;this.variantBandHeight=10+l*(h+a);let c=this.callSets;!c&&this._f&&(c=this._f.callSets);const u=this.getCallsetsLength();if(c&&u>0&&!1!==this.showGenotypes&&na.strokeLine(t,0,this.variantBandHeight,e,this.variantBandHeight,{strokeStyle:"rgb(224,224,224) "}),o){const i="SQUISHED"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight,s="SQUISHED"===this.displayMode?this.squishedVGap:this.expandedVGap,a=r+e*n+1;for(let e of o){if(e.enda)break;const o="SQUISHED"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,l=10+("COLLAPSED"===this.displayMode?0:e.row*(o+s)),h=o;let d=Math.round((e.start-r)/n),f=Math.round((e.end-r)/n),p=Math.max(1,f-d);p<3?(p=3,d-=1):p>5&&(d+=1,p-=2),t.fillStyle=this.getColorForFeature(e),t.fillRect(d,l,p,h);let g=this.getVariantStrokecolor(e);if(g&&(t.strokeStyle=g,t.strokeRect(d,l,p,h)),this.callContextHook(e,t,d,l,p,h),e.pixelRect={x:d,y:l,w:p,h},u>0&&!1!==this.showGenotypes){const n="COLLAPSED"===this.displayMode?1:this.nVariantRows;this.sampleYOffset=this.variantBandHeight+s,this.sampleHeight=n*(i+s);let r=0;if(c&&e.calls)for(let n of c){const o=e.calls[n.id];if(o){const a="COLLAPSED"===this.displayMode?0:e.row,l=this.sampleYOffset+r*this.sampleHeight+a*(i+s);let h=!0,c=!0,u=!1;if(o.genotype)for(let t of o.genotype){if("."===t){u=!0;break}0!==t&&(c=!1),0===t&&(h=!1)}o.genotype?t.fillStyle=u?this.noCallColor:c?this.homrefColor:h?this.homvarColor:this.hetvarColor:t.fillStyle=this.noGenotypeColor,t.fillRect(d,l,p,i),n.pixelRect={x:d,y:l,w:p,h:i}}r++}}}}else console.log("No feature list")}getColorForFeature(t){const e=t._f||t;let i;if(this.colorBy){const t=this.colorBy;let n;e.info.hasOwnProperty(t)?n=e.info[t]:Tf.has(t)&&(n=e[Tf.get(t)]),i=this.getVariantColorTable(t).getColor(n),i||(i="gray")}else i=this._color?"function"==typeof this._color?this._color(t):this._color:"NONVARIANT"===e.type?this.nonRefColor:"MIXED"===e.type?this.mixedColor:this.color;return i}getVariantStrokecolor(t){const e=t._f||t;let i;return i=this._strokecolor?"function"==typeof this._strokecolor?this._strokecolor(e):this._strokecolor:void 0,i}callContextHook(t,e,i,n,r,s){if(this._context_hook&&"function"==typeof this._context_hook){const o=t._f||t;e.save(),this._context_hook(o,e,i,n,r,s),e.restore()}}clickedFeatures(t){let e=super.clickedFeatures(t);const i="EXPANDED"===this.displayMode?this.expandedVGap:this.squishedVGap,n=i+("SQUISHED"===this.displayMode?this.squishedCallHeight:this.expandedCallHeight),r=t.y;if(r<=this.variantBandHeight){const t="SQUISHED"===this.displayMode?this.squishedVariantHeight:this.expandedVariantHeight,n=Math.floor((r-10)/(t+i));"COLLAPSED"!==this.displayMode&&(e=e.filter((t=>t.row===n)))}else if(this.callSets){const t=this.callSets,i=r-this.variantBandHeight,s=Math.floor(i/this.sampleHeight);if(s>=0&&st.row===r)),a=t[s];e=o.map((t=>{const e=t.calls[a.id];return function(t,e){if(t.genotype){let i="";if("."===e.alternateBases)i="No Call";else{const n=e.alternateBases.split(",");for(let r of t.genotype)i.length>0&&(i+="|"),i+="."===r?".":0===r?e.referenceBases:n[r-1].replace("<","<")}t.genotypeName=i}}(e,t),e}))}}return e}popupData(t,e){void 0===e&&(e=this.clickedFeatures(t));const i=t.genomicLocation,n=this.browser.genome.id,r=this.browser.sampleInformation;let s=[];for(let t of e){const e=t._f||t;if(s.length>0&&s.push({html:'
'}),"function"==typeof e.popupData){const t=e.popupData(i,n);Array.prototype.push.apply(s,t)}else{const t=e;if(void 0!==t.callSetName&&s.push({name:"Name",value:t.callSetName}),t.genotypeName&&s.push({name:"Genotype",value:t.genotypeName}),void 0!==t.phaseset&&s.push({name:"Phase set",value:t.phaseset}),void 0!==t.genotypeLikelihood&&s.push({name:"genotypeLikelihood",value:t.genotypeLikelihood.toString()}),r){var o=r.getAttributes(t.callSetName);o&&Object.keys(o).forEach((function(t){var e=t.replace(/([A-Z])/g," $1");e=e.charAt(0).toUpperCase()+e.slice(1),s.push({name:e,value:o[t]})}))}var a=Object.keys(t.info);a.length&&s.push("
"),a.forEach((function(e){s.push({name:e,value:decodeURIComponent(t.info[e])})}))}}return s}menuItemList(){const t=[];if(this.header.INFO&&this.header.INFO){const e=this.header.INFO.SVTYPE?["SVTYPE"]:[];if(this._initColorBy&&"SVTYPE"!==this._initColorBy&&e.push(this._initColorBy),e.length>0){t.push("
");const i=fe('
');i.text("Color by:"),t.push({name:void 0,object:i,click:void 0,init:void 0}),e.sort();for(let i of e){const e=this.colorBy===i,n=i||"None";t.push(this.colorByCB({key:i,label:n},e))}t.push(this.colorByCB({key:void 0,label:"None"},void 0===this.colorBy)),t.push("
")}}this.getCallsetsLength()>0&&(t.push({object:fe('
')}),t.push({object:fe(zi("Show Genotypes",this.showGenotypes)),click:()=>{this.showGenotypes=!this.showGenotypes,this.trackView.checkContentHeight(),this.trackView.repaintViews()}})),t.push({object:fe('
')});for(let e of["COLLAPSED","SQUISHED","EXPANDED"])t.push({object:fe(zi({COLLAPSED:"Collapse",SQUISHED:"Squish",EXPANDED:"Expand"}[e],e===this.displayMode)),click:()=>{this.displayMode=e,this.trackView.checkContentHeight(),this.trackView.repaintViews()}});return this.browser.circularView&&(t.push("
"),t.push({label:"Add SVs to circular view",click:()=>{for(let t of this.trackView.viewports)this.sendChordsForViewport(t)}})),t}contextMenuItemList(t){if(this.browser.circularView){const e=t.viewport,i=[];return i.push({label:"Add SVs to Circular View",click:()=>{this.sendChordsForViewport(e)}}),i.push("
"),i}}sendChordsForViewport(t){const e=t.referenceFrame;let i;if("all"===e.chr){const t=this.featureSource.getAllFeatures(),e=Object.keys(t).map((e=>t[e]));i=[].concat(...e)}else i=this.featureSource.featureCache.queryFeatures(e.chr,e.start,e.end);_d(i.filter((t=>{const e=t._f||t;return e.info&&e.info.CHR2&&e.info.END&&(e.info.CHR2!==e.chr||Math.abs(Number.parseInt(e.info.END)-e.pos)>1e6)})).map((t=>{const e=t._f||t,i=Number.parseInt(e.info.END),n=i-100,r=i+100;return{uniqueId:`${e.chr}:${e.start}-${e.end}_${e.info.CHR2}:${e.info.END}`,refName:vd(e.chr),start:e.start,end:e.end,mate:{refName:vd(e.info.CHR2),start:n,end:r}}})),this,e,.5)}colorByCB(t,e){return{name:void 0,object:fe(zi(t.label,e)),click:()=>{t.key===this.colorBy?(this.colorBy=void 0,delete this.config.colorBy,this.trackView.repaintViews()):(this.colorBy=t.key,this.config.colorBy=t.key,this.trackView.repaintViews())},init:void 0}}getState(){const t=super.getState();return this._color&&"function"!=typeof this._color&&(t.color=this._color),t}getVariantColorTable(t){if(this.colorTables||(this.colorTables=new Map),!this.colorTables.has(t)){let e;e="SVTYPE"===t?Ef:new ta("Set1"),this.colorTables.set(t,e)}return this.colorTables.get(t)}}const Ef=new ea({DEL:"#ff2101",INS:"#001888",DUP:"#028401",INV:"#008688",CNV:"#8931ff",BND:"#891100","*":"#002eff"});class Mf extends ch{constructor(t,e){super(t,e)}init(t){super.init(t),this.name=t.name,this.pValueField=t.pValueField||"pValue",this.geneField=t.geneField||"geneSymbol",this.snpField=t.snpField||"snp";const e=t.minLogP||t.min,i=t.maxLogP||t.max;this.dataRange={min:e||3.5,max:i||25},this.autoscale=!i||t.autoscale,this.autoscalePercentile=void 0===t.autoscalePercentile?98:t.autoscalePercentile,this.background=t.background,this.divider=t.divider||"rgb(225,225,225)",this.dotSize=t.dotSize||2,this.height=t.height||100,this.autoHeight=!1,this.disableButtons=t.disableButtons,this.visibilityWindow=void 0===t.visibilityWindow?2e6:t.visibilityWindow>=0?Math.min(2e6,t.visibilityWindow):2e6,this.featureSource=$c(t,this.browser.genome),Sd.gtexLoaded=!0}paintAxis(t,e,i){const n=(this.dataRange.max-this.dataRange.min)/i,r={font:"normal 10px Arial",textAlign:"right",strokeStyle:"black"};na.fillRect(t,0,0,e,i,{fillStyle:"rgb(255, 255, 255)"});const s=Math.ceil(10*(this.dataRange.max-this.dataRange.min)/i);for(let o=4;o<=this.dataRange.max;o+=s){const s=.85*e,a=s-5,l=s,h=i-(o-this.dataRange.min)/n;na.strokeLine(t,a,h,l,h,r),h>8&&na.fillText(t,o,a-1,h+2,r)}r.textAlign="center",na.fillText(t,"-log10(pvalue)",e/4,i/2,r,{rotate:{angle:-90}})}async getFeatures(t,e,i){const n=this.pValueField,r=this.visibilityWindow,s=await this.featureSource.getFeatures({chr:t,start:e,end:i,visibilityWindow:r});return s.forEach((function(t){t.value=t[n]})),s}draw(t){const e=t.context,i=t.pixelWidth,n=t.pixelHeight;this.background&&na.fillRect(e,0,0,i,n,{fillStyle:this.background}),na.strokeLine(e,0,n-1,i,n-1,{strokeStyle:this.divider});const r=r=>{const s=r?2*this.dotSize:this.dotSize,o=t.bpStart,a=(this.dataRange.max-this.dataRange.min)/n,l=t.referenceFrame.selection;for(let c of t.features){const u=(c.start-o+.5)/t.bpPerPixel;if(u<0)continue;if(u>i)break;const d=c.snp.toUpperCase(),f=c[this.geneField].toUpperCase(),p=l&&(l.snp===d||l.gene===f);if(!r||p){l&&l.snp===d&&l.addGene(f);var h=-Math.log(c[this.pValueField])/Math.LN10;if(h>=this.dataRange.min){let t;h>this.dataRange.max?(h=this.dataRange.max,t=!0):t=!1;const i=Math.max(0+s,n-Math.round((h-this.dataRange.min)/a));let o;c.px=u,c.py=i,c.radius=s,r&&l?(o=l.colorForGene(f),na.setProperties(e,{fillStyle:o,strokeStyle:"black"})):(o=t?"rgb(150, 150, 150)":"rgb(180, 180, 180)",na.setProperties(e,{fillStyle:o,strokeStyle:o})),na.fillCircle(e,u,i,s),na.strokeCircle(e,u,i,s)}}}};r(!1),r(!0)}popupData(t,e){if(void 0===e&&(e=t.viewport.cachedFeatures),!e||0===e.length)return[];const i=this.name,n=[];for(let r of e)Math.abs(r.px-t.canvasX)0&&n.push("
"),n.push({name:"snp id",value:r.snp},{name:"gene id",value:r.geneId},{name:"gene name",value:r.geneName},{name:"p value",value:r.pValue},{name:"tissue",value:i}));return n}menuItemList(){return Ui.numericDataMenuItems(this.trackView)}doAutoscale(t){if(t.length>0){var e=t.map((function(t){return-Math.log(t.value)/Math.LN10}));this.dataRange.max=function(t,e){if(0!==t.length){var i=Math.floor(t.length*((100-e)/100));return 0===i?(t.sort((function(t,e){return e-t})),t[i]):function(t,e){var i,n=new wo;for(i=0;in.content[0])&&(n.content.length===e&&n.pop(),n.push(r))}return n.content[0]}(t,i)}}(e,this.autoscalePercentile)}else{const t=this.config.maxLogP||this.config.max;this.dataRange.max=t||25}return this.dataRange}}const Rf={X:"rgb(204, 153, 0)",Y:"rgb(153, 204, 0)",Un:"darkGray)",1:"rgb(80, 80, 255)",2:"rgb(206, 61, 50)","2a":"rgb(210, 65, 55)","2b":"rgb(215, 70, 60)",3:"rgb(116, 155, 88)",4:"rgb(240, 230, 133)",5:"rgb(70, 105, 131)",6:"rgb(186, 99, 56)",7:"rgb(93, 177, 221)",8:"rgb(128, 34, 104)",9:"rgb(107, 215, 107)",10:"rgb(213, 149, 167)",11:"rgb(146, 72, 34)",12:"rgb(131, 123, 141)",13:"rgb(199, 81, 39)",14:"rgb(213, 143, 92)",15:"rgb(122, 101, 165)",16:"rgb(228, 175, 105)",17:"rgb(59, 27, 83)",18:"rgb(205, 222, 183)",19:"rgb(97, 42, 121)",20:"rgb(174, 31, 99)",21:"rgb(231, 199, 111)",22:"rgb(90, 101, 94)",23:"rgb(204, 153, 0)",24:"rgb(153, 204, 0)",25:"rgb(51, 204, 0)",26:"rgb(0, 204, 51)",27:"rgb(0, 204, 153)",28:"rgb(0, 153, 204)",29:"rgb(10, 71, 255)",30:"rgb(71, 117, 255)",31:"rgb(255, 194, 10)",32:"rgb(255, 209, 71)",33:"rgb(153, 0, 51)",34:"rgb(153, 26, 0)",35:"rgb(153, 102, 0)",36:"rgb(128, 153, 0)",37:"rgb(51, 153, 0)",38:"rgb(0, 153, 26)",39:"rgb(0, 153, 102)",40:"rgb(0, 128, 153)",41:"rgb(0, 51, 153)",42:"rgb(26, 0, 153)",43:"rgb(102, 0, 153)",44:"rgb(153, 0, 128)",45:"rgb(214, 0, 71)",46:"rgb(255, 20, 99)",47:"rgb(0, 214, 143)",48:"rgb(20, 255, 177)"};for(let Sy of Object.keys(Rf))Rf["chr"+Sy]=Rf[Sy];for(let Cy=1;Cy<=48;Cy++){if(10===Cy)continue;const Ay=Lf(Cy);Rf[Ay]=Rf[Cy.toString()]}function Lf(t){if(!+t)return!1;for(var e=String(+t).split(""),i=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"],n="",r=3;r--;)n=(i[+e.pop()+10*r]||"")+n;return Array(+e.join("")+1).join("M")+n}class Bf extends ch{constructor(t,e){super(t,e)}init(t){super.init(t),this.useChrColors=void 0===t.useChrColors||t.useChrColors,this.trait=t.trait,this.posteriorProbability=t.posteriorProbability,this.valueProperty="bed"===t.format?"score":"value",this.height=t.height||100,this.autoscale=t.autoscale,this.autoscalePercentile=void 0===t.autoscalePercentile?98:t.autoscalePercentile,this.background=t.background,this.divider=t.divider||"rgb(225,225,225)",this.dotSize=t.dotSize||3,this.popoverWindow=void 0===t.popoverWindow?1e8:t.popoverWindow,this.useChrColors?this.colorScale=new ea(t.colorTable||Rf):t.color?this.colorScale=new pf(t.color):this.colorScale=new df(t.colorScale||{thresholds:[5e-8,5e-4,.5],colors:["rgb(255,50,50)","rgb(251,100,100)","rgb(251,170,170)","rgb(227,238,249)"]}),this.featureSource=$c(t,this.browser.genome)}async postInit(){if("function"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),this.autoscale||(this.posteriorProbability?this.dataRange={min:void 0===this.config.min?0:this.config.min,max:void 0===this.config.max?1:this.config.max}:this.dataRange={min:void 0===this.config.min?0:this.config.min,max:void 0===this.config.max?25:this.config.max}),this}get supportsWholeGenome(){return!0}async getFeatures(t,e,i){const n=this.visibilityWindow;return this.featureSource.getFeatures({chr:t,start:e,end:i,visibilityWindow:n})}draw(t){const e=t.features,i=t.context,n=t.pixelWidth,r=t.pixelHeight;if(this.background&&na.fillRect(i,0,0,n,r,{fillStyle:this.background}),na.strokeLine(i,0,r-1,n,r-1,{strokeStyle:this.divider}),e){const s=t.bpPerPixel,o=t.bpStart,a=o+n*s+1;for(let t of e){const e=t.start;if(ea)break;let n;if(this.posteriorProbability)n=t[this.valueProperty];else{const e=t[this.valueProperty];if(!e)continue;n=-Math.log10(e)}const l=this.useChrColors?t._f?t._f.chr:t.chr:n,h=this.colorScale.getColor(l),c=(this.dataRange.max-this.dataRange.min)/r,u=Math.round((e-o)/s),d=Math.max(this.dotSize,r-Math.round((n-this.dataRange.min)/c));h&&na.setProperties(i,{fillStyle:h,strokeStyle:"black"}),na.fillCircle(i,u,d,this.dotSize),t.px=u,t.py=d}}}paintAxis(t,e,i){na.fillRect(t,0,0,e,i,{fillStyle:"rgb(255, 255, 255)"});var n={font:"normal 10px Arial",textAlign:"right",strokeStyle:"black"};const r=(this.dataRange.max-this.dataRange.min)/i;if(this.posteriorProbability){const e=.1;for(let s=this.dataRange.min;s0&&i.push("
"),5==r){i.push("...");break}if("function"==typeof s.popupData)i=i.concat(s.popupData());else{const t=s.realChr||s.chr,e=(s.realStart||s.start)+1;i.push({name:"chromosome",value:t}),i.push({name:"position",value:e}),i.push({name:"name",value:s.name}),n.posteriorProbability?i.push({name:"posterior probability",value:a}):i.push({name:"pValue",value:a})}r++}}}return i}menuItemList(){return Ui.numericDataMenuItems(this.trackView)}doAutoscale(t){if(t.length>0){const e=this.valueProperty,i=this.posteriorProbability,n=t.map((function(t){const n=t[e];return{value:i?n:-Math.log(n)/Math.LN10}}));this.dataRange=ha(n)}else this.posteriorProbability?this.dataRange={min:this.config.min||0,max:this.config.max||1}:this.dataRange={min:this.config.max||25,max:this.config.min||0};return this.dataRange}}class Nf extends ch{constructor(t,e){super(t,e)}init(t){super.init(t),this.autoscale=t.autoscale||void 0===t.max,this.dataRange={min:t.min||0,max:t.max},this.windowFunction=t.windowFunction||"mean",this.paintAxis=$u,this.graphType=t.graphType||"bar",t._featureSource?(this.featureSource=t._featureSource,delete t._featureSource):this.featureSource=$c(this.config,this.browser.genome),this.visibilityWindow=-1,this.featureSource.visibilityWindow=this.visibilityWindow}async postInit(){if("function"==typeof this.featureSource.getHeader){if(this.header=await this.featureSource.getHeader(),this.disposed)return;if(this.sampleNames=this.header.columnNames.slice(3),this.setTrackProperties(this.header),this.header.hasOwnProperty("clickToHighlight")){let t=this.header.clickToHighlight;this.config.clickToHighlight=t,this.config.samplesClickedToHighlight={}}if(this.header.hasOwnProperty("highlight")){this.config.highlightSamples={};let t=this.header.highlight;Array.isArray(t)||(t=[t]);for(let e of t){const t=e.split(";");2===t.length&&(this.config.highlightSamples[t[0]]=t[1])}}}}menuItemList(){return Ui.numericDataMenuItems(this.trackView)}async getFeatures(t,e,i){const n=await this.featureSource.getFeatures({chr:t,start:0,end:Number.MAX_SAFE_INTEGER,visibilityWindow:this.visibilityWindow});let r,s;for(let t=1;te&&(r=t-1),void 0===s&&n[t].start>i){s=t+1;break}return void 0===r&&(r=0),void 0===s&&(s=n.length),n.slice(r,s)}draw(t){const{features:e,context:i,bpPerPixel:n,bpStart:r,pixelWidth:s,pixelHeight:o}=t,a=t=>(this.dataRange.max-t)/(this.dataRange.max-this.dataRange.min)*o,l=function(t){let e=Math.floor((t-r)/n);return isNaN(e)&&console.warn("isNaN(x). feature start "+$i(t)+" bp start "+$i(r)),e};if(e&&e.length>0&&(void 0===this.dataRange.min&&(this.dataRange.min=0),this.dataRange.max>this.dataRange.min)){const t=this.config.highlightSamples,n=this.config.onlyHandleClicksForHighlightedSamples,r=this.config.clickToHighlight;let s=-1,o={},h=[],c=[];this.clickDetectorCache={};for(let u of e){const e=l(u.start),d=l(u.end),f=s>=0?l(s):e;if(!isNaN(e)&&!isNaN(d)){this.clickDetectorCache[e]=[],this.clickDetectorCache[d]=[];for(let s=0;s=1){const s=o[l],c=a(s),u=t&&t[l];u?h.push([f,c,e,g,u]):r&&l in this.config.samplesClickedToHighlight?h.push([f,c,e,g,this.config.samplesClickedToHighlight[l]]):na.strokeLine(i,f,c,e,g,{strokeStyle:"#D9D9D9"}),n&&!(l in t)||this.clickDetectorCache[e].push([f,c,e,g,l,u||"gray"])}if(d-e>=1){const s=t&&t[l];s?c.push([e,g,d,g,s]):r&&l in this.config.samplesClickedToHighlight?c.push([e,g,d,g,this.config.samplesClickedToHighlight[l]]):na.strokeLine(i,e,g,d,g,{strokeStyle:"gray"}),n&&!(l in t)||this.clickDetectorCache[d].push([e,g,d,g,l,s||"gray"])}o[l]=p}s=u.end}}for(let t of h)na.strokeLine(i,t[0],t[1],t[2],t[3],{strokeStyle:t[4],lineWidth:1.3});for(let t of c)na.strokeLine(i,t[0],t[1],t[2],t[3],{strokeStyle:t[4],lineWidth:2})}(t=>{if(this.config.hasOwnProperty("guideLines"))for(let e of this.config.guideLines)if(e.hasOwnProperty("color")&&e.hasOwnProperty("y")&&e.hasOwnProperty("dotted")){let i=a(e.y),n={strokeStyle:e.color,strokeWidth:2};e.dotted?na.dashedLine(t.context,0,i,t.pixelWidth,i,5,n):na.strokeLine(t.context,0,i,t.pixelWidth,i,n)}})(t)}doAutoscale(t){let e,i;return t.length>0?(e=Number.MAX_VALUE,i=-Number.MAX_VALUE,t.forEach((function(t){e=Math.min(e,...t.values),i=Math.max(i,...t.values)})),e-=.01,i+=.01):(e=0,i=100),{min:e,max:i}}clickedFeatures(t){const e=t.canvasX,i=t.canvasY;let n=null;for(n of Object.keys(this.clickDetectorCache))if(n=parseInt(n),n>=e)break;if(n){let t=Number.MAX_VALUE,o=[];const a=this.clickDetectorCache[n];for(let n of a){const r=n[0],s=n[2];if(es)return[];const a=n[1],l=n[3];if(iMath.max(a,l)+10)continue;const h=Ff(e,i,r,a,s,l);h0?l/h:0}class Of extends ch{constructor(t,e){super(t,e),t.height||(this.height=300),this.arcOrientation=!1,this.theta=Math.PI/2,"bp"===t.format?this.featureSource=new Pf(t,e.genome):this.featureSource=new bc(t,e.genome)}async getFeatures(t,e,i){const n=this.visibilityWindow;return this.featureSource.getFeatures({chr:t,start:e,end:i,visibilityWindow:n})}draw(t){const e=t.context,i=Math.PI/2,n=t.pixelWidth,r=t.pixelHeight;t.viewportWidth;const s=t.bpPerPixel,o=t.bpStart,a=s,l=this.arcOrientation;na.fillRect(e,0,t.pixelTop,n,r,{fillStyle:"rgb(255, 255, 255)"});const h=t.features;if(h){Df(h,1);for(let t of h)if(t.startLeft){let n=Math.round((t.startLeft-o)/a),r=Math.round((t.startRight-o)/a),s=Math.round((t.endLeft-o)/a),h=Math.round((t.endRight-o)/a);e.fillStyle=t.color,e.strokeStyle=t.color,e.beginPath();let c=(n+h)/2,u=(h-n)/2,d=this.height,f=Math.PI+(Math.PI/2-i),p=2*Math.PI-(Math.PI/2-i);l?(d=0,e.arc(c,d,u,p,f),e.lineTo(h,d)):(e.arc(c,d,u,f,p),e.lineTo(s,d));const g=(r+s)/2,m=(s-r)/2,b=d;l?(e.arc(g,b,m,f,p,!0),e.lineTo(s,b)):(e.arc(g,b,m,p,f,!0),e.lineTo(n,b)),e.stroke(),e.fill(),t.drawState={x1:c,y1:d,r1:u,x2:g,y2:b,r2:m,sa:f,ea:p}}else{let n=Math.round((t.start-o)/a),r=Math.round((t.end-o)/a);e.strokeStyle=t.color,e.beginPath();let s=(n+r)/2,h=(r-n)/2,c=this.height,u=Math.PI+(Math.PI/2-i),d=2*Math.PI-(Math.PI/2-i);l?(c=0,e.arc(s,c,h,d,u)):e.arc(s,c,h,u,d),e.stroke(),t.drawState={x1:s,y1:c,r1:h,sa:u,ea:d}}}}clickedFeatures(t){const e=super.clickedFeatures(t),i=[];Df(e,-1);for(let n of e){const e=n.drawState,r=t.canvasX-e.x1,s=t.canvasY-e.y1,o=Math.sqrt(r*r+s*s),a=e.r1+3;let l,h;if(void 0===e.x2)l=o,h=e.r1-3;else{const i=t.canvasX-e.x2,n=t.canvasY-e.y2;l=Math.sqrt(i*i+n*n),h=e.r2-3}if(oh){i.push(n);break}}return i}popupData(t,e){if(void 0===e&&(e=this.clickedFeatures(t)),e&&e.length>0)return this.extractPopupData(e[0],this.getGenomeId())}menuItemList(){var t=this;return[{name:"Toggle arc direction",click:function(){t.arcOrientation=!t.arcOrientation,t.trackView.repaintViews()}}]}}function Df(t,e){t.sort((function(t,i){const n=void 0===t.score?-Number.MAX_VALUE:t.score,r=void 0===i.score?-Number.MAX_VALUE:i.score;return(void 0===e?1:e)*(n-r)}))}class Pf{constructor(t,e){this.config=t,this.genome=e}async getFeatures({chr:t,start:e,end:i,bpPerPixel:n,visibilityWindow:r}){const s=this.genome;if(this.featureCache)return this.featureCache.queryFeatures(t,e,i);{const n=la(this.config),r=await zo.loadString(this.config.url,n);return this.featureCache=new Zo(function(t){if(!t)return null;const e=Hh(t);let i,n=!0;const r=[],s=[],o=[];for(;void 0!==(i=e.nextLine());){const t=i.split("\t");if(n&&i.startsWith("color:")){const e="rgb("+t[1]+","+t[2]+","+t[3]+")";r.push(e),t.length>4&&s.push(t[4])}else{n=!1;const e=t[0],i=Number.parseInt(t[1])-1,l=Number.parseInt(t[2])-1,h=Number.parseInt(t[3]),c=Number.parseInt(t[4]);var a=Number.parseInt(t[5]);const u=r[a];let d;d=i<=c?{chr:e,startLeft:Math.min(i,l),startRight:Math.max(i,l),endLeft:Math.min(h,c),endRight:Math.max(h,c),color:u,score:a}:{chr:e,startLeft:Math.min(h,c),startRight:Math.max(h,c),endLeft:Math.min(i,l),endRight:Math.max(i,l),color:u,score:a},d.start=d.startLeft,d.end=d.endRight,s.length>a&&(d.description=s[a]),o.push(d)}}return o}(r),s),this.featureCache.queryFeatures(t,e,i)}}}class zf{constructor(t){this.browser=t,this.type="ideogram",this.height=16,this.order=Number.MIN_SAFE_INTEGER,this.disableButtons=!0,this.ignoreTrackMenu=!0}async getFeatures(t,e,i){return[]}computePixelHeight(t){return this.height}draw({context:t,referenceFrame:e,pixelWidth:i,pixelHeight:n}){const r=e.chr,s=e.genome.getChromosome(r);if(void 0===s||i<=0||n<=0||"all"===r.toLowerCase())return;!function({ctx:t,chr:e,referenceFrame:i,genome:n,width:r,height:s,stainColors:o}){const a=.5;if(void 0===n)return;na.fillRect(t,0,0,r,s,{fillStyle:xo.greyScale(255)});const l=n.getCytobands(e);if(l){const e=0+s/2,i=[],n=[];if(0===l.length)return;const h=r/l[l.length-1].end;t.beginPath(),na.roundRect(t,a,.5,r-1,s-1,(s-1)/2,0,1),t.clip();for(let r=0;r0&&h[h.length-1].end&&(l=Math.max(l,h[h.length-1].end),s.bpLength=l),o{Vf.getColor(t)}));const Hf={};class jf extends ch{constructor(t,e){super(t,e)}init(t){super.init(t),this.type=t.type||"junctions",t._featureSource?(this.featureSource=t._featureSource,delete t._featureSource):this.featureSource=t.featureSource?t.featureSource:$c(t,this.browser.genome),this.margin=void 0===t.margin?10:t.margin,this.height||(this.height=100),void 0===t.colorByNumReadsThreshold&&(t.colorByNumReadsThreshold=5)}async postInit(){if("function"!=typeof this.featureSource.getHeader||(this.header=await this.featureSource.getHeader(),!this.disposed))return this.header&&this.setTrackProperties(this.header),void 0===this.visibilityWindow&&"function"==typeof this.featureSource.defaultVisibilityWindow&&(this.visibilityWindow=await this.featureSource.defaultVisibilityWindow()),this}get supportsWholeGenome(){return!1}async getFeatures(t,e,i,n){const r=this.visibilityWindow;return this.featureSource.getFeatures({chr:t,start:e,end:i,bpPerPixel:n,visibilityWindow:r})}computePixelHeight(t){return this.height}draw(t){const e=t.features,i=t.context,n=t.bpPerPixel,r=t.bpStart,s=t.pixelWidth,o=t.pixelHeight,a=r+s*n+1;if(this.config.isMergedTrack||na.fillRect(i,0,t.pixelTop,s,o,{fillStyle:"rgb(255, 255, 255)"}),e){Hf.referenceFrame=t.viewport.referenceFrame,Hf.referenceFrameStart=Hf.referenceFrame.start,Hf.referenceFrameEnd=Hf.referenceFrameStart+Hf.referenceFrame.toBP(t.viewport.getWidth()),Hf.featureZoomOutTracker={};for(let t of e)if(!(t.enda)break;this.renderJunction(t,r,n,o,i)}}else console.log("No feature list")}renderJunction(t,e,i,n,r){t.isVisible=!1;const s=Math.round((t.start-e)/i),o=Math.round((t.end-e)/i),a=(s+o)/2;if(o-s<=3){if(a in Hf.featureZoomOutTracker)return;Hf.featureZoomOutTracker[a]=!0}if(this.config.hideAnnotatedJunctions&&"true"===t.attributes.annotated_junction)return;if(this.config.hideUnannotatedJunctions&&"false"===t.attributes.annotated_junction)return;if(this.config.hideMotifs&&this.config.hideMotifs.includes(t.attributes.motif))return;if(this.config.hideStrand===t.strand)return;if(this.config.minJunctionEndsVisible){let e=0;if(t.start>=Hf.referenceFrameStart&&t.start<=Hf.referenceFrameEnd&&(e+=1),t.end>=Hf.referenceFrameStart&&t.end<=Hf.referenceFrameEnd&&(e+=1),e0&&h/c>this.config.maxFractionMultiMappedReads)return;if(t.attributes.maximum_spliced_alignment_overhang&&parseInt(t.attributes.maximum_spliced_alignment_overhang)this.config.maxSamplesWithThisJunction)return;if(t.attributes.num_samples_total&&(t.attributes.percent_samples_with_this_junction=100*u/Number(t.attributes.num_samples_total),this.config.minPercentSamplesWithThisJunction&&(t.attributes.percent_samples_with_this_junctionthis.config.maxPercentSamplesWithThisJunction)))return}const d=this.margin,f=this.height,p=d+.5*f;let g=d;const m=d+f-10,b=(s+a)/2,y=(a+o)/2;let v,w,_=1;t.attributes.line_width?_=Number(t.attributes.line_width):(void 0===this.config.thicknessBasedOn||"numUniqueReads"===this.config.thicknessBasedOn?_=l:"numReads"===this.config.thicknessBasedOn?_=c:"numSamplesWithThisJunction"===this.config.thicknessBasedOn&&void 0!==u&&(_=u),_=1+Math.log(_+1)/Math.log(12)),void 0===this.config.bounceHeightBasedOn||"random"===this.config.bounceHeightBasedOn?v=(t.start+t.end)%7:"distance"===this.config.bounceHeightBasedOn?v=6*(t.end-t.start)/(Hf.referenceFrameEnd-Hf.referenceFrameStart):"thickness"===this.config.bounceHeightBasedOn&&(v=2*_),g+=f*Math.max(7-v,0)/10,w=t.attributes.color?t.attributes.color:void 0===this.config.colorBy||"numUniqueReads"===this.config.colorBy?l>this.config.colorByNumReadsThreshold?"blue":"#AAAAAA":"numReads"===this.config.colorBy?c>this.config.colorByNumReadsThreshold?"blue":"#AAAAAA":"isAnnotatedJunction"===this.config.colorBy?"true"===t.attributes.annotated_junction?"#b0b0ec":"orange":"strand"===this.config.colorBy?"+"===t.strand?"#b0b0ec":"#ecb0b0":"motif"===this.config.colorBy?Vf.getColor(t.attributes.motif):"#AAAAAA";let x="";t.attributes.label?x=t.attributes.label.replace(/_/g," "):void 0===this.config.labelWith||"uniqueReadCount"===this.config.labelWith?x=l:"totalReadCount"===this.config.labelWith?x=c:"numSamplesWithThisJunction"===this.config.labelWith?void 0!==u&&(x=u):"percentSamplesWithThisJunction"===this.config.labelWith?void 0!==t.attributes.percent_samples_with_this_junction&&(x=t.attributes.percent_samples_with_this_junction.toFixed(0)+"%"):"motif"===this.config.labelWith&&void 0!==t.attributes.motif&&(x+=t.attributes.motif),"uniqueReadCount"===this.config.labelWithInParen?x+=" ("+l+")":"totalReadCount"===this.config.labelWithInParen?x+=" ("+c+")":"multiMappedReadCount"===this.config.labelWithInParen?h>0&&(x+=" (+"+h+")"):"numSamplesWithThisJunction"===this.config.labelWithInParen?void 0!==u&&(x+=" ("+u+")"):"percentSamplesWithThisJunction"===this.config.labelWithInParen?void 0!==t.attributes.percent_samples_with_this_junction&&(x+=" ("+t.attributes.percent_samples_with_this_junction.toFixed(0)+"%)"):"motif"===this.config.labelWithInParen&&void 0!==t.attributes.motif&&(x+=` ${t.attributes.motif}`),t.isVisible=!0,r.beginPath(),r.moveTo(s,m),r.bezierCurveTo(b,g,y,g,o,m),r.lineWidth=_,r.strokeStyle=w,r.stroke();const k=(t,e,i,n)=>{t.beginPath(),t.moveTo(e,i),t.lineTo(e-n/2,i-n),t.lineTo(e+n/2,i-n),t.lineTo(e,i),t.closePath(),t.fill()};if(t.attributes.left_shape||t.attributes.right_shape){r.fillStyle=w;const e=r.lineWidth>2?10:7;t.attributes.left_shape&&k(r,s,m,e),t.attributes.right_shape&&k(r,o,m,e)}r.fillText(x,a-r.measureText(x).width/2,(7*g+p)/8)}clickedFeatures(t){return super.clickedFeatures(t).filter((function(t){return t.isVisible&&t.attributes}))}popupData(t,e){void 0===e&&(e=this.clickedFeatures(t));const i=t.genomicLocation,n=[];for(let t of e){const e="function"==typeof t.popupData?t.popupData(i):this.extractPopupData(t._f||t,this.getGenomeId());e&&(n.length>0&&n.push("

"),Array.prototype.push.apply(n,e))}return n}dispose(){this.trackView=void 0}}class $f{constructor(t){var e;this.config=t,this.url=(e=t.path||t.url).includes("//www.dropbox.com")?e.replace("//www.dropbox.com","//dl.dropboxusercontent.com"):e.startsWith("ftp://ftp.ncbi.nlm.nih.gov")?e.replace("ftp://","https://"):e}async read(t,e){const i=this.config.headers||{};if(void 0!==t&&e){const n="bytes="+t+"-"+(t+e-1);i.Range=n}let n=this.url.slice();if(this.config.oauthToken){const t=async function(t){return"function"==typeof t?await Promise.resolve(t()):t}(this.config.oauthToken);i.Authorization=`Bearer ${t}`}this.config.apiKey&&(n=function(t,e,i){const n=t.includes("?")?"&":"?";return t+n+"key="+i}(n,0,this.config.apiKey));const r=await fetch(n,{method:"GET",headers:i,redirect:"follow",mode:"cors"}),s=r.status;if(s>=400){const t=Error(r.statusText);throw t.code=s,t}return r.arrayBuffer()}}class qf{constructor(t){this.file=t.file,this.fetchSize=t.fetchSize||16e3,this.maxSize=t.maxSize||1e6,this.buffers=[]}async read(t,e){let i=this.buffers.filter((i=>i.overlaps(t,t+e)));for(let n of i)if(n.contains(t,t+e))return n.slice(t,t+e);if(0===i.length){let i=Math.max(e,this.fetchSize);this.buffers.sort(((t,e)=>t.start-e.start));const n=function(e,i,n){let r=-1,s=e.length;for(;1+r>1);e[i].start>t?s=i:r=i}return s}(this.buffers);nt.start-e.start));const n=[];let r=t;for(let t of i){if(rr){const t=r,e=s-t,i=await this.file.read(t,e),o=new Wf(t,i);n.push(o)}const o=n[0].start,a=function(t){const e=t.reduce(((t,e)=>t+e.byteLength),0),i=new Uint8Array(e);let n=0;for(let e of t)i.set(new Uint8Array(e),n),n+=e.byteLength;return i.buffer}(n.map((t=>t.buffer))),l=new Wf(o,a),h=new Set(i);return this.buffers=this.buffers.filter((t=>!h.has(t))),this.addBuffer(l),l.slice(t,t+e)}}addBuffer(t){const e=this.buffers.reduce(((t,e)=>t+e.size),0)+t.size;if(e>this.maxSize){const t=e-this.maxSize;this.buffers.sort(((t,e)=>t.creationTime-e.creationTime));let i,n=0;for(i=0;it));i++);this.buffers=ithis.buffer.byteLength)throw Error("buffer bounds error");return this.buffer.slice(t-this.start,e-this.start)}get end(){return this.start+this.buffer.byteLength}get size(){return this.buffer.byteLength}contains(t,e){return t>=this.start&&e<=this.end}overlaps(t,e){return t>this.start&&tthis.start&&e=!@]?(i|u|f)(\d*)/);i=parseInt(s||4,10),e="get"+Jf[r]+(8*i).toFixed()}return[e,n,i]}var ep=new class{constructor(){this.big_endian=function(){const t=new Uint8Array(4);return!((new Uint32Array(t.buffer)[0]=1)&t[0])}(),this.getters={s:"getUint8",b:"getInt8",B:"getUint8",h:"getInt16",H:"getUint16",i:"getInt32",I:"getUint32",l:"getInt32",L:"getUint32",q:"getInt64",Q:"getUint64",f:"getFloat32",d:"getFloat64"},this.byte_lengths={s:1,b:1,B:1,h:2,H:2,i:4,I:4,l:4,L:4,q:8,Q:8,f:4,d:8};let t=Object.keys(this.byte_lengths).join("");this.fmt_size_regex="(\\d*)(["+t+"])"}calcsize(t){for(var e,i=0,n=new RegExp(this.fmt_size_regex,"g");null!==(e=n.exec(t));){let t=parseInt(e[1]||1,10),n=e[2];i+=t*this.byte_lengths[n]}return i}_is_big_endian(t){return!/^)/.test(t)||this.big_endian)}async unpack_from_async(t,e,i){i=Number(i||0);const n=this.calcsize(t),r=await e.slice(i,i+n);let s=0;for(var o,a=new ip(r),l=[],h=this._is_big_endian(t),c=new RegExp(this.fmt_size_regex,"g");null!==(o=c.exec(t));){let t=parseInt(o[1]||1,10),e=o[2],i=this.getters[e],n=this.byte_lengths[e];if("s"==e)l.push((new TextDecoder).decode(r.slice(s,s+t))),s+=t;else for(var u=0;ut+(e<<8*i)),0);return o}var sp=class{constructor(t,e){this.buf=t,this.offset=e,this.dtype=this.determine_dtype()}async determine_dtype(){let t=await Zf(op,this.buf,this.offset);this.offset+=ap;let e=15&t.get("class_and_version");if(e==lp)return this._determine_dtype_fixed_point(t);if(e==hp)return this._determine_dtype_floating_point(t);if(e==cp)throw"Time datatype class not supported.";if(e==up)return this._determine_dtype_string(t);if(e==dp)throw"Bitfield datatype class not supported.";if(e==fp)return{datatype_class:fp,size:t.get("size")};if(e==pp)return this._determine_dtype_compound(t);if(e==gp)return["REFERENCE",t.get("size")];if(e==mp)return this.determine_dtype();if(e==yp)throw"Array datatype class not supported.";if(e==bp){let e=this._determine_dtype_vlen(t);return"VLEN_SEQUENCE"==e[0]&&(e=["VLEN_SEQUENCE",this.determine_dtype()]),e}throw"Invalid datatype class "+e}_determine_dtype_fixed_point(t){let e=t.get("size");if(![1,2,4,8].includes(e))throw"Unsupported datatype size";var i,n;return i=(8&t.get("class_bit_field_0"))>0?"i":"u",n=0==(1&t.get("class_bit_field_0"))?"<":">",this.offset+=4,n+i+e.toFixed()}_determine_dtype_floating_point(t){let e=t.get("size");if(![1,2,4,8].includes(e))throw"Unsupported datatype size";var i;return i=0==(1&t.get("class_bit_field_0"))?"<":">",this.offset+=12,i+"f"+e.toFixed()}_determine_dtype_string(t){return"S"+t.get("size").toFixed()}_determine_dtype_vlen(t){return 1!=(1&t.get("class_bit_field_0"))?["VLEN_SEQUENCE",0,0]:["VLEN_STRING",t.get("class_bit_field_0")>>4,1&t.get("class_bit_field_1")]}_determine_dtype_compound(t){throw"Compound type not yet implemented!"}},op=new Map([["class_and_version","B"],["class_bit_field_0","B"],["class_bit_field_1","B"],["class_bit_field_2","B"],["size","I"]]),ap=Xf(op);Xf(new Map([["offset","I"],["dimensionality","B"],["reserved_0","B"],["reserved_1","B"],["reserved_2","B"],["permutation","I"],["reserved_3","I"],["dim_size_1","I"],["dim_size_2","I"],["dim_size_3","I"],["dim_size_4","I"]]));var lp=0,hp=1,cp=2,up=3,dp=4,fp=5,pp=6,gp=7,mp=8,bp=9,yp=10;function vp(t){let e=t.length;for(;--e>=0;)t[e]=0}vp(new Array(576)),vp(new Array(60)),vp(new Array(512)),vp(new Array(256)),vp(new Array(29)),vp(new Array(30));var wp=(t,e,i,n)=>{let r=65535&t|0,s=t>>>16&65535|0,o=0;for(;0!==i;){o=i>2e3?2e3:i,i-=o;do{r=r+e[n++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16|0},_p=new Uint32Array((()=>{let t,e=[];for(var i=0;i<256;i++){t=i;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e})()),xp=(t,e,i,n)=>{const r=_p,s=n+i;t^=-1;for(let i=n;i>>8^r[255&(t^e[i])];return-1^t},kp={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Sp={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},Cp=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Ap={assign:function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const e in i)Cp(i,e)&&(t[e]=i[e])}}return t},flattenChunks:t=>{let e=0;for(let i=0,n=t.length;i=252?6:Iy>=248?5:Iy>=240?4:Iy>=224?3:Iy>=192?2:1;Ip[254]=Ip[254]=1;var Ep={string2buf:t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,i,n,r,s,o=t.length,a=0;for(r=0;r>>6,e[s++]=128|63&i):i<65536?(e[s++]=224|i>>>12,e[s++]=128|i>>>6&63,e[s++]=128|63&i):(e[s++]=240|i>>>18,e[s++]=128|i>>>12&63,e[s++]=128|i>>>6&63,e[s++]=128|63&i);return e},buf2string:(t,e)=>{const i=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let n,r;const s=new Array(2*i);for(r=0,n=0;n4)s[r++]=65533,n+=o-1;else{for(e&=2===o?31:3===o?15:7;o>1&&n1?s[r++]=65533:e<65536?s[r++]=e:(e-=65536,s[r++]=55296|e>>10&1023,s[r++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Tp)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let i="";for(let n=0;n{(e=e||t.length)>t.length&&(e=t.length);let i=e-1;for(;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+Ip[t[i]]>e?i:e}},Mp=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},Rp=function(t,e){let i,n,r,s,o,a,l,h,c,u,d,f,p,g,m,b,y,v,w,_,x,k,S,C;const A=t.state;i=t.next_in,S=t.input,n=i+(t.avail_in-5),r=t.next_out,C=t.output,s=r-(e-t.avail_out),o=r+(t.avail_out-257),a=A.dmax,l=A.wsize,h=A.whave,c=A.wnext,u=A.window,d=A.hold,f=A.bits,p=A.lencode,g=A.distcode,m=(1<>>24,d>>>=v,f-=v,v=y>>>16&255,0===v)C[r++]=65535&y;else{if(!(16&v)){if(0==(64&v)){y=p[(65535&y)+(d&(1<>>=v,f-=v),f<15&&(d+=S[i++]<>>24,d>>>=v,f-=v,v=y>>>16&255,!(16&v)){if(0==(64&v)){y=g[(65535&y)+(d&(1<a){t.msg="invalid distance too far back",A.mode=30;break t}if(d>>>=v,f-=v,v=r-s,_>v){if(v=_-v,v>h&&A.sane){t.msg="invalid distance too far back",A.mode=30;break t}if(x=0,k=u,0===c){if(x+=l-v,v2;)C[r++]=k[x++],C[r++]=k[x++],C[r++]=k[x++],w-=3;w&&(C[r++]=k[x++],w>1&&(C[r++]=k[x++]))}else{x=r-_;do{C[r++]=C[x++],C[r++]=C[x++],C[r++]=C[x++],w-=3}while(w>2);w&&(C[r++]=C[x++],w>1&&(C[r++]=C[x++]))}break}}break}}while(i>3,i-=w,f-=w<<3,d&=(1<{const l=a.bits;let h,c,u,d,f,p,g=0,m=0,b=0,y=0,v=0,w=0,_=0,x=0,k=0,S=0,C=null,A=0;const T=new Uint16Array(16),I=new Uint16Array(16);let E,M,R,L=null,B=0;for(g=0;g<=15;g++)T[g]=0;for(m=0;m=1&&0===T[y];y--);if(v>y&&(v=y),0===y)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(b=1;b0&&(0===t||1!==y))return-1;for(I[1]=0,g=1;g<15;g++)I[g+1]=I[g]+T[g];for(m=0;m852||2===t&&k>592)return 1;for(;;){E=g-_,o[m]p?(M=L[B+o[m]],R=C[A+o[m]]):(M=96,R=0),h=1<>_)+c]=E<<24|M<<16|R|0}while(0!==c);for(h=1<>=1;if(0!==h?(S&=h-1,S+=h):S=0,m++,0==--T[g]){if(g===y)break;g=e[i+o[m]]}if(g>v&&(S&d)!==u){for(0===_&&(_=v),f+=b,w=g-_,x=1<852||2===t&&k>592)return 1;u=S&d,r[u]=v<<24|w<<16|f-s|0}}return 0!==S&&(r[f+S]=g-_<<24|64<<16|0),a.bits=v,0},{Z_FINISH:Dp,Z_BLOCK:Pp,Z_TREES:zp,Z_OK:Up,Z_STREAM_END:Vp,Z_NEED_DICT:Hp,Z_STREAM_ERROR:jp,Z_DATA_ERROR:$p,Z_MEM_ERROR:qp,Z_BUF_ERROR:Wp,Z_DEFLATED:Gp}=Sp,Zp=12,Yp=30,Qp=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function Xp(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var Kp,Jp,tg=t=>{if(!t||!t.state)return jp;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,Up},eg=t=>{if(!t||!t.state)return jp;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,tg(t)},ig=(t,e)=>{let i;if(!t||!t.state)return jp;const n=t.state;return e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?jp:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=i,n.wbits=e,eg(t))},ng=(t,e)=>{if(!t)return jp;const i=new Xp;t.state=i,i.window=null;const n=ig(t,e);return n!==Up&&(t.state=null),n},rg=!0,sg=t=>{if(rg){Kp=new Int32Array(512),Jp=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(Op(1,t.lens,0,288,Kp,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;Op(2,t.lens,0,32,Jp,0,t.work,{bits:5}),rg=!1}t.lencode=Kp,t.lenbits=9,t.distcode=Jp,t.distbits=5},og=(t,e,i,n)=>{let r;const s=t.state;return null===s.window&&(s.wsize=1<=s.wsize?(s.window.set(e.subarray(i-s.wsize,i),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>n&&(r=n),s.window.set(e.subarray(i-n,i-n+r),s.wnext),(n-=r)?(s.window.set(e.subarray(i-n,i),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whaveng(t,15),inflateInit2:ng,inflate:(t,e)=>{let i,n,r,s,o,a,l,h,c,u,d,f,p,g,m,b,y,v,w,_,x,k,S=0;const C=new Uint8Array(4);let A,T;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return jp;i=t.state,i.mode===Zp&&(i.mode=13),o=t.next_out,r=t.output,l=t.avail_out,s=t.next_in,n=t.input,a=t.avail_in,h=i.hold,c=i.bits,u=a,d=l,k=Up;t:for(;;)switch(i.mode){case 1:if(0===i.wrap){i.mode=13;break}for(;c<16;){if(0===a)break t;a--,h+=n[s++]<>>8&255,i.check=xp(i.check,C,2,0),h=0,c=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&h)<<8)+(h>>8))%31){t.msg="incorrect header check",i.mode=Yp;break}if((15&h)!==Gp){t.msg="unknown compression method",i.mode=Yp;break}if(h>>>=4,c-=4,x=8+(15&h),0===i.wbits)i.wbits=x;else if(x>i.wbits){t.msg="invalid window size",i.mode=Yp;break}i.dmax=1<>8&1),512&i.flags&&(C[0]=255&h,C[1]=h>>>8&255,i.check=xp(i.check,C,2,0)),h=0,c=0,i.mode=3;case 3:for(;c<32;){if(0===a)break t;a--,h+=n[s++]<>>8&255,C[2]=h>>>16&255,C[3]=h>>>24&255,i.check=xp(i.check,C,4,0)),h=0,c=0,i.mode=4;case 4:for(;c<16;){if(0===a)break t;a--,h+=n[s++]<>8),512&i.flags&&(C[0]=255&h,C[1]=h>>>8&255,i.check=xp(i.check,C,2,0)),h=0,c=0,i.mode=5;case 5:if(1024&i.flags){for(;c<16;){if(0===a)break t;a--,h+=n[s++]<>>8&255,i.check=xp(i.check,C,2,0)),h=0,c=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(f=i.length,f>a&&(f=a),f&&(i.head&&(x=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(s,s+f),x)),512&i.flags&&(i.check=xp(i.check,n,f,s)),a-=f,s+=f,i.length-=f),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===a)break t;f=0;do{x=n[s+f++],i.head&&x&&i.length<65536&&(i.head.name+=String.fromCharCode(x))}while(x&&f>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=Zp;break;case 10:for(;c<32;){if(0===a)break t;a--,h+=n[s++]<>>=7&c,c-=7&c,i.mode=27;break}for(;c<3;){if(0===a)break t;a--,h+=n[s++]<>>=1,c-=1,3&h){case 0:i.mode=14;break;case 1:if(sg(i),i.mode=20,e===zp){h>>>=2,c-=2;break t}break;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=Yp}h>>>=2,c-=2;break;case 14:for(h>>>=7&c,c-=7&c;c<32;){if(0===a)break t;a--,h+=n[s++]<>>16^65535)){t.msg="invalid stored block lengths",i.mode=Yp;break}if(i.length=65535&h,h=0,c=0,i.mode=15,e===zp)break t;case 15:i.mode=16;case 16:if(f=i.length,f){if(f>a&&(f=a),f>l&&(f=l),0===f)break t;r.set(n.subarray(s,s+f),o),a-=f,s+=f,l-=f,o+=f,i.length-=f;break}i.mode=Zp;break;case 17:for(;c<14;){if(0===a)break t;a--,h+=n[s++]<>>=5,c-=5,i.ndist=1+(31&h),h>>>=5,c-=5,i.ncode=4+(15&h),h>>>=4,c-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=Yp;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,c-=3}for(;i.have<19;)i.lens[I[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,A={bits:i.lenbits},k=Op(0,i.lens,0,19,i.lencode,0,i.work,A),i.lenbits=A.bits,k){t.msg="invalid code lengths set",i.mode=Yp;break}i.have=0,i.mode=19;case 19:for(;i.have>>24,b=S>>>16&255,y=65535&S,!(m<=c);){if(0===a)break t;a--,h+=n[s++]<>>=m,c-=m,i.lens[i.have++]=y;else{if(16===y){for(T=m+2;c>>=m,c-=m,0===i.have){t.msg="invalid bit length repeat",i.mode=Yp;break}x=i.lens[i.have-1],f=3+(3&h),h>>>=2,c-=2}else if(17===y){for(T=m+3;c>>=m,c-=m,x=0,f=3+(7&h),h>>>=3,c-=3}else{for(T=m+7;c>>=m,c-=m,x=0,f=11+(127&h),h>>>=7,c-=7}if(i.have+f>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=Yp;break}for(;f--;)i.lens[i.have++]=x}}if(i.mode===Yp)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=Yp;break}if(i.lenbits=9,A={bits:i.lenbits},k=Op(1,i.lens,0,i.nlen,i.lencode,0,i.work,A),i.lenbits=A.bits,k){t.msg="invalid literal/lengths set",i.mode=Yp;break}if(i.distbits=6,i.distcode=i.distdyn,A={bits:i.distbits},k=Op(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,A),i.distbits=A.bits,k){t.msg="invalid distances set",i.mode=Yp;break}if(i.mode=20,e===zp)break t;case 20:i.mode=21;case 21:if(a>=6&&l>=258){t.next_out=o,t.avail_out=l,t.next_in=s,t.avail_in=a,i.hold=h,i.bits=c,Rp(t,d),o=t.next_out,r=t.output,l=t.avail_out,s=t.next_in,n=t.input,a=t.avail_in,h=i.hold,c=i.bits,i.mode===Zp&&(i.back=-1);break}for(i.back=0;S=i.lencode[h&(1<>>24,b=S>>>16&255,y=65535&S,!(m<=c);){if(0===a)break t;a--,h+=n[s++]<>v)],m=S>>>24,b=S>>>16&255,y=65535&S,!(v+m<=c);){if(0===a)break t;a--,h+=n[s++]<>>=v,c-=v,i.back+=v}if(h>>>=m,c-=m,i.back+=m,i.length=y,0===b){i.mode=26;break}if(32&b){i.back=-1,i.mode=Zp;break}if(64&b){t.msg="invalid literal/length code",i.mode=Yp;break}i.extra=15&b,i.mode=22;case 22:if(i.extra){for(T=i.extra;c>>=i.extra,c-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;S=i.distcode[h&(1<>>24,b=S>>>16&255,y=65535&S,!(m<=c);){if(0===a)break t;a--,h+=n[s++]<>v)],m=S>>>24,b=S>>>16&255,y=65535&S,!(v+m<=c);){if(0===a)break t;a--,h+=n[s++]<>>=v,c-=v,i.back+=v}if(h>>>=m,c-=m,i.back+=m,64&b){t.msg="invalid distance code",i.mode=Yp;break}i.offset=y,i.extra=15&b,i.mode=24;case 24:if(i.extra){for(T=i.extra;c>>=i.extra,c-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=Yp;break}i.mode=25;case 25:if(0===l)break t;if(f=d-l,i.offset>f){if(f=i.offset-f,f>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=Yp;break}f>i.wnext?(f-=i.wnext,p=i.wsize-f):p=i.wnext-f,f>i.length&&(f=i.length),g=i.window}else g=r,p=o-i.offset,f=i.length;f>l&&(f=l),l-=f,i.length-=f;do{r[o++]=g[p++]}while(--f);0===i.length&&(i.mode=21);break;case 26:if(0===l)break t;r[o++]=i.length,l--,i.mode=21;break;case 27:if(i.wrap){for(;c<32;){if(0===a)break t;a--,h|=n[s++]<{if(!t||!t.state)return jp;let e=t.state;return e.window&&(e.window=null),t.state=null,Up},inflateGetHeader:(t,e)=>{if(!t||!t.state)return jp;const i=t.state;return 0==(2&i.wrap)?jp:(i.head=e,e.done=!1,Up)},inflateSetDictionary:(t,e)=>{const i=e.length;let n,r,s;return t&&t.state?(n=t.state,0!==n.wrap&&11!==n.mode?jp:11===n.mode&&(r=1,r=wp(r,e,i,0),r!==n.check)?$p:(s=og(t,e,i,i),s?(n.mode=31,qp):(n.havedict=1,Up))):jp},inflateInfo:"pako inflate (from Nodeca project)"},lg=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1},hg=Object.prototype.toString,{Z_NO_FLUSH:cg,Z_FINISH:ug,Z_OK:dg,Z_STREAM_END:fg,Z_NEED_DICT:pg,Z_STREAM_ERROR:gg,Z_DATA_ERROR:mg,Z_MEM_ERROR:bg}=Sp;function yg(t){this.options=Ap.assign({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Mp,this.strm.avail_out=0;let i=ag.inflateInit2(this.strm,e.windowBits);if(i!==dg)throw new Error(kp[i]);if(this.header=new lg,ag.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Ep.string2buf(e.dictionary):"[object ArrayBuffer]"===hg.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(i=ag.inflateSetDictionary(this.strm,e.dictionary),i!==dg)))throw new Error(kp[i])}function vg(t,e){const i=new yg(e);if(i.push(t),i.err)throw i.msg||kp[i.err];return i.result}yg.prototype.push=function(t,e){const i=this.strm,n=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=e===~~e?e:!0===e?ug:cg,"[object ArrayBuffer]"===hg.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),s=ag.inflate(i,o),s===pg&&r&&(s=ag.inflateSetDictionary(i,r),s===dg?s=ag.inflate(i,o):s===mg&&(s=pg));i.avail_in>0&&s===fg&&i.state.wrap>0&&0!==t[i.next_in];)ag.inflateReset(i),s=ag.inflate(i,o);switch(s){case gg:case mg:case pg:case bg:return this.onEnd(s),this.ended=!0,!1}if(a=i.avail_out,i.next_out&&(0===i.avail_out||s===fg))if("string"===this.options.to){let t=Ep.utf8border(i.output,i.next_out),e=i.next_out-t,r=Ep.buf2string(i.output,t);i.next_out=e,i.avail_out=n-e,e&&i.output.set(i.output.subarray(t,t+e),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(s!==dg||0!==a){if(s===fg)return s=ag.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},yg.prototype.onData=function(t){this.chunks.push(t)},yg.prototype.onEnd=function(t){t===dg&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Ap.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var wg={Inflate:yg,inflate:vg,inflateRaw:function(t,e){return(e=e||{}).raw=!0,vg(t,e)},ungzip:vg,constants:Sp},{Inflate:_g,inflate:xg,inflateRaw:kg,ungzip:Sg}=wg,Cg=xg,Ag=Sg,Tg=new Map([[1,function(t,e){let i=new Uint8Array(t);return Cg(i).buffer}],[2,function(t,e){let i=t.byteLength,n=new Uint8Array(i),r=Math.floor(i/e),s=new DataView(t);for(var o=0;oHH",t,i);if(r!=(a%=65535)||s!=(l%=65535))throw'ValueError("fletcher32 checksum invalid")'}(t),t.slice(0,-4)}]]),Ig=class{constructor(t,e){this.fh=t,this.offset=e,this.depth=null}async init(){this.all_nodes=new Map,await this._read_root_node(),await this._read_children()}async _read_children(){let t=this.depth;for(;t>0;){for(var e of this.all_nodes.get(t))for(var i of e.get("addresses"))this._add_node(await this._read_node(i,t-1));t--}}async _read_root_node(){let t=await this._read_node(this.offset,null);this._add_node(t),this.depth=t.get("node_level")}_add_node(t){let e=t.get("node_level");this.all_nodes.has(e)?this.all_nodes.get(e).push(t):this.all_nodes.set(e,[t])}async _read_node(t,e){let i=await this._read_node_header(t,e);return i.set("keys",[]),i.set("addresses",[]),i}async _read_node_header(t){throw"NotImplementedError: must define _read_node_header in implementation class"}},Eg=class extends Ig{B_LINK_NODE=new Map([["signature","4s"],["node_type","B"],["node_level","B"],["entries_used","H"],["left_sibling","Q"],["right_sibling","Q"]]);async _read_node_header(t,e){let i=await Zf(this.B_LINK_NODE,this.fh,t);if(null!=e&&i.get("node_level")!=e)throw"node level does not match";return i}},Mg=class extends Eg{NODE_TYPE=0;constructor(t,e){super(t,e),this.ready=this.init()}async _read_node(t,e){let i=await this._read_node_header(t,e);t+=Xf(this.B_LINK_NODE);let n=[],r=[],s=i.get("entries_used");for(var o=0;o=0&&v[x]>=t[x];x--)v[x]=0,y[x]=b[x],x>0&&(v[x-1]+=1,y[x-1]+=1);if(y.slice(0,-1).every((function(t,i){return t=0;o--){if(e&1<0?r*=n:r=n}}return s}_nrecords_max(t,e,i){return Math.floor((t-10-i)/(e+i))}_required_bytes(t){return Math.ceil(np(t)/8)}_int_format(t){return["0&&(c=(await ep.unpack_from_async(a,this.fh,i))[0],i+=r),l.push([n,h,c])}}return s.set("keys",a),s.set("addresses",l),s}async _read_node_header(t,e){let i=await Zf(this.B_LINK_NODE,this.fh,t);return i.set("node_level",e),i}*iter_records(){for(let t of this.all_nodes.values())for(let e of t)for(let t of e.get("keys"))yield t}_parse_record(t){throw"NotImplementedError"}},Bg=class extends Lg{NODE_TYPE=5;async _parse_record(t,e,i){let n=(await ep.unpack_from_async("0)throw"Filter info size not supported on FractalHeap";if(e.get("btree_address_huge_objects")!=Vg)throw"Huge objects not implemented in FractalHeap";e.set("btree_address_huge_objects",null),e.get("root_block_address")==Vg&&e.set("root_block_address",null);let i=e.get("log2_maximum_heap_size"),n=this._min_size_nbits(i),r=new Map([["signature","4s"],["version","B"],["heap_header_adddress","Q"],["block_offset",`${n}B`]]);this.indirect_block_header=new Map(r),this.indirect_block_header_size=Xf(r),2==(2&e.get("flags"))&&r.set("checksum","I"),this.direct_block_header=r,this.direct_block_header_size=Xf(r);let s=e.get("maximum_direct_block_size");this._managed_object_offset_size=this._min_size_nbits(i);let o=Math.min(s,e.get("max_managed_object_size"));this._managed_object_length_size=this._min_size_integer(o);let a=e.get("starting_block_size"),l=e.get("table_width");if(!(a>0))throw"Starting block size == 0 not implemented";let h=Number(Math.floor(Math.log2(s)));Qf(1n<0)for await(let t of this._iter_indirect_block(this.fh,f,p))d.push(t);else{let t=await this._read_direct_block(this.fh,f,a);d.push(t)}let g=d.reduce(((t,e)=>t+e.byteLength),0),m=new Uint8Array(g),b=0;d.forEach((t=>{m.set(new Uint8Array(t),b),b+=t.byteLength})),this.managed=m.buffer}async _read_direct_block(t,e,i){let n=await t.slice(e,e+i);return Qf("FHDB"==Yf(this.direct_block_header,n).get("signature")),n}get_data(t){let e=ep.unpack_from(">4&3,n=1;if(0==i){Qf(0==e>>6);let i=this._managed_object_offset_size,r=rp(i,t,n);n+=i,i=this._managed_object_length_size;let s=rp(i,t,n);return this.managed.slice(r,r+s)}throw 1==i?"tiny objectID not supported in FractalHeap":2==i?"huge objectID not supported in FractalHeap":"unknown objectID type in FractalHeap"}_min_size_integer(t){return this._min_size_nbits(np(t))}_min_size_nbits(t){return Math.ceil(t/8)}async*_iter_indirect_block(t,e,i){let n=await Zf(this.indirect_block_header,t,e);e+=this.indirect_block_header_size,Qf("FHIB"==n.get("signature"));let r=n.get("block_offset").reduce(((t,e,i)=>t+(e<<8*i)),0);n.set("block_offset",r);let[s,o]=this._indirect_info(i),a=[];for(let i=0;ithis._chunks))}get shape(){let t=this.find_msg_type(Im)[0].get("offset_to_message");return async function(t,e){let i=(await ep.unpack_from_async("255&&(s=(await ep.unpack_from_async("0;t.set("optional",a);let l,h=(await ep.unpack_from_async("0&&(l=(await ep.unpack_from_async(`${s}s`,i,e))[0],e+=s),t.set("name",l);let c=await ep.unpack_from_async(`<${h}i`,i,e);e+=4*h,t.set("client_data_values",c),r.push(t)}}return this._filter_pipeline=r,this._filter_pipeline}find_msg_type(t){return this.msgs.filter((function(e){return e.get("type")==t}))}async get_attributes(){let t={},e=this.find_msg_type(Fm);for(let i of e){let e=i.get("offset_to_message"),[n,r]=await this.unpack_attribute(e);t[n]=r}return t}async get_fillvalue(){var t,e=this.find_msg_type(Rm)[0].get("offset_to_message");let i=(await ep.unpack_from_async("=r&&([s,r]=a[++l],h=0);let e=await Zf(gm,t,s+h),i=s+h+mm;if(e.set("offset_to_message",i),e.get("type")==Om){var[d,f]=await ep.unpack_from_async("=o-ym){let t=l[++h];if(null==t)break;[r,o]=t,c=0}let e=await Zf(bm,t,r+c),i=r+c+ym+n;if(e.set("offset_to_message",i),e.get("type")==Om){var[u,d]=await ep.unpack_from_async("0,l=(4&n)>0;(8&n)>0?(r=(await ep.unpack_from_async("0&&(e+=8);let r=(2&n)>0?_m:wm,s=await Zf(r,t,e),o=new Map;for(let[t,e]of s.entries())o.set(t,e==nm?null:e);return o}get is_dataset(){return this.find_msg_type(Im).length>0}async get_data(){let t=this.find_msg_type(Bm)[0].get("offset_to_message");var[e,i,n,r]=await this._get_data_message_properties(t);if(0==n)throw"Compact storage of DataObject not implemented";return 1==n?this._get_contiguous_data(r):2==n?this._get_chunked_data(t):void 0}async _get_data_message_properties(t){let e,i,n,[r,s,o]=await ep.unpack_from_async("=1&&r<=4),[r,e,i,n]}async _get_contiguous_data(t){let[e]=await ep.unpack_from_async("=!@\|]?(i|u|f|S)(\d*)/.test(n)){let[t,i,s]=tp(n),a=new Array(r);const l=await this.fh.slice(e,e+s*r);let h=new ip(l);for(var o=0;o=1&&e<=3);var a="<"+(i-1).toFixed()+"I",l=await ep.unpack_from_async(a,this.fh,s);this._chunks=l,this._chunk_dims=i,this._chunk_address=o}}}},nm=ep.unpack_from("this.get(t)))}length(){return this.keys.length}_dereference(t){if(!t)throw"cannot deference null reference";let e=this.file._get_object_by_address(t);if(null==e)throw"reference not found in file";return e}async get(t){if("number"==typeof t)return this._dereference(t);var e=Vm(t);if("/"==e)return this.file;if("."==e)return this;if(/^\//.test(e))return this.file.get(e.slice(1));if(""!=function(t){let e=t.lastIndexOf("/")+1,i=t.slice(0,e),n=new RegExp("^/+$"),r=new RegExp("/$");return i&&!n.test(i)&&(i=i.replace(r,"")),i}(e))var[i,n]=e.split(/\/(.*)/);else var i=e,n=".";if(!(i in this._links))throw i+" not found in group";var r=Vm(this.name+"/"+i);let s=this._links[i];if("string"==typeof s)try{return this.get(s)}catch(t){return null}var o=new im(this.file._fh,s);if(await o.ready,o.is_dataset){if("."!=n)throw r+" is a dataset, not a group";return new Um(r,o,this)}var a=new Pm(r,this);return await a.init(o),a.get(n)}visit(t){return this.visititems(((e,i)=>t(e)))}visititems(t){var e=this.name.length;/\/$/.test(this.name)||(e+=1);for(var i=this.values.slice();i;){let n=i.shift();1==i.length&&console.log(n);let r=t(n.name.slice(e),n);if(null!=r)return r;n instanceof Pm&&(i=i.concat(n.values))}return null}get attrs(){return null==this._attrs&&(this._attrs=this._dataobjects.get_attributes()),this._attrs}},zm=class extends Pm{constructor(t,e,i){super("/",null),this.ready=this.init(t,e,i)}async init(t,e,i){var n=new Fg(t,0);await n.ready;var r=await n.get_offset_to_dataobjects(),s=new im(t,r);if(await s.ready,this.parent=this,this.file=this,this.name="/",this._dataobjects=s,this._attrs=null,this._keys=null,this._fh=t,this.filename=e||"",this.mode="r",this.userblock_size=0,i&&i.index)this.index=i.index;else{let e;if(i&&i.indexOffset)e=i.indexOffset;else{const t=await this.attrs;if(t.hasOwnProperty("_index_offset"))e=t._index_offset;else{const t=this.indexName||"_index",i=await s.find_link(t);i&&(e=i[1])}}if(e)try{const i=new im(t,e);await i.ready;const n=await i.get_data(),r=Ag(n),s=(new TextDecoder).decode(r);this.index=JSON.parse(s)}catch(t){console.error(`Error loading index by offset ${t}`)}}this.index&&this.name in this.index?this._links=this.index[this.name]:this._links=await s.get_links()}_get_object_by_address(t){return this._dataobjects.offset==t?this:this.visititems((t=>{t._dataobjects.offset}))}},Um=class extends Array{constructor(t,e,i){super(),this.parent=i,this.file=i.file,this.name=t,this._dataobjects=e,this._attrs=null,this._astype=null}get value(){var t=this._dataobjects.get_data();return null==this._astype?this.getValue(t):t.astype(this._astype)}get shape(){return this._dataobjects.shape}get attrs(){return this._dataobjects.get_attributes()}get dtype(){return this._dataobjects.dtype}get fillvalue(){return this._dataobjects.get_fillvalue()}async to_array(){return function(t,e){const i=t.length,n=e.reduce(((t,e)=>t*e),1);i!==n&&console.warn(`shape product: ${n} does not match length of flattened array: ${i}`);let r=t;const s=e.slice(1).reverse();for(let t of s){const e=[],{length:i}=r;let n=0;for(;nt.substr(0,t.indexOf("\0")))):t}};function Vm(t){return t.replace(/\/(\/)+/g,"/")}class Hm{constructor(t){this.fileReader=t}async slice(t,e){return this.fileReader.read(t,e-t)}}function jm(t){const e=t.lastIndexOf("/");return e>0?t.substring(e+1):t}class $m{constructor(t,e=1e5){this.h5_file=t,this.bin_size=e,this.h5_obj=void 0}async fetch(){return this.h5_obj||(this.h5_obj=await async function(t){var e;t.url&&"function"==typeof(e=t.url).slice&&"function"==typeof e.arrayBuffer&&(t.file=t.url,t.url=void 0);const i=void 0!==t.url;let n=t.reader?t.reader:function(t){if(t.url)return new $f(t);if(t.path)return new NodeLocalFile(t);if(t.file)return new Gf(t.file);throw Error("One of 'url', 'path (node only)', or 'file (browser only)' must be specified")}(t);const r=t.fetchSize||2e3,s=t.maxSize||2e5;i&&(n=new qf({file:n,fetchSize:r,maxSize:s}));const o=new Hm(n),a=await async function(t){let e;if(t.indexReader)e=t.indexReader;else{if(t.index)return t.index;t.indexURL?e=new $f({url:t.indexURL}):t.indexPath?e=new NodeLocalFile({path:t.indexPath}):t.indexFile&&(e=new Gf({file:t.indexFile}))}if(e){const t=await e.read(),i=(new TextDecoder).decode(t);return JSON.parse(i)}}(t),l=t.indexOffset,h=function(t){return t.url?jm(t.url):t.path?jm(t.path):t.file?t.file.name:void 0}(t),c=new zm(o,h,{index:a,indexOffset:l});return await c.ready,c}({url:this.h5_file,fetchSize:1e6,maxSize:2e8})),this.h5_obj}async get_keys(){return(await this.fetch()).keys}async get_rd_signal(t=this.bin_size){let e=await this.fetch(),i=e.keys,n=new qm(i),r=n.get_rd_bins(),s=n.get_snp_bins();this.available_bins=[...new Set(r,s)],this.available_bins.includes(t)||(t=this.available_bins.at(-1));const o=await e.get("rd_chromosomes");await o.dtype;let a=await o.value,l=await this.rd_stat(e,i,t);var h=[],c=[],u=[],d=[],f=[],p=[];for(let n of a){var g=`his_rd_p_${n}_${t}`;let r=await this.get_chr_signal(e,i,n,t,g,l);h=h.concat(r);var m=`his_rd_p_${n}_${t}_GC`;let s=await this.get_chr_signal(e,i,n,t,m,l);c=c.concat(s);let o=`his_rd_p_${n}_${t}_partition_GC_merge`,a=await this.get_chr_signal(e,i,n,t,o,l);u=u.concat(a);let b=await this.rd_call_combined(e,i,n,t,l);d=d.concat(b);let y=`snp_likelihood_${n}_${t}_mask`,v=await this.get_baf_signals(e,i,n,t,y);f=f.concat(v[0]),p=p.concat(v[1])}this.callers=[],0!=d.length&&this.callers.push("ReadDepth"),0!=d.length&&this.callers.push("2D");var b={},y={RD_Raw:h,RD_Raw_gc_coor:c,ReadDepth:u,"2D":d,BAF1:f,BAF2:p};return b[t]=y,b}decode_segments(t){let e=[],i=[];for(let n of t)4294967295==n?(e.push(i),i=[]):i.push(n);return e}async rd_call_combined(t,e,i,n,r){let s,o=[],a=`his_rd_p_${i}_${n}_partition_GC_mosaic_segments_2d`;if(e.includes(a)){const e=await t.get(a);let i=await e.value;s=this.decode_segments(i)}let l=`his_rd_p_${i}_${n}_partition_GC_mosaic_call_2d`;if(e.includes(l)){const e=await t.get(l);let a=await e.to_array();s.forEach(((t,e)=>{t.forEach(((t,s)=>{o.push({chr:i,start:t*n,end:(t+1)*n,value:a[0][e]/r[4]*2})}))}))}return o}async rd_stat(t,e,i){let n,r=`rd_stat_${i}_auto`;if(e.includes(r)){const e=await t.get(r);n=await e.value}return n}async get_chr_signal(t,e,i,n,r,s){let o=[];if(e.includes(r)){const e=await t.get(r);(await e.value).forEach(((t,e)=>{o.push({chr:i,start:e*n,end:(e+1)*n,value:t/s[4]*2})}))}return o}async get_baf_signals(t,e,i,n,r){let s=[],o=[];if(e.includes(r)){let e=await t.get(r);(await e.to_array()).forEach(((t,e)=>{let r=Math.max(...t);const a=t.indexOf(r);let l=Math.max(a/200,1-a/200);s.push({chr:i,start:e*n,end:(e+1)*n,value:-2*l}),.5!=l&&o.push({chr:i,start:e*n,end:(e+1)*n,value:-2*(1-l)})}))}return[s,o]}async get_baf_signals_v2(t,e,i,n,r){let s=[],o=[];if(e.includes(r)){let e=await t.get(r);(await e.to_array()).forEach(((t,e)=>{isNaN(t)||(s.push({chr:i,start:e*n,end:(e+1)*n,value:-2*(.5-t)}),.5!=t&&o.push({chr:i,start:e*n,end:(e+1)*n,value:-2*(.5+t)}))}))}return console.log(i,s,o),[s,o]}}class qm{constructor(t){this.signals=t}get_rd_bins(){let t=[];return this.signals.forEach((e=>{let i=e.match(/^his_rd_p_(.*)_(\d+)$/);i&&t.push({chr:i[1],bin_size:i[2]})})),[...new Set(t.map((t=>Number(t.bin_size))))]}get_snp_bins(){let t=[];return this.signals.forEach((e=>{let i=e.match(/^snp_likelihood_(.*)_(\d+)_mask$/);i&&t.push({chr:i[1],bin_size:i[2]})})),[...new Set(t.map((t=>Number(t.bin_size))))]}}function Wm(t){let e=function(t){if(t.length<4)return t;let e,i,n,r,s,o;return e=t.slice().sort(((t,e)=>t-e)),e.length/4%1==0?(i=.5*(e[e.length/4]+e[e.length/4+1]),n=.5*(e[e.length*(3/4)]+e[e.length*(3/4)+1])):(i=e[Math.floor(e.length/4+1)],n=e[Math.ceil(e.length*(3/4)+1)]),r=n-i,s=n+1.5*r,o=i-1.5*r,e.filter((t=>t>=o&&t<=s))}(t);const i=e.length,n=e.reduce(((t,e)=>t+e))/i,r=Math.sqrt(e.map((t=>Math.pow(t-n,2))).reduce(((t,e)=>t+e))/i);return[n,r]}var Gm=function(t,e,i){if(void 0===i&&(i=Math.max(Math.round(e-t)+1,1)),i<2)return 1===i?[t]:[];var n=Array(i);for(let r=--i;r>=0;r--)n[r]=(r*e+(i-r)*t)/i;return n},Zm=class{constructor(t){this.allBins=t}getValues(){return Object.values(this.allBins).reduce(((t,e)=>t.concat(e.filter((t=>t.binScore>0)).map((t=>t.binScore)))),[])}getMean(t){return t.reduce((function(t,e){return t+e}))/t.length}fit_data(){return Wm(this.getValues())}histogram(t,e){const i=e[1]-e[0],n=[];t.forEach(((t,r)=>{e.forEach(((e,r)=>{if(n[e]||(n[e]={count:0}),e<=t&&t{r.push(t.count)})),r}};function Ym(t,e){return isNaN(t)||isNaN(e)||e<=0?NaN:0===t?.5:.5+.5*(Qm(.5*e,.5,1)-Qm(.5*e,.5,e/(e+t*t)))*Math.sign(t)}function Qm(t,e,i){if(0==i)return 0;if(1==i)return 1;{let n=tb(t+e)-tb(t)-tb(e)+t*Math.log(i)+e*Math.log(1-i);return i<(t+1)/(t+e+2)?Math.exp(n)*Xm(t,e,i)/t:1-Math.exp(n)*Xm(e,t,1-i)/e}}function Xm(t,e,i,n=1e3){let r=1,s=1,o=1,a=t+e,l=t+1,h=t-1,c=1-a*i/l;for(let u=0;u<=n;u++){let n=parseFloat(u+1),d=n+n,f=n*(e-n)*i/((h+d)*(t+d)),p=r+f*s,g=c+f*o;f=-(t+n)*(a+n)*i/((l+d)*(t+d));let m=g+f*c,b=r;if(s=p/m,o=g/m,r=(p+f*r)/m,c=1,Math.abs(r-b)<3e-7*Math.abs(r))return r}}function Km(t){return 0==t||1==t?1:t*Km(t-1)}function Jm(t){let e;var i=[75122.633153,80916.6278952,36308.2951477,8687.24529705,1168.92649479,83.8676043424,2.50662827511],n=0,r=1;if(0==t)e=1e99;else if(t%1==0)e=Km(t-1);else{for(let e=0;ee?t:e}))}function nb(t,e,i,n){return e*Math.exp(-1*(t-i)**2/(2*n**2))/Math.sqrt(2*Math.PI)/n}function rb(t,e,i,n){return Math.exp(-1*(t-i)**2/(e**2+n**2))}function sb(t,e){let i;try{i=t.reduce(((t,i,n)=>t+Math.min(i,e[n])))}catch{return console.log("Failed to find likelihood overlap: ",t,e),0}return i}function ob(t,e,i,n){return 0==e&&0==n?{nl:.5*(t+i),ne:0}:{nl:(t*n*n+i*e*e)/(e*e+n*n),ne:Math.sqrt(e*e*n*n/(e*e+n*n))}}function ab(t,e){let i=parseInt(e*(t.length-1)),n=e*(t.length-1)-i;return iMath.floor(e/2)&&(n=e-1-n);const r=(e/2-n)/(e+1),s=Math.floor((e/2+n)/2),o=e-1-s;let a=t.slice(s,o+1).reduce(((t,e)=>t+e),0)/t.reduce(((t,e)=>t+e),0);return n===Math.floor(e/2)&&(a=1),{mean:r,p:a}}var hb=class{constructor(t,e){this.wigFeatures=t,this.binSize=e}get_fit(){var t=new Zm(this.wigFeatures),[e,i]=t.fit_data();return{globalMean:e,globalStd:i}}async call_2d(t=null,e=null,i="both",n=.1,r=0,s=10,o=0){let a=this.get_fit();this.globalMean=a.globalMean,this.globalStd=a.globalStd;let l=null==t?.05*this.binSize/3e9:t,h=null==e?parseInt(this.binSize/1e4):e,c=[],u=[],d=[],f=[],p=[],g=[];for(const[t,e]of Object.entries(this.wigFeatures)){let t=[],i=[],s=[];e.forEach(((e,n)=>{e.hets_count>4&&e.dp_count>h&&(t.push([n]),i.push(e.binScore),s.push(e.likelihood_score),delete e.likelihood_score)}));let o=[];for(let t=1;tMath.sqrt(Math.sqrt(t)**2+this.globalStd**2+Math.pow(a[e]/2,2)))),m=[];for(let e=0;e0;){m=m.filter((t=>"number"==typeof t));let e=ib(m);if(isNaN(e)&&console.log("NaN value",m),et*s[o+1][e])),r=n.reduce(((t,e)=>t+e))}catch{console.log(s),console.log("max_overlap:",e,o,m.length),console.log("likelihood: ",o,s[o],s[o+1]),console.log("nlh: ",r)}if(i[o]=a.nl,g[o]=a.ne,s[o]=n.map((function(t){return t/r})),t[o].push(...t[o+1]),i.splice(o+1,1),g.splice(o+1,1),t.splice(o+1,1),s.splice(o+1,1),m.splice(o,1),o0){let t=rb(i[o-1],g[o-1],i[o],g[o])*sb(s[o-1],s[o]);m[o-1]=t}}let b=-1;for(;;){m=[];for(let e=0;et*s[r+1][e])),a=n.reduce(((t,e)=>t+e));s[r]=n.map((function(t){return t/a})),t[r].push(...t[r+1]),t[r]=t[r].sort(((t,e)=>t-e)),i.splice(o,1),g.splice(o,1),t.splice(o,1),s.splice(o,1),o>=t.length&&(r+=1,o=r+1)}else o+=1,o>=t.length&&(r+=1,o=r+1)}if(b==t.length)break;b=t.length}t.forEach(((t,n)=>{let o=lb(s[n]);t.length>1&&(t.forEach(((t,s)=>{u.push(e[t]),o.mean<=r&&c.push(e[t]),e[t].segment_score=i[n]})),d.push(i[n]),f.push(g[n]),p.push(s[n]))}))}let m=parseInt(1e3*(1-o));0==m&&(m=1);let b=Gm(o,1,m),y={},v={};for(let t=10;t>-1;t--)for(let e=0;e1-e+e*t/2)),a=t/2;t>0?(n=.5-e/(e+s),r=b.map(((t,i)=>.5-(1-t+t*e)/(2-2*t+(e+s)*t)))):(n=0,r=b.map(((t,e)=>0*t)));for(let i=0;i{if(!isNaN(r[e])){let n=nb(t*this.globalMean,1,d[i],f[i])*ab(p[i],.5+r[e]);h+=n,n>c&&(c=n,u=b[e])}})),i in y?y[i].push([t,e,s,h/b.length,u]):y[i]=[t,e,s,h/b.length,u]}for(let t=0;tt[3]-e[3]));else if(y[t].sort(((t,e)=>t[3]-e[3])),"both"==i&&(v[t].sort(((t,e)=>t[3]-e[3])),v[t][0][3]>y[t][0][3])){let e=y[t].filter((e=>e[0]!=v[t][0][0]&&e[1]<=v[t][0][1]));y[t]=[v[t][0]].push(...e)}for(let t=0;t{var r={...t};1!=i&&(r.value=t[e]/i*2),n.push(r)}));return n}formatDataStructure_BAF(t,e=2){const i=[],n=[];for(const[e,r]of Object.entries(this.wigFeatures))r.forEach((e=>{var r={...e},s={...e};let o=e[t];.5!=o&&(s.value=-2*(1-o),n.push(s)),r.value=-2*o,i.push(r)}));return[i,n]}};function cb(t){for(var e=1,i=1,n=1*t,r=1;r<50;r++)e*=r,n+=(i*=-1)*Math.pow(t,2*r+1)/(e*(2*r+1));return 2*n/Math.sqrt(3.14159265358979)}function ub(t,e,i,n,r){var s=new pb(i.slice(n,r));return 0==s.std&&(s.std=e>0?e*s.mean/t:1),gb(t,s.mean,s.std,r-n)/(r-n)}function db(t,e,i,n,r){var s=new pb(i.slice(n,r));if(s.means&!h&l0&&(c=ub(t,e,i,n-1,r)),r-n>2)var u=ub(t,e,i,n+1,r),d=ub(t,e,i,n,r-1);if(rt+e))/t.length,this.std=Math.sqrt(t.reduce(((t,e)=>(e-this.mean)**2))/t.length)}}function gb(t,e,i,n){0==i&&(i=1);var r=(t-e)/i*Math.sqrt(n);return 1-eb.TdistributionCDF(Math.abs(r),n-1)}function mb(t,e,i,n,r,s){0==e&&(e=1),0==r&&(r=1);var o=(t-n)/Math.sqrt(e**2/i+r**2/s),a=(e**2/i+r**2/s)**2*(i-1)*(s-1)/(e**4*(s-1)/i**2+r**4*(i-1)/s**2);return 1-eb.TdistributionCDF(Math.abs(o),parseInt(a+.5))}var bb=class{constructor(t,e,i){this.rd=t,this.mean=e,this.std=i,this.bin_bands=[2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128]}get_rd_signal_bandwidth(t){var e=[];return t.forEach(((t,i)=>{var n;n=t>this.mean/4?this.mean/(this.std**2*t):4/this.std**2,e.push(n)})),e}meanShiftCaller(t=3){var e={};return Object.entries(this.rd).forEach((([i,n])=>{var r=new Array(n.length).fill(!1),s=new Array(n.length);for(let t=0;t{var o=r.map(((t,e)=>!t)),a=[];Object.entries(n).forEach((([t,e])=>{a.push(e.binScore)}));var l=[0],h=0;for(let t=0;t0&&(l.push(l[l.length-1]+h-1),h=0):h+=1;l.shift();for(let i=0;i=a.length||Math.abs(t-i)>=a.length)){var d=(i-t)*Math.exp(-.5*(i-t)**2/e**2)*Math.exp(-.5*(a[t]-a[i])**2*c[t]);u[t]+=d}for(var f=new Array,p=0;p=0&&f.push(p);f.push(u.length-1),f=f.concat(l).sort(((t,e)=>t-e)),f=Array.from(new Set(f));var g=0;for(p=0;pt+e))/m.length;a.fill(b,g,f[p]+1),g=f[p]+1}}p=0;for(var y=0;p.01&&f.push(p+1);for(f.unshift(0),f.push(s.length),r=new Array(this.rd.length).fill(!1),p=1;p1))continue;w[0]=f[p-2];var _=[f[p],f[p]];if(!(p.01/genome_size*bin_size*(x+k))continue;if(mb(C.mean,C.std,C.data.length,M.mean,M.std,M.data.length)>.01/genome_size*bin_size*(x+S))continue}if(gb(this.mean,C.mean,C.std,C.data.length)>.05)continue;let t=a.slice(v[0],v[1]);var R=new pb(t);r.fill(!0,v[0],v[1]),s.fill(R.mean,v[0],v[1])}})),e[i]=s})),e}call_mean_shift(t=3){for(var e=new Array(this.rd.length).fill(!1),i=new Array(this.rd.length),n=0;n{var s=e.map(((t,e)=>!t)),o=[];s.forEach(((t,e)=>{t&&o.push(this.rd[e])}));for(var a=[0],l=0,h=0;h0&&(a.push(a[a.length-1]+l-1),l=0):l+=1;a.shift();for(var c=0;c=o.length||Math.abs(h-f)>=o.length)){var p=(f-h)*Math.exp(-.5*(f-h)**2/n**2)*Math.exp(-.5*(o[h]-o[f])**2*u[h]);d[h]+=p}var g=new Array;for(h=0;h=0&&g.push(h);g.push(d.length-1),g=g.concat(a).sort(((t,e)=>t-e)),g=Array.from(new Set(g));var m=0;for(h=0;ht+e))/b.length;o.fill(y,m,g[h]+1),m=g[h]+1}}for(h=0,f=0;h.01&&g.push(h+1);for(g.unshift(0),g.push(i.length),e=new Array(this.rd.length).fill(!1),h=1;h1){w[0]=g[h-2];var _=[g[h],g[h]];if(h3.483106931382794e-9*(x+k))continue;if(mb(C.mean,C.std,C.data.length,M.mean,M.std,M.data.length)>3.483106931382794e-9*(x+S))continue}if(!(gb(this.mean,C.mean,C.std,C.data.length)>.05)){var R=new pb(this.rd.slice(v[0],v[1]));e.fill(!0,v[0],v[1]),i.fill(R.mean,v[0],v[1])}}}}}})),i}cnv_calling(t=1e5){var e=(e=.25)*this.mean,i=this.mean-e,n=this.mean+e,r=this.meanShiftCaller(),s={},o=[];return Object.entries(r).forEach((([a,l])=>{for(var h=!1;!h;){h=!0;var c=new Array(1).fill(0);for(let t=0;t.01&&c.push(t+1);c.push(l.length);for(let t=0;t0&&(d=Math.abs(l[c[t]]-l[c[t-1]])),t{g.push(e.binScore)}));for(var m,b=new Array(l.length).fill(""),y=0,v=.05*t/2971e6;y_+1){var x=fb(this.mean,this.std,g,_,k,v);if(x){var k=x;b.fill("D",_,k)}}for(_=y;yn;)y+=1;(k=y)>_+1&&(x=fb(this.mean,this.std,g,_,k,v))&&(k=x,b.fill("A",_,k)),y==w&&(y+=1)}for(y=0;y_+1&&(db(this.mean,this.std,g,_,k)<1682935038707506e-26&&b.fill(["d"]*(k-_),_,k),y-=1),y+=1}(y=0)=b.length););if(y>_){var C=new pb(S.slice(_,y));S.fill(C.mean,_,y)}ya&&(s>0&&e.push({chr:i,start:o,end:a,value:r,bin:l,count:s}),r=0,o=n.start-n.start%this.binSize,a=o+this.binSize);const h=n.calls[9].info.DP;h&&(r+=Number.parseInt(h),s++)}s>0&&e.push({chr:i,start:o,end:a,value:r,bin:l,count:s})}return e}async computeReadDepth(){const t=Object.keys(this.allVariants);var e={};for(let n of t){const t=this.allVariants[n];var i;if(0!==t.length)for(let r of t){i=Math.max(Math.floor(r.start/this.rowBinSize),0),e[n]||(e[n]=[]),e[n][i]||(e[n][i]={chr:n,start:i*this.rowBinSize,end:(i+1)*this.rowBinSize,value:0,sum_score:0,count:0});const t=r.calls[9].info.DP;t&&(e[n][i].sum_score+=Number.parseInt(t),e[n][i].count++)}}var n={};for(let i of t){n[i]||(n[i]=[]);for(let t=0;t{e.forEach(((e,i)=>{e.partition_level=parseInt(s[t][i]),e.partition_call=parseInt(o[0][t][i])}))})),[this.formatDataStructure(t,"binScore",i),this.formatDataStructure(t,"partition_level",i),this.formatDataStructure(t,"partition_call",i),o[1]]}formatDataStructure(t,e,i=1){const n=[];for(const[r,s]of Object.entries(t))s.forEach((t=>{var r={...t};1!=i&&(r.value=t[e]/i*2),n.push(r)}));return n}async computeBAF_v2(){const t=Object.keys(this.allVariants),e={},i=[],n=[];for(let o of t){const t=this.allVariants[o];if(0===t.length)continue;var r;for(let a of t){if(r=Math.max(Math.floor(a.start/this.binSize),0),e[o]||(e[o]=[]),!e[o][r]){if(r>0){let t=r-1;if(e[o][t]){const r=this.get_max_min_score(e[o][t]);if(.5!=r.value){let t=Object.assign({},r);t.value=-2*(1-r.value),n.push(t)}r.value=-2*r.value,e[o][t]=r,i.push(e[o][t])}}e[o][r]={chr:o,start:r*this.binSize,end:(r+1)*this.binSize,value:0,count:0,likelihood_score:[],min_score:0}}const t=a.calls[9];let l=t.genotype,h=t.info.AD.split(","),c=h[0],u=h[1];if(0==l[0]&&1==l[1]||1==l[0]&&0==l[1]){if(0==e[o][r].likelihood_score.length)e[o][r].likelihood_score=Gm(0,1,100).map(((t,e)=>vb(c,u,t)));else{var s=0;e[o][r].likelihood_score=Gm(0,1,100).map(((t,i)=>{var n=e[o][r].likelihood_score[i]*vb(c,u,t);return s+=n,n})),e[o][r].likelihood_score=Gm(0,1,100).map(((t,i)=>e[o][r].likelihood_score[i]/s))}e[o][r].count++}}const a=this.get_max_min_score(e[o][r]);if(.5!=a.value){let t=Object.assign({},a);t.value=-2*(1-a.value),n.push(t)}a.value=-2*a.value,e[o][r]=a,i.push(e[o][r])}return[i,n]}format_BAF_likelihood(t){const e=[];for(const[i,n]of Object.entries(t))n.forEach((t=>{var i={...t};.5!=t.value&&(i.value=1-t.value,e.push(i))}));return e}get_max_min_score(t){if(t.likelihood_score.length>0){const e=Math.max(...t.likelihood_score),i=t.likelihood_score.indexOf(e);t.value=Math.max(i/100,1-i/100),t.min_score=Math.min(i/100,1-i/100)}else t.score=0;return t}async getAllbins(){const t=await this.computeDepthFeatures();return new Zm(t).fit_data(),t}async read_rd_baf(t="ReadDepth"){const e=Object.keys(this.allVariants);var i={};for(let t of e){const e=this.allVariants[t];var n;if(0!==e.length)for(let r of e){n=Math.max(Math.floor(r.start/this.rowBinSize),0),i[t]||(i[t]=[]),i[t][n]||(i[t][n]={chr:t,start:n*this.rowBinSize,end:(n+1)*this.rowBinSize,dp_sum_score:0,dp_count:0,hets_count:0,hets:[]});const e=r.calls[9],s=e.info.DP;s&&(i[t][n].dp_sum_score+=Number.parseInt(s),i[t][n].dp_count++);let o=e.info.AD.split(","),a=e.genotype;if(0==a[0]&&1==a[1]||1==a[0]&&0==a[1]){i[t][n].hets_count++;let e=parseInt(o[0]),r=parseInt(o[1]);i[t][n].hets.push({ref:e,alt:r})}}}var r,s=this.adjust_bin_size(i);if("ReadDepth"==t){r=this.readDepthMeanshift(s);var o=this.formatDataStructure_BAF(s,"max_likelihood")}else if("2D"==t){let t=new hb(s,this.binSize),e=await t.call_2d();r=[e.binScore,[],e.segment_score],o=t.formatDataStructure_BAF("max_likelihood")}return[r,o]}formatDataStructure_BAF(t,e,i=2){const n=[],r=[];for(const[i,s]of Object.entries(t))s.forEach((t=>{delete t.likelihood_score;var i={...t},s={...t};let o=t[e];.5!=o&&(s.value=-2*(1-o),r.push(s)),i.value=-2*o,n.push(i)}));return[n,r]}adjust_bin_size(t){const e=Object.keys(this.allVariants);var i={};for(let s of e){i[s]||(i[s]=[]);for(let e=0;e{if(0==i[s][e].likelihood_score.length)i[s][e].likelihood_score=Gm(0,1,100).map(((e,i)=>vb(t.ref,t.alt,e)));else{var r=0;i[s][e].likelihood_score=Gm(0,1,100).map(((n,o)=>{var a=i[s][e].likelihood_score[o]*vb(t.ref,t.alt,n);return r+=a,a})),i[s][e].likelihood_score=Gm(0,1,100).map(((t,n)=>i[s][e].likelihood_score[n]/r))}}))}const a=this.get_max_min_score(i[s][e]);i[s][e].max_likelihood=a.value}}return i}}function vb(t,e,i,n=!0){return i**t*(1-i)**e+i**e*(1-i)**t}class wb extends ch{constructor(t,e){super(t,e),this.featureType="numeric",this.paintAxis=$u,t.max||(this.defaultScale=!0,this.autoscale=!1),this.height=void 0!==t.height?t.height:250}async init(t){this.type="cnvpytor",this.graphType=t.graphType||"points",this.bin_size=t.bin_size||1e5,this.signal_name=t.signal_name||"rd_snp",this.cnv_caller=t.cnv_caller||"2D",this.colors=t.colors||["gray","black","green","blue"],super.init(t)}get supportsWholeGenome(){return!0}get_signals(){let t=[];return"rd_snp"==this.signal_name?t=["RD_Raw","RD_Raw_gc_coor",this.cnv_caller,"BAF1","BAF2"]:"rd"==this.signal_name?t=["RD_Raw","RD_Raw_gc_coor",this.cnv_caller]:"snp"==this.signal_name?t=["BAF1","BAF2"]:"cnh"==this.signal_name&&(t=[this.cnv_caller]),t}get_signal_colors(){return[{singal_name:"RD_Raw",color:this.colors[0]},{singal_name:"RD_Raw_gc_coor",color:this.colors[1]},{singal_name:"ReadDepth",color:this.colors[2]},{singal_name:"2D",color:this.colors[2]},{singal_name:"BAF1",color:this.colors[3]},{singal_name:"BAF2",color:this.colors[3]}]}async postInit(){if("vcf"==this.config.format){this.featureSource=$c(this.config,this.browser.genome),this.header=await this.getHeader();var t=this.featureSource.reader.features.reduce((function(t,e){return t[e.chr]=t[e.chr]||[],t[e.chr].push(e),t}),Object.create(null));const e=new yb(t,this.bin_size);let i,n,r;this.wigFeatures_obj={},this.wigFeatures_obj[this.bin_size]={},"2D"==this.config.cnv_caller?(r=await e.read_rd_baf("2D"),i=r[0],n=r[1],this.wigFeatures_obj[this.bin_size]["2D"]=i[2],this.available_callers=["2D"]):(r=await e.read_rd_baf(),i=r[0],n=r[1],this.wigFeatures_obj[this.bin_size].ReadDepth=i[2],this.available_callers=["ReadDepth"]),this.wigFeatures_obj[this.bin_size].RD_Raw=i[0],this.wigFeatures_obj[this.bin_size].RD_Raw_gc_coor=i[1],this.wigFeatures_obj[this.bin_size].BAF1=n[0],this.wigFeatures_obj[this.bin_size].BAF2=n[1],this.available_bins=[this.bin_size],this.set_available_callers()}else this.cnvpytor_obj=new $m(this.config.url,this.bin_size),this.wigFeatures_obj=await this.cnvpytor_obj.get_rd_signal(this.bin_size),this.available_bins=this.cnvpytor_obj.available_bins,this.available_callers=this.cnvpytor_obj.callers,this.set_available_callers();this.tracks=[];const e=[];this.signals=this.get_signals(),this.signal_colors=this.get_signal_colors();for(let t in this.wigFeatures_obj)for(const[i,n]of Object.entries(this.wigFeatures_obj[t]))if(this.signals.includes(i)){let t={type:"wig",isMergedTrack:!0};t.features=n,t.name=i,t.color=this.signal_colors.filter((t=>t.singal_name===i)).map((t=>t.color));const r=await this.browser.createTrack(t);r?(r.autoscale=!1,this.tracks.push(r)):console.warn("Could not create track "+t),"function"==typeof r.postInit&&e.push(r.postInit())}this.flipAxis=!!this.config.flipAxis&&this.config.flipAxis,this.logScale=!!this.config.logScale&&this.config.logScale,this.autoscale=this.config.autoscale,this.autoscale||(this.dataRange={min:this.config.min||0,max:this.config.max});for(let t of this.tracks)t.autoscale=!1,t.dataRange=this.dataRange;return Promise.all(e)}set_available_callers(){this.available_callers.includes(this.cnv_caller)||(this.available_callers.length>0?this.cnv_caller=this.available_callers[0]:this.cnv_caller=null)}async getHeader(){if(!this.header){if("function"==typeof this.featureSource.getHeader){const t=await this.featureSource.getHeader();t&&(this.callSets=t.callSets||[]),this.header=t}this.sampleNames=this.callSets?this.callSets.map((t=>t.name)):[]}return this.header}get height(){return this._height}set height(t){if(this._height=t,this.tracks)for(let e of this.tracks)e.height=t,e.config.height=t}menuItemList(){let t=[];void 0!==this.flipAxis&&t.push({label:"Flip y-axis",click:()=>{this.flipAxis=!this.flipAxis,this.trackView.repaintViews()}}),t=t.concat(Ui.numericDataMenuItems(this.trackView)),t.push("
"),t.push("Bin Sizes");for(let e of this.available_bins){const i=zi(e,e===this.bin_size);t.push({object:fe(i),click:async()=>{this.bin_size=e,await this.recreate_tracks(e),this.clearCachedFeatures(),this.trackView.updateViews(),this.trackView.repaintViews()}})}t.push("
"),t.push("Signal Type");let e={rd_snp:"RD and BAF Likelihood",rd:"RD Signal",snp:"BAF Likelihood"};for(let i in e){const n=zi(e[i],i===this.signal_name);t.push({object:fe(n),click:async()=>{this.signal_name=i,await this.recreate_tracks(this.bin_size),this.clearCachedFeatures(),this.trackView.updateViews(),this.trackView.repaintViews()}})}t.push("
"),t.push("CNV caller");for(let e of this.available_callers){const i=zi(e,e===this.cnv_caller);t.push({object:fe(i),click:async()=>{this.cnv_caller=e,await this.recreate_tracks(this.bin_size),this.clearCachedFeatures(),this.trackView.updateViews(),this.trackView.repaintViews()}})}return t}async recreate_tracks(t){this.tracks=[];const e=[];t in this.wigFeatures_obj||(this.wigFeatures_obj={...this.wigFeatures_obj,...await this.cnvpytor_obj.get_rd_signal(t)}),this.signals=this.get_signals(),this.signal_colors=this.get_signal_colors();for(const[i,n]of Object.entries(this.wigFeatures_obj[t]))if(this.signals.includes(i)){let t={type:"wig",isMergedTrack:!0};t.features=n,t.name=i,t.color=this.signal_colors.filter((t=>t.singal_name===i)).map((t=>t.color));const r=await this.browser.createTrack(t);r?(r.autoscale=!1,this.tracks.push(r)):console.warn("Could not create track "+t),"function"==typeof r.postInit&&e.push(r.postInit())}this.flipAxis=!!this.config.flipAxis&&this.config.flipAxis,this.logScale=!!this.config.logScale&&this.config.logScale,this.autoscale=this.config.autoscale,this.autoscale||(this.dataRange={min:this.config.min||0,max:this.config.max});for(let t of this.tracks)t.autoscale=!1,t.dataRange=this.dataRange;return Promise.all(e)}async getFeatures(t,e,i,n){if(this.tracks){const r=this.tracks.map((r=>r.getFeatures(t,e,i,n)));return Promise.all(r)}}getScaleFactor(t,e,i,n){return n?i/(Math.log10(e+1)-(t<=0?0:Math.log10(t+1))):i/(e-t)}computeYPixelValue(t,e){return(this.flipAxis?t-this.dataRange.min:this.dataRange.max-t)*e}computeYPixelValueInLogScale(t,e){let i=this.dataRange.max,n=this.dataRange.min;return i<=0?0:(n<=-1&&(n=0),n=n<=0?0:Math.log10(n+1),i=Math.log10(i+1),t=Math.log10(t+1),(this.flipAxis?t-n:i-t)*e)}draw(t){const e=t.features;if(!e)return;if(this.defaultScale&&("rd_snp"==this.signal_name?this.dataRange={min:this.config.min||this.dataRange.min||-2,max:this.config.max||this.dataRange.max||6}:"rd"==this.signal_name?this.dataRange={min:this.config.min||this.dataRange.min||0,max:this.config.max||this.dataRange.max||6}:"snp"==this.signal_name&&(this.dataRange={min:this.config.min||this.dataRange.min||-2,max:this.config.max||this.dataRange.max||0})),this.autoscale&&(this.dataRange=function(t,e){let i=0,n=-Number.MAX_VALUE;for(let t of e)for(let e of t)void 0===e.value||Number.isNaN(e.value)||(i=Math.min(i,e.value),n=Math.max(n,e.value));return{min:i,max:n}}(t.referenceFrame.chr,e)),this.tracks)for(let i=0,n=this.tracks.length;ithis.logScale?this.computeYPixelValueInLogScale(t,i):this.computeYPixelValue(t,i);if(this.config.hasOwnProperty("guideLines"))for(let e of this.config.guideLines)if(e.hasOwnProperty("color")&&e.hasOwnProperty("y")&&e.hasOwnProperty("dotted")){let i=n(e.y),r={strokeStyle:e.color,strokeWidth:1};e.dotted?na.dashedLine(t.context,0,i,t.pixelWidth,i,5,r):na.strokeLine(t.context,0,i,t.pixelWidth,i,r)}}popupData(t,e){const i=e||t.viewport.cachedFeatures;if(i&&i.length===this.tracks.length){const e=[];for(let n=0;n0&&e.push("
"),e.push(`
${this.tracks[n].name}
`);const r=this.tracks[n].popupData(t,i[n]);e.push(...r)}return e}}}const _b=new Map([["ideogram",(t,e)=>new zf(t,e)],["sequence",(t,e)=>new Xa(t,e)],["feature",(t,e)=>new Nd(t,e)],["seg",(t,e)=>new gf(t,e)],["mut",(t,e)=>new gf(t,e)],["maf",(t,e)=>new gf(t,e)],["wig",(t,e)=>new uf(t,e)],["merged",(t,e)=>new bf(t,e)],["alignment",(t,e)=>new jd(t,e)],["interaction",(t,e)=>new vf(t,e)],["interact",(t,e)=>new vf(t,e)],["variant",(t,e)=>new If(t,e)],["eqtl",(t,e)=>new Mf(t,e)],["gwas",(t,e)=>new Bf(t,e)],["arc",(t,e)=>new Of(t,e)],["gcnv",(t,e)=>new Nf(t,e)],["junction",(t,e)=>new jf(t,e)],["blat",(t,e)=>new Ud(t,e)],["cnvpytor",(t,e)=>new wb(t,e)]]);var xb=function(t,e){_b.set(t,e)};class kb{constructor(t,e){const i=(new DOMParser).parseFromString(t,"text/xml");this.processRootNode(i,e);const n=i.getElementsByTagName("Resource"),r=i.getElementsByTagName("Track"),s=r&&r.length>0,o=[];this.tracks=o;const a=new Map;Array.from(n).forEach((function(t,e){var i={url:t.getAttribute("path"),indexURL:t.getAttribute("index"),order:e};a.set(i.url,i),s||o.push(i)})),s&&Array.from(r).forEach((function(t){const e=t.getElementsByTagName("Track");if(e&&e.length>0){const i={type:"merged",tracks:[]};Sb(t,i),o.push(i),Array.from(e).forEach((function(t){t.processed=!0;const e=t.getAttribute("id"),n=a.get(e);n&&(i.tracks.push(n),Sb(t,n),n.autoscale=!1,i.height=n.height)}))}else if(!t.processed){const e=t.getAttribute("id"),i=a.get(e);i&&(o.push(i),Sb(t,i))}}))}processRootNode(t,e){const i=t.getElementsByTagName("Session");!i||i.length;const n=i.item(0),r=n.getAttribute("genome"),s=n.getAttribute("locus"),o=n.getAttribute("ucscID");e&&e.hasOwnProperty(r)?this.genome=r:(this.reference={fastaURL:r},o&&(this.reference.id=o)),s&&(this.locus=s)}}function Sb(t,e){e.name=t.getAttribute("name");const i=t.getAttribute("color");i&&(e.color="rgb("+i+")");const n=t.getAttribute("altColor");i&&(e.altColor="rgb("+n+")");const r=t.getAttribute("height");r&&(e.height=parseInt(r));const s=t.getAttribute("autoScale");s&&(e.autoscale="true"===s);const o=t.getAttribute("autoscaleGroup");o&&(e.autoscaleGroup=o);const a=t.getAttribute("windowFunction");a&&(e.windowFunction=a);const l=t.getAttribute("visibilityWindow")||t.getAttribute("featureVisibilityWindow");l&&(e.visibilityWindow=l);const h=t.getAttribute("indexed");h&&(e.indexed="true"===h);const c=t.getAttribute("normalize");c&&(e.normalize="true"===c);const u=t.getElementsByTagName("DataRange");if(u.length>0){const t=u.item(0);e.min=Number(t.getAttribute("minimum")),e.max=Number(t.getAttribute("maximum")),e.logScale="LOG"===t.getAttribute("type")}}const Cb=qi;class Ab{constructor(){this.attributes={},this.plinkLoaded=!1}async loadPlinkFile(t,e){e||(e={});var i=la(e);const n=await zo.loadString(t,i);var r=Cb(n);for(let t of r){var s=t.split(" ");this.attributes[s[1]]={familyId:s[0],fatherId:s[2],motherId:s[3],sex:s[4],phenotype:s[5]}}return this.plinkLoaded=!0,this}getAttributes(t){return this.attributes[t]}getAttributeNames(){return this.hasAttributes()?Object.keys(this.attributes[Object.keys(this.attributes)[0]]):[]}hasAttributes(){return Object.keys(this.attributes).length>0}}class Tb{constructor(t,e){this.geneColors={},this.gene=null,this.snp=null,this.genesCount=0,t&&(this.gene=t.toUpperCase(),this.geneColors[this.gene]=Ib[this.genesCount++]),e&&(this.snp=e.toUpperCase())}addGene(t){this.geneColors[t.toUpperCase()]||(this.geneColors[t.toUpperCase()]=Ib[this.genesCount++])}colorForGene(t){return this.geneColors[t.toUpperCase()]}}var Ib=[];Ib.push("rgb(228,26,28)"),Ib.push("rgb(55,126,184)"),Ib.push("rgb(77,175,74)"),Ib.push("rgb(166,86,40)"),Ib.push("rgb(152,78,163)"),Ib.push("rgb(255,127,0)"),Ib.push("rgb(247,129,191)"),Ib.push("rgb(153,153,153)"),Ib.push("rgb(255,255,51)"),Ib.push("rgb(102, 194, 165"),Ib.push("rgb(252, 141, 98"),Ib.push("rgb(141, 160, 203"),Ib.push("rgb(231, 138, 195"),Ib.push("rgb(166, 216, 84"),Ib.push("rgb(255, 217, 47"),Ib.push("rgb(229, 196, 148"),Ib.push("rgb(179, 179, 179"),Ib.push("rgb( 141, 211, 199"),Ib.push("rgb(255, 255, 179"),Ib.push("rgb(190, 186, 218"),Ib.push("rgb(251, 128, 114"),Ib.push("rgb(128, 177, 211"),Ib.push("rgb(253, 180, 98"),Ib.push("rgb(179, 222, 105"),Ib.push("rgb(252, 205, 229"),Ib.push("rgb(217, 217, 217"),Ib.push("rgb(188, 128, 189"),Ib.push("rgb(204, 235, 197"),Ib.push("rgb(255, 237, 111");class Eb{constructor(t,e,i,n,r){this.genome=t,this.chr=e,this.start=i,this.end=n,this.bpPerPixel=r,this.id=_e.guid()}extend(t){const e=Math.min(t.start,this.start),i=Math.max(t.end,this.end),n=(i-e)/(this.end-this.start);this.start=e,this.end=i,this.bpPerPixel*=n}calculateEnd(t){return this.start+this.bpPerPixel*t}calculateBPP(t,e){return(t-this.start)/e}set(t){this.chr=t.chr,this.start=t.start,this.bpPerPixel=t.bpPerPixel}toPixels(t){return t/this.bpPerPixel}toBP(t){return this.bpPerPixel*t}shiftPixels(t,e,i){const n=this.start,r=t*this.bpPerPixel;return this.start+=r,i&&this.clampStart(e),this.end=this.start+e*this.bpPerPixel,n!==this.start}clampStart(t){const e=this.genome.getChromosome(this.chr).bpStart||0;if(this.start=Math.max(e,this.start),t){const{bpLength:e}=this.genome.getChromosome(this.chr),i=e-t*this.bpPerPixel;this.start>i&&(this.start=i)}}async zoomWithScaleFactor(t,e,i,n){const r=void 0===n?this.start+this.toBP(i/2):n,{start:s,bpPerPixel:o}=this.start,{bpLength:a}=this.getChromosome(),l=e<1?t.minimumBases()/i:a/i;this.bpPerPixel=e<1?Math.max(this.bpPerPixel*e,l):Math.min(this.bpPerPixel*e,l);const h=this.bpPerPixel*i;this.start=r-.5*h,this.clampStart(i),this.end=this.start+h,(s!==this.start||o!==this.bpPerPixel)&&await t.updateViews(!0)}getChromosome(){return this.genome.getChromosome(this.chr)}getMultiLocusLabelBPLengthOnly(t){const e=" ",i=Math.floor(this.start)+1,n=Math.round(this.start+this.bpPerPixel*t);return`${e}${this.chr}${e}${da(n-i)}${e}`}getMultiLocusLabelLocusOnly(t){const e=" ",{chr:i,start:n,end:r}=this.getPresentationLocusComponents(t);return`${e}${i}:${n}-${r}${e}`}getMultiLocusLabel(t){const e=" ",{chr:i,start:n,end:r}=this.getPresentationLocusComponents(t),s=Math.floor(this.start)+1;return`${e}${i}:${n}-${r}${e}${e}(${da(Math.round(this.start+this.bpPerPixel*t)-s)})${e}`}getPresentationLocusComponents(t){if("all"===this.chr)return{chr:this.chr};{const e=$i(Math.floor(this.start)+1),i=$i(Math.round(this.start+this.bpPerPixel*t));return{chr:this.chr,start:e,end:i}}}getLocusString(){if("all"===this.chr)return"all";{const t=$i(Math.floor(this.start)+1),e=$i(Math.round(this.end));return`${this.chr}:${t}-${e}`}}description(t){console.log(` ${t||""} referenceFrame - ${this.chr} bpp ${this.bpPerPixel.toFixed(3)} start ${$i(Math.round(this.start))} end ${$i(Math.round(this.end))} `)}}const Mb={timeout:5e3,type:"plain",url:"https://igv.org/genomes/locus.php?genome=$GENOME$&name=$FEATURE$",coords:0,chromosomeField:"chromosome",startField:"start",endField:"end",geneField:"gene",snpField:"snp"};class Rb{constructor(t){this.browser=t}navbarDidResize(t){this.updateNavbar(this.createResponsiveClassSchedule(t))}updateNavbar(t){this.browser.$toggle_button_container.removeClass(),this.browser.$toggle_button_container.addClass(t.$toggle_button_container),fe(this.browser.zoomWidget.zoomContainer).removeClass(),fe(this.browser.zoomWidget.zoomContainer).addClass(t.zoomContainer)}createResponsiveClassSchedule(t){let e={};const i=this.browser.isMultiLocusWholeGenomeView()||this.browser.referenceFrameList&&ul.isWholeGenomeView(this.browser.referenceFrameList[0].chr);return i?this.browser.windowSizePanel.hide():this.browser.windowSizePanel.show(),t>990?(e.$toggle_button_container="igv-navbar-toggle-button-container",e.zoomContainer="igv-zoom-widget"):t>860?(e.$toggle_button_container="igv-navbar-toggle-button-container",e.zoomContainer="igv-zoom-widget-900"):t>540?(e.$toggle_button_container="igv-navbar-toggle-button-container-750",e.zoomContainer="igv-zoom-widget-900"):(e.$toggle_button_container="igv-navbar-toggle-button-container-750",e.zoomContainer="igv-zoom-widget-900",this.browser.windowSizePanel.hide()),i&&(e.zoomContainer="igv-zoom-widget-hidden"),e}}const Lb=function(t,e){this.container=_e.div({class:"igv-chromosome-select-widget-container"}),e.appendChild(this.container),this.select=document.createElement("select"),this.select.setAttribute("name","chromosome-select-widget"),this.container.appendChild(this.select),this.select.addEventListener("change",(()=>{this.select.blur(),""!==this.select.value&&t.search(this.select.value)})),this.showAllChromosomes=!1!==t.config.showAllChromosomes};Lb.prototype.show=function(){this.container.style.display="flex"},Lb.prototype.hide=function(){this.container.style.display="none"},Lb.prototype.update=function(t){const e=this.showAllChromosomes?t.chromosomeNames.slice():t.wgChromosomeNames.slice();t.showWholeGenomeView()&&(e.unshift("all"),e.unshift("")),this.select.innerHTML="";for(let t of e){const e=document.createElement("option");e.setAttribute("value",t),e.innerText=t,this.select.appendChild(e)}};class Bb{constructor(t,e){this.container=_e.div({class:"igv-windowsize-panel-container"}),t.appendChild(this.container),e.on("locuschange",(t=>{this.updatePanel(t)})),this.browser=e}show(){this.container.style.display="block"}hide(){this.container.style.display="none"}updatePanel(t){const e=this.browser.calculateViewportWidth(this.browser.referenceFrameList.length);this.container.innerText=1===t.length?da(Math.round(e*t[0].bpPerPixel)):""}}class Nb{constructor(t,e){this.browser=e,this.columnContainer=t,this.horizontalGuide=_e.div({class:"igv-cursor-guide-horizontal"}),t.appendChild(this.horizontalGuide),this.verticalGuide=_e.div({class:"igv-cursor-guide-vertical"}),t.appendChild(this.verticalGuide),this.addMouseHandler(e),this.setVisibility(e.config.showCursorGuide)}addMouseHandler(t){this.boundMouseMoveHandler=function(e){const{x:i,y:n}=_e.translateMouseCoordinates(e,this.columnContainer);this.horizontalGuide.style.top=`${n}px`;const r=function(t,e){for(;t.parentElement;){if(t.parentElement.classList.contains("igv-viewport"))return t.parentElement;t=t.parentElement}}(document.elementFromPoint(e.clientX,e.clientY));if(r&&t.getRulerTrackView()){this.verticalGuide.style.left=`${i}px`;const n=t.root.querySelectorAll(".igv-column");let s;const o=r.parentElement;for(let t=0;t{t.cursorGuideVisible=!t.cursorGuideVisible,t.setCursorGuideVisibility(t.cursorGuideVisible),this.setButtonState(t.cursorGuideVisible)})),this.setButtonState(t.cursorGuideVisible),t.config.showCursorTrackingGuideButton?this.show():this.hide()}setButtonState(t){!0===t?this.button.classList.add("igv-navbar-button-clicked"):this.button.classList.remove("igv-navbar-button-clicked")}show(){this.button.style.display="block",this.setButtonState(this.browser.cursorGuideVisible)}hide(){this.button.style.display="none"}}class Ob{constructor(t,e){this.browser=t,this.button=_e.div({class:"igv-navbar-button"}),e.appendChild(this.button),this.button.textContent="center line",this.button.addEventListener("click",(()=>{t.isCenterLineVisible=!t.isCenterLineVisible,t.setCenterLineVisibility(t.isCenterLineVisible),this.setButtonState(t.isCenterLineVisible)})),this.setButtonState(t.isCenterLineVisible),t.config.showCenterGuideButton?this.show():this.hide()}setButtonState(t){!0===t?this.button.classList.add("igv-navbar-button-clicked"):this.button.classList.remove("igv-navbar-button-clicked")}show(){this.isVisible=!0,this.button.style.display="block",this.setButtonState(this.browser.isCenterLineVisible)}hide(){this.isVisible=!1,this.button.style.display="none"}}class Db{constructor(t,e){this.button=_e.div({class:"igv-navbar-button"}),t.appendChild(this.button),this.button.textContent="track labels",this.button.addEventListener("click",(()=>{e.trackLabelsVisible=!e.trackLabelsVisible,this.setState(e.trackLabelsVisible),e.setTrackLabelVisibility(e.trackLabelsVisible)})),this.browser=e,this.setVisibility(e.config.showTrackLabelButton),this.setState(e.trackLabelsVisible)}setVisibility(t){!0===t?this.show():this.hide()}setState(t){!0===t?this.button.classList.add("igv-navbar-button-clicked"):this.button.classList.remove("igv-navbar-button-clicked")}show(){this.button.style.display="block",this.setState(this.browser.trackLabelsVisible)}hide(){this.button.style.display="none"}}class Pb{constructor(t,e){this.button=_e.div({class:"igv-navbar-button"}),t.appendChild(this.button),this.button.innerText="Sample Names",this.setState(e.showSampleNames),this.setVisibility(e.showSampleNameButton),this.button.addEventListener("click",(()=>{e.showSampleNames=!e.showSampleNames,this.setState(e.showSampleNames);for(let{sampleNameViewport:t}of e.trackViews)!1===e.showSampleNames?t.hide():t.show();e.layoutChange()}))}setVisibility(t){!0===t?this.show():this.hide()}setState(t){!0===t?this.button.classList.add("igv-navbar-button-clicked"):this.button.classList.remove("igv-navbar-button-clicked")}hide(){this.button.style.display="none"}show(){this.button.style.display="block"}}let zb=23,Ub=0;const Vb=function(t,e){this.browser=t,this.zoomContainer=_e.div({class:"igv-zoom-widget"}),e.appendChild(this.zoomContainer),this.zoomOutButton=_e.div(),this.zoomContainer.appendChild(this.zoomOutButton),this.zoomOutButton.appendChild(_i.createIcon("minus-circle")),this.zoomOutButton.addEventListener("click",(()=>{t.zoomOut()}));const i=_e.div();this.zoomContainer.appendChild(i),this.slider=document.createElement("input"),this.slider.type="range",this.slider.min="0",this.slider.max=`${zb}`,i.appendChild(this.slider),this.slider.addEventListener("change",(e=>{e.preventDefault(),e.stopPropagation();const i=t.referenceFrameList[0],{bpLength:n}=i.genome.getChromosome(i.chr),{end:r,start:s}=i,o=r-s,a=n/Math.pow(2,e.target.valueAsNumber);t.zoomWithScaleFactor(a/o)})),this.zoomInButton=_e.div(),this.zoomContainer.appendChild(this.zoomInButton),this.zoomInButton.appendChild(_i.createIcon("plus-circle")),this.zoomInButton.addEventListener("click",(()=>{t.zoomIn()})),t.on("locuschange",(t=>{this.browser.isMultiLocusMode()?this.disable():(this.enable(),this.update(t))}))};Vb.prototype.update=function(t){const e=t[0],{bpLength:i}=e.genome.getChromosome(e.chr),{start:n,end:r}=e;zb=Math.ceil(Math.log2(i/this.browser.minimumBases())),this.slider.max=`${zb}`;const s=i/(r-n);Ub=Math.log2(s),this.slider.value=`${Math.round(Ub)}`},Vb.prototype.enable=function(){this.slider.disabled=!1},Vb.prototype.disable=function(){this.slider.disabled=!0},Vb.prototype.hide=function(){this.zoomContainer.style.display="none"},Vb.prototype.show=function(){this.zoomContainer.style.display="block"},Vb.prototype.hideSlider=function(){this.slider.style.display="none"},Vb.prototype.showSlider=function(){this.slider.style.display="block"};const Hb=function(t,e){const i=_e.div({class:"igv-navbar-button"});t.append(i),i.textContent="Save SVG",i.addEventListener("click",(()=>e.saveSVGtoFile({})))};class jb{constructor(t,e,i){this.browser=t,this.referenceFrame=e,this.column=i,this.container=_e.div({class:"igv-center-line"}),i.appendChild(this.container),t.isCenterLineVisible?this.show():this.hide()}repaint(){if(this.referenceFrame)if(1/this.referenceFrame.bpPerPixel>1){const t=Math.floor(this.referenceFrame.toPixels(1));this.container.style.width=`${t}px`,this.container.classList.remove("igv-center-line-thin"),this.container.classList.add("igv-center-line-wide")}else this.container.style.width="1px",this.container.classList.remove("igv-center-line-wide"),this.container.classList.add("igv-center-line-thin")}show(){this.isVisible=!0,this.container.style.display="block",this.repaint()}hide(){this.isVisible=!1,this.container.style.display="none"}resize(){this.repaint()}}const $b=$i;class qb{constructor(t){this.browser=t,this.height=40,this.name="",this.id="ruler",this.disableButtons=!0,this.ignoreTrackMenu=!0,this.order=.01*Number.MIN_SAFE_INTEGER,this.removable=!1,this.type="ruler"}async getFeatures(t,e,i){return[]}computePixelHeight(t){return this.height}draw({context:t,referenceFrame:e,pixelWidth:i,pixelHeight:n,bpPerPixel:r,bpStart:s}){ul.isWholeGenomeView(e.chr)?this.drawWholeGenome({context:t,pixelWidth:i,pixelHeight:n,bpPerPixel:r}):this.doDraw({context:t,referenceFrame:e,pixelWidth:i,pixelHeight:n,bpStart:s})}drawWholeGenome({context:t,pixelWidth:e,pixelHeight:i,bpPerPixel:n}){t.save(),na.fillRect(t,0,0,e,i,{fillStyle:"white"});for(let e of this.browser.genome.wgChromosomeNames){let r=this.browser.genome.getCumulativeOffset(e),s=this.browser.genome.getChromosome(e).bpLength,o=Math.round(r/n),a=Math.round(s/n);this.renderChromosomeRect(t,o,0,a,i,e)}t.restore()}doDraw({context:t,referenceFrame:e,pixelWidth:i,pixelHeight:n,bpStart:r}){t.clearRect(0,0,i,n);const s=function(t,e){if(t<10)return new Wb(1,"bp",1);const i=Math.floor(Math.log10(t));let n="bp",r=1;i>9?(n="gb",r=1e9):i>6?(n="mb",r=1e6):i>3&&(n="kb",r=1e3);const s=t/Math.pow(10,i-1),o=Math.pow(10,i-1),a=Math.pow(10,i)/2;return new Wb(s<75&&!0!==e?o:a,n,r)}(Math.floor(e.toBP(i)),t.isSVG);let o=Math.floor(r/s.majorTick)-1;const{tickDelta:a,labelLength:l}=function(t,e,i,n,r){const s=l(e,a(1+n,r),i)-l(e,a(n,r),i),o=`${$i(Math.floor(a(n,r)/r.unitMultiplier))} ${r.majorUnit}`;return{tickDelta:s,labelLength:Math.floor(t.measureText(o).width)};function a(t,e){return Math.floor(t*e.majorTick)}function l(t,e,i){return Math.round(t.toPixels(e-1-i+.5))}}(t,e,r,o,s);let h,c;this.browser.referenceFrameList.indexOf(e);let u=a;const d=.25*l;do{c=Math.floor(o*s.majorTick);const i=`${$i(Math.floor(c/s.unitMultiplier))} ${s.majorUnit}`;h=Math.round(e.toPixels(c-1-r+.5));const n=Math.round(h-t.measureText(i).width/2);n>0&&d+l<=u&&(na.fillText(t,i,n,this.height-8),u=0),h>0&&na.strokeLine(t,h,this.height-6,h,this.height-2),c=Math.floor((1+o)*s.majorTick);let f=h+(Math.round(e.toPixels(c-1-r+.5))-h)/2;f>0&&na.strokeLine(t,f,this.height-6,f,this.height-2),++o,u+=a}while(ht.measureText(o).width&&na.fillText(t,o,e+n/2,i+r/2,{fillStyle:xo.greyScale(68)})}get supportsWholeGenome(){return!0}dispose(){}}class Wb{constructor(t,e,i){this.majorTick=t,this.minorTick=t/10,this.majorUnit=e,this.unitMultiplier=i}description(t){console.log((t||"")+" tick "+$b(this.majorTick)+" label width "+$b(this.labelWidthBP)+" multiplier "+this.unitMultiplier)}}const Gb=function(t,e){this.button=_e.div({class:"igv-navbar-button"}),t.appendChild(this.button),this.button.textContent="circular view",this.button.addEventListener("click",(()=>{e.circularViewVisible=!e.circularViewVisible})),this.browser=e,this.setVisibility(e.config.showCircularViewButton),this.setState(e.circularViewVisible)};Gb.prototype.setVisibility=function(t){!0===t?this.show():this.hide()},Gb.prototype.setState=function(t){!0===t?this.button.classList.add("igv-navbar-button-clicked"):this.button.classList.remove("igv-navbar-button-clicked")},Gb.prototype.show=function(){this.button.style.display="block",this.setState(this.browser.circularViewVisible)},Gb.prototype.hide=function(){this.button.style.display="none"};const Zb=function(t,e,i){const n=_e.div({class:"igv-navbar-button"});t.append(n),n.textContent=i.label,n.addEventListener("click",(()=>i.callback(e)))};class Yb{constructor(t,e,i,n,r){this.browser=t,this.roiMenu=e,this.roiTable=i,this.top=n,this.roiSets=r||[],this.boundLocusChangeHandler=Qb.bind(this),t.on("locuschange",this.boundLocusChangeHandler)}async initialize(){this.roiSets.length>0&&(this.browser.showROITableButton=!0,this.browser.roiTableControl.setVisibility(this.browser.showROITableButton));const t=this.roiSets.map((t=>this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:t})));t.length>0&&await Promise.all(t);const e=await this.getTableRecords();this.roiTable.renderTable(e)}async loadROI(t,e){const i=Array.isArray(t)?t:[t];for(let t of i)this.roiSets.push(new Gc(t,e));await this.initialize()}clearROIs(){this.roiTable.clearTable();const t=this.browser.columnContainer.querySelectorAll(".igv-roi-region");for(let e of t)e.remove();for(let t of this.roiSets)t.dispose();this.roiSets=[]}async getTableRecords(){const t=[];for(let e of this.roiSets){const i=e.isUserDefined?"":e.name||"",n=await e.getAllFeatures();for(let e of Object.keys(n))for(let r of n[e])t.push({setName:i,feature:r})}return t}presentTable(){this.roiTable.present()}async repaintTable(){const t=await this.getTableRecords();this.roiTable.renderTable(t)}dismissTable(){this.roiTable.dismiss()}async updateUserDefinedROISet(t){let e=await this.getUserDefinedROISet();void 0===e&&(e=this.initializeUserDefinedROISet()),e.addFeature(t),!1===this.browser.showROITableButton&&this.setROITableButtonVisibility(!0),await this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:e});const i=await this.getTableRecords();this.roiTable.renderTable(i)}setROITableButtonVisibility(t){this.browser.showROITableButton=t,this.browser.roiTableControl.setVisibility(this.browser.showROITableButton)}async renderAllROISets(){for(let t of this.roiSets)await this.renderROISet({browser:this.browser,pixelTop:this.top,roiSet:t})}async renderROISet({browser:t,pixelTop:e,roiSet:i}){const n=t.columnContainer.querySelectorAll(".igv-column");for(let r=0;ra)&&t.remove()}const c=await i.getFeatures(s,o,a);if(c)for(let h of c){const c=Xb(s,h.start,h.end),{x:u,width:d}=Zc(Math.max(o,h.start),Math.min(a,h.end),o,l),f=n[r].querySelector(Kb(c));if(f)f.style.left=`${u}px`,f.style.width=`${d}px`;else{const s=this.createRegionElement(t.columnContainer,e,u,d,i,c,h.name);n[r].appendChild(s)}}}}createRegionElement(t,e,i,n,r,s,o){const a=_e.div({class:"igv-roi-region"});a.style.top=`${e}px`,a.style.left=`${i}px`,a.style.width=`${n}px`,a.style.backgroundColor=r.color,a.dataset.region=s;const l=_e.div();return a.appendChild(l),l.style.backgroundColor=r.headerColor,!0===r.isUserDefined?l.addEventListener("click",(e=>{e.preventDefault(),e.stopPropagation();const{x:i,y:n}=_e.translateMouseCoordinates(e,t);this.roiMenu.present(i,n,this,t,a)})):o?l.addEventListener("click",(e=>{e.preventDefault(),e.stopPropagation(),this.popover&&this.popover.dispose(),this.popover=new Oi(t,r.name),this.popover.presentContentWithEvent(e,o)})):l.style.pointerEvents="none",a}renderSVGContext(t,{deltaX:e,deltaY:i}){for(const n of document.querySelectorAll(".igv-roi-region")){const{x:r,y:s,width:o,height:a}=n.getBoundingClientRect();t.fillStyle=n.style.backgroundColor,t.fillRect(r+e,s+i,o,a);const l=n.querySelector("div"),{x:h,y:c,width:u,height:d}=l.getBoundingClientRect();t.fillStyle=l.style.backgroundColor,t.fillRect(h+e,c+i,u,d)}}async getUserDefinedROISet(){return this.roiSets.find((t=>!0===t.isUserDefined))}initializeUserDefinedROISet(){const t=new Gc({isUserDefined:!0,features:[]},this.browser.genome);return this.roiSets.push(t),t}async deleteUserDefinedRegionWithKey(t,e){e.querySelectorAll(Kb(t)).forEach((t=>t.remove()));const i=await this.findUserDefinedRegionWithKey(t),n=await this.getUserDefinedROISet();n&&n.removeFeature(i),0===(await this.getTableRecords()).length&&(this.browser.roiTableControl.buttonHandler(!1),this.setROITableButtonVisibility(!1))}async findUserDefinedRegionWithKey(t){const{chr:e,start:i,end:n}=Jb(t),r=await this.getUserDefinedROISet();if(r){const t=await r.getFeatures(e,i,n);for(let r of t)if(r.chr===e&&r.start>=i&&r.end<=n)return r}}toJSON(){return this.roiSets.map((t=>t.toJSON()))}dispose(){this.browser.off("locuschange",this.boundLocusChangeHandler);const t=this.browser.columnContainer.querySelectorAll(".igv-roi-region");for(let e of t)e.remove();this.roiMenu&&this.roiMenu.dispose(),this.roiTable&&this.roiTable.dispose();for(let t of this.roiSets)t.dispose();for(let t of Object.keys(this))this[t]=void 0}}function Qb(){this.renderAllROISets()}function Xb(t,e,i){return`${t}-${e}-${i}`}function Kb(t){return`[data-region="${t}"]`}function Jb(t){let[e,i,n]=t.split("-");return i=parseInt(i),n=parseInt(n),{chr:e,start:i,end:n,locus:`${e}:${i}-${n}`,bedRecord:`${e}\t${i}\t${n}`}}class ty extends Fd{constructor(t){super(Object.assign({width:"512px"},t))}tableRowDOM(t){const e=_e.div({class:"igv-roi-table-row"}),{setName:i,feature:n}=t;e.dataset.region=Xb(n.chr,n.start,n.end);let r=[n.chr,$i(n.start),$i(n.end),n.name||"",i];4===this.columnFormat.length&&(r=r.slice(0,4));for(let t=0;tt.remove())),t.length>0){const e=t.sort(((t,e)=>t.feature.chr.localeCompare(e.feature.chr)||t.feature.start-e.feature.start||t.feature.end-e.feature.end));for(let t of e){const e=this.tableRowDOM(t);this.tableRowContainer.appendChild(e)}}}dispose(){document.removeEventListener("click",this.boundGotoButtonHandler),this.browser.roiTableControl.buttonHandler(!1),super.dispose()}static getColumnFormatConfiguration(t){return!0===t?[{label:"Chr",width:"20%"},{label:"Start",width:"15%"},{label:"End",width:"15%"},{label:"Description",width:"30%"},{label:"ROI Set",width:"20%"}]:[{label:"Chr",width:"25%"},{label:"Start",width:"20%"},{label:"End",width:"20%"},{label:"Description",width:"35%"}]}static gotoButtonHandler(t){t.stopPropagation();const e=this.tableDOM.querySelectorAll(".igv-roi-table-row-selected"),i=[];for(let t of e){const{locus:e}=Jb(t.dataset.region);i.push(e)}for(let t of this.tableDOM.querySelectorAll(".igv-roi-table-row"))t.classList.remove("igv-roi-table-row-selected");this.setTableRowSelectionState(!1),i.length>0&&this.browser.search(i.join(" "))}}class ey{constructor(t,e){this.browser=t,this.container=_e.div({class:"igv-roi-menu-next-gen"}),e.appendChild(this.container);const i=_e.div();this.container.appendChild(i),ki.attachDialogCloseHandlerWithParent(i,(()=>this.container.style.display="none")),this.body=_e.div(),this.container.appendChild(this.body),this.container.style.display="none"}async present(t,e,i,n,r){iy(this.body);const s=await this.browser.roiManager.findUserDefinedRegionWithKey(r.dataset.region),o=_e.div();this.body.appendChild(o);const a="Description",l=s.name||a;o.innerText=l,o.setAttribute("title",l),a===l?o.classList.add("igv-roi-placeholder"):o.classList.remove("igv-roi-placeholder");const h=_e.div();this.body.appendChild(h),h.innerText="Set Description",h.addEventListener("click",(t=>{t.stopPropagation(),this.container.style.display="none";const e={label:"Description",value:s.name||"",callback:()=>{const t=this.browser.inputDialog.value||"";s.name=t.trim(),this.container.style.display="none",this.browser.roiManager.repaintTable()}};this.browser.inputDialog.present(e,t)}));const c=_e.div();this.body.appendChild(c),c.innerText="Delete Region",c.addEventListener("click",(t=>{t.stopPropagation(),this.container.style.display="none",this.browser.roiManager.deleteUserDefinedRegionWithKey(r.dataset.region,this.browser.columnContainer)})),this.container.style.left=`${t}px`,this.container.style.top=`${e}px`,this.container.style.display="flex"}async __present(t,e,i,n,r){iy(this.container);const s=await this.browser.roiManager.findUserDefinedRegionWithKey(r.dataset.region);let o;o=_e.div({class:"igv-roi-menu-row-edit-description"}),this.container.appendChild(o),o.addEventListener("click",(t=>{t.stopPropagation()}));const a="description-input",l=document.createElement("label");o.appendChild(l),l.setAttribute("for",a),l.innerText="Description:";const h=document.createElement("input");o.appendChild(h),h.setAttribute("type","text"),h.setAttribute("name",a),h.setAttribute("placeholder",""),h.value=s.name||"",h.addEventListener("change",(async t=>{t.stopPropagation(),(await this.browser.roiManager.findUserDefinedRegionWithKey(r.dataset.region)).name=h.value,h.blur(),this.container.style.display="none",await this.browser.roiManager.repaintTable()})),o=_e.div({class:"igv-roi-menu-row"}),o.innerText="Delete region",this.container.appendChild(o),o.addEventListener("click",(t=>{t.stopPropagation(),this.container.style.display="none",this.browser.roiManager.deleteUserDefinedRegionWithKey(r.dataset.region,this.browser.columnContainer)})),this.container.style.left=`${t}px`,this.container.style.top=`${e}px`,this.container.style.display="flex",n.addEventListener("click",(t=>{t.stopPropagation(),this.container.style.display="none"}))}dispose(){this.container.innerHTML=""}}function iy(t){for(;t.firstChild;)t.removeChild(t.firstChild)}class ny{constructor(t,e){this.name=t.name,this.featureSource=t.featureSource||$c(t,e),this.color=t.color||qc}async getFeatures(t,e,i){return this.featureSource.getFeatures({chr:t,start:e,end:i})}draw(t){const{context:e,bpPerPixel:i,bpStart:n,pixelTop:r,pixelHeight:s,pixelWidth:o,features:a}=t;if(!a)return;const l=n+o*i+1;for(let{start:t,end:o}of a){if(ol)break;const{x:a,width:h}=Zc(t,o,n,i);na.fillRect(e,a,r,h,s,{fillStyle:this.color})}}}class ry{constructor(t,e){this.browser=e,this.button=_e.div({class:"igv-navbar-button"}),t.appendChild(this.button),this.button.textContent="ROI Table",this.button.addEventListener("click",(()=>{this.buttonHandler(!e.roiTableVisible)})),this.browser=e,this.setVisibility(e.showROITableButton),this.setState(e.roiTableVisible)}buttonHandler(t){this.browser.roiTableVisible=t,this.setState(this.browser.roiTableVisible),this.browser.setROITableVisibility(this.browser.roiTableVisible)}setVisibility(t){!0===t?this.show():this.hide()}setState(t){!0===t?this.button.classList.add("igv-navbar-button-clicked"):this.button.classList.remove("igv-navbar-button-clicked")}show(){this.button.style.display="block",this.setState(this.browser.roiTableVisible)}hide(){this.button.style.display="none"}}class sy{constructor(t,e){this.config=t,this.guid=_e.guid(),this.namespace=".browser_"+this.guid,this.parent=e,this.root=_e.div({class:"igv-container"}),e.appendChild(this.root),this.alert=new sa(this.root),this.columnContainer=_e.div({class:"igv-column-container"}),this.root.appendChild(this.columnContainer),this.menuPopup=new sf(this.columnContainer),this.initialize(t),this.trackViews=[],this.constants={dragThreshold:3,scrollThreshold:5,defaultColor:"rgb(0,0,150)",doubleClickDelay:t.doubleClickDelay||500},this.eventHandlers={},this.addMouseHandlers(),this.setControls(t)}initialize(t){t.gtex&&(Sd.gtexLoaded=!0),this.flanking=t.flanking,this.crossDomainProxy=t.crossDomainProxy,this.formats=t.formats,this.trackDefaults=t.trackDefaults,this.nucleotideColors=t.nucleotideColors||$a;for(let t of Object.keys(this.nucleotideColors))this.nucleotideColors[t.toLowerCase()]=this.nucleotideColors[t];this.trackLabelsVisible=t.showTrackLabels,this.roiTableVisible=t.showROITable,this.showROITableButton=t.showROITableButton,this.isCenterLineVisible=t.showCenterGuide,this.cursorGuideVisible=t.showCursorGuide,this.showSampleNames=t.showSampleNames,this.showSampleNameButton=t.showSampleNameButton,this.sampleNameViewportWidth=t.sampleNameViewportWidth||200,t.search&&(this.searchConfig={type:"json",url:t.search.url,coords:void 0===t.search.coords?1:t.search.coords,chromosomeField:t.search.chromosomeField||"chromosome",startField:t.search.startField||"start",endField:t.search.endField||"end",geneField:t.search.geneField||"gene",snpField:t.search.snpField||"snp",resultsField:t.search.resultsField})}setControls(t){const e=this.createStandardControls(t);e.insertBefore(fe(this.columnContainer)),this.$navigation=e,!1===t.showControls&&e.hide()}createStandardControls(t){this.navbarManager=new Rb(this);const e=fe("
",{class:"igv-navbar"});this.$navigation=e;const i=fe("
",{class:"igv-navbar-left-container"});e.append(i);const n=fe("
",{class:"igv-logo"});i.append(n);const r=fe('IGV; ');r.css("width","34px"),r.css("height","32px"),n.append(r),this.$current_genome=fe("
",{class:"igv-current-genome"}),i.append(this.$current_genome),this.$current_genome.text("");const s=fe("
",{class:"igv-navbar-genomic-location"});i.append(s),this.chromosomeSelectWidget=new Lb(this,s.get(0)),void 0===t.showChromosomeWidget&&(t.showChromosomeWidget=!0),!0===t.showChromosomeWidget?this.chromosomeSelectWidget.show():this.chromosomeSelectWidget.hide();const o=fe("
",{class:"igv-locus-size-group"});s.append(o);const a=fe("
",{class:"igv-search-container"});o.append(a),this.$searchInput=fe("",{class:"igv-search-input",type:"text",placeholder:"Locus Search"}),a.append(this.$searchInput),this.$searchInput.change((()=>this.doSearch(this.$searchInput.val())));const l=_e.div({class:"igv-search-icon-container"});a.append(fe(l)),l.appendChild(_i.createIcon("search")),l.addEventListener("click",(()=>this.doSearch(this.$searchInput.val()))),this.windowSizePanel=new Bb(o.get(0),this);const h=fe("
",{class:"igv-navbar-right-container"});e.append(h);const c=fe('
');if(h.append(c),this.$toggle_button_container=c,this.cursorGuide=new Nb(this.columnContainer,this),this.cursorGuideButton=new Fb(this,c.get(0)),this.centerLineButton=new Ob(this,c.get(0)),this.setTrackLabelVisibility(t.showTrackLabels),this.trackLabelControl=new Db(c.get(0),this),this.roiTableControl=new ry(c.get(0),this),this.sampleNameControl=new Pb(c.get(0),this),!0===t.showSVGButton&&(this.svgSaveControl=new Hb(c.get(0),this)),t.customButtons)for(let e of t.customButtons)new Zb(c.get(0),this,e);return this.zoomWidget=new Vb(this,h.get(0)),!1===t.showNavigation&&this.$navigation.hide(),this.inputDialog=new Mi(this.root),this.inputDialog.container.id=`igv-input-dialog-${_e.guid()}`,this.dataRangeDialog=new Hi(this,fe(this.root)),this.dataRangeDialog.$container.get(0).id=`igv-data-range-dialog-${_e.guid()}`,this.genericColorPicker=new Pi({parent:this.columnContainer,width:432}),this.genericColorPicker.container.id=`igv-track-color-picker-${_e.guid()}`,e}getSampleNameViewportWidth(){return!1===this.showSampleNames?0:this.sampleNameViewportWidth}isMultiLocusMode(){return this.referenceFrameList&&this.referenceFrameList.length>1}addTrackToFactory(t,e){xb(t,e)}isMultiLocusWholeGenomeView(){if(void 0===this.referenceFrameList||1===this.referenceFrameList.length)return!1;for(let t of this.referenceFrameList)if("all"===t.chr.toLowerCase())return!0;return!1}currentLoci(){const t=t=>`${t.chr}:${t.start+1}-${t.end}`;return void 0===this.referenceFrameList||0===this.referenceFrameList.length?"":1===this.referenceFrameList.length?t(this.referenceFrameList[0]):this.referenceFrameList.map((e=>t(e)))}toSVG(){const{y:t,width:e,height:i}=this.columnContainer.getBoundingClientRect(),n=new ll({width:e,height:8e3,backdropColor:"white",multiLocusGap:0,viewbox:{x:0,y:0,width:e,height:8e3}}),r={deltaX:0,deltaY:-t};for(let t of this.trackViews)t.renderSVGContext(n,r);return this.roiManager.renderSVGContext(n,r),n.setHeight(i),n.getSerializedSvg(!0)}renderSVG(t){const e=this.toSVG();return t.empty(),t.append(e),e}saveSVGtoFile(t){let e=this.toSVG();t.$container&&(t.$container.empty(),t.$container.append(e)),Qi(t.filename||"igvjs.svg",URL.createObjectURL(new Blob([e],{type:"application/octet-stream"})))}async loadSession(t){let e;return this.roiSets=[],e=t.url||t.file?await async function(t){const e=t.url||t.file;if(t.url&&(t.url.startsWith("blob:")||t.url.startsWith("data:"))){const e=sy.uncompressSession(t.url);return JSON.parse(e)}{let i=t.filename;if(i||(i=t.url?await ua(t.url):t.file.name),i.endsWith(".xml")){const t=ul.KNOWN_GENOMES,i=await zo.loadString(e);return new kb(i,t)}return i.endsWith(".json")?zo.loadJson(e):void 0}}(t):t,this.loadSessionObject(e)}async loadSessionObject(t){this.cleanHouseForSession(),this.showSampleNames=t.showSampleNames||!1,this.sampleNameControl.setState(!0===this.showSampleNames),t.sampleNameViewportWidth&&(this.sampleNameViewportWidth=t.sampleNameViewportWidth),pa(this.columnContainer,"igv-axis-column"),pa(this.columnContainer,"igv-sample-name-column"),pa(this.columnContainer,"igv-scrollbar-column"),pa(this.columnContainer,"igv-track-drag-column"),pa(this.columnContainer,"igv-gear-menu-column");const e=t.reference||t.genome;if(!e)return void console.warn("No genome or reference object specified");const i=await ul.expandReference(this.alert,e);await this.loadReference(i,t.locus),this.centerLineList=this.createCenterLineList(this.columnContainer);let n=0;if(!1!==t.showIdeogram){const t=new zf(this);t.id="ideogram";const e=new hf(this,this.columnContainer,t),{$viewport:i}=e.viewports[0];n=function(t){t="string"==typeof t?document.querySelector(t):t;const e=window.getComputedStyle(t),i=parseFloat(e.marginTop)+parseFloat(e.marginBottom),n=t.offsetHeight;return Math.ceil(i+n)}(i.get(0)),this.trackViews.push(e)}if(!1!==t.showRuler&&this.trackViews.push(new hf(this,this.columnContainer,new qb(this))),t.gtexSelections)for(let e of this.referenceFrameList)for(let i of Object.keys(t.gtexSelections)){const n=t.gtexSelections[i].gene,r=t.gtexSelections[i].snp;e.selection=new Tb(n,r)}this.roiManager&&this.roiManager.dispose();const r=new ey(this,this.columnContainer),s={browser:this,parent:this.columnContainer,headerTitle:"Regions of Interest",dismissHandler:()=>this.roiTableControl.buttonHandler(!1),gotoButtonHandler:ty.gotoButtonHandler};if(t.roi){const e=t.roi.map((t=>new Gc(t,this.genome))),i=e.filter((({name:t})=>void 0!==t&&t.length>0));s.columnFormat=ty.getColumnFormatConfiguration(i.length>0);const o=new ty(s);this.roiManager=new Yb(this,r,o,n,e)}else{s.columnFormat=ty.getColumnFormatConfiguration(!1);const t=new ty(s);this.roiManager=new Yb(this,r,t,n,void 0)}await this.roiManager.initialize();const o=i.tracks||[],a=t.tracks?o.concat(t.tracks):o;0===a.filter((t=>"sequence"===t.type&&!t.url&&!t.fastaURL)).length&&a.push({type:"sequence",order:qa});let l=1;for(let t of a)void 0===t.order&&(t.order=l++);await this.loadTrackList(a);for(let t of this.trackViews.filter((t=>"ruler"===t.track.type||"ideogram"===t.track.type)))t.updateViews();this.updateUIWithReferenceFrameList()}createCenterLineList(t){const e=t.querySelectorAll(".igv-center-line");for(let t=0;tt.remove())),this.trackViews=[],this.circularView&&this.circularView.clearChords()}updateNavbarDOMWithGenome(t){let e=t.id&&t.id.length<10?t.id:"";this.$current_genome.text(e),this.$current_genome.attr("title",t.id||""),this.chromosomeSelectWidget.update(t)}async loadGenome(t){const e=await ul.expandReference(this.alert,t);await this.loadReference(e,void 0);const i=e.tracks||[];return 0===i.filter((t=>"sequence"===t.type)).length&&i.push({type:"sequence",order:qa}),await this.loadTrackList(i),await this.updateViews(),this.genome}updateUIWithReferenceFrameList(){const t=this.referenceFrameList;this.updateLocusSearchWidget();const e=this.isMultiLocusWholeGenomeView()||ul.isWholeGenomeView(t[0].chr);this.navbarManager.navbarDidResize(this.$navigation.width(),e),hy(this.trackViews,this.trackLabelsVisible),this.setCenterLineAndCenterLineButtonVisibility(!ul.isWholeGenomeView(t[0].chr))}setTrackLabelVisibility(t){hy(this.trackViews,t)}setROITableVisibility(t){!0===t?this.roiManager.presentTable():this.roiManager.dismissTable()}setCursorGuideVisibility(t){t?this.cursorGuide.show():this.cursorGuide.hide()}setCustomCursorGuideMouseHandler(t){this.cursorGuide.customMouseHandler=t}setCenterLineVisibility(t){for(let e of this.centerLineList)!0===t?(e.show(),e.repaint()):e.hide()}setCenterLineAndCenterLineButtonVisibility(t){for(let e of this.centerLineList)t&&e.isVisible?e.show():e.container.style.display="none";t&&this.centerLineButton.isVisible?this.centerLineButton.show():this.centerLineButton.button.style.display="none"}async loadTrackList(t){const e=[];for(let i of t)e.push(this._loadTrack(i));const i=await Promise.all(e);return this.trackViews.filter((function(t){return t.track.autoscaleGroup})).length>0&&this.updateViews(),i}async loadTrack(t){const e=this._loadTrack(t);return t.autoscaleGroup&&(await e,this.updateViews()),e}async _loadTrack(t){ji(t)&&(t=JSON.parse(t));try{const e=await this.createTrack(t);if(void 0===e)return;void 0===e.order&&(e.order=this.trackViews.length);const i=new hf(this,this.columnContainer,e);if(this.trackViews.push(i),hy(this.trackViews,this.trackLabelsVisible),this.reorderTracks(),this.fireEvent("trackorderchanged",[this.getTrackOrder()]),"function"==typeof e.postInit)try{i.startSpinner(),await e.postInit()}finally{i.stopSpinner()}return e.autoscaleGroup||(t.sync?await i.updateViews():i.updateViews()),"function"==typeof e.hasSamples&&e.hasSamples()&&!1!==this.config.showSampleNameButton&&this.sampleNameControl.show(),e}catch(e){const i={401:"Access unauthorized",403:"Access forbidden",404:"Not found"};console.error(e);let n=e.message||e.error||e.toString();i.hasOwnProperty(n)&&(n=i[n]),n+=": "+t.url,this.alert.present(new Error(n),void 0)}}async loadROI(t){await this.roiManager.loadROI(t,this.genome)}clearROIs(){this.roiManager.clearROIs()}async getUserDefinedROIs(){if(this.roiManager){const t=await this.roiManager.getUserDefinedROISet();if(void 0===t)return[];const e=await t.getAllFeatures(),i=[];for(let t of Object.values(e))i.push(...t);return i}return[]}getRulerTrackView(){const t=this.trackViews.filter((({track:t})=>"ruler"===t.id));return t.length>0?t[0]:void 0}async createTrack(t){let e=await async function(t){return"function"==typeof t?t():t}(t.url||t.fastaURL);if(ji(e)&&(e=e.trim()),e)if(t.format)t.format=t.format.toLowerCase();else if(t.fastaURL)t.format="fasta";else{let i=t.filename;i||(i=await ua(e));const n=ka(i);"tsv"===n?t.format=await Aa(t):n?t.format=n:"htsget"===t.sourceType&&await cc.inferFormat(t)}let i=t.type?t.type.toLowerCase():void 0;if(!i){if(i=Ca(t),"bedtype"===i){const e=$c(t,this.genome);t._featureSource=e;i=await e.trackType()||"annotation"}t.type=i}if(this.trackDefaults&&i){const e=this.trackDefaults[i];if(e)for(let i in e)e.hasOwnProperty(i)&&void 0===t[i]&&(t[i]=e[i])}const n=function(t,e,i){let n;switch(t){case"annotation":case"genes":case"fusionjuncspan":case"snp":n="feature";break;case"seg":case"maf":case"mut":n="seg";break;case"junctions":case"splicejunctions":n="junction";break;default:n=t}return _b.has(n)?_b.get(n)(e,i):void 0}(i,t,this);if(void 0!==n)return t.roi&&t.roi.length>0&&(n.roiSets=t.roi.map((t=>new ny(t,this.genome)))),n;this.alert.present(new Error(`Error creating track. Could not determine track type for file: ${t.url||t}`),void 0)}reorderTracks(){this.trackViews.sort((function(t,e){const i=t=>"ideogram"===t.track.id?1:"ruler"===t.track.id?2:3,n=i(t),r=i(e);return n===r?(t.track.order||0)-(e.track.order||0):n-r}));for(let{axis:t,viewports:e,sampleNameViewport:i,outerScroll:n,dragHandle:r,gearContainer:s}of this.trackViews){t.remove();for(let{$viewport:t}of e)t.detach();i.viewport.remove(),n.remove(),r.remove(),s.remove()}const t=this.columnContainer.querySelectorAll(".igv-column");for(let{axis:e,viewports:i,sampleNameViewport:n,outerScroll:r,dragHandle:s,gearContainer:o}of this.trackViews){this.columnContainer.querySelector(".igv-axis-column").appendChild(e);for(let e=0;et.track&&t.track.name)).map((t=>t.track.name))}removeTrackByName(t){const e=this.trackViews.slice();for(let i of e)t===i.track.name&&this.removeTrack(i.track)}removeTrack(t){for(let e of this.trackViews)if(t===e.track){this._removeTrack(e.track);break}}_removeTrack(t){t.disposed||(this.trackViews.splice(this.trackViews.indexOf(t.trackView),1),this.fireEvent("trackremoved",[t]),this.fireEvent("trackorderchanged",[this.getTrackOrder()]),t.trackView&&t.trackView.dispose())}removeAllTracks(){const t=[];for(let e of this.trackViews)"ruler"!==e.track.id&&"ideogram"!==e.track.id?(this.fireEvent("trackremoved",[e.track]),e.dispose()):t.push(e);this.trackViews=t}findTracks(t,e){let i="function"==typeof t?e=>t(e.track):i=>e===i.track[t];return this.trackViews.filter(i).map((t=>t.track))}setTrackHeight(t){this.trackHeight=t,this.trackViews.forEach((function(e){e.setTrackHeight(t)}))}async visibilityChange(){this.layoutChange()}async layoutChange(){if(this.referenceFrameList.find((t=>t.bpPerPixel<0))){const t=this.calculateViewportWidth(this.referenceFrameList.length);for(let e of this.referenceFrameList)e.bpPerPixel=(e.end-e.start)/t}if(this.referenceFrameList){const t=this.isMultiLocusWholeGenomeView()||ul.isWholeGenomeView(this.referenceFrameList[0].chr);this.navbarManager.navbarDidResize(this.$navigation.width(),t)}oy.call(this),await this.updateViews()}async updateViews(){const t=this.trackViews;this.updateLocusSearchWidget();for(let t of this.centerLineList)t.repaint();if(this.dragObject)for(let e of t)await e.updateViews();else{const r={},s=[];for(let i of t){const t=i.track.autoscaleGroup;if(t){var e=r[t];e||(e=[],r[t]=e),e.push(i)}else s.push(i)}if(Object.entries(r).length>0){const t=Object.keys(r);for(let e of t){const t=r[e],s=[];for(let e of t)s.push(e.getInViewFeatures());const o=await Promise.all(s);var i,n=[];for(let t of o)n=n.concat(t);i=ha(n);const a=[];for(let e of t)e.track.dataRange=i,e.track.autoscale=!1,a.push(e.updateViews());await Promise.all(a)}}await Promise.all(s.map((t=>t.updateViews())))}}repaintViews(){for(let t of this.trackViews)t.repaintViews()}updateLocusSearchWidget(){if(!this.referenceFrameList)return;const t=this.referenceFrameList,e=this.calculateViewportWidth(this.referenceFrameList.length);for(let i of t)i.end=i.start+i.bpPerPixel*e;this.chromosomeSelectWidget.select.value=1===t.length?this.referenceFrameList[0].chr:"";const i=this.referenceFrameList.map((t=>t.getLocusString())).join(" ");this.$searchInput.val(i),this.fireEvent("locuschange",[this.referenceFrameList])}calculateViewportWidth(t){let{width:e}=this.columnContainer.getBoundingClientRect();return e-=50+this.getSampleNameViewportWidth()+14+12+28,e-=5*(t-1),Math.floor(e/t)}getCenterLineXOffset(){let{width:t}=this.columnContainer.getBoundingClientRect();return t-=50+this.getSampleNameViewportWidth()+14+12+28,Math.floor(t/2+50)}minimumBases(){return this.config.minimumBases}zoomIn(){this.zoomWithScaleFactor(.5)}zoomOut(){this.zoomWithScaleFactor(2)}async zoomWithScaleFactor(t,e,i){if(!this.referenceFrameList)return;const n=this.calculateViewportWidth(this.referenceFrameList.length);let r=i?[i]:this.referenceFrameList;for(let i of r)i.zoomWithScaleFactor(this,t,n,e)}async addMultiLocusPanel(t,e,i,n){if(!this.referenceFrameList)return;const r=this.calculateViewportWidth(1+this.referenceFrameList.length),s=this.calculateViewportWidth(this.referenceFrameList.length)/this.calculateViewportWidth(1+this.referenceFrameList.length);for(let t of this.referenceFrameList)t.bpPerPixel*=s;const o=(i-e)/r,a=new Eb(this.genome,t,e,i,o),l=n?this.referenceFrameList.indexOf(n):this.referenceFrameList.length-1,h=1+l,{$viewport:c}=this.trackViews[0].viewports[l],u=(t=>{const e=_e.div({class:"igv-column-shim"});ma(e,t);const i=_e.div({class:"igv-column"});return ma(i,e),i})(c.get(0).parentElement);if(h===this.referenceFrameList.length){this.referenceFrameList.push(a);for(let t of this.trackViews){const e=tf(t,u,a);t.viewports.push(e)}}else{this.referenceFrameList.splice(h,0,a);for(let t of this.trackViews){const e=tf(t,u,a);t.viewports.splice(h,0,e)}}this.centerLineList=this.createCenterLineList(this.columnContainer),oy.call(this),await this.updateViews(!0)}async removeMultiLocusPanel(t){const e=this.referenceFrameList.indexOf(t),{$viewport:i}=this.trackViews[0].viewports[e];((t,e)=>{const i=0===t?e.nextElementSibling:e.previousElementSibling;e.remove(),i.remove()})(e,i.parent().get(0));for(let{viewports:t}of this.trackViews)t[e].dispose(),t.splice(e,1);if(this.referenceFrameList.splice(e,1),1===this.referenceFrameList.length&&this.getRulerTrackView())for(let t of this.getRulerTrackView().viewports)t.dismissLocusLabel();const n=this.calculateViewportWidth(1+this.referenceFrameList.length)/this.calculateViewportWidth(this.referenceFrameList.length);await this.rescaleForMultiLocus(n)}async gotoMultilocusPanel(t){const e=this.referenceFrameList.indexOf(t);this.columnContainer.querySelectorAll(".igv-column").forEach(((t,i)=>{i===e||t.remove()})),this.columnContainer.querySelectorAll(".igv-column-shim").forEach((t=>t.remove()));for(let t of this.trackViews){const i=t.viewports[e];t.viewports.filter(((t,i)=>i!==e)).forEach((t=>t.dispose())),t.viewports=[i]}const i=this.calculateViewportWidth(1);t.bpPerPixel=(t.end-t.start)/i,this.referenceFrameList=[t],this.trackViews.forEach((({viewports:t})=>t.forEach((t=>t.setWidth(i))))),this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),await this.updateViews(!0)}async rescaleForMultiLocus(t){const e=this.calculateViewportWidth(this.referenceFrameList.length);for(let e of this.referenceFrameList)e.bpPerPixel*=t;for(let{viewports:t}of this.trackViews)for(let i of t)i.setWidth(e);this.centerLineList=this.createCenterLineList(this.columnContainer),this.updateUIWithReferenceFrameList(),await this.updateViews()}async goto(t,e,i){await this.search(t+":"+e+"-"+i)}async doSearch(t,e){const i=await this.search(t,e);return i||this.alert.present(new Error(`Unrecognized locus: ${t} `)),i}async search(t,e){const i=await async function(t,e){if(void 0===e||""===e.trim())return;(e&&"all"===e.trim().toLowerCase()||"*"===e)&&(e="all");const i=e.split(" ");let n=t.searchConfig||Mb,r=[];const s=async i=>{let r=function(t,e){const i=e.split("\t");if(i.length>=3)try{const e=t.genome.getChromosomeName(i[0]),n=parseInt(i[1].replace(/,/g,""),10)-1,r=parseInt(i[2].replace(/,/g,""),10);if(!isNaN(n)&&!isNaN(r))return{chr:e,start:n,end:r}}catch(t){}const n=e.split(":"),r=n[0];if("all"===r&&t.genome.getChromosome(r))return{chr:r,start:0,end:t.genome.getChromosome(r).bpLength};if(void 0!==t.genome.getChromosome(r)){const e={chr:t.genome.getChromosomeName(r),start:0,end:t.genome.getChromosome(r).bpLength};if(n.length>1){let i,r=n[1].split("-");if(r.length>2){if(!n[1].startsWith("-"))return;{const t=n[1].indexOf("-",1);t>0&&(r=[n[1].substring(0,t),n[1].substring(t+1)])}}if(i=r[0].replace(/,/g,""),isNaN(i))return;if(e.start=parseInt(i,10)-1,e.end=e.start+1,1===r.length&&(e.start-=20,e.end+=20),2===r.length){if(i=r[1].replace(/,/g,""),isNaN(i))return;if(e.end=parseInt(i,10),e.start<0&&!t.isSoftclipped()){const t=-e.start;e.start+=t,e.end+=t}}}return e}}(t,i);if(!r){const n=t.genome.featureDB.get(i.toUpperCase());n&&(r={chr:n.chr,start:n.start,end:n.end,gene:n.name,locusSearchString:e})}if(!r&&t.config&&!1!==t.config.search)try{r=await async function(t,e,i){let n=i.url.replace("$FEATURE$",e.toUpperCase());n.indexOf("$GENOME$")>-1&&(n=n.replace("$GENOME$",t.genome.id?t.genome.id:"hg19"));const r=i.timeout?{timeout:i.timeout}:void 0,s=function(t,e,i){let n;if(n="plain"===i.type?function(t,e){const i=[],n=[];return qi(e).forEach((function(t){""===t||i.push(t)})),i.forEach((function(e){var i,r,s,o,a=e.split("\t");a.length>=3&&(s=(r=a[1].split(":"))[1].split("-"),i=a[2].trim(),o={gene:a[0],chromosome:t.genome.getChromosomeName(r[0].trim()),start:parseInt(s[0].replace(/,/g,"")),end:parseInt(s[1].replace(/,/g,"")),type:"gtex"===i?"snp":"gene"},n.push(o))})),n}(t,e):JSON.parse(e),i.resultsField&&(n=n[i.resultsField]),n&&0!==n.length){const e=i.chromosomeField||"chromosome",r=i.startField||"start",s=i.endField||"end",o=i.coords||1;let a;a=Array.isArray(n)?n[0]:n,a.hasOwnProperty(e)&&a.hasOwnProperty(r)||console.error("Search service results must include chromosome and start fields: "+a);const l=a[e],h=t.genome.getChromosome(l);if(!h)return;const c=h.name;let u=a[r]-o,d=a[s];void 0===d&&(d=u+1);const f={chr:c,start:u,end:d},p=a.type?a.type:"gene";return i.geneField&&"gene"===p&&(f.gene=a[i.geneField]),i.snpField&&"snp"===p&&(f.snp=a[i.snpField]),f}}(t,await zo.loadString(n,r),i);return s&&(s.locusSearchString=e),s}(t,i,n)}catch(t){throw console.error(t),Error("Search service currently unavailable.")}return r};for(let t of i){const e=await s(t);e&&(e.locusSearchString=t,r.push(e))}if(0===r.length){const t=await s(e);t&&(t.locusSearchString=e,r.push(t))}return 0===r.length?void 0:r}(this,t);if(i&&i.length>0){this.referenceFrameList=function(t,e,i,n,r,s){return t.map((t=>{if(i&&t.gene&&(t.start=Math.max(0,t.start-i),t.end+=i),!s){const i=e.getChromosome(t.chr);ca(i.bpLength,t,n)}const o=new Eb(e,t.chr,t.start,t.end,(t.end-t.start)/r);return o.locusSearchString=t.locusSearchString,(t.gene||t.snp)&&(o.selection=new Tb(t.gene,t.snp)),o}))}(i,this.genome,this.flanking,this.minimumBases(),this.calculateViewportWidth(i.length),this.isSoftclipped());for(let t of this.trackViews)t.removeDOMFromColumnContainer();this.columnContainer.querySelectorAll(".igv-column-shim, .igv-column").forEach((t=>t.remove())),((t,e)=>{for(let i=0;i1&&i>0&&ga(_e.div({class:"igv-column-shim"}),n)}})(this.columnContainer.querySelector(".igv-sample-name-column"),this.referenceFrameList.length),this.centerLineList=this.createCenterLineList(this.columnContainer);for(let t of this.trackViews)t.addDOMToColumnContainer(this,this.columnContainer,this.referenceFrameList);return this.updateUIWithReferenceFrameList(),e||await this.updateViews(),!0}return!1}async loadSampleInformation(t){var e=t;Yi(t)&&(e=t.name),"fam"===e.substr(e.lastIndexOf(".")+1)&&(this.sampleInformation=await function(t,e){return(new Ab).loadPlinkFile(t,void 0)}(t))}on(t,e){this.eventHandlers[t]||(this.eventHandlers[t]=[]),this.eventHandlers[t].push(e)}un(t,e){this.off(t,e)}off(t,e){if(t)if(e){const i=this.eventHandlers[t];if(i&&0!==i.length){const n=i.indexOf(e);-1!==n&&this.eventHandlers[t].splice(n,1)}else console.warn("No handlers to remove for event: "+t)}else this.eventHandlers[t]=[];else this.eventHandlers={}}fireEvent(t,e,i){const n=this.eventHandlers[t];if(void 0===n||0===n.length)return;const r=i||window;return n.map((function(t){return t.apply(r,e)}))[0]}dispose(){this.removeMouseHandlers();for(let t of this.trackViews)t.dispose()}toJSON(){const t={version:"2.15.11"};if(void 0!==this.showSampleNames&&(t.showSampleNames=this.showSampleNames),200!==this.sampleNameViewportWidth&&(t.sampleNameViewportWidth=this.sampleNameViewportWidth),t.reference=this.genome.toJSON(),t.reference.fastaURL instanceof File)throw new Error(`Error. Sessions cannot include local file references ${t.reference.fastaURL.name}.`);if(t.reference.indexURL instanceof File)throw new Error(`Error. Sessions cannot include local file references ${t.reference.indexURL.name}.`);const e=[],i={};let n=!1,r=this.trackViews[0];for(let{referenceFrame:t}of r.viewports){const r=t.getLocusString();if(e.push(r),t.selection){const e={gene:t.selection.gene,snp:t.selection.snp};i[r]=e,n=!0}}t.locus=1===e.length?e[0]:e,n&&(t.gtexSelections=i),t.roi=this.roiManager.toJSON();const s=[],o=[];for(let{track:t}of this.trackViews)try{let e;e="function"==typeof t.getState?t.getState():t.config,e&&(e.browser&&delete e.browser,e.order=t.order,s.push(e))}catch(e){console.error(`Track: ${t.name}: ${e}`),o.push(`Track: ${t.name}: ${e}`)}if(o.length>0){let t=1,e="Errors encountered saving session:
";for(let i of o)e+=` (${t++}) ${i.toString()}
`;throw Error(e)}return t.tracks=s,t}compressedSession(){return function(t){const e=new Uint8Array(t.length);for(var i=0;i0?t.substring(0,e):t)+"?sessionURL=blob:"+this.compressedSession()}mouseDownOnViewport(t,e){var i;i=_e.pageCoordinates(t),this.vpMouseDown={viewport:e,lastMouseX:i.x,mouseDownX:i.x,lastMouseY:i.y,mouseDownY:i.y,referenceFrame:e.referenceFrame}}cancelTrackPan(){const t=this.dragObject;this.dragObject=void 0,this.isScrolling=!1,this.vpMouseDown=void 0,t&&t.viewport.referenceFrame.start!==t.start&&(this.updateViews(),this.fireEvent("trackdragend"))}isTrackPanning(){return this.dragObject}isSoftclipped(){return void 0!==this.trackViews.find((t=>!0===t.track.showSoftClips))}startTrackDrag(t){this.dragTrack=t}updateTrackDrag(t){if(t&&this.dragTrack){const e=this.dragTrack,i=this.trackViews.indexOf(t),n=this.trackViews.indexOf(e),r=this.trackViews;r[i]=e,r[n]=t;const s=this.trackViews[i].track.order;this.trackViews[n].track.order=s;const o=r.length;let a=s;if(i0;t--){const e=r[t].track;if(!(e.order>=a))break;e.order=Math.max(-Number.MAX_SAFE_INTEGER,a-1),a=e.order}this.reorderTracks()}}endTrackDrag(){this.dragTrack?(this.dragTrack=void 0,this.fireEvent("trackorderchanged",[this.getTrackOrder()])):this.dragTrack=void 0}addMouseHandlers(){this.addWindowResizeHandler(),this.addRootMouseUpHandler(),this.addRootMouseLeaveHandler(),this.addColumnContainerEventHandlers()}removeMouseHandlers(){this.removeWindowResizeHandler(),this.removeRootMouseUpHandler(),this.removeRootMouseLeaveHandler(),this.removeColumnContainerEventHandlers()}addWindowResizeHandler(){this.boundWindowResizeHandler=oy.bind(this),window.addEventListener("resize",this.boundWindowResizeHandler)}removeWindowResizeHandler(){window.removeEventListener("resize",this.boundWindowResizeHandler)}addRootMouseUpHandler(){this.boundRootMouseUpHandler=ly.bind(this),this.root.addEventListener("mouseup",this.boundRootMouseUpHandler)}removeRootMouseUpHandler(){this.root.removeEventListener("mouseup",this.boundRootMouseUpHandler)}addRootMouseLeaveHandler(){this.boundRootMouseLeaveHandler=ly.bind(this),this.root.addEventListener("mouseleave",this.boundRootMouseLeaveHandler)}removeRootMouseLeaveHandler(){this.root.removeEventListener("mouseleave",this.boundRootMouseLeaveHandler)}addColumnContainerEventHandlers(){this.boundColumnContainerMouseMoveHandler=ay.bind(this),this.boundColumnContainerTouchMoveHandler=ay.bind(this),this.boundColumnContainerMouseLeaveHandler=ly.bind(this),this.boundColumnContainerMouseUpHandler=ly.bind(this),this.boundColumnContainerTouchEndHandler=ly.bind(this),this.columnContainer.addEventListener("mousemove",this.boundColumnContainerMouseMoveHandler),this.columnContainer.addEventListener("touchmove",this.boundColumnContainerTouchMoveHandler),this.columnContainer.addEventListener("mouseleave",this.boundColumnContainerMouseLeaveHandler),this.columnContainer.addEventListener("mouseup",this.boundColumnContainerMouseUpHandler),this.columnContainer.addEventListener("touchend",this.boundColumnContainerTouchEndHandler)}removeColumnContainerEventHandlers(){this.columnContainer.removeEventListener("mousemove",this.boundColumnContainerMouseMoveHandler),this.columnContainer.removeEventListener("touchmove",this.boundColumnContainerTouchMoveHandler),this.columnContainer.removeEventListener("mouseleave",this.boundColumnContainerMouseLeaveHandler),this.columnContainer.removeEventListener("mouseup",this.boundColumnContainerMouseUpHandler),this.columnContainer.removeEventListener("touchend",this.boundColumnContainerTouchEndHandler)}static uncompressSession(t){let e;if(t.indexOf("/gzip;base64")>0){e=bo(t);let i="";for(let t of e)i+=String.fromCharCode(t);return i}return function(t){t=t.replace(/\./g,"+").replace(/_/g,"/").replace(/-/g,"=");const e=atob(t),i=[];for(let t=0;t{const r=t.data,s=r.mate;function o(t){t.chr=i.genome.getChromosomeName(t.refName);let e=!1;for(let n of i.referenceFrameList){const i=qu.fromLocusString(n.getLocusString());if(i.contains(t)){e=!0;break}if(i.overlaps(t)){n.extend(t),e=!0;break}}if(!e){const e=2e3,n=(t.start+t.end)/2;i.addMultiLocusPanel(t.chr,n-e,n+e)}}o(r),o(s)}})),this.circularViewControl=new Gb(this.$toggle_button_container.get(0),this),this.circularView.setAssembly({name:this.genome.id,id:this.genome.id,chromosomes:wd(this.genome)}),this.circularViewVisible=e,this.circularView}get circularViewVisible(){return void 0!==this.circularView&&this.circularView.visible}set circularViewVisible(t){this.circularView&&(this.circularView.visible=t,this.circularViewControl.setState(t))}}async function oy(){if(!this.referenceFrameList)return;const t=this.calculateViewportWidth(this.referenceFrameList.length);for(let e of this.referenceFrameList){const i=this.referenceFrameList.indexOf(e),{chr:n,genome:r}=e,{bpLength:s}=r.getChromosome(e.chr),o=e.toBP(t);ul.isWholeGenomeView(n)||o>s?e.bpPerPixel=s/t:e.end=e.start+e.toBP(t);for(let{viewports:e}of this.trackViews)e[i].setWidth(t)}this.updateUIWithReferenceFrameList(),await this.updateViews(!0)}function ay(t){t.preventDefault();const{x:e,y:i}=_e.pageCoordinates(t);if(this.vpMouseDown){const{viewport:t,referenceFrame:n}=this.vpMouseDown,r=Math.abs(e-this.vpMouseDown.mouseDownX)>Math.abs(i-this.vpMouseDown.mouseDownY);if(!this.dragObject&&!this.isScrolling)if(r)this.vpMouseDown.mouseDownX&&Math.abs(e-this.vpMouseDown.mouseDownX)>this.constants.dragThreshold&&(this.dragObject={viewport:t,start:n.start});else if(this.vpMouseDown.mouseDownY&&Math.abs(i-this.vpMouseDown.mouseDownY)>this.constants.scrollThreshold){this.isScrolling=!0;const e=t.$viewport.height(),i=t.trackView.maxViewportContentHeight();this.vpMouseDown.r=e/i}if(this.dragObject){const i=!this.isSoftclipped();let r=this.vpMouseDown.lastMouseX-e;n.shiftPixels(r,t.$viewport.width(),i)&&this.updateViews(),this.fireEvent("trackdrag")}if(this.isScrolling){const e=this.vpMouseDown.r*(this.vpMouseDown.lastMouseY-i);t.trackView.moveScroller(e)}this.vpMouseDown.lastMouseX=e,this.vpMouseDown.lastMouseY=i}}function ly(t){this.cancelTrackPan(),this.endTrackDrag()}function hy(t,e){for(let{viewports:i}of t)for(let t of i)t.$trackLabel&&(0===i.indexOf(t)&&!0===e?t.$trackLabel.show():t.$trackLabel.hide())}let cy=[];const uy=zo.setApiKey;!function(){var t=document.createElement("style");t.setAttribute("type","text/css"),t.innerHTML='.igv-navbar {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n box-sizing: border-box;\n width: 100%;\n color: #444;\n font-size: 12px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n line-height: 32px;\n padding-left: 8px;\n padding-right: 8px;\n margin-top: 2px;\n margin-bottom: 6px;\n height: 32px;\n border-style: solid;\n border-radius: 3px;\n border-width: thin;\n border-color: #bfbfbf;\n background-color: #f3f3f3;\n}\n.igv-navbar .igv-navbar-left-container {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n height: 32px;\n line-height: 32px;\n}\n.igv-navbar .igv-navbar-left-container .igv-logo {\n width: 34px;\n height: 32px;\n margin-right: 8px;\n}\n.igv-navbar .igv-navbar-left-container .igv-current-genome {\n height: 32px;\n margin-left: 4px;\n margin-right: 4px;\n user-select: none;\n line-height: 32px;\n vertical-align: middle;\n text-align: center;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n height: 100%;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-chromosome-select-widget-container {\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n height: 100%;\n width: 125px;\n margin-right: 4px;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-chromosome-select-widget-container select {\n display: block;\n cursor: pointer;\n width: 100px;\n height: 75%;\n outline: none;\n font-size: 12px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n margin-left: 8px;\n height: 22px;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n width: 210px;\n height: 22px;\n line-height: 22px;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container input.igv-search-input {\n cursor: text;\n width: 85%;\n height: 22px;\n line-height: 22px;\n font-size: 12px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n text-align: left;\n padding-left: 8px;\n margin-right: 8px;\n outline: none;\n border-style: solid;\n border-radius: 3px;\n border-width: thin;\n border-color: #bfbfbf;\n background-color: white;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-search-container .igv-search-icon-container {\n cursor: pointer;\n height: 16px;\n width: 16px;\n}\n.igv-navbar .igv-navbar-left-container .igv-navbar-genomic-location .igv-locus-size-group .igv-windowsize-panel-container {\n margin-left: 4px;\n user-select: none;\n}\n.igv-navbar .igv-navbar-right-container {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n height: 32px;\n line-height: 32px;\n}\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n height: 100%;\n}\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container div {\n margin-left: 0;\n margin-right: 4px;\n}\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container div:last-child {\n margin-left: 0;\n margin-right: 0;\n}\n.igv-navbar .igv-navbar-right-container .igv-navbar-toggle-button-container-750 {\n display: none;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget {\n color: #737373;\n font-size: 18px;\n height: 32px;\n line-height: 32px;\n margin-left: 8px;\n user-select: none;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div {\n cursor: pointer;\n margin-left: unset;\n margin-right: unset;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:first-child {\n height: 24px;\n width: 24px;\n margin-left: unset;\n margin-right: 8px;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:last-child {\n height: 24px;\n width: 24px;\n margin-left: 8px;\n margin-right: unset;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget div:nth-child(even) {\n display: block;\n height: fit-content;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget input {\n display: block;\n width: 125px;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget svg {\n display: block;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 {\n color: #737373;\n font-size: 18px;\n height: 32px;\n line-height: 32px;\n margin-left: 8px;\n user-select: none;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div {\n cursor: pointer;\n margin-left: unset;\n margin-right: unset;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:first-child {\n height: 24px;\n width: 24px;\n margin-left: unset;\n margin-right: 8px;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:last-child {\n height: 24px;\n width: 24px;\n margin-left: 8px;\n margin-right: unset;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 div:nth-child(even) {\n width: 0;\n height: 0;\n display: none;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 input {\n width: 0;\n height: 0;\n display: none;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-900 svg {\n display: block;\n}\n.igv-navbar .igv-navbar-right-container .igv-zoom-widget-hidden {\n display: none;\n}\n\n.igv-navbar-button {\n display: block;\n box-sizing: unset;\n padding-left: 6px;\n padding-right: 6px;\n height: 18px;\n text-transform: capitalize;\n user-select: none;\n line-height: 18px;\n text-align: center;\n vertical-align: middle;\n font-family: "Open Sans", sans-serif;\n font-size: 11px;\n font-weight: 200;\n color: #737373;\n background-color: #f3f3f3;\n border-color: #737373;\n border-style: solid;\n border-width: thin;\n border-radius: 6px;\n}\n\n.igv-navbar-button-clicked {\n color: white;\n background-color: #737373;\n}\n\n.igv-navbar-button:hover {\n cursor: pointer;\n}\n\n.igv-zoom-in-notice-container {\n z-index: 1024;\n position: absolute;\n top: 8px;\n left: 50%;\n transform: translate(-50%, 0%);\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n justify-content: center;\n align-items: center;\n background-color: white;\n}\n.igv-zoom-in-notice-container > div {\n padding-left: 4px;\n padding-right: 4px;\n padding-top: 2px;\n padding-bottom: 2px;\n width: 100%;\n height: 100%;\n font-family: "Open Sans", sans-serif;\n font-size: 14px;\n font-weight: 400;\n color: #3f3f3f;\n}\n\n.igv-zoom-in-notice {\n position: absolute;\n top: 10px;\n left: 50%;\n}\n.igv-zoom-in-notice div {\n position: relative;\n left: -50%;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n color: #3f3f3f;\n background-color: rgba(255, 255, 255, 0.51);\n z-index: 64;\n}\n\n.igv-container-spinner {\n position: absolute;\n top: 90%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 1024;\n width: 24px;\n height: 24px;\n pointer-events: none;\n color: #737373;\n}\n\n.igv-multi-locus-close-button {\n position: absolute;\n top: 2px;\n right: 0;\n padding-left: 2px;\n padding-right: 2px;\n width: 12px;\n height: 12px;\n color: #666666;\n background-color: white;\n z-index: 1000;\n}\n.igv-multi-locus-close-button > svg {\n vertical-align: top;\n}\n\n.igv-multi-locus-close-button:hover {\n cursor: pointer;\n color: #434343;\n}\n\n.igv-multi-locus-ruler-label {\n z-index: 64;\n position: absolute;\n top: 2px;\n left: 0;\n width: 100%;\n height: 12px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: center;\n align-items: center;\n}\n.igv-multi-locus-ruler-label > div {\n font-family: "Open Sans", sans-serif;\n font-size: 12px;\n color: rgb(16, 16, 16);\n background-color: white;\n}\n.igv-multi-locus-ruler-label > div {\n cursor: pointer;\n}\n\n.igv-multi-locus-ruler-label-square-dot {\n z-index: 64;\n position: absolute;\n left: 50%;\n top: 5%;\n transform: translate(-50%, 0%);\n background-color: white;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-multi-locus-ruler-label-square-dot > div:first-child {\n width: 14px;\n height: 14px;\n}\n.igv-multi-locus-ruler-label-square-dot > div:last-child {\n margin-left: 16px;\n font-family: "Open Sans", sans-serif;\n font-size: 14px;\n font-weight: 400;\n color: rgb(16, 16, 16);\n}\n\n.igv-ruler-sweeper {\n display: none;\n pointer-events: none;\n position: absolute;\n top: 26px;\n bottom: 0;\n left: 0;\n width: 0;\n z-index: 99999;\n background-color: rgba(68, 134, 247, 0.25);\n}\n\n.igv-ruler-tooltip {\n pointer-events: none;\n z-index: 128;\n position: absolute;\n top: 0;\n left: 0;\n width: 1px;\n height: 32px;\n background-color: transparent;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-ruler-tooltip > div {\n pointer-events: none;\n width: 128px;\n height: auto;\n padding: 1px;\n color: #373737;\n font-size: 10px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n background-color: white;\n border-style: solid;\n border-width: thin;\n border-color: #373737;\n}\n\n.igv-track-label {\n position: absolute;\n left: 8px;\n top: 8px;\n width: auto;\n height: auto;\n max-width: 50%;\n padding-left: 4px;\n padding-right: 4px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n font-family: "Open Sans", sans-serif;\n font-size: small;\n font-weight: 400;\n text-align: center;\n user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n border-color: #444;\n border-radius: 2px;\n border-style: solid;\n border-width: thin;\n background-color: white;\n z-index: 128;\n cursor: pointer;\n}\n\n.igv-track-label:hover,\n.igv-track-label:focus,\n.igv-track-label:active {\n background-color: #e8e8e8;\n}\n\n.igv-track-label-popup-shim {\n padding-left: 8px;\n padding-right: 8px;\n padding-top: 4px;\n}\n\n.igv-center-line {\n display: none;\n pointer-events: none;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 50%;\n transform: translateX(-50%);\n z-index: 8;\n user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n border-left-style: dashed;\n border-left-width: thin;\n border-right-style: dashed;\n border-right-width: thin;\n}\n\n.igv-center-line-wide {\n background-color: rgba(0, 0, 0, 0);\n border-left-color: rgba(127, 127, 127, 0.51);\n border-right-color: rgba(127, 127, 127, 0.51);\n}\n\n.igv-center-line-thin {\n background-color: rgba(0, 0, 0, 0);\n border-left-color: rgba(127, 127, 127, 0.51);\n border-right-color: rgba(0, 0, 0, 0);\n}\n\n.igv-cursor-guide-horizontal {\n display: none;\n pointer-events: none;\n user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n position: absolute;\n left: 0;\n right: 0;\n top: 50%;\n height: 1px;\n z-index: 1;\n margin-left: 50px;\n margin-right: 54px;\n border-top-style: dotted;\n border-top-width: thin;\n border-top-color: rgba(127, 127, 127, 0.76);\n}\n\n.igv-cursor-guide-vertical {\n pointer-events: none;\n user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 50%;\n width: 1px;\n z-index: 1;\n border-left-style: dotted;\n border-left-width: thin;\n border-left-color: rgba(127, 127, 127, 0.76);\n display: none;\n}\n\n.igv-user-feedback {\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 512px;\n height: 360px;\n z-index: 2048;\n background-color: white;\n border-color: #a2a2a2;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n color: #444;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-user-feedback div:first-child {\n position: relative;\n height: 24px;\n width: 100%;\n background-color: white;\n border-bottom-color: #a2a2a2;\n border-bottom-style: solid;\n border-bottom-width: thin;\n}\n.igv-user-feedback div:first-child div {\n position: absolute;\n top: 2px;\n width: 16px;\n height: 16px;\n background-color: transparent;\n}\n.igv-user-feedback div:first-child div:first-child {\n left: 8px;\n}\n.igv-user-feedback div:first-child div:last-child {\n cursor: pointer;\n right: 8px;\n}\n.igv-user-feedback div:last-child {\n width: 100%;\n height: calc(100% - 24px);\n border-width: 0;\n}\n.igv-user-feedback div:last-child div {\n width: auto;\n height: auto;\n margin: 8px;\n}\n\n.igv-generic-dialog-container {\n position: absolute;\n top: 0;\n left: 0;\n width: 300px;\n height: 200px;\n border-color: #7F7F7F;\n border-radius: 4px;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n z-index: 2048;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-generic-dialog-container .igv-generic-dialog-header {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n width: 100%;\n height: 24px;\n cursor: move;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-color: #7F7F7F;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n}\n.igv-generic-dialog-container .igv-generic-dialog-header div {\n margin-right: 4px;\n margin-bottom: 2px;\n height: 12px;\n width: 12px;\n color: #7F7F7F;\n}\n.igv-generic-dialog-container .igv-generic-dialog-header div:hover {\n cursor: pointer;\n color: #444;\n}\n.igv-generic-dialog-container .igv-generic-dialog-one-liner {\n color: #373737;\n width: 95%;\n height: 24px;\n line-height: 24px;\n text-align: left;\n margin-top: 8px;\n padding-left: 8px;\n overflow-wrap: break-word;\n background-color: white;\n}\n.igv-generic-dialog-container .igv-generic-dialog-label-input {\n margin-top: 8px;\n width: 95%;\n height: 24px;\n color: #373737;\n line-height: 24px;\n padding-left: 8px;\n background-color: white;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-generic-dialog-container .igv-generic-dialog-label-input div {\n width: 30%;\n height: 100%;\n font-size: 16px;\n text-align: right;\n padding-right: 8px;\n background-color: white;\n}\n.igv-generic-dialog-container .igv-generic-dialog-label-input input {\n display: block;\n height: 100%;\n width: 100%;\n padding-left: 4px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n color: #373737;\n text-align: left;\n outline: none;\n border-style: solid;\n border-width: thin;\n border-color: #7F7F7F;\n background-color: white;\n}\n.igv-generic-dialog-container .igv-generic-dialog-label-input input {\n width: 50%;\n font-size: 16px;\n}\n.igv-generic-dialog-container .igv-generic-dialog-input {\n margin-top: 8px;\n width: calc(100% - 16px);\n height: 24px;\n color: #373737;\n line-height: 24px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n.igv-generic-dialog-container .igv-generic-dialog-input input {\n display: block;\n height: 100%;\n width: 100%;\n padding-left: 4px;\n font-family: "Open Sans", sans-serif;\n font-weight: 400;\n color: #373737;\n text-align: left;\n outline: none;\n border-style: solid;\n border-width: thin;\n border-color: #7F7F7F;\n background-color: white;\n}\n.igv-generic-dialog-container .igv-generic-dialog-input input {\n font-size: 16px;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel {\n width: 100%;\n height: 28px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div {\n margin-top: 32px;\n color: white;\n font-family: "Open Sans", sans-serif;\n font-size: 14px;\n font-weight: 400;\n width: 75px;\n height: 28px;\n line-height: 28px;\n text-align: center;\n border-color: transparent;\n border-style: solid;\n border-width: thin;\n border-radius: 2px;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:first-child {\n margin-left: 32px;\n margin-right: 0;\n background-color: #5ea4e0;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:last-child {\n margin-left: 0;\n margin-right: 32px;\n background-color: #c4c4c4;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:first-child:hover {\n cursor: pointer;\n background-color: #3b5c7f;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok-cancel div:last-child:hover {\n cursor: pointer;\n background-color: #7f7f7f;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok {\n width: 100%;\n height: 36px;\n margin-top: 32px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok div {\n width: 98px;\n height: 36px;\n line-height: 36px;\n text-align: center;\n color: white;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n border-color: white;\n border-style: solid;\n border-width: thin;\n border-radius: 4px;\n background-color: #2B81AF;\n}\n.igv-generic-dialog-container .igv-generic-dialog-ok div:hover {\n cursor: pointer;\n background-color: #25597f;\n}\n\n.igv-generic-container {\n position: absolute;\n top: 0;\n left: 0;\n z-index: 2048;\n background-color: white;\n cursor: pointer;\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-generic-container div:first-child {\n cursor: move;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n height: 24px;\n width: 100%;\n background-color: #dddddd;\n}\n.igv-generic-container div:first-child i {\n display: block;\n color: #5f5f5f;\n cursor: pointer;\n width: 14px;\n height: 14px;\n margin-right: 8px;\n margin-bottom: 4px;\n}\n\n.igv-menu-popup {\n position: absolute;\n top: 0;\n left: 0;\n width: max-content;\n z-index: 4096;\n cursor: pointer;\n font-family: "Open Sans", sans-serif;\n font-size: small;\n font-weight: 400;\n color: #4b4b4b;\n background: white;\n border-radius: 4px;\n border-color: #7F7F7F;\n border-style: solid;\n border-width: thin;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-end;\n text-align: left;\n}\n.igv-menu-popup > div:not(:first-child) {\n width: 100%;\n}\n.igv-menu-popup > div:not(:first-child) > div {\n background: white;\n}\n.igv-menu-popup > div:not(:first-child) > div.context-menu {\n padding-left: 4px;\n padding-right: 4px;\n}\n.igv-menu-popup > div:not(:first-child) > div:last-child {\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n border-bottom-color: transparent;\n border-bottom-style: solid;\n border-bottom-width: thin;\n}\n.igv-menu-popup > div:not(:first-child) > div:hover {\n background: #efefef;\n}\n\n.igv-menu-popup-shim {\n padding-left: 8px;\n padding-right: 8px;\n padding-bottom: 1px;\n padding-top: 1px;\n}\n\n.igv-menu-popup-header {\n position: relative;\n width: 100%;\n height: 24px;\n cursor: move;\n border-top-color: transparent;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-color: #7F7F7F;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n}\n.igv-menu-popup-header div {\n margin-right: 4px;\n height: 12px;\n width: 12px;\n color: #7F7F7F;\n}\n.igv-menu-popup-header div:hover {\n cursor: pointer;\n color: #444;\n}\n\n.igv-menu-popup-check-container {\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n width: 100%;\n height: 20px;\n margin-right: 4px;\n background-color: transparent;\n}\n.igv-menu-popup-check-container div {\n padding-top: 2px;\n padding-left: 8px;\n}\n.igv-menu-popup-check-container div:first-child {\n position: relative;\n width: 12px;\n height: 12px;\n}\n.igv-menu-popup-check-container div:first-child svg {\n position: absolute;\n width: 12px;\n height: 12px;\n}\n\n.igv-user-feedback {\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 512px;\n height: 360px;\n z-index: 2048;\n background-color: white;\n border-color: #a2a2a2;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n font-size: medium;\n font-weight: 400;\n color: #444;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n}\n.igv-user-feedback div:first-child {\n position: relative;\n height: 24px;\n width: 100%;\n background-color: white;\n border-bottom-color: #a2a2a2;\n border-bottom-style: solid;\n border-bottom-width: thin;\n}\n.igv-user-feedback div:first-child div {\n position: absolute;\n top: 2px;\n width: 16px;\n height: 16px;\n background-color: transparent;\n}\n.igv-user-feedback div:first-child div:first-child {\n left: 8px;\n}\n.igv-user-feedback div:first-child div:last-child {\n cursor: pointer;\n right: 8px;\n}\n.igv-user-feedback div:last-child {\n width: 100%;\n height: calc(100% - 24px);\n border-width: 0;\n}\n.igv-user-feedback div:last-child div {\n width: auto;\n height: auto;\n margin: 8px;\n}\n\n.igv-loading-spinner-container {\n z-index: 1024;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 32px;\n height: 32px;\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n justify-content: center;\n align-items: center;\n}\n.igv-loading-spinner-container > div {\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n border-radius: 50%;\n border: 4px solid rgba(128, 128, 128, 0.5);\n border-top-color: rgb(255, 255, 255);\n animation: spin 1s ease-in-out infinite;\n -webkit-animation: spin 1s ease-in-out infinite;\n}\n\n@keyframes spin {\n to {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n@-webkit-keyframes spin {\n to {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n.igv-roi-menu-next-gen {\n position: absolute;\n z-index: 512;\n font-family: "Open Sans", sans-serif;\n font-size: small;\n font-weight: 400;\n color: #4b4b4b;\n background-color: white;\n width: 192px;\n border-radius: 4px;\n border-color: #7F7F7F;\n border-style: solid;\n border-width: thin;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n}\n.igv-roi-menu-next-gen > div:first-child {\n height: 24px;\n border-top-color: transparent;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-color: #7F7F7F;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: flex-end;\n align-items: center;\n}\n.igv-roi-menu-next-gen > div:first-child > div {\n margin-right: 4px;\n height: 12px;\n width: 12px;\n color: #7F7F7F;\n}\n.igv-roi-menu-next-gen > div:first-child > div:hover {\n cursor: pointer;\n color: #444;\n}\n.igv-roi-menu-next-gen > div:last-child {\n background-color: white;\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n border-bottom-color: transparent;\n border-bottom-style: solid;\n border-bottom-width: 0;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n text-align: start;\n vertical-align: middle;\n}\n.igv-roi-menu-next-gen > div:last-child > div {\n height: 24px;\n padding-left: 4px;\n border-bottom-style: solid;\n border-bottom-width: thin;\n border-bottom-color: #7f7f7f;\n}\n.igv-roi-menu-next-gen > div:last-child > div:not(:first-child):hover {\n background-color: rgba(127, 127, 127, 0.1);\n}\n.igv-roi-menu-next-gen > div:last-child div:first-child {\n font-style: italic;\n text-align: center;\n padding-right: 4px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.igv-roi-menu-next-gen > div:last-child > div:last-child {\n border-bottom-width: 0;\n border-bottom-color: transparent;\n}\n\n.igv-roi-placeholder {\n font-style: normal;\n color: rgba(75, 75, 75, 0.6);\n}\n\n.igv-roi-table {\n position: absolute;\n z-index: 1024;\n width: min-content;\n max-width: 1600px;\n border-color: #7f7f7f;\n border-radius: 4px;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n font-size: 12px;\n font-weight: 400;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n cursor: default;\n}\n.igv-roi-table > div {\n height: 24px;\n font-size: 14px;\n text-align: start;\n vertical-align: middle;\n line-height: 24px;\n}\n.igv-roi-table > div:first-child {\n border-color: transparent;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-top-width: 0;\n border-bottom-color: #7f7f7f;\n border-bottom-style: solid;\n border-bottom-width: thin;\n background-color: #eee;\n cursor: move;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-between;\n align-items: center;\n}\n.igv-roi-table > div:first-child > div:first-child {\n text-align: center;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n margin-left: 4px;\n margin-right: 4px;\n width: calc(100% - 4px - 12px);\n}\n.igv-roi-table > div:first-child > div:last-child {\n margin-right: 4px;\n margin-bottom: 2px;\n height: 12px;\n width: 12px;\n color: #7f7f7f;\n}\n.igv-roi-table > div:first-child > div:last-child > svg {\n display: block;\n}\n.igv-roi-table > div:first-child > div:last-child:hover {\n cursor: pointer;\n color: #444;\n}\n.igv-roi-table > .igv-roi-table-description {\n padding: 4px;\n margin-left: 4px;\n word-break: break-all;\n overflow-y: auto;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n background-color: transparent;\n}\n.igv-roi-table > .igv-roi-table-goto-explainer {\n margin-top: 5px;\n margin-left: 4px;\n color: #7F7F7F;\n font-style: italic;\n height: 24px;\n border-top: solid lightgray;\n background-color: transparent;\n}\n.igv-roi-table > .igv-roi-table-column-titles {\n height: 24px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: stretch;\n align-items: stretch;\n padding-right: 16px;\n background-color: white;\n border-top-color: #7f7f7f;\n border-top-style: solid;\n border-top-width: thin;\n border-bottom-color: #7f7f7f;\n border-bottom-style: solid;\n border-bottom-width: thin;\n}\n.igv-roi-table > .igv-roi-table-column-titles > div {\n font-size: 14px;\n vertical-align: middle;\n line-height: 24px;\n text-align: left;\n margin-left: 4px;\n height: 24px;\n overflow: hidden;\n text-overflow: ellipsis;\n border-right-color: #7f7f7f;\n border-right-style: solid;\n border-right-width: thin;\n}\n.igv-roi-table > .igv-roi-table-column-titles > div:last-child {\n border-right: unset;\n}\n.igv-roi-table > .igv-roi-table-row-container {\n overflow: auto;\n resize: both;\n max-width: 1600px;\n height: 360px;\n background-color: transparent;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row {\n height: 24px;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: stretch;\n align-items: stretch;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div {\n font-size: 14px;\n vertical-align: middle;\n line-height: 24px;\n text-align: left;\n margin-left: 4px;\n height: 24px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n border-right-color: transparent;\n border-right-style: solid;\n border-right-width: thin;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row > div:last-child {\n border-right: unset;\n}\n.igv-roi-table > .igv-roi-table-row-container > .igv-roi-table-row-hover {\n background-color: rgba(0, 0, 0, 0.04);\n}\n.igv-roi-table > div:last-child {\n height: 32px;\n line-height: 32px;\n border-top-color: #7f7f7f;\n border-top-style: solid;\n border-top-width: thin;\n border-bottom-color: transparent;\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n border-bottom-width: 0;\n background-color: #eee;\n display: flex;\n flex-flow: row;\n flex-wrap: nowrap;\n justify-content: space-around;\n align-items: center;\n}\n\n.igv-roi-table-row-selected {\n background-color: rgba(0, 0, 0, 0.125);\n}\n\n.igv-roi-table-button {\n cursor: pointer;\n height: 20px;\n user-select: none;\n line-height: 20px;\n text-align: center;\n vertical-align: middle;\n font-family: "Open Sans", sans-serif;\n font-size: 13px;\n font-weight: 400;\n color: black;\n padding-left: 6px;\n padding-right: 6px;\n background-color: rgb(239, 239, 239);\n border-color: black;\n border-style: solid;\n border-width: thin;\n border-radius: 3px;\n}\n\n.igv-roi-table-button:hover {\n font-weight: 400;\n background-color: rgba(0, 0, 0, 0.13);\n}\n\n.igv-roi-region {\n z-index: 64;\n position: absolute;\n top: 0;\n bottom: 0;\n pointer-events: none;\n overflow: visible;\n margin-top: 44px;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n}\n.igv-roi-region > div {\n position: relative;\n width: 100%;\n height: 8px;\n pointer-events: auto;\n}\n\n.igv-roi-menu {\n position: absolute;\n z-index: 1024;\n width: 144px;\n border-color: #7f7f7f;\n border-radius: 4px;\n border-style: solid;\n border-width: thin;\n font-family: "Open Sans", sans-serif;\n background-color: white;\n display: flex;\n flex-flow: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n}\n.igv-roi-menu > div:not(:last-child) {\n border-bottom-color: rgba(128, 128, 128, 0.5);\n border-bottom-style: solid;\n border-bottom-width: thin;\n}\n.igv-roi-menu > div:first-child {\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-top-color: transparent;\n border-top-style: solid;\n border-top-width: 0;\n}\n.igv-roi-menu > div:last-child {\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n border-bottom-color: transparent;\n border-bottom-style: solid;\n border-bottom-width: 0;\n}\n\n.igv-roi-menu-row {\n height: 24px;\n padding-left: 8px;\n font-size: small;\n text-align: start;\n vertical-align: middle;\n line-height: 24px;\n background-color: white;\n}\n\n.igv-roi-menu-row-edit-description {\n width: -webkit-fill-available;\n font-size: small;\n text-align: start;\n vertical-align: middle;\n background-color: white;\n padding-left: 4px;\n padding-right: 4px;\n padding-bottom: 4px;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: stretch;\n align-items: stretch;\n}\n.igv-roi-menu-row-edit-description > label {\n margin-left: 2px;\n margin-bottom: 0;\n display: block;\n width: -webkit-fill-available;\n}\n.igv-roi-menu-row-edit-description > input {\n display: block;\n margin-left: 2px;\n margin-right: 2px;\n margin-bottom: 1px;\n width: -webkit-fill-available;\n}\n\n.igv-container {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n padding-top: 4px;\n user-select: none;\n -webkit-user-select: none;\n -ms-user-select: none;\n}\n\n.igv-viewport {\n position: relative;\n margin-top: 5px;\n line-height: 1;\n overflow-x: hidden;\n overflow-y: hidden;\n}\n\n.igv-viewport-content {\n position: relative;\n width: 100%;\n}\n.igv-viewport-content > canvas {\n position: relative;\n display: block;\n}\n\n.igv-column-container {\n position: relative;\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: stretch;\n width: 100%;\n}\n\n.igv-column-shim {\n width: 1px;\n margin-left: 2px;\n margin-right: 2px;\n background-color: #545453;\n}\n\n.igv-column {\n position: relative;\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n}\n\n.igv-axis-column {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n width: 50px;\n}\n.igv-axis-column > div {\n margin-top: 5px;\n width: 100%;\n}\n\n.igv-sample-name-column {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n}\n\n.igv-scrollbar-column {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n width: 14px;\n}\n.igv-scrollbar-column > div {\n position: relative;\n margin-top: 5px;\n width: 14px;\n}\n.igv-scrollbar-column > div > div {\n cursor: pointer;\n position: absolute;\n top: 0;\n left: 2px;\n width: 8px;\n border-width: 1px;\n border-style: solid;\n border-color: #c4c4c4;\n border-top-left-radius: 4px;\n border-top-right-radius: 4px;\n border-bottom-left-radius: 4px;\n border-bottom-right-radius: 4px;\n}\n.igv-scrollbar-column > div > div:hover {\n background-color: #c4c4c4;\n}\n\n.igv-track-drag-column {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n width: 12px;\n background-color: white;\n}\n.igv-track-drag-column > .igv-track-drag-handle {\n z-index: 512;\n position: relative;\n cursor: pointer;\n margin-top: 5px;\n width: 100%;\n border-style: solid;\n border-width: 0;\n border-top-right-radius: 6px;\n border-bottom-right-radius: 6px;\n background-color: #c4c4c4;\n}\n.igv-track-drag-column .igv-track-drag-handle-hover {\n background-color: #787878;\n}\n.igv-track-drag-column > .igv-track-drag-shim {\n position: relative;\n margin-top: 5px;\n width: 100%;\n border-style: solid;\n border-width: 0;\n}\n\n.igv-gear-menu-column {\n position: relative;\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: flex-start;\n box-sizing: border-box;\n height: 100%;\n width: 28px;\n}\n.igv-gear-menu-column > div {\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n justify-content: flex-start;\n align-items: center;\n margin-top: 5px;\n width: 100%;\n background: white;\n}\n.igv-gear-menu-column > div > div {\n position: relative;\n margin-top: 4px;\n width: 16px;\n height: 16px;\n color: #7F7F7F;\n}\n.igv-gear-menu-column > div > div:hover {\n cursor: pointer;\n color: #444;\n}\n\n/*# sourceMappingURL=dom.css.map */\n',document.head.append(t)}();const dy=zo.oauth;var fy={TrackUtils:Ia,IGVGraphics:na,MenuUtils:Ui,DataRangeDialog:Hi,createTrack:async function(t,e){return await sy.prototype.createTrack.call(e,t)},createBrowser:async function(t,e){void 0===e&&(e={}),ul.KNOWN_GENOMES||await ul.initializeGenomes(e),function(t){void 0===t.minimumBases&&(t.minimumBases=40),void 0===t.showIdeogram&&(t.showIdeogram=!0),void 0===t.showCircularView&&(t.showCircularView=!1),void 0===t.showCircularViewButton&&(t.showCircularViewButton=!1),void 0===t.showTrackLabelButton&&(t.showTrackLabelButton=!0),void 0===t.showTrackLabels&&(t.showTrackLabels=!0),void 0===t.showROITableButton&&(t.showROITableButton=!1),void 0===t.showROITable&&(t.showROITable=!1),void 0===t.showCursorTrackingGuideButton&&(t.showCursorTrackingGuideButton=!0),void 0===t.showCursorGuide&&(t.showCursorGuide=t.showCursorTrackingGuide||!1),void 0===t.showCenterGuideButton&&(t.showCenterGuideButton=!0),void 0===t.showCenterGuide&&(t.showCenterGuide=!1),void 0===t.showSampleNames&&(t.showSampleNames=!1),void 0===t.showSVGButton&&(t.showSVGButton=!0),void 0===t.showControls&&(t.showControls=!0),void 0===t.showNavigation&&(t.showNavigation=!0),void 0===t.showRuler&&(t.showRuler=!0),void 0===t.flanking&&(t.flanking=1e3),void 0===t.pairsSupported&&(t.pairsSupported=!0),t.tracks||(t.tracks=[])}(e),e.queryParametersSupported&&function(t){var e,i,n,r,s,o,a,l;let h,c,u;if({},e=(o=window.location.href).indexOf("?"),i=o.lastIndexOf("#"),e>=0)for(i<0&&(i=o.length),n=e+1;ne&&(i.indexURL=c[e]),u&&u.length>e&&(i.name=u[e]),t.tracks.push(i)}}}(e),e.apiKey&&zo.setApiKey(e.apiKey),e.oauthToken&&zo.setOauthToken(e.oauthToken),e.clientId&&!Ro()&&await async function(t){if(!google.accounts.oauth2.initTokenClient)throw new Error("Google accounts token client not loaded (https://accounts.google.com/gsi/client)");if(Ro())throw new Error("Google client is already initialized");const e={client_id:t.client_id,scope:t.scope||"https://www.googleapis.com/auth/userinfo.profile",state:t.state||"igv",error:t=>{throw new Error(t.type)},hint:t.hint,hosted_domain:t.hosted_domain},i=google.accounts.oauth2.initTokenClient(e);google.igv={tokenClient:i,apiKey:t.apiKey}}({clientId:e.clientId,apiKey:e.apiKey,scope:"https://www.googleapis.com/auth/userinfo.profile"});const i=new sy(e,t);return cy.push(i),e.sessionURL?await i.loadSession({url:e.sessionURL}):await i.loadSessionObject(e),i.navbarManager.navbarDidResize(i.$navigation.width()),i},removeBrowser:function(t){t.dispose(),t.root.remove(),cy=cy.filter((e=>e!==t))},removeAllBrowsers:function(){for(let t of cy)t.dispose(),t.root.remove();cy=[]},visibilityChange:async function(){for(let t of cy)await t.visibilityChange()},setGoogleOauthToken:function(t){return zo.setOauthToken(t)},setOauthToken:function(t,e){return zo.setOauthToken(t,e)},oauth:dy,version:function(){return"2.15.11"},setApiKey:uy,registerFileFormats:Ta};return fy}));var uo,fo,po=function(e){function i(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,i),(e=ao(this,i,[t])).browser=null,e}var n,r;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&co(t,e)}(i,e),n=i,(r=[{key:"componentDidMount",value:function(){this.initializeIGV(this.props.genomeReference||"hg19")}},{key:"componentDidUpdate",value:function(t){this.props.genomeReference!==t.genomeReference&&this.initializeIGV(this.props.genomeReference),this.props.crisprResults!==t.crisprResults&&this.updateTracks(this.props.crisprResults)}},{key:"initializeIGV",value:function(e){var i=this,n=document.getElementById("igvDiv"),r={genome:e};t.createBrowser(n,r).then((function(t){i.browser=t,i.updateTracks(i.props.crisprResults)}))}},{key:"updateTracks",value:function(t){if(this.browser&&t&&t.length>0){this.browser.removeAllTracks();var e="track name='CRISPR Targets' description='CRISPR Cas9 Predictions'\n";e+=t.map((function(t){var e=t[0],i=t[1],n=t[2],r=1===t[3]?"+":"-",s="gRNA: ".concat(t[4]," Score: ").concat(t[5]);return"".concat(e,"\t").concat(i,"\t").concat(n,"\t").concat(s,"\t0\t").concat(r)})).join("\n");var i=new Blob([e],{type:"text/plain"}),n={name:"CRISPR Targets",url:URL.createObjectURL(i),format:"bed",type:"annotation",indexed:!1};this.browser.loadTrack(n)}}},{key:"render",value:function(){return u.createElement("div",{id:"igvDiv",style:{height:"500px"}})}}])&&so(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),i}(u.Component);uo=po,fo=function(t){function e(e){var i=t.call(this,e)||this;return i.componentDidMount=function(){eo.events.addEventListener(eo.RENDER_EVENT,i.onRenderEvent),eo.setComponentReady()},i.componentDidUpdate=function(){null!=i.state.componentError&&eo.setFrameHeight()},i.componentWillUnmount=function(){eo.events.removeEventListener(eo.RENDER_EVENT,i.onRenderEvent)},i.onRenderEvent=function(t){i.setState({renderData:t.detail})},i.state={renderData:void 0,componentError:void 0},i}return no(e,t),e.prototype.render=function(){return null!=this.state.componentError?u.createElement("div",null,u.createElement("h1",null,"Component Error"),u.createElement("span",null,this.state.componentError.message)):null==this.state.renderData?null:u.createElement(uo,{width:window.innerWidth,disabled:this.state.renderData.disabled,args:this.state.renderData.args,theme:this.state.renderData.theme})},e.getDerivedStateFromError=function(t){return{componentError:t}},e}(u.PureComponent),f()(fo,uo)})()})();