diff --git a/igv_component/build/index.html b/igv_component/build/index.html new file mode 100644 index 0000000000000000000000000000000000000000..3aa7059ca2509d4c628d1bb93c81f7fb55dcde68 --- /dev/null +++ b/igv_component/build/index.html @@ -0,0 +1 @@ +IGV Component \ No newline at end of file diff --git a/igv_component/build/main.js b/igv_component/build/main.js index f752729e3fc6d792dd7423a01abd06fe595ec180..c6fef65d40eb05210b4aba9eff4d75139229b0fa 100644 --- a/igv_component/build/main.js +++ b/igv_component/build/main.js @@ -1,2 +1,2 @@ /*! 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.default.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)})()})(); \ No newline at end of file +(()=>{"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)})()})(); \ No newline at end of file diff --git a/igv_component/igvcomponent.js b/igv_component/igvcomponent.js index 858612df4c5e97c5bddbc223aa35beb5c4e33a51..3c2af49642554497541c5ed5f43fbee642365fcb 100644 --- a/igv_component/igvcomponent.js +++ b/igv_component/igvcomponent.js @@ -1,6 +1,6 @@ import React from "react"; import { Streamlit, withStreamlitConnection } from "streamlit-component-lib"; -import igv from "igv"; +import * as igv from 'igv'; class IGVComponent extends React.Component { constructor(props) { diff --git a/igv_component/node_modules/.bin/he b/igv_component/node_modules/.bin/he new file mode 100644 index 0000000000000000000000000000000000000000..70e18de98a2aaf3fd1e6178c615d15fbc25ea859 --- /dev/null +++ b/igv_component/node_modules/.bin/he @@ -0,0 +1,12 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + exec "$basedir/node" "$basedir/../he/bin/he" "$@" +else + exec node "$basedir/../he/bin/he" "$@" +fi diff --git a/igv_component/node_modules/.bin/he.cmd b/igv_component/node_modules/.bin/he.cmd new file mode 100644 index 0000000000000000000000000000000000000000..611a864acd34b7f6bd08d1969e3ef8a8b41cf18f --- /dev/null +++ b/igv_component/node_modules/.bin/he.cmd @@ -0,0 +1,17 @@ +@ECHO off +GOTO start +:find_dp0 +SET dp0=%~dp0 +EXIT /b +:start +SETLOCAL +CALL :find_dp0 + +IF EXIST "%dp0%\node.exe" ( + SET "_prog=%dp0%\node.exe" +) ELSE ( + SET "_prog=node" + SET PATHEXT=%PATHEXT:;.JS;=;% +) + +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\he\bin\he" %* diff --git a/igv_component/node_modules/.bin/he.ps1 b/igv_component/node_modules/.bin/he.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..b0010bc6c4ced22d14bdd6cd41f0d75d01ed0fb1 --- /dev/null +++ b/igv_component/node_modules/.bin/he.ps1 @@ -0,0 +1,28 @@ +#!/usr/bin/env pwsh +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent + +$exe="" +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) { + # Fix case when both the Windows and Linux builds of Node + # are installed in the same directory + $exe=".exe" +} +$ret=0 +if (Test-Path "$basedir/node$exe") { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "$basedir/node$exe" "$basedir/../he/bin/he" $args + } else { + & "$basedir/node$exe" "$basedir/../he/bin/he" $args + } + $ret=$LASTEXITCODE +} else { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "node$exe" "$basedir/../he/bin/he" $args + } else { + & "node$exe" "$basedir/../he/bin/he" $args + } + $ret=$LASTEXITCODE +} +exit $ret diff --git a/igv_component/node_modules/.bin/html-minifier-terser b/igv_component/node_modules/.bin/html-minifier-terser new file mode 100644 index 0000000000000000000000000000000000000000..b41bcf8ebdd4ae853ec0e6ae2d4fc54af8f85c01 --- /dev/null +++ b/igv_component/node_modules/.bin/html-minifier-terser @@ -0,0 +1,12 @@ +#!/bin/sh +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") + +case `uname` in + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; +esac + +if [ -x "$basedir/node" ]; then + exec "$basedir/node" "$basedir/../html-minifier-terser/cli.js" "$@" +else + exec node "$basedir/../html-minifier-terser/cli.js" "$@" +fi diff --git a/igv_component/node_modules/.bin/html-minifier-terser.cmd b/igv_component/node_modules/.bin/html-minifier-terser.cmd new file mode 100644 index 0000000000000000000000000000000000000000..8d037e4f7afcf44f960c62843247d64abe124d94 --- /dev/null +++ b/igv_component/node_modules/.bin/html-minifier-terser.cmd @@ -0,0 +1,17 @@ +@ECHO off +GOTO start +:find_dp0 +SET dp0=%~dp0 +EXIT /b +:start +SETLOCAL +CALL :find_dp0 + +IF EXIST "%dp0%\node.exe" ( + SET "_prog=%dp0%\node.exe" +) ELSE ( + SET "_prog=node" + SET PATHEXT=%PATHEXT:;.JS;=;% +) + +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\html-minifier-terser\cli.js" %* diff --git a/igv_component/node_modules/.bin/html-minifier-terser.ps1 b/igv_component/node_modules/.bin/html-minifier-terser.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..6fec7c4934dae20adaee06c25c55557d252eb99a --- /dev/null +++ b/igv_component/node_modules/.bin/html-minifier-terser.ps1 @@ -0,0 +1,28 @@ +#!/usr/bin/env pwsh +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent + +$exe="" +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) { + # Fix case when both the Windows and Linux builds of Node + # are installed in the same directory + $exe=".exe" +} +$ret=0 +if (Test-Path "$basedir/node$exe") { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "$basedir/node$exe" "$basedir/../html-minifier-terser/cli.js" $args + } else { + & "$basedir/node$exe" "$basedir/../html-minifier-terser/cli.js" $args + } + $ret=$LASTEXITCODE +} else { + # Support pipeline input + if ($MyInvocation.ExpectingInput) { + $input | & "node$exe" "$basedir/../html-minifier-terser/cli.js" $args + } else { + & "node$exe" "$basedir/../html-minifier-terser/cli.js" $args + } + $ret=$LASTEXITCODE +} +exit $ret diff --git a/igv_component/node_modules/.package-lock.json b/igv_component/node_modules/.package-lock.json index 94c24587e66b2bc53579338f5f0f5aa35dc2f8c3..0384ed268ceb5472088b0cd183b47c8890429ddc 100644 --- a/igv_component/node_modules/.package-lock.json +++ b/igv_component/node_modules/.package-lock.json @@ -1879,6 +1879,12 @@ "resolved": "https://registry.npmjs.org/@types/flatbuffers/-/flatbuffers-1.10.3.tgz", "integrity": "sha512-kwJQsAROanCiMXSLjcTLmYVBIJ9Qyuqs92SaDIcj2EII2KnDgZbiU7it1Z/JfZd1gmxw/lAahMysQ6ZM+j3Ryw==" }, + "node_modules/@types/html-minifier-terser": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@types/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz", + "integrity": "sha512-oh/6byDPnL1zeNXFrDXFLyZjkr1MsBG667IM792caf1L2UPOOMf65NFzjUH/ltyfwjAGfs1rsX1eftK0jC/KIg==", + "dev": true + }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", @@ -2163,6 +2169,15 @@ "ajv": "^8.8.2" } }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", @@ -2259,6 +2274,12 @@ "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0" } }, + "node_modules/boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", + "dev": true + }, "node_modules/browserslist": { "version": "4.22.3", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.3.tgz", @@ -2297,6 +2318,16 @@ "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", "dev": true }, + "node_modules/camel-case": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz", + "integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==", + "dev": true, + "dependencies": { + "pascal-case": "^3.1.2", + "tslib": "^2.0.3" + } + }, "node_modules/caniuse-lite": { "version": "1.0.30001581", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001581.tgz", @@ -2339,6 +2370,18 @@ "node": ">=6.0" } }, + "node_modules/clean-css": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.3.tgz", + "integrity": "sha512-D5J+kHaVb/wKSFcyyV75uCn8fiY4sV38XJoe4CUyGQ+mOU/fMVYUdH1hJC+CJQ5uY3EnW27SbJYS4X8BiLrAFg==", + "dev": true, + "dependencies": { + "source-map": "~0.6.0" + }, + "engines": { + "node": ">= 10.0" + } + }, "node_modules/clone-deep": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-4.0.1.tgz", @@ -2461,6 +2504,34 @@ "node": ">= 8" } }, + "node_modules/css-select": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-4.3.0.tgz", + "integrity": "sha512-wPpOYtnsVontu2mODhA19JrqWxNsfdatRKd64kmpRbQgh1KtItko5sTnEpPdpSaJszTOhEMlF/RPz28qj4HqhQ==", + "dev": true, + "dependencies": { + "boolbase": "^1.0.0", + "css-what": "^6.0.1", + "domhandler": "^4.3.1", + "domutils": "^2.8.0", + "nth-check": "^2.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/css-what": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz", + "integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==", + "dev": true, + "engines": { + "node": ">= 6" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -2486,6 +2557,80 @@ "node": ">=4.0.0" } }, + "node_modules/dom-converter": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/dom-converter/-/dom-converter-0.2.0.tgz", + "integrity": "sha512-gd3ypIPfOMr9h5jIKq8E3sHOTCjeirnl0WK5ZdS1AW0Odt0b1PaWaHdJ4Qk4klv+YB9aJBS7mESXjFoDQPu6DA==", + "dev": true, + "dependencies": { + "utila": "~0.4" + } + }, + "node_modules/dom-serializer": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.4.1.tgz", + "integrity": "sha512-VHwB3KfrcOOkelEG2ZOfxqLZdfkil8PtJi4P8N2MMXucZq2yLp75ClViUlOVwyoHEDjYU433Aq+5zWP61+RGag==", + "dev": true, + "dependencies": { + "domelementtype": "^2.0.1", + "domhandler": "^4.2.0", + "entities": "^2.0.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ] + }, + "node_modules/domhandler": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.3.1.tgz", + "integrity": "sha512-GrwoxYN+uWlzO8uhUXRl0P+kHE4GtVPfYzVLcUxPL7KNdHKj66vvlhiweIHqYYXWlw+T8iLMp42Lm67ghw4WMQ==", + "dev": true, + "dependencies": { + "domelementtype": "^2.2.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/domutils": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-2.8.0.tgz", + "integrity": "sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==", + "dev": true, + "dependencies": { + "dom-serializer": "^1.0.1", + "domelementtype": "^2.2.0", + "domhandler": "^4.2.0" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, + "node_modules/dot-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", + "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", + "dev": true, + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, "node_modules/electron-to-chromium": { "version": "1.4.648", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.648.tgz", @@ -2505,6 +2650,15 @@ "node": ">=10.13.0" } }, + "node_modules/entities": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", + "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", + "dev": true, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, "node_modules/envinfo": { "version": "7.11.0", "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.11.0.tgz", @@ -2738,6 +2892,15 @@ "node": ">= 0.4" } }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true, + "bin": { + "he": "bin/he" + } + }, "node_modules/hoist-non-react-statics": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", @@ -2746,6 +2909,87 @@ "react-is": "^16.7.0" } }, + "node_modules/html-minifier-terser": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz", + "integrity": "sha512-YXxSlJBZTP7RS3tWnQw74ooKa6L9b9i9QYXY21eUEvhZ3u9XLfv6OnFsQq6RxkhHygsaUMvYsZRV5rU/OVNZxw==", + "dev": true, + "dependencies": { + "camel-case": "^4.1.2", + "clean-css": "^5.2.2", + "commander": "^8.3.0", + "he": "^1.2.0", + "param-case": "^3.0.4", + "relateurl": "^0.2.7", + "terser": "^5.10.0" + }, + "bin": { + "html-minifier-terser": "cli.js" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/html-minifier-terser/node_modules/commander": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", + "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", + "dev": true, + "engines": { + "node": ">= 12" + } + }, + "node_modules/html-webpack-plugin": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-5.6.0.tgz", + "integrity": "sha512-iwaY4wzbe48AfKLZ/Cc8k0L+FKG6oSNRaZ8x5A/T/IVDGyXcbHncM9TdDa93wn0FsSm82FhTKW7f3vS61thXAw==", + "dev": true, + "dependencies": { + "@types/html-minifier-terser": "^6.0.0", + "html-minifier-terser": "^6.0.2", + "lodash": "^4.17.21", + "pretty-error": "^4.0.0", + "tapable": "^2.0.0" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/html-webpack-plugin" + }, + "peerDependencies": { + "@rspack/core": "0.x || 1.x", + "webpack": "^5.20.0" + }, + "peerDependenciesMeta": { + "@rspack/core": { + "optional": true + }, + "webpack": { + "optional": true + } + } + }, + "node_modules/htmlparser2": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.1.0.tgz", + "integrity": "sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A==", + "dev": true, + "funding": [ + "https://github.com/fb55/htmlparser2?sponsor=1", + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "dependencies": { + "domelementtype": "^2.0.1", + "domhandler": "^4.0.0", + "domutils": "^2.5.2", + "entities": "^2.0.0" + } + }, "node_modules/igv": { "version": "2.15.11", "resolved": "https://registry.npmjs.org/igv/-/igv-2.15.11.tgz", @@ -3011,6 +3255,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, "node_modules/lodash.camelcase": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", @@ -3033,6 +3283,15 @@ "loose-envify": "cli.js" } }, + "node_modules/lower-case": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", + "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", + "dev": true, + "dependencies": { + "tslib": "^2.0.3" + } + }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -3081,12 +3340,34 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, + "node_modules/no-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", + "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", + "dev": true, + "dependencies": { + "lower-case": "^2.0.2", + "tslib": "^2.0.3" + } + }, "node_modules/node-releases": { "version": "2.0.14", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz", "integrity": "sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==", "dev": true }, + "node_modules/nth-check": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", + "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", + "dev": true, + "dependencies": { + "boolbase": "^1.0.0" + }, + "funding": { + "url": "https://github.com/fb55/nth-check?sponsor=1" + } + }, "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -3145,6 +3426,26 @@ "node": ">=0.10.0" } }, + "node_modules/param-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz", + "integrity": "sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==", + "dev": true, + "dependencies": { + "dot-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/pascal-case": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz", + "integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==", + "dev": true, + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, "node_modules/path-exists": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-5.0.0.tgz", @@ -3190,6 +3491,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/pretty-error": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/pretty-error/-/pretty-error-4.0.0.tgz", + "integrity": "sha512-AoJ5YMAcXKYxKhuJGdcvse+Voc6v1RgnsR3nWcYU7q4t6z0Q6T86sv5Zq8VIRbOWWFpvdGE83LtdSMNd+6Y0xw==", + "dev": true, + "dependencies": { + "lodash": "^4.17.20", + "renderkid": "^3.0.0" + } + }, "node_modules/prop-types": { "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", @@ -3341,6 +3652,28 @@ "jsesc": "bin/jsesc" } }, + "node_modules/relateurl": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz", + "integrity": "sha512-G08Dxvm4iDN3MLM0EsP62EDV9IuhXPR6blNz6Utcp7zyV3tr4HVNINt6MpaRWbxoOHT3Q7YN2P+jaHX8vUbgog==", + "dev": true, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/renderkid": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/renderkid/-/renderkid-3.0.0.tgz", + "integrity": "sha512-q/7VIQA8lmM1hF+jn+sFSPWGlMkSAeNYcPLmDQx2zzuiDfaLrOmumR8iaUKlenFgh0XRPIUeSPlH3A+AW3Z5pg==", + "dev": true, + "dependencies": { + "css-select": "^4.1.3", + "dom-converter": "^0.2.0", + "htmlparser2": "^6.1.0", + "lodash": "^4.17.21", + "strip-ansi": "^6.0.1" + } + }, "node_modules/repeat-string": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", @@ -3525,6 +3858,18 @@ "react-dom": "^16.14.0" } }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -3789,6 +4134,12 @@ "punycode": "^2.1.0" } }, + "node_modules/utila": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/utila/-/utila-0.4.0.tgz", + "integrity": "sha512-Z0DbgELS9/L/75wZbro8xAnT50pBVFQZ+hUEueGDU5FN51YSCYM+jdxsfCiHjwNP/4LCDD0i/graKpeBnOXKRA==", + "dev": true + }, "node_modules/watchpack": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", diff --git a/igv_component/node_modules/@types/html-minifier-terser/LICENSE b/igv_component/node_modules/@types/html-minifier-terser/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..9e841e7a26e4eb057b24511e7b92d42b257a80e5 --- /dev/null +++ b/igv_component/node_modules/@types/html-minifier-terser/LICENSE @@ -0,0 +1,21 @@ + MIT License + + Copyright (c) Microsoft Corporation. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE diff --git a/igv_component/node_modules/@types/html-minifier-terser/README.md b/igv_component/node_modules/@types/html-minifier-terser/README.md new file mode 100644 index 0000000000000000000000000000000000000000..eadf47cf872de63efdf8179c6350e2595868c3cc --- /dev/null +++ b/igv_component/node_modules/@types/html-minifier-terser/README.md @@ -0,0 +1,16 @@ +# Installation +> `npm install --save @types/html-minifier-terser` + +# Summary +This package contains type definitions for html-minifier-terser (https://github.com/terser/html-minifier-terser#readme). + +# Details +Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/html-minifier-terser. + +### Additional Details + * Last updated: Tue, 23 Nov 2021 21:01:04 GMT + * Dependencies: none + * Global values: none + +# Credits +These definitions were written by [Piotr Błażejewicz](https://github.com/peterblazejewicz). diff --git a/igv_component/node_modules/@types/html-minifier-terser/index.d.ts b/igv_component/node_modules/@types/html-minifier-terser/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f17a30e220c9601f2c0e8660ef356f1ab0022395 --- /dev/null +++ b/igv_component/node_modules/@types/html-minifier-terser/index.d.ts @@ -0,0 +1,211 @@ +// Type definitions for html-minifier-terser 6.1 +// Project: https://github.com/terser/html-minifier-terser#readme +// Definitions by: Piotr Błażejewicz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * HTMLMinifier is a highly configurable, well-tested, JavaScript-based HTML minifier. + * @async + */ +export function minify(value: string, options?: Options): Promise; + +/** + * Most of the options are disabled by default + */ +export interface Options { + /** + * Treat attributes in case sensitive manner (useful for custom HTML tags) + * @default false + */ + caseSensitive?: boolean | undefined; + /** + * Omit attribute values from boolean attributes + * @default false + */ + collapseBooleanAttributes?: boolean | undefined; + /** + * Don't leave any spaces between display:inline; + * elements when collapsing. Must be used in conjunction with collapseWhitespace=true + * @default false + */ + collapseInlineTagWhitespace?: boolean | undefined; + /** + * Collapse white space that contributes to text nodes in a document tree + * @default false + */ + collapseWhitespace?: boolean | undefined; + /** + * Always collapse to 1 space (never remove it entirely). Must be used in conjunction with `collapseWhitespace=true` + * @default false + */ + conservativeCollapse?: boolean | undefined; + /** + * Handle parse errors + * @default false + */ + continueOnParseError?: boolean | undefined; + /** + * Arrays of regex'es that allow to support custom attribute assign expressions (e.g. `'
'`) + * @default [] + */ + customAttrAssign?: RegExp[] | undefined; + /** + * Regex that specifies custom attribute to strip newlines from (e.g. `/ng-class/` + */ + customAttrCollapse?: RegExp | undefined; + /** + * Arrays of regex'es that allow to support custom attribute surround expressions (e.g. ``) + * @default [] + */ + customAttrSurround?: RegExp[] | undefined; + /** + * Arrays of regex'es that allow to support custom event attributes for `minifyJS` (e.g. `ng-click`) + * @default [/^on[a-z]{3,}$/] + */ + customEventAttributes?: RegExp[] | undefined; + /** + * Use direct Unicode characters whenever possible + * @default false + */ + decodeEntities?: boolean | undefined; + /** + * Parse input according to HTML5 specifications + * @default true + */ + html5?: boolean | undefined; + /** + * Array of regex'es that allow to ignore certain comments, when matched + * @default [ /^!/, /^\s*#/ ] + */ + ignoreCustomComments?: RegExp[] | undefined; + /** + * Array of regex'es that allow to ignore certain fragments, when matched (e.g. ``, `{{ ... }}`, etc.) + * @default [/<%[\s\S]*?%>/, /<\?[\s\S]\*?\?>/] + */ + ignoreCustomFragments?: RegExp[] | undefined; + /** + * Insert tags generated by HTML parser + * @default true + */ + includeAutoGeneratedTags?: boolean | undefined; + /** + * Keep the trailing slash on singleton elements + * @default false + */ + keepClosingSlash?: boolean | undefined; + /** + * Specify a maximum line length. Compressed output will be split by newlines at valid HTML split-points + */ + maxLineLength?: number | undefined; + /** + * Minify CSS in style elements and style attributes + * @default false + */ + minifyCSS?: boolean | object | ((text: string, type?: string) => string) | undefined; + /** + * Minify JavaScript in script elements and event attributes + * @default false + */ + minifyJS?: boolean | object | ((text: string, inline?: boolean) => string) | undefined; + /** + * Minify URLs in various attributes + * @default false + */ + minifyURLs?: boolean | string | object | ((text: string) => string) | undefined; + /** + * Never add a newline before a tag that closes an element + * @default false + */ + noNewlinesBeforeTagClose?: boolean | undefined; + /** + * Always collapse to 1 line break (never remove it entirely) when whitespace between tags include a line break. + * Must be used in conjunction with `collapseWhitespace=true` + * @default false + */ + preserveLineBreaks?: boolean | undefined; + /** + * Prevents the escaping of the values of attributes + * @default false + */ + preventAttributesEscaping?: boolean | undefined; + /** + * Process contents of conditional comments through minifier + * @default false + */ + processConditionalComments?: boolean | undefined; + /** + * Array of strings corresponding to types of script elements to process through minifier + * (e.g. `text/ng-template`, `text/x-handlebars-template`, etc.) + * @default [] + */ + processScripts?: string[] | undefined; + /** + * Type of quote to use for attribute values (' or ") + */ + quoteCharacter?: string | undefined; + /** + * Remove quotes around attributes when possible + * @default false + */ + removeAttributeQuotes?: boolean | undefined; + /** + * Strip HTML comments + * @default false + */ + removeComments?: boolean | undefined; + /** + * Remove all attributes with whitespace-only values + * @default false + */ + removeEmptyAttributes?: boolean | ((attrName: string, tag: string) => boolean) | undefined; + /** + * Remove all elements with empty contents + * @default false + */ + removeEmptyElements?: boolean | undefined; + /** + * Remove optional tags + * @default false + */ + removeOptionalTags?: boolean | undefined; + /** + * Remove attributes when value matches default + * @default false + */ + removeRedundantAttributes?: boolean | undefined; + /** + * Remove `type="text/javascript"` from `script` tags. Other `type` attribute values are left intact + * @default false + */ + removeScriptTypeAttributes?: boolean | undefined; + /** + * Remove `type="text/css"` from `style` and `link` tags. Other `type` attribute values are left intact + * @default false + */ + removeStyleLinkTypeAttributes?: boolean | undefined; + /** + * Remove space between attributes whenever possible. **Note that this will result in invalid HTML!** + * @default false + */ + removeTagWhitespace?: boolean | undefined; + /** + * Sort attributes by frequency + * @default false + */ + sortAttributes?: boolean | undefined; + /** + * Sort style classes by frequency + * @default false + */ + sortClassName?: boolean | undefined; + /** + * Trim white space around `ignoreCustomFragments` + * @default false + */ + trimCustomFragments?: boolean | undefined; + /** + * Replaces the `doctype` with the short (HTML5) doctype + * @default false + */ + useShortDoctype?: boolean | undefined; +} diff --git a/igv_component/node_modules/@types/html-minifier-terser/package.json b/igv_component/node_modules/@types/html-minifier-terser/package.json new file mode 100644 index 0000000000000000000000000000000000000000..80e8ceb284878447c5e478c78b4b3fa259434242 --- /dev/null +++ b/igv_component/node_modules/@types/html-minifier-terser/package.json @@ -0,0 +1,25 @@ +{ + "name": "@types/html-minifier-terser", + "version": "6.1.0", + "description": "TypeScript definitions for html-minifier-terser", + "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/html-minifier-terser", + "license": "MIT", + "contributors": [ + { + "name": "Piotr Błażejewicz", + "url": "https://github.com/peterblazejewicz", + "githubUsername": "peterblazejewicz" + } + ], + "main": "", + "types": "index.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", + "directory": "types/html-minifier-terser" + }, + "scripts": {}, + "dependencies": {}, + "typesPublisherContentHash": "e851f65ded989d19a70b471ff32b156ed08fec7ed641ce4c5a7fdee809bd53e2", + "typeScriptVersion": "3.8" +} \ No newline at end of file diff --git a/igv_component/node_modules/ansi-regex/index.d.ts b/igv_component/node_modules/ansi-regex/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2dbf6af2b6f3b5701c83caaea7ed2210192023a8 --- /dev/null +++ b/igv_component/node_modules/ansi-regex/index.d.ts @@ -0,0 +1,37 @@ +declare namespace ansiRegex { + interface Options { + /** + Match only the first ANSI escape. + + @default false + */ + onlyFirst: boolean; + } +} + +/** +Regular expression for matching ANSI escape codes. + +@example +``` +import ansiRegex = require('ansi-regex'); + +ansiRegex().test('\u001B[4mcake\u001B[0m'); +//=> true + +ansiRegex().test('cake'); +//=> false + +'\u001B[4mcake\u001B[0m'.match(ansiRegex()); +//=> ['\u001B[4m', '\u001B[0m'] + +'\u001B[4mcake\u001B[0m'.match(ansiRegex({onlyFirst: true})); +//=> ['\u001B[4m'] + +'\u001B]8;;https://github.com\u0007click\u001B]8;;\u0007'.match(ansiRegex()); +//=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007'] +``` +*/ +declare function ansiRegex(options?: ansiRegex.Options): RegExp; + +export = ansiRegex; diff --git a/igv_component/node_modules/ansi-regex/index.js b/igv_component/node_modules/ansi-regex/index.js new file mode 100644 index 0000000000000000000000000000000000000000..616ff837d3ff01e028c208062fc699c7f1c8d418 --- /dev/null +++ b/igv_component/node_modules/ansi-regex/index.js @@ -0,0 +1,10 @@ +'use strict'; + +module.exports = ({onlyFirst = false} = {}) => { + const pattern = [ + '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', + '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))' + ].join('|'); + + return new RegExp(pattern, onlyFirst ? undefined : 'g'); +}; diff --git a/igv_component/node_modules/ansi-regex/license b/igv_component/node_modules/ansi-regex/license new file mode 100644 index 0000000000000000000000000000000000000000..e7af2f77107d73046421ef56c4684cbfdd3c1e89 --- /dev/null +++ b/igv_component/node_modules/ansi-regex/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/igv_component/node_modules/ansi-regex/package.json b/igv_component/node_modules/ansi-regex/package.json new file mode 100644 index 0000000000000000000000000000000000000000..017f53116a9e2805ccb12efc3c7fcd7e4384735d --- /dev/null +++ b/igv_component/node_modules/ansi-regex/package.json @@ -0,0 +1,55 @@ +{ + "name": "ansi-regex", + "version": "5.0.1", + "description": "Regular expression for matching ANSI escape codes", + "license": "MIT", + "repository": "chalk/ansi-regex", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "engines": { + "node": ">=8" + }, + "scripts": { + "test": "xo && ava && tsd", + "view-supported": "node fixtures/view-codes.js" + }, + "files": [ + "index.js", + "index.d.ts" + ], + "keywords": [ + "ansi", + "styles", + "color", + "colour", + "colors", + "terminal", + "console", + "cli", + "string", + "tty", + "escape", + "formatting", + "rgb", + "256", + "shell", + "xterm", + "command-line", + "text", + "regex", + "regexp", + "re", + "match", + "test", + "find", + "pattern" + ], + "devDependencies": { + "ava": "^2.4.0", + "tsd": "^0.9.0", + "xo": "^0.25.3" + } +} diff --git a/igv_component/node_modules/ansi-regex/readme.md b/igv_component/node_modules/ansi-regex/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..4d848bc36f6b862e5db3effa59ebed515730284e --- /dev/null +++ b/igv_component/node_modules/ansi-regex/readme.md @@ -0,0 +1,78 @@ +# ansi-regex + +> Regular expression for matching [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) + + +## Install + +``` +$ npm install ansi-regex +``` + + +## Usage + +```js +const ansiRegex = require('ansi-regex'); + +ansiRegex().test('\u001B[4mcake\u001B[0m'); +//=> true + +ansiRegex().test('cake'); +//=> false + +'\u001B[4mcake\u001B[0m'.match(ansiRegex()); +//=> ['\u001B[4m', '\u001B[0m'] + +'\u001B[4mcake\u001B[0m'.match(ansiRegex({onlyFirst: true})); +//=> ['\u001B[4m'] + +'\u001B]8;;https://github.com\u0007click\u001B]8;;\u0007'.match(ansiRegex()); +//=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007'] +``` + + +## API + +### ansiRegex(options?) + +Returns a regex for matching ANSI escape codes. + +#### options + +Type: `object` + +##### onlyFirst + +Type: `boolean`
+Default: `false` *(Matches any ANSI escape codes in a string)* + +Match only the first ANSI escape. + + +## FAQ + +### Why do you test for codes not in the ECMA 48 standard? + +Some of the codes we run as a test are codes that we acquired finding various lists of non-standard or manufacturer specific codes. We test for both standard and non-standard codes, as most of them follow the same or similar format and can be safely matched in strings without the risk of removing actual string content. There are a few non-standard control codes that do not follow the traditional format (i.e. they end in numbers) thus forcing us to exclude them from the test because we cannot reliably match them. + +On the historical side, those ECMA standards were established in the early 90's whereas the VT100, for example, was designed in the mid/late 70's. At that point in time, control codes were still pretty ungoverned and engineers used them for a multitude of things, namely to activate hardware ports that may have been proprietary. Somewhere else you see a similar 'anarchy' of codes is in the x86 architecture for processors; there are a ton of "interrupts" that can mean different things on certain brands of processors, most of which have been phased out. + + +## Maintainers + +- [Sindre Sorhus](https://github.com/sindresorhus) +- [Josh Junon](https://github.com/qix-) + + +--- + +
+ + Get professional support for this package with a Tidelift subscription + +
+ + Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies. +
+
diff --git a/igv_component/node_modules/boolbase/README.md b/igv_component/node_modules/boolbase/README.md new file mode 100644 index 0000000000000000000000000000000000000000..85eefa5e5048913b08ec4eb37d0a78473f88505d --- /dev/null +++ b/igv_component/node_modules/boolbase/README.md @@ -0,0 +1,10 @@ +#boolbase +This very simple module provides two basic functions, one that always returns true (`trueFunc`) and one that always returns false (`falseFunc`). + +###WTF? + +By having only a single instance of these functions around, it's possible to do some nice optimizations. Eg. [`CSSselect`](https://github.com/fb55/CSSselect) uses these functions to determine whether a selector won't match any elements. If that's the case, the DOM doesn't even have to be touched. + +###And why is this a separate module? + +I'm trying to modularize `CSSselect` and most modules depend on these functions. IMHO, having a separate module is the easiest solution to this problem. \ No newline at end of file diff --git a/igv_component/node_modules/boolbase/index.js b/igv_component/node_modules/boolbase/index.js new file mode 100644 index 0000000000000000000000000000000000000000..8799fd95dbe31a85c48b956eb19f3625da9f8fb1 --- /dev/null +++ b/igv_component/node_modules/boolbase/index.js @@ -0,0 +1,8 @@ +module.exports = { + trueFunc: function trueFunc(){ + return true; + }, + falseFunc: function falseFunc(){ + return false; + } +}; \ No newline at end of file diff --git a/igv_component/node_modules/boolbase/package.json b/igv_component/node_modules/boolbase/package.json new file mode 100644 index 0000000000000000000000000000000000000000..78330a8f72728c2749da781730390073794e231b --- /dev/null +++ b/igv_component/node_modules/boolbase/package.json @@ -0,0 +1,23 @@ +{ + "name": "boolbase", + "version": "1.0.0", + "description": "two functions: One that returns true, one that returns false", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "https://github.com/fb55/boolbase" + }, + "keywords": [ + "boolean", + "function" + ], + "author": "Felix Boehm ", + "license": "ISC", + "bugs": { + "url": "https://github.com/fb55/boolbase/issues" + }, + "homepage": "https://github.com/fb55/boolbase" +} diff --git a/igv_component/node_modules/camel-case/LICENSE b/igv_component/node_modules/camel-case/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..983fbe8aec3f4e2d4add592bb1083b00d7366f66 --- /dev/null +++ b/igv_component/node_modules/camel-case/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/igv_component/node_modules/camel-case/README.md b/igv_component/node_modules/camel-case/README.md new file mode 100644 index 0000000000000000000000000000000000000000..33ecb1be82f110dfe6ad2eeab0bb806c6333acc8 --- /dev/null +++ b/igv_component/node_modules/camel-case/README.md @@ -0,0 +1,47 @@ +# Camel Case + +[![NPM version][npm-image]][npm-url] +[![NPM downloads][downloads-image]][downloads-url] +[![Bundle size][bundlephobia-image]][bundlephobia-url] + +> Transform into a string with the separator denoted by the next word capitalized. + +## Installation + +``` +npm install camel-case --save +``` + +## Usage + +```js +import { camelCase } from "camel-case"; + +camelCase("string"); //=> "string" +camelCase("dot.case"); //=> "dotCase" +camelCase("PascalCase"); //=> "pascalCase" +camelCase("version 1.2.10"); //=> "version_1_2_10" +``` + +The function also accepts [`options`](https://github.com/blakeembrey/change-case#options). + +### Merge Numbers + +If you'd like to remove the behavior prefixing `_` before numbers, you can use `camelCaseTransformMerge`: + +```js +import { camelCaseTransformMerge } from "camel-case"; + +camelCase("version 12", { transform: camelCaseTransformMerge }); //=> "version12" +``` + +## License + +MIT + +[npm-image]: https://img.shields.io/npm/v/camel-case.svg?style=flat +[npm-url]: https://npmjs.org/package/camel-case +[downloads-image]: https://img.shields.io/npm/dm/camel-case.svg?style=flat +[downloads-url]: https://npmjs.org/package/camel-case +[bundlephobia-image]: https://img.shields.io/bundlephobia/minzip/camel-case.svg +[bundlephobia-url]: https://bundlephobia.com/result?p=camel-case diff --git a/igv_component/node_modules/camel-case/dist.es2015/index.d.ts b/igv_component/node_modules/camel-case/dist.es2015/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..23c665c6128155ae489d2549b67621b3b40f57c0 --- /dev/null +++ b/igv_component/node_modules/camel-case/dist.es2015/index.d.ts @@ -0,0 +1,5 @@ +import { Options } from "pascal-case"; +export { Options }; +export declare function camelCaseTransform(input: string, index: number): string; +export declare function camelCaseTransformMerge(input: string, index: number): string; +export declare function camelCase(input: string, options?: Options): string; diff --git a/igv_component/node_modules/camel-case/dist.es2015/index.js b/igv_component/node_modules/camel-case/dist.es2015/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c5fd0a4c54db0df94f573752b77d6e861e93b8d7 --- /dev/null +++ b/igv_component/node_modules/camel-case/dist.es2015/index.js @@ -0,0 +1,17 @@ +import { __assign } from "tslib"; +import { pascalCase, pascalCaseTransform, pascalCaseTransformMerge, } from "pascal-case"; +export function camelCaseTransform(input, index) { + if (index === 0) + return input.toLowerCase(); + return pascalCaseTransform(input, index); +} +export function camelCaseTransformMerge(input, index) { + if (index === 0) + return input.toLowerCase(); + return pascalCaseTransformMerge(input); +} +export function camelCase(input, options) { + if (options === void 0) { options = {}; } + return pascalCase(input, __assign({ transform: camelCaseTransform }, options)); +} +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/igv_component/node_modules/camel-case/dist.es2015/index.js.map b/igv_component/node_modules/camel-case/dist.es2015/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..b9ef1debb7d955c4d6246744f9d263fd5945ef37 --- /dev/null +++ b/igv_component/node_modules/camel-case/dist.es2015/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,wBAAwB,GAEzB,MAAM,aAAa,CAAC;AAIrB,MAAM,UAAU,kBAAkB,CAAC,KAAa,EAAE,KAAa;IAC7D,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;IAC5C,OAAO,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,KAAa,EAAE,KAAa;IAClE,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;IAC5C,OAAO,wBAAwB,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAa,EAAE,OAAqB;IAArB,wBAAA,EAAA,YAAqB;IAC5D,OAAO,UAAU,CAAC,KAAK,aACrB,SAAS,EAAE,kBAAkB,IAC1B,OAAO,EACV,CAAC;AACL,CAAC","sourcesContent":["import {\n pascalCase,\n pascalCaseTransform,\n pascalCaseTransformMerge,\n Options,\n} from \"pascal-case\";\n\nexport { Options };\n\nexport function camelCaseTransform(input: string, index: number) {\n if (index === 0) return input.toLowerCase();\n return pascalCaseTransform(input, index);\n}\n\nexport function camelCaseTransformMerge(input: string, index: number) {\n if (index === 0) return input.toLowerCase();\n return pascalCaseTransformMerge(input);\n}\n\nexport function camelCase(input: string, options: Options = {}) {\n return pascalCase(input, {\n transform: camelCaseTransform,\n ...options,\n });\n}\n"]} \ No newline at end of file diff --git a/igv_component/node_modules/camel-case/dist.es2015/index.spec.d.ts b/igv_component/node_modules/camel-case/dist.es2015/index.spec.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/igv_component/node_modules/camel-case/dist.es2015/index.spec.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/igv_component/node_modules/camel-case/dist.es2015/index.spec.js b/igv_component/node_modules/camel-case/dist.es2015/index.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..0396a8ace47830c2159e617db9bab73ace06d3aa --- /dev/null +++ b/igv_component/node_modules/camel-case/dist.es2015/index.spec.js @@ -0,0 +1,24 @@ +import { camelCase, camelCaseTransformMerge } from "."; +var TEST_CASES = [ + ["", ""], + ["test", "test"], + ["test string", "testString"], + ["Test String", "testString"], + ["TestV2", "testV2"], + ["_foo_bar_", "fooBar"], + ["version 1.2.10", "version_1_2_10"], + ["version 1.21.0", "version_1_21_0"], + ["version 1.2.10", "version1210", { transform: camelCaseTransformMerge }], +]; +describe("camel case", function () { + var _loop_1 = function (input, result, options) { + it(input + " -> " + result, function () { + expect(camelCase(input, options)).toEqual(result); + }); + }; + for (var _i = 0, TEST_CASES_1 = TEST_CASES; _i < TEST_CASES_1.length; _i++) { + var _a = TEST_CASES_1[_i], input = _a[0], result = _a[1], options = _a[2]; + _loop_1(input, result, options); + } +}); +//# sourceMappingURL=index.spec.js.map \ No newline at end of file diff --git a/igv_component/node_modules/camel-case/dist.es2015/index.spec.js.map b/igv_component/node_modules/camel-case/dist.es2015/index.spec.js.map new file mode 100644 index 0000000000000000000000000000000000000000..13472d71dc571cef8239db24b2f602b0b8cfd855 --- /dev/null +++ b/igv_component/node_modules/camel-case/dist.es2015/index.spec.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.spec.js","sourceRoot":"","sources":["../src/index.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAW,MAAM,GAAG,CAAC;AAEhE,IAAM,UAAU,GAAiC;IAC/C,CAAC,EAAE,EAAE,EAAE,CAAC;IACR,CAAC,MAAM,EAAE,MAAM,CAAC;IAChB,CAAC,aAAa,EAAE,YAAY,CAAC;IAC7B,CAAC,aAAa,EAAE,YAAY,CAAC;IAC7B,CAAC,QAAQ,EAAE,QAAQ,CAAC;IACpB,CAAC,WAAW,EAAE,QAAQ,CAAC;IACvB,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IACpC,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IACpC,CAAC,gBAAgB,EAAE,aAAa,EAAE,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;CAC1E,CAAC;AAEF,QAAQ,CAAC,YAAY,EAAE;4BACT,KAAK,EAAE,MAAM,EAAE,OAAO;QAChC,EAAE,CAAI,KAAK,YAAO,MAAQ,EAAE;YAC1B,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;;IAHL,KAAuC,UAAU,EAAV,yBAAU,EAAV,wBAAU,EAAV,IAAU;QAAtC,IAAA,qBAAwB,EAAvB,KAAK,QAAA,EAAE,MAAM,QAAA,EAAE,OAAO,QAAA;gBAAtB,KAAK,EAAE,MAAM,EAAE,OAAO;KAIjC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { camelCase, camelCaseTransformMerge, Options } from \".\";\n\nconst TEST_CASES: [string, string, Options?][] = [\n [\"\", \"\"],\n [\"test\", \"test\"],\n [\"test string\", \"testString\"],\n [\"Test String\", \"testString\"],\n [\"TestV2\", \"testV2\"],\n [\"_foo_bar_\", \"fooBar\"],\n [\"version 1.2.10\", \"version_1_2_10\"],\n [\"version 1.21.0\", \"version_1_21_0\"],\n [\"version 1.2.10\", \"version1210\", { transform: camelCaseTransformMerge }],\n];\n\ndescribe(\"camel case\", () => {\n for (const [input, result, options] of TEST_CASES) {\n it(`${input} -> ${result}`, () => {\n expect(camelCase(input, options)).toEqual(result);\n });\n }\n});\n"]} \ No newline at end of file diff --git a/igv_component/node_modules/camel-case/dist/index.d.ts b/igv_component/node_modules/camel-case/dist/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..23c665c6128155ae489d2549b67621b3b40f57c0 --- /dev/null +++ b/igv_component/node_modules/camel-case/dist/index.d.ts @@ -0,0 +1,5 @@ +import { Options } from "pascal-case"; +export { Options }; +export declare function camelCaseTransform(input: string, index: number): string; +export declare function camelCaseTransformMerge(input: string, index: number): string; +export declare function camelCase(input: string, options?: Options): string; diff --git a/igv_component/node_modules/camel-case/dist/index.js b/igv_component/node_modules/camel-case/dist/index.js new file mode 100644 index 0000000000000000000000000000000000000000..856a8d3d0c8fed08a14de016bda2e6837ec8a380 --- /dev/null +++ b/igv_component/node_modules/camel-case/dist/index.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.camelCase = exports.camelCaseTransformMerge = exports.camelCaseTransform = void 0; +var tslib_1 = require("tslib"); +var pascal_case_1 = require("pascal-case"); +function camelCaseTransform(input, index) { + if (index === 0) + return input.toLowerCase(); + return pascal_case_1.pascalCaseTransform(input, index); +} +exports.camelCaseTransform = camelCaseTransform; +function camelCaseTransformMerge(input, index) { + if (index === 0) + return input.toLowerCase(); + return pascal_case_1.pascalCaseTransformMerge(input); +} +exports.camelCaseTransformMerge = camelCaseTransformMerge; +function camelCase(input, options) { + if (options === void 0) { options = {}; } + return pascal_case_1.pascalCase(input, tslib_1.__assign({ transform: camelCaseTransform }, options)); +} +exports.camelCase = camelCase; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/igv_component/node_modules/camel-case/dist/index.js.map b/igv_component/node_modules/camel-case/dist/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..2636e6678e20b6e9551f0098030736bde87805e3 --- /dev/null +++ b/igv_component/node_modules/camel-case/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,2CAKqB;AAIrB,SAAgB,kBAAkB,CAAC,KAAa,EAAE,KAAa;IAC7D,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;IAC5C,OAAO,iCAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC3C,CAAC;AAHD,gDAGC;AAED,SAAgB,uBAAuB,CAAC,KAAa,EAAE,KAAa;IAClE,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;IAC5C,OAAO,sCAAwB,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC;AAHD,0DAGC;AAED,SAAgB,SAAS,CAAC,KAAa,EAAE,OAAqB;IAArB,wBAAA,EAAA,YAAqB;IAC5D,OAAO,wBAAU,CAAC,KAAK,qBACrB,SAAS,EAAE,kBAAkB,IAC1B,OAAO,EACV,CAAC;AACL,CAAC;AALD,8BAKC","sourcesContent":["import {\n pascalCase,\n pascalCaseTransform,\n pascalCaseTransformMerge,\n Options,\n} from \"pascal-case\";\n\nexport { Options };\n\nexport function camelCaseTransform(input: string, index: number) {\n if (index === 0) return input.toLowerCase();\n return pascalCaseTransform(input, index);\n}\n\nexport function camelCaseTransformMerge(input: string, index: number) {\n if (index === 0) return input.toLowerCase();\n return pascalCaseTransformMerge(input);\n}\n\nexport function camelCase(input: string, options: Options = {}) {\n return pascalCase(input, {\n transform: camelCaseTransform,\n ...options,\n });\n}\n"]} \ No newline at end of file diff --git a/igv_component/node_modules/camel-case/dist/index.spec.d.ts b/igv_component/node_modules/camel-case/dist/index.spec.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb0ff5c3b541f646105198ee23ac0fc3d805023e --- /dev/null +++ b/igv_component/node_modules/camel-case/dist/index.spec.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/igv_component/node_modules/camel-case/dist/index.spec.js b/igv_component/node_modules/camel-case/dist/index.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..7826a52741de0f006397f18f14ff19d13313b14f --- /dev/null +++ b/igv_component/node_modules/camel-case/dist/index.spec.js @@ -0,0 +1,26 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var _1 = require("."); +var TEST_CASES = [ + ["", ""], + ["test", "test"], + ["test string", "testString"], + ["Test String", "testString"], + ["TestV2", "testV2"], + ["_foo_bar_", "fooBar"], + ["version 1.2.10", "version_1_2_10"], + ["version 1.21.0", "version_1_21_0"], + ["version 1.2.10", "version1210", { transform: _1.camelCaseTransformMerge }], +]; +describe("camel case", function () { + var _loop_1 = function (input, result, options) { + it(input + " -> " + result, function () { + expect(_1.camelCase(input, options)).toEqual(result); + }); + }; + for (var _i = 0, TEST_CASES_1 = TEST_CASES; _i < TEST_CASES_1.length; _i++) { + var _a = TEST_CASES_1[_i], input = _a[0], result = _a[1], options = _a[2]; + _loop_1(input, result, options); + } +}); +//# sourceMappingURL=index.spec.js.map \ No newline at end of file diff --git a/igv_component/node_modules/camel-case/dist/index.spec.js.map b/igv_component/node_modules/camel-case/dist/index.spec.js.map new file mode 100644 index 0000000000000000000000000000000000000000..44f7e9260e6e614fe2c74d2d293a16de2c013d72 --- /dev/null +++ b/igv_component/node_modules/camel-case/dist/index.spec.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.spec.js","sourceRoot":"","sources":["../src/index.spec.ts"],"names":[],"mappings":";;AAAA,sBAAgE;AAEhE,IAAM,UAAU,GAAiC;IAC/C,CAAC,EAAE,EAAE,EAAE,CAAC;IACR,CAAC,MAAM,EAAE,MAAM,CAAC;IAChB,CAAC,aAAa,EAAE,YAAY,CAAC;IAC7B,CAAC,aAAa,EAAE,YAAY,CAAC;IAC7B,CAAC,QAAQ,EAAE,QAAQ,CAAC;IACpB,CAAC,WAAW,EAAE,QAAQ,CAAC;IACvB,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IACpC,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IACpC,CAAC,gBAAgB,EAAE,aAAa,EAAE,EAAE,SAAS,EAAE,0BAAuB,EAAE,CAAC;CAC1E,CAAC;AAEF,QAAQ,CAAC,YAAY,EAAE;4BACT,KAAK,EAAE,MAAM,EAAE,OAAO;QAChC,EAAE,CAAI,KAAK,YAAO,MAAQ,EAAE;YAC1B,MAAM,CAAC,YAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;;IAHL,KAAuC,UAAU,EAAV,yBAAU,EAAV,wBAAU,EAAV,IAAU;QAAtC,IAAA,qBAAwB,EAAvB,KAAK,QAAA,EAAE,MAAM,QAAA,EAAE,OAAO,QAAA;gBAAtB,KAAK,EAAE,MAAM,EAAE,OAAO;KAIjC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { camelCase, camelCaseTransformMerge, Options } from \".\";\n\nconst TEST_CASES: [string, string, Options?][] = [\n [\"\", \"\"],\n [\"test\", \"test\"],\n [\"test string\", \"testString\"],\n [\"Test String\", \"testString\"],\n [\"TestV2\", \"testV2\"],\n [\"_foo_bar_\", \"fooBar\"],\n [\"version 1.2.10\", \"version_1_2_10\"],\n [\"version 1.21.0\", \"version_1_21_0\"],\n [\"version 1.2.10\", \"version1210\", { transform: camelCaseTransformMerge }],\n];\n\ndescribe(\"camel case\", () => {\n for (const [input, result, options] of TEST_CASES) {\n it(`${input} -> ${result}`, () => {\n expect(camelCase(input, options)).toEqual(result);\n });\n }\n});\n"]} \ No newline at end of file diff --git a/igv_component/node_modules/camel-case/package.json b/igv_component/node_modules/camel-case/package.json new file mode 100644 index 0000000000000000000000000000000000000000..28644308dcf16c5f5ce34e72134d03bd38f4358d --- /dev/null +++ b/igv_component/node_modules/camel-case/package.json @@ -0,0 +1,89 @@ +{ + "name": "camel-case", + "version": "4.1.2", + "description": "Transform into a string with the separator denoted by the next word capitalized", + "main": "dist/index.js", + "typings": "dist/index.d.ts", + "module": "dist.es2015/index.js", + "sideEffects": false, + "jsnext:main": "dist.es2015/index.js", + "files": [ + "dist/", + "dist.es2015/", + "LICENSE" + ], + "scripts": { + "lint": "tslint \"src/**/*\" --project tsconfig.json", + "build": "rimraf dist/ dist.es2015/ && tsc && tsc -P tsconfig.es2015.json", + "specs": "jest --coverage", + "test": "npm run build && npm run lint && npm run specs", + "size": "size-limit", + "prepare": "npm run build" + }, + "repository": { + "type": "git", + "url": "git://github.com/blakeembrey/change-case.git" + }, + "keywords": [ + "camel", + "case", + "camelcase", + "camel-case", + "convert", + "transform", + "identifier" + ], + "author": { + "name": "Blake Embrey", + "email": "hello@blakeembrey.com", + "url": "http://blakeembrey.me" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/blakeembrey/change-case/issues" + }, + "homepage": "https://github.com/blakeembrey/change-case/tree/master/packages/camel-case#readme", + "size-limit": [ + { + "path": "dist/index.js", + "limit": "450 B" + } + ], + "jest": { + "roots": [ + "/src/" + ], + "transform": { + "\\.tsx?$": "ts-jest" + }, + "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(tsx?|jsx?)$", + "moduleFileExtensions": [ + "ts", + "tsx", + "js", + "jsx", + "json", + "node" + ] + }, + "publishConfig": { + "access": "public" + }, + "dependencies": { + "pascal-case": "^3.1.2", + "tslib": "^2.0.3" + }, + "devDependencies": { + "@size-limit/preset-small-lib": "^2.2.1", + "@types/jest": "^24.0.23", + "@types/node": "^12.12.14", + "jest": "^24.9.0", + "rimraf": "^3.0.0", + "ts-jest": "^24.2.0", + "tslint": "^5.20.1", + "tslint-config-prettier": "^1.18.0", + "tslint-config-standard": "^9.0.0", + "typescript": "^4.1.2" + }, + "gitHead": "76a21a7f6f2a226521ef6abd345ff309cbd01fb0" +} diff --git a/igv_component/node_modules/clean-css/History.md b/igv_component/node_modules/clean-css/History.md new file mode 100644 index 0000000000000000000000000000000000000000..be890f19769786adee4dfb5ccbdb5cdff7366a73 --- /dev/null +++ b/igv_component/node_modules/clean-css/History.md @@ -0,0 +1,1504 @@ +[5.3.3 / 2023-11-30](https://github.com/clean-css/clean-css/compare/v5.3.2...v5.3.3) +================== + +* Fixed issue [#1262](https://github.com/clean-css/clean-css/issues/1262) - dynamically require os for edge runtime compatibility. + +[5.3.2 / 2023-01-19](https://github.com/clean-css/clean-css/compare/v5.3.1...v5.3.2) +================== + +* Fixed issue [#1224](https://github.com/clean-css/clean-css/issues/1224) - incorrect parsing of selectors with double hyphen. +* Fixed issue [#1228](https://github.com/clean-css/clean-css/issues/1228) - incorrect appending of '%' inside rgba colors. +* Fixed issue [#1232](https://github.com/clean-css/clean-css/issues/1232) - support for `@container` keyword. +* Fixed issue [#1239](https://github.com/clean-css/clean-css/issues/1239) - edge case in handling `@import` statements. +* Fixed issue [#1242](https://github.com/clean-css/clean-css/issues/1242) - support for `@layer` keyword. + +[5.3.1 / 2022-07-13](https://github.com/clean-css/clean-css/compare/v5.3.0...v5.3.1) +================== + +* Fixed issue [#1218](https://github.com/clean-css/clean-css/issues/1218) - double hyphen in at-rule breaks parsing. +* Fixed issue [#1220](https://github.com/clean-css/clean-css/issues/1220) - adds optimization for nth-* rules. + +[5.3.0 / 2022-03-31](https://github.com/clean-css/clean-css/compare/v5.2.3...v5.3.0) +================== + +* Adds customizable value optimizers for variables. +* Fixed issue [#1159](https://github.com/clean-css/clean-css/issues/1159) - adds optimization for `nth-child` and `nth-of-type`. +* Fixed issue [#1181](https://github.com/clean-css/clean-css/issues/1181) - CSS level 4 color functions with spaces. +* Fixed issue [#1183](https://github.com/clean-css/clean-css/issues/1183) - fraction optimizer breaks `image-set`. +* Fixed issue [#1208](https://github.com/clean-css/clean-css/issues/1208) - handling generic family names. +* Fixed issue [#1210](https://github.com/clean-css/clean-css/issues/1210) - handling `file://` protocol. + +[5.2.4 / 2022-01-28](https://github.com/clean-css/clean-css/compare/v5.2.3...v5.2.4) +================== + +* Fixed issue [#1196](https://github.com/clean-css/clean-css/issues/1196) - correctly parse variables & comments mix. + +[5.2.3 / 2022-01-26](https://github.com/clean-css/clean-css/compare/v5.2.2...v5.2.3) +================== + +* Fixed issue [#1185](https://github.com/clean-css/clean-css/issues/1185) - keeping comments inside variables. +* Fixed issue [#1194](https://github.com/clean-css/clean-css/issues/1194) - unexpected end of JSON input when source map is empty. + +[5.2.2 / 2021-10-21](https://github.com/clean-css/clean-css/compare/v5.2.1...v5.2.2) +================== + +* Fixed an unsafe data URI regex, which, when clean-css is used as a service, could be used in a DOS attack. + +[5.2.1 / 2021-09-30](https://github.com/clean-css/clean-css/compare/v5.2.0...v5.2.1) +================== + +* Fixed issue [#1186](https://github.com/clean-css/clean-css/issues/1186) - bad error handling in batch mode with promises. + +[5.2.0 / 2021-09-25](https://github.com/clean-css/clean-css/compare/5.1...v5.2.0) +================== + +* Fixed issue [#1180](https://github.com/clean-css/clean-css/issues/1180) - properly handle empty variable values. + +[5.1.5 / 2021-08-05](https://github.com/clean-css/clean-css/compare/v5.1.4...v5.1.5) +================== + +* Fixed issue [#1178](https://github.com/clean-css/clean-css/issues/1178) - fixes lack of space removal in variable blocks. + +[5.1.4 / 2021-07-29](https://github.com/clean-css/clean-css/compare/v5.1.3...v5.1.4) +================== + +* Fixed issue [#1177](https://github.com/clean-css/clean-css/issues/1177) - fix to missing local imports when only remote ones allowed. + +[5.1.3 / 2021-06-25](https://github.com/clean-css/clean-css/compare/v5.1.2...v5.1.3) +================== + +* Fixed issue [#1160](https://github.com/clean-css/clean-css/issues/1160) - keep zero units when inside multiple functions. +* Fixed issue [#1161](https://github.com/clean-css/clean-css/issues/1161) - extra whitespace in URLs. +* Fixed issue [#1166](https://github.com/clean-css/clean-css/issues/1166) - incorrect compoment splitting when empty multiplex part. + +[5.1.2 / 2021-03-19](https://github.com/clean-css/clean-css/compare/v5.1.1...v5.1.2) +================== + +* Fixed issue [#996](https://github.com/clean-css/clean-css/issues/996) - space removed from pseudo classes. + +[5.1.1 / 2021-03-03](https://github.com/clean-css/clean-css/compare/v5.1.0...v5.1.1) +================== + +* Fixed issue [#1156](https://github.com/clean-css/clean-css/issues/1156) - invalid hsl/hsla validation in level 2 optimizations. + +[5.1.0 / 2021-02-18](https://github.com/clean-css/clean-css/compare/5.0...v5.1.0) +================== + +* Fixes stripping '%' from inside color functions. +* Improves tokenization speed by ~30%. +* Fixed issue [#1143](https://github.com/clean-css/clean-css/issues/1143) - some missing level 1 value optimizations. + + +[5.0.1 / 2021-01-29](https://github.com/clean-css/clean-css/compare/v5.0.0...v5.0.1) +================== + +* Fixed issue [#1139](https://github.com/clean-css/clean-css/issues/1139) - overriding & merging properties without `canOverride` set. + +[5.0.0 / 2021-01-29](https://github.com/clean-css/clean-css/compare/4.2...v5.0.0) +================== + +* Adds a way process input files without bundling it into one big output file. +* Adds level 1 and level 2 optimization plugins. +* Disables URL rebasing by default. +* Disables URL unquoting by default. +* Drops support for Node.js 6 & 8 to support last 3 Node.js releases: 10, 12, and 14. +* Fixed issue [#889](https://github.com/clean-css/clean-css/issues/889) - whitelisted level 1 optimizations. +* Fixed issue [#975](https://github.com/clean-css/clean-css/issues/975) - incorrect block name optimization. +* Fixed issue [#1009](https://github.com/clean-css/clean-css/issues/1009) - whitespace around comments. +* Fixed issue [#1021](https://github.com/clean-css/clean-css/issues/1021) - allow one- and two-letter property names. +* Fixed issue [#1022](https://github.com/clean-css/clean-css/issues/1022) - merging into shorthands new property positioning. +* Fixed issue [#1032](https://github.com/clean-css/clean-css/issues/1032) - wrong order of merged shorthands with inherit. +* Fixed issue [#1043](https://github.com/clean-css/clean-css/issues/1043) - `calc` fallback removed within other function. +* Fixed issue [#1045](https://github.com/clean-css/clean-css/issues/1045) - non-standard protocol-less URL first slash removed. +* Fixed issue [#1050](https://github.com/clean-css/clean-css/issues/1050) - correctly keeps default animation duration if delay is also set. +* Fixed issue [#1053](https://github.com/clean-css/clean-css/issues/1053) - treats `calc()` as first class width value. +* Fixed issue [#1055](https://github.com/clean-css/clean-css/issues/1055) - supports 4- and 8-character hex with alpha color notation. +* Fixed issue [#1057](https://github.com/clean-css/clean-css/issues/1057) - level 2 optimizations and quoted font family name. +* Fixed issue [#1059](https://github.com/clean-css/clean-css/issues/1059) - animation time units as CSS expressions. +* Fixed issue [#1060](https://github.com/clean-css/clean-css/issues/1060) - variable removed when shorthand's only value. +* Fixed issue [#1062](https://github.com/clean-css/clean-css/issues/1062) - wrong optimization of CSS pseudo-classes with selector list. +* Fixed issue [#1073](https://github.com/clean-css/clean-css/issues/1073) - adds support for non-standard `rpx` units. +* Fixed issue [#1075](https://github.com/clean-css/clean-css/issues/1075) - media merging and variables. +* Fixed issue [#1087](https://github.com/clean-css/clean-css/issues/1087) - allow units with any case. +* Fixed issue [#1088](https://github.com/clean-css/clean-css/issues/1088) - building source maps with source preserved via comments. +* Fixed issue [#1090](https://github.com/clean-css/clean-css/issues/1090) - edge case in merging for `border` and `border-image`. +* Fixed issue [#1103](https://github.com/clean-css/clean-css/issues/1103) - don't allow merging longhand into `unset` shorthand. +* Fixed issue [#1115](https://github.com/clean-css/clean-css/issues/1115) - incorrect multiplex longhand into shorthand merging. +* Fixed issue [#1117](https://github.com/clean-css/clean-css/issues/1117) - don't change zero values inside `min`, `max`, and `clamp` functions. +* Fixed issue [#1122](https://github.com/clean-css/clean-css/issues/1122) - don't wrap data URI in single quotes. +* Fixed issue [#1125](https://github.com/clean-css/clean-css/issues/1125) - quotes stripped from withing `@supports` clause. +* Fixed issue [#1128](https://github.com/clean-css/clean-css/issues/1128) - take variables into account when reordering properties. +* Fixed issue [#1132](https://github.com/clean-css/clean-css/issues/1132) - vendor-prefixed classes inside `:not()`. +* Reworks all level 1 optimizations to conform to plugin style. + +[4.2.3 / 2020-01-28](https://github.com/clean-css/clean-css/compare/v4.2.2...v4.2.3) +================== + +* Fixed issue [#1106](https://github.com/clean-css/clean-css/issues/1106) - regression in handling RGBA/HSLA colors. + +[4.2.2 / 2020-01-25](https://github.com/clean-css/clean-css/compare/v4.2.1...v4.2.2) +================== + +* Fixed error when property block has no value. +* Fixed issue [#1077](https://github.com/clean-css/clean-css/issues/1077) - local fonts with color in name. +* Fixed issue [#1082](https://github.com/clean-css/clean-css/issues/1082) - correctly convert colors if alpha >= 1. +* Fixed issue [#1085](https://github.com/clean-css/clean-css/issues/1085) - prevent unquoting of grid elements. + +[4.2.1 / 2018-08-07](https://github.com/clean-css/clean-css/compare/v4.2.0...v4.2.1) +================== + +* Fixes giving `breakWith` option via a string. + +[4.2.0 / 2018-08-02](https://github.com/clean-css/clean-css/compare/4.1...v4.2.0) +================== + +* Adds `process` method for compatibility with optimize-css-assets-webpack-plugin. +* Fixed issue [#861](https://github.com/clean-css/clean-css/issues/861) - new `transition` property optimizer. +* Fixed issue [#895](https://github.com/clean-css/clean-css/issues/895) - ignoring specific styles. +* Fixed issue [#947](https://github.com/clean-css/clean-css/issues/947) - selector based filtering. +* Fixed issue [#964](https://github.com/clean-css/clean-css/issues/964) - adds configurable line breaks. +* Fixed issue [#986](https://github.com/clean-css/clean-css/issues/986) - level 2 optimizations and CSS 4 colors. +* Fixed issue [#1000](https://github.com/clean-css/clean-css/issues/1000) - carriage return handling in tokenizer. +* Fixed issue [#1038](https://github.com/clean-css/clean-css/issues/1038) - `font-variation-settings` quoting. +* Fixes ReDOS vulnerabilities in validator code. + +[4.1.11 / 2018-03-06](https://github.com/clean-css/clean-css/compare/v4.1.10...v4.1.11) +================== + +* Backports fixes to ReDOS vulnerabilities in validator code. + +[4.1.10 / 2018-03-05](https://github.com/clean-css/clean-css/compare/v4.1.9...v4.1.10) +================== + +* Fixed issue [#988](https://github.com/clean-css/clean-css/issues/988) - edge case in dropping default animation-duration. +* Fixed issue [#989](https://github.com/clean-css/clean-css/issues/989) - edge case in removing unused at rules. +* Fixed issue [#1001](https://github.com/clean-css/clean-css/issues/1001) - corrupted tokenizer state. +* Fixed issue [#1006](https://github.com/clean-css/clean-css/issues/1006) - edge case in handling invalid source maps. +* Fixed issue [#1008](https://github.com/clean-css/clean-css/issues/1008) - edge case in breaking up `font` shorthand. + +[4.1.9 / 2017-09-19](https://github.com/clean-css/clean-css/compare/v4.1.8...v4.1.9) +================== + +* Fixed issue [#971](https://github.com/clean-css/clean-css/issues/971) - edge case in removing unused at rules. + +[4.1.8 / 2017-09-02](https://github.com/clean-css/clean-css/compare/v4.1.7...v4.1.8) +================== + +* Fixed issue [#959](https://github.com/clean-css/clean-css/issues/959) - regression in shortening long hex values. +* Fixed issue [#960](https://github.com/clean-css/clean-css/issues/960) - better explanation of `efficiency` stat. +* Fixed issue [#965](https://github.com/clean-css/clean-css/issues/965) - edge case in parsing comment endings. +* Fixed issue [#966](https://github.com/clean-css/clean-css/issues/966) - remote `@import`s referenced from local ones. + +[4.1.7 / 2017-07-14](https://github.com/clean-css/clean-css/compare/v4.1.6...v4.1.7) +================== + +* Fixed issue [#957](https://github.com/clean-css/clean-css/issues/957) - `0%` minification of `width` property. + +[4.1.6 / 2017-07-08](https://github.com/clean-css/clean-css/compare/v4.1.5...v4.1.6) +================== + +* Fixed issue [#887](https://github.com/clean-css/clean-css/issues/887) - edge case in serializing comments. +* Fixed issue [#953](https://github.com/clean-css/clean-css/issues/953) - beautify breaks attribute selectors. + +[4.1.5 / 2017-06-29](https://github.com/clean-css/clean-css/compare/v4.1.4...v4.1.5) +================== + +* Fixed issue [#945](https://github.com/clean-css/clean-css/issues/945) - hex RGBA colors in IE filters. +* Fixed issue [#952](https://github.com/clean-css/clean-css/issues/952) - parsing `@page` according to CSS3 spec. + +[4.1.4 / 2017-06-14](https://github.com/clean-css/clean-css/compare/v4.1.3...v4.1.4) +================== + +* Fixed issue [#950](https://github.com/clean-css/clean-css/issues/950) - bug in removing unused `@font-face` rules. + +[4.1.3 / 2017-05-18](https://github.com/clean-css/clean-css/compare/v4.1.2...v4.1.3) +================== + +* Fixed issue [#946](https://github.com/clean-css/clean-css/issues/946) - tokenizing `-ms-grid-columns` repeat syntax. + +[4.1.2 / 2017-05-10](https://github.com/clean-css/clean-css/compare/v4.1.1...v4.1.2) +================== + +* Fixed issue [#939](https://github.com/clean-css/clean-css/issues/939) - semicolon after `@apply` at rule. +* Fixed issue [#940](https://github.com/clean-css/clean-css/issues/940) - handling more `font` keywords. +* Fixed issue [#941](https://github.com/clean-css/clean-css/issues/941) - breaking up vendor prefixed `animation`. + +[4.1.1 / 2017-05-08](https://github.com/clean-css/clean-css/compare/v4.1.0...v4.1.1) +================== + +* Fixed issue [#938](https://github.com/clean-css/clean-css/issues/938) - removing unused at-rules with `!important`. + +[4.1.0 / 2017-05-07](https://github.com/clean-css/clean-css/compare/4.0...v4.1.0) +================== + +* Improves longhand-into-shorthand merging mechanism in complex cases as with `border-*` shorthands. +* Fixed issue [#254](https://github.com/clean-css/clean-css/issues/254) - adds `font` property optimizer. +* Fixed issue [#525](https://github.com/clean-css/clean-css/issues/525) - restores `inherit`-based merging. +* Fixed issue [#755](https://github.com/clean-css/clean-css/issues/755) - adds custom handling of remote requests. +* Fixed issue [#860](https://github.com/clean-css/clean-css/issues/860) - adds `animation` property optimizer. +* Fixed issue [#862](https://github.com/clean-css/clean-css/issues/862) - allows removing unused at rules. +* Fixed issue [#886](https://github.com/clean-css/clean-css/issues/886) - better multi pseudo class / element merging. +* Fixed issue [#890](https://github.com/clean-css/clean-css/issues/890) - adds toggle to disable empty tokens removal. +* Fixed issue [#893](https://github.com/clean-css/clean-css/issues/893) - `inline: false` as alias to `inline: 'none'`. +* Fixed issue [#905](https://github.com/clean-css/clean-css/issues/905) - allows disabling selector sorting. +* Fixed issue [#906](https://github.com/clean-css/clean-css/issues/906) - improves usability of web UI settings. +* Fixed issue [#908](https://github.com/clean-css/clean-css/issues/908) - improved `minify` method signature. +* Fixed issue [#916](https://github.com/clean-css/clean-css/issues/916) - maximum number of merged selectors. +* Fixed issue [#920](https://github.com/clean-css/clean-css/issues/920) - allows skipping certain properties in level 2 optimizations. +* Fixed issue [#934](https://github.com/clean-css/clean-css/issues/934) - smarter longhand into shorthand merging. + +[4.0.13 / 2017-05-10](https://github.com/clean-css/clean-css/compare/v4.0.12...v4.0.13) +================== + +* Backports [#939](https://github.com/clean-css/clean-css/issues/939) - semicolon after `@apply` at rule. + +[4.0.12 / 2017-04-12](https://github.com/clean-css/clean-css/compare/v4.0.11...v4.0.12) +================== + +* Fixed issue [#930](https://github.com/clean-css/clean-css/issues/930) - regression in tidying selectors. + +[4.0.11 / 2017-04-04](https://github.com/clean-css/clean-css/compare/v4.0.10...v4.0.11) +================== + +* Fixed issue [#924](https://github.com/clean-css/clean-css/issues/924) - `hsl` zero percent eager optimization. + +[4.0.10 / 2017-03-22](https://github.com/clean-css/clean-css/compare/v4.0.9...v4.0.10) +================== + +* Fixed issue [#917](https://github.com/clean-css/clean-css/issues/917) - prevents grid area unquoting. +* Backported [#916](https://github.com/clean-css/clean-css/issues/916) - maximum number of merged selectors. +* Refixed issue [#556](https://github.com/clean-css/clean-css/issues/556) - IE backslash hacks. + +[4.0.9 / 2017-03-15](https://github.com/clean-css/clean-css/compare/v4.0.8...v4.0.9) +================== + +* Fixed issue [#902](https://github.com/clean-css/clean-css/issues/902) - case insensitive attribute matchers. +* Fixed issue [#903](https://github.com/clean-css/clean-css/issues/903) - web UI and source maps. +* Fixed issue [#907](https://github.com/clean-css/clean-css/issues/907) - space after closing brace in `@supports`. +* Fixed issue [#910](https://github.com/clean-css/clean-css/issues/910) - too aggressive precision optimizations. + +[4.0.8 / 2017-02-22](https://github.com/clean-css/clean-css/compare/v4.0.7...v4.0.8) +================== + +* Fixes edge case in remote stylesheet fetching. +* Fixed issue [#899](https://github.com/clean-css/clean-css/issues/899) - regression in optimizing pseudo class arguments. + +[4.0.7 / 2017-02-14](https://github.com/clean-css/clean-css/compare/v4.0.6...v4.0.7) +================== + +* Fixed issue [#891](https://github.com/clean-css/clean-css/issues/891) - merging vendor-prefixed pseudo-classes. + +[4.0.6 / 2017-02-10](https://github.com/clean-css/clean-css/compare/v4.0.5...v4.0.6) +================== + +* Fixed issue [#885](https://github.com/clean-css/clean-css/issues/885) - unquoting `font-feature-settings`. + +[4.0.5 / 2017-02-07](https://github.com/clean-css/clean-css/compare/v4.0.4...v4.0.5) +================== + +* Fixed issue [#884](https://github.com/clean-css/clean-css/issues/884) - handling absolute paths on Windows. +* Fixed issue [#881](https://github.com/clean-css/clean-css/issues/881) - incorrect `require` arity. +* Fixed issue [#880](https://github.com/clean-css/clean-css/issues/880) - incorrect token type identification. + +[4.0.4 / 2017-02-04](https://github.com/clean-css/clean-css/compare/v4.0.3...v4.0.4) +================== + +* Fixed issue [#879](https://github.com/clean-css/clean-css/issues/879) - incorrect handling of spaces in paths. +* Fixed issue [#878](https://github.com/clean-css/clean-css/issues/878) - invalid double backslash tokenization. + +[4.0.3 / 2017-01-30](https://github.com/clean-css/clean-css/compare/v4.0.2...v4.0.3) +================== + +* Fixed issue [#875](https://github.com/clean-css/clean-css/issues/875) - invalid traversing in semantic merging. + +[4.0.2 / 2017-01-26](https://github.com/clean-css/clean-css/compare/v4.0.1...v4.0.2) +================== + +* Fixed issue [#874](https://github.com/clean-css/clean-css/issues/874) - regression in at-rule tokenization. + +[4.0.1 / 2017-01-25](https://github.com/clean-css/clean-css/compare/v4.0.0...v4.0.1) +================== + +* Fixed issue [#866](https://github.com/clean-css/clean-css/issues/866) - edge case in `inline` option. +* Fixed issue [#867](https://github.com/clean-css/clean-css/issues/867) - skip optimizing variable values. +* Fixed issue [#868](https://github.com/clean-css/clean-css/issues/868) - accept absolute paths in input hash. +* Fixed issue [#872](https://github.com/clean-css/clean-css/issues/872) - edge case in CSS tokenization. + +[4.0.0 / 2017-01-23](https://github.com/clean-css/clean-css/compare/v3.4.24...v4.0.0) +================== + +* Adds more detailed error & warning messages on top of the new tokenizer. +* Disables restructuring optimizations by default until optimized in #533. +* Fixes a bug ignoring incorrect properties in complex restructuring. +* Requires Node.js 4.0+ to run. +* Removes `benchmark` API option as total time is always reported under `stats` property. +* Removes `debug` API switch as stats are always gathered and available under `stats` property. +* Replaces the old tokenizer with a new one which doesn't use any escaping. +* Replaces the old `@import` inlining with one on top of the new tokenizer. +* Re-enables `background-(clip|origin|size)` merging with `background` shorthand. +* Simplifies URL rebasing with a single `rebaseTo` option in API or inferred from `--output` in CLI. +* Splits `inliner` option into `inlineRequest` and `inlineTimeout`. +* Fixed issue [#209](https://github.com/clean-css/clean-css/issues/209) - adds output formatting via `format` flag. +* Fixed issue [#290](https://github.com/clean-css/clean-css/issues/290) - removes aggressive merging. +* Fixed issue [#432](https://github.com/clean-css/clean-css/issues/432) - adds URLs normalization. +* Fixed issue [#460](https://github.com/clean-css/clean-css/issues/460) - unescaped semicolon in selector. +* Fixed issue [#657](https://github.com/clean-css/clean-css/issues/657) - adds property name validation. +* Fixed issue [#685](https://github.com/clean-css/clean-css/issues/685) - adds lowercasing hex colors optimization. +* Fixed issue [#686](https://github.com/clean-css/clean-css/issues/686) - adds rounding precision for all units. +* Fixed issue [#703](https://github.com/clean-css/clean-css/issues/703) - changes default IE compatibility to 10+. +* Fixed issue [#731](https://github.com/clean-css/clean-css/issues/731) - adds granular control over level 2 optimizations. +* Fixed issue [#739](https://github.com/clean-css/clean-css/issues/739) - error when a closing brace is missing. +* Fixed issue [#750](https://github.com/clean-css/clean-css/issues/750) - allows `width` overriding. +* Fixed issue [#756](https://github.com/clean-css/clean-css/issues/756) - adds disabling font-weight optimizations. +* Fixed issue [#758](https://github.com/clean-css/clean-css/issues/758) - ignores rules with empty selector. +* Fixed issue [#767](https://github.com/clean-css/clean-css/issues/767) - disables remote `@import` inlining by default. +* Fixed issue [#773](https://github.com/clean-css/clean-css/issues/773) - adds reordering based on selector specificity. +* Fixed issue [#785](https://github.com/clean-css/clean-css/issues/785) - adds `@font-face` de-duplication. +* Fixed issue [#791](https://github.com/clean-css/clean-css/issues/791) - resolves imports in-memory if possible. +* Fixed issue [#796](https://github.com/clean-css/clean-css/issues/796) - semantic merging for `@media` blocks. +* Fixed issue [#801](https://github.com/clean-css/clean-css/issues/801) - smarter `@import` inlining. +* Fixed issue [#806](https://github.com/clean-css/clean-css/issues/806) - skip optimizing variable properties. +* Fixed issue [#817](https://github.com/clean-css/clean-css/issues/817) - makes `off` disable rounding. +* Fixed issue [#818](https://github.com/clean-css/clean-css/issues/818) - disables `px` rounding by default. +* Fixed issue [#828](https://github.com/clean-css/clean-css/issues/828) - `-chrome-` hack support. +* Fixed issue [#829](https://github.com/clean-css/clean-css/issues/829) - adds more strict selector merging rules. +* Fixed issue [#834](https://github.com/clean-css/clean-css/issues/834) - adds extra line break in nested blocks. +* Fixed issue [#836](https://github.com/clean-css/clean-css/issues/836) - enables level `0` optimizations. +* Fixed issue [#839](https://github.com/clean-css/clean-css/issues/839) - allows URIs in import inlining rules. +* Fixed issue [#840](https://github.com/clean-css/clean-css/issues/840) - allows input source map as map object. +* Fixed issue [#843](https://github.com/clean-css/clean-css/issues/843) - regression in selector handling. +* Fixed issue [#845](https://github.com/clean-css/clean-css/issues/845) - web compatibility of 4.0 branch. +* Fixed issue [#847](https://github.com/clean-css/clean-css/issues/847) - regression in handling invalid selectors. +* Fixed issue [#849](https://github.com/clean-css/clean-css/issues/849) - disables inlining protocol-less resources. +* Fixed issue [#856](https://github.com/clean-css/clean-css/issues/856) - allows `minify` to return a promise. +* Fixed issue [#857](https://github.com/clean-css/clean-css/issues/857) - normalizes CleanCSS API interface. +* Fixed issue [#863](https://github.com/clean-css/clean-css/issues/863) - adds `transform` callback for custom optimizations. + +[3.4.26 / 2017-05-10](https://github.com/clean-css/clean-css/compare/v3.4.25...v3.4.26) +================== + +* Backports [#939](https://github.com/clean-css/clean-css/issues/939) - semicolon after `@apply` at-rule. + +[3.4.25 / 2017-02-22](https://github.com/clean-css/clean-css/compare/v3.4.24...v3.4.25) +================== + +* Fixed issue [#897](https://github.com/clean-css/clean-css/issues/897) - tokenization with escaped markers. + +[3.4.24 / 2017-01-20](https://github.com/clean-css/clean-css/compare/v3.4.23...v3.4.24) +================== + +* Fixed issue [#859](https://github.com/clean-css/clean-css/issues/859) - avoid `-webkit-border-radius` optimizations. + +[3.4.23 / 2016-12-17](https://github.com/clean-css/clean-css/compare/v3.4.22...v3.4.23) +================== + +* Fixed issue [#844](https://github.com/clean-css/clean-css/issues/844) - regression in property values extraction. + +[3.4.22 / 2016-12-12](https://github.com/clean-css/clean-css/compare/v3.4.21...v3.4.22) +================== + +* Fixed issue [#841](https://github.com/clean-css/clean-css/issues/841) - disabled importing and files passed as array. +* Ignores `@import` at-rules if appearing after any non-`@import` rules. + +[3.4.21 / 2016-11-16](https://github.com/clean-css/clean-css/compare/v3.4.20...v3.4.21) +================== + +* Fixed issue [#821](https://github.com/clean-css/clean-css/issues/821) - reducing non-adjacent rules. +* Fixed issue [#830](https://github.com/clean-css/clean-css/issues/830) - reordering border-* properties. +* Fixed issue [#833](https://github.com/clean-css/clean-css/issues/833) - moving `@media` queries. + +[3.4.20 / 2016-09-26](https://github.com/clean-css/clean-css/compare/v3.4.19...v3.4.20) +================== + +* Fixed issue [#814](https://github.com/clean-css/clean-css/issues/814) - `:selection` rule merging. + +[3.4.19 / 2016-07-25](https://github.com/clean-css/clean-css/compare/v3.4.18...v3.4.19) +================== + +* Fixed issue [#795](https://github.com/clean-css/clean-css/issues/795) - `!important` and override compacting. + +[3.4.18 / 2016-06-15](https://github.com/clean-css/clean-css/compare/v3.4.17...v3.4.18) +================== + +* Fixed issue [#787](https://github.com/clean-css/clean-css/issues/787) - regression in processing data URIs. + +[3.4.17 / 2016-06-04](https://github.com/clean-css/clean-css/compare/v3.4.16...v3.4.17) +================== + +* Fixed issue [#783](https://github.com/clean-css/clean-css/issues/783) - regression in processing data URIs. + +[3.4.16 / 2016-06-02](https://github.com/clean-css/clean-css/compare/v3.4.15...v3.4.16) +================== + +* Fixed issue [#781](https://github.com/clean-css/clean-css/issues/781) - regression in override compacting. +* Fixed issue [#782](https://github.com/clean-css/clean-css/issues/782) - regression in processing data URIs. + +[3.4.15 / 2016-06-01](https://github.com/clean-css/clean-css/compare/v3.4.14...v3.4.15) +================== + +* Fixed issue [#776](https://github.com/clean-css/clean-css/issues/776) - edge case in quoted data URIs. +* Fixed issue [#779](https://github.com/clean-css/clean-css/issues/779) - merging `background-(position|size)`. +* Fixed issue [#780](https://github.com/clean-css/clean-css/issues/780) - space after inlined variables. + +[3.4.14 / 2016-05-31](https://github.com/clean-css/clean-css/compare/v3.4.13...v3.4.14) +================== + +* Fixed issue [#751](https://github.com/clean-css/clean-css/issues/751) - stringifying CSS variables. +* Fixed issue [#763](https://github.com/clean-css/clean-css/issues/763) - data URI SVG and quoting. +* Fixed issue [#765](https://github.com/clean-css/clean-css/issues/765) - two values of border-radius. +* Fixed issue [#768](https://github.com/clean-css/clean-css/issues/768) - invalid border-radius property. + +[3.4.13 / 2016-05-23](https://github.com/clean-css/clean-css/compare/v3.4.12...v3.4.13) +================== + +* Fixed issue [#734](https://github.com/clean-css/clean-css/issues/769) - Node.js 6.x support. + +[3.4.12 / 2016-04-09](https://github.com/clean-css/clean-css/compare/v3.4.11...v3.4.12) +================== + +* Fixed issue [#734](https://github.com/clean-css/clean-css/issues/734) - `--root` option edge case. +* Fixed issue [#758](https://github.com/clean-css/clean-css/issues/758) - treats empty rule as unmergeable. + +[3.4.11 / 2016-04-01](https://github.com/clean-css/clean-css/compare/v3.4.10...v3.4.11) +================== + +* Fixed issue [#738](https://github.com/clean-css/clean-css/issues/738) - edge case in comment processing. +* Fixed issue [#741](https://github.com/clean-css/clean-css/issues/741) - HTTP proxy with HTTPS inlining. +* Fixed issue [#743](https://github.com/clean-css/clean-css/issues/743) - background shorthand and source maps. +* Fixed issue [#745](https://github.com/clean-css/clean-css/issues/745) - matching mixed case `!important`. + +[3.4.10 / 2016-02-29](https://github.com/clean-css/clean-css/compare/v3.4.9...v3.4.10) +================== + +* Fixed issue [#735](https://github.com/clean-css/clean-css/issues/735) - whitespace removal with escaped chars. + +[3.4.9 / 2016-01-03](https://github.com/clean-css/clean-css/compare/v3.4.8...v3.4.9) +================== + +* Sped up merging by body advanced optimization. +* Fixed issue [#693](https://github.com/clean-css/clean-css/issues/693) - restructuring edge case. +* Fixed issue [#711](https://github.com/clean-css/clean-css/issues/711) - border fuzzy matching. +* Fixed issue [#714](https://github.com/clean-css/clean-css/issues/714) - stringifying property level at rules. +* Fixed issue [#715](https://github.com/clean-css/clean-css/issues/715) - stack too deep in comment scan. + +[3.4.8 / 2015-11-13](https://github.com/clean-css/clean-css/compare/v3.4.7...v3.4.8) +================== + +* Fixed issue [#676](https://github.com/clean-css/clean-css/issues/676) - fuzzy matching unqoted data URIs. + +[3.4.7 / 2015-11-10](https://github.com/clean-css/clean-css/compare/v3.4.6...v3.4.7) +================== + +* Fixed issue [#692](https://github.com/clean-css/clean-css/issues/692) - edge case in URL quoting. +* Fixed issue [#695](https://github.com/clean-css/clean-css/issues/695) - shorthand overriding edge case. +* Fixed issue [#699](https://github.com/clean-css/clean-css/issues/699) - IE9 transparent hack. +* Fixed issue [#701](https://github.com/clean-css/clean-css/issues/701) - `url` quoting with hash arguments. + +[3.4.6 / 2015-10-14](https://github.com/clean-css/clean-css/compare/v3.4.5...v3.4.6) +================== + +* Fixed issue [#679](https://github.com/clean-css/clean-css/issues/679) - wrong rebasing of remote URLs. + +[3.4.5 / 2015-09-28](https://github.com/clean-css/clean-css/compare/v3.4.4...v3.4.5) +================== + +* Fixed issue [#681](https://github.com/clean-css/clean-css/issues/681) - property inheritance & restructuring. +* Fixed issue [#675](https://github.com/clean-css/clean-css/issues/675) - overriding with `!important`. + +[3.4.4 / 2015-09-21](https://github.com/clean-css/clean-css/compare/v3.4.3...v3.4.4) +================== + +* Fixed issue [#626](https://github.com/clean-css/clean-css/issues/626) - edge case in import rebasing. +* Fixed issue [#674](https://github.com/clean-css/clean-css/issues/674) - adjacent merging order. + +[3.4.3 / 2015-09-15](https://github.com/clean-css/clean-css/compare/v3.4.2...v3.4.3) +================== + +* Fixed issue [#668](https://github.com/clean-css/clean-css/issues/668) - node v4 path.join. +* Fixed issue [#669](https://github.com/clean-css/clean-css/issues/669) - adjacent overriding with `!important`. + +[3.4.2 / 2015-09-14](https://github.com/clean-css/clean-css/compare/v3.4.1...v3.4.2) +================== + +* Fixed issue [#598](https://github.com/clean-css/clean-css/issues/598) - restructuring border properties. +* Fixed issue [#654](https://github.com/clean-css/clean-css/issues/654) - disables length optimizations. +* Fixed issue [#655](https://github.com/clean-css/clean-css/issues/655) - shorthands override merging. +* Fixed issue [#660](https://github.com/clean-css/clean-css/issues/660) - !important token overriding. +* Fixed issue [#662](https://github.com/clean-css/clean-css/issues/662) - !important selector reducing. +* Fixed issue [#667](https://github.com/clean-css/clean-css/issues/667) - rebasing remote URLs. + +[3.4.1 / 2015-08-27](https://github.com/clean-css/clean-css/compare/v3.4.0...v3.4.1) +================== + +* Fixed issue [#652](https://github.com/clean-css/clean-css/issues/652) - order of restoring and removing tokens. + +[3.4.0 / 2015-08-27](https://github.com/clean-css/clean-css/compare/v3.3.10...v3.4.0) +================== + +* Adds an option for a fine-grained `@import` control. +* Adds unit compatibility switches to disable length optimizations. +* Adds inferring proxy settings from HTTP_PROXY environment variable. +* Adds support for Polymer / Web Components special selectors. +* Adds support for Polymer mixins. +* Adds testing source maps in batch mode. +* Unifies wrappers for simple & advanced optimizations. +* Fixed issue [#596](https://github.com/clean-css/clean-css/issues/596) - support for !ie IE<8 hack. +* Fixed issue [#599](https://github.com/clean-css/clean-css/issues/599) - support for inlined source maps. +* Fixed issue [#607](https://github.com/clean-css/clean-css/issues/607) - adds better rule reordering. +* Fixed issue [#612](https://github.com/clean-css/clean-css/issues/612) - adds HTTP proxy support. +* Fixed issue [#618](https://github.com/clean-css/clean-css/issues/618) - adds safer function validation. +* Fixed issue [#625](https://github.com/clean-css/clean-css/issues/625) - adds length unit optimizations. +* Fixed issue [#632](https://github.com/clean-css/clean-css/issues/632) - adds disabling remote `import`s. +* Fixed issue [#635](https://github.com/clean-css/clean-css/issues/635) - adds safer `0%` optimizations. +* Fixed issue [#644](https://github.com/clean-css/clean-css/issues/644) - adds time unit optimizations. +* Fixed issue [#645](https://github.com/clean-css/clean-css/issues/645) - adds bottom to top `media` merging. +* Fixed issue [#648](https://github.com/clean-css/clean-css/issues/648) - adds property level at-rule support. + +[3.3.10 / 2015-08-27](https://github.com/clean-css/clean-css/compare/v3.3.9...v3.3.10) +================== + +* Adds better comments + keepBreaks handling. +* Adds better text normalizing in source maps mode. +* Fixes non-adjacent optimizations for source maps. +* Fixes removing unused items. +* Improves `outline` break up with source maps. +* Refixed issue [#629](https://github.com/clean-css/clean-css/issues/629) - source maps & background shorthands. + +[3.3.9 / 2015-08-09](https://github.com/clean-css/clean-css/compare/v3.3.8...v3.3.9) +================== + +* Fixed issue [#640](https://github.com/clean-css/clean-css/issues/640) - URI processing regression. + +[3.3.8 / 2015-08-06](https://github.com/clean-css/clean-css/compare/v3.3.7...v3.3.8) +================== + +* Fixed issue [#629](https://github.com/clean-css/clean-css/issues/629) - source maps & background shorthands. +* Fixed issue [#630](https://github.com/clean-css/clean-css/issues/630) - vendor prefixed flex optimizations. +* Fixed issue [#633](https://github.com/clean-css/clean-css/issues/633) - handling data URI with brackets. +* Fixed issue [#634](https://github.com/clean-css/clean-css/issues/634) - merging :placeholder selectors. + +[3.3.7 / 2015-07-29](https://github.com/clean-css/clean-css/compare/v3.3.6...v3.3.7) +================== + +* Fixed issue [#616](https://github.com/clean-css/clean-css/issues/616) - ordering in restructuring. + +[3.3.6 / 2015-07-14](https://github.com/clean-css/clean-css/compare/v3.3.5...v3.3.6) +================== + +* Fixed issue [#620](https://github.com/clean-css/clean-css/issues/620) - `bold` style in font shorthands. + +[3.3.5 / 2015-07-01](https://github.com/clean-css/clean-css/compare/v3.3.4...v3.3.5) +================== + +* Fixed issue [#608](https://github.com/clean-css/clean-css/issues/608) - custom URI protocols handling. + +[3.3.4 / 2015-06-24](https://github.com/clean-css/clean-css/compare/v3.3.3...v3.3.4) +================== + +* Fixed issue [#610](https://github.com/clean-css/clean-css/issues/610) - `border:inherit` restoring. +* Fixed issue [#611](https://github.com/clean-css/clean-css/issues/611) - edge case in quote stripping. + +[3.3.3 / 2015-06-16](https://github.com/clean-css/clean-css/compare/v3.3.2...v3.3.3) +================== + +* Fixed issue [#603](https://github.com/clean-css/clean-css/issues/603) - IE suffix hack defaults to on. + +[3.3.2 / 2015-06-14](https://github.com/clean-css/clean-css/compare/v3.3.1...v3.3.2) +================== + +* Fixed issue [#595](https://github.com/clean-css/clean-css/issues/595) - more relaxed block matching. +* Fixed issue [#601](https://github.com/clean-css/clean-css/issues/601) - percentage minifying inside `flex`. +* Fixed issue [#602](https://github.com/clean-css/clean-css/issues/602) - backslash IE hacks after a space. + +[3.3.1 / 2015-06-02](https://github.com/clean-css/clean-css/compare/v3.3.0...v3.3.1) +================== + +* Fixed issue [#590](https://github.com/clean-css/clean-css/issues/590) - edge case in `@import` processing. + +[3.3.0 / 2015-05-31](https://github.com/clean-css/clean-css/compare/v3.2.11...v3.3.0) +================== + +* Cleans up url rebase code getting rid of unnecessary state. +* Cleans up tokenizer code getting rid of unnecessary state. +* Moves source maps tracker into lib/source-maps/track. +* Moves tokenizer code into lib/tokenizer. +* Moves URL scanner into lib/urls/reduce (was named incorrectly before). +* Moves URL rebasing & rewriting into lib/urls. +* Fixed issue [#375](https://github.com/clean-css/clean-css/issues/375) - unit compatibility switches. +* Fixed issue [#436](https://github.com/clean-css/clean-css/issues/436) - refactors URI rewriting. +* Fixed issue [#448](https://github.com/clean-css/clean-css/issues/448) - rebasing no protocol URIs. +* Fixed issue [#517](https://github.com/clean-css/clean-css/issues/517) - turning off color optimizations. +* Fixed issue [#542](https://github.com/clean-css/clean-css/issues/542) - space after closing brace in IE. +* Fixed issue [#562](https://github.com/clean-css/clean-css/issues/562) - optimizing invalid color values. +* Fixed issue [#563](https://github.com/clean-css/clean-css/issues/563) - `background:inherit` restoring. +* Fixed issue [#570](https://github.com/clean-css/clean-css/issues/570) - rebasing "no-url()" imports. +* Fixed issue [#574](https://github.com/clean-css/clean-css/issues/574) - rewriting internal URLs. +* Fixed issue [#575](https://github.com/clean-css/clean-css/issues/575) - missing directory as a `target`. +* Fixed issue [#577](https://github.com/clean-css/clean-css/issues/577) - `background-clip` into shorthand. +* Fixed issue [#579](https://github.com/clean-css/clean-css/issues/579) - `background-origin` into shorthand. +* Fixed issue [#580](https://github.com/clean-css/clean-css/issues/580) - mixed `@import` processing. +* Fixed issue [#582](https://github.com/clean-css/clean-css/issues/582) - overriding with prefixed values. +* Fixed issue [#583](https://github.com/clean-css/clean-css/issues/583) - URL quoting for SVG data. +* Fixed issue [#587](https://github.com/clean-css/clean-css/issues/587) - too aggressive `border` reordering. + +[3.2.11 / 2015-05-31](https://github.com/clean-css/clean-css/compare/v3.2.10...v3.2.11) +================== + +* Fixed issue [#563](https://github.com/clean-css/clean-css/issues/563) - `background:inherit` restoring. +* Fixed issue [#582](https://github.com/clean-css/clean-css/issues/582) - overriding with prefixed values. +* Fixed issue [#583](https://github.com/clean-css/clean-css/issues/583) - URL quoting for SVG data. +* Fixed issue [#587](https://github.com/clean-css/clean-css/issues/587) - too aggressive `border` reordering. + +[3.2.10 / 2015-05-14](https://github.com/clean-css/clean-css/compare/v3.2.9...v3.2.10) +================== + +* Fixed issue [#572](https://github.com/clean-css/clean-css/issues/572) - empty elements removal. + +[3.2.9 / 2015-05-08](https://github.com/clean-css/clean-css/compare/v3.2.8...v3.2.9) +================== + +* Fixed issue [#567](https://github.com/clean-css/clean-css/issues/567) - merging colors as functions. + +[3.2.8 / 2015-05-04](https://github.com/clean-css/clean-css/compare/v3.2.7...v3.2.8) +================== + +* Fixed issue [#561](https://github.com/clean-css/clean-css/issues/561) - restructuring special selectors. + +[3.2.7 / 2015-05-03](https://github.com/clean-css/clean-css/compare/v3.2.6...v3.2.7) +================== + +* Fixed issue [#551](https://github.com/clean-css/clean-css/issues/551) - edge case in restructuring. +* Fixed issue [#553](https://github.com/clean-css/clean-css/issues/553) - another style of SVG fallback. +* Fixed issue [#558](https://github.com/clean-css/clean-css/issues/558) - units in same selector merging. + +[3.2.6 / 2015-04-28](https://github.com/clean-css/clean-css/compare/v3.2.5...v3.2.6) +================== + +* Fixed issue [#550](https://github.com/clean-css/clean-css/issues/550) - proper `contentSources` tracking. +* Fixed issue [#556](https://github.com/clean-css/clean-css/issues/556) - regression in IE backslash hacks. + +[3.2.5 / 2015-04-25](https://github.com/clean-css/clean-css/compare/v3.2.4...v3.2.5) +================== + +* Fixed issue [#543](https://github.com/clean-css/clean-css/issues/543) - better "comment in body" handling. +* Fixed issue [#548](https://github.com/clean-css/clean-css/issues/548) - regression in font minifying. +* Fixed issue [#549](https://github.com/clean-css/clean-css/issues/549) - special comments in source maps. + +[3.2.4 / 2015-04-24](https://github.com/clean-css/clean-css/compare/v3.2.3...v3.2.4) +================== + +* Fixed issue [#544](https://github.com/clean-css/clean-css/issues/544) - regression in same value merging. +* Fixed issue [#546](https://github.com/clean-css/clean-css/issues/546) - IE<11 `calc()` issue. + +[3.2.3 / 2015-04-22](https://github.com/clean-css/clean-css/compare/v3.2.2...v3.2.3) +================== + +* Fixed issue [#541](https://github.com/clean-css/clean-css/issues/541) - `outline-style:auto` in shorthand. + +[3.2.2 / 2015-04-21](https://github.com/clean-css/clean-css/compare/v3.2.1...v3.2.2) +================== + +* Fixed issue [#537](https://github.com/clean-css/clean-css/issues/537) - regression in simple optimizer. + +[3.2.1 / 2015-04-20](https://github.com/clean-css/clean-css/compare/v3.2.0...v3.2.1) +================== + +* Fixed issue [#534](https://github.com/clean-css/clean-css/issues/534) - wrong `@font-face` stringifying. + +[3.2.0 / 2015-04-19](https://github.com/clean-css/clean-css/compare/v3.1.9...v3.2.0) +================== + +* Bumps commander to 2.8.x. +* Fixes remote asset rebasing when passing data as a hash. +* Improves path resolution inside source maps. +* Makes `root` option implicitely default to `process.cwd()`. +* Fixed issue [#371](https://github.com/clean-css/clean-css/issues/371) - `background` fallback with `none`. +* Fixed issue [#376](https://github.com/clean-css/clean-css/issues/376) - option to disable `0[unit]` -> `0`. +* Fixed issue [#396](https://github.com/clean-css/clean-css/issues/396) - better input source maps tracking. +* Fixed issue [#397](https://github.com/clean-css/clean-css/issues/397) - support for source map sources. +* Fixed issue [#399](https://github.com/clean-css/clean-css/issues/399) - support compacting with source maps. +* Fixed issue [#429](https://github.com/clean-css/clean-css/issues/429) - unifies data tokenization. +* Fixed issue [#446](https://github.com/clean-css/clean-css/issues/446) - `list-style` fuzzy matching. +* Fixed issue [#468](https://github.com/clean-css/clean-css/issues/468) - bumps `source-map` to 0.4.x. +* Fixed issue [#480](https://github.com/clean-css/clean-css/issues/480) - extracting uppercase property names. +* Fixed issue [#487](https://github.com/clean-css/clean-css/issues/487) - source map paths under Windows. +* Fixed issue [#490](https://github.com/clean-css/clean-css/issues/490) - vendor prefixed multivalue `background`. +* Fixed issue [#500](https://github.com/clean-css/clean-css/issues/500) - merging duplicate adjacent properties. +* Fixed issue [#504](https://github.com/clean-css/clean-css/issues/504) - keeping `url()` quotes. +* Fixed issue [#507](https://github.com/clean-css/clean-css/issues/507) - merging longhands into many shorthands. +* Fixed issue [#508](https://github.com/clean-css/clean-css/issues/508) - removing duplicate media queries. +* Fixed issue [#521](https://github.com/clean-css/clean-css/issues/521) - unit optimizations inside `calc()`. +* Fixed issue [#524](https://github.com/clean-css/clean-css/issues/524) - timeouts in `@import` inlining. +* Fixed issue [#526](https://github.com/clean-css/clean-css/issues/526) - shorthand overriding into a function. +* Fixed issue [#528](https://github.com/clean-css/clean-css/issues/528) - better support for IE<9 hacks. +* Fixed issue [#529](https://github.com/clean-css/clean-css/issues/529) - wrong font weight minification. + +[3.1.9 / 2015-04-04](https://github.com/clean-css/clean-css/compare/v3.1.8...v3.1.9) +================== + +* Fixes issue [#511](https://github.com/clean-css/clean-css/issues/511) - `)` advanced processing. + +[3.1.8 / 2015-03-17](https://github.com/clean-css/clean-css/compare/v3.1.7...v3.1.8) +================== + +* Fixes issue [#498](https://github.com/clean-css/clean-css/issues/498) - reordering and flexbox. +* Fixes issue [#499](https://github.com/clean-css/clean-css/issues/499) - too aggressive `-` removal. + +[3.1.7 / 2015-03-16](https://github.com/clean-css/clean-css/compare/v3.1.6...v3.1.7) +================== + +* Backports fix to [#480](https://github.com/clean-css/clean-css/issues/480) - reordering and uppercase properties. +* Fixes issue [#496](https://github.com/clean-css/clean-css/issues/496) - space after bracket removal. + +[3.1.6 / 2015-03-12](https://github.com/clean-css/clean-css/compare/v3.1.5...v3.1.6) +================== + +* Fixes issue [#489](https://github.com/clean-css/clean-css/issues/489) - `AlphaImageLoader` IE filter. + +[3.1.5 / 2015-03-06](https://github.com/clean-css/clean-css/compare/v3.1.4...v3.1.5) +================== + +* Fixes issue [#483](https://github.com/clean-css/clean-css/issues/483) - property order in restructuring. + +[3.1.4 / 2015-03-04](https://github.com/clean-css/clean-css/compare/v3.1.3...v3.1.4) +================== + +* Fixes issue [#472](https://github.com/clean-css/clean-css/issues/472) - broken function minification. +* Fixes issue [#477](https://github.com/clean-css/clean-css/issues/477) - `@import`s order in restructuring. +* Fixes issue [#478](https://github.com/clean-css/clean-css/issues/478) - ultimate fix to brace whitespace. + +[3.1.3 / 2015-03-03](https://github.com/clean-css/clean-css/compare/v3.1.2...v3.1.3) +================== + +* Fixes issue [#464](https://github.com/clean-css/clean-css/issues/464) - data URI with quoted braces. +* Fixes issue [#475](https://github.com/clean-css/clean-css/issues/475) - whitespace after closing brace. + +[3.1.2 / 2015-03-01](https://github.com/clean-css/clean-css/compare/v3.1.1...v3.1.2) +================== + +* Refixed issue [#471](https://github.com/clean-css/clean-css/issues/471) - correct order after restructuring. +* Fixes issue [#466](https://github.com/clean-css/clean-css/issues/466) - rebuilding background shorthand. +* Fixes issue [#462](https://github.com/clean-css/clean-css/issues/462) - escaped apostrophes in selectors. + +[3.1.1 / 2015-02-27](https://github.com/clean-css/clean-css/compare/v3.1.0...v3.1.1) +================== + +* Fixed issue [#469](https://github.com/clean-css/clean-css/issues/469) - extracting broken property. +* Fixed issue [#470](https://github.com/clean-css/clean-css/issues/470) - negative padding removal. +* Fixed issue [#471](https://github.com/clean-css/clean-css/issues/471) - correct order after restructuring. + +[3.1.0 / 2015-02-26](https://github.com/clean-css/clean-css/compare/v3.0.10...v3.1.0) +================== + +* Adds `0deg` to `0` minification where possible. +* Adds better non-adjacent selector merging when body is the same. +* Adds official support for node.js 0.12. +* Adds official support for io.js 1.0. +* Adds restructuring optimizations to reorganize selectors, which vastly improves minification. +* Fixed issue [#158](https://github.com/clean-css/clean-css/issues/158) - adds body-based selectors reduction. +* Fixed issue [#182](https://github.com/clean-css/clean-css/issues/182) - removing space after closing brace. +* Fixed issue [#204](https://github.com/clean-css/clean-css/issues/204) - `@media` merging. +* Fixed issue [#351](https://github.com/clean-css/clean-css/issues/351) - remote `@import`s after content. +* Fixed issue [#357](https://github.com/clean-css/clean-css/issues/357) - non-standard but valid URLs. +* Fixed issue [#416](https://github.com/clean-css/clean-css/issues/416) - accepts hash as `minify` argument. +* Fixed issue [#419](https://github.com/clean-css/clean-css/issues/419) - multiple input source maps. +* Fixed issue [#435](https://github.com/clean-css/clean-css/issues/435) - `background-clip` in shorthand. +* Fixed issue [#439](https://github.com/clean-css/clean-css/issues/439) - `background-origin` in shorthand. +* Fixed issue [#442](https://github.com/clean-css/clean-css/issues/442) - space before adjacent `nav`. +* Fixed issue [#445](https://github.com/clean-css/clean-css/issues/445) - regression issue in url processor. +* Fixed issue [#449](https://github.com/clean-css/clean-css/issues/449) - warns of missing close braces. +* Fixed issue [#463](https://github.com/clean-css/clean-css/issues/463) - relative remote `@import` URLs. + +[3.0.10 / 2015-02-07](https://github.com/clean-css/clean-css/compare/v3.0.9...v3.0.10) +================== + +* Fixed issue [#453](https://github.com/clean-css/clean-css/issues/453) - double `background-repeat`. +* Fixed issue [#455](https://github.com/clean-css/clean-css/issues/455) - property extracting regression. + +[3.0.9 / 2015-02-04](https://github.com/clean-css/clean-css/compare/v3.0.8...v3.0.9) +================== + +* Fixed issue [#452](https://github.com/clean-css/clean-css/issues/452) - regression in advanced merging. + +[3.0.8 / 2015-01-31](https://github.com/clean-css/clean-css/compare/v3.0.7...v3.0.8) +================== + +* Fixed issue [#447](https://github.com/clean-css/clean-css/issues/447) - `background-color` in shorthands. +* Fixed issue [#450](https://github.com/clean-css/clean-css/issues/450) - name to hex color converting. + +[3.0.7 / 2015-01-22](https://github.com/clean-css/clean-css/compare/v3.0.6...v3.0.7) +================== + +* Fixed issue [#441](https://github.com/clean-css/clean-css/issues/441) - hex to name color converting. + +[3.0.6 / 2015-01-20](https://github.com/clean-css/clean-css/compare/v3.0.5...v3.0.6) +================== + +* Refixed issue [#414](https://github.com/clean-css/clean-css/issues/414) - source maps position fallback. + +[3.0.5 / 2015-01-18](https://github.com/clean-css/clean-css/compare/v3.0.4...v3.0.5) +================== + +* Fixed issue [#414](https://github.com/clean-css/clean-css/issues/414) - source maps position fallback. +* Fixed issue [#433](https://github.com/clean-css/clean-css/issues/433) - meging `!important` in shorthands. + +[3.0.4 / 2015-01-11](https://github.com/clean-css/clean-css/compare/v3.0.3...v3.0.4) +================== + +* Fixed issue [#314](https://github.com/clean-css/clean-css/issues/314) - spaces inside `calc`. + +[3.0.3 / 2015-01-07](https://github.com/clean-css/clean-css/compare/v3.0.2...v3.0.3) +================== + +* Just a version bump as npm incorrectly things 2.2.23 is the latest one. + +[3.0.2 / 2015-01-04](https://github.com/clean-css/clean-css/compare/v3.0.1...v3.0.2) +================== + +* Fixed issue [#422](https://github.com/clean-css/clean-css/issues/422) - handling `calc` as a unit. + +[3.0.1 / 2014-12-19](https://github.com/clean-css/clean-css/compare/v3.0.0...v3.0.1) +================== + +* Fixed issue [#410](https://github.com/clean-css/clean-css/issues/410) - advanced merging and comments. +* Fixed issue [#411](https://github.com/clean-css/clean-css/issues/411) - properties and important comments. + +[3.0.0 / 2014-12-18](https://github.com/clean-css/clean-css/compare/v2.2.22...v3.0.0) +================== + +* Adds more granular control over compatibility settings. +* Adds support for @counter-style at-rule. +* Adds `--source-map`/`sourceMap` switch for building input's source map. +* Adds `--skip-shorthand-compacting`/`shorthandComacting` option for disabling shorthand compacting. +* Allows `target` option to be a path to a folder instead of a file. +* Allows disabling rounding precision. By [@superlukas](https://github.com/superlukas). +* Breaks 2.x compatibility for using CleanCSS as a function. +* Changes `minify` method output to handle multiple outputs. +* Reworks minification to tokenize first then minify. + See [changes](https://github.com/clean-css/clean-css/compare/b06f37d...dd8c14a). +* Removes support for node.js 0.8.x. +* Renames `noAdvanced` option into `advanced`. +* Renames `noAggressiveMerging` option into `aggressiveMerging`. +* Renames `noRebase` option into `rebase`. +* Speeds up advanced processing by shortening optimize loop. +* Fixed issue [#125](https://github.com/clean-css/clean-css/issues/125) - source maps! +* Fixed issue [#344](https://github.com/clean-css/clean-css/issues/344) - merging `background-size` into shorthand. +* Fixed issue [#352](https://github.com/clean-css/clean-css/issues/352) - honors rebasing in imported stylesheets. +* Fixed issue [#360](https://github.com/clean-css/clean-css/issues/360) - adds 7 extra CSS colors. +* Fixed issue [#363](https://github.com/clean-css/clean-css/issues/363) - `rem` units overriding `px`. +* Fixed issue [#373](https://github.com/clean-css/clean-css/issues/373) - proper `background` shorthand merging. +* Fixed issue [#395](https://github.com/clean-css/clean-css/issues/395) - unescaped brackets in data URIs. +* Fixed issue [#398](https://github.com/clean-css/clean-css/issues/398) - restoring important comments. +* Fixed issue [#400](https://github.com/clean-css/clean-css/issues/400) - API to accept an array of filenames. +* Fixed issue [#403](https://github.com/clean-css/clean-css/issues/403) - tracking input files in source maps. +* Fixed issue [#404](https://github.com/clean-css/clean-css/issues/404) - no state sharing in API. +* Fixed issue [#405](https://github.com/clean-css/clean-css/issues/405) - disables default `background-size` merging. +* Refixed issue [#304](https://github.com/clean-css/clean-css/issues/304) - `background-position` merging. + +[2.2.22 / 2014-12-13](https://github.com/clean-css/clean-css/compare/v2.2.21...v2.2.22) +================== + +* Backports fix to issue [#304](https://github.com/clean-css/clean-css/issues/304) - `background-position` merging. + +[2.2.21 / 2014-12-10](https://github.com/clean-css/clean-css/compare/v2.2.20...v2.2.21) +================== + +* Backports fix to issue [#373](https://github.com/clean-css/clean-css/issues/373) - `background` shorthand merging. + +[2.2.20 / 2014-12-02](https://github.com/clean-css/clean-css/compare/v2.2.19...v2.2.20) +================== + +* Backports fix to issue [#390](https://github.com/clean-css/clean-css/issues/390) - pseudo-class merging. + +[2.2.19 / 2014-11-20](https://github.com/clean-css/clean-css/compare/v2.2.18...v2.2.19) +================== + +* Fixed issue [#385](https://github.com/clean-css/clean-css/issues/385) - edge cases in processing cut off data. + +[2.2.18 / 2014-11-17](https://github.com/clean-css/clean-css/compare/v2.2.17...v2.2.18) +================== + +* Fixed issue [#383](https://github.com/clean-css/clean-css/issues/383) - rounding fractions once again. + +[2.2.17 / 2014-11-09](https://github.com/clean-css/clean-css/compare/v2.2.16...v2.2.17) +================== + +* Fixed issue [#380](https://github.com/clean-css/clean-css/issues/380) - rounding fractions to a whole number. + +[2.2.16 / 2014-09-16](https://github.com/clean-css/clean-css/compare/v2.2.15...v2.2.16) +================== + +* Fixed issue [#359](https://github.com/clean-css/clean-css/issues/359) - handling escaped double backslash. +* Fixed issue [#358](https://github.com/clean-css/clean-css/issues/358) - property merging in compatibility mode. +* Fixed issue [#356](https://github.com/clean-css/clean-css/issues/356) - preserving `*+html` hack. +* Fixed issue [#354](https://github.com/clean-css/clean-css/issues/354) - `!important` overriding in shorthands. + +[2.2.15 / 2014-09-01](https://github.com/clean-css/clean-css/compare/v2.2.14...v2.2.15) +================== + +* Fixed issue [#343](https://github.com/clean-css/clean-css/issues/343) - too aggressive `rgba`/`hsla` minification. +* Fixed issue [#345](https://github.com/clean-css/clean-css/issues/345) - URL rebasing for document relative ones. +* Fixed issue [#346](https://github.com/clean-css/clean-css/issues/346) - overriding `!important` by `!important`. +* Fixed issue [#350](https://github.com/clean-css/clean-css/issues/350) - edge cases in `@import` processing. + +[2.2.14 / 2014-08-25](https://github.com/clean-css/clean-css/compare/v2.2.13...v2.2.14) +================== + +* Makes multival operations idempotent. +* Fixed issue [#339](https://github.com/clean-css/clean-css/issues/339) - skips invalid properties. +* Fixed issue [#341](https://github.com/clean-css/clean-css/issues/341) - ensure output is shorter than input. + +[2.2.13 / 2014-08-12](https://github.com/clean-css/clean-css/compare/v2.2.12...v2.2.13) +================== + +* Fixed issue [#337](https://github.com/clean-css/clean-css/issues/337) - handling component importance. + +[2.2.12 / 2014-08-02](https://github.com/clean-css/clean-css/compare/v2.2.11...v2.2.12) +================== + +* Fixed issue with tokenizer removing first selector after an unknown @ rule. +* Fixed issue [#329](https://github.com/clean-css/clean-css/issues/329) - `font` shorthands incorrectly processed. +* Fixed issue [#332](https://github.com/clean-css/clean-css/issues/332) - `background` shorthand with colors. +* Refixed issue [#325](https://github.com/clean-css/clean-css/issues/325) - invalid charset declarations. + +[2.2.11 / 2014-07-28](https://github.com/clean-css/clean-css/compare/v2.2.10...v2.2.11) +================== + +* Fixed issue [#326](https://github.com/clean-css/clean-css/issues/326) - `background-size` regression. + +[2.2.10 / 2014-07-27](https://github.com/clean-css/clean-css/compare/v2.2.9...v2.2.10) +================== + +* Improved performance of advanced mode validators. +* Fixed issue [#307](https://github.com/clean-css/clean-css/issues/307) - `background-color` in multiple backgrounds. +* Fixed issue [#322](https://github.com/clean-css/clean-css/issues/322) - adds `background-size` support. +* Fixed issue [#323](https://github.com/clean-css/clean-css/issues/323) - stripping variable references. +* Fixed issue [#325](https://github.com/clean-css/clean-css/issues/325) - removing invalid `@charset` declarations. + +[2.2.9 / 2014-07-23](https://github.com/clean-css/clean-css/compare/v2.2.8...v2.2.9) +================== + +* Adds `background` normalization according to W3C spec. +* Fixed issue [#316](https://github.com/clean-css/clean-css/issues/316) - incorrect `background` processing. + +[2.2.8 / 2014-07-14](https://github.com/clean-css/clean-css/compare/v2.2.7...v2.2.8) +================== + +* Fixed issue [#313](https://github.com/clean-css/clean-css/issues/313) - processing comment marks in URLs. +* Fixed issue [#315](https://github.com/clean-css/clean-css/issues/315) - `rgba`/`hsla` -> `transparent` in gradients. + +[2.2.7 / 2014-07-10](https://github.com/clean-css/clean-css/compare/v2.2.6...v2.2.7) +================== + +* Fixed issue [#304](https://github.com/clean-css/clean-css/issues/304) - merging multiple backgrounds. +* Fixed issue [#312](https://github.com/clean-css/clean-css/issues/312) - merging with mixed repeat. + +[2.2.6 / 2014-07-05](https://github.com/clean-css/clean-css/compare/v2.2.5...v2.2.6) +================== + +* Adds faster quote matching in QuoteScanner. +* Improves QuoteScanner to handle comments correctly. +* Fixed issue [#308](https://github.com/clean-css/clean-css/issues/308) - parsing comments in quoted URLs. +* Fixed issue [#311](https://github.com/clean-css/clean-css/issues/311) - leading/trailing decimal points. + +[2.2.5 / 2014-06-29](https://github.com/clean-css/clean-css/compare/v2.2.4...v2.2.5) +================== + +* Adds removing extra spaces around / in border-radius. +* Adds replacing same horizontal & vertical value in border-radius. +* Fixed issue [#305](https://github.com/clean-css/clean-css/issues/305) - allows width keywords in `border-width`. + +[2.2.4 / 2014-06-27](https://github.com/clean-css/clean-css/compare/v2.2.3...v2.2.4) +================== + +* Fixed issue [#301](https://github.com/clean-css/clean-css/issues/301) - proper `border-radius` processing. +* Fixed issue [#303](https://github.com/clean-css/clean-css/issues/303) - correctly preserves viewport units. + +[2.2.3 / 2014-06-24](https://github.com/clean-css/clean-css/compare/v2.2.2...v2.2.3) +================== + +* Fixed issue [#302](https://github.com/clean-css/clean-css/issues/302) - handling of `outline-style: auto`. + +[2.2.2 / 2014-06-18](https://github.com/clean-css/clean-css/compare/v2.2.1...v2.2.2) +================== + +* Fixed issue [#297](https://github.com/clean-css/clean-css/issues/297) - `box-shadow` zeros minification. + +[2.2.1 / 2014-06-14](https://github.com/clean-css/clean-css/compare/v2.2.0...v2.2.1) +================== + +* Fixes new property optimizer for 'none' values. +* Fixed issue [#294](https://github.com/clean-css/clean-css/issues/294) - space after `rgba`/`hsla` in IE<=11. + +[2.2.0 / 2014-06-11](https://github.com/clean-css/clean-css/compare/v2.1.8...v2.2.0) +================== + +* Adds a better algorithm for quotation marks' removal. +* Adds a better non-adjacent optimizer compatible with the upcoming new property optimizer. +* Adds minifying remote files directly from CLI. +* Adds `--rounding-precision` to control rounding precision. +* Moves quotation matching into a `QuoteScanner` class. +* Adds `npm run browserify` for creating embeddable version of clean-css. +* Fixed list-style-* advanced processing. +* Fixed issue [#134](https://github.com/clean-css/clean-css/issues/134) - merges properties into shorthand form. +* Fixed issue [#164](https://github.com/clean-css/clean-css/issues/164) - removes default values if not needed. +* Fixed issue [#168](https://github.com/clean-css/clean-css/issues/168) - adds better property merging algorithm. +* Fixed issue [#173](https://github.com/clean-css/clean-css/issues/173) - merges same properties if grouped. +* Fixed issue [#184](https://github.com/clean-css/clean-css/issues/184) - uses `!important` for optimization opportunities. +* Fixed issue [#190](https://github.com/clean-css/clean-css/issues/190) - uses shorthand to override another shorthand. +* Fixed issue [#197](https://github.com/clean-css/clean-css/issues/197) - adds borders merging by understandability. +* Fixed issue [#210](https://github.com/clean-css/clean-css/issues/210) - adds temporary workaround for aggressive merging. +* Fixed issue [#246](https://github.com/clean-css/clean-css/issues/246) - removes IE hacks when not in compatibility mode. +* Fixed issue [#247](https://github.com/clean-css/clean-css/issues/247) - removes deprecated `selectorsMergeMode` switch. +* Refixed issue [#250](https://github.com/clean-css/clean-css/issues/250) - based on new quotation marks removal. +* Fixed issue [#257](https://github.com/clean-css/clean-css/issues/257) - turns `rgba`/`hsla` to `transparent` if possible. +* Fixed issue [#265](https://github.com/clean-css/clean-css/issues/265) - adds support for multiple input files. +* Fixed issue [#275](https://github.com/clean-css/clean-css/issues/275) - handling transform properties. +* Fixed issue [#276](https://github.com/clean-css/clean-css/issues/276) - corrects unicode handling. +* Fixed issue [#288](https://github.com/clean-css/clean-css/issues/288) - adds smarter expression parsing. +* Fixed issue [#293](https://github.com/clean-css/clean-css/issues/293) - handles escaped `@` symbols in class names and IDs. + +[2.1.8 / 2014-03-28](https://github.com/clean-css/clean-css/compare/v2.1.7...v2.1.8) +================== + +* Fixed issue [#267](https://github.com/clean-css/clean-css/issues/267) - incorrect non-adjacent selector merging. + +[2.1.7 / 2014-03-24](https://github.com/clean-css/clean-css/compare/v2.1.6...v2.1.7) +================== + +* Fixed issue [#264](https://github.com/clean-css/clean-css/issues/264) - `@import` statements inside comments. + +[2.1.6 / 2014-03-10](https://github.com/clean-css/clean-css/compare/v2.1.5...v2.1.6) +================== + +* Fixed issue [#258](https://github.com/clean-css/clean-css/issues/258) - wrong `@import` handling in `EmptyRemoval`. + +[2.1.5 / 2014-03-07](https://github.com/clean-css/clean-css/compare/v2.1.4...v2.1.5) +================== + +* Fixed issue [#255](https://github.com/clean-css/clean-css/issues/255) - incorrect processing of a trailing `-0`. + +[2.1.4 / 2014-03-01](https://github.com/clean-css/clean-css/compare/v2.1.3...v2.1.4) +================== + +* Fixed issue [#250](https://github.com/clean-css/clean-css/issues/250) - correctly handle JSON data in quotations. + +[2.1.3 / 2014-02-26](https://github.com/clean-css/clean-css/compare/v2.1.2...v2.1.3) +================== + +* Fixed issue [#248](https://github.com/clean-css/clean-css/issues/248) - incorrect merging for vendor selectors. + +[2.1.2 / 2014-02-25](https://github.com/clean-css/clean-css/compare/v2.1.1...v2.1.2) +================== + +* Fixed issue [#245](https://github.com/clean-css/clean-css/issues/245) - incorrect handling of backslash IE hack. + +[2.1.1 / 2014-02-18](https://github.com/clean-css/clean-css/compare/v2.1.0...v2.1.1) +================== + +* Adds faster selectors processing in advanced optimizer. +* Fixed issue [#241](https://github.com/clean-css/clean-css/issues/241) - incorrect handling of `:not()` selectors. + +[2.1.0 / 2014-02-13](https://github.com/clean-css/clean-css/compare/v2.0.8...v2.1.0) +================== + +* Adds an optional callback to minify method. +* Deprecates `--selectors-merge-mode` / `selectorsMergeMode` in favor to `--compatibility` / `compatibility`. +* Fixes debug mode stats for stylesheets using `@import` statements. +* Skips empty removal if advanced processing is enabled. +* Fixed issue [#85](https://github.com/clean-css/clean-css/issues/85) - resolving protocol `@import`s. +* Fixed issue [#160](https://github.com/clean-css/clean-css/issues/160) - re-runs optimizer until a clean pass. +* Fixed issue [#161](https://github.com/clean-css/clean-css/issues/161) - improves tokenizer performance. +* Fixed issue [#163](https://github.com/clean-css/clean-css/issues/163) - round pixels to 2nd decimal place. +* Fixed issue [#165](https://github.com/clean-css/clean-css/issues/165) - extra space after trailing parenthesis. +* Fixed issue [#186](https://github.com/clean-css/clean-css/issues/186) - strip unit from `0rem`. +* Fixed issue [#207](https://github.com/clean-css/clean-css/issues/207) - bug in parsing protocol `@import`s. +* Fixed issue [#213](https://github.com/clean-css/clean-css/issues/213) - faster `rgb` to `hex` transforms. +* Fixed issue [#215](https://github.com/clean-css/clean-css/issues/215) - leading zeros in numerical values. +* Fixed issue [#217](https://github.com/clean-css/clean-css/issues/217) - whitespace inside attribute selectors and URLs. +* Fixed issue [#218](https://github.com/clean-css/clean-css/issues/218) - `@import` statements cleanup. +* Fixed issue [#220](https://github.com/clean-css/clean-css/issues/220) - selector between comments. +* Fixed issue [#223](https://github.com/clean-css/clean-css/issues/223) - two-pass adjacent selectors merging. +* Fixed issue [#226](https://github.com/clean-css/clean-css/issues/226) - don't minify `border:none` to `border:0`. +* Fixed issue [#229](https://github.com/clean-css/clean-css/issues/229) - improved processing of fraction numbers. +* Fixed issue [#230](https://github.com/clean-css/clean-css/issues/230) - better handling of zero values. +* Fixed issue [#235](https://github.com/clean-css/clean-css/issues/235) - IE7 compatibility mode. +* Fixed issue [#236](https://github.com/clean-css/clean-css/issues/236) - incorrect rebasing with nested `import`s. + +[2.0.8 / 2014-02-07](https://github.com/clean-css/clean-css/compare/v2.0.7...v2.0.8) +================== + +* Fixed issue [#232](https://github.com/clean-css/clean-css/issues/232) - edge case in non-adjacent selectors merging. + +[2.0.7 / 2014-01-16](https://github.com/clean-css/clean-css/compare/v2.0.6...v2.0.7) +================== + +* Fixed issue [#208](https://github.com/clean-css/clean-css/issues/208) - don't swallow `@page` and `@viewport`. + +[2.0.6 / 2014-01-04](https://github.com/clean-css/clean-css/compare/v2.0.5...v2.0.6) +================== + +* Fixed issue [#198](https://github.com/clean-css/clean-css/issues/198) - process comments and `@import`s correctly. +* Fixed issue [#205](https://github.com/clean-css/clean-css/issues/205) - freeze on broken `@import` declaration. + +[2.0.5 / 2014-01-03](https://github.com/clean-css/clean-css/compare/v2.0.4...v2.0.5) +================== + +* Fixed issue [#199](https://github.com/clean-css/clean-css/issues/199) - keep line breaks with no advanced optimizations. +* Fixed issue [#203](https://github.com/clean-css/clean-css/issues/203) - Buffer as a first argument to minify method. + +[2.0.4 / 2013-12-19](https://github.com/clean-css/clean-css/compare/v2.0.3...v2.0.4) +================== + +* Fixed issue [#193](https://github.com/clean-css/clean-css/issues/193) - HSL color space normalization. + +[2.0.3 / 2013-12-18](https://github.com/clean-css/clean-css/compare/v2.0.2...v2.0.3) +================== + +* Fixed issue [#191](https://github.com/clean-css/clean-css/issues/191) - leading numbers in `font`/`animation` names. +* Fixed issue [#192](https://github.com/clean-css/clean-css/issues/192) - many `@import`s inside a comment. + +[2.0.2 / 2013-11-18](https://github.com/clean-css/clean-css/compare/v2.0.1...v2.0.2) +================== + +* Fixed issue [#177](https://github.com/clean-css/clean-css/issues/177) - process broken content correctly. + +[2.0.1 / 2013-11-14](https://github.com/clean-css/clean-css/compare/v2.0.0...v2.0.1) +================== + +* Fixed issue [#176](https://github.com/clean-css/clean-css/issues/176) - hangs on `undefined` keyword. + +[2.0.0 / 2013-11-04](https://github.com/clean-css/clean-css/compare/v1.1.7...v2.0.0) +================== + +* Adds simplified and more advanced text escaping / restoring via `EscapeStore` class. +* Adds simplified and much faster empty elements removal. +* Adds missing `@import` processing to our benchmark (run via `npm run bench`). +* Adds CSS tokenizer which will make it possible to optimize content by reordering and/or merging selectors. +* Adds basic optimizer removing duplicate selectors from a list. +* Adds merging duplicate properties within a single selector's body. +* Adds merging adjacent selectors within a scope (single and multiple ones). +* Changes behavior of `--keep-line-breaks`/`keepBreaks` option to keep breaks after trailing braces only. +* Makes all multiple selectors ordered alphabetically (aids merging). +* Adds property overriding so more coarse properties override more granular ones. +* Adds reducing non-adjacent selectors. +* Adds `--skip-advanced`/`noAdvanced` switch to disable advanced optimizations. +* Adds reducing non-adjacent selectors when overridden by more complex selectors. +* Fixed issue [#138](https://github.com/clean-css/clean-css/issues/138) - makes CleanCSS interface OO. +* Fixed issue [#139](https://github.com/clean-css/clean-css/issues/138) - consistent error & warning handling. +* Fixed issue [#145](https://github.com/clean-css/clean-css/issues/145) - debug mode in library too. +* Fixed issue [#157](https://github.com/clean-css/clean-css/issues/157) - gets rid of `removeEmpty` option. +* Fixed issue [#159](https://github.com/clean-css/clean-css/issues/159) - escaped quotes inside content. +* Fixed issue [#162](https://github.com/clean-css/clean-css/issues/162) - strip quotes from Base64 encoded URLs. +* Fixed issue [#166](https://github.com/clean-css/clean-css/issues/166) - `debug` formatting in CLI +* Fixed issue [#167](https://github.com/clean-css/clean-css/issues/167) - `background:transparent` minification. + +[1.1.7 / 2013-10-28](https://github.com/clean-css/clean-css/compare/v1.1.6...v1.1.7) +================== + +* Fixed issue [#156](https://github.com/clean-css/clean-css/issues/156) - `@import`s inside comments. + +[1.1.6 / 2013-10-26](https://github.com/clean-css/clean-css/compare/v1.1.5...v1.1.6) +================== + +* Fixed issue [#155](https://github.com/clean-css/clean-css/issues/155) - broken irregular CSS content. + +[1.1.5 / 2013-10-24](https://github.com/clean-css/clean-css/compare/v1.1.4...v1.1.5) +================== + +* Fixed issue [#153](https://github.com/clean-css/clean-css/issues/153) - `keepSpecialComments` `0`/`1` as a string. + +[1.1.4 / 2013-10-23](https://github.com/clean-css/clean-css/compare/v1.1.3...v1.1.4) +================== + +* Fixed issue [#152](https://github.com/clean-css/clean-css/issues/152) - adds an option to disable rebasing. + +[1.1.3 / 2013-10-04](https://github.com/clean-css/clean-css/compare/v1.1.2...v1.1.3) +================== + +* Fixed issue [#150](https://github.com/clean-css/clean-css/issues/150) - minifying `background:none`. + +[1.1.2 / 2013-09-29](https://github.com/clean-css/clean-css/compare/v1.1.1...v1.1.2) +================== + +* Fixed issue [#149](https://github.com/clean-css/clean-css/issues/149) - shorthand `font` property. + +[1.1.1 / 2013-09-07](https://github.com/clean-css/clean-css/compare/v1.1.0...v1.1.1) +================== + +* Fixed issue [#144](https://github.com/clean-css/clean-css/issues/144) - skip URLs rebasing by default. + +[1.1.0 / 2013-09-06](https://github.com/clean-css/clean-css/compare/v1.0.12...v1.1.0) +================== + +* Renamed lib's `debug` option to `benchmark` when doing per-minification benchmarking. +* Added simplified comments processing & imports. +* Fixed issue [#43](https://github.com/clean-css/clean-css/issues/43) - `--debug` switch for minification stats. +* Fixed issue [#65](https://github.com/clean-css/clean-css/issues/65) - full color name / hex shortening. +* Fixed issue [#84](https://github.com/clean-css/clean-css/issues/84) - support for `@import` with media queries. +* Fixed issue [#124](https://github.com/clean-css/clean-css/issues/124) - raise error on broken imports. +* Fixed issue [#126](https://github.com/clean-css/clean-css/issues/126) - proper CSS expressions handling. +* Fixed issue [#129](https://github.com/clean-css/clean-css/issues/129) - rebasing imported URLs. +* Fixed issue [#130](https://github.com/clean-css/clean-css/issues/130) - better code modularity. +* Fixed issue [#135](https://github.com/clean-css/clean-css/issues/135) - require node.js 0.8+. + +[1.0.12 / 2013-07-19](https://github.com/clean-css/clean-css/compare/v1.0.11...v1.0.12) +=================== + +* Fixed issue [#121](https://github.com/clean-css/clean-css/issues/121) - ability to skip `@import` processing. + +[1.0.11 / 2013-07-08](https://github.com/clean-css/clean-css/compare/v1.0.10...v1.0.11) +=================== + +* Fixed issue [#117](https://github.com/clean-css/clean-css/issues/117) - line break escaping in comments. + +[1.0.10 / 2013-06-13](https://github.com/clean-css/clean-css/compare/v1.0.9...v1.0.10) +=================== + +* Fixed issue [#114](https://github.com/clean-css/clean-css/issues/114) - comments in imported stylesheets. + +[1.0.9 / 2013-06-11](https://github.com/clean-css/clean-css/compare/v1.0.8...v1.0.9) +================== + +* Fixed issue [#113](https://github.com/clean-css/clean-css/issues/113) - `@import` in comments. + +[1.0.8 / 2013-06-10](https://github.com/clean-css/clean-css/compare/v1.0.7...v1.0.8) +================== + +* Fixed issue [#112](https://github.com/clean-css/clean-css/issues/112) - reducing `box-shadow` zeros. + +[1.0.7 / 2013-06-05](https://github.com/clean-css/clean-css/compare/v1.0.6...v1.0.7) +================== + +* Support for `@import` URLs starting with `//`. By [@petetak](https://github.com/petetak). + +[1.0.6 / 2013-06-04](https://github.com/clean-css/clean-css/compare/v1.0.5...v1.0.6) +================== + +* Fixed issue [#110](https://github.com/clean-css/clean-css/issues/110) - data URIs in URLs. + +[1.0.5 / 2013-05-26](https://github.com/clean-css/clean-css/compare/v1.0.4...v1.0.5) +================== + +* Fixed issue [#107](https://github.com/clean-css/clean-css/issues/107) - data URIs in imported stylesheets. + +1.0.4 / 2013-05-23 +================== + +* Rewrite relative URLs in imported stylesheets. By [@bluej100](https://github.com/bluej100). + +1.0.3 / 2013-05-20 +================== + +* Support alternative `@import` syntax with file name not wrapped inside `url()` statement. + By [@bluej100](https://github.com/bluej100). + +1.0.2 / 2013-04-29 +================== + +* Fixed issue [#97](https://github.com/clean-css/clean-css/issues/97) - `--remove-empty` & FontAwesome. + +1.0.1 / 2013-04-08 +================== + +* Do not pick up `bench` and `test` while building `npm` package. + By [@sindresorhus](https://https://github.com/sindresorhus). + +1.0.0 / 2013-03-30 +================== + +* Fixed issue [#2](https://github.com/clean-css/clean-css/issues/2) - resolving `@import` rules. +* Fixed issue [#44](https://github.com/clean-css/clean-css/issues/44) - examples in `--help`. +* Fixed issue [#46](https://github.com/clean-css/clean-css/issues/46) - preserving special characters in URLs and attributes. +* Fixed issue [#80](https://github.com/clean-css/clean-css/issues/80) - quotation in multi line strings. +* Fixed issue [#83](https://github.com/clean-css/clean-css/issues/83) - HSL to hex color conversions. +* Fixed issue [#86](https://github.com/clean-css/clean-css/issues/86) - broken `@charset` replacing. +* Fixed issue [#88](https://github.com/clean-css/clean-css/issues/88) - removes space in `! important`. +* Fixed issue [#92](https://github.com/clean-css/clean-css/issues/92) - uppercase hex to short versions. + +0.10.2 / 2013-03-19 +=================== + +* Fixed issue [#79](https://github.com/clean-css/clean-css/issues/79) - node.js 0.10.x compatibility. + +0.10.1 / 2013-02-14 +=================== + +* Fixed issue [#66](https://github.com/clean-css/clean-css/issues/66) - line breaks without extra spaces should + be handled correctly. + +0.10.0 / 2013-02-09 +=================== + +* Switched from [optimist](https://github.com/substack/node-optimist) to + [commander](https://github.com/visionmedia/commander.js) for CLI processing. +* Changed long options from `--removeempty` to `--remove-empty` and from `--keeplinebreaks` to `--keep-line-breaks`. +* Fixed performance issue with replacing multiple `@charset` declarations and issue + with line break after `@charset` when using `keepLineBreaks` option. By [@rrjaime](https://github.com/rrjamie). +* Removed Makefile in favor to `npm run` commands (e.g. `make check` -> `npm run check`). +* Fixed issue [#47](https://github.com/clean-css/clean-css/issues/47) - commandline issues on Windows. +* Fixed issue [#49](https://github.com/clean-css/clean-css/issues/49) - remove empty selectors from media query. +* Fixed issue [#52](https://github.com/clean-css/clean-css/issues/52) - strip fraction zeros if not needed. +* Fixed issue [#58](https://github.com/clean-css/clean-css/issues/58) - remove colon where possible. +* Fixed issue [#59](https://github.com/clean-css/clean-css/issues/59) - content property handling. + +0.9.1 / 2012-12-19 +================== + +* Fixed issue [#37](https://github.com/clean-css/clean-css/issues/37) - converting + `white` and other colors in class names (reported by [@malgorithms](https://github.com/malgorithms)). + +0.9.0 / 2012-12-15 +================== + +* Added stripping quotation from font names (if possible). +* Added stripping quotation from `@keyframes` declaration, `animation` and + `animation-name` property. +* Added stripping quotations from attributes' value (e.g. `[data-target='x']`). +* Added better hex->name and name->hex color shortening. +* Added `font: normal` and `font: bold` shortening the same way as `font-weight` is. +* Refactored shorthand selectors and added `border-radius`, `border-style` + and `border-color` shortening. +* Added `margin`, `padding` and `border-width` shortening. +* Added removing line break after commas. +* Fixed removing whitespace inside media query definition. +* Added removing line breaks after a comma, so all declarations are one-liners now. +* Speed optimizations (~10% despite many new features). +* Added [JSHint](https://github.com/jshint/jshint/) validation rules via `make check`. + +0.8.3 / 2012-11-29 +================== + +* Fixed HSL/HSLA colors processing. + +0.8.2 / 2012-10-31 +================== + +* Fixed shortening hex colors and their relation to hashes in URLs. +* Cleanup by [@XhmikosR](https://github.com/XhmikosR). + +0.8.1 / 2012-10-28 +================== + +* Added better zeros processing for `rect(...)` syntax (clip property). + +0.8.0 / 2012-10-21 +================== + +* Added removing URLs quotation if possible. +* Rewrote breaks processing. +* Added `keepBreaks`/`-b` option to keep line breaks in the minimized file. +* Reformatted [lib/clean.js](/lib/clean.js) so it's easier to follow the rules. +* Minimized test data is now minimized with line breaks so it's easier to + compare the changes line by line. + +0.7.0 / 2012-10-14 +================== + +* Added stripping special comments to CLI (`--s0` and `--s1` options). +* Added stripping special comments to programmatic interface + (`keepSpecialComments` option). + +0.6.0 / 2012-08-05 +================== + +* Full Windows support with tests (./test.bat). + +0.5.0 / 2012-08-02 +================== + +* Made path to vows local. +* Explicit node.js 0.6 requirement. + +0.4.2 / 2012-06-28 +================== + +* Updated binary `-v` option (version). +* Updated binary to output help when no options given (but not in piped mode). +* Added binary tests. + +0.4.1 / 2012-06-10 +================== + +* Fixed stateless mode where calling `CleanCSS#process` directly was giving + errors (reported by [@facelessuser](https://github.com/facelessuser)). + +0.4.0 / 2012-06-04 +================== + +* Speed improvements up to 4x thanks to the rewrite of comments and CSS' content + processing. +* Stripping empty CSS tags is now optional (see [bin/cleancss](/bin/cleancss) for details). +* Improved debugging mode (see [test/bench.js](/test/bench.js)) +* Added `make bench` for a one-pass benchmark. + +0.3.3 / 2012-05-27 +================== + +* Fixed tests, [package.json](/package.json) for development, and regex + for removing empty declarations (thanks to [@vvo](https://github.com/vvo)). + +0.3.2 / 2012-01-17 +================== + +* Fixed output method under node.js 0.6 which incorrectly tried to close + `process.stdout`. + +0.3.1 / 2011-12-16 +================== + +* Fixed cleaning up `0 0 0 0` expressions. + +0.3.0 / 2011-11-29 +================== + +* Clean-css requires node.js 0.4.0+ to run. +* Removed node.js's 0.2.x 'sys' package dependency + (thanks to [@jmalonzo](https://github.com/jmalonzo) for a patch). + +0.2.6 / 2011-11-27 +================== + +* Fixed expanding `+` signs in `calc()` when mixed up with adjacent `+` selector. + +0.2.5 / 2011-11-27 +================== + +* Fixed issue with cleaning up spaces inside `calc`/`-moz-calc` declarations + (thanks to [@cvan](https://github.com/cvan) for reporting it). +* Fixed converting `#f00` to `red` in borders and gradients. + +0.2.4 / 2011-05-25 +================== + +* Fixed problem with expanding `none` to `0` in partial/full background + declarations. +* Fixed including clean-css library from binary (global to local). + +0.2.3 / 2011-04-18 +================== + +* Fixed problem with optimizing IE filters. + +0.2.2 / 2011-04-17 +================== + +* Fixed problem with space before color in `border` property. + +0.2.1 / 2011-03-19 +================== + +* Added stripping space before `!important` keyword. +* Updated repository location and author information in [package.json](/package.json). + +0.2.0 / 2011-03-02 +================== + +* Added options parsing via optimist. +* Changed code inclusion (thus the version bump). + +0.1.0 / 2011-02-27 +================== + +* First version of clean-css library. +* Implemented all basic CSS transformations. diff --git a/igv_component/node_modules/clean-css/LICENSE b/igv_component/node_modules/clean-css/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..bf2f4055b06a239578d4c885f417d82492a457c7 --- /dev/null +++ b/igv_component/node_modules/clean-css/LICENSE @@ -0,0 +1,19 @@ +Copyright (C) 2017 JakubPawlowicz.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/igv_component/node_modules/clean-css/README.md b/igv_component/node_modules/clean-css/README.md new file mode 100644 index 0000000000000000000000000000000000000000..0361b636318097f90829b3ad7f3a544aa2f80a2f --- /dev/null +++ b/igv_component/node_modules/clean-css/README.md @@ -0,0 +1,987 @@ +

+
+ clean-css logo +
+
+

+ +[![npm version](https://img.shields.io/npm/v/clean-css.svg?style=flat)](https://www.npmjs.com/package/clean-css) +[![Build Status](https://img.shields.io/github/workflow/status/clean-css/clean-css/Tests/master)](https://github.com/clean-css/clean-css/actions?query=workflow%3ATests+branch%3Amaster) +[![PPC Linux Build Status](https://img.shields.io/travis/clean-css/clean-css/master.svg?style=flat&label=PPC%20Linux%20build)](https://travis-ci.org/clean-css/clean-css) +[![Dependency Status](https://img.shields.io/david/clean-css/clean-css.svg?style=flat)](https://david-dm.org/clean-css/clean-css) +[![npm Downloads](https://img.shields.io/npm/dm/clean-css.svg)](https://npmcharts.com/compare/clean-css?minimal=true) + +clean-css is a fast and efficient CSS optimizer for [Node.js](http://nodejs.org/) platform and [any modern browser](https://clean-css.github.io/). + +According to [tests](http://goalsmashers.github.io/css-minification-benchmark/) it is one of the best available. + +**Table of Contents** + +- [Node.js version support](#nodejs-version-support) +- [Install](#install) +- [Use](#use) + * [What's new in version 5.3](#whats-new-in-version-53) + * [What's new in version 5.0](#whats-new-in-version-50) + * [What's new in version 4.2](#whats-new-in-version-42) + * [What's new in version 4.1](#whats-new-in-version-41) + * [Important: 4.0 breaking changes](#important-40-breaking-changes) + * [Constructor options](#constructor-options) + * [Compatibility modes](#compatibility-modes) + * [Fetch option](#fetch-option) + * [Formatting options](#formatting-options) + * [Inlining options](#inlining-options) + * [Optimization levels](#optimization-levels) + + [Level 0 optimizations](#level-0-optimizations) + + [Level 1 optimizations](#level-1-optimizations) + + [Level 2 optimizations](#level-2-optimizations) + * [Plugins](#plugins) + * [Minify method](#minify-method) + * [Promise interface](#promise-interface) + * [CLI utility](#cli-utility) +- [FAQ](#faq) + * [How to optimize multiple files?](#how-to-optimize-multiple-files) + * [How to process multiple files without concatenating them into one output file?](#how-to-process-multiple-files-without-concatenating-them-into-one-output-file) + * [How to process remote `@import`s correctly?](#how-to-process-remote-imports-correctly) + * [How to apply arbitrary transformations to CSS properties?](#how-to-apply-arbitrary-transformations-to-css-properties) + * [How to specify a custom rounding precision?](#how-to-specify-a-custom-rounding-precision) + * [How to keep a CSS fragment intact?](#how-to-keep-a-css-fragment-intact) + * [How to preserve a comment block?](#how-to-preserve-a-comment-block) + * [How to rebase relative image URLs?](#how-to-rebase-relative-image-urls) + * [How to work with source maps?](#how-to-work-with-source-maps) + * [How to apply level 1 & 2 optimizations at the same time?](#how-to-apply-level-1--2-optimizations-at-the-same-time) + * [What level 2 optimizations do?](#what-level-2-optimizations-do) + * [What errors and warnings are?](#what-errors-and-warnings-are) + * [How to use clean-css with build tools?](#how-to-use-clean-css-with-build-tools) + * [How to use clean-css from web browser?](#how-to-use-clean-css-from-web-browser) +- [Contributing](#contributing) + * [How to get started?](#how-to-get-started) +- [Acknowledgments](#acknowledgments) +- [License](#license) + +# Node.js version support + +clean-css requires Node.js 10.0+ (tested on Linux, OS X, and Windows) + +# Install + +``` +npm install --save-dev clean-css +``` + +# Use + +```js +var CleanCSS = require('clean-css'); +var input = 'a{font-weight:bold;}'; +var options = { /* options */ }; +var output = new CleanCSS(options).minify(input); +``` + +## What's new in version 5.3 + +clean-css 5.3 introduces one new feature: + +* variables can be optimized using level 1's `variableValueOptimizers` option, which accepts a list of [value optimizers](https://github.com/clean-css/clean-css/blob/master/lib/optimizer/level-1/value-optimizers.js) or a list of their names, e.g. `variableValueOptimizers: ['color', 'fraction']`. + +## What's new in version 5.0 + +clean-css 5.0 introduced some breaking changes: + +* Node.js 6.x and 8.x are officially no longer supported; +* `transform` callback in level-1 optimizations is removed in favor of new [plugins](#plugins) interface; +* changes default Internet Explorer compatibility from 10+ to >11, to revert the old default use `{ compatibility: 'ie10' }` flag; +* changes default `rebase` option from `true` to `false` so URLs are not rebased by default. Please note that if you set `rebaseTo` option it still counts as setting `rebase: true` to preserve some of the backward compatibility. + +And on the new features side of things: + +* format options now accepts numerical values for all breaks, which will allow you to have more control over output formatting, e.g. `format: {breaks: {afterComment: 2}}` means clean-css will add two line breaks after each comment +* a new `batch` option (defaults to `false`) is added, when set to `true` it will process all inputs, given either as an array or a hash, without concatenating them. + +## What's new in version 4.2 + +clean-css 4.2 introduces the following changes / features: + +* Adds `process` method for compatibility with optimize-css-assets-webpack-plugin; +* new `transition` property optimizer; +* preserves any CSS content between `/* clean-css ignore:start */` and `/* clean-css ignore:end */` comments; +* allows filtering based on selector in `transform` callback, see [example](#how-to-apply-arbitrary-transformations-to-css-properties); +* adds configurable line breaks via `format: { breakWith: 'lf' }` option. + +## What's new in version 4.1 + +clean-css 4.1 introduces the following changes / features: + +* `inline: false` as an alias to `inline: ['none']`; +* `multiplePseudoMerging` compatibility flag controlling merging of rules with multiple pseudo classes / elements; +* `removeEmpty` flag in level 1 optimizations controlling removal of rules and nested blocks; +* `removeEmpty` flag in level 2 optimizations controlling removal of rules and nested blocks; +* `compatibility: { selectors: { mergeLimit: } }` flag in compatibility settings controlling maximum number of selectors in a single rule; +* `minify` method improved signature accepting a list of hashes for a predictable traversal; +* `selectorsSortingMethod` level 1 optimization allows `false` or `'none'` for disabling selector sorting; +* `fetch` option controlling a function for handling remote requests; +* new `font` shorthand and `font-*` longhand optimizers; +* removal of `optimizeFont` flag in level 1 optimizations due to new `font` shorthand optimizer; +* `skipProperties` flag in level 2 optimizations controlling which properties won't be optimized; +* new `animation` shorthand and `animation-*` longhand optimizers; +* `removeUnusedAtRules` level 2 optimization controlling removal of unused `@counter-style`, `@font-face`, `@keyframes`, and `@namespace` at rules; +* the [web interface](https://clean-css.github.io/) gets an improved settings panel with "reset to defaults", instant option changes, and settings being persisted across sessions. + +## Important: 4.0 breaking changes + +clean-css 4.0 introduces some breaking changes: + +* API and CLI interfaces are split, so API stays in this repository while CLI moves to [clean-css-cli](https://github.com/clean-css/clean-css-cli); +* `root`, `relativeTo`, and `target` options are replaced by a single `rebaseTo` option - this means that rebasing URLs and import inlining is much simpler but may not be (YMMV) as powerful as in 3.x; +* `debug` option is gone as stats are always provided in output object under `stats` property; +* `roundingPrecision` is disabled by default; +* `roundingPrecision` applies to **all** units now, not only `px` as in 3.x; +* `processImport` and `processImportFrom` are merged into `inline` option which defaults to `local`. Remote `@import` rules are **NOT** inlined by default anymore; +* splits `inliner: { request: ..., timeout: ... }` option into `inlineRequest` and `inlineTimeout` options; +* remote resources without a protocol, e.g. `//fonts.googleapis.com/css?family=Domine:700`, are not inlined anymore; +* changes default Internet Explorer compatibility from 9+ to 10+, to revert the old default use `{ compatibility: 'ie9' }` flag; +* renames `keepSpecialComments` to `specialComments`; +* moves `roundingPrecision` and `specialComments` to level 1 optimizations options, see examples; +* moves `mediaMerging`, `restructuring`, `semanticMerging`, and `shorthandCompacting` to level 2 optimizations options, see examples below; +* renames `shorthandCompacting` option to `mergeIntoShorthands`; +* level 1 optimizations are the new default, up to 3.x it was level 2; +* `keepBreaks` option is replaced with `{ format: 'keep-breaks' }` to ease transition; +* `sourceMap` option has to be a boolean from now on - to specify an input source map pass it a 2nd argument to `minify` method or via a hash instead; +* `aggressiveMerging` option is removed as aggressive merging is replaced by smarter override merging. + +## Constructor options + +clean-css constructor accepts a hash as a parameter with the following options available: + +* `compatibility` - controls compatibility mode used; defaults to `ie10+`; see [compatibility modes](#compatibility-modes) for examples; +* `fetch` - controls a function for handling remote requests; see [fetch option](#fetch-option) for examples (since 4.1.0); +* `format` - controls output CSS formatting; defaults to `false`; see [formatting options](#formatting-options) for examples; +* `inline` - controls `@import` inlining rules; defaults to `'local'`; see [inlining options](#inlining-options) for examples; +* `inlineRequest` - controls extra options for inlining remote `@import` rules, can be any of [HTTP(S) request options](https://nodejs.org/api/http.html#http_http_request_options_callback); +* `inlineTimeout` - controls number of milliseconds after which inlining a remote `@import` fails; defaults to 5000; +* `level` - controls optimization level used; defaults to `1`; see [optimization levels](#optimization-levels) for examples; +* `rebase` - controls URL rebasing; defaults to `false`; +* `rebaseTo` - controls a directory to which all URLs are rebased, most likely the directory under which the output file will live; defaults to the current directory; +* `returnPromise` - controls whether `minify` method returns a Promise object or not; defaults to `false`; see [promise interface](#promise-interface) for examples; +* `sourceMap` - controls whether an output source map is built; defaults to `false`; +* `sourceMapInlineSources` - controls embedding sources inside a source map's `sourcesContent` field; defaults to false. + +## Compatibility modes + +There is a certain number of compatibility mode shortcuts, namely: + +* `new CleanCSS({ compatibility: '*' })` (default) - Internet Explorer 10+ compatibility mode +* `new CleanCSS({ compatibility: 'ie9' })` - Internet Explorer 9+ compatibility mode +* `new CleanCSS({ compatibility: 'ie8' })` - Internet Explorer 8+ compatibility mode +* `new CleanCSS({ compatibility: 'ie7' })` - Internet Explorer 7+ compatibility mode + +Each of these modes is an alias to a [fine grained configuration](https://github.com/clean-css/clean-css/blob/master/lib/options/compatibility.js), with the following options available: + +```js +new CleanCSS({ + compatibility: { + colors: { + hexAlpha: false, // controls 4- and 8-character hex color support + opacity: true // controls `rgba()` / `hsla()` color support + }, + properties: { + backgroundClipMerging: true, // controls background-clip merging into shorthand + backgroundOriginMerging: true, // controls background-origin merging into shorthand + backgroundSizeMerging: true, // controls background-size merging into shorthand + colors: true, // controls color optimizations + ieBangHack: false, // controls keeping IE bang hack + ieFilters: false, // controls keeping IE `filter` / `-ms-filter` + iePrefixHack: false, // controls keeping IE prefix hack + ieSuffixHack: false, // controls keeping IE suffix hack + merging: true, // controls property merging based on understandability + shorterLengthUnits: false, // controls shortening pixel units into `pc`, `pt`, or `in` units + spaceAfterClosingBrace: true, // controls keeping space after closing brace - `url() no-repeat` into `url()no-repeat` + urlQuotes: true, // controls keeping quoting inside `url()` + zeroUnits: true // controls removal of units `0` value + }, + selectors: { + adjacentSpace: false, // controls extra space before `nav` element + ie7Hack: true, // controls removal of IE7 selector hacks, e.g. `*+html...` + mergeablePseudoClasses: [':active', ...], // controls a whitelist of mergeable pseudo classes + mergeablePseudoElements: ['::after', ...], // controls a whitelist of mergeable pseudo elements + mergeLimit: 8191, // controls maximum number of selectors in a single rule (since 4.1.0) + multiplePseudoMerging: true // controls merging of rules with multiple pseudo classes / elements (since 4.1.0) + }, + units: { + ch: true, // controls treating `ch` as a supported unit + in: true, // controls treating `in` as a supported unit + pc: true, // controls treating `pc` as a supported unit + pt: true, // controls treating `pt` as a supported unit + rem: true, // controls treating `rem` as a supported unit + vh: true, // controls treating `vh` as a supported unit + vm: true, // controls treating `vm` as a supported unit + vmax: true, // controls treating `vmax` as a supported unit + vmin: true // controls treating `vmin` as a supported unit + } + } +}) +``` + +You can also use a string when setting a compatibility mode, e.g. + +```js +new CleanCSS({ + compatibility: 'ie9,-properties.merging' // sets compatibility to IE9 mode with disabled property merging +}) +``` + +## Fetch option + +The `fetch` option accepts a function which handles remote resource fetching, e.g. + +```js +var request = require('request'); +var source = '@import url(http://example.com/path/to/stylesheet.css);'; +new CleanCSS({ + fetch: function (uri, inlineRequest, inlineTimeout, callback) { + request(uri, function (error, response, body) { + if (error) { + callback(error, null); + } else if (response && response.statusCode != 200) { + callback(response.statusCode, null); + } else { + callback(null, body); + } + }); + } +}).minify(source); +``` + +This option provides a convenient way of overriding the default fetching logic if it doesn't support a particular feature, say CONNECT proxies. + +Unless given, the default [loadRemoteResource](https://github.com/clean-css/clean-css/blob/master/lib/reader/load-remote-resource.js) logic is used. + +## Formatting options + +By default output CSS is formatted without any whitespace unless a `format` option is given. +First of all there are two shorthands: + +```js +new CleanCSS({ + format: 'beautify' // formats output in a really nice way +}) +``` + +and + +```js +new CleanCSS({ + format: 'keep-breaks' // formats output the default way but adds line breaks for improved readability +}) +``` + +however `format` option also accept a fine-grained set of options: + +```js +new CleanCSS({ + format: { + breaks: { // controls where to insert breaks + afterAtRule: false, // controls if a line break comes after an at-rule; e.g. `@charset`; defaults to `false` + afterBlockBegins: false, // controls if a line break comes after a block begins; e.g. `@media`; defaults to `false` + afterBlockEnds: false, // controls if a line break comes after a block ends, defaults to `false` + afterComment: false, // controls if a line break comes after a comment; defaults to `false` + afterProperty: false, // controls if a line break comes after a property; defaults to `false` + afterRuleBegins: false, // controls if a line break comes after a rule begins; defaults to `false` + afterRuleEnds: false, // controls if a line break comes after a rule ends; defaults to `false` + beforeBlockEnds: false, // controls if a line break comes before a block ends; defaults to `false` + betweenSelectors: false // controls if a line break comes between selectors; defaults to `false` + }, + breakWith: '\n', // controls the new line character, can be `'\r\n'` or `'\n'` (aliased as `'windows'` and `'unix'` or `'crlf'` and `'lf'`); defaults to system one, so former on Windows and latter on Unix + indentBy: 0, // controls number of characters to indent with; defaults to `0` + indentWith: 'space', // controls a character to indent with, can be `'space'` or `'tab'`; defaults to `'space'` + spaces: { // controls where to insert spaces + aroundSelectorRelation: false, // controls if spaces come around selector relations; e.g. `div > a`; defaults to `false` + beforeBlockBegins: false, // controls if a space comes before a block begins; e.g. `.block {`; defaults to `false` + beforeValue: false // controls if a space comes before a value; e.g. `width: 1rem`; defaults to `false` + }, + wrapAt: false, // controls maximum line length; defaults to `false` + semicolonAfterLastProperty: false // controls removing trailing semicolons in rule; defaults to `false` - means remove + } +}) +``` + +Also since clean-css 5.0 you can use numerical values for all line breaks, which will repeat a line break that many times, e.g: + +```js + new CleanCSS({ + format: { + breaks: { + afterAtRule: 2, + afterBlockBegins: 1, // 1 is synonymous with `true` + afterBlockEnds: 2, + afterComment: 1, + afterProperty: 1, + afterRuleBegins: 1, + afterRuleEnds: 1, + beforeBlockEnds: 1, + betweenSelectors: 0 // 0 is synonymous with `false` + } + } + }) +``` + +which will add nicer spacing between at rules and blocks. + +## Inlining options + +`inline` option whitelists which `@import` rules will be processed, e.g. + +```js +new CleanCSS({ + inline: ['local'] // default; enables local inlining only +}) +``` + +```js +new CleanCSS({ + inline: ['none'] // disables all inlining +}) +``` + +```js +// introduced in clean-css 4.1.0 + +new CleanCSS({ + inline: false // disables all inlining (alias to `['none']`) +}) +``` + +```js +new CleanCSS({ + inline: ['all'] // enables all inlining, same as ['local', 'remote'] +}) +``` + +```js +new CleanCSS({ + inline: ['local', 'mydomain.example.com'] // enables local inlining plus given remote source +}) +``` + +```js +new CleanCSS({ + inline: ['local', 'remote', '!fonts.googleapis.com'] // enables all inlining but from given remote source +}) +``` + +## Optimization levels + +The `level` option can be either `0`, `1` (default), or `2`, e.g. + +```js +new CleanCSS({ + level: 2 +}) +``` + +or a fine-grained configuration given via a hash. + +Please note that level 1 optimization options are generally safe while level 2 optimizations should be safe for most users. + +### Level 0 optimizations + +Level 0 optimizations simply means "no optimizations". Use it when you'd like to inline imports and / or rebase URLs but skip everything else. + +### Level 1 optimizations + +Level 1 optimizations (default) operate on single properties only, e.g. can remove units when not required, turn rgb colors to a shorter hex representation, remove comments, etc + +Here is a full list of available options: + +```js +new CleanCSS({ + level: { + 1: { + cleanupCharsets: true, // controls `@charset` moving to the front of a stylesheet; defaults to `true` + normalizeUrls: true, // controls URL normalization; defaults to `true` + optimizeBackground: true, // controls `background` property optimizations; defaults to `true` + optimizeBorderRadius: true, // controls `border-radius` property optimizations; defaults to `true` + optimizeFilter: true, // controls `filter` property optimizations; defaults to `true` + optimizeFont: true, // controls `font` property optimizations; defaults to `true` + optimizeFontWeight: true, // controls `font-weight` property optimizations; defaults to `true` + optimizeOutline: true, // controls `outline` property optimizations; defaults to `true` + removeEmpty: true, // controls removing empty rules and nested blocks; defaults to `true` + removeNegativePaddings: true, // controls removing negative paddings; defaults to `true` + removeQuotes: true, // controls removing quotes when unnecessary; defaults to `true` + removeWhitespace: true, // controls removing unused whitespace; defaults to `true` + replaceMultipleZeros: true, // contols removing redundant zeros; defaults to `true` + replaceTimeUnits: true, // controls replacing time units with shorter values; defaults to `true` + replaceZeroUnits: true, // controls replacing zero values with units; defaults to `true` + roundingPrecision: false, // rounds pixel values to `N` decimal places; `false` disables rounding; defaults to `false` + selectorsSortingMethod: 'standard', // denotes selector sorting method; can be `'natural'` or `'standard'`, `'none'`, or false (the last two since 4.1.0); defaults to `'standard'` + specialComments: 'all', // denotes a number of /*! ... */ comments preserved; defaults to `all` + tidyAtRules: true, // controls at-rules (e.g. `@charset`, `@import`) optimizing; defaults to `true` + tidyBlockScopes: true, // controls block scopes (e.g. `@media`) optimizing; defaults to `true` + tidySelectors: true, // controls selectors optimizing; defaults to `true`, + variableValueOptimizers: [] // controls value optimizers which are applied to variables + } + } +}); +``` + +There is an `all` shortcut for toggling all options at the same time, e.g. + +```js +new CleanCSS({ + level: { + 1: { + all: false, // set all values to `false` + tidySelectors: true // turns on optimizing selectors + } + } +}); +``` + +### Level 2 optimizations + +Level 2 optimizations operate at rules or multiple properties level, e.g. can remove duplicate rules, remove properties redefined further down a stylesheet, or restructure rules by moving them around. + +Please note that if level 2 optimizations are turned on then, unless explicitely disabled, level 1 optimizations are applied as well. + +Here is a full list of available options: + +```js +new CleanCSS({ + level: { + 2: { + mergeAdjacentRules: true, // controls adjacent rules merging; defaults to true + mergeIntoShorthands: true, // controls merging properties into shorthands; defaults to true + mergeMedia: true, // controls `@media` merging; defaults to true + mergeNonAdjacentRules: true, // controls non-adjacent rule merging; defaults to true + mergeSemantically: false, // controls semantic merging; defaults to false + overrideProperties: true, // controls property overriding based on understandability; defaults to true + removeEmpty: true, // controls removing empty rules and nested blocks; defaults to `true` + reduceNonAdjacentRules: true, // controls non-adjacent rule reducing; defaults to true + removeDuplicateFontRules: true, // controls duplicate `@font-face` removing; defaults to true + removeDuplicateMediaBlocks: true, // controls duplicate `@media` removing; defaults to true + removeDuplicateRules: true, // controls duplicate rules removing; defaults to true + removeUnusedAtRules: false, // controls unused at rule removing; defaults to false (available since 4.1.0) + restructureRules: false, // controls rule restructuring; defaults to false + skipProperties: [] // controls which properties won't be optimized, defaults to `[]` which means all will be optimized (since 4.1.0) + } + } +}); +``` + +There is an `all` shortcut for toggling all options at the same time, e.g. + +```js +new CleanCSS({ + level: { + 2: { + all: false, // sets all values to `false` + removeDuplicateRules: true // turns on removing duplicate rules + } + } +}); +``` + +## Plugins + +In clean-css version 5 and above you can define plugins which run alongside level 1 and level 2 optimizations, e.g. + +```js +var myPlugin = { + level1: { + property: function removeRepeatedBackgroundRepeat(_rule, property, _options) { + // So `background-repeat:no-repeat no-repeat` becomes `background-repeat:no-repeat` + if (property.name == 'background-repeat' && property.value.length == 2 && property.value[0][1] == property.value[1][1]) { + property.value.pop(); + property.dirty = true; + } + } + } +} + +new CleanCSS({plugins: [myPlugin]}) + +``` + +Search `test\module-test.js` for `plugins` or check out `lib/optimizer/level-1/property-optimizers` and `lib/optimizer/level-1/value-optimizers` for more examples. + +__Important__: To rewrite your old `transform` as a plugin, check out [this commit](https://github.com/clean-css/clean-css/commit/b6ddc523267fc42cf0f6bd1626a79cad97319e17#diff-a71ef45f934725cdb25860dc0b606bcd59e3acee9788cd6df4f9d05339e8a153). + +## Minify method + +Once configured clean-css provides a `minify` method to optimize a given CSS, e.g. + +```js +var output = new CleanCSS(options).minify(source); +``` + +The output of the `minify` method is a hash with following fields: + +```js +console.log(output.styles); // optimized output CSS as a string +console.log(output.sourceMap); // output source map if requested with `sourceMap` option +console.log(output.errors); // a list of errors raised +console.log(output.warnings); // a list of warnings raised +console.log(output.stats.originalSize); // original content size after import inlining +console.log(output.stats.minifiedSize); // optimized content size +console.log(output.stats.timeSpent); // time spent on optimizations in milliseconds +console.log(output.stats.efficiency); // `(originalSize - minifiedSize) / originalSize`, e.g. 0.25 if size is reduced from 100 bytes to 75 bytes +``` +Example: Minifying a CSS string: + +```js +const CleanCSS = require("clean-css"); + +const output = new CleanCSS().minify(` + + a { + color: blue; + } + div { + margin: 5px + } + +`); + +console.log(output); + +// Log: +{ + styles: 'a{color:#00f}div{margin:5px}', + stats: { + efficiency: 0.6704545454545454, + minifiedSize: 29, + originalSize: 88, + timeSpent: 6 + }, + errors: [], + inlinedStylesheets: [], + warnings: [] +} +``` + +The `minify` method also accepts an input source map, e.g. + +```js +var output = new CleanCSS(options).minify(source, inputSourceMap); +``` + +or a callback invoked when optimizations are finished, e.g. + +```js +new CleanCSS(options).minify(source, function (error, output) { + // `output` is the same as in the synchronous call above +}); +``` + +To optimize a single file, without reading it first, pass a path to it to `minify` method as follows: + +```js +var output = new CleanCSS(options).minify(['path/to/file.css']) +``` + +(if you won't enclose the path in an array, it will be treated as a CSS source instead). + +There are several ways to optimize multiple files at the same time, see [How to optimize multiple files?](#how-to-optimize-multiple-files). + +## Promise interface + +If you prefer clean-css to return a Promise object then you need to explicitely ask for it, e.g. + +```js +new CleanCSS({ returnPromise: true }) + .minify(source) + .then(function (output) { console.log(output.styles); }) + .catch(function (error) { // deal with errors }); +``` + +## CLI utility + +Clean-css has an associated command line utility that can be installed separately using `npm install clean-css-cli`. For more detailed information, please visit https://github.com/clean-css/clean-css-cli. + +# FAQ + +## How to optimize multiple files? + +It can be done either by passing an array of paths, or, when sources are already available, a hash or an array of hashes: + +```js +new CleanCSS().minify(['path/to/file/one', 'path/to/file/two']); +``` + +```js +new CleanCSS().minify({ + 'path/to/file/one': { + styles: 'contents of file one' + }, + 'path/to/file/two': { + styles: 'contents of file two' + } +}); +``` + +```js +new CleanCSS().minify([ + {'path/to/file/one': {styles: 'contents of file one'}}, + {'path/to/file/two': {styles: 'contents of file two'}} +]); +``` + +Passing an array of hashes allows you to explicitly specify the order in which the input files are concatenated. Whereas when you use a single hash the order is determined by the [traversal order of object properties](http://2ality.com/2015/10/property-traversal-order-es6.html) - available since 4.1.0. + +Important note - any `@import` rules already present in the hash will be resolved in memory. + +## How to process multiple files without concatenating them into one output file? + +Since clean-css 5.0 you can, when passing an array of paths, hash, or array of hashes (see above), ask clean-css not to join styles into one output, but instead return stylesheets optimized one by one, e.g. + +```js +var output = new CleanCSS({ batch: true }).minify(['path/to/file/one', 'path/to/file/two']); +var outputOfFile1 = output['path/to/file/one'].styles // all other fields, like errors, warnings, or stats are there too +var outputOfFile2 = output['path/to/file/two'].styles +``` + +## How to process remote `@import`s correctly? + +In order to inline remote `@import` statements you need to provide a callback to minify method as fetching remote assets is an asynchronous operation, e.g.: + +```js +var source = '@import url(http://example.com/path/to/remote/styles);'; +new CleanCSS({ inline: ['remote'] }).minify(source, function (error, output) { + // output.styles +}); +``` + +If you don't provide a callback, then remote `@import`s will be left as is. + +## How to apply arbitrary transformations to CSS properties? + +Please see [plugins](#plugins). + +## How to specify a custom rounding precision? + +The level 1 `roundingPrecision` optimization option accept a string with per-unit rounding precision settings, e.g. + +```js +new CleanCSS({ + level: { + 1: { + roundingPrecision: 'all=3,px=5' + } + } +}).minify(source) +``` + +which sets all units rounding precision to 3 digits except `px` unit precision of 5 digits. + +## How to optimize a stylesheet with custom `rpx` units? + +Since `rpx` is a non standard unit (see [#1074](https://github.com/clean-css/clean-css/issues/1074)), it will be dropped by default as an invalid value. + +However you can treat `rpx` units as regular ones: + +```js +new CleanCSS({ + compatibility: { + customUnits: { + rpx: true + } + } +}).minify(source) +``` + +## How to keep a CSS fragment intact? + +Note: available since 4.2.0. + +Wrap the CSS fragment in special comments which instruct clean-css to preserve it, e.g. + +```css +.block-1 { + color: red +} +/* clean-css ignore:start */ +.block-special { + color: transparent +} +/* clean-css ignore:end */ +.block-2 { + margin: 0 +} +``` + +Optimizing this CSS will result in the following output: + +```css +.block-1{color:red} +.block-special { + color: transparent +} +.block-2{margin:0} +``` + +## How to preserve a comment block? + +Use the `/*!` notation instead of the standard one `/*`: + +```css +/*! + Important comments included in optimized output. +*/ +``` + +## How to rebase relative image URLs? + +clean-css will handle it automatically for you in the following cases: + +* when full paths to input files are passed in as options; +* when correct paths are passed in via a hash; +* when `rebaseTo` is used with any of above two. + +## How to work with source maps? + +To generate a source map, use `sourceMap: true` option, e.g.: + +```js +new CleanCSS({ sourceMap: true, rebaseTo: pathToOutputDirectory }) + .minify(source, function (error, output) { + // access output.sourceMap for SourceMapGenerator object + // see https://github.com/mozilla/source-map/#sourcemapgenerator for more details +}); +``` + +You can also pass an input source map directly as a 2nd argument to `minify` method: + +```js +new CleanCSS({ sourceMap: true, rebaseTo: pathToOutputDirectory }) + .minify(source, inputSourceMap, function (error, output) { + // access output.sourceMap to access SourceMapGenerator object + // see https://github.com/mozilla/source-map/#sourcemapgenerator for more details +}); +``` + +or even multiple input source maps at once: + +```js +new CleanCSS({ sourceMap: true, rebaseTo: pathToOutputDirectory }).minify({ + 'path/to/source/1': { + styles: '...styles...', + sourceMap: '...source-map...' + }, + 'path/to/source/2': { + styles: '...styles...', + sourceMap: '...source-map...' + } +}, function (error, output) { + // access output.sourceMap as above +}); +``` + +## How to apply level 1 & 2 optimizations at the same time? + +Using the hash configuration specifying both optimization levels, e.g. + +```js +new CleanCSS({ + level: { + 1: { + all: true, + normalizeUrls: false + }, + 2: { + restructureRules: true + } + } +}) +``` + +will apply level 1 optimizations, except url normalization, and default level 2 optimizations with rule restructuring. + +## What level 2 optimizations do? + +All level 2 optimizations are dispatched [here](https://github.com/clean-css/clean-css/blob/master/lib/optimizer/level-2/optimize.js#L67), and this is what they do: + +* `recursivelyOptimizeBlocks` - does all the following operations on a nested block, like `@media` or `@keyframe`; +* `recursivelyOptimizeProperties` - optimizes properties in rulesets and flat at-rules, like @font-face, by splitting them into components (e.g. `margin` into `margin-(bottom|left|right|top)`), optimizing, and restoring them back. You may want to use `mergeIntoShorthands` option to control whether you want to turn multiple components into shorthands; +* `removeDuplicates` - gets rid of duplicate rulesets with exactly the same set of properties, e.g. when including a Sass / Less partial twice for no good reason; +* `mergeAdjacent` - merges adjacent rulesets with the same selector or rules; +* `reduceNonAdjacent` - identifies which properties are overridden in same-selector non-adjacent rulesets, and removes them; +* `mergeNonAdjacentBySelector` - identifies same-selector non-adjacent rulesets which can be moved (!) to be merged, requires all intermediate rulesets to not redefine the moved properties, or if redefined to have the same value; +* `mergeNonAdjacentByBody` - same as the one above but for same-selector non-adjacent rulesets; +* `restructure` - tries to reorganize different-selector different-rules rulesets so they take less space, e.g. `.one{padding:0}.two{margin:0}.one{margin-bottom:3px}` into `.two{margin:0}.one{padding:0;margin-bottom:3px}`; +* `removeDuplicateFontAtRules` - removes duplicated `@font-face` rules; +* `removeDuplicateMediaQueries` - removes duplicated `@media` nested blocks; +* `mergeMediaQueries` - merges non-adjacent `@media` at-rules by the same rules as `mergeNonAdjacentBy*` above; + +## What errors and warnings are? + +If clean-css encounters invalid CSS, it will try to remove the invalid part and continue optimizing the rest of the code. It will make you aware of the problem by generating an error or warning. Although clean-css can work with invalid CSS, it is always recommended that you fix warnings and errors in your CSS. + +Example: Minify invalid CSS, resulting in two warnings: + +```js +const CleanCSS = require("clean-css"); + +const output = new CleanCSS().minify(` + + a { + -notarealproperty-: 5px; + color: + } + div { + margin: 5px + } + +`); + +console.log(output); + +// Log: +{ + styles: 'div{margin:5px}', + stats: { + efficiency: 0.8695652173913043, + minifiedSize: 15, + originalSize: 115, + timeSpent: 1 + }, + errors: [], + inlinedStylesheets: [], + warnings: [ + "Invalid property name '-notarealproperty-' at 4:8. Ignoring.", + "Empty property 'color' at 5:8. Ignoring." + ] +} +``` + +Example: Minify invalid CSS, resulting in one error: + +```js +const CleanCSS = require("clean-css"); + +const output = new CleanCSS().minify(` + + @import "idontexist.css"; + a { + color: blue; + } + div { + margin: 5px + } + +`); + +console.log(output); + +// Log: +{ + styles: 'a{color:#00f}div{margin:5px}', + stats: { + efficiency: 0.7627118644067796, + minifiedSize: 28, + originalSize: 118, + timeSpent: 2 + }, + errors: [ + 'Ignoring local @import of "idontexist.css" as resource is missing.' + ], + inlinedStylesheets: [], + warnings: [] +} +``` +## Clean-css for Gulp +An example of how you can include clean-css in gulp +```js +const { src, dest, series } = require('gulp'); +const CleanCSS = require('clean-css'); +const concat = require('gulp-concat'); + +function css() { + const options = { + compatibility: '*', // (default) - Internet Explorer 10+ compatibility mode + inline: ['all'], // enables all inlining, same as ['local', 'remote'] + level: 2 // Optimization levels. The level option can be either 0, 1 (default), or 2, e.g. + // Please note that level 1 optimization options are generally safe while level 2 optimizations should be safe for most users. + }; + + return src('app/**/*.css') + .pipe(concat('style.min.css')) + .on('data', function(file) { + const buferFile = new CleanCSS(options).minify(file.contents) + return file.contents = Buffer.from(buferFile.styles) + }) + .pipe(dest('build')) +} +exports.css = series(css) +``` + +## How to use clean-css with build tools? + +There is a number of 3rd party plugins to popular build tools: + +* [Broccoli](https://github.com/broccolijs/broccoli#broccoli): [broccoli-clean-css](https://github.com/shinnn/broccoli-clean-css) +* [Brunch](http://brunch.io/): [clean-css-brunch](https://github.com/brunch/clean-css-brunch) +* [Grunt](http://gruntjs.com): [grunt-contrib-cssmin](https://github.com/gruntjs/grunt-contrib-cssmin) +* [Gulp](http://gulpjs.com/): [gulp-clean-css](https://github.com/scniro/gulp-clean-css) +* [Gulp](http://gulpjs.com/): [using vinyl-map as a wrapper - courtesy of @sogko](https://github.com/clean-css/clean-css/issues/342) +* [component-builder2](https://github.com/component/builder2.js): [builder-clean-css](https://github.com/poying/builder-clean-css) +* [Metalsmith](http://metalsmith.io): [metalsmith-clean-css](https://github.com/aymericbeaumet/metalsmith-clean-css) +* [Lasso](https://github.com/lasso-js/lasso): [lasso-clean-css](https://github.com/yomed/lasso-clean-css) +* [Start](https://github.com/start-runner/start): [start-clean-css](https://github.com/start-runner/clean-css) + +## How to use clean-css from web browser? + +* https://clean-css.github.io/ (official web interface) +* http://refresh-sf.com/ +* http://adamburgess.github.io/clean-css-online/ + +# Contributing + +See [CONTRIBUTING.md](https://github.com/clean-css/clean-css/blob/master/CONTRIBUTING.md). + +## How to get started? + +First clone the sources: + +```bash +git clone git@github.com:clean-css/clean-css.git +``` + +then install dependencies: + +```bash +cd clean-css +npm install +``` + +then use any of the following commands to verify your copy: + +```bash +npm run bench # for clean-css benchmarks (see [test/bench.js](https://github.com/clean-css/clean-css/blob/master/test/bench.js) for details) +npm run browserify # to create the browser-ready clean-css version +npm run check # to lint JS sources with [JSHint](https://github.com/jshint/jshint/) +npm test # to run all tests +``` + +# Acknowledgments + +Sorted alphabetically by GitHub handle: + +* [@abarre](https://github.com/abarre) (Anthony Barre) for improvements to `@import` processing; +* [@alexlamsl](https://github.com/alexlamsl) (Alex Lam S.L.) for testing early clean-css 4 versions, reporting bugs, and suggesting numerous improvements. +* [@altschuler](https://github.com/altschuler) (Simon Altschuler) for fixing `@import` processing inside comments; +* [@ben-eb](https://github.com/ben-eb) (Ben Briggs) for sharing ideas about CSS optimizations; +* [@davisjam](https://github.com/davisjam) (Jamie Davis) for disclosing ReDOS vulnerabilities; +* [@facelessuser](https://github.com/facelessuser) (Isaac) for pointing out a flaw in clean-css' stateless mode; +* [@grandrath](https://github.com/grandrath) (Martin Grandrath) for improving `minify` method source traversal in ES6; +* [@jmalonzo](https://github.com/jmalonzo) (Jan Michael Alonzo) for a patch removing node.js' old `sys` package; +* [@lukeapage](https://github.com/lukeapage) (Luke Page) for suggestions and testing the source maps feature; + Plus everyone else involved in [#125](https://github.com/clean-css/clean-css/issues/125) for pushing it forward; +* [@madwizard-thomas](https://github.com/madwizard-thomas) for sharing ideas about `@import` inlining and URL rebasing. +* [@ngyikp](https://github.com/ngyikp) (Ng Yik Phang) for testing early clean-css 4 versions, reporting bugs, and suggesting numerous improvements. +* [@wagenet](https://github.com/wagenet) (Peter Wagenet) for suggesting improvements to `@import` inlining behavior; +* [@venemo](https://github.com/venemo) (Timur Kristóf) for an outstanding contribution of advanced property optimizer for 2.2 release; +* [@vvo](https://github.com/vvo) (Vincent Voyer) for a patch with better empty element regex and for inspiring us to do many performance improvements in 0.4 release; +* [@xhmikosr](https://github.com/xhmikosr) for suggesting new features, like option to remove special comments and strip out URLs quotation, and pointing out numerous improvements like JSHint, media queries, etc. + +# License + +clean-css is released under the [MIT License](https://github.com/clean-css/clean-css/blob/master/LICENSE). diff --git a/igv_component/node_modules/clean-css/index.js b/igv_component/node_modules/clean-css/index.js new file mode 100644 index 0000000000000000000000000000000000000000..d7b05030ffda79a15ebf06044ce9af37c81a59eb --- /dev/null +++ b/igv_component/node_modules/clean-css/index.js @@ -0,0 +1 @@ +module.exports = require('./lib/clean'); diff --git a/igv_component/node_modules/clean-css/lib/clean.js b/igv_component/node_modules/clean-css/lib/clean.js new file mode 100644 index 0000000000000000000000000000000000000000..a3a744498401807f8b5ff6729e91d6d44246a0a1 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/clean.js @@ -0,0 +1,241 @@ +/** + * Clean-css - https://github.com/clean-css/clean-css + * Released under the terms of MIT license + */ + +var level0Optimize = require('./optimizer/level-0/optimize'); +var level1Optimize = require('./optimizer/level-1/optimize'); +var level2Optimize = require('./optimizer/level-2/optimize'); +var validator = require('./optimizer/validator'); + +var compatibilityFrom = require('./options/compatibility'); +var fetchFrom = require('./options/fetch'); +var formatFrom = require('./options/format').formatFrom; +var inlineFrom = require('./options/inline'); +var inlineRequestFrom = require('./options/inline-request'); +var inlineTimeoutFrom = require('./options/inline-timeout'); +var OptimizationLevel = require('./options/optimization-level').OptimizationLevel; +var optimizationLevelFrom = require('./options/optimization-level').optimizationLevelFrom; +var pluginsFrom = require('./options/plugins'); +var rebaseFrom = require('./options/rebase'); +var rebaseToFrom = require('./options/rebase-to'); + +var inputSourceMapTracker = require('./reader/input-source-map-tracker'); +var readSources = require('./reader/read-sources'); + +var serializeStyles = require('./writer/simple'); +var serializeStylesAndSourceMap = require('./writer/source-maps'); + +var CleanCSS = module.exports = function CleanCSS(options) { + options = options || {}; + + this.options = { + batch: !!options.batch, + compatibility: compatibilityFrom(options.compatibility), + explicitRebaseTo: 'rebaseTo' in options, + fetch: fetchFrom(options.fetch), + format: formatFrom(options.format), + inline: inlineFrom(options.inline), + inlineRequest: inlineRequestFrom(options.inlineRequest), + inlineTimeout: inlineTimeoutFrom(options.inlineTimeout), + level: optimizationLevelFrom(options.level), + plugins: pluginsFrom(options.plugins), + rebase: rebaseFrom(options.rebase, options.rebaseTo), + rebaseTo: rebaseToFrom(options.rebaseTo), + returnPromise: !!options.returnPromise, + sourceMap: !!options.sourceMap, + sourceMapInlineSources: !!options.sourceMapInlineSources + }; +}; + +// for compatibility with optimize-css-assets-webpack-plugin +CleanCSS.process = function(input, opts) { + var cleanCss; + var optsTo = opts.to; + + delete opts.to; + cleanCss = new CleanCSS(Object.assign({ + returnPromise: true, rebaseTo: optsTo + }, opts)); + + return cleanCss.minify(input) + .then(function(output) { + return { css: output.styles }; + }); +}; + +CleanCSS.prototype.minify = function(input, maybeSourceMap, maybeCallback) { + var options = this.options; + + if (options.returnPromise) { + return new Promise(function(resolve, reject) { + minifyAll(input, options, maybeSourceMap, function(errors, output) { + return errors + ? reject(errors) + : resolve(output); + }); + }); + } + return minifyAll(input, options, maybeSourceMap, maybeCallback); +}; + +function minifyAll(input, options, maybeSourceMap, maybeCallback) { + if (options.batch && Array.isArray(input)) { + return minifyInBatchesFromArray(input, options, maybeSourceMap, maybeCallback); + } if (options.batch && (typeof input == 'object')) { + return minifyInBatchesFromHash(input, options, maybeSourceMap, maybeCallback); + } + return minify(input, options, maybeSourceMap, maybeCallback); +} + +function minifyInBatchesFromArray(input, options, maybeSourceMap, maybeCallback) { + var callback = typeof maybeCallback == 'function' + ? maybeCallback + : (typeof maybeSourceMap == 'function' ? maybeSourceMap : null); + var errors = []; + var outputAsHash = {}; + var inputValue; + var i, l; + + function whenHashBatchDone(innerErrors, output) { + outputAsHash = Object.assign(outputAsHash, output); + + if (innerErrors !== null) { + errors = errors.concat(innerErrors); + } + } + + for (i = 0, l = input.length; i < l; i++) { + if (typeof input[i] == 'object') { + minifyInBatchesFromHash(input[i], options, whenHashBatchDone); + } else { + inputValue = input[i]; + + outputAsHash[inputValue] = minify([inputValue], options); + errors = errors.concat(outputAsHash[inputValue].errors); + } + } + + return callback + ? callback(errors.length > 0 ? errors : null, outputAsHash) + : outputAsHash; +} + +function minifyInBatchesFromHash(input, options, maybeSourceMap, maybeCallback) { + var callback = typeof maybeCallback == 'function' + ? maybeCallback + : (typeof maybeSourceMap == 'function' ? maybeSourceMap : null); + var errors = []; + var outputAsHash = {}; + var inputKey; + var inputValue; + + for (inputKey in input) { + inputValue = input[inputKey]; + + outputAsHash[inputKey] = minify(inputValue.styles, options, inputValue.sourceMap); + errors = errors.concat(outputAsHash[inputKey].errors); + } + + return callback + ? callback(errors.length > 0 ? errors : null, outputAsHash) + : outputAsHash; +} + +function minify(input, options, maybeSourceMap, maybeCallback) { + var sourceMap = typeof maybeSourceMap != 'function' + ? maybeSourceMap + : null; + var callback = typeof maybeCallback == 'function' + ? maybeCallback + : (typeof maybeSourceMap == 'function' ? maybeSourceMap : null); + var context = { + stats: { + efficiency: 0, + minifiedSize: 0, + originalSize: 0, + startedAt: Date.now(), + timeSpent: 0 + }, + cache: { specificity: {} }, + errors: [], + inlinedStylesheets: [], + inputSourceMapTracker: inputSourceMapTracker(), + localOnly: !callback, + options: options, + source: null, + sourcesContent: {}, + validator: validator(options.compatibility), + warnings: [] + }; + var implicitRebaseToWarning; + + if (sourceMap) { + context.inputSourceMapTracker.track(undefined, sourceMap); + } + + if (options.rebase && !options.explicitRebaseTo) { + implicitRebaseToWarning = 'You have set `rebase: true` without giving `rebaseTo` option, which, in this case, defaults to the current working directory. ' + + 'You are then warned this can lead to unexpected URL rebasing (aka here be dragons)! ' + + 'If you are OK with the clean-css output, then you can get rid of this warning by giving clean-css a `rebaseTo: process.cwd()` option.'; + context.warnings.push(implicitRebaseToWarning); + } + + return runner(context.localOnly)(function() { + return readSources(input, context, function(tokens) { + var serialize = context.options.sourceMap + ? serializeStylesAndSourceMap + : serializeStyles; + + var optimizedTokens = optimize(tokens, context); + var optimizedStyles = serialize(optimizedTokens, context); + var output = withMetadata(optimizedStyles, context); + + return callback + ? callback(context.errors.length > 0 ? context.errors : null, output) + : output; + }); + }); +} + +function runner(localOnly) { + // to always execute code asynchronously when a callback is given + // more at blog.izs.me/post/59142742143/designing-apis-for-asynchrony + return localOnly + ? function(callback) { return callback(); } + : process.nextTick; +} + +function optimize(tokens, context) { + var optimized = level0Optimize(tokens, context); + + optimized = OptimizationLevel.One in context.options.level + ? level1Optimize(tokens, context) + : tokens; + optimized = OptimizationLevel.Two in context.options.level + ? level2Optimize(tokens, context, true) + : optimized; + + return optimized; +} + +function withMetadata(output, context) { + output.stats = calculateStatsFrom(output.styles, context); + output.errors = context.errors; + output.inlinedStylesheets = context.inlinedStylesheets; + output.warnings = context.warnings; + + return output; +} + +function calculateStatsFrom(styles, context) { + var finishedAt = Date.now(); + var timeSpent = finishedAt - context.stats.startedAt; + + delete context.stats.startedAt; + context.stats.timeSpent = timeSpent; + context.stats.efficiency = 1 - styles.length / context.stats.originalSize; + context.stats.minifiedSize = styles.length; + + return context.stats; +} diff --git a/igv_component/node_modules/clean-css/lib/optimizer/clone.js b/igv_component/node_modules/clean-css/lib/optimizer/clone.js new file mode 100644 index 0000000000000000000000000000000000000000..e6a006f382f16b2235807d1cd07779da87048562 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/clone.js @@ -0,0 +1,33 @@ +var wrapSingle = require('./wrap-for-optimizing').single; + +var Token = require('../tokenizer/token'); + +function deep(property) { + var cloned = shallow(property); + for (var i = property.components.length - 1; i >= 0; i--) { + var component = shallow(property.components[i]); + component.value = property.components[i].value.slice(0); + cloned.components.unshift(component); + } + + cloned.dirty = true; + cloned.value = property.value.slice(0); + + return cloned; +} + +function shallow(property) { + var cloned = wrapSingle([ + Token.PROPERTY, + [Token.PROPERTY_NAME, property.name] + ]); + cloned.important = property.important; + cloned.hack = property.hack; + cloned.unused = false; + return cloned; +} + +module.exports = { + deep: deep, + shallow: shallow +}; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/configuration.js b/igv_component/node_modules/clean-css/lib/optimizer/configuration.js new file mode 100644 index 0000000000000000000000000000000000000000..9da654dd7496dd2082909eba20425fbfb31fb2b4 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/configuration.js @@ -0,0 +1,1640 @@ +// Contains the interpretation of CSS properties, as used by the property optimizer + +var breakUp = require('./configuration/break-up'); +var canOverride = require('./configuration/can-override'); +var restore = require('./configuration/restore'); + +var propertyOptimizers = require('./level-1/property-optimizers'); +var valueOptimizers = require('./level-1/value-optimizers'); + +var override = require('../utils/override'); + +// Properties to process +// Extend this object in order to add support for more properties in the optimizer. +// +// Each key in this object represents a CSS property and should be an object. +// Such an object contains properties that describe how the represented CSS property should be handled. +// Possible options: +// +// * components: array (Only specify for shorthand properties.) +// Contains the names of the granular properties this shorthand compacts. +// +// * canOverride: function +// Returns whether two tokens of this property can be merged with each other. +// This property has no meaning for shorthands. +// +// * defaultValue: string +// Specifies the default value of the property according to the CSS standard. +// For shorthand, this is used when every component is set to its default value, therefore it should be the shortest possible default value of all the components. +// +// * shortestValue: string +// Specifies the shortest possible value the property can possibly have. +// (Falls back to defaultValue if unspecified.) +// +// * breakUp: function (Only specify for shorthand properties.) +// Breaks the shorthand up to its components. +// +// * restore: function (Only specify for shorthand properties.) +// Puts the shorthand together from its components. +// +var configuration = { + animation: { + canOverride: canOverride.generic.components([ + canOverride.generic.time, + canOverride.generic.timingFunction, + canOverride.generic.time, + canOverride.property.animationIterationCount, + canOverride.property.animationDirection, + canOverride.property.animationFillMode, + canOverride.property.animationPlayState, + canOverride.property.animationName + ]), + components: [ + 'animation-duration', + 'animation-timing-function', + 'animation-delay', + 'animation-iteration-count', + 'animation-direction', + 'animation-fill-mode', + 'animation-play-state', + 'animation-name' + ], + breakUp: breakUp.multiplex(breakUp.animation), + defaultValue: 'none', + restore: restore.multiplex(restore.withoutDefaults), + shorthand: true, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.textQuotes, + valueOptimizers.time, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ], + vendorPrefixes: [ + '-moz-', + '-o-', + '-webkit-' + ] + }, + 'animation-delay': { + canOverride: canOverride.generic.time, + componentOf: [ + 'animation' + ], + defaultValue: '0s', + intoMultiplexMode: 'real', + valueOptimizers: [ + valueOptimizers.time, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ], + vendorPrefixes: [ + '-moz-', + '-o-', + '-webkit-' + ] + }, + 'animation-direction': { + canOverride: canOverride.property.animationDirection, + componentOf: [ + 'animation' + ], + defaultValue: 'normal', + intoMultiplexMode: 'real', + vendorPrefixes: [ + '-moz-', + '-o-', + '-webkit-' + ] + }, + 'animation-duration': { + canOverride: canOverride.generic.time, + componentOf: [ + 'animation' + ], + defaultValue: '0s', + intoMultiplexMode: 'real', + keepUnlessDefault: 'animation-delay', + valueOptimizers: [ + valueOptimizers.time, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ], + vendorPrefixes: [ + '-moz-', + '-o-', + '-webkit-' + ] + }, + 'animation-fill-mode': { + canOverride: canOverride.property.animationFillMode, + componentOf: [ + 'animation' + ], + defaultValue: 'none', + intoMultiplexMode: 'real', + vendorPrefixes: [ + '-moz-', + '-o-', + '-webkit-' + ] + }, + 'animation-iteration-count': { + canOverride: canOverride.property.animationIterationCount, + componentOf: [ + 'animation' + ], + defaultValue: '1', + intoMultiplexMode: 'real', + vendorPrefixes: [ + '-moz-', + '-o-', + '-webkit-' + ] + }, + 'animation-name': { + canOverride: canOverride.property.animationName, + componentOf: [ + 'animation' + ], + defaultValue: 'none', + intoMultiplexMode: 'real', + valueOptimizers: [ + valueOptimizers.textQuotes + ], + vendorPrefixes: [ + '-moz-', + '-o-', + '-webkit-' + ] + }, + 'animation-play-state': { + canOverride: canOverride.property.animationPlayState, + componentOf: [ + 'animation' + ], + defaultValue: 'running', + intoMultiplexMode: 'real', + vendorPrefixes: [ + '-moz-', + '-o-', + '-webkit-' + ] + }, + 'animation-timing-function': { + canOverride: canOverride.generic.timingFunction, + componentOf: [ + 'animation' + ], + defaultValue: 'ease', + intoMultiplexMode: 'real', + vendorPrefixes: [ + '-moz-', + '-o-', + '-webkit-' + ] + }, + background: { + canOverride: canOverride.generic.components([ + canOverride.generic.image, + canOverride.property.backgroundPosition, + canOverride.property.backgroundSize, + canOverride.property.backgroundRepeat, + canOverride.property.backgroundAttachment, + canOverride.property.backgroundOrigin, + canOverride.property.backgroundClip, + canOverride.generic.color + ]), + components: [ + 'background-image', + 'background-position', + 'background-size', + 'background-repeat', + 'background-attachment', + 'background-origin', + 'background-clip', + 'background-color' + ], + breakUp: breakUp.multiplex(breakUp.background), + defaultValue: '0 0', + propertyOptimizer: propertyOptimizers.background, + restore: restore.multiplex(restore.background), + shortestValue: '0', + shorthand: true, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.urlWhiteSpace, + valueOptimizers.fraction, + valueOptimizers.zero, + valueOptimizers.color, + valueOptimizers.urlPrefix, + valueOptimizers.urlQuotes + ] + }, + 'background-attachment': { + canOverride: canOverride.property.backgroundAttachment, + componentOf: [ + 'background' + ], + defaultValue: 'scroll', + intoMultiplexMode: 'real' + }, + 'background-clip': { + canOverride: canOverride.property.backgroundClip, + componentOf: [ + 'background' + ], + defaultValue: 'border-box', + intoMultiplexMode: 'real', + shortestValue: 'border-box' + }, + 'background-color': { + canOverride: canOverride.generic.color, + componentOf: [ + 'background' + ], + defaultValue: 'transparent', + intoMultiplexMode: 'real', // otherwise real color will turn into default since color appears in last multiplex only + multiplexLastOnly: true, + nonMergeableValue: 'none', + shortestValue: 'red', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.color + ] + }, + 'background-image': { + canOverride: canOverride.generic.image, + componentOf: [ + 'background' + ], + defaultValue: 'none', + intoMultiplexMode: 'default', + valueOptimizers: [ + valueOptimizers.urlWhiteSpace, + valueOptimizers.urlPrefix, + valueOptimizers.urlQuotes, + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero, + valueOptimizers.color + ] + }, + 'background-origin': { + canOverride: canOverride.property.backgroundOrigin, + componentOf: [ + 'background' + ], + defaultValue: 'padding-box', + intoMultiplexMode: 'real', + shortestValue: 'border-box' + }, + 'background-position': { + canOverride: canOverride.property.backgroundPosition, + componentOf: [ + 'background' + ], + defaultValue: ['0', '0'], + doubleValues: true, + intoMultiplexMode: 'real', + shortestValue: '0', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'background-repeat': { + canOverride: canOverride.property.backgroundRepeat, + componentOf: [ + 'background' + ], + defaultValue: ['repeat'], + doubleValues: true, + intoMultiplexMode: 'real' + }, + 'background-size': { + canOverride: canOverride.property.backgroundSize, + componentOf: [ + 'background' + ], + defaultValue: ['auto'], + doubleValues: true, + intoMultiplexMode: 'real', + shortestValue: '0 0', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + bottom: { + canOverride: canOverride.property.bottom, + defaultValue: 'auto', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + border: { + breakUp: breakUp.border, + canOverride: canOverride.generic.components([ + canOverride.generic.unit, + canOverride.property.borderStyle, + canOverride.generic.color + ]), + components: [ + 'border-width', + 'border-style', + 'border-color' + ], + defaultValue: 'none', + overridesShorthands: [ + 'border-bottom', + 'border-left', + 'border-right', + 'border-top' + ], + restore: restore.withoutDefaults, + shorthand: true, + shorthandComponents: true, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.zero, + valueOptimizers.color + ] + }, + 'border-bottom': { + breakUp: breakUp.border, + canOverride: canOverride.generic.components([ + canOverride.generic.unit, + canOverride.property.borderStyle, + canOverride.generic.color + ]), + components: [ + 'border-bottom-width', + 'border-bottom-style', + 'border-bottom-color' + ], + defaultValue: 'none', + restore: restore.withoutDefaults, + shorthand: true, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.zero, + valueOptimizers.color + ] + }, + 'border-bottom-color': { + canOverride: canOverride.generic.color, + componentOf: [ + 'border-bottom', + 'border-color' + ], + defaultValue: 'none', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.color + ] + }, + 'border-bottom-left-radius': { + canOverride: canOverride.generic.unit, + componentOf: [ + 'border-radius' + ], + defaultValue: '0', + propertyOptimizer: propertyOptimizers.borderRadius, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ], + vendorPrefixes: [ + '-moz-', + '-o-' + ] + }, + 'border-bottom-right-radius': { + canOverride: canOverride.generic.unit, + componentOf: [ + 'border-radius' + ], + defaultValue: '0', + propertyOptimizer: propertyOptimizers.borderRadius, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ], + vendorPrefixes: [ + '-moz-', + '-o-' + ] + }, + 'border-bottom-style': { + canOverride: canOverride.property.borderStyle, + componentOf: [ + 'border-bottom', + 'border-style' + ], + defaultValue: 'none' + }, + 'border-bottom-width': { + canOverride: canOverride.generic.unit, + componentOf: [ + 'border-bottom', + 'border-width' + ], + defaultValue: 'medium', + oppositeTo: 'border-top-width', + shortestValue: '0', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'border-collapse': { + canOverride: canOverride.property.borderCollapse, + defaultValue: 'separate' + }, + 'border-color': { + breakUp: breakUp.fourValues, + canOverride: canOverride.generic.components([ + canOverride.generic.color, + canOverride.generic.color, + canOverride.generic.color, + canOverride.generic.color + ]), + componentOf: [ + 'border' + ], + components: [ + 'border-top-color', + 'border-right-color', + 'border-bottom-color', + 'border-left-color' + ], + defaultValue: 'none', + restore: restore.fourValues, + shortestValue: 'red', + shorthand: true, + singleTypeComponents: true, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.color + ] + }, + 'border-left': { + breakUp: breakUp.border, + canOverride: canOverride.generic.components([ + canOverride.generic.unit, + canOverride.property.borderStyle, + canOverride.generic.color + ]), + components: [ + 'border-left-width', + 'border-left-style', + 'border-left-color' + ], + defaultValue: 'none', + restore: restore.withoutDefaults, + shorthand: true, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.zero, + valueOptimizers.color + ] + }, + 'border-left-color': { + canOverride: canOverride.generic.color, + componentOf: [ + 'border-color', + 'border-left' + ], + defaultValue: 'none', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.color + ] + }, + 'border-left-style': { + canOverride: canOverride.property.borderStyle, + componentOf: [ + 'border-left', + 'border-style' + ], + defaultValue: 'none' + }, + 'border-left-width': { + canOverride: canOverride.generic.unit, + componentOf: [ + 'border-left', + 'border-width' + ], + defaultValue: 'medium', + oppositeTo: 'border-right-width', + shortestValue: '0', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'border-radius': { + breakUp: breakUp.borderRadius, + canOverride: canOverride.generic.components([ + canOverride.generic.unit, + canOverride.generic.unit, + canOverride.generic.unit, + canOverride.generic.unit + ]), + components: [ + 'border-top-left-radius', + 'border-top-right-radius', + 'border-bottom-right-radius', + 'border-bottom-left-radius' + ], + defaultValue: '0', + propertyOptimizer: propertyOptimizers.borderRadius, + restore: restore.borderRadius, + shorthand: true, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ], + vendorPrefixes: [ + '-moz-', + '-o-' + ] + }, + 'border-right': { + breakUp: breakUp.border, + canOverride: canOverride.generic.components([ + canOverride.generic.unit, + canOverride.property.borderStyle, + canOverride.generic.color + ]), + components: [ + 'border-right-width', + 'border-right-style', + 'border-right-color' + ], + defaultValue: 'none', + restore: restore.withoutDefaults, + shorthand: true, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.color + ] + }, + 'border-right-color': { + canOverride: canOverride.generic.color, + componentOf: [ + 'border-color', + 'border-right' + ], + defaultValue: 'none', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.color + ] + }, + 'border-right-style': { + canOverride: canOverride.property.borderStyle, + componentOf: [ + 'border-right', + 'border-style' + ], + defaultValue: 'none' + }, + 'border-right-width': { + canOverride: canOverride.generic.unit, + componentOf: [ + 'border-right', + 'border-width' + ], + defaultValue: 'medium', + oppositeTo: 'border-left-width', + shortestValue: '0', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'border-style': { + breakUp: breakUp.fourValues, + canOverride: canOverride.generic.components([ + canOverride.property.borderStyle, + canOverride.property.borderStyle, + canOverride.property.borderStyle, + canOverride.property.borderStyle + ]), + componentOf: [ + 'border' + ], + components: [ + 'border-top-style', + 'border-right-style', + 'border-bottom-style', + 'border-left-style' + ], + defaultValue: 'none', + restore: restore.fourValues, + shorthand: true, + singleTypeComponents: true + }, + 'border-top': { + breakUp: breakUp.border, + canOverride: canOverride.generic.components([ + canOverride.generic.unit, + canOverride.property.borderStyle, + canOverride.generic.color + ]), + components: [ + 'border-top-width', + 'border-top-style', + 'border-top-color' + ], + defaultValue: 'none', + restore: restore.withoutDefaults, + shorthand: true, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.zero, + valueOptimizers.color, + valueOptimizers.unit + ] + }, + 'border-top-color': { + canOverride: canOverride.generic.color, + componentOf: [ + 'border-color', + 'border-top' + ], + defaultValue: 'none', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.color + ] + }, + 'border-top-left-radius': { + canOverride: canOverride.generic.unit, + componentOf: [ + 'border-radius' + ], + defaultValue: '0', + propertyOptimizer: propertyOptimizers.borderRadius, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ], + vendorPrefixes: [ + '-moz-', + '-o-' + ] + }, + 'border-top-right-radius': { + canOverride: canOverride.generic.unit, + componentOf: [ + 'border-radius' + ], + defaultValue: '0', + propertyOptimizer: propertyOptimizers.borderRadius, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ], + vendorPrefixes: [ + '-moz-', + '-o-' + ] + }, + 'border-top-style': { + canOverride: canOverride.property.borderStyle, + componentOf: [ + 'border-style', + 'border-top' + ], + defaultValue: 'none' + }, + 'border-top-width': { + canOverride: canOverride.generic.unit, + componentOf: [ + 'border-top', + 'border-width' + ], + defaultValue: 'medium', + oppositeTo: 'border-bottom-width', + shortestValue: '0', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'border-width': { + breakUp: breakUp.fourValues, + canOverride: canOverride.generic.components([ + canOverride.generic.unit, + canOverride.generic.unit, + canOverride.generic.unit, + canOverride.generic.unit + ]), + componentOf: [ + 'border' + ], + components: [ + 'border-top-width', + 'border-right-width', + 'border-bottom-width', + 'border-left-width' + ], + defaultValue: 'medium', + restore: restore.fourValues, + shortestValue: '0', + shorthand: true, + singleTypeComponents: true, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'box-shadow': { + propertyOptimizer: propertyOptimizers.boxShadow, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero, + valueOptimizers.color + ], + vendorPrefixes: [ + '-moz-', + '-ms-', + '-o-', + '-webkit-' + ] + }, + clear: { + canOverride: canOverride.property.clear, + defaultValue: 'none' + }, + clip: { + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + color: { + canOverride: canOverride.generic.color, + defaultValue: 'transparent', + shortestValue: 'red', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.color + ] + }, + 'column-gap': { + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + cursor: { + canOverride: canOverride.property.cursor, + defaultValue: 'auto' + }, + display: { canOverride: canOverride.property.display }, + filter: { + propertyOptimizer: propertyOptimizers.filter, + valueOptimizers: [ + valueOptimizers.fraction + ] + }, + float: { + canOverride: canOverride.property.float, + defaultValue: 'none' + }, + font: { + breakUp: breakUp.font, + canOverride: canOverride.generic.components([ + canOverride.property.fontStyle, + canOverride.property.fontVariant, + canOverride.property.fontWeight, + canOverride.property.fontStretch, + canOverride.generic.unit, + canOverride.generic.unit, + canOverride.property.fontFamily + ]), + components: [ + 'font-style', + 'font-variant', + 'font-weight', + 'font-stretch', + 'font-size', + 'line-height', + 'font-family' + ], + restore: restore.font, + shorthand: true, + valueOptimizers: [ + valueOptimizers.textQuotes + ] + }, + 'font-family': { + canOverride: canOverride.property.fontFamily, + defaultValue: 'user|agent|specific', + valueOptimizers: [ + valueOptimizers.textQuotes + ] + }, + 'font-size': { + canOverride: canOverride.generic.unit, + defaultValue: 'medium', + shortestValue: '0', + valueOptimizers: [ + valueOptimizers.fraction + ] + }, + 'font-stretch': { + canOverride: canOverride.property.fontStretch, + defaultValue: 'normal' + }, + 'font-style': { + canOverride: canOverride.property.fontStyle, + defaultValue: 'normal' + }, + 'font-variant': { + canOverride: canOverride.property.fontVariant, + defaultValue: 'normal' + }, + 'font-weight': { + canOverride: canOverride.property.fontWeight, + defaultValue: 'normal', + propertyOptimizer: propertyOptimizers.fontWeight, + shortestValue: '400' + }, + gap: { + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + height: { + canOverride: canOverride.generic.unit, + defaultValue: 'auto', + shortestValue: '0', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + left: { + canOverride: canOverride.property.left, + defaultValue: 'auto', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'letter-spacing': { + valueOptimizers: [ + valueOptimizers.fraction, + valueOptimizers.zero + ] + }, + 'line-height': { + canOverride: canOverride.generic.unitOrNumber, + defaultValue: 'normal', + shortestValue: '0', + valueOptimizers: [ + valueOptimizers.fraction, + valueOptimizers.zero + ] + }, + 'list-style': { + canOverride: canOverride.generic.components([ + canOverride.property.listStyleType, + canOverride.property.listStylePosition, + canOverride.property.listStyleImage + ]), + components: [ + 'list-style-type', + 'list-style-position', + 'list-style-image' + ], + breakUp: breakUp.listStyle, + restore: restore.withoutDefaults, + defaultValue: 'outside', // can't use 'disc' because that'd override default 'decimal' for
    + shortestValue: 'none', + shorthand: true + }, + 'list-style-image': { + canOverride: canOverride.generic.image, + componentOf: [ + 'list-style' + ], + defaultValue: 'none' + }, + 'list-style-position': { + canOverride: canOverride.property.listStylePosition, + componentOf: [ + 'list-style' + ], + defaultValue: 'outside', + shortestValue: 'inside' + }, + 'list-style-type': { + canOverride: canOverride.property.listStyleType, + componentOf: [ + 'list-style' + ], + // NOTE: we can't tell the real default value here, it's 'disc' for
      and 'decimal' for
        + // this is a hack, but it doesn't matter because this value will be either overridden or + // it will disappear at the final step anyway + defaultValue: 'decimal|disc', + shortestValue: 'none' + }, + margin: { + breakUp: breakUp.fourValues, + canOverride: canOverride.generic.components([ + canOverride.generic.unit, + canOverride.generic.unit, + canOverride.generic.unit, + canOverride.generic.unit + ]), + components: [ + 'margin-top', + 'margin-right', + 'margin-bottom', + 'margin-left' + ], + defaultValue: '0', + propertyOptimizer: propertyOptimizers.margin, + restore: restore.fourValues, + shorthand: true, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'margin-bottom': { + canOverride: canOverride.generic.unit, + componentOf: [ + 'margin' + ], + defaultValue: '0', + oppositeTo: 'margin-top', + propertyOptimizer: propertyOptimizers.margin, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'margin-inline-end': { + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'margin-inline-start': { + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'margin-left': { + canOverride: canOverride.generic.unit, + componentOf: [ + 'margin' + ], + defaultValue: '0', + oppositeTo: 'margin-right', + propertyOptimizer: propertyOptimizers.margin, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'margin-right': { + canOverride: canOverride.generic.unit, + componentOf: [ + 'margin' + ], + defaultValue: '0', + oppositeTo: 'margin-left', + propertyOptimizer: propertyOptimizers.margin, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'margin-top': { + canOverride: canOverride.generic.unit, + componentOf: [ + 'margin' + ], + defaultValue: '0', + oppositeTo: 'margin-bottom', + propertyOptimizer: propertyOptimizers.margin, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'max-height': { + canOverride: canOverride.generic.unit, + defaultValue: 'none', + shortestValue: '0', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'max-width': { + canOverride: canOverride.generic.unit, + defaultValue: 'none', + shortestValue: '0', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'min-height': { + canOverride: canOverride.generic.unit, + defaultValue: '0', + shortestValue: '0', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'min-width': { + canOverride: canOverride.generic.unit, + defaultValue: '0', + shortestValue: '0', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + opacity: { + valueOptimizers: [ + valueOptimizers.fraction, + valueOptimizers.precision + ] + }, + outline: { + canOverride: canOverride.generic.components([ + canOverride.generic.color, + canOverride.property.outlineStyle, + canOverride.generic.unit + ]), + components: [ + 'outline-color', + 'outline-style', + 'outline-width' + ], + breakUp: breakUp.outline, + restore: restore.withoutDefaults, + defaultValue: '0', + propertyOptimizer: propertyOptimizers.outline, + shorthand: true, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'outline-color': { + canOverride: canOverride.generic.color, + componentOf: [ + 'outline' + ], + defaultValue: 'invert', + shortestValue: 'red', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.color + ] + }, + 'outline-style': { + canOverride: canOverride.property.outlineStyle, + componentOf: [ + 'outline' + ], + defaultValue: 'none' + }, + 'outline-width': { + canOverride: canOverride.generic.unit, + componentOf: [ + 'outline' + ], + defaultValue: 'medium', + shortestValue: '0', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + overflow: { + canOverride: canOverride.property.overflow, + defaultValue: 'visible' + }, + 'overflow-x': { + canOverride: canOverride.property.overflow, + defaultValue: 'visible' + }, + 'overflow-y': { + canOverride: canOverride.property.overflow, + defaultValue: 'visible' + }, + padding: { + breakUp: breakUp.fourValues, + canOverride: canOverride.generic.components([ + canOverride.generic.unit, + canOverride.generic.unit, + canOverride.generic.unit, + canOverride.generic.unit + ]), + components: [ + 'padding-top', + 'padding-right', + 'padding-bottom', + 'padding-left' + ], + defaultValue: '0', + propertyOptimizer: propertyOptimizers.padding, + restore: restore.fourValues, + shorthand: true, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'padding-bottom': { + canOverride: canOverride.generic.unit, + componentOf: [ + 'padding' + ], + defaultValue: '0', + oppositeTo: 'padding-top', + propertyOptimizer: propertyOptimizers.padding, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'padding-left': { + canOverride: canOverride.generic.unit, + componentOf: [ + 'padding' + ], + defaultValue: '0', + oppositeTo: 'padding-right', + propertyOptimizer: propertyOptimizers.padding, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'padding-right': { + canOverride: canOverride.generic.unit, + componentOf: [ + 'padding' + ], + defaultValue: '0', + oppositeTo: 'padding-left', + propertyOptimizer: propertyOptimizers.padding, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'padding-top': { + canOverride: canOverride.generic.unit, + componentOf: [ + 'padding' + ], + defaultValue: '0', + oppositeTo: 'padding-bottom', + propertyOptimizer: propertyOptimizers.padding, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + position: { + canOverride: canOverride.property.position, + defaultValue: 'static' + }, + right: { + canOverride: canOverride.property.right, + defaultValue: 'auto', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'row-gap': { + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + src: { + valueOptimizers: [ + valueOptimizers.urlWhiteSpace, + valueOptimizers.urlPrefix, + valueOptimizers.urlQuotes + ] + }, + 'stroke-width': { + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'text-align': { + canOverride: canOverride.property.textAlign, + // NOTE: we can't tell the real default value here, as it depends on default text direction + // this is a hack, but it doesn't matter because this value will be either overridden or + // it will disappear anyway + defaultValue: 'left|right' + }, + 'text-decoration': { + canOverride: canOverride.property.textDecoration, + defaultValue: 'none' + }, + 'text-indent': { + canOverride: canOverride.property.textOverflow, + defaultValue: 'none', + valueOptimizers: [ + valueOptimizers.fraction, + valueOptimizers.zero + ] + }, + 'text-overflow': { + canOverride: canOverride.property.textOverflow, + defaultValue: 'none' + }, + 'text-shadow': { + canOverride: canOverride.property.textShadow, + defaultValue: 'none', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.zero, + valueOptimizers.color + ] + }, + top: { + canOverride: canOverride.property.top, + defaultValue: 'auto', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + transform: { + canOverride: canOverride.property.transform, + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.degrees, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ], + vendorPrefixes: [ + '-moz-', + '-ms-', + '-o-', + '-webkit-' + ] + }, + transition: { + breakUp: breakUp.multiplex(breakUp.transition), + canOverride: canOverride.generic.components([ + canOverride.property.transitionProperty, + canOverride.generic.time, + canOverride.generic.timingFunction, + canOverride.generic.time + ]), + components: [ + 'transition-property', + 'transition-duration', + 'transition-timing-function', + 'transition-delay' + ], + defaultValue: 'none', + restore: restore.multiplex(restore.withoutDefaults), + shorthand: true, + valueOptimizers: [ + valueOptimizers.time, + valueOptimizers.fraction + ], + vendorPrefixes: [ + '-moz-', + '-ms-', + '-o-', + '-webkit-' + ] + }, + 'transition-delay': { + canOverride: canOverride.generic.time, + componentOf: [ + 'transition' + ], + defaultValue: '0s', + intoMultiplexMode: 'real', + valueOptimizers: [ + valueOptimizers.time + ], + vendorPrefixes: [ + '-moz-', + '-ms-', + '-o-', + '-webkit-' + ] + }, + 'transition-duration': { + canOverride: canOverride.generic.time, + componentOf: [ + 'transition' + ], + defaultValue: '0s', + intoMultiplexMode: 'real', + keepUnlessDefault: 'transition-delay', + valueOptimizers: [ + valueOptimizers.time, + valueOptimizers.fraction + ], + vendorPrefixes: [ + '-moz-', + '-ms-', + '-o-', + '-webkit-' + ] + }, + 'transition-property': { + canOverride: canOverride.generic.propertyName, + componentOf: [ + 'transition' + ], + defaultValue: 'all', + intoMultiplexMode: 'placeholder', + placeholderValue: '_', // it's a short value that won't match any property and still be a valid `transition-property` + vendorPrefixes: [ + '-moz-', + '-ms-', + '-o-', + '-webkit-' + ] + }, + 'transition-timing-function': { + canOverride: canOverride.generic.timingFunction, + componentOf: [ + 'transition' + ], + defaultValue: 'ease', + intoMultiplexMode: 'real', + vendorPrefixes: [ + '-moz-', + '-ms-', + '-o-', + '-webkit-' + ] + }, + 'vertical-align': { + canOverride: canOverride.property.verticalAlign, + defaultValue: 'baseline', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + visibility: { + canOverride: canOverride.property.visibility, + defaultValue: 'visible' + }, + '-webkit-tap-highlight-color': { + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.color + ] + }, + '-webkit-margin-end': { + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'white-space': { + canOverride: canOverride.property.whiteSpace, + defaultValue: 'normal' + }, + width: { + canOverride: canOverride.generic.unit, + defaultValue: 'auto', + shortestValue: '0', + valueOptimizers: [ + valueOptimizers.whiteSpace, + valueOptimizers.fraction, + valueOptimizers.precision, + valueOptimizers.unit, + valueOptimizers.zero + ] + }, + 'z-index': { + canOverride: canOverride.property.zIndex, + defaultValue: 'auto' + } +}; + +// generate vendor-prefixed configuration +var vendorPrefixedConfiguration = {}; + +function cloneDescriptor(propertyName, prefix) { + var clonedDescriptor = override(configuration[propertyName], {}); + + if ('componentOf' in clonedDescriptor) { + clonedDescriptor.componentOf = clonedDescriptor.componentOf.map(function(shorthandName) { + return prefix + shorthandName; + }); + } + + if ('components' in clonedDescriptor) { + clonedDescriptor.components = clonedDescriptor.components.map(function(longhandName) { + return prefix + longhandName; + }); + } + + if ('keepUnlessDefault' in clonedDescriptor) { + clonedDescriptor.keepUnlessDefault = prefix + clonedDescriptor.keepUnlessDefault; + } + + return clonedDescriptor; +} + +for (var propertyName in configuration) { + var descriptor = configuration[propertyName]; + + if (!('vendorPrefixes' in descriptor)) { + continue; + } + + for (var i = 0; i < descriptor.vendorPrefixes.length; i++) { + var prefix = descriptor.vendorPrefixes[i]; + var clonedDescriptor = cloneDescriptor(propertyName, prefix); + delete clonedDescriptor.vendorPrefixes; + + vendorPrefixedConfiguration[prefix + propertyName] = clonedDescriptor; + } + + delete descriptor.vendorPrefixes; +} + +module.exports = override(configuration, vendorPrefixedConfiguration); diff --git a/igv_component/node_modules/clean-css/lib/optimizer/configuration/break-up.js b/igv_component/node_modules/clean-css/lib/optimizer/configuration/break-up.js new file mode 100644 index 0000000000000000000000000000000000000000..da069bf2473ac9d84a594465dd1e577d091f2957 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/configuration/break-up.js @@ -0,0 +1,656 @@ +var InvalidPropertyError = require('../invalid-property-error'); + +var wrapSingle = require('../wrap-for-optimizing').single; + +var Token = require('../../tokenizer/token'); +var Marker = require('../../tokenizer/marker'); + +var formatPosition = require('../../utils/format-position'); + +function _anyIsInherit(values) { + var i, l; + + for (i = 0, l = values.length; i < l; i++) { + if (values[i][1] == 'inherit') { + return true; + } + } + + return false; +} + +function _colorFilter(validator) { + return function(value) { + return value[1] == 'invert' || validator.isColor(value[1]) || validator.isPrefixed(value[1]); + }; +} + +function _styleFilter(validator) { + return function(value) { + return value[1] != 'inherit' && validator.isStyleKeyword(value[1]) && !validator.isColorFunction(value[1]); + }; +} + +function _wrapDefault(name, property, configuration) { + var descriptor = configuration[name]; + if (descriptor.doubleValues && descriptor.defaultValue.length == 2) { + return wrapSingle([ + Token.PROPERTY, + [Token.PROPERTY_NAME, name], + [Token.PROPERTY_VALUE, descriptor.defaultValue[0]], + [Token.PROPERTY_VALUE, descriptor.defaultValue[1]] + ]); + } if (descriptor.doubleValues && descriptor.defaultValue.length == 1) { + return wrapSingle([ + Token.PROPERTY, + [Token.PROPERTY_NAME, name], + [Token.PROPERTY_VALUE, descriptor.defaultValue[0]] + ]); + } + return wrapSingle([ + Token.PROPERTY, + [Token.PROPERTY_NAME, name], + [Token.PROPERTY_VALUE, descriptor.defaultValue] + ]); +} + +function _widthFilter(validator) { + return function(value) { + return value[1] != 'inherit' + && (validator.isWidth(value[1]) || validator.isUnit(value[1]) || validator.isDynamicUnit(value[1])) + && !validator.isStyleKeyword(value[1]) + && !validator.isColorFunction(value[1]); + }; +} + +function animation(property, configuration, validator) { + var duration = _wrapDefault(property.name + '-duration', property, configuration); + var timing = _wrapDefault(property.name + '-timing-function', property, configuration); + var delay = _wrapDefault(property.name + '-delay', property, configuration); + var iteration = _wrapDefault(property.name + '-iteration-count', property, configuration); + var direction = _wrapDefault(property.name + '-direction', property, configuration); + var fill = _wrapDefault(property.name + '-fill-mode', property, configuration); + var play = _wrapDefault(property.name + '-play-state', property, configuration); + var name = _wrapDefault(property.name + '-name', property, configuration); + var components = [duration, timing, delay, iteration, direction, fill, play, name]; + var values = property.value; + var value; + var durationSet = false; + var timingSet = false; + var delaySet = false; + var iterationSet = false; + var directionSet = false; + var fillSet = false; + var playSet = false; + var nameSet = false; + var i; + var l; + + if (property.value.length == 1 && property.value[0][1] == 'inherit') { + // eslint-disable-next-line max-len + duration.value = timing.value = delay.value = iteration.value = direction.value = fill.value = play.value = name.value = property.value; + return components; + } + + if (values.length > 1 && _anyIsInherit(values)) { + throw new InvalidPropertyError('Invalid animation values at ' + formatPosition(values[0][2][0]) + '. Ignoring.'); + } + + for (i = 0, l = values.length; i < l; i++) { + value = values[i]; + + if (validator.isTime(value[1]) && !durationSet) { + duration.value = [value]; + durationSet = true; + } else if (validator.isTime(value[1]) && !delaySet) { + delay.value = [value]; + delaySet = true; + } else if ((validator.isGlobal(value[1]) || validator.isTimingFunction(value[1])) && !timingSet) { + timing.value = [value]; + timingSet = true; + } else if ((validator.isAnimationIterationCountKeyword(value[1]) + || validator.isPositiveNumber(value[1])) + && !iterationSet) { + iteration.value = [value]; + iterationSet = true; + } else if (validator.isAnimationDirectionKeyword(value[1]) && !directionSet) { + direction.value = [value]; + directionSet = true; + } else if (validator.isAnimationFillModeKeyword(value[1]) && !fillSet) { + fill.value = [value]; + fillSet = true; + } else if (validator.isAnimationPlayStateKeyword(value[1]) && !playSet) { + play.value = [value]; + playSet = true; + } else if ((validator.isAnimationNameKeyword(value[1]) || validator.isIdentifier(value[1])) && !nameSet) { + name.value = [value]; + nameSet = true; + } else { + throw new InvalidPropertyError('Invalid animation value at ' + formatPosition(value[2][0]) + '. Ignoring.'); + } + } + + return components; +} + +function background(property, configuration, validator) { + var image = _wrapDefault('background-image', property, configuration); + var position = _wrapDefault('background-position', property, configuration); + var size = _wrapDefault('background-size', property, configuration); + var repeat = _wrapDefault('background-repeat', property, configuration); + var attachment = _wrapDefault('background-attachment', property, configuration); + var origin = _wrapDefault('background-origin', property, configuration); + var clip = _wrapDefault('background-clip', property, configuration); + var color = _wrapDefault('background-color', property, configuration); + var components = [image, position, size, repeat, attachment, origin, clip, color]; + var values = property.value; + + var positionSet = false; + var clipSet = false; + var originSet = false; + var repeatSet = false; + + var anyValueSet = false; + + if (property.value.length == 1 && property.value[0][1] == 'inherit') { + // NOTE: 'inherit' is not a valid value for background-attachment + color.value = image.value = repeat.value = position.value = size.value = origin.value = clip.value = property.value; + return components; + } + + if (property.value.length == 1 && property.value[0][1] == '0 0') { + return components; + } + + for (var i = values.length - 1; i >= 0; i--) { + var value = values[i]; + + if (validator.isBackgroundAttachmentKeyword(value[1])) { + attachment.value = [value]; + anyValueSet = true; + } else if (validator.isBackgroundClipKeyword(value[1]) || validator.isBackgroundOriginKeyword(value[1])) { + if (clipSet) { + origin.value = [value]; + originSet = true; + } else { + clip.value = [value]; + clipSet = true; + } + anyValueSet = true; + } else if (validator.isBackgroundRepeatKeyword(value[1])) { + if (repeatSet) { + repeat.value.unshift(value); + } else { + repeat.value = [value]; + repeatSet = true; + } + anyValueSet = true; + } else if (validator.isBackgroundPositionKeyword(value[1]) + || validator.isBackgroundSizeKeyword(value[1]) + || validator.isUnit(value[1]) + || validator.isDynamicUnit(value[1])) { + if (i > 0) { + var previousValue = values[i - 1]; + + if (previousValue[1] == Marker.FORWARD_SLASH) { + size.value = [value]; + } else if (i > 1 && values[i - 2][1] == Marker.FORWARD_SLASH) { + size.value = [previousValue, value]; + i -= 2; + } else { + if (!positionSet) { position.value = []; } + + position.value.unshift(value); + positionSet = true; + } + } else { + if (!positionSet) { position.value = []; } + + position.value.unshift(value); + positionSet = true; + } + anyValueSet = true; + } else if ((color.value[0][1] == configuration[color.name].defaultValue || color.value[0][1] == 'none') && (validator.isColor(value[1]) || validator.isPrefixed(value[1]))) { + color.value = [value]; + anyValueSet = true; + } else if (validator.isUrl(value[1]) || validator.isFunction(value[1])) { + image.value = [value]; + anyValueSet = true; + } + } + + if (clipSet && !originSet) { origin.value = clip.value.slice(0); } + + if (!anyValueSet) { + throw new InvalidPropertyError('Invalid background value at ' + formatPosition(values[0][2][0]) + '. Ignoring.'); + } + + return components; +} + +function borderRadius(property, configuration) { + var values = property.value; + var splitAt = -1; + + for (var i = 0, l = values.length; i < l; i++) { + if (values[i][1] == Marker.FORWARD_SLASH) { + splitAt = i; + break; + } + } + + if (splitAt === 0 || splitAt === values.length - 1) { + throw new InvalidPropertyError('Invalid border-radius value at ' + formatPosition(values[0][2][0]) + '. Ignoring.'); + } + + var target = _wrapDefault(property.name, property, configuration); + target.value = splitAt > -1 + ? values.slice(0, splitAt) + : values.slice(0); + target.components = fourValues(target, configuration); + + var remainder = _wrapDefault(property.name, property, configuration); + remainder.value = splitAt > -1 + ? values.slice(splitAt + 1) + : values.slice(0); + remainder.components = fourValues(remainder, configuration); + + for (var j = 0; j < 4; j++) { + target.components[j].multiplex = true; + target.components[j].value = target.components[j].value.concat(remainder.components[j].value); + } + + return target.components; +} + +function font(property, configuration, validator) { + var style = _wrapDefault('font-style', property, configuration); + var variant = _wrapDefault('font-variant', property, configuration); + var weight = _wrapDefault('font-weight', property, configuration); + var stretch = _wrapDefault('font-stretch', property, configuration); + var size = _wrapDefault('font-size', property, configuration); + var height = _wrapDefault('line-height', property, configuration); + var family = _wrapDefault('font-family', property, configuration); + var components = [style, variant, weight, stretch, size, height, family]; + var values = property.value; + var fuzzyMatched = 4; // style, variant, weight, and stretch + var index = 0; + var isStretchSet = false; + var isStretchValid; + var isStyleSet = false; + var isStyleValid; + var isVariantSet = false; + var isVariantValid; + var isWeightSet = false; + var isWeightValid; + var appendableFamilyName = false; + + if (!values[index]) { + throw new InvalidPropertyError('Missing font values at ' + formatPosition(property.all[property.position][1][2][0]) + '. Ignoring.'); + } + + if (values.length == 1 && values[0][1] == 'inherit') { + style.value = variant.value = weight.value = stretch.value = size.value = height.value = family.value = values; + return components; + } + + if (values.length == 1 + && (validator.isFontKeyword(values[0][1]) + || validator.isGlobal(values[0][1]) + || validator.isPrefixed(values[0][1])) + ) { + values[0][1] = Marker.INTERNAL + values[0][1]; + style.value = variant.value = weight.value = stretch.value = size.value = height.value = family.value = values; + return components; + } + + if (values.length < 2 || !_anyIsFontSize(values, validator) || !_anyIsFontFamily(values, validator)) { + throw new InvalidPropertyError('Invalid font values at ' + formatPosition(property.all[property.position][1][2][0]) + '. Ignoring.'); + } + + if (values.length > 1 && _anyIsInherit(values)) { + throw new InvalidPropertyError('Invalid font values at ' + formatPosition(values[0][2][0]) + '. Ignoring.'); + } + + // fuzzy match style, variant, weight, and stretch on first elements + while (index < fuzzyMatched) { + isStretchValid = validator.isFontStretchKeyword(values[index][1]) || validator.isGlobal(values[index][1]); + isStyleValid = validator.isFontStyleKeyword(values[index][1]) || validator.isGlobal(values[index][1]); + isVariantValid = validator.isFontVariantKeyword(values[index][1]) || validator.isGlobal(values[index][1]); + isWeightValid = validator.isFontWeightKeyword(values[index][1]) || validator.isGlobal(values[index][1]); + + if (isStyleValid && !isStyleSet) { + style.value = [values[index]]; + isStyleSet = true; + } else if (isVariantValid && !isVariantSet) { + variant.value = [values[index]]; + isVariantSet = true; + } else if (isWeightValid && !isWeightSet) { + weight.value = [values[index]]; + isWeightSet = true; + } else if (isStretchValid && !isStretchSet) { + stretch.value = [values[index]]; + isStretchSet = true; + } else if (isStyleValid + && isStyleSet + || isVariantValid + && isVariantSet + || isWeightValid + && isWeightSet + || isStretchValid + && isStretchSet) { + throw new InvalidPropertyError('Invalid font style / variant / weight / stretch value at ' + formatPosition(values[0][2][0]) + '. Ignoring.'); + } else { + break; + } + + index++; + } + + // now comes font-size ... + if (validator.isFontSizeKeyword(values[index][1]) + || validator.isUnit(values[index][1]) + && !validator.isDynamicUnit(values[index][1])) { + size.value = [values[index]]; + index++; + } else { + throw new InvalidPropertyError('Missing font size at ' + formatPosition(values[0][2][0]) + '. Ignoring.'); + } + + if (!values[index]) { + throw new InvalidPropertyError('Missing font family at ' + formatPosition(values[0][2][0]) + '. Ignoring.'); + } + + // ... and perhaps line-height + if (values[index] + && values[index][1] == Marker.FORWARD_SLASH + && values[index + 1] + && (validator.isLineHeightKeyword(values[index + 1][1]) + || validator.isUnit(values[index + 1][1]) + || validator.isNumber(values[index + 1][1]))) { + height.value = [values[index + 1]]; + index++; + index++; + } + + // ... and whatever comes next is font-family + family.value = []; + + while (values[index]) { + if (values[index][1] == Marker.COMMA) { + appendableFamilyName = false; + } else { + if (appendableFamilyName) { + family.value[family.value.length - 1][1] += Marker.SPACE + values[index][1]; + } else { + family.value.push(values[index]); + } + + appendableFamilyName = true; + } + + index++; + } + + if (family.value.length === 0) { + throw new InvalidPropertyError('Missing font family at ' + formatPosition(values[0][2][0]) + '. Ignoring.'); + } + + return components; +} + +function _anyIsFontSize(values, validator) { + var value; + var i, l; + + for (i = 0, l = values.length; i < l; i++) { + value = values[i]; + + if (validator.isFontSizeKeyword(value[1]) + || validator.isUnit(value[1]) + && !validator.isDynamicUnit(value[1]) + || validator.isFunction(value[1])) { + return true; + } + } + + return false; +} + +function _anyIsFontFamily(values, validator) { + var value; + var i, l; + + for (i = 0, l = values.length; i < l; i++) { + value = values[i]; + + if (validator.isIdentifier(value[1]) || validator.isQuotedText(value[1])) { + return true; + } + } + + return false; +} + +function fourValues(property, configuration) { + var componentNames = configuration[property.name].components; + var components = []; + var value = property.value; + + if (value.length < 1) { return []; } + + if (value.length < 2) { value[1] = value[0].slice(0); } + if (value.length < 3) { value[2] = value[0].slice(0); } + if (value.length < 4) { value[3] = value[1].slice(0); } + + for (var i = componentNames.length - 1; i >= 0; i--) { + var component = wrapSingle([ + Token.PROPERTY, + [Token.PROPERTY_NAME, componentNames[i]] + ]); + component.value = [value[i]]; + components.unshift(component); + } + + return components; +} + +function multiplex(splitWith) { + return function(property, configuration, validator) { + var splitsAt = []; + var values = property.value; + var i, j, l, m; + + // find split commas + for (i = 0, l = values.length; i < l; i++) { + if (values[i][1] == ',') { splitsAt.push(i); } + } + + if (splitsAt.length === 0) { return splitWith(property, configuration, validator); } + + var splitComponents = []; + + // split over commas, and into components + for (i = 0, l = splitsAt.length; i <= l; i++) { + var from = i === 0 ? 0 : splitsAt[i - 1] + 1; + var to = i < l ? splitsAt[i] : values.length; + + var _property = _wrapDefault(property.name, property, configuration); + _property.value = values.slice(from, to); + + if (_property.value.length > 0) { + splitComponents.push(splitWith(_property, configuration, validator)); + } + } + + var components = splitComponents[0]; + + // group component values from each split + for (i = 0, l = components.length; i < l; i++) { + components[i].multiplex = true; + + for (j = 1, m = splitComponents.length; j < m; j++) { + components[i].value.push([Token.PROPERTY_VALUE, Marker.COMMA]); + Array.prototype.push.apply(components[i].value, splitComponents[j][i].value); + } + } + + return components; + }; +} + +function listStyle(property, configuration, validator) { + var type = _wrapDefault('list-style-type', property, configuration); + var position = _wrapDefault('list-style-position', property, configuration); + var image = _wrapDefault('list-style-image', property, configuration); + var components = [type, position, image]; + + if (property.value.length == 1 && property.value[0][1] == 'inherit') { + type.value = position.value = image.value = [property.value[0]]; + return components; + } + + var values = property.value.slice(0); + var total = values.length; + var index = 0; + + // `image` first... + for (index = 0, total = values.length; index < total; index++) { + if (validator.isUrl(values[index][1]) || values[index][1] == '0') { + image.value = [values[index]]; + values.splice(index, 1); + break; + } + } + + // ... then `position` + for (index = 0, total = values.length; index < total; index++) { + if (validator.isListStylePositionKeyword(values[index][1])) { + position.value = [values[index]]; + values.splice(index, 1); + break; + } + } + + // ... and what's left is a `type` + if (values.length > 0 && (validator.isListStyleTypeKeyword(values[0][1]) || validator.isIdentifier(values[0][1]))) { + type.value = [values[0]]; + } + + return components; +} + +function transition(property, configuration, validator) { + var prop = _wrapDefault(property.name + '-property', property, configuration); + var duration = _wrapDefault(property.name + '-duration', property, configuration); + var timing = _wrapDefault(property.name + '-timing-function', property, configuration); + var delay = _wrapDefault(property.name + '-delay', property, configuration); + var components = [prop, duration, timing, delay]; + var values = property.value; + var value; + var durationSet = false; + var delaySet = false; + var propSet = false; + var timingSet = false; + var i; + var l; + + if (property.value.length == 1 && property.value[0][1] == 'inherit') { + prop.value = duration.value = timing.value = delay.value = property.value; + return components; + } + + if (values.length > 1 && _anyIsInherit(values)) { + throw new InvalidPropertyError('Invalid animation values at ' + formatPosition(values[0][2][0]) + '. Ignoring.'); + } + + for (i = 0, l = values.length; i < l; i++) { + value = values[i]; + + if (validator.isTime(value[1]) && !durationSet) { + duration.value = [value]; + durationSet = true; + } else if (validator.isTime(value[1]) && !delaySet) { + delay.value = [value]; + delaySet = true; + } else if ((validator.isGlobal(value[1]) || validator.isTimingFunction(value[1])) && !timingSet) { + timing.value = [value]; + timingSet = true; + } else if (validator.isIdentifier(value[1]) && !propSet) { + prop.value = [value]; + propSet = true; + } else { + throw new InvalidPropertyError('Invalid animation value at ' + formatPosition(value[2][0]) + '. Ignoring.'); + } + } + + return components; +} + +function widthStyleColor(property, configuration, validator) { + var descriptor = configuration[property.name]; + var components = [ + _wrapDefault(descriptor.components[0], property, configuration), + _wrapDefault(descriptor.components[1], property, configuration), + _wrapDefault(descriptor.components[2], property, configuration) + ]; + var color, style, width; + + for (var i = 0; i < 3; i++) { + var component = components[i]; + + if (component.name.indexOf('color') > 0) { color = component; } else if (component.name.indexOf('style') > 0) { style = component; } else { width = component; } + } + + if ((property.value.length == 1 && property.value[0][1] == 'inherit') + || (property.value.length == 3 && property.value[0][1] == 'inherit' && property.value[1][1] == 'inherit' && property.value[2][1] == 'inherit')) { + color.value = style.value = width.value = [property.value[0]]; + return components; + } + + var values = property.value.slice(0); + var match, matches; + + // NOTE: usually users don't follow the required order of parts in this shorthand, + // so we'll try to parse it caring as little about order as possible + + if (values.length > 0) { + matches = values.filter(_widthFilter(validator)); + match = matches.length > 1 && (matches[0][1] == 'none' || matches[0][1] == 'auto') ? matches[1] : matches[0]; + if (match) { + width.value = [match]; + values.splice(values.indexOf(match), 1); + } + } + + if (values.length > 0) { + match = values.filter(_styleFilter(validator))[0]; + if (match) { + style.value = [match]; + values.splice(values.indexOf(match), 1); + } + } + + if (values.length > 0) { + match = values.filter(_colorFilter(validator))[0]; + if (match) { + color.value = [match]; + values.splice(values.indexOf(match), 1); + } + } + + return components; +} + +module.exports = { + animation: animation, + background: background, + border: widthStyleColor, + borderRadius: borderRadius, + font: font, + fourValues: fourValues, + listStyle: listStyle, + multiplex: multiplex, + outline: widthStyleColor, + transition: transition +}; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/configuration/can-override.js b/igv_component/node_modules/clean-css/lib/optimizer/configuration/can-override.js new file mode 100644 index 0000000000000000000000000000000000000000..d5cb3fa08cf729dbd88666f06141ef93e7233af4 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/configuration/can-override.js @@ -0,0 +1,314 @@ +var understandable = require('./properties/understandable'); + +function animationIterationCount(validator, value1, value2) { + if (!understandable(validator, value1, value2, 0, true) + && !(validator.isAnimationIterationCountKeyword(value2) || validator.isPositiveNumber(value2))) { + return false; + } if (validator.isVariable(value1) && validator.isVariable(value2)) { + return true; + } + + return validator.isAnimationIterationCountKeyword(value2) || validator.isPositiveNumber(value2); +} + +function animationName(validator, value1, value2) { + if (!understandable(validator, value1, value2, 0, true) + && !(validator.isAnimationNameKeyword(value2) || validator.isIdentifier(value2))) { + return false; + } if (validator.isVariable(value1) && validator.isVariable(value2)) { + return true; + } + + return validator.isAnimationNameKeyword(value2) || validator.isIdentifier(value2); +} + +function areSameFunction(validator, value1, value2) { + if (!validator.isFunction(value1) || !validator.isFunction(value2)) { + return false; + } + + var function1Name = value1.substring(0, value1.indexOf('(')); + var function2Name = value2.substring(0, value2.indexOf('(')); + + var function1Value = value1.substring(function1Name.length + 1, value1.length - 1); + var function2Value = value2.substring(function2Name.length + 1, value2.length - 1); + + if (validator.isFunction(function1Value) || validator.isFunction(function2Value)) { + return function1Name === function2Name && areSameFunction(validator, function1Value, function2Value); + } + return function1Name === function2Name; +} + +function backgroundPosition(validator, value1, value2) { + if (!understandable(validator, value1, value2, 0, true) + && !(validator.isBackgroundPositionKeyword(value2) || validator.isGlobal(value2))) { + return false; + } if (validator.isVariable(value1) && validator.isVariable(value2)) { + return true; + } if (validator.isBackgroundPositionKeyword(value2) || validator.isGlobal(value2)) { + return true; + } + + return unit(validator, value1, value2); +} + +function backgroundSize(validator, value1, value2) { + if (!understandable(validator, value1, value2, 0, true) + && !(validator.isBackgroundSizeKeyword(value2) || validator.isGlobal(value2))) { + return false; + } if (validator.isVariable(value1) && validator.isVariable(value2)) { + return true; + } if (validator.isBackgroundSizeKeyword(value2) || validator.isGlobal(value2)) { + return true; + } + + return unit(validator, value1, value2); +} + +function color(validator, value1, value2) { + if (!understandable(validator, value1, value2, 0, true) && !validator.isColor(value2)) { + return false; + } if (validator.isVariable(value1) && validator.isVariable(value2)) { + return true; + } if (!validator.colorOpacity && (validator.isRgbColor(value1) || validator.isHslColor(value1))) { + return false; + } if (!validator.colorOpacity && (validator.isRgbColor(value2) || validator.isHslColor(value2))) { + return false; + } if (!validator.colorHexAlpha && (validator.isHexAlphaColor(value1) || validator.isHexAlphaColor(value2))) { + return false; + } if (validator.isColor(value1) && validator.isColor(value2)) { + return true; + } + + return sameFunctionOrValue(validator, value1, value2); +} + +function components(overrideCheckers) { + return function(validator, value1, value2, position) { + return overrideCheckers[position](validator, value1, value2); + }; +} + +function fontFamily(validator, value1, value2) { + return understandable(validator, value1, value2, 0, true); +} + +function image(validator, value1, value2) { + if (!understandable(validator, value1, value2, 0, true) && !validator.isImage(value2)) { + return false; + } if (validator.isVariable(value1) && validator.isVariable(value2)) { + return true; + } if (validator.isImage(value2)) { + return true; + } if (validator.isImage(value1)) { + return false; + } + + return sameFunctionOrValue(validator, value1, value2); +} + +function keyword(propertyName) { + return function(validator, value1, value2) { + if (!understandable(validator, value1, value2, 0, true) && !validator.isKeyword(propertyName)(value2)) { + return false; + } if (validator.isVariable(value1) && validator.isVariable(value2)) { + return true; + } + + return validator.isKeyword(propertyName)(value2); + }; +} + +function keywordWithGlobal(propertyName) { + return function(validator, value1, value2) { + if (!understandable(validator, value1, value2, 0, true) + && !(validator.isKeyword(propertyName)(value2) || validator.isGlobal(value2))) { + return false; + } if (validator.isVariable(value1) && validator.isVariable(value2)) { + return true; + } + + return validator.isKeyword(propertyName)(value2) || validator.isGlobal(value2); + }; +} + +function propertyName(validator, value1, value2) { + if (!understandable(validator, value1, value2, 0, true) && !validator.isIdentifier(value2)) { + return false; + } if (validator.isVariable(value1) && validator.isVariable(value2)) { + return true; + } + + return validator.isIdentifier(value2); +} + +function sameFunctionOrValue(validator, value1, value2) { + return areSameFunction(validator, value1, value2) + ? true + : value1 === value2; +} + +function textShadow(validator, value1, value2) { + if (!understandable(validator, value1, value2, 0, true) + && !(validator.isUnit(value2) + || validator.isColor(value2) + || validator.isGlobal(value2))) { + return false; + } if (validator.isVariable(value1) && validator.isVariable(value2)) { + return true; + } + + return validator.isUnit(value2) || validator.isColor(value2) || validator.isGlobal(value2); +} + +function time(validator, value1, value2) { + if (!understandable(validator, value1, value2, 0, true) && !validator.isTime(value2)) { + return false; + } if (validator.isVariable(value1) && validator.isVariable(value2)) { + return true; + } if (validator.isTime(value1) && !validator.isTime(value2)) { + return false; + } if (validator.isTime(value2)) { + return true; + } if (validator.isTime(value1)) { + return false; + } if (validator.isFunction(value1) + && !validator.isPrefixed(value1) + && validator.isFunction(value2) + && !validator.isPrefixed(value2)) { + return true; + } + + return sameFunctionOrValue(validator, value1, value2); +} + +function timingFunction(validator, value1, value2) { + if (!understandable(validator, value1, value2, 0, true) + && !(validator.isTimingFunction(value2) || validator.isGlobal(value2))) { + return false; + } if (validator.isVariable(value1) && validator.isVariable(value2)) { + return true; + } + + return validator.isTimingFunction(value2) || validator.isGlobal(value2); +} + +function unit(validator, value1, value2) { + if (!understandable(validator, value1, value2, 0, true) && !validator.isUnit(value2)) { + return false; + } if (validator.isVariable(value1) && validator.isVariable(value2)) { + return true; + } if (validator.isUnit(value1) && !validator.isUnit(value2)) { + return false; + } if (validator.isUnit(value2)) { + return true; + } if (validator.isUnit(value1)) { + return false; + } if (validator.isFunction(value1) + && !validator.isPrefixed(value1) + && validator.isFunction(value2) + && !validator.isPrefixed(value2)) { + return true; + } + + return sameFunctionOrValue(validator, value1, value2); +} + +function unitOrKeywordWithGlobal(propertyName) { + var byKeyword = keywordWithGlobal(propertyName); + + return function(validator, value1, value2) { + return unit(validator, value1, value2) || byKeyword(validator, value1, value2); + }; +} + +function unitOrNumber(validator, value1, value2) { + if (!understandable(validator, value1, value2, 0, true) + && !(validator.isUnit(value2) + || validator.isNumber(value2))) { + return false; + } if (validator.isVariable(value1) && validator.isVariable(value2)) { + return true; + } if ((validator.isUnit(value1) + || validator.isNumber(value1)) + && !(validator.isUnit(value2) + || validator.isNumber(value2))) { + return false; + } if (validator.isUnit(value2) || validator.isNumber(value2)) { + return true; + } if (validator.isUnit(value1) || validator.isNumber(value1)) { + return false; + } if (validator.isFunction(value1) + && !validator.isPrefixed(value1) + && validator.isFunction(value2) + && !validator.isPrefixed(value2)) { + return true; + } + + return sameFunctionOrValue(validator, value1, value2); +} + +function zIndex(validator, value1, value2) { + if (!understandable(validator, value1, value2, 0, true) && !validator.isZIndex(value2)) { + return false; + } if (validator.isVariable(value1) && validator.isVariable(value2)) { + return true; + } + + return validator.isZIndex(value2); +} + +module.exports = { + generic: { + color: color, + components: components, + image: image, + propertyName: propertyName, + time: time, + timingFunction: timingFunction, + unit: unit, + unitOrNumber: unitOrNumber + }, + property: { + animationDirection: keywordWithGlobal('animation-direction'), + animationFillMode: keyword('animation-fill-mode'), + animationIterationCount: animationIterationCount, + animationName: animationName, + animationPlayState: keywordWithGlobal('animation-play-state'), + backgroundAttachment: keyword('background-attachment'), + backgroundClip: keywordWithGlobal('background-clip'), + backgroundOrigin: keyword('background-origin'), + backgroundPosition: backgroundPosition, + backgroundRepeat: keyword('background-repeat'), + backgroundSize: backgroundSize, + bottom: unitOrKeywordWithGlobal('bottom'), + borderCollapse: keyword('border-collapse'), + borderStyle: keywordWithGlobal('*-style'), + clear: keywordWithGlobal('clear'), + cursor: keywordWithGlobal('cursor'), + display: keywordWithGlobal('display'), + float: keywordWithGlobal('float'), + left: unitOrKeywordWithGlobal('left'), + fontFamily: fontFamily, + fontStretch: keywordWithGlobal('font-stretch'), + fontStyle: keywordWithGlobal('font-style'), + fontVariant: keywordWithGlobal('font-variant'), + fontWeight: keywordWithGlobal('font-weight'), + listStyleType: keywordWithGlobal('list-style-type'), + listStylePosition: keywordWithGlobal('list-style-position'), + outlineStyle: keywordWithGlobal('*-style'), + overflow: keywordWithGlobal('overflow'), + position: keywordWithGlobal('position'), + right: unitOrKeywordWithGlobal('right'), + textAlign: keywordWithGlobal('text-align'), + textDecoration: keywordWithGlobal('text-decoration'), + textOverflow: keywordWithGlobal('text-overflow'), + textShadow: textShadow, + top: unitOrKeywordWithGlobal('top'), + transform: sameFunctionOrValue, + verticalAlign: unitOrKeywordWithGlobal('vertical-align'), + visibility: keywordWithGlobal('visibility'), + whiteSpace: keywordWithGlobal('white-space'), + zIndex: zIndex + } +}; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/configuration/properties/understandable.js b/igv_component/node_modules/clean-css/lib/optimizer/configuration/properties/understandable.js new file mode 100644 index 0000000000000000000000000000000000000000..60f34293e5a4136a0e87404fcd5f8ed25360f810 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/configuration/properties/understandable.js @@ -0,0 +1,15 @@ +var sameVendorPrefixes = require('../../vendor-prefixes').same; + +function understandable(validator, value1, value2, _position, isPaired) { + if (!sameVendorPrefixes(value1, value2)) { + return false; + } + + if (isPaired && validator.isVariable(value1) !== validator.isVariable(value2)) { + return false; + } + + return true; +} + +module.exports = understandable; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/configuration/restore.js b/igv_component/node_modules/clean-css/lib/optimizer/configuration/restore.js new file mode 100644 index 0000000000000000000000000000000000000000..af902088f809b414e1a33b9abf90f430ceb455d7 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/configuration/restore.js @@ -0,0 +1,294 @@ +var shallowClone = require('../clone').shallow; + +var Token = require('../../tokenizer/token'); +var Marker = require('../../tokenizer/marker'); + +function isInheritOnly(values) { + for (var i = 0, l = values.length; i < l; i++) { + var value = values[i][1]; + + if (value != 'inherit' && value != Marker.COMMA && value != Marker.FORWARD_SLASH) { return false; } + } + + return true; +} + +function background(property, configuration, lastInMultiplex) { + var components = property.components; + var restored = []; + var needsOne, needsBoth; + + function restoreValue(component) { + Array.prototype.unshift.apply(restored, component.value); + } + + function isDefaultValue(component) { + var descriptor = configuration[component.name]; + + if (descriptor.doubleValues && descriptor.defaultValue.length == 1) { + return component.value[0][1] == descriptor.defaultValue[0] + && (component.value[1] + ? component.value[1][1] == descriptor.defaultValue[0] + : true); + } if (descriptor.doubleValues && descriptor.defaultValue.length != 1) { + return component.value[0][1] == descriptor.defaultValue[0] + && ((component.value[1] ? component.value[1][1] : component.value[0][1]) + == descriptor.defaultValue[1]); + } + return component.value[0][1] == descriptor.defaultValue; + } + + for (var i = components.length - 1; i >= 0; i--) { + var component = components[i]; + var isDefault = isDefaultValue(component); + + if (component.name == 'background-clip') { + var originComponent = components[i - 1]; + var isOriginDefault = isDefaultValue(originComponent); + + needsOne = component.value[0][1] == originComponent.value[0][1]; + + needsBoth = !needsOne && ( + (isOriginDefault && !isDefault) + || (!isOriginDefault && !isDefault) + || (!isOriginDefault && isDefault && component.value[0][1] != originComponent.value[0][1])); + + if (needsOne) { + restoreValue(originComponent); + } else if (needsBoth) { + restoreValue(component); + restoreValue(originComponent); + } + + i--; + } else if (component.name == 'background-size') { + var positionComponent = components[i - 1]; + var isPositionDefault = isDefaultValue(positionComponent); + + needsOne = !isPositionDefault && isDefault; + + needsBoth = !needsOne + && (isPositionDefault && !isDefault || !isPositionDefault && !isDefault); + + if (needsOne) { + restoreValue(positionComponent); + } else if (needsBoth) { + restoreValue(component); + restored.unshift([Token.PROPERTY_VALUE, Marker.FORWARD_SLASH]); + restoreValue(positionComponent); + } else if (positionComponent.value.length == 1) { + restoreValue(positionComponent); + } + + i--; + } else { + if (isDefault || configuration[component.name].multiplexLastOnly && !lastInMultiplex) { continue; } + + restoreValue(component); + } + } + + if (restored.length === 0 && property.value.length == 1 && property.value[0][1] == '0') { restored.push(property.value[0]); } + + if (restored.length === 0) { restored.push([Token.PROPERTY_VALUE, configuration[property.name].defaultValue]); } + + if (isInheritOnly(restored)) { return [restored[0]]; } + + return restored; +} + +function borderRadius(property) { + if (property.multiplex) { + var horizontal = shallowClone(property); + var vertical = shallowClone(property); + + for (var i = 0; i < 4; i++) { + var component = property.components[i]; + + var horizontalComponent = shallowClone(property); + horizontalComponent.value = [component.value[0]]; + horizontal.components.push(horizontalComponent); + + var verticalComponent = shallowClone(property); + // FIXME: only shorthand compactor (see breakup#borderRadius) knows that border radius + // longhands have two values, whereas tokenizer does not care about populating 2nd value + // if it's missing, hence this fallback + verticalComponent.value = [component.value[1] || component.value[0]]; + vertical.components.push(verticalComponent); + } + + var horizontalValues = fourValues(horizontal); + var verticalValues = fourValues(vertical); + + if (horizontalValues.length == verticalValues.length + && horizontalValues[0][1] == verticalValues[0][1] + && (horizontalValues.length > 1 ? horizontalValues[1][1] == verticalValues[1][1] : true) + && (horizontalValues.length > 2 ? horizontalValues[2][1] == verticalValues[2][1] : true) + && (horizontalValues.length > 3 ? horizontalValues[3][1] == verticalValues[3][1] : true)) { + return horizontalValues; + } + return horizontalValues.concat([[Token.PROPERTY_VALUE, Marker.FORWARD_SLASH]]).concat(verticalValues); + } + return fourValues(property); +} + +function font(property, configuration) { + var components = property.components; + var restored = []; + var component; + var componentIndex = 0; + var fontFamilyIndex = 0; + + if (property.value[0][1].indexOf(Marker.INTERNAL) === 0) { + property.value[0][1] = property.value[0][1].substring(Marker.INTERNAL.length); + return property.value; + } + + // first four components are optional + while (componentIndex < 4) { + component = components[componentIndex]; + + if (component.value[0][1] != configuration[component.name].defaultValue) { + Array.prototype.push.apply(restored, component.value); + } + + componentIndex++; + } + + // then comes font-size + Array.prototype.push.apply(restored, components[componentIndex].value); + componentIndex++; + + // then may come line-height + if (components[componentIndex].value[0][1] != configuration[components[componentIndex].name].defaultValue) { + Array.prototype.push.apply(restored, [[Token.PROPERTY_VALUE, Marker.FORWARD_SLASH]]); + Array.prototype.push.apply(restored, components[componentIndex].value); + } + + componentIndex++; + + // then comes font-family + while (components[componentIndex].value[fontFamilyIndex]) { + restored.push(components[componentIndex].value[fontFamilyIndex]); + + if (components[componentIndex].value[fontFamilyIndex + 1]) { + restored.push([Token.PROPERTY_VALUE, Marker.COMMA]); + } + + fontFamilyIndex++; + } + + if (isInheritOnly(restored)) { + return [restored[0]]; + } + + return restored; +} + +function fourValues(property) { + var components = property.components; + var value1 = components[0].value[0]; + var value2 = components[1].value[0]; + var value3 = components[2].value[0]; + var value4 = components[3].value[0]; + + if (value1[1] == value2[1] && value1[1] == value3[1] && value1[1] == value4[1]) { + return [value1]; + } if (value1[1] == value3[1] && value2[1] == value4[1]) { + return [value1, value2]; + } if (value2[1] == value4[1]) { + return [value1, value2, value3]; + } + return [value1, value2, value3, value4]; +} + +function multiplex(restoreWith) { + return function(property, configuration) { + if (!property.multiplex) { return restoreWith(property, configuration, true); } + + var multiplexSize = 0; + var restored = []; + var componentMultiplexSoFar = {}; + var i, l; + + // At this point we don't know what's the multiplex size, e.g. how many background layers are there + for (i = 0, l = property.components[0].value.length; i < l; i++) { + if (property.components[0].value[i][1] == Marker.COMMA) { multiplexSize++; } + } + + for (i = 0; i <= multiplexSize; i++) { + var _property = shallowClone(property); + + // We split multiplex into parts and restore them one by one + for (var j = 0, m = property.components.length; j < m; j++) { + var componentToClone = property.components[j]; + var _component = shallowClone(componentToClone); + _property.components.push(_component); + + // The trick is some properties has more than one value, so we iterate over values looking for + // a multiplex separator - a comma + for (var k = componentMultiplexSoFar[_component.name] || 0, n = componentToClone.value.length; k < n; k++) { + if (componentToClone.value[k][1] == Marker.COMMA) { + componentMultiplexSoFar[_component.name] = k + 1; + break; + } + + _component.value.push(componentToClone.value[k]); + } + } + + // No we can restore shorthand value + var lastInMultiplex = i == multiplexSize; + var _restored = restoreWith(_property, configuration, lastInMultiplex); + Array.prototype.push.apply(restored, _restored); + + if (i < multiplexSize) { restored.push([Token.PROPERTY_VALUE, Marker.COMMA]); } + } + + return restored; + }; +} + +function withoutDefaults(property, configuration) { + var components = property.components; + var restored = []; + + for (var i = components.length - 1; i >= 0; i--) { + var component = components[i]; + var descriptor = configuration[component.name]; + + if (component.value[0][1] != descriptor.defaultValue || ('keepUnlessDefault' in descriptor) && !isDefault(components, configuration, descriptor.keepUnlessDefault)) { + restored.unshift(component.value[0]); + } + } + + if (restored.length === 0) { restored.push([Token.PROPERTY_VALUE, configuration[property.name].defaultValue]); } + + if (isInheritOnly(restored)) { return [restored[0]]; } + + return restored; +} + +function isDefault(components, configuration, propertyName) { + var component; + var i, l; + + for (i = 0, l = components.length; i < l; i++) { + component = components[i]; + + if (component.name == propertyName && component.value[0][1] == configuration[propertyName].defaultValue) { + return true; + } + } + + return false; +} + +module.exports = { + background: background, + borderRadius: borderRadius, + font: font, + fourValues: fourValues, + multiplex: multiplex, + withoutDefaults: withoutDefaults +}; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/hack.js b/igv_component/node_modules/clean-css/lib/optimizer/hack.js new file mode 100644 index 0000000000000000000000000000000000000000..812b5d5ecda8ccf28e52c0bf9626e779ef425778 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/hack.js @@ -0,0 +1,8 @@ +var Hack = { + ASTERISK: 'asterisk', + BANG: 'bang', + BACKSLASH: 'backslash', + UNDERSCORE: 'underscore' +}; + +module.exports = Hack; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/invalid-property-error.js b/igv_component/node_modules/clean-css/lib/optimizer/invalid-property-error.js new file mode 100644 index 0000000000000000000000000000000000000000..86d5b5f9b8066813b20abbedc40fe1fe63b8b829 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/invalid-property-error.js @@ -0,0 +1,10 @@ +function InvalidPropertyError(message) { + this.name = 'InvalidPropertyError'; + this.message = message; + this.stack = (new Error()).stack; +} + +InvalidPropertyError.prototype = Object.create(Error.prototype); +InvalidPropertyError.prototype.constructor = InvalidPropertyError; + +module.exports = InvalidPropertyError; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-0/optimize.js b/igv_component/node_modules/clean-css/lib/optimizer/level-0/optimize.js new file mode 100644 index 0000000000000000000000000000000000000000..2a56f89c6c58f89e441e12fbba4a91aea52190c8 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-0/optimize.js @@ -0,0 +1,6 @@ +function level0Optimize(tokens) { + // noop as level 0 means no optimizations! + return tokens; +} + +module.exports = level0Optimize; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/optimize.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/optimize.js new file mode 100644 index 0000000000000000000000000000000000000000..d0461e06e4a71e5970f1bdd8ba878fc2f57f4286 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/optimize.js @@ -0,0 +1,325 @@ +var sortSelectors = require('./sort-selectors'); +var tidyRules = require('./tidy-rules'); +var tidyBlock = require('./tidy-block'); +var tidyAtRule = require('./tidy-at-rule'); + +var Hack = require('../hack'); +var removeUnused = require('../remove-unused'); +var restoreFromOptimizing = require('../restore-from-optimizing'); +var wrapForOptimizing = require('../wrap-for-optimizing').all; + +var configuration = require('../configuration'); +var optimizers = require('./value-optimizers'); + +var OptimizationLevel = require('../../options/optimization-level').OptimizationLevel; + +var Token = require('../../tokenizer/token'); +var Marker = require('../../tokenizer/marker'); + +var formatPosition = require('../../utils/format-position'); + +var serializeRules = require('../../writer/one-time').rules; + +var CHARSET_TOKEN = '@charset'; +var CHARSET_REGEXP = new RegExp('^' + CHARSET_TOKEN, 'i'); + +var DEFAULT_ROUNDING_PRECISION = require('../../options/rounding-precision').DEFAULT; + +var VARIABLE_PROPERTY_NAME_PATTERN = /^--\S+$/; +var PROPERTY_NAME_PATTERN = /^(?:-chrome-|-[\w-]+\w|\w[\w-]+\w|\w{1,})$/; +var IMPORT_PREFIX_PATTERN = /^@import/i; +var URL_PREFIX_PATTERN = /^url\(/i; + +function startsAsUrl(value) { + return URL_PREFIX_PATTERN.test(value); +} + +function isImport(token) { + return IMPORT_PREFIX_PATTERN.test(token[1]); +} + +function isLegacyFilter(property) { + var value; + + if (property.name == 'filter' || property.name == '-ms-filter') { + value = property.value[0][1]; + + return value.indexOf('progid') > -1 + || value.indexOf('alpha') === 0 + || value.indexOf('chroma') === 0; + } + return false; +} + +function noop() {} + +function noopValueOptimizer(_name, value, _options) { return value; } + +function optimizeBody(rule, properties, context) { + var options = context.options; + var valueOptimizers; + var property, name, type, value; + var propertyToken; + var propertyOptimizer; + var serializedRule = serializeRules(rule); + var _properties = wrapForOptimizing(properties); + var pluginValueOptimizers = context.options.plugins.level1Value; + var pluginPropertyOptimizers = context.options.plugins.level1Property; + var isVariable; + var i, l; + + for (i = 0, l = _properties.length; i < l; i++) { + var j, k, m, n; + + property = _properties[i]; + name = property.name; + propertyOptimizer = configuration[name] && configuration[name].propertyOptimizer || noop; + valueOptimizers = configuration[name] && configuration[name].valueOptimizers || [optimizers.whiteSpace]; + isVariable = VARIABLE_PROPERTY_NAME_PATTERN.test(name); + + if (isVariable) { + valueOptimizers = options.variableOptimizers.length > 0 + ? options.variableOptimizers + : [optimizers.whiteSpace]; + } + + if (!isVariable && !PROPERTY_NAME_PATTERN.test(name)) { + propertyToken = property.all[property.position]; + context.warnings.push('Invalid property name \'' + name + '\' at ' + formatPosition(propertyToken[1][2][0]) + '. Ignoring.'); + property.unused = true; + continue; + } + + if (property.value.length === 0) { + propertyToken = property.all[property.position]; + context.warnings.push('Empty property \'' + name + '\' at ' + formatPosition(propertyToken[1][2][0]) + '. Ignoring.'); + property.unused = true; + continue; + } + + if (property.hack && ( + (property.hack[0] == Hack.ASTERISK || property.hack[0] == Hack.UNDERSCORE) + && !options.compatibility.properties.iePrefixHack + || property.hack[0] == Hack.BACKSLASH && !options.compatibility.properties.ieSuffixHack + || property.hack[0] == Hack.BANG && !options.compatibility.properties.ieBangHack)) { + property.unused = true; + continue; + } + + if (!options.compatibility.properties.ieFilters && isLegacyFilter(property)) { + property.unused = true; + continue; + } + + if (property.block) { + optimizeBody(rule, property.value[0][1], context); + continue; + } + + for (j = 0, m = property.value.length; j < m; j++) { + type = property.value[j][0]; + value = property.value[j][1]; + + if (type == Token.PROPERTY_BLOCK) { + property.unused = true; + context.warnings.push('Invalid value token at ' + formatPosition(value[0][1][2][0]) + '. Ignoring.'); + break; + } + + if (startsAsUrl(value) && !context.validator.isUrl(value)) { + property.unused = true; + context.warnings.push('Broken URL \'' + value + '\' at ' + formatPosition(property.value[j][2][0]) + '. Ignoring.'); + break; + } + + for (k = 0, n = valueOptimizers.length; k < n; k++) { + value = valueOptimizers[k](name, value, options); + } + + for (k = 0, n = pluginValueOptimizers.length; k < n; k++) { + value = pluginValueOptimizers[k](name, value, options); + } + + property.value[j][1] = value; + } + + propertyOptimizer(serializedRule, property, options); + + for (j = 0, m = pluginPropertyOptimizers.length; j < m; j++) { + pluginPropertyOptimizers[j](serializedRule, property, options); + } + } + + restoreFromOptimizing(_properties); + removeUnused(_properties); + removeComments(properties, options); +} + +function removeComments(tokens, options) { + var token; + var i; + + for (i = 0; i < tokens.length; i++) { + token = tokens[i]; + + if (token[0] != Token.COMMENT) { + continue; + } + + optimizeComment(token, options); + + if (token[1].length === 0) { + tokens.splice(i, 1); + i--; + } + } +} + +function optimizeComment(token, options) { + if (token[1][2] == Marker.EXCLAMATION && (options.level[OptimizationLevel.One].specialComments == 'all' || options.commentsKept < options.level[OptimizationLevel.One].specialComments)) { + options.commentsKept++; + return; + } + + token[1] = []; +} + +function cleanupCharsets(tokens) { + var hasCharset = false; + + for (var i = 0, l = tokens.length; i < l; i++) { + var token = tokens[i]; + + if (token[0] != Token.AT_RULE) { continue; } + + if (!CHARSET_REGEXP.test(token[1])) { continue; } + + if (hasCharset || token[1].indexOf(CHARSET_TOKEN) == -1) { + tokens.splice(i, 1); + i--; + l--; + } else { + hasCharset = true; + tokens.splice(i, 1); + tokens.unshift([Token.AT_RULE, token[1].replace(CHARSET_REGEXP, CHARSET_TOKEN)]); + } + } +} + +function buildUnitRegexp(options) { + var units = ['px', 'em', 'ex', 'cm', 'mm', 'in', 'pt', 'pc', '%']; + var otherUnits = ['ch', 'rem', 'vh', 'vm', 'vmax', 'vmin', 'vw']; + + otherUnits.forEach(function(unit) { + if (options.compatibility.units[unit]) { + units.push(unit); + } + }); + + return new RegExp('(^|\\s|\\(|,)0(?:' + units.join('|') + ')(\\W|$)', 'g'); +} + +function buildPrecisionOptions(roundingPrecision) { + var precisionOptions = { + matcher: null, + units: {} + }; + var optimizable = []; + var unit; + var value; + + for (unit in roundingPrecision) { + value = roundingPrecision[unit]; + + if (value != DEFAULT_ROUNDING_PRECISION) { + precisionOptions.units[unit] = {}; + precisionOptions.units[unit].value = value; + precisionOptions.units[unit].multiplier = 10 ** value; + + optimizable.push(unit); + } + } + + if (optimizable.length > 0) { + precisionOptions.enabled = true; + precisionOptions.decimalPointMatcher = new RegExp('(\\d)\\.($|' + optimizable.join('|') + ')($|\\W)', 'g'); + precisionOptions.zeroMatcher = new RegExp('(\\d*)(\\.\\d+)(' + optimizable.join('|') + ')', 'g'); + } + + return precisionOptions; +} + +function buildVariableOptimizers(options) { + return options.level[OptimizationLevel.One].variableValueOptimizers.map(function(optimizer) { + if (typeof (optimizer) == 'string') { + return optimizers[optimizer] || noopValueOptimizer; + } + + return optimizer; + }); +} + +function level1Optimize(tokens, context) { + var options = context.options; + var levelOptions = options.level[OptimizationLevel.One]; + var ie7Hack = options.compatibility.selectors.ie7Hack; + var adjacentSpace = options.compatibility.selectors.adjacentSpace; + var spaceAfterClosingBrace = options.compatibility.properties.spaceAfterClosingBrace; + var format = options.format; + var mayHaveCharset = false; + var afterRules = false; + + options.unitsRegexp = options.unitsRegexp || buildUnitRegexp(options); + options.precision = options.precision || buildPrecisionOptions(levelOptions.roundingPrecision); + options.commentsKept = options.commentsKept || 0; + options.variableOptimizers = options.variableOptimizers || buildVariableOptimizers(options); + + for (var i = 0, l = tokens.length; i < l; i++) { + var token = tokens[i]; + + switch (token[0]) { + case Token.AT_RULE: + token[1] = isImport(token) && afterRules ? '' : token[1]; + token[1] = levelOptions.tidyAtRules ? tidyAtRule(token[1]) : token[1]; + mayHaveCharset = true; + break; + case Token.AT_RULE_BLOCK: + optimizeBody(token[1], token[2], context); + afterRules = true; + break; + case Token.NESTED_BLOCK: + token[1] = levelOptions.tidyBlockScopes ? tidyBlock(token[1], spaceAfterClosingBrace) : token[1]; + level1Optimize(token[2], context); + afterRules = true; + break; + case Token.COMMENT: + optimizeComment(token, options); + break; + case Token.RULE: + token[1] = levelOptions.tidySelectors + ? tidyRules(token[1], !ie7Hack, adjacentSpace, format, context.warnings) + : token[1]; + token[1] = token[1].length > 1 ? sortSelectors(token[1], levelOptions.selectorsSortingMethod) : token[1]; + optimizeBody(token[1], token[2], context); + afterRules = true; + break; + } + + if (token[0] == Token.COMMENT + && token[1].length === 0 + || levelOptions.removeEmpty + && (token[1].length === 0 || (token[2] && token[2].length === 0))) { + tokens.splice(i, 1); + i--; + l--; + } + } + + if (levelOptions.cleanupCharsets && mayHaveCharset) { + cleanupCharsets(tokens); + } + + return tokens; +} + +module.exports = level1Optimize; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers.js new file mode 100644 index 0000000000000000000000000000000000000000..4cbc8ca2c4e4ea9d8744a5a1b883f4ef894fa1fa --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers.js @@ -0,0 +1,10 @@ +module.exports = { + background: require('./property-optimizers/background').level1.property, + boxShadow: require('./property-optimizers/box-shadow').level1.property, + borderRadius: require('./property-optimizers/border-radius').level1.property, + filter: require('./property-optimizers/filter').level1.property, + fontWeight: require('./property-optimizers/font-weight').level1.property, + margin: require('./property-optimizers/margin').level1.property, + outline: require('./property-optimizers/outline').level1.property, + padding: require('./property-optimizers/padding').level1.property +}; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/background.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/background.js new file mode 100644 index 0000000000000000000000000000000000000000..831cb16345324f36a970f8eea47f7cb72e495810 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/background.js @@ -0,0 +1,23 @@ +var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel; + +var plugin = { + level1: { + property: function background(_rule, property, options) { + var values = property.value; + + if (!options.level[OptimizationLevel.One].optimizeBackground) { + return; + } + + if (values.length == 1 && values[0][1] == 'none') { + values[0][1] = '0 0'; + } + + if (values.length == 1 && values[0][1] == 'transparent') { + values[0][1] = '0 0'; + } + } + } +}; + +module.exports = plugin; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/border-radius.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/border-radius.js new file mode 100644 index 0000000000000000000000000000000000000000..856f0a8e984fa30b2f2efe78ed410f73da0f4c6f --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/border-radius.js @@ -0,0 +1,29 @@ +var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel; + +var plugin = { + level1: { + property: function borderRadius(_rule, property, options) { + var values = property.value; + + if (!options.level[OptimizationLevel.One].optimizeBorderRadius) { + return; + } + + if (values.length == 3 && values[1][1] == '/' && values[0][1] == values[2][1]) { + property.value.splice(1); + property.dirty = true; + } else if (values.length == 5 && values[2][1] == '/' && values[0][1] == values[3][1] && values[1][1] == values[4][1]) { + property.value.splice(2); + property.dirty = true; + } else if (values.length == 7 && values[3][1] == '/' && values[0][1] == values[4][1] && values[1][1] == values[5][1] && values[2][1] == values[6][1]) { + property.value.splice(3); + property.dirty = true; + } else if (values.length == 9 && values[4][1] == '/' && values[0][1] == values[5][1] && values[1][1] == values[6][1] && values[2][1] == values[7][1] && values[3][1] == values[8][1]) { + property.value.splice(4); + property.dirty = true; + } + } + } +}; + +module.exports = plugin; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/box-shadow.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/box-shadow.js new file mode 100644 index 0000000000000000000000000000000000000000..b12a0a67200ee50a8a572e9f1aca4d8982e236f8 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/box-shadow.js @@ -0,0 +1,15 @@ +var plugin = { + level1: { + property: function boxShadow(_rule, property) { + var values = property.value; + + // remove multiple zeros + if (values.length == 4 && values[0][1] === '0' && values[1][1] === '0' && values[2][1] === '0' && values[3][1] === '0') { + property.value.splice(2); + property.dirty = true; + } + } + } +}; + +module.exports = plugin; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/filter.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/filter.js new file mode 100644 index 0000000000000000000000000000000000000000..60b3848c64402cbed93ec7f6d05c81c82549b426 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/filter.js @@ -0,0 +1,34 @@ +var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel; + +var ALPHA_OR_CHROMA_FILTER_PATTERN = /progid:DXImageTransform\.Microsoft\.(Alpha|Chroma)(\W)/; +var NO_SPACE_AFTER_COMMA_PATTERN = /,(\S)/g; +var WHITESPACE_AROUND_EQUALS_PATTERN = / ?= ?/g; + +var plugin = { + level1: { + property: function filter(_rule, property, options) { + if (!options.compatibility.properties.ieFilters) { + return; + } + + if (!options.level[OptimizationLevel.One].optimizeFilter) { + return; + } + + if (property.value.length == 1) { + property.value[0][1] = property.value[0][1].replace( + ALPHA_OR_CHROMA_FILTER_PATTERN, + function(match, filter, suffix) { + return filter.toLowerCase() + suffix; + } + ); + } + + property.value[0][1] = property.value[0][1] + .replace(NO_SPACE_AFTER_COMMA_PATTERN, ', $1') + .replace(WHITESPACE_AROUND_EQUALS_PATTERN, '='); + } + } +}; + +module.exports = plugin; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/font-weight.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/font-weight.js new file mode 100644 index 0000000000000000000000000000000000000000..41b548df3b36d3e2ab3f29eb23b8f805858e8934 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/font-weight.js @@ -0,0 +1,23 @@ +var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel; + +var plugin = { + level1: { + property: function fontWeight(_rule, property, options) { + var value = property.value[0][1]; + + if (!options.level[OptimizationLevel.One].optimizeFontWeight) { + return; + } + + if (value == 'normal') { + value = '400'; + } else if (value == 'bold') { + value = '700'; + } + + property.value[0][1] = value; + } + } +}; + +module.exports = plugin; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/margin.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/margin.js new file mode 100644 index 0000000000000000000000000000000000000000..b35e8cad89e6efb93f48706fb6f4324502392ee5 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/margin.js @@ -0,0 +1,21 @@ +var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel; + +var plugin = { + level1: { + property: function margin(_rule, property, options) { + var values = property.value; + + if (!options.level[OptimizationLevel.One].replaceMultipleZeros) { + return; + } + + // remove multiple zeros + if (values.length == 4 && values[0][1] === '0' && values[1][1] === '0' && values[2][1] === '0' && values[3][1] === '0') { + property.value.splice(1); + property.dirty = true; + } + } + } +}; + +module.exports = plugin; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/outline.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/outline.js new file mode 100644 index 0000000000000000000000000000000000000000..ca5c009eff913fdb815660babe13bfc3bf33d2ed --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/outline.js @@ -0,0 +1,19 @@ +var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel; + +var plugin = { + level1: { + property: function outline(_rule, property, options) { + var values = property.value; + + if (!options.level[OptimizationLevel.One].optimizeOutline) { + return; + } + + if (values.length == 1 && values[0][1] == 'none') { + values[0][1] = '0'; + } + } + } +}; + +module.exports = plugin; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/padding.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/padding.js new file mode 100644 index 0000000000000000000000000000000000000000..001258e8284c3c93166f6542e2ce58945b36906b --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/property-optimizers/padding.js @@ -0,0 +1,32 @@ +var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel; + +function isNegative(value) { + return value && value[1][0] == '-' && parseFloat(value[1]) < 0; +} + +var plugin = { + level1: { + property: function padding(_rule, property, options) { + var values = property.value; + + // remove multiple zeros + if (values.length == 4 && values[0][1] === '0' && values[1][1] === '0' && values[2][1] === '0' && values[3][1] === '0') { + property.value.splice(1); + property.dirty = true; + } + + // remove negative paddings + if (options.level[OptimizationLevel.One].removeNegativePaddings + && ( + isNegative(property.value[0]) + || isNegative(property.value[1]) + || isNegative(property.value[2]) + || isNegative(property.value[3]) + )) { + property.unused = true; + } + } + } +}; + +module.exports = plugin; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/sort-selectors.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/sort-selectors.js new file mode 100644 index 0000000000000000000000000000000000000000..e8d39c149c0f97f10500dd49059b4451b4f802f6 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/sort-selectors.js @@ -0,0 +1,23 @@ +var naturalCompare = require('../../utils/natural-compare'); + +function naturalSorter(scope1, scope2) { + return naturalCompare(scope1[1], scope2[1]); +} + +function standardSorter(scope1, scope2) { + return scope1[1] > scope2[1] ? 1 : -1; +} + +function sortSelectors(selectors, method) { + switch (method) { + case 'natural': + return selectors.sort(naturalSorter); + case 'standard': + return selectors.sort(standardSorter); + case 'none': + case false: + return selectors; + } +} + +module.exports = sortSelectors; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/tidy-at-rule.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/tidy-at-rule.js new file mode 100644 index 0000000000000000000000000000000000000000..a7b149fb51788b00ed8635bc59abe3c21ef95f8f --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/tidy-at-rule.js @@ -0,0 +1,9 @@ +function tidyAtRule(value) { + return value + .replace(/\s+/g, ' ') + .replace(/url\(\s+/g, 'url(') + .replace(/\s+\)/g, ')') + .trim(); +} + +module.exports = tidyAtRule; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/tidy-block.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/tidy-block.js new file mode 100644 index 0000000000000000000000000000000000000000..0cbbd99f6d2470a83dde837951a3eeccd7d93b8d --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/tidy-block.js @@ -0,0 +1,34 @@ +var SUPPORTED_COMPACT_BLOCK_MATCHER = /^@media\W/; +var SUPPORTED_QUOTE_REMOVAL_MATCHER = /^@(?:keyframes|-moz-keyframes|-o-keyframes|-webkit-keyframes)\W/; + +function tidyBlock(values, spaceAfterClosingBrace) { + var withoutSpaceAfterClosingBrace; + var withoutQuotes; + var i; + + for (i = values.length - 1; i >= 0; i--) { + withoutSpaceAfterClosingBrace = !spaceAfterClosingBrace && SUPPORTED_COMPACT_BLOCK_MATCHER.test(values[i][1]); + withoutQuotes = SUPPORTED_QUOTE_REMOVAL_MATCHER.test(values[i][1]); + + values[i][1] = values[i][1] + .replace(/\n|\r\n/g, ' ') + .replace(/\s+/g, ' ') + .replace(/(,|:|\() /g, '$1') + .replace(/ \)/g, ')'); + + if (withoutQuotes) { + values[i][1] = values[i][1] + .replace(/'([a-zA-Z][a-zA-Z\d\-_]+)'/, '$1') + .replace(/"([a-zA-Z][a-zA-Z\d\-_]+)"/, '$1'); + } + + if (withoutSpaceAfterClosingBrace) { + values[i][1] = values[i][1] + .replace(/\) /g, ')'); + } + } + + return values; +} + +module.exports = tidyBlock; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/tidy-rules.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/tidy-rules.js new file mode 100644 index 0000000000000000000000000000000000000000..bb467e298ff376ff378b355ad73ae91952736e66 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/tidy-rules.js @@ -0,0 +1,265 @@ +var Spaces = require('../../options/format').Spaces; +var Marker = require('../../tokenizer/marker'); +var formatPosition = require('../../utils/format-position'); + +var CASE_ATTRIBUTE_PATTERN = /[\s"'][iI]\s*\]/; +var CASE_RESTORE_PATTERN = /([\d\w])([iI])\]/g; +var DOUBLE_QUOTE_CASE_PATTERN = /="([a-zA-Z][a-zA-Z\d\-_]+)"([iI])/g; +var DOUBLE_QUOTE_PATTERN = /="([a-zA-Z][a-zA-Z\d\-_]+)"(\s|\])/g; +var HTML_COMMENT_PATTERN = /^(?:(?:)\s*)+/; +var SINGLE_QUOTE_CASE_PATTERN = /='([a-zA-Z][a-zA-Z\d\-_]+)'([iI])/g; +var SINGLE_QUOTE_PATTERN = /='([a-zA-Z][a-zA-Z\d\-_]+)'(\s|\])/g; +var RELATION_PATTERN = /[>+~]/; +var WHITESPACE_PATTERN = /\s/; + +var ASTERISK_PLUS_HTML_HACK = '*+html '; +var ASTERISK_FIRST_CHILD_PLUS_HTML_HACK = '*:first-child+html '; +var LESS_THAN = '<'; + +var PSEUDO_CLASSES_WITH_SELECTORS = [ + ':current', + ':future', + ':has', + ':host', + ':host-context', + ':is', + ':not', + ':past', + ':where' +]; + +function hasInvalidCharacters(value) { + var isEscaped; + var isInvalid = false; + var character; + var isQuote = false; + var i, l; + + for (i = 0, l = value.length; i < l; i++) { + character = value[i]; + + if (isEscaped) { + // continue as always + } else if (character == Marker.SINGLE_QUOTE || character == Marker.DOUBLE_QUOTE) { + isQuote = !isQuote; + } else if (!isQuote + && (character == Marker.CLOSE_CURLY_BRACKET + || character == Marker.EXCLAMATION + || character == LESS_THAN + || character == Marker.SEMICOLON) + ) { + isInvalid = true; + break; + } else if (!isQuote && i === 0 && RELATION_PATTERN.test(character)) { + isInvalid = true; + break; + } + + isEscaped = character == Marker.BACK_SLASH; + } + + return isInvalid; +} + +function removeWhitespace(value, format) { + var stripped = []; + var character; + var isNewLineNix; + var isNewLineWin; + var isEscaped; + var wasEscaped; + var isQuoted; + var isSingleQuoted; + var isDoubleQuoted; + var isAttribute; + var isRelation; + var isWhitespace; + var isSpaceAwarePseudoClass; + var roundBracketLevel = 0; + var wasComma = false; + var wasRelation = false; + var wasWhitespace = false; + var withCaseAttribute = CASE_ATTRIBUTE_PATTERN.test(value); + var spaceAroundRelation = format && format.spaces[Spaces.AroundSelectorRelation]; + var i, l; + + for (i = 0, l = value.length; i < l; i++) { + character = value[i]; + + isNewLineNix = character == Marker.NEW_LINE_NIX; + isNewLineWin = character == Marker.NEW_LINE_NIX && value[i - 1] == Marker.CARRIAGE_RETURN; + isQuoted = isSingleQuoted || isDoubleQuoted; + isRelation = !isAttribute && !isEscaped && roundBracketLevel === 0 && RELATION_PATTERN.test(character); + isWhitespace = WHITESPACE_PATTERN.test(character); + isSpaceAwarePseudoClass = roundBracketLevel == 1 && character == Marker.CLOSE_ROUND_BRACKET + ? false + : isSpaceAwarePseudoClass + || (roundBracketLevel === 0 && character == Marker.COLON && isPseudoClassWithSelectors(value, i)); + + if (wasEscaped && isQuoted && isNewLineWin) { + // swallow escaped new windows lines in comments + stripped.pop(); + stripped.pop(); + } else if (isEscaped && isQuoted && isNewLineNix) { + // swallow escaped new *nix lines in comments + stripped.pop(); + } else if (isEscaped) { + stripped.push(character); + } else if (character == Marker.OPEN_SQUARE_BRACKET && !isQuoted) { + stripped.push(character); + isAttribute = true; + } else if (character == Marker.CLOSE_SQUARE_BRACKET && !isQuoted) { + stripped.push(character); + isAttribute = false; + } else if (character == Marker.OPEN_ROUND_BRACKET && !isQuoted) { + stripped.push(character); + roundBracketLevel++; + } else if (character == Marker.CLOSE_ROUND_BRACKET && !isQuoted) { + stripped.push(character); + roundBracketLevel--; + } else if (character == Marker.SINGLE_QUOTE && !isQuoted) { + stripped.push(character); + isSingleQuoted = true; + } else if (character == Marker.DOUBLE_QUOTE && !isQuoted) { + stripped.push(character); + isDoubleQuoted = true; + } else if (character == Marker.SINGLE_QUOTE && isQuoted) { + stripped.push(character); + isSingleQuoted = false; + } else if (character == Marker.DOUBLE_QUOTE && isQuoted) { + stripped.push(character); + isDoubleQuoted = false; + } else if (isWhitespace && wasRelation && !spaceAroundRelation) { + continue; + } else if (!isWhitespace && wasRelation && spaceAroundRelation) { + stripped.push(Marker.SPACE); + stripped.push(character); + } else if (isWhitespace && !wasWhitespace && wasComma && roundBracketLevel > 0 && isSpaceAwarePseudoClass) { + // skip space + } else if (isWhitespace && !wasWhitespace && roundBracketLevel > 0 && isSpaceAwarePseudoClass) { + stripped.push(character); + } else if (isWhitespace && (isAttribute || roundBracketLevel > 0) && !isQuoted) { + // skip space + } else if (isWhitespace && wasWhitespace && !isQuoted) { + // skip extra space + } else if ((isNewLineWin || isNewLineNix) && (isAttribute || roundBracketLevel > 0) && isQuoted) { + // skip newline + } else if (isRelation && wasWhitespace && !spaceAroundRelation) { + stripped.pop(); + stripped.push(character); + } else if (isRelation && !wasWhitespace && spaceAroundRelation) { + stripped.push(Marker.SPACE); + stripped.push(character); + } else if (isWhitespace) { + stripped.push(Marker.SPACE); + } else { + stripped.push(character); + } + + wasEscaped = isEscaped; + isEscaped = character == Marker.BACK_SLASH; + wasRelation = isRelation; + wasWhitespace = isWhitespace; + wasComma = character == Marker.COMMA; + } + + return withCaseAttribute + ? stripped.join('').replace(CASE_RESTORE_PATTERN, '$1 $2]') + : stripped.join(''); +} + +function isPseudoClassWithSelectors(value, colonPosition) { + var pseudoClass = value.substring(colonPosition, value.indexOf(Marker.OPEN_ROUND_BRACKET, colonPosition)); + + return PSEUDO_CLASSES_WITH_SELECTORS.indexOf(pseudoClass) > -1; +} + +function removeQuotes(value) { + if (value.indexOf('\'') == -1 && value.indexOf('"') == -1) { + return value; + } + + return value + .replace(SINGLE_QUOTE_CASE_PATTERN, '=$1 $2') + .replace(SINGLE_QUOTE_PATTERN, '=$1$2') + .replace(DOUBLE_QUOTE_CASE_PATTERN, '=$1 $2') + .replace(DOUBLE_QUOTE_PATTERN, '=$1$2'); +} + +function replacePseudoClasses(value) { + return value + .replace('nth-child(1)', 'first-child') + .replace('nth-of-type(1)', 'first-of-type') + .replace('nth-of-type(even)', 'nth-of-type(2n)') + .replace('nth-child(even)', 'nth-child(2n)') + .replace('nth-of-type(2n+1)', 'nth-of-type(odd)') + .replace('nth-child(2n+1)', 'nth-child(odd)') + .replace('nth-last-child(1)', 'last-child') + .replace('nth-last-of-type(1)', 'last-of-type') + .replace('nth-last-of-type(even)', 'nth-last-of-type(2n)') + .replace('nth-last-child(even)', 'nth-last-child(2n)') + .replace('nth-last-of-type(2n+1)', 'nth-last-of-type(odd)') + .replace('nth-last-child(2n+1)', 'nth-last-child(odd)'); +} + +function tidyRules(rules, removeUnsupported, adjacentSpace, format, warnings) { + var list = []; + var repeated = []; + + function removeHTMLComment(rule, match) { + warnings.push('HTML comment \'' + match + '\' at ' + formatPosition(rule[2][0]) + '. Removing.'); + return ''; + } + + for (var i = 0, l = rules.length; i < l; i++) { + var rule = rules[i]; + var reduced = rule[1]; + + reduced = reduced.replace(HTML_COMMENT_PATTERN, removeHTMLComment.bind(null, rule)); + + if (hasInvalidCharacters(reduced)) { + warnings.push('Invalid selector \'' + rule[1] + '\' at ' + formatPosition(rule[2][0]) + '. Ignoring.'); + continue; + } + + reduced = removeWhitespace(reduced, format); + reduced = removeQuotes(reduced); + + if (adjacentSpace && reduced.indexOf('nav') > 0) { + reduced = reduced.replace(/\+nav(\S|$)/, '+ nav$1'); + } + + if (removeUnsupported && reduced.indexOf(ASTERISK_PLUS_HTML_HACK) > -1) { + continue; + } + + if (removeUnsupported && reduced.indexOf(ASTERISK_FIRST_CHILD_PLUS_HTML_HACK) > -1) { + continue; + } + + if (reduced.indexOf('*') > -1) { + reduced = reduced + .replace(/\*([:#.[])/g, '$1') + .replace(/^(:first-child)?\+html/, '*$1+html'); + } + + if (repeated.indexOf(reduced) > -1) { + continue; + } + + reduced = replacePseudoClasses(reduced); + + rule[1] = reduced; + repeated.push(reduced); + list.push(rule); + } + + if (list.length == 1 && list[0][1].length === 0) { + warnings.push('Empty selector \'' + list[0][1] + '\' at ' + formatPosition(list[0][2][0]) + '. Ignoring.'); + list = []; + } + + return list; +} + +module.exports = tidyRules; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers.js new file mode 100644 index 0000000000000000000000000000000000000000..03bd0f31f55c1aa27831f053cbb6d4a1f74848a5 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers.js @@ -0,0 +1,14 @@ +module.exports = { + color: require('./value-optimizers/color').level1.value, + degrees: require('./value-optimizers/degrees').level1.value, + fraction: require('./value-optimizers/fraction').level1.value, + precision: require('./value-optimizers/precision').level1.value, + textQuotes: require('./value-optimizers/text-quotes').level1.value, + time: require('./value-optimizers/time').level1.value, + unit: require('./value-optimizers/unit').level1.value, + urlPrefix: require('./value-optimizers/url-prefix').level1.value, + urlQuotes: require('./value-optimizers/url-quotes').level1.value, + urlWhiteSpace: require('./value-optimizers/url-whitespace').level1.value, + whiteSpace: require('./value-optimizers/whitespace').level1.value, + zero: require('./value-optimizers/zero').level1.value +}; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/color.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/color.js new file mode 100644 index 0000000000000000000000000000000000000000..58018c90869821eedeff744c79ddb610b6d6fdea --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/color.js @@ -0,0 +1,89 @@ +var shortenHex = require('./color/shorten-hex'); +var shortenHsl = require('./color/shorten-hsl'); +var shortenRgb = require('./color/shorten-rgb'); + +var split = require('../../../utils/split'); + +var ANY_COLOR_FUNCTION_PATTERN = /(rgb|rgba|hsl|hsla)\(([^()]+)\)/gi; +var COLOR_PREFIX_PATTERN = /#|rgb|hsl/gi; +var HEX_LONG_PATTERN = /(^|[^='"])#([0-9a-f]{6})/gi; +var HEX_SHORT_PATTERN = /(^|[^='"])#([0-9a-f]{3})/gi; +var HEX_VALUE_PATTERN = /[0-9a-f]/i; +var HSL_PATTERN = /hsl\((-?\d+),(-?\d+)%?,(-?\d+)%?\)/gi; +var RGBA_HSLA_PATTERN = /(rgb|hsl)a?\((-?\d+),(-?\d+%?),(-?\d+%?),(0*[1-9]+[0-9]*(\.?\d*)?)\)/gi; +var RGB_PATTERN = /rgb\((-?\d+),(-?\d+),(-?\d+)\)/gi; +var TRANSPARENT_FUNCTION_PATTERN = /(?:rgba|hsla)\(0,0%?,0%?,0\)/g; + +var plugin = { + level1: { + value: function color(name, value, options) { + if (!options.compatibility.properties.colors) { + return value; + } + + if (!value.match(COLOR_PREFIX_PATTERN)) { + return shortenHex(value); + } + + value = value + .replace(RGBA_HSLA_PATTERN, function(match, colorFn, p1, p2, p3, alpha) { + return (parseInt(alpha) >= 1 ? colorFn + '(' + [p1, p2, p3].join(',') + ')' : match); + }) + .replace(RGB_PATTERN, function(match, red, green, blue) { + return shortenRgb(red, green, blue); + }) + .replace(HSL_PATTERN, function(match, hue, saturation, lightness) { + return shortenHsl(hue, saturation, lightness); + }) + .replace(HEX_LONG_PATTERN, function(match, prefix, color, at, inputValue) { + var suffix = inputValue[at + match.length]; + + if (suffix && HEX_VALUE_PATTERN.test(suffix)) { + return match; + } if (color[0] == color[1] && color[2] == color[3] && color[4] == color[5]) { + return (prefix + '#' + color[0] + color[2] + color[4]).toLowerCase(); + } + return (prefix + '#' + color).toLowerCase(); + }) + .replace(HEX_SHORT_PATTERN, function(match, prefix, color) { + return prefix + '#' + color.toLowerCase(); + }) + .replace(ANY_COLOR_FUNCTION_PATTERN, function(match, colorFunction, colorDef) { + var tokens = colorDef.split(','); + var colorFnLowercase = colorFunction && colorFunction.toLowerCase(); + var applies = (colorFnLowercase == 'hsl' && tokens.length == 3) + || (colorFnLowercase == 'hsla' && tokens.length == 4) + || (colorFnLowercase == 'rgb' && tokens.length === 3 && colorDef.indexOf('%') > 0) + || (colorFnLowercase == 'rgba' && tokens.length == 4 && tokens[0].indexOf('%') > 0); + + if (!applies) { + return match; + } + + if (tokens[1].indexOf('%') == -1) { + tokens[1] += '%'; + } + + if (tokens[2].indexOf('%') == -1) { + tokens[2] += '%'; + } + + return colorFunction + '(' + tokens.join(',') + ')'; + }); + + if (options.compatibility.colors.opacity && name.indexOf('background') == -1) { + value = value.replace(TRANSPARENT_FUNCTION_PATTERN, function(match) { + if (split(value, ',').pop().indexOf('gradient(') > -1) { + return match; + } + + return 'transparent'; + }); + } + + return shortenHex(value); + } + } +}; + +module.exports = plugin; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/color/shorten-hex.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/color/shorten-hex.js new file mode 100644 index 0000000000000000000000000000000000000000..448ffd85842bdfaa2fdc932661815954f4370349 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/color/shorten-hex.js @@ -0,0 +1,189 @@ +var COLORS = { + aliceblue: '#f0f8ff', + antiquewhite: '#faebd7', + aqua: '#0ff', + aquamarine: '#7fffd4', + azure: '#f0ffff', + beige: '#f5f5dc', + bisque: '#ffe4c4', + black: '#000', + blanchedalmond: '#ffebcd', + blue: '#00f', + blueviolet: '#8a2be2', + brown: '#a52a2a', + burlywood: '#deb887', + cadetblue: '#5f9ea0', + chartreuse: '#7fff00', + chocolate: '#d2691e', + coral: '#ff7f50', + cornflowerblue: '#6495ed', + cornsilk: '#fff8dc', + crimson: '#dc143c', + cyan: '#0ff', + darkblue: '#00008b', + darkcyan: '#008b8b', + darkgoldenrod: '#b8860b', + darkgray: '#a9a9a9', + darkgreen: '#006400', + darkgrey: '#a9a9a9', + darkkhaki: '#bdb76b', + darkmagenta: '#8b008b', + darkolivegreen: '#556b2f', + darkorange: '#ff8c00', + darkorchid: '#9932cc', + darkred: '#8b0000', + darksalmon: '#e9967a', + darkseagreen: '#8fbc8f', + darkslateblue: '#483d8b', + darkslategray: '#2f4f4f', + darkslategrey: '#2f4f4f', + darkturquoise: '#00ced1', + darkviolet: '#9400d3', + deeppink: '#ff1493', + deepskyblue: '#00bfff', + dimgray: '#696969', + dimgrey: '#696969', + dodgerblue: '#1e90ff', + firebrick: '#b22222', + floralwhite: '#fffaf0', + forestgreen: '#228b22', + fuchsia: '#f0f', + gainsboro: '#dcdcdc', + ghostwhite: '#f8f8ff', + gold: '#ffd700', + goldenrod: '#daa520', + gray: '#808080', + green: '#008000', + greenyellow: '#adff2f', + grey: '#808080', + 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', + lightgray: '#d3d3d3', + lightgreen: '#90ee90', + lightgrey: '#d3d3d3', + lightpink: '#ffb6c1', + lightsalmon: '#ffa07a', + lightseagreen: '#20b2aa', + lightskyblue: '#87cefa', + lightslategray: '#778899', + lightslategrey: '#778899', + lightsteelblue: '#b0c4de', + lightyellow: '#ffffe0', + lime: '#0f0', + limegreen: '#32cd32', + linen: '#faf0e6', + magenta: '#ff00ff', + maroon: '#800000', + mediumaquamarine: '#66cdaa', + mediumblue: '#0000cd', + mediumorchid: '#ba55d3', + mediumpurple: '#9370db', + 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: '#db7093', + papayawhip: '#ffefd5', + peachpuff: '#ffdab9', + peru: '#cd853f', + pink: '#ffc0cb', + plum: '#dda0dd', + powderblue: '#b0e0e6', + purple: '#800080', + rebeccapurple: '#663399', + red: '#f00', + rosybrown: '#bc8f8f', + royalblue: '#4169e1', + saddlebrown: '#8b4513', + salmon: '#fa8072', + sandybrown: '#f4a460', + seagreen: '#2e8b57', + seashell: '#fff5ee', + sienna: '#a0522d', + silver: '#c0c0c0', + skyblue: '#87ceeb', + slateblue: '#6a5acd', + slategray: '#708090', + slategrey: '#708090', + snow: '#fffafa', + springgreen: '#00ff7f', + steelblue: '#4682b4', + tan: '#d2b48c', + teal: '#008080', + thistle: '#d8bfd8', + tomato: '#ff6347', + turquoise: '#40e0d0', + violet: '#ee82ee', + wheat: '#f5deb3', + white: '#fff', + whitesmoke: '#f5f5f5', + yellow: '#ff0', + yellowgreen: '#9acd32' +}; + +var toHex = {}; +var toName = {}; + +for (var name in COLORS) { + var hex = COLORS[name]; + + if (name.length < hex.length) { + toName[hex] = name; + } else { + toHex[name] = hex; + } +} + +var toHexPattern = new RegExp('(^| |,|\\))(' + Object.keys(toHex).join('|') + ')( |,|\\)|$)', 'ig'); +var toNamePattern = new RegExp('(' + Object.keys(toName).join('|') + ')([^a-f0-9]|$)', 'ig'); + +function hexConverter(match, prefix, colorValue, suffix) { + return prefix + toHex[colorValue.toLowerCase()] + suffix; +} + +function nameConverter(match, colorValue, suffix) { + return toName[colorValue.toLowerCase()] + suffix; +} + +function shortenHex(value) { + var hasHex = value.indexOf('#') > -1; + var shortened = value.replace(toHexPattern, hexConverter); + + if (shortened != value) { + shortened = shortened.replace(toHexPattern, hexConverter); + } + + return hasHex + ? shortened.replace(toNamePattern, nameConverter) + : shortened; +} + +module.exports = shortenHex; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/color/shorten-hsl.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/color/shorten-hsl.js new file mode 100644 index 0000000000000000000000000000000000000000..883bf69e9906060895a2ac03fae9415e712a32f2 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/color/shorten-hsl.js @@ -0,0 +1,54 @@ +// HSL to RGB converter. Both methods adapted from: +// http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript + +function hslToRgb(h, s, l) { + var r, g, b; + + // normalize hue orientation b/w 0 and 360 degrees + h %= 360; + if (h < 0) { h += 360; } + h = ~~h / 360; + + if (s < 0) { s = 0; } else if (s > 100) { s = 100; } + s = ~~s / 100; + + if (l < 0) { l = 0; } else if (l > 100) { l = 100; } + l = ~~l / 100; + + if (s === 0) { + r = g = b = l; // achromatic + } else { + var q = l < 0.5 + ? l * (1 + s) + : l + s - l * s; + var p = 2 * l - q; + r = hueToRgb(p, q, h + 1 / 3); + g = hueToRgb(p, q, h); + b = hueToRgb(p, q, h - 1 / 3); + } + + return [~~(r * 255), ~~(g * 255), ~~(b * 255)]; +} + +function hueToRgb(p, q, t) { + if (t < 0) { t += 1; } + if (t > 1) { t -= 1; } + if (t < 1 / 6) { return p + (q - p) * 6 * t; } + if (t < 1 / 2) { return q; } + if (t < 2 / 3) { return p + (q - p) * (2 / 3 - t) * 6; } + return p; +} + +function shortenHsl(hue, saturation, lightness) { + var asRgb = hslToRgb(hue, saturation, lightness); + var redAsHex = asRgb[0].toString(16); + var greenAsHex = asRgb[1].toString(16); + var blueAsHex = asRgb[2].toString(16); + + return '#' + + ((redAsHex.length == 1 ? '0' : '') + redAsHex) + + ((greenAsHex.length == 1 ? '0' : '') + greenAsHex) + + ((blueAsHex.length == 1 ? '0' : '') + blueAsHex); +} + +module.exports = shortenHsl; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/color/shorten-rgb.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/color/shorten-rgb.js new file mode 100644 index 0000000000000000000000000000000000000000..3c0a5fa31a4a99fbc805ac16abd60bf42a946e4d --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/color/shorten-rgb.js @@ -0,0 +1,10 @@ +function shortenRgb(red, green, blue) { + var normalizedRed = Math.max(0, Math.min(parseInt(red), 255)); + var normalizedGreen = Math.max(0, Math.min(parseInt(green), 255)); + var normalizedBlue = Math.max(0, Math.min(parseInt(blue), 255)); + + // Credit: Asen http://jsbin.com/UPUmaGOc/2/edit?js,console + return '#' + ('00000' + (normalizedRed << 16 | normalizedGreen << 8 | normalizedBlue).toString(16)).slice(-6); +} + +module.exports = shortenRgb; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/degrees.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/degrees.js new file mode 100644 index 0000000000000000000000000000000000000000..29b7672a4a17a62b0d92a388a72f0305f0712254 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/degrees.js @@ -0,0 +1,19 @@ +var ZERO_DEG_PATTERN = /\(0deg\)/g; + +var plugin = { + level1: { + value: function degrees(_name, value, options) { + if (!options.compatibility.properties.zeroUnits) { + return value; + } + + if (value.indexOf('0deg') == -1) { + return value; + } + + return value.replace(ZERO_DEG_PATTERN, '(0)'); + } + } +}; + +module.exports = plugin; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/fraction.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/fraction.js new file mode 100644 index 0000000000000000000000000000000000000000..c29a04c341184e4f5ec9e83c531c3a5aca99d764 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/fraction.js @@ -0,0 +1,72 @@ +var split = require('../../../utils/split'); +var startsAsUrl = require('./starts-as-url'); + +var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel; + +var EXPRESSION_PATTERN = /^expression\(.*\)$/; +var ANY_FUNCTION_PATTERN = /^(-(?:moz|ms|o|webkit)-[a-z-]+|[a-z-]+)\((.+)\)$/; +var TOKEN_SEPARATOR_PATTERN = /([\s,/])/; + +var DOT_ZERO_PATTERN = /(^|\D)\.0+(\D|$)/g; +var FRACTION_PATTERN = /\.([1-9]*)0+(\D|$)/g; +var LEADING_ZERO_FRACTION_PATTERN = /(^|\D)0\.(\d)/g; +var MINUS_ZERO_FRACTION_PATTERN = /([^\w\d-]|^)-0([^.]|$)/g; +var ZERO_PREFIXED_UNIT_PATTERN = /(^|\s)0+([1-9])/g; + +function optimizeRecursively(value) { + var functionTokens; + var tokens; + + if (startsAsUrl(value)) { + return value; + } + + if (EXPRESSION_PATTERN.test(value)) { + return value; + } + + functionTokens = ANY_FUNCTION_PATTERN.exec(value); + + if (!functionTokens) { + return optimizeFractions(value); + } + + tokens = split(functionTokens[2], TOKEN_SEPARATOR_PATTERN) + .map(function(token) { return optimizeRecursively(token); }); + + return functionTokens[1] + '(' + tokens.join('') + ')'; +} + +function optimizeFractions(value) { + if (value.indexOf('0') == -1) { + return value; + } + + if (value.indexOf('-') > -1) { + value = value + .replace(MINUS_ZERO_FRACTION_PATTERN, '$10$2') + .replace(MINUS_ZERO_FRACTION_PATTERN, '$10$2'); + } + + return value + .replace(ZERO_PREFIXED_UNIT_PATTERN, '$1$2') + .replace(DOT_ZERO_PATTERN, '$10$2') + .replace(FRACTION_PATTERN, function(match, nonZeroPart, suffix) { + return (nonZeroPart.length > 0 ? '.' : '') + nonZeroPart + suffix; + }) + .replace(LEADING_ZERO_FRACTION_PATTERN, '$1.$2'); +} + +var plugin = { + level1: { + value: function fraction(name, value, options) { + if (!options.level[OptimizationLevel.One].replaceZeroUnits) { + return value; + } + + return optimizeRecursively(value); + } + } +}; + +module.exports = plugin; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/precision.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/precision.js new file mode 100644 index 0000000000000000000000000000000000000000..6cbc359baee78a1d4828bd9d621f0d5b8cc88c1b --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/precision.js @@ -0,0 +1,22 @@ +var plugin = { + level1: { + value: function precision(_name, value, options) { + if (!options.precision.enabled || value.indexOf('.') === -1) { + return value; + } + + return value + .replace(options.precision.decimalPointMatcher, '$1$2$3') + .replace(options.precision.zeroMatcher, function(match, integerPart, fractionPart, unit) { + var multiplier = options.precision.units[unit].multiplier; + var parsedInteger = parseInt(integerPart); + var integer = Number.isNaN(parsedInteger) ? 0 : parsedInteger; + var fraction = parseFloat(fractionPart); + + return Math.round((integer + fraction) * multiplier) / multiplier + unit; + }); + } + } +}; + +module.exports = plugin; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/starts-as-url.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/starts-as-url.js new file mode 100644 index 0000000000000000000000000000000000000000..7b7f1477abf9e5f7480925154873257cac5aebd4 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/starts-as-url.js @@ -0,0 +1,7 @@ +var URL_PREFIX_PATTERN = /^url\(/i; + +function startsAsUrl(value) { + return URL_PREFIX_PATTERN.test(value); +} + +module.exports = startsAsUrl; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/text-quotes.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/text-quotes.js new file mode 100644 index 0000000000000000000000000000000000000000..0992342816dcff3216320f96e64ae2b472471cd6 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/text-quotes.js @@ -0,0 +1,31 @@ +var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel; + +var LOCAL_PREFIX_PATTERN = /^local\(/i; +var QUOTED_PATTERN = /^('.*'|".*")$/; +var QUOTED_BUT_SAFE_PATTERN = /^['"][a-zA-Z][a-zA-Z\d\-_]+['"]$/; +// eslint-disable-next-line max-len +var GENERIC_FONT_FAMILY_PATTERN = /^['"](?:cursive|default|emoji|fangsong|fantasy|inherit|initial|math|monospace|revert|revert-layer|sans-serif|serif|system-ui|ui-monospace|ui-rounded|ui-sans-serif|ui-serif|unset)['"]$/; + +var plugin = { + level1: { + value: function textQuotes(name, value, options) { + if ((name == 'font-family' || name == 'font') && GENERIC_FONT_FAMILY_PATTERN.test(value)) { + return value; + } + + if (!options.level[OptimizationLevel.One].removeQuotes) { + return value; + } + + if (!QUOTED_PATTERN.test(value) && !LOCAL_PREFIX_PATTERN.test(value)) { + return value; + } + + return QUOTED_BUT_SAFE_PATTERN.test(value) + ? value.substring(1, value.length - 1) + : value; + } + } +}; + +module.exports = plugin; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/time.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/time.js new file mode 100644 index 0000000000000000000000000000000000000000..8fb2021c3e86d1f288541c869ebd54fb2f5d3076 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/time.js @@ -0,0 +1,31 @@ +var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel; + +var TIME_VALUE = /^(-?[\d.]+)(m?s)$/; + +var plugin = { + level1: { + value: function time(name, value, options) { + if (!options.level[OptimizationLevel.One].replaceTimeUnits) { + return value; + } + + if (!TIME_VALUE.test(value)) { + return value; + } + + return value.replace(TIME_VALUE, function(match, val, unit) { + var newValue; + + if (unit == 'ms') { + newValue = parseInt(val) / 1000 + 's'; + } else if (unit == 's') { + newValue = parseFloat(val) * 1000 + 'ms'; + } + + return newValue.length < match.length ? newValue : match; + }); + } + } +}; + +module.exports = plugin; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/unit.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/unit.js new file mode 100644 index 0000000000000000000000000000000000000000..df2cda594fc4f3b19db5ed56f804ac2a06aa8865 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/unit.js @@ -0,0 +1,46 @@ +var WHOLE_PIXEL_VALUE = /(?:^|\s|\()(-?\d+)px/; + +var plugin = { + level1: { + value: function unit(_name, value, options) { + if (!WHOLE_PIXEL_VALUE.test(value)) { + return value; + } + + return value.replace(WHOLE_PIXEL_VALUE, function(match, val) { + var newValue; + var intVal = parseInt(val); + + if (intVal === 0) { + return match; + } + + if (options.compatibility.properties.shorterLengthUnits + && options.compatibility.units.pt + && intVal * 3 % 4 === 0) { + newValue = intVal * 3 / 4 + 'pt'; + } + + if (options.compatibility.properties.shorterLengthUnits + && options.compatibility.units.pc + && intVal % 16 === 0) { + newValue = intVal / 16 + 'pc'; + } + + if (options.compatibility.properties.shorterLengthUnits + && options.compatibility.units.in + && intVal % 96 === 0) { + newValue = intVal / 96 + 'in'; + } + + if (newValue) { + newValue = match.substring(0, match.indexOf(val)) + newValue; + } + + return newValue && newValue.length < match.length ? newValue : match; + }); + } + } +}; + +module.exports = plugin; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/url-prefix.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/url-prefix.js new file mode 100644 index 0000000000000000000000000000000000000000..8ae7e508fc44775ea3ea98395526c0de21edbd3d --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/url-prefix.js @@ -0,0 +1,23 @@ +var startsAsUrl = require('./starts-as-url'); + +var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel; + +var URL_PREFIX_PATTERN = /^url\(/i; + +var plugin = { + level1: { + value: function urlPrefix(_name, value, options) { + if (!options.level[OptimizationLevel.One].normalizeUrls) { + return value; + } + + if (!startsAsUrl(value)) { + return value; + } + + return value.replace(URL_PREFIX_PATTERN, 'url('); + } + } +}; + +module.exports = plugin; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/url-quotes.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/url-quotes.js new file mode 100644 index 0000000000000000000000000000000000000000..022b80b169d9d0aadc664fcebdde6ec5fa3a60db --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/url-quotes.js @@ -0,0 +1,22 @@ +var QUOTED_URL_PATTERN = /^url\(['"].+['"]\)$/; +var QUOTED_URL_WITH_WHITESPACE_PATTERN = /^url\(['"].*[*\s()'"].*['"]\)$/; +var QUOTES_PATTERN = /["']/g; +var URL_DATA_PATTERN = /^url\(['"]data:[^;]+;charset/; + +var plugin = { + level1: { + value: function urlQuotes(_name, value, options) { + if (options.compatibility.properties.urlQuotes) { + return value; + } + + return QUOTED_URL_PATTERN.test(value) + && !QUOTED_URL_WITH_WHITESPACE_PATTERN.test(value) + && !URL_DATA_PATTERN.test(value) + ? value.replace(QUOTES_PATTERN, '') + : value; + } + } +}; + +module.exports = plugin; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/url-whitespace.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/url-whitespace.js new file mode 100644 index 0000000000000000000000000000000000000000..bd1aaff9d93a7cac210dee0224b8cb51dea86331 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/url-whitespace.js @@ -0,0 +1,22 @@ +var startsAsUrl = require('./starts-as-url'); + +var WHITESPACE_PATTERN = /\\?\n|\\?\r\n/g; +var WHITESPACE_PREFIX_PATTERN = /(\()\s+/g; +var WHITESPACE_SUFFIX_PATTERN = /\s+(\))/g; + +var plugin = { + level1: { + value: function urlWhitespace(_name, value) { + if (!startsAsUrl(value)) { + return value; + } + + return value + .replace(WHITESPACE_PATTERN, '') + .replace(WHITESPACE_PREFIX_PATTERN, '$1') + .replace(WHITESPACE_SUFFIX_PATTERN, '$1'); + } + } +}; + +module.exports = plugin; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/whitespace.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/whitespace.js new file mode 100644 index 0000000000000000000000000000000000000000..bf776301e6e72a38d7cee6650faa1db0f25d5bcf --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/whitespace.js @@ -0,0 +1,48 @@ +var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel; + +var Marker = require('../../../tokenizer/marker'); + +var CALC_DIVISION_WHITESPACE_PATTERN = /\) ?\/ ?/g; +var COMMA_AND_SPACE_PATTERN = /, /g; +var LINE_BREAK_PATTERN = /\r?\n/g; +var MULTI_WHITESPACE_PATTERN = /\s+/g; +var FUNCTION_CLOSING_BRACE_WHITESPACE_PATTERN = /\s+(;?\))/g; +var FUNCTION_OPENING_BRACE_WHITESPACE_PATTERN = /(\(;?)\s+/g; +var VARIABLE_NAME_PATTERN = /^--\S+$/; +var VARIABLE_VALUE_PATTERN = /^var\(\s*--\S+\s*\)$/; + +var plugin = { + level1: { + value: function whitespace(name, value, options) { + if (!options.level[OptimizationLevel.One].removeWhitespace) { + return value; + } + + if (VARIABLE_NAME_PATTERN.test(name) && !VARIABLE_VALUE_PATTERN.test(value)) { + return value; + } + + if ((value.indexOf(' ') == -1 && value.indexOf('\n') == -1) || value.indexOf('expression') === 0) { + return value; + } + + if (value.indexOf(Marker.SINGLE_QUOTE) > -1 || value.indexOf(Marker.DOUBLE_QUOTE) > -1) { + return value; + } + + value = value.replace(LINE_BREAK_PATTERN, ''); + value = value.replace(MULTI_WHITESPACE_PATTERN, ' '); + + if (value.indexOf('calc') > -1) { + value = value.replace(CALC_DIVISION_WHITESPACE_PATTERN, ')/ '); + } + + return value + .replace(FUNCTION_OPENING_BRACE_WHITESPACE_PATTERN, '$1') + .replace(FUNCTION_CLOSING_BRACE_WHITESPACE_PATTERN, '$1') + .replace(COMMA_AND_SPACE_PATTERN, ','); + } + } +}; + +module.exports = plugin; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/zero.js b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/zero.js new file mode 100644 index 0000000000000000000000000000000000000000..0e60346ab36505cd0275147a2b23fe6b7471bdfb --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/zero.js @@ -0,0 +1,49 @@ +var split = require('../../../utils/split'); + +var ANY_FUNCTION_PATTERN = /^(-(?:moz|ms|o|webkit)-[a-z-]+|[a-z-]+)\((.+)\)$/; +var SKIP_FUNCTION_PATTERN = /^(?:-moz-calc|-webkit-calc|calc|rgb|hsl|rgba|hsla|min|max|clamp|expression)\(/; +var TOKEN_SEPARATOR_PATTERN = /([\s,/])/; + +function removeRecursively(value, options) { + var functionTokens; + var tokens; + + if (SKIP_FUNCTION_PATTERN.test(value)) { + return value; + } + + functionTokens = ANY_FUNCTION_PATTERN.exec(value); + + if (!functionTokens) { + return removeZeros(value, options); + } + + tokens = split(functionTokens[2], TOKEN_SEPARATOR_PATTERN) + .map(function(token) { return removeRecursively(token, options); }); + + return functionTokens[1] + '(' + tokens.join('') + ')'; +} + +function removeZeros(value, options) { + return value + .replace(options.unitsRegexp, '$10$2') + .replace(options.unitsRegexp, '$10$2'); +} + +var plugin = { + level1: { + value: function zero(name, value, options) { + if (!options.compatibility.properties.zeroUnits) { + return value; + } + + if (value.indexOf('%') > 0 && (name == 'height' || name == 'max-height' || name == 'width' || name == 'max-width')) { + return value; + } + + return removeRecursively(value, options); + } + } +}; + +module.exports = plugin; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/extract-properties.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/extract-properties.js new file mode 100644 index 0000000000000000000000000000000000000000..66888c43fa2b4e8d654365b96fe9c0b60a2bc584 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/extract-properties.js @@ -0,0 +1,61 @@ +// This extractor is used in level 2 optimizations +// IMPORTANT: Mind Token class and this code is not related! +// Properties will be tokenized in one step, see #429 + +var Token = require('../../tokenizer/token'); +var serializeRules = require('../../writer/one-time').rules; +var serializeValue = require('../../writer/one-time').value; + +function extractProperties(token) { + var properties = []; + var inSpecificSelector; + var property; + var name; + var value; + var i, l; + + if (token[0] == Token.RULE) { + inSpecificSelector = !/[.+>~]/.test(serializeRules(token[1])); + + for (i = 0, l = token[2].length; i < l; i++) { + property = token[2][i]; + + if (property[0] != Token.PROPERTY) { continue; } + + name = property[1][1]; + if (name.length === 0) { continue; } + + value = serializeValue(property, i); + + properties.push([ + name, + value, + findNameRoot(name), + token[2][i], + name + ':' + value, + token[1], + inSpecificSelector + ]); + } + } else if (token[0] == Token.NESTED_BLOCK) { + for (i = 0, l = token[2].length; i < l; i++) { + properties = properties.concat(extractProperties(token[2][i])); + } + } + + return properties; +} + +function findNameRoot(name) { + if (name == 'list-style') { return name; } + if (name.indexOf('-radius') > 0) { return 'border-radius'; } + if (name == 'border-collapse' || name == 'border-spacing' || name == 'border-image') { return name; } + if (name.indexOf('border-') === 0 && /^border-\w+-\w+$/.test(name)) { return name.match(/border-\w+/)[0]; } + if (name.indexOf('border-') === 0 && /^border-\w+$/.test(name)) { return 'border'; } + if (name.indexOf('text-') === 0) { return name; } + if (name == '-chrome-') { return name; } + + return name.replace(/^-\w+-/, '').match(/([a-zA-Z]+)/)[0].toLowerCase(); +} + +module.exports = extractProperties; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/is-mergeable.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/is-mergeable.js new file mode 100644 index 0000000000000000000000000000000000000000..dff393a9e04e7bbcddee75e59a525976d547a418 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/is-mergeable.js @@ -0,0 +1,273 @@ +var Marker = require('../../tokenizer/marker'); +var split = require('../../utils/split'); + +var DEEP_SELECTOR_PATTERN = /\/deep\//; +var DOUBLE_COLON_PATTERN = /^::/; +var VENDOR_PREFIXED_PATTERN = /:(-moz-|-ms-|-o-|-webkit-)/; + +var NOT_PSEUDO = ':not'; +var PSEUDO_CLASSES_WITH_ARGUMENTS = [ + ':dir', + ':lang', + ':not', + ':nth-child', + ':nth-last-child', + ':nth-last-of-type', + ':nth-of-type' +]; +var RELATION_PATTERN = /[>+~]/; +var UNMIXABLE_PSEUDO_CLASSES = [ + ':after', + ':before', + ':first-letter', + ':first-line', + ':lang' +]; +var UNMIXABLE_PSEUDO_ELEMENTS = [ + '::after', + '::before', + '::first-letter', + '::first-line' +]; + +var Level = { + DOUBLE_QUOTE: 'double-quote', + SINGLE_QUOTE: 'single-quote', + ROOT: 'root' +}; + +function isMergeable(selector, mergeablePseudoClasses, mergeablePseudoElements, multiplePseudoMerging) { + var singleSelectors = split(selector, Marker.COMMA); + var singleSelector; + var i, l; + + for (i = 0, l = singleSelectors.length; i < l; i++) { + singleSelector = singleSelectors[i]; + + if (singleSelector.length === 0 + || isDeepSelector(singleSelector) + || isVendorPrefixed(singleSelector) + || (singleSelector.indexOf(Marker.COLON) > -1 + && !areMergeable( + singleSelector, + extractPseudoFrom(singleSelector), + mergeablePseudoClasses, + mergeablePseudoElements, + multiplePseudoMerging + ))) { + return false; + } + } + + return true; +} + +function isDeepSelector(selector) { + return DEEP_SELECTOR_PATTERN.test(selector); +} + +function isVendorPrefixed(selector) { + return VENDOR_PREFIXED_PATTERN.test(selector); +} + +function extractPseudoFrom(selector) { + var list = []; + var character; + var buffer = []; + var level = Level.ROOT; + var roundBracketLevel = 0; + var isQuoted; + var isEscaped; + var isPseudo = false; + var isRelation; + var wasColon = false; + var index; + var len; + + for (index = 0, len = selector.length; index < len; index++) { + character = selector[index]; + + isRelation = !isEscaped && RELATION_PATTERN.test(character); + isQuoted = level == Level.DOUBLE_QUOTE || level == Level.SINGLE_QUOTE; + + if (isEscaped) { + buffer.push(character); + } else if (character == Marker.DOUBLE_QUOTE && level == Level.ROOT) { + buffer.push(character); + level = Level.DOUBLE_QUOTE; + } else if (character == Marker.DOUBLE_QUOTE && level == Level.DOUBLE_QUOTE) { + buffer.push(character); + level = Level.ROOT; + } else if (character == Marker.SINGLE_QUOTE && level == Level.ROOT) { + buffer.push(character); + level = Level.SINGLE_QUOTE; + } else if (character == Marker.SINGLE_QUOTE && level == Level.SINGLE_QUOTE) { + buffer.push(character); + level = Level.ROOT; + } else if (isQuoted) { + buffer.push(character); + } else if (character == Marker.OPEN_ROUND_BRACKET) { + buffer.push(character); + roundBracketLevel++; + } else if (character == Marker.CLOSE_ROUND_BRACKET && roundBracketLevel == 1 && isPseudo) { + buffer.push(character); + list.push(buffer.join('')); + roundBracketLevel--; + buffer = []; + isPseudo = false; + } else if (character == Marker.CLOSE_ROUND_BRACKET) { + buffer.push(character); + roundBracketLevel--; + } else if (character == Marker.COLON && roundBracketLevel === 0 && isPseudo && !wasColon) { + list.push(buffer.join('')); + buffer = []; + buffer.push(character); + } else if (character == Marker.COLON && roundBracketLevel === 0 && !wasColon) { + buffer = []; + buffer.push(character); + isPseudo = true; + } else if (character == Marker.SPACE && roundBracketLevel === 0 && isPseudo) { + list.push(buffer.join('')); + buffer = []; + isPseudo = false; + } else if (isRelation && roundBracketLevel === 0 && isPseudo) { + list.push(buffer.join('')); + buffer = []; + isPseudo = false; + } else { + buffer.push(character); + } + + isEscaped = character == Marker.BACK_SLASH; + wasColon = character == Marker.COLON; + } + + if (buffer.length > 0 && isPseudo) { + list.push(buffer.join('')); + } + + return list; +} + +function areMergeable(selector, matches, mergeablePseudoClasses, mergeablePseudoElements, multiplePseudoMerging) { + return areAllowed(matches, mergeablePseudoClasses, mergeablePseudoElements) + && needArguments(matches) + && (matches.length < 2 || !someIncorrectlyChained(selector, matches)) + && (matches.length < 2 || multiplePseudoMerging && allMixable(matches)); +} + +function areAllowed(matches, mergeablePseudoClasses, mergeablePseudoElements) { + var match; + var name; + var i, l; + + for (i = 0, l = matches.length; i < l; i++) { + match = matches[i]; + name = match.indexOf(Marker.OPEN_ROUND_BRACKET) > -1 + ? match.substring(0, match.indexOf(Marker.OPEN_ROUND_BRACKET)) + : match; + + if (mergeablePseudoClasses.indexOf(name) === -1 && mergeablePseudoElements.indexOf(name) === -1) { + return false; + } + } + + return true; +} + +function needArguments(matches) { + var match; + var name; + var bracketOpensAt; + var hasArguments; + var i, l; + + for (i = 0, l = matches.length; i < l; i++) { + match = matches[i]; + + bracketOpensAt = match.indexOf(Marker.OPEN_ROUND_BRACKET); + hasArguments = bracketOpensAt > -1; + name = hasArguments + ? match.substring(0, bracketOpensAt) + : match; + + if (hasArguments && PSEUDO_CLASSES_WITH_ARGUMENTS.indexOf(name) == -1) { + return false; + } + + if (!hasArguments && PSEUDO_CLASSES_WITH_ARGUMENTS.indexOf(name) > -1) { + return false; + } + } + + return true; +} + +function someIncorrectlyChained(selector, matches) { + var positionInSelector = 0; + var match; + var matchAt; + var nextMatch; + var nextMatchAt; + var name; + var nextName; + var areChained; + var i, l; + + for (i = 0, l = matches.length; i < l; i++) { + match = matches[i]; + nextMatch = matches[i + 1]; + + if (!nextMatch) { + break; + } + + matchAt = selector.indexOf(match, positionInSelector); + nextMatchAt = selector.indexOf(match, matchAt + 1); + positionInSelector = nextMatchAt; + areChained = matchAt + match.length == nextMatchAt; + + if (areChained) { + name = match.indexOf(Marker.OPEN_ROUND_BRACKET) > -1 + ? match.substring(0, match.indexOf(Marker.OPEN_ROUND_BRACKET)) + : match; + nextName = nextMatch.indexOf(Marker.OPEN_ROUND_BRACKET) > -1 + ? nextMatch.substring(0, nextMatch.indexOf(Marker.OPEN_ROUND_BRACKET)) + : nextMatch; + + if (name != NOT_PSEUDO || nextName != NOT_PSEUDO) { + return true; + } + } + } + + return false; +} + +function allMixable(matches) { + var unmixableMatches = 0; + var match; + var i, l; + + for (i = 0, l = matches.length; i < l; i++) { + match = matches[i]; + + if (isPseudoElement(match)) { + unmixableMatches += UNMIXABLE_PSEUDO_ELEMENTS.indexOf(match) > -1 ? 1 : 0; + } else { + unmixableMatches += UNMIXABLE_PSEUDO_CLASSES.indexOf(match) > -1 ? 1 : 0; + } + + if (unmixableMatches > 1) { + return false; + } + } + + return true; +} + +function isPseudoElement(pseudo) { + return DOUBLE_COLON_PATTERN.test(pseudo); +} + +module.exports = isMergeable; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/merge-adjacent.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/merge-adjacent.js new file mode 100644 index 0000000000000000000000000000000000000000..7873aa1bc7072b8ec9eb43c43284eebe4c10a26d --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/merge-adjacent.js @@ -0,0 +1,55 @@ +var isMergeable = require('./is-mergeable'); + +var optimizeProperties = require('./properties/optimize'); + +var sortSelectors = require('../level-1/sort-selectors'); +var tidyRules = require('../level-1/tidy-rules'); + +var OptimizationLevel = require('../../options/optimization-level').OptimizationLevel; + +var serializeBody = require('../../writer/one-time').body; +var serializeRules = require('../../writer/one-time').rules; + +var Token = require('../../tokenizer/token'); + +function mergeAdjacent(tokens, context) { + var lastToken = [null, [], []]; + var options = context.options; + var adjacentSpace = options.compatibility.selectors.adjacentSpace; + var selectorsSortingMethod = options.level[OptimizationLevel.One].selectorsSortingMethod; + var mergeablePseudoClasses = options.compatibility.selectors.mergeablePseudoClasses; + var mergeablePseudoElements = options.compatibility.selectors.mergeablePseudoElements; + var mergeLimit = options.compatibility.selectors.mergeLimit; + var multiplePseudoMerging = options.compatibility.selectors.multiplePseudoMerging; + + for (var i = 0, l = tokens.length; i < l; i++) { + var token = tokens[i]; + + if (token[0] != Token.RULE) { + lastToken = [null, [], []]; + continue; + } + + if (lastToken[0] == Token.RULE && serializeRules(token[1]) == serializeRules(lastToken[1])) { + Array.prototype.push.apply(lastToken[2], token[2]); + optimizeProperties(lastToken[2], true, true, context); + token[2] = []; + } else if (lastToken[0] == Token.RULE && serializeBody(token[2]) == serializeBody(lastToken[2]) + && isMergeable(serializeRules(token[1]), mergeablePseudoClasses, mergeablePseudoElements, multiplePseudoMerging) + && isMergeable( + serializeRules(lastToken[1]), + mergeablePseudoClasses, + mergeablePseudoElements, + multiplePseudoMerging + ) + && lastToken[1].length < mergeLimit) { + lastToken[1] = tidyRules(lastToken[1].concat(token[1]), false, adjacentSpace, false, context.warnings); + lastToken[1] = lastToken.length > 1 ? sortSelectors(lastToken[1], selectorsSortingMethod) : lastToken[1]; + token[2] = []; + } else { + lastToken = token; + } + } +} + +module.exports = mergeAdjacent; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/merge-media-queries.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/merge-media-queries.js new file mode 100644 index 0000000000000000000000000000000000000000..21d8186afe5b3fdd3949cd12b836e1d0b81974ff --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/merge-media-queries.js @@ -0,0 +1,105 @@ +var canReorder = require('./reorderable').canReorder; +var canReorderSingle = require('./reorderable').canReorderSingle; +var extractProperties = require('./extract-properties'); +var rulesOverlap = require('./rules-overlap'); + +var serializeRules = require('../../writer/one-time').rules; +var OptimizationLevel = require('../../options/optimization-level').OptimizationLevel; +var Token = require('../../tokenizer/token'); + +function mergeMediaQueries(tokens, context) { + var mergeSemantically = context.options.level[OptimizationLevel.Two].mergeSemantically; + var specificityCache = context.cache.specificity; + var candidates = {}; + var reduced = []; + + for (var i = tokens.length - 1; i >= 0; i--) { + var token = tokens[i]; + if (token[0] != Token.NESTED_BLOCK) { + continue; + } + + var key = serializeRules(token[1]); + var candidate = candidates[key]; + if (!candidate) { + candidate = []; + candidates[key] = candidate; + } + + candidate.push(i); + } + + for (var name in candidates) { + var positions = candidates[name]; + + positionLoop: + for (var j = positions.length - 1; j > 0; j--) { + var positionOne = positions[j]; + var tokenOne = tokens[positionOne]; + var positionTwo = positions[j - 1]; + var tokenTwo = tokens[positionTwo]; + + directionLoop: + for (var direction = 1; direction >= -1; direction -= 2) { + var topToBottom = direction == 1; + var from = topToBottom ? positionOne + 1 : positionTwo - 1; + var to = topToBottom ? positionTwo : positionOne; + var delta = topToBottom ? 1 : -1; + var source = topToBottom ? tokenOne : tokenTwo; + var target = topToBottom ? tokenTwo : tokenOne; + var movedProperties = extractProperties(source); + + while (from != to) { + var traversedProperties = extractProperties(tokens[from]); + from += delta; + + if (mergeSemantically + && allSameRulePropertiesCanBeReordered(movedProperties, traversedProperties, specificityCache) + ) { + continue; + } + + if (!canReorder(movedProperties, traversedProperties, specificityCache)) { continue directionLoop; } + } + + target[2] = topToBottom + ? source[2].concat(target[2]) + : target[2].concat(source[2]); + source[2] = []; + + reduced.push(target); + continue positionLoop; + } + } + } + + return reduced; +} + +function allSameRulePropertiesCanBeReordered(movedProperties, traversedProperties, specificityCache) { + var movedProperty; + var movedRule; + var traversedProperty; + var traversedRule; + var i, l; + var j, m; + + for (i = 0, l = movedProperties.length; i < l; i++) { + movedProperty = movedProperties[i]; + movedRule = movedProperty[5]; + + for (j = 0, m = traversedProperties.length; j < m; j++) { + traversedProperty = traversedProperties[j]; + traversedRule = traversedProperty[5]; + + if (rulesOverlap(movedRule, traversedRule, true) + && !canReorderSingle(movedProperty, traversedProperty, specificityCache)) { + return false; + } + } + } + + return true; +} + +module.exports = mergeMediaQueries; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/merge-non-adjacent-by-body.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/merge-non-adjacent-by-body.js new file mode 100644 index 0000000000000000000000000000000000000000..0c60db407fb3cb7ae1e03a8ceaac3da1def09d39 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/merge-non-adjacent-by-body.js @@ -0,0 +1,88 @@ +var isMergeable = require('./is-mergeable'); + +var sortSelectors = require('../level-1/sort-selectors'); +var tidyRules = require('../level-1/tidy-rules'); + +var OptimizationLevel = require('../../options/optimization-level').OptimizationLevel; + +var serializeBody = require('../../writer/one-time').body; +var serializeRules = require('../../writer/one-time').rules; + +var Token = require('../../tokenizer/token'); + +function unsafeSelector(value) { + return /\.|\*| :/.test(value); +} + +function isBemElement(token) { + var asString = serializeRules(token[1]); + return asString.indexOf('__') > -1 || asString.indexOf('--') > -1; +} + +function withoutModifier(selector) { + return selector.replace(/--[^ ,>+~:]+/g, ''); +} + +function removeAnyUnsafeElements(left, candidates) { + var leftSelector = withoutModifier(serializeRules(left[1])); + + for (var body in candidates) { + var right = candidates[body]; + var rightSelector = withoutModifier(serializeRules(right[1])); + + if (rightSelector.indexOf(leftSelector) > -1 || leftSelector.indexOf(rightSelector) > -1) { + delete candidates[body]; + } + } +} + +function mergeNonAdjacentByBody(tokens, context) { + var options = context.options; + var mergeSemantically = options.level[OptimizationLevel.Two].mergeSemantically; + var adjacentSpace = options.compatibility.selectors.adjacentSpace; + var selectorsSortingMethod = options.level[OptimizationLevel.One].selectorsSortingMethod; + var mergeablePseudoClasses = options.compatibility.selectors.mergeablePseudoClasses; + var mergeablePseudoElements = options.compatibility.selectors.mergeablePseudoElements; + var multiplePseudoMerging = options.compatibility.selectors.multiplePseudoMerging; + var candidates = {}; + + for (var i = tokens.length - 1; i >= 0; i--) { + var token = tokens[i]; + if (token[0] != Token.RULE) { continue; } + + if (token[2].length > 0 && (!mergeSemantically && unsafeSelector(serializeRules(token[1])))) { candidates = {}; } + + if (token[2].length > 0 && mergeSemantically && isBemElement(token)) { removeAnyUnsafeElements(token, candidates); } + + var candidateBody = serializeBody(token[2]); + var oldToken = candidates[candidateBody]; + if (oldToken + && isMergeable( + serializeRules(token[1]), + mergeablePseudoClasses, + mergeablePseudoElements, + multiplePseudoMerging + ) + && isMergeable( + serializeRules(oldToken[1]), + mergeablePseudoClasses, + mergeablePseudoElements, + multiplePseudoMerging + ) + ) { + if (token[2].length > 0) { + token[1] = tidyRules(oldToken[1].concat(token[1]), false, adjacentSpace, false, context.warnings); + token[1] = token[1].length > 1 ? sortSelectors(token[1], selectorsSortingMethod) : token[1]; + } else { + token[1] = oldToken[1].concat(token[1]); + } + + oldToken[2] = []; + candidates[candidateBody] = null; + } + + candidates[serializeBody(token[2])] = token; + } +} + +module.exports = mergeNonAdjacentByBody; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/merge-non-adjacent-by-selector.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/merge-non-adjacent-by-selector.js new file mode 100644 index 0000000000000000000000000000000000000000..27d096c2990f2d7960a2a7a23434440f6c963a80 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/merge-non-adjacent-by-selector.js @@ -0,0 +1,73 @@ +var canReorder = require('./reorderable').canReorder; +var extractProperties = require('./extract-properties'); + +var optimizeProperties = require('./properties/optimize'); + +var serializeRules = require('../../writer/one-time').rules; + +var Token = require('../../tokenizer/token'); + +function mergeNonAdjacentBySelector(tokens, context) { + var specificityCache = context.cache.specificity; + var allSelectors = {}; + var repeatedSelectors = []; + var i; + + for (i = tokens.length - 1; i >= 0; i--) { + if (tokens[i][0] != Token.RULE) { continue; } + if (tokens[i][2].length === 0) { continue; } + + var selector = serializeRules(tokens[i][1]); + allSelectors[selector] = [i].concat(allSelectors[selector] || []); + + if (allSelectors[selector].length == 2) { repeatedSelectors.push(selector); } + } + + for (i = repeatedSelectors.length - 1; i >= 0; i--) { + var positions = allSelectors[repeatedSelectors[i]]; + + selectorIterator: + for (var j = positions.length - 1; j > 0; j--) { + var positionOne = positions[j - 1]; + var tokenOne = tokens[positionOne]; + var positionTwo = positions[j]; + var tokenTwo = tokens[positionTwo]; + + directionIterator: + for (var direction = 1; direction >= -1; direction -= 2) { + var topToBottom = direction == 1; + var from = topToBottom ? positionOne + 1 : positionTwo - 1; + var to = topToBottom ? positionTwo : positionOne; + var delta = topToBottom ? 1 : -1; + var moved = topToBottom ? tokenOne : tokenTwo; + var target = topToBottom ? tokenTwo : tokenOne; + var movedProperties = extractProperties(moved); + + while (from != to) { + var traversedProperties = extractProperties(tokens[from]); + from += delta; + + // traversed then moved as we move selectors towards the start + var reorderable = topToBottom + ? canReorder(movedProperties, traversedProperties, specificityCache) + : canReorder(traversedProperties, movedProperties, specificityCache); + + if (!reorderable && !topToBottom) { continue selectorIterator; } + if (!reorderable && topToBottom) { continue directionIterator; } + } + + if (topToBottom) { + Array.prototype.push.apply(moved[2], target[2]); + target[2] = moved[2]; + } else { + Array.prototype.push.apply(target[2], moved[2]); + } + + optimizeProperties(target[2], true, true, context); + moved[2] = []; + } + } + } +} + +module.exports = mergeNonAdjacentBySelector; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/optimize.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/optimize.js new file mode 100644 index 0000000000000000000000000000000000000000..a176501a1b8b6dd57f33bed1f065e973bffec3e4 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/optimize.js @@ -0,0 +1,139 @@ +var mergeAdjacent = require('./merge-adjacent'); +var mergeMediaQueries = require('./merge-media-queries'); +var mergeNonAdjacentByBody = require('./merge-non-adjacent-by-body'); +var mergeNonAdjacentBySelector = require('./merge-non-adjacent-by-selector'); +var reduceNonAdjacent = require('./reduce-non-adjacent'); +var removeDuplicateFontAtRules = require('./remove-duplicate-font-at-rules'); +var removeDuplicateMediaQueries = require('./remove-duplicate-media-queries'); +var removeDuplicates = require('./remove-duplicates'); +var removeUnusedAtRules = require('./remove-unused-at-rules'); +var restructure = require('./restructure'); + +var optimizeProperties = require('./properties/optimize'); + +var OptimizationLevel = require('../../options/optimization-level').OptimizationLevel; + +var Token = require('../../tokenizer/token'); + +function removeEmpty(tokens) { + for (var i = 0, l = tokens.length; i < l; i++) { + var token = tokens[i]; + var isEmpty = false; + + switch (token[0]) { + case Token.RULE: + isEmpty = token[1].length === 0 || token[2].length === 0; + break; + case Token.NESTED_BLOCK: + removeEmpty(token[2]); + isEmpty = token[2].length === 0; + break; + case Token.AT_RULE: + isEmpty = token[1].length === 0; + break; + case Token.AT_RULE_BLOCK: + isEmpty = token[2].length === 0; + } + + if (isEmpty) { + tokens.splice(i, 1); + i--; + l--; + } + } +} + +function recursivelyOptimizeBlocks(tokens, context) { + for (var i = 0, l = tokens.length; i < l; i++) { + var token = tokens[i]; + + if (token[0] == Token.NESTED_BLOCK) { + var isKeyframes = /@(-moz-|-o-|-webkit-)?keyframes/.test(token[1][0][1]); + level2Optimize(token[2], context, !isKeyframes); + } + } +} + +function recursivelyOptimizeProperties(tokens, context) { + for (var i = 0, l = tokens.length; i < l; i++) { + var token = tokens[i]; + + switch (token[0]) { + case Token.RULE: + optimizeProperties(token[2], true, true, context); + break; + case Token.NESTED_BLOCK: + recursivelyOptimizeProperties(token[2], context); + } + } +} + +function level2Optimize(tokens, context, withRestructuring) { + var levelOptions = context.options.level[OptimizationLevel.Two]; + var level2Plugins = context.options.plugins.level2Block; + var reduced; + var i; + + recursivelyOptimizeBlocks(tokens, context); + recursivelyOptimizeProperties(tokens, context); + + if (levelOptions.removeDuplicateRules) { + removeDuplicates(tokens, context); + } + + if (levelOptions.mergeAdjacentRules) { + mergeAdjacent(tokens, context); + } + + if (levelOptions.reduceNonAdjacentRules) { + reduceNonAdjacent(tokens, context); + } + + if (levelOptions.mergeNonAdjacentRules && levelOptions.mergeNonAdjacentRules != 'body') { + mergeNonAdjacentBySelector(tokens, context); + } + + if (levelOptions.mergeNonAdjacentRules && levelOptions.mergeNonAdjacentRules != 'selector') { + mergeNonAdjacentByBody(tokens, context); + } + + if (levelOptions.restructureRules && levelOptions.mergeAdjacentRules && withRestructuring) { + restructure(tokens, context); + mergeAdjacent(tokens, context); + } + + if (levelOptions.restructureRules && !levelOptions.mergeAdjacentRules && withRestructuring) { + restructure(tokens, context); + } + + if (levelOptions.removeDuplicateFontRules) { + removeDuplicateFontAtRules(tokens, context); + } + + if (levelOptions.removeDuplicateMediaBlocks) { + removeDuplicateMediaQueries(tokens, context); + } + + if (levelOptions.removeUnusedAtRules) { + removeUnusedAtRules(tokens, context); + } + + if (levelOptions.mergeMedia) { + reduced = mergeMediaQueries(tokens, context); + for (i = reduced.length - 1; i >= 0; i--) { + level2Optimize(reduced[i][2], context, false); + } + } + + for (i = 0; i < level2Plugins.length; i++) { + level2Plugins[i](tokens); + } + + if (levelOptions.removeEmpty) { + removeEmpty(tokens); + } + + return tokens; +} + +module.exports = level2Optimize; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/every-values-pair.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/every-values-pair.js new file mode 100644 index 0000000000000000000000000000000000000000..44fcb7d534a9d2b1e81b85a574410b06d1b8c829 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/every-values-pair.js @@ -0,0 +1,28 @@ +var Marker = require('../../../tokenizer/marker'); + +function everyValuesPair(fn, left, right) { + var leftSize = left.value.length; + var rightSize = right.value.length; + var total = Math.max(leftSize, rightSize); + var lowerBound = Math.min(leftSize, rightSize) - 1; + var leftValue; + var rightValue; + var position; + + for (position = 0; position < total; position++) { + leftValue = left.value[position] && left.value[position][1] || leftValue; + rightValue = right.value[position] && right.value[position][1] || rightValue; + + if (leftValue == Marker.COMMA || rightValue == Marker.COMMA) { + continue; + } + + if (!fn(leftValue, rightValue, position, position <= lowerBound)) { + return false; + } + } + + return true; +} + +module.exports = everyValuesPair; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/find-component-in.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/find-component-in.js new file mode 100644 index 0000000000000000000000000000000000000000..745543b69f13e300a821c7aca24f2df19a0000e2 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/find-component-in.js @@ -0,0 +1,38 @@ +var configuration = require('../../configuration'); + +function findComponentIn(shorthand, longhand) { + var comparator = nameComparator(longhand); + + return findInDirectComponents(shorthand, comparator) || findInSubComponents(shorthand, comparator); +} + +function nameComparator(to) { + return function(property) { + return to.name === property.name; + }; +} + +function findInDirectComponents(shorthand, comparator) { + return shorthand.components.filter(comparator)[0]; +} + +function findInSubComponents(shorthand, comparator) { + var shorthandComponent; + var longhandMatch; + var i, l; + + if (!configuration[shorthand.name].shorthandComponents) { + return; + } + + for (i = 0, l = shorthand.components.length; i < l; i++) { + shorthandComponent = shorthand.components[i]; + longhandMatch = findInDirectComponents(shorthandComponent, comparator); + + if (longhandMatch) { + return longhandMatch; + } + } +} + +module.exports = findComponentIn; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/has-inherit.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/has-inherit.js new file mode 100644 index 0000000000000000000000000000000000000000..8a029c5960a022d7bdcbaae8ef9598210cae3a33 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/has-inherit.js @@ -0,0 +1,9 @@ +function hasInherit(property) { + for (var i = property.value.length - 1; i >= 0; i--) { + if (property.value[i][1] == 'inherit') { return true; } + } + + return false; +} + +module.exports = hasInherit; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/has-same-values.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/has-same-values.js new file mode 100644 index 0000000000000000000000000000000000000000..18815191041ed883be8a5b75d1d2bc320cbd5795 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/has-same-values.js @@ -0,0 +1,14 @@ +function hasSameValues(property) { + var firstValue = property.value[0][1]; + var i, l; + + for (i = 1, l = property.value.length; i < l; i++) { + if (property.value[i][1] != firstValue) { + return false; + } + } + + return true; +} + +module.exports = hasSameValues; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/has-unset.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/has-unset.js new file mode 100644 index 0000000000000000000000000000000000000000..d31a4888434dcadf92d9389a712a510816688e2f --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/has-unset.js @@ -0,0 +1,9 @@ +function hasUnset(property) { + for (var i = property.value.length - 1; i >= 0; i--) { + if (property.value[i][1] == 'unset') { return true; } + } + + return false; +} + +module.exports = hasUnset; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/is-component-of.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/is-component-of.js new file mode 100644 index 0000000000000000000000000000000000000000..571d05eb741499811ebf52756ef8a70050003d58 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/is-component-of.js @@ -0,0 +1,22 @@ +var configuration = require('../../configuration'); + +function isComponentOf(property1, property2, shallow) { + return isDirectComponentOf(property1, property2) + || !shallow && !!configuration[property1.name].shorthandComponents && isSubComponentOf(property1, property2); +} + +function isDirectComponentOf(property1, property2) { + var descriptor = configuration[property1.name]; + + return 'components' in descriptor && descriptor.components.indexOf(property2.name) > -1; +} + +function isSubComponentOf(property1, property2) { + return property1 + .components + .some(function(component) { + return isDirectComponentOf(component, property2); + }); +} + +module.exports = isComponentOf; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/is-mergeable-shorthand.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/is-mergeable-shorthand.js new file mode 100644 index 0000000000000000000000000000000000000000..ee7191ef625e3eb041b950b401fcd3bb27d3b1a9 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/is-mergeable-shorthand.js @@ -0,0 +1,11 @@ +var Marker = require('../../../tokenizer/marker'); + +function isMergeableShorthand(shorthand) { + if (shorthand.name != 'font') { + return true; + } + + return shorthand.value[0][1].indexOf(Marker.INTERNAL) == -1; +} + +module.exports = isMergeableShorthand; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/merge-into-shorthands.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/merge-into-shorthands.js new file mode 100644 index 0000000000000000000000000000000000000000..9ff9139f7d3f2162fd28b35c7be8495f2439cea4 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/merge-into-shorthands.js @@ -0,0 +1,496 @@ +var everyValuesPair = require('./every-values-pair'); +var hasInherit = require('./has-inherit'); +var hasSameValues = require('./has-same-values'); +var populateComponents = require('./populate-components'); + +var configuration = require('../../configuration'); +var deepClone = require('../../clone').deep; +var restoreWithComponents = require('../restore-with-components'); + +var restoreFromOptimizing = require('../../restore-from-optimizing'); +var wrapSingle = require('../../wrap-for-optimizing').single; + +var serializeBody = require('../../../writer/one-time').body; +var Token = require('../../../tokenizer/token'); + +function mergeIntoShorthands(properties, validator) { + var candidates = {}; + var descriptor; + var componentOf; + var property; + var i, l; + var j, m; + + // there is no shorthand property made up of less than 3 longhands + if (properties.length < 3) { + return; + } + + for (i = 0, l = properties.length; i < l; i++) { + property = properties[i]; + descriptor = configuration[property.name]; + + if (property.dynamic) { + continue; + } + + if (property.unused) { + continue; + } + + if (property.hack) { + continue; + } + + if (property.block) { + continue; + } + + if (descriptor && descriptor.singleTypeComponents && !hasSameValues(property)) { + continue; + } + + invalidateOrCompact(properties, i, candidates, validator); + + if (descriptor && descriptor.componentOf) { + for (j = 0, m = descriptor.componentOf.length; j < m; j++) { + componentOf = descriptor.componentOf[j]; + + candidates[componentOf] = candidates[componentOf] || {}; + candidates[componentOf][property.name] = property; + } + } + } + + invalidateOrCompact(properties, i, candidates, validator); +} + +function invalidateOrCompact(properties, position, candidates, validator) { + var invalidatedBy = properties[position]; + var shorthandName; + var shorthandDescriptor; + var candidateComponents; + var replacedCandidates = []; + var i; + + for (shorthandName in candidates) { + if (undefined !== invalidatedBy && shorthandName == invalidatedBy.name) { + continue; + } + + shorthandDescriptor = configuration[shorthandName]; + candidateComponents = candidates[shorthandName]; + if (invalidatedBy && invalidates(candidates, shorthandName, invalidatedBy)) { + delete candidates[shorthandName]; + continue; + } + + if (shorthandDescriptor.components.length > Object.keys(candidateComponents).length) { + continue; + } + + if (mixedImportance(candidateComponents)) { + continue; + } + + if (!overridable(candidateComponents, shorthandName, validator)) { + continue; + } + + if (!mergeable(candidateComponents)) { + continue; + } + + if (mixedInherit(candidateComponents)) { + replaceWithInheritBestFit(properties, candidateComponents, shorthandName, validator); + } else { + replaceWithShorthand(properties, candidateComponents, shorthandName, validator); + } + + replacedCandidates.push(shorthandName); + } + + for (i = replacedCandidates.length - 1; i >= 0; i--) { + delete candidates[replacedCandidates[i]]; + } +} + +function invalidates(candidates, shorthandName, invalidatedBy) { + var shorthandDescriptor = configuration[shorthandName]; + var invalidatedByDescriptor = configuration[invalidatedBy.name]; + var componentName; + + if ('overridesShorthands' in shorthandDescriptor && shorthandDescriptor.overridesShorthands.indexOf(invalidatedBy.name) > -1) { + return true; + } + + if (invalidatedByDescriptor && 'componentOf' in invalidatedByDescriptor) { + for (componentName in candidates[shorthandName]) { + if (invalidatedByDescriptor.componentOf.indexOf(componentName) > -1) { + return true; + } + } + } + + return false; +} + +function mixedImportance(components) { + var important; + var componentName; + + for (componentName in components) { + if (undefined !== important && components[componentName].important != important) { + return true; + } + + important = components[componentName].important; + } + + return false; +} + +function overridable(components, shorthandName, validator) { + var descriptor = configuration[shorthandName]; + var newValuePlaceholder = [ + Token.PROPERTY, + [Token.PROPERTY_NAME, shorthandName], + [Token.PROPERTY_VALUE, descriptor.defaultValue] + ]; + var newProperty = wrapSingle(newValuePlaceholder); + var component; + var mayOverride; + var i, l; + + populateComponents([newProperty], validator, []); + + for (i = 0, l = descriptor.components.length; i < l; i++) { + component = components[descriptor.components[i]]; + mayOverride = configuration[component.name].canOverride || sameValue; + + if (!everyValuesPair(mayOverride.bind(null, validator), newProperty.components[i], component)) { + return false; + } + } + + return true; +} + +function sameValue(_validator, value1, value2) { + return value1 === value2; +} + +function mergeable(components) { + var lastCount = null; + var currentCount; + var componentName; + var component; + var descriptor; + var values; + + for (componentName in components) { + component = components[componentName]; + descriptor = configuration[componentName]; + + if (!('restore' in descriptor)) { + continue; + } + + restoreFromOptimizing([component.all[component.position]], restoreWithComponents); + values = descriptor.restore(component, configuration); + + currentCount = values.length; + + if (lastCount !== null && currentCount !== lastCount) { + return false; + } + + lastCount = currentCount; + } + + return true; +} + +function mixedInherit(components) { + var componentName; + var lastValue = null; + var currentValue; + + for (componentName in components) { + currentValue = hasInherit(components[componentName]); + + if (lastValue !== null && lastValue !== currentValue) { + return true; + } + + lastValue = currentValue; + } + + return false; +} + +function replaceWithInheritBestFit(properties, candidateComponents, shorthandName, validator) { + var viaLonghands = buildSequenceWithInheritLonghands(candidateComponents, shorthandName, validator); + var viaShorthand = buildSequenceWithInheritShorthand(candidateComponents, shorthandName, validator); + var longhandTokensSequence = viaLonghands[0]; + var shorthandTokensSequence = viaShorthand[0]; + var isLonghandsShorter = serializeBody(longhandTokensSequence).length < serializeBody(shorthandTokensSequence).length; + var newTokensSequence = isLonghandsShorter ? longhandTokensSequence : shorthandTokensSequence; + var newProperty = isLonghandsShorter ? viaLonghands[1] : viaShorthand[1]; + var newComponents = isLonghandsShorter ? viaLonghands[2] : viaShorthand[2]; + var lastComponent = candidateComponents[Object.keys(candidateComponents).pop()]; + var all = lastComponent.all; + var insertAt = lastComponent.position; + var componentName; + var oldComponent; + var newComponent; + var newToken; + + newProperty.position = insertAt; + newProperty.shorthand = true; + newProperty.important = lastComponent.important; + newProperty.multiplex = false; + newProperty.dirty = true; + newProperty.all = all; + newProperty.all[insertAt] = newTokensSequence[0]; + + properties.splice(insertAt, 1, newProperty); + + for (componentName in candidateComponents) { + oldComponent = candidateComponents[componentName]; + oldComponent.unused = true; + + newProperty.multiplex = newProperty.multiplex || oldComponent.multiplex; + + if (oldComponent.name in newComponents) { + newComponent = newComponents[oldComponent.name]; + newToken = findTokenIn(newTokensSequence, componentName); + + newComponent.position = all.length; + newComponent.all = all; + newComponent.all.push(newToken); + + properties.push(newComponent); + } + } +} + +function buildSequenceWithInheritLonghands(components, shorthandName, validator) { + var tokensSequence = []; + var inheritComponents = {}; + var nonInheritComponents = {}; + var descriptor = configuration[shorthandName]; + var shorthandToken = [ + Token.PROPERTY, + [Token.PROPERTY_NAME, shorthandName], + [Token.PROPERTY_VALUE, descriptor.defaultValue] + ]; + var newProperty = wrapSingle(shorthandToken); + var component; + var longhandToken; + var newComponent; + var nameMetadata; + var i, l; + + populateComponents([newProperty], validator, []); + + for (i = 0, l = descriptor.components.length; i < l; i++) { + component = components[descriptor.components[i]]; + + if (hasInherit(component)) { + longhandToken = component.all[component.position].slice(0, 2); + Array.prototype.push.apply(longhandToken, component.value); + tokensSequence.push(longhandToken); + + newComponent = deepClone(component); + newComponent.value = inferComponentValue(components, newComponent.name); + + newProperty.components[i] = newComponent; + inheritComponents[component.name] = deepClone(component); + } else { + newComponent = deepClone(component); + newComponent.all = component.all; + newProperty.components[i] = newComponent; + + nonInheritComponents[component.name] = component; + } + } + + newProperty.important = components[Object.keys(components).pop()].important; + + nameMetadata = joinMetadata(nonInheritComponents, 1); + shorthandToken[1].push(nameMetadata); + + restoreFromOptimizing([newProperty], restoreWithComponents); + + shorthandToken = shorthandToken.slice(0, 2); + Array.prototype.push.apply(shorthandToken, newProperty.value); + + tokensSequence.unshift(shorthandToken); + + return [tokensSequence, newProperty, inheritComponents]; +} + +function inferComponentValue(components, propertyName) { + var descriptor = configuration[propertyName]; + + if ('oppositeTo' in descriptor) { + return components[descriptor.oppositeTo].value; + } + return [[Token.PROPERTY_VALUE, descriptor.defaultValue]]; +} + +function joinMetadata(components, at) { + var metadata = []; + var component; + var originalValue; + var componentMetadata; + var componentName; + + for (componentName in components) { + component = components[componentName]; + originalValue = component.all[component.position]; + componentMetadata = originalValue[at][originalValue[at].length - 1]; + + Array.prototype.push.apply(metadata, componentMetadata); + } + + return metadata.sort(metadataSorter); +} + +function metadataSorter(metadata1, metadata2) { + var line1 = metadata1[0]; + var line2 = metadata2[0]; + var column1 = metadata1[1]; + var column2 = metadata2[1]; + + if (line1 < line2) { + return -1; + } if (line1 === line2) { + return column1 < column2 ? -1 : 1; + } + return 1; +} + +function buildSequenceWithInheritShorthand(components, shorthandName, validator) { + var tokensSequence = []; + var inheritComponents = {}; + var nonInheritComponents = {}; + var descriptor = configuration[shorthandName]; + var shorthandToken = [ + Token.PROPERTY, + [Token.PROPERTY_NAME, shorthandName], + [Token.PROPERTY_VALUE, 'inherit'] + ]; + var newProperty = wrapSingle(shorthandToken); + var component; + var longhandToken; + var nameMetadata; + var valueMetadata; + var i, l; + + populateComponents([newProperty], validator, []); + + for (i = 0, l = descriptor.components.length; i < l; i++) { + component = components[descriptor.components[i]]; + + if (hasInherit(component)) { + inheritComponents[component.name] = component; + } else { + longhandToken = component.all[component.position].slice(0, 2); + Array.prototype.push.apply(longhandToken, component.value); + tokensSequence.push(longhandToken); + + nonInheritComponents[component.name] = deepClone(component); + } + } + + nameMetadata = joinMetadata(inheritComponents, 1); + shorthandToken[1].push(nameMetadata); + + valueMetadata = joinMetadata(inheritComponents, 2); + shorthandToken[2].push(valueMetadata); + + tokensSequence.unshift(shorthandToken); + + return [tokensSequence, newProperty, nonInheritComponents]; +} + +function findTokenIn(tokens, componentName) { + var i, l; + + for (i = 0, l = tokens.length; i < l; i++) { + if (tokens[i][1][1] == componentName) { + return tokens[i]; + } + } +} + +function replaceWithShorthand(properties, candidateComponents, shorthandName, validator) { + var descriptor = configuration[shorthandName]; + var nameMetadata; + var valueMetadata; + var newValuePlaceholder = [ + Token.PROPERTY, + [Token.PROPERTY_NAME, shorthandName], + [Token.PROPERTY_VALUE, descriptor.defaultValue] + ]; + var all; + var insertAt = inferInsertAtFrom(properties, candidateComponents, shorthandName); + + var newProperty = wrapSingle(newValuePlaceholder); + newProperty.shorthand = true; + newProperty.dirty = true; + newProperty.multiplex = false; + + populateComponents([newProperty], validator, []); + + for (var i = 0, l = descriptor.components.length; i < l; i++) { + var component = candidateComponents[descriptor.components[i]]; + + newProperty.components[i] = deepClone(component); + newProperty.important = component.important; + newProperty.multiplex = newProperty.multiplex || component.multiplex; + + all = component.all; + } + + for (var componentName in candidateComponents) { + candidateComponents[componentName].unused = true; + } + + nameMetadata = joinMetadata(candidateComponents, 1); + newValuePlaceholder[1].push(nameMetadata); + + valueMetadata = joinMetadata(candidateComponents, 2); + newValuePlaceholder[2].push(valueMetadata); + + newProperty.position = insertAt; + newProperty.all = all; + newProperty.all[insertAt] = newValuePlaceholder; + + properties.splice(insertAt, 1, newProperty); +} + +function inferInsertAtFrom(properties, candidateComponents, shorthandName) { + var candidateComponentNames = Object.keys(candidateComponents); + var firstCandidatePosition = candidateComponents[candidateComponentNames[0]].position; + var lastCandidatePosition = candidateComponents[candidateComponentNames[candidateComponentNames.length - 1]].position; + + if (shorthandName == 'border' && traversesVia(properties.slice(firstCandidatePosition, lastCandidatePosition), 'border-image')) { + return firstCandidatePosition; + } + return lastCandidatePosition; +} + +function traversesVia(properties, propertyName) { + for (var i = properties.length - 1; i >= 0; i--) { + if (properties[i].name == propertyName) { + return true; + } + } + + return false; +} + +module.exports = mergeIntoShorthands; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/optimize.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/optimize.js new file mode 100644 index 0000000000000000000000000000000000000000..536cd6d564dcfd60fd9bc207f90aa7f1fd69ede0 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/optimize.js @@ -0,0 +1,40 @@ +var mergeIntoShorthands = require('./merge-into-shorthands'); +var overrideProperties = require('./override-properties'); +var populateComponents = require('./populate-components'); + +var restoreWithComponents = require('../restore-with-components'); + +var wrapForOptimizing = require('../../wrap-for-optimizing').all; +var removeUnused = require('../../remove-unused'); +var restoreFromOptimizing = require('../../restore-from-optimizing'); + +var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel; + +function optimizeProperties(properties, withOverriding, withMerging, context) { + var levelOptions = context.options.level[OptimizationLevel.Two]; + var _properties = wrapForOptimizing(properties, levelOptions.skipProperties); + var _property; + var i, l; + + populateComponents(_properties, context.validator, context.warnings); + + for (i = 0, l = _properties.length; i < l; i++) { + _property = _properties[i]; + if (_property.block) { + optimizeProperties(_property.value[0][1], withOverriding, withMerging, context); + } + } + + if (withMerging && levelOptions.mergeIntoShorthands) { + mergeIntoShorthands(_properties, context.validator); + } + + if (withOverriding && levelOptions.overrideProperties) { + overrideProperties(_properties, withMerging, context.options.compatibility, context.validator); + } + + restoreFromOptimizing(_properties, restoreWithComponents); + removeUnused(_properties); +} + +module.exports = optimizeProperties; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/override-properties.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/override-properties.js new file mode 100644 index 0000000000000000000000000000000000000000..5f7aa38e62955556d44ca23aaaa37acf40e9b7c8 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/override-properties.js @@ -0,0 +1,461 @@ +var hasInherit = require('./has-inherit'); +var hasUnset = require('./has-unset'); +var everyValuesPair = require('./every-values-pair'); +var findComponentIn = require('./find-component-in'); +var isComponentOf = require('./is-component-of'); +var isMergeableShorthand = require('./is-mergeable-shorthand'); +var overridesNonComponentShorthand = require('./overrides-non-component-shorthand'); +var sameVendorPrefixesIn = require('./../../vendor-prefixes').same; + +var configuration = require('../../configuration'); +var deepClone = require('../../clone').deep; +var restoreWithComponents = require('../restore-with-components'); +var shallowClone = require('../../clone').shallow; + +var restoreFromOptimizing = require('../../restore-from-optimizing'); + +var Token = require('../../../tokenizer/token'); +var Marker = require('../../../tokenizer/marker'); + +var serializeProperty = require('../../../writer/one-time').property; + +function sameValue(_validator, value1, value2) { + return value1 === value2; +} + +function wouldBreakCompatibility(property, validator) { + for (var i = 0; i < property.components.length; i++) { + var component = property.components[i]; + var descriptor = configuration[component.name]; + var canOverride = descriptor && descriptor.canOverride || sameValue; + + var _component = shallowClone(component); + _component.value = [[Token.PROPERTY_VALUE, descriptor.defaultValue]]; + + if (!everyValuesPair(canOverride.bind(null, validator), _component, component)) { + return true; + } + } + + return false; +} + +function overrideIntoMultiplex(property, by) { + by.unused = true; + + turnIntoMultiplex(by, multiplexSize(property)); + property.value = by.value; +} + +function overrideByMultiplex(property, by) { + by.unused = true; + property.multiplex = true; + property.value = by.value; +} + +function overrideSimple(property, by) { + by.unused = true; + property.value = by.value; +} + +function override(property, by) { + if (by.multiplex) { + overrideByMultiplex(property, by); + } else if (property.multiplex) { + overrideIntoMultiplex(property, by); + } else { + overrideSimple(property, by); + } +} + +function overrideShorthand(property, by) { + by.unused = true; + + for (var i = 0, l = property.components.length; i < l; i++) { + override(property.components[i], by.components[i]); + } +} + +function turnIntoMultiplex(property, size) { + property.multiplex = true; + + if (configuration[property.name].shorthand) { + turnShorthandValueIntoMultiplex(property, size); + } else { + turnLonghandValueIntoMultiplex(property, size); + } +} + +function turnShorthandValueIntoMultiplex(property, size) { + var component; + var i, l; + + for (i = 0, l = property.components.length; i < l; i++) { + component = property.components[i]; + + if (!component.multiplex) { + turnLonghandValueIntoMultiplex(component, size); + } + } +} + +function turnLonghandValueIntoMultiplex(property, size) { + var descriptor = configuration[property.name]; + var withRealValue = descriptor.intoMultiplexMode == 'real'; + var withValue = descriptor.intoMultiplexMode == 'real' + ? property.value.slice(0) + : (descriptor.intoMultiplexMode == 'placeholder' ? descriptor.placeholderValue : descriptor.defaultValue); + var i = multiplexSize(property); + var j; + var m = withValue.length; + + for (; i < size; i++) { + property.value.push([Token.PROPERTY_VALUE, Marker.COMMA]); + + if (Array.isArray(withValue)) { + for (j = 0; j < m; j++) { + property.value.push(withRealValue ? withValue[j] : [Token.PROPERTY_VALUE, withValue[j]]); + } + } else { + property.value.push(withRealValue ? withValue : [Token.PROPERTY_VALUE, withValue]); + } + } +} + +function multiplexSize(component) { + var size = 0; + + for (var i = 0, l = component.value.length; i < l; i++) { + if (component.value[i][1] == Marker.COMMA) { size++; } + } + + return size + 1; +} + +function lengthOf(property) { + var fakeAsArray = [ + Token.PROPERTY, + [Token.PROPERTY_NAME, property.name] + ].concat(property.value); + return serializeProperty([fakeAsArray], 0).length; +} + +function moreSameShorthands(properties, startAt, name) { + // Since we run the main loop in `compactOverrides` backwards, at this point some + // properties may not be marked as unused. + // We should consider reverting the order if possible + var count = 0; + + for (var i = startAt; i >= 0; i--) { + if (properties[i].name == name && !properties[i].unused) { count++; } + if (count > 1) { break; } + } + + return count > 1; +} + +function overridingFunction(shorthand, validator) { + for (var i = 0, l = shorthand.components.length; i < l; i++) { + if (!anyValue(validator.isUrl, shorthand.components[i]) + && anyValue(validator.isFunction, shorthand.components[i])) { return true; } + } + + return false; +} + +function anyValue(fn, property) { + for (var i = 0, l = property.value.length; i < l; i++) { + if (property.value[i][1] == Marker.COMMA) { continue; } + + if (fn(property.value[i][1])) { return true; } + } + + return false; +} + +function wouldResultInLongerValue(left, right) { + if (!left.multiplex && !right.multiplex || left.multiplex && right.multiplex) { return false; } + + var multiplex = left.multiplex ? left : right; + var simple = left.multiplex ? right : left; + var component; + + var multiplexClone = deepClone(multiplex); + restoreFromOptimizing([multiplexClone], restoreWithComponents); + + var simpleClone = deepClone(simple); + restoreFromOptimizing([simpleClone], restoreWithComponents); + + var lengthBefore = lengthOf(multiplexClone) + 1 + lengthOf(simpleClone); + + if (left.multiplex) { + component = findComponentIn(multiplexClone, simpleClone); + overrideIntoMultiplex(component, simpleClone); + } else { + component = findComponentIn(simpleClone, multiplexClone); + turnIntoMultiplex(simpleClone, multiplexSize(multiplexClone)); + overrideByMultiplex(component, multiplexClone); + } + + restoreFromOptimizing([simpleClone], restoreWithComponents); + + var lengthAfter = lengthOf(simpleClone); + + return lengthBefore <= lengthAfter; +} + +function isCompactable(property) { + return property.name in configuration; +} + +function noneOverrideHack(left, right) { + return !left.multiplex + && (left.name == 'background' || left.name == 'background-image') + && right.multiplex + && (right.name == 'background' || right.name == 'background-image') + && anyLayerIsNone(right.value); +} + +function anyLayerIsNone(values) { + var layers = intoLayers(values); + + for (var i = 0, l = layers.length; i < l; i++) { + if (layers[i].length == 1 && layers[i][0][1] == 'none') { return true; } + } + + return false; +} + +function intoLayers(values) { + var layers = []; + + for (var i = 0, layer = [], l = values.length; i < l; i++) { + var value = values[i]; + if (value[1] == Marker.COMMA) { + layers.push(layer); + layer = []; + } else { + layer.push(value); + } + } + + layers.push(layer); + return layers; +} + +function overrideProperties(properties, withMerging, compatibility, validator) { + var mayOverride, right, left, component; + var overriddenComponents; + var overriddenComponent; + var overridingComponent; + var overridable; + var i, j, k; + + propertyLoop: + for (i = properties.length - 1; i >= 0; i--) { + right = properties[i]; + + if (!isCompactable(right)) { continue; } + + if (right.block) { continue; } + + mayOverride = configuration[right.name].canOverride || sameValue; + + traverseLoop: + for (j = i - 1; j >= 0; j--) { + left = properties[j]; + + if (!isCompactable(left)) { continue; } + + if (left.block) { continue; } + + if (left.dynamic || right.dynamic) { continue; } + + if (left.unused || right.unused) { continue; } + + if (left.hack && !right.hack && !right.important || !left.hack && !left.important && right.hack) { continue; } + + if (left.important == right.important && left.hack[0] != right.hack[0]) { continue; } + + if (left.important == right.important + && (left.hack[0] != right.hack[0] || (left.hack[1] && left.hack[1] != right.hack[1]))) { continue; } + + if (hasInherit(right)) { continue; } + + if (noneOverrideHack(left, right)) { continue; } + + if (right.shorthand && isComponentOf(right, left)) { + // maybe `left` can be overridden by `right` which is a shorthand? + if (!right.important && left.important) { continue; } + + if (!sameVendorPrefixesIn([left], right.components)) { continue; } + + if (!anyValue(validator.isFunction, left) && overridingFunction(right, validator)) { continue; } + + if (!isMergeableShorthand(right)) { + left.unused = true; + continue; + } + + component = findComponentIn(right, left); + mayOverride = configuration[left.name].canOverride || sameValue; + if (everyValuesPair(mayOverride.bind(null, validator), left, component)) { + left.unused = true; + } + } else if (right.shorthand && overridesNonComponentShorthand(right, left)) { + // `right` is a shorthand while `left` can be overriden by it, think `border` and `border-top` + if (!right.important && left.important) { + continue; + } + + if (!sameVendorPrefixesIn([left], right.components)) { + continue; + } + + if (!anyValue(validator.isFunction, left) && overridingFunction(right, validator)) { + continue; + } + + overriddenComponents = left.shorthand + ? left.components + : [left]; + + for (k = overriddenComponents.length - 1; k >= 0; k--) { + overriddenComponent = overriddenComponents[k]; + overridingComponent = findComponentIn(right, overriddenComponent); + mayOverride = configuration[overriddenComponent.name].canOverride || sameValue; + + if (!everyValuesPair(mayOverride.bind(null, validator), left, overridingComponent)) { + continue traverseLoop; + } + } + + left.unused = true; + } else if (withMerging && left.shorthand && !right.shorthand && isComponentOf(left, right, true)) { + // maybe `right` can be pulled into `left` which is a shorthand? + if (right.important && !left.important) { continue; } + + if (!right.important && left.important) { + right.unused = true; + continue; + } + + // Pending more clever algorithm in #527 + if (moreSameShorthands(properties, i - 1, left.name)) { continue; } + + if (overridingFunction(left, validator)) { continue; } + + if (!isMergeableShorthand(left)) { continue; } + + if (hasUnset(left) || hasUnset(right)) { continue; } + + component = findComponentIn(left, right); + if (everyValuesPair(mayOverride.bind(null, validator), component, right)) { + var disabledBackgroundMerging = !compatibility.properties.backgroundClipMerging && component.name.indexOf('background-clip') > -1 + || !compatibility.properties.backgroundOriginMerging && component.name.indexOf('background-origin') > -1 + || !compatibility.properties.backgroundSizeMerging && component.name.indexOf('background-size') > -1; + var nonMergeableValue = configuration[right.name].nonMergeableValue === right.value[0][1]; + + if (disabledBackgroundMerging || nonMergeableValue) { continue; } + + if (!compatibility.properties.merging && wouldBreakCompatibility(left, validator)) { continue; } + + if (component.value[0][1] != right.value[0][1] && (hasInherit(left) || hasInherit(right))) { continue; } + + if (wouldResultInLongerValue(left, right)) { continue; } + + if (!left.multiplex && right.multiplex) { turnIntoMultiplex(left, multiplexSize(right)); } + + override(component, right); + left.dirty = true; + } + } else if (withMerging && left.shorthand && right.shorthand && left.name == right.name) { + // merge if all components can be merged + + if (!left.multiplex && right.multiplex) { continue; } + + if (!right.important && left.important) { + right.unused = true; + continue propertyLoop; + } + + if (right.important && !left.important) { + left.unused = true; + continue; + } + + if (!isMergeableShorthand(right)) { + left.unused = true; + continue; + } + + for (k = left.components.length - 1; k >= 0; k--) { + var leftComponent = left.components[k]; + var rightComponent = right.components[k]; + + mayOverride = configuration[leftComponent.name].canOverride || sameValue; + if (!everyValuesPair(mayOverride.bind(null, validator), leftComponent, rightComponent)) { + continue propertyLoop; + } + } + + overrideShorthand(left, right); + left.dirty = true; + } else if (withMerging && left.shorthand && right.shorthand && isComponentOf(left, right)) { + // border is a shorthand but any of its components is a shorthand too + + if (!left.important && right.important) { continue; } + + component = findComponentIn(left, right); + mayOverride = configuration[right.name].canOverride || sameValue; + if (!everyValuesPair(mayOverride.bind(null, validator), component, right)) { continue; } + + if (left.important && !right.important) { + right.unused = true; + continue; + } + + var rightRestored = configuration[right.name].restore(right, configuration); + if (rightRestored.length > 1) { continue; } + + component = findComponentIn(left, right); + override(component, right); + right.dirty = true; + } else if (left.name == right.name) { + // two non-shorthands should be merged based on understandability + overridable = true; + + if (right.shorthand) { + for (k = right.components.length - 1; k >= 0 && overridable; k--) { + overriddenComponent = left.components[k]; + overridingComponent = right.components[k]; + mayOverride = configuration[overridingComponent.name].canOverride || sameValue; + + overridable = everyValuesPair(mayOverride.bind(null, validator), overriddenComponent, overridingComponent); + } + } else { + mayOverride = configuration[right.name].canOverride || sameValue; + overridable = everyValuesPair(mayOverride.bind(null, validator), left, right); + } + + if (left.important && !right.important && overridable) { + right.unused = true; + continue; + } + + if (!left.important && right.important && overridable) { + left.unused = true; + continue; + } + + if (!overridable) { + continue; + } + + left.unused = true; + } + } + } +} + +module.exports = overrideProperties; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/overrides-non-component-shorthand.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/overrides-non-component-shorthand.js new file mode 100644 index 0000000000000000000000000000000000000000..2f5886f3a3b8333e7869fa158c3a0d14f3d382fd --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/overrides-non-component-shorthand.js @@ -0,0 +1,9 @@ +var configuration = require('../../configuration'); + +function overridesNonComponentShorthand(property1, property2) { + return property1.name in configuration + && 'overridesShorthands' in configuration[property1.name] + && configuration[property1.name].overridesShorthands.indexOf(property2.name) > -1; +} + +module.exports = overridesNonComponentShorthand; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/populate-components.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/populate-components.js new file mode 100644 index 0000000000000000000000000000000000000000..e5367465a756a05e2490b625d5f41d04d58b03fa --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/properties/populate-components.js @@ -0,0 +1,61 @@ +var configuration = require('../../configuration'); +var InvalidPropertyError = require('../../invalid-property-error'); + +function populateComponents(properties, validator, warnings) { + var component; + var j, m; + + for (var i = properties.length - 1; i >= 0; i--) { + var property = properties[i]; + var descriptor = configuration[property.name]; + + if (!property.dynamic && descriptor && descriptor.shorthand) { + if (onlyValueIsVariable(property, validator) || moreThanOneValueIsVariable(property, validator)) { + property.optimizable = false; + continue; + } + + property.shorthand = true; + property.dirty = true; + + try { + property.components = descriptor.breakUp(property, configuration, validator); + + if (descriptor.shorthandComponents) { + for (j = 0, m = property.components.length; j < m; j++) { + component = property.components[j]; + component.components = configuration[component.name].breakUp(component, configuration, validator); + } + } + } catch (e) { + if (e instanceof InvalidPropertyError) { + property.components = []; // this will set property.unused to true below + warnings.push(e.message); + } else { + throw e; + } + } + + if (property.components.length > 0) { + property.multiplex = property.components[0].multiplex; + } else { + property.unused = true; + } + } + } +} + +function onlyValueIsVariable(property, validator) { + return property.value.length == 1 && validator.isVariable(property.value[0][1]); +} + +function moreThanOneValueIsVariable(property, validator) { + return property.value.length > 1 + && property.value.filter( + function(value) { + return validator.isVariable(value[1]); + } + ).length > 1; +} + +module.exports = populateComponents; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/reduce-non-adjacent.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/reduce-non-adjacent.js new file mode 100644 index 0000000000000000000000000000000000000000..9e3a78909ba19301d14b68871c6ab7b92b181b1b --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/reduce-non-adjacent.js @@ -0,0 +1,174 @@ +var isMergeable = require('./is-mergeable'); + +var optimizeProperties = require('./properties/optimize'); + +var cloneArray = require('../../utils/clone-array'); + +var Token = require('../../tokenizer/token'); + +var serializeBody = require('../../writer/one-time').body; +var serializeRules = require('../../writer/one-time').rules; + +function reduceNonAdjacent(tokens, context) { + var options = context.options; + var mergeablePseudoClasses = options.compatibility.selectors.mergeablePseudoClasses; + var mergeablePseudoElements = options.compatibility.selectors.mergeablePseudoElements; + var multiplePseudoMerging = options.compatibility.selectors.multiplePseudoMerging; + var candidates = {}; + var repeated = []; + + for (var i = tokens.length - 1; i >= 0; i--) { + var token = tokens[i]; + + if (token[0] != Token.RULE) { + continue; + } else if (token[2].length === 0) { + continue; + } + + var selectorAsString = serializeRules(token[1]); + var isComplexAndNotSpecial = token[1].length > 1 + && isMergeable(selectorAsString, mergeablePseudoClasses, mergeablePseudoElements, multiplePseudoMerging); + var wrappedSelectors = wrappedSelectorsFrom(token[1]); + var selectors = isComplexAndNotSpecial + ? [selectorAsString].concat(wrappedSelectors) + : [selectorAsString]; + + for (var j = 0, m = selectors.length; j < m; j++) { + var selector = selectors[j]; + + if (!candidates[selector]) { candidates[selector] = []; } else { repeated.push(selector); } + + candidates[selector].push({ + where: i, + list: wrappedSelectors, + isPartial: isComplexAndNotSpecial && j > 0, + isComplex: isComplexAndNotSpecial && j === 0 + }); + } + } + + reduceSimpleNonAdjacentCases(tokens, repeated, candidates, options, context); + reduceComplexNonAdjacentCases(tokens, candidates, options, context); +} + +function wrappedSelectorsFrom(list) { + var wrapped = []; + + for (var i = 0; i < list.length; i++) { + wrapped.push([list[i][1]]); + } + + return wrapped; +} + +function reduceSimpleNonAdjacentCases(tokens, repeated, candidates, options, context) { + function filterOut(idx, bodies) { + return data[idx].isPartial && bodies.length === 0; + } + + function reduceBody(token, newBody, processedCount, tokenIdx) { + if (!data[processedCount - tokenIdx - 1].isPartial) { token[2] = newBody; } + } + + for (var i = 0, l = repeated.length; i < l; i++) { + var selector = repeated[i]; + var data = candidates[selector]; + + reduceSelector(tokens, data, { + filterOut: filterOut, + callback: reduceBody + }, options, context); + } +} + +function reduceComplexNonAdjacentCases(tokens, candidates, options, context) { + var mergeablePseudoClasses = options.compatibility.selectors.mergeablePseudoClasses; + var mergeablePseudoElements = options.compatibility.selectors.mergeablePseudoElements; + var multiplePseudoMerging = options.compatibility.selectors.multiplePseudoMerging; + var localContext = {}; + + function filterOut(idx) { + return localContext.data[idx].where < localContext.intoPosition; + } + + function collectReducedBodies(token, newBody, processedCount, tokenIdx) { + if (tokenIdx === 0) { localContext.reducedBodies.push(newBody); } + } + + allSelectors: + for (var complexSelector in candidates) { + var into = candidates[complexSelector]; + if (!into[0].isComplex) { continue; } + + var intoPosition = into[into.length - 1].where; + var intoToken = tokens[intoPosition]; + var reducedBodies = []; + + var selectors = isMergeable(complexSelector, mergeablePseudoClasses, mergeablePseudoElements, multiplePseudoMerging) + ? into[0].list + : [complexSelector]; + + localContext.intoPosition = intoPosition; + localContext.reducedBodies = reducedBodies; + + for (var j = 0, m = selectors.length; j < m; j++) { + var selector = selectors[j]; + var data = candidates[selector]; + + if (data.length < 2) { continue allSelectors; } + + localContext.data = data; + + reduceSelector(tokens, data, { + filterOut: filterOut, + callback: collectReducedBodies + }, options, context); + + if (serializeBody(reducedBodies[reducedBodies.length - 1]) != serializeBody(reducedBodies[0])) { + continue allSelectors; + } + } + + intoToken[2] = reducedBodies[0]; + } +} + +function reduceSelector(tokens, data, context, options, outerContext) { + var bodies = []; + var bodiesAsList = []; + var processedTokens = []; + + for (var j = data.length - 1; j >= 0; j--) { + if (context.filterOut(j, bodies)) { continue; } + + var where = data[j].where; + var token = tokens[where]; + var clonedBody = cloneArray(token[2]); + + bodies = bodies.concat(clonedBody); + bodiesAsList.push(clonedBody); + processedTokens.push(where); + } + + optimizeProperties(bodies, true, false, outerContext); + + var processedCount = processedTokens.length; + var propertyIdx = bodies.length - 1; + var tokenIdx = processedCount - 1; + + while (tokenIdx >= 0) { + if ((tokenIdx === 0 + || (bodies[propertyIdx] && bodiesAsList[tokenIdx].indexOf(bodies[propertyIdx]) > -1)) && propertyIdx > -1) { + propertyIdx--; + continue; + } + + var newBody = bodies.splice(propertyIdx + 1); + context.callback(tokens[processedTokens[tokenIdx]], newBody, processedCount, tokenIdx); + + tokenIdx--; + } +} + +module.exports = reduceNonAdjacent; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/remove-duplicate-font-at-rules.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/remove-duplicate-font-at-rules.js new file mode 100644 index 0000000000000000000000000000000000000000..bc85d5d67f6f3664cf0a3e797cf0f9925662eecb --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/remove-duplicate-font-at-rules.js @@ -0,0 +1,30 @@ +var Token = require('../../tokenizer/token'); + +var serializeAll = require('../../writer/one-time').all; + +var FONT_FACE_SCOPE = '@font-face'; + +function removeDuplicateFontAtRules(tokens) { + var fontAtRules = []; + var token; + var key; + var i, l; + + for (i = 0, l = tokens.length; i < l; i++) { + token = tokens[i]; + + if (token[0] != Token.AT_RULE_BLOCK && token[1][0][1] != FONT_FACE_SCOPE) { + continue; + } + + key = serializeAll([token]); + + if (fontAtRules.indexOf(key) > -1) { + token[2] = []; + } else { + fontAtRules.push(key); + } + } +} + +module.exports = removeDuplicateFontAtRules; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/remove-duplicate-media-queries.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/remove-duplicate-media-queries.js new file mode 100644 index 0000000000000000000000000000000000000000..2c8f31d9de910def63e27c0f53feb4e0755c01b5 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/remove-duplicate-media-queries.js @@ -0,0 +1,30 @@ +var Token = require('../../tokenizer/token'); + +var serializeAll = require('../../writer/one-time').all; +var serializeRules = require('../../writer/one-time').rules; + +function removeDuplicateMediaQueries(tokens) { + var candidates = {}; + var candidate; + var token; + var key; + var i, l; + + for (i = 0, l = tokens.length; i < l; i++) { + token = tokens[i]; + if (token[0] != Token.NESTED_BLOCK) { + continue; + } + + key = serializeRules(token[1]) + '%' + serializeAll(token[2]); + candidate = candidates[key]; + + if (candidate) { + candidate[2] = []; + } + + candidates[key] = token; + } +} + +module.exports = removeDuplicateMediaQueries; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/remove-duplicates.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/remove-duplicates.js new file mode 100644 index 0000000000000000000000000000000000000000..cbbe367a1955b964a2644a092edd0be7f9f1a7ad --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/remove-duplicates.js @@ -0,0 +1,36 @@ +var Token = require('../../tokenizer/token'); + +var serializeBody = require('../../writer/one-time').body; +var serializeRules = require('../../writer/one-time').rules; + +function removeDuplicates(tokens) { + var matched = {}; + var moreThanOnce = []; + var id, token; + var body, bodies; + + for (var i = 0, l = tokens.length; i < l; i++) { + token = tokens[i]; + if (token[0] != Token.RULE) { continue; } + + id = serializeRules(token[1]); + + if (matched[id] && matched[id].length == 1) { moreThanOnce.push(id); } else { matched[id] = matched[id] || []; } + + matched[id].push(i); + } + + for (i = 0, l = moreThanOnce.length; i < l; i++) { + id = moreThanOnce[i]; + bodies = []; + + for (var j = matched[id].length - 1; j >= 0; j--) { + token = tokens[matched[id][j]]; + body = serializeBody(token[2]); + + if (bodies.indexOf(body) > -1) { token[2] = []; } else { bodies.push(body); } + } + } +} + +module.exports = removeDuplicates; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/remove-unused-at-rules.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/remove-unused-at-rules.js new file mode 100644 index 0000000000000000000000000000000000000000..71e5eba2d7920fb1c2eed65205e9e5234a7295c6 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/remove-unused-at-rules.js @@ -0,0 +1,249 @@ +var populateComponents = require('./properties/populate-components'); + +var wrapForOptimizing = require('../wrap-for-optimizing').single; +var restoreFromOptimizing = require('../restore-from-optimizing'); + +var Token = require('../../tokenizer/token'); + +var animationNameRegex = /^(-moz-|-o-|-webkit-)?animation-name$/; +var animationRegex = /^(-moz-|-o-|-webkit-)?animation$/; +var keyframeRegex = /^@(-moz-|-o-|-webkit-)?keyframes /; +var importantRegex = /\s{0,31}!important$/; +var optionalMatchingQuotesRegex = /^(['"]?)(.*)\1$/; + +function normalize(value) { + return value + .replace(optionalMatchingQuotesRegex, '$2') + .replace(importantRegex, ''); +} + +function removeUnusedAtRules(tokens, context) { + removeUnusedAtRule(tokens, matchCounterStyle, markCounterStylesAsUsed, context); + removeUnusedAtRule(tokens, matchFontFace, markFontFacesAsUsed, context); + removeUnusedAtRule(tokens, matchKeyframe, markKeyframesAsUsed, context); + removeUnusedAtRule(tokens, matchNamespace, markNamespacesAsUsed, context); +} + +function removeUnusedAtRule(tokens, matchCallback, markCallback, context) { + var atRules = {}; + var atRule; + var atRuleTokens; + var atRuleToken; + var zeroAt; + var i, l; + + for (i = 0, l = tokens.length; i < l; i++) { + matchCallback(tokens[i], atRules); + } + + if (Object.keys(atRules).length === 0) { + return; + } + + markUsedAtRules(tokens, markCallback, atRules, context); + + for (atRule in atRules) { + atRuleTokens = atRules[atRule]; + + for (i = 0, l = atRuleTokens.length; i < l; i++) { + atRuleToken = atRuleTokens[i]; + zeroAt = atRuleToken[0] == Token.AT_RULE ? 1 : 2; + atRuleToken[zeroAt] = []; + } + } +} + +function markUsedAtRules(tokens, markCallback, atRules, context) { + var boundMarkCallback = markCallback(atRules); + var i, l; + + for (i = 0, l = tokens.length; i < l; i++) { + switch (tokens[i][0]) { + case Token.RULE: + boundMarkCallback(tokens[i], context); + break; + case Token.NESTED_BLOCK: + markUsedAtRules(tokens[i][2], markCallback, atRules, context); + } + } +} + +function matchCounterStyle(token, atRules) { + var match; + + if (token[0] == Token.AT_RULE_BLOCK && token[1][0][1].indexOf('@counter-style') === 0) { + match = token[1][0][1].split(' ')[1]; + atRules[match] = atRules[match] || []; + atRules[match].push(token); + } +} + +function markCounterStylesAsUsed(atRules) { + return function(token, context) { + var property; + var wrappedProperty; + var i, l; + + for (i = 0, l = token[2].length; i < l; i++) { + property = token[2][i]; + + if (property[1][1] == 'list-style') { + wrappedProperty = wrapForOptimizing(property); + populateComponents([wrappedProperty], context.validator, context.warnings); + + if (wrappedProperty.components[0].value[0][1] in atRules) { + delete atRules[property[2][1]]; + } + + restoreFromOptimizing([wrappedProperty]); + } + + if (property[1][1] == 'list-style-type' && property[2][1] in atRules) { + delete atRules[property[2][1]]; + } + } + }; +} + +function matchFontFace(token, atRules) { + var property; + var match; + var i, l; + + if (token[0] == Token.AT_RULE_BLOCK && token[1][0][1] == '@font-face') { + for (i = 0, l = token[2].length; i < l; i++) { + property = token[2][i]; + + if (property[1][1] == 'font-family') { + match = normalize(property[2][1].toLowerCase()); + atRules[match] = atRules[match] || []; + atRules[match].push(token); + break; + } + } + } +} + +function markFontFacesAsUsed(atRules) { + return function(token, context) { + var property; + var wrappedProperty; + var component; + var normalizedMatch; + var i, l; + var j, m; + + for (i = 0, l = token[2].length; i < l; i++) { + property = token[2][i]; + + if (property[1][1] == 'font') { + wrappedProperty = wrapForOptimizing(property); + populateComponents([wrappedProperty], context.validator, context.warnings); + component = wrappedProperty.components[6]; + + for (j = 0, m = component.value.length; j < m; j++) { + normalizedMatch = normalize(component.value[j][1].toLowerCase()); + + if (normalizedMatch in atRules) { + delete atRules[normalizedMatch]; + } + } + + restoreFromOptimizing([wrappedProperty]); + } + + if (property[1][1] == 'font-family') { + for (j = 2, m = property.length; j < m; j++) { + normalizedMatch = normalize(property[j][1].toLowerCase()); + + if (normalizedMatch in atRules) { + delete atRules[normalizedMatch]; + } + } + } + } + }; +} + +function matchKeyframe(token, atRules) { + var match; + + if (token[0] == Token.NESTED_BLOCK && keyframeRegex.test(token[1][0][1])) { + match = token[1][0][1].split(' ')[1]; + atRules[match] = atRules[match] || []; + atRules[match].push(token); + } +} + +function markKeyframesAsUsed(atRules) { + return function(token, context) { + var property; + var wrappedProperty; + var component; + var i, l; + var j, m; + + for (i = 0, l = token[2].length; i < l; i++) { + property = token[2][i]; + + if (animationRegex.test(property[1][1])) { + wrappedProperty = wrapForOptimizing(property); + populateComponents([wrappedProperty], context.validator, context.warnings); + component = wrappedProperty.components[7]; + + for (j = 0, m = component.value.length; j < m; j++) { + if (component.value[j][1] in atRules) { + delete atRules[component.value[j][1]]; + } + } + + restoreFromOptimizing([wrappedProperty]); + } + + if (animationNameRegex.test(property[1][1])) { + for (j = 2, m = property.length; j < m; j++) { + if (property[j][1] in atRules) { + delete atRules[property[j][1]]; + } + } + } + } + }; +} + +function matchNamespace(token, atRules) { + var match; + + if (token[0] == Token.AT_RULE && token[1].indexOf('@namespace') === 0) { + match = token[1].split(' ')[1]; + atRules[match] = atRules[match] || []; + atRules[match].push(token); + } +} + +function markNamespacesAsUsed(atRules) { + var namespaceRegex = new RegExp(Object.keys(atRules).join('\\||') + '\\|', 'g'); + + return function(token) { + var match; + var scope; + var normalizedMatch; + var i, l; + var j, m; + + for (i = 0, l = token[1].length; i < l; i++) { + scope = token[1][i]; + match = scope[1].match(namespaceRegex); + + for (j = 0, m = match.length; j < m; j++) { + normalizedMatch = match[j].substring(0, match[j].length - 1); + + if (normalizedMatch in atRules) { + delete atRules[normalizedMatch]; + } + } + } + }; +} + +module.exports = removeUnusedAtRules; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/reorderable.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/reorderable.js new file mode 100644 index 0000000000000000000000000000000000000000..4e00ce289d28ee6523ddce5ec2e455c25a45edee --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/reorderable.js @@ -0,0 +1,93 @@ +// TODO: it'd be great to merge it with the other canReorder functionality + +var rulesOverlap = require('./rules-overlap'); +var specificitiesOverlap = require('./specificities-overlap'); + +var FLEX_PROPERTIES = /align-items|box-align|box-pack|flex|justify/; +var BORDER_PROPERTIES = /^border-(top|right|bottom|left|color|style|width|radius)/; + +function canReorder(left, right, cache) { + for (var i = right.length - 1; i >= 0; i--) { + for (var j = left.length - 1; j >= 0; j--) { + if (!canReorderSingle(left[j], right[i], cache)) { return false; } + } + } + + return true; +} + +function canReorderSingle(left, right, cache) { + var leftName = left[0]; + var leftValue = left[1]; + var leftNameRoot = left[2]; + var leftSelector = left[5]; + var leftInSpecificSelector = left[6]; + var rightName = right[0]; + var rightValue = right[1]; + var rightNameRoot = right[2]; + var rightSelector = right[5]; + var rightInSpecificSelector = right[6]; + + if (leftName == 'font' && rightName == 'line-height' || rightName == 'font' && leftName == 'line-height') { return false; } + if (FLEX_PROPERTIES.test(leftName) && FLEX_PROPERTIES.test(rightName)) { return false; } + if (leftNameRoot == rightNameRoot + && unprefixed(leftName) == unprefixed(rightName) + && (vendorPrefixed(leftName) ^ vendorPrefixed(rightName))) { return false; } + if (leftNameRoot == 'border' && BORDER_PROPERTIES.test(rightNameRoot) && (leftName == 'border' || leftName == rightNameRoot || (leftValue != rightValue && sameBorderComponent(leftName, rightName)))) { return false; } + if (rightNameRoot == 'border' && BORDER_PROPERTIES.test(leftNameRoot) && (rightName == 'border' || rightName == leftNameRoot || (leftValue != rightValue && sameBorderComponent(leftName, rightName)))) { return false; } + if (leftNameRoot == 'border' && rightNameRoot == 'border' && leftName != rightName && (isSideBorder(leftName) && isStyleBorder(rightName) || isStyleBorder(leftName) && isSideBorder(rightName))) { return false; } + if (leftNameRoot != rightNameRoot) { return true; } + if (leftName == rightName + && leftNameRoot == rightNameRoot + && (leftValue == rightValue || withDifferentVendorPrefix(leftValue, rightValue))) { return true; } + if (leftName != rightName + && leftNameRoot == rightNameRoot + && leftName != leftNameRoot + && rightName != rightNameRoot) { return true; } + if (leftName != rightName + && leftNameRoot == rightNameRoot + && leftValue == rightValue) { return true; } + if (rightInSpecificSelector + && leftInSpecificSelector + && !inheritable(leftNameRoot) + && !inheritable(rightNameRoot) + && !rulesOverlap(rightSelector, leftSelector, false)) { return true; } + if (!specificitiesOverlap(leftSelector, rightSelector, cache)) { return true; } + + return false; +} + +function vendorPrefixed(name) { + return /^-(?:moz|webkit|ms|o)-/.test(name); +} + +function unprefixed(name) { + return name.replace(/^-(?:moz|webkit|ms|o)-/, ''); +} + +function sameBorderComponent(name1, name2) { + return name1.split('-').pop() == name2.split('-').pop(); +} + +function isSideBorder(name) { + return name == 'border-top' || name == 'border-right' || name == 'border-bottom' || name == 'border-left'; +} + +function isStyleBorder(name) { + return name == 'border-color' || name == 'border-style' || name == 'border-width'; +} + +function withDifferentVendorPrefix(value1, value2) { + return vendorPrefixed(value1) && vendorPrefixed(value2) && value1.split('-')[1] != value2.split('-')[2]; +} + +function inheritable(name) { + // According to http://www.w3.org/TR/CSS21/propidx.html + // Others will be catched by other, preceeding rules + return name == 'font' || name == 'line-height' || name == 'list-style'; +} + +module.exports = { + canReorder: canReorder, + canReorderSingle: canReorderSingle +}; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/restore-with-components.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/restore-with-components.js new file mode 100644 index 0000000000000000000000000000000000000000..f2965bab8f0fdd90c67a8831721d57003d33cc34 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/restore-with-components.js @@ -0,0 +1,12 @@ +var configuration = require('../configuration'); + +function restoreWithComponents(property) { + var descriptor = configuration[property.name]; + + if (descriptor && descriptor.shorthand) { + return descriptor.restore(property, configuration); + } + return property.value; +} + +module.exports = restoreWithComponents; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/restructure.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/restructure.js new file mode 100644 index 0000000000000000000000000000000000000000..934a925df85103b0432452d8b1ce077ff3178ee2 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/restructure.js @@ -0,0 +1,392 @@ +var canReorderSingle = require('./reorderable').canReorderSingle; +var extractProperties = require('./extract-properties'); +var isMergeable = require('./is-mergeable'); +var tidyRuleDuplicates = require('./tidy-rule-duplicates'); + +var Token = require('../../tokenizer/token'); + +var cloneArray = require('../../utils/clone-array'); + +var serializeBody = require('../../writer/one-time').body; +var serializeRules = require('../../writer/one-time').rules; + +function naturalSorter(a, b) { + return a > b ? 1 : -1; +} + +function cloneAndMergeSelectors(propertyA, propertyB) { + var cloned = cloneArray(propertyA); + cloned[5] = cloned[5].concat(propertyB[5]); + + return cloned; +} + +function restructure(tokens, context) { + var options = context.options; + var mergeablePseudoClasses = options.compatibility.selectors.mergeablePseudoClasses; + var mergeablePseudoElements = options.compatibility.selectors.mergeablePseudoElements; + var mergeLimit = options.compatibility.selectors.mergeLimit; + var multiplePseudoMerging = options.compatibility.selectors.multiplePseudoMerging; + var specificityCache = context.cache.specificity; + var movableTokens = {}; + var movedProperties = []; + var multiPropertyMoveCache = {}; + var movedToBeDropped = []; + var maxCombinationsLevel = 2; + var ID_JOIN_CHARACTER = '%'; + + function sendToMultiPropertyMoveCache(position, movedProperty, allFits) { + for (var i = allFits.length - 1; i >= 0; i--) { + var fit = allFits[i][0]; + var id = addToCache(movedProperty, fit); + + if (multiPropertyMoveCache[id].length > 1 && processMultiPropertyMove(position, multiPropertyMoveCache[id])) { + removeAllMatchingFromCache(id); + break; + } + } + } + + function addToCache(movedProperty, fit) { + var id = cacheId(fit); + multiPropertyMoveCache[id] = multiPropertyMoveCache[id] || []; + multiPropertyMoveCache[id].push([movedProperty, fit]); + return id; + } + + function removeAllMatchingFromCache(matchId) { + var matchSelectors = matchId.split(ID_JOIN_CHARACTER); + var forRemoval = []; + var i; + + for (var id in multiPropertyMoveCache) { + var selectors = id.split(ID_JOIN_CHARACTER); + for (i = selectors.length - 1; i >= 0; i--) { + if (matchSelectors.indexOf(selectors[i]) > -1) { + forRemoval.push(id); + break; + } + } + } + + for (i = forRemoval.length - 1; i >= 0; i--) { + delete multiPropertyMoveCache[forRemoval[i]]; + } + } + + function cacheId(cachedTokens) { + var id = []; + for (var i = 0, l = cachedTokens.length; i < l; i++) { + id.push(serializeRules(cachedTokens[i][1])); + } + return id.join(ID_JOIN_CHARACTER); + } + + function tokensToMerge(sourceTokens) { + var uniqueTokensWithBody = []; + var mergeableTokens = []; + + for (var i = sourceTokens.length - 1; i >= 0; i--) { + if (!isMergeable( + serializeRules(sourceTokens[i][1]), + mergeablePseudoClasses, + mergeablePseudoElements, + multiplePseudoMerging + )) { + continue; + } + + mergeableTokens.unshift(sourceTokens[i]); + if (sourceTokens[i][2].length > 0 + && uniqueTokensWithBody.indexOf(sourceTokens[i]) == -1) { + uniqueTokensWithBody.push(sourceTokens[i]); + } + } + + return uniqueTokensWithBody.length > 1 + ? mergeableTokens + : []; + } + + function shortenIfPossible(position, movedProperty) { + var name = movedProperty[0]; + var value = movedProperty[1]; + var key = movedProperty[4]; + var valueSize = name.length + value.length + 1; + var allSelectors = []; + var qualifiedTokens = []; + + var mergeableTokens = tokensToMerge(movableTokens[key]); + if (mergeableTokens.length < 2) { return; } + + var allFits = findAllFits(mergeableTokens, valueSize, 1); + var bestFit = allFits[0]; + if (bestFit[1] > 0) { return sendToMultiPropertyMoveCache(position, movedProperty, allFits); } + + for (var i = bestFit[0].length - 1; i >= 0; i--) { + allSelectors = bestFit[0][i][1].concat(allSelectors); + qualifiedTokens.unshift(bestFit[0][i]); + } + + allSelectors = tidyRuleDuplicates(allSelectors); + dropAsNewTokenAt(position, [movedProperty], allSelectors, qualifiedTokens); + } + + function fitSorter(fit1, fit2) { + return fit1[1] > fit2[1] ? 1 : (fit1[1] == fit2[1] ? 0 : -1); + } + + function findAllFits(mergeableTokens, propertySize, propertiesCount) { + var combinations = allCombinations(mergeableTokens, propertySize, propertiesCount, maxCombinationsLevel - 1); + return combinations.sort(fitSorter); + } + + function allCombinations(tokensVariant, propertySize, propertiesCount, level) { + var differenceVariants = [[tokensVariant, sizeDifference(tokensVariant, propertySize, propertiesCount)]]; + if (tokensVariant.length > 2 && level > 0) { + for (var i = tokensVariant.length - 1; i >= 0; i--) { + var subVariant = Array.prototype.slice.call(tokensVariant, 0); + subVariant.splice(i, 1); + differenceVariants = differenceVariants.concat( + allCombinations(subVariant, propertySize, propertiesCount, level - 1) + ); + } + } + + return differenceVariants; + } + + function sizeDifference(tokensVariant, propertySize, propertiesCount) { + var allSelectorsSize = 0; + for (var i = tokensVariant.length - 1; i >= 0; i--) { + allSelectorsSize += tokensVariant[i][2].length > propertiesCount + ? serializeRules(tokensVariant[i][1]).length + : -1; + } + return allSelectorsSize - (tokensVariant.length - 1) * propertySize + 1; + } + + function dropAsNewTokenAt(position, properties, allSelectors, mergeableTokens) { + var i, j, k, m; + var allProperties = []; + + for (i = mergeableTokens.length - 1; i >= 0; i--) { + var mergeableToken = mergeableTokens[i]; + + for (j = mergeableToken[2].length - 1; j >= 0; j--) { + var mergeableProperty = mergeableToken[2][j]; + + for (k = 0, m = properties.length; k < m; k++) { + var property = properties[k]; + + var mergeablePropertyName = mergeableProperty[1][1]; + var propertyName = property[0]; + var propertyBody = property[4]; + if (mergeablePropertyName == propertyName && serializeBody([mergeableProperty]) == propertyBody) { + mergeableToken[2].splice(j, 1); + break; + } + } + } + } + + for (i = properties.length - 1; i >= 0; i--) { + allProperties.unshift(properties[i][3]); + } + + var newToken = [Token.RULE, allSelectors, allProperties]; + tokens.splice(position, 0, newToken); + } + + function dropPropertiesAt(position, movedProperty) { + var key = movedProperty[4]; + var toMove = movableTokens[key]; + + if (toMove && toMove.length > 1) { + if (!shortenMultiMovesIfPossible(position, movedProperty)) { shortenIfPossible(position, movedProperty); } + } + } + + function shortenMultiMovesIfPossible(position, movedProperty) { + var candidates = []; + var propertiesAndMergableTokens = []; + var key = movedProperty[4]; + var j, k; + + var mergeableTokens = tokensToMerge(movableTokens[key]); + if (mergeableTokens.length < 2) { return; } + + movableLoop: + for (var value in movableTokens) { + var tokensList = movableTokens[value]; + + for (j = mergeableTokens.length - 1; j >= 0; j--) { + if (tokensList.indexOf(mergeableTokens[j]) == -1) { continue movableLoop; } + } + + candidates.push(value); + } + + if (candidates.length < 2) { return false; } + + for (j = candidates.length - 1; j >= 0; j--) { + for (k = movedProperties.length - 1; k >= 0; k--) { + if (movedProperties[k][4] == candidates[j]) { + propertiesAndMergableTokens.unshift([movedProperties[k], mergeableTokens]); + break; + } + } + } + + return processMultiPropertyMove(position, propertiesAndMergableTokens); + } + + function processMultiPropertyMove(position, propertiesAndMergableTokens) { + var valueSize = 0; + var properties = []; + var property; + + for (var i = propertiesAndMergableTokens.length - 1; i >= 0; i--) { + property = propertiesAndMergableTokens[i][0]; + var fullValue = property[4]; + valueSize += fullValue.length + (i > 0 ? 1 : 0); + + properties.push(property); + } + + var mergeableTokens = propertiesAndMergableTokens[0][1]; + var bestFit = findAllFits(mergeableTokens, valueSize, properties.length)[0]; + if (bestFit[1] > 0) { return false; } + + var allSelectors = []; + var qualifiedTokens = []; + for (i = bestFit[0].length - 1; i >= 0; i--) { + allSelectors = bestFit[0][i][1].concat(allSelectors); + qualifiedTokens.unshift(bestFit[0][i]); + } + + allSelectors = tidyRuleDuplicates(allSelectors); + dropAsNewTokenAt(position, properties, allSelectors, qualifiedTokens); + + for (i = properties.length - 1; i >= 0; i--) { + property = properties[i]; + var index = movedProperties.indexOf(property); + + delete movableTokens[property[4]]; + + if (index > -1 && movedToBeDropped.indexOf(index) == -1) { movedToBeDropped.push(index); } + } + + return true; + } + + function boundToAnotherPropertyInCurrrentToken(property, movedProperty, token) { + var propertyName = property[0]; + var movedPropertyName = movedProperty[0]; + if (propertyName != movedPropertyName) { return false; } + + var key = movedProperty[4]; + var toMove = movableTokens[key]; + return toMove && toMove.indexOf(token) > -1; + } + + for (var i = tokens.length - 1; i >= 0; i--) { + var token = tokens[i]; + var isRule; + var j, k, m; + var samePropertyAt; + + if (token[0] == Token.RULE) { + isRule = true; + } else if (token[0] == Token.NESTED_BLOCK) { + isRule = false; + } else { + continue; + } + + // We cache movedProperties.length as it may change in the loop + var movedCount = movedProperties.length; + + var properties = extractProperties(token); + movedToBeDropped = []; + + var unmovableInCurrentToken = []; + for (j = properties.length - 1; j >= 0; j--) { + for (k = j - 1; k >= 0; k--) { + if (!canReorderSingle(properties[j], properties[k], specificityCache)) { + unmovableInCurrentToken.push(j); + break; + } + } + } + + for (j = properties.length - 1; j >= 0; j--) { + var property = properties[j]; + var movedSameProperty = false; + + for (k = 0; k < movedCount; k++) { + var movedProperty = movedProperties[k]; + + if (movedToBeDropped.indexOf(k) == -1 && ( + !canReorderSingle(property, movedProperty, specificityCache) + && !boundToAnotherPropertyInCurrrentToken(property, movedProperty, token) + || movableTokens[movedProperty[4]] && movableTokens[movedProperty[4]].length === mergeLimit) + ) { + dropPropertiesAt(i + 1, movedProperty); + + if (movedToBeDropped.indexOf(k) == -1) { + movedToBeDropped.push(k); + delete movableTokens[movedProperty[4]]; + } + } + + if (!movedSameProperty) { + movedSameProperty = property[0] == movedProperty[0] && property[1] == movedProperty[1]; + + if (movedSameProperty) { + samePropertyAt = k; + } + } + } + + if (!isRule || unmovableInCurrentToken.indexOf(j) > -1) { continue; } + + var key = property[4]; + + if (movedSameProperty && movedProperties[samePropertyAt][5].length + property[5].length > mergeLimit) { + dropPropertiesAt(i + 1, movedProperties[samePropertyAt]); + movedProperties.splice(samePropertyAt, 1); + movableTokens[key] = [token]; + movedSameProperty = false; + } else { + movableTokens[key] = movableTokens[key] || []; + movableTokens[key].push(token); + } + + if (movedSameProperty) { + movedProperties[samePropertyAt] = cloneAndMergeSelectors(movedProperties[samePropertyAt], property); + } else { + movedProperties.push(property); + } + } + + movedToBeDropped = movedToBeDropped.sort(naturalSorter); + for (j = 0, m = movedToBeDropped.length; j < m; j++) { + var dropAt = movedToBeDropped[j] - j; + movedProperties.splice(dropAt, 1); + } + } + + var position = tokens[0] && tokens[0][0] == Token.AT_RULE && tokens[0][1].indexOf('@charset') === 0 ? 1 : 0; + for (; position < tokens.length - 1; position++) { + var isImportRule = tokens[position][0] === Token.AT_RULE && tokens[position][1].indexOf('@import') === 0; + var isComment = tokens[position][0] === Token.COMMENT; + if (!(isImportRule || isComment)) { break; } + } + + for (i = 0; i < movedProperties.length; i++) { + dropPropertiesAt(position, movedProperties[i]); + } +} + +module.exports = restructure; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/rules-overlap.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/rules-overlap.js new file mode 100644 index 0000000000000000000000000000000000000000..ed87c4edc81b5e8d3e5c0b7170b7899235a9208d --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/rules-overlap.js @@ -0,0 +1,32 @@ +var MODIFIER_PATTERN = /--.+$/; + +function rulesOverlap(rule1, rule2, bemMode) { + var scope1; + var scope2; + var i, l; + var j, m; + + for (i = 0, l = rule1.length; i < l; i++) { + scope1 = rule1[i][1]; + + for (j = 0, m = rule2.length; j < m; j++) { + scope2 = rule2[j][1]; + + if (scope1 == scope2) { + return true; + } + + if (bemMode && withoutModifiers(scope1) == withoutModifiers(scope2)) { + return true; + } + } + } + + return false; +} + +function withoutModifiers(scope) { + return scope.replace(MODIFIER_PATTERN, ''); +} + +module.exports = rulesOverlap; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/specificities-overlap.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/specificities-overlap.js new file mode 100644 index 0000000000000000000000000000000000000000..f166d91a0e1c922b1d1603e6e05a2c497851c640 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/specificities-overlap.js @@ -0,0 +1,36 @@ +var specificity = require('./specificity'); + +function specificitiesOverlap(selector1, selector2, cache) { + var specificity1; + var specificity2; + var i, l; + var j, m; + + for (i = 0, l = selector1.length; i < l; i++) { + specificity1 = findSpecificity(selector1[i][1], cache); + + for (j = 0, m = selector2.length; j < m; j++) { + specificity2 = findSpecificity(selector2[j][1], cache); + + if (specificity1[0] === specificity2[0] + && specificity1[1] === specificity2[1] + && specificity1[2] === specificity2[2]) { + return true; + } + } + } + + return false; +} + +function findSpecificity(selector, cache) { + var value; + + if (!(selector in cache)) { + cache[selector] = value = specificity(selector); + } + + return value || cache[selector]; +} + +module.exports = specificitiesOverlap; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/specificity.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/specificity.js new file mode 100644 index 0000000000000000000000000000000000000000..376290fdef6b04bea3f348c12e3de04adeaf5c5a --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/specificity.js @@ -0,0 +1,77 @@ +var Marker = require('../../tokenizer/marker'); + +var Selector = { + ADJACENT_SIBLING: '+', + DESCENDANT: '>', + DOT: '.', + HASH: '#', + NON_ADJACENT_SIBLING: '~', + PSEUDO: ':' +}; + +var LETTER_PATTERN = /[a-zA-Z]/; +var NOT_PREFIX = ':not('; +var SEPARATOR_PATTERN = /[\s,(>~+]/; + +function specificity(selector) { + var result = [0, 0, 0]; + var character; + var isEscaped; + var isSingleQuoted; + var isDoubleQuoted; + var roundBracketLevel = 0; + var couldIntroduceNewTypeSelector; + var withinNotPseudoClass = false; + var wasPseudoClass = false; + var i, l; + + for (i = 0, l = selector.length; i < l; i++) { + character = selector[i]; + + if (isEscaped) { + // noop + } else if (character == Marker.SINGLE_QUOTE && !isDoubleQuoted && !isSingleQuoted) { + isSingleQuoted = true; + } else if (character == Marker.SINGLE_QUOTE && !isDoubleQuoted && isSingleQuoted) { + isSingleQuoted = false; + } else if (character == Marker.DOUBLE_QUOTE && !isDoubleQuoted && !isSingleQuoted) { + isDoubleQuoted = true; + } else if (character == Marker.DOUBLE_QUOTE && isDoubleQuoted && !isSingleQuoted) { + isDoubleQuoted = false; + } else if (isSingleQuoted || isDoubleQuoted) { + continue; + } else if (roundBracketLevel > 0 && !withinNotPseudoClass) { + // noop + } else if (character == Marker.OPEN_ROUND_BRACKET) { + roundBracketLevel++; + } else if (character == Marker.CLOSE_ROUND_BRACKET && roundBracketLevel == 1) { + roundBracketLevel--; + withinNotPseudoClass = false; + } else if (character == Marker.CLOSE_ROUND_BRACKET) { + roundBracketLevel--; + } else if (character == Selector.HASH) { + result[0]++; + } else if (character == Selector.DOT || character == Marker.OPEN_SQUARE_BRACKET) { + result[1]++; + } else if (character == Selector.PSEUDO && !wasPseudoClass && !isNotPseudoClass(selector, i)) { + result[1]++; + withinNotPseudoClass = false; + } else if (character == Selector.PSEUDO) { + withinNotPseudoClass = true; + } else if ((i === 0 || couldIntroduceNewTypeSelector) && LETTER_PATTERN.test(character)) { + result[2]++; + } + + isEscaped = character == Marker.BACK_SLASH; + wasPseudoClass = character == Selector.PSEUDO; + couldIntroduceNewTypeSelector = !isEscaped && SEPARATOR_PATTERN.test(character); + } + + return result; +} + +function isNotPseudoClass(selector, index) { + return selector.indexOf(NOT_PREFIX, index) === index; +} + +module.exports = specificity; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/level-2/tidy-rule-duplicates.js b/igv_component/node_modules/clean-css/lib/optimizer/level-2/tidy-rule-duplicates.js new file mode 100644 index 0000000000000000000000000000000000000000..30a9c2177f095a0474221a321c6179d0a410eccf --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/level-2/tidy-rule-duplicates.js @@ -0,0 +1,21 @@ +function ruleSorter(s1, s2) { + return s1[1] > s2[1] ? 1 : -1; +} + +function tidyRuleDuplicates(rules) { + var list = []; + var repeated = []; + + for (var i = 0, l = rules.length; i < l; i++) { + var rule = rules[i]; + + if (repeated.indexOf(rule[1]) == -1) { + repeated.push(rule[1]); + list.push(rule); + } + } + + return list.sort(ruleSorter); +} + +module.exports = tidyRuleDuplicates; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/remove-unused.js b/igv_component/node_modules/clean-css/lib/optimizer/remove-unused.js new file mode 100644 index 0000000000000000000000000000000000000000..7b90c40793fd95cf10af351d2f33fffe248a9f44 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/remove-unused.js @@ -0,0 +1,11 @@ +function removeUnused(properties) { + for (var i = properties.length - 1; i >= 0; i--) { + var property = properties[i]; + + if (property.unused) { + property.all.splice(property.position, 1); + } + } +} + +module.exports = removeUnused; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/restore-from-optimizing.js b/igv_component/node_modules/clean-css/lib/optimizer/restore-from-optimizing.js new file mode 100644 index 0000000000000000000000000000000000000000..b45ed9c85ff7e8d4ba9aced1a88c80a84024946f --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/restore-from-optimizing.js @@ -0,0 +1,78 @@ +var Hack = require('./hack'); + +var Marker = require('../tokenizer/marker'); + +var ASTERISK_HACK = '*'; +var BACKSLASH_HACK = '\\'; +var IMPORTANT_TOKEN = '!important'; +var UNDERSCORE_HACK = '_'; +var BANG_HACK = '!ie'; + +function restoreFromOptimizing(properties, restoreCallback) { + var property; + var restored; + var current; + var i; + + for (i = properties.length - 1; i >= 0; i--) { + property = properties[i]; + + if (property.dynamic && property.important) { + restoreImportant(property); + continue; + } + + if (property.dynamic) { + continue; + } + + if (property.unused) { + continue; + } + + if (!property.dirty && !property.important && !property.hack) { + continue; + } + + if (property.optimizable && restoreCallback) { + restored = restoreCallback(property); + property.value = restored; + } else { + restored = property.value; + } + + if (property.important) { + restoreImportant(property); + } + + if (property.hack) { + restoreHack(property); + } + + if ('all' in property) { + current = property.all[property.position]; + current[1][1] = property.name; + + current.splice(2, current.length - 1); + Array.prototype.push.apply(current, restored); + } + } +} + +function restoreImportant(property) { + property.value[property.value.length - 1][1] += IMPORTANT_TOKEN; +} + +function restoreHack(property) { + if (property.hack[0] == Hack.UNDERSCORE) { + property.name = UNDERSCORE_HACK + property.name; + } else if (property.hack[0] == Hack.ASTERISK) { + property.name = ASTERISK_HACK + property.name; + } else if (property.hack[0] == Hack.BACKSLASH) { + property.value[property.value.length - 1][1] += BACKSLASH_HACK + property.hack[1]; + } else if (property.hack[0] == Hack.BANG) { + property.value[property.value.length - 1][1] += Marker.SPACE + BANG_HACK; + } +} + +module.exports = restoreFromOptimizing; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/validator.js b/igv_component/node_modules/clean-css/lib/optimizer/validator.js new file mode 100644 index 0000000000000000000000000000000000000000..3e2a5c880edf2c110ee92b9121a9715f800f43d8 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/validator.js @@ -0,0 +1,561 @@ +var functionNoVendorRegexStr = '[A-Z]+(\\-|[A-Z]|[0-9])+\\(.*?\\)'; +var functionVendorRegexStr = '\\-(\\-|[A-Z]|[0-9])+\\(.*?\\)'; +var variableRegexStr = 'var\\(\\-\\-[^\\)]+\\)'; +var functionAnyRegexStr = '(' + variableRegexStr + '|' + functionNoVendorRegexStr + '|' + functionVendorRegexStr + ')'; + +var calcRegex = new RegExp('^(\\-moz\\-|\\-webkit\\-)?calc\\([^\\)]+\\)$', 'i'); +var decimalRegex = /[0-9]/; +var functionAnyRegex = new RegExp('^' + functionAnyRegexStr + '$', 'i'); +var hexAlphaColorRegex = /^#(?:[0-9a-f]{4}|[0-9a-f]{8})$/i; +// eslint-disable-next-line max-len +var hslColorRegex = /^hsl\(\s{0,31}[-.]?\d+\s{0,31},\s{0,31}\d*\.?\d+%\s{0,31},\s{0,31}\d*\.?\d+%\s{0,31}\)|hsla\(\s{0,31}[-.]?\d+\s{0,31},\s{0,31}\d*\.?\d+%\s{0,31},\s{0,31}\d*\.?\d+%\s{0,31},\s{0,31}\.?\d+\s{0,31}\)$/; +// eslint-disable-next-line max-len +var hslColorWithSpacesRegex = /^hsl\(\s{0,31}[-.]?\d+(deg)?\s{1,31}\d*\.?\d+%\s{1,31}\d*\.?\d+%\s{0,31}\)|hsla\(\s{0,31}[-.]?\d+(deg)?\s{1,31}\d*\.?\d+%\s{1,31}\d*\.?\d+%\s{1,31}\/\s{1,31}\d*\.?\d+%?\s{0,31}\)$/; +var identifierRegex = /^(-[a-z0-9_][a-z0-9\-_]*|[a-z_][a-z0-9\-_]*)$/i; +var namedEntityRegex = /^[a-z]+$/i; +var prefixRegex = /^-([a-z0-9]|-)*$/i; +var quotedTextRegex = /^("[^"]*"|'[^']*')$/i; +// eslint-disable-next-line max-len +var rgbColorRegex = /^rgb\(\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31}\)|rgba\(\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[.\d]+\s{0,31}\)$/i; +// eslint-disable-next-line max-len +var rgbColorWithSpacesRegex = /^rgb\(\s{0,31}[\d]{1,3}\s{1,31}[\d]{1,3}\s{1,31}[\d]{1,3}\s{0,31}\)|rgba\(\s{0,31}[\d]{1,3}\s{1,31}[\d]{1,3}\s{1,31}[\d]{1,3}\s{1,31}\/\s{1,31}[\d]*\.?[.\d]+%?\s{0,31}\)$/i; +var timeUnitPattern = /\d+(s|ms)/; +var timingFunctionRegex = /^(cubic-bezier|steps)\([^)]+\)$/; +var validTimeUnits = ['ms', 's']; +var urlRegex = /^url\([\s\S]+\)$/i; +var variableRegex = new RegExp('^' + variableRegexStr + '$', 'i'); + +var eightValueColorRegex = /^#[0-9a-f]{8}$/i; +var fourValueColorRegex = /^#[0-9a-f]{4}$/i; +var sixValueColorRegex = /^#[0-9a-f]{6}$/i; +var threeValueColorRegex = /^#[0-9a-f]{3}$/i; + +var DECIMAL_DOT = '.'; +var MINUS_SIGN = '-'; +var PLUS_SIGN = '+'; + +var Keywords = { + '^': [ + 'inherit', + 'initial', + 'unset' + ], + '*-style': [ + 'auto', + 'dashed', + 'dotted', + 'double', + 'groove', + 'hidden', + 'inset', + 'none', + 'outset', + 'ridge', + 'solid' + ], + '*-timing-function': [ + 'ease', + 'ease-in', + 'ease-in-out', + 'ease-out', + 'linear', + 'step-end', + 'step-start' + ], + 'animation-direction': [ + 'alternate', + 'alternate-reverse', + 'normal', + 'reverse' + ], + 'animation-fill-mode': [ + 'backwards', + 'both', + 'forwards', + 'none' + ], + 'animation-iteration-count': [ + 'infinite' + ], + 'animation-name': [ + 'none' + ], + 'animation-play-state': [ + 'paused', + 'running' + ], + 'background-attachment': [ + 'fixed', + 'inherit', + 'local', + 'scroll' + ], + 'background-clip': [ + 'border-box', + 'content-box', + 'inherit', + 'padding-box', + 'text' + ], + 'background-origin': [ + 'border-box', + 'content-box', + 'inherit', + 'padding-box' + ], + 'background-position': [ + 'bottom', + 'center', + 'left', + 'right', + 'top' + ], + 'background-repeat': [ + 'no-repeat', + 'inherit', + 'repeat', + 'repeat-x', + 'repeat-y', + 'round', + 'space' + ], + 'background-size': [ + 'auto', + 'cover', + 'contain' + ], + 'border-collapse': [ + 'collapse', + 'inherit', + 'separate' + ], + bottom: [ + 'auto' + ], + clear: [ + 'both', + 'left', + 'none', + 'right' + ], + color: [ + 'transparent' + ], + cursor: [ + 'all-scroll', + 'auto', + 'col-resize', + 'crosshair', + 'default', + 'e-resize', + 'help', + 'move', + 'n-resize', + 'ne-resize', + 'no-drop', + 'not-allowed', + 'nw-resize', + 'pointer', + 'progress', + 'row-resize', + 's-resize', + 'se-resize', + 'sw-resize', + 'text', + 'vertical-text', + 'w-resize', + 'wait' + ], + display: [ + 'block', + 'inline', + 'inline-block', + 'inline-table', + 'list-item', + 'none', + 'table', + 'table-caption', + 'table-cell', + 'table-column', + 'table-column-group', + 'table-footer-group', + 'table-header-group', + 'table-row', + 'table-row-group' + ], + float: [ + 'left', + 'none', + 'right' + ], + left: [ + 'auto' + ], + font: [ + 'caption', + 'icon', + 'menu', + 'message-box', + 'small-caption', + 'status-bar', + 'unset' + ], + 'font-size': [ + 'large', + 'larger', + 'medium', + 'small', + 'smaller', + 'x-large', + 'x-small', + 'xx-large', + 'xx-small' + ], + 'font-stretch': [ + 'condensed', + 'expanded', + 'extra-condensed', + 'extra-expanded', + 'normal', + 'semi-condensed', + 'semi-expanded', + 'ultra-condensed', + 'ultra-expanded' + ], + 'font-style': [ + 'italic', + 'normal', + 'oblique' + ], + 'font-variant': [ + 'normal', + 'small-caps' + ], + 'font-weight': [ + '100', + '200', + '300', + '400', + '500', + '600', + '700', + '800', + '900', + 'bold', + 'bolder', + 'lighter', + 'normal' + ], + 'line-height': [ + 'normal' + ], + 'list-style-position': [ + 'inside', + 'outside' + ], + 'list-style-type': [ + 'armenian', + 'circle', + 'decimal', + 'decimal-leading-zero', + 'disc', + 'decimal|disc', // this is the default value of list-style-type, see comment in configuration.js + 'georgian', + 'lower-alpha', + 'lower-greek', + 'lower-latin', + 'lower-roman', + 'none', + 'square', + 'upper-alpha', + 'upper-latin', + 'upper-roman' + ], + overflow: [ + 'auto', + 'hidden', + 'scroll', + 'visible' + ], + position: [ + 'absolute', + 'fixed', + 'relative', + 'static' + ], + right: [ + 'auto' + ], + 'text-align': [ + 'center', + 'justify', + 'left', + 'left|right', // this is the default value of list-style-type, see comment in configuration.js + 'right' + ], + 'text-decoration': [ + 'line-through', + 'none', + 'overline', + 'underline' + ], + 'text-overflow': [ + 'clip', + 'ellipsis' + ], + top: [ + 'auto' + ], + 'vertical-align': [ + 'baseline', + 'bottom', + 'middle', + 'sub', + 'super', + 'text-bottom', + 'text-top', + 'top' + ], + visibility: [ + 'collapse', + 'hidden', + 'visible' + ], + 'white-space': [ + 'normal', + 'nowrap', + 'pre' + ], + width: [ + 'inherit', + 'initial', + 'medium', + 'thick', + 'thin' + ] +}; + +var Units = [ + '%', + 'ch', + 'cm', + 'em', + 'ex', + 'in', + 'mm', + 'pc', + 'pt', + 'px', + 'rem', + 'vh', + 'vm', + 'vmax', + 'vmin', + 'vw' +]; + +function isColor(value) { + return value != 'auto' + && ( + isKeyword('color')(value) + || isHexColor(value) + || isColorFunction(value) + || isNamedEntity(value) + ); +} + +function isColorFunction(value) { + return isRgbColor(value) || isHslColor(value); +} + +function isDynamicUnit(value) { + return calcRegex.test(value); +} + +function isFunction(value) { + return functionAnyRegex.test(value); +} + +function isHexColor(value) { + return threeValueColorRegex.test(value) + || fourValueColorRegex.test(value) + || sixValueColorRegex.test(value) + || eightValueColorRegex.test(value); +} + +function isHslColor(value) { + return hslColorRegex.test(value) || hslColorWithSpacesRegex.test(value); +} + +function isHexAlphaColor(value) { + return hexAlphaColorRegex.test(value); +} + +function isIdentifier(value) { + return identifierRegex.test(value); +} + +function isQuotedText(value) { + return quotedTextRegex.test(value); +} + +function isImage(value) { + return value == 'none' || value == 'inherit' || isUrl(value); +} + +function isKeyword(propertyName) { + return function(value) { + return Keywords[propertyName].indexOf(value) > -1; + }; +} + +function isNamedEntity(value) { + return namedEntityRegex.test(value); +} + +function isNumber(value) { + return scanForNumber(value) == value.length; +} + +function isRgbColor(value) { + return rgbColorRegex.test(value) || rgbColorWithSpacesRegex.test(value); +} + +function isPrefixed(value) { + return prefixRegex.test(value); +} + +function isPositiveNumber(value) { + return isNumber(value) + && parseFloat(value) >= 0; +} + +function isVariable(value) { + return variableRegex.test(value); +} + +function isTime(value) { + var numberUpTo = scanForNumber(value); + + return numberUpTo == value.length && parseInt(value) === 0 + || numberUpTo > -1 && validTimeUnits.indexOf(value.slice(numberUpTo + 1)) > -1 + || isCalculatedTime(value); +} + +function isCalculatedTime(value) { + return isFunction(value) && timeUnitPattern.test(value); +} + +function isTimingFunction() { + var isTimingFunctionKeyword = isKeyword('*-timing-function'); + + return function(value) { + return isTimingFunctionKeyword(value) || timingFunctionRegex.test(value); + }; +} + +function isUnit(validUnits, value) { + var numberUpTo = scanForNumber(value); + + return numberUpTo == value.length && parseInt(value) === 0 + || numberUpTo > -1 && validUnits.indexOf(value.slice(numberUpTo + 1).toLowerCase()) > -1 + || value == 'auto' + || value == 'inherit'; +} + +function isUrl(value) { + return urlRegex.test(value); +} + +function isZIndex(value) { + return value == 'auto' + || isNumber(value) + || isKeyword('^')(value); +} + +function scanForNumber(value) { + var hasDot = false; + var hasSign = false; + var character; + var i, l; + + for (i = 0, l = value.length; i < l; i++) { + character = value[i]; + + if (i === 0 && (character == PLUS_SIGN || character == MINUS_SIGN)) { + hasSign = true; + } else if (i > 0 && hasSign && (character == PLUS_SIGN || character == MINUS_SIGN)) { + return i - 1; + } else if (character == DECIMAL_DOT && !hasDot) { + hasDot = true; + } else if (character == DECIMAL_DOT && hasDot) { + return i - 1; + } else if (decimalRegex.test(character)) { + continue; + } else { + return i - 1; + } + } + + return i; +} + +function validator(compatibility) { + var validUnits = Units.slice(0).filter(function(value) { + return !(value in compatibility.units) || compatibility.units[value] === true; + }); + + if (compatibility.customUnits.rpx) { + validUnits.push('rpx'); + } + + return { + colorOpacity: compatibility.colors.opacity, + colorHexAlpha: compatibility.colors.hexAlpha, + isAnimationDirectionKeyword: isKeyword('animation-direction'), + isAnimationFillModeKeyword: isKeyword('animation-fill-mode'), + isAnimationIterationCountKeyword: isKeyword('animation-iteration-count'), + isAnimationNameKeyword: isKeyword('animation-name'), + isAnimationPlayStateKeyword: isKeyword('animation-play-state'), + isTimingFunction: isTimingFunction(), + isBackgroundAttachmentKeyword: isKeyword('background-attachment'), + isBackgroundClipKeyword: isKeyword('background-clip'), + isBackgroundOriginKeyword: isKeyword('background-origin'), + isBackgroundPositionKeyword: isKeyword('background-position'), + isBackgroundRepeatKeyword: isKeyword('background-repeat'), + isBackgroundSizeKeyword: isKeyword('background-size'), + isColor: isColor, + isColorFunction: isColorFunction, + isDynamicUnit: isDynamicUnit, + isFontKeyword: isKeyword('font'), + isFontSizeKeyword: isKeyword('font-size'), + isFontStretchKeyword: isKeyword('font-stretch'), + isFontStyleKeyword: isKeyword('font-style'), + isFontVariantKeyword: isKeyword('font-variant'), + isFontWeightKeyword: isKeyword('font-weight'), + isFunction: isFunction, + isGlobal: isKeyword('^'), + isHexAlphaColor: isHexAlphaColor, + isHslColor: isHslColor, + isIdentifier: isIdentifier, + isImage: isImage, + isKeyword: isKeyword, + isLineHeightKeyword: isKeyword('line-height'), + isListStylePositionKeyword: isKeyword('list-style-position'), + isListStyleTypeKeyword: isKeyword('list-style-type'), + isNumber: isNumber, + isPrefixed: isPrefixed, + isPositiveNumber: isPositiveNumber, + isQuotedText: isQuotedText, + isRgbColor: isRgbColor, + isStyleKeyword: isKeyword('*-style'), + isTime: isTime, + isUnit: isUnit.bind(null, validUnits), + isUrl: isUrl, + isVariable: isVariable, + isWidth: isKeyword('width'), + isZIndex: isZIndex + }; +} + +module.exports = validator; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/vendor-prefixes.js b/igv_component/node_modules/clean-css/lib/optimizer/vendor-prefixes.js new file mode 100644 index 0000000000000000000000000000000000000000..5032c7e8e2bd5949da8da31c24d098e542908d14 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/vendor-prefixes.js @@ -0,0 +1,24 @@ +var VENDOR_PREFIX_PATTERN = /(?:^|\W)(-\w+-)/g; + +function unique(value) { + var prefixes = []; + var match; + + // eslint-disable-next-line no-cond-assign + while ((match = VENDOR_PREFIX_PATTERN.exec(value)) !== null) { + if (prefixes.indexOf(match[0]) == -1) { + prefixes.push(match[0]); + } + } + + return prefixes; +} + +function same(value1, value2) { + return unique(value1).sort().join(',') == unique(value2).sort().join(','); +} + +module.exports = { + unique: unique, + same: same +}; diff --git a/igv_component/node_modules/clean-css/lib/optimizer/wrap-for-optimizing.js b/igv_component/node_modules/clean-css/lib/optimizer/wrap-for-optimizing.js new file mode 100644 index 0000000000000000000000000000000000000000..30aedaff3f2de8162dd4304b6dae90f08b1a75ce --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/optimizer/wrap-for-optimizing.js @@ -0,0 +1,192 @@ +var Hack = require('./hack'); + +var Marker = require('../tokenizer/marker'); +var Token = require('../tokenizer/token'); + +var Match = { + ASTERISK: '*', + BACKSLASH: '\\', + BANG: '!', + BANG_SUFFIX_PATTERN: /!\w+$/, + IMPORTANT_TOKEN: '!important', + IMPORTANT_TOKEN_PATTERN: new RegExp('!important$', 'i'), + IMPORTANT_WORD: 'important', + IMPORTANT_WORD_PATTERN: new RegExp('important$', 'i'), + SUFFIX_BANG_PATTERN: /!$/, + UNDERSCORE: '_', + VARIABLE_REFERENCE_PATTERN: /var\(--.+\)$/ +}; + +function wrapAll(properties, skipProperties) { + var wrapped = []; + var single; + var property; + var i; + + for (i = properties.length - 1; i >= 0; i--) { + property = properties[i]; + + if (property[0] != Token.PROPERTY) { + continue; + } + + if (skipProperties && skipProperties.indexOf(property[1][1]) > -1) { + continue; + } + + single = wrapSingle(property); + single.all = properties; + single.position = i; + wrapped.unshift(single); + } + + return wrapped; +} + +function someVariableReferences(property) { + var i, l; + var value; + + // skipping `property` and property name tokens + for (i = 2, l = property.length; i < l; i++) { + value = property[i]; + + if (value[0] != Token.PROPERTY_VALUE) { + continue; + } + + if (isVariableReference(value[1])) { + return true; + } + } + + return false; +} + +function isVariableReference(value) { + return Match.VARIABLE_REFERENCE_PATTERN.test(value); +} + +function isMultiplex(property) { + var value; + var i, l; + + for (i = 3, l = property.length; i < l; i++) { + value = property[i]; + + if (value[0] == Token.PROPERTY_VALUE && (value[1] == Marker.COMMA || value[1] == Marker.FORWARD_SLASH)) { + return true; + } + } + + return false; +} + +function hackFrom(property) { + var match = false; + var name = property[1][1]; + var lastValue = property[property.length - 1]; + + if (name[0] == Match.UNDERSCORE) { + match = [Hack.UNDERSCORE]; + } else if (name[0] == Match.ASTERISK) { + match = [Hack.ASTERISK]; + } else if (lastValue[1][0] == Match.BANG && !lastValue[1].match(Match.IMPORTANT_WORD_PATTERN)) { + match = [Hack.BANG]; + } else if (lastValue[1].indexOf(Match.BANG) > 0 + && !lastValue[1].match(Match.IMPORTANT_WORD_PATTERN) + && Match.BANG_SUFFIX_PATTERN.test(lastValue[1])) { + match = [Hack.BANG]; + } else if (lastValue[1].indexOf(Match.BACKSLASH) > 0 + && lastValue[1].indexOf(Match.BACKSLASH) == lastValue[1].length - Match.BACKSLASH.length - 1) { + match = [Hack.BACKSLASH, lastValue[1].substring(lastValue[1].indexOf(Match.BACKSLASH) + 1)]; + } else if (lastValue[1].indexOf(Match.BACKSLASH) === 0 && lastValue[1].length == 2) { + match = [Hack.BACKSLASH, lastValue[1].substring(1)]; + } + + return match; +} + +function isImportant(property) { + if (property.length < 3) { return false; } + + var lastValue = property[property.length - 1]; + if (Match.IMPORTANT_TOKEN_PATTERN.test(lastValue[1])) { + return true; + } if (Match.IMPORTANT_WORD_PATTERN.test(lastValue[1]) + && Match.SUFFIX_BANG_PATTERN.test(property[property.length - 2][1])) { + return true; + } + + return false; +} + +function stripImportant(property) { + var lastValue = property[property.length - 1]; + var oneButLastValue = property[property.length - 2]; + + if (Match.IMPORTANT_TOKEN_PATTERN.test(lastValue[1])) { + lastValue[1] = lastValue[1].replace(Match.IMPORTANT_TOKEN_PATTERN, ''); + } else { + lastValue[1] = lastValue[1].replace(Match.IMPORTANT_WORD_PATTERN, ''); + oneButLastValue[1] = oneButLastValue[1].replace(Match.SUFFIX_BANG_PATTERN, ''); + } + + if (lastValue[1].length === 0) { + property.pop(); + } + + if (oneButLastValue[1].length === 0) { + property.pop(); + } +} + +function stripPrefixHack(property) { + property[1][1] = property[1][1].substring(1); +} + +function stripSuffixHack(property, hackFrom) { + var lastValue = property[property.length - 1]; + lastValue[1] = lastValue[1] + .substring(0, lastValue[1].indexOf(hackFrom[0] == Hack.BACKSLASH ? Match.BACKSLASH : Match.BANG)) + .trim(); + + if (lastValue[1].length === 0) { + property.pop(); + } +} + +function wrapSingle(property) { + var importantProperty = isImportant(property); + if (importantProperty) { + stripImportant(property); + } + + var whichHack = hackFrom(property); + if (whichHack[0] == Hack.ASTERISK || whichHack[0] == Hack.UNDERSCORE) { + stripPrefixHack(property); + } else if (whichHack[0] == Hack.BACKSLASH || whichHack[0] == Hack.BANG) { + stripSuffixHack(property, whichHack); + } + + return { + block: property[2] && property[2][0] == Token.PROPERTY_BLOCK, + components: [], + dirty: false, + dynamic: someVariableReferences(property), + hack: whichHack, + important: importantProperty, + name: property[1][1], + multiplex: property.length > 3 ? isMultiplex(property) : false, + optimizable: true, + position: 0, + shorthand: false, + unused: false, + value: property.slice(2) + }; +} + +module.exports = { + all: wrapAll, + single: wrapSingle +}; diff --git a/igv_component/node_modules/clean-css/lib/options/compatibility.js b/igv_component/node_modules/clean-css/lib/options/compatibility.js new file mode 100644 index 0000000000000000000000000000000000000000..a55fc11c486c5434d4c613ac3af5d8c8343cd14c --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/options/compatibility.js @@ -0,0 +1,181 @@ +var DEFAULTS = { + '*': { + colors: { + hexAlpha: false, // 4- and 8-character hex notation + opacity: true // rgba / hsla + }, + customUnits: { rpx: false }, + properties: { + backgroundClipMerging: true, // background-clip to shorthand + backgroundOriginMerging: true, // background-origin to shorthand + backgroundSizeMerging: true, // background-size to shorthand + colors: true, // any kind of color transformations, like `#ff00ff` to `#f0f` or `#fff` into `red` + ieBangHack: false, // !ie suffix hacks on IE<8 + ieFilters: false, // whether to preserve `filter` and `-ms-filter` properties + iePrefixHack: false, // underscore / asterisk prefix hacks on IE + ieSuffixHack: false, // \9 suffix hacks on IE6-9, \0 suffix hack on IE6-11 + merging: true, // merging properties into one + shorterLengthUnits: false, // optimize pixel units into `pt`, `pc` or `in` units + spaceAfterClosingBrace: true, // 'url() no-repeat' to 'url()no-repeat' + urlQuotes: true, // whether to wrap content of `url()` into quotes or not + zeroUnits: true // 0[unit] -> 0 + }, + selectors: { + adjacentSpace: false, // div+ nav Android stock browser hack + ie7Hack: false, // *+html hack + mergeablePseudoClasses: [ + ':active', + ':after', + ':before', + ':empty', + ':checked', + ':disabled', + ':empty', + ':enabled', + ':first-child', + ':first-letter', + ':first-line', + ':first-of-type', + ':focus', + ':hover', + ':lang', + ':last-child', + ':last-of-type', + ':link', + ':not', + ':nth-child', + ':nth-last-child', + ':nth-last-of-type', + ':nth-of-type', + ':only-child', + ':only-of-type', + ':root', + ':target', + ':visited' + ], // selectors with these pseudo-classes can be merged as these are universally supported + mergeablePseudoElements: [ + '::after', + '::before', + '::first-letter', + '::first-line' + ], // selectors with these pseudo-elements can be merged as these are universally supported + mergeLimit: 8191, // number of rules that can be safely merged together + multiplePseudoMerging: true + }, + units: { + ch: true, + in: true, + pc: true, + pt: true, + rem: true, + vh: true, + vm: true, // vm is vmin on IE9+ see https://developer.mozilla.org/en-US/docs/Web/CSS/length + vmax: true, + vmin: true, + vw: true + } + } +}; + +DEFAULTS.ie11 = merge(DEFAULTS['*'], { properties: { ieSuffixHack: true } }); + +DEFAULTS.ie10 = merge(DEFAULTS['*'], { properties: { ieSuffixHack: true } }); + +DEFAULTS.ie9 = merge(DEFAULTS['*'], { + properties: { + ieFilters: true, + ieSuffixHack: true + } +}); + +DEFAULTS.ie8 = merge(DEFAULTS.ie9, { + colors: { opacity: false }, + properties: { + backgroundClipMerging: false, + backgroundOriginMerging: false, + backgroundSizeMerging: false, + iePrefixHack: true, + merging: false + }, + selectors: { + mergeablePseudoClasses: [ + ':after', + ':before', + ':first-child', + ':first-letter', + ':focus', + ':hover', + ':visited' + ], + mergeablePseudoElements: [] + }, + units: { + ch: false, + rem: false, + vh: false, + vm: false, + vmax: false, + vmin: false, + vw: false + } +}); + +DEFAULTS.ie7 = merge(DEFAULTS.ie8, { + properties: { ieBangHack: true }, + selectors: { + ie7Hack: true, + mergeablePseudoClasses: [ + ':first-child', + ':first-letter', + ':hover', + ':visited' + ] + } +}); + +function compatibilityFrom(source) { + return merge(DEFAULTS['*'], calculateSource(source)); +} + +function merge(source, target) { + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + var value = source[key]; + + if (Object.prototype.hasOwnProperty.call(target, key) && typeof value === 'object' && !Array.isArray(value)) { + target[key] = merge(value, target[key] || {}); + } else { + target[key] = key in target ? target[key] : value; + } + } + } + + return target; +} + +function calculateSource(source) { + if (typeof source == 'object') { return source; } + + if (!/[,+-]/.test(source)) { return DEFAULTS[source] || DEFAULTS['*']; } + + var parts = source.split(','); + var template = parts[0] in DEFAULTS + ? DEFAULTS[parts.shift()] + : DEFAULTS['*']; + + source = {}; + + parts.forEach(function(part) { + var isAdd = part[0] == '+'; + var key = part.substring(1).split('.'); + var group = key[0]; + var option = key[1]; + + source[group] = source[group] || {}; + source[group][option] = isAdd; + }); + + return merge(template, source); +} + +module.exports = compatibilityFrom; diff --git a/igv_component/node_modules/clean-css/lib/options/fetch.js b/igv_component/node_modules/clean-css/lib/options/fetch.js new file mode 100644 index 0000000000000000000000000000000000000000..0aaad7866bce24af8bb69962f4899c617db0f809 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/options/fetch.js @@ -0,0 +1,7 @@ +var loadRemoteResource = require('../reader/load-remote-resource'); + +function fetchFrom(callback) { + return callback || loadRemoteResource; +} + +module.exports = fetchFrom; diff --git a/igv_component/node_modules/clean-css/lib/options/format.js b/igv_component/node_modules/clean-css/lib/options/format.js new file mode 100644 index 0000000000000000000000000000000000000000..8c56c372fefa1c65d26b3fd372aa441342a7e2fc --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/options/format.js @@ -0,0 +1,241 @@ +var override = require('../utils/override'); + +function getSystemLineBreak() { + var systemLineBreak = '\n'; + try { + var os = require('os'); + systemLineBreak = os.EOL; + } catch (_) { + // no op + } + return systemLineBreak; +} + +var Breaks = { + AfterAtRule: 'afterAtRule', + AfterBlockBegins: 'afterBlockBegins', + AfterBlockEnds: 'afterBlockEnds', + AfterComment: 'afterComment', + AfterProperty: 'afterProperty', + AfterRuleBegins: 'afterRuleBegins', + AfterRuleEnds: 'afterRuleEnds', + BeforeBlockEnds: 'beforeBlockEnds', + BetweenSelectors: 'betweenSelectors' +}; + +var BreakWith = { + CarriageReturnLineFeed: '\r\n', + LineFeed: '\n', + System: getSystemLineBreak() +}; + +var IndentWith = { + Space: ' ', + Tab: '\t' +}; + +var Spaces = { + AroundSelectorRelation: 'aroundSelectorRelation', + BeforeBlockBegins: 'beforeBlockBegins', + BeforeValue: 'beforeValue' +}; + +var DEFAULTS = { + breaks: breaks(false), + breakWith: BreakWith.System, + indentBy: 0, + indentWith: IndentWith.Space, + spaces: spaces(false), + wrapAt: false, + semicolonAfterLastProperty: false +}; + +var BEAUTIFY_ALIAS = 'beautify'; +var KEEP_BREAKS_ALIAS = 'keep-breaks'; + +var OPTION_SEPARATOR = ';'; +var OPTION_NAME_VALUE_SEPARATOR = ':'; +var HASH_VALUES_OPTION_SEPARATOR = ','; +var HASH_VALUES_NAME_VALUE_SEPARATOR = '='; + +var FALSE_KEYWORD_1 = 'false'; +var FALSE_KEYWORD_2 = 'off'; +var TRUE_KEYWORD_1 = 'true'; +var TRUE_KEYWORD_2 = 'on'; + +function breaks(value) { + var breakOptions = {}; + + breakOptions[Breaks.AfterAtRule] = value; + breakOptions[Breaks.AfterBlockBegins] = value; + breakOptions[Breaks.AfterBlockEnds] = value; + breakOptions[Breaks.AfterComment] = value; + breakOptions[Breaks.AfterProperty] = value; + breakOptions[Breaks.AfterRuleBegins] = value; + breakOptions[Breaks.AfterRuleEnds] = value; + breakOptions[Breaks.BeforeBlockEnds] = value; + breakOptions[Breaks.BetweenSelectors] = value; + + return breakOptions; +} + +function spaces(value) { + var spaceOptions = {}; + + spaceOptions[Spaces.AroundSelectorRelation] = value; + spaceOptions[Spaces.BeforeBlockBegins] = value; + spaceOptions[Spaces.BeforeValue] = value; + + return spaceOptions; +} + +function formatFrom(source) { + if (source === undefined || source === false) { + return false; + } + + if (typeof source == 'object' && 'breakWith' in source) { + source = override(source, { breakWith: mapBreakWith(source.breakWith) }); + } + + if (typeof source == 'object' && 'indentBy' in source) { + source = override(source, { indentBy: parseInt(source.indentBy) }); + } + + if (typeof source == 'object' && 'indentWith' in source) { + source = override(source, { indentWith: mapIndentWith(source.indentWith) }); + } + + if (typeof source == 'object') { + return remapBreaks(override(DEFAULTS, source)); + } + + if (typeof source == 'string' && source == BEAUTIFY_ALIAS) { + return remapBreaks( + override(DEFAULTS, { + breaks: breaks(true), + indentBy: 2, + spaces: spaces(true) + }) + ); + } + + if (typeof source == 'string' && source == KEEP_BREAKS_ALIAS) { + return remapBreaks( + override(DEFAULTS, { + breaks: { + afterAtRule: true, + afterBlockBegins: true, + afterBlockEnds: true, + afterComment: true, + afterRuleEnds: true, + beforeBlockEnds: true + } + }) + ); + } + + if (typeof source == 'string') { + return remapBreaks(override(DEFAULTS, toHash(source))); + } + + return DEFAULTS; +} + +function toHash(string) { + return string + .split(OPTION_SEPARATOR) + .reduce(function(accumulator, directive) { + var parts = directive.split(OPTION_NAME_VALUE_SEPARATOR); + var name = parts[0]; + var value = parts[1]; + + if (name == 'breaks' || name == 'spaces') { + accumulator[name] = hashValuesToHash(value); + } else if (name == 'indentBy' || name == 'wrapAt') { + accumulator[name] = parseInt(value); + } else if (name == 'indentWith') { + accumulator[name] = mapIndentWith(value); + } else if (name == 'breakWith') { + accumulator[name] = mapBreakWith(value); + } + + return accumulator; + }, {}); +} + +function hashValuesToHash(string) { + return string + .split(HASH_VALUES_OPTION_SEPARATOR) + .reduce(function(accumulator, directive) { + var parts = directive.split(HASH_VALUES_NAME_VALUE_SEPARATOR); + var name = parts[0]; + var value = parts[1]; + + accumulator[name] = normalizeValue(value); + + return accumulator; + }, {}); +} + +function normalizeValue(value) { + switch (value) { + case FALSE_KEYWORD_1: + case FALSE_KEYWORD_2: + return false; + case TRUE_KEYWORD_1: + case TRUE_KEYWORD_2: + return true; + default: + return value; + } +} + +function mapBreakWith(value) { + switch (value) { + case 'windows': + case 'crlf': + case BreakWith.CarriageReturnLineFeed: + return BreakWith.CarriageReturnLineFeed; + case 'unix': + case 'lf': + case BreakWith.LineFeed: + return BreakWith.LineFeed; + default: + return BreakWith.System; + } +} + +function mapIndentWith(value) { + switch (value) { + case 'space': + return IndentWith.Space; + case 'tab': + return IndentWith.Tab; + default: + return value; + } +} + +function remapBreaks(source) { + for (var key in Breaks) { + var breakName = Breaks[key]; + var breakValue = source.breaks[breakName]; + + if (breakValue === true) { + source.breaks[breakName] = source.breakWith; + } else if (breakValue === false) { + source.breaks[breakName] = ''; + } else { + source.breaks[breakName] = source.breakWith.repeat(parseInt(breakValue)); + } + } + + return source; +} + +module.exports = { + Breaks: Breaks, + Spaces: Spaces, + formatFrom: formatFrom +}; diff --git a/igv_component/node_modules/clean-css/lib/options/inline-request.js b/igv_component/node_modules/clean-css/lib/options/inline-request.js new file mode 100644 index 0000000000000000000000000000000000000000..e611dc29d1633790e4b6312fbfb86308eea1ff9e --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/options/inline-request.js @@ -0,0 +1,22 @@ +var url = require('url'); + +var override = require('../utils/override'); + +function inlineRequestFrom(option) { + return override( + /* jshint camelcase: false */ + proxyOptionsFrom(process.env.HTTP_PROXY || process.env.http_proxy), + option || {} + ); +} + +function proxyOptionsFrom(httpProxy) { + return httpProxy + ? { + hostname: url.parse(httpProxy).hostname, + port: parseInt(url.parse(httpProxy).port) + } + : {}; +} + +module.exports = inlineRequestFrom; diff --git a/igv_component/node_modules/clean-css/lib/options/inline-timeout.js b/igv_component/node_modules/clean-css/lib/options/inline-timeout.js new file mode 100644 index 0000000000000000000000000000000000000000..c7fb454d50fabef50dcdec1eac4b16d04ee4f1ed --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/options/inline-timeout.js @@ -0,0 +1,7 @@ +var DEFAULT_TIMEOUT = 5000; + +function inlineTimeoutFrom(option) { + return option || DEFAULT_TIMEOUT; +} + +module.exports = inlineTimeoutFrom; diff --git a/igv_component/node_modules/clean-css/lib/options/inline.js b/igv_component/node_modules/clean-css/lib/options/inline.js new file mode 100644 index 0000000000000000000000000000000000000000..6b18f2dbdfd86bd3b6fbeed5e327baf92e5fc9bb --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/options/inline.js @@ -0,0 +1,15 @@ +function inlineOptionsFrom(rules) { + if (Array.isArray(rules)) { + return rules; + } + + if (rules === false) { + return ['none']; + } + + return undefined === rules + ? ['local'] + : rules.split(','); +} + +module.exports = inlineOptionsFrom; diff --git a/igv_component/node_modules/clean-css/lib/options/optimization-level.js b/igv_component/node_modules/clean-css/lib/options/optimization-level.js new file mode 100644 index 0000000000000000000000000000000000000000..0b6f0fa12df02012454d7bb85346f0775c60eca2 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/options/optimization-level.js @@ -0,0 +1,218 @@ +var roundingPrecisionFrom = require('./rounding-precision').roundingPrecisionFrom; + +var override = require('../utils/override'); + +var OptimizationLevel = { + Zero: '0', + One: '1', + Two: '2' +}; + +var DEFAULTS = {}; + +DEFAULTS[OptimizationLevel.Zero] = {}; +DEFAULTS[OptimizationLevel.One] = { + cleanupCharsets: true, + normalizeUrls: true, + optimizeBackground: true, + optimizeBorderRadius: true, + optimizeFilter: true, + optimizeFontWeight: true, + optimizeOutline: true, + removeEmpty: true, + removeNegativePaddings: true, + removeQuotes: true, + removeWhitespace: true, + replaceMultipleZeros: true, + replaceTimeUnits: true, + replaceZeroUnits: true, + roundingPrecision: roundingPrecisionFrom(undefined), + selectorsSortingMethod: 'standard', + specialComments: 'all', + tidyAtRules: true, + tidyBlockScopes: true, + tidySelectors: true, + variableValueOptimizers: [] +}; +DEFAULTS[OptimizationLevel.Two] = { + mergeAdjacentRules: true, + mergeIntoShorthands: true, + mergeMedia: true, + mergeNonAdjacentRules: true, + mergeSemantically: false, + overrideProperties: true, + removeEmpty: true, + reduceNonAdjacentRules: true, + removeDuplicateFontRules: true, + removeDuplicateMediaBlocks: true, + removeDuplicateRules: true, + removeUnusedAtRules: false, + restructureRules: false, + skipProperties: [] +}; + +var ALL_KEYWORD_1 = '*'; +var ALL_KEYWORD_2 = 'all'; +var FALSE_KEYWORD_1 = 'false'; +var FALSE_KEYWORD_2 = 'off'; +var TRUE_KEYWORD_1 = 'true'; +var TRUE_KEYWORD_2 = 'on'; + +var LIST_VALUE_SEPARATOR = ','; +var OPTION_SEPARATOR = ';'; +var OPTION_VALUE_SEPARATOR = ':'; + +function optimizationLevelFrom(source) { + var level = override(DEFAULTS, {}); + var Zero = OptimizationLevel.Zero; + var One = OptimizationLevel.One; + var Two = OptimizationLevel.Two; + + if (undefined === source) { + delete level[Two]; + return level; + } + + if (typeof source == 'string') { + source = parseInt(source); + } + + if (typeof source == 'number' && source === parseInt(Two)) { + return level; + } + + if (typeof source == 'number' && source === parseInt(One)) { + delete level[Two]; + return level; + } + + if (typeof source == 'number' && source === parseInt(Zero)) { + delete level[Two]; + delete level[One]; + return level; + } + + if (typeof source == 'object') { + source = covertValuesToHashes(source); + } + + if (One in source && 'roundingPrecision' in source[One]) { + source[One].roundingPrecision = roundingPrecisionFrom(source[One].roundingPrecision); + } + + if (Two in source && 'skipProperties' in source[Two] && typeof (source[Two].skipProperties) == 'string') { + source[Two].skipProperties = source[Two].skipProperties.split(LIST_VALUE_SEPARATOR); + } + + if (Zero in source || One in source || Two in source) { + level[Zero] = override(level[Zero], source[Zero]); + } + + if (One in source && ALL_KEYWORD_1 in source[One]) { + level[One] = override(level[One], defaults(One, normalizeValue(source[One][ALL_KEYWORD_1]))); + delete source[One][ALL_KEYWORD_1]; + } + + if (One in source && ALL_KEYWORD_2 in source[One]) { + level[One] = override(level[One], defaults(One, normalizeValue(source[One][ALL_KEYWORD_2]))); + delete source[One][ALL_KEYWORD_2]; + } + + if (One in source || Two in source) { + level[One] = override(level[One], source[One]); + } else { + delete level[One]; + } + + if (Two in source && ALL_KEYWORD_1 in source[Two]) { + level[Two] = override(level[Two], defaults(Two, normalizeValue(source[Two][ALL_KEYWORD_1]))); + delete source[Two][ALL_KEYWORD_1]; + } + + if (Two in source && ALL_KEYWORD_2 in source[Two]) { + level[Two] = override(level[Two], defaults(Two, normalizeValue(source[Two][ALL_KEYWORD_2]))); + delete source[Two][ALL_KEYWORD_2]; + } + + if (Two in source) { + level[Two] = override(level[Two], source[Two]); + } else { + delete level[Two]; + } + + return level; +} + +function defaults(level, value) { + var options = override(DEFAULTS[level], {}); + var key; + + for (key in options) { + if (typeof options[key] == 'boolean') { + options[key] = value; + } + } + + return options; +} + +function normalizeValue(value) { + switch (value) { + case FALSE_KEYWORD_1: + case FALSE_KEYWORD_2: + return false; + case TRUE_KEYWORD_1: + case TRUE_KEYWORD_2: + return true; + default: + return value; + } +} + +function covertValuesToHashes(source) { + var clonedSource = override(source, {}); + var level; + var i; + + for (i = 0; i <= 2; i++) { + level = '' + i; + + if (level in clonedSource && (clonedSource[level] === undefined || clonedSource[level] === false)) { + delete clonedSource[level]; + } + + if (level in clonedSource && clonedSource[level] === true) { + clonedSource[level] = {}; + } + + if (level in clonedSource && typeof clonedSource[level] == 'string') { + clonedSource[level] = covertToHash(clonedSource[level], level); + } + } + + return clonedSource; +} + +function covertToHash(asString, level) { + return asString + .split(OPTION_SEPARATOR) + .reduce(function(accumulator, directive) { + var parts = directive.split(OPTION_VALUE_SEPARATOR); + var name = parts[0]; + var value = parts[1]; + var normalizedValue = normalizeValue(value); + + if (ALL_KEYWORD_1 == name || ALL_KEYWORD_2 == name) { + accumulator = override(accumulator, defaults(level, normalizedValue)); + } else { + accumulator[name] = normalizedValue; + } + + return accumulator; + }, {}); +} + +module.exports = { + OptimizationLevel: OptimizationLevel, + optimizationLevelFrom: optimizationLevelFrom +}; diff --git a/igv_component/node_modules/clean-css/lib/options/plugins.js b/igv_component/node_modules/clean-css/lib/options/plugins.js new file mode 100644 index 0000000000000000000000000000000000000000..ddec9d92f0bba301e1ae56b60d07ab5274d26279 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/options/plugins.js @@ -0,0 +1,25 @@ +function pluginsFrom(plugins) { + var flatPlugins = { + level1Value: [], + level1Property: [], + level2Block: [] + }; + + plugins = plugins || []; + + flatPlugins.level1Value = plugins + .map(function(plugin) { return plugin.level1 && plugin.level1.value; }) + .filter(function(plugin) { return plugin != null; }); + + flatPlugins.level1Property = plugins + .map(function(plugin) { return plugin.level1 && plugin.level1.property; }) + .filter(function(plugin) { return plugin != null; }); + + flatPlugins.level2Block = plugins + .map(function(plugin) { return plugin.level2 && plugin.level2.block; }) + .filter(function(plugin) { return plugin != null; }); + + return flatPlugins; +} + +module.exports = pluginsFrom; diff --git a/igv_component/node_modules/clean-css/lib/options/rebase-to.js b/igv_component/node_modules/clean-css/lib/options/rebase-to.js new file mode 100644 index 0000000000000000000000000000000000000000..134b4a38268de774b93d9c27e6fa696dc1ebdf2a --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/options/rebase-to.js @@ -0,0 +1,7 @@ +var path = require('path'); + +function rebaseToFrom(option) { + return option ? path.resolve(option) : process.cwd(); +} + +module.exports = rebaseToFrom; diff --git a/igv_component/node_modules/clean-css/lib/options/rebase.js b/igv_component/node_modules/clean-css/lib/options/rebase.js new file mode 100644 index 0000000000000000000000000000000000000000..a3e60c4ebc7890024e2ef98fc9f081357fa43048 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/options/rebase.js @@ -0,0 +1,10 @@ +function rebaseFrom(rebaseOption, rebaseToOption) { + if (undefined !== rebaseToOption) { + return true; + } if (undefined === rebaseOption) { + return false; + } + return !!rebaseOption; +} + +module.exports = rebaseFrom; diff --git a/igv_component/node_modules/clean-css/lib/options/rounding-precision.js b/igv_component/node_modules/clean-css/lib/options/rounding-precision.js new file mode 100644 index 0000000000000000000000000000000000000000..3de62a84800e77b74302ae539511a30ed459754d --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/options/rounding-precision.js @@ -0,0 +1,88 @@ +var override = require('../utils/override'); + +var INTEGER_PATTERN = /^\d+$/; + +var ALL_UNITS = ['*', 'all']; +var DEFAULT_PRECISION = 'off'; // all precision changes are disabled +var DIRECTIVES_SEPARATOR = ','; // e.g. *=5,px=3 +var DIRECTIVE_VALUE_SEPARATOR = '='; // e.g. *=5 + +function roundingPrecisionFrom(source) { + return override(defaults(DEFAULT_PRECISION), buildPrecisionFrom(source)); +} + +function defaults(value) { + return { + ch: value, + cm: value, + em: value, + ex: value, + in: value, + mm: value, + pc: value, + pt: value, + px: value, + q: value, + rem: value, + vh: value, + vmax: value, + vmin: value, + vw: value, + '%': value + }; +} + +function buildPrecisionFrom(source) { + if (source === null || source === undefined) { + return {}; + } + + if (typeof source == 'boolean') { + return {}; + } + + if (typeof source == 'number' && source == -1) { + return defaults(DEFAULT_PRECISION); + } + + if (typeof source == 'number') { + return defaults(source); + } + + if (typeof source == 'string' && INTEGER_PATTERN.test(source)) { + return defaults(parseInt(source)); + } + + if (typeof source == 'string' && source == DEFAULT_PRECISION) { + return defaults(DEFAULT_PRECISION); + } + + if (typeof source == 'object') { + return source; + } + + return source + .split(DIRECTIVES_SEPARATOR) + .reduce(function(accumulator, directive) { + var directiveParts = directive.split(DIRECTIVE_VALUE_SEPARATOR); + var name = directiveParts[0]; + var value = parseInt(directiveParts[1]); + + if (Number.isNaN(value) || value == -1) { + value = DEFAULT_PRECISION; + } + + if (ALL_UNITS.indexOf(name) > -1) { + accumulator = override(accumulator, defaults(value)); + } else { + accumulator[name] = value; + } + + return accumulator; + }, {}); +} + +module.exports = { + DEFAULT: DEFAULT_PRECISION, + roundingPrecisionFrom: roundingPrecisionFrom +}; diff --git a/igv_component/node_modules/clean-css/lib/reader/apply-source-maps.js b/igv_component/node_modules/clean-css/lib/reader/apply-source-maps.js new file mode 100644 index 0000000000000000000000000000000000000000..8de33df18d970411f046d61ecd7dca0f9ffd9165 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/reader/apply-source-maps.js @@ -0,0 +1,246 @@ +var fs = require('fs'); +var path = require('path'); + +var isAllowedResource = require('./is-allowed-resource'); +var matchDataUri = require('./match-data-uri'); +var rebaseLocalMap = require('./rebase-local-map'); +var rebaseRemoteMap = require('./rebase-remote-map'); + +var Token = require('../tokenizer/token'); +var hasProtocol = require('../utils/has-protocol'); +var isDataUriResource = require('../utils/is-data-uri-resource'); +var isRemoteResource = require('../utils/is-remote-resource'); + +var MAP_MARKER_PATTERN = /^\/\*# sourceMappingURL=(\S+) \*\/$/; + +function applySourceMaps(tokens, context, callback) { + var applyContext = { + callback: callback, + fetch: context.options.fetch, + index: 0, + inline: context.options.inline, + inlineRequest: context.options.inlineRequest, + inlineTimeout: context.options.inlineTimeout, + inputSourceMapTracker: context.inputSourceMapTracker, + localOnly: context.localOnly, + processedTokens: [], + rebaseTo: context.options.rebaseTo, + sourceTokens: tokens, + warnings: context.warnings + }; + + return context.options.sourceMap && tokens.length > 0 + ? doApplySourceMaps(applyContext) + : callback(tokens); +} + +function doApplySourceMaps(applyContext) { + var singleSourceTokens = []; + var lastSource = findTokenSource(applyContext.sourceTokens[0]); + var source; + var token; + var l; + + for (l = applyContext.sourceTokens.length; applyContext.index < l; applyContext.index++) { + token = applyContext.sourceTokens[applyContext.index]; + source = findTokenSource(token); + + if (source != lastSource) { + singleSourceTokens = []; + lastSource = source; + } + + singleSourceTokens.push(token); + applyContext.processedTokens.push(token); + + if (token[0] == Token.COMMENT && MAP_MARKER_PATTERN.test(token[1])) { + return fetchAndApplySourceMap(token[1], source, singleSourceTokens, applyContext); + } + } + + return applyContext.callback(applyContext.processedTokens); +} + +function findTokenSource(token) { + var scope; + var metadata; + + if (token[0] == Token.AT_RULE || token[0] == Token.COMMENT || token[0] == Token.RAW) { + metadata = token[2][0]; + } else { + scope = token[1][0]; + metadata = scope[2][0]; + } + + return metadata[2]; +} + +function fetchAndApplySourceMap(sourceMapComment, source, singleSourceTokens, applyContext) { + return extractInputSourceMapFrom(sourceMapComment, applyContext, function(inputSourceMap) { + if (inputSourceMap) { + applyContext.inputSourceMapTracker.track(source, inputSourceMap); + applySourceMapRecursively(singleSourceTokens, applyContext.inputSourceMapTracker); + } + + applyContext.index++; + return doApplySourceMaps(applyContext); + }); +} + +function extractInputSourceMapFrom(sourceMapComment, applyContext, whenSourceMapReady) { + var uri = MAP_MARKER_PATTERN.exec(sourceMapComment)[1]; + var absoluteUri; + var sourceMap; + var rebasedMap; + + if (isDataUriResource(uri)) { + sourceMap = extractInputSourceMapFromDataUri(uri); + return whenSourceMapReady(sourceMap); + } if (isRemoteResource(uri)) { + return loadInputSourceMapFromRemoteUri(uri, applyContext, function(sourceMap) { + var parsedMap; + + if (sourceMap) { + parsedMap = JSON.parse(sourceMap); + rebasedMap = rebaseRemoteMap(parsedMap, uri); + whenSourceMapReady(rebasedMap); + } else { + whenSourceMapReady(null); + } + }); + } + // at this point `uri` is already rebased, see lib/reader/rebase.js#rebaseSourceMapComment + // it is rebased to be consistent with rebasing other URIs + // however here we need to resolve it back to read it from disk + absoluteUri = path.resolve(applyContext.rebaseTo, uri); + sourceMap = loadInputSourceMapFromLocalUri(absoluteUri, applyContext); + + if (sourceMap) { + rebasedMap = rebaseLocalMap(sourceMap, absoluteUri, applyContext.rebaseTo); + return whenSourceMapReady(rebasedMap); + } + return whenSourceMapReady(null); +} + +function extractInputSourceMapFromDataUri(uri) { + var dataUriMatch = matchDataUri(uri); + var charset = dataUriMatch[2] ? dataUriMatch[2].split(/[=;]/)[2] : 'us-ascii'; + var encoding = dataUriMatch[3] ? dataUriMatch[3].split(';')[1] : 'utf8'; + var data = encoding == 'utf8' ? global.unescape(dataUriMatch[4]) : dataUriMatch[4]; + + var buffer = Buffer.from(data, encoding); + buffer.charset = charset; + + return JSON.parse(buffer.toString()); +} + +function loadInputSourceMapFromRemoteUri(uri, applyContext, whenLoaded) { + var isAllowed = isAllowedResource(uri, true, applyContext.inline); + var isRuntimeResource = !hasProtocol(uri); + + if (applyContext.localOnly) { + applyContext.warnings.push('Cannot fetch remote resource from "' + uri + '" as no callback given.'); + return whenLoaded(null); + } if (isRuntimeResource) { + applyContext.warnings.push('Cannot fetch "' + uri + '" as no protocol given.'); + return whenLoaded(null); + } if (!isAllowed) { + applyContext.warnings.push('Cannot fetch "' + uri + '" as resource is not allowed.'); + return whenLoaded(null); + } + + applyContext.fetch(uri, applyContext.inlineRequest, applyContext.inlineTimeout, function(error, body) { + if (error) { + applyContext.warnings.push('Missing source map at "' + uri + '" - ' + error); + return whenLoaded(null); + } + + whenLoaded(body); + }); +} + +function loadInputSourceMapFromLocalUri(uri, applyContext) { + var isAllowed = isAllowedResource(uri, false, applyContext.inline); + var sourceMap; + + if (!fs.existsSync(uri) || !fs.statSync(uri).isFile()) { + applyContext.warnings.push('Ignoring local source map at "' + uri + '" as resource is missing.'); + return null; + } if (!isAllowed) { + applyContext.warnings.push('Cannot fetch "' + uri + '" as resource is not allowed.'); + return null; + } if (!fs.statSync(uri).size) { + applyContext.warnings.push('Cannot fetch "' + uri + '" as resource is empty.'); + return null; + } + + sourceMap = fs.readFileSync(uri, 'utf-8'); + return JSON.parse(sourceMap); +} + +function applySourceMapRecursively(tokens, inputSourceMapTracker) { + var token; + var i, l; + + for (i = 0, l = tokens.length; i < l; i++) { + token = tokens[i]; + + switch (token[0]) { + case Token.AT_RULE: + applySourceMapTo(token, inputSourceMapTracker); + break; + case Token.AT_RULE_BLOCK: + applySourceMapRecursively(token[1], inputSourceMapTracker); + applySourceMapRecursively(token[2], inputSourceMapTracker); + break; + case Token.AT_RULE_BLOCK_SCOPE: + applySourceMapTo(token, inputSourceMapTracker); + break; + case Token.NESTED_BLOCK: + applySourceMapRecursively(token[1], inputSourceMapTracker); + applySourceMapRecursively(token[2], inputSourceMapTracker); + break; + case Token.NESTED_BLOCK_SCOPE: + applySourceMapTo(token, inputSourceMapTracker); + break; + case Token.COMMENT: + applySourceMapTo(token, inputSourceMapTracker); + break; + case Token.PROPERTY: + applySourceMapRecursively(token, inputSourceMapTracker); + break; + case Token.PROPERTY_BLOCK: + applySourceMapRecursively(token[1], inputSourceMapTracker); + break; + case Token.PROPERTY_NAME: + applySourceMapTo(token, inputSourceMapTracker); + break; + case Token.PROPERTY_VALUE: + applySourceMapTo(token, inputSourceMapTracker); + break; + case Token.RULE: + applySourceMapRecursively(token[1], inputSourceMapTracker); + applySourceMapRecursively(token[2], inputSourceMapTracker); + break; + case Token.RULE_SCOPE: + applySourceMapTo(token, inputSourceMapTracker); + } + } + + return tokens; +} + +function applySourceMapTo(token, inputSourceMapTracker) { + var value = token[1]; + var metadata = token[2]; + var newMetadata = []; + var i, l; + + for (i = 0, l = metadata.length; i < l; i++) { + newMetadata.push(inputSourceMapTracker.originalPositionFor(metadata[i], value.length)); + } + + token[2] = newMetadata; +} + +module.exports = applySourceMaps; diff --git a/igv_component/node_modules/clean-css/lib/reader/extract-import-url-and-media.js b/igv_component/node_modules/clean-css/lib/reader/extract-import-url-and-media.js new file mode 100644 index 0000000000000000000000000000000000000000..56e04c236150a07c48797343e4f480fbb3dd31c8 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/reader/extract-import-url-and-media.js @@ -0,0 +1,35 @@ +var split = require('../utils/split'); + +var BRACE_PREFIX = /^\(/; +var BRACE_SUFFIX = /\)$/; +var IMPORT_PREFIX_PATTERN = /^@import/i; +var QUOTE_PREFIX_PATTERN = /['"]\s{0,31}/; +var QUOTE_SUFFIX_PATTERN = /\s{0,31}['"]/; +var URL_PREFIX_PATTERN = /^url\(\s{0,31}/i; +var URL_SUFFIX_PATTERN = /\s{0,31}\)/i; + +function extractImportUrlAndMedia(atRuleValue) { + var uri; + var mediaQuery; + var normalized; + var parts; + + normalized = atRuleValue + .replace(IMPORT_PREFIX_PATTERN, '') + .trim() + .replace(URL_PREFIX_PATTERN, '(') + .replace(URL_SUFFIX_PATTERN, ') ') + .replace(QUOTE_PREFIX_PATTERN, '') + .replace(QUOTE_SUFFIX_PATTERN, ''); + + parts = split(normalized, ' '); + + uri = parts[0] + .replace(BRACE_PREFIX, '') + .replace(BRACE_SUFFIX, ''); + mediaQuery = parts.slice(1).join(' '); + + return [uri, mediaQuery]; +} + +module.exports = extractImportUrlAndMedia; diff --git a/igv_component/node_modules/clean-css/lib/reader/input-source-map-tracker.js b/igv_component/node_modules/clean-css/lib/reader/input-source-map-tracker.js new file mode 100644 index 0000000000000000000000000000000000000000..417abae129399c68f7459759b8b726cfdf913acf --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/reader/input-source-map-tracker.js @@ -0,0 +1,58 @@ +var SourceMapConsumer = require('source-map').SourceMapConsumer; + +function inputSourceMapTracker() { + var maps = {}; + + return { + all: all.bind(null, maps), + isTracking: isTracking.bind(null, maps), + originalPositionFor: originalPositionFor.bind(null, maps), + track: track.bind(null, maps) + }; +} + +function all(maps) { + return maps; +} + +function isTracking(maps, source) { + return source in maps; +} + +function originalPositionFor(maps, metadata, range, selectorFallbacks) { + var line = metadata[0]; + var column = metadata[1]; + var source = metadata[2]; + var position = { + line: line, + column: column + range + }; + var originalPosition; + + while (!originalPosition && position.column > column) { + position.column--; + originalPosition = maps[source].originalPositionFor(position); + } + + if (!originalPosition || originalPosition.column < 0) { + return metadata; + } + + if (originalPosition.line === null && line > 1 && selectorFallbacks > 0) { + return originalPositionFor(maps, [line - 1, column, source], range, selectorFallbacks - 1); + } + + return originalPosition.line !== null + ? toMetadata(originalPosition) + : metadata; +} + +function toMetadata(asHash) { + return [asHash.line, asHash.column, asHash.source]; +} + +function track(maps, source, data) { + maps[source] = new SourceMapConsumer(data); +} + +module.exports = inputSourceMapTracker; diff --git a/igv_component/node_modules/clean-css/lib/reader/is-allowed-resource.js b/igv_component/node_modules/clean-css/lib/reader/is-allowed-resource.js new file mode 100644 index 0000000000000000000000000000000000000000..7873e78426150ad56be052a8a281b83f0bb3edd2 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/reader/is-allowed-resource.js @@ -0,0 +1,77 @@ +var path = require('path'); +var url = require('url'); + +var isRemoteResource = require('../utils/is-remote-resource'); +var hasProtocol = require('../utils/has-protocol'); + +var HTTP_PROTOCOL = 'http:'; + +function isAllowedResource(uri, isRemote, rules) { + var match; + var absoluteUri; + var allowed = !isRemote; + var rule; + var isNegated; + var normalizedRule; + var i; + + if (rules.length === 0) { + return false; + } + + if (isRemote && !hasProtocol(uri)) { + uri = HTTP_PROTOCOL + uri; + } + + match = isRemote + ? url.parse(uri).host + : uri; + + absoluteUri = isRemote + ? uri + : path.resolve(uri); + + for (i = 0; i < rules.length; i++) { + rule = rules[i]; + isNegated = rule[0] == '!'; + normalizedRule = rule.substring(1); + + if (isNegated && isRemote && isRemoteRule(normalizedRule)) { + allowed = allowed && !isAllowedResource(uri, true, [normalizedRule]); + } else if (isNegated && !isRemote && !isRemoteRule(normalizedRule)) { + allowed = allowed && !isAllowedResource(uri, false, [normalizedRule]); + } else if (isNegated) { + allowed = allowed && true; + } else if (rule == 'all') { + allowed = true; + } else if (isRemote && rule == 'local') { + allowed = allowed || false; + } else if (isRemote && rule == 'remote') { + allowed = true; + } else if (!isRemote && rule == 'remote') { + allowed = false; + } else if (!isRemote && rule == 'local') { + allowed = true; + } else if (rule === match) { + allowed = true; + } else if (rule === uri) { + allowed = true; + } else if (isRemote && absoluteUri.indexOf(rule) === 0) { + allowed = true; + } else if (!isRemote && absoluteUri.indexOf(path.resolve(rule)) === 0) { + allowed = true; + } else if (isRemote != isRemoteRule(normalizedRule)) { + allowed = allowed && true; + } else { + allowed = false; + } + } + + return allowed; +} + +function isRemoteRule(rule) { + return isRemoteResource(rule) || url.parse(HTTP_PROTOCOL + '//' + rule).host == rule; +} + +module.exports = isAllowedResource; diff --git a/igv_component/node_modules/clean-css/lib/reader/load-original-sources.js b/igv_component/node_modules/clean-css/lib/reader/load-original-sources.js new file mode 100644 index 0000000000000000000000000000000000000000..ac7142040205b7d2200144d141ebb205ee0a9fc6 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/reader/load-original-sources.js @@ -0,0 +1,129 @@ +var fs = require('fs'); +var path = require('path'); + +var isAllowedResource = require('./is-allowed-resource'); + +var hasProtocol = require('../utils/has-protocol'); +var isRemoteResource = require('../utils/is-remote-resource'); + +function loadOriginalSources(context, callback) { + var loadContext = { + callback: callback, + fetch: context.options.fetch, + index: 0, + inline: context.options.inline, + inlineRequest: context.options.inlineRequest, + inlineTimeout: context.options.inlineTimeout, + localOnly: context.localOnly, + rebaseTo: context.options.rebaseTo, + sourcesContent: context.sourcesContent, + uriToSource: uriToSourceMapping(context.inputSourceMapTracker.all()), + warnings: context.warnings + }; + + return context.options.sourceMap && context.options.sourceMapInlineSources + ? doLoadOriginalSources(loadContext) + : callback(); +} + +function uriToSourceMapping(allSourceMapConsumers) { + var mapping = {}; + var consumer; + var uri; + var source; + var i, l; + + for (source in allSourceMapConsumers) { + consumer = allSourceMapConsumers[source]; + + for (i = 0, l = consumer.sources.length; i < l; i++) { + uri = consumer.sources[i]; + source = consumer.sourceContentFor(uri, true); + + mapping[uri] = source; + } + } + + return mapping; +} + +function doLoadOriginalSources(loadContext) { + var uris = Object.keys(loadContext.uriToSource); + var uri; + var source; + var total; + + for (total = uris.length; loadContext.index < total; loadContext.index++) { + uri = uris[loadContext.index]; + source = loadContext.uriToSource[uri]; + + if (source) { + loadContext.sourcesContent[uri] = source; + } else { + return loadOriginalSource(uri, loadContext); + } + } + + return loadContext.callback(); +} + +function loadOriginalSource(uri, loadContext) { + var content; + + if (isRemoteResource(uri)) { + return loadOriginalSourceFromRemoteUri(uri, loadContext, function(content) { + loadContext.index++; + loadContext.sourcesContent[uri] = content; + return doLoadOriginalSources(loadContext); + }); + } + content = loadOriginalSourceFromLocalUri(uri, loadContext); + loadContext.index++; + loadContext.sourcesContent[uri] = content; + return doLoadOriginalSources(loadContext); +} + +function loadOriginalSourceFromRemoteUri(uri, loadContext, whenLoaded) { + var isAllowed = isAllowedResource(uri, true, loadContext.inline); + var isRuntimeResource = !hasProtocol(uri); + + if (loadContext.localOnly) { + loadContext.warnings.push('Cannot fetch remote resource from "' + uri + '" as no callback given.'); + return whenLoaded(null); + } if (isRuntimeResource) { + loadContext.warnings.push('Cannot fetch "' + uri + '" as no protocol given.'); + return whenLoaded(null); + } if (!isAllowed) { + loadContext.warnings.push('Cannot fetch "' + uri + '" as resource is not allowed.'); + return whenLoaded(null); + } + + loadContext.fetch(uri, loadContext.inlineRequest, loadContext.inlineTimeout, function(error, content) { + if (error) { + loadContext.warnings.push('Missing original source at "' + uri + '" - ' + error); + } + + whenLoaded(content); + }); +} + +function loadOriginalSourceFromLocalUri(relativeUri, loadContext) { + var isAllowed = isAllowedResource(relativeUri, false, loadContext.inline); + var absoluteUri = path.resolve(loadContext.rebaseTo, relativeUri); + + if (!fs.existsSync(absoluteUri) || !fs.statSync(absoluteUri).isFile()) { + loadContext.warnings.push('Ignoring local source map at "' + absoluteUri + '" as resource is missing.'); + return null; + } if (!isAllowed) { + loadContext.warnings.push('Cannot fetch "' + absoluteUri + '" as resource is not allowed.'); + return null; + } + + var result = fs.readFileSync(absoluteUri, 'utf8'); + if (result.charCodeAt(0) === 65279) { + result = result.substring(1); + } + return result; +} + +module.exports = loadOriginalSources; diff --git a/igv_component/node_modules/clean-css/lib/reader/load-remote-resource.js b/igv_component/node_modules/clean-css/lib/reader/load-remote-resource.js new file mode 100644 index 0000000000000000000000000000000000000000..8f1a7acbfc353bdff9cd2f7436fd47f245509893 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/reader/load-remote-resource.js @@ -0,0 +1,74 @@ +var http = require('http'); +var https = require('https'); +var url = require('url'); + +var isHttpResource = require('../utils/is-http-resource'); +var isHttpsResource = require('../utils/is-https-resource'); +var override = require('../utils/override'); + +var HTTP_PROTOCOL = 'http:'; + +function loadRemoteResource(uri, inlineRequest, inlineTimeout, callback) { + var proxyProtocol = inlineRequest.protocol || inlineRequest.hostname; + var errorHandled = false; + var requestOptions; + var fetch; + + requestOptions = override( + url.parse(uri), + inlineRequest || {} + ); + + if (inlineRequest.hostname !== undefined) { + // overwrite as we always expect a http proxy currently + requestOptions.protocol = inlineRequest.protocol || HTTP_PROTOCOL; + requestOptions.path = requestOptions.href; + } + + fetch = (proxyProtocol && !isHttpsResource(proxyProtocol)) || isHttpResource(uri) + ? http.get + : https.get; + + fetch(requestOptions, function(res) { + var chunks = []; + var movedUri; + + if (errorHandled) { + return; + } + + if (res.statusCode < 200 || res.statusCode > 399) { + return callback(res.statusCode, null); + } if (res.statusCode > 299) { + movedUri = url.resolve(uri, res.headers.location); + return loadRemoteResource(movedUri, inlineRequest, inlineTimeout, callback); + } + + res.on('data', function(chunk) { + chunks.push(chunk.toString()); + }); + res.on('end', function() { + var body = chunks.join(''); + callback(null, body); + }); + }) + .on('error', function(res) { + if (errorHandled) { + return; + } + + errorHandled = true; + callback(res.message, null); + }) + .on('timeout', function() { + if (errorHandled) { + return; + } + + errorHandled = true; + callback('timeout', null); + }) + .setTimeout(inlineTimeout); +} + +module.exports = loadRemoteResource; diff --git a/igv_component/node_modules/clean-css/lib/reader/match-data-uri.js b/igv_component/node_modules/clean-css/lib/reader/match-data-uri.js new file mode 100644 index 0000000000000000000000000000000000000000..0e321ea9f66a3c8f0c5e319fa1fb639f38b92001 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/reader/match-data-uri.js @@ -0,0 +1,7 @@ +var DATA_URI_PATTERN = /^data:(\S*?)?(;charset=(?:(?!;charset=)[^;])+)?(;[^,]+?)?,(.+)/; + +function matchDataUri(uri) { + return DATA_URI_PATTERN.exec(uri); +} + +module.exports = matchDataUri; diff --git a/igv_component/node_modules/clean-css/lib/reader/normalize-path.js b/igv_component/node_modules/clean-css/lib/reader/normalize-path.js new file mode 100644 index 0000000000000000000000000000000000000000..a9eca38cb8738c5948c34cbac9792400a071b44d --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/reader/normalize-path.js @@ -0,0 +1,8 @@ +var UNIX_SEPARATOR = '/'; +var WINDOWS_SEPARATOR_PATTERN = /\\/g; + +function normalizePath(path) { + return path.replace(WINDOWS_SEPARATOR_PATTERN, UNIX_SEPARATOR); +} + +module.exports = normalizePath; diff --git a/igv_component/node_modules/clean-css/lib/reader/read-sources.js b/igv_component/node_modules/clean-css/lib/reader/read-sources.js new file mode 100644 index 0000000000000000000000000000000000000000..e9940de74735ded6b578f5bffc4bbd0b80e6052b --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/reader/read-sources.js @@ -0,0 +1,344 @@ +var fs = require('fs'); +var path = require('path'); + +var applySourceMaps = require('./apply-source-maps'); +var extractImportUrlAndMedia = require('./extract-import-url-and-media'); +var isAllowedResource = require('./is-allowed-resource'); +var loadOriginalSources = require('./load-original-sources'); +var normalizePath = require('./normalize-path'); +var rebase = require('./rebase'); +var rebaseLocalMap = require('./rebase-local-map'); +var rebaseRemoteMap = require('./rebase-remote-map'); +var restoreImport = require('./restore-import'); + +var tokenize = require('../tokenizer/tokenize'); +var Token = require('../tokenizer/token'); +var Marker = require('../tokenizer/marker'); +var hasProtocol = require('../utils/has-protocol'); +var isImport = require('../utils/is-import'); +var isRemoteResource = require('../utils/is-remote-resource'); + +var UNKNOWN_URI = 'uri:unknown'; +var FILE_RESOURCE_PROTOCOL = 'file://'; + +function readSources(input, context, callback) { + return doReadSources(input, context, function(tokens) { + return applySourceMaps(tokens, context, function() { + return loadOriginalSources(context, function() { return callback(tokens); }); + }); + }); +} + +function doReadSources(input, context, callback) { + if (typeof input == 'string') { + return fromString(input, context, callback); + } if (Buffer.isBuffer(input)) { + return fromString(input.toString(), context, callback); + } if (Array.isArray(input)) { + return fromArray(input, context, callback); + } if (typeof input == 'object') { + return fromHash(input, context, callback); + } +} + +function fromString(input, context, callback) { + context.source = undefined; + context.sourcesContent[undefined] = input; + context.stats.originalSize += input.length; + + return fromStyles(input, context, { inline: context.options.inline }, callback); +} + +function fromArray(input, context, callback) { + var inputAsImports = input.reduce(function(accumulator, uriOrHash) { + if (typeof uriOrHash === 'string') { + return addStringSource(uriOrHash, accumulator); + } + return addHashSource(uriOrHash, context, accumulator); + }, []); + + return fromStyles(inputAsImports.join(''), context, { inline: ['all'] }, callback); +} + +function fromHash(input, context, callback) { + var inputAsImports = addHashSource(input, context, []); + return fromStyles(inputAsImports.join(''), context, { inline: ['all'] }, callback); +} + +function addStringSource(input, imports) { + imports.push(restoreAsImport(normalizeUri(input))); + return imports; +} + +function addHashSource(input, context, imports) { + var uri; + var normalizedUri; + var source; + + for (uri in input) { + source = input[uri]; + normalizedUri = normalizeUri(uri); + + imports.push(restoreAsImport(normalizedUri)); + + context.sourcesContent[normalizedUri] = source.styles; + + if (source.sourceMap) { + trackSourceMap(source.sourceMap, normalizedUri, context); + } + } + + return imports; +} + +function normalizeUri(uri) { + var currentPath = path.resolve(''); + var absoluteUri; + var relativeToCurrentPath; + var normalizedUri; + + if (isRemoteResource(uri)) { + return uri; + } + + absoluteUri = path.isAbsolute(uri) + ? uri + : path.resolve(uri); + relativeToCurrentPath = path.relative(currentPath, absoluteUri); + normalizedUri = normalizePath(relativeToCurrentPath); + + return normalizedUri; +} + +function trackSourceMap(sourceMap, uri, context) { + var parsedMap = typeof sourceMap == 'string' + ? JSON.parse(sourceMap) + : sourceMap; + var rebasedMap = isRemoteResource(uri) + ? rebaseRemoteMap(parsedMap, uri) + : rebaseLocalMap(parsedMap, uri || UNKNOWN_URI, context.options.rebaseTo); + + context.inputSourceMapTracker.track(uri, rebasedMap); +} + +function restoreAsImport(uri) { + return restoreImport('url(' + uri + ')', '') + Marker.SEMICOLON; +} + +function fromStyles(styles, context, parentInlinerContext, callback) { + var tokens; + var rebaseConfig = {}; + + if (!context.source) { + rebaseConfig.fromBase = path.resolve(''); + rebaseConfig.toBase = context.options.rebaseTo; + } else if (isRemoteResource(context.source)) { + rebaseConfig.fromBase = context.source; + rebaseConfig.toBase = context.source; + } else if (path.isAbsolute(context.source)) { + rebaseConfig.fromBase = path.dirname(context.source); + rebaseConfig.toBase = context.options.rebaseTo; + } else { + rebaseConfig.fromBase = path.dirname(path.resolve(context.source)); + rebaseConfig.toBase = context.options.rebaseTo; + } + + tokens = tokenize(styles, context); + tokens = rebase(tokens, context.options.rebase, context.validator, rebaseConfig); + + return allowsAnyImports(parentInlinerContext.inline) + ? inline(tokens, context, parentInlinerContext, callback) + : callback(tokens); +} + +function allowsAnyImports(inline) { + return !(inline.length == 1 && inline[0] == 'none'); +} + +function inline(tokens, externalContext, parentInlinerContext, callback) { + var inlinerContext = { + afterContent: false, + callback: callback, + errors: externalContext.errors, + externalContext: externalContext, + fetch: externalContext.options.fetch, + inlinedStylesheets: parentInlinerContext.inlinedStylesheets || externalContext.inlinedStylesheets, + inline: parentInlinerContext.inline, + inlineRequest: externalContext.options.inlineRequest, + inlineTimeout: externalContext.options.inlineTimeout, + isRemote: parentInlinerContext.isRemote || false, + localOnly: externalContext.localOnly, + outputTokens: [], + rebaseTo: externalContext.options.rebaseTo, + sourceTokens: tokens, + warnings: externalContext.warnings + }; + + return doInlineImports(inlinerContext); +} + +function doInlineImports(inlinerContext) { + var token; + var i, l; + + for (i = 0, l = inlinerContext.sourceTokens.length; i < l; i++) { + token = inlinerContext.sourceTokens[i]; + + if (token[0] == Token.AT_RULE && isImport(token[1])) { + inlinerContext.sourceTokens.splice(0, i); + return inlineStylesheet(token, inlinerContext); + } if (token[0] == Token.AT_RULE || token[0] == Token.COMMENT) { + inlinerContext.outputTokens.push(token); + } else { + inlinerContext.outputTokens.push(token); + inlinerContext.afterContent = true; + } + } + + inlinerContext.sourceTokens = []; + return inlinerContext.callback(inlinerContext.outputTokens); +} + +function inlineStylesheet(token, inlinerContext) { + var uriAndMediaQuery = extractImportUrlAndMedia(token[1]); + var uri = uriAndMediaQuery[0]; + var mediaQuery = uriAndMediaQuery[1]; + var metadata = token[2]; + + return isRemoteResource(uri) + ? inlineRemoteStylesheet(uri, mediaQuery, metadata, inlinerContext) + : inlineLocalStylesheet(uri, mediaQuery, metadata, inlinerContext); +} + +function inlineRemoteStylesheet(uri, mediaQuery, metadata, inlinerContext) { + var isAllowed = isAllowedResource(uri, true, inlinerContext.inline); + var originalUri = uri; + var isLoaded = uri in inlinerContext.externalContext.sourcesContent; + var isRuntimeResource = !hasProtocol(uri); + + if (inlinerContext.inlinedStylesheets.indexOf(uri) > -1) { + inlinerContext.warnings.push('Ignoring remote @import of "' + uri + '" as it has already been imported.'); + inlinerContext.sourceTokens = inlinerContext.sourceTokens.slice(1); + return doInlineImports(inlinerContext); + } if (inlinerContext.localOnly && inlinerContext.afterContent) { + inlinerContext.warnings.push('Ignoring remote @import of "' + uri + '" as no callback given and after other content.'); + inlinerContext.sourceTokens = inlinerContext.sourceTokens.slice(1); + return doInlineImports(inlinerContext); + } if (isRuntimeResource) { + inlinerContext.warnings.push('Skipping remote @import of "' + uri + '" as no protocol given.'); + inlinerContext.outputTokens = inlinerContext.outputTokens.concat(inlinerContext.sourceTokens.slice(0, 1)); + inlinerContext.sourceTokens = inlinerContext.sourceTokens.slice(1); + return doInlineImports(inlinerContext); + } if (inlinerContext.localOnly && !isLoaded) { + inlinerContext.warnings.push('Skipping remote @import of "' + uri + '" as no callback given.'); + inlinerContext.outputTokens = inlinerContext.outputTokens.concat(inlinerContext.sourceTokens.slice(0, 1)); + inlinerContext.sourceTokens = inlinerContext.sourceTokens.slice(1); + return doInlineImports(inlinerContext); + } if (!isAllowed && inlinerContext.afterContent) { + inlinerContext.warnings.push('Ignoring remote @import of "' + uri + '" as resource is not allowed and after other content.'); + inlinerContext.sourceTokens = inlinerContext.sourceTokens.slice(1); + return doInlineImports(inlinerContext); + } if (!isAllowed) { + inlinerContext.warnings.push('Skipping remote @import of "' + uri + '" as resource is not allowed.'); + inlinerContext.outputTokens = inlinerContext.outputTokens.concat(inlinerContext.sourceTokens.slice(0, 1)); + inlinerContext.sourceTokens = inlinerContext.sourceTokens.slice(1); + return doInlineImports(inlinerContext); + } + + inlinerContext.inlinedStylesheets.push(uri); + + function whenLoaded(error, importedStyles) { + if (error) { + inlinerContext.errors.push('Broken @import declaration of "' + uri + '" - ' + error); + + return process.nextTick(function() { + inlinerContext.outputTokens = inlinerContext.outputTokens.concat(inlinerContext.sourceTokens.slice(0, 1)); + inlinerContext.sourceTokens = inlinerContext.sourceTokens.slice(1); + doInlineImports(inlinerContext); + }); + } + + inlinerContext.inline = inlinerContext.externalContext.options.inline; + inlinerContext.isRemote = true; + + inlinerContext.externalContext.source = originalUri; + inlinerContext.externalContext.sourcesContent[uri] = importedStyles; + inlinerContext.externalContext.stats.originalSize += importedStyles.length; + + return fromStyles(importedStyles, inlinerContext.externalContext, inlinerContext, function(importedTokens) { + importedTokens = wrapInMedia(importedTokens, mediaQuery, metadata); + + inlinerContext.outputTokens = inlinerContext.outputTokens.concat(importedTokens); + inlinerContext.sourceTokens = inlinerContext.sourceTokens.slice(1); + + return doInlineImports(inlinerContext); + }); + } + + return isLoaded + ? whenLoaded(null, inlinerContext.externalContext.sourcesContent[uri]) + : inlinerContext.fetch(uri, inlinerContext.inlineRequest, inlinerContext.inlineTimeout, whenLoaded); +} + +function inlineLocalStylesheet(uri, mediaQuery, metadata, inlinerContext) { + var protocolLessUri = uri.replace(FILE_RESOURCE_PROTOCOL, ''); + var currentPath = path.resolve(''); + var absoluteUri = path.isAbsolute(protocolLessUri) + ? path.resolve(currentPath, protocolLessUri[0] == '/' ? protocolLessUri.substring(1) : protocolLessUri) + : path.resolve(inlinerContext.rebaseTo, protocolLessUri); + var relativeToCurrentPath = path.relative(currentPath, absoluteUri); + var importedStyles; + var isAllowed = isAllowedResource(protocolLessUri, false, inlinerContext.inline); + var normalizedPath = normalizePath(relativeToCurrentPath); + var isLoaded = normalizedPath in inlinerContext.externalContext.sourcesContent; + + if (inlinerContext.inlinedStylesheets.indexOf(absoluteUri) > -1) { + inlinerContext.warnings.push('Ignoring local @import of "' + protocolLessUri + '" as it has already been imported.'); + } else if (isAllowed && !isLoaded && (!fs.existsSync(absoluteUri) || !fs.statSync(absoluteUri).isFile())) { + inlinerContext.errors.push('Ignoring local @import of "' + protocolLessUri + '" as resource is missing.'); + } else if (!isAllowed && inlinerContext.afterContent) { + inlinerContext.warnings.push('Ignoring local @import of "' + protocolLessUri + '" as resource is not allowed and after other content.'); + } else if (inlinerContext.afterContent) { + inlinerContext.warnings.push('Ignoring local @import of "' + protocolLessUri + '" as after other content.'); + } else if (!isAllowed) { + inlinerContext.warnings.push('Skipping local @import of "' + protocolLessUri + '" as resource is not allowed.'); + inlinerContext.outputTokens = inlinerContext.outputTokens.concat(inlinerContext.sourceTokens.slice(0, 1)); + } else { + importedStyles = isLoaded + ? inlinerContext.externalContext.sourcesContent[normalizedPath] + : fs.readFileSync(absoluteUri, 'utf-8'); + + if (importedStyles.charCodeAt(0) === 65279) { + importedStyles = importedStyles.substring(1); + } + + inlinerContext.inlinedStylesheets.push(absoluteUri); + inlinerContext.inline = inlinerContext.externalContext.options.inline; + + inlinerContext.externalContext.source = normalizedPath; + inlinerContext.externalContext.sourcesContent[normalizedPath] = importedStyles; + inlinerContext.externalContext.stats.originalSize += importedStyles.length; + + return fromStyles(importedStyles, inlinerContext.externalContext, inlinerContext, function(importedTokens) { + importedTokens = wrapInMedia(importedTokens, mediaQuery, metadata); + + inlinerContext.outputTokens = inlinerContext.outputTokens.concat(importedTokens); + inlinerContext.sourceTokens = inlinerContext.sourceTokens.slice(1); + + return doInlineImports(inlinerContext); + }); + } + + inlinerContext.sourceTokens = inlinerContext.sourceTokens.slice(1); + + return doInlineImports(inlinerContext); +} + +function wrapInMedia(tokens, mediaQuery, metadata) { + if (mediaQuery) { + return [[Token.NESTED_BLOCK, [[Token.NESTED_BLOCK_SCOPE, '@media ' + mediaQuery, metadata]], tokens]]; + } + return tokens; +} + +module.exports = readSources; diff --git a/igv_component/node_modules/clean-css/lib/reader/rebase-local-map.js b/igv_component/node_modules/clean-css/lib/reader/rebase-local-map.js new file mode 100644 index 0000000000000000000000000000000000000000..aec8d23240c7e28c66fe99062c99fa05b0365970 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/reader/rebase-local-map.js @@ -0,0 +1,15 @@ +var path = require('path'); + +function rebaseLocalMap(sourceMap, sourceUri, rebaseTo) { + var currentPath = path.resolve(''); + var absoluteUri = path.resolve(currentPath, sourceUri); + var absoluteUriDirectory = path.dirname(absoluteUri); + + sourceMap.sources = sourceMap.sources.map(function(source) { + return path.relative(rebaseTo, path.resolve(absoluteUriDirectory, source)); + }); + + return sourceMap; +} + +module.exports = rebaseLocalMap; diff --git a/igv_component/node_modules/clean-css/lib/reader/rebase-remote-map.js b/igv_component/node_modules/clean-css/lib/reader/rebase-remote-map.js new file mode 100644 index 0000000000000000000000000000000000000000..7b6bb7ac9ad40ec97b40c758f12ef37c6867d1bc --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/reader/rebase-remote-map.js @@ -0,0 +1,14 @@ +var path = require('path'); +var url = require('url'); + +function rebaseRemoteMap(sourceMap, sourceUri) { + var sourceDirectory = path.dirname(sourceUri); + + sourceMap.sources = sourceMap.sources.map(function(source) { + return url.resolve(sourceDirectory, source); + }); + + return sourceMap; +} + +module.exports = rebaseRemoteMap; diff --git a/igv_component/node_modules/clean-css/lib/reader/rebase.js b/igv_component/node_modules/clean-css/lib/reader/rebase.js new file mode 100644 index 0000000000000000000000000000000000000000..d1e46bbe33472e578921e61264c5923c5f424588 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/reader/rebase.js @@ -0,0 +1,101 @@ +var extractImportUrlAndMedia = require('./extract-import-url-and-media'); +var restoreImport = require('./restore-import'); +var rewriteUrl = require('./rewrite-url'); + +var Token = require('../tokenizer/token'); +var isImport = require('../utils/is-import'); + +var SOURCE_MAP_COMMENT_PATTERN = /^\/\*# sourceMappingURL=(\S+) \*\/$/; + +function rebase(tokens, rebaseAll, validator, rebaseConfig) { + return rebaseAll + ? rebaseEverything(tokens, validator, rebaseConfig) + : rebaseAtRules(tokens, validator, rebaseConfig); +} + +function rebaseEverything(tokens, validator, rebaseConfig) { + var token; + var i, l; + + for (i = 0, l = tokens.length; i < l; i++) { + token = tokens[i]; + + switch (token[0]) { + case Token.AT_RULE: + rebaseAtRule(token, validator, rebaseConfig); + break; + case Token.AT_RULE_BLOCK: + rebaseProperties(token[2], validator, rebaseConfig); + break; + case Token.COMMENT: + rebaseSourceMapComment(token, rebaseConfig); + break; + case Token.NESTED_BLOCK: + rebaseEverything(token[2], validator, rebaseConfig); + break; + case Token.RULE: + rebaseProperties(token[2], validator, rebaseConfig); + break; + } + } + + return tokens; +} + +function rebaseAtRules(tokens, validator, rebaseConfig) { + var token; + var i, l; + + for (i = 0, l = tokens.length; i < l; i++) { + token = tokens[i]; + + switch (token[0]) { + case Token.AT_RULE: + rebaseAtRule(token, validator, rebaseConfig); + break; + } + } + + return tokens; +} + +function rebaseAtRule(token, validator, rebaseConfig) { + if (!isImport(token[1])) { + return; + } + + var uriAndMediaQuery = extractImportUrlAndMedia(token[1]); + var newUrl = rewriteUrl(uriAndMediaQuery[0], rebaseConfig); + var mediaQuery = uriAndMediaQuery[1]; + + token[1] = restoreImport(newUrl, mediaQuery); +} + +function rebaseSourceMapComment(token, rebaseConfig) { + var matches = SOURCE_MAP_COMMENT_PATTERN.exec(token[1]); + + if (matches && matches[1].indexOf('data:') === -1) { + token[1] = token[1].replace(matches[1], rewriteUrl(matches[1], rebaseConfig, true)); + } +} + +function rebaseProperties(properties, validator, rebaseConfig) { + var property; + var value; + var i, l; + var j, m; + + for (i = 0, l = properties.length; i < l; i++) { + property = properties[i]; + + for (j = 2 /* 0 is Token.PROPERTY, 1 is name */, m = property.length; j < m; j++) { + value = property[j][1]; + + if (validator.isUrl(value)) { + property[j][1] = rewriteUrl(value, rebaseConfig); + } + } + } +} + +module.exports = rebase; diff --git a/igv_component/node_modules/clean-css/lib/reader/restore-import.js b/igv_component/node_modules/clean-css/lib/reader/restore-import.js new file mode 100644 index 0000000000000000000000000000000000000000..5bdbd92c8a78474bd8010c34ce0fcd0651d4b5b9 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/reader/restore-import.js @@ -0,0 +1,5 @@ +function restoreImport(uri, mediaQuery) { + return ('@import ' + uri + ' ' + mediaQuery).trim(); +} + +module.exports = restoreImport; diff --git a/igv_component/node_modules/clean-css/lib/reader/rewrite-url.js b/igv_component/node_modules/clean-css/lib/reader/rewrite-url.js new file mode 100644 index 0000000000000000000000000000000000000000..1e2ea1447e9a1dfb7da2a8fdb064f797dae83bcf --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/reader/rewrite-url.js @@ -0,0 +1,112 @@ +var path = require('path'); +var url = require('url'); + +var isDataUriResource = require('../utils/is-data-uri-resource'); + +var DOUBLE_QUOTE = '"'; +var SINGLE_QUOTE = '\''; +var URL_PREFIX = 'url('; +var URL_SUFFIX = ')'; + +var PROTOCOL_LESS_PREFIX_PATTERN = /^[^\w\d]*\/\//; +var QUOTE_PREFIX_PATTERN = /^["']/; +var QUOTE_SUFFIX_PATTERN = /["']$/; +var ROUND_BRACKETS_PATTERN = /[()]/; +var URL_PREFIX_PATTERN = /^url\(/i; +var URL_SUFFIX_PATTERN = /\)$/; +var WHITESPACE_PATTERN = /\s/; + +var isWindows = process.platform == 'win32'; + +function rebase(uri, rebaseConfig) { + if (!rebaseConfig) { + return uri; + } + + if (isAbsolute(uri) && !isRemote(rebaseConfig.toBase)) { + return uri; + } + + if (isRemote(uri) || isSVGMarker(uri) || isInternal(uri) || isDataUriResource(uri)) { + return uri; + } + + if (isRemote(rebaseConfig.toBase)) { + return url.resolve(rebaseConfig.toBase, uri); + } + + return rebaseConfig.absolute + ? normalize(absolute(uri, rebaseConfig)) + : normalize(relative(uri, rebaseConfig)); +} + +function isAbsolute(uri) { + return path.isAbsolute(uri); +} + +function isSVGMarker(uri) { + return uri[0] == '#'; +} + +function isInternal(uri) { + return /^\w+:\w+/.test(uri); +} + +function isRemote(uri) { + return /^[^:]+?:\/\//.test(uri) || PROTOCOL_LESS_PREFIX_PATTERN.test(uri); +} + +function absolute(uri, rebaseConfig) { + return path + .resolve(path.join(rebaseConfig.fromBase || '', uri)) + .replace(rebaseConfig.toBase, ''); +} + +function relative(uri, rebaseConfig) { + return path.relative(rebaseConfig.toBase, path.join(rebaseConfig.fromBase || '', uri)); +} + +function normalize(uri) { + return isWindows ? uri.replace(/\\/g, '/') : uri; +} + +function quoteFor(unquotedUrl) { + if (unquotedUrl.indexOf(SINGLE_QUOTE) > -1) { + return DOUBLE_QUOTE; + } if (unquotedUrl.indexOf(DOUBLE_QUOTE) > -1) { + return SINGLE_QUOTE; + } if (hasWhitespace(unquotedUrl) || hasRoundBrackets(unquotedUrl)) { + return SINGLE_QUOTE; + } + return ''; +} + +function hasWhitespace(url) { + return WHITESPACE_PATTERN.test(url); +} + +function hasRoundBrackets(url) { + return ROUND_BRACKETS_PATTERN.test(url); +} + +function rewriteUrl(originalUrl, rebaseConfig, pathOnly) { + var strippedUrl = originalUrl + .replace(URL_PREFIX_PATTERN, '') + .replace(URL_SUFFIX_PATTERN, '') + .trim(); + + var unquotedUrl = strippedUrl + .replace(QUOTE_PREFIX_PATTERN, '') + .replace(QUOTE_SUFFIX_PATTERN, '') + .trim(); + + var quote = strippedUrl[0] == SINGLE_QUOTE || strippedUrl[0] == DOUBLE_QUOTE + ? strippedUrl[0] + : quoteFor(unquotedUrl); + + return pathOnly + ? rebase(unquotedUrl, rebaseConfig) + : URL_PREFIX + quote + rebase(unquotedUrl, rebaseConfig) + quote + URL_SUFFIX; +} + +module.exports = rewriteUrl; diff --git a/igv_component/node_modules/clean-css/lib/tokenizer/marker.js b/igv_component/node_modules/clean-css/lib/tokenizer/marker.js new file mode 100644 index 0000000000000000000000000000000000000000..270fdbc3be3fbde7ccb10e1d02f2aa42a39daaf6 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/tokenizer/marker.js @@ -0,0 +1,26 @@ +var Marker = { + ASTERISK: '*', + AT: '@', + BACK_SLASH: '\\', + CARRIAGE_RETURN: '\r', + CLOSE_CURLY_BRACKET: '}', + CLOSE_ROUND_BRACKET: ')', + CLOSE_SQUARE_BRACKET: ']', + COLON: ':', + COMMA: ',', + DOUBLE_QUOTE: '"', + EXCLAMATION: '!', + FORWARD_SLASH: '/', + INTERNAL: '-clean-css-', + NEW_LINE_NIX: '\n', + OPEN_CURLY_BRACKET: '{', + OPEN_ROUND_BRACKET: '(', + OPEN_SQUARE_BRACKET: '[', + SEMICOLON: ';', + SINGLE_QUOTE: '\'', + SPACE: ' ', + TAB: '\t', + UNDERSCORE: '_' +}; + +module.exports = Marker; diff --git a/igv_component/node_modules/clean-css/lib/tokenizer/token.js b/igv_component/node_modules/clean-css/lib/tokenizer/token.js new file mode 100644 index 0000000000000000000000000000000000000000..a1d726f0ee8c216fe6bc81e9ab2e34f94160123b --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/tokenizer/token.js @@ -0,0 +1,17 @@ +var Token = { + AT_RULE: 'at-rule', // e.g. `@import`, `@charset` + AT_RULE_BLOCK: 'at-rule-block', // e.g. `@font-face{...}` + AT_RULE_BLOCK_SCOPE: 'at-rule-block-scope', // e.g. `@font-face` + COMMENT: 'comment', // e.g. `/* comment */` + NESTED_BLOCK: 'nested-block', // e.g. `@media screen{...}`, `@keyframes animation {...}` + NESTED_BLOCK_SCOPE: 'nested-block-scope', // e.g. `@media`, `@keyframes` + PROPERTY: 'property', // e.g. `color:red` + PROPERTY_BLOCK: 'property-block', // e.g. `--var:{color:red}` + PROPERTY_NAME: 'property-name', // e.g. `color` + PROPERTY_VALUE: 'property-value', // e.g. `red` + RAW: 'raw', // e.g. anything between /* clean-css ignore:start */ and /* clean-css ignore:end */ comments + RULE: 'rule', // e.g `div > a{...}` + RULE_SCOPE: 'rule-scope' // e.g `div > a` +}; + +module.exports = Token; diff --git a/igv_component/node_modules/clean-css/lib/tokenizer/tokenize.js b/igv_component/node_modules/clean-css/lib/tokenizer/tokenize.js new file mode 100644 index 0000000000000000000000000000000000000000..09f506bcf4a2c06ac88e474a691040afe2037090 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/tokenizer/tokenize.js @@ -0,0 +1,867 @@ +var Marker = require('./marker'); +var Token = require('./token'); + +var formatPosition = require('../utils/format-position'); + +var Level = { + BLOCK: 'block', + COMMENT: 'comment', + DOUBLE_QUOTE: 'double-quote', + RULE: 'rule', + SINGLE_QUOTE: 'single-quote' +}; + +var AT_RULES = [ + '@charset', + '@import' +]; + +var BLOCK_RULES = [ + '@-moz-document', + '@document', + '@-moz-keyframes', + '@-ms-keyframes', + '@-o-keyframes', + '@-webkit-keyframes', + '@keyframes', + '@media', + '@supports', + '@container', + '@layer' +]; + +var IGNORE_END_COMMENT_PATTERN = /\/\* clean-css ignore:end \*\/$/; +var IGNORE_START_COMMENT_PATTERN = /^\/\* clean-css ignore:start \*\//; + +var PAGE_MARGIN_BOXES = [ + '@bottom-center', + '@bottom-left', + '@bottom-left-corner', + '@bottom-right', + '@bottom-right-corner', + '@left-bottom', + '@left-middle', + '@left-top', + '@right-bottom', + '@right-middle', + '@right-top', + '@top-center', + '@top-left', + '@top-left-corner', + '@top-right', + '@top-right-corner' +]; + +var EXTRA_PAGE_BOXES = [ + '@footnote', + '@footnotes', + '@left', + '@page-float-bottom', + '@page-float-top', + '@right' +]; + +var REPEAT_PATTERN = /^\[\s{0,31}\d+\s{0,31}\]$/; +var TAIL_BROKEN_VALUE_PATTERN = /([^}])\}*$/; +var RULE_WORD_SEPARATOR_PATTERN = /[\s(]/; + +function tokenize(source, externalContext) { + var internalContext = { + level: Level.BLOCK, + position: { + source: externalContext.source || undefined, + line: 1, + column: 0, + index: 0 + } + }; + + return intoTokens(source, externalContext, internalContext, false); +} + +function intoTokens(source, externalContext, internalContext, isNested) { + var allTokens = []; + var newTokens = allTokens; + var lastToken; + var ruleToken; + var ruleTokens = []; + var propertyToken; + var metadata; + var metadatas = []; + var level = internalContext.level; + var levels = []; + var buffer = []; + var buffers = []; + var isBufferEmpty = true; + var serializedBuffer; + var serializedBufferPart; + var roundBracketLevel = 0; + var isQuoted; + var isSpace; + var isNewLineNix; + var isNewLineWin; + var isCarriageReturn; + var isCommentStart; + var wasCommentStart = false; + var isCommentEnd; + var wasCommentEnd = false; + var isCommentEndMarker; + var isEscaped; + var wasEscaped = false; + var characterWithNoSpecialMeaning; + var isPreviousDash = false; + var isVariable = false; + var isRaw = false; + var seekingValue = false; + var seekingPropertyBlockClosing = false; + var position = internalContext.position; + var lastCommentStartAt; + + for (; position.index < source.length; position.index++) { + var character = source[position.index]; + + isQuoted = level == Level.SINGLE_QUOTE || level == Level.DOUBLE_QUOTE; + isSpace = character == Marker.SPACE || character == Marker.TAB; + isNewLineNix = character == Marker.NEW_LINE_NIX; + isNewLineWin = character == Marker.NEW_LINE_NIX + && source[position.index - 1] == Marker.CARRIAGE_RETURN; + isCarriageReturn = character == Marker.CARRIAGE_RETURN + && source[position.index + 1] && source[position.index + 1] != Marker.NEW_LINE_NIX; + isCommentStart = !wasCommentEnd + && level != Level.COMMENT && !isQuoted + && character == Marker.ASTERISK && source[position.index - 1] == Marker.FORWARD_SLASH; + isCommentEndMarker = !wasCommentStart + && !isQuoted && character == Marker.FORWARD_SLASH + && source[position.index - 1] == Marker.ASTERISK; + isCommentEnd = level == Level.COMMENT && isCommentEndMarker; + characterWithNoSpecialMeaning = !isSpace && !isCarriageReturn && (character >= 'A' && character <= 'Z' || character >= 'a' && character <= 'z' || character >= '0' && character <= '9' || character == '-'); + isVariable = isVariable || (level != Level.COMMENT && !seekingValue && isPreviousDash && character === '-' && buffer.length === 1); + isPreviousDash = character === '-'; + roundBracketLevel = Math.max(roundBracketLevel, 0); + + metadata = isBufferEmpty + ? [position.line, position.column, position.source] + : metadata; + + if (isEscaped) { + // previous character was a backslash + buffer.push(character); + isBufferEmpty = false; + } else if (characterWithNoSpecialMeaning) { + // it's just an alphanumeric character or a hyphen (part of any rule or property name) so let's end it quickly + buffer.push(character); + isBufferEmpty = false; + } else if ((isSpace || isNewLineNix && !isNewLineWin) && (isQuoted || level == Level.COMMENT)) { + buffer.push(character); + isBufferEmpty = false; + } else if ((isSpace || isNewLineNix && !isNewLineWin) && isBufferEmpty) { + // noop + } else if (!isCommentEnd && level == Level.COMMENT) { + buffer.push(character); + isBufferEmpty = false; + } else if (!isCommentStart && !isCommentEnd && isRaw) { + buffer.push(character); + isBufferEmpty = false; + } else if (isCommentStart + && isVariable + && (level == Level.BLOCK || level == Level.RULE) && buffer.length > 1) { + // comment start within a variable, e.g. var(/*<-- + buffer.push(character); + isBufferEmpty = false; + + levels.push(level); + level = Level.COMMENT; + } else if (isCommentStart && (level == Level.BLOCK || level == Level.RULE) && buffer.length > 1) { + // comment start within block preceded by some content, e.g. div/*<-- + metadatas.push(metadata); + buffer.push(character); + buffers.push(buffer.slice(0, -2)); + isBufferEmpty = false; + + buffer = buffer.slice(-2); + metadata = [position.line, position.column - 1, position.source]; + + levels.push(level); + level = Level.COMMENT; + } else if (isCommentStart) { + // comment start, e.g. /*<-- + levels.push(level); + level = Level.COMMENT; + buffer.push(character); + isBufferEmpty = false; + } else if (isCommentEnd && isVariable) { + // comment end within a variable, e.g. var(/*!*/<-- + buffer.push(character); + level = levels.pop(); + } else if (isCommentEnd && isIgnoreStartComment(buffer)) { + // ignore:start comment end, e.g. /* clean-css ignore:start */<-- + serializedBuffer = buffer.join('').trim() + character; + lastToken = [ + Token.COMMENT, + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext)] + ]; + newTokens.push(lastToken); + + isRaw = true; + metadata = metadatas.pop() || null; + buffer = buffers.pop() || []; + isBufferEmpty = buffer.length === 0; + } else if (isCommentEnd && isIgnoreEndComment(buffer)) { + // ignore:start comment end, e.g. /* clean-css ignore:end */<-- + serializedBuffer = buffer.join('') + character; + lastCommentStartAt = serializedBuffer.lastIndexOf(Marker.FORWARD_SLASH + Marker.ASTERISK); + + serializedBufferPart = serializedBuffer.substring(0, lastCommentStartAt); + lastToken = [ + Token.RAW, + serializedBufferPart, + [originalMetadata(metadata, serializedBufferPart, externalContext)] + ]; + newTokens.push(lastToken); + + serializedBufferPart = serializedBuffer.substring(lastCommentStartAt); + metadata = [position.line, position.column - serializedBufferPart.length + 1, position.source]; + lastToken = [ + Token.COMMENT, + serializedBufferPart, + [originalMetadata(metadata, serializedBufferPart, externalContext)] + ]; + newTokens.push(lastToken); + + isRaw = false; + level = levels.pop(); + metadata = metadatas.pop() || null; + buffer = buffers.pop() || []; + isBufferEmpty = buffer.length === 0; + } else if (isCommentEnd) { + // comment end, e.g. /* comment */<-- + serializedBuffer = buffer.join('').trim() + character; + lastToken = [ + Token.COMMENT, + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext)] + ]; + newTokens.push(lastToken); + + level = levels.pop(); + metadata = metadatas.pop() || null; + buffer = buffers.pop() || []; + isBufferEmpty = buffer.length === 0; + } else if (isCommentEndMarker && source[position.index + 1] != Marker.ASTERISK) { + externalContext.warnings.push('Unexpected \'*/\' at ' + formatPosition([position.line, position.column, position.source]) + '.'); + buffer = []; + isBufferEmpty = true; + } else if (character == Marker.SINGLE_QUOTE && !isQuoted) { + // single quotation start, e.g. a[href^='https<-- + levels.push(level); + level = Level.SINGLE_QUOTE; + buffer.push(character); + isBufferEmpty = false; + } else if (character == Marker.SINGLE_QUOTE && level == Level.SINGLE_QUOTE) { + // single quotation end, e.g. a[href^='https'<-- + level = levels.pop(); + buffer.push(character); + isBufferEmpty = false; + } else if (character == Marker.DOUBLE_QUOTE && !isQuoted) { + // double quotation start, e.g. a[href^="<-- + levels.push(level); + level = Level.DOUBLE_QUOTE; + buffer.push(character); + isBufferEmpty = false; + } else if (character == Marker.DOUBLE_QUOTE && level == Level.DOUBLE_QUOTE) { + // double quotation end, e.g. a[href^="https"<-- + level = levels.pop(); + buffer.push(character); + isBufferEmpty = false; + } else if (character != Marker.CLOSE_ROUND_BRACKET + && character != Marker.OPEN_ROUND_BRACKET + && level != Level.COMMENT && !isQuoted && roundBracketLevel > 0) { + // character inside any function, e.g. hsla(.<-- + buffer.push(character); + isBufferEmpty = false; + } else if (character == Marker.OPEN_ROUND_BRACKET + && !isQuoted && level != Level.COMMENT + && !seekingValue) { + // round open bracket, e.g. @import url(<-- + buffer.push(character); + isBufferEmpty = false; + + roundBracketLevel++; + } else if (character == Marker.CLOSE_ROUND_BRACKET + && !isQuoted + && level != Level.COMMENT + && !seekingValue) { + // round open bracket, e.g. @import url(test.css)<-- + buffer.push(character); + isBufferEmpty = false; + + roundBracketLevel--; + } else if (character == Marker.SEMICOLON && level == Level.BLOCK && buffer[0] == Marker.AT) { + // semicolon ending rule at block level, e.g. @import '...';<-- + serializedBuffer = buffer.join('').trim(); + allTokens.push([ + Token.AT_RULE, + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext)] + ]); + + buffer = []; + isBufferEmpty = true; + } else if (character == Marker.COMMA && level == Level.BLOCK && ruleToken) { + // comma separator at block level, e.g. a,div,<-- + serializedBuffer = buffer.join('').trim(); + ruleToken[1].push([ + tokenScopeFrom(ruleToken[0]), + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext, ruleToken[1].length)] + ]); + + buffer = []; + isBufferEmpty = true; + } else if (character == Marker.COMMA && level == Level.BLOCK && tokenTypeFrom(buffer) == Token.AT_RULE) { + // comma separator at block level, e.g. @import url(...) screen,<-- + // keep iterating as end semicolon will create the token + buffer.push(character); + isBufferEmpty = false; + } else if (character == Marker.COMMA && level == Level.BLOCK) { + // comma separator at block level, e.g. a,<-- + ruleToken = [tokenTypeFrom(buffer), [], []]; + serializedBuffer = buffer.join('').trim(); + ruleToken[1].push([ + tokenScopeFrom(ruleToken[0]), + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext, 0)] + ]); + + buffer = []; + isBufferEmpty = true; + } else if (character == Marker.OPEN_CURLY_BRACKET + && level == Level.BLOCK + && ruleToken + && ruleToken[0] == Token.NESTED_BLOCK) { + // open brace opening at-rule at block level, e.g. @media{<-- + serializedBuffer = buffer.join('').trim(); + ruleToken[1].push([ + Token.NESTED_BLOCK_SCOPE, + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext)] + ]); + allTokens.push(ruleToken); + + levels.push(level); + position.column++; + position.index++; + buffer = []; + isBufferEmpty = true; + + ruleToken[2] = intoTokens(source, externalContext, internalContext, true); + ruleToken = null; + } else if (character == Marker.OPEN_CURLY_BRACKET + && level == Level.BLOCK + && tokenTypeFrom(buffer) == Token.NESTED_BLOCK) { + // open brace opening at-rule at block level, e.g. @media{<-- + serializedBuffer = buffer.join('').trim(); + ruleToken = ruleToken || [Token.NESTED_BLOCK, [], []]; + ruleToken[1].push([ + Token.NESTED_BLOCK_SCOPE, + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext)] + ]); + allTokens.push(ruleToken); + + levels.push(level); + position.column++; + position.index++; + buffer = []; + isBufferEmpty = true; + isVariable = false; + + ruleToken[2] = intoTokens(source, externalContext, internalContext, true); + ruleToken = null; + } else if (character == Marker.OPEN_CURLY_BRACKET && level == Level.BLOCK) { + // open brace opening rule at block level, e.g. div{<-- + serializedBuffer = buffer.join('').trim(); + ruleToken = ruleToken || [tokenTypeFrom(buffer), [], []]; + ruleToken[1].push([ + tokenScopeFrom(ruleToken[0]), + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext, ruleToken[1].length)] + ]); + newTokens = ruleToken[2]; + allTokens.push(ruleToken); + + levels.push(level); + level = Level.RULE; + buffer = []; + isBufferEmpty = true; + } else if (character == Marker.OPEN_CURLY_BRACKET && level == Level.RULE && seekingValue) { + // open brace opening rule at rule level, e.g. div{--variable:{<-- + ruleTokens.push(ruleToken); + ruleToken = [Token.PROPERTY_BLOCK, []]; + propertyToken.push(ruleToken); + newTokens = ruleToken[1]; + + levels.push(level); + level = Level.RULE; + seekingValue = false; + } else if (character == Marker.OPEN_CURLY_BRACKET && level == Level.RULE && isPageMarginBox(buffer)) { + // open brace opening page-margin box at rule level, e.g. @page{@top-center{<-- + serializedBuffer = buffer.join('').trim(); + ruleTokens.push(ruleToken); + ruleToken = [Token.AT_RULE_BLOCK, [], []]; + ruleToken[1].push([ + Token.AT_RULE_BLOCK_SCOPE, + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext)] + ]); + newTokens.push(ruleToken); + newTokens = ruleToken[2]; + + levels.push(level); + level = Level.RULE; + buffer = []; + isBufferEmpty = true; + } else if (character == Marker.COLON && level == Level.RULE && !seekingValue) { + // colon at rule level, e.g. a{color:<-- + serializedBuffer = buffer.join('').trim(); + propertyToken = [ + Token.PROPERTY, + [ + Token.PROPERTY_NAME, + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext)] + ] + ]; + newTokens.push(propertyToken); + + seekingValue = true; + buffer = []; + isBufferEmpty = true; + } else if (character == Marker.SEMICOLON + && level == Level.RULE + && propertyToken + && ruleTokens.length > 0 + && !isBufferEmpty + && buffer[0] == Marker.AT) { + // semicolon at rule level for at-rule, e.g. a{--color:{@apply(--other-color);<-- + serializedBuffer = buffer.join('').trim(); + ruleToken[1].push([ + Token.AT_RULE, + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext)] + ]); + + buffer = []; + isBufferEmpty = true; + } else if (character == Marker.SEMICOLON && level == Level.RULE && propertyToken && !isBufferEmpty) { + // semicolon at rule level, e.g. a{color:red;<-- + serializedBuffer = buffer.join('').trim(); + propertyToken.push([ + Token.PROPERTY_VALUE, + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext)] + ]); + + propertyToken = null; + seekingValue = false; + buffer = []; + isBufferEmpty = true; + isVariable = false; + } else if (character == Marker.SEMICOLON + && level == Level.RULE + && propertyToken + && isBufferEmpty + && isVariable + && !propertyToken[2]) { + // semicolon after empty variable value at rule level, e.g. a{--color: ;<-- + propertyToken.push([Token.PROPERTY_VALUE, ' ', [originalMetadata(metadata, ' ', externalContext)]]); + isVariable = false; + propertyToken = null; + seekingValue = false; + } else if (character == Marker.SEMICOLON && level == Level.RULE && propertyToken && isBufferEmpty) { + // semicolon after bracketed value at rule level, e.g. a{color:rgb(...);<-- + propertyToken = null; + seekingValue = false; + } else if (character == Marker.SEMICOLON + && level == Level.RULE + && !isBufferEmpty + && buffer[0] == Marker.AT) { + // semicolon for at-rule at rule level, e.g. a{@apply(--variable);<-- + serializedBuffer = buffer.join(''); + newTokens.push([ + Token.AT_RULE, + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext)] + ]); + + seekingValue = false; + buffer = []; + isBufferEmpty = true; + } else if (character == Marker.SEMICOLON && level == Level.RULE && seekingPropertyBlockClosing) { + // close brace after a property block at rule level, e.g. a{--custom:{color:red;};<-- + seekingPropertyBlockClosing = false; + buffer = []; + isBufferEmpty = true; + } else if (character == Marker.SEMICOLON && level == Level.RULE && isBufferEmpty) { + // stray semicolon at rule level, e.g. a{;<-- + // noop + } else if (character == Marker.CLOSE_CURLY_BRACKET + && level == Level.RULE + && propertyToken + && seekingValue + && !isBufferEmpty && ruleTokens.length > 0) { + // close brace at rule level, e.g. a{--color:{color:red}<-- + serializedBuffer = buffer.join(''); + propertyToken.push([ + Token.PROPERTY_VALUE, + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext)] + ]); + propertyToken = null; + ruleToken = ruleTokens.pop(); + newTokens = ruleToken[2]; + + level = levels.pop(); + seekingValue = false; + buffer = []; + isBufferEmpty = true; + } else if (character == Marker.CLOSE_CURLY_BRACKET + && level == Level.RULE + && propertyToken + && !isBufferEmpty + && buffer[0] == Marker.AT + && ruleTokens.length > 0) { + // close brace at rule level for at-rule, e.g. a{--color:{@apply(--other-color)}<-- + serializedBuffer = buffer.join(''); + ruleToken[1].push([ + Token.AT_RULE, + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext)] + ]); + propertyToken = null; + ruleToken = ruleTokens.pop(); + newTokens = ruleToken[2]; + + level = levels.pop(); + seekingValue = false; + buffer = []; + isBufferEmpty = true; + } else if (character == Marker.CLOSE_CURLY_BRACKET + && level == Level.RULE + && propertyToken + && ruleTokens.length > 0) { + // close brace at rule level after space, e.g. a{--color:{color:red }<-- + propertyToken = null; + ruleToken = ruleTokens.pop(); + newTokens = ruleToken[2]; + + level = levels.pop(); + seekingValue = false; + } else if (character == Marker.CLOSE_CURLY_BRACKET + && level == Level.RULE + && propertyToken + && !isBufferEmpty) { + // close brace at rule level, e.g. a{color:red}<-- + serializedBuffer = buffer.join(''); + propertyToken.push([ + Token.PROPERTY_VALUE, + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext)] + ]); + propertyToken = null; + ruleToken = ruleTokens.pop(); + newTokens = allTokens; + + level = levels.pop(); + seekingValue = false; + buffer = []; + isBufferEmpty = true; + } else if (character == Marker.CLOSE_CURLY_BRACKET + && level == Level.RULE + && !isBufferEmpty + && buffer[0] == Marker.AT) { + // close brace after at-rule at rule level, e.g. a{@apply(--variable)}<-- + propertyToken = null; + ruleToken = null; + serializedBuffer = buffer.join('').trim(); + newTokens.push([ + Token.AT_RULE, + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext)] + ]); + newTokens = allTokens; + + level = levels.pop(); + seekingValue = false; + buffer = []; + isBufferEmpty = true; + } else if (character == Marker.CLOSE_CURLY_BRACKET + && level == Level.RULE + && levels[levels.length - 1] == Level.RULE) { + // close brace after a property block at rule level, e.g. a{--custom:{color:red;}<-- + propertyToken = null; + ruleToken = ruleTokens.pop(); + newTokens = ruleToken[2]; + + level = levels.pop(); + seekingValue = false; + seekingPropertyBlockClosing = true; + buffer = []; + isBufferEmpty = true; + } else if (character == Marker.CLOSE_CURLY_BRACKET + && level == Level.RULE + && isVariable + && propertyToken + && !propertyToken[2]) { + // close brace after an empty variable declaration inside a rule, e.g. a{--color: }<-- + propertyToken.push([Token.PROPERTY_VALUE, ' ', [originalMetadata(metadata, ' ', externalContext)]]); + isVariable = false; + propertyToken = null; + ruleToken = null; + newTokens = allTokens; + + level = levels.pop(); + seekingValue = false; + isVariable = false; + } else if (character == Marker.CLOSE_CURLY_BRACKET && level == Level.RULE) { + // close brace after a rule, e.g. a{color:red;}<-- + propertyToken = null; + ruleToken = null; + newTokens = allTokens; + + level = levels.pop(); + seekingValue = false; + isVariable = false; + } else if (character == Marker.CLOSE_CURLY_BRACKET + && level == Level.BLOCK + && !isNested + && position.index <= source.length - 1) { + // stray close brace at block level, e.g. a{color:red}color:blue}<-- + externalContext.warnings.push('Unexpected \'}\' at ' + formatPosition([position.line, position.column, position.source]) + '.'); + buffer.push(character); + isBufferEmpty = false; + } else if (character == Marker.CLOSE_CURLY_BRACKET && level == Level.BLOCK) { + // close brace at block level, e.g. @media screen {...}<-- + break; + } else if (character == Marker.OPEN_ROUND_BRACKET && level == Level.RULE && seekingValue) { + // round open bracket, e.g. a{color:hsla(<-- + buffer.push(character); + isBufferEmpty = false; + roundBracketLevel++; + } else if (character == Marker.CLOSE_ROUND_BRACKET + && level == Level.RULE + && seekingValue + && roundBracketLevel == 1) { + // round close bracket, e.g. a{color:hsla(0,0%,0%)<-- + buffer.push(character); + isBufferEmpty = false; + serializedBuffer = buffer.join('').trim(); + propertyToken.push([ + Token.PROPERTY_VALUE, + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext)] + ]); + + roundBracketLevel--; + buffer = []; + isBufferEmpty = true; + isVariable = false; + } else if (character == Marker.CLOSE_ROUND_BRACKET && level == Level.RULE && seekingValue) { + // round close bracket within other brackets, e.g. a{width:calc((10rem / 2)<-- + buffer.push(character); + isBufferEmpty = false; + isVariable = false; + roundBracketLevel--; + } else if (character == Marker.FORWARD_SLASH + && source[position.index + 1] != Marker.ASTERISK + && level == Level.RULE + && seekingValue + && !isBufferEmpty) { + // forward slash within a property, e.g. a{background:url(image.png) 0 0/<-- + serializedBuffer = buffer.join('').trim(); + propertyToken.push([ + Token.PROPERTY_VALUE, + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext)] + ]); + propertyToken.push([ + Token.PROPERTY_VALUE, + character, + [[position.line, position.column, position.source]] + ]); + + buffer = []; + isBufferEmpty = true; + } else if (character == Marker.FORWARD_SLASH + && source[position.index + 1] != Marker.ASTERISK + && level == Level.RULE + && seekingValue) { + // forward slash within a property after space, e.g. a{background:url(image.png) 0 0 /<-- + propertyToken.push([ + Token.PROPERTY_VALUE, + character, + [[position.line, position.column, position.source]] + ]); + + buffer = []; + isBufferEmpty = true; + } else if (character == Marker.COMMA && level == Level.RULE && seekingValue && !isBufferEmpty) { + // comma within a property, e.g. a{background:url(image.png),<-- + serializedBuffer = buffer.join('').trim(); + propertyToken.push([ + Token.PROPERTY_VALUE, + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext)] + ]); + propertyToken.push([ + Token.PROPERTY_VALUE, + character, + [[position.line, position.column, position.source]] + ]); + + buffer = []; + isBufferEmpty = true; + } else if (character == Marker.COMMA && level == Level.RULE && seekingValue) { + // comma within a property after space, e.g. a{background:url(image.png) ,<-- + propertyToken.push([ + Token.PROPERTY_VALUE, + character, + [[position.line, position.column, position.source]] + ]); + + buffer = []; + isBufferEmpty = true; + } else if (character == Marker.CLOSE_SQUARE_BRACKET + && propertyToken + && propertyToken.length > 1 + && !isBufferEmpty + && isRepeatToken(buffer)) { + buffer.push(character); + serializedBuffer = buffer.join('').trim(); + propertyToken[propertyToken.length - 1][1] += serializedBuffer; + + buffer = []; + isBufferEmpty = true; + } else if ((isSpace || (isNewLineNix && !isNewLineWin)) + && level == Level.RULE + && seekingValue + && propertyToken + && !isBufferEmpty) { + // space or *nix newline within property, e.g. a{margin:0 <-- + serializedBuffer = buffer.join('').trim(); + propertyToken.push([ + Token.PROPERTY_VALUE, + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext)] + ]); + + buffer = []; + isBufferEmpty = true; + } else if (isNewLineWin && level == Level.RULE && seekingValue && propertyToken && buffer.length > 1) { + // win newline within property, e.g. a{margin:0\r\n<-- + serializedBuffer = buffer.join('').trim(); + propertyToken.push([ + Token.PROPERTY_VALUE, + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext)] + ]); + + buffer = []; + isBufferEmpty = true; + } else if (isNewLineWin && level == Level.RULE && seekingValue) { + // win newline + buffer = []; + isBufferEmpty = true; + } else if (isNewLineWin && buffer.length == 1) { + // ignore windows newline which is composed of two characters + buffer.pop(); + isBufferEmpty = buffer.length === 0; + } else if (!isBufferEmpty || !isSpace && !isNewLineNix && !isNewLineWin && !isCarriageReturn) { + // any character + buffer.push(character); + isBufferEmpty = false; + } + + wasEscaped = isEscaped; + isEscaped = !wasEscaped && character == Marker.BACK_SLASH; + wasCommentStart = isCommentStart; + wasCommentEnd = isCommentEnd; + + position.line = (isNewLineWin || isNewLineNix || isCarriageReturn) ? position.line + 1 : position.line; + position.column = (isNewLineWin || isNewLineNix || isCarriageReturn) ? 0 : position.column + 1; + } + + if (seekingValue) { + externalContext.warnings.push('Missing \'}\' at ' + formatPosition([position.line, position.column, position.source]) + '.'); + } + + if (seekingValue && buffer.length > 0) { + serializedBuffer = buffer.join('').trimRight().replace(TAIL_BROKEN_VALUE_PATTERN, '$1').trimRight(); + propertyToken.push([ + Token.PROPERTY_VALUE, + serializedBuffer, + [originalMetadata(metadata, serializedBuffer, externalContext)] + ]); + + buffer = []; + } + + if (buffer.length > 0) { + externalContext.warnings.push('Invalid character(s) \'' + buffer.join('') + '\' at ' + formatPosition(metadata) + '. Ignoring.'); + } + + return allTokens; +} + +function isIgnoreStartComment(buffer) { + return IGNORE_START_COMMENT_PATTERN.test(buffer.join('') + Marker.FORWARD_SLASH); +} + +function isIgnoreEndComment(buffer) { + return IGNORE_END_COMMENT_PATTERN.test(buffer.join('') + Marker.FORWARD_SLASH); +} + +function originalMetadata(metadata, value, externalContext, selectorFallbacks) { + var source = metadata[2]; + + return externalContext.inputSourceMapTracker.isTracking(source) + ? externalContext.inputSourceMapTracker.originalPositionFor(metadata, value.length, selectorFallbacks) + : metadata; +} + +function tokenTypeFrom(buffer) { + var isAtRule = buffer[0] == Marker.AT || buffer[0] == Marker.UNDERSCORE; + var ruleWord = buffer.join('').split(RULE_WORD_SEPARATOR_PATTERN)[0]; + + if (isAtRule && BLOCK_RULES.indexOf(ruleWord) > -1) { + return Token.NESTED_BLOCK; + } if (isAtRule && AT_RULES.indexOf(ruleWord) > -1) { + return Token.AT_RULE; + } if (isAtRule) { + return Token.AT_RULE_BLOCK; + } + return Token.RULE; +} + +function tokenScopeFrom(tokenType) { + if (tokenType == Token.RULE) { + return Token.RULE_SCOPE; + } if (tokenType == Token.NESTED_BLOCK) { + return Token.NESTED_BLOCK_SCOPE; + } if (tokenType == Token.AT_RULE_BLOCK) { + return Token.AT_RULE_BLOCK_SCOPE; + } +} + +function isPageMarginBox(buffer) { + var serializedBuffer = buffer.join('').trim(); + + return PAGE_MARGIN_BOXES.indexOf(serializedBuffer) > -1 || EXTRA_PAGE_BOXES.indexOf(serializedBuffer) > -1; +} + +function isRepeatToken(buffer) { + return REPEAT_PATTERN.test(buffer.join('') + Marker.CLOSE_SQUARE_BRACKET); +} + +module.exports = tokenize; diff --git a/igv_component/node_modules/clean-css/lib/utils/clone-array.js b/igv_component/node_modules/clean-css/lib/utils/clone-array.js new file mode 100644 index 0000000000000000000000000000000000000000..a44bf38d6fcd15c355085152127c65698066d546 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/utils/clone-array.js @@ -0,0 +1,11 @@ +function cloneArray(array) { + var cloned = array.slice(0); + + for (var i = 0, l = cloned.length; i < l; i++) { + if (Array.isArray(cloned[i])) { cloned[i] = cloneArray(cloned[i]); } + } + + return cloned; +} + +module.exports = cloneArray; diff --git a/igv_component/node_modules/clean-css/lib/utils/format-position.js b/igv_component/node_modules/clean-css/lib/utils/format-position.js new file mode 100644 index 0000000000000000000000000000000000000000..876a0b14daae902d72fafa72bd50b3bbca019c73 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/utils/format-position.js @@ -0,0 +1,11 @@ +function formatPosition(metadata) { + var line = metadata[0]; + var column = metadata[1]; + var source = metadata[2]; + + return source + ? source + ':' + line + ':' + column + : line + ':' + column; +} + +module.exports = formatPosition; diff --git a/igv_component/node_modules/clean-css/lib/utils/has-protocol.js b/igv_component/node_modules/clean-css/lib/utils/has-protocol.js new file mode 100644 index 0000000000000000000000000000000000000000..fa1b61fd57ad1ebee52ebcb683d0d32a83a5f5b8 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/utils/has-protocol.js @@ -0,0 +1,7 @@ +var NO_PROTOCOL_RESOURCE_PATTERN = /^\/\//; + +function hasProtocol(uri) { + return !NO_PROTOCOL_RESOURCE_PATTERN.test(uri); +} + +module.exports = hasProtocol; diff --git a/igv_component/node_modules/clean-css/lib/utils/is-data-uri-resource.js b/igv_component/node_modules/clean-css/lib/utils/is-data-uri-resource.js new file mode 100644 index 0000000000000000000000000000000000000000..0977fbcebe3dee3f867aee23a6ff83d8634a1d06 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/utils/is-data-uri-resource.js @@ -0,0 +1,7 @@ +var DATA_URI_PATTERN = /^data:(\S{0,31}?)?(;charset=(?:(?!;charset=)[^;])+)?(;[^,]+?)?,(.+)/; + +function isDataUriResource(uri) { + return DATA_URI_PATTERN.test(uri); +} + +module.exports = isDataUriResource; diff --git a/igv_component/node_modules/clean-css/lib/utils/is-http-resource.js b/igv_component/node_modules/clean-css/lib/utils/is-http-resource.js new file mode 100644 index 0000000000000000000000000000000000000000..5179c2ea9d8b2ab2f3cf797dd0adb2f64805a21b --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/utils/is-http-resource.js @@ -0,0 +1,7 @@ +var HTTP_RESOURCE_PATTERN = /^http:\/\//; + +function isHttpResource(uri) { + return HTTP_RESOURCE_PATTERN.test(uri); +} + +module.exports = isHttpResource; diff --git a/igv_component/node_modules/clean-css/lib/utils/is-https-resource.js b/igv_component/node_modules/clean-css/lib/utils/is-https-resource.js new file mode 100644 index 0000000000000000000000000000000000000000..c6938f57da13c1f292ba944cc790019563f55ea1 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/utils/is-https-resource.js @@ -0,0 +1,7 @@ +var HTTPS_RESOURCE_PATTERN = /^https:\/\//; + +function isHttpsResource(uri) { + return HTTPS_RESOURCE_PATTERN.test(uri); +} + +module.exports = isHttpsResource; diff --git a/igv_component/node_modules/clean-css/lib/utils/is-import.js b/igv_component/node_modules/clean-css/lib/utils/is-import.js new file mode 100644 index 0000000000000000000000000000000000000000..72abc32873c78205748529dd66745c377000b588 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/utils/is-import.js @@ -0,0 +1,7 @@ +var IMPORT_PREFIX_PATTERN = /^@import/i; + +function isImport(value) { + return IMPORT_PREFIX_PATTERN.test(value); +} + +module.exports = isImport; diff --git a/igv_component/node_modules/clean-css/lib/utils/is-remote-resource.js b/igv_component/node_modules/clean-css/lib/utils/is-remote-resource.js new file mode 100644 index 0000000000000000000000000000000000000000..00e6d3bebc1397101eb8f5b36f7436bb81a3cfd5 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/utils/is-remote-resource.js @@ -0,0 +1,8 @@ +var REMOTE_RESOURCE_PATTERN = /^(\w+:\/\/|\/\/)/; +var FILE_RESOURCE_PATTERN = /^file:\/\//; + +function isRemoteResource(uri) { + return REMOTE_RESOURCE_PATTERN.test(uri) && !FILE_RESOURCE_PATTERN.test(uri); +} + +module.exports = isRemoteResource; diff --git a/igv_component/node_modules/clean-css/lib/utils/natural-compare.js b/igv_component/node_modules/clean-css/lib/utils/natural-compare.js new file mode 100644 index 0000000000000000000000000000000000000000..03b8bd614e39391ffe7a4a14204dca2d4a9b9da8 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/utils/natural-compare.js @@ -0,0 +1,31 @@ +// adapted from http://nedbatchelder.com/blog/200712.html#e20071211T054956 + +var NUMBER_PATTERN = /([0-9]+)/; + +function naturalCompare(value1, value2) { + var keys1 = ('' + value1).split(NUMBER_PATTERN).map(tryParseInt); + var keys2 = ('' + value2).split(NUMBER_PATTERN).map(tryParseInt); + var key1; + var key2; + var compareFirst = Math.min(keys1.length, keys2.length); + var i, l; + + for (i = 0, l = compareFirst; i < l; i++) { + key1 = keys1[i]; + key2 = keys2[i]; + + if (key1 != key2) { + return key1 > key2 ? 1 : -1; + } + } + + return keys1.length > keys2.length ? 1 : (keys1.length == keys2.length ? 0 : -1); +} + +function tryParseInt(value) { + return ('' + parseInt(value)) == value + ? parseInt(value) + : value; +} + +module.exports = naturalCompare; diff --git a/igv_component/node_modules/clean-css/lib/utils/override.js b/igv_component/node_modules/clean-css/lib/utils/override.js new file mode 100644 index 0000000000000000000000000000000000000000..e7f84948c2e26fbcf602d4a48fe28d26e004adbd --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/utils/override.js @@ -0,0 +1,34 @@ +function override(source1, source2) { + var target = {}; + var key1; + var key2; + var item; + + for (key1 in source1) { + item = source1[key1]; + + if (Array.isArray(item)) { + target[key1] = item.slice(0); + } else if (typeof item == 'object' && item !== null) { + target[key1] = override(item, {}); + } else { + target[key1] = item; + } + } + + for (key2 in source2) { + item = source2[key2]; + + if (key2 in target && Array.isArray(item)) { + target[key2] = item.slice(0); + } else if (key2 in target && typeof item == 'object' && item !== null) { + target[key2] = override(target[key2], item); + } else { + target[key2] = item; + } + } + + return target; +} + +module.exports = override; diff --git a/igv_component/node_modules/clean-css/lib/utils/split.js b/igv_component/node_modules/clean-css/lib/utils/split.js new file mode 100644 index 0000000000000000000000000000000000000000..b824ceb5617bdc9aa055a563b1f9c9a65a073b22 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/utils/split.js @@ -0,0 +1,62 @@ +var Marker = require('../tokenizer/marker'); + +function is(value, separator, isSeparatorRegex) { + return isSeparatorRegex + ? separator.test(value) + : value === separator; +} + +function split(value, separator) { + var openLevel = Marker.OPEN_ROUND_BRACKET; + var closeLevel = Marker.CLOSE_ROUND_BRACKET; + var level = 0; + var cursor = 0; + var lastStart = 0; + var lastValue; + var lastCharacter; + var len = value.length; + var parts = []; + var isSeparatorRegex = typeof (separator) == 'object' && 'exec' in separator; + + if (!isSeparatorRegex && value.indexOf(separator) == -1) { + return [value]; + } + + if (value.indexOf(openLevel) == -1) { + return value.split(separator); + } + + while (cursor < len) { + if (value[cursor] == openLevel) { + level++; + } else if (value[cursor] == closeLevel) { + level--; + } + + if (level === 0 && cursor > 0 && cursor + 1 < len && is(value[cursor], separator, isSeparatorRegex)) { + parts.push(value.substring(lastStart, cursor)); + + if (isSeparatorRegex && separator.exec(value[cursor]).length > 1) { + parts.push(value[cursor]); + } + + lastStart = cursor + 1; + } + + cursor++; + } + + if (lastStart < cursor + 1) { + lastValue = value.substring(lastStart); + lastCharacter = lastValue[lastValue.length - 1]; + if (is(lastCharacter, separator, isSeparatorRegex)) { + lastValue = lastValue.substring(0, lastValue.length - 1); + } + + parts.push(lastValue); + } + + return parts; +} + +module.exports = split; diff --git a/igv_component/node_modules/clean-css/lib/writer/helpers.js b/igv_component/node_modules/clean-css/lib/writer/helpers.js new file mode 100644 index 0000000000000000000000000000000000000000..79ea2e8be7b8a60553a5b9c9f5d3852eeb6e27c7 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/writer/helpers.js @@ -0,0 +1,256 @@ +var emptyCharacter = ''; + +var Breaks = require('../options/format').Breaks; +var Spaces = require('../options/format').Spaces; + +var Marker = require('../tokenizer/marker'); +var Token = require('../tokenizer/token'); + +function supportsAfterClosingBrace(token) { + return token[1][1] == 'background' || token[1][1] == 'transform' || token[1][1] == 'src'; +} + +function afterClosingBrace(token, valueIndex) { + return token[valueIndex][1][token[valueIndex][1].length - 1] == Marker.CLOSE_ROUND_BRACKET; +} + +function afterComma(token, valueIndex) { + return token[valueIndex][1] == Marker.COMMA; +} + +function afterSlash(token, valueIndex) { + return token[valueIndex][1] == Marker.FORWARD_SLASH; +} + +function beforeComma(token, valueIndex) { + return token[valueIndex + 1] && token[valueIndex + 1][1] == Marker.COMMA; +} + +function beforeSlash(token, valueIndex) { + return token[valueIndex + 1] && token[valueIndex + 1][1] == Marker.FORWARD_SLASH; +} + +function inFilter(token) { + return token[1][1] == 'filter' || token[1][1] == '-ms-filter'; +} + +function disallowsSpace(context, token, valueIndex) { + return !context.spaceAfterClosingBrace + && supportsAfterClosingBrace(token) + && afterClosingBrace(token, valueIndex) + || beforeSlash(token, valueIndex) + || afterSlash(token, valueIndex) + || beforeComma(token, valueIndex) + || afterComma(token, valueIndex); +} + +function rules(context, tokens) { + var store = context.store; + + for (var i = 0, l = tokens.length; i < l; i++) { + store(context, tokens[i]); + + if (i < l - 1) { + store(context, comma(context)); + } + } +} + +function body(context, tokens) { + var lastPropertyAt = lastPropertyIndex(tokens); + + for (var i = 0, l = tokens.length; i < l; i++) { + property(context, tokens, i, lastPropertyAt); + } +} + +function lastPropertyIndex(tokens) { + var index = tokens.length - 1; + + for (; index >= 0; index--) { + if (tokens[index][0] != Token.COMMENT) { + break; + } + } + + return index; +} + +function property(context, tokens, position, lastPropertyAt) { + var store = context.store; + var token = tokens[position]; + + var propertyValue = token[2]; + var isPropertyBlock = propertyValue && propertyValue[0] === Token.PROPERTY_BLOCK; + + var needsSemicolon; + if (context.format) { + if (context.format.semicolonAfterLastProperty || isPropertyBlock) { + needsSemicolon = true; + } else if (position < lastPropertyAt) { + needsSemicolon = true; + } else { + needsSemicolon = false; + } + } else { + needsSemicolon = position < lastPropertyAt || isPropertyBlock; + } + + var isLast = position === lastPropertyAt; + + switch (token[0]) { + case Token.AT_RULE: + store(context, token); + store(context, semicolon(context, Breaks.AfterProperty, false)); + break; + case Token.AT_RULE_BLOCK: + rules(context, token[1]); + store(context, openBrace(context, Breaks.AfterRuleBegins, true)); + body(context, token[2]); + store(context, closeBrace(context, Breaks.AfterRuleEnds, false, isLast)); + break; + case Token.COMMENT: + store(context, token); + store(context, breakFor(context, Breaks.AfterComment) + context.indentWith); + break; + case Token.PROPERTY: + store(context, token[1]); + store(context, colon(context)); + if (propertyValue) { + value(context, token); + } + store( + context, + needsSemicolon ? semicolon(context, Breaks.AfterProperty, isLast) : emptyCharacter + ); + break; + case Token.RAW: + store(context, token); + } +} + +function value(context, token) { + var store = context.store; + var j, m; + + if (token[2][0] == Token.PROPERTY_BLOCK) { + store(context, openBrace(context, Breaks.AfterBlockBegins, false)); + body(context, token[2][1]); + store(context, closeBrace(context, Breaks.AfterBlockEnds, false, true)); + } else { + for (j = 2, m = token.length; j < m; j++) { + store(context, token[j]); + + if (j < m - 1 && (inFilter(token) || !disallowsSpace(context, token, j))) { + store(context, Marker.SPACE); + } + } + } +} + +function breakFor(context, where) { + return context.format ? context.format.breaks[where] : emptyCharacter; +} + +function allowsSpace(context, where) { + return context.format && context.format.spaces[where]; +} + +function openBrace(context, where, needsPrefixSpace) { + if (context.format) { + context.indentBy += context.format.indentBy; + context.indentWith = context.format.indentWith.repeat(context.indentBy); + return ( + needsPrefixSpace + && allowsSpace(context, Spaces.BeforeBlockBegins) ? Marker.SPACE : emptyCharacter + ) + Marker.OPEN_CURLY_BRACKET + + breakFor(context, where) + + context.indentWith; + } + return Marker.OPEN_CURLY_BRACKET; +} + +function closeBrace(context, where, beforeBlockEnd, isLast) { + if (context.format) { + context.indentBy -= context.format.indentBy; + context.indentWith = context.format.indentWith.repeat(context.indentBy); + return ( + beforeBlockEnd + ? breakFor(context, Breaks.BeforeBlockEnds) + : breakFor(context, Breaks.AfterProperty) + ) + context.indentWith + + Marker.CLOSE_CURLY_BRACKET + + (isLast ? emptyCharacter : breakFor(context, where) + context.indentWith); + } + return Marker.CLOSE_CURLY_BRACKET; +} + +function colon(context) { + return context.format + ? Marker.COLON + (allowsSpace(context, Spaces.BeforeValue) ? Marker.SPACE : emptyCharacter) + : Marker.COLON; +} + +function semicolon(context, where, isLast) { + return context.format + ? Marker.SEMICOLON + (isLast ? emptyCharacter : (breakFor(context, where) + context.indentWith)) + : Marker.SEMICOLON; +} + +function comma(context) { + return context.format + ? Marker.COMMA + breakFor(context, Breaks.BetweenSelectors) + context.indentWith + : Marker.COMMA; +} + +function all(context, tokens) { + var store = context.store; + var token; + var isLast; + var i, l; + + for (i = 0, l = tokens.length; i < l; i++) { + token = tokens[i]; + isLast = i == l - 1; + + switch (token[0]) { + case Token.AT_RULE: + store(context, token); + store(context, semicolon(context, Breaks.AfterAtRule, isLast)); + break; + case Token.AT_RULE_BLOCK: + rules(context, token[1]); + store(context, openBrace(context, Breaks.AfterRuleBegins, true)); + body(context, token[2]); + store(context, closeBrace(context, Breaks.AfterRuleEnds, false, isLast)); + break; + case Token.NESTED_BLOCK: + rules(context, token[1]); + store(context, openBrace(context, Breaks.AfterBlockBegins, true)); + all(context, token[2]); + store(context, closeBrace(context, Breaks.AfterBlockEnds, true, isLast)); + break; + case Token.COMMENT: + store(context, token); + store(context, breakFor(context, Breaks.AfterComment) + context.indentWith); + break; + case Token.RAW: + store(context, token); + break; + case Token.RULE: + rules(context, token[1]); + store(context, openBrace(context, Breaks.AfterRuleBegins, true)); + body(context, token[2]); + store(context, closeBrace(context, Breaks.AfterRuleEnds, false, isLast)); + break; + } + } +} + +module.exports = { + all: all, + body: body, + property: property, + rules: rules, + value: value +}; diff --git a/igv_component/node_modules/clean-css/lib/writer/one-time.js b/igv_component/node_modules/clean-css/lib/writer/one-time.js new file mode 100644 index 0000000000000000000000000000000000000000..33fccead642d6604d16d136278e3b62ff0529b74 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/writer/one-time.js @@ -0,0 +1,52 @@ +var helpers = require('./helpers'); + +function store(serializeContext, token) { + serializeContext.output.push(typeof token == 'string' ? token : token[1]); +} + +function context() { + var newContext = { + output: [], + store: store + }; + + return newContext; +} + +function all(tokens) { + var oneTimeContext = context(); + helpers.all(oneTimeContext, tokens); + return oneTimeContext.output.join(''); +} + +function body(tokens) { + var oneTimeContext = context(); + helpers.body(oneTimeContext, tokens); + return oneTimeContext.output.join(''); +} + +function property(tokens, position) { + var oneTimeContext = context(); + helpers.property(oneTimeContext, tokens, position, true); + return oneTimeContext.output.join(''); +} + +function rules(tokens) { + var oneTimeContext = context(); + helpers.rules(oneTimeContext, tokens); + return oneTimeContext.output.join(''); +} + +function value(tokens) { + var oneTimeContext = context(); + helpers.value(oneTimeContext, tokens); + return oneTimeContext.output.join(''); +} + +module.exports = { + all: all, + body: body, + property: property, + rules: rules, + value: value +}; diff --git a/igv_component/node_modules/clean-css/lib/writer/simple.js b/igv_component/node_modules/clean-css/lib/writer/simple.js new file mode 100644 index 0000000000000000000000000000000000000000..3b4ecc9aa7efb98ed95597fbccff3341af145150 --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/writer/simple.js @@ -0,0 +1,48 @@ +var all = require('./helpers').all; + +function store(serializeContext, token) { + var value = typeof token == 'string' + ? token + : token[1]; + var wrap = serializeContext.wrap; + + wrap(serializeContext, value); + track(serializeContext, value); + serializeContext.output.push(value); +} + +function wrap(serializeContext, value) { + if (serializeContext.column + value.length > serializeContext.format.wrapAt) { + track(serializeContext, serializeContext.format.breakWith); + serializeContext.output.push(serializeContext.format.breakWith); + } +} + +function track(serializeContext, value) { + var parts = value.split('\n'); + + serializeContext.line += parts.length - 1; + serializeContext.column = parts.length > 1 ? 0 : (serializeContext.column + parts.pop().length); +} + +function serializeStyles(tokens, context) { + var serializeContext = { + column: 0, + format: context.options.format, + indentBy: 0, + indentWith: '', + line: 1, + output: [], + spaceAfterClosingBrace: context.options.compatibility.properties.spaceAfterClosingBrace, + store: store, + wrap: context.options.format.wrapAt + ? wrap + : function() { /* noop */ } + }; + + all(serializeContext, tokens); + + return { styles: serializeContext.output.join('') }; +} + +module.exports = serializeStyles; diff --git a/igv_component/node_modules/clean-css/lib/writer/source-maps.js b/igv_component/node_modules/clean-css/lib/writer/source-maps.js new file mode 100644 index 0000000000000000000000000000000000000000..6e391ef718662f25fd9b682f803fc419410e83ab --- /dev/null +++ b/igv_component/node_modules/clean-css/lib/writer/source-maps.js @@ -0,0 +1,104 @@ +var SourceMapGenerator = require('source-map').SourceMapGenerator; +var all = require('./helpers').all; + +var isRemoteResource = require('../utils/is-remote-resource'); + +var isWindows = process.platform == 'win32'; + +var NIX_SEPARATOR_PATTERN = /\//g; +var UNKNOWN_SOURCE = '$stdin'; +var WINDOWS_SEPARATOR = '\\'; + +function store(serializeContext, element) { + var fromString = typeof element == 'string'; + var value = fromString ? element : element[1]; + var mappings = fromString ? null : element[2]; + var wrap = serializeContext.wrap; + + wrap(serializeContext, value); + track(serializeContext, value, mappings); + serializeContext.output.push(value); +} + +function wrap(serializeContext, value) { + if (serializeContext.column + value.length > serializeContext.format.wrapAt) { + track(serializeContext, serializeContext.format.breakWith, false); + serializeContext.output.push(serializeContext.format.breakWith); + } +} + +function track(serializeContext, value, mappings) { + var parts = value.split('\n'); + + if (mappings) { + trackAllMappings(serializeContext, mappings); + } + + serializeContext.line += parts.length - 1; + serializeContext.column = parts.length > 1 ? 0 : (serializeContext.column + parts.pop().length); +} + +function trackAllMappings(serializeContext, mappings) { + for (var i = 0, l = mappings.length; i < l; i++) { + trackMapping(serializeContext, mappings[i]); + } +} + +function trackMapping(serializeContext, mapping) { + var line = mapping[0]; + var column = mapping[1]; + var originalSource = mapping[2]; + var source = originalSource; + var storedSource = source || UNKNOWN_SOURCE; + + if (isWindows && source && !isRemoteResource(source)) { + storedSource = source.replace(NIX_SEPARATOR_PATTERN, WINDOWS_SEPARATOR); + } + + serializeContext.outputMap.addMapping({ + generated: { + line: serializeContext.line, + column: serializeContext.column + }, + source: storedSource, + original: { + line: line, + column: column + } + }); + + if (serializeContext.inlineSources && (originalSource in serializeContext.sourcesContent)) { + serializeContext.outputMap.setSourceContent( + storedSource, + serializeContext.sourcesContent[originalSource] + ); + } +} + +function serializeStylesAndSourceMap(tokens, context) { + var serializeContext = { + column: 0, + format: context.options.format, + indentBy: 0, + indentWith: '', + inlineSources: context.options.sourceMapInlineSources, + line: 1, + output: [], + outputMap: new SourceMapGenerator(), + sourcesContent: context.sourcesContent, + spaceAfterClosingBrace: context.options.compatibility.properties.spaceAfterClosingBrace, + store: store, + wrap: context.options.format.wrapAt + ? wrap + : function() { /* noop */ } + }; + + all(serializeContext, tokens); + + return { + sourceMap: serializeContext.outputMap, + styles: serializeContext.output.join('') + }; +} + +module.exports = serializeStylesAndSourceMap; diff --git a/igv_component/node_modules/clean-css/package.json b/igv_component/node_modules/clean-css/package.json new file mode 100644 index 0000000000000000000000000000000000000000..c2ee7b62ab7547f05f9199b72e62399347b71c19 --- /dev/null +++ b/igv_component/node_modules/clean-css/package.json @@ -0,0 +1,48 @@ +{ + "name": "clean-css", + "version": "5.3.3", + "author": "Jakub Pawlowicz ", + "description": "A well-tested CSS minifier", + "license": "MIT", + "keywords": [ + "css", + "minifier" + ], + "homepage": "https://github.com/clean-css/clean-css", + "repository": { + "type": "git", + "url": "https://github.com/clean-css/clean-css.git" + }, + "bugs": { + "url": "https://github.com/clean-css/clean-css/issues" + }, + "main": "index.js", + "files": [ + "lib", + "History.md", + "index.js", + "LICENSE" + ], + "scripts": { + "browserify": "browserify --standalone CleanCSS index.js | uglifyjs --compress --mangle -o cleancss-browser.js", + "bench": "node ./test/bench.js", + "lint": "eslint ./lib/ --ext .js", + "test": "vows" + }, + "dependencies": { + "source-map": "~0.6.0" + }, + "devDependencies": { + "browserify": "^17.0.0", + "eslint": "^8.8.0", + "eslint-config-airbnb-base": "^15.0.0", + "http-proxy": "1.x", + "nock": "^13.0.0", + "server-destroy": "1.x", + "uglify-js": ">=2.6.1", + "vows": "0.8.x" + }, + "engines": { + "node": ">= 10.0" + } +} diff --git a/igv_component/node_modules/css-select/LICENSE b/igv_component/node_modules/css-select/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..c464f863ea2b18a15ca3883bc5d98065ed5d039a --- /dev/null +++ b/igv_component/node_modules/css-select/LICENSE @@ -0,0 +1,11 @@ +Copyright (c) Felix Böhm +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/igv_component/node_modules/css-select/README.md b/igv_component/node_modules/css-select/README.md new file mode 100644 index 0000000000000000000000000000000000000000..287441a518d75b5ffe8e23888d8c4b79e1885ff5 --- /dev/null +++ b/igv_component/node_modules/css-select/README.md @@ -0,0 +1,255 @@ +# css-select [![NPM version](http://img.shields.io/npm/v/css-select.svg)](https://npmjs.org/package/css-select) [![Build Status](https://travis-ci.com/fb55/css-select.svg?branch=master)](http://travis-ci.com/fb55/css-select) [![Downloads](https://img.shields.io/npm/dm/css-select.svg)](https://npmjs.org/package/css-select) [![Coverage](https://coveralls.io/repos/fb55/css-select/badge.svg?branch=master)](https://coveralls.io/r/fb55/css-select) + +A CSS selector compiler and engine + +## What? + +As a **compiler**, css-select turns CSS selectors into functions that tests if +elements match them. + +As an **engine**, css-select looks through a DOM tree, searching for elements. +Elements are tested "from the top", similar to how browsers execute CSS +selectors. + +In its default configuration, css-select queries the DOM structure of the +[`domhandler`](https://github.com/fb55/domhandler) module (also known as +htmlparser2 DOM). To query alternative DOM structures, see [`Options`](#options) +below. + +**Features:** + +- 🔬 Full implementation of CSS3 selectors, as well as most CSS4 selectors +- 🧪 Partial implementation of jQuery/Sizzle extensions (see + [cheerio-select](https://github.com/cheeriojs/cheerio-select) for the + remaining selectors) +- 🧑‍🔬 High test coverage, including the full test suites from Sizzle, Qwery and + NWMatcher. +- 🥼 Reliably great performance + +## Why? + +Most CSS engines written in JavaScript execute selectors left-to-right. That +means thet execute every component of the selector in order, from left to right +_(duh)_. As an example: For the selector `a b`, these engines will first query +for `a` elements, then search these for `b` elements. (That's the approach of +eg. [`Sizzle`](https://github.com/jquery/sizzle), +[`nwmatcher`](https://github.com/dperini/nwmatcher/) and +[`qwery`](https://github.com/ded/qwery).) + +While this works, it has some downsides: Children of `a`s will be checked +multiple times; first, to check if they are also `a`s, then, for every superior +`a` once, if they are `b`s. Using +[Big O notation](http://en.wikipedia.org/wiki/Big_O_notation), that would be +`O(n^(k+1))`, where `k` is the number of descendant selectors (that's the space +in the example above). + +The far more efficient approach is to first look for `b` elements, then check if +they have superior `a` elements: Using big O notation again, that would be +`O(n)`. That's called right-to-left execution. + +And that's what css-select does – and why it's quite performant. + +## How does it work? + +By building a stack of functions. + +_Wait, what?_ + +Okay, so let's suppose we want to compile the selector `a b`, for right-to-left +execution. We start by _parsing_ the selector. This turns the selector into an +array of the building blocks. That's what the +[`css-what`](https://github.com/fb55/css-what) module is for, if you want to +have a look. + +Anyway, after parsing, we end up with an array like this one: + +```js +[ + { type: "tag", name: "a" }, + { type: "descendant" }, + { type: "tag", name: "b" }, +]; +``` + +(Actually, this array is wrapped in another array, but that's another story, +involving commas in selectors.) + +Now that we know the meaning of every part of the selector, we can compile it. +That is where things become interesting. + +The basic idea is to turn every part of the selector into a function, which +takes an element as its only argument. The function checks whether a passed +element matches its part of the selector: If it does, the element is passed to +the next function representing the next part of the selector. That function does +the same. If an element is accepted by all parts of the selector, it _matches_ +the selector and double rainbow ALL THE WAY. + +As said before, we want to do right-to-left execution with all the big O +improvements. That means elements are passed from the rightmost part of the +selector (`b` in our example) to the leftmost (~~which would be `c`~~ of course +`a`). + +For traversals, such as the _descendant_ operating the space between `a` and +`b`, we walk up the DOM tree, starting from the element passed as argument. + +_//TODO: More in-depth description. Implementation details. Build a spaceship._ + +## API + +```js +const CSSselect = require("css-select"); +``` + +**Note:** css-select throws errors when invalid selectors are passed to it.This +is done to aid with writing css selectors, but can be unexpected when processing +arbitrary strings. + +#### `CSSselect.selectAll(query, elems, options)` + +Queries `elems`, returns an array containing all matches. + +- `query` can be either a CSS selector or a function. +- `elems` can be either an array of elements, or a single element. If it is an + element, its children will be queried. +- `options` is described below. + +Aliases: `default` export, `CSSselect.iterate(query, elems)`. + +#### `CSSselect.compile(query, options)` + +Compiles the query, returns a function. + +#### `CSSselect.is(elem, query, options)` + +Tests whether or not an element is matched by `query`. `query` can be either a +CSS selector or a function. + +#### `CSSselect.selectOne(query, elems, options)` + +Arguments are the same as for `CSSselect.selectAll(query, elems)`. Only returns +the first match, or `null` if there was no match. + +### Options + +All options are optional. + +- `xmlMode`: When enabled, tag names will be case-sensitive. Default: `false`. +- `rootFunc`: The last function in the stack, will be called with the last + element that's looked at. +- `adapter`: The adapter to use when interacting with the backing DOM + structure. By default it uses the `domutils` module. +- `context`: The context of the current query. Used to limit the scope of + searches. Can be matched directly using the `:scope` pseudo-selector. +- `cacheResults`: Allow css-select to cache results for some selectors, + sometimes greatly improving querying performance. Disable this if your + document can change in between queries with the same compiled selector. + Default: `true`. + +#### Custom Adapters + +A custom adapter must match the interface described +[here](https://github.com/fb55/css-select/blob/1aa44bdd64aaf2ebdfd7f338e2e76bed36521957/src/types.ts#L6-L96). + +You may want to have a look at [`domutils`](https://github.com/fb55/domutils) to +see the default implementation, or at +[`css-select-browser-adapter`](https://github.com/nrkn/css-select-browser-adapter/blob/master/index.js) +for an implementation backed by the DOM. + +## Supported selectors + +_As defined by CSS 4 and / or jQuery._ + +- [Selector lists](https://developer.mozilla.org/en-US/docs/Web/CSS/Selector_list) + (`,`) +- [Universal](https://developer.mozilla.org/en-US/docs/Web/CSS/Universal_selectors) + (`*`) +- [Type](https://developer.mozilla.org/en-US/docs/Web/CSS/Type_selectors) + (``) +- [Descendant](https://developer.mozilla.org/en-US/docs/Web/CSS/Descendant_combinator) + (` `) +- [Child](https://developer.mozilla.org/en-US/docs/Web/CSS/Child_combinator) + (`>`) +- Parent (`<`) +- [Adjacent sibling](https://developer.mozilla.org/en-US/docs/Web/CSS/Adjacent_sibling_combinator) + (`+`) +- [General sibling](https://developer.mozilla.org/en-US/docs/Web/CSS/General_sibling_combinator) + (`~`) +- [Attribute](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors) + (`[attr=foo]`), with supported comparisons: + - `[attr]` (existential) + - `=` + - `~=` + - `|=` + - `*=` + - `^=` + - `$=` + - `!=` + - `i` and `s` can be added after the comparison to make the comparison + case-insensitive or case-sensitive (eg. `[attr=foo i]`). If neither is + supplied, css-select will follow the HTML spec's + [case-sensitivity rules](https://html.spec.whatwg.org/multipage/semantics-other.html#case-sensitivity-of-selectors). +- Pseudos: + - [`:not`](https://developer.mozilla.org/en-US/docs/Web/CSS/:not) + - [`:contains`](https://api.jquery.com/contains-selector) + - `:icontains` (case-insensitive version of `:contains`) + - [`:has`](https://developer.mozilla.org/en-US/docs/Web/CSS/:has) + - [`:root`](https://developer.mozilla.org/en-US/docs/Web/CSS/:root) + - [`:empty`](https://developer.mozilla.org/en-US/docs/Web/CSS/:empty) + - [`:parent`](https://api.jquery.com/parent-selector) + - [`:first-child`](https://developer.mozilla.org/en-US/docs/Web/CSS/:first-child), + [`:last-child`](https://developer.mozilla.org/en-US/docs/Web/CSS/:last-child), + [`:first-of-type`](https://developer.mozilla.org/en-US/docs/Web/CSS/:first-of-type), + [`:last-of-type`](https://developer.mozilla.org/en-US/docs/Web/CSS/:last-of-type) + - [`:only-of-type`](https://developer.mozilla.org/en-US/docs/Web/CSS/:only-of-type), + [`:only-child`](https://developer.mozilla.org/en-US/docs/Web/CSS/:only-child) + - [`:nth-child`](https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-child), + [`:nth-last-child`](https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-last-child), + [`:nth-of-type`](https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-of-type), + [`:nth-last-of-type`](https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-last-of-type), + - [`:link`](https://developer.mozilla.org/en-US/docs/Web/CSS/:link), + [`:any-link`](https://developer.mozilla.org/en-US/docs/Web/CSS/:any-link) + - [`:visited`](https://developer.mozilla.org/en-US/docs/Web/CSS/:visited), + [`:hover`](https://developer.mozilla.org/en-US/docs/Web/CSS/:hover), + [`:active`](https://developer.mozilla.org/en-US/docs/Web/CSS/:active) + (these depend on optional `Adapter` methods, so these will only match + elements if implemented in `Adapter`) + - [`:selected`](https://api.jquery.com/selected-selector), + [`:checked`](https://developer.mozilla.org/en-US/docs/Web/CSS/:checked) + - [`:enabled`](https://developer.mozilla.org/en-US/docs/Web/CSS/:enabled), + [`:disabled`](https://developer.mozilla.org/en-US/docs/Web/CSS/:disabled) + - [`:required`](https://developer.mozilla.org/en-US/docs/Web/CSS/:required), + [`:optional`](https://developer.mozilla.org/en-US/docs/Web/CSS/:optional) + - [`:header`](https://api.jquery.com/header-selector), + [`:button`](https://api.jquery.com/button-selector), + [`:input`](https://api.jquery.com/input-selector), + [`:text`](https://api.jquery.com/text-selector), + [`:checkbox`](https://api.jquery.com/checkbox-selector), + [`:file`](https://api.jquery.com/file-selector), + [`:password`](https://api.jquery.com/password-selector), + [`:reset`](https://api.jquery.com/reset-selector), + [`:radio`](https://api.jquery.com/radio-selector) etc. + - [`:is`](https://developer.mozilla.org/en-US/docs/Web/CSS/:is), plus its + legacy alias `:matches` + - [`:scope`](https://developer.mozilla.org/en-US/docs/Web/CSS/:scope) + (uses the context from the passed options) + +--- + +License: BSD-2-Clause + +## Security contact information + +To report a security vulnerability, please use the +[Tidelift security contact](https://tidelift.com/security). Tidelift will +coordinate the fix and disclosure. + +## `css-select` for enterprise + +Available as part of the Tidelift Subscription + +The maintainers of `css-select` and thousands of other packages are working with +Tidelift to deliver commercial support and maintenance for the open source +dependencies you use to build your applications. Save time, reduce risk, and +improve code health, while paying the maintainers of the exact dependencies you +use. +[Learn more.](https://tidelift.com/subscription/pkg/npm-css-select?utm_source=npm-css-select&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) diff --git a/igv_component/node_modules/css-select/lib/attributes.d.ts b/igv_component/node_modules/css-select/lib/attributes.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bcbc396fbf5e021320092b1fc74a5566ba75abd8 --- /dev/null +++ b/igv_component/node_modules/css-select/lib/attributes.d.ts @@ -0,0 +1,7 @@ +import { CompiledQuery, InternalOptions } from "./types"; +import type { AttributeSelector, AttributeAction } from "css-what"; +/** + * Attribute selectors + */ +export declare const attributeRules: Record(next: CompiledQuery, data: AttributeSelector, options: InternalOptions) => CompiledQuery>; +//# sourceMappingURL=attributes.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/attributes.d.ts.map b/igv_component/node_modules/css-select/lib/attributes.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..8ad56f44ecba42a92f4a4439d790b9f98bcb51a3 --- /dev/null +++ b/igv_component/node_modules/css-select/lib/attributes.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../src/attributes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AA+EnE;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAC/B,eAAe,EACf,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAC3B,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,KAC1C,aAAa,CAAC,WAAW,CAAC,CAsLlC,CAAC"} \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/attributes.js b/igv_component/node_modules/css-select/lib/attributes.js new file mode 100644 index 0000000000000000000000000000000000000000..bc524a05fa2227f7b6a1f1f1d4e0918cc758d865 --- /dev/null +++ b/igv_component/node_modules/css-select/lib/attributes.js @@ -0,0 +1,232 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.attributeRules = void 0; +var boolbase_1 = require("boolbase"); +/** + * All reserved characters in a regex, used for escaping. + * + * Taken from XRegExp, (c) 2007-2020 Steven Levithan under the MIT license + * https://github.com/slevithan/xregexp/blob/95eeebeb8fac8754d54eafe2b4743661ac1cf028/src/xregexp.js#L794 + */ +var reChars = /[-[\]{}()*+?.,\\^$|#\s]/g; +function escapeRegex(value) { + return value.replace(reChars, "\\$&"); +} +/** + * Attributes that are case-insensitive in HTML. + * + * @private + * @see https://html.spec.whatwg.org/multipage/semantics-other.html#case-sensitivity-of-selectors + */ +var caseInsensitiveAttributes = new Set([ + "accept", + "accept-charset", + "align", + "alink", + "axis", + "bgcolor", + "charset", + "checked", + "clear", + "codetype", + "color", + "compact", + "declare", + "defer", + "dir", + "direction", + "disabled", + "enctype", + "face", + "frame", + "hreflang", + "http-equiv", + "lang", + "language", + "link", + "media", + "method", + "multiple", + "nohref", + "noresize", + "noshade", + "nowrap", + "readonly", + "rel", + "rev", + "rules", + "scope", + "scrolling", + "selected", + "shape", + "target", + "text", + "type", + "valign", + "valuetype", + "vlink", +]); +function shouldIgnoreCase(selector, options) { + return typeof selector.ignoreCase === "boolean" + ? selector.ignoreCase + : selector.ignoreCase === "quirks" + ? !!options.quirksMode + : !options.xmlMode && caseInsensitiveAttributes.has(selector.name); +} +/** + * Attribute selectors + */ +exports.attributeRules = { + equals: function (next, data, options) { + var adapter = options.adapter; + var name = data.name; + var value = data.value; + if (shouldIgnoreCase(data, options)) { + value = value.toLowerCase(); + return function (elem) { + var attr = adapter.getAttributeValue(elem, name); + return (attr != null && + attr.length === value.length && + attr.toLowerCase() === value && + next(elem)); + }; + } + return function (elem) { + return adapter.getAttributeValue(elem, name) === value && next(elem); + }; + }, + hyphen: function (next, data, options) { + var adapter = options.adapter; + var name = data.name; + var value = data.value; + var len = value.length; + if (shouldIgnoreCase(data, options)) { + value = value.toLowerCase(); + return function hyphenIC(elem) { + var attr = adapter.getAttributeValue(elem, name); + return (attr != null && + (attr.length === len || attr.charAt(len) === "-") && + attr.substr(0, len).toLowerCase() === value && + next(elem)); + }; + } + return function hyphen(elem) { + var attr = adapter.getAttributeValue(elem, name); + return (attr != null && + (attr.length === len || attr.charAt(len) === "-") && + attr.substr(0, len) === value && + next(elem)); + }; + }, + element: function (next, data, options) { + var adapter = options.adapter; + var name = data.name, value = data.value; + if (/\s/.test(value)) { + return boolbase_1.falseFunc; + } + var regex = new RegExp("(?:^|\\s)".concat(escapeRegex(value), "(?:$|\\s)"), shouldIgnoreCase(data, options) ? "i" : ""); + return function element(elem) { + var attr = adapter.getAttributeValue(elem, name); + return (attr != null && + attr.length >= value.length && + regex.test(attr) && + next(elem)); + }; + }, + exists: function (next, _a, _b) { + var name = _a.name; + var adapter = _b.adapter; + return function (elem) { return adapter.hasAttrib(elem, name) && next(elem); }; + }, + start: function (next, data, options) { + var adapter = options.adapter; + var name = data.name; + var value = data.value; + var len = value.length; + if (len === 0) { + return boolbase_1.falseFunc; + } + if (shouldIgnoreCase(data, options)) { + value = value.toLowerCase(); + return function (elem) { + var attr = adapter.getAttributeValue(elem, name); + return (attr != null && + attr.length >= len && + attr.substr(0, len).toLowerCase() === value && + next(elem)); + }; + } + return function (elem) { + var _a; + return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.startsWith(value)) && + next(elem); + }; + }, + end: function (next, data, options) { + var adapter = options.adapter; + var name = data.name; + var value = data.value; + var len = -value.length; + if (len === 0) { + return boolbase_1.falseFunc; + } + if (shouldIgnoreCase(data, options)) { + value = value.toLowerCase(); + return function (elem) { + var _a; + return ((_a = adapter + .getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.substr(len).toLowerCase()) === value && next(elem); + }; + } + return function (elem) { + var _a; + return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.endsWith(value)) && + next(elem); + }; + }, + any: function (next, data, options) { + var adapter = options.adapter; + var name = data.name, value = data.value; + if (value === "") { + return boolbase_1.falseFunc; + } + if (shouldIgnoreCase(data, options)) { + var regex_1 = new RegExp(escapeRegex(value), "i"); + return function anyIC(elem) { + var attr = adapter.getAttributeValue(elem, name); + return (attr != null && + attr.length >= value.length && + regex_1.test(attr) && + next(elem)); + }; + } + return function (elem) { + var _a; + return !!((_a = adapter.getAttributeValue(elem, name)) === null || _a === void 0 ? void 0 : _a.includes(value)) && + next(elem); + }; + }, + not: function (next, data, options) { + var adapter = options.adapter; + var name = data.name; + var value = data.value; + if (value === "") { + return function (elem) { + return !!adapter.getAttributeValue(elem, name) && next(elem); + }; + } + else if (shouldIgnoreCase(data, options)) { + value = value.toLowerCase(); + return function (elem) { + var attr = adapter.getAttributeValue(elem, name); + return ((attr == null || + attr.length !== value.length || + attr.toLowerCase() !== value) && + next(elem)); + }; + } + return function (elem) { + return adapter.getAttributeValue(elem, name) !== value && next(elem); + }; + }, +}; diff --git a/igv_component/node_modules/css-select/lib/compile.d.ts b/igv_component/node_modules/css-select/lib/compile.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7184c95b94dcc8b0f2f9bab3693b88cb0216f5a8 --- /dev/null +++ b/igv_component/node_modules/css-select/lib/compile.d.ts @@ -0,0 +1,14 @@ +import { InternalSelector } from "./types"; +import { Selector } from "css-what"; +import type { CompiledQuery, InternalOptions } from "./types"; +/** + * Compiles a selector to an executable function. + * + * @param selector Selector to compile. + * @param options Compilation options. + * @param context Optional context for the selector. + */ +export declare function compile(selector: string | Selector[][], options: InternalOptions, context?: Node[] | Node): CompiledQuery; +export declare function compileUnsafe(selector: string | Selector[][], options: InternalOptions, context?: Node[] | Node): CompiledQuery; +export declare function compileToken(token: InternalSelector[][], options: InternalOptions, context?: Node[] | Node): CompiledQuery; +//# sourceMappingURL=compile.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/compile.d.ts.map b/igv_component/node_modules/css-select/lib/compile.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..e6d43d663b0a4ba90f431ce5df1fd64b85430faf --- /dev/null +++ b/igv_component/node_modules/css-select/lib/compile.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAS,QAAQ,EAAgB,MAAM,UAAU,CAAC;AASzD,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE9D;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAClD,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,EAAE,EAC/B,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,GACxB,aAAa,CAAC,IAAI,CAAC,CAGrB;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACxD,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,EAAE,EAC/B,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,GACxB,aAAa,CAAC,WAAW,CAAC,CAG5B;AAiDD,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACvD,KAAK,EAAE,gBAAgB,EAAE,EAAE,EAC3B,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,GACxB,aAAa,CAAC,WAAW,CAAC,CA2C5B"} \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/compile.js b/igv_component/node_modules/css-select/lib/compile.js new file mode 100644 index 0000000000000000000000000000000000000000..fc736d649ae5b9936371b22cb953663f5c8cd0e4 --- /dev/null +++ b/igv_component/node_modules/css-select/lib/compile.js @@ -0,0 +1,119 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.compileToken = exports.compileUnsafe = exports.compile = void 0; +var css_what_1 = require("css-what"); +var boolbase_1 = require("boolbase"); +var sort_1 = __importDefault(require("./sort")); +var procedure_1 = require("./procedure"); +var general_1 = require("./general"); +var subselects_1 = require("./pseudo-selectors/subselects"); +/** + * Compiles a selector to an executable function. + * + * @param selector Selector to compile. + * @param options Compilation options. + * @param context Optional context for the selector. + */ +function compile(selector, options, context) { + var next = compileUnsafe(selector, options, context); + return (0, subselects_1.ensureIsTag)(next, options.adapter); +} +exports.compile = compile; +function compileUnsafe(selector, options, context) { + var token = typeof selector === "string" ? (0, css_what_1.parse)(selector) : selector; + return compileToken(token, options, context); +} +exports.compileUnsafe = compileUnsafe; +function includesScopePseudo(t) { + return (t.type === "pseudo" && + (t.name === "scope" || + (Array.isArray(t.data) && + t.data.some(function (data) { return data.some(includesScopePseudo); })))); +} +var DESCENDANT_TOKEN = { type: css_what_1.SelectorType.Descendant }; +var FLEXIBLE_DESCENDANT_TOKEN = { + type: "_flexibleDescendant", +}; +var SCOPE_TOKEN = { + type: css_what_1.SelectorType.Pseudo, + name: "scope", + data: null, +}; +/* + * CSS 4 Spec (Draft): 3.3.1. Absolutizing a Scope-relative Selector + * http://www.w3.org/TR/selectors4/#absolutizing + */ +function absolutize(token, _a, context) { + var adapter = _a.adapter; + // TODO Use better check if the context is a document + var hasContext = !!(context === null || context === void 0 ? void 0 : context.every(function (e) { + var parent = adapter.isTag(e) && adapter.getParent(e); + return e === subselects_1.PLACEHOLDER_ELEMENT || (parent && adapter.isTag(parent)); + })); + for (var _i = 0, token_1 = token; _i < token_1.length; _i++) { + var t = token_1[_i]; + if (t.length > 0 && (0, procedure_1.isTraversal)(t[0]) && t[0].type !== "descendant") { + // Don't continue in else branch + } + else if (hasContext && !t.some(includesScopePseudo)) { + t.unshift(DESCENDANT_TOKEN); + } + else { + continue; + } + t.unshift(SCOPE_TOKEN); + } +} +function compileToken(token, options, context) { + var _a; + token = token.filter(function (t) { return t.length > 0; }); + token.forEach(sort_1.default); + context = (_a = options.context) !== null && _a !== void 0 ? _a : context; + var isArrayContext = Array.isArray(context); + var finalContext = context && (Array.isArray(context) ? context : [context]); + absolutize(token, options, finalContext); + var shouldTestNextSiblings = false; + var query = token + .map(function (rules) { + if (rules.length >= 2) { + var first = rules[0], second = rules[1]; + if (first.type !== "pseudo" || first.name !== "scope") { + // Ignore + } + else if (isArrayContext && second.type === "descendant") { + rules[1] = FLEXIBLE_DESCENDANT_TOKEN; + } + else if (second.type === "adjacent" || + second.type === "sibling") { + shouldTestNextSiblings = true; + } + } + return compileRules(rules, options, finalContext); + }) + .reduce(reduceRules, boolbase_1.falseFunc); + query.shouldTestNextSiblings = shouldTestNextSiblings; + return query; +} +exports.compileToken = compileToken; +function compileRules(rules, options, context) { + var _a; + return rules.reduce(function (previous, rule) { + return previous === boolbase_1.falseFunc + ? boolbase_1.falseFunc + : (0, general_1.compileGeneralSelector)(previous, rule, options, context, compileToken); + }, (_a = options.rootFunc) !== null && _a !== void 0 ? _a : boolbase_1.trueFunc); +} +function reduceRules(a, b) { + if (b === boolbase_1.falseFunc || a === boolbase_1.trueFunc) { + return a; + } + if (a === boolbase_1.falseFunc || b === boolbase_1.trueFunc) { + return b; + } + return function combine(elem) { + return a(elem) || b(elem); + }; +} diff --git a/igv_component/node_modules/css-select/lib/general.d.ts b/igv_component/node_modules/css-select/lib/general.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..de69feeb0d5d59cc57ac23fe73a6e6bbc91ce7eb --- /dev/null +++ b/igv_component/node_modules/css-select/lib/general.d.ts @@ -0,0 +1,3 @@ +import type { CompiledQuery, InternalOptions, InternalSelector, CompileToken } from "./types"; +export declare function compileGeneralSelector(next: CompiledQuery, selector: InternalSelector, options: InternalOptions, context: Node[] | undefined, compileToken: CompileToken): CompiledQuery; +//# sourceMappingURL=general.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/general.d.ts.map b/igv_component/node_modules/css-select/lib/general.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..85d72c01d3f2f43e502136bb3badca5745235b16 --- /dev/null +++ b/igv_component/node_modules/css-select/lib/general.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../src/general.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACR,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,YAAY,EACf,MAAM,SAAS,CAAC;AAOjB,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACjE,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,EAAE,IAAI,EAAE,GAAG,SAAS,EAC3B,YAAY,EAAE,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,GAC9C,aAAa,CAAC,WAAW,CAAC,CAiK5B"} \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/general.js b/igv_component/node_modules/css-select/lib/general.js new file mode 100644 index 0000000000000000000000000000000000000000..1381d93257523ee9279e1a0232af1d3812c6754b --- /dev/null +++ b/igv_component/node_modules/css-select/lib/general.js @@ -0,0 +1,140 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.compileGeneralSelector = void 0; +var attributes_1 = require("./attributes"); +var pseudo_selectors_1 = require("./pseudo-selectors"); +var css_what_1 = require("css-what"); +/* + * All available rules + */ +function compileGeneralSelector(next, selector, options, context, compileToken) { + var adapter = options.adapter, equals = options.equals; + switch (selector.type) { + case css_what_1.SelectorType.PseudoElement: { + throw new Error("Pseudo-elements are not supported by css-select"); + } + case css_what_1.SelectorType.ColumnCombinator: { + throw new Error("Column combinators are not yet supported by css-select"); + } + case css_what_1.SelectorType.Attribute: { + if (selector.namespace != null) { + throw new Error("Namespaced attributes are not yet supported by css-select"); + } + if (!options.xmlMode || options.lowerCaseAttributeNames) { + selector.name = selector.name.toLowerCase(); + } + return attributes_1.attributeRules[selector.action](next, selector, options); + } + case css_what_1.SelectorType.Pseudo: { + return (0, pseudo_selectors_1.compilePseudoSelector)(next, selector, options, context, compileToken); + } + // Tags + case css_what_1.SelectorType.Tag: { + if (selector.namespace != null) { + throw new Error("Namespaced tag names are not yet supported by css-select"); + } + var name_1 = selector.name; + if (!options.xmlMode || options.lowerCaseTags) { + name_1 = name_1.toLowerCase(); + } + return function tag(elem) { + return adapter.getName(elem) === name_1 && next(elem); + }; + } + // Traversal + case css_what_1.SelectorType.Descendant: { + if (options.cacheResults === false || + typeof WeakSet === "undefined") { + return function descendant(elem) { + var current = elem; + while ((current = adapter.getParent(current))) { + if (adapter.isTag(current) && next(current)) { + return true; + } + } + return false; + }; + } + // @ts-expect-error `ElementNode` is not extending object + var isFalseCache_1 = new WeakSet(); + return function cachedDescendant(elem) { + var current = elem; + while ((current = adapter.getParent(current))) { + if (!isFalseCache_1.has(current)) { + if (adapter.isTag(current) && next(current)) { + return true; + } + isFalseCache_1.add(current); + } + } + return false; + }; + } + case "_flexibleDescendant": { + // Include element itself, only used while querying an array + return function flexibleDescendant(elem) { + var current = elem; + do { + if (adapter.isTag(current) && next(current)) + return true; + } while ((current = adapter.getParent(current))); + return false; + }; + } + case css_what_1.SelectorType.Parent: { + return function parent(elem) { + return adapter + .getChildren(elem) + .some(function (elem) { return adapter.isTag(elem) && next(elem); }); + }; + } + case css_what_1.SelectorType.Child: { + return function child(elem) { + var parent = adapter.getParent(elem); + return parent != null && adapter.isTag(parent) && next(parent); + }; + } + case css_what_1.SelectorType.Sibling: { + return function sibling(elem) { + var siblings = adapter.getSiblings(elem); + for (var i = 0; i < siblings.length; i++) { + var currentSibling = siblings[i]; + if (equals(elem, currentSibling)) + break; + if (adapter.isTag(currentSibling) && next(currentSibling)) { + return true; + } + } + return false; + }; + } + case css_what_1.SelectorType.Adjacent: { + if (adapter.prevElementSibling) { + return function adjacent(elem) { + var previous = adapter.prevElementSibling(elem); + return previous != null && next(previous); + }; + } + return function adjacent(elem) { + var siblings = adapter.getSiblings(elem); + var lastElement; + for (var i = 0; i < siblings.length; i++) { + var currentSibling = siblings[i]; + if (equals(elem, currentSibling)) + break; + if (adapter.isTag(currentSibling)) { + lastElement = currentSibling; + } + } + return !!lastElement && next(lastElement); + }; + } + case css_what_1.SelectorType.Universal: { + if (selector.namespace != null && selector.namespace !== "*") { + throw new Error("Namespaced universal selectors are not yet supported by css-select"); + } + return next; + } + } +} +exports.compileGeneralSelector = compileGeneralSelector; diff --git a/igv_component/node_modules/css-select/lib/index.d.ts b/igv_component/node_modules/css-select/lib/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4d9f6448ed49ea020333433dedd85b166d9122fc --- /dev/null +++ b/igv_component/node_modules/css-select/lib/index.d.ts @@ -0,0 +1,49 @@ +import type { CompiledQuery, Options, Query, Adapter } from "./types"; +export type { Options }; +/** + * Compiles the query, returns a function. + */ +export declare const compile: (selector: string | import("css-what").Selector[][], options?: Options | undefined, context?: Node_1 | Node_1[] | undefined) => CompiledQuery; +export declare const _compileUnsafe: (selector: string | import("css-what").Selector[][], options?: Options | undefined, context?: Node_1 | Node_1[] | undefined) => CompiledQuery; +export declare const _compileToken: (selector: import("./types").InternalSelector[][], options?: Options | undefined, context?: Node_1 | Node_1[] | undefined) => CompiledQuery; +export declare function prepareContext(elems: Node | Node[], adapter: Adapter, shouldTestNextSiblings?: boolean): Node[]; +/** + * @template Node The generic Node type for the DOM adapter being used. + * @template ElementNode The Node type for elements for the DOM adapter being used. + * @param elems Elements to query. If it is an element, its children will be queried.. + * @param query can be either a CSS selector string or a compiled query function. + * @param [options] options for querying the document. + * @see compile for supported selector queries. + * @returns All matching elements. + * + */ +export declare const selectAll: (query: Query, elements: Node_1 | Node_1[], options?: Options | undefined) => ElementNode[]; +/** + * @template Node The generic Node type for the DOM adapter being used. + * @template ElementNode The Node type for elements for the DOM adapter being used. + * @param elems Elements to query. If it is an element, its children will be queried.. + * @param query can be either a CSS selector string or a compiled query function. + * @param [options] options for querying the document. + * @see compile for supported selector queries. + * @returns the first match, or null if there was no match. + */ +export declare const selectOne: (query: Query, elements: Node_1 | Node_1[], options?: Options | undefined) => ElementNode | null; +/** + * Tests whether or not an element is matched by query. + * + * @template Node The generic Node type for the DOM adapter being used. + * @template ElementNode The Node type for elements for the DOM adapter being used. + * @param elem The element to test if it matches the query. + * @param query can be either a CSS selector string or a compiled query function. + * @param [options] options for querying the document. + * @see compile for supported selector queries. + * @returns + */ +export declare function is(elem: ElementNode, query: Query, options?: Options): boolean; +/** + * Alias for selectAll(query, elems, options). + * @see [compile] for supported selector queries. + */ +export default selectAll; +export { filters, pseudos, aliases } from "./pseudo-selectors"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/index.d.ts.map b/igv_component/node_modules/css-select/lib/index.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..159d5f8ab9c21f67359ef9d38babe68161acd8de --- /dev/null +++ b/igv_component/node_modules/css-select/lib/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACR,aAAa,EACb,OAAO,EAEP,KAAK,EACL,OAAO,EAEV,MAAM,SAAS,CAAC;AAGjB,YAAY,EAAE,OAAO,EAAE,CAAC;AA0CxB;;GAEG;AACH,eAAO,MAAM,OAAO,gNAA0B,CAAC;AAC/C,eAAO,MAAM,cAAc,qNAA6B,CAAC;AACzD,eAAO,MAAM,aAAa,mNAA4B,CAAC;AA6BvD,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACzD,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,EACpB,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,EACnC,sBAAsB,UAAQ,GAC/B,IAAI,EAAE,CAYR;AAiBD;;;;;;;;;GASG;AACH,eAAO,MAAM,SAAS,mKASrB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,wKASrB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,EAAE,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAC7C,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,EACzB,OAAO,CAAC,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,GACrC,OAAO,CAKT;AAED;;;GAGG;AACH,eAAe,SAAS,CAAC;AAGzB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC"} \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/index.js b/igv_component/node_modules/css-select/lib/index.js new file mode 100644 index 0000000000000000000000000000000000000000..a8477bed40ab5e7c937514b64b6e5f7febec142a --- /dev/null +++ b/igv_component/node_modules/css-select/lib/index.js @@ -0,0 +1,149 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.aliases = exports.pseudos = exports.filters = exports.is = exports.selectOne = exports.selectAll = exports.prepareContext = exports._compileToken = exports._compileUnsafe = exports.compile = void 0; +var DomUtils = __importStar(require("domutils")); +var boolbase_1 = require("boolbase"); +var compile_1 = require("./compile"); +var subselects_1 = require("./pseudo-selectors/subselects"); +var defaultEquals = function (a, b) { return a === b; }; +var defaultOptions = { + adapter: DomUtils, + equals: defaultEquals, +}; +function convertOptionFormats(options) { + var _a, _b, _c, _d; + /* + * We force one format of options to the other one. + */ + // @ts-expect-error Default options may have incompatible `Node` / `ElementNode`. + var opts = options !== null && options !== void 0 ? options : defaultOptions; + // @ts-expect-error Same as above. + (_a = opts.adapter) !== null && _a !== void 0 ? _a : (opts.adapter = DomUtils); + // @ts-expect-error `equals` does not exist on `Options` + (_b = opts.equals) !== null && _b !== void 0 ? _b : (opts.equals = (_d = (_c = opts.adapter) === null || _c === void 0 ? void 0 : _c.equals) !== null && _d !== void 0 ? _d : defaultEquals); + return opts; +} +function wrapCompile(func) { + return function addAdapter(selector, options, context) { + var opts = convertOptionFormats(options); + return func(selector, opts, context); + }; +} +/** + * Compiles the query, returns a function. + */ +exports.compile = wrapCompile(compile_1.compile); +exports._compileUnsafe = wrapCompile(compile_1.compileUnsafe); +exports._compileToken = wrapCompile(compile_1.compileToken); +function getSelectorFunc(searchFunc) { + return function select(query, elements, options) { + var opts = convertOptionFormats(options); + if (typeof query !== "function") { + query = (0, compile_1.compileUnsafe)(query, opts, elements); + } + var filteredElements = prepareContext(elements, opts.adapter, query.shouldTestNextSiblings); + return searchFunc(query, filteredElements, opts); + }; +} +function prepareContext(elems, adapter, shouldTestNextSiblings) { + if (shouldTestNextSiblings === void 0) { shouldTestNextSiblings = false; } + /* + * Add siblings if the query requires them. + * See https://github.com/fb55/css-select/pull/43#issuecomment-225414692 + */ + if (shouldTestNextSiblings) { + elems = appendNextSiblings(elems, adapter); + } + return Array.isArray(elems) + ? adapter.removeSubsets(elems) + : adapter.getChildren(elems); +} +exports.prepareContext = prepareContext; +function appendNextSiblings(elem, adapter) { + // Order matters because jQuery seems to check the children before the siblings + var elems = Array.isArray(elem) ? elem.slice(0) : [elem]; + var elemsLength = elems.length; + for (var i = 0; i < elemsLength; i++) { + var nextSiblings = (0, subselects_1.getNextSiblings)(elems[i], adapter); + elems.push.apply(elems, nextSiblings); + } + return elems; +} +/** + * @template Node The generic Node type for the DOM adapter being used. + * @template ElementNode The Node type for elements for the DOM adapter being used. + * @param elems Elements to query. If it is an element, its children will be queried.. + * @param query can be either a CSS selector string or a compiled query function. + * @param [options] options for querying the document. + * @see compile for supported selector queries. + * @returns All matching elements. + * + */ +exports.selectAll = getSelectorFunc(function (query, elems, options) { + return query === boolbase_1.falseFunc || !elems || elems.length === 0 + ? [] + : options.adapter.findAll(query, elems); +}); +/** + * @template Node The generic Node type for the DOM adapter being used. + * @template ElementNode The Node type for elements for the DOM adapter being used. + * @param elems Elements to query. If it is an element, its children will be queried.. + * @param query can be either a CSS selector string or a compiled query function. + * @param [options] options for querying the document. + * @see compile for supported selector queries. + * @returns the first match, or null if there was no match. + */ +exports.selectOne = getSelectorFunc(function (query, elems, options) { + return query === boolbase_1.falseFunc || !elems || elems.length === 0 + ? null + : options.adapter.findOne(query, elems); +}); +/** + * Tests whether or not an element is matched by query. + * + * @template Node The generic Node type for the DOM adapter being used. + * @template ElementNode The Node type for elements for the DOM adapter being used. + * @param elem The element to test if it matches the query. + * @param query can be either a CSS selector string or a compiled query function. + * @param [options] options for querying the document. + * @see compile for supported selector queries. + * @returns + */ +function is(elem, query, options) { + var opts = convertOptionFormats(options); + return (typeof query === "function" ? query : (0, compile_1.compile)(query, opts))(elem); +} +exports.is = is; +/** + * Alias for selectAll(query, elems, options). + * @see [compile] for supported selector queries. + */ +exports.default = exports.selectAll; +// Export filters, pseudos and aliases to allow users to supply their own. +var pseudo_selectors_1 = require("./pseudo-selectors"); +Object.defineProperty(exports, "filters", { enumerable: true, get: function () { return pseudo_selectors_1.filters; } }); +Object.defineProperty(exports, "pseudos", { enumerable: true, get: function () { return pseudo_selectors_1.pseudos; } }); +Object.defineProperty(exports, "aliases", { enumerable: true, get: function () { return pseudo_selectors_1.aliases; } }); diff --git a/igv_component/node_modules/css-select/lib/procedure.d.ts b/igv_component/node_modules/css-select/lib/procedure.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a9116231dcc9fc18d65a919c599b375cf687342d --- /dev/null +++ b/igv_component/node_modules/css-select/lib/procedure.d.ts @@ -0,0 +1,5 @@ +import type { Traversal } from "css-what"; +import type { InternalSelector } from "./types"; +export declare const procedure: Record; +export declare function isTraversal(t: InternalSelector): t is Traversal; +//# sourceMappingURL=procedure.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/procedure.d.ts.map b/igv_component/node_modules/css-select/lib/procedure.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..9b18be368bea9cb5f8636e8a69d9e74e0d2c538f --- /dev/null +++ b/igv_component/node_modules/css-select/lib/procedure.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"procedure.d.ts","sourceRoot":"","sources":["../src/procedure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,CAa9D,CAAC;AAEF,wBAAgB,WAAW,CAAC,CAAC,EAAE,gBAAgB,GAAG,CAAC,IAAI,SAAS,CAE/D"} \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/procedure.js b/igv_component/node_modules/css-select/lib/procedure.js new file mode 100644 index 0000000000000000000000000000000000000000..b775b20ad5eb22f145ca532a097f6c8c141684a1 --- /dev/null +++ b/igv_component/node_modules/css-select/lib/procedure.js @@ -0,0 +1,21 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isTraversal = exports.procedure = void 0; +exports.procedure = { + universal: 50, + tag: 30, + attribute: 1, + pseudo: 0, + "pseudo-element": 0, + "column-combinator": -1, + descendant: -1, + child: -1, + parent: -1, + sibling: -1, + adjacent: -1, + _flexibleDescendant: -1, +}; +function isTraversal(t) { + return exports.procedure[t.type] < 0; +} +exports.isTraversal = isTraversal; diff --git a/igv_component/node_modules/css-select/lib/pseudo-selectors/aliases.d.ts b/igv_component/node_modules/css-select/lib/pseudo-selectors/aliases.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1bcb31a418d238271db48c1a54e247a2ae950470 --- /dev/null +++ b/igv_component/node_modules/css-select/lib/pseudo-selectors/aliases.d.ts @@ -0,0 +1,5 @@ +/** + * Aliases are pseudos that are expressed as selectors. + */ +export declare const aliases: Record; +//# sourceMappingURL=aliases.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/pseudo-selectors/aliases.d.ts.map b/igv_component/node_modules/css-select/lib/pseudo-selectors/aliases.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..57346592c9b0eb2f75c9b600e9743c10133cebae --- /dev/null +++ b/igv_component/node_modules/css-select/lib/pseudo-selectors/aliases.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"aliases.d.ts","sourceRoot":"","sources":["../../src/pseudo-selectors/aliases.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAwC1C,CAAC"} \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/pseudo-selectors/aliases.js b/igv_component/node_modules/css-select/lib/pseudo-selectors/aliases.js new file mode 100644 index 0000000000000000000000000000000000000000..f9a03daf2e6f72bd682a11a793f08666ca9ac457 --- /dev/null +++ b/igv_component/node_modules/css-select/lib/pseudo-selectors/aliases.js @@ -0,0 +1,33 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.aliases = void 0; +/** + * Aliases are pseudos that are expressed as selectors. + */ +exports.aliases = { + // Links + "any-link": ":is(a, area, link)[href]", + link: ":any-link:not(:visited)", + // Forms + // https://html.spec.whatwg.org/multipage/scripting.html#disabled-elements + disabled: ":is(\n :is(button, input, select, textarea, optgroup, option)[disabled],\n optgroup[disabled] > option,\n fieldset[disabled]:not(fieldset[disabled] legend:first-of-type *)\n )", + enabled: ":not(:disabled)", + checked: ":is(:is(input[type=radio], input[type=checkbox])[checked], option:selected)", + required: ":is(input, select, textarea)[required]", + optional: ":is(input, select, textarea):not([required])", + // JQuery extensions + // https://html.spec.whatwg.org/multipage/form-elements.html#concept-option-selectedness + selected: "option:is([selected], select:not([multiple]):not(:has(> option[selected])) > :first-of-type)", + checkbox: "[type=checkbox]", + file: "[type=file]", + password: "[type=password]", + radio: "[type=radio]", + reset: "[type=reset]", + image: "[type=image]", + submit: "[type=submit]", + parent: ":not(:empty)", + header: ":is(h1, h2, h3, h4, h5, h6)", + button: ":is(button, input[type=button])", + input: ":is(input, textarea, select, button)", + text: "input:is(:not([type!='']), [type=text])", +}; diff --git a/igv_component/node_modules/css-select/lib/pseudo-selectors/filters.d.ts b/igv_component/node_modules/css-select/lib/pseudo-selectors/filters.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..90634f7e65d1b3355e477adc54ab1c1f1e4169d8 --- /dev/null +++ b/igv_component/node_modules/css-select/lib/pseudo-selectors/filters.d.ts @@ -0,0 +1,4 @@ +import type { CompiledQuery, InternalOptions } from "../types"; +export declare type Filter = (next: CompiledQuery, text: string, options: InternalOptions, context?: Node[]) => CompiledQuery; +export declare const filters: Record; +//# sourceMappingURL=filters.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/pseudo-selectors/filters.d.ts.map b/igv_component/node_modules/css-select/lib/pseudo-selectors/filters.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..c2caa25b6f799cf1560c4a5f252dd730007c4cb4 --- /dev/null +++ b/igv_component/node_modules/css-select/lib/pseudo-selectors/filters.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../src/pseudo-selectors/filters.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAW,MAAM,UAAU,CAAC;AAExE,oBAAY,MAAM,GAAG,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAChD,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,CAAC,EAAE,IAAI,EAAE,KACf,aAAa,CAAC,WAAW,CAAC,CAAC;AAYhC,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA2I1C,CAAC"} \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/pseudo-selectors/filters.js b/igv_component/node_modules/css-select/lib/pseudo-selectors/filters.js new file mode 100644 index 0000000000000000000000000000000000000000..84f86c1cb3cef8597005e6606335675cdb118fbd --- /dev/null +++ b/igv_component/node_modules/css-select/lib/pseudo-selectors/filters.js @@ -0,0 +1,156 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.filters = void 0; +var nth_check_1 = __importDefault(require("nth-check")); +var boolbase_1 = require("boolbase"); +function getChildFunc(next, adapter) { + return function (elem) { + var parent = adapter.getParent(elem); + return parent != null && adapter.isTag(parent) && next(elem); + }; +} +exports.filters = { + contains: function (next, text, _a) { + var adapter = _a.adapter; + return function contains(elem) { + return next(elem) && adapter.getText(elem).includes(text); + }; + }, + icontains: function (next, text, _a) { + var adapter = _a.adapter; + var itext = text.toLowerCase(); + return function icontains(elem) { + return (next(elem) && + adapter.getText(elem).toLowerCase().includes(itext)); + }; + }, + // Location specific methods + "nth-child": function (next, rule, _a) { + var adapter = _a.adapter, equals = _a.equals; + var func = (0, nth_check_1.default)(rule); + if (func === boolbase_1.falseFunc) + return boolbase_1.falseFunc; + if (func === boolbase_1.trueFunc) + return getChildFunc(next, adapter); + return function nthChild(elem) { + var siblings = adapter.getSiblings(elem); + var pos = 0; + for (var i = 0; i < siblings.length; i++) { + if (equals(elem, siblings[i])) + break; + if (adapter.isTag(siblings[i])) { + pos++; + } + } + return func(pos) && next(elem); + }; + }, + "nth-last-child": function (next, rule, _a) { + var adapter = _a.adapter, equals = _a.equals; + var func = (0, nth_check_1.default)(rule); + if (func === boolbase_1.falseFunc) + return boolbase_1.falseFunc; + if (func === boolbase_1.trueFunc) + return getChildFunc(next, adapter); + return function nthLastChild(elem) { + var siblings = adapter.getSiblings(elem); + var pos = 0; + for (var i = siblings.length - 1; i >= 0; i--) { + if (equals(elem, siblings[i])) + break; + if (adapter.isTag(siblings[i])) { + pos++; + } + } + return func(pos) && next(elem); + }; + }, + "nth-of-type": function (next, rule, _a) { + var adapter = _a.adapter, equals = _a.equals; + var func = (0, nth_check_1.default)(rule); + if (func === boolbase_1.falseFunc) + return boolbase_1.falseFunc; + if (func === boolbase_1.trueFunc) + return getChildFunc(next, adapter); + return function nthOfType(elem) { + var siblings = adapter.getSiblings(elem); + var pos = 0; + for (var i = 0; i < siblings.length; i++) { + var currentSibling = siblings[i]; + if (equals(elem, currentSibling)) + break; + if (adapter.isTag(currentSibling) && + adapter.getName(currentSibling) === adapter.getName(elem)) { + pos++; + } + } + return func(pos) && next(elem); + }; + }, + "nth-last-of-type": function (next, rule, _a) { + var adapter = _a.adapter, equals = _a.equals; + var func = (0, nth_check_1.default)(rule); + if (func === boolbase_1.falseFunc) + return boolbase_1.falseFunc; + if (func === boolbase_1.trueFunc) + return getChildFunc(next, adapter); + return function nthLastOfType(elem) { + var siblings = adapter.getSiblings(elem); + var pos = 0; + for (var i = siblings.length - 1; i >= 0; i--) { + var currentSibling = siblings[i]; + if (equals(elem, currentSibling)) + break; + if (adapter.isTag(currentSibling) && + adapter.getName(currentSibling) === adapter.getName(elem)) { + pos++; + } + } + return func(pos) && next(elem); + }; + }, + // TODO determine the actual root element + root: function (next, _rule, _a) { + var adapter = _a.adapter; + return function (elem) { + var parent = adapter.getParent(elem); + return (parent == null || !adapter.isTag(parent)) && next(elem); + }; + }, + scope: function (next, rule, options, context) { + var equals = options.equals; + if (!context || context.length === 0) { + // Equivalent to :root + return exports.filters.root(next, rule, options); + } + if (context.length === 1) { + // NOTE: can't be unpacked, as :has uses this for side-effects + return function (elem) { return equals(context[0], elem) && next(elem); }; + } + return function (elem) { return context.includes(elem) && next(elem); }; + }, + hover: dynamicStatePseudo("isHovered"), + visited: dynamicStatePseudo("isVisited"), + active: dynamicStatePseudo("isActive"), +}; +/** + * Dynamic state pseudos. These depend on optional Adapter methods. + * + * @param name The name of the adapter method to call. + * @returns Pseudo for the `filters` object. + */ +function dynamicStatePseudo(name) { + return function dynamicPseudo(next, _rule, _a) { + var adapter = _a.adapter; + var func = adapter[name]; + if (typeof func !== "function") { + return boolbase_1.falseFunc; + } + return function active(elem) { + return func(elem) && next(elem); + }; + }; +} diff --git a/igv_component/node_modules/css-select/lib/pseudo-selectors/index.d.ts b/igv_component/node_modules/css-select/lib/pseudo-selectors/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..70f467d729069bf3fef9d814ad0a800f98008cd5 --- /dev/null +++ b/igv_component/node_modules/css-select/lib/pseudo-selectors/index.d.ts @@ -0,0 +1,8 @@ +import type { CompiledQuery, InternalOptions, CompileToken } from "../types"; +import { PseudoSelector } from "css-what"; +import { filters } from "./filters"; +import { pseudos } from "./pseudos"; +import { aliases } from "./aliases"; +export { filters, pseudos, aliases }; +export declare function compilePseudoSelector(next: CompiledQuery, selector: PseudoSelector, options: InternalOptions, context: Node[] | undefined, compileToken: CompileToken): CompiledQuery; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/pseudo-selectors/index.d.ts.map b/igv_component/node_modules/css-select/lib/pseudo-selectors/index.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..abe85a6f873c35db9160bbe70491d7b053001283 --- /dev/null +++ b/igv_component/node_modules/css-select/lib/pseudo-selectors/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pseudo-selectors/index.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7E,OAAO,EAAS,cAAc,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAoB,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAErC,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAChE,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,EAAE,IAAI,EAAE,GAAG,SAAS,EAC3B,YAAY,EAAE,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,GAC9C,aAAa,CAAC,WAAW,CAAC,CA6B5B"} \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/pseudo-selectors/index.js b/igv_component/node_modules/css-select/lib/pseudo-selectors/index.js new file mode 100644 index 0000000000000000000000000000000000000000..26d71cf6f7f4573893d2a718202552af0ac09964 --- /dev/null +++ b/igv_component/node_modules/css-select/lib/pseudo-selectors/index.js @@ -0,0 +1,54 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.compilePseudoSelector = exports.aliases = exports.pseudos = exports.filters = void 0; +/* + * Pseudo selectors + * + * Pseudo selectors are available in three forms: + * + * 1. Filters are called when the selector is compiled and return a function + * that has to return either false, or the results of `next()`. + * 2. Pseudos are called on execution. They have to return a boolean. + * 3. Subselects work like filters, but have an embedded selector that will be run separately. + * + * Filters are great if you want to do some pre-processing, or change the call order + * of `next()` and your code. + * Pseudos should be used to implement simple checks. + */ +var boolbase_1 = require("boolbase"); +var css_what_1 = require("css-what"); +var filters_1 = require("./filters"); +Object.defineProperty(exports, "filters", { enumerable: true, get: function () { return filters_1.filters; } }); +var pseudos_1 = require("./pseudos"); +Object.defineProperty(exports, "pseudos", { enumerable: true, get: function () { return pseudos_1.pseudos; } }); +var aliases_1 = require("./aliases"); +Object.defineProperty(exports, "aliases", { enumerable: true, get: function () { return aliases_1.aliases; } }); +var subselects_1 = require("./subselects"); +function compilePseudoSelector(next, selector, options, context, compileToken) { + var name = selector.name, data = selector.data; + if (Array.isArray(data)) { + return subselects_1.subselects[name](next, data, options, context, compileToken); + } + if (name in aliases_1.aliases) { + if (data != null) { + throw new Error("Pseudo ".concat(name, " doesn't have any arguments")); + } + // The alias has to be parsed here, to make sure options are respected. + var alias = (0, css_what_1.parse)(aliases_1.aliases[name]); + return subselects_1.subselects.is(next, alias, options, context, compileToken); + } + if (name in filters_1.filters) { + return filters_1.filters[name](next, data, options, context); + } + if (name in pseudos_1.pseudos) { + var pseudo_1 = pseudos_1.pseudos[name]; + (0, pseudos_1.verifyPseudoArgs)(pseudo_1, name, data); + return pseudo_1 === boolbase_1.falseFunc + ? boolbase_1.falseFunc + : next === boolbase_1.trueFunc + ? function (elem) { return pseudo_1(elem, options, data); } + : function (elem) { return pseudo_1(elem, options, data) && next(elem); }; + } + throw new Error("unmatched pseudo-class :".concat(name)); +} +exports.compilePseudoSelector = compilePseudoSelector; diff --git a/igv_component/node_modules/css-select/lib/pseudo-selectors/pseudos.d.ts b/igv_component/node_modules/css-select/lib/pseudo-selectors/pseudos.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..afd483fbb63b900f3c7b56285a22c0056e76d7f0 --- /dev/null +++ b/igv_component/node_modules/css-select/lib/pseudo-selectors/pseudos.d.ts @@ -0,0 +1,6 @@ +import { PseudoSelector } from "css-what"; +import type { InternalOptions } from "../types"; +export declare type Pseudo = (elem: ElementNode, options: InternalOptions, subselect?: ElementNode | string | null) => boolean; +export declare const pseudos: Record; +export declare function verifyPseudoArgs(func: Pseudo, name: string, subselect: PseudoSelector["data"]): void; +//# sourceMappingURL=pseudos.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/pseudo-selectors/pseudos.d.ts.map b/igv_component/node_modules/css-select/lib/pseudo-selectors/pseudos.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..daa0f45cfd9a624e9e2a13045adf763555ea1754 --- /dev/null +++ b/igv_component/node_modules/css-select/lib/pseudo-selectors/pseudos.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"pseudos.d.ts","sourceRoot":"","sources":["../../src/pseudo-selectors/pseudos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,oBAAY,MAAM,GAAG,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAChD,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,SAAS,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,KACtC,OAAO,CAAC;AAGb,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA8E1C,CAAC;AAEF,wBAAgB,gBAAgB,CAC5B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,cAAc,CAAC,MAAM,CAAC,GAClC,IAAI,CAQN"} \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/pseudo-selectors/pseudos.js b/igv_component/node_modules/css-select/lib/pseudo-selectors/pseudos.js new file mode 100644 index 0000000000000000000000000000000000000000..c5da83987dd9bacd2561c7fe8939c13ddfc4070d --- /dev/null +++ b/igv_component/node_modules/css-select/lib/pseudo-selectors/pseudos.js @@ -0,0 +1,89 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.verifyPseudoArgs = exports.pseudos = void 0; +// While filters are precompiled, pseudos get called when they are needed +exports.pseudos = { + empty: function (elem, _a) { + var adapter = _a.adapter; + return !adapter.getChildren(elem).some(function (elem) { + // FIXME: `getText` call is potentially expensive. + return adapter.isTag(elem) || adapter.getText(elem) !== ""; + }); + }, + "first-child": function (elem, _a) { + var adapter = _a.adapter, equals = _a.equals; + var firstChild = adapter + .getSiblings(elem) + .find(function (elem) { return adapter.isTag(elem); }); + return firstChild != null && equals(elem, firstChild); + }, + "last-child": function (elem, _a) { + var adapter = _a.adapter, equals = _a.equals; + var siblings = adapter.getSiblings(elem); + for (var i = siblings.length - 1; i >= 0; i--) { + if (equals(elem, siblings[i])) + return true; + if (adapter.isTag(siblings[i])) + break; + } + return false; + }, + "first-of-type": function (elem, _a) { + var adapter = _a.adapter, equals = _a.equals; + var siblings = adapter.getSiblings(elem); + var elemName = adapter.getName(elem); + for (var i = 0; i < siblings.length; i++) { + var currentSibling = siblings[i]; + if (equals(elem, currentSibling)) + return true; + if (adapter.isTag(currentSibling) && + adapter.getName(currentSibling) === elemName) { + break; + } + } + return false; + }, + "last-of-type": function (elem, _a) { + var adapter = _a.adapter, equals = _a.equals; + var siblings = adapter.getSiblings(elem); + var elemName = adapter.getName(elem); + for (var i = siblings.length - 1; i >= 0; i--) { + var currentSibling = siblings[i]; + if (equals(elem, currentSibling)) + return true; + if (adapter.isTag(currentSibling) && + adapter.getName(currentSibling) === elemName) { + break; + } + } + return false; + }, + "only-of-type": function (elem, _a) { + var adapter = _a.adapter, equals = _a.equals; + var elemName = adapter.getName(elem); + return adapter + .getSiblings(elem) + .every(function (sibling) { + return equals(elem, sibling) || + !adapter.isTag(sibling) || + adapter.getName(sibling) !== elemName; + }); + }, + "only-child": function (elem, _a) { + var adapter = _a.adapter, equals = _a.equals; + return adapter + .getSiblings(elem) + .every(function (sibling) { return equals(elem, sibling) || !adapter.isTag(sibling); }); + }, +}; +function verifyPseudoArgs(func, name, subselect) { + if (subselect === null) { + if (func.length > 2) { + throw new Error("pseudo-selector :".concat(name, " requires an argument")); + } + } + else if (func.length === 2) { + throw new Error("pseudo-selector :".concat(name, " doesn't have any arguments")); + } +} +exports.verifyPseudoArgs = verifyPseudoArgs; diff --git a/igv_component/node_modules/css-select/lib/pseudo-selectors/subselects.d.ts b/igv_component/node_modules/css-select/lib/pseudo-selectors/subselects.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..192d8800576f889dd094134af48972da30d6a384 --- /dev/null +++ b/igv_component/node_modules/css-select/lib/pseudo-selectors/subselects.d.ts @@ -0,0 +1,10 @@ +import { CompileToken } from "./../types"; +import type { Selector } from "css-what"; +import type { CompiledQuery, InternalOptions, Adapter } from "../types"; +/** Used as a placeholder for :has. Will be replaced with the actual element. */ +export declare const PLACEHOLDER_ELEMENT: {}; +export declare function ensureIsTag(next: CompiledQuery, adapter: Adapter): CompiledQuery; +export declare type Subselect = (next: CompiledQuery, subselect: Selector[][], options: InternalOptions, context: Node[] | undefined, compileToken: CompileToken) => CompiledQuery; +export declare function getNextSiblings(elem: Node, adapter: Adapter): ElementNode[]; +export declare const subselects: Record; +//# sourceMappingURL=subselects.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/pseudo-selectors/subselects.d.ts.map b/igv_component/node_modules/css-select/lib/pseudo-selectors/subselects.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..a6f188ff00bed301fb92fc56e500fac1d412ce1f --- /dev/null +++ b/igv_component/node_modules/css-select/lib/pseudo-selectors/subselects.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"subselects.d.ts","sourceRoot":"","sources":["../../src/pseudo-selectors/subselects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGxE,gFAAgF;AAChF,eAAO,MAAM,mBAAmB,IAAK,CAAC;AAEtC,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACtD,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,GACpC,aAAa,CAAC,IAAI,CAAC,CAGrB;AAED,oBAAY,SAAS,GAAG,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EACnD,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,EAChC,SAAS,EAAE,QAAQ,EAAE,EAAE,EACvB,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,EAAE,IAAI,EAAE,GAAG,SAAS,EAC3B,YAAY,EAAE,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,KAC5C,aAAa,CAAC,WAAW,CAAC,CAAC;AAEhC,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,EAC1D,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,GACpC,WAAW,EAAE,CAMf;AAkBD,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CA6EhD,CAAC"} \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/pseudo-selectors/subselects.js b/igv_component/node_modules/css-select/lib/pseudo-selectors/subselects.js new file mode 100644 index 0000000000000000000000000000000000000000..a42ee0c1fab5c21cbda2e28eed12c704f4a1cef3 --- /dev/null +++ b/igv_component/node_modules/css-select/lib/pseudo-selectors/subselects.js @@ -0,0 +1,110 @@ +"use strict"; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.subselects = exports.getNextSiblings = exports.ensureIsTag = exports.PLACEHOLDER_ELEMENT = void 0; +var boolbase_1 = require("boolbase"); +var procedure_1 = require("../procedure"); +/** Used as a placeholder for :has. Will be replaced with the actual element. */ +exports.PLACEHOLDER_ELEMENT = {}; +function ensureIsTag(next, adapter) { + if (next === boolbase_1.falseFunc) + return boolbase_1.falseFunc; + return function (elem) { return adapter.isTag(elem) && next(elem); }; +} +exports.ensureIsTag = ensureIsTag; +function getNextSiblings(elem, adapter) { + var siblings = adapter.getSiblings(elem); + if (siblings.length <= 1) + return []; + var elemIndex = siblings.indexOf(elem); + if (elemIndex < 0 || elemIndex === siblings.length - 1) + return []; + return siblings.slice(elemIndex + 1).filter(adapter.isTag); +} +exports.getNextSiblings = getNextSiblings; +var is = function (next, token, options, context, compileToken) { + var opts = { + xmlMode: !!options.xmlMode, + adapter: options.adapter, + equals: options.equals, + }; + var func = compileToken(token, opts, context); + return function (elem) { return func(elem) && next(elem); }; +}; +/* + * :not, :has, :is, :matches and :where have to compile selectors + * doing this in src/pseudos.ts would lead to circular dependencies, + * so we add them here + */ +exports.subselects = { + is: is, + /** + * `:matches` and `:where` are aliases for `:is`. + */ + matches: is, + where: is, + not: function (next, token, options, context, compileToken) { + var opts = { + xmlMode: !!options.xmlMode, + adapter: options.adapter, + equals: options.equals, + }; + var func = compileToken(token, opts, context); + if (func === boolbase_1.falseFunc) + return next; + if (func === boolbase_1.trueFunc) + return boolbase_1.falseFunc; + return function not(elem) { + return !func(elem) && next(elem); + }; + }, + has: function (next, subselect, options, _context, compileToken) { + var adapter = options.adapter; + var opts = { + xmlMode: !!options.xmlMode, + adapter: adapter, + equals: options.equals, + }; + // @ts-expect-error Uses an array as a pointer to the current element (side effects) + var context = subselect.some(function (s) { + return s.some(procedure_1.isTraversal); + }) + ? [exports.PLACEHOLDER_ELEMENT] + : undefined; + var compiled = compileToken(subselect, opts, context); + if (compiled === boolbase_1.falseFunc) + return boolbase_1.falseFunc; + if (compiled === boolbase_1.trueFunc) { + return function (elem) { + return adapter.getChildren(elem).some(adapter.isTag) && next(elem); + }; + } + var hasElement = ensureIsTag(compiled, adapter); + var _a = compiled.shouldTestNextSiblings, shouldTestNextSiblings = _a === void 0 ? false : _a; + /* + * `shouldTestNextSiblings` will only be true if the query starts with + * a traversal (sibling or adjacent). That means we will always have a context. + */ + if (context) { + return function (elem) { + context[0] = elem; + var childs = adapter.getChildren(elem); + var nextElements = shouldTestNextSiblings + ? __spreadArray(__spreadArray([], childs, true), getNextSiblings(elem, adapter), true) : childs; + return (next(elem) && adapter.existsOne(hasElement, nextElements)); + }; + } + return function (elem) { + return next(elem) && + adapter.existsOne(hasElement, adapter.getChildren(elem)); + }; + }, +}; diff --git a/igv_component/node_modules/css-select/lib/sort.d.ts b/igv_component/node_modules/css-select/lib/sort.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d5b9c6e603ce990d4488094bcd9a5e9d08e69344 --- /dev/null +++ b/igv_component/node_modules/css-select/lib/sort.d.ts @@ -0,0 +1,10 @@ +import type { InternalSelector } from "./types"; +/** + * Sort the parts of the passed selector, + * as there is potential for optimization + * (some types of selectors are faster than others) + * + * @param arr Selector to sort + */ +export default function sortByProcedure(arr: InternalSelector[]): void; +//# sourceMappingURL=sort.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/sort.d.ts.map b/igv_component/node_modules/css-select/lib/sort.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..f55e27bc4bbab236bd5b62baa32cf9a1841f13cb --- /dev/null +++ b/igv_component/node_modules/css-select/lib/sort.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../src/sort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAehD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,GAAG,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAerE"} \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/sort.js b/igv_component/node_modules/css-select/lib/sort.js new file mode 100644 index 0000000000000000000000000000000000000000..7facad18ccb47894e7abcfb802480e1db97db06e --- /dev/null +++ b/igv_component/node_modules/css-select/lib/sort.js @@ -0,0 +1,85 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var css_what_1 = require("css-what"); +var procedure_1 = require("./procedure"); +var attributes = { + exists: 10, + equals: 8, + not: 7, + start: 6, + end: 6, + any: 5, + hyphen: 4, + element: 4, +}; +/** + * Sort the parts of the passed selector, + * as there is potential for optimization + * (some types of selectors are faster than others) + * + * @param arr Selector to sort + */ +function sortByProcedure(arr) { + var procs = arr.map(getProcedure); + for (var i = 1; i < arr.length; i++) { + var procNew = procs[i]; + if (procNew < 0) + continue; + for (var j = i - 1; j >= 0 && procNew < procs[j]; j--) { + var token = arr[j + 1]; + arr[j + 1] = arr[j]; + arr[j] = token; + procs[j + 1] = procs[j]; + procs[j] = procNew; + } + } +} +exports.default = sortByProcedure; +function getProcedure(token) { + var proc = procedure_1.procedure[token.type]; + if (token.type === css_what_1.SelectorType.Attribute) { + proc = attributes[token.action]; + if (proc === attributes.equals && token.name === "id") { + // Prefer ID selectors (eg. #ID) + proc = 9; + } + if (token.ignoreCase) { + /* + * IgnoreCase adds some overhead, prefer "normal" token + * this is a binary operation, to ensure it's still an int + */ + proc >>= 1; + } + } + else if (token.type === css_what_1.SelectorType.Pseudo) { + if (!token.data) { + proc = 3; + } + else if (token.name === "has" || token.name === "contains") { + proc = 0; // Expensive in any case + } + else if (Array.isArray(token.data)) { + // "matches" and "not" + proc = 0; + for (var i = 0; i < token.data.length; i++) { + // TODO better handling of complex selectors + if (token.data[i].length !== 1) + continue; + var cur = getProcedure(token.data[i][0]); + // Avoid executing :has or :contains + if (cur === 0) { + proc = 0; + break; + } + if (cur > proc) + proc = cur; + } + if (token.data.length > 1 && proc > 0) + proc -= 1; + } + else { + proc = 1; + } + } + return proc; +} diff --git a/igv_component/node_modules/css-select/lib/types.d.ts b/igv_component/node_modules/css-select/lib/types.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3eb2ec5aa415683965b5522ccb60feea9dd788be --- /dev/null +++ b/igv_component/node_modules/css-select/lib/types.d.ts @@ -0,0 +1,144 @@ +import type { Selector } from "css-what"; +export declare type InternalSelector = Selector | { + type: "_flexibleDescendant"; +}; +export declare type Predicate = (v: Value) => boolean; +export interface Adapter { + /** + * Is the node a tag? + */ + isTag: (node: Node) => node is ElementNode; + /** + * Does at least one of passed element nodes pass the test predicate? + */ + existsOne: (test: Predicate, elems: Node[]) => boolean; + /** + * Get the attribute value. + */ + getAttributeValue: (elem: ElementNode, name: string) => string | undefined; + /** + * Get the node's children + */ + getChildren: (node: Node) => Node[]; + /** + * Get the name of the tag + */ + getName: (elem: ElementNode) => string; + /** + * Get the parent of the node + */ + getParent: (node: ElementNode) => ElementNode | null; + /** + * Get the siblings of the node. Note that unlike jQuery's `siblings` method, + * this is expected to include the current node as well + */ + getSiblings: (node: Node) => Node[]; + /** + * Returns the previous element sibling of a node. + */ + prevElementSibling?: (node: Node) => ElementNode | null; + /** + * Get the text content of the node, and its children if it has any. + */ + getText: (node: Node) => string; + /** + * Does the element have the named attribute? + */ + hasAttrib: (elem: ElementNode, name: string) => boolean; + /** + * Takes an array of nodes, and removes any duplicates, as well as any + * nodes whose ancestors are also in the array. + */ + removeSubsets: (nodes: Node[]) => Node[]; + /** + * Finds all of the element nodes in the array that match the test predicate, + * as well as any of their children that match it. + */ + findAll: (test: Predicate, nodes: Node[]) => ElementNode[]; + /** + * Finds the first node in the array that matches the test predicate, or one + * of its children. + */ + findOne: (test: Predicate, elems: Node[]) => ElementNode | null; + /** + * The adapter can also optionally include an equals method, if your DOM + * structure needs a custom equality test to compare two objects which refer + * to the same underlying node. If not provided, `css-select` will fall back to + * `a === b`. + */ + equals?: (a: Node, b: Node) => boolean; + /** + * Is the element in hovered state? + */ + isHovered?: (elem: ElementNode) => boolean; + /** + * Is the element in visited state? + */ + isVisited?: (elem: ElementNode) => boolean; + /** + * Is the element in active state? + */ + isActive?: (elem: ElementNode) => boolean; +} +export interface Options { + /** + * When enabled, tag names will be case-sensitive. + * + * @default false + */ + xmlMode?: boolean; + /** + * Lower-case attribute names. + * + * @default !xmlMode + */ + lowerCaseAttributeNames?: boolean; + /** + * Lower-case tag names. + * + * @default !xmlMode + */ + lowerCaseTags?: boolean; + /** + * Is the document in quirks mode? + * + * This will lead to .className and #id being case-insensitive. + * + * @default false + */ + quirksMode?: boolean; + /** + * The last function in the stack, will be called with the last element + * that's looked at. + */ + rootFunc?: (element: ElementNode) => boolean; + /** + * The adapter to use when interacting with the backing DOM structure. By + * default it uses the `domutils` module. + */ + adapter?: Adapter; + /** + * The context of the current query. Used to limit the scope of searches. + * Can be matched directly using the `:scope` pseudo-selector. + */ + context?: Node | Node[]; + /** + * Allow css-select to cache results for some selectors, sometimes greatly + * improving querying performance. Disable this if your document can + * change in between queries with the same compiled selector. + * + * @default true + */ + cacheResults?: boolean; +} +export interface InternalOptions extends Options { + adapter: Adapter; + equals: (a: Node, b: Node) => boolean; +} +export interface CompiledQuery { + (node: ElementNode): boolean; + shouldTestNextSiblings?: boolean; +} +export declare type Query = string | CompiledQuery | Selector[][]; +export declare type CompileToken = (token: InternalSelector[][], options: InternalOptions, context?: Node[] | Node) => CompiledQuery; +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/types.d.ts.map b/igv_component/node_modules/css-select/lib/types.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..578b2fef077dae8cc3bd56435cae242ad9839bde --- /dev/null +++ b/igv_component/node_modules/css-select/lib/types.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,oBAAY,gBAAgB,GAAG,QAAQ,GAAG;IAAE,IAAI,EAAE,qBAAqB,CAAA;CAAE,CAAC;AAE1E,oBAAY,SAAS,CAAC,KAAK,IAAI,CAAC,CAAC,EAAE,KAAK,KAAK,OAAO,CAAC;AACrD,MAAM,WAAW,OAAO,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI;IACnD;;OAEG;IACH,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,IAAI,WAAW,CAAC;IAE3C;;OAEG;IACH,SAAS,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,OAAO,CAAC;IAEpE;;OAEG;IACH,iBAAiB,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IAE3E;;OAEG;IACH,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,EAAE,CAAC;IAEpC;;OAEG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,MAAM,CAAC;IAEvC;;OAEG;IACH,SAAS,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,WAAW,GAAG,IAAI,CAAC;IAErD;;;OAGG;IACH,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,EAAE,CAAC;IAEpC;;OAEG;IACH,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,WAAW,GAAG,IAAI,CAAC;IAExD;;OAEG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC;IAEhC;;OAEG;IACH,SAAS,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAExD;;;OAGG;IACH,aAAa,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;IAEzC;;;OAGG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,CAAC;IAExE;;;OAGG;IACH,OAAO,EAAE,CACL,IAAI,EAAE,SAAS,CAAC,WAAW,CAAC,EAC5B,KAAK,EAAE,IAAI,EAAE,KACZ,WAAW,GAAG,IAAI,CAAC;IAExB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,KAAK,OAAO,CAAC;IAEvC;;OAEG;IACH,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC;IAE3C;;OAEG;IACH,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC;IAE3C;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC;CAC7C;AAED,MAAM,WAAW,OAAO,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI;IACnD;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC;IAC7C;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IACrC;;;OAGG;IACH,OAAO,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,CAAC;IACxB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B;AAGD,MAAM,WAAW,eAAe,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,CAC3D,SAAQ,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC;IAClC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IACpC,MAAM,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,KAAK,OAAO,CAAC;CACzC;AAED,MAAM,WAAW,aAAa,CAAC,WAAW;IACtC,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC;IAC7B,sBAAsB,CAAC,EAAE,OAAO,CAAC;CACpC;AACD,oBAAY,KAAK,CAAC,WAAW,IACvB,MAAM,GACN,aAAa,CAAC,WAAW,CAAC,GAC1B,QAAQ,EAAE,EAAE,CAAC;AACnB,oBAAY,YAAY,CAAC,IAAI,EAAE,WAAW,SAAS,IAAI,IAAI,CACvD,KAAK,EAAE,gBAAgB,EAAE,EAAE,EAC3B,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,EAC3C,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,KACtB,aAAa,CAAC,WAAW,CAAC,CAAC"} \ No newline at end of file diff --git a/igv_component/node_modules/css-select/lib/types.js b/igv_component/node_modules/css-select/lib/types.js new file mode 100644 index 0000000000000000000000000000000000000000..c8ad2e549bdc6801e0d1c80b0308d4b9bd4985ce --- /dev/null +++ b/igv_component/node_modules/css-select/lib/types.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/igv_component/node_modules/css-select/package.json b/igv_component/node_modules/css-select/package.json new file mode 100644 index 0000000000000000000000000000000000000000..0eaa9ed81cbf9cc88385acb8f56a0abf31e3869f --- /dev/null +++ b/igv_component/node_modules/css-select/package.json @@ -0,0 +1,70 @@ +{ + "name": "css-select", + "version": "4.3.0", + "description": "a CSS selector compiler/engine", + "author": "Felix Boehm ", + "funding": { + "url": "https://github.com/sponsors/fb55" + }, + "keywords": [ + "css", + "selector", + "sizzle" + ], + "repository": { + "type": "git", + "url": "git://github.com/fb55/css-select.git" + }, + "main": "lib/index.js", + "types": "lib/index.d.ts", + "files": [ + "lib" + ], + "dependencies": { + "boolbase": "^1.0.0", + "css-what": "^6.0.1", + "domhandler": "^4.3.1", + "domutils": "^2.8.0", + "nth-check": "^2.0.1" + }, + "devDependencies": { + "@types/boolbase": "^1.0.1", + "@types/jest": "^27.4.1", + "@types/node": "^17.0.23", + "@typescript-eslint/eslint-plugin": "^5.16.0", + "@typescript-eslint/parser": "^5.16.0", + "cheerio-soupselect": "^0.1.1", + "eslint": "^8.12.0", + "eslint-config-prettier": "^8.5.0", + "htmlparser2": "^7.2.0", + "jest": "^27.5.1", + "prettier": "^2.6.1", + "ts-jest": "^27.1.4", + "typescript": "^4.6.3" + }, + "scripts": { + "test": "npm run test:jest && npm run lint", + "test:jest": "jest", + "lint": "npm run lint:es && npm run lint:prettier", + "lint:es": "eslint src", + "lint:prettier": "npm run prettier -- --check", + "format": "npm run format:es && npm run format:prettier", + "format:es": "npm run lint:es -- --fix", + "format:prettier": "npm run prettier -- --write", + "prettier": "prettier '**/*.{ts,md,json,yml}'", + "build": "tsc", + "prepare": "npm run build" + }, + "license": "BSD-2-Clause", + "prettier": { + "tabWidth": 4, + "proseWrap": "always" + }, + "jest": { + "preset": "ts-jest", + "testEnvironment": "node", + "testMatch": [ + "/test/*.ts" + ] + } +} diff --git a/igv_component/node_modules/css-what/LICENSE b/igv_component/node_modules/css-what/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..c464f863ea2b18a15ca3883bc5d98065ed5d039a --- /dev/null +++ b/igv_component/node_modules/css-what/LICENSE @@ -0,0 +1,11 @@ +Copyright (c) Felix Böhm +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/igv_component/node_modules/css-what/lib/commonjs/index.d.ts b/igv_component/node_modules/css-what/lib/commonjs/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ee9d66e6f1d537ae798891ba1961d6499b0a87bc --- /dev/null +++ b/igv_component/node_modules/css-what/lib/commonjs/index.d.ts @@ -0,0 +1,4 @@ +export * from "./types"; +export { isTraversal, parse } from "./parse"; +export { stringify } from "./stringify"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/css-what/lib/commonjs/index.d.ts.map b/igv_component/node_modules/css-what/lib/commonjs/index.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..8a428b61dad0c37955078081f679c375a34cebb1 --- /dev/null +++ b/igv_component/node_modules/css-what/lib/commonjs/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"} \ No newline at end of file diff --git a/igv_component/node_modules/css-what/lib/commonjs/index.js b/igv_component/node_modules/css-what/lib/commonjs/index.js new file mode 100644 index 0000000000000000000000000000000000000000..3a2058a0269c50964084accf513cd9a977005da5 --- /dev/null +++ b/igv_component/node_modules/css-what/lib/commonjs/index.js @@ -0,0 +1,23 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.stringify = exports.parse = exports.isTraversal = void 0; +__exportStar(require("./types"), exports); +var parse_1 = require("./parse"); +Object.defineProperty(exports, "isTraversal", { enumerable: true, get: function () { return parse_1.isTraversal; } }); +Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parse_1.parse; } }); +var stringify_1 = require("./stringify"); +Object.defineProperty(exports, "stringify", { enumerable: true, get: function () { return stringify_1.stringify; } }); diff --git a/igv_component/node_modules/css-what/lib/commonjs/parse.d.ts b/igv_component/node_modules/css-what/lib/commonjs/parse.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1d6e3a21d4348094b3232a4bfea9b660d0706c8f --- /dev/null +++ b/igv_component/node_modules/css-what/lib/commonjs/parse.d.ts @@ -0,0 +1,20 @@ +import { Selector, Traversal } from "./types"; +/** + * Checks whether a specific selector is a traversal. + * This is useful eg. in swapping the order of elements that + * are not traversals. + * + * @param selector Selector to check. + */ +export declare function isTraversal(selector: Selector): selector is Traversal; +/** + * Parses `selector`, optionally with the passed `options`. + * + * @param selector Selector to parse. + * @param options Options for parsing. + * @returns Returns a two-dimensional array. + * The first dimension represents selectors separated by commas (eg. `sub1, sub2`), + * the second contains the relevant tokens for that selector. + */ +export declare function parse(selector: string): Selector[][]; +//# sourceMappingURL=parse.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/css-what/lib/commonjs/parse.d.ts.map b/igv_component/node_modules/css-what/lib/commonjs/parse.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..e4a5b0513efb9199c25fcbade3ca911f14bc2d0a --- /dev/null +++ b/igv_component/node_modules/css-what/lib/commonjs/parse.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EAGR,SAAS,EAIZ,MAAM,SAAS,CAAC;AA6DjB;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,IAAI,SAAS,CAYrE;AAoCD;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,EAAE,CAUpD"} \ No newline at end of file diff --git a/igv_component/node_modules/css-what/lib/commonjs/parse.js b/igv_component/node_modules/css-what/lib/commonjs/parse.js new file mode 100644 index 0000000000000000000000000000000000000000..708de6704271bdc8d3c1e2a0b98800231a7a948d --- /dev/null +++ b/igv_component/node_modules/css-what/lib/commonjs/parse.js @@ -0,0 +1,425 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.parse = exports.isTraversal = void 0; +var types_1 = require("./types"); +var reName = /^[^\\#]?(?:\\(?:[\da-f]{1,6}\s?|.)|[\w\-\u00b0-\uFFFF])+/; +var reEscape = /\\([\da-f]{1,6}\s?|(\s)|.)/gi; +var actionTypes = new Map([ + [126 /* Tilde */, types_1.AttributeAction.Element], + [94 /* Circumflex */, types_1.AttributeAction.Start], + [36 /* Dollar */, types_1.AttributeAction.End], + [42 /* Asterisk */, types_1.AttributeAction.Any], + [33 /* ExclamationMark */, types_1.AttributeAction.Not], + [124 /* Pipe */, types_1.AttributeAction.Hyphen], +]); +// Pseudos, whose data property is parsed as well. +var unpackPseudos = new Set([ + "has", + "not", + "matches", + "is", + "where", + "host", + "host-context", +]); +/** + * Checks whether a specific selector is a traversal. + * This is useful eg. in swapping the order of elements that + * are not traversals. + * + * @param selector Selector to check. + */ +function isTraversal(selector) { + switch (selector.type) { + case types_1.SelectorType.Adjacent: + case types_1.SelectorType.Child: + case types_1.SelectorType.Descendant: + case types_1.SelectorType.Parent: + case types_1.SelectorType.Sibling: + case types_1.SelectorType.ColumnCombinator: + return true; + default: + return false; + } +} +exports.isTraversal = isTraversal; +var stripQuotesFromPseudos = new Set(["contains", "icontains"]); +// Unescape function taken from https://github.com/jquery/sizzle/blob/master/src/sizzle.js#L152 +function funescape(_, escaped, escapedWhitespace) { + var high = parseInt(escaped, 16) - 0x10000; + // NaN means non-codepoint + return high !== high || escapedWhitespace + ? escaped + : high < 0 + ? // BMP codepoint + String.fromCharCode(high + 0x10000) + : // Supplemental Plane codepoint (surrogate pair) + String.fromCharCode((high >> 10) | 0xd800, (high & 0x3ff) | 0xdc00); +} +function unescapeCSS(str) { + return str.replace(reEscape, funescape); +} +function isQuote(c) { + return c === 39 /* SingleQuote */ || c === 34 /* DoubleQuote */; +} +function isWhitespace(c) { + return (c === 32 /* Space */ || + c === 9 /* Tab */ || + c === 10 /* NewLine */ || + c === 12 /* FormFeed */ || + c === 13 /* CarriageReturn */); +} +/** + * Parses `selector`, optionally with the passed `options`. + * + * @param selector Selector to parse. + * @param options Options for parsing. + * @returns Returns a two-dimensional array. + * The first dimension represents selectors separated by commas (eg. `sub1, sub2`), + * the second contains the relevant tokens for that selector. + */ +function parse(selector) { + var subselects = []; + var endIndex = parseSelector(subselects, "".concat(selector), 0); + if (endIndex < selector.length) { + throw new Error("Unmatched selector: ".concat(selector.slice(endIndex))); + } + return subselects; +} +exports.parse = parse; +function parseSelector(subselects, selector, selectorIndex) { + var tokens = []; + function getName(offset) { + var match = selector.slice(selectorIndex + offset).match(reName); + if (!match) { + throw new Error("Expected name, found ".concat(selector.slice(selectorIndex))); + } + var name = match[0]; + selectorIndex += offset + name.length; + return unescapeCSS(name); + } + function stripWhitespace(offset) { + selectorIndex += offset; + while (selectorIndex < selector.length && + isWhitespace(selector.charCodeAt(selectorIndex))) { + selectorIndex++; + } + } + function readValueWithParenthesis() { + selectorIndex += 1; + var start = selectorIndex; + var counter = 1; + for (; counter > 0 && selectorIndex < selector.length; selectorIndex++) { + if (selector.charCodeAt(selectorIndex) === + 40 /* LeftParenthesis */ && + !isEscaped(selectorIndex)) { + counter++; + } + else if (selector.charCodeAt(selectorIndex) === + 41 /* RightParenthesis */ && + !isEscaped(selectorIndex)) { + counter--; + } + } + if (counter) { + throw new Error("Parenthesis not matched"); + } + return unescapeCSS(selector.slice(start, selectorIndex - 1)); + } + function isEscaped(pos) { + var slashCount = 0; + while (selector.charCodeAt(--pos) === 92 /* BackSlash */) + slashCount++; + return (slashCount & 1) === 1; + } + function ensureNotTraversal() { + if (tokens.length > 0 && isTraversal(tokens[tokens.length - 1])) { + throw new Error("Did not expect successive traversals."); + } + } + function addTraversal(type) { + if (tokens.length > 0 && + tokens[tokens.length - 1].type === types_1.SelectorType.Descendant) { + tokens[tokens.length - 1].type = type; + return; + } + ensureNotTraversal(); + tokens.push({ type: type }); + } + function addSpecialAttribute(name, action) { + tokens.push({ + type: types_1.SelectorType.Attribute, + name: name, + action: action, + value: getName(1), + namespace: null, + ignoreCase: "quirks", + }); + } + /** + * We have finished parsing the current part of the selector. + * + * Remove descendant tokens at the end if they exist, + * and return the last index, so that parsing can be + * picked up from here. + */ + function finalizeSubselector() { + if (tokens.length && + tokens[tokens.length - 1].type === types_1.SelectorType.Descendant) { + tokens.pop(); + } + if (tokens.length === 0) { + throw new Error("Empty sub-selector"); + } + subselects.push(tokens); + } + stripWhitespace(0); + if (selector.length === selectorIndex) { + return selectorIndex; + } + loop: while (selectorIndex < selector.length) { + var firstChar = selector.charCodeAt(selectorIndex); + switch (firstChar) { + // Whitespace + case 32 /* Space */: + case 9 /* Tab */: + case 10 /* NewLine */: + case 12 /* FormFeed */: + case 13 /* CarriageReturn */: { + if (tokens.length === 0 || + tokens[0].type !== types_1.SelectorType.Descendant) { + ensureNotTraversal(); + tokens.push({ type: types_1.SelectorType.Descendant }); + } + stripWhitespace(1); + break; + } + // Traversals + case 62 /* GreaterThan */: { + addTraversal(types_1.SelectorType.Child); + stripWhitespace(1); + break; + } + case 60 /* LessThan */: { + addTraversal(types_1.SelectorType.Parent); + stripWhitespace(1); + break; + } + case 126 /* Tilde */: { + addTraversal(types_1.SelectorType.Sibling); + stripWhitespace(1); + break; + } + case 43 /* Plus */: { + addTraversal(types_1.SelectorType.Adjacent); + stripWhitespace(1); + break; + } + // Special attribute selectors: .class, #id + case 46 /* Period */: { + addSpecialAttribute("class", types_1.AttributeAction.Element); + break; + } + case 35 /* Hash */: { + addSpecialAttribute("id", types_1.AttributeAction.Equals); + break; + } + case 91 /* LeftSquareBracket */: { + stripWhitespace(1); + // Determine attribute name and namespace + var name_1 = void 0; + var namespace = null; + if (selector.charCodeAt(selectorIndex) === 124 /* Pipe */) { + // Equivalent to no namespace + name_1 = getName(1); + } + else if (selector.startsWith("*|", selectorIndex)) { + namespace = "*"; + name_1 = getName(2); + } + else { + name_1 = getName(0); + if (selector.charCodeAt(selectorIndex) === 124 /* Pipe */ && + selector.charCodeAt(selectorIndex + 1) !== + 61 /* Equal */) { + namespace = name_1; + name_1 = getName(1); + } + } + stripWhitespace(0); + // Determine comparison operation + var action = types_1.AttributeAction.Exists; + var possibleAction = actionTypes.get(selector.charCodeAt(selectorIndex)); + if (possibleAction) { + action = possibleAction; + if (selector.charCodeAt(selectorIndex + 1) !== + 61 /* Equal */) { + throw new Error("Expected `=`"); + } + stripWhitespace(2); + } + else if (selector.charCodeAt(selectorIndex) === 61 /* Equal */) { + action = types_1.AttributeAction.Equals; + stripWhitespace(1); + } + // Determine value + var value = ""; + var ignoreCase = null; + if (action !== "exists") { + if (isQuote(selector.charCodeAt(selectorIndex))) { + var quote = selector.charCodeAt(selectorIndex); + var sectionEnd = selectorIndex + 1; + while (sectionEnd < selector.length && + (selector.charCodeAt(sectionEnd) !== quote || + isEscaped(sectionEnd))) { + sectionEnd += 1; + } + if (selector.charCodeAt(sectionEnd) !== quote) { + throw new Error("Attribute value didn't end"); + } + value = unescapeCSS(selector.slice(selectorIndex + 1, sectionEnd)); + selectorIndex = sectionEnd + 1; + } + else { + var valueStart = selectorIndex; + while (selectorIndex < selector.length && + ((!isWhitespace(selector.charCodeAt(selectorIndex)) && + selector.charCodeAt(selectorIndex) !== + 93 /* RightSquareBracket */) || + isEscaped(selectorIndex))) { + selectorIndex += 1; + } + value = unescapeCSS(selector.slice(valueStart, selectorIndex)); + } + stripWhitespace(0); + // See if we have a force ignore flag + var forceIgnore = selector.charCodeAt(selectorIndex) | 0x20; + // If the forceIgnore flag is set (either `i` or `s`), use that value + if (forceIgnore === 115 /* LowerS */) { + ignoreCase = false; + stripWhitespace(1); + } + else if (forceIgnore === 105 /* LowerI */) { + ignoreCase = true; + stripWhitespace(1); + } + } + if (selector.charCodeAt(selectorIndex) !== + 93 /* RightSquareBracket */) { + throw new Error("Attribute selector didn't terminate"); + } + selectorIndex += 1; + var attributeSelector = { + type: types_1.SelectorType.Attribute, + name: name_1, + action: action, + value: value, + namespace: namespace, + ignoreCase: ignoreCase, + }; + tokens.push(attributeSelector); + break; + } + case 58 /* Colon */: { + if (selector.charCodeAt(selectorIndex + 1) === 58 /* Colon */) { + tokens.push({ + type: types_1.SelectorType.PseudoElement, + name: getName(2).toLowerCase(), + data: selector.charCodeAt(selectorIndex) === + 40 /* LeftParenthesis */ + ? readValueWithParenthesis() + : null, + }); + continue; + } + var name_2 = getName(1).toLowerCase(); + var data = null; + if (selector.charCodeAt(selectorIndex) === + 40 /* LeftParenthesis */) { + if (unpackPseudos.has(name_2)) { + if (isQuote(selector.charCodeAt(selectorIndex + 1))) { + throw new Error("Pseudo-selector ".concat(name_2, " cannot be quoted")); + } + data = []; + selectorIndex = parseSelector(data, selector, selectorIndex + 1); + if (selector.charCodeAt(selectorIndex) !== + 41 /* RightParenthesis */) { + throw new Error("Missing closing parenthesis in :".concat(name_2, " (").concat(selector, ")")); + } + selectorIndex += 1; + } + else { + data = readValueWithParenthesis(); + if (stripQuotesFromPseudos.has(name_2)) { + var quot = data.charCodeAt(0); + if (quot === data.charCodeAt(data.length - 1) && + isQuote(quot)) { + data = data.slice(1, -1); + } + } + data = unescapeCSS(data); + } + } + tokens.push({ type: types_1.SelectorType.Pseudo, name: name_2, data: data }); + break; + } + case 44 /* Comma */: { + finalizeSubselector(); + tokens = []; + stripWhitespace(1); + break; + } + default: { + if (selector.startsWith("/*", selectorIndex)) { + var endIndex = selector.indexOf("*/", selectorIndex + 2); + if (endIndex < 0) { + throw new Error("Comment was not terminated"); + } + selectorIndex = endIndex + 2; + // Remove leading whitespace + if (tokens.length === 0) { + stripWhitespace(0); + } + break; + } + var namespace = null; + var name_3 = void 0; + if (firstChar === 42 /* Asterisk */) { + selectorIndex += 1; + name_3 = "*"; + } + else if (firstChar === 124 /* Pipe */) { + name_3 = ""; + if (selector.charCodeAt(selectorIndex + 1) === 124 /* Pipe */) { + addTraversal(types_1.SelectorType.ColumnCombinator); + stripWhitespace(2); + break; + } + } + else if (reName.test(selector.slice(selectorIndex))) { + name_3 = getName(0); + } + else { + break loop; + } + if (selector.charCodeAt(selectorIndex) === 124 /* Pipe */ && + selector.charCodeAt(selectorIndex + 1) !== 124 /* Pipe */) { + namespace = name_3; + if (selector.charCodeAt(selectorIndex + 1) === + 42 /* Asterisk */) { + name_3 = "*"; + selectorIndex += 2; + } + else { + name_3 = getName(1); + } + } + tokens.push(name_3 === "*" + ? { type: types_1.SelectorType.Universal, namespace: namespace } + : { type: types_1.SelectorType.Tag, name: name_3, namespace: namespace }); + } + } + } + finalizeSubselector(); + return selectorIndex; +} diff --git a/igv_component/node_modules/css-what/lib/commonjs/stringify.d.ts b/igv_component/node_modules/css-what/lib/commonjs/stringify.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2883b0c32cff0ebe51caca567bd8d54bda0e840b --- /dev/null +++ b/igv_component/node_modules/css-what/lib/commonjs/stringify.d.ts @@ -0,0 +1,8 @@ +import { Selector } from "./types"; +/** + * Turns `selector` back into a string. + * + * @param selector Selector to stringify. + */ +export declare function stringify(selector: Selector[][]): string; +//# sourceMappingURL=stringify.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/css-what/lib/commonjs/stringify.d.ts.map b/igv_component/node_modules/css-what/lib/commonjs/stringify.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..98f99ca7678aae9e860a5d0571a6654c24a28780 --- /dev/null +++ b/igv_component/node_modules/css-what/lib/commonjs/stringify.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"stringify.d.ts","sourceRoot":"","sources":["../../src/stringify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiC,MAAM,SAAS,CAAC;AA6BlE;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,GAAG,MAAM,CAIxD"} \ No newline at end of file diff --git a/igv_component/node_modules/css-what/lib/commonjs/stringify.js b/igv_component/node_modules/css-what/lib/commonjs/stringify.js new file mode 100644 index 0000000000000000000000000000000000000000..158b180aafe50bd1b14b5fa37b7593b3f301a7ac --- /dev/null +++ b/igv_component/node_modules/css-what/lib/commonjs/stringify.js @@ -0,0 +1,138 @@ +"use strict"; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.stringify = void 0; +var types_1 = require("./types"); +var attribValChars = ["\\", '"']; +var pseudoValChars = __spreadArray(__spreadArray([], attribValChars, true), ["(", ")"], false); +var charsToEscapeInAttributeValue = new Set(attribValChars.map(function (c) { return c.charCodeAt(0); })); +var charsToEscapeInPseudoValue = new Set(pseudoValChars.map(function (c) { return c.charCodeAt(0); })); +var charsToEscapeInName = new Set(__spreadArray(__spreadArray([], pseudoValChars, true), [ + "~", + "^", + "$", + "*", + "+", + "!", + "|", + ":", + "[", + "]", + " ", + ".", +], false).map(function (c) { return c.charCodeAt(0); })); +/** + * Turns `selector` back into a string. + * + * @param selector Selector to stringify. + */ +function stringify(selector) { + return selector + .map(function (token) { return token.map(stringifyToken).join(""); }) + .join(", "); +} +exports.stringify = stringify; +function stringifyToken(token, index, arr) { + switch (token.type) { + // Simple types + case types_1.SelectorType.Child: + return index === 0 ? "> " : " > "; + case types_1.SelectorType.Parent: + return index === 0 ? "< " : " < "; + case types_1.SelectorType.Sibling: + return index === 0 ? "~ " : " ~ "; + case types_1.SelectorType.Adjacent: + return index === 0 ? "+ " : " + "; + case types_1.SelectorType.Descendant: + return " "; + case types_1.SelectorType.ColumnCombinator: + return index === 0 ? "|| " : " || "; + case types_1.SelectorType.Universal: + // Return an empty string if the selector isn't needed. + return token.namespace === "*" && + index + 1 < arr.length && + "name" in arr[index + 1] + ? "" + : "".concat(getNamespace(token.namespace), "*"); + case types_1.SelectorType.Tag: + return getNamespacedName(token); + case types_1.SelectorType.PseudoElement: + return "::".concat(escapeName(token.name, charsToEscapeInName)).concat(token.data === null + ? "" + : "(".concat(escapeName(token.data, charsToEscapeInPseudoValue), ")")); + case types_1.SelectorType.Pseudo: + return ":".concat(escapeName(token.name, charsToEscapeInName)).concat(token.data === null + ? "" + : "(".concat(typeof token.data === "string" + ? escapeName(token.data, charsToEscapeInPseudoValue) + : stringify(token.data), ")")); + case types_1.SelectorType.Attribute: { + if (token.name === "id" && + token.action === types_1.AttributeAction.Equals && + token.ignoreCase === "quirks" && + !token.namespace) { + return "#".concat(escapeName(token.value, charsToEscapeInName)); + } + if (token.name === "class" && + token.action === types_1.AttributeAction.Element && + token.ignoreCase === "quirks" && + !token.namespace) { + return ".".concat(escapeName(token.value, charsToEscapeInName)); + } + var name_1 = getNamespacedName(token); + if (token.action === types_1.AttributeAction.Exists) { + return "[".concat(name_1, "]"); + } + return "[".concat(name_1).concat(getActionValue(token.action), "=\"").concat(escapeName(token.value, charsToEscapeInAttributeValue), "\"").concat(token.ignoreCase === null ? "" : token.ignoreCase ? " i" : " s", "]"); + } + } +} +function getActionValue(action) { + switch (action) { + case types_1.AttributeAction.Equals: + return ""; + case types_1.AttributeAction.Element: + return "~"; + case types_1.AttributeAction.Start: + return "^"; + case types_1.AttributeAction.End: + return "$"; + case types_1.AttributeAction.Any: + return "*"; + case types_1.AttributeAction.Not: + return "!"; + case types_1.AttributeAction.Hyphen: + return "|"; + case types_1.AttributeAction.Exists: + throw new Error("Shouldn't be here"); + } +} +function getNamespacedName(token) { + return "".concat(getNamespace(token.namespace)).concat(escapeName(token.name, charsToEscapeInName)); +} +function getNamespace(namespace) { + return namespace !== null + ? "".concat(namespace === "*" + ? "*" + : escapeName(namespace, charsToEscapeInName), "|") + : ""; +} +function escapeName(str, charsToEscape) { + var lastIdx = 0; + var ret = ""; + for (var i = 0; i < str.length; i++) { + if (charsToEscape.has(str.charCodeAt(i))) { + ret += "".concat(str.slice(lastIdx, i), "\\").concat(str.charAt(i)); + lastIdx = i + 1; + } + } + return ret.length > 0 ? ret + str.slice(lastIdx) : str; +} diff --git a/igv_component/node_modules/css-what/lib/commonjs/types.d.ts b/igv_component/node_modules/css-what/lib/commonjs/types.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6eedca46cf46bb86698a3ea1d66f54dd8d0476c1 --- /dev/null +++ b/igv_component/node_modules/css-what/lib/commonjs/types.d.ts @@ -0,0 +1,70 @@ +export declare type Selector = PseudoSelector | PseudoElement | AttributeSelector | TagSelector | UniversalSelector | Traversal; +export declare enum SelectorType { + Attribute = "attribute", + Pseudo = "pseudo", + PseudoElement = "pseudo-element", + Tag = "tag", + Universal = "universal", + Adjacent = "adjacent", + Child = "child", + Descendant = "descendant", + Parent = "parent", + Sibling = "sibling", + ColumnCombinator = "column-combinator" +} +/** + * Modes for ignore case. + * + * This could be updated to an enum, and the object is + * the current stand-in that will allow code to be updated + * without big changes. + */ +export declare const IgnoreCaseMode: { + readonly Unknown: null; + readonly QuirksMode: "quirks"; + readonly IgnoreCase: true; + readonly CaseSensitive: false; +}; +export interface AttributeSelector { + type: SelectorType.Attribute; + name: string; + action: AttributeAction; + value: string; + ignoreCase: "quirks" | boolean | null; + namespace: string | null; +} +export declare type DataType = Selector[][] | null | string; +export interface PseudoSelector { + type: SelectorType.Pseudo; + name: string; + data: DataType; +} +export interface PseudoElement { + type: SelectorType.PseudoElement; + name: string; + data: string | null; +} +export interface TagSelector { + type: SelectorType.Tag; + name: string; + namespace: string | null; +} +export interface UniversalSelector { + type: SelectorType.Universal; + namespace: string | null; +} +export interface Traversal { + type: TraversalType; +} +export declare enum AttributeAction { + Any = "any", + Element = "element", + End = "end", + Equals = "equals", + Exists = "exists", + Hyphen = "hyphen", + Not = "not", + Start = "start" +} +export declare type TraversalType = SelectorType.Adjacent | SelectorType.Child | SelectorType.Descendant | SelectorType.Parent | SelectorType.Sibling | SelectorType.ColumnCombinator; +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/css-what/lib/commonjs/types.d.ts.map b/igv_component/node_modules/css-what/lib/commonjs/types.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..5759e96128d92fa4cf90927c30ed08ed8f11d6eb --- /dev/null +++ b/igv_component/node_modules/css-what/lib/commonjs/types.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ,GACd,cAAc,GACd,aAAa,GACb,iBAAiB,GACjB,WAAW,GACX,iBAAiB,GACjB,SAAS,CAAC;AAEhB,oBAAY,YAAY;IACpB,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,aAAa,mBAAmB;IAChC,GAAG,QAAQ;IACX,SAAS,cAAc;IAGvB,QAAQ,aAAa;IACrB,KAAK,UAAU;IACf,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,gBAAgB,sBAAsB;CACzC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;;;CAKjB,CAAC;AAEX,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,eAAe,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI,CAAC;IACtC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,oBAAY,QAAQ,GAAG,QAAQ,EAAE,EAAE,GAAG,IAAI,GAAG,MAAM,CAAC;AAEpD,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,YAAY,CAAC,aAAa,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,YAAY,CAAC,GAAG,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC;IAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,SAAS;IACtB,IAAI,EAAE,aAAa,CAAC;CACvB;AAED,oBAAY,eAAe;IACvB,GAAG,QAAQ;IACX,OAAO,YAAY;IACnB,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,GAAG,QAAQ;IACX,KAAK,UAAU;CAClB;AAED,oBAAY,aAAa,GACnB,YAAY,CAAC,QAAQ,GACrB,YAAY,CAAC,KAAK,GAClB,YAAY,CAAC,UAAU,GACvB,YAAY,CAAC,MAAM,GACnB,YAAY,CAAC,OAAO,GACpB,YAAY,CAAC,gBAAgB,CAAC"} \ No newline at end of file diff --git a/igv_component/node_modules/css-what/lib/commonjs/types.js b/igv_component/node_modules/css-what/lib/commonjs/types.js new file mode 100644 index 0000000000000000000000000000000000000000..9ad74672c028f8e4d33bbda29b1d52b8170b4dea --- /dev/null +++ b/igv_component/node_modules/css-what/lib/commonjs/types.js @@ -0,0 +1,42 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AttributeAction = exports.IgnoreCaseMode = exports.SelectorType = void 0; +var SelectorType; +(function (SelectorType) { + SelectorType["Attribute"] = "attribute"; + SelectorType["Pseudo"] = "pseudo"; + SelectorType["PseudoElement"] = "pseudo-element"; + SelectorType["Tag"] = "tag"; + SelectorType["Universal"] = "universal"; + // Traversals + SelectorType["Adjacent"] = "adjacent"; + SelectorType["Child"] = "child"; + SelectorType["Descendant"] = "descendant"; + SelectorType["Parent"] = "parent"; + SelectorType["Sibling"] = "sibling"; + SelectorType["ColumnCombinator"] = "column-combinator"; +})(SelectorType = exports.SelectorType || (exports.SelectorType = {})); +/** + * Modes for ignore case. + * + * This could be updated to an enum, and the object is + * the current stand-in that will allow code to be updated + * without big changes. + */ +exports.IgnoreCaseMode = { + Unknown: null, + QuirksMode: "quirks", + IgnoreCase: true, + CaseSensitive: false, +}; +var AttributeAction; +(function (AttributeAction) { + AttributeAction["Any"] = "any"; + AttributeAction["Element"] = "element"; + AttributeAction["End"] = "end"; + AttributeAction["Equals"] = "equals"; + AttributeAction["Exists"] = "exists"; + AttributeAction["Hyphen"] = "hyphen"; + AttributeAction["Not"] = "not"; + AttributeAction["Start"] = "start"; +})(AttributeAction = exports.AttributeAction || (exports.AttributeAction = {})); diff --git a/igv_component/node_modules/css-what/lib/es/index.d.ts b/igv_component/node_modules/css-what/lib/es/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ee9d66e6f1d537ae798891ba1961d6499b0a87bc --- /dev/null +++ b/igv_component/node_modules/css-what/lib/es/index.d.ts @@ -0,0 +1,4 @@ +export * from "./types"; +export { isTraversal, parse } from "./parse"; +export { stringify } from "./stringify"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/css-what/lib/es/index.d.ts.map b/igv_component/node_modules/css-what/lib/es/index.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..8a428b61dad0c37955078081f679c375a34cebb1 --- /dev/null +++ b/igv_component/node_modules/css-what/lib/es/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"} \ No newline at end of file diff --git a/igv_component/node_modules/css-what/lib/es/index.js b/igv_component/node_modules/css-what/lib/es/index.js new file mode 100644 index 0000000000000000000000000000000000000000..1cf4a531c00159300d4efc21a6f7ee424fcbc4a0 --- /dev/null +++ b/igv_component/node_modules/css-what/lib/es/index.js @@ -0,0 +1,3 @@ +export * from "./types"; +export { isTraversal, parse } from "./parse"; +export { stringify } from "./stringify"; diff --git a/igv_component/node_modules/css-what/lib/es/parse.d.ts b/igv_component/node_modules/css-what/lib/es/parse.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1d6e3a21d4348094b3232a4bfea9b660d0706c8f --- /dev/null +++ b/igv_component/node_modules/css-what/lib/es/parse.d.ts @@ -0,0 +1,20 @@ +import { Selector, Traversal } from "./types"; +/** + * Checks whether a specific selector is a traversal. + * This is useful eg. in swapping the order of elements that + * are not traversals. + * + * @param selector Selector to check. + */ +export declare function isTraversal(selector: Selector): selector is Traversal; +/** + * Parses `selector`, optionally with the passed `options`. + * + * @param selector Selector to parse. + * @param options Options for parsing. + * @returns Returns a two-dimensional array. + * The first dimension represents selectors separated by commas (eg. `sub1, sub2`), + * the second contains the relevant tokens for that selector. + */ +export declare function parse(selector: string): Selector[][]; +//# sourceMappingURL=parse.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/css-what/lib/es/parse.d.ts.map b/igv_component/node_modules/css-what/lib/es/parse.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..e4a5b0513efb9199c25fcbade3ca911f14bc2d0a --- /dev/null +++ b/igv_component/node_modules/css-what/lib/es/parse.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EAGR,SAAS,EAIZ,MAAM,SAAS,CAAC;AA6DjB;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,IAAI,SAAS,CAYrE;AAoCD;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,EAAE,CAUpD"} \ No newline at end of file diff --git a/igv_component/node_modules/css-what/lib/es/parse.js b/igv_component/node_modules/css-what/lib/es/parse.js new file mode 100644 index 0000000000000000000000000000000000000000..fe6ea9a4d5b920eb0e3967e1c8eea7a3672dfa48 --- /dev/null +++ b/igv_component/node_modules/css-what/lib/es/parse.js @@ -0,0 +1,420 @@ +import { SelectorType, AttributeAction, } from "./types"; +const reName = /^[^\\#]?(?:\\(?:[\da-f]{1,6}\s?|.)|[\w\-\u00b0-\uFFFF])+/; +const reEscape = /\\([\da-f]{1,6}\s?|(\s)|.)/gi; +const actionTypes = new Map([ + [126 /* Tilde */, AttributeAction.Element], + [94 /* Circumflex */, AttributeAction.Start], + [36 /* Dollar */, AttributeAction.End], + [42 /* Asterisk */, AttributeAction.Any], + [33 /* ExclamationMark */, AttributeAction.Not], + [124 /* Pipe */, AttributeAction.Hyphen], +]); +// Pseudos, whose data property is parsed as well. +const unpackPseudos = new Set([ + "has", + "not", + "matches", + "is", + "where", + "host", + "host-context", +]); +/** + * Checks whether a specific selector is a traversal. + * This is useful eg. in swapping the order of elements that + * are not traversals. + * + * @param selector Selector to check. + */ +export function isTraversal(selector) { + switch (selector.type) { + case SelectorType.Adjacent: + case SelectorType.Child: + case SelectorType.Descendant: + case SelectorType.Parent: + case SelectorType.Sibling: + case SelectorType.ColumnCombinator: + return true; + default: + return false; + } +} +const stripQuotesFromPseudos = new Set(["contains", "icontains"]); +// Unescape function taken from https://github.com/jquery/sizzle/blob/master/src/sizzle.js#L152 +function funescape(_, escaped, escapedWhitespace) { + const high = parseInt(escaped, 16) - 0x10000; + // NaN means non-codepoint + return high !== high || escapedWhitespace + ? escaped + : high < 0 + ? // BMP codepoint + String.fromCharCode(high + 0x10000) + : // Supplemental Plane codepoint (surrogate pair) + String.fromCharCode((high >> 10) | 0xd800, (high & 0x3ff) | 0xdc00); +} +function unescapeCSS(str) { + return str.replace(reEscape, funescape); +} +function isQuote(c) { + return c === 39 /* SingleQuote */ || c === 34 /* DoubleQuote */; +} +function isWhitespace(c) { + return (c === 32 /* Space */ || + c === 9 /* Tab */ || + c === 10 /* NewLine */ || + c === 12 /* FormFeed */ || + c === 13 /* CarriageReturn */); +} +/** + * Parses `selector`, optionally with the passed `options`. + * + * @param selector Selector to parse. + * @param options Options for parsing. + * @returns Returns a two-dimensional array. + * The first dimension represents selectors separated by commas (eg. `sub1, sub2`), + * the second contains the relevant tokens for that selector. + */ +export function parse(selector) { + const subselects = []; + const endIndex = parseSelector(subselects, `${selector}`, 0); + if (endIndex < selector.length) { + throw new Error(`Unmatched selector: ${selector.slice(endIndex)}`); + } + return subselects; +} +function parseSelector(subselects, selector, selectorIndex) { + let tokens = []; + function getName(offset) { + const match = selector.slice(selectorIndex + offset).match(reName); + if (!match) { + throw new Error(`Expected name, found ${selector.slice(selectorIndex)}`); + } + const [name] = match; + selectorIndex += offset + name.length; + return unescapeCSS(name); + } + function stripWhitespace(offset) { + selectorIndex += offset; + while (selectorIndex < selector.length && + isWhitespace(selector.charCodeAt(selectorIndex))) { + selectorIndex++; + } + } + function readValueWithParenthesis() { + selectorIndex += 1; + const start = selectorIndex; + let counter = 1; + for (; counter > 0 && selectorIndex < selector.length; selectorIndex++) { + if (selector.charCodeAt(selectorIndex) === + 40 /* LeftParenthesis */ && + !isEscaped(selectorIndex)) { + counter++; + } + else if (selector.charCodeAt(selectorIndex) === + 41 /* RightParenthesis */ && + !isEscaped(selectorIndex)) { + counter--; + } + } + if (counter) { + throw new Error("Parenthesis not matched"); + } + return unescapeCSS(selector.slice(start, selectorIndex - 1)); + } + function isEscaped(pos) { + let slashCount = 0; + while (selector.charCodeAt(--pos) === 92 /* BackSlash */) + slashCount++; + return (slashCount & 1) === 1; + } + function ensureNotTraversal() { + if (tokens.length > 0 && isTraversal(tokens[tokens.length - 1])) { + throw new Error("Did not expect successive traversals."); + } + } + function addTraversal(type) { + if (tokens.length > 0 && + tokens[tokens.length - 1].type === SelectorType.Descendant) { + tokens[tokens.length - 1].type = type; + return; + } + ensureNotTraversal(); + tokens.push({ type }); + } + function addSpecialAttribute(name, action) { + tokens.push({ + type: SelectorType.Attribute, + name, + action, + value: getName(1), + namespace: null, + ignoreCase: "quirks", + }); + } + /** + * We have finished parsing the current part of the selector. + * + * Remove descendant tokens at the end if they exist, + * and return the last index, so that parsing can be + * picked up from here. + */ + function finalizeSubselector() { + if (tokens.length && + tokens[tokens.length - 1].type === SelectorType.Descendant) { + tokens.pop(); + } + if (tokens.length === 0) { + throw new Error("Empty sub-selector"); + } + subselects.push(tokens); + } + stripWhitespace(0); + if (selector.length === selectorIndex) { + return selectorIndex; + } + loop: while (selectorIndex < selector.length) { + const firstChar = selector.charCodeAt(selectorIndex); + switch (firstChar) { + // Whitespace + case 32 /* Space */: + case 9 /* Tab */: + case 10 /* NewLine */: + case 12 /* FormFeed */: + case 13 /* CarriageReturn */: { + if (tokens.length === 0 || + tokens[0].type !== SelectorType.Descendant) { + ensureNotTraversal(); + tokens.push({ type: SelectorType.Descendant }); + } + stripWhitespace(1); + break; + } + // Traversals + case 62 /* GreaterThan */: { + addTraversal(SelectorType.Child); + stripWhitespace(1); + break; + } + case 60 /* LessThan */: { + addTraversal(SelectorType.Parent); + stripWhitespace(1); + break; + } + case 126 /* Tilde */: { + addTraversal(SelectorType.Sibling); + stripWhitespace(1); + break; + } + case 43 /* Plus */: { + addTraversal(SelectorType.Adjacent); + stripWhitespace(1); + break; + } + // Special attribute selectors: .class, #id + case 46 /* Period */: { + addSpecialAttribute("class", AttributeAction.Element); + break; + } + case 35 /* Hash */: { + addSpecialAttribute("id", AttributeAction.Equals); + break; + } + case 91 /* LeftSquareBracket */: { + stripWhitespace(1); + // Determine attribute name and namespace + let name; + let namespace = null; + if (selector.charCodeAt(selectorIndex) === 124 /* Pipe */) { + // Equivalent to no namespace + name = getName(1); + } + else if (selector.startsWith("*|", selectorIndex)) { + namespace = "*"; + name = getName(2); + } + else { + name = getName(0); + if (selector.charCodeAt(selectorIndex) === 124 /* Pipe */ && + selector.charCodeAt(selectorIndex + 1) !== + 61 /* Equal */) { + namespace = name; + name = getName(1); + } + } + stripWhitespace(0); + // Determine comparison operation + let action = AttributeAction.Exists; + const possibleAction = actionTypes.get(selector.charCodeAt(selectorIndex)); + if (possibleAction) { + action = possibleAction; + if (selector.charCodeAt(selectorIndex + 1) !== + 61 /* Equal */) { + throw new Error("Expected `=`"); + } + stripWhitespace(2); + } + else if (selector.charCodeAt(selectorIndex) === 61 /* Equal */) { + action = AttributeAction.Equals; + stripWhitespace(1); + } + // Determine value + let value = ""; + let ignoreCase = null; + if (action !== "exists") { + if (isQuote(selector.charCodeAt(selectorIndex))) { + const quote = selector.charCodeAt(selectorIndex); + let sectionEnd = selectorIndex + 1; + while (sectionEnd < selector.length && + (selector.charCodeAt(sectionEnd) !== quote || + isEscaped(sectionEnd))) { + sectionEnd += 1; + } + if (selector.charCodeAt(sectionEnd) !== quote) { + throw new Error("Attribute value didn't end"); + } + value = unescapeCSS(selector.slice(selectorIndex + 1, sectionEnd)); + selectorIndex = sectionEnd + 1; + } + else { + const valueStart = selectorIndex; + while (selectorIndex < selector.length && + ((!isWhitespace(selector.charCodeAt(selectorIndex)) && + selector.charCodeAt(selectorIndex) !== + 93 /* RightSquareBracket */) || + isEscaped(selectorIndex))) { + selectorIndex += 1; + } + value = unescapeCSS(selector.slice(valueStart, selectorIndex)); + } + stripWhitespace(0); + // See if we have a force ignore flag + const forceIgnore = selector.charCodeAt(selectorIndex) | 0x20; + // If the forceIgnore flag is set (either `i` or `s`), use that value + if (forceIgnore === 115 /* LowerS */) { + ignoreCase = false; + stripWhitespace(1); + } + else if (forceIgnore === 105 /* LowerI */) { + ignoreCase = true; + stripWhitespace(1); + } + } + if (selector.charCodeAt(selectorIndex) !== + 93 /* RightSquareBracket */) { + throw new Error("Attribute selector didn't terminate"); + } + selectorIndex += 1; + const attributeSelector = { + type: SelectorType.Attribute, + name, + action, + value, + namespace, + ignoreCase, + }; + tokens.push(attributeSelector); + break; + } + case 58 /* Colon */: { + if (selector.charCodeAt(selectorIndex + 1) === 58 /* Colon */) { + tokens.push({ + type: SelectorType.PseudoElement, + name: getName(2).toLowerCase(), + data: selector.charCodeAt(selectorIndex) === + 40 /* LeftParenthesis */ + ? readValueWithParenthesis() + : null, + }); + continue; + } + const name = getName(1).toLowerCase(); + let data = null; + if (selector.charCodeAt(selectorIndex) === + 40 /* LeftParenthesis */) { + if (unpackPseudos.has(name)) { + if (isQuote(selector.charCodeAt(selectorIndex + 1))) { + throw new Error(`Pseudo-selector ${name} cannot be quoted`); + } + data = []; + selectorIndex = parseSelector(data, selector, selectorIndex + 1); + if (selector.charCodeAt(selectorIndex) !== + 41 /* RightParenthesis */) { + throw new Error(`Missing closing parenthesis in :${name} (${selector})`); + } + selectorIndex += 1; + } + else { + data = readValueWithParenthesis(); + if (stripQuotesFromPseudos.has(name)) { + const quot = data.charCodeAt(0); + if (quot === data.charCodeAt(data.length - 1) && + isQuote(quot)) { + data = data.slice(1, -1); + } + } + data = unescapeCSS(data); + } + } + tokens.push({ type: SelectorType.Pseudo, name, data }); + break; + } + case 44 /* Comma */: { + finalizeSubselector(); + tokens = []; + stripWhitespace(1); + break; + } + default: { + if (selector.startsWith("/*", selectorIndex)) { + const endIndex = selector.indexOf("*/", selectorIndex + 2); + if (endIndex < 0) { + throw new Error("Comment was not terminated"); + } + selectorIndex = endIndex + 2; + // Remove leading whitespace + if (tokens.length === 0) { + stripWhitespace(0); + } + break; + } + let namespace = null; + let name; + if (firstChar === 42 /* Asterisk */) { + selectorIndex += 1; + name = "*"; + } + else if (firstChar === 124 /* Pipe */) { + name = ""; + if (selector.charCodeAt(selectorIndex + 1) === 124 /* Pipe */) { + addTraversal(SelectorType.ColumnCombinator); + stripWhitespace(2); + break; + } + } + else if (reName.test(selector.slice(selectorIndex))) { + name = getName(0); + } + else { + break loop; + } + if (selector.charCodeAt(selectorIndex) === 124 /* Pipe */ && + selector.charCodeAt(selectorIndex + 1) !== 124 /* Pipe */) { + namespace = name; + if (selector.charCodeAt(selectorIndex + 1) === + 42 /* Asterisk */) { + name = "*"; + selectorIndex += 2; + } + else { + name = getName(1); + } + } + tokens.push(name === "*" + ? { type: SelectorType.Universal, namespace } + : { type: SelectorType.Tag, name, namespace }); + } + } + } + finalizeSubselector(); + return selectorIndex; +} diff --git a/igv_component/node_modules/css-what/lib/es/stringify.d.ts b/igv_component/node_modules/css-what/lib/es/stringify.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2883b0c32cff0ebe51caca567bd8d54bda0e840b --- /dev/null +++ b/igv_component/node_modules/css-what/lib/es/stringify.d.ts @@ -0,0 +1,8 @@ +import { Selector } from "./types"; +/** + * Turns `selector` back into a string. + * + * @param selector Selector to stringify. + */ +export declare function stringify(selector: Selector[][]): string; +//# sourceMappingURL=stringify.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/css-what/lib/es/stringify.d.ts.map b/igv_component/node_modules/css-what/lib/es/stringify.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..98f99ca7678aae9e860a5d0571a6654c24a28780 --- /dev/null +++ b/igv_component/node_modules/css-what/lib/es/stringify.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"stringify.d.ts","sourceRoot":"","sources":["../../src/stringify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiC,MAAM,SAAS,CAAC;AA6BlE;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,GAAG,MAAM,CAIxD"} \ No newline at end of file diff --git a/igv_component/node_modules/css-what/lib/es/stringify.js b/igv_component/node_modules/css-what/lib/es/stringify.js new file mode 100644 index 0000000000000000000000000000000000000000..5f3b8ef9f415b10dc72c4c7b98ed87d3a2279d30 --- /dev/null +++ b/igv_component/node_modules/css-what/lib/es/stringify.js @@ -0,0 +1,126 @@ +import { SelectorType, AttributeAction } from "./types"; +const attribValChars = ["\\", '"']; +const pseudoValChars = [...attribValChars, "(", ")"]; +const charsToEscapeInAttributeValue = new Set(attribValChars.map((c) => c.charCodeAt(0))); +const charsToEscapeInPseudoValue = new Set(pseudoValChars.map((c) => c.charCodeAt(0))); +const charsToEscapeInName = new Set([ + ...pseudoValChars, + "~", + "^", + "$", + "*", + "+", + "!", + "|", + ":", + "[", + "]", + " ", + ".", +].map((c) => c.charCodeAt(0))); +/** + * Turns `selector` back into a string. + * + * @param selector Selector to stringify. + */ +export function stringify(selector) { + return selector + .map((token) => token.map(stringifyToken).join("")) + .join(", "); +} +function stringifyToken(token, index, arr) { + switch (token.type) { + // Simple types + case SelectorType.Child: + return index === 0 ? "> " : " > "; + case SelectorType.Parent: + return index === 0 ? "< " : " < "; + case SelectorType.Sibling: + return index === 0 ? "~ " : " ~ "; + case SelectorType.Adjacent: + return index === 0 ? "+ " : " + "; + case SelectorType.Descendant: + return " "; + case SelectorType.ColumnCombinator: + return index === 0 ? "|| " : " || "; + case SelectorType.Universal: + // Return an empty string if the selector isn't needed. + return token.namespace === "*" && + index + 1 < arr.length && + "name" in arr[index + 1] + ? "" + : `${getNamespace(token.namespace)}*`; + case SelectorType.Tag: + return getNamespacedName(token); + case SelectorType.PseudoElement: + return `::${escapeName(token.name, charsToEscapeInName)}${token.data === null + ? "" + : `(${escapeName(token.data, charsToEscapeInPseudoValue)})`}`; + case SelectorType.Pseudo: + return `:${escapeName(token.name, charsToEscapeInName)}${token.data === null + ? "" + : `(${typeof token.data === "string" + ? escapeName(token.data, charsToEscapeInPseudoValue) + : stringify(token.data)})`}`; + case SelectorType.Attribute: { + if (token.name === "id" && + token.action === AttributeAction.Equals && + token.ignoreCase === "quirks" && + !token.namespace) { + return `#${escapeName(token.value, charsToEscapeInName)}`; + } + if (token.name === "class" && + token.action === AttributeAction.Element && + token.ignoreCase === "quirks" && + !token.namespace) { + return `.${escapeName(token.value, charsToEscapeInName)}`; + } + const name = getNamespacedName(token); + if (token.action === AttributeAction.Exists) { + return `[${name}]`; + } + return `[${name}${getActionValue(token.action)}="${escapeName(token.value, charsToEscapeInAttributeValue)}"${token.ignoreCase === null ? "" : token.ignoreCase ? " i" : " s"}]`; + } + } +} +function getActionValue(action) { + switch (action) { + case AttributeAction.Equals: + return ""; + case AttributeAction.Element: + return "~"; + case AttributeAction.Start: + return "^"; + case AttributeAction.End: + return "$"; + case AttributeAction.Any: + return "*"; + case AttributeAction.Not: + return "!"; + case AttributeAction.Hyphen: + return "|"; + case AttributeAction.Exists: + throw new Error("Shouldn't be here"); + } +} +function getNamespacedName(token) { + return `${getNamespace(token.namespace)}${escapeName(token.name, charsToEscapeInName)}`; +} +function getNamespace(namespace) { + return namespace !== null + ? `${namespace === "*" + ? "*" + : escapeName(namespace, charsToEscapeInName)}|` + : ""; +} +function escapeName(str, charsToEscape) { + let lastIdx = 0; + let ret = ""; + for (let i = 0; i < str.length; i++) { + if (charsToEscape.has(str.charCodeAt(i))) { + ret += `${str.slice(lastIdx, i)}\\${str.charAt(i)}`; + lastIdx = i + 1; + } + } + return ret.length > 0 ? ret + str.slice(lastIdx) : str; +} diff --git a/igv_component/node_modules/css-what/lib/es/types.d.ts b/igv_component/node_modules/css-what/lib/es/types.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6eedca46cf46bb86698a3ea1d66f54dd8d0476c1 --- /dev/null +++ b/igv_component/node_modules/css-what/lib/es/types.d.ts @@ -0,0 +1,70 @@ +export declare type Selector = PseudoSelector | PseudoElement | AttributeSelector | TagSelector | UniversalSelector | Traversal; +export declare enum SelectorType { + Attribute = "attribute", + Pseudo = "pseudo", + PseudoElement = "pseudo-element", + Tag = "tag", + Universal = "universal", + Adjacent = "adjacent", + Child = "child", + Descendant = "descendant", + Parent = "parent", + Sibling = "sibling", + ColumnCombinator = "column-combinator" +} +/** + * Modes for ignore case. + * + * This could be updated to an enum, and the object is + * the current stand-in that will allow code to be updated + * without big changes. + */ +export declare const IgnoreCaseMode: { + readonly Unknown: null; + readonly QuirksMode: "quirks"; + readonly IgnoreCase: true; + readonly CaseSensitive: false; +}; +export interface AttributeSelector { + type: SelectorType.Attribute; + name: string; + action: AttributeAction; + value: string; + ignoreCase: "quirks" | boolean | null; + namespace: string | null; +} +export declare type DataType = Selector[][] | null | string; +export interface PseudoSelector { + type: SelectorType.Pseudo; + name: string; + data: DataType; +} +export interface PseudoElement { + type: SelectorType.PseudoElement; + name: string; + data: string | null; +} +export interface TagSelector { + type: SelectorType.Tag; + name: string; + namespace: string | null; +} +export interface UniversalSelector { + type: SelectorType.Universal; + namespace: string | null; +} +export interface Traversal { + type: TraversalType; +} +export declare enum AttributeAction { + Any = "any", + Element = "element", + End = "end", + Equals = "equals", + Exists = "exists", + Hyphen = "hyphen", + Not = "not", + Start = "start" +} +export declare type TraversalType = SelectorType.Adjacent | SelectorType.Child | SelectorType.Descendant | SelectorType.Parent | SelectorType.Sibling | SelectorType.ColumnCombinator; +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/css-what/lib/es/types.d.ts.map b/igv_component/node_modules/css-what/lib/es/types.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..5759e96128d92fa4cf90927c30ed08ed8f11d6eb --- /dev/null +++ b/igv_component/node_modules/css-what/lib/es/types.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ,GACd,cAAc,GACd,aAAa,GACb,iBAAiB,GACjB,WAAW,GACX,iBAAiB,GACjB,SAAS,CAAC;AAEhB,oBAAY,YAAY;IACpB,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,aAAa,mBAAmB;IAChC,GAAG,QAAQ;IACX,SAAS,cAAc;IAGvB,QAAQ,aAAa;IACrB,KAAK,UAAU;IACf,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,gBAAgB,sBAAsB;CACzC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;;;CAKjB,CAAC;AAEX,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,eAAe,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI,CAAC;IACtC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,oBAAY,QAAQ,GAAG,QAAQ,EAAE,EAAE,GAAG,IAAI,GAAG,MAAM,CAAC;AAEpD,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,YAAY,CAAC,aAAa,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,YAAY,CAAC,GAAG,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC;IAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,SAAS;IACtB,IAAI,EAAE,aAAa,CAAC;CACvB;AAED,oBAAY,eAAe;IACvB,GAAG,QAAQ;IACX,OAAO,YAAY;IACnB,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,GAAG,QAAQ;IACX,KAAK,UAAU;CAClB;AAED,oBAAY,aAAa,GACnB,YAAY,CAAC,QAAQ,GACrB,YAAY,CAAC,KAAK,GAClB,YAAY,CAAC,UAAU,GACvB,YAAY,CAAC,MAAM,GACnB,YAAY,CAAC,OAAO,GACpB,YAAY,CAAC,gBAAgB,CAAC"} \ No newline at end of file diff --git a/igv_component/node_modules/css-what/lib/es/types.js b/igv_component/node_modules/css-what/lib/es/types.js new file mode 100644 index 0000000000000000000000000000000000000000..a0a33d2192a73a86de614da93aca8b90dd1259af --- /dev/null +++ b/igv_component/node_modules/css-what/lib/es/types.js @@ -0,0 +1,39 @@ +export var SelectorType; +(function (SelectorType) { + SelectorType["Attribute"] = "attribute"; + SelectorType["Pseudo"] = "pseudo"; + SelectorType["PseudoElement"] = "pseudo-element"; + SelectorType["Tag"] = "tag"; + SelectorType["Universal"] = "universal"; + // Traversals + SelectorType["Adjacent"] = "adjacent"; + SelectorType["Child"] = "child"; + SelectorType["Descendant"] = "descendant"; + SelectorType["Parent"] = "parent"; + SelectorType["Sibling"] = "sibling"; + SelectorType["ColumnCombinator"] = "column-combinator"; +})(SelectorType || (SelectorType = {})); +/** + * Modes for ignore case. + * + * This could be updated to an enum, and the object is + * the current stand-in that will allow code to be updated + * without big changes. + */ +export const IgnoreCaseMode = { + Unknown: null, + QuirksMode: "quirks", + IgnoreCase: true, + CaseSensitive: false, +}; +export var AttributeAction; +(function (AttributeAction) { + AttributeAction["Any"] = "any"; + AttributeAction["Element"] = "element"; + AttributeAction["End"] = "end"; + AttributeAction["Equals"] = "equals"; + AttributeAction["Exists"] = "exists"; + AttributeAction["Hyphen"] = "hyphen"; + AttributeAction["Not"] = "not"; + AttributeAction["Start"] = "start"; +})(AttributeAction || (AttributeAction = {})); diff --git a/igv_component/node_modules/css-what/package.json b/igv_component/node_modules/css-what/package.json new file mode 100644 index 0000000000000000000000000000000000000000..8aa2c44a22b7300c3294c92ddcdc4af2472b548d --- /dev/null +++ b/igv_component/node_modules/css-what/package.json @@ -0,0 +1,59 @@ +{ + "author": "Felix Böhm (http://feedic.com)", + "name": "css-what", + "description": "a CSS selector parser", + "version": "6.1.0", + "funding": { + "url": "https://github.com/sponsors/fb55" + }, + "repository": { + "type": "git", + "url": "https://github.com/fb55/css-what" + }, + "main": "lib/commonjs/index.js", + "module": "lib/es/index.js", + "types": "lib/es/index.d.ts", + "sideEffects": false, + "files": [ + "lib/**/*" + ], + "scripts": { + "test": "npm run test:jest && npm run lint", + "test:jest": "jest", + "lint": "npm run lint:es && npm run lint:prettier", + "lint:es": "eslint src", + "lint:prettier": "npm run prettier -- --check", + "format": "npm run format:es && npm run format:prettier", + "format:es": "npm run lint:es -- --fix", + "format:prettier": "npm run prettier -- --write", + "prettier": "prettier '**/*.{ts,md,json,yml}'", + "build": "tsc && tsc -p tsconfig.es.json", + "prepare": "npm run build" + }, + "devDependencies": { + "@types/jest": "^27.4.1", + "@types/node": "^17.0.23", + "@typescript-eslint/eslint-plugin": "^5.17.0", + "@typescript-eslint/parser": "^5.17.0", + "eslint": "^8.12.0", + "eslint-config-prettier": "^8.5.0", + "eslint-plugin-node": "^11.1.0", + "jest": "^27.5.1", + "prettier": "^2.6.1", + "ts-jest": "^27.1.4", + "typescript": "^4.6.3" + }, + "engines": { + "node": ">= 6" + }, + "license": "BSD-2-Clause", + "jest": { + "preset": "ts-jest", + "roots": [ + "src" + ] + }, + "prettier": { + "tabWidth": 4 + } +} diff --git a/igv_component/node_modules/css-what/readme.md b/igv_component/node_modules/css-what/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..0c4a198c2f95735f733bfa43cc76d940fe87ee71 --- /dev/null +++ b/igv_component/node_modules/css-what/readme.md @@ -0,0 +1,69 @@ +# css-what + +[![Build Status](https://img.shields.io/github/workflow/status/fb55/css-what/Node.js%20CI/master)](https://github.com/fb55/css-what/actions/workflows/nodejs-test.yml) +[![Coverage](https://img.shields.io/coveralls/github/fb55/css-what/master)](https://coveralls.io/github/fb55/css-what?branch=master) + +A CSS selector parser. + +## Example + +```js +import * as CSSwhat from "css-what"; + +CSSwhat.parse("foo[bar]:baz") + +~> [ + [ + { type: "tag", name: "foo" }, + { + type: "attribute", + name: "bar", + action: "exists", + value: "", + ignoreCase: null + }, + { type: "pseudo", name: "baz", data: null } + ] +] +``` + +## API + +**`CSSwhat.parse(selector)` - Parses `selector`.** + +The function returns a two-dimensional array. The first array represents selectors separated by commas (eg. `sub1, sub2`), the second contains the relevant tokens for that selector. Possible token types are: + +| name | properties | example | output | +| ------------------- | --------------------------------------- | ------------- | ---------------------------------------------------------------------------------------- | +| `tag` | `name` | `div` | `{ type: 'tag', name: 'div' }` | +| `universal` | - | `*` | `{ type: 'universal' }` | +| `pseudo` | `name`, `data` | `:name(data)` | `{ type: 'pseudo', name: 'name', data: 'data' }` | +| `pseudo` | `name`, `data` | `:name` | `{ type: 'pseudo', name: 'name', data: null }` | +| `pseudo-element` | `name` | `::name` | `{ type: 'pseudo-element', name: 'name' }` | +| `attribute` | `name`, `action`, `value`, `ignoreCase` | `[attr]` | `{ type: 'attribute', name: 'attr', action: 'exists', value: '', ignoreCase: false }` | +| `attribute` | `name`, `action`, `value`, `ignoreCase` | `[attr=val]` | `{ type: 'attribute', name: 'attr', action: 'equals', value: 'val', ignoreCase: false }` | +| `attribute` | `name`, `action`, `value`, `ignoreCase` | `[attr^=val]` | `{ type: 'attribute', name: 'attr', action: 'start', value: 'val', ignoreCase: false }` | +| `attribute` | `name`, `action`, `value`, `ignoreCase` | `[attr$=val]` | `{ type: 'attribute', name: 'attr', action: 'end', value: 'val', ignoreCase: false }` | +| `child` | - | `>` | `{ type: 'child' }` | +| `parent` | - | `<` | `{ type: 'parent' }` | +| `sibling` | - | `~` | `{ type: 'sibling' }` | +| `adjacent` | - | `+` | `{ type: 'adjacent' }` | +| `descendant` | - | | `{ type: 'descendant' }` | +| `column-combinator` | - | `\|\|` | `{ type: 'column-combinator' }` | + +**`CSSwhat.stringify(selector)` - Turns `selector` back into a string.** + +--- + +License: BSD-2-Clause + +## Security contact information + +To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). +Tidelift will coordinate the fix and disclosure. + +## `css-what` for enterprise + +Available as part of the Tidelift Subscription + +The maintainers of `css-what` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-css-what?utm_source=npm-css-what&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) diff --git a/igv_component/node_modules/dom-converter/LICENSE b/igv_component/node_modules/dom-converter/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..0641f709bc298fe6d21828f689a6d6da6364396d --- /dev/null +++ b/igv_component/node_modules/dom-converter/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2013 Aria Minaei + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/igv_component/node_modules/dom-converter/README.md b/igv_component/node_modules/dom-converter/README.md new file mode 100644 index 0000000000000000000000000000000000000000..ccc687514c22becf287fd33cc943793cdaab528d --- /dev/null +++ b/igv_component/node_modules/dom-converter/README.md @@ -0,0 +1,3 @@ +Converts bare objects to DOM objects, compatible with htmlparser2's DOM objects. + +This is useful when you want to work with DOM without having to compose/parse html. \ No newline at end of file diff --git a/igv_component/node_modules/dom-converter/lib/domConverter.js b/igv_component/node_modules/dom-converter/lib/domConverter.js new file mode 100644 index 0000000000000000000000000000000000000000..60ee21d99512478aeaf85c8b8f010a3839893561 --- /dev/null +++ b/igv_component/node_modules/dom-converter/lib/domConverter.js @@ -0,0 +1,33 @@ +// Generated by CoffeeScript 1.12.7 +var domToMarkup, object, objectToSaneObject, saneObjectToDom, self; + +objectToSaneObject = require('./objectToSaneObject'); + +saneObjectToDom = require('./saneObjectToDom'); + +domToMarkup = require('./domToMarkup'); + +object = require('utila').object; + +module.exports = self = { + objectToDom: function(o) { + o = self._object2SaneObject(o); + return saneObjectToDom.convert(o); + }, + object2markup: function(o) { + var dom; + dom = self.objectToDom(o); + return domToMarkup.convert(dom); + }, + domToMarkup: function(dom) { + return domToMarkup.convert(dom); + }, + _object2SaneObject: function(o) { + if (!Array.isArray(o)) { + if (!object.isBareObject(o)) { + throw Error("toDom() only accepts arrays and bare objects as input"); + } + } + return objectToSaneObject.sanitize(o); + } +}; diff --git a/igv_component/node_modules/dom-converter/lib/domToMarkup.js b/igv_component/node_modules/dom-converter/lib/domToMarkup.js new file mode 100644 index 0000000000000000000000000000000000000000..fe17fb06fa0a0dfbe598ecfd27b1f0bcf3857a1e --- /dev/null +++ b/igv_component/node_modules/dom-converter/lib/domToMarkup.js @@ -0,0 +1,2 @@ +// Generated by CoffeeScript 1.12.7 + diff --git a/igv_component/node_modules/dom-converter/lib/objectToSaneObject.js b/igv_component/node_modules/dom-converter/lib/objectToSaneObject.js new file mode 100644 index 0000000000000000000000000000000000000000..d87d2d5c624a72c36d318a87626fb7a9b18840f4 --- /dev/null +++ b/igv_component/node_modules/dom-converter/lib/objectToSaneObject.js @@ -0,0 +1,63 @@ +// Generated by CoffeeScript 1.12.7 +var object, self, + hasProp = {}.hasOwnProperty; + +object = require('utila').object; + +module.exports = self = { + sanitize: function(val) { + return self._toChildren(val); + }, + _toChildren: function(val) { + var ref; + if (object.isBareObject(val)) { + return self._objectToChildren(val); + } else if (Array.isArray(val)) { + return self._arrayToChildren(val); + } else if (val === null || typeof val === 'undefined') { + return []; + } else if ((ref = typeof val) === 'string' || ref === 'number') { + return [String(val)]; + } else { + throw Error("not a valid child node: `" + val); + } + }, + _objectToChildren: function(o) { + var a, cur, key, val; + a = []; + for (key in o) { + if (!hasProp.call(o, key)) continue; + val = o[key]; + cur = {}; + cur[key] = self.sanitize(val); + a.push(cur); + } + return a; + }, + _arrayToChildren: function(a) { + var i, len, ret, v; + ret = []; + for (i = 0, len = a.length; i < len; i++) { + v = a[i]; + ret.push(self._toNode(v)); + } + return ret; + }, + _toNode: function(o) { + var key, keys, obj, ref; + if ((ref = typeof o) === 'string' || ref === 'number') { + return String(o); + } else if (object.isBareObject(o)) { + keys = Object.keys(o); + if (keys.length !== 1) { + throw Error("a node must only have one key as tag name"); + } + key = keys[0]; + obj = {}; + obj[key] = self._toChildren(o[key]); + return obj; + } else { + throw Error("not a valid node: `" + o + "`"); + } + } +}; diff --git a/igv_component/node_modules/dom-converter/lib/saneObjectToDom.js b/igv_component/node_modules/dom-converter/lib/saneObjectToDom.js new file mode 100644 index 0000000000000000000000000000000000000000..0f94d5f30e21fd7b32afeabda247af547df1931b --- /dev/null +++ b/igv_component/node_modules/dom-converter/lib/saneObjectToDom.js @@ -0,0 +1,114 @@ +// Generated by CoffeeScript 1.12.7 +var self, + hasProp = {}.hasOwnProperty; + +module.exports = self = { + convert: function(obj) { + return self._arrayToChildren(obj); + }, + _arrayToChildren: function(a, parent) { + var children, j, len, node, prev, v; + if (parent == null) { + parent = null; + } + children = []; + prev = null; + for (j = 0, len = a.length; j < len; j++) { + v = a[j]; + if (typeof v === 'string') { + node = self._getTextNodeFor(v); + } else { + node = self._objectToNode(v, parent); + node.prev = null; + node.next = null; + node.parent = parent; + if (prev != null) { + node.prev = prev; + prev.next = node; + } + prev = node; + } + children.push(node); + } + return children; + }, + _objectToNode: function(o) { + var attribs, children, i, k, key, name, node, ref, v, val; + i = 0; + for (k in o) { + if (!hasProp.call(o, k)) continue; + v = o[k]; + if (i > 0) { + throw Error("_objectToNode() only accepts an object with one key/value"); + } + key = k; + val = v; + i++; + } + node = {}; + if (typeof key !== 'string') { + throw Error("_objectToNode()'s key must be a string of tag name and classes"); + } + if (typeof val === 'string') { + children = [self._getTextNodeFor(val)]; + } else if (Array.isArray(val)) { + children = self._arrayToChildren(val, node); + } else { + inspect(o); + throw Error("_objectToNode()'s key's value must only be a string or an array"); + } + node.type = 'tag'; + ref = self._parseTag(key), name = ref.name, attribs = ref.attribs; + node.name = name; + node.attribs = attribs; + node.children = children; + return node; + }, + _getTextNodeFor: function(s) { + return { + type: 'text', + data: s + }; + }, + _nameRx: /^[a-zA-Z\-\_]{1}[a-zA-Z0-9\-\_]*$/, + _parseTag: function(k) { + var attribs, classes, cls, id, m, name, parts; + if (!k.match(/^[a-zA-Z0-9\#\-\_\.\[\]\"\'\=\,\s]+$/) || k.match(/^[0-9]+/)) { + throw Error("cannot parse tag `" + k + "`"); + } + attribs = {}; + parts = { + name: '', + attribs: attribs + }; + if (m = k.match(/^([^\.#]+)/)) { + name = m[1]; + if (!name.match(self._nameRx)) { + throw Error("tag name `" + name + "` is not valid"); + } + parts.name = name; + k = k.substr(name.length, k.length); + } + if (m = k.match(/^#([a-zA-Z0-9\-]+)/)) { + id = m[1]; + if (!id.match(self._nameRx)) { + throw Error("tag id `" + id + "` is not valid"); + } + attribs.id = id; + k = k.substr(id.length + 1, k.length); + } + classes = []; + while (m = k.match(/\.([a-zA-Z0-9\-\_]+)/)) { + cls = m[1]; + if (!cls.match(self._nameRx)) { + throw Error("tag class `" + cls + "` is not valid"); + } + classes.push(cls); + k = k.replace('.' + cls, ''); + } + if (classes.length) { + attribs["class"] = classes.join(" "); + } + return parts; + } +}; diff --git a/igv_component/node_modules/dom-converter/package.json b/igv_component/node_modules/dom-converter/package.json new file mode 100644 index 0000000000000000000000000000000000000000..cbf6f40462a190b1fc7c85864f3c7377ac855934 --- /dev/null +++ b/igv_component/node_modules/dom-converter/package.json @@ -0,0 +1,38 @@ +{ + "name": "dom-converter", + "version": "0.2.0", + "description": "converts bare objects to DOM objects or xml representations", + "main": "lib/domConverter.js", + "dependencies": { + "utila": "~0.4" + }, + "devDependencies": { + "chai": "^1.10.0", + "chai-changes": "^1.3.4", + "chai-fuzzy": "^1.4.0", + "coffee-script": "^1.8.0", + "jitter": "^1.3.0", + "mocha": "^2.0.1", + "mocha-pretty-spec-reporter": "0.1.0-beta.1", + "sinon": "^1.12.2", + "sinon-chai": "^2.6.0" + }, + "scripts": { + "test": "mocha \"test/**/*.coffee\"", + "test:watch": "mocha \"test/**/*.coffee\" --watch", + "compile": "coffee --bare --compile --output ./lib ./src", + "compile:watch": "jitter src lib -b", + "watch": "npm run compile:watch & npm run test:watch", + "winwatch": "start/b npm run compile:watch & npm run test:watch", + "prepublish": "npm run compile" + }, + "author": "Aria Minaei", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/AriaMinaei/dom-converter" + }, + "bugs": { + "url": "https://github.com/AriaMinaei/dom-converter/issues" + } +} diff --git a/igv_component/node_modules/dom-serializer/LICENSE b/igv_component/node_modules/dom-serializer/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..3d241a8d091f77c40b752cbdd40290084d6107af --- /dev/null +++ b/igv_component/node_modules/dom-serializer/LICENSE @@ -0,0 +1,11 @@ +License + +(The MIT License) + +Copyright (c) 2014 The cheeriojs contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/igv_component/node_modules/dom-serializer/README.md b/igv_component/node_modules/dom-serializer/README.md new file mode 100644 index 0000000000000000000000000000000000000000..9ef0eecc9e7bf3a7300fad514749b4f76a6b0d05 --- /dev/null +++ b/igv_component/node_modules/dom-serializer/README.md @@ -0,0 +1,97 @@ +# dom-serializer [![Build Status](https://travis-ci.com/cheeriojs/dom-serializer.svg?branch=master)](https://travis-ci.com/cheeriojs/dom-serializer) + +Renders a [domhandler](https://github.com/fb55/domhandler) DOM node or an array of domhandler DOM nodes to a string. + +```js +import render from "dom-serializer"; + +// OR + +const render = require("dom-serializer").default; +``` + +# API + +## `render` + +▸ **render**(`node`: Node \| Node[], `options?`: [_Options_](#Options)): _string_ + +Renders a DOM node or an array of DOM nodes to a string. + +Can be thought of as the equivalent of the `outerHTML` of the passed node(s). + +#### Parameters: + +| Name | Type | Default value | Description | +| :-------- | :--------------------------------- | :------------ | :----------------------------- | +| `node` | Node \| Node[] | - | Node to be rendered. | +| `options` | [_DomSerializerOptions_](#Options) | {} | Changes serialization behavior | + +**Returns:** _string_ + +## Options + +### `decodeEntities` + +• `Optional` **decodeEntities**: _boolean_ + +Encode characters that are either reserved in HTML or XML, or are outside of the ASCII range. + +**`default`** true + +--- + +### `emptyAttrs` + +• `Optional` **emptyAttrs**: _boolean_ + +Print an empty attribute's value. + +**`default`** xmlMode + +**`example`** With emptyAttrs: false: <input checked> + +**`example`** With emptyAttrs: true: <input checked=""> + +--- + +### `selfClosingTags` + +• `Optional` **selfClosingTags**: _boolean_ + +Print self-closing tags for tags without contents. + +**`default`** xmlMode + +**`example`** With selfClosingTags: false: <foo></foo> + +**`example`** With selfClosingTags: true: <foo /> + +--- + +### `xmlMode` + +• `Optional` **xmlMode**: _boolean_ \| _"foreign"_ + +Treat the input as an XML document; enables the `emptyAttrs` and `selfClosingTags` options. + +If the value is `"foreign"`, it will try to correct mixed-case attribute names. + +**`default`** false + +--- + +## Ecosystem + +| Name | Description | +| ------------------------------------------------------------- | ------------------------------------------------------- | +| [htmlparser2](https://github.com/fb55/htmlparser2) | Fast & forgiving HTML/XML parser | +| [domhandler](https://github.com/fb55/domhandler) | Handler for htmlparser2 that turns documents into a DOM | +| [domutils](https://github.com/fb55/domutils) | Utilities for working with domhandler's DOM | +| [css-select](https://github.com/fb55/css-select) | CSS selector engine, compatible with domhandler's DOM | +| [cheerio](https://github.com/cheeriojs/cheerio) | The jQuery API for domhandler's DOM | +| [dom-serializer](https://github.com/cheeriojs/dom-serializer) | Serializer for domhandler's DOM | + +--- + +LICENSE: MIT diff --git a/igv_component/node_modules/dom-serializer/lib/esm/foreignNames.d.ts b/igv_component/node_modules/dom-serializer/lib/esm/foreignNames.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a8b09380ffe95decabf6248b1b50074a4c4a90ca --- /dev/null +++ b/igv_component/node_modules/dom-serializer/lib/esm/foreignNames.d.ts @@ -0,0 +1,3 @@ +export declare const elementNames: Map; +export declare const attributeNames: Map; +//# sourceMappingURL=foreignNames.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/dom-serializer/lib/esm/foreignNames.d.ts.map b/igv_component/node_modules/dom-serializer/lib/esm/foreignNames.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..f471fd0c8c992ee5235f87e940db5556e8f46772 --- /dev/null +++ b/igv_component/node_modules/dom-serializer/lib/esm/foreignNames.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"foreignNames.d.ts","sourceRoot":"","sources":["../../src/foreignNames.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,qBAwCxB,CAAC;AACF,eAAO,MAAM,cAAc,qBA8D1B,CAAC"} \ No newline at end of file diff --git a/igv_component/node_modules/dom-serializer/lib/esm/foreignNames.js b/igv_component/node_modules/dom-serializer/lib/esm/foreignNames.js new file mode 100644 index 0000000000000000000000000000000000000000..ebd627283f665c670e8ee76aefa1fc8e024c4daf --- /dev/null +++ b/igv_component/node_modules/dom-serializer/lib/esm/foreignNames.js @@ -0,0 +1,100 @@ +export const elementNames = new Map([ + "altGlyph", + "altGlyphDef", + "altGlyphItem", + "animateColor", + "animateMotion", + "animateTransform", + "clipPath", + "feBlend", + "feColorMatrix", + "feComponentTransfer", + "feComposite", + "feConvolveMatrix", + "feDiffuseLighting", + "feDisplacementMap", + "feDistantLight", + "feDropShadow", + "feFlood", + "feFuncA", + "feFuncB", + "feFuncG", + "feFuncR", + "feGaussianBlur", + "feImage", + "feMerge", + "feMergeNode", + "feMorphology", + "feOffset", + "fePointLight", + "feSpecularLighting", + "feSpotLight", + "feTile", + "feTurbulence", + "foreignObject", + "glyphRef", + "linearGradient", + "radialGradient", + "textPath", +].map((val) => [val.toLowerCase(), val])); +export const attributeNames = new Map([ + "definitionURL", + "attributeName", + "attributeType", + "baseFrequency", + "baseProfile", + "calcMode", + "clipPathUnits", + "diffuseConstant", + "edgeMode", + "filterUnits", + "glyphRef", + "gradientTransform", + "gradientUnits", + "kernelMatrix", + "kernelUnitLength", + "keyPoints", + "keySplines", + "keyTimes", + "lengthAdjust", + "limitingConeAngle", + "markerHeight", + "markerUnits", + "markerWidth", + "maskContentUnits", + "maskUnits", + "numOctaves", + "pathLength", + "patternContentUnits", + "patternTransform", + "patternUnits", + "pointsAtX", + "pointsAtY", + "pointsAtZ", + "preserveAlpha", + "preserveAspectRatio", + "primitiveUnits", + "refX", + "refY", + "repeatCount", + "repeatDur", + "requiredExtensions", + "requiredFeatures", + "specularConstant", + "specularExponent", + "spreadMethod", + "startOffset", + "stdDeviation", + "stitchTiles", + "surfaceScale", + "systemLanguage", + "tableValues", + "targetX", + "targetY", + "textLength", + "viewBox", + "viewTarget", + "xChannelSelector", + "yChannelSelector", + "zoomAndPan", +].map((val) => [val.toLowerCase(), val])); diff --git a/igv_component/node_modules/dom-serializer/lib/esm/index.d.ts b/igv_component/node_modules/dom-serializer/lib/esm/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cdf04f0693d17a3a8b6a3740326711ea70060d98 --- /dev/null +++ b/igv_component/node_modules/dom-serializer/lib/esm/index.d.ts @@ -0,0 +1,52 @@ +import type { AnyNode } from "domhandler"; +export interface DomSerializerOptions { + /** + * Print an empty attribute's value. + * + * @default xmlMode + * @example With emptyAttrs: false: <input checked> + * @example With emptyAttrs: true: <input checked=""> + */ + emptyAttrs?: boolean; + /** + * Print self-closing tags for tags without contents. + * + * @default xmlMode + * @example With selfClosingTags: false: <foo></foo> + * @example With selfClosingTags: true: <foo /> + */ + selfClosingTags?: boolean; + /** + * Treat the input as an XML document; enables the `emptyAttrs` and `selfClosingTags` options. + * + * If the value is `"foreign"`, it will try to correct mixed-case attribute names. + * + * @default false + */ + xmlMode?: boolean | "foreign"; + /** + * Encode characters that are either reserved in HTML or XML. + * + * If `xmlMode` is `true` or the value not `'utf8'`, characters outside of the utf8 range will be encoded as well. + * + * @default `decodeEntities` + */ + encodeEntities?: boolean | "utf8"; + /** + * Option inherited from parsing; will be used as the default value for `encodeEntities`. + * + * @default true + */ + decodeEntities?: boolean; +} +/** + * Renders a DOM node or an array of DOM nodes to a string. + * + * Can be thought of as the equivalent of the `outerHTML` of the passed node(s). + * + * @param node Node to be rendered. + * @param options Changes serialization behavior + */ +export declare function render(node: AnyNode | ArrayLike, options?: DomSerializerOptions): string; +export default render; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/dom-serializer/lib/esm/index.d.ts.map b/igv_component/node_modules/dom-serializer/lib/esm/index.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..0476a46fb65f6fa27f1e30b76a6e91373c924026 --- /dev/null +++ b/igv_component/node_modules/dom-serializer/lib/esm/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,OAAO,EAMR,MAAM,YAAY,CAAC;AAWpB,MAAM,WAAW,oBAAoB;IACnC;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAClC;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AA4ED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,EAClC,OAAO,GAAE,oBAAyB,GACjC,MAAM,CAUR;AAED,eAAe,MAAM,CAAC"} \ No newline at end of file diff --git a/igv_component/node_modules/dom-serializer/lib/esm/index.js b/igv_component/node_modules/dom-serializer/lib/esm/index.js new file mode 100644 index 0000000000000000000000000000000000000000..1ccc9d54918dfaa20692f46af33255e58b732094 --- /dev/null +++ b/igv_component/node_modules/dom-serializer/lib/esm/index.js @@ -0,0 +1,190 @@ +/* + * Module dependencies + */ +import * as ElementType from "domelementtype"; +import { encodeXML, escapeAttribute, escapeText } from "entities"; +/** + * Mixed-case SVG and MathML tags & attributes + * recognized by the HTML parser. + * + * @see https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inforeign + */ +import { elementNames, attributeNames } from "./foreignNames.js"; +const unencodedElements = new Set([ + "style", + "script", + "xmp", + "iframe", + "noembed", + "noframes", + "plaintext", + "noscript", +]); +function replaceQuotes(value) { + return value.replace(/"/g, """); +} +/** + * Format attributes + */ +function formatAttributes(attributes, opts) { + var _a; + if (!attributes) + return; + const encode = ((_a = opts.encodeEntities) !== null && _a !== void 0 ? _a : opts.decodeEntities) === false + ? replaceQuotes + : opts.xmlMode || opts.encodeEntities !== "utf8" + ? encodeXML + : escapeAttribute; + return Object.keys(attributes) + .map((key) => { + var _a, _b; + const value = (_a = attributes[key]) !== null && _a !== void 0 ? _a : ""; + if (opts.xmlMode === "foreign") { + /* Fix up mixed-case attribute names */ + key = (_b = attributeNames.get(key)) !== null && _b !== void 0 ? _b : key; + } + if (!opts.emptyAttrs && !opts.xmlMode && value === "") { + return key; + } + return `${key}="${encode(value)}"`; + }) + .join(" "); +} +/** + * Self-enclosing tags + */ +const singleTag = new Set([ + "area", + "base", + "basefont", + "br", + "col", + "command", + "embed", + "frame", + "hr", + "img", + "input", + "isindex", + "keygen", + "link", + "meta", + "param", + "source", + "track", + "wbr", +]); +/** + * Renders a DOM node or an array of DOM nodes to a string. + * + * Can be thought of as the equivalent of the `outerHTML` of the passed node(s). + * + * @param node Node to be rendered. + * @param options Changes serialization behavior + */ +export function render(node, options = {}) { + const nodes = "length" in node ? node : [node]; + let output = ""; + for (let i = 0; i < nodes.length; i++) { + output += renderNode(nodes[i], options); + } + return output; +} +export default render; +function renderNode(node, options) { + switch (node.type) { + case ElementType.Root: + return render(node.children, options); + // @ts-expect-error We don't use `Doctype` yet + case ElementType.Doctype: + case ElementType.Directive: + return renderDirective(node); + case ElementType.Comment: + return renderComment(node); + case ElementType.CDATA: + return renderCdata(node); + case ElementType.Script: + case ElementType.Style: + case ElementType.Tag: + return renderTag(node, options); + case ElementType.Text: + return renderText(node, options); + } +} +const foreignModeIntegrationPoints = new Set([ + "mi", + "mo", + "mn", + "ms", + "mtext", + "annotation-xml", + "foreignObject", + "desc", + "title", +]); +const foreignElements = new Set(["svg", "math"]); +function renderTag(elem, opts) { + var _a; + // Handle SVG / MathML in HTML + if (opts.xmlMode === "foreign") { + /* Fix up mixed-case element names */ + elem.name = (_a = elementNames.get(elem.name)) !== null && _a !== void 0 ? _a : elem.name; + /* Exit foreign mode at integration points */ + if (elem.parent && + foreignModeIntegrationPoints.has(elem.parent.name)) { + opts = { ...opts, xmlMode: false }; + } + } + if (!opts.xmlMode && foreignElements.has(elem.name)) { + opts = { ...opts, xmlMode: "foreign" }; + } + let tag = `<${elem.name}`; + const attribs = formatAttributes(elem.attribs, opts); + if (attribs) { + tag += ` ${attribs}`; + } + if (elem.children.length === 0 && + (opts.xmlMode + ? // In XML mode or foreign mode, and user hasn't explicitly turned off self-closing tags + opts.selfClosingTags !== false + : // User explicitly asked for self-closing tags, even in HTML mode + opts.selfClosingTags && singleTag.has(elem.name))) { + if (!opts.xmlMode) + tag += " "; + tag += "/>"; + } + else { + tag += ">"; + if (elem.children.length > 0) { + tag += render(elem.children, opts); + } + if (opts.xmlMode || !singleTag.has(elem.name)) { + tag += ``; + } + } + return tag; +} +function renderDirective(elem) { + return `<${elem.data}>`; +} +function renderText(elem, opts) { + var _a; + let data = elem.data || ""; + // If entities weren't decoded, no need to encode them back + if (((_a = opts.encodeEntities) !== null && _a !== void 0 ? _a : opts.decodeEntities) !== false && + !(!opts.xmlMode && + elem.parent && + unencodedElements.has(elem.parent.name))) { + data = + opts.xmlMode || opts.encodeEntities !== "utf8" + ? encodeXML(data) + : escapeText(data); + } + return data; +} +function renderCdata(elem) { + return ``; +} +function renderComment(elem) { + return ``; +} diff --git a/igv_component/node_modules/dom-serializer/lib/esm/package.json b/igv_component/node_modules/dom-serializer/lib/esm/package.json new file mode 100644 index 0000000000000000000000000000000000000000..089153bcb5adf57dc25f206a9dad3114c9cff80d --- /dev/null +++ b/igv_component/node_modules/dom-serializer/lib/esm/package.json @@ -0,0 +1 @@ +{"type":"module"} diff --git a/igv_component/node_modules/dom-serializer/lib/foreignNames.d.ts b/igv_component/node_modules/dom-serializer/lib/foreignNames.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a8b09380ffe95decabf6248b1b50074a4c4a90ca --- /dev/null +++ b/igv_component/node_modules/dom-serializer/lib/foreignNames.d.ts @@ -0,0 +1,3 @@ +export declare const elementNames: Map; +export declare const attributeNames: Map; +//# sourceMappingURL=foreignNames.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/dom-serializer/lib/foreignNames.d.ts.map b/igv_component/node_modules/dom-serializer/lib/foreignNames.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..50e4f26a55e07148fc960e3a1cda1ad7a8a53465 --- /dev/null +++ b/igv_component/node_modules/dom-serializer/lib/foreignNames.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"foreignNames.d.ts","sourceRoot":"","sources":["../src/foreignNames.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,qBAsCvB,CAAC;AACH,eAAO,MAAM,cAAc,qBA4DzB,CAAC"} \ No newline at end of file diff --git a/igv_component/node_modules/dom-serializer/lib/foreignNames.js b/igv_component/node_modules/dom-serializer/lib/foreignNames.js new file mode 100644 index 0000000000000000000000000000000000000000..966253e0df0ea5b4fe57954cb4bcb7856a8c801a --- /dev/null +++ b/igv_component/node_modules/dom-serializer/lib/foreignNames.js @@ -0,0 +1,103 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.attributeNames = exports.elementNames = void 0; +exports.elementNames = new Map([ + ["altglyph", "altGlyph"], + ["altglyphdef", "altGlyphDef"], + ["altglyphitem", "altGlyphItem"], + ["animatecolor", "animateColor"], + ["animatemotion", "animateMotion"], + ["animatetransform", "animateTransform"], + ["clippath", "clipPath"], + ["feblend", "feBlend"], + ["fecolormatrix", "feColorMatrix"], + ["fecomponenttransfer", "feComponentTransfer"], + ["fecomposite", "feComposite"], + ["feconvolvematrix", "feConvolveMatrix"], + ["fediffuselighting", "feDiffuseLighting"], + ["fedisplacementmap", "feDisplacementMap"], + ["fedistantlight", "feDistantLight"], + ["fedropshadow", "feDropShadow"], + ["feflood", "feFlood"], + ["fefunca", "feFuncA"], + ["fefuncb", "feFuncB"], + ["fefuncg", "feFuncG"], + ["fefuncr", "feFuncR"], + ["fegaussianblur", "feGaussianBlur"], + ["feimage", "feImage"], + ["femerge", "feMerge"], + ["femergenode", "feMergeNode"], + ["femorphology", "feMorphology"], + ["feoffset", "feOffset"], + ["fepointlight", "fePointLight"], + ["fespecularlighting", "feSpecularLighting"], + ["fespotlight", "feSpotLight"], + ["fetile", "feTile"], + ["feturbulence", "feTurbulence"], + ["foreignobject", "foreignObject"], + ["glyphref", "glyphRef"], + ["lineargradient", "linearGradient"], + ["radialgradient", "radialGradient"], + ["textpath", "textPath"], +]); +exports.attributeNames = new Map([ + ["definitionurl", "definitionURL"], + ["attributename", "attributeName"], + ["attributetype", "attributeType"], + ["basefrequency", "baseFrequency"], + ["baseprofile", "baseProfile"], + ["calcmode", "calcMode"], + ["clippathunits", "clipPathUnits"], + ["diffuseconstant", "diffuseConstant"], + ["edgemode", "edgeMode"], + ["filterunits", "filterUnits"], + ["glyphref", "glyphRef"], + ["gradienttransform", "gradientTransform"], + ["gradientunits", "gradientUnits"], + ["kernelmatrix", "kernelMatrix"], + ["kernelunitlength", "kernelUnitLength"], + ["keypoints", "keyPoints"], + ["keysplines", "keySplines"], + ["keytimes", "keyTimes"], + ["lengthadjust", "lengthAdjust"], + ["limitingconeangle", "limitingConeAngle"], + ["markerheight", "markerHeight"], + ["markerunits", "markerUnits"], + ["markerwidth", "markerWidth"], + ["maskcontentunits", "maskContentUnits"], + ["maskunits", "maskUnits"], + ["numoctaves", "numOctaves"], + ["pathlength", "pathLength"], + ["patterncontentunits", "patternContentUnits"], + ["patterntransform", "patternTransform"], + ["patternunits", "patternUnits"], + ["pointsatx", "pointsAtX"], + ["pointsaty", "pointsAtY"], + ["pointsatz", "pointsAtZ"], + ["preservealpha", "preserveAlpha"], + ["preserveaspectratio", "preserveAspectRatio"], + ["primitiveunits", "primitiveUnits"], + ["refx", "refX"], + ["refy", "refY"], + ["repeatcount", "repeatCount"], + ["repeatdur", "repeatDur"], + ["requiredextensions", "requiredExtensions"], + ["requiredfeatures", "requiredFeatures"], + ["specularconstant", "specularConstant"], + ["specularexponent", "specularExponent"], + ["spreadmethod", "spreadMethod"], + ["startoffset", "startOffset"], + ["stddeviation", "stdDeviation"], + ["stitchtiles", "stitchTiles"], + ["surfacescale", "surfaceScale"], + ["systemlanguage", "systemLanguage"], + ["tablevalues", "tableValues"], + ["targetx", "targetX"], + ["targety", "targetY"], + ["textlength", "textLength"], + ["viewbox", "viewBox"], + ["viewtarget", "viewTarget"], + ["xchannelselector", "xChannelSelector"], + ["ychannelselector", "yChannelSelector"], + ["zoomandpan", "zoomAndPan"], +]); diff --git a/igv_component/node_modules/dom-serializer/lib/index.d.ts b/igv_component/node_modules/dom-serializer/lib/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..84f6d1689e3605266ab815c6cc00de6a5c3589cb --- /dev/null +++ b/igv_component/node_modules/dom-serializer/lib/index.d.ts @@ -0,0 +1,43 @@ +import type { Node } from "domhandler"; +export interface DomSerializerOptions { + /** + * Print an empty attribute's value. + * + * @default xmlMode + * @example With emptyAttrs: false: <input checked> + * @example With emptyAttrs: true: <input checked=""> + */ + emptyAttrs?: boolean; + /** + * Print self-closing tags for tags without contents. + * + * @default xmlMode + * @example With selfClosingTags: false: <foo></foo> + * @example With selfClosingTags: true: <foo /> + */ + selfClosingTags?: boolean; + /** + * Treat the input as an XML document; enables the `emptyAttrs` and `selfClosingTags` options. + * + * If the value is `"foreign"`, it will try to correct mixed-case attribute names. + * + * @default false + */ + xmlMode?: boolean | "foreign"; + /** + * Encode characters that are either reserved in HTML or XML, or are outside of the ASCII range. + * + * @default true + */ + decodeEntities?: boolean; +} +/** + * Renders a DOM node or an array of DOM nodes to a string. + * + * Can be thought of as the equivalent of the `outerHTML` of the passed node(s). + * + * @param node Node to be rendered. + * @param options Changes serialization behavior + */ +export default function render(node: Node | ArrayLike, options?: DomSerializerOptions): string; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/igv_component/node_modules/dom-serializer/lib/index.d.ts.map b/igv_component/node_modules/dom-serializer/lib/index.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..c04bdd48016305f9933b2fd3118cf23bce5b1a24 --- /dev/null +++ b/igv_component/node_modules/dom-serializer/lib/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAuC,MAAM,YAAY,CAAC;AAW5E,MAAM,WAAW,oBAAoB;IACnC;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAqED;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAC5B,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,EAC5B,OAAO,GAAE,oBAAyB,GACjC,MAAM,CAUR"} \ No newline at end of file diff --git a/igv_component/node_modules/dom-serializer/lib/index.js b/igv_component/node_modules/dom-serializer/lib/index.js new file mode 100644 index 0000000000000000000000000000000000000000..a5e1f936406854efd649bb87045dcb10ea5e9df4 --- /dev/null +++ b/igv_component/node_modules/dom-serializer/lib/index.js @@ -0,0 +1,211 @@ +"use strict"; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +/* + * Module dependencies + */ +var ElementType = __importStar(require("domelementtype")); +var entities_1 = require("entities"); +/** + * Mixed-case SVG and MathML tags & attributes + * recognized by the HTML parser. + * + * @see https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inforeign + */ +var foreignNames_1 = require("./foreignNames"); +var unencodedElements = new Set([ + "style", + "script", + "xmp", + "iframe", + "noembed", + "noframes", + "plaintext", + "noscript", +]); +/** + * Format attributes + */ +function formatAttributes(attributes, opts) { + if (!attributes) + return; + return Object.keys(attributes) + .map(function (key) { + var _a, _b; + var value = (_a = attributes[key]) !== null && _a !== void 0 ? _a : ""; + if (opts.xmlMode === "foreign") { + /* Fix up mixed-case attribute names */ + key = (_b = foreignNames_1.attributeNames.get(key)) !== null && _b !== void 0 ? _b : key; + } + if (!opts.emptyAttrs && !opts.xmlMode && value === "") { + return key; + } + return key + "=\"" + (opts.decodeEntities !== false + ? entities_1.encodeXML(value) + : value.replace(/"/g, """)) + "\""; + }) + .join(" "); +} +/** + * Self-enclosing tags + */ +var singleTag = new Set([ + "area", + "base", + "basefont", + "br", + "col", + "command", + "embed", + "frame", + "hr", + "img", + "input", + "isindex", + "keygen", + "link", + "meta", + "param", + "source", + "track", + "wbr", +]); +/** + * Renders a DOM node or an array of DOM nodes to a string. + * + * Can be thought of as the equivalent of the `outerHTML` of the passed node(s). + * + * @param node Node to be rendered. + * @param options Changes serialization behavior + */ +function render(node, options) { + if (options === void 0) { options = {}; } + var nodes = "length" in node ? node : [node]; + var output = ""; + for (var i = 0; i < nodes.length; i++) { + output += renderNode(nodes[i], options); + } + return output; +} +exports.default = render; +function renderNode(node, options) { + switch (node.type) { + case ElementType.Root: + return render(node.children, options); + case ElementType.Directive: + case ElementType.Doctype: + return renderDirective(node); + case ElementType.Comment: + return renderComment(node); + case ElementType.CDATA: + return renderCdata(node); + case ElementType.Script: + case ElementType.Style: + case ElementType.Tag: + return renderTag(node, options); + case ElementType.Text: + return renderText(node, options); + } +} +var foreignModeIntegrationPoints = new Set([ + "mi", + "mo", + "mn", + "ms", + "mtext", + "annotation-xml", + "foreignObject", + "desc", + "title", +]); +var foreignElements = new Set(["svg", "math"]); +function renderTag(elem, opts) { + var _a; + // Handle SVG / MathML in HTML + if (opts.xmlMode === "foreign") { + /* Fix up mixed-case element names */ + elem.name = (_a = foreignNames_1.elementNames.get(elem.name)) !== null && _a !== void 0 ? _a : elem.name; + /* Exit foreign mode at integration points */ + if (elem.parent && + foreignModeIntegrationPoints.has(elem.parent.name)) { + opts = __assign(__assign({}, opts), { xmlMode: false }); + } + } + if (!opts.xmlMode && foreignElements.has(elem.name)) { + opts = __assign(__assign({}, opts), { xmlMode: "foreign" }); + } + var tag = "<" + elem.name; + var attribs = formatAttributes(elem.attribs, opts); + if (attribs) { + tag += " " + attribs; + } + if (elem.children.length === 0 && + (opts.xmlMode + ? // In XML mode or foreign mode, and user hasn't explicitly turned off self-closing tags + opts.selfClosingTags !== false + : // User explicitly asked for self-closing tags, even in HTML mode + opts.selfClosingTags && singleTag.has(elem.name))) { + if (!opts.xmlMode) + tag += " "; + tag += "/>"; + } + else { + tag += ">"; + if (elem.children.length > 0) { + tag += render(elem.children, opts); + } + if (opts.xmlMode || !singleTag.has(elem.name)) { + tag += ""; + } + } + return tag; +} +function renderDirective(elem) { + return "<" + elem.data + ">"; +} +function renderText(elem, opts) { + var data = elem.data || ""; + // If entities weren't decoded, no need to encode them back + if (opts.decodeEntities !== false && + !(!opts.xmlMode && + elem.parent && + unencodedElements.has(elem.parent.name))) { + data = entities_1.encodeXML(data); + } + return data; +} +function renderCdata(elem) { + return ""; +} +function renderComment(elem) { + return ""; +} diff --git a/igv_component/node_modules/dom-serializer/package.json b/igv_component/node_modules/dom-serializer/package.json new file mode 100644 index 0000000000000000000000000000000000000000..219922d6c5ea5076dc6c53aec9bc36f6710d923c --- /dev/null +++ b/igv_component/node_modules/dom-serializer/package.json @@ -0,0 +1,55 @@ +{ + "name": "dom-serializer", + "version": "1.4.1", + "description": "render domhandler DOM nodes to a string", + "author": "Felix Boehm ", + "sideEffects": false, + "keywords": [ + "html", + "xml", + "render" + ], + "repository": { + "type": "git", + "url": "git://github.com/cheeriojs/dom-renderer.git" + }, + "main": "lib/index.js", + "types": "lib/index.d.ts", + "files": [ + "lib/**/*" + ], + "dependencies": { + "domelementtype": "^2.0.1", + "domhandler": "^4.2.0", + "entities": "^2.0.0" + }, + "devDependencies": { + "@types/jest": "^26.0.23", + "@types/node": "^15.3.0", + "@typescript-eslint/eslint-plugin": "^4.23.0", + "@typescript-eslint/parser": "^4.23.0", + "cheerio": "^1.0.0-rc.9", + "coveralls": "^3.0.5", + "eslint": "^7.26.0", + "eslint-config-prettier": "^8.3.0", + "htmlparser2": "^6.1.0", + "jest": "^26.0.1", + "prettier": "^2.3.0", + "ts-jest": "^26.5.6", + "typescript": "^4.0.2" + }, + "scripts": { + "test": "jest --coverage && npm run lint", + "coverage": "cat coverage/lcov.info | coveralls", + "lint": "eslint src", + "format": "prettier --write '**/*.{ts,md,json}'", + "build": "tsc", + "prepare": "npm run build" + }, + "jest": { + "preset": "ts-jest", + "testEnvironment": "node" + }, + "funding": "https://github.com/cheeriojs/dom-serializer?sponsor=1", + "license": "MIT" +} diff --git a/igv_component/node_modules/domelementtype/LICENSE b/igv_component/node_modules/domelementtype/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..c464f863ea2b18a15ca3883bc5d98065ed5d039a --- /dev/null +++ b/igv_component/node_modules/domelementtype/LICENSE @@ -0,0 +1,11 @@ +Copyright (c) Felix Böhm +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/igv_component/node_modules/domelementtype/lib/esm/index.d.ts b/igv_component/node_modules/domelementtype/lib/esm/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..72fa4f8750dccfc98e0958cc8eafc4cb9471f8d4 --- /dev/null +++ b/igv_component/node_modules/domelementtype/lib/esm/index.d.ts @@ -0,0 +1,48 @@ +/** Types of elements found in htmlparser2's DOM */ +export declare enum ElementType { + /** Type for the root element of a document */ + Root = "root", + /** Type for Text */ + Text = "text", + /** Type for */ + Directive = "directive", + /** Type for */ + Comment = "comment", + /** Type for "; +const handler = new DomHandler((error, dom) => { + if (error) { + // Handle error + } else { + // Parsing completed, do something + console.log(dom); + } +}); +const parser = new Parser(handler); +parser.write(rawHtml); +parser.end(); +``` + +Output: + +```javascript +[ + { + data: "Xyz ", + type: "text", + }, + { + type: "script", + name: "script", + attribs: { + language: "javascript", + }, + children: [ + { + data: "var foo = '';<", + type: "text", + }, + ], + }, + { + data: "`. + +### Preserving SVG tags + +SVG tags are automatically recognized, and when they are minified, both case-sensitivity and closing-slashes are preserved, regardless of the minification settings used for the rest of the file. + +### Working with invalid markup + +HTMLMinifier **can't work with invalid or partial chunks of markup**. This is because it parses markup into a tree structure, then modifies it (removing anything that was specified for removal, ignoring anything that was specified to be ignored, etc.), then it creates a markup out of that tree and returns it. + +Input markup (e.g. `

        foo`) + +↓ + +Internal representation of markup in a form of tree (e.g. `{ tag: "p", attr: "id", children: ["foo"] }`) + +↓ + +Transformation of internal representation (e.g. removal of `id` attribute) + +↓ + +Output of resulting markup (e.g. `

        foo

        `) + +HTMLMinifier can't know that original markup was only half of the tree; it does its best to try to parse it as a full tree and it loses information about tree being malformed or partial in the beginning. As a result, it can't create a partial/malformed tree at the time of the output. + +## Installation Instructions + +From NPM for use as a command line app: + +```shell +npm install html-minifier-terser -g +``` + +From NPM for programmatic use: + +```shell +npm install html-minifier-terser +``` + +From Git: + +```shell +git clone git://github.com/terser/html-minifier-terser.git +cd html-minifier-terser +npm link . +``` + +## Usage + +Note that almost all options are disabled by default. For command line usage please see `html-minifier-terser --help` for a list of available options. Experiment and find what works best for you and your project. + +- **Sample command line:** `html-minifier-terser --collapse-whitespace --remove-comments --remove-optional-tags --remove-redundant-attributes --remove-script-type-attributes --remove-tag-whitespace --use-short-doctype --minify-css true --minify-js true` + +### Node.js + +```js +const { minify } = require('html-minifier-terser'); + +const result = await minify('

        foo

        ', { + removeAttributeQuotes: true +}); +result; // '

        foo

        ' +``` + +## Running benchmarks + +Benchmarks for minified HTML: + +```shell +node benchmark.js +``` + +## Running local server + +```shell +npm run serve +``` diff --git a/igv_component/node_modules/html-minifier-terser/cli.js b/igv_component/node_modules/html-minifier-terser/cli.js new file mode 100644 index 0000000000000000000000000000000000000000..054d81fd590fabd5cedf35916e9162f1ef4635c6 --- /dev/null +++ b/igv_component/node_modules/html-minifier-terser/cli.js @@ -0,0 +1,315 @@ +#!/usr/bin/env node +/** + * html-minifier-terser CLI tool + * + * The MIT License (MIT) + * + * Copyright (c) 2014-2016 Zoltan Frombach + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +'use strict'; + +var camelCase = require('camel-case').camelCase; +var fs = require('fs'); +var info = require('./package.json'); +var minify = require('./' + info.main).minify; +var paramCase = require('param-case').paramCase; +var path = require('path'); +var { Command } = require('commander'); + +const program = new Command(); +program.name(info.name); +program.version(info.version); + +function fatal(message) { + console.error(message); + process.exit(1); +} + +/** + * JSON does not support regexes, so, e.g., JSON.parse() will not create + * a RegExp from the JSON value `[ "/matchString/" ]`, which is + * technically just an array containing a string that begins and end with + * a forward slash. To get a RegExp from a JSON string, it must be + * constructed explicitly in JavaScript. + * + * The likelihood of actually wanting to match text that is enclosed in + * forward slashes is probably quite rare, so if forward slashes were + * included in an argument that requires a regex, the user most likely + * thought they were part of the syntax for specifying a regex. + * + * In the unlikely case that forward slashes are indeed desired in the + * search string, the user would need to enclose the expression in a + * second set of slashes: + * + * --customAttrSrround "[\"//matchString//\"]" + */ +function parseRegExp(value) { + if (value) { + return new RegExp(value.replace(/^\/(.*)\/$/, '$1')); + } +} + +function parseJSON(value) { + if (value) { + try { + return JSON.parse(value); + } + catch (e) { + if (/^{/.test(value)) { + fatal('Could not parse JSON value \'' + value + '\''); + } + return value; + } + } +} + +function parseJSONArray(value) { + if (value) { + value = parseJSON(value); + return Array.isArray(value) ? value : [value]; + } +} + +function parseJSONRegExpArray(value) { + value = parseJSONArray(value); + return value && value.map(parseRegExp); +} + +function parseString(value) { + return value; +} + +var mainOptions = { + caseSensitive: 'Treat attributes in case sensitive manner (useful for SVG; e.g. viewBox)', + collapseBooleanAttributes: 'Omit attribute values from boolean attributes', + collapseInlineTagWhitespace: 'Collapse white space around inline tag', + collapseWhitespace: 'Collapse white space that contributes to text nodes in a document tree.', + conservativeCollapse: 'Always collapse to 1 space (never remove it entirely)', + continueOnParseError: 'Handle parse errors instead of aborting', + customAttrAssign: ['Arrays of regex\'es that allow to support custom attribute assign expressions (e.g. \'
        \')', parseJSONRegExpArray], + customAttrCollapse: ['Regex that specifies custom attribute to strip newlines from (e.g. /ng-class/)', parseRegExp], + customAttrSurround: ['Arrays of regex\'es that allow to support custom attribute surround expressions (e.g. )', parseJSONRegExpArray], + customEventAttributes: ['Arrays of regex\'es that allow to support custom event attributes for minifyJS (e.g. ng-click)', parseJSONRegExpArray], + decodeEntities: 'Use direct Unicode characters whenever possible', + html5: 'Parse input according to HTML5 specifications', + ignoreCustomComments: ['Array of regex\'es that allow to ignore certain comments, when matched', parseJSONRegExpArray], + ignoreCustomFragments: ['Array of regex\'es that allow to ignore certain fragments, when matched (e.g. , {{ ... }})', parseJSONRegExpArray], + includeAutoGeneratedTags: 'Insert tags generated by HTML parser', + keepClosingSlash: 'Keep the trailing slash on singleton elements', + maxLineLength: ['Max line length', parseInt], + minifyCSS: ['Minify CSS in style elements and style attributes (uses clean-css)', parseJSON], + minifyJS: ['Minify Javascript in script elements and on* attributes (uses terser)', parseJSON], + minifyURLs: ['Minify URLs in various attributes (uses relateurl)', parseJSON], + noNewlinesBeforeTagClose: 'Never add a newline before a tag that closes an element', + preserveLineBreaks: 'Always collapse to 1 line break (never remove it entirely) when whitespace between tags include a line break.', + preventAttributesEscaping: 'Prevents the escaping of the values of attributes.', + processConditionalComments: 'Process contents of conditional comments through minifier', + processScripts: ['Array of strings corresponding to types of script elements to process through minifier (e.g. "text/ng-template", "text/x-handlebars-template", etc.)', parseJSONArray], + quoteCharacter: ['Type of quote to use for attribute values (\' or ")', parseString], + removeAttributeQuotes: 'Remove quotes around attributes when possible.', + removeComments: 'Strip HTML comments', + removeEmptyAttributes: 'Remove all attributes with whitespace-only values', + removeEmptyElements: 'Remove all elements with empty contents', + removeOptionalTags: 'Remove unrequired tags', + removeRedundantAttributes: 'Remove attributes when value matches default.', + removeScriptTypeAttributes: 'Removes the following attributes from script tags: text/javascript, text/ecmascript, text/jscript, application/javascript, application/x-javascript, application/ecmascript. Other type attribute values are left intact', + removeStyleLinkTypeAttributes: 'Remove type="text/css" from style and link tags. Other type attribute values are left intact.', + removeTagWhitespace: 'Remove space between attributes whenever possible', + sortAttributes: 'Sort attributes by frequency', + sortClassName: 'Sort style classes by frequency', + trimCustomFragments: 'Trim white space around ignoreCustomFragments.', + useShortDoctype: 'Replaces the doctype with the short (HTML5) doctype' +}; +var mainOptionKeys = Object.keys(mainOptions); +mainOptionKeys.forEach(function(key) { + var option = mainOptions[key]; + if (Array.isArray(option)) { + key = key === 'minifyURLs' ? '--minify-urls' : '--' + paramCase(key); + key += option[1] === parseJSON ? ' [value]' : ' '; + program.option(key, option[0], option[1]); + } + else if (~['html5', 'includeAutoGeneratedTags'].indexOf(key)) { + program.option('--no-' + paramCase(key), option); + } + else { + program.option('--' + paramCase(key), option); + } +}); +program.option('-o --output ', 'Specify output file (if not specified STDOUT will be used for output)'); + +function readFile(file) { + try { + return fs.readFileSync(file, { encoding: 'utf8' }); + } + catch (e) { + fatal('Cannot read ' + file + '\n' + e.message); + } +} + +var config = {}; +program.option('-c --config-file ', 'Use config file', function(configPath) { + var data = readFile(configPath); + try { + config = JSON.parse(data); + } + catch (je) { + try { + config = require(path.resolve(configPath)); + } + catch (ne) { + fatal('Cannot read the specified config file.\nAs JSON: ' + je.message + '\nAs module: ' + ne.message); + } + } + mainOptionKeys.forEach(function(key) { + if (key in config) { + var option = mainOptions[key]; + if (Array.isArray(option)) { + var value = config[key]; + config[key] = option[1](typeof value === 'string' ? value : JSON.stringify(value)); + } + } + }); +}); +program.option('--input-dir ', 'Specify an input directory'); +program.option('--output-dir ', 'Specify an output directory'); +program.option('--file-ext ', 'Specify an extension to be read, ex: html'); +var content; +program.arguments('[files...]').action(function(files) { + content = files.map(readFile).join(''); +}).parse(process.argv); + +const programOptions = program.opts(); + +function createOptions() { + var options = {}; + mainOptionKeys.forEach(function(key) { + var param = programOptions[key === 'minifyURLs' ? 'minifyUrls' : camelCase(key)]; + if (typeof param !== 'undefined') { + options[key] = param; + } + else if (key in config) { + options[key] = config[key]; + } + }); + return options; +} + +function mkdir(outputDir, callback) { + fs.mkdir(outputDir, function(err) { + if (err) { + switch (err.code) { + case 'ENOENT': + return mkdir(path.join(outputDir, '..'), function() { + mkdir(outputDir, callback); + }); + case 'EEXIST': + break; + default: + fatal('Cannot create directory ' + outputDir + '\n' + err.message); + } + } + callback(); + }); +} + +function processFile(inputFile, outputFile) { + fs.readFile(inputFile, { encoding: 'utf8' }, async function(err, data) { + if (err) { + fatal('Cannot read ' + inputFile + '\n' + err.message); + } + var minified; + try { + minified = await minify(data, createOptions()); + } + catch (e) { + fatal('Minification error on ' + inputFile + '\n' + e.message); + } + fs.writeFile(outputFile, minified, { encoding: 'utf8' }, function(err) { + if (err) { + fatal('Cannot write ' + outputFile + '\n' + err.message); + } + }); + }); +} + +function processDirectory(inputDir, outputDir, fileExt) { + fs.readdir(inputDir, function(err, files) { + if (err) { + fatal('Cannot read directory ' + inputDir + '\n' + err.message); + } + files.forEach(function(file) { + var inputFile = path.join(inputDir, file); + var outputFile = path.join(outputDir, file); + fs.stat(inputFile, function(err, stat) { + if (err) { + fatal('Cannot read ' + inputFile + '\n' + err.message); + } + else if (stat.isDirectory()) { + processDirectory(inputFile, outputFile, fileExt); + } + else if (!fileExt || path.extname(file) === '.' + fileExt) { + mkdir(outputDir, function() { + processFile(inputFile, outputFile); + }); + } + }); + }); + }); +} + +async function writeMinify() { + var minified; + try { + minified = await minify(content, createOptions()); + } + catch (e) { + fatal('Minification error:\n' + e.message); + } + (programOptions.output ? fs.createWriteStream(programOptions.output).on('error', function(e) { + fatal('Cannot write ' + programOptions.output + '\n' + e.message); + }) : process.stdout).write(minified); +} + +var inputDir = programOptions.inputDir; +var outputDir = programOptions.outputDir; +var fileExt = programOptions.fileExt; +if (inputDir || outputDir) { + if (!inputDir) { + fatal('The option output-dir needs to be used with the option input-dir. If you are working with a single file, use -o.'); + } + else if (!outputDir) { + fatal('You need to specify where to write the output files with the option --output-dir'); + } + processDirectory(inputDir, outputDir, fileExt); +} +// Minifying one or more files specified on the CMD line +else if (content) { + writeMinify(); +} +// Minifying input coming from STDIN +else { + content = ''; + process.stdin.setEncoding('utf8'); + process.stdin.on('data', function(data) { + content += data; + }).on('end', writeMinify); +} diff --git a/igv_component/node_modules/html-minifier-terser/node_modules/commander/LICENSE b/igv_component/node_modules/html-minifier-terser/node_modules/commander/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..10f997ab104594695189c3fca8fa6c65ae9ccdd6 --- /dev/null +++ b/igv_component/node_modules/html-minifier-terser/node_modules/commander/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2011 TJ Holowaychuk + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/igv_component/node_modules/html-minifier-terser/node_modules/commander/Readme.md b/igv_component/node_modules/html-minifier-terser/node_modules/commander/Readme.md new file mode 100644 index 0000000000000000000000000000000000000000..9a2ab9500874c02ad3e16d0a61ef05122db30fd5 --- /dev/null +++ b/igv_component/node_modules/html-minifier-terser/node_modules/commander/Readme.md @@ -0,0 +1,1015 @@ +# Commander.js + +[![Build Status](https://github.com/tj/commander.js/workflows/build/badge.svg)](https://github.com/tj/commander.js/actions?query=workflow%3A%22build%22) +[![NPM Version](http://img.shields.io/npm/v/commander.svg?style=flat)](https://www.npmjs.org/package/commander) +[![NPM Downloads](https://img.shields.io/npm/dm/commander.svg?style=flat)](https://npmcharts.com/compare/commander?minimal=true) +[![Install Size](https://packagephobia.now.sh/badge?p=commander)](https://packagephobia.now.sh/result?p=commander) + +The complete solution for [node.js](http://nodejs.org) command-line interfaces. + +Read this in other languages: English | [简体中文](./Readme_zh-CN.md) + +- [Commander.js](#commanderjs) + - [Installation](#installation) + - [Declaring _program_ variable](#declaring-program-variable) + - [Options](#options) + - [Common option types, boolean and value](#common-option-types-boolean-and-value) + - [Default option value](#default-option-value) + - [Other option types, negatable boolean and boolean|value](#other-option-types-negatable-boolean-and-booleanvalue) + - [Required option](#required-option) + - [Variadic option](#variadic-option) + - [Version option](#version-option) + - [More configuration](#more-configuration) + - [Custom option processing](#custom-option-processing) + - [Commands](#commands) + - [Command-arguments](#command-arguments) + - [More configuration](#more-configuration-1) + - [Custom argument processing](#custom-argument-processing) + - [Action handler](#action-handler) + - [Stand-alone executable (sub)commands](#stand-alone-executable-subcommands) + - [Life cycle hooks](#life-cycle-hooks) + - [Automated help](#automated-help) + - [Custom help](#custom-help) + - [Display help after errors](#display-help-after-errors) + - [Display help from code](#display-help-from-code) + - [.usage and .name](#usage-and-name) + - [.helpOption(flags, description)](#helpoptionflags-description) + - [.addHelpCommand()](#addhelpcommand) + - [More configuration](#more-configuration-2) + - [Custom event listeners](#custom-event-listeners) + - [Bits and pieces](#bits-and-pieces) + - [.parse() and .parseAsync()](#parse-and-parseasync) + - [Parsing Configuration](#parsing-configuration) + - [Legacy options as properties](#legacy-options-as-properties) + - [TypeScript](#typescript) + - [createCommand()](#createcommand) + - [Node options such as `--harmony`](#node-options-such-as---harmony) + - [Debugging stand-alone executable subcommands](#debugging-stand-alone-executable-subcommands) + - [Override exit and output handling](#override-exit-and-output-handling) + - [Additional documentation](#additional-documentation) + - [Examples](#examples) + - [Support](#support) + - [Commander for enterprise](#commander-for-enterprise) + +For information about terms used in this document see: [terminology](./docs/terminology.md) + +## Installation + +```bash +npm install commander +``` + +## Declaring _program_ variable + +Commander exports a global object which is convenient for quick programs. +This is used in the examples in this README for brevity. + +```js +const { program } = require('commander'); +program.version('0.0.1'); +``` + +For larger programs which may use commander in multiple ways, including unit testing, it is better to create a local Command object to use. + +```js +const { Command } = require('commander'); +const program = new Command(); +program.version('0.0.1'); +``` + +For named imports in ECMAScript modules, import from `commander/esm.mjs`. + +```js +// index.mjs +import { Command } from 'commander/esm.mjs'; +const program = new Command(); +``` + +And in TypeScript: + +```ts +// index.ts +import { Command } from 'commander'; +const program = new Command(); +``` + +## Options + +Options are defined with the `.option()` method, also serving as documentation for the options. Each option can have a short flag (single character) and a long name, separated by a comma or space or vertical bar ('|'). + +The parsed options can be accessed by calling `.opts()` on a `Command` object, and are passed to the action handler. +(You can also use `.getOptionValue()` and `.setOptionValue()` to work with a single option value, +and `.getOptionValueSource()` and `.setOptionValueWithSource()` when it matters where the option value came from.) + +Multi-word options such as "--template-engine" are camel-cased, becoming `program.opts().templateEngine` etc. + +Multiple short flags may optionally be combined in a single argument following the dash: boolean flags, followed by a single option taking a value (possibly followed by the value). +For example `-a -b -p 80` may be written as `-ab -p80` or even `-abp80`. + +You can use `--` to indicate the end of the options, and any remaining arguments will be used without being interpreted. + +By default options on the command line are not positional, and can be specified before or after other arguments. + +### Common option types, boolean and value + +The two most used option types are a boolean option, and an option which takes its value +from the following argument (declared with angle brackets like `--expect `). Both are `undefined` unless specified on command line. + +Example file: [options-common.js](./examples/options-common.js) + +```js +program + .option('-d, --debug', 'output extra debugging') + .option('-s, --small', 'small pizza size') + .option('-p, --pizza-type ', 'flavour of pizza'); + +program.parse(process.argv); + +const options = program.opts(); +if (options.debug) console.log(options); +console.log('pizza details:'); +if (options.small) console.log('- small pizza size'); +if (options.pizzaType) console.log(`- ${options.pizzaType}`); +``` + +```bash +$ pizza-options -p +error: option '-p, --pizza-type ' argument missing +$ pizza-options -d -s -p vegetarian +{ debug: true, small: true, pizzaType: 'vegetarian' } +pizza details: +- small pizza size +- vegetarian +$ pizza-options --pizza-type=cheese +pizza details: +- cheese +``` + +`program.parse(arguments)` processes the arguments, leaving any args not consumed by the program options in the `program.args` array. The parameter is optional and defaults to `process.argv`. + +### Default option value + +You can specify a default value for an option which takes a value. + +Example file: [options-defaults.js](./examples/options-defaults.js) + +```js +program + .option('-c, --cheese ', 'add the specified type of cheese', 'blue'); + +program.parse(); + +console.log(`cheese: ${program.opts().cheese}`); +``` + +```bash +$ pizza-options +cheese: blue +$ pizza-options --cheese stilton +cheese: stilton +``` + +### Other option types, negatable boolean and boolean|value + +You can define a boolean option long name with a leading `no-` to set the option value to false when used. +Defined alone this also makes the option true by default. + +If you define `--foo` first, adding `--no-foo` does not change the default value from what it would +otherwise be. You can specify a default boolean value for a boolean option and it can be overridden on command line. + +Example file: [options-negatable.js](./examples/options-negatable.js) + +```js +program + .option('--no-sauce', 'Remove sauce') + .option('--cheese ', 'cheese flavour', 'mozzarella') + .option('--no-cheese', 'plain with no cheese') + .parse(); + +const options = program.opts(); +const sauceStr = options.sauce ? 'sauce' : 'no sauce'; +const cheeseStr = (options.cheese === false) ? 'no cheese' : `${options.cheese} cheese`; +console.log(`You ordered a pizza with ${sauceStr} and ${cheeseStr}`); +``` + +```bash +$ pizza-options +You ordered a pizza with sauce and mozzarella cheese +$ pizza-options --sauce +error: unknown option '--sauce' +$ pizza-options --cheese=blue +You ordered a pizza with sauce and blue cheese +$ pizza-options --no-sauce --no-cheese +You ordered a pizza with no sauce and no cheese +``` + +You can specify an option which may be used as a boolean option but may optionally take an option-argument +(declared with square brackets like `--optional [value]`). + +Example file: [options-boolean-or-value.js](./examples/options-boolean-or-value.js) + +```js +program + .option('-c, --cheese [type]', 'Add cheese with optional type'); + +program.parse(process.argv); + +const options = program.opts(); +if (options.cheese === undefined) console.log('no cheese'); +else if (options.cheese === true) console.log('add cheese'); +else console.log(`add cheese type ${options.cheese}`); +``` + +```bash +$ pizza-options +no cheese +$ pizza-options --cheese +add cheese +$ pizza-options --cheese mozzarella +add cheese type mozzarella +``` + +For information about possible ambiguous cases, see [options taking varying arguments](./docs/options-taking-varying-arguments.md). + +### Required option + +You may specify a required (mandatory) option using `.requiredOption`. The option must have a value after parsing, usually specified on the command line, or perhaps from a default value (say from environment). The method is otherwise the same as `.option` in format, taking flags and description, and optional default value or custom processing. + +Example file: [options-required.js](./examples/options-required.js) + +```js +program + .requiredOption('-c, --cheese ', 'pizza must have cheese'); + +program.parse(); +``` + +```bash +$ pizza +error: required option '-c, --cheese ' not specified +``` + +### Variadic option + +You may make an option variadic by appending `...` to the value placeholder when declaring the option. On the command line you +can then specify multiple option-arguments, and the parsed option value will be an array. The extra arguments +are read until the first argument starting with a dash. The special argument `--` stops option processing entirely. If a value +is specified in the same argument as the option then no further values are read. + +Example file: [options-variadic.js](./examples/options-variadic.js) + +```js +program + .option('-n, --number ', 'specify numbers') + .option('-l, --letter [letters...]', 'specify letters'); + +program.parse(); + +console.log('Options: ', program.opts()); +console.log('Remaining arguments: ', program.args); +``` + +```bash +$ collect -n 1 2 3 --letter a b c +Options: { number: [ '1', '2', '3' ], letter: [ 'a', 'b', 'c' ] } +Remaining arguments: [] +$ collect --letter=A -n80 operand +Options: { number: [ '80' ], letter: [ 'A' ] } +Remaining arguments: [ 'operand' ] +$ collect --letter -n 1 -n 2 3 -- operand +Options: { number: [ '1', '2', '3' ], letter: true } +Remaining arguments: [ 'operand' ] +``` + +For information about possible ambiguous cases, see [options taking varying arguments](./docs/options-taking-varying-arguments.md). + +### Version option + +The optional `version` method adds handling for displaying the command version. The default option flags are `-V` and `--version`, and when present the command prints the version number and exits. + +```js +program.version('0.0.1'); +``` + +```bash +$ ./examples/pizza -V +0.0.1 +``` + +You may change the flags and description by passing additional parameters to the `version` method, using +the same syntax for flags as the `option` method. + +```js +program.version('0.0.1', '-v, --vers', 'output the current version'); +``` + +### More configuration + +You can add most options using the `.option()` method, but there are some additional features available +by constructing an `Option` explicitly for less common cases. + +Example files: [options-extra.js](./examples/options-extra.js), [options-env.js](./examples/options-env.js) + +```js +program + .addOption(new Option('-s, --secret').hideHelp()) + .addOption(new Option('-t, --timeout ', 'timeout in seconds').default(60, 'one minute')) + .addOption(new Option('-d, --drink ', 'drink size').choices(['small', 'medium', 'large'])) + .addOption(new Option('-p, --port ', 'port number').env('PORT')); +``` + +```bash +$ extra --help +Usage: help [options] + +Options: + -t, --timeout timeout in seconds (default: one minute) + -d, --drink drink cup size (choices: "small", "medium", "large") + -p, --port port number (env: PORT) + -h, --help display help for command + +$ extra --drink huge +error: option '-d, --drink ' argument 'huge' is invalid. Allowed choices are small, medium, large. + +$ PORT=80 extra +Options: { timeout: 60, port: '80' } +``` + +### Custom option processing + +You may specify a function to do custom processing of option-arguments. The callback function receives two parameters, +the user specified option-argument and the previous value for the option. It returns the new value for the option. + +This allows you to coerce the option-argument to the desired type, or accumulate values, or do entirely custom processing. + +You can optionally specify the default/starting value for the option after the function parameter. + +Example file: [options-custom-processing.js](./examples/options-custom-processing.js) + +```js +function myParseInt(value, dummyPrevious) { + // parseInt takes a string and a radix + const parsedValue = parseInt(value, 10); + if (isNaN(parsedValue)) { + throw new commander.InvalidArgumentError('Not a number.'); + } + return parsedValue; +} + +function increaseVerbosity(dummyValue, previous) { + return previous + 1; +} + +function collect(value, previous) { + return previous.concat([value]); +} + +function commaSeparatedList(value, dummyPrevious) { + return value.split(','); +} + +program + .option('-f, --float ', 'float argument', parseFloat) + .option('-i, --integer ', 'integer argument', myParseInt) + .option('-v, --verbose', 'verbosity that can be increased', increaseVerbosity, 0) + .option('-c, --collect ', 'repeatable value', collect, []) + .option('-l, --list ', 'comma separated list', commaSeparatedList) +; + +program.parse(); + +const options = program.opts(); +if (options.float !== undefined) console.log(`float: ${options.float}`); +if (options.integer !== undefined) console.log(`integer: ${options.integer}`); +if (options.verbose > 0) console.log(`verbosity: ${options.verbose}`); +if (options.collect.length > 0) console.log(options.collect); +if (options.list !== undefined) console.log(options.list); +``` + +```bash +$ custom -f 1e2 +float: 100 +$ custom --integer 2 +integer: 2 +$ custom -v -v -v +verbose: 3 +$ custom -c a -c b -c c +[ 'a', 'b', 'c' ] +$ custom --list x,y,z +[ 'x', 'y', 'z' ] +``` + +## Commands + +You can specify (sub)commands using `.command()` or `.addCommand()`. There are two ways these can be implemented: using an action handler attached to the command, or as a stand-alone executable file (described in more detail later). The subcommands may be nested ([example](./examples/nestedCommands.js)). + +In the first parameter to `.command()` you specify the command name. You may append the command-arguments after the command name, or specify them separately using `.argument()`. The arguments may be `` or `[optional]`, and the last argument may also be `variadic...`. + +You can use `.addCommand()` to add an already configured subcommand to the program. + +For example: + +```js +// Command implemented using action handler (description is supplied separately to `.command`) +// Returns new command for configuring. +program + .command('clone [destination]') + .description('clone a repository into a newly created directory') + .action((source, destination) => { + console.log('clone command called'); + }); + +// Command implemented using stand-alone executable file, indicated by adding description as second parameter to `.command`. +// Returns `this` for adding more commands. +program + .command('start ', 'start named service') + .command('stop [service]', 'stop named service, or all if no name supplied'); + +// Command prepared separately. +// Returns `this` for adding more commands. +program + .addCommand(build.makeBuildCommand()); +``` + +Configuration options can be passed with the call to `.command()` and `.addCommand()`. Specifying `hidden: true` will +remove the command from the generated help output. Specifying `isDefault: true` will run the subcommand if no other +subcommand is specified ([example](./examples/defaultCommand.js)). + +### Command-arguments + +For subcommands, you can specify the argument syntax in the call to `.command()` (as shown above). This +is the only method usable for subcommands implemented using a stand-alone executable, but for other subcommands +you can instead use the following method. + +To configure a command, you can use `.argument()` to specify each expected command-argument. +You supply the argument name and an optional description. The argument may be `` or `[optional]`. +You can specify a default value for an optional command-argument. + +Example file: [argument.js](./examples/argument.js) + +```js +program + .version('0.1.0') + .argument('', 'user to login') + .argument('[password]', 'password for user, if required', 'no password given') + .action((username, password) => { + console.log('username:', username); + console.log('password:', password); + }); +``` + + The last argument of a command can be variadic, and only the last argument. To make an argument variadic you + append `...` to the argument name. A variadic argument is passed to the action handler as an array. For example: + +```js +program + .version('0.1.0') + .command('rmdir') + .argument('') + .action(function (dirs) { + dirs.forEach((dir) => { + console.log('rmdir %s', dir); + }); + }); +``` + +There is a convenience method to add multiple arguments at once, but without descriptions: + +```js +program + .arguments(' '); +``` + +#### More configuration + +There are some additional features available by constructing an `Argument` explicitly for less common cases. + +Example file: [arguments-extra.js](./examples/arguments-extra.js) + +```js +program + .addArgument(new commander.Argument('', 'drink cup size').choices(['small', 'medium', 'large'])) + .addArgument(new commander.Argument('[timeout]', 'timeout in seconds').default(60, 'one minute')) +``` + +#### Custom argument processing + +You may specify a function to do custom processing of command-arguments (like for option-arguments). +The callback function receives two parameters, the user specified command-argument and the previous value for the argument. +It returns the new value for the argument. + +The processed argument values are passed to the action handler, and saved as `.processedArgs`. + +You can optionally specify the default/starting value for the argument after the function parameter. + +Example file: [arguments-custom-processing.js](./examples/arguments-custom-processing.js) + +```js +program + .command('add') + .argument('', 'integer argument', myParseInt) + .argument('[second]', 'integer argument', myParseInt, 1000) + .action((first, second) => { + console.log(`${first} + ${second} = ${first + second}`); + }) +; +``` + +### Action handler + +The action handler gets passed a parameter for each command-argument you declared, and two additional parameters +which are the parsed options and the command object itself. + +Example file: [thank.js](./examples/thank.js) + +```js +program + .argument('') + .option('-t, --title ', 'title to use before name') + .option('-d, --debug', 'display some debugging') + .action((name, options, command) => { + if (options.debug) { + console.error('Called %s with options %o', command.name(), options); + } + const title = options.title ? `${options.title} ` : ''; + console.log(`Thank-you ${title}${name}`); + }); +``` + +You may supply an `async` action handler, in which case you call `.parseAsync` rather than `.parse`. + +```js +async function run() { /* code goes here */ } + +async function main() { + program + .command('run') + .action(run); + await program.parseAsync(process.argv); +} +``` + +A command's options and arguments on the command line are validated when the command is used. Any unknown options or missing arguments will be reported as an error. You can suppress the unknown option checks with `.allowUnknownOption()`. By default it is not an error to +pass more arguments than declared, but you can make this an error with `.allowExcessArguments(false)`. + +### Stand-alone executable (sub)commands + +When `.command()` is invoked with a description argument, this tells Commander that you're going to use stand-alone executables for subcommands. +Commander will search the executables in the directory of the entry script (like `./examples/pm`) with the name `program-subcommand`, like `pm-install`, `pm-search`. +You can specify a custom name with the `executableFile` configuration option. + +You handle the options for an executable (sub)command in the executable, and don't declare them at the top-level. + +Example file: [pm](./examples/pm) + +```js +program + .version('0.1.0') + .command('install [name]', 'install one or more packages') + .command('search [query]', 'search with optional query') + .command('update', 'update installed packages', { executableFile: 'myUpdateSubCommand' }) + .command('list', 'list packages installed', { isDefault: true }); + +program.parse(process.argv); +``` + +If the program is designed to be installed globally, make sure the executables have proper modes, like `755`. + +### Life cycle hooks + +You can add callback hooks to a command for life cycle events. + +Example file: [hook.js](./examples/hook.js) + +```js +program + .option('-t, --trace', 'display trace statements for commands') + .hook('preAction', (thisCommand, actionCommand) => { + if (thisCommand.opts().trace) { + console.log(`About to call action handler for subcommand: ${actionCommand.name()}`); + console.log('arguments: %O', actionCommand.args); + console.log('options: %o', actionCommand.opts()); + } + }); +``` + +The callback hook can be `async`, in which case you call `.parseAsync` rather than `.parse`. You can add multiple hooks per event. + +The supported events are: + +- `preAction`: called before action handler for this command and its subcommands +- `postAction`: called after action handler for this command and its subcommands + +The hook is passed the command it was added to, and the command running the action handler. + +## Automated help + +The help information is auto-generated based on the information commander already knows about your program. The default +help option is `-h,--help`. + +Example file: [pizza](./examples/pizza) + +```bash +$ node ./examples/pizza --help +Usage: pizza [options] + +An application for pizza ordering + +Options: + -p, --peppers Add peppers + -c, --cheese Add the specified type of cheese (default: "marble") + -C, --no-cheese You do not want any cheese + -h, --help display help for command +``` + +A `help` command is added by default if your command has subcommands. It can be used alone, or with a subcommand name to show +further help for the subcommand. These are effectively the same if the `shell` program has implicit help: + +```bash +shell help +shell --help + +shell help spawn +shell spawn --help +``` + +### Custom help + +You can add extra text to be displayed along with the built-in help. + +Example file: [custom-help](./examples/custom-help) + +```js +program + .option('-f, --foo', 'enable some foo'); + +program.addHelpText('after', ` + +Example call: + $ custom-help --help`); +``` + +Yields the following help output: + +```Text +Usage: custom-help [options] + +Options: + -f, --foo enable some foo + -h, --help display help for command + +Example call: + $ custom-help --help +``` + +The positions in order displayed are: + +- `beforeAll`: add to the program for a global banner or header +- `before`: display extra information before built-in help +- `after`: display extra information after built-in help +- `afterAll`: add to the program for a global footer (epilog) + +The positions "beforeAll" and "afterAll" apply to the command and all its subcommands. + +The second parameter can be a string, or a function returning a string. The function is passed a context object for your convenience. The properties are: + +- error: a boolean for whether the help is being displayed due to a usage error +- command: the Command which is displaying the help + +### Display help after errors + +The default behaviour for usage errors is to just display a short error message. +You can change the behaviour to show the full help or a custom help message after an error. + +```js +program.showHelpAfterError(); +// or +program.showHelpAfterError('(add --help for additional information)'); +``` + +```sh +$ pizza --unknown +error: unknown option '--unknown' +(add --help for additional information) +``` + +You can also show suggestions after an error for an unknown command or option. + +```js +program.showSuggestionAfterError(); +``` + +```sh +$ pizza --hepl +error: unknown option '--hepl' +(Did you mean --help?) +``` + +### Display help from code + +`.help()`: display help information and exit immediately. You can optionally pass `{ error: true }` to display on stderr and exit with an error status. + +`.outputHelp()`: output help information without exiting. You can optionally pass `{ error: true }` to display on stderr. + +`.helpInformation()`: get the built-in command help information as a string for processing or displaying yourself. + +### .usage and .name + +These allow you to customise the usage description in the first line of the help. The name is otherwise +deduced from the (full) program arguments. Given: + +```js +program + .name("my-command") + .usage("[global options] command") +``` + +The help will start with: + +```Text +Usage: my-command [global options] command +``` + +### .helpOption(flags, description) + +By default every command has a help option. Override the default help flags and description. Pass false to disable the built-in help option. + +```js +program + .helpOption('-e, --HELP', 'read more information'); +``` + +### .addHelpCommand() + +A help command is added by default if your command has subcommands. You can explicitly turn on or off the implicit help command with `.addHelpCommand()` and `.addHelpCommand(false)`. + +You can both turn on and customise the help command by supplying the name and description: + +```js +program.addHelpCommand('assist [command]', 'show assistance'); +``` + +### More configuration + +The built-in help is formatted using the Help class. +You can configure the Help behaviour by modifying data properties and methods using `.configureHelp()`, or by subclassing using `.createHelp()` if you prefer. + +The data properties are: + +- `helpWidth`: specify the wrap width, useful for unit tests +- `sortSubcommands`: sort the subcommands alphabetically +- `sortOptions`: sort the options alphabetically + +There are methods getting the visible lists of arguments, options, and subcommands. There are methods for formatting the items in the lists, with each item having a _term_ and _description_. Take a look at `.formatHelp()` to see how they are used. + +Example file: [configure-help.js](./examples/configure-help.js) + +```js +program.configureHelp({ + sortSubcommands: true, + subcommandTerm: (cmd) => cmd.name() // Just show the name, instead of short usage. +}); +``` + +## Custom event listeners + +You can execute custom actions by listening to command and option events. + +```js +program.on('option:verbose', function () { + process.env.VERBOSE = this.opts().verbose; +}); +``` + +## Bits and pieces + +### .parse() and .parseAsync() + +The first argument to `.parse` is the array of strings to parse. You may omit the parameter to implicitly use `process.argv`. + +If the arguments follow different conventions than node you can pass a `from` option in the second parameter: + +- 'node': default, `argv[0]` is the application and `argv[1]` is the script being run, with user parameters after that +- 'electron': `argv[1]` varies depending on whether the electron application is packaged +- 'user': all of the arguments from the user + +For example: + +```js +program.parse(process.argv); // Explicit, node conventions +program.parse(); // Implicit, and auto-detect electron +program.parse(['-f', 'filename'], { from: 'user' }); +``` + +### Parsing Configuration + +If the default parsing does not suit your needs, there are some behaviours to support other usage patterns. + +By default program options are recognised before and after subcommands. To only look for program options before subcommands, use `.enablePositionalOptions()`. This lets you use +an option for a different purpose in subcommands. + +Example file: [positional-options.js](./examples/positional-options.js) + +With positional options, the `-b` is a program option in the first line and a subcommand option in the second line: + +```sh +program -b subcommand +program subcommand -b +``` + +By default options are recognised before and after command-arguments. To only process options that come +before the command-arguments, use `.passThroughOptions()`. This lets you pass the arguments and following options through to another program +without needing to use `--` to end the option processing. +To use pass through options in a subcommand, the program needs to enable positional options. + +Example file: [pass-through-options.js](./examples/pass-through-options.js) + +With pass through options, the `--port=80` is a program option in the first line and passed through as a command-argument in the second line: + +```sh +program --port=80 arg +program arg --port=80 +``` + +By default the option processing shows an error for an unknown option. To have an unknown option treated as an ordinary command-argument and continue looking for options, use `.allowUnknownOption()`. This lets you mix known and unknown options. + +By default the argument processing does not display an error for more command-arguments than expected. +To display an error for excess arguments, use`.allowExcessArguments(false)`. + +### Legacy options as properties + +Before Commander 7, the option values were stored as properties on the command. +This was convenient to code but the downside was possible clashes with +existing properties of `Command`. You can revert to the old behaviour to run unmodified legacy code by using `.storeOptionsAsProperties()`. + +```js +program + .storeOptionsAsProperties() + .option('-d, --debug') + .action((commandAndOptions) => { + if (commandAndOptions.debug) { + console.error(`Called ${commandAndOptions.name()}`); + } + }); +``` + +### TypeScript + +If you use `ts-node` and stand-alone executable subcommands written as `.ts` files, you need to call your program through node to get the subcommands called correctly. e.g. + +```bash +node -r ts-node/register pm.ts +``` + +### createCommand() + +This factory function creates a new command. It is exported and may be used instead of using `new`, like: + +```js +const { createCommand } = require('commander'); +const program = createCommand(); +``` + +`createCommand` is also a method of the Command object, and creates a new command rather than a subcommand. This gets used internally +when creating subcommands using `.command()`, and you may override it to +customise the new subcommand (example file [custom-command-class.js](./examples/custom-command-class.js)). + +### Node options such as `--harmony` + +You can enable `--harmony` option in two ways: + +- Use `#! /usr/bin/env node --harmony` in the subcommands scripts. (Note Windows does not support this pattern.) +- Use the `--harmony` option when call the command, like `node --harmony examples/pm publish`. The `--harmony` option will be preserved when spawning subcommand process. + +### Debugging stand-alone executable subcommands + +An executable subcommand is launched as a separate child process. + +If you are using the node inspector for [debugging](https://nodejs.org/en/docs/guides/debugging-getting-started/) executable subcommands using `node --inspect` et al, +the inspector port is incremented by 1 for the spawned subcommand. + +If you are using VSCode to debug executable subcommands you need to set the `"autoAttachChildProcesses": true` flag in your launch.json configuration. + +### Override exit and output handling + +By default Commander calls `process.exit` when it detects errors, or after displaying the help or version. You can override +this behaviour and optionally supply a callback. The default override throws a `CommanderError`. + +The override callback is passed a `CommanderError` with properties `exitCode` number, `code` string, and `message`. The default override behaviour is to throw the error, except for async handling of executable subcommand completion which carries on. The normal display of error messages or version or help +is not affected by the override which is called after the display. + +```js +program.exitOverride(); + +try { + program.parse(process.argv); +} catch (err) { + // custom processing... +} +``` + +By default Commander is configured for a command-line application and writes to stdout and stderr. +You can modify this behaviour for custom applications. In addition, you can modify the display of error messages. + +Example file: [configure-output.js](./examples/configure-output.js) + +```js +function errorColor(str) { + // Add ANSI escape codes to display text in red. + return `\x1b[31m${str}\x1b[0m`; +} + +program + .configureOutput({ + // Visibly override write routines as example! + writeOut: (str) => process.stdout.write(`[OUT] ${str}`), + writeErr: (str) => process.stdout.write(`[ERR] ${str}`), + // Highlight errors in color. + outputError: (str, write) => write(errorColor(str)) + }); +``` + +### Additional documentation + +There is more information available about: + +- [deprecated](./docs/deprecated.md) features still supported for backwards compatibility +- [options taking varying arguments](./docs/options-taking-varying-arguments.md) + +## Examples + +In a single command program, you might not need an action handler. + +Example file: [pizza](./examples/pizza) + +```js +const { program } = require('commander'); + +program + .description('An application for pizza ordering') + .option('-p, --peppers', 'Add peppers') + .option('-c, --cheese ', 'Add the specified type of cheese', 'marble') + .option('-C, --no-cheese', 'You do not want any cheese'); + +program.parse(); + +const options = program.opts(); +console.log('you ordered a pizza with:'); +if (options.peppers) console.log(' - peppers'); +const cheese = !options.cheese ? 'no' : options.cheese; +console.log(' - %s cheese', cheese); +``` + +In a multi-command program, you will have action handlers for each command (or stand-alone executables for the commands). + +Example file: [deploy](./examples/deploy) + +```js +const { Command } = require('commander'); +const program = new Command(); + +program + .version('0.0.1') + .option('-c, --config ', 'set config path', './deploy.conf'); + +program + .command('setup [env]') + .description('run setup commands for all envs') + .option('-s, --setup_mode ', 'Which setup mode to use', 'normal') + .action((env, options) => { + env = env || 'all'; + console.log('read config from %s', program.opts().config); + console.log('setup for %s env(s) with %s mode', env, options.setup_mode); + }); + +program + .command('exec + + + + +``` + +If you have multiple `webpack` entry points, they will all be included with `script` tags in the generated HTML. + +If you have any CSS assets in webpack's output (for example, CSS extracted with the [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin)) +then these will be included with `` tags in the HTML head. + +If you have plugins that make use of it, `html-webpack-plugin` should be ordered first before any of the integrated Plugins. + +

        Options

        + +You can pass a hash of configuration options to `html-webpack-plugin`. +Allowed values are as follows: + +|Name|Type|Default|Description| +|:--:|:--:|:-----:|:----------| +|**`title`**|`{String}`|`Webpack App`|The title to use for the generated HTML document| +|**`filename`**|`{String\|Function}`|`'index.html'`|The file to write the HTML to. Defaults to `index.html`. You can specify a subdirectory here too (eg: `assets/admin.html`). The `[name]` placeholder will be replaced with the entry name. Can also be a function e.g. `(entryName) => entryName + '.html'`. | +|**`template`**|`{String}`|``|`webpack` relative or absolute path to the template. By default it will use `src/index.ejs` if it exists. Please see the [docs](https://github.com/jantimon/html-webpack-plugin/blob/master/docs/template-option.md) for details| +|**`templateContent`**|`{string\|Function\|false}`|false| Can be used instead of `template` to provide an inline template - please read the [Writing Your Own Templates](https://github.com/jantimon/html-webpack-plugin#writing-your-own-templates) section | +|**`templateParameters`**|`{Boolean\|Object\|Function}`| `false`| Allows to overwrite the parameters used in the template - see [example](https://github.com/jantimon/html-webpack-plugin/tree/master/examples/template-parameters) | +|**`inject`**|`{Boolean\|String}`|`true`|`true \|\| 'head' \|\| 'body' \|\| false` Inject all assets into the given `template` or `templateContent`. When passing `'body'` all javascript resources will be placed at the bottom of the body element. `'head'` will place the scripts in the head element. Passing `true` will add it to the head/body depending on the `scriptLoading` option. Passing `false` will disable automatic injections. - see the [inject:false example](https://github.com/jantimon/html-webpack-plugin/tree/master/examples/custom-insertion-position)| +|**`publicPath`**|`{String\|'auto'}`|`'auto'`|The publicPath used for script and link tags| +|**`scriptLoading`**|`{'blocking'\|'defer'\|'module'\|'systemjs-module'}`|`'defer'`| Modern browsers support non blocking javascript loading (`'defer'`) to improve the page startup performance. Setting to `'module'` adds attribute [`type="module"`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#applying_the_module_to_your_html). This also implies "defer", since modules are automatically deferred. | +|**`favicon`**|`{String}`|``|Adds the given favicon path to the output HTML| +|**`meta`**|`{Object}`|`{}`|Allows to inject `meta`-tags. E.g. `meta: {viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no'}`| +|**`base`**|`{Object\|String\|false}`|`false`|Inject a [`base`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base) tag. E.g. `base: "https://example.com/path/page.html`| +|**`minify`**|`{Boolean\|Object}`|`true` if `mode` is `'production'`, otherwise `false`|Controls if and in what ways the output should be minified. See [minification](#minification) below for more details.| +|**`hash`**|`{Boolean}`|`false`|If `true` then append a unique `webpack` compilation hash to all included scripts and CSS files (i.e. `main.js?hash=compilation_hash`). This is useful for cache busting| +|**`cache`**|`{Boolean}`|`true`|Emit the file only if it was changed| +|**`showErrors`**|`{Boolean}`|`true`|Errors details will be written into the HTML page| +|**`chunks`**|`{?}`|`?`|Allows you to add only some chunks (e.g only the unit-test chunk)| +|**`chunksSortMode`**|`{String\|Function}`|`auto`|Allows to control how chunks should be sorted before they are included to the HTML. Allowed values are `'none' \| 'auto' \| 'manual' \| {Function}`| +|**`excludeChunks`**|`{Array.}`|``|Allows you to skip some chunks (e.g don't add the unit-test chunk)| +|**`xhtml`**|`{Boolean}`|`false`|If `true` render the `link` tags as self-closing (XHTML compliant)| + +Here's an example webpack config illustrating how to use these options + +**webpack.config.js** +```js +{ + entry: 'index.js', + output: { + path: __dirname + '/dist', + filename: 'index_bundle.js' + }, + plugins: [ + new HtmlWebpackPlugin({ + title: 'My App', + filename: 'assets/admin.html' + }) + ] +} +``` + +### Generating Multiple HTML Files + +To generate more than one HTML file, declare the plugin more than +once in your plugins array + +**webpack.config.js** +```js +{ + entry: 'index.js', + output: { + path: __dirname + '/dist', + filename: 'index_bundle.js' + }, + plugins: [ + new HtmlWebpackPlugin(), // Generates default index.html + new HtmlWebpackPlugin({ // Also generate a test.html + filename: 'test.html', + template: 'src/assets/test.html' + }) + ] +} +``` + +### Writing Your Own Templates + +If the default generated HTML doesn't meet your needs you can supply +your own template. The easiest way is to use the `template` option and pass a custom HTML file. +The html-webpack-plugin will automatically inject all necessary CSS, JS, manifest +and favicon files into the markup. + +Details of other template loaders are [documented here](https://github.com/jantimon/html-webpack-plugin/blob/master/docs/template-option.md). + +```js +plugins: [ + new HtmlWebpackPlugin({ + title: 'Custom template', + // Load a custom template (lodash by default) + template: 'index.html' + }) +] +``` + +**index.html** +```html + + + + + <%= htmlWebpackPlugin.options.title %> + + + + +``` + +If you already have a template loader, you can use it to parse the template. +Please note that this will also happen if you specify the html-loader and use `.html` file as template. + +**webpack.config.js** +```js +module: { + loaders: [ + { test: /\.hbs$/, loader: "handlebars-loader" } + ] +}, +plugins: [ + new HtmlWebpackPlugin({ + title: 'Custom template using Handlebars', + template: 'index.hbs' + }) +] +``` + +You can use the `lodash` syntax out of the box. If the `inject` feature doesn't fit your needs and you want full control over the asset placement use the [default template](https://github.com/jaketrent/html-webpack-template/blob/86f285d5c790a6c15263f5cc50fd666d51f974fd/index.html) of the [html-webpack-template project](https://github.com/jaketrent/html-webpack-template) as a starting point for writing your own. + +The following variables are available in the template by default (you can extend them using the `templateParameters` option): + +- `htmlWebpackPlugin`: data specific to this plugin + + - `htmlWebpackPlugin.options`: the options hash that was passed to + the plugin. In addition to the options actually used by this plugin, + you can use this hash to pass arbitrary data through to your template. + + - `htmlWebpackPlugin.tags`: the prepared `headTags` and `bodyTags` Array to render the ``, ``, ` + * defer will result in + * + * @default 'defer' + */ + scriptLoading?: "blocking" | "defer" | "module" | "systemjs-module"; + /** + * Inject meta tags + */ + meta?: + | false // Disable injection + | { + [name: string]: + | string + | false // name content pair e.g. {viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no'}` + | { [attributeName: string]: string | boolean }; // custom properties e.g. { name:"viewport" content:"width=500, initial-scale=1" } + }; + /** + * HTML Minification options accepts the following values: + * - Set to `false` to disable minifcation + * - Set to `'auto'` to enable minifcation only for production mode + * - Set to custom minification according to + * {@link https://github.com/kangax/html-minifier#options-quick-reference} + */ + minify?: "auto" | boolean | MinifyOptions; + /** + * Render errors into the HTML page + */ + showErrors?: boolean; + /** + * The `webpack` require path to the template. + * @see https://github.com/jantimon/html-webpack-plugin/blob/master/docs/template-option.md + */ + template?: string; + /** + * Allow to use a html string instead of reading from a file + */ + templateContent?: + | false // Use the template option instead to load a file + | string + | ((templateParameters: { + [option: string]: any; + }) => string | Promise) + | Promise; + /** + * Allows to overwrite the parameters used in the template + */ + templateParameters?: + | false // Pass an empty object to the template function + | (( + compilation: Compilation, + assets: { + publicPath: string; + js: Array; + css: Array; + manifest?: string; + favicon?: string; + }, + assetTags: { + headTags: HtmlTagObject[]; + bodyTags: HtmlTagObject[]; + }, + options: ProcessedOptions + ) => { [option: string]: any } | Promise<{ [option: string]: any }>) + | { [option: string]: any }; + /** + * The title to use for the generated HTML document + */ + title?: string; + /** + * Enforce self closing tags e.g. + */ + xhtml?: boolean; + /** + * In addition to the options actually used by this plugin, you can use this hash to pass arbitrary data through + * to your template. + */ + [option: string]: any; + } + + /** + * The plugin options after adding default values + */ + interface ProcessedOptions extends Required { + filename: string; + } + + /** + * The values which are available during template execution + * + * Please keep in mind that the `templateParameter` options allows to change them + */ + interface TemplateParameter { + compilation: Compilation; + htmlWebpackPlugin: { + tags: { + headTags: HtmlTagObject[]; + bodyTags: HtmlTagObject[]; + }; + files: { + publicPath: string; + js: Array; + css: Array; + manifest?: string; + favicon?: string; + }; + options: Options; + }; + webpackConfig: any; + } + + interface Hooks { + alterAssetTags: AsyncSeriesWaterfallHook<{ + assetTags: { + scripts: HtmlTagObject[]; + styles: HtmlTagObject[]; + meta: HtmlTagObject[]; + }; + publicPath: string, + outputName: string; + plugin: HtmlWebpackPlugin; + }>; + + alterAssetTagGroups: AsyncSeriesWaterfallHook<{ + headTags: HtmlTagObject[]; + bodyTags: HtmlTagObject[]; + outputName: string; + publicPath: string, + plugin: HtmlWebpackPlugin; + }>; + + afterTemplateExecution: AsyncSeriesWaterfallHook<{ + html: string; + headTags: HtmlTagObject[]; + bodyTags: HtmlTagObject[]; + outputName: string; + plugin: HtmlWebpackPlugin; + }>; + + beforeAssetTagGeneration: AsyncSeriesWaterfallHook<{ + assets: { + publicPath: string; + js: Array; + css: Array; + favicon?: string; + manifest?: string; + }; + outputName: string; + plugin: HtmlWebpackPlugin; + }>; + + beforeEmit: AsyncSeriesWaterfallHook<{ + html: string; + outputName: string; + plugin: HtmlWebpackPlugin; + }>; + + afterEmit: AsyncSeriesWaterfallHook<{ + outputName: string; + plugin: HtmlWebpackPlugin; + }>; + } + + /** + * A tag element according to the htmlWebpackPlugin object notation + */ + interface HtmlTagObject { + /** + * Attributes of the html tag + * E.g. `{'disabled': true, 'value': 'demo'}` + */ + attributes: { + [attributeName: string]: string | boolean | null | undefined; + }; + /** + * The tag name e.g. `'div'` + */ + tagName: string; + /** + * The inner HTML + */ + innerHTML?: string; + /** + * Whether this html must not contain innerHTML + * @see https://www.w3.org/TR/html5/syntax.html#void-elements + */ + voidTag: boolean; + /** + * Meta information about the tag + * E.g. `{'plugin': 'html-webpack-plugin'}` + */ + meta: { + plugin?: string, + [metaAttributeName: string]: any; + }; + } +} diff --git a/igv_component/node_modules/htmlparser2/LICENSE b/igv_component/node_modules/htmlparser2/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..0a35e029afdc4b3a7f3141143399525f70ce499d --- /dev/null +++ b/igv_component/node_modules/htmlparser2/LICENSE @@ -0,0 +1,18 @@ +Copyright 2010, 2011, Chris Winberry . All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. \ No newline at end of file diff --git a/igv_component/node_modules/htmlparser2/README.md b/igv_component/node_modules/htmlparser2/README.md new file mode 100644 index 0000000000000000000000000000000000000000..5ec9095acf0b9f54025ae67d905391c0f6aa7879 --- /dev/null +++ b/igv_component/node_modules/htmlparser2/README.md @@ -0,0 +1,164 @@ +# htmlparser2 + +[![NPM version](http://img.shields.io/npm/v/htmlparser2.svg?style=flat)](https://npmjs.org/package/htmlparser2) +[![Downloads](https://img.shields.io/npm/dm/htmlparser2.svg?style=flat)](https://npmjs.org/package/htmlparser2) +[![Build Status](https://img.shields.io/github/workflow/status/fb55/htmlparser2/Node.js%20Test?label=tests&style=flat)](https://github.com/fb55/htmlparser2/actions?query=workflow%3A%22Node.js+Test%22) +[![Coverage](http://img.shields.io/coveralls/fb55/htmlparser2.svg?style=flat)](https://coveralls.io/r/fb55/htmlparser2) + +The fast & forgiving HTML/XML parser. + +## Installation + + npm install htmlparser2 + +A live demo of `htmlparser2` is available [here](https://astexplorer.net/#/2AmVrGuGVJ). + +## Ecosystem + +| Name | Description | +| ------------------------------------------------------------- | ------------------------------------------------------- | +| [htmlparser2](https://github.com/fb55/htmlparser2) | Fast & forgiving HTML/XML parser | +| [domhandler](https://github.com/fb55/domhandler) | Handler for htmlparser2 that turns documents into a DOM | +| [domutils](https://github.com/fb55/domutils) | Utilities for working with domhandler's DOM | +| [css-select](https://github.com/fb55/css-select) | CSS selector engine, compatible with domhandler's DOM | +| [cheerio](https://github.com/cheeriojs/cheerio) | The jQuery API for domhandler's DOM | +| [dom-serializer](https://github.com/cheeriojs/dom-serializer) | Serializer for domhandler's DOM | + +## Usage + +`htmlparser2` itself provides a callback interface that allows consumption of documents with minimal allocations. +For a more ergonomic experience, read [Getting a DOM](#getting-a-dom) below. + +```javascript +const htmlparser2 = require("htmlparser2"); +const parser = new htmlparser2.Parser({ + onopentag(name, attributes) { + /* + * This fires when a new tag is opened. + * + * If you don't need an aggregated `attributes` object, + * have a look at the `onopentagname` and `onattribute` events. + */ + if (name === "script" && attributes.type === "text/javascript") { + console.log("JS! Hooray!"); + } + }, + ontext(text) { + /* + * Fires whenever a section of text was processed. + * + * Note that this can fire at any point within text and you might + * have to stich together multiple pieces. + */ + console.log("-->", text); + }, + onclosetag(tagname) { + /* + * Fires when a tag is closed. + * + * You can rely on this event only firing when you have received an + * equivalent opening tag before. Closing tags without corresponding + * opening tags will be ignored. + */ + if (tagname === "script") { + console.log("That's it?!"); + } + }, +}); +parser.write( + "Xyz