igc-xc-score
Version:
igc-xc-score is a paragliding and hang-gliding XC scoring program in vanilla JS
2 lines • 172 kB
JavaScript
#!/usr/bin/env node
"use strict";const[_version,_year]=["1.8.0","2024"];var fs=require("fs"),v8=require("v8");function _interopNamespaceDefault(e){var n=Object.create(null);return e&&Object.keys(e).forEach((function(k){if("default"!==k){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:!0,get:function(){return e[k]}})}})),n.default=e,Object.freeze(n)}var fs__namespace=_interopNamespaceDefault(fs),v8__namespace=_interopNamespaceDefault(v8),commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x.default:x}var lookup,hasRequiredLookup,igcParser,hasRequiredIgcParser,require$$0=[{name:"Aircotec",long:"ACT",short:"I"},{name:"Cambridge Aero Instruments",long:"CAM",short:"C"},{name:"ClearNav Instruments",long:"CNI",short:null},{name:"Data Swan/DSX",long:"DSX",short:"D"},{name:"EW Avionics",long:"EWA",short:"E"},{name:"Filser",long:"FIL",short:"F"},{name:"Flarm",long:"FLA",short:"G"},{name:"Flytech",long:"FLY",short:null},{name:"Garrecht",long:"GCS",short:"A"},{name:"IMI Gliding Equipment",long:"IMI",short:"M"},{name:"Logstream",long:"LGS",short:null},{name:"LX Navigation",long:"LXN",short:"L"},{name:"LXNAV",long:"LXV",short:"V"},{name:"Naviter",long:"NAV",short:null},{name:"New Technologies",long:"NTE",short:"N"},{name:"Nielsen Kellerman",long:"NKL",short:"K"},{name:"Peschges",long:"PES",short:"P"},{name:"PressFinish Electronics",long:"PFE",short:null},{name:"Print Technik",long:"PRT",short:"R"},{name:"Scheffel",long:"SCH",short:"H"},{name:"Streamline Data Instruments",long:"SDI",short:"S"},{name:"Triadis Engineering GmbH",long:"TRI",short:"T"},{name:"Zander",long:"ZAN",short:"Z"},{name:"XCSoar",long:"XCS",short:null},{name:"LK8000",long:"XLK",short:null},{name:"GpsDump",long:"XGD",short:null},{name:"SeeYou Recorder",long:"XCM",short:null},{name:"Flyskyhy",long:"XFH",short:null},{name:"XCTrack",long:"XCT",short:null},{name:"Flymaster Live",long:"XFM",short:null},{name:"XCTracer",long:"XTR",short:null},{name:"SkyBean",long:"XSB",short:null},{name:"leGPSBip",long:"XSD",short:null},{name:"Logfly",long:"XLF",short:null},{name:"Loctome",long:"XLM",short:null}];var shimFunction,hasRequiredShimFunction,genericCollection,hasRequiredGenericCollection,igcParserExports=function(){if(hasRequiredIgcParser)return igcParser;hasRequiredIgcParser=1;var lookupManufacturer=function(){if(hasRequiredLookup)return lookup;hasRequiredLookup=1;const MANUFACTURERS=require$$0;return lookup=function(id){let short=1===id.length;id=id.toUpperCase();let manufacturers=MANUFACTURERS.filter((it=>it[short?"short":"long"]===id));return 0!==manufacturers.length?manufacturers[0].name:id},lookup}(),RE_A=/^A(\w{3})(\w{3,}?)(?:FLIGHT:(\d+)|\:(.+))?$/,RE_HFDTE=/^HFDTE(?:DATE:)?(\d{2})(\d{2})(\d{2})(?:,?(\d{2}))?/,RE_PLT_HEADER=/^H(\w)PLT(?:.{0,}?:(.*)|(.*))$/,RE_CM2_HEADER=/^H(\w)CM2(?:.{0,}?:(.*)|(.*))$/,RE_GTY_HEADER=/^H(\w)GTY(?:.{0,}?:(.*)|(.*))$/,RE_GID_HEADER=/^H(\w)GID(?:.{0,}?:(.*)|(.*))$/,RE_CID_HEADER=/^H(\w)CID(?:.{0,}?:(.*)|(.*))$/,RE_CCL_HEADER=/^H(\w)CCL(?:.{0,}?:(.*)|(.*))$/,RE_SIT_HEADER=/^H(\w)SIT(?:.{0,}?:(.*)|(.*))$/,RE_FTY_HEADER=/^H(\w)FTY(?:.{0,}?:(.*)|(.*))$/,RE_RFW_HEADER=/^H(\w)RFW(?:.{0,}?:(.*)|(.*))$/,RE_RHW_HEADER=/^H(\w)RHW(?:.{0,}?:(.*)|(.*))$/,RE_B=/^B(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{3})([NS])(\d{3})(\d{2})(\d{3})([EW])([AV])(-\d{4}|\d{5})(-\d{4}|\d{5})/,RE_K=/^K(\d{2})(\d{2})(\d{2})/,RE_IJ=/^[IJ](\d{2})(?:\d{2}\d{2}[A-Z]{3})+/,RE_TASK=/^C(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{4})([-\d]{2})(.*)/,RE_TASKPOINT=/^C(\d{2})(\d{2})(\d{3})([NS])(\d{3})(\d{2})(\d{3})([EW])(.*)/,VALID_DATA_SOURCES=["F","O","P"],IGCParser=function(){function IGCParser(options){void 0===options&&(options={}),this._result={numFlight:null,pilot:null,copilot:null,gliderType:null,registration:null,callsign:null,competitionClass:null,loggerType:null,firmwareVersion:null,hardwareVersion:null,task:null,fixes:[],dataRecords:[],security:null,errors:[]},this.fixExtensions=[],this.dataExtensions=[],this.lineNumber=0,this.prevTimestamp=null,this.options=options}return IGCParser.parse=function(str,options){void 0===options&&(options={});for(var parser=new IGCParser(options),errors=[],_i=0,_a=str.split("\n");_i<_a.length;_i++){var line=_a[_i];try{parser.processLine(line.trim())}catch(error){if(!options.lenient)throw error;errors.push(error)}}var result=parser.result;return result.errors=errors,result},Object.defineProperty(IGCParser.prototype,"result",{get:function(){if(!this._result.loggerManufacturer)throw new Error("Missing A record");if(!this._result.date)throw new Error("Missing HFDTE record");return this._result},enumerable:!1,configurable:!0}),IGCParser.prototype.processLine=function(line){this.lineNumber+=1;var recordType=line[0];if("B"===recordType){var fix=this.parseBRecord(line);this.prevTimestamp=fix.timestamp,this._result.fixes.push(fix)}else if("K"===recordType){var data=this.parseKRecord(line);this.prevTimestamp=data.timestamp,this._result.dataRecords.push(data)}else if("H"===recordType)this.processHeader(line);else if("C"===recordType)this.processTaskLine(line);else if("A"===recordType){var record=this.parseARecord(line);this._result.loggerId=record.loggerId,this._result.loggerManufacturer=record.manufacturer,null!==record.numFlight&&(this._result.numFlight=record.numFlight)}else"I"===recordType?this.fixExtensions=this.parseIJRecord(line):"J"===recordType?this.dataExtensions=this.parseIJRecord(line):"G"===recordType&&(this._result.security=(this._result.security||"")+line.slice(1))},IGCParser.prototype.processHeader=function(line){var headerType=line.slice(2,5);if("DTE"===headerType){var record=this.parseDateHeader(line);this._result.date=record.date,null!==record.numFlight&&(this._result.numFlight=record.numFlight)}else"PLT"===headerType?this._result.pilot=this.parsePilot(line):"CM2"===headerType?this._result.copilot=this.parseCopilot(line):"GTY"===headerType?this._result.gliderType=this.parseGliderType(line):"GID"===headerType?this._result.registration=this.parseRegistration(line):"CID"===headerType?this._result.callsign=this.parseCallsign(line):"CCL"===headerType?this._result.competitionClass=this.parseCompetitionClass(line):"SIT"===headerType?this._result.site=this.parseSite(line):"FTY"===headerType?this._result.loggerType=this.parseLoggerType(line):"RFW"===headerType?this._result.firmwareVersion=this.parseFirmwareVersion(line):"RHW"===headerType&&(this._result.hardwareVersion=this.parseHardwareVersion(line))},IGCParser.prototype.parseARecord=function(line){var match=line.match(RE_A);if(match)return{manufacturer:lookupManufacturer(match[1]),loggerId:match[2],numFlight:match[3]?parseInt(match[3],10):null,additionalData:match[4]||null};if(match=line.match(/^A(\w{3})(.+)?$/))return{manufacturer:lookupManufacturer(match[1]),loggerId:null,numFlight:null,additionalData:match[2]?match[2].trim():null};throw new Error("Invalid A record at line "+this.lineNumber+": "+line)},IGCParser.prototype.parseDateHeader=function(line){var match=line.match(RE_HFDTE);if(!match)throw new Error("Invalid DTE header at line "+this.lineNumber+": "+line);return{date:("8"===match[3][0]||"9"===match[3][0]?"19":"20")+match[3]+"-"+match[2]+"-"+match[1],numFlight:match[4]?parseInt(match[4],10):null}},IGCParser.prototype.parseTextHeader=function(headerType,regex,line,underscoreReplacement){void 0===underscoreReplacement&&(underscoreReplacement=" ");var match=line.match(regex);if(!match)throw new Error("Invalid "+headerType+" header at line "+this.lineNumber+": "+line);var dataSource=match[1];if(-1===VALID_DATA_SOURCES.indexOf(dataSource)&&!this.options.lenient)throw new Error("Invalid data source at line "+this.lineNumber+": "+dataSource);return(match[2]||match[3]||"").replace(/_/g,underscoreReplacement).trim()},IGCParser.prototype.parsePilot=function(line){return this.parseTextHeader("PLT",RE_PLT_HEADER,line)},IGCParser.prototype.parseCopilot=function(line){return this.parseTextHeader("CM2",RE_CM2_HEADER,line)},IGCParser.prototype.parseGliderType=function(line){return this.parseTextHeader("GTY",RE_GTY_HEADER,line)},IGCParser.prototype.parseRegistration=function(line){return this.parseTextHeader("GID",RE_GID_HEADER,line,"-")},IGCParser.prototype.parseCallsign=function(line){return this.parseTextHeader("GTY",RE_CID_HEADER,line)},IGCParser.prototype.parseCompetitionClass=function(line){return this.parseTextHeader("GID",RE_CCL_HEADER,line)},IGCParser.prototype.parseSite=function(line){return this.parseTextHeader("SIT",RE_SIT_HEADER,line)},IGCParser.prototype.parseLoggerType=function(line){return this.parseTextHeader("FTY",RE_FTY_HEADER,line)},IGCParser.prototype.parseFirmwareVersion=function(line){return this.parseTextHeader("RFW",RE_RFW_HEADER,line)},IGCParser.prototype.parseHardwareVersion=function(line){return this.parseTextHeader("RHW",RE_RHW_HEADER,line)},IGCParser.prototype.processTaskLine=function(line){this._result.task?this._result.task.points.push(this.parseTaskPoint(line)):this._result.task=this.parseTask(line)},IGCParser.prototype.parseTask=function(line){var match=line.match(RE_TASK);if(!match)throw new Error("Invalid task declaration at line "+this.lineNumber+": "+line);var lastCentury="8"===match[3][0]||"9"===match[3][0],declarationDate=(lastCentury?"19":"20")+match[3]+"-"+match[2]+"-"+match[1],declarationTime=match[4]+":"+match[5]+":"+match[6],declarationTimestamp=Date.parse(declarationDate+"T"+declarationTime+"Z"),flightDate=null;return"00"===match[7]&&"00"===match[8]&&"00"===match[9]||(flightDate=((lastCentury="8"===match[9][0]||"9"===match[9][0])?"19":"20")+match[9]+"-"+match[8]+"-"+match[7]),{declarationDate:declarationDate,declarationTime:declarationTime,declarationTimestamp:declarationTimestamp,flightDate:flightDate,taskNumber:"0000"!==match[10]?parseInt(match[10],10):null,numTurnpoints:parseInt(match[11],10),comment:match[12]||null,points:[]}},IGCParser.prototype.parseTaskPoint=function(line){var match=line.match(RE_TASKPOINT);if(!match)throw new Error("Invalid task point declaration at line "+this.lineNumber+": "+line);return{latitude:IGCParser.parseLatitude(match[1],match[2],match[3],match[4]),longitude:IGCParser.parseLongitude(match[5],match[6],match[7],match[8]),name:match[9]||null}},IGCParser.prototype.parseBRecord=function(line){if(!this._result.date)throw new Error("Missing HFDTE record before first B record");var match=line.match(RE_B);if(!match)throw new Error("Invalid B record at line "+this.lineNumber+": "+line);var time=match[1]+":"+match[2]+":"+match[3],timestamp=this.calcTimestamp(time),latitude=IGCParser.parseLatitude(match[4],match[5],match[6],match[7]),longitude=IGCParser.parseLongitude(match[8],match[9],match[10],match[11]),valid="A"===match[12],pressureAltitude="00000"===match[13]?null:parseInt(match[13],10),gpsAltitude="00000"===match[14]?null:parseInt(match[14],10),extensions={};if(this.fixExtensions)for(var _i=0,_a=this.fixExtensions;_i<_a.length;_i++){var _b=_a[_i],code=_b.code,start=_b.start,length=_b.length;extensions[code]=line.slice(start,start+length)}var enl=null;if(extensions.ENL){var enlLength=this.fixExtensions.filter((function(it){return"ENL"===it.code}))[0].length,enlMax=Math.pow(10,enlLength);enl=parseInt(extensions.ENL,10)/enlMax}return{timestamp:timestamp,time:time,latitude:latitude,longitude:longitude,valid:valid,pressureAltitude:pressureAltitude,gpsAltitude:gpsAltitude,extensions:extensions,enl:enl,fixAccuracy:extensions.FXA?parseInt(extensions.FXA,10):null}},IGCParser.prototype.parseKRecord=function(line){if(!this._result.date)throw new Error("Missing HFDTE record before first K record");if(!this.dataExtensions)throw new Error("Missing J record before first K record");var match=line.match(RE_K);if(!match)throw new Error("Invalid K record at line "+this.lineNumber+": "+line);var time=match[1]+":"+match[2]+":"+match[3],timestamp=this.calcTimestamp(time),extensions={};if(this.dataExtensions)for(var _i=0,_a=this.dataExtensions;_i<_a.length;_i++){var _b=_a[_i],code=_b.code,start=_b.start,length=_b.length;extensions[code]=line.slice(start,start+length)}return{timestamp:timestamp,time:time,extensions:extensions}},IGCParser.prototype.parseIJRecord=function(line){var match=line.match(RE_IJ);if(!match)throw new Error("Invalid "+line[0]+" record at line "+this.lineNumber+": "+line);var num=parseInt(match[1],10);if(line.length<3+7*num)throw new Error("Invalid "+line[0]+" record at line "+this.lineNumber+": "+line);for(var extensions=new Array(num),i=0;i<num;i++){var offset=3+7*i,start=parseInt(line.slice(offset,offset+2),10)-1,length=parseInt(line.slice(offset+2,offset+4),10)-1-start+1,code=line.slice(offset+4,offset+7);extensions[i]={start:start,length:length,code:code}}return extensions},IGCParser.parseLatitude=function(dd,mm,mmm,ns){var degrees=parseInt(dd,10)+parseFloat(mm+"."+mmm)/60;return"S"===ns?-degrees:degrees},IGCParser.parseLongitude=function(ddd,mm,mmm,ew){var degrees=parseInt(ddd,10)+parseFloat(mm+"."+mmm)/60;return"W"===ew?-degrees:degrees},IGCParser.prototype.calcTimestamp=function(time){for(var timestamp=Date.parse(this._result.date+"T"+time+"Z");this.prevTimestamp&×tamp<this.prevTimestamp-36e5;)timestamp+=864e5;return timestamp},IGCParser}();return igcParser=IGCParser}(),IGCParser=getDefaultExportFromCjs(igcParserExports),shim={};function requireShimFunction(){return hasRequiredShimFunction||(hasRequiredShimFunction=1,shimFunction=Function,Function.noop=function(){},Function.identity=function(value){return value},Function.by=function(by,compare){compare=compare||Object.compare,by=by||Function.identity;var compareBy=function(a,b){return compare(by(a),by(b))};return compareBy.compare=compare,compareBy.by=by,compareBy},Function.get=function(key){return function(object){return Object.get(object,key)}}),shimFunction}function requireGenericCollection(){if(hasRequiredGenericCollection)return genericCollection;function GenericCollection(){throw new Error("Can't construct. GenericCollection is a mixin.")}hasRequiredGenericCollection=1,genericCollection=GenericCollection;var DOMTokenList=commonjsGlobal.DOMTokenList||function(){};return GenericCollection.EmptyArray=Object.freeze([]),GenericCollection.prototype.addEach=function(values,mapFn,thisp){if(values&&(values instanceof Array||values instanceof DOMTokenList||values instanceof String))if(mapFn)for(var i=0;i<values.length;i++)this.add(mapFn.call(thisp,values[i]),i);else for(i=0;i<values.length;i++)this.add(values[i],i);else if(values&&Object(values)===values)if("function"==typeof values.forEach)mapFn?values.map(mapFn,thisp).forEach(this.add,this):values.forEach(this.add,this);else if("function"==typeof values.next){var value;i=0;if(mapFn)for(;value=values.next().value;)this.add(mapFn.call(thisp,value),i++);else for(;value=values.next().value;)this.add(value,i++)}else if("number"==typeof values.length)if(mapFn)for(i=0;i<values.length;i++)this.add(mapFn.call(thisp,values[i]),i);else for(i=0;i<values.length;i++)this.add(values[i],i);else mapFn?Object.keys(values).forEach((function(key){this.add(mapFn.call(thisp,values[key]),key)}),this):Object.keys(values).forEach((function(key){this.add(values[key],key)}),this);return this},GenericCollection.prototype.deleteEach=function(values,equals){return values.forEach((function(value){this.delete(value,equals)}),this),this},GenericCollection.prototype.forEach=function(callback){var thisp=arguments[1];return this.reduce((function(undefined$1,value,key,object,depth){callback.call(thisp,value,key,object,depth)}),void 0)},GenericCollection.prototype.map=function(callback){var thisp=arguments[1],result=[];return this.reduce((function(undefined$1,value,key,object,depth){result.push(callback.call(thisp,value,key,object,depth))}),void 0),result},GenericCollection.prototype.enumerate=function(start){null==start&&(start=0);var result=[];return this.reduce((function(undefined$1,value){result.push([start++,value])}),void 0),result},GenericCollection.prototype.group=function(callback,thisp,equals){equals=equals||Object.equals;var groups=[],keys=[];return this.forEach((function(value,key,object){key=callback.call(thisp,value,key,object);var group,index=keys.indexOf(key,equals);-1===index?(group=[],groups.push([key,group]),keys.push(key)):group=groups[index][1],group.push(value)})),groups},GenericCollection.prototype.toArray=function(){return this.map(Function.identity)},GenericCollection.prototype.toObject=function(){var object={};return this.reduce((function(undefined$1,value,key){object[key]=value}),void 0),object},GenericCollection.from=function(){return this.apply(this,arguments)},GenericCollection.prototype.filter=function(callback){var thisp=arguments[1],result=this.constructClone();return this.reduce((function(undefined$1,value,key,object,depth){callback.call(thisp,value,key,object,depth)&&result.add(value,key)}),void 0),result},GenericCollection.prototype.every=function(callback){var thisp=arguments[1];return this.reduce((function(result,value,key,object,depth){return result&&callback.call(thisp,value,key,object,depth)}),!0)},GenericCollection.prototype.some=function(callback){var thisp=arguments[1];return this.reduce((function(result,value,key,object,depth){return result||callback.call(thisp,value,key,object,depth)}),!1)},GenericCollection.prototype.all=function(){return this.every(Boolean)},GenericCollection.prototype.any=function(){return this.some(Boolean)},GenericCollection.prototype.min=function(compare){compare=compare||this.contentCompare||Object.compare;var first=!0;return this.reduce((function(result,value){return first?(first=!1,value):compare(value,result)<0?value:result}),void 0)},GenericCollection.prototype.max=function(compare){compare=compare||this.contentCompare||Object.compare;var first=!0;return this.reduce((function(result,value){return first?(first=!1,value):compare(value,result)>0?value:result}),void 0)},GenericCollection.prototype.sum=function(zero){return zero=void 0===zero?0:zero,this.reduce((function(a,b){return a+b}),zero)},GenericCollection.prototype.average=function(zero){var sum=void 0===zero?0:zero,count=void 0===zero?0:zero;return this.reduce((function(undefined$1,value){sum+=value,count+=1}),void 0),sum/count},GenericCollection.prototype.concat=function(){for(var result=this.constructClone(this),i=0;i<arguments.length;i++)result.addEach(arguments[i]);return result},GenericCollection.prototype.flatten=function(){var self=this;return this.reduce((function(result,array){return array.forEach((function(value){this.push(value)}),result,self),result}),[])},GenericCollection.prototype.zip=function(){var table=Array.prototype.slice.call(arguments);return table.unshift(this),Array.unzip(table)},GenericCollection.prototype.join=function(delimiter){return this.reduce((function(result,string){return void 0===result?string:result+delimiter+string}),void 0)},GenericCollection.prototype.sorted=function(compare,by,order){return(compare=compare||this.contentCompare||Object.compare).by?(by=compare.by,compare=compare.compare||this.contentCompare||Object.compare):by=by||Function.identity,void 0===order&&(order=1),this.map((function(item){return{by:by(item),value:item}})).sort((function(a,b){return compare(a.by,b.by)*order})).map((function(pair){return pair.value}))},GenericCollection.prototype.reversed=function(){return this.constructClone(this).reverse()},GenericCollection.prototype.clone=function(depth,memo){if(void 0===depth)depth=1/0;else if(0===depth)return this;var clone=this.constructClone();return this.forEach((function(value,key){clone.add(Object.clone(value,depth-1,memo),key)}),this),clone},GenericCollection.prototype.only=function(){if(1===this.length)return this.one()},GenericCollection.prototype.iterator=function(){return this.iterate.apply(this,arguments)},GenericCollection._sizePropertyDescriptor={get:function(){return this.length},enumerable:!1,configurable:!0},Object.defineProperty(GenericCollection.prototype,"size",GenericCollection._sizePropertyDescriptor),requireShimArray(),genericCollection}var hasRequiredWeakMap$1,weakMap,hasRequiredWeakMap,shimObject,hasRequiredShimObject,genericOrder,hasRequiredGenericOrder,shimArray,hasRequiredShimArray,weakMap$1={exports:{}};function requireWeakMap(){return hasRequiredWeakMap||(hasRequiredWeakMap=1,weakMap="undefined"!=typeof WeakMap?WeakMap:(hasRequiredWeakMap$1||(hasRequiredWeakMap$1=1,function(){if("undefined"==typeof ses||!ses.ok||ses.ok()){"undefined"!=typeof ses&&(ses.weakMapPermitHostObjects=weakMapPermitHostObjects);var doubleWeakMapCheckSilentFailure=!1;if("function"==typeof WeakMap){var HostWeakMap=WeakMap;if("undefined"!=typeof navigator&&/Firefox/.test(navigator.userAgent));else{var testMap=new HostWeakMap,testObject=Object.freeze({});if(testMap.set(testObject,1),1===testMap.get(testObject))return void(weakMap$1.exports=WeakMap);doubleWeakMapCheckSilentFailure=!0}}var gopn=Object.getOwnPropertyNames,defProp=Object.defineProperty,isExtensible=Object.isExtensible,HIDDEN_NAME="weakmap:ident:"+Math.random()+"___";if("undefined"!=typeof crypto&&"function"==typeof crypto.getRandomValues&&"function"==typeof ArrayBuffer&&"function"==typeof Uint8Array){var ab=new ArrayBuffer(25),u8s=new Uint8Array(ab);crypto.getRandomValues(u8s),HIDDEN_NAME="weakmap:rand:"+Array.prototype.map.call(u8s,(function(u8){return(u8%36).toString(36)})).join("")+"___"}if(defProp(Object,"getOwnPropertyNames",{value:function(obj){return gopn(obj).filter(isNotHiddenName)}}),"getPropertyNames"in Object){var originalGetPropertyNames=Object.getPropertyNames;defProp(Object,"getPropertyNames",{value:function(obj){return originalGetPropertyNames(obj).filter(isNotHiddenName)}})}!function(){var oldFreeze=Object.freeze;defProp(Object,"freeze",{value:function(obj){return getHiddenRecord(obj),oldFreeze(obj)}});var oldSeal=Object.seal;defProp(Object,"seal",{value:function(obj){return getHiddenRecord(obj),oldSeal(obj)}});var oldPreventExtensions=Object.preventExtensions;defProp(Object,"preventExtensions",{value:function(obj){return getHiddenRecord(obj),oldPreventExtensions(obj)}})}();var calledAsFunctionWarningDone=!1,nextId=0,OurWeakMap=function(){this instanceof OurWeakMap||calledAsFunctionWarning();var keys=[],values=[],id=nextId++;return Object.create(OurWeakMap.prototype,{get___:{value:constFunc((function(key,opt_default){var index,hiddenRecord=getHiddenRecord(key);return hiddenRecord?id in hiddenRecord?hiddenRecord[id]:opt_default:(index=keys.indexOf(key))>=0?values[index]:opt_default}))},has___:{value:constFunc((function(key){var hiddenRecord=getHiddenRecord(key);return hiddenRecord?id in hiddenRecord:keys.indexOf(key)>=0}))},set___:{value:constFunc((function(key,value){var index,hiddenRecord=getHiddenRecord(key);return hiddenRecord?hiddenRecord[id]=value:(index=keys.indexOf(key))>=0?values[index]=value:(index=keys.length,values[index]=value,keys[index]=key),this}))},delete___:{value:constFunc((function(key){var index,lastIndex,hiddenRecord=getHiddenRecord(key);return hiddenRecord?id in hiddenRecord&&delete hiddenRecord[id]:!((index=keys.indexOf(key))<0||(lastIndex=keys.length-1,keys[index]=void 0,values[index]=values[lastIndex],keys[index]=keys[lastIndex],keys.length=lastIndex,values.length=lastIndex,0))}))}})};OurWeakMap.prototype=Object.create(Object.prototype,{get:{value:function(key,opt_default){return this.get___(key,opt_default)},writable:!0,configurable:!0},has:{value:function(key){return this.has___(key)},writable:!0,configurable:!0},set:{value:function(key,value){return this.set___(key,value)},writable:!0,configurable:!0},delete:{value:function(key){return this.delete___(key)},writable:!0,configurable:!0}}),"function"==typeof HostWeakMap?function(){function DoubleWeakMap(){this instanceof OurWeakMap||calledAsFunctionWarning();var dset,hmap=new HostWeakMap,omap=void 0,enableSwitching=!1;return dset=doubleWeakMapCheckSilentFailure?function(key,value){return hmap.set(key,value),hmap.has(key)||(omap||(omap=new OurWeakMap),omap.set(key,value)),this}:function(key,value){if(enableSwitching)try{hmap.set(key,value)}catch(e){omap||(omap=new OurWeakMap),omap.set___(key,value)}else hmap.set(key,value);return this},Object.create(OurWeakMap.prototype,{get___:{value:constFunc((function(key,opt_default){return omap?hmap.has(key)?hmap.get(key):omap.get___(key,opt_default):hmap.get(key,opt_default)}))},has___:{value:constFunc((function(key){return hmap.has(key)||!!omap&&omap.has___(key)}))},set___:{value:constFunc(dset)},delete___:{value:constFunc((function(key){var result=!!hmap.delete(key);return omap&&omap.delete___(key)||result}))},permitHostObjects___:{value:constFunc((function(token){if(token!==weakMapPermitHostObjects)throw new Error("bogus call to permitHostObjects___");enableSwitching=!0}))}})}doubleWeakMapCheckSilentFailure&&"undefined"!=typeof Proxy&&(Proxy=void 0),DoubleWeakMap.prototype=OurWeakMap.prototype,weakMap$1.exports=DoubleWeakMap,Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:!1,configurable:!0,writable:!0})}():("undefined"!=typeof Proxy&&(Proxy=void 0),weakMap$1.exports=OurWeakMap)}function weakMapPermitHostObjects(map){map.permitHostObjects___&&map.permitHostObjects___(weakMapPermitHostObjects)}function isNotHiddenName(name){return!("weakmap:"==name.substr(0,8)&&"___"===name.substr(name.length-3))}function getHiddenRecord(key){if(key!==Object(key))throw new TypeError("Not an object: "+key);var hiddenRecord=key[HIDDEN_NAME];if(hiddenRecord&&hiddenRecord.key===key)return hiddenRecord;if(isExtensible(key)){hiddenRecord={key:key};try{return defProp(key,HIDDEN_NAME,{value:hiddenRecord,writable:!1,enumerable:!1,configurable:!1}),hiddenRecord}catch(error){return}}}function constFunc(func){return func.prototype=null,Object.freeze(func)}function calledAsFunctionWarning(){calledAsFunctionWarningDone||"undefined"==typeof console||(calledAsFunctionWarningDone=!0,console.warn("WeakMap should be invoked as new WeakMap(), not WeakMap(). This will be an error in the future."))}}()),weakMap$1.exports)),weakMap}function requireShimObject(){if(hasRequiredShimObject)return shimObject;hasRequiredShimObject=1;var WeakMap=requireWeakMap();requireShimFunction(),shimObject=Object,Object.empty=Object.freeze(Object.create(null)),Object.isObject=function(object){return Object(object)===object},Object.getValueOf=function(value){return value&&"function"==typeof value.valueOf&&(value=value.valueOf()),value};var hashMap=new WeakMap;Object.hash=function(object){return object&&"function"==typeof object.hash?""+object.hash():Object(object)===object?(hashMap.has(object)||hashMap.set(object,Math.random().toString(36).slice(2)),hashMap.get(object)):""+object};var owns=Object.prototype.hasOwnProperty;return Object.owns=function(object,key){return owns.call(object,key)},Object.has=function(object,key){if("object"!=typeof object)throw new Error("Object.has can't accept non-object: "+typeof object);if(object&&"function"==typeof object.has)return object.has(key);if("string"==typeof key)return key in object&&object[key]!==Object.prototype[key];throw new Error("Key must be a string for Object.has on plain objects")},Object.get=function(object,key,value){if("object"!=typeof object)throw new Error("Object.get can't accept non-object: "+typeof object);return object&&"function"==typeof object.get?object.get(key,value):Object.has(object,key)?object[key]:value},Object.set=function(object,key,value){object&&"function"==typeof object.set?object.set(key,value):object[key]=value},Object.addEach=function(target,source,overrides){var overridesExistingProperty=3!==arguments.length||overrides;if(source)if("function"!=typeof source.forEach||source.hasOwnProperty("forEach"))if("number"==typeof source.length)for(var index=0;index<source.length;index++)target[index]=source[index];else for(var key,keys=Object.keys(source),i=0;key=keys[i];i++)!overridesExistingProperty&&Object.owns(target,key)||(target[key]=source[key]);else!0===source.isMap?source.forEach((function(value,key){target[key]=value})):source.forEach((function(pair){target[pair[0]]=pair[1]}));else;return target},Object.defineEach=function(target,source,overrides,configurable,enumerable,writable){var overridesExistingProperty=3!==arguments.length||overrides;if(source)if("function"!=typeof source.forEach||source.hasOwnProperty("forEach"))if("number"==typeof source.length)for(var index=0;index<source.length;index++)Object.defineProperty(target,index,{value:source[index],writable:writable,configurable:configurable,enumerable:enumerable});else for(var key,keys=Object.keys(source),i=0;key=keys[i];i++)!overridesExistingProperty&&Object.owns(target,key)||Object.defineProperty(target,key,{value:source[key],writable:writable,configurable:configurable,enumerable:enumerable});else!0===source.isMap?source.forEach((function(value,key){Object.defineProperty(target,key,{value:value,writable:writable,configurable:configurable,enumerable:enumerable})})):source.forEach((function(pair){Object.defineProperty(target,pair[0],{value:pair[1],writable:writable,configurable:configurable,enumerable:enumerable})}));else;return target},Object.forEach=function(object,callback,thisp){for(var iKey,keys=Object.keys(object),i=0;iKey=keys[i];i++)callback.call(thisp,object[iKey],iKey,object)},Object.map=function(object,callback,thisp){for(var iKey,keys=Object.keys(object),i=0,result=[];iKey=keys[i];i++)result.push(callback.call(thisp,object[iKey],iKey,object));return result},Object.values=function(object){return Object.map(object,Function.identity)},Object.concat=function(){for(var object={},i=0;i<arguments.length;i++)Object.addEach(object,arguments[i]);return object},Object.from=Object.concat,Object.is=function(x,y){return x===y?0!==x||1/x==1/y:x!=x&&y!=y},Object.equals=function(a,b,equals,memo){if(equals=equals||Object.equals,(a=Object.getValueOf(a))===(b=Object.getValueOf(b)))return!0;if(Object.isObject(a)){if((memo=memo||new WeakMap).has(a))return!0;memo.set(a,!0)}if(Object.isObject(a)&&"function"==typeof a.equals)return a.equals(b,equals,memo);if(Object.isObject(b)&&"function"==typeof b.equals)return b.equals(a,equals,memo);if(Object.isObject(a)&&Object.isObject(b)&&Object.getPrototypeOf(a)===Object.prototype&&Object.getPrototypeOf(b)===Object.prototype){for(var name in a)if(!equals(a[name],b[name],equals,memo))return!1;for(var name in b)if(!(name in a)||!equals(b[name],a[name],equals,memo))return!1;return!0}return a!=a&&b!=b||(!a||!b)&&a===b},Object.compare=function(a,b){if((a=Object.getValueOf(a))===(b=Object.getValueOf(b)))return 0;var aType=typeof a,bType=typeof b;return"number"===aType&&"number"===bType?a-b:"string"===aType&&"string"===bType?a<b?-1/0:1/0:a&&"function"==typeof a.compare?a.compare(b):b&&"function"==typeof b.compare?-b.compare(a):0},Object.clone=function(value,depth,memo){if(value=Object.getValueOf(value),memo=memo||new WeakMap,void 0===depth)depth=1/0;else if(0===depth)return value;if(Object.isObject(value)){if(!memo.has(value))if(value&&"function"==typeof value.clone)memo.set(value,value.clone(depth,memo));else{var prototype=Object.getPrototypeOf(value);if(null!==prototype&&prototype!==Object.prototype)throw new Error("Can't clone "+value);var clone=Object.create(prototype);for(var key in memo.set(value,clone),value)clone[key]=Object.clone(value[key],depth-1,memo)}return memo.get(value)}return value},Object.clear=function(object){if(object&&"function"==typeof object.clear)object.clear();else for(var keys=Object.keys(object),i=keys.length;i;)delete object[keys[--i]];return object},shimObject}function requireGenericOrder(){if(hasRequiredGenericOrder)return genericOrder;hasRequiredGenericOrder=1;var Object=requireShimObject();function GenericOrder(){throw new Error("Can't construct. GenericOrder is a mixin.")}return genericOrder=GenericOrder,GenericOrder.prototype.equals=function(that,equals){return equals=equals||this.contentEquals||Object.equals,this===that||!!that&&(this.length===that.length&&this.zip(that).every((function(pair){return equals(pair[0],pair[1])})))},GenericOrder.prototype.compare=function(that,compare){if(compare=compare||this.contentCompare||Object.compare,this===that)return 0;if(!that)return 1;var length=Math.min(this.length,that.length),comparison=this.zip(that).reduce((function(comparison,pair,index){return 0===comparison?index>=length?comparison:compare(pair[0],pair[1]):comparison}),0);return 0===comparison?this.length-that.length:comparison},GenericOrder.prototype.toJSON=function(){return this.toArray()},genericOrder}function requireShimArray(){if(hasRequiredShimArray)return shimArray;hasRequiredShimArray=1,requireShimFunction();var GenericCollection=requireGenericCollection(),GenericOrder=requireGenericOrder(),WeakMap=requireWeakMap();shimArray=Array;var array_splice=Array.prototype.splice,array_slice=Array.prototype.slice;Array.empty||(Array.empty=[],Object.freeze&&Object.freeze(Array.empty)),Array.nativeFrom||(Array.nativeFrom=Array.from);var isSymbolDefined="undefined"!=typeof Symbol;function define(key,value){Object.defineProperty(Array.prototype,key,{value:value,writable:!0,configurable:!0,enumerable:!1})}Array.from=function(values,mapFn,thisArg){if(isSymbolDefined&&values&&("function"==typeof values[Symbol.iterator]||"function"==typeof mapFn))return Array.nativeFrom(values,mapFn,thisArg);var array=[];return array.addEach(values),array},Array.unzip=function(table){for(var transpose=[],length=1/0,i=0;i<table.length;i++){var row=table[i];table[i]=row.toArray(),row.length<length&&(length=row.length)}for(i=0;i<table.length;i++){row=table[i];for(var j=0;j<row.length;j++)j<length&&j in row&&(transpose[j]=transpose[j]||[],transpose[j][i]=row[j])}return transpose},define("addEach",GenericCollection.prototype.addEach),define("deleteEach",GenericCollection.prototype.deleteEach),define("toArray",GenericCollection.prototype.toArray),define("toObject",GenericCollection.prototype.toObject),define("all",GenericCollection.prototype.all),define("any",GenericCollection.prototype.any),define("min",GenericCollection.prototype.min),define("max",GenericCollection.prototype.max),define("sum",GenericCollection.prototype.sum),define("average",GenericCollection.prototype.average),define("only",GenericCollection.prototype.only),define("flatten",GenericCollection.prototype.flatten),define("zip",GenericCollection.prototype.zip),define("enumerate",GenericCollection.prototype.enumerate),define("group",GenericCollection.prototype.group),define("sorted",GenericCollection.prototype.sorted),define("reversed",GenericCollection.prototype.reversed),define("constructClone",(function(values){var clone=new this.constructor;return clone.addEach(values),clone})),define("has",(function(value,equals){return-1!==this.findValue(value,equals)})),define("get",(function(index,defaultValue){if(+index!==index)throw new Error("Indicies must be numbers");return!index in this?defaultValue:this[index]})),define("set",(function(index,value){return this[index]=value,!0})),define("add",(function(value){return this.push(value),!0})),define("delete",(function(value,equals){var index=this.findValue(value,equals);return-1!==index&&(this.spliceOne(index),!0)})),define("deleteAll",(function(value,equals){equals=equals||this.contentEquals||Object.equals;for(var count=0,index=0;index<this.length;)equals(value,this[index])?(this.swap(index,1),count++):index++;return count})),Array.prototype.find||define("find",(function(predicate){if(null==this)throw new TypeError('"this" is null or not defined');var o=Object(this),len=o.length>>>0;if("function"!=typeof predicate)throw new TypeError("predicate must be a function");for(var thisArg=arguments[1],k=0;k<len;){var kValue=o[k];if(predicate.call(thisArg,kValue,k,o))return kValue;k++}}));var deprecatedWarnNonce={};function deprecatedWarn(msg,notOnce){"undefined"!=typeof console&&"function"==typeof console.warn&&!0!==notOnce&&!1===deprecatedWarnNonce.hasOwnProperty(msg)&&(console.warn(msg),deprecatedWarnNonce[msg]++)}var ArrayFindPrototype=Object.getOwnPropertyDescriptor(Array.prototype,"find").value;function ArrayIterator(array,start,end){this.array=array,this.start=null==start?0:start,this.end=end}return define("find",(function(value,equals,index){return"function"==typeof arguments[0]&&this instanceof Array?ArrayFindPrototype.apply(this,arguments):(deprecatedWarn("Array#find usage is deprecated please use Array#findValue"),this.findValue.apply(this,arguments))})),define("findValue",(function(value,equals,index){if(index)throw new Error("Array#findValue does not support third argument: index");equals=equals||this.contentEquals||Object.equals;for(index=0;index<this.length;index++)if(index in this&&equals(value,this[index]))return index;return-1})),define("findLast",(function(value,equals){return deprecatedWarn("Array#findLast function is deprecated please use Array#findLastValue instead."),this.findLastValue.apply(this,arguments)})),define("findLastValue",(function(value,equals){equals=equals||this.contentEquals||Object.equals;var index=this.length;do{if(--index in this&&equals(this[index],value))return index}while(index>0);return-1})),define("swap",(function(start,length,plus){var args,plusLength,i,j,returnValue;if(start>this.length&&(this.length=start),void 0!==plus){if(args=[start,length],Array.isArray(plus)||(plus=array_slice.call(plus)),i=0,(plusLength=plus.length)<1e3){for(;i<plusLength;i++)args[i+2]=plus[i];return array_splice.apply(this,args)}for(returnValue=array_splice.apply(this,args);i<plusLength;){for(args=[start+i,0],j=2;j<1002&&i<plusLength;j++,i++)args[j]=plus[i];array_splice.apply(this,args)}return returnValue}return void 0!==length?array_splice.call(this,start,length):void 0!==start?array_splice.call(this,start):[]})),define("peek",(function(){return this[0]})),define("poke",(function(value){this.length>0&&(this[0]=value)})),define("peekBack",(function(){if(this.length>0)return this[this.length-1]})),define("pokeBack",(function(value){this.length>0&&(this[this.length-1]=value)})),define("one",(function(){for(var i in this)if(Object.owns(this,i))return this[i]})),Array.prototype.clear||define("clear",(function(){return this.length=0,this})),define("compare",(function(that,compare){var i,length,relative;if(compare=compare||Object.compare,this===that)return 0;if(!that||!Array.isArray(that))return GenericOrder.prototype.compare.call(this,that,compare);for(length=this.length<that.length?this.length:that.length,i=0;i<length;i++)if(i in this){if(!(i in that))return-1;if(relative=compare(this[i],that[i]))return relative}else if(i in that)return 1;return this.length-that.length})),define("equals",(function(that,equals){equals=equals||Object.equals;var i=0,length=this.length;if(this===that)return!0;if(!that||!Array.isArray(that))return GenericOrder.prototype.equals.call(this,that);if(length!==that.length)return!1;for(;i<length;++i)if(i in this){if(!(i in that))return!1;if(!equals(this[i],that[i]))return!1}else if(i in that)return!1;return!0})),define("clone",(function(depth,memo){if(null==depth)depth=1/0;else if(0===depth)return this;if((memo=memo||new WeakMap).has(this))return memo.get(this);var clone=new Array(this.length);for(var i in memo.set(this,clone),this)clone[i]=Object.clone(this[i],depth-1,memo);return clone})),define("iterate",(function(start,end){return new ArrayIterator(this,start,end)})),void 0===Array.prototype.spliceOne&&define("spliceOne",(function(index,itemToAdd){var len=this.length;if(len)if(1===arguments.length){for(;index<len;)this[index]=this[index+1],index++;this.length--}else this[index]=itemToAdd})),define("Iterator",ArrayIterator),ArrayIterator.prototype.__iterationObject=null,Object.defineProperty(ArrayIterator.prototype,"_iterationObject",{get:function(){return this.__iterationObject||(this.__iterationObject={done:!1,value:null})}}),ArrayIterator.prototype.next=function(){return this.start===(null==this.end?this.array.length:this.end)?(this._iterationObject.done=!0,this._iterationObject.value=void 0):this._iterationObject.value=this.array[this.start++],this._iterationObject},shimArray}var hasRequiredShimRegexp,hasRequiredShim,genericSet,hasRequiredGenericSet,shimRegexp={};function requireShim(){return hasRequiredShim||(hasRequiredShim=1,requireShimArray(),requireShimObject(),requireShimFunction(),function(){if(hasRequiredShimRegexp)return shimRegexp;if(hasRequiredShimRegexp=1,!RegExp.escape){var special=/[-[\]{}()*+?.\\^$|,#\s]/g;RegExp.escape=function(string){return string.replace(special,"\\$&")}}}()),shim}function requireGenericSet(){if(hasRequiredGenericSet)return genericSet;function GenericSet(){throw new Error("Can't construct. GenericSet is a mixin.")}hasRequiredGenericSet=1,genericSet=GenericSet,GenericSet.prototype.isSet=!0,GenericSet.prototype.union=function(that){var union=this.constructClone(this);return union.addEach(that),union},GenericSet.prototype.intersection=function(that){return this.constructClone(this.filter((function(value){return that.has(value)})))},GenericSet.prototype.difference=function(that){var union=this.constructClone(this);return union.deleteEach(that),union},GenericSet.prototype.symmetricDifference=function(that){var union=this.union(that),intersection=this.intersection(that);return union.difference(intersection)},GenericSet.prototype.deleteAll=function(value){return+this.delete(value)},GenericSet.prototype.equals=function(that,equals){var self=this;return that&&"function"==typeof that.reduce&&this.length===that.length&&that.reduce((function(equal,value){return equal&&self.has(value,equals)}),!0)},GenericSet.prototype.forEach=function(callback){var thisp=arguments[1];return this.reduce((function(undefined$1,value,key,object,depth){callback.call(thisp,value,value,object,depth)}),void 0)},GenericSet.prototype.toJSON=function(){return this.toArray()},GenericSet.prototype.contains=function(value){return this.has(value)},GenericSet.prototype.remove=function(value){return this.delete(value)},GenericSet.prototype.toggle=function(value){this.has(value)?this.delete(value):this.add(value)};var _valuesArrayFunction=function(value,key){return value};GenericSet.prototype.valuesArray=function(){return this.map(_valuesArrayFunction)};var _entriesArrayFunction=function(value,key){return[key,value]};return GenericSet.prototype.entriesArray=function(){return this.map(_entriesArrayFunction)},genericSet}var _list,hasRequired_list,iterator,hasRequiredIterator,genericMap,hasRequiredGenericMap,_dict,hasRequired_dict,treeLog,hasRequiredTreeLog,_fastSet,hasRequired_fastSet,hasRequired_set,hasRequired_map,_map={exports:{}},_set={exports:{}};function require_list(){if(hasRequired_list)return _list;hasRequired_list=1,_list=List,requireShim();var GenericCollection=requireGenericCollection(),GenericOrder=requireGenericOrder();function List(values,equals,getDefault){return List._init(List,this,values,equals,getDefault)}function ListIterator(head){this.head=head,this.at=head.next}function Node(value){this.value=value,this.prev=null,this.next=null}return List._init=function(constructor,object,values,equals,getDefault){if(!(object instanceof constructor))return new constructor(values,equals,getDefault);var head=object.head=new object.Node;head.next=head,head.prev=head,object.contentEquals=equals||Object.equals,object.getDefault=getDefault||Function.noop,object.length=0,object.addEach(values)},List.List=List,Object.addEach(List.prototype,GenericCollection.prototype),Object.addEach(List.prototype,GenericOrder.prototype),List.from=GenericCollection.from,List.prototype.constructClone=function(values){return new this.constructor(values,this.contentEquals,this.getDefault)},List.prototype.find=function(value,equals,index){equals=equals||this.contentEquals;for(var head=this.head,at=this.scan(index,head.next);at!==head;){if(equals(at.value,value))return at;at=at.next}},List.prototype.findLast=function(value,equals,index){equals=equals||this.contentEquals;for(var head=this.head,at=this.scan(index,head.prev);at!==head;){if(equals(at.value,value))return at;at=at.prev}},List.prototype.has=function(value,equals){return!!this.find(value,equals)},List.prototype.get=function(value,equals){var found=this.find(value,equals);return found?found.value:this.getDefault(value)},List.prototype.delete=function(value,equals){var found=this.findLast(value,equals);return!!found&&(found.delete(),this.length--,!0)},List.prototype.deleteAll=function(value,equals){equals=equals||this.contentEquals;for(var head=this.head,at=head.next,count=0;at!==head;)equals(value,at.value)&&(at.delete(),count++),at=at.next;return this.length-=count,count},List.prototype.clear=function(){this.head.next=this.head.prev=this.head,this.length=0},List.prototype.add=function(value){var node=new this.Node(value);return this._addNode(node)},List.prototype._addNode=function(node){return this.head.addBefore(node),this.length++,!0},List.prototype.push=function(){for(var head=this.head,i=0;i<arguments.length;i++){var value=arguments[i],node=new this.Node(value);head.addBefore(node)}this.length+=arguments.length},List.prototype.unshift=function(){for(var at=this.head,i=0;i<arguments.length;i++){var value=arguments[i],node=new this.Node(value);at.addAfter(node),at=node}this.length+=arguments.length},List.prototype._shouldPop=function(){var value,head=this.head;return head.prev!==head&&(value=head.prev.value),value},List.prototype.pop=function(_before,_after){var value,head=this.head;if(head.prev!==head){value=head.prev.value;var index=this.length-1,popDispatchValueArray=_before?_before.call(this,value,index):void 0;head.prev.delete(),this.length--,_after&&_after.call(this,value,index,popDispatchValueArray)}return value},List.prototype.shift=function(_before,_after){var value,head=this.head;if(head.prev!==head){value=head.next.value;var dispatchValueArray=_before?_before.call(this,value,0):void 0;head.next.delete(),this.length--,_after&&_after.call(this,value,0,dispatchValueArray)}return value},List.prototype.peek=function(){if(this.head!==this.head.next)return this.head.next.value},List.prototype.poke=function(value){this.head!==this.head.next?this.head.next.value=value:this.push(value)},List.prototype.one=function(){return this.peek()},List.prototype.scan=function(at,fallback){var head=this.head;if("number"==typeof at){var count=at;if(count>=0)for(at=head.next;count&&(count--,(at=at.next)!=head););else for(at=head;count<0&&(count++,(at=at.prev)!=head););return at}return at||fallback},List.prototype.slice=function(at,end){var sliced=[],head=this.head;for(at=this.scan(at,head.next),end=this.scan(end,head);at!==end&&at!==head;)sliced.push(at.value),at=at.next;return sliced},List.prototype.splice=function(at,length){return this.swap(at,length,Array.prototype.slice.call(arguments,2))},List.prototype.swap=function(start,length,plus,_before,_after){var initial=start;start=this.scan(start,this.head),null==length&&(length=1/0),plus=Array.from(plus);for(var minus=[],at=start;length--&&length>=0&&at!==this.head;)minus.push(at.value),at=at.next;_before&&_before.call(this,start,plus,minus);at=start;var i=0;for(at=start;i<minus.length;i++,at=at.next)at.delete();null==initial&&at===this.head&&(at=this.head.next);for(i=0;i<plus.length;i++){var node=new this.Node(plus[i]);at.addBefore(node)}return this.length+=plus.length-minus.length,_after&&_after.call(this,start,plus,minus),minus},List.prototype.reverse=function(){var at=this.head;do{var temp=at.next;at.next=at.prev,at.prev=temp,at=at.next}while(at!==this.head);return this},List.prototype.sort=function(){this.swap(0,this.length,this.sorted.apply(this,arguments))},List.prototype.reduce=function(callback,basis){for(var thisp=arguments[2],head=this.head,at=head.next;at!==head;)basis=callback.call(thisp,basis,at.value,at,this),at=at.next;return basis},List.prototype.reduceRight=function(callback,basis){for(var thisp=arguments[2],head=this.head,at=head.prev;at!==head;)basis=callback.call(thisp,basis,at.value,at,this),at=at.prev;return basis},List.prototype.updateIndexes=function(node,index){for(;node!==this.head;)node.index=index++,node=node.next},List.prototype.iterate=function(){return new ListIterator(this.head)},ListIterator.prototype.__iterationObject=null,Object.defineProperty(ListIterator.prototype,"_iterationObject",{get:function(){return this.__iterationObject||(this.__iterationObject={done:!1,value:null})}}),ListIterator.prototype.next=function(){if(this.at===this.head)this._iterationObject.done=!0,this._iterationObject.value=void 0;else{var value=this.at.value;this.at=this.at.next,this._iterationObject.value=value}return this._iterationObject},List.prototype.Node=Node,Node.prototype.delete=function(){this.prev.next=this.next,this.next.prev=this.prev},Node.prototype.addBefore=function(node){var prev=this.prev;this.prev=node,node.prev=prev,prev.next=node,node.next=this},Node.prototype.addAfter=function(node){var next=this.next;this.next=node,node.next=next,next.prev=node,node.prev=this},_list}function requireIterator(){if(hasRequiredIterator)return iterator;hasRequiredIterator=1,iterator=Iterator;var Object=requireShimObject(),GenericCollection=requireGenericCollection();function Iterator(iterable,standardMode){var values=standardMode&&iterable&&iterable.values&&iterable.values();if(values&&"function"==typeof values.next)return values;if(!(this instanceof Iterator))return new Iterator(iterable);if(Array.isArray(iterable)||"string"==typeof iterable)return Iterator.iterate(iterable);if((iterable=Object(iterable))instanceof Iterator)return iterable;if(iterable.next)this.next=function(){return iterable.next()};else if(iterable.iterate){var iterator=iterable.iterate();this.next=function(){return iterator.next()}}else{if("[object Function]"!==Object.prototype.toString.call(iterable))throw new TypeError("Can't iterate "+iterable);this.next=iterable}}return Iterator.prototype.forEach=GenericCollection.prototype.forEach,Iterator.prototype.map=GenericCollection.prototype.map,Iterator.prototype.f