Skip to content

Instantly share code, notes, and snippets.

@juliushaertl
Created October 9, 2016 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juliushaertl/436af4f82da2a994726cb5c170be3b61 to your computer and use it in GitHub Desktop.
Save juliushaertl/436af4f82da2a994726cb5c170be3b61 to your computer and use it in GitHub Desktop.
hackzogtum.user.js
// ==UserScript==
// @name Hackzogtum Donate via Amazon
// @version 1.70
// @description Donate money to Hackzogtum, while shopping at different Shops
// @match *://www.amazon.de/*
// @grant GM_getValue
// @grant GM_setValue
// @updateURL
// @downloadURL
// @run-at document-start
// ==/UserScript==
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){var ms=require("ms");module.exports={bouncer:{url:"http://www.hackerspace-bamberg.de/bckspc_widgets/bouncer.php",salt:"verySecureSalt4223"},affilinet:{accountId:737145,timeout:ms("10 days"),partner:[{id:-1,domain:"elv.de"},{id:-1,domain:"lieferheld.de"},{id:-1,domain:"farnell.de"},{id:-1,domain:"reichelt.de"},{id:-1,domain:"lieferando.de"}]},thomann:{offid:1,affid:18,timeout:ms("10 days")}}},{ms:23}],2:[function(require,module,exports){module.exports={bouncer:{url:"http://test.de/bouncer.php",salt:"verySecureSalt4223"}}},{}],3:[function(require,module,exports){var URI=require("URIjs");var AffiliateManager=function(){this.affiliates=[]};AffiliateManager.prototype.addAffiliate=function(affiliate){this.affiliates.push(affiliate)};AffiliateManager.prototype.run=function(url){url=URI(url);var newUrl=false;this.affiliates.every(function(affiliate){if(affiliate.visit(url)){newUrl=affiliate.getUrl(url);return false}return true});return newUrl};module.exports=AffiliateManager},{URIjs:16}],4:[function(require,module,exports){var URI=require("URIjs");var md5=require("md5");var config=require("./configuration");var BOUNCER_TARGET_PARAMETER="url";var BOUNCER_TOKEN_PARAMETER="v";var BOUNCER_HTTP_REDIRECT_PARAMETER="head";var Bouncer=module.exports=function Bouncer(){};Bouncer.getMetaRedirectBouncerUrl=function(target){return this.__getBouncerUrl(target).toString()};Bouncer.getHttpRedirectBouncerUrl=function(target){return this.__getBouncerUrl(target).addQuery(BOUNCER_HTTP_REDIRECT_PARAMETER,"true").toString()};Bouncer.__getBouncerUrl=function(target){var token=md5.digest_s(config.bouncer.salt+target);return URI(config.bouncer.url).addQuery(BOUNCER_TARGET_PARAMETER,target).addQuery(BOUNCER_TOKEN_PARAMETER,token)}},{"./configuration":12,URIjs:16,md5:22}],5:[function(require,module,exports){function IFrame(target){this.target=target}IFrame.prototype.getIFrameElement=function(){var iFrame=document.createElement("iframe");iFrame.setAttribute("src",this.target);iFrame.style.width="1px";iFrame.style.height="1px";return iFrame};IFrame.prototype.inject=function(domElement){var iFrame=this.getIFrameElement();domElement.appendChild(iFrame)};module.exports=IFrame},{}],6:[function(require,module,exports){(function(global){var ms=require("ms");function Persistence(){}Persistence.set=function(key,value,expirationMs){var store=StoredValue.create(value,expirationMs);GM_setValue(key,store.serialize())};Persistence.get=function(key){var stored=GM_getValue(key,false);if(stored===false){return false}var storedValue=StoredValue.unserialize(stored);if(storedValue.isExpired()){this.remove(key);return false}return storedValue.getValue()};Persistence.remove=function(key){if(global.GM_deleteValue){GM_deleteValue(key)}else{this.set(key,false,ms("1 day"))}};function StoredValue(value,expireOn){this.value=value;this.expireOn=expireOn}StoredValue.create=function(value,expirationMs){var expireOn=StoredValue.getCurrentTimestamp()+expirationMs;return new StoredValue(value,expireOn)};StoredValue.prototype.isExpired=function(){return StoredValue.getCurrentTimestamp()>this.expireOn};StoredValue.getCurrentTimestamp=function(){return parseInt(Date.now(),10)};StoredValue.prototype.getValue=function(){return this.value};StoredValue.prototype.serialize=function(){return JSON.stringify({value:this.value,expireOn:this.expireOn})};StoredValue.unserialize=function(serializedObject){var unserializedData=JSON.parse(serializedObject);return new StoredValue(unserializedData.value,unserializedData.expireOn)};module.exports=Persistence}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{ms:23}],7:[function(require,module,exports){module.exports={endsWith:function(str,suffix){return str.indexOf(suffix,str.length-suffix.length)!==-1}}},{}],8:[function(require,module,exports){var Persistence=require("./Persistence");var TagTimeout=function(key,timeoutMs){this.key=key;this.timeoutMs=timeoutMs};TagTimeout.prototype.isAlreadyTagged=function(){return Persistence.get(this.key)!==false};TagTimeout.prototype.markAsTagged=function(){Persistence.set(this.key,true,this.timeoutMs)};TagTimeout.prototype.clear=function(){Persistence.remove(this.key)};module.exports=TagTimeout},{"./Persistence":6}],9:[function(require,module,exports){var TagTimeout=require("../TagTimeout");var Bouncer=require("../Bouncer");var IFrame=require("../IFrame");var URI=require("URIjs");var TRACKER_URL="http://partners.webmasterplan.com/click.asp";var Affilinet=function(siteId,domain,accountId,tagTimeout){this.siteId=siteId;this.domain=domain;this.accountId=accountId;this.tagTimeout=tagTimeout};Affilinet.factory=function(domain,siteId,accountId,timeoutMs){var tagTimeout=new TagTimeout("affilinet-"+domain,timeoutMs);return new Affilinet(domain,siteId,accountId,tagTimeout)};Affilinet.prototype.visit=function(url){if(url.domain()=="webmasterplan.com"&&url.filename()=="registersale.asp"&&url.hasQuery("site",this.siteId)){this.tagTimeout.clear();return false}if(url.domain()==this.domain&&!this.tagTimeout.isAlreadyTagged()){return true}return false};Affilinet.prototype.__getAffilinetTrackingUrl=function(){return URI(TRACKER_URL).addQuery("ref",this.accountId).addQuery("site",this.siteId).toString()};Affilinet.prototype.__getIFrameUrl=function(){return Bouncer.getMetaRedirectBouncerUrl(this.__getAffilinetTrackingUrl())};Affilinet.prototype.getUrl=function(url){if(this.tagTimeout.isAlreadyTagged()){return url}this.tagTimeout.markAsTagged();var iFrame=new IFrame(this.__getIFrameUrl());document.addEventListener("DOMContentLoaded",function(){iFrame.inject(document.body)});return url};module.exports=Affilinet},{"../Bouncer":4,"../IFrame":5,"../TagTimeout":8,URIjs:16}],10:[function(require,module,exports){var StringUtils=require("../StringUtils");var Amazon=function(tld,tag){this.tld=tld;this.tag=tag};Amazon.prototype.visit=function(url){if(url.domain()=="amazon."+this.tld&&url.path().toString().match("(dp|gp/offer-listing|gp/product|.+?/dp)/[A-Z0-9]{10}.*")){return true}return false};Amazon.prototype.getUrl=function(url){return url.removeQuery("tag").addQuery("tag",this.tag)};module.exports=Amazon},{"../StringUtils":7}],11:[function(require,module,exports){var StringUtils=require("../StringUtils");var Thomann=function(offid,affid,tagTimeout){this.offid=offid;this.affid=affid;this.tagTimeout=tagTimeout};Thomann.prototype.visit=function(url){if(url.domain()=="clickfire.de"&&url.subdomain()=="thomann"&&url.filename()=="add_tr"){this.tagTimeout.clear();return false}if(url.domain()=="thomann.de"&&StringUtils.endsWith(url.path().toString(),".htm")){if(this.isAlreadyTagged()){return false}return true}return false};Thomann.prototype.getUrl=function(url){if(this.isAlreadyTagged()){return url}this.markAsTagged();return url.removeQuery(["offid","affid"]).addQuery("offid",this.offid).addQuery("affid",this.affid)};Thomann.prototype.markAsTagged=function(){if(this.tagTimeout){this.tagTimeout.markAsTagged()}};Thomann.prototype.isAlreadyTagged=function(){return this.tagTimeout&&this.tagTimeout.isAlreadyTagged()};module.exports=Thomann},{"../StringUtils":7}],12:[function(require,module,exports){(function(process){var defaultConfiguration=require("../config/default.js");var extend=require("util")._extend;var config=defaultConfiguration;if(process.env.NODE_ENV=="development"){var testConfiguration=require("../config/test.js");config=extend(config,testConfiguration)}module.exports=config}).call(this,require("_process"))},{"../config/default.js":1,"../config/test.js":2,_process:19,util:21}],13:[function(require,module,exports){var AffiliateManager=require("./lib/AffiliateManager");var Amazon=require("./lib/affiliates/Amazon");var Thomann=require("./lib/affiliates/Thomann");var Affilinet=require("./lib/affiliates/Affilinet");var TagTimeout=require("./lib/TagTimeout");var config=require("./lib/configuration");var currentUrl=window.location.href;var tagTimeout=new TagTimeout("th0mann",config.thomann.timeout);var manager=new AffiliateManager;manager.addAffiliate(new Amazon("de","hackzcobur-21"));var newUrl=manager.run(currentUrl);if(newUrl&&newUrl.toString()!=currentUrl){if(window.location.replace){window.location.replace(newUrl.toString())}else{window.location.href=newUrl.toString()}}},{"./lib/AffiliateManager":3,"./lib/TagTimeout":8,"./lib/affiliates/Affilinet":9,"./lib/affiliates/Amazon":10,"./lib/affiliates/Thomann":11,"./lib/configuration":12}],14:[function(require,module,exports){(function(root,factory){"use strict";if(typeof exports==="object"){module.exports=factory()}else if(typeof define==="function"&&define.amd){define(factory)}else{root.IPv6=factory(root)}})(this,function(root){"use strict";var _IPv6=root&&root.IPv6;function bestPresentation(address){var _address=address.toLowerCase();var segments=_address.split(":");var length=segments.length;var total=8;if(segments[0]===""&&segments[1]===""&&segments[2]===""){segments.shift();segments.shift()}else if(segments[0]===""&&segments[1]===""){segments.shift()}else if(segments[length-1]===""&&segments[length-2]===""){segments.pop()}length=segments.length;if(segments[length-1].indexOf(".")!==-1){total=7}var pos;for(pos=0;pos<length;pos++){if(segments[pos]===""){break}}if(pos<total){segments.splice(pos,1,"0000");while(segments.length<total){segments.splice(pos,0,"0000")}length=segments.length}var _segments;for(var i=0;i<total;i++){_segments=segments[i].split("");for(var j=0;j<3;j++){if(_segments[0]==="0"&&_segments.length>1){_segments.splice(0,1)}else{break}}segments[i]=_segments.join("")}var best=-1;var _best=0;var _current=0;var current=-1;var inzeroes=false;for(i=0;i<total;i++){if(inzeroes){if(segments[i]==="0"){_current+=1}else{inzeroes=false;if(_current>_best){best=current;_best=_current}}}else{if(segments[i]==="0"){inzeroes=true;current=i;_current=1}}}if(_current>_best){best=current;_best=_current}if(_best>1){segments.splice(best,_best,"")}length=segments.length;var result="";if(segments[0]===""){result=":"}for(i=0;i<length;i++){result+=segments[i];if(i===length-1){break}result+=":"}if(segments[length-1]===""){result+=":"}return result}function noConflict(){if(root.IPv6===this){root.IPv6=_IPv6}return this}return{best:bestPresentation,noConflict:noConflict}})},{}],15:[function(require,module,exports){(function(root,factory){"use strict";if(typeof exports==="object"){module.exports=factory()}else if(typeof define==="function"&&define.amd){define(factory)}else{root.SecondLevelDomains=factory(root)}})(this,function(root){"use strict";var _SecondLevelDomains=root&&root.SecondLevelDomains;var SLD={list:{ac:" com gov mil net org ",ae:" ac co gov mil name net org pro sch ",af:" com edu gov net org ",al:" com edu gov mil net org ",ao:" co ed gv it og pb ",ar:" com edu gob gov int mil net org tur ",at:" ac co gv or ",au:" asn com csiro edu gov id net org ",ba:" co com edu gov mil net org rs unbi unmo unsa untz unze ",bb:" biz co com edu gov info net org store tv ",bh:" biz cc com edu gov info net org ",bn:" com edu gov net org ",bo:" com edu gob gov int mil net org tv ",br:" adm adv agr am arq art ato b bio blog bmd cim cng cnt com coop ecn edu eng esp etc eti far flog fm fnd fot fst g12 ggf gov imb ind inf jor jus lel mat med mil mus net nom not ntr odo org ppg pro psc psi qsl rec slg srv tmp trd tur tv vet vlog wiki zlg ",bs:" com edu gov net org ",bz:" du et om ov rg ",ca:" ab bc mb nb nf nl ns nt nu on pe qc sk yk ",ck:" biz co edu gen gov info net org ",cn:" ac ah bj com cq edu fj gd gov gs gx gz ha hb he hi hl hn jl js jx ln mil net nm nx org qh sc sd sh sn sx tj tw xj xz yn zj ",co:" com edu gov mil net nom org ",cr:" ac c co ed fi go or sa ",cy:" ac biz com ekloges gov ltd name net org parliament press pro tm ","do":" art com edu gob gov mil net org sld web ",dz:" art asso com edu gov net org pol ",ec:" com edu fin gov info med mil net org pro ",eg:" com edu eun gov mil name net org sci ",er:" com edu gov ind mil net org rochest w ",es:" com edu gob nom org ",et:" biz com edu gov info name net org ",fj:" ac biz com info mil name net org pro ",fk:" ac co gov net nom org ",fr:" asso com f gouv nom prd presse tm ",gg:" co net org ",gh:" com edu gov mil org ",gn:" ac com gov net org ",gr:" com edu gov mil net org ",gt:" com edu gob ind mil net org ",gu:" com edu gov net org ",hk:" com edu gov idv net org ",hu:" 2000 agrar bolt casino city co erotica erotika film forum games hotel info ingatlan jogasz konyvelo lakas media news org priv reklam sex shop sport suli szex tm tozsde utazas video ",id:" ac co go mil net or sch web ",il:" ac co gov idf k12 muni net org ","in":" ac co edu ernet firm gen gov i ind mil net nic org res ",iq:" com edu gov i mil net org ",ir:" ac co dnssec gov i id net org sch ",it:" edu gov ",je:" co net org ",jo:" com edu gov mil name net org sch ",jp:" ac ad co ed go gr lg ne or ",ke:" ac co go info me mobi ne or sc ",kh:" com edu gov mil net org per ",ki:" biz com de edu gov info mob net org tel ",km:" asso com coop edu gouv k medecin mil nom notaires pharmaciens presse tm veterinaire ",kn:" edu gov net org ",kr:" ac busan chungbuk chungnam co daegu daejeon es gangwon go gwangju gyeongbuk gyeonggi gyeongnam hs incheon jeju jeonbuk jeonnam k kg mil ms ne or pe re sc seoul ulsan ",kw:" com edu gov net org ",ky:" com edu gov net org ",kz:" com edu gov mil net org ",lb:" com edu gov net org ",lk:" assn com edu gov grp hotel int ltd net ngo org sch soc web ",lr:" com edu gov net org ",lv:" asn com conf edu gov id mil net org ",ly:" com edu gov id med net org plc sch ",ma:" ac co gov m net org press ",mc:" asso tm ",me:" ac co edu gov its net org priv ",mg:" com edu gov mil nom org prd tm ",mk:" com edu gov inf name net org pro ",ml:" com edu gov net org presse ",mn:" edu gov org ",mo:" com edu gov net org ",mt:" com edu gov net org ",mv:" aero biz com coop edu gov info int mil museum name net org pro ",mw:" ac co com coop edu gov int museum net org ",mx:" com edu gob net org ",my:" com edu gov mil name net org sch ",nf:" arts com firm info net other per rec store web ",ng:" biz com edu gov mil mobi name net org sch ",ni:" ac co com edu gob mil net nom org ",np:" com edu gov mil net org ",nr:" biz com edu gov info net org ",om:" ac biz co com edu gov med mil museum net org pro sch ",pe:" com edu gob mil net nom org sld ",ph:" com edu gov i mil net ngo org ",pk:" biz com edu fam gob gok gon gop gos gov net org web ",pl:" art bialystok biz com edu gda gdansk gorzow gov info katowice krakow lodz lublin mil net ngo olsztyn org poznan pwr radom slupsk szczecin torun warszawa waw wroc wroclaw zgora ",pr:" ac biz com edu est gov info isla name net org pro prof ",ps:" com edu gov net org plo sec ",pw:" belau co ed go ne or ",ro:" arts com firm info nom nt org rec store tm www ",rs:" ac co edu gov in org ",sb:" com edu gov net org ",sc:" com edu gov net org ",sh:" co com edu gov net nom org ",sl:" com edu gov net org ",st:" co com consulado edu embaixada gov mil net org principe saotome store ",sv:" com edu gob org red ",sz:" ac co org ",tr:" av bbs bel biz com dr edu gen gov info k12 name net org pol tel tsk tv web ",tt:" aero biz cat co com coop edu gov info int jobs mil mobi museum name net org pro tel travel ",tw:" club com ebiz edu game gov idv mil net org ",mu:" ac co com gov net or org ",mz:" ac co edu gov org ",na:" co com ",nz:" ac co cri geek gen govt health iwi maori mil net org parliament school ",pa:" abo ac com edu gob ing med net nom org sld ",pt:" com edu gov int net nome org publ ",py:" com edu gov mil net org ",qa:" com edu gov mil net org ",re:" asso com nom ",ru:" ac adygeya altai amur arkhangelsk astrakhan bashkiria belgorod bir bryansk buryatia cbg chel chelyabinsk chita chukotka chuvashia com dagestan e-burg edu gov grozny int irkutsk ivanovo izhevsk jar joshkar-ola kalmykia kaluga kamchatka karelia kazan kchr kemerovo khabarovsk khakassia khv kirov koenig komi kostroma kranoyarsk kuban kurgan kursk lipetsk magadan mari mari-el marine mil mordovia mosreg msk murmansk nalchik net nnov nov novosibirsk nsk omsk orenburg org oryol penza perm pp pskov ptz rnd ryazan sakhalin samara saratov simbirsk smolensk spb stavropol stv surgut tambov tatarstan tom tomsk tsaritsyn tsk tula tuva tver tyumen udm udmurtia ulan-ude vladikavkaz vladimir vladivostok volgograd vologda voronezh vrn vyatka yakutia yamal yekaterinburg yuzhno-sakhalinsk ",rw:" ac co com edu gouv gov int mil net ",sa:" com edu gov med net org pub sch ",sd:" com edu gov info med net org tv ",se:" a ac b bd c d e f g h i k l m n o org p parti pp press r s t tm u w x y z ",sg:" com edu gov idn net org per ",sn:" art com edu gouv org perso univ ",sy:" com edu gov mil net news org ",th:" ac co go in mi net or ",tj:" ac biz co com edu go gov info int mil name net nic org test web ",tn:" agrinet com defense edunet ens fin gov ind info intl mincom nat net org perso rnrt rns rnu tourism ",tz:" ac co go ne or ",ua:" biz cherkassy chernigov chernovtsy ck cn co com crimea cv dn dnepropetrovsk donetsk dp edu gov if in ivano-frankivsk kh kharkov kherson khmelnitskiy kiev kirovograd km kr ks kv lg lugansk lutsk lviv me mk net nikolaev od odessa org pl poltava pp rovno rv sebastopol sumy te ternopil uzhgorod vinnica vn zaporizhzhe zhitomir zp zt ",ug:" ac co go ne or org sc ",uk:" ac bl british-library co cym gov govt icnet jet lea ltd me mil mod national-library-scotland nel net nhs nic nls org orgn parliament plc police sch scot soc ",us:" dni fed isa kids nsn ",uy:" com edu gub mil net org ",ve:" co com edu gob info mil net org web ",vi:" co com k12 net org ",vn:" ac biz com edu gov health info int name net org pro ",ye:" co com gov ltd me net org plc ",yu:" ac co edu gov org ",za:" ac agric alt bourse city co cybernet db edu gov grondar iaccess imt inca landesign law mil net ngo nis nom olivetti org pix school tm web ",zm:" ac co com edu gov net org sch "},has:function(domain){var tldOffset=domain.lastIndexOf(".");if(tldOffset<=0||tldOffset>=domain.length-1){return false}var sldOffset=domain.lastIndexOf(".",tldOffset-1);if(sldOffset<=0||sldOffset>=tldOffset-1){return false}var sldList=SLD.list[domain.slice(tldOffset+1)];if(!sldList){return false}return sldList.indexOf(" "+domain.slice(sldOffset+1,tldOffset)+" ")>=0},is:function(domain){var tldOffset=domain.lastIndexOf(".");if(tldOffset<=0||tldOffset>=domain.length-1){return false}var sldOffset=domain.lastIndexOf(".",tldOffset-1);if(sldOffset>=0){return false}var sldList=SLD.list[domain.slice(tldOffset+1)];if(!sldList){return false}return sldList.indexOf(" "+domain.slice(0,tldOffset)+" ")>=0},get:function(domain){var tldOffset=domain.lastIndexOf(".");if(tldOffset<=0||tldOffset>=domain.length-1){return null}var sldOffset=domain.lastIndexOf(".",tldOffset-1);if(sldOffset<=0||sldOffset>=tldOffset-1){return null}var sldList=SLD.list[domain.slice(tldOffset+1)];if(!sldList){return null}if(sldList.indexOf(" "+domain.slice(sldOffset+1,tldOffset)+" ")<0){return null}return domain.slice(sldOffset+1)},noConflict:function(){if(root.SecondLevelDomains===this){root.SecondLevelDomains=_SecondLevelDomains}return this}};return SLD})},{}],16:[function(require,module,exports){(function(root,factory){"use strict";if(typeof exports==="object"){module.exports=factory(require("./punycode"),require("./IPv6"),require("./SecondLevelDomains"))}else if(typeof define==="function"&&define.amd){define(["./punycode","./IPv6","./SecondLevelDomains"],factory)}else{root.URI=factory(root.punycode,root.IPv6,root.SecondLevelDomains,root)}})(this,function(punycode,IPv6,SLD,root){"use strict";var _URI=root&&root.URI;function URI(url,base){var _urlSupplied=arguments.length>=1;var _baseSupplied=arguments.length>=2;if(!(this instanceof URI)){if(_urlSupplied){if(_baseSupplied){return new URI(url,base)}return new URI(url)}return new URI}if(url===undefined){if(_urlSupplied){throw new TypeError("undefined is not a valid argument for URI")}if(typeof location!=="undefined"){url=location.href+""}else{url=""}}this.href(url);if(base!==undefined){return this.absoluteTo(base)}return this}URI.version="1.15.1";var p=URI.prototype;var hasOwn=Object.prototype.hasOwnProperty;function escapeRegEx(string){return string.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function getType(value){if(value===undefined){return"Undefined"}return String(Object.prototype.toString.call(value)).slice(8,-1)}function isArray(obj){return getType(obj)==="Array"}function filterArrayValues(data,value){var lookup={};var i,length;if(getType(value)==="RegExp"){lookup=null}else if(isArray(value)){for(i=0,length=value.length;i<length;i++){lookup[value[i]]=true}}else{lookup[value]=true}for(i=0,length=data.length;i<length;i++){var _match=lookup&&lookup[data[i]]!==undefined||!lookup&&value.test(data[i]);if(_match){data.splice(i,1);length--;i--}}return data}function arrayContains(list,value){var i,length;if(isArray(value)){for(i=0,length=value.length;i<length;i++){if(!arrayContains(list,value[i])){return false}}return true}var _type=getType(value);for(i=0,length=list.length;i<length;i++){if(_type==="RegExp"){if(typeof list[i]==="string"&&list[i].match(value)){return true}}else if(list[i]===value){return true}}return false}function arraysEqual(one,two){if(!isArray(one)||!isArray(two)){return false}if(one.length!==two.length){return false}one.sort();two.sort();for(var i=0,l=one.length;i<l;i++){if(one[i]!==two[i]){return false}}return true}URI._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,duplicateQueryParameters:URI.duplicateQueryParameters,escapeQuerySpace:URI.escapeQuerySpace}};URI.duplicateQueryParameters=false;URI.escapeQuerySpace=true;URI.protocol_expression=/^[a-z][a-z0-9.+-]*$/i;URI.idn_expression=/[^a-z0-9\.-]/i;URI.punycode_expression=/(xn--)/i;URI.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;URI.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/;URI.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi;URI.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?«»“”„‘’]+$/};URI.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"};URI.invalid_hostname_characters=/[^a-zA-Z0-9\.-]/;URI.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src",audio:"src",video:"src"};URI.getDomAttribute=function(node){if(!node||!node.nodeName){return undefined}var nodeName=node.nodeName.toLowerCase();if(nodeName==="input"&&node.type!=="image"){return undefined}return URI.domAttributes[nodeName]};function escapeForDumbFirefox36(value){return escape(value)}function strictEncodeURIComponent(string){return encodeURIComponent(string).replace(/[!'()*]/g,escapeForDumbFirefox36).replace(/\*/g,"%2A")}URI.encode=strictEncodeURIComponent;URI.decode=decodeURIComponent;URI.iso8859=function(){URI.encode=escape;URI.decode=unescape};URI.unicode=function(){URI.encode=strictEncodeURIComponent;URI.decode=decodeURIComponent};URI.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/gi,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/gi,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}},urnpath:{encode:{expression:/%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/gi,map:{"%21":"!","%24":"$","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"=","%40":"@"}},decode:{expression:/[\/\?#:]/g,map:{"/":"%2F","?":"%3F","#":"%23",":":"%3A"}}}};URI.encodeQuery=function(string,escapeQuerySpace){var escaped=URI.encode(string+"");if(escapeQuerySpace===undefined){escapeQuerySpace=URI.escapeQuerySpace}return escapeQuerySpace?escaped.replace(/%20/g,"+"):escaped};URI.decodeQuery=function(string,escapeQuerySpace){string+="";if(escapeQuerySpace===undefined){escapeQuerySpace=URI.escapeQuerySpace}try{return URI.decode(escapeQuerySpace?string.replace(/\+/g,"%20"):string)}catch(e){return string}};var _parts={encode:"encode",decode:"decode"};var _part;var generateAccessor=function(_group,_part){return function(string){try{return URI[_part](string+"").replace(URI.characters[_group][_part].expression,function(c){return URI.characters[_group][_part].map[c]})}catch(e){return string}}};for(_part in _parts){URI[_part+"PathSegment"]=generateAccessor("pathname",_parts[_part]);URI[_part+"UrnPathSegment"]=generateAccessor("urnpath",_parts[_part])}var generateSegmentedPathFunction=function(_sep,_codingFuncName,_innerCodingFuncName){return function(string){var actualCodingFunc;if(!_innerCodingFuncName){actualCodingFunc=URI[_codingFuncName]}else{actualCodingFunc=function(string){return URI[_codingFuncName](URI[_innerCodingFuncName](string))}}var segments=(string+"").split(_sep);for(var i=0,length=segments.length;i<length;i++){segments[i]=actualCodingFunc(segments[i])}return segments.join(_sep)}};URI.decodePath=generateSegmentedPathFunction("/","decodePathSegment");URI.decodeUrnPath=generateSegmentedPathFunction(":","decodeUrnPathSegment");URI.recodePath=generateSegmentedPathFunction("/","encodePathSegment","decode");URI.recodeUrnPath=generateSegmentedPathFunction(":","encodeUrnPathSegment","decode");URI.encodeReserved=generateAccessor("reserved","encode");URI.parse=function(string,parts){var pos;if(!parts){parts={}}pos=string.indexOf("#");if(pos>-1){parts.fragment=string.substring(pos+1)||null;string=string.substring(0,pos)}pos=string.indexOf("?");if(pos>-1){parts.query=string.substring(pos+1)||null;string=string.substring(0,pos)}if(string.substring(0,2)==="//"){parts.protocol=null;string=string.substring(2);string=URI.parseAuthority(string,parts)}else{pos=string.indexOf(":");if(pos>-1){parts.protocol=string.substring(0,pos)||null;if(parts.protocol&&!parts.protocol.match(URI.protocol_expression)){parts.protocol=undefined}else if(string.substring(pos+1,pos+3)==="//"){string=string.substring(pos+3);string=URI.parseAuthority(string,parts)}else{string=string.substring(pos+1);parts.urn=true}}}parts.path=string;return parts};URI.parseHost=function(string,parts){var pos=string.indexOf("/");var bracketPos;var t;if(pos===-1){pos=string.length}if(string.charAt(0)==="["){bracketPos=string.indexOf("]");parts.hostname=string.substring(1,bracketPos)||null;parts.port=string.substring(bracketPos+2,pos)||null;if(parts.port==="/"){parts.port=null}}else{var firstColon=string.indexOf(":");var firstSlash=string.indexOf("/");var nextColon=string.indexOf(":",firstColon+1);if(nextColon!==-1&&(firstSlash===-1||nextColon<firstSlash)){parts.hostname=string.substring(0,pos)||null;parts.port=null}else{t=string.substring(0,pos).split(":");parts.hostname=t[0]||null;parts.port=t[1]||null}}if(parts.hostname&&string.substring(pos).charAt(0)!=="/"){pos++;string="/"+string}return string.substring(pos)||"/"};URI.parseAuthority=function(string,parts){string=URI.parseUserinfo(string,parts);return URI.parseHost(string,parts)};URI.parseUserinfo=function(string,parts){var firstSlash=string.indexOf("/");var pos=string.lastIndexOf("@",firstSlash>-1?firstSlash:string.length-1);var t;if(pos>-1&&(firstSlash===-1||pos<firstSlash)){t=string.substring(0,pos).split(":");parts.username=t[0]?URI.decode(t[0]):null;t.shift();parts.password=t[0]?URI.decode(t.join(":")):null;string=string.substring(pos+1)}else{parts.username=null;parts.password=null}return string};URI.parseQuery=function(string,escapeQuerySpace){if(!string){return{}}string=string.replace(/&+/g,"&").replace(/^\?*&*|&+$/g,"");if(!string){return{}}var items={};var splits=string.split("&");var length=splits.length;var v,name,value;for(var i=0;i<length;i++){v=splits[i].split("=");name=URI.decodeQuery(v.shift(),escapeQuerySpace);value=v.length?URI.decodeQuery(v.join("="),escapeQuerySpace):null;if(hasOwn.call(items,name)){if(typeof items[name]==="string"){items[name]=[items[name]]}items[name].push(value)}else{items[name]=value}}return items};URI.build=function(parts){var t="";if(parts.protocol){t+=parts.protocol+":"}if(!parts.urn&&(t||parts.hostname)){t+="//"}t+=URI.buildAuthority(parts)||"";if(typeof parts.path==="string"){if(parts.path.charAt(0)!=="/"&&typeof parts.hostname==="string"){t+="/"}t+=parts.path}if(typeof parts.query==="string"&&parts.query){t+="?"+parts.query}if(typeof parts.fragment==="string"&&parts.fragment){t+="#"+parts.fragment}return t};URI.buildHost=function(parts){var t="";if(!parts.hostname){return""}else if(URI.ip6_expression.test(parts.hostname)){t+="["+parts.hostname+"]"}else{t+=parts.hostname}if(parts.port){t+=":"+parts.port}return t};URI.buildAuthority=function(parts){return URI.buildUserinfo(parts)+URI.buildHost(parts)};URI.buildUserinfo=function(parts){var t="";if(parts.username){t+=URI.encode(parts.username);if(parts.password){t+=":"+URI.encode(parts.password)}t+="@"}return t};URI.buildQuery=function(data,duplicateQueryParameters,escapeQuerySpace){var t="";var unique,key,i,length;for(key in data){if(hasOwn.call(data,key)&&key){if(isArray(data[key])){unique={};for(i=0,length=data[key].length;i<length;i++){if(data[key][i]!==undefined&&unique[data[key][i]+""]===undefined){t+="&"+URI.buildQueryParameter(key,data[key][i],escapeQuerySpace);if(duplicateQueryParameters!==true){unique[data[key][i]+""]=true}}}}else if(data[key]!==undefined){t+="&"+URI.buildQueryParameter(key,data[key],escapeQuerySpace)}}}return t.substring(1)};URI.buildQueryParameter=function(name,value,escapeQuerySpace){return URI.encodeQuery(name,escapeQuerySpace)+(value!==null?"="+URI.encodeQuery(value,escapeQuerySpace):"")};URI.addQuery=function(data,name,value){if(typeof name==="object"){for(var key in name){if(hasOwn.call(name,key)){URI.addQuery(data,key,name[key])}}}else if(typeof name==="string"){if(data[name]===undefined){data[name]=value;return}else if(typeof data[name]==="string"){data[name]=[data[name]]}if(!isArray(value)){value=[value]}data[name]=(data[name]||[]).concat(value)}else{throw new TypeError("URI.addQuery() accepts an object, string as the name parameter")}};URI.removeQuery=function(data,name,value){var i,length,key;if(isArray(name)){
for(i=0,length=name.length;i<length;i++){data[name[i]]=undefined}}else if(getType(name)==="RegExp"){for(key in data){if(name.test(key)){data[key]=undefined}}}else if(typeof name==="object"){for(key in name){if(hasOwn.call(name,key)){URI.removeQuery(data,key,name[key])}}}else if(typeof name==="string"){if(value!==undefined){if(getType(value)==="RegExp"){if(!isArray(data[name])&&value.test(data[name])){data[name]=undefined}else{data[name]=filterArrayValues(data[name],value)}}else if(data[name]===value){data[name]=undefined}else if(isArray(data[name])){data[name]=filterArrayValues(data[name],value)}}else{data[name]=undefined}}else{throw new TypeError("URI.removeQuery() accepts an object, string, RegExp as the first parameter")}};URI.hasQuery=function(data,name,value,withinArray){if(typeof name==="object"){for(var key in name){if(hasOwn.call(name,key)){if(!URI.hasQuery(data,key,name[key])){return false}}}return true}else if(typeof name!=="string"){throw new TypeError("URI.hasQuery() accepts an object, string as the name parameter")}switch(getType(value)){case"Undefined":return name in data;case"Boolean":var _booly=Boolean(isArray(data[name])?data[name].length:data[name]);return value===_booly;case"Function":return!!value(data[name],name,data);case"Array":if(!isArray(data[name])){return false}var op=withinArray?arrayContains:arraysEqual;return op(data[name],value);case"RegExp":if(!isArray(data[name])){return Boolean(data[name]&&data[name].match(value))}if(!withinArray){return false}return arrayContains(data[name],value);case"Number":value=String(value);case"String":if(!isArray(data[name])){return data[name]===value}if(!withinArray){return false}return arrayContains(data[name],value);default:throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter")}};URI.commonPath=function(one,two){var length=Math.min(one.length,two.length);var pos;for(pos=0;pos<length;pos++){if(one.charAt(pos)!==two.charAt(pos)){pos--;break}}if(pos<1){return one.charAt(0)===two.charAt(0)&&one.charAt(0)==="/"?"/":""}if(one.charAt(pos)!=="/"||two.charAt(pos)!=="/"){pos=one.substring(0,pos).lastIndexOf("/")}return one.substring(0,pos+1)};URI.withinString=function(string,callback,options){options||(options={});var _start=options.start||URI.findUri.start;var _end=options.end||URI.findUri.end;var _trim=options.trim||URI.findUri.trim;var _attributeOpen=/[a-z0-9-]=["']?$/i;_start.lastIndex=0;while(true){var match=_start.exec(string);if(!match){break}var start=match.index;if(options.ignoreHtml){var attributeOpen=string.slice(Math.max(start-3,0),start);if(attributeOpen&&_attributeOpen.test(attributeOpen)){continue}}var end=start+string.slice(start).search(_end);var slice=string.slice(start,end).replace(_trim,"");if(options.ignore&&options.ignore.test(slice)){continue}end=start+slice.length;var result=callback(slice,start,end,string);string=string.slice(0,start)+result+string.slice(end);_start.lastIndex=start+result.length}_start.lastIndex=0;return string};URI.ensureValidHostname=function(v){if(v.match(URI.invalid_hostname_characters)){if(!punycode){throw new TypeError('Hostname "'+v+'" contains characters other than [A-Z0-9.-] and Punycode.js is not available')}if(punycode.toASCII(v).match(URI.invalid_hostname_characters)){throw new TypeError('Hostname "'+v+'" contains characters other than [A-Z0-9.-]')}}};URI.noConflict=function(removeAll){if(removeAll){var unconflicted={URI:this.noConflict()};if(root.URITemplate&&typeof root.URITemplate.noConflict==="function"){unconflicted.URITemplate=root.URITemplate.noConflict()}if(root.IPv6&&typeof root.IPv6.noConflict==="function"){unconflicted.IPv6=root.IPv6.noConflict()}if(root.SecondLevelDomains&&typeof root.SecondLevelDomains.noConflict==="function"){unconflicted.SecondLevelDomains=root.SecondLevelDomains.noConflict()}return unconflicted}else if(root.URI===this){root.URI=_URI}return this};p.build=function(deferBuild){if(deferBuild===true){this._deferred_build=true}else if(deferBuild===undefined||this._deferred_build){this._string=URI.build(this._parts);this._deferred_build=false}return this};p.clone=function(){return new URI(this)};p.valueOf=p.toString=function(){return this.build(false)._string};function generateSimpleAccessor(_part){return function(v,build){if(v===undefined){return this._parts[_part]||""}else{this._parts[_part]=v||null;this.build(!build);return this}}}function generatePrefixAccessor(_part,_key){return function(v,build){if(v===undefined){return this._parts[_part]||""}else{if(v!==null){v=v+"";if(v.charAt(0)===_key){v=v.substring(1)}}this._parts[_part]=v;this.build(!build);return this}}}p.protocol=generateSimpleAccessor("protocol");p.username=generateSimpleAccessor("username");p.password=generateSimpleAccessor("password");p.hostname=generateSimpleAccessor("hostname");p.port=generateSimpleAccessor("port");p.query=generatePrefixAccessor("query","?");p.fragment=generatePrefixAccessor("fragment","#");p.search=function(v,build){var t=this.query(v,build);return typeof t==="string"&&t.length?"?"+t:t};p.hash=function(v,build){var t=this.fragment(v,build);return typeof t==="string"&&t.length?"#"+t:t};p.pathname=function(v,build){if(v===undefined||v===true){var res=this._parts.path||(this._parts.hostname?"/":"");return v?(this._parts.urn?URI.decodeUrnPath:URI.decodePath)(res):res}else{if(this._parts.urn){this._parts.path=v?URI.recodeUrnPath(v):""}else{this._parts.path=v?URI.recodePath(v):"/"}this.build(!build);return this}};p.path=p.pathname;p.href=function(href,build){var key;if(href===undefined){return this.toString()}this._string="";this._parts=URI._parts();var _URI=href instanceof URI;var _object=typeof href==="object"&&(href.hostname||href.path||href.pathname);if(href.nodeName){var attribute=URI.getDomAttribute(href);href=href[attribute]||"";_object=false}if(!_URI&&_object&&href.pathname!==undefined){href=href.toString()}if(typeof href==="string"||href instanceof String){this._parts=URI.parse(String(href),this._parts)}else if(_URI||_object){var src=_URI?href._parts:href;for(key in src){if(hasOwn.call(this._parts,key)){this._parts[key]=src[key]}}}else{throw new TypeError("invalid input")}this.build(!build);return this};p.is=function(what){var ip=false;var ip4=false;var ip6=false;var name=false;var sld=false;var idn=false;var punycode=false;var relative=!this._parts.urn;if(this._parts.hostname){relative=false;ip4=URI.ip4_expression.test(this._parts.hostname);ip6=URI.ip6_expression.test(this._parts.hostname);ip=ip4||ip6;name=!ip;sld=name&&SLD&&SLD.has(this._parts.hostname);idn=name&&URI.idn_expression.test(this._parts.hostname);punycode=name&&URI.punycode_expression.test(this._parts.hostname)}switch(what.toLowerCase()){case"relative":return relative;case"absolute":return!relative;case"domain":case"name":return name;case"sld":return sld;case"ip":return ip;case"ip4":case"ipv4":case"inet4":return ip4;case"ip6":case"ipv6":case"inet6":return ip6;case"idn":return idn;case"url":return!this._parts.urn;case"urn":return!!this._parts.urn;case"punycode":return punycode}return null};var _protocol=p.protocol;var _port=p.port;var _hostname=p.hostname;p.protocol=function(v,build){if(v!==undefined){if(v){v=v.replace(/:(\/\/)?$/,"");if(!v.match(URI.protocol_expression)){throw new TypeError('Protocol "'+v+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]")}}}return _protocol.call(this,v,build)};p.scheme=p.protocol;p.port=function(v,build){if(this._parts.urn){return v===undefined?"":this}if(v!==undefined){if(v===0){v=null}if(v){v+="";if(v.charAt(0)===":"){v=v.substring(1)}if(v.match(/[^0-9]/)){throw new TypeError('Port "'+v+'" contains characters other than [0-9]')}}}return _port.call(this,v,build)};p.hostname=function(v,build){if(this._parts.urn){return v===undefined?"":this}if(v!==undefined){var x={};URI.parseHost(v,x);v=x.hostname}return _hostname.call(this,v,build)};p.host=function(v,build){if(this._parts.urn){return v===undefined?"":this}if(v===undefined){return this._parts.hostname?URI.buildHost(this._parts):""}else{URI.parseHost(v,this._parts);this.build(!build);return this}};p.authority=function(v,build){if(this._parts.urn){return v===undefined?"":this}if(v===undefined){return this._parts.hostname?URI.buildAuthority(this._parts):""}else{URI.parseAuthority(v,this._parts);this.build(!build);return this}};p.userinfo=function(v,build){if(this._parts.urn){return v===undefined?"":this}if(v===undefined){if(!this._parts.username){return""}var t=URI.buildUserinfo(this._parts);return t.substring(0,t.length-1)}else{if(v[v.length-1]!=="@"){v+="@"}URI.parseUserinfo(v,this._parts);this.build(!build);return this}};p.resource=function(v,build){var parts;if(v===undefined){return this.path()+this.search()+this.hash()}parts=URI.parse(v);this._parts.path=parts.path;this._parts.query=parts.query;this._parts.fragment=parts.fragment;this.build(!build);return this};p.subdomain=function(v,build){if(this._parts.urn){return v===undefined?"":this}if(v===undefined){if(!this._parts.hostname||this.is("IP")){return""}var end=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,end)||""}else{var e=this._parts.hostname.length-this.domain().length;var sub=this._parts.hostname.substring(0,e);var replace=new RegExp("^"+escapeRegEx(sub));if(v&&v.charAt(v.length-1)!=="."){v+="."}if(v){URI.ensureValidHostname(v)}this._parts.hostname=this._parts.hostname.replace(replace,v);this.build(!build);return this}};p.domain=function(v,build){if(this._parts.urn){return v===undefined?"":this}if(typeof v==="boolean"){build=v;v=undefined}if(v===undefined){if(!this._parts.hostname||this.is("IP")){return""}var t=this._parts.hostname.match(/\./g);if(t&&t.length<2){return this._parts.hostname}var end=this._parts.hostname.length-this.tld(build).length-1;end=this._parts.hostname.lastIndexOf(".",end-1)+1;return this._parts.hostname.substring(end)||""}else{if(!v){throw new TypeError("cannot set domain empty")}URI.ensureValidHostname(v);if(!this._parts.hostname||this.is("IP")){this._parts.hostname=v}else{var replace=new RegExp(escapeRegEx(this.domain())+"$");this._parts.hostname=this._parts.hostname.replace(replace,v)}this.build(!build);return this}};p.tld=function(v,build){if(this._parts.urn){return v===undefined?"":this}if(typeof v==="boolean"){build=v;v=undefined}if(v===undefined){if(!this._parts.hostname||this.is("IP")){return""}var pos=this._parts.hostname.lastIndexOf(".");var tld=this._parts.hostname.substring(pos+1);if(build!==true&&SLD&&SLD.list[tld.toLowerCase()]){return SLD.get(this._parts.hostname)||tld}return tld}else{var replace;if(!v){throw new TypeError("cannot set TLD empty")}else if(v.match(/[^a-zA-Z0-9-]/)){if(SLD&&SLD.is(v)){replace=new RegExp(escapeRegEx(this.tld())+"$");this._parts.hostname=this._parts.hostname.replace(replace,v)}else{throw new TypeError('TLD "'+v+'" contains characters other than [A-Z0-9]')}}else if(!this._parts.hostname||this.is("IP")){throw new ReferenceError("cannot set TLD on non-domain host")}else{replace=new RegExp(escapeRegEx(this.tld())+"$");this._parts.hostname=this._parts.hostname.replace(replace,v)}this.build(!build);return this}};p.directory=function(v,build){if(this._parts.urn){return v===undefined?"":this}if(v===undefined||v===true){if(!this._parts.path&&!this._parts.hostname){return""}if(this._parts.path==="/"){return"/"}var end=this._parts.path.length-this.filename().length-1;var res=this._parts.path.substring(0,end)||(this._parts.hostname?"/":"");return v?URI.decodePath(res):res}else{var e=this._parts.path.length-this.filename().length;var directory=this._parts.path.substring(0,e);var replace=new RegExp("^"+escapeRegEx(directory));if(!this.is("relative")){if(!v){v="/"}if(v.charAt(0)!=="/"){v="/"+v}}if(v&&v.charAt(v.length-1)!=="/"){v+="/"}v=URI.recodePath(v);this._parts.path=this._parts.path.replace(replace,v);this.build(!build);return this}};p.filename=function(v,build){if(this._parts.urn){return v===undefined?"":this}if(v===undefined||v===true){if(!this._parts.path||this._parts.path==="/"){return""}var pos=this._parts.path.lastIndexOf("/");var res=this._parts.path.substring(pos+1);return v?URI.decodePathSegment(res):res}else{var mutatedDirectory=false;if(v.charAt(0)==="/"){v=v.substring(1)}if(v.match(/\.?\//)){mutatedDirectory=true}var replace=new RegExp(escapeRegEx(this.filename())+"$");v=URI.recodePath(v);this._parts.path=this._parts.path.replace(replace,v);if(mutatedDirectory){this.normalizePath(build)}else{this.build(!build)}return this}};p.suffix=function(v,build){if(this._parts.urn){return v===undefined?"":this}if(v===undefined||v===true){if(!this._parts.path||this._parts.path==="/"){return""}var filename=this.filename();var pos=filename.lastIndexOf(".");var s,res;if(pos===-1){return""}s=filename.substring(pos+1);res=/^[a-z0-9%]+$/i.test(s)?s:"";return v?URI.decodePathSegment(res):res}else{if(v.charAt(0)==="."){v=v.substring(1)}var suffix=this.suffix();var replace;if(!suffix){if(!v){return this}this._parts.path+="."+URI.recodePath(v)}else if(!v){replace=new RegExp(escapeRegEx("."+suffix)+"$")}else{replace=new RegExp(escapeRegEx(suffix)+"$")}if(replace){v=URI.recodePath(v);this._parts.path=this._parts.path.replace(replace,v)}this.build(!build);return this}};p.segment=function(segment,v,build){var separator=this._parts.urn?":":"/";var path=this.path();var absolute=path.substring(0,1)==="/";var segments=path.split(separator);if(segment!==undefined&&typeof segment!=="number"){build=v;v=segment;segment=undefined}if(segment!==undefined&&typeof segment!=="number"){throw new Error('Bad segment "'+segment+'", must be 0-based integer')}if(absolute){segments.shift()}if(segment<0){segment=Math.max(segments.length+segment,0)}if(v===undefined){return segment===undefined?segments:segments[segment]}else if(segment===null||segments[segment]===undefined){if(isArray(v)){segments=[];for(var i=0,l=v.length;i<l;i++){if(!v[i].length&&(!segments.length||!segments[segments.length-1].length)){continue}if(segments.length&&!segments[segments.length-1].length){segments.pop()}segments.push(v[i])}}else if(v||typeof v==="string"){if(segments[segments.length-1]===""){segments[segments.length-1]=v}else{segments.push(v)}}}else{if(v){segments[segment]=v}else{segments.splice(segment,1)}}if(absolute){segments.unshift("")}return this.path(segments.join(separator),build)};p.segmentCoded=function(segment,v,build){var segments,i,l;if(typeof segment!=="number"){build=v;v=segment;segment=undefined}if(v===undefined){segments=this.segment(segment,v,build);if(!isArray(segments)){segments=segments!==undefined?URI.decode(segments):undefined}else{for(i=0,l=segments.length;i<l;i++){segments[i]=URI.decode(segments[i])}}return segments}if(!isArray(v)){v=typeof v==="string"||v instanceof String?URI.encode(v):v}else{for(i=0,l=v.length;i<l;i++){v[i]=URI.decode(v[i])}}return this.segment(segment,v,build)};var q=p.query;p.query=function(v,build){if(v===true){return URI.parseQuery(this._parts.query,this._parts.escapeQuerySpace)}else if(typeof v==="function"){var data=URI.parseQuery(this._parts.query,this._parts.escapeQuerySpace);var result=v.call(this,data);this._parts.query=URI.buildQuery(result||data,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);this.build(!build);return this}else if(v!==undefined&&typeof v!=="string"){this._parts.query=URI.buildQuery(v,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);this.build(!build);return this}else{return q.call(this,v,build)}};p.setQuery=function(name,value,build){var data=URI.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if(typeof name==="string"||name instanceof String){data[name]=value!==undefined?value:null}else if(typeof name==="object"){for(var key in name){if(hasOwn.call(name,key)){data[key]=name[key]}}}else{throw new TypeError("URI.addQuery() accepts an object, string as the name parameter")}this._parts.query=URI.buildQuery(data,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);if(typeof name!=="string"){build=value}this.build(!build);return this};p.addQuery=function(name,value,build){var data=URI.parseQuery(this._parts.query,this._parts.escapeQuerySpace);URI.addQuery(data,name,value===undefined?null:value);this._parts.query=URI.buildQuery(data,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);if(typeof name!=="string"){build=value}this.build(!build);return this};p.removeQuery=function(name,value,build){var data=URI.parseQuery(this._parts.query,this._parts.escapeQuerySpace);URI.removeQuery(data,name,value);this._parts.query=URI.buildQuery(data,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);if(typeof name!=="string"){build=value}this.build(!build);return this};p.hasQuery=function(name,value,withinArray){var data=URI.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return URI.hasQuery(data,name,value,withinArray)};p.setSearch=p.setQuery;p.addSearch=p.addQuery;p.removeSearch=p.removeQuery;p.hasSearch=p.hasQuery;p.normalize=function(){if(this._parts.urn){return this.normalizeProtocol(false).normalizePath(false).normalizeQuery(false).normalizeFragment(false).build()}return this.normalizeProtocol(false).normalizeHostname(false).normalizePort(false).normalizePath(false).normalizeQuery(false).normalizeFragment(false).build()};p.normalizeProtocol=function(build){if(typeof this._parts.protocol==="string"){this._parts.protocol=this._parts.protocol.toLowerCase();this.build(!build)}return this};p.normalizeHostname=function(build){if(this._parts.hostname){if(this.is("IDN")&&punycode){this._parts.hostname=punycode.toASCII(this._parts.hostname)}else if(this.is("IPv6")&&IPv6){this._parts.hostname=IPv6.best(this._parts.hostname)}this._parts.hostname=this._parts.hostname.toLowerCase();this.build(!build)}return this};p.normalizePort=function(build){if(typeof this._parts.protocol==="string"&&this._parts.port===URI.defaultPorts[this._parts.protocol]){this._parts.port=null;this.build(!build)}return this};p.normalizePath=function(build){var _path=this._parts.path;if(!_path){return this}if(this._parts.urn){this._parts.path=URI.recodeUrnPath(this._parts.path);this.build(!build);return this}if(this._parts.path==="/"){return this}var _was_relative;var _leadingParents="";var _parent,_pos;if(_path.charAt(0)!=="/"){_was_relative=true;_path="/"+_path}_path=_path.replace(/(\/(\.\/)+)|(\/\.$)/g,"/").replace(/\/{2,}/g,"/");if(_was_relative){_leadingParents=_path.substring(1).match(/^(\.\.\/)+/)||"";if(_leadingParents){_leadingParents=_leadingParents[0]}}while(true){_parent=_path.indexOf("/..");if(_parent===-1){break}else if(_parent===0){_path=_path.substring(3);continue}_pos=_path.substring(0,_parent).lastIndexOf("/");if(_pos===-1){_pos=_parent}_path=_path.substring(0,_pos)+_path.substring(_parent+3)}if(_was_relative&&this.is("relative")){_path=_leadingParents+_path.substring(1)}_path=URI.recodePath(_path);this._parts.path=_path;this.build(!build);return this};p.normalizePathname=p.normalizePath;p.normalizeQuery=function(build){if(typeof this._parts.query==="string"){if(!this._parts.query.length){this._parts.query=null}else{this.query(URI.parseQuery(this._parts.query,this._parts.escapeQuerySpace))}this.build(!build)}return this};p.normalizeFragment=function(build){if(!this._parts.fragment){this._parts.fragment=null;this.build(!build)}return this};p.normalizeSearch=p.normalizeQuery;p.normalizeHash=p.normalizeFragment;p.iso8859=function(){var e=URI.encode;var d=URI.decode;URI.encode=escape;URI.decode=decodeURIComponent;try{this.normalize()}finally{URI.encode=e;URI.decode=d}return this};p.unicode=function(){var e=URI.encode;var d=URI.decode;URI.encode=strictEncodeURIComponent;URI.decode=unescape;try{this.normalize()}finally{URI.encode=e;URI.decode=d}return this};p.readable=function(){var uri=this.clone();uri.username("").password("").normalize();var t="";if(uri._parts.protocol){t+=uri._parts.protocol+"://"}if(uri._parts.hostname){if(uri.is("punycode")&&punycode){t+=punycode.toUnicode(uri._parts.hostname);if(uri._parts.port){t+=":"+uri._parts.port}}else{t+=uri.host()}}if(uri._parts.hostname&&uri._parts.path&&uri._parts.path.charAt(0)!=="/"){t+="/"}t+=uri.path(true);if(uri._parts.query){var q="";for(var i=0,qp=uri._parts.query.split("&"),l=qp.length;i<l;i++){var kv=(qp[i]||"").split("=");q+="&"+URI.decodeQuery(kv[0],this._parts.escapeQuerySpace).replace(/&/g,"%26");if(kv[1]!==undefined){q+="="+URI.decodeQuery(kv[1],this._parts.escapeQuerySpace).replace(/&/g,"%26")}}t+="?"+q.substring(1)}t+=URI.decodeQuery(uri.hash(),true);return t};p.absoluteTo=function(base){var resolved=this.clone();var properties=["protocol","username","password","hostname","port"];var basedir,i,p;if(this._parts.urn){throw new Error("URNs do not have any generally defined hierarchical components")}if(!(base instanceof URI)){base=new URI(base)}if(!resolved._parts.protocol){resolved._parts.protocol=base._parts.protocol}if(this._parts.hostname){return resolved}for(i=0;p=properties[i];i++){resolved._parts[p]=base._parts[p]}if(!resolved._parts.path){resolved._parts.path=base._parts.path;if(!resolved._parts.query){resolved._parts.query=base._parts.query}}else if(resolved._parts.path.substring(-2)===".."){resolved._parts.path+="/"}if(resolved.path().charAt(0)!=="/"){basedir=base.directory();basedir=basedir?basedir:base.path().indexOf("/")===0?"/":"";resolved._parts.path=(basedir?basedir+"/":"")+resolved._parts.path;resolved.normalizePath()}resolved.build();return resolved};p.relativeTo=function(base){var relative=this.clone().normalize();var relativeParts,baseParts,common,relativePath,basePath;if(relative._parts.urn){throw new Error("URNs do not have any generally defined hierarchical components")}base=new URI(base).normalize();relativeParts=relative._parts;baseParts=base._parts;relativePath=relative.path();basePath=base.path();if(relativePath.charAt(0)!=="/"){throw new Error("URI is already relative")}if(basePath.charAt(0)!=="/"){throw new Error("Cannot calculate a URI relative to another relative URI")}if(relativeParts.protocol===baseParts.protocol){relativeParts.protocol=null}if(relativeParts.username!==baseParts.username||relativeParts.password!==baseParts.password){return relative.build()}if(relativeParts.protocol!==null||relativeParts.username!==null||relativeParts.password!==null){return relative.build()}if(relativeParts.hostname===baseParts.hostname&&relativeParts.port===baseParts.port){relativeParts.hostname=null;relativeParts.port=null}else{return relative.build()}if(relativePath===basePath){relativeParts.path="";return relative.build()}common=URI.commonPath(relative.path(),base.path());if(!common){return relative.build()}var parents=baseParts.path.substring(common.length).replace(/[^\/]*$/,"").replace(/.*?\//g,"../");relativeParts.path=parents+relativeParts.path.substring(common.length);return relative.build()};p.equals=function(uri){var one=this.clone();var two=new URI(uri);var one_map={};var two_map={};var checked={};var one_query,two_query,key;one.normalize();two.normalize();if(one.toString()===two.toString()){return true}one_query=one.query();two_query=two.query();one.query("");two.query("");if(one.toString()!==two.toString()){return false}if(one_query.length!==two_query.length){return false}one_map=URI.parseQuery(one_query,this._parts.escapeQuerySpace);two_map=URI.parseQuery(two_query,this._parts.escapeQuerySpace);for(key in one_map){if(hasOwn.call(one_map,key)){if(!isArray(one_map[key])){if(one_map[key]!==two_map[key]){return false}}else if(!arraysEqual(one_map[key],two_map[key])){return false}checked[key]=true}}for(key in two_map){if(hasOwn.call(two_map,key)){if(!checked[key]){return false}}}return true};p.duplicateQueryParameters=function(v){this._parts.duplicateQueryParameters=!!v;return this};p.escapeQuerySpace=function(v){this._parts.escapeQuerySpace=!!v;return this};return URI})},{"./IPv6":14,"./SecondLevelDomains":15,"./punycode":17}],17:[function(require,module,exports){(function(global){(function(root){var freeExports=typeof exports=="object"&&exports;var freeModule=typeof module=="object"&&module&&module.exports==freeExports&&module;var freeGlobal=typeof global=="object"&&global;if(freeGlobal.global===freeGlobal||freeGlobal.window===freeGlobal){root=freeGlobal}var punycode,maxInt=2147483647,base=36,tMin=1,tMax=26,skew=38,damp=700,initialBias=72,initialN=128,delimiter="-",regexPunycode=/^xn--/,regexNonASCII=/[^ -~]/,regexSeparators=/\x2E|\u3002|\uFF0E|\uFF61/g,errors={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},baseMinusTMin=base-tMin,floor=Math.floor,stringFromCharCode=String.fromCharCode,key;function error(type){throw RangeError(errors[type])}function map(array,fn){var length=array.length;while(length--){array[length]=fn(array[length])}return array}function mapDomain(string,fn){return map(string.split(regexSeparators),fn).join(".")}function ucs2decode(string){var output=[],counter=0,length=string.length,value,extra;while(counter<length){value=string.charCodeAt(counter++);if(value>=55296&&value<=56319&&counter<length){extra=string.charCodeAt(counter++);if((extra&64512)==56320){output.push(((value&1023)<<10)+(extra&1023)+65536)}else{output.push(value);counter--}}else{output.push(value)}}return output}function ucs2encode(array){return map(array,function(value){var output="";if(value>65535){value-=65536;output+=stringFromCharCode(value>>>10&1023|55296);value=56320|value&1023}output+=stringFromCharCode(value);return output}).join("")}function basicToDigit(codePoint){if(codePoint-48<10){return codePoint-22}if(codePoint-65<26){return codePoint-65}if(codePoint-97<26){return codePoint-97}return base}function digitToBasic(digit,flag){return digit+22+75*(digit<26)-((flag!=0)<<5)}function adapt(delta,numPoints,firstTime){var k=0;delta=firstTime?floor(delta/damp):delta>>1;delta+=floor(delta/numPoints);for(;delta>baseMinusTMin*tMax>>1;k+=base){delta=floor(delta/baseMinusTMin)}return floor(k+(baseMinusTMin+1)*delta/(delta+skew))}function decode(input){var output=[],inputLength=input.length,out,i=0,n=initialN,bias=initialBias,basic,j,index,oldi,w,k,digit,t,length,baseMinusT;basic=input.lastIndexOf(delimiter);if(basic<0){basic=0}for(j=0;j<basic;++j){if(input.charCodeAt(j)>=128){error("not-basic")}output.push(input.charCodeAt(j))}for(index=basic>0?basic+1:0;index<inputLength;){for(oldi=i,w=1,k=base;;k+=base){if(index>=inputLength){error("invalid-input")}digit=basicToDigit(input.charCodeAt(index++));if(digit>=base||digit>floor((maxInt-i)/w)){error("overflow")}i+=digit*w;t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias;if(digit<t){break}baseMinusT=base-t;if(w>floor(maxInt/baseMinusT)){error("overflow")}w*=baseMinusT}out=output.length+1;bias=adapt(i-oldi,out,oldi==0);if(floor(i/out)>maxInt-n){error("overflow")}n+=floor(i/out);i%=out;output.splice(i++,0,n)}return ucs2encode(output)}function encode(input){var n,delta,handledCPCount,basicLength,bias,j,m,q,k,t,currentValue,output=[],inputLength,handledCPCountPlusOne,baseMinusT,qMinusT;input=ucs2decode(input);inputLength=input.length;n=initialN;delta=0;bias=initialBias;for(j=0;j<inputLength;++j){currentValue=input[j];if(currentValue<128){output.push(stringFromCharCode(currentValue))}}handledCPCount=basicLength=output.length;if(basicLength){output.push(delimiter)}while(handledCPCount<inputLength){for(m=maxInt,j=0;j<inputLength;++j){currentValue=input[j];if(currentValue>=n&&currentValue<m){m=currentValue}}handledCPCountPlusOne=handledCPCount+1;if(m-n>floor((maxInt-delta)/handledCPCountPlusOne)){error("overflow")}delta+=(m-n)*handledCPCountPlusOne;n=m;for(j=0;j<inputLength;++j){currentValue=input[j];if(currentValue<n&&++delta>maxInt){error("overflow")}if(currentValue==n){for(q=delta,k=base;;k+=base){t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias;if(q<t){break}qMinusT=q-t;baseMinusT=base-t;output.push(stringFromCharCode(digitToBasic(t+qMinusT%baseMinusT,0)));q=floor(qMinusT/baseMinusT)}output.push(stringFromCharCode(digitToBasic(q,0)));bias=adapt(delta,handledCPCountPlusOne,handledCPCount==basicLength);delta=0;++handledCPCount}}++delta;++n}return output.join("")}function toUnicode(domain){return mapDomain(domain,function(string){return regexPunycode.test(string)?decode(string.slice(4).toLowerCase()):string})}function toASCII(domain){return mapDomain(domain,function(string){return regexNonASCII.test(string)?"xn--"+encode(string):string})}punycode={version:"1.2.3",ucs2:{decode:ucs2decode,encode:ucs2encode},decode:decode,encode:encode,toASCII:toASCII,toUnicode:toUnicode};if(typeof define=="function"&&typeof define.amd=="object"&&define.amd){define(function(){return punycode})}else if(freeExports&&!freeExports.nodeType){if(freeModule){freeModule.exports=punycode}else{for(key in punycode){punycode.hasOwnProperty(key)&&(freeExports[key]=punycode[key])}}}else{root.punycode=punycode}})(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],18:[function(require,module,exports){if(typeof Object.create==="function"){module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:false,writable:true,configurable:true}})}}else{module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype;ctor.prototype=new TempCtor;ctor.prototype.constructor=ctor}}},{}],19:[function(require,module,exports){var process=module.exports={};process.nextTick=function(){var canSetImmediate=typeof window!=="undefined"&&window.setImmediate;var canMutationObserver=typeof window!=="undefined"&&window.MutationObserver;var canPost=typeof window!=="undefined"&&window.postMessage&&window.addEventListener;if(canSetImmediate){return function(f){return window.setImmediate(f)}}var queue=[];if(canMutationObserver){var hiddenDiv=document.createElement("div");var observer=new MutationObserver(function(){var queueList=queue.slice();queue.length=0;queueList.forEach(function(fn){fn()})});observer.observe(hiddenDiv,{attributes:true});return function nextTick(fn){if(!queue.length){hiddenDiv.setAttribute("yes","no")}queue.push(fn)}}if(canPost){window.addEventListener("message",function(ev){var source=ev.source;if((source===window||source===null)&&ev.data==="process-tick"){ev.stopPropagation();if(queue.length>0){var fn=queue.shift();fn()}}},true);return function nextTick(fn){queue.push(fn);window.postMessage("process-tick","*")}}return function nextTick(fn){setTimeout(fn,0)}}();process.title="browser";process.browser=true;process.env={};process.argv=[];function noop(){}process.on=noop;process.addListener=noop;process.once=noop;process.off=noop;process.removeListener=noop;process.removeAllListeners=noop;process.emit=noop;process.binding=function(name){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(dir){throw new Error("process.chdir is not supported")}},{}],20:[function(require,module,exports){module.exports=function isBuffer(arg){return arg&&typeof arg==="object"&&typeof arg.copy==="function"&&typeof arg.fill==="function"&&typeof arg.readUInt8==="function"}},{}],21:[function(require,module,exports){(function(process,global){var formatRegExp=/%[sdj%]/g;exports.format=function(f){if(!isString(f)){var objects=[];for(var i=0;i<arguments.length;i++){objects.push(inspect(arguments[i]))}return objects.join(" ")}var i=1;var args=arguments;var len=args.length;var str=String(f).replace(formatRegExp,function(x){if(x==="%%")return"%";if(i>=len)return x;switch(x){case"%s":return String(args[i++]);case"%d":return Number(args[i++]);case"%j":try{return JSON.stringify(args[i++])}catch(_){return"[Circular]"}default:return x}});for(var x=args[i];i<len;x=args[++i]){if(isNull(x)||!isObject(x)){str+=" "+x}else{str+=" "+inspect(x)}}return str};exports.deprecate=function(fn,msg){if(isUndefined(global.process)){return function(){return exports.deprecate(fn,msg).apply(this,arguments);
}}if(process.noDeprecation===true){return fn}var warned=false;function deprecated(){if(!warned){if(process.throwDeprecation){throw new Error(msg)}else if(process.traceDeprecation){console.trace(msg)}else{console.error(msg)}warned=true}return fn.apply(this,arguments)}return deprecated};var debugs={};var debugEnviron;exports.debuglog=function(set){if(isUndefined(debugEnviron))debugEnviron=process.env.NODE_DEBUG||"";set=set.toUpperCase();if(!debugs[set]){if(new RegExp("\\b"+set+"\\b","i").test(debugEnviron)){var pid=process.pid;debugs[set]=function(){var msg=exports.format.apply(exports,arguments);console.error("%s %d: %s",set,pid,msg)}}else{debugs[set]=function(){}}}return debugs[set]};function inspect(obj,opts){var ctx={seen:[],stylize:stylizeNoColor};if(arguments.length>=3)ctx.depth=arguments[2];if(arguments.length>=4)ctx.colors=arguments[3];if(isBoolean(opts)){ctx.showHidden=opts}else if(opts){exports._extend(ctx,opts)}if(isUndefined(ctx.showHidden))ctx.showHidden=false;if(isUndefined(ctx.depth))ctx.depth=2;if(isUndefined(ctx.colors))ctx.colors=false;if(isUndefined(ctx.customInspect))ctx.customInspect=true;if(ctx.colors)ctx.stylize=stylizeWithColor;return formatValue(ctx,obj,ctx.depth)}exports.inspect=inspect;inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};inspect.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"};function stylizeWithColor(str,styleType){var style=inspect.styles[styleType];if(style){return"["+inspect.colors[style][0]+"m"+str+"["+inspect.colors[style][1]+"m"}else{return str}}function stylizeNoColor(str,styleType){return str}function arrayToHash(array){var hash={};array.forEach(function(val,idx){hash[val]=true});return hash}function formatValue(ctx,value,recurseTimes){if(ctx.customInspect&&value&&isFunction(value.inspect)&&value.inspect!==exports.inspect&&!(value.constructor&&value.constructor.prototype===value)){var ret=value.inspect(recurseTimes,ctx);if(!isString(ret)){ret=formatValue(ctx,ret,recurseTimes)}return ret}var primitive=formatPrimitive(ctx,value);if(primitive){return primitive}var keys=Object.keys(value);var visibleKeys=arrayToHash(keys);if(ctx.showHidden){keys=Object.getOwnPropertyNames(value)}if(isError(value)&&(keys.indexOf("message")>=0||keys.indexOf("description")>=0)){return formatError(value)}if(keys.length===0){if(isFunction(value)){var name=value.name?": "+value.name:"";return ctx.stylize("[Function"+name+"]","special")}if(isRegExp(value)){return ctx.stylize(RegExp.prototype.toString.call(value),"regexp")}if(isDate(value)){return ctx.stylize(Date.prototype.toString.call(value),"date")}if(isError(value)){return formatError(value)}}var base="",array=false,braces=["{","}"];if(isArray(value)){array=true;braces=["[","]"]}if(isFunction(value)){var n=value.name?": "+value.name:"";base=" [Function"+n+"]"}if(isRegExp(value)){base=" "+RegExp.prototype.toString.call(value)}if(isDate(value)){base=" "+Date.prototype.toUTCString.call(value)}if(isError(value)){base=" "+formatError(value)}if(keys.length===0&&(!array||value.length==0)){return braces[0]+base+braces[1]}if(recurseTimes<0){if(isRegExp(value)){return ctx.stylize(RegExp.prototype.toString.call(value),"regexp")}else{return ctx.stylize("[Object]","special")}}ctx.seen.push(value);var output;if(array){output=formatArray(ctx,value,recurseTimes,visibleKeys,keys)}else{output=keys.map(function(key){return formatProperty(ctx,value,recurseTimes,visibleKeys,key,array)})}ctx.seen.pop();return reduceToSingleString(output,base,braces)}function formatPrimitive(ctx,value){if(isUndefined(value))return ctx.stylize("undefined","undefined");if(isString(value)){var simple="'"+JSON.stringify(value).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return ctx.stylize(simple,"string")}if(isNumber(value))return ctx.stylize(""+value,"number");if(isBoolean(value))return ctx.stylize(""+value,"boolean");if(isNull(value))return ctx.stylize("null","null")}function formatError(value){return"["+Error.prototype.toString.call(value)+"]"}function formatArray(ctx,value,recurseTimes,visibleKeys,keys){var output=[];for(var i=0,l=value.length;i<l;++i){if(hasOwnProperty(value,String(i))){output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,String(i),true))}else{output.push("")}}keys.forEach(function(key){if(!key.match(/^\d+$/)){output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,key,true))}});return output}function formatProperty(ctx,value,recurseTimes,visibleKeys,key,array){var name,str,desc;desc=Object.getOwnPropertyDescriptor(value,key)||{value:value[key]};if(desc.get){if(desc.set){str=ctx.stylize("[Getter/Setter]","special")}else{str=ctx.stylize("[Getter]","special")}}else{if(desc.set){str=ctx.stylize("[Setter]","special")}}if(!hasOwnProperty(visibleKeys,key)){name="["+key+"]"}if(!str){if(ctx.seen.indexOf(desc.value)<0){if(isNull(recurseTimes)){str=formatValue(ctx,desc.value,null)}else{str=formatValue(ctx,desc.value,recurseTimes-1)}if(str.indexOf("\n")>-1){if(array){str=str.split("\n").map(function(line){return" "+line}).join("\n").substr(2)}else{str="\n"+str.split("\n").map(function(line){return" "+line}).join("\n")}}}else{str=ctx.stylize("[Circular]","special")}}if(isUndefined(name)){if(array&&key.match(/^\d+$/)){return str}name=JSON.stringify(""+key);if(name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)){name=name.substr(1,name.length-2);name=ctx.stylize(name,"name")}else{name=name.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'");name=ctx.stylize(name,"string")}}return name+": "+str}function reduceToSingleString(output,base,braces){var numLinesEst=0;var length=output.reduce(function(prev,cur){numLinesEst++;if(cur.indexOf("\n")>=0)numLinesEst++;return prev+cur.replace(/\u001b\[\d\d?m/g,"").length+1},0);if(length>60){return braces[0]+(base===""?"":base+"\n ")+" "+output.join(",\n ")+" "+braces[1]}return braces[0]+base+" "+output.join(", ")+" "+braces[1]}function isArray(ar){return Array.isArray(ar)}exports.isArray=isArray;function isBoolean(arg){return typeof arg==="boolean"}exports.isBoolean=isBoolean;function isNull(arg){return arg===null}exports.isNull=isNull;function isNullOrUndefined(arg){return arg==null}exports.isNullOrUndefined=isNullOrUndefined;function isNumber(arg){return typeof arg==="number"}exports.isNumber=isNumber;function isString(arg){return typeof arg==="string"}exports.isString=isString;function isSymbol(arg){return typeof arg==="symbol"}exports.isSymbol=isSymbol;function isUndefined(arg){return arg===void 0}exports.isUndefined=isUndefined;function isRegExp(re){return isObject(re)&&objectToString(re)==="[object RegExp]"}exports.isRegExp=isRegExp;function isObject(arg){return typeof arg==="object"&&arg!==null}exports.isObject=isObject;function isDate(d){return isObject(d)&&objectToString(d)==="[object Date]"}exports.isDate=isDate;function isError(e){return isObject(e)&&(objectToString(e)==="[object Error]"||e instanceof Error)}exports.isError=isError;function isFunction(arg){return typeof arg==="function"}exports.isFunction=isFunction;function isPrimitive(arg){return arg===null||typeof arg==="boolean"||typeof arg==="number"||typeof arg==="string"||typeof arg==="symbol"||typeof arg==="undefined"}exports.isPrimitive=isPrimitive;exports.isBuffer=require("./support/isBuffer");function objectToString(o){return Object.prototype.toString.call(o)}function pad(n){return n<10?"0"+n.toString(10):n.toString(10)}var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function timestamp(){var d=new Date;var time=[pad(d.getHours()),pad(d.getMinutes()),pad(d.getSeconds())].join(":");return[d.getDate(),months[d.getMonth()],time].join(" ")}exports.log=function(){console.log("%s - %s",timestamp(),exports.format.apply(exports,arguments))};exports.inherits=require("inherits");exports._extend=function(origin,add){if(!add||!isObject(add))return origin;var keys=Object.keys(add);var i=keys.length;while(i--){origin[keys[i]]=add[keys[i]]}return origin};function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}}).call(this,require("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./support/isBuffer":20,_process:19,inherits:18}],22:[function(require,module,exports){(function(){"use strict";exports.digest=function(M){var originalLength,i,j,k,l,A,B,C,D,AA,BB,CC,DD,X,rval;function F(x,y,z){return x&y|~x&z}function G(x,y,z){return x&z|y&~z}function H(x,y,z){return x^y^z}function I(x,y,z){return y^(x|~z)}function to4bytes(n){return[n&255,n>>>8&255,n>>>16&255,n>>>24&255]}originalLength=M.length;M.push(128);l=56-M.length&63;for(i=0;i<l;i++)M.push(0);to4bytes(8*originalLength).forEach(function(e){M.push(e)});[0,0,0,0].forEach(function(e){M.push(e)});A=[1732584193];B=[4023233417];C=[2562383102];D=[271733878];function rounds(a,b,c,d,k,s,t,f){a[0]+=f(b[0],c[0],d[0])+X[k]+t;a[0]=a[0]<<s|a[0]>>>32-s;a[0]+=b[0]}for(i=0;i<M.length;i+=64){X=[];for(j=0;j<64;j+=4){k=i+j;X.push(M[k]|M[k+1]<<8|M[k+2]<<16|M[k+3]<<24)}AA=A[0];BB=B[0];CC=C[0];DD=D[0];rounds(A,B,C,D,0,7,3614090360,F);rounds(D,A,B,C,1,12,3905402710,F);rounds(C,D,A,B,2,17,606105819,F);rounds(B,C,D,A,3,22,3250441966,F);rounds(A,B,C,D,4,7,4118548399,F);rounds(D,A,B,C,5,12,1200080426,F);rounds(C,D,A,B,6,17,2821735955,F);rounds(B,C,D,A,7,22,4249261313,F);rounds(A,B,C,D,8,7,1770035416,F);rounds(D,A,B,C,9,12,2336552879,F);rounds(C,D,A,B,10,17,4294925233,F);rounds(B,C,D,A,11,22,2304563134,F);rounds(A,B,C,D,12,7,1804603682,F);rounds(D,A,B,C,13,12,4254626195,F);rounds(C,D,A,B,14,17,2792965006,F);rounds(B,C,D,A,15,22,1236535329,F);rounds(A,B,C,D,1,5,4129170786,G);rounds(D,A,B,C,6,9,3225465664,G);rounds(C,D,A,B,11,14,643717713,G);rounds(B,C,D,A,0,20,3921069994,G);rounds(A,B,C,D,5,5,3593408605,G);rounds(D,A,B,C,10,9,38016083,G);rounds(C,D,A,B,15,14,3634488961,G);rounds(B,C,D,A,4,20,3889429448,G);rounds(A,B,C,D,9,5,568446438,G);rounds(D,A,B,C,14,9,3275163606,G);rounds(C,D,A,B,3,14,4107603335,G);rounds(B,C,D,A,8,20,1163531501,G);rounds(A,B,C,D,13,5,2850285829,G);rounds(D,A,B,C,2,9,4243563512,G);rounds(C,D,A,B,7,14,1735328473,G);rounds(B,C,D,A,12,20,2368359562,G);rounds(A,B,C,D,5,4,4294588738,H);rounds(D,A,B,C,8,11,2272392833,H);rounds(C,D,A,B,11,16,1839030562,H);rounds(B,C,D,A,14,23,4259657740,H);rounds(A,B,C,D,1,4,2763975236,H);rounds(D,A,B,C,4,11,1272893353,H);rounds(C,D,A,B,7,16,4139469664,H);rounds(B,C,D,A,10,23,3200236656,H);rounds(A,B,C,D,13,4,681279174,H);rounds(D,A,B,C,0,11,3936430074,H);rounds(C,D,A,B,3,16,3572445317,H);rounds(B,C,D,A,6,23,76029189,H);rounds(A,B,C,D,9,4,3654602809,H);rounds(D,A,B,C,12,11,3873151461,H);rounds(C,D,A,B,15,16,530742520,H);rounds(B,C,D,A,2,23,3299628645,H);rounds(A,B,C,D,0,6,4096336452,I);rounds(D,A,B,C,7,10,1126891415,I);rounds(C,D,A,B,14,15,2878612391,I);rounds(B,C,D,A,5,21,4237533241,I);rounds(A,B,C,D,12,6,1700485571,I);rounds(D,A,B,C,3,10,2399980690,I);rounds(C,D,A,B,10,15,4293915773,I);rounds(B,C,D,A,1,21,2240044497,I);rounds(A,B,C,D,8,6,1873313359,I);rounds(D,A,B,C,15,10,4264355552,I);rounds(C,D,A,B,6,15,2734768916,I);rounds(B,C,D,A,13,21,1309151649,I);rounds(A,B,C,D,4,6,4149444226,I);rounds(D,A,B,C,11,10,3174756917,I);rounds(C,D,A,B,2,15,718787259,I);rounds(B,C,D,A,9,21,3951481745,I);A[0]+=AA;B[0]+=BB;C[0]+=CC;D[0]+=DD}rval=[];to4bytes(A[0]).forEach(function(e){rval.push(e)});to4bytes(B[0]).forEach(function(e){rval.push(e)});to4bytes(C[0]).forEach(function(e){rval.push(e)});to4bytes(D[0]).forEach(function(e){rval.push(e)});return rval};exports.digest_s=function(s){var M=[],i,d,rstr,s;for(i=0;i<s.length;i++)M.push(s.charCodeAt(i));d=exports.digest(M);rstr="";d.forEach(function(e){s=e.toString(16);while(s.length<2)s="0"+s;rstr+=s});return rstr}})()},{}],23:[function(require,module,exports){var s=1e3;var m=s*60;var h=m*60;var d=h*24;var y=d*365.25;module.exports=function(val,options){options=options||{};if("string"==typeof val)return parse(val);return options.long?long(val):short(val)};function parse(str){str=""+str;if(str.length>1e4)return;var match=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);if(!match)return;var n=parseFloat(match[1]);var type=(match[2]||"ms").toLowerCase();switch(type){case"years":case"year":case"yrs":case"yr":case"y":return n*y;case"days":case"day":case"d":return n*d;case"hours":case"hour":case"hrs":case"hr":case"h":return n*h;case"minutes":case"minute":case"mins":case"min":case"m":return n*m;case"seconds":case"second":case"secs":case"sec":case"s":return n*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n}}function short(ms){if(ms>=d)return Math.round(ms/d)+"d";if(ms>=h)return Math.round(ms/h)+"h";if(ms>=m)return Math.round(ms/m)+"m";if(ms>=s)return Math.round(ms/s)+"s";return ms+"ms"}function long(ms){return plural(ms,d,"day")||plural(ms,h,"hour")||plural(ms,m,"minute")||plural(ms,s,"second")||ms+" ms"}function plural(ms,n,name){if(ms<n)return;if(ms<n*1.5)return Math.floor(ms/n)+" "+name;return Math.ceil(ms/n)+" "+name+"s"}},{}]},{},[13]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment