text: !function(f){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=f();else if("function"==typeof define&&define.amd)define([],f);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).matchmore=f()}}(function(){return function(){return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&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||e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}}()({1:[function(require,module,exports){(function(Buffer){var root,factory;root=this,factory=function(superagent,querystring){"use strict";var exports=function(){this.basePath="https://api.matchmore.io/v5".replace(/\/+$/,""),this.authentications={"api-key":{type:"apiKey",in:"header",name:"api-key"}},this.defaultHeaders={},this.timeout=6e4,this.cache=!0,this.enableCookies=!1,"undefined"==typeof window&&(this.agent=new superagent.agent),this.requestAgent=null};return exports.prototype.paramToString=function(param){return void 0==param||null==param?"":param instanceof Date?param.toJSON():param.toString()},exports.prototype.buildUrl=function(path,pathParams){path.match(/^\//)||(path="/"+path);var url=this.basePath+path,_this=this;return url=url.replace(/\{([\w-]+)\}/g,function(fullMatch,key){var value;return value=pathParams.hasOwnProperty(key)?_this.paramToString(pathParams[key]):fullMatch,encodeURIComponent(value)})},exports.prototype.isJsonMime=function(contentType){return Boolean(null!=contentType&&contentType.match(/^application\/json(;.*)?$/i))},exports.prototype.jsonPreferredMime=function(contentTypes){for(var i=0;i<contentTypes.length;i++)if(this.isJsonMime(contentTypes[i]))return contentTypes[i];return contentTypes[0]},exports.prototype.isFileParam=function(param){return"function"==typeof require||("function"==typeof Buffer&&param instanceof Buffer||("function"==typeof Blob&&param instanceof Blob||"function"==typeof File&&param instanceof File))},exports.prototype.normalizeParams=function(params){var newParams={};for(var key in params)if(params.hasOwnProperty(key)&&void 0!=params[key]&&null!=params[key]){var value=params[key];this.isFileParam(value)||Array.isArray(value)?newParams[key]=value:newParams[key]=this.paramToString(value)}return newParams},exports.CollectionFormatEnum={CSV:",",SSV:" ",TSV:"\t",PIPES:"|",MULTI:"multi"},exports.prototype.buildCollectionParam=function(param,collectionFormat){if(null==param)return null;switch(collectionFormat){case"csv":return param.map(this.paramToString).join(",");case"ssv":return param.map(this.paramToString).join(" ");case"tsv":return param.map(this.paramToString).join("\t");case"pipes":return param.map(this.paramToString).join("|");case"multi":return param.map(this.paramToString);default:throw new Error("Unknown collection format: "+collectionFormat)}},exports.prototype.applyAuthToRequest=function(request,authNames){var _this=this;authNames.forEach(function(authName){var auth=_this.authentications[authName];switch(auth.type){case"basic":(auth.username||auth.password)&&request.auth(auth.username||"",auth.password||"");break;case"apiKey":if(auth.apiKey){var data={};auth.apiKeyPrefix?data[auth.name]=auth.apiKeyPrefix+" "+auth.apiKey:data[auth.name]=auth.apiKey,"header"===auth.in?request.set(data):request.query(data)}break;case"oauth2":auth.accessToken&&request.set({Authorization:"Bearer "+auth.accessToken});break;default:throw new Error("Unknown authentication type: "+auth.type)}})},exports.prototype.deserialize=function(response,returnType){if(null==response||null==returnType||204==response.status)return null;var data=response.body;return(null==data||"object"==typeof data&&void 0===data.length&&!Object.keys(data).length)&&(data=response.text),exports.convertToType(data,returnType)},exports.prototype.callApi=function(path,httpMethod,pathParams,queryParams,collectionQueryParams,headerParams,formParams,bodyParam,authNames,contentTypes,accepts,returnType,callback){var _this=this,url=this.buildUrl(path,pathParams),request=superagent(httpMethod,url);for(var key in this.applyAuthToRequest(request,authNames),collectionQueryParams)if(collectionQueryParams.hasOwnProperty(key)){var param=collectionQueryParams[key];if("csv"===param.collectionFormat){if(null!=param.value){var value=param.value.map(this.paramToString).map(encodeURIComponent).join(",");request.query(encodeURIComponent(key)+"="+value)}}else queryParams[key]=this.buildCollectionParam(param.value,param.collectionFormat)}"GET"===httpMethod.toUpperCase()&&!1===this.cache&&(queryParams._=(new Date).getTime()),request.query(this.normalizeParams(queryParams)),request.set(this.defaultHeaders).set(this.normalizeParams(headerParams)),this.requestAgent&&request.agent(this.requestAgent),request.timeout(this.timeout);var contentType=this.jsonPreferredMime(contentTypes);if(contentType?"multipart/form-data"!=contentType&&request.type(contentType):request.header["Content-Type"]||request.type("application/json"),"application/x-www-form-urlencoded"===contentType)request.send(querystring.stringify(this.normalizeParams(formParams)));else if("multipart/form-data"==contentType){var _formParams=this.normalizeParams(formParams);for(var key in _formParams)_formParams.hasOwnProperty(key)&&(this.isFileParam(_formParams[key])?request.attach(key,_formParams[key]):request.field(key,_formParams[key]))}else bodyParam&&request.send(bodyParam);var accept=this.jsonPreferredMime(accepts);return accept&&request.accept(accept),"Blob"===returnType?request.responseType("blob"):"String"===returnType&&request.responseType("string"),this.enableCookies&&("undefined"==typeof window?this.agent.attachCookies(request):request.withCredentials()),request.end(function(error,response){if(callback){var data=null;if(!error)try{data=_this.deserialize(response,returnType),_this.enableCookies&&"undefined"==typeof window&&_this.agent.saveCookies(response)}catch(err){error=err}callback(error,data,response)}}),request},exports.parseDate=function(str){return new Date(str.replace(/T/i," "))},exports.convertToType=function(data,type){if(null===data||void 0===data)return data;switch(type){case"Boolean":return Boolean(data);case"Integer":return parseInt(data,10);case"Number":return parseFloat(data);case"String":return String(data);case"Date":return this.parseDate(String(data));case"Blob":default:return data}},exports.constructFromObject=function(data,obj,itemType){if(Array.isArray(data))for(var i=0;i<data.length;i++)data.hasOwnProperty(i)&&(obj[i]=exports.convertToType(data[i],itemType));else for(var k in data)data.hasOwnProperty(k)&&(obj[k]=exports.convertToType(data[k],itemType))},exports.instance=new exports,exports},"object"==typeof module&&module.exports?module.exports=factory(require("superagent"),require("querystring")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.ApiClient=factory(root.superagent,root.querystring))}).call(this,require("buffer").Buffer)},{buffer:38,querystring:43,superagent:45}],2:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient,APIError,Device,DeviceUpdate,IBeaconTriples,Location,Match,Matches,ProximityEvent,Publication,Publications,Subscription,Subscriptions){"use strict";return function(apiClient){this.apiClient=apiClient||ApiClient.instance,this.createDevice=function(device,callback){var postBody=device;if(void 0===device||null===device)throw new Error("Missing the required parameter 'device' when calling createDevice");var returnType=Device;return this.apiClient.callApi("/devices","POST",{},{},{},{},{},postBody,["api-key"],["application/json"],["application/json"],returnType,callback)},this.createLocation=function(deviceId,location,callback){var postBody=location;if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling createLocation");if(void 0===location||null===location)throw new Error("Missing the required parameter 'location' when calling createLocation");var pathParams={deviceId:deviceId},returnType=Location;return this.apiClient.callApi("/devices/{deviceId}/locations","POST",pathParams,{},{},{},{},postBody,["api-key"],["application/json"],["application/json"],returnType,callback)},this.createPublication=function(deviceId,publication,callback){var postBody=publication;if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling createPublication");if(void 0===publication||null===publication)throw new Error("Missing the required parameter 'publication' when calling createPublication");var pathParams={deviceId:deviceId},returnType=Publication;return this.apiClient.callApi("/devices/{deviceId}/publications","POST",pathParams,{},{},{},{},postBody,["api-key"],["application/json"],["application/json"],returnType,callback)},this.createSubscription=function(deviceId,subscription,callback){var postBody=subscription;if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling createSubscription");if(void 0===subscription||null===subscription)throw new Error("Missing the required parameter 'subscription' when calling createSubscription");var pathParams={deviceId:deviceId},returnType=Subscription;return this.apiClient.callApi("/devices/{deviceId}/subscriptions","POST",pathParams,{},{},{},{},postBody,["api-key"],["application/json"],["application/json"],returnType,callback)},this.deleteDevice=function(deviceId,callback){if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling deleteDevice");var pathParams={deviceId:deviceId};return this.apiClient.callApi("/devices/{deviceId}","DELETE",pathParams,{},{},{},{},null,["api-key"],["application/json"],["application/json"],null,callback)},this.deletePublication=function(deviceId,publicationId,callback){if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling deletePublication");if(void 0===publicationId||null===publicationId)throw new Error("Missing the required parameter 'publicationId' when calling deletePublication");var pathParams={deviceId:deviceId,publicationId:publicationId};return this.apiClient.callApi("/devices/{deviceId}/publications/{publicationId}","DELETE",pathParams,{},{},{},{},null,["api-key"],["application/json"],["application/json"],null,callback)},this.deleteSubscription=function(deviceId,subscriptionId,callback){if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling deleteSubscription");if(void 0===subscriptionId||null===subscriptionId)throw new Error("Missing the required parameter 'subscriptionId' when calling deleteSubscription");var pathParams={deviceId:deviceId,subscriptionId:subscriptionId};return this.apiClient.callApi("/devices/{deviceId}/subscriptions/{subscriptionId}","DELETE",pathParams,{},{},{},{},null,["api-key"],["application/json"],["application/json"],null,callback)},this.getDevice=function(deviceId,callback){if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling getDevice");var pathParams={deviceId:deviceId},returnType=Device;return this.apiClient.callApi("/devices/{deviceId}","GET",pathParams,{},{},{},{},null,["api-key"],["application/json"],["application/json"],returnType,callback)},this.getIBeaconTriples=function(callback){var returnType=IBeaconTriples;return this.apiClient.callApi("/devices/IBeaconTriples","GET",{},{},{},{},{},null,["api-key"],["application/json"],["application/json"],returnType,callback)},this.getMatch=function(deviceId,matchId,callback){if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling getMatch");if(void 0===matchId||null===matchId)throw new Error("Missing the required parameter 'matchId' when calling getMatch");var pathParams={deviceId:deviceId,matchId:matchId},returnType=Match;return this.apiClient.callApi("/devices/{deviceId}/matches/{matchId}","GET",pathParams,{},{},{},{},null,["api-key"],["application/json"],["application/json"],returnType,callback)},this.getMatches=function(deviceId,callback){if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling getMatches");var pathParams={deviceId:deviceId},returnType=Matches;return this.apiClient.callApi("/devices/{deviceId}/matches","GET",pathParams,{},{},{},{},null,["api-key"],["application/json"],["application/json"],returnType,callback)},this.getPublication=function(deviceId,publicationId,callback){if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling getPublication");if(void 0===publicationId||null===publicationId)throw new Error("Missing the required parameter 'publicationId' when calling getPublication");var pathParams={deviceId:deviceId,publicationId:publicationId},returnType=Publication;return this.apiClient.callApi("/devices/{deviceId}/publications/{publicationId}","GET",pathParams,{},{},{},{},null,["api-key"],["application/json"],["application/json"],returnType,callback)},this.getPublications=function(deviceId,callback){if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling getPublications");var pathParams={deviceId:deviceId},returnType=Publications;return this.apiClient.callApi("/devices/{deviceId}/publications","GET",pathParams,{},{},{},{},null,["api-key"],["application/json"],["application/json"],returnType,callback)},this.getSubscription=function(deviceId,subscriptionId,callback){if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling getSubscription");if(void 0===subscriptionId||null===subscriptionId)throw new Error("Missing the required parameter 'subscriptionId' when calling getSubscription");var pathParams={deviceId:deviceId,subscriptionId:subscriptionId},returnType=Subscription;return this.apiClient.callApi("/devices/{deviceId}/subscriptions/{subscriptionId}","GET",pathParams,{},{},{},{},null,["api-key"],["application/json"],["application/json"],returnType,callback)},this.getSubscriptions=function(deviceId,callback){if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling getSubscriptions");var pathParams={deviceId:deviceId},returnType=Subscriptions;return this.apiClient.callApi("/devices/{deviceId}/subscriptions","GET",pathParams,{},{},{},{},null,["api-key"],["application/json"],["application/json"],returnType,callback)},this.triggerProximityEvents=function(deviceId,proximityEvent,callback){var postBody=proximityEvent;if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling triggerProximityEvents");if(void 0===proximityEvent||null===proximityEvent)throw new Error("Missing the required parameter 'proximityEvent' when calling triggerProximityEvents");var pathParams={deviceId:deviceId},returnType=ProximityEvent;return this.apiClient.callApi("/devices/{deviceId}/proximityEvents","POST",pathParams,{},{},{},{},postBody,["api-key"],["application/json"],["application/json"],returnType,callback)},this.updateDevice=function(device,callback){var postBody=device;if(void 0===device||null===device)throw new Error("Missing the required parameter 'device' when calling updateDevice");var returnType=Device;return this.apiClient.callApi("/devices/{deviceId}","PATCH",{},{},{},{},{},postBody,["api-key"],["application/json"],["application/json"],returnType,callback)}}},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient"),require("../model/APIError"),require("../model/Device"),require("../model/DeviceUpdate"),require("../model/IBeaconTriples"),require("../model/Location"),require("../model/Match"),require("../model/Matches"),require("../model/ProximityEvent"),require("../model/Publication"),require("../model/Publications"),require("../model/Subscription"),require("../model/Subscriptions")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.DeviceApi=factory(root.MatchmoreAlpsCoreRestApi.ApiClient,root.MatchmoreAlpsCoreRestApi.APIError,root.MatchmoreAlpsCoreRestApi.Device,root.MatchmoreAlpsCoreRestApi.DeviceUpdate,root.MatchmoreAlpsCoreRestApi.IBeaconTriples,root.MatchmoreAlpsCoreRestApi.Location,root.MatchmoreAlpsCoreRestApi.Match,root.MatchmoreAlpsCoreRestApi.Matches,root.MatchmoreAlpsCoreRestApi.ProximityEvent,root.MatchmoreAlpsCoreRestApi.Publication,root.MatchmoreAlpsCoreRestApi.Publications,root.MatchmoreAlpsCoreRestApi.Subscription,root.MatchmoreAlpsCoreRestApi.Subscriptions))},{"../ApiClient":1,"../model/APIError":8,"../model/Device":9,"../model/DeviceUpdate":11,"../model/IBeaconTriples":15,"../model/Location":16,"../model/Match":17,"../model/Matches":18,"../model/ProximityEvent":21,"../model/Publication":22,"../model/Publications":23,"../model/Subscription":24,"../model/Subscriptions":25}],3:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient,APIError,Location){"use strict";return function(apiClient){this.apiClient=apiClient||ApiClient.instance,this.createLocation=function(deviceId,location,callback){var postBody=location;if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling createLocation");if(void 0===location||null===location)throw new Error("Missing the required parameter 'location' when calling createLocation");var pathParams={deviceId:deviceId},returnType=Location;return this.apiClient.callApi("/devices/{deviceId}/locations","POST",pathParams,{},{},{},{},postBody,["api-key"],["application/json"],["application/json"],returnType,callback)}}},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient"),require("../model/APIError"),require("../model/Location")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.LocationApi=factory(root.MatchmoreAlpsCoreRestApi.ApiClient,root.MatchmoreAlpsCoreRestApi.APIError,root.MatchmoreAlpsCoreRestApi.Location))},{"../ApiClient":1,"../model/APIError":8,"../model/Location":16}],4:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient,APIError,Match,Matches){"use strict";return function(apiClient){this.apiClient=apiClient||ApiClient.instance,this.getMatch=function(deviceId,matchId,callback){if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling getMatch");if(void 0===matchId||null===matchId)throw new Error("Missing the required parameter 'matchId' when calling getMatch");var pathParams={deviceId:deviceId,matchId:matchId},returnType=Match;return this.apiClient.callApi("/devices/{deviceId}/matches/{matchId}","GET",pathParams,{},{},{},{},null,["api-key"],["application/json"],["application/json"],returnType,callback)},this.getMatches=function(deviceId,callback){if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling getMatches");var pathParams={deviceId:deviceId},returnType=Matches;return this.apiClient.callApi("/devices/{deviceId}/matches","GET",pathParams,{},{},{},{},null,["api-key"],["application/json"],["application/json"],returnType,callback)}}},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient"),require("../model/APIError"),require("../model/Match"),require("../model/Matches")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.MatchesApi=factory(root.MatchmoreAlpsCoreRestApi.ApiClient,root.MatchmoreAlpsCoreRestApi.APIError,root.MatchmoreAlpsCoreRestApi.Match,root.MatchmoreAlpsCoreRestApi.Matches))},{"../ApiClient":1,"../model/APIError":8,"../model/Match":17,"../model/Matches":18}],5:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient,APIError,Publication,Publications){"use strict";return function(apiClient){this.apiClient=apiClient||ApiClient.instance,this.createPublication=function(deviceId,publication,callback){var postBody=publication;if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling createPublication");if(void 0===publication||null===publication)throw new Error("Missing the required parameter 'publication' when calling createPublication");var pathParams={deviceId:deviceId},returnType=Publication;return this.apiClient.callApi("/devices/{deviceId}/publications","POST",pathParams,{},{},{},{},postBody,["api-key"],["application/json"],["application/json"],returnType,callback)},this.deletePublication=function(deviceId,publicationId,callback){if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling deletePublication");if(void 0===publicationId||null===publicationId)throw new Error("Missing the required parameter 'publicationId' when calling deletePublication");var pathParams={deviceId:deviceId,publicationId:publicationId};return this.apiClient.callApi("/devices/{deviceId}/publications/{publicationId}","DELETE",pathParams,{},{},{},{},null,["api-key"],["application/json"],["application/json"],null,callback)},this.getPublication=function(deviceId,publicationId,callback){if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling getPublication");if(void 0===publicationId||null===publicationId)throw new Error("Missing the required parameter 'publicationId' when calling getPublication");var pathParams={deviceId:deviceId,publicationId:publicationId},returnType=Publication;return this.apiClient.callApi("/devices/{deviceId}/publications/{publicationId}","GET",pathParams,{},{},{},{},null,["api-key"],["application/json"],["application/json"],returnType,callback)},this.getPublications=function(deviceId,callback){if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling getPublications");var pathParams={deviceId:deviceId},returnType=Publications;return this.apiClient.callApi("/devices/{deviceId}/publications","GET",pathParams,{},{},{},{},null,["api-key"],["application/json"],["application/json"],returnType,callback)}}},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient"),require("../model/APIError"),require("../model/Publication"),require("../model/Publications")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.PublicationApi=factory(root.MatchmoreAlpsCoreRestApi.ApiClient,root.MatchmoreAlpsCoreRestApi.APIError,root.MatchmoreAlpsCoreRestApi.Publication,root.MatchmoreAlpsCoreRestApi.Publications))},{"../ApiClient":1,"../model/APIError":8,"../model/Publication":22,"../model/Publications":23}],6:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient,APIError,Subscription,Subscriptions){"use strict";return function(apiClient){this.apiClient=apiClient||ApiClient.instance,this.createSubscription=function(deviceId,subscription,callback){var postBody=subscription;if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling createSubscription");if(void 0===subscription||null===subscription)throw new Error("Missing the required parameter 'subscription' when calling createSubscription");var pathParams={deviceId:deviceId},returnType=Subscription;return this.apiClient.callApi("/devices/{deviceId}/subscriptions","POST",pathParams,{},{},{},{},postBody,["api-key"],["application/json"],["application/json"],returnType,callback)},this.deleteSubscription=function(deviceId,subscriptionId,callback){if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling deleteSubscription");if(void 0===subscriptionId||null===subscriptionId)throw new Error("Missing the required parameter 'subscriptionId' when calling deleteSubscription");var pathParams={deviceId:deviceId,subscriptionId:subscriptionId};return this.apiClient.callApi("/devices/{deviceId}/subscriptions/{subscriptionId}","DELETE",pathParams,{},{},{},{},null,["api-key"],["application/json"],["application/json"],null,callback)},this.getSubscription=function(deviceId,subscriptionId,callback){if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling getSubscription");if(void 0===subscriptionId||null===subscriptionId)throw new Error("Missing the required parameter 'subscriptionId' when calling getSubscription");var pathParams={deviceId:deviceId,subscriptionId:subscriptionId},returnType=Subscription;return this.apiClient.callApi("/devices/{deviceId}/subscriptions/{subscriptionId}","GET",pathParams,{},{},{},{},null,["api-key"],["application/json"],["application/json"],returnType,callback)},this.getSubscriptions=function(deviceId,callback){if(void 0===deviceId||null===deviceId)throw new Error("Missing the required parameter 'deviceId' when calling getSubscriptions");var pathParams={deviceId:deviceId},returnType=Subscriptions;return this.apiClient.callApi("/devices/{deviceId}/subscriptions","GET",pathParams,{},{},{},{},null,["api-key"],["application/json"],["application/json"],returnType,callback)}}},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient"),require("../model/APIError"),require("../model/Subscription"),require("../model/Subscriptions")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.SubscriptionApi=factory(root.MatchmoreAlpsCoreRestApi.ApiClient,root.MatchmoreAlpsCoreRestApi.APIError,root.MatchmoreAlpsCoreRestApi.Subscription,root.MatchmoreAlpsCoreRestApi.Subscriptions))},{"../ApiClient":1,"../model/APIError":8,"../model/Subscription":24,"../model/Subscriptions":25}],7:[function(require,module,exports){var factory;factory=function(ApiClient,APIError,Device,DeviceType,DeviceUpdate,Devices,IBeaconTriple,IBeaconTriples,Location,Match,Matches,ProximityEvent,Publication,Publications,Subscription,Subscriptions,IBeaconDevice,MobileDevice,PinDevice,DeviceApi,LocationApi,MatchesApi,PublicationApi,SubscriptionApi){"use strict";return{ApiClient:ApiClient,APIError:APIError,Device:Device,DeviceType:DeviceType,DeviceUpdate:DeviceUpdate,Devices:Devices,IBeaconTriple:IBeaconTriple,IBeaconTriples:IBeaconTriples,Location:Location,Match:Match,Matches:Matches,ProximityEvent:ProximityEvent,Publication:Publication,Publications:Publications,Subscription:Subscription,Subscriptions:Subscriptions,IBeaconDevice:IBeaconDevice,MobileDevice:MobileDevice,PinDevice:PinDevice,DeviceApi:DeviceApi,LocationApi:LocationApi,MatchesApi:MatchesApi,PublicationApi:PublicationApi,SubscriptionApi:SubscriptionApi}},"object"==typeof module&&module.exports&&(module.exports=factory(require("./ApiClient"),require("./model/APIError"),require("./model/Device"),require("./model/DeviceType"),require("./model/DeviceUpdate"),require("./model/Devices"),require("./model/IBeaconTriple"),require("./model/IBeaconTriples"),require("./model/Location"),require("./model/Match"),require("./model/Matches"),require("./model/ProximityEvent"),require("./model/Publication"),require("./model/Publications"),require("./model/Subscription"),require("./model/Subscriptions"),require("./model/IBeaconDevice"),require("./model/MobileDevice"),require("./model/PinDevice"),require("./api/DeviceApi"),require("./api/LocationApi"),require("./api/MatchesApi"),require("./api/PublicationApi"),require("./api/SubscriptionApi")))},{"./ApiClient":1,"./api/DeviceApi":2,"./api/LocationApi":3,"./api/MatchesApi":4,"./api/PublicationApi":5,"./api/SubscriptionApi":6,"./model/APIError":8,"./model/Device":9,"./model/DeviceType":10,"./model/DeviceUpdate":11,"./model/Devices":12,"./model/IBeaconDevice":13,"./model/IBeaconTriple":14,"./model/IBeaconTriples":15,"./model/Location":16,"./model/Match":17,"./model/Matches":18,"./model/MobileDevice":19,"./model/PinDevice":20,"./model/ProximityEvent":21,"./model/Publication":22,"./model/Publications":23,"./model/Subscription":24,"./model/Subscriptions":25}],8:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient){"use strict";var exports=function(code,message){this.code=code,this.message=message};return exports.constructFromObject=function(data,obj){return data&&(obj=obj||new exports,data.hasOwnProperty("code")&&(obj.code=ApiClient.convertToType(data.code,"Number")),data.hasOwnProperty("message")&&(obj.message=ApiClient.convertToType(data.message,"String"))),obj},exports.prototype.code=void 0,exports.prototype.message=void 0,exports},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.APIError=factory(root.MatchmoreAlpsCoreRestApi.ApiClient))},{"../ApiClient":1}],9:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient,DeviceType){"use strict";var exports=function(deviceType){this.deviceType=deviceType};return exports.constructFromObject=function(data,obj){return data&&(obj=obj||new exports,data.hasOwnProperty("id")&&(obj.id=ApiClient.convertToType(data.id,"String")),data.hasOwnProperty("createdAt")&&(obj.createdAt=ApiClient.convertToType(data.createdAt,"Number")),data.hasOwnProperty("updatedAt")&&(obj.updatedAt=ApiClient.convertToType(data.updatedAt,"Number")),data.hasOwnProperty("group")&&(obj.group=ApiClient.convertToType(data.group,["String"])),data.hasOwnProperty("name")&&(obj.name=ApiClient.convertToType(data.name,"String")),data.hasOwnProperty("deviceType")&&(obj.deviceType=DeviceType.constructFromObject(data.deviceType))),obj},exports.prototype.id=void 0,exports.prototype.createdAt=void 0,exports.prototype.updatedAt=void 0,exports.prototype.group=void 0,exports.prototype.name="",exports.prototype.deviceType=void 0,exports},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient"),require("./DeviceType")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.Device=factory(root.MatchmoreAlpsCoreRestApi.ApiClient,root.MatchmoreAlpsCoreRestApi.DeviceType))},{"../ApiClient":1,"./DeviceType":10}],10:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient){"use strict";var exports={MobileDevice:"MobileDevice",PinDevice:"PinDevice",IBeaconDevice:"IBeaconDevice",constructFromObject:function(object){return object}};return exports},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.DeviceType=factory(root.MatchmoreAlpsCoreRestApi.ApiClient))},{"../ApiClient":1}],11:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient){"use strict";var exports=function(){};return exports.constructFromObject=function(data,obj){return data&&(obj=obj||new exports,data.hasOwnProperty("name")&&(obj.name=ApiClient.convertToType(data.name,"String")),data.hasOwnProperty("deviceToken")&&(obj.deviceToken=ApiClient.convertToType(data.deviceToken,"String"))),obj},exports.prototype.name=void 0,exports.prototype.deviceToken=void 0,exports},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.DeviceUpdate=factory(root.MatchmoreAlpsCoreRestApi.ApiClient))},{"../ApiClient":1}],12:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient,Device){"use strict";var exports=function(){var _this;return _this=new Array,Object.setPrototypeOf(_this,exports),_this};return exports.constructFromObject=function(data,obj){return data&&(obj=obj||new exports,ApiClient.constructFromObject(data,obj,"Device")),obj},exports},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient"),require("./Device")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.Devices=factory(root.MatchmoreAlpsCoreRestApi.ApiClient,root.MatchmoreAlpsCoreRestApi.Device))},{"../ApiClient":1,"./Device":9}],13:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient,Device,DeviceType){"use strict";var exports=function(deviceType,proximityUUID,major,minor){Device.call(this,deviceType),this.proximityUUID=proximityUUID,this.major=major,this.minor=minor};return exports.constructFromObject=function(data,obj){return data&&(obj=obj||new exports,Device.constructFromObject(data,obj),data.hasOwnProperty("proximityUUID")&&(obj.proximityUUID=ApiClient.convertToType(data.proximityUUID,"String")),data.hasOwnProperty("major")&&(obj.major=ApiClient.convertToType(data.major,"Number")),data.hasOwnProperty("minor")&&(obj.minor=ApiClient.convertToType(data.minor,"Number"))),obj},(exports.prototype=Object.create(Device.prototype)).constructor=exports,exports.prototype.proximityUUID=void 0,exports.prototype.major=void 0,exports.prototype.minor=void 0,exports},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient"),require("./Device"),require("./DeviceType")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.IBeaconDevice=factory(root.MatchmoreAlpsCoreRestApi.ApiClient,root.MatchmoreAlpsCoreRestApi.Device,root.MatchmoreAlpsCoreRestApi.DeviceType))},{"../ApiClient":1,"./Device":9,"./DeviceType":10}],14:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient){"use strict";var exports=function(){};return exports.constructFromObject=function(data,obj){return data&&(obj=obj||new exports,data.hasOwnProperty("deviceId")&&(obj.deviceId=ApiClient.convertToType(data.deviceId,"String")),data.hasOwnProperty("proximityUUID")&&(obj.proximityUUID=ApiClient.convertToType(data.proximityUUID,"String")),data.hasOwnProperty("major")&&(obj.major=ApiClient.convertToType(data.major,"Number")),data.hasOwnProperty("minor")&&(obj.minor=ApiClient.convertToType(data.minor,"Number"))),obj},exports.prototype.deviceId=void 0,exports.prototype.proximityUUID=void 0,exports.prototype.major=void 0,exports.prototype.minor=void 0,exports},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.IBeaconTriple=factory(root.MatchmoreAlpsCoreRestApi.ApiClient))},{"../ApiClient":1}],15:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient,IBeaconTriple){"use strict";var exports=function(){var _this;return _this=new Array,Object.setPrototypeOf(_this,exports),_this};return exports.constructFromObject=function(data,obj){return data&&(obj=obj||new exports,ApiClient.constructFromObject(data,obj,"IBeaconTriple")),obj},exports},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient"),require("./IBeaconTriple")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.IBeaconTriples=factory(root.MatchmoreAlpsCoreRestApi.ApiClient,root.MatchmoreAlpsCoreRestApi.IBeaconTriple))},{"../ApiClient":1,"./IBeaconTriple":14}],16:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient){"use strict";var exports=function(latitude,longitude,altitude){this.latitude=latitude,this.longitude=longitude,this.altitude=altitude};return exports.constructFromObject=function(data,obj){return data&&(obj=obj||new exports,data.hasOwnProperty("createdAt")&&(obj.createdAt=ApiClient.convertToType(data.createdAt,"Number")),data.hasOwnProperty("latitude")&&(obj.latitude=ApiClient.convertToType(data.latitude,"Number")),data.hasOwnProperty("longitude")&&(obj.longitude=ApiClient.convertToType(data.longitude,"Number")),data.hasOwnProperty("altitude")&&(obj.altitude=ApiClient.convertToType(data.altitude,"Number")),data.hasOwnProperty("horizontalAccuracy")&&(obj.horizontalAccuracy=ApiClient.convertToType(data.horizontalAccuracy,"Number")),data.hasOwnProperty("verticalAccuracy")&&(obj.verticalAccuracy=ApiClient.convertToType(data.verticalAccuracy,"Number"))),obj},exports.prototype.createdAt=void 0,exports.prototype.latitude=0,exports.prototype.longitude=0,exports.prototype.altitude=0,exports.prototype.horizontalAccuracy=1,exports.prototype.verticalAccuracy=1,exports},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.Location=factory(root.MatchmoreAlpsCoreRestApi.ApiClient))},{"../ApiClient":1}],17:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient,Publication,Subscription){"use strict";var exports=function(publication,subscription){this.publication=publication,this.subscription=subscription};return exports.constructFromObject=function(data,obj){return data&&(obj=obj||new exports,data.hasOwnProperty("id")&&(obj.id=ApiClient.convertToType(data.id,"String")),data.hasOwnProperty("createdAt")&&(obj.createdAt=ApiClient.convertToType(data.createdAt,"Number")),data.hasOwnProperty("publication")&&(obj.publication=Publication.constructFromObject(data.publication)),data.hasOwnProperty("subscription")&&(obj.subscription=Subscription.constructFromObject(data.subscription))),obj},exports.prototype.id=void 0,exports.prototype.createdAt=void 0,exports.prototype.publication=void 0,exports.prototype.subscription=void 0,exports},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient"),require("./Publication"),require("./Subscription")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.Match=factory(root.MatchmoreAlpsCoreRestApi.ApiClient,root.MatchmoreAlpsCoreRestApi.Publication,root.MatchmoreAlpsCoreRestApi.Subscription))},{"../ApiClient":1,"./Publication":22,"./Subscription":24}],18:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient,Match){"use strict";var exports=function(){var _this;return _this=new Array,Object.setPrototypeOf(_this,exports),_this};return exports.constructFromObject=function(data,obj){return data&&(obj=obj||new exports,ApiClient.constructFromObject(data,obj,"Match")),obj},exports},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient"),require("./Match")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.Matches=factory(root.MatchmoreAlpsCoreRestApi.ApiClient,root.MatchmoreAlpsCoreRestApi.Match))},{"../ApiClient":1,"./Match":17}],19:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient,Device,DeviceType,Location){"use strict";var exports=function(deviceType,platform,deviceToken,location){Device.call(this,deviceType),this.platform=platform,this.deviceToken=deviceToken,this.location=location};return exports.constructFromObject=function(data,obj){return data&&(obj=obj||new exports,Device.constructFromObject(data,obj),data.hasOwnProperty("platform")&&(obj.platform=ApiClient.convertToType(data.platform,"String")),data.hasOwnProperty("deviceToken")&&(obj.deviceToken=ApiClient.convertToType(data.deviceToken,"String")),data.hasOwnProperty("location")&&(obj.location=Location.constructFromObject(data.location))),obj},(exports.prototype=Object.create(Device.prototype)).constructor=exports,exports.prototype.platform=void 0,exports.prototype.deviceToken=void 0,exports.prototype.location=void 0,exports},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient"),require("./Device"),require("./DeviceType"),require("./Location")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.MobileDevice=factory(root.MatchmoreAlpsCoreRestApi.ApiClient,root.MatchmoreAlpsCoreRestApi.Device,root.MatchmoreAlpsCoreRestApi.DeviceType,root.MatchmoreAlpsCoreRestApi.Location))},{"../ApiClient":1,"./Device":9,"./DeviceType":10,"./Location":16}],20:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient,Device,DeviceType,Location){"use strict";var exports=function(deviceType,location){Device.call(this,deviceType),this.location=location};return exports.constructFromObject=function(data,obj){return data&&(obj=obj||new exports,Device.constructFromObject(data,obj),data.hasOwnProperty("location")&&(obj.location=Location.constructFromObject(data.location))),obj},(exports.prototype=Object.create(Device.prototype)).constructor=exports,exports.prototype.location=void 0,exports},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient"),require("./Device"),require("./DeviceType"),require("./Location")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.PinDevice=factory(root.MatchmoreAlpsCoreRestApi.ApiClient,root.MatchmoreAlpsCoreRestApi.Device,root.MatchmoreAlpsCoreRestApi.DeviceType,root.MatchmoreAlpsCoreRestApi.Location))},{"../ApiClient":1,"./Device":9,"./DeviceType":10,"./Location":16}],21:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient){"use strict";var exports=function(deviceId,distance){this.deviceId=deviceId,this.distance=distance};return exports.constructFromObject=function(data,obj){return data&&(obj=obj||new exports,data.hasOwnProperty("id")&&(obj.id=ApiClient.convertToType(data.id,"String")),data.hasOwnProperty("createdAt")&&(obj.createdAt=ApiClient.convertToType(data.createdAt,"Number")),data.hasOwnProperty("deviceId")&&(obj.deviceId=ApiClient.convertToType(data.deviceId,"String")),data.hasOwnProperty("distance")&&(obj.distance=ApiClient.convertToType(data.distance,"Number"))),obj},exports.prototype.id=void 0,exports.prototype.createdAt=void 0,exports.prototype.deviceId=void 0,exports.prototype.distance=void 0,exports},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.ProximityEvent=factory(root.MatchmoreAlpsCoreRestApi.ApiClient))},{"../ApiClient":1}],22:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient){"use strict";var exports=function(worldId,deviceId,topic,range,duration,properties){this.worldId=worldId,this.deviceId=deviceId,this.topic=topic,this.range=range,this.duration=duration,this.properties=properties};return exports.constructFromObject=function(data,obj){return data&&(obj=obj||new exports,data.hasOwnProperty("id")&&(obj.id=ApiClient.convertToType(data.id,"String")),data.hasOwnProperty("createdAt")&&(obj.createdAt=ApiClient.convertToType(data.createdAt,"Number")),data.hasOwnProperty("worldId")&&(obj.worldId=ApiClient.convertToType(data.worldId,"String")),data.hasOwnProperty("deviceId")&&(obj.deviceId=ApiClient.convertToType(data.deviceId,"String")),data.hasOwnProperty("topic")&&(obj.topic=ApiClient.convertToType(data.topic,"String")),data.hasOwnProperty("range")&&(obj.range=ApiClient.convertToType(data.range,"Number")),data.hasOwnProperty("duration")&&(obj.duration=ApiClient.convertToType(data.duration,"Number")),data.hasOwnProperty("properties")&&(obj.properties=ApiClient.convertToType(data.properties,Object))),obj},exports.prototype.id=void 0,exports.prototype.createdAt=void 0,exports.prototype.worldId=void 0,exports.prototype.deviceId=void 0,exports.prototype.topic=void 0,exports.prototype.range=void 0,exports.prototype.duration=void 0,exports.prototype.properties=void 0,exports},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.Publication=factory(root.MatchmoreAlpsCoreRestApi.ApiClient))},{"../ApiClient":1}],23:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient,Publication){"use strict";var exports=function(){var _this;return _this=new Array,Object.setPrototypeOf(_this,exports),_this};return exports.constructFromObject=function(data,obj){return data&&(obj=obj||new exports,ApiClient.constructFromObject(data,obj,"Publication")),obj},exports},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient"),require("./Publication")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.Publications=factory(root.MatchmoreAlpsCoreRestApi.ApiClient,root.MatchmoreAlpsCoreRestApi.Publication))},{"../ApiClient":1,"./Publication":22}],24:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient){"use strict";var exports=function(worldId,deviceId,topic,selector,range,duration){this.worldId=worldId,this.deviceId=deviceId,this.topic=topic,this.selector=selector,this.range=range,this.duration=duration};return exports.constructFromObject=function(data,obj){return data&&(obj=obj||new exports,data.hasOwnProperty("id")&&(obj.id=ApiClient.convertToType(data.id,"String")),data.hasOwnProperty("createdAt")&&(obj.createdAt=ApiClient.convertToType(data.createdAt,"Number")),data.hasOwnProperty("worldId")&&(obj.worldId=ApiClient.convertToType(data.worldId,"String")),data.hasOwnProperty("deviceId")&&(obj.deviceId=ApiClient.convertToType(data.deviceId,"String")),data.hasOwnProperty("topic")&&(obj.topic=ApiClient.convertToType(data.topic,"String")),data.hasOwnProperty("selector")&&(obj.selector=ApiClient.convertToType(data.selector,"String")),data.hasOwnProperty("range")&&(obj.range=ApiClient.convertToType(data.range,"Number")),data.hasOwnProperty("duration")&&(obj.duration=ApiClient.convertToType(data.duration,"Number")),data.hasOwnProperty("matchTTL")&&(obj.matchTTL=ApiClient.convertToType(data.matchTTL,"Number")),data.hasOwnProperty("pushers")&&(obj.pushers=ApiClient.convertToType(data.pushers,["String"]))),obj},exports.prototype.id=void 0,exports.prototype.createdAt=void 0,exports.prototype.worldId=void 0,exports.prototype.deviceId=void 0,exports.prototype.topic=void 0,exports.prototype.selector=void 0,exports.prototype.range=void 0,exports.prototype.duration=void 0,exports.prototype.matchTTL=void 0,exports.prototype.pushers=void 0,exports},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.Subscription=factory(root.MatchmoreAlpsCoreRestApi.ApiClient))},{"../ApiClient":1}],25:[function(require,module,exports){var root,factory;root=this,factory=function(ApiClient,Subscription){"use strict";var exports=function(){var _this;return _this=new Array,Object.setPrototypeOf(_this,exports),_this};return exports.constructFromObject=function(data,obj){return data&&(obj=obj||new exports,ApiClient.constructFromObject(data,obj,"Subscription")),obj},exports},"object"==typeof module&&module.exports?module.exports=factory(require("../ApiClient"),require("./Subscription")):(root.MatchmoreAlpsCoreRestApi||(root.MatchmoreAlpsCoreRestApi={}),root.MatchmoreAlpsCoreRestApi.Subscriptions=factory(root.MatchmoreAlpsCoreRestApi.ApiClient,root.MatchmoreAlpsCoreRestApi.Subscription))},{"../ApiClient":1,"./Subscription":24}],26:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const manager_1=require("./manager");exports.Manager=manager_1.Manager;const InMemoryPersistenceManager_1=require("./persistences/InMemoryPersistenceManager");exports.InMemoryPersistenceManager=InMemoryPersistenceManager_1.default;const LocalStoragePersistenceManager_1=require("./persistences/LocalStoragePersistenceManager");exports.LocalStoragePersistenceManager=LocalStoragePersistenceManager_1.default;const platform_1=require("./platform");exports.PlatformConfig=platform_1.default},{"./manager":28,"./persistences/InMemoryPersistenceManager":33,"./persistences/LocalStoragePersistenceManager":34,"./platform":35}],27:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.LocationManager=class{constructor(manager,config){this.manager=manager,this.onLocationReceived=(loc=>{loc.coords.horizontalAccuracy=1,loc.coords.verticalAccuracy=1,this._onLocationUpdate&&this._onLocationUpdate(loc);const{latitude:latitude,longitude:longitude,altitude:altitude}=loc.coords,coords={latitude:latitude,longitude:longitude,altitude:altitude||0};this.manager.updateLocation(coords)}),this._gpsConfig=config||{enableHighAccuracy:!1,timeout:6e4,maximumAge:6e4},this._onLocationUpdate=(loc=>{})}startUpdatingLocation(){if(!navigator.geolocation)throw new Error("Geolocation is not supported in this browser/app");navigator.geolocation.getCurrentPosition(this.onLocationReceived,this.onError,this._gpsConfig),this._geoId=navigator.geolocation.watchPosition(this.onLocationReceived,this.onError,this._gpsConfig)}stopUpdatingLocation(){if(!navigator.geolocation)throw new Error("Geolocation is not supported in this browser/app");navigator.geolocation.clearWatch(this._geoId)}set onLocationUpdate(onLocationUpdate){this._onLocationUpdate=onLocationUpdate}onError(error){throw new Error(error.message)}}},{}],28:[function(require,module,exports){"use strict";var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator.throw(value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):new P(function(resolve){resolve(result.value)}).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0});const ScalpsCoreRestApi=require("./api"),Base64=require("Base64"),matchmonitor_1=require("./matchmonitor"),locationmanager_1=require("./locationmanager"),models=require("./model/models"),index_1=require("./index");exports.Manager=class{constructor(apiKey,apiUrlOverride,persistenceManager,gpsConfig){if(this.apiKey=apiKey,this.apiUrlOverride=apiUrlOverride,!apiKey)throw new Error("Api key required");this._persistenceManager=persistenceManager||new index_1.InMemoryPersistenceManager,this.defaultClient=ScalpsCoreRestApi.ApiClient.instance,this.token=JSON.parse(Base64.atob(this.apiKey.split(".")[1])),this.defaultClient.authentications["api-key"].apiKey=this.apiKey,this.apiUrlOverride?this.defaultClient.basePath=this.apiUrlOverride:this.apiUrlOverride=this.defaultClient.basePath,this._matchMonitor=new matchmonitor_1.MatchMonitor(this),this._locationManager=new locationmanager_1.LocationManager(this,gpsConfig)}load(){return __awaiter(this,void 0,void 0,function*(){return yield this._persistenceManager.load()})}get apiUrl(){return this.defaultClient.basePath}get defaultDevice(){return this._persistenceManager.defaultDevice()}get devices(){return this._persistenceManager.devices()}get publications(){return this._persistenceManager.publications()}get subscriptions(){return this._persistenceManager.subscriptions()}createMobileDevice(name,platform,deviceToken,completion){return this.createAnyDevice({deviceType:models.DeviceType.MobileDevice,name:name,platform:platform,deviceToken:deviceToken},completion)}createPinDevice(name,location,completion){return this.createAnyDevice({deviceType:models.DeviceType.PinDevice,name:name,location:location},completion)}createIBeaconDevice(name,proximityUUID,major,minor,location,completion){return this.createAnyDevice({deviceType:models.DeviceType.IBeaconDevice,name:name,proximityUUID:proximityUUID,major:major,minor:minor,location:location},completion)}createAnyDevice(device,completion){return device=this.setDeviceType(device),new Promise((resolve,reject)=>{(new ScalpsCoreRestApi.DeviceApi).createDevice(device,function(error,data,response){error?reject("An error has occured while creating device '"+device.name+"' :"+error):resolve(JSON.parse(response.text))})}).then(device=>{let isDefault=!this._persistenceManager.defaultDevice();return this._persistenceManager.addDevice(device,isDefault),completion&&completion(device),device})}deleteDevice(deviceId,completion){return new Promise((resolve,reject)=>{(new ScalpsCoreRestApi.DeviceApi).deleteDevice(deviceId,function(error,data,response){error?reject("An error has occured while deleting device '"+deviceId+"' :"+error):resolve()})}).then(()=>{let d=this._persistenceManager.devices().find(d=>d.id==deviceId);d&&this._persistenceManager.remove(d),completion&&completion()})}setDeviceType(device){if(this.isMobileDevice(device))return device.deviceType=models.DeviceType.MobileDevice,device;if(this.isBeaconDevice(device))return device.deviceType=models.DeviceType.IBeaconDevice,device;if(this.isPinDevice(device))return device.deviceType=models.DeviceType.PinDevice,device;throw new Error("Cannot determine device type")}isMobileDevice(device){return void 0!==device.platform}isPinDevice(device){return void 0!==device.location}isBeaconDevice(device){return void 0!==device.major}createPublication(topic,range,duration,properties,deviceId,completion){return this.withDevice(deviceId)(deviceId=>new Promise((resolve,reject)=>{let api=new ScalpsCoreRestApi.PublicationApi,publication={worldId:this.token.sub,topic:topic,deviceId:deviceId,range:range,duration:duration,properties:properties};api.createPublication(deviceId,publication,function(error,data,response){error?reject("An error has occured while creating publication '"+topic+"' :"+error):resolve(JSON.parse(response.text))})}).then(publication=>(this._persistenceManager.add(publication),completion&&completion(publication),publication)))}deletePublication(deviceId,pubId,completion){return new Promise((resolve,reject)=>{(new ScalpsCoreRestApi.DeviceApi).deletePublication(deviceId,pubId,function(error,data,response){error?reject("An error has occured while deleting publication '"+pubId+"' :"+error):resolve()})}).then(()=>{let d=this._persistenceManager.publications().find(d=>d.id==pubId);d&&this._persistenceManager.remove(d),completion&&completion()})}createSubscription(topic,range,duration,selector,deviceId,completion){return this.withDevice(deviceId)(deviceId=>new Promise((resolve,reject)=>{let api=new ScalpsCoreRestApi.SubscriptionApi,subscription={worldId:this.token.sub,topic:topic,deviceId:deviceId,range:range,duration:duration,selector:selector||""};api.createSubscription(deviceId,subscription,function(error,data,response){error?reject("An error has occured while creating subscription '"+topic+"' :"+error):resolve(JSON.parse(response.text))})}).then(subscription=>(this._persistenceManager.add(subscription),completion&&completion(subscription),subscription)))}deleteSubscription(deviceId,subId,completion){return new Promise((resolve,reject)=>{(new ScalpsCoreRestApi.DeviceApi).deleteSubscription(deviceId,subId,function(error,data,response){error?reject("An error has occured while deleting Ssbscription '"+subId+"' :"+error):resolve()})}).then(()=>{let d=this._persistenceManager.publications().find(d=>d.id==subId);d&&this._persistenceManager.remove(d),completion&&completion()})}updateLocation(location,deviceId){return this.withDevice(deviceId)(deviceId=>new Promise((resolve,reject)=>{(new ScalpsCoreRestApi.LocationApi).createLocation(deviceId,location,function(error,data,response){error?reject("An error has occured while creating location ['"+location.latitude+"','"+location.longitude+"']  :"+error):resolve()})}).then(_=>{}))}getAllMatches(deviceId,completion){return this.withDevice(deviceId)(deviceId=>new Promise((resolve,reject)=>{(new ScalpsCoreRestApi.DeviceApi).getMatches(deviceId,function(error,data,response){error?reject("An error has occured while fetching matches: "+error):resolve(JSON.parse(response.text))})}).then(matches=>(completion&&completion(matches),matches)))}getMatch(matchId,string,deviceId,completion){return this.withDevice(deviceId)(deviceId=>new Promise((resolve,reject)=>{(new ScalpsCoreRestApi.DeviceApi).getMatch(deviceId,matchId,function(error,data,response){error?reject("An error has occured while fetching matches: "+error):resolve(JSON.parse(response.text))})}).then(matches=>(completion&&completion(matches),matches)))}getAllPublications(deviceId,completion){return this.withDevice(deviceId)(deviceId=>new Promise((resolve,reject)=>{(new ScalpsCoreRestApi.DeviceApi).getPublications(deviceId,function(error,data,response){error?reject("An error has occured while fetching publications: "+error):resolve(JSON.parse(response.text))})}))}withDevice(deviceId){if(deviceId)return p=>p(deviceId);if(this.defaultDevice&&this.defaultDevice.id)return p=>p(this.defaultDevice.id);throw new Error("There is no default device available and no other device id was supplied,  please call createDevice before thi call or provide a device id")}getAllSubscriptions(deviceId,completion){return this.withDevice(deviceId)(deviceId=>new Promise((resolve,reject)=>{(new ScalpsCoreRestApi.DeviceApi).getSubscriptions(deviceId,function(error,data,response){error?reject("An error has occured while fetching subscriptions: "+error):resolve(JSON.parse(response.text))})}))}set onMatch(completion){this._matchMonitor.onMatch=completion}set onLocationUpdate(completion){this._locationManager.onLocationUpdate=completion}startMonitoringMatches(mode){this._matchMonitor.startMonitoringMatches(mode)}stopMonitoringMatches(){this._matchMonitor.stopMonitoringMatches()}startUpdatingLocation(){this._locationManager.startUpdatingLocation()}stopUpdatingLocation(){this._locationManager.stopUpdatingLocation()}}},{"./api":7,"./index":26,"./locationmanager":27,"./matchmonitor":29,"./model/models":31,Base64:36}],29:[function(require,module,exports){"use strict";var MatchMonitorMode;Object.defineProperty(exports,"__esModule",{value:!0}),function(MatchMonitorMode){MatchMonitorMode[MatchMonitorMode.polling=0]="polling",MatchMonitorMode[MatchMonitorMode.websocket=1]="websocket"}(MatchMonitorMode=exports.MatchMonitorMode||(exports.MatchMonitorMode={}));exports.MatchMonitor=class{constructor(manager){this.manager=manager,this._deliveredMatches=[],this._onMatch=(match=>{})}set onMatch(onMatch){this._onMatch=onMatch}get deliveredMatches(){return this._deliveredMatches}startMonitoringMatches(mode){if(!this.manager.defaultDevice)throw new Error("Default device not yet set!");if(void 0!==mode&&mode!=+MatchMonitorMode.polling){if(mode==MatchMonitorMode.websocket){let socketUrl=this.manager.apiUrl.replace("https://","wss://").replace("http://","ws://").replace("v5","")+"pusher/v5/ws/"+this.manager.defaultDevice.id,ws=new WebSocket(socketUrl,["api-key",this.manager.token.sub]);ws.onopen=(msg=>console.log("opened")),ws.onerror=(msg=>console.log(msg)),ws.onmessage=(msg=>this.checkMatch(msg.data))}}else this.stopMonitoringMatches(),setInterval(()=>{this.checkMatches()},1e3)}stopMonitoringMatches(){this._timerId&&clearInterval(this._timerId)}checkMatch(matchId){this.manager.defaultDevice&&this.hasNotBeenDelivered({id:matchId})&&this.manager.getMatch(matchId,this.manager.defaultDevice.id).then(match=>{this._deliveredMatches.push(match),this._onMatch(match)})}checkMatches(){this.manager.getAllMatches().then(matches=>{for(let idx in matches){let match=matches[idx];this.hasNotBeenDelivered(match)&&(this._deliveredMatches.push(match),this._onMatch(match))}})}hasNotBeenDelivered(match){for(let idx in this._deliveredMatches)if(this._deliveredMatches[idx].id==match.id)return!1;return!0}}},{}],30:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),function(DeviceType){DeviceType[DeviceType.MobileDevice="MobileDevice"]="MobileDevice",DeviceType[DeviceType.PinDevice="PinDevice"]="PinDevice",DeviceType[DeviceType.IBeaconDevice="IBeaconDevice"]="IBeaconDevice"}(exports.DeviceType||(exports.DeviceType={}))},{}],31:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),function(m){for(var p in m)exports.hasOwnProperty(p)||(exports[p]=m[p])}(require("./DeviceType"))},{"./DeviceType":30}],32:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.MatchmoreEntityDiscriminator=class{static isDevice(x){return void 0!==x.deviceToken||void 0!==x.location||void 0!==x.proximityUUID}static isSubscription(x){return void 0!==x.selector}static isPublication(x){return void 0!==x.properties}}},{}],33:[function(require,module,exports){"use strict";var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator.throw(value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):new P(function(resolve){resolve(result.value)}).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0});const persistence_1=require("../persistence");exports.default=class{constructor(){this._devices=[],this._publications=[],this._subscriptions=[]}devices(){return this._devices}publications(){return this._publications}onLoad(onLoad){this._onLoad=onLoad}subscriptions(){return this._subscriptions}add(entity){if(persistence_1.MatchmoreEntityDiscriminator.isDevice(entity)){let device=entity;this._devices.push(device)}else if(persistence_1.MatchmoreEntityDiscriminator.isPublication(entity)){let pub=entity;this._publications.push(pub)}else if(persistence_1.MatchmoreEntityDiscriminator.isSubscription(entity)){let sub=entity;this._subscriptions.push(sub)}}remove(entity){if(persistence_1.MatchmoreEntityDiscriminator.isDevice(entity)){let device=entity;if(device.id==this._defaultDevice.id)throw new Error("Cannot delete default device");this._devices=this._devices.filter(d=>device.id!=d.id)}else if(persistence_1.MatchmoreEntityDiscriminator.isPublication(entity)){let pub=entity;this._publications=this._publications.filter(d=>pub.id!=d.id)}else if(persistence_1.MatchmoreEntityDiscriminator.isSubscription(entity)){let sub=entity;this._subscriptions=this._subscriptions.filter(d=>sub.id!=d.id)}}defaultDevice(){return this._defaultDevice}addDevice(device,isDefault){this.add(device),isDefault&&(this._defaultDevice=device)}load(){return __awaiter(this,void 0,void 0,function*(){return!0})}save(){return __awaiter(this,void 0,void 0,function*(){return!0})}}},{"../persistence":32}],34:[function(require,module,exports){"use strict";var __awaiter=this&&this.__awaiter||function(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator.throw(value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):new P(function(resolve){resolve(result.value)}).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0});const persistence_1=require("../persistence"),platform_1=require("../platform"),storageKey="@matchmoreSdk:data";exports.default=class{constructor(){this._devices=[],this._publications=[],this._subscriptions=[]}devices(){return this._devices}publications(){return this._publications}subscriptions(){return this._subscriptions}add(entity){if(persistence_1.MatchmoreEntityDiscriminator.isDevice(entity)){let device=entity;return this._devices.push(device),void this.save()}if(persistence_1.MatchmoreEntityDiscriminator.isPublication(entity)){let pub=entity;return this._publications.push(pub),void this.save()}if(persistence_1.MatchmoreEntityDiscriminator.isSubscription(entity)){let sub=entity;return this._subscriptions.push(sub),void this.save()}}remove(entity){if(persistence_1.MatchmoreEntityDiscriminator.isDevice(entity)){let device=entity;if(device.id==this._defaultDevice.id)throw new Error("Cannot delete default device");return this._devices=this._devices.filter(d=>device.id!=d.id),void this.save()}if(persistence_1.MatchmoreEntityDiscriminator.isPublication(entity)){let pub=entity;return this._publications=this._publications.filter(d=>pub.id!=d.id),void this.save()}if(persistence_1.MatchmoreEntityDiscriminator.isSubscription(entity)){let sub=entity;return this._subscriptions=this._subscriptions.filter(d=>sub.id!=d.id),void this.save()}}defaultDevice(){return this._defaultDevice}addDevice(device,isDefault){this.add(device),isDefault&&(this._defaultDevice=device),this.save()}onLoad(onLoad){this._onLoad=onLoad}load(){return __awaiter(this,void 0,void 0,function*(){const dataString=yield platform_1.default.storage.load(storageKey),data=JSON.parse(dataString);return data&&(this._devices=data.devices.map(deviceObject=>deviceObject),this._subscriptions=data.subscriptions.map(subscriptionObject=>subscriptionObject),this._publications=data.publications.map(publicationObject=>publicationObject),this._defaultDevice=data.defaultDevice),!0})}save(){return __awaiter(this,void 0,void 0,function*(){const saveData={devices:this._devices,subscriptions:this._subscriptions,publications:this._publications,defaultDevice:this._defaultDevice};return yield platform_1.default.storage.save(storageKey,JSON.stringify(saveData))})}}},{"../persistence":32,"../platform":35}],35:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class PlatformConfig{constructor(){this.storage=null,this.webSocket=null}static getInstance(){return PlatformConfig.instance||(PlatformConfig.instance=new PlatformConfig),PlatformConfig.instance}}exports.PlatformConfig=PlatformConfig;const instance=PlatformConfig.getInstance();exports.default=instance},{}],36:[function(require,module,exports){!function(){var object=void 0!==exports?exports:"undefined"!=typeof self?self:$.global,chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function InvalidCharacterError(message){this.message=message}InvalidCharacterError.prototype=new Error,InvalidCharacterError.prototype.name="InvalidCharacterError",object.btoa||(object.btoa=function(input){for(var block,charCode,str=String(input),idx=0,map=chars,output="";str.charAt(0|idx)||(map="=",idx%1);output+=map.charAt(63&block>>8-idx%1*8)){if((charCode=str.charCodeAt(idx+=.75))>255)throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");block=block<<8|charCode}return output}),object.atob||(object.atob=function(input){var str=String(input).replace(/[=]+$/,"");if(str.length%4==1)throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");for(var bs,buffer,bc=0,idx=0,output="";buffer=str.charAt(idx++);~buffer&&(bs=bc%4?64*bs+buffer:buffer,bc++%4)?output+=String.fromCharCode(255&bs>>(-2*bc&6)):0)buffer=chars.indexOf(buffer);return output})}()},{}],37:[function(require,module,exports){"use strict";exports.byteLength=function(b64){return 3*b64.length/4-placeHoldersCount(b64)},exports.toByteArray=function(b64){var i,l,tmp,placeHolders,arr,len=b64.length;placeHolders=placeHoldersCount(b64),arr=new Arr(3*len/4-placeHolders),l=placeHolders>0?len-4:len;var L=0;for(i=0;i<l;i+=4)tmp=revLookup[b64.charCodeAt(i)]<<18|revLookup[b64.charCodeAt(i+1)]<<12|revLookup[b64.charCodeAt(i+2)]<<6|revLookup[b64.charCodeAt(i+3)],arr[L++]=tmp>>16&255,arr[L++]=tmp>>8&255,arr[L++]=255&tmp;2===placeHolders?(tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4,arr[L++]=255&tmp):1===placeHolders&&(tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2,arr[L++]=tmp>>8&255,arr[L++]=255&tmp);return arr},exports.fromByteArray=function(uint8){for(var tmp,len=uint8.length,extraBytes=len%3,output="",parts=[],i=0,len2=len-extraBytes;i<len2;i+=16383)parts.push(encodeChunk(uint8,i,i+16383>len2?len2:i+16383));1===extraBytes?(tmp=uint8[len-1],output+=lookup[tmp>>2],output+=lookup[tmp<<4&63],output+="=="):2===extraBytes&&(tmp=(uint8[len-2]<<8)+uint8[len-1],output+=lookup[tmp>>10],output+=lookup[tmp>>4&63],output+=lookup[tmp<<2&63],output+="=");return parts.push(output),parts.join("")};for(var lookup=[],revLookup=[],Arr="undefined"!=typeof Uint8Array?Uint8Array:Array,code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,len=code.length;i<len;++i)lookup[i]=code[i],revLookup[code.charCodeAt(i)]=i;function placeHoldersCount(b64){var len=b64.length;if(len%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===b64[len-2]?2:"="===b64[len-1]?1:0}function encodeChunk(uint8,start,end){for(var tmp,num,output=[],i=start;i<end;i+=3)tmp=(uint8[i]<<16&16711680)+(uint8[i+1]<<8&65280)+(255&uint8[i+2]),output.push(lookup[(num=tmp)>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[63&num]);return output.join("")}revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63},{}],38:[function(require,module,exports){"use strict";var base64=require("base64-js"),ieee754=require("ieee754");exports.Buffer=Buffer,exports.SlowBuffer=function(length){+length!=length&&(length=0);return Buffer.alloc(+length)},exports.INSPECT_MAX_BYTES=50;var K_MAX_LENGTH=2147483647;function createBuffer(length){if(length>K_MAX_LENGTH)throw new RangeError("Invalid typed array length");var buf=new Uint8Array(length);return buf.__proto__=Buffer.prototype,buf}function Buffer(arg,encodingOrOffset,length){if("number"==typeof arg){if("string"==typeof encodingOrOffset)throw new Error("If encoding is specified then the first argument must be a string");return allocUnsafe(arg)}return from(arg,encodingOrOffset,length)}function from(value,encodingOrOffset,length){if("number"==typeof value)throw new TypeError('"value" argument must not be a number');return isArrayBuffer(value)||value&&isArrayBuffer(value.buffer)?function(array,byteOffset,length){if(byteOffset<0||array.byteLength<byteOffset)throw new RangeError('"offset" is outside of buffer bounds');if(array.byteLength<byteOffset+(length||0))throw new RangeError('"length" is outside of buffer bounds');var buf;buf=void 0===byteOffset&&void 0===length?new Uint8Array(array):void 0===length?new Uint8Array(array,byteOffset):new Uint8Array(array,byteOffset,length);return buf.__proto__=Buffer.prototype,buf}(value,encodingOrOffset,length):"string"==typeof value?function(string,encoding){"string"==typeof encoding&&""!==encoding||(encoding="utf8");if(!Buffer.isEncoding(encoding))throw new TypeError("Unknown encoding: "+encoding);var length=0|byteLength(string,encoding),buf=createBuffer(length),actual=buf.write(string,encoding);actual!==length&&(buf=buf.slice(0,actual));return buf}(value,encodingOrOffset):function(obj){if(Buffer.isBuffer(obj)){var len=0|checked(obj.length),buf=createBuffer(len);return 0===buf.length?buf:(obj.copy(buf,0,0,len),buf)}if(obj){if(ArrayBuffer.isView(obj)||"length"in obj)return"number"!=typeof obj.length||numberIsNaN(obj.length)?createBuffer(0):fromArrayLike(obj);if("Buffer"===obj.type&&Array.isArray(obj.data))return fromArrayLike(obj.data)}throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.")}(value)}function assertSize(size){if("number"!=typeof size)throw new TypeError('"size" argument must be of type number');if(size<0)throw new RangeError('"size" argument must not be negative')}function allocUnsafe(size){return assertSize(size),createBuffer(size<0?0:0|checked(size))}function fromArrayLike(array){for(var length=array.length<0?0:0|checked(array.length),buf=createBuffer(length),i=0;i<length;i+=1)buf[i]=255&array[i];return buf}function checked(length){if(length>=K_MAX_LENGTH)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+K_MAX_LENGTH.toString(16)+" bytes");return 0|length}function byteLength(string,encoding){if(Buffer.isBuffer(string))return string.length;if(ArrayBuffer.isView(string)||isArrayBuffer(string))return string.byteLength;"string"!=typeof string&&(string=""+string);var len=string.length;if(0===len)return 0;for(var loweredCase=!1;;)switch(encoding){case"ascii":case"latin1":case"binary":return len;case"utf8":case"utf-8":case void 0:return utf8ToBytes(string).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*len;case"hex":return len>>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase)return utf8ToBytes(string).length;encoding=(""+encoding).toLowerCase(),loweredCase=!0}}function swap(b,n,m){var i=b[n];b[n]=b[m],b[m]=i}function bidirectionalIndexOf(buffer,val,byteOffset,encoding,dir){if(0===buffer.length)return-1;if("string"==typeof byteOffset?(encoding=byteOffset,byteOffset=0):byteOffset>2147483647?byteOffset=2147483647:byteOffset<-2147483648&&(byteOffset=-2147483648),numberIsNaN(byteOffset=+byteOffset)&&(byteOffset=dir?0:buffer.length-1),byteOffset<0&&(byteOffset=buffer.length+byteOffset),byteOffset>=buffer.length){if(dir)return-1;byteOffset=buffer.length-1}else if(byteOffset<0){if(!dir)return-1;byteOffset=0}if("string"==typeof val&&(val=Buffer.from(val,encoding)),Buffer.isBuffer(val))return 0===val.length?-1:arrayIndexOf(buffer,val,byteOffset,encoding,dir);if("number"==typeof val)return val&=255,"function"==typeof Uint8Array.prototype.indexOf?dir?Uint8Array.prototype.indexOf.call(buffer,val,byteOffset):Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset):arrayIndexOf(buffer,[val],byteOffset,encoding,dir);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){var i,indexSize=1,arrLength=arr.length,valLength=val.length;if(void 0!==encoding&&("ucs2"===(encoding=String(encoding).toLowerCase())||"ucs-2"===encoding||"utf16le"===encoding||"utf-16le"===encoding)){if(arr.length<2||val.length<2)return-1;indexSize=2,arrLength/=2,valLength/=2,byteOffset/=2}function read(buf,i){return 1===indexSize?buf[i]:buf.readUInt16BE(i*indexSize)}if(dir){var foundIndex=-1;for(i=byteOffset;i<arrLength;i++)if(read(arr,i)===read(val,-1===foundIndex?0:i-foundIndex)){if(-1===foundIndex&&(foundIndex=i),i-foundIndex+1===valLength)return foundIndex*indexSize}else-1!==foundIndex&&(i-=i-foundIndex),foundIndex=-1}else for(byteOffset+valLength>arrLength&&(byteOffset=arrLength-valLength),i=byteOffset;i>=0;i--){for(var found=!0,j=0;j<valLength;j++)if(read(arr,i+j)!==read(val,j)){found=!1;break}if(found)return i}return-1}function hexWrite(buf,string,offset,length){offset=Number(offset)||0;var remaining=buf.length-offset;length?(length=Number(length))>remaining&&(length=remaining):length=remaining;var strLen=string.length;length>strLen/2&&(length=strLen/2);for(var i=0;i<length;++i){var parsed=parseInt(string.substr(2*i,2),16);if(numberIsNaN(parsed))return i;buf[offset+i]=parsed}return i}function utf8Write(buf,string,offset,length){return blitBuffer(utf8ToBytes(string,buf.length-offset),buf,offset,length)}function asciiWrite(buf,string,offset,length){return blitBuffer(function(str){for(var byteArray=[],i=0;i<str.length;++i)byteArray.push(255&str.charCodeAt(i));return byteArray}(string),buf,offset,length)}function latin1Write(buf,string,offset,length){return asciiWrite(buf,string,offset,length)}function base64Write(buf,string,offset,length){return blitBuffer(base64ToBytes(string),buf,offset,length)}function ucs2Write(buf,string,offset,length){return blitBuffer(function(str,units){for(var c,hi,lo,byteArray=[],i=0;i<str.length&&!((units-=2)<0);++i)c=str.charCodeAt(i),hi=c>>8,lo=c%256,byteArray.push(lo),byteArray.push(hi);return byteArray}(string,buf.length-offset),buf,offset,length)}function base64Slice(buf,start,end){return 0===start&&end===buf.length?base64.fromByteArray(buf):base64.fromByteArray(buf.slice(start,end))}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);for(var res=[],i=start;i<end;){var secondByte,thirdByte,fourthByte,tempCodePoint,firstByte=buf[i],codePoint=null,bytesPerSequence=firstByte>239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end)switch(bytesPerSequence){case 1:firstByte<128&&(codePoint=firstByte);break;case 2:128==(192&(secondByte=buf[i+1]))&&(tempCodePoint=(31&firstByte)<<6|63&secondByte)>127&&(codePoint=tempCodePoint);break;case 3:secondByte=buf[i+1],thirdByte=buf[i+2],128==(192&secondByte)&&128==(192&thirdByte)&&(tempCodePoint=(15&firstByte)<<12|(63&secondByte)<<6|63&thirdByte)>2047&&(tempCodePoint<55296||tempCodePoint>57343)&&(codePoint=tempCodePoint);break;case 4:secondByte=buf[i+1],thirdByte=buf[i+2],fourthByte=buf[i+3],128==(192&secondByte)&&128==(192&thirdByte)&&128==(192&fourthByte)&&(tempCodePoint=(15&firstByte)<<18|(63&secondByte)<<12|(63&thirdByte)<<6|63&fourthByte)>65535&&tempCodePoint<1114112&&(codePoint=tempCodePoint)}null===codePoint?(codePoint=65533,bytesPerSequence=1):codePoint>65535&&(codePoint-=65536,res.push(codePoint>>>10&1023|55296),codePoint=56320|1023&codePoint),res.push(codePoint),i+=bytesPerSequence}return function(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,codePoints);var res="",i=0;for(;i<len;)res+=String.fromCharCode.apply(String,codePoints.slice(i,i+=MAX_ARGUMENTS_LENGTH));return res}(res)}exports.kMaxLength=K_MAX_LENGTH,Buffer.TYPED_ARRAY_SUPPORT=function(){try{var arr=new Uint8Array(1);return arr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===arr.foo()}catch(e){return!1}}(),Buffer.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(Buffer.prototype,"parent",{get:function(){if(this instanceof Buffer)return this.buffer}}),Object.defineProperty(Buffer.prototype,"offset",{get:function(){if(this instanceof Buffer)return this.byteOffset}}),"undefined"!=typeof Symbol&&Symbol.species&&Buffer[Symbol.species]===Buffer&&Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),Buffer.poolSize=8192,Buffer.from=function(value,encodingOrOffset,length){return from(value,encodingOrOffset,length)},Buffer.prototype.__proto__=Uint8Array.prototype,Buffer.__proto__=Uint8Array,Buffer.alloc=function(size,fill,encoding){return function(size,fill,encoding){return assertSize(size),size<=0?createBuffer(size):void 0!==fill?"string"==typeof encoding?createBuffer(size).fill(fill,encoding):createBuffer(size).fill(fill):createBuffer(size)}(size,fill,encoding)},Buffer.allocUnsafe=function(size){return allocUnsafe(size)},Buffer.allocUnsafeSlow=function(size){return allocUnsafe(size)},Buffer.isBuffer=function(b){return null!=b&&!0===b._isBuffer},Buffer.compare=function(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b))throw new TypeError("Arguments must be Buffers");if(a===b)return 0;for(var x=a.length,y=b.length,i=0,len=Math.min(x,y);i<len;++i)if(a[i]!==b[i]){x=a[i],y=b[i];break}return x<y?-1:y<x?1:0},Buffer.isEncoding=function(encoding){switch(String(encoding).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Buffer.concat=function(list,length){if(!Array.isArray(list))throw new TypeError('"list" argument must be an Array of Buffers');if(0===list.length)return Buffer.alloc(0);var i;if(void 0===length)for(length=0,i=0;i<list.length;++i)length+=list[i].length;var buffer=Buffer.allocUnsafe(length),pos=0;for(i=0;i<list.length;++i){var buf=list[i];if(ArrayBuffer.isView(buf)&&(buf=Buffer.from(buf)),!Buffer.isBuffer(buf))throw new TypeError('"list" argument must be an Array of Buffers');buf.copy(buffer,pos),pos+=buf.length}return buffer},Buffer.byteLength=byteLength,Buffer.prototype._isBuffer=!0,Buffer.prototype.swap16=function(){var len=this.length;if(len%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var i=0;i<len;i+=2)swap(this,i,i+1);return this},Buffer.prototype.swap32=function(){var len=this.length;if(len%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var i=0;i<len;i+=4)swap(this,i,i+3),swap(this,i+1,i+2);return this},Buffer.prototype.swap64=function(){var len=this.length;if(len%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var i=0;i<len;i+=8)swap(this,i,i+7),swap(this,i+1,i+6),swap(this,i+2,i+5),swap(this,i+3,i+4);return this},Buffer.prototype.toString=function(){var length=this.length;return 0===length?"":0===arguments.length?utf8Slice(this,0,length):function(encoding,start,end){var loweredCase=!1;if((void 0===start||start<0)&&(start=0),start>this.length)return"";if((void 0===end||end>this.length)&&(end=this.length),end<=0)return"";if((end>>>=0)<=(start>>>=0))return"";for(encoding||(encoding="utf8");;)switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"latin1":case"binary":return latin1Slice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase(),loweredCase=!0}}.apply(this,arguments)},Buffer.prototype.toLocaleString=Buffer.prototype.toString,Buffer.prototype.equals=function(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");return this===b||0===Buffer.compare(this,b)},Buffer.prototype.inspect=function(){var str="",max=exports.INSPECT_MAX_BYTES;return this.length>0&&(str=this.toString("hex",0,max).match(/.{2}/g).join(" "),this.length>max&&(str+=" ... ")),"<Buffer "+str+">"},Buffer.prototype.compare=function(target,start,end,thisStart,thisEnd){if(!Buffer.isBuffer(target))throw new TypeError("Argument must be a Buffer");if(void 0===start&&(start=0),void 0===end&&(end=target?target.length:0),void 0===thisStart&&(thisStart=0),void 0===thisEnd&&(thisEnd=this.length),start<0||end>target.length||thisStart<0||thisEnd>this.length)throw new RangeError("out of range index");if(thisStart>=thisEnd&&start>=end)return 0;if(thisStart>=thisEnd)return-1;if(start>=end)return 1;if(start>>>=0,end>>>=0,thisStart>>>=0,thisEnd>>>=0,this===target)return 0;for(var x=thisEnd-thisStart,y=end-start,len=Math.min(x,y),thisCopy=this.slice(thisStart,thisEnd),targetCopy=target.slice(start,end),i=0;i<len;++i)if(thisCopy[i]!==targetCopy[i]){x=thisCopy[i],y=targetCopy[i];break}return x<y?-1:y<x?1:0},Buffer.prototype.includes=function(val,byteOffset,encoding){return-1!==this.indexOf(val,byteOffset,encoding)},Buffer.prototype.indexOf=function(val,byteOffset,encoding){return bidirectionalIndexOf(this,val,byteOffset,encoding,!0)},Buffer.prototype.lastIndexOf=function(val,byteOffset,encoding){return bidirectionalIndexOf(this,val,byteOffset,encoding,!1)},Buffer.prototype.write=function(string,offset,length,encoding){if(void 0===offset)encoding="utf8",length=this.length,offset=0;else if(void 0===length&&"string"==typeof offset)encoding=offset,length=this.length,offset=0;else{if(!isFinite(offset))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");offset>>>=0,isFinite(length)?(length>>>=0,void 0===encoding&&(encoding="utf8")):(encoding=length,length=void 0)}var remaining=this.length-offset;if((void 0===length||length>remaining)&&(length=remaining),string.length>0&&(length<0||offset<0)||offset>this.length)throw new RangeError("Attempt to write outside buffer bounds");encoding||(encoding="utf8");for(var loweredCase=!1;;)switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return latin1Write(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase(),loweredCase=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var MAX_ARGUMENTS_LENGTH=4096;function asciiSlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;++i)ret+=String.fromCharCode(127&buf[i]);return ret}function latin1Slice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;++i)ret+=String.fromCharCode(buf[i]);return ret}function hexSlice(buf,start,end){var len=buf.length;(!start||start<0)&&(start=0),(!end||end<0||end>len)&&(end=len);for(var out="",i=start;i<end;++i)out+=toHex(buf[i]);return out}function utf16leSlice(buf,start,end){for(var bytes=buf.slice(start,end),res="",i=0;i<bytes.length;i+=2)res+=String.fromCharCode(bytes[i]+256*bytes[i+1]);return res}function checkOffset(offset,ext,length){if(offset%1!=0||offset<0)throw new RangeError("offset is not uint");if(offset+ext>length)throw new RangeError("Trying to access beyond buffer length")}function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||value<min)throw new RangeError('"value" argument is out of bounds');if(offset+ext>buf.length)throw new RangeError("Index out of range")}function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){return value=+value,offset>>>=0,noAssert||checkIEEE754(buf,0,offset,4),ieee754.write(buf,value,offset,littleEndian,23,4),offset+4}function writeDouble(buf,value,offset,littleEndian,noAssert){return value=+value,offset>>>=0,noAssert||checkIEEE754(buf,0,offset,8),ieee754.write(buf,value,offset,littleEndian,52,8),offset+8}Buffer.prototype.slice=function(start,end){var len=this.length;start=~~start,end=void 0===end?len:~~end,start<0?(start+=len)<0&&(start=0):start>len&&(start=len),end<0?(end+=len)<0&&(end=0):end>len&&(end=len),end<start&&(end=start);var newBuf=this.subarray(start,end);return newBuf.__proto__=Buffer.prototype,newBuf},Buffer.prototype.readUIntLE=function(offset,byteLength,noAssert){offset>>>=0,byteLength>>>=0,noAssert||checkOffset(offset,byteLength,this.length);for(var val=this[offset],mul=1,i=0;++i<byteLength&&(mul*=256);)val+=this[offset+i]*mul;return val},Buffer.prototype.readUIntBE=function(offset,byteLength,noAssert){offset>>>=0,byteLength>>>=0,noAssert||checkOffset(offset,byteLength,this.length);for(var val=this[offset+--byteLength],mul=1;byteLength>0&&(mul*=256);)val+=this[offset+--byteLength]*mul;return val},Buffer.prototype.readUInt8=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,1,this.length),this[offset]},Buffer.prototype.readUInt16LE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,2,this.length),this[offset]|this[offset+1]<<8},Buffer.prototype.readUInt16BE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,2,this.length),this[offset]<<8|this[offset+1]},Buffer.prototype.readUInt32LE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+16777216*this[offset+3]},Buffer.prototype.readUInt32BE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),16777216*this[offset]+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])},Buffer.prototype.readIntLE=function(offset,byteLength,noAssert){offset>>>=0,byteLength>>>=0,noAssert||checkOffset(offset,byteLength,this.length);for(var val=this[offset],mul=1,i=0;++i<byteLength&&(mul*=256);)val+=this[offset+i]*mul;return val>=(mul*=128)&&(val-=Math.pow(2,8*byteLength)),val},Buffer.prototype.readIntBE=function(offset,byteLength,noAssert){offset>>>=0,byteLength>>>=0,noAssert||checkOffset(offset,byteLength,this.length);for(var i=byteLength,mul=1,val=this[offset+--i];i>0&&(mul*=256);)val+=this[offset+--i]*mul;return val>=(mul*=128)&&(val-=Math.pow(2,8*byteLength)),val},Buffer.prototype.readInt8=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,1,this.length),128&this[offset]?-1*(255-this[offset]+1):this[offset]},Buffer.prototype.readInt16LE=function(offset,noAssert){offset>>>=0,noAssert||checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return 32768&val?4294901760|val:val},Buffer.prototype.readInt16BE=function(offset,noAssert){offset>>>=0,noAssert||checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return 32768&val?4294901760|val:val},Buffer.prototype.readInt32LE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24},Buffer.prototype.readInt32BE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]},Buffer.prototype.readFloatLE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),ieee754.read(this,offset,!0,23,4)},Buffer.prototype.readFloatBE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,4,this.length),ieee754.read(this,offset,!1,23,4)},Buffer.prototype.readDoubleLE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,8,this.length),ieee754.read(this,offset,!0,52,8)},Buffer.prototype.readDoubleBE=function(offset,noAssert){return offset>>>=0,noAssert||checkOffset(offset,8,this.length),ieee754.read(this,offset,!1,52,8)},Buffer.prototype.writeUIntLE=function(value,offset,byteLength,noAssert){(value=+value,offset>>>=0,byteLength>>>=0,noAssert)||checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength)-1,0);var mul=1,i=0;for(this[offset]=255&value;++i<byteLength&&(mul*=256);)this[offset+i]=value/mul&255;return offset+byteLength},Buffer.prototype.writeUIntBE=function(value,offset,byteLength,noAssert){(value=+value,offset>>>=0,byteLength>>>=0,noAssert)||checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength)-1,0);var i=byteLength-1,mul=1;for(this[offset+i]=255&value;--i>=0&&(mul*=256);)this[offset+i]=value/mul&255;return offset+byteLength},Buffer.prototype.writeUInt8=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,1,255,0),this[offset]=255&value,offset+1},Buffer.prototype.writeUInt16LE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,2,65535,0),this[offset]=255&value,this[offset+1]=value>>>8,offset+2},Buffer.prototype.writeUInt16BE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,2,65535,0),this[offset]=value>>>8,this[offset+1]=255&value,offset+2},Buffer.prototype.writeUInt32LE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,4,4294967295,0),this[offset+3]=value>>>24,this[offset+2]=value>>>16,this[offset+1]=value>>>8,this[offset]=255&value,offset+4},Buffer.prototype.writeUInt32BE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,4,4294967295,0),this[offset]=value>>>24,this[offset+1]=value>>>16,this[offset+2]=value>>>8,this[offset+3]=255&value,offset+4},Buffer.prototype.writeIntLE=function(value,offset,byteLength,noAssert){if(value=+value,offset>>>=0,!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0,mul=1,sub=0;for(this[offset]=255&value;++i<byteLength&&(mul*=256);)value<0&&0===sub&&0!==this[offset+i-1]&&(sub=1),this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength},Buffer.prototype.writeIntBE=function(value,offset,byteLength,noAssert){if(value=+value,offset>>>=0,!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1,mul=1,sub=0;for(this[offset+i]=255&value;--i>=0&&(mul*=256);)value<0&&0===sub&&0!==this[offset+i+1]&&(sub=1),this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength},Buffer.prototype.writeInt8=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,1,127,-128),value<0&&(value=255+value+1),this[offset]=255&value,offset+1},Buffer.prototype.writeInt16LE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,2,32767,-32768),this[offset]=255&value,this[offset+1]=value>>>8,offset+2},Buffer.prototype.writeInt16BE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,2,32767,-32768),this[offset]=value>>>8,this[offset+1]=255&value,offset+2},Buffer.prototype.writeInt32LE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,4,2147483647,-2147483648),this[offset]=255&value,this[offset+1]=value>>>8,this[offset+2]=value>>>16,this[offset+3]=value>>>24,offset+4},Buffer.prototype.writeInt32BE=function(value,offset,noAssert){return value=+value,offset>>>=0,noAssert||checkInt(this,value,offset,4,2147483647,-2147483648),value<0&&(value=4294967295+value+1),this[offset]=value>>>24,this[offset+1]=value>>>16,this[offset+2]=value>>>8,this[offset+3]=255&value,offset+4},Buffer.prototype.writeFloatLE=function(value,offset,noAssert){return writeFloat(this,value,offset,!0,noAssert)},Buffer.prototype.writeFloatBE=function(value,offset,noAssert){return writeFloat(this,value,offset,!1,noAssert)},Buffer.prototype.writeDoubleLE=function(value,offset,noAssert){return writeDouble(this,value,offset,!0,noAssert)},Buffer.prototype.writeDoubleBE=function(value,offset,noAssert){return writeDouble(this,value,offset,!1,noAssert)},Buffer.prototype.copy=function(target,targetStart,start,end){if(!Buffer.isBuffer(target))throw new TypeError("argument should be a Buffer");if(start||(start=0),end||0===end||(end=this.length),targetStart>=target.length&&(targetStart=target.length),targetStart||(targetStart=0),end>0&&end<start&&(end=start),end===start)return 0;if(0===target.length||0===this.length)return 0;if(targetStart<0)throw new RangeError("targetStart out of bounds");if(start<0||start>=this.length)throw new RangeError("Index out of range");if(end<0)throw new RangeError("sourceEnd out of bounds");end>this.length&&(end=this.length),target.length-targetStart<end-start&&(end=target.length-targetStart+start);var len=end-start;if(this===target&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(targetStart,start,end);else if(this===target&&start<targetStart&&targetStart<end)for(var i=len-1;i>=0;--i)target[i+targetStart]=this[i+start];else Uint8Array.prototype.set.call(target,this.subarray(start,end),targetStart);return len},Buffer.prototype.fill=function(val,start,end,encoding){if("string"==typeof val){if("string"==typeof start?(encoding=start,start=0,end=this.length):"string"==typeof end&&(encoding=end,end=this.length),void 0!==encoding&&"string"!=typeof encoding)throw new TypeError("encoding must be a string");if("string"==typeof encoding&&!Buffer.isEncoding(encoding))throw new TypeError("Unknown encoding: "+encoding);if(1===val.length){var code=val.charCodeAt(0);("utf8"===encoding&&code<128||"latin1"===encoding)&&(val=code)}}else"number"==typeof val&&(val&=255);if(start<0||this.length<start||this.length<end)throw new RangeError("Out of range index");if(end<=start)return this;var i;if(start>>>=0,end=void 0===end?this.length:end>>>0,val||(val=0),"number"==typeof val)for(i=start;i<end;++i)this[i]=val;else{var bytes=Buffer.isBuffer(val)?val:new Buffer(val,encoding),len=bytes.length;if(0===len)throw new TypeError('The value "'+val+'" is invalid for argument "value"');for(i=0;i<end-start;++i)this[i+start]=bytes[i%len]}return this};var INVALID_BASE64_RE=/[^+/0-9A-Za-z-_]/g;function toHex(n){return n<16?"0"+n.toString(16):n.toString(16)}function utf8ToBytes(string,units){var codePoint;units=units||1/0;for(var length=string.length,leadSurrogate=null,bytes=[],i=0;i<length;++i){if((codePoint=string.charCodeAt(i))>55295&&codePoint<57344){if(!leadSurrogate){if(codePoint>56319){(units-=3)>-1&&bytes.push(239,191,189);continue}if(i+1===length){(units-=3)>-1&&bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(codePoint<56320){(units-=3)>-1&&bytes.push(239,191,189),leadSurrogate=codePoint;continue}codePoint=65536+(leadSurrogate-55296<<10|codePoint-56320)}else leadSurrogate&&(units-=3)>-1&&bytes.push(239,191,189);if(leadSurrogate=null,codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,63&codePoint|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,63&codePoint|128)}else{if(!(codePoint<1114112))throw new Error("Invalid code point");if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,63&codePoint|128)}}return bytes}function base64ToBytes(str){return base64.toByteArray(function(str){if((str=(str=str.split("=")[0]).trim().replace(INVALID_BASE64_RE,"")).length<2)return"";for(;str.length%4!=0;)str+="=";return str}(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i<length&&!(i+offset>=dst.length||i>=src.length);++i)dst[i+offset]=src[i];return i}function isArrayBuffer(obj){return obj instanceof ArrayBuffer||null!=obj&&null!=obj.constructor&&"ArrayBuffer"===obj.constructor.name&&"number"==typeof obj.byteLength}function numberIsNaN(obj){return obj!=obj}},{"base64-js":37,ieee754:40}],39:[function(require,module,exports){function Emitter(obj){if(obj)return function(obj){for(var key in Emitter.prototype)obj[key]=Emitter.prototype[key];return obj}(obj)}void 0!==module&&(module.exports=Emitter),Emitter.prototype.on=Emitter.prototype.addEventListener=function(event,fn){return this._callbacks=this._callbacks||{},(this._callbacks["$"+event]=this._callbacks["$"+event]||[]).push(fn),this},Emitter.prototype.once=function(event,fn){function on(){this.off(event,on),fn.apply(this,arguments)}return on.fn=fn,this.on(event,on),this},Emitter.prototype.off=Emitter.prototype.removeListener=Emitter.prototype.removeAllListeners=Emitter.prototype.removeEventListener=function(event,fn){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var cb,callbacks=this._callbacks["$"+event];if(!callbacks)return this;if(1==arguments.length)return delete this._callbacks["$"+event],this;for(var i=0;i<callbacks.length;i++)if((cb=callbacks[i])===fn||cb.fn===fn){callbacks.splice(i,1);break}return this},Emitter.prototype.emit=function(event){this._callbacks=this._callbacks||{};var args=[].slice.call(arguments,1),callbacks=this._callbacks["$"+event];if(callbacks)for(var i=0,len=(callbacks=callbacks.slice(0)).length;i<len;++i)callbacks[i].apply(this,args);return this},Emitter.prototype.listeners=function(event){return this._callbacks=this._callbacks||{},this._callbacks["$"+event]||[]},Emitter.prototype.hasListeners=function(event){return!!this.listeners(event).length}},{}],40:[function(require,module,exports){exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m,eLen=8*nBytes-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,nBits=-7,i=isLE?nBytes-1:0,d=isLE?-1:1,s=buffer[offset+i];for(i+=d,e=s&(1<<-nBits)-1,s>>=-nBits,nBits+=eLen;nBits>0;e=256*e+buffer[offset+i],i+=d,nBits-=8);for(m=e&(1<<-nBits)-1,e>>=-nBits,nBits+=mLen;nBits>0;m=256*m+buffer[offset+i],i+=d,nBits-=8);if(0===e)e=1-eBias;else{if(e===eMax)return m?NaN:1/0*(s?-1:1);m+=Math.pow(2,mLen),e-=eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)},exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c,eLen=8*nBytes-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,rt=23===mLen?Math.pow(2,-24)-Math.pow(2,-77):0,i=isLE?0:nBytes-1,d=isLE?1:-1,s=value<0||0===value&&1/value<0?1:0;for(value=Math.abs(value),isNaN(value)||value===1/0?(m=isNaN(value)?1:0,e=eMax):(e=Math.floor(Math.log(value)/Math.LN2),value*(c=Math.pow(2,-e))<1&&(e--,c*=2),(value+=e+eBias>=1?rt/c:rt*Math.pow(2,1-eBias))*c>=2&&(e++,c/=2),e+eBias>=eMax?(m=0,e=eMax):e+eBias>=1?(m=(value*c-1)*Math.pow(2,mLen),e+=eBias):(m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen),e=0));mLen>=8;buffer[offset+i]=255&m,i+=d,m/=256,mLen-=8);for(e=e<<mLen|m,eLen+=mLen;eLen>0;buffer[offset+i]=255&e,i+=d,e/=256,eLen-=8);buffer[offset+i-d]|=128*s}},{}],41:[function(require,module,exports){"use strict";function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}module.exports=function(qs,sep,eq,options){sep=sep||"&",eq=eq||"=";var obj={};if("string"!=typeof qs||0===qs.length)return obj;var regexp=/\+/g;qs=qs.split(sep);var maxKeys=1e3;options&&"number"==typeof options.maxKeys&&(maxKeys=options.maxKeys);var len=qs.length;maxKeys>0&&len>maxKeys&&(len=maxKeys);for(var i=0;i<len;++i){var kstr,vstr,k,v,x=qs[i].replace(regexp,"%20"),idx=x.indexOf(eq);idx>=0?(kstr=x.substr(0,idx),vstr=x.substr(idx+1)):(kstr=x,vstr=""),k=decodeURIComponent(kstr),v=decodeURIComponent(vstr),hasOwnProperty(obj,k)?isArray(obj[k])?obj[k].push(v):obj[k]=[obj[k],v]:obj[k]=v}return obj};var isArray=Array.isArray||function(xs){return"[object Array]"===Object.prototype.toString.call(xs)}},{}],42:[function(require,module,exports){"use strict";var stringifyPrimitive=function(v){switch(typeof v){case"string":return v;case"boolean":return v?"true":"false";case"number":return isFinite(v)?v:"";default:return""}};module.exports=function(obj,sep,eq,name){return sep=sep||"&",eq=eq||"=",null===obj&&(obj=void 0),"object"==typeof obj?map(objectKeys(obj),function(k){var ks=encodeURIComponent(stringifyPrimitive(k))+eq;return isArray(obj[k])?map(obj[k],function(v){return ks+encodeURIComponent(stringifyPrimitive(v))}).join(sep):ks+encodeURIComponent(stringifyPrimitive(obj[k]))}).join(sep):name?encodeURIComponent(stringifyPrimitive(name))+eq+encodeURIComponent(stringifyPrimitive(obj)):""};var isArray=Array.isArray||function(xs){return"[object Array]"===Object.prototype.toString.call(xs)};function map(xs,f){if(xs.map)return xs.map(f);for(var res=[],i=0;i<xs.length;i++)res.push(f(xs[i],i));return res}var objectKeys=Object.keys||function(obj){var res=[];for(var key in obj)Object.prototype.hasOwnProperty.call(obj,key)&&res.push(key);return res}},{}],43:[function(require,module,exports){"use strict";exports.decode=exports.parse=require("./decode"),exports.encode=exports.stringify=require("./encode")},{"./decode":41,"./encode":42}],44:[function(require,module,exports){function Agent(){this._defaults=[]}["use","on","once","set","query","type","accept","auth","withCredentials","sortQuery","retry","ok","redirects","timeout","buffer","serialize","parse","ca","key","pfx","cert"].forEach(function(fn){Agent.prototype[fn]=function(){return this._defaults.push({fn:fn,arguments:arguments}),this}}),Agent.prototype._setDefaults=function(req){this._defaults.forEach(function(def){req[def.fn].apply(req,def.arguments)})},module.exports=Agent},{}],45:[function(require,module,exports){var root;"undefined"!=typeof window?root=window:"undefined"!=typeof self?root=self:(console.warn("Using browser-only version of superagent in non-browser environment"),root=this);var Emitter=require("component-emitter"),RequestBase=require("./request-base"),isObject=require("./is-object"),ResponseBase=require("./response-base"),Agent=require("./agent-base");function noop(){}var request=exports=module.exports=function(method,url){return"function"==typeof url?new exports.Request("GET",method).end(url):1==arguments.length?new exports.Request("GET",method):new exports.Request(method,url)};exports.Request=Request,request.getXHR=function(){if(!(!root.XMLHttpRequest||root.location&&"file:"==root.location.protocol&&root.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(e){}throw Error("Browser-only version of superagent could not find XHR")};var trim="".trim?function(s){return s.trim()}:function(s){return s.replace(/(^\s*|\s*$)/g,"")};function serialize(obj){if(!isObject(obj))return obj;var pairs=[];for(var key in obj)pushEncodedKeyValuePair(pairs,key,obj[key]);return pairs.join("&")}function pushEncodedKeyValuePair(pairs,key,val){if(null!=val)if(Array.isArray(val))val.forEach(function(v){pushEncodedKeyValuePair(pairs,key,v)});else if(isObject(val))for(var subkey in val)pushEncodedKeyValuePair(pairs,key+"["+subkey+"]",val[subkey]);else pairs.push(encodeURIComponent(key)+"="+encodeURIComponent(val));else null===val&&pairs.push(encodeURIComponent(key))}function parseString(str){for(var pair,pos,obj={},pairs=str.split("&"),i=0,len=pairs.length;i<len;++i)-1==(pos=(pair=pairs[i]).indexOf("="))?obj[decodeURIComponent(pair)]="":obj[decodeURIComponent(pair.slice(0,pos))]=decodeURIComponent(pair.slice(pos+1));return obj}function isJSON(mime){return/[\/+]json($|[^-\w])/.test(mime)}function Response(req){this.req=req,this.xhr=this.req.xhr,this.text="HEAD"!=this.req.method&&(""===this.xhr.responseType||"text"===this.xhr.responseType)||void 0===this.xhr.responseType?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText;var status=this.xhr.status;1223===status&&(status=204),this._setStatusProperties(status),this.header=this.headers=function(str){for(var index,line,field,val,lines=str.split(/\r?\n/),fields={},i=0,len=lines.length;i<len;++i)-1!==(index=(line=lines[i]).indexOf(":"))&&(field=line.slice(0,index).toLowerCase(),val=trim(line.slice(index+1)),fields[field]=val);return fields}(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this._setHeaderProperties(this.header),null===this.text&&req._responseType?this.body=this.xhr.response:this.body="HEAD"!=this.req.method?this._parseBody(this.text?this.text:this.xhr.response):null}function Request(method,url){var self=this;this._query=this._query||[],this.method=method,this.url=url,this.header={},this._header={},this.on("end",function(){var new_err,err=null,res=null;try{res=new Response(self)}catch(e){return(err=new Error("Parser is unable to parse the response")).parse=!0,err.original=e,self.xhr?(err.rawResponse=void 0===self.xhr.responseType?self.xhr.responseText:self.xhr.response,err.status=self.xhr.status?self.xhr.status:null,err.statusCode=err.status):(err.rawResponse=null,err.status=null),self.callback(err)}self.emit("response",res);try{self._isResponseOK(res)||(new_err=new Error(res.statusText||"Unsuccessful HTTP response"))}catch(custom_err){new_err=custom_err}new_err?(new_err.original=err,new_err.response=res,new_err.status=res.status,self.callback(new_err,res)):self.callback(null,res)})}function del(url,data,fn){var req=request("DELETE",url);return"function"==typeof data&&(fn=data,data=null),data&&req.send(data),fn&&req.end(fn),req}request.serializeObject=serialize,request.parseString=parseString,request.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},request.serialize={"application/x-www-form-urlencoded":serialize,"application/json":JSON.stringify},request.parse={"application/x-www-form-urlencoded":parseString,"application/json":JSON.parse},ResponseBase(Response.prototype),Response.prototype._parseBody=function(str){var parse=request.parse[this.type];return this.req._parser?this.req._parser(this,str):(!parse&&isJSON(this.type)&&(parse=request.parse["application/json"]),parse&&str&&(str.length||str instanceof Object)?parse(str):null)},Response.prototype.toError=function(){var req=this.req,method=req.method,url=req.url,msg="cannot "+method+" "+url+" ("+this.status+")",err=new Error(msg);return err.status=this.status,err.method=method,err.url=url,err},request.Response=Response,Emitter(Request.prototype),RequestBase(Request.prototype),Request.prototype.type=function(type){return this.set("Content-Type",request.types[type]||type),this},Request.prototype.accept=function(type){return this.set("Accept",request.types[type]||type),this},Request.prototype.auth=function(user,pass,options){1===arguments.length&&(pass=""),"object"==typeof pass&&null!==pass&&(options=pass,pass=""),options||(options={type:"function"==typeof btoa?"basic":"auto"});return this._auth(user,pass,options,function(string){if("function"==typeof btoa)return btoa(string);throw new Error("Cannot use basic auth, btoa is not a function")})},Request.prototype.query=function(val){return"string"!=typeof val&&(val=serialize(val)),val&&this._query.push(val),this},Request.prototype.attach=function(field,file,options){if(file){if(this._data)throw Error("superagent can't mix .send() and .attach()");this._getFormData().append(field,file,options||file.name)}return this},Request.prototype._getFormData=function(){return this._formData||(this._formData=new root.FormData),this._formData},Request.prototype.callback=function(err,res){if(this._shouldRetry(err,res))return this._retry();var fn=this._callback;this.clearTimeout(),err&&(this._maxRetries&&(err.retries=this._retries-1),this.emit("error",err)),fn(err,res)},Request.prototype.crossDomainError=function(){var err=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");err.crossDomain=!0,err.status=this.status,err.method=this.method,err.url=this.url,this.callback(err)},Request.prototype.buffer=Request.prototype.ca=Request.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},Request.prototype.pipe=Request.prototype.write=function(){throw Error("Streaming is not supported in browser version of superagent")},Request.prototype._isHost=function(obj){return obj&&"object"==typeof obj&&!Array.isArray(obj)&&"[object Object]"!==Object.prototype.toString.call(obj)},Request.prototype.end=function(fn){return this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=fn||noop,this._finalizeQueryString(),this._end()},Request.prototype._end=function(){var self=this,xhr=this.xhr=request.getXHR(),data=this._formData||this._data;this._setTimeouts(),xhr.onreadystatechange=function(){var readyState=xhr.readyState;if(readyState>=2&&self._responseTimeoutTimer&&clearTimeout(self._responseTimeoutTimer),4==readyState){var status;try{status=xhr.status}catch(e){status=0}if(!status){if(self.timedout||self._aborted)return;return self.crossDomainError()}self.emit("end")}};var handleProgress=function(direction,e){e.total>0&&(e.percent=e.loaded/e.total*100),e.direction=direction,self.emit("progress",e)};if(this.hasListeners("progress"))try{xhr.onprogress=handleProgress.bind(null,"download"),xhr.upload&&(xhr.upload.onprogress=handleProgress.bind(null,"upload"))}catch(e){}try{this.username&&this.password?xhr.open(this.method,this.url,!0,this.username,this.password):xhr.open(this.method,this.url,!0)}catch(err){return this.callback(err)}if(this._withCredentials&&(xhr.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof data&&!this._isHost(data)){var contentType=this._header["content-type"],serialize=this._serializer||request.serialize[contentType?contentType.split(";")[0]:""];!serialize&&isJSON(contentType)&&(serialize=request.serialize["application/json"]),serialize&&(data=serialize(data))}for(var field in this.header)null!=this.header[field]&&this.header.hasOwnProperty(field)&&xhr.setRequestHeader(field,this.header[field]);return this._responseType&&(xhr.responseType=this._responseType),this.emit("request",this),xhr.send(void 0!==data?data:null),this},request.agent=function(){return new Agent},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(method){Agent.prototype[method.toLowerCase()]=function(url,fn){var req=new request.Request(method,url);return this._setDefaults(req),fn&&req.end(fn),req}}),Agent.prototype.del=Agent.prototype.delete,request.get=function(url,data,fn){var req=request("GET",url);return"function"==typeof data&&(fn=data,data=null),data&&req.query(data),fn&&req.end(fn),req},request.head=function(url,data,fn){var req=request("HEAD",url);return"function"==typeof data&&(fn=data,data=null),data&&req.query(data),fn&&req.end(fn),req},request.options=function(url,data,fn){var req=request("OPTIONS",url);return"function"==typeof data&&(fn=data,data=null),data&&req.send(data),fn&&req.end(fn),req},request.del=del,request.delete=del,request.patch=function(url,data,fn){var req=request("PATCH",url);return"function"==typeof data&&(fn=data,data=null),data&&req.send(data),fn&&req.end(fn),req},request.post=function(url,data,fn){var req=request("POST",url);return"function"==typeof data&&(fn=data,data=null),data&&req.send(data),fn&&req.end(fn),req},request.put=function(url,data,fn){var req=request("PUT",url);return"function"==typeof data&&(fn=data,data=null),data&&req.send(data),fn&&req.end(fn),req}},{"./agent-base":44,"./is-object":46,"./request-base":47,"./response-base":48,"component-emitter":39}],46:[function(require,module,exports){"use strict";module.exports=function(obj){return null!==obj&&"object"==typeof obj}},{}],47:[function(require,module,exports){"use strict";var isObject=require("./is-object");function RequestBase(obj){if(obj)return function(obj){for(var key in RequestBase.prototype)obj[key]=RequestBase.prototype[key];return obj}(obj)}module.exports=RequestBase,RequestBase.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this},RequestBase.prototype.parse=function(fn){return this._parser=fn,this},RequestBase.prototype.responseType=function(val){return this._responseType=val,this},RequestBase.prototype.serialize=function(fn){return this._serializer=fn,this},RequestBase.prototype.timeout=function(options){if(!options||"object"!=typeof options)return this._timeout=options,this._responseTimeout=0,this;for(var option in options)switch(option){case"deadline":this._timeout=options.deadline;break;case"response":this._responseTimeout=options.response;break;default:console.warn("Unknown timeout option",option)}return this},RequestBase.prototype.retry=function(count,fn){return 0!==arguments.length&&!0!==count||(count=1),count<=0&&(count=0),this._maxRetries=count,this._retries=0,this._retryCallback=fn,this};var ERROR_CODES=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];RequestBase.prototype._shouldRetry=function(err,res){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var override=this._retryCallback(err,res);if(!0===override)return!0;if(!1===override)return!1}catch(e){console.error(e)}if(res&&res.status&&res.status>=500&&501!=res.status)return!0;if(err){if(err.code&&~ERROR_CODES.indexOf(err.code))return!0;if(err.timeout&&"ECONNABORTED"==err.code)return!0;if(err.crossDomain)return!0}return!1},RequestBase.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},RequestBase.prototype.then=function(resolve,reject){if(!this._fullfilledPromise){var self=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(innerResolve,innerReject){self.end(function(err,res){err?innerReject(err):innerResolve(res)})})}return this._fullfilledPromise.then(resolve,reject)},RequestBase.prototype.catch=function(cb){return this.then(void 0,cb)},RequestBase.prototype.use=function(fn){return fn(this),this},RequestBase.prototype.ok=function(cb){if("function"!=typeof cb)throw Error("Callback required");return this._okCallback=cb,this},RequestBase.prototype._isResponseOK=function(res){return!!res&&(this._okCallback?this._okCallback(res):res.status>=200&&res.status<300)},RequestBase.prototype.get=function(field){return this._header[field.toLowerCase()]},RequestBase.prototype.getHeader=RequestBase.prototype.get,RequestBase.prototype.set=function(field,val){if(isObject(field)){for(var key in field)this.set(key,field[key]);return this}return this._header[field.toLowerCase()]=val,this.header[field]=val,this},RequestBase.prototype.unset=function(field){return delete this._header[field.toLowerCase()],delete this.header[field],this},RequestBase.prototype.field=function(name,val){if(null===name||void 0===name)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),isObject(name)){for(var key in name)this.field(key,name[key]);return this}if(Array.isArray(val)){for(var i in val)this.field(name,val[i]);return this}if(null===val||void 0===val)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof val&&(val=""+val),this._getFormData().append(name,val),this},RequestBase.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},RequestBase.prototype._auth=function(user,pass,options,base64Encoder){switch(options.type){case"basic":this.set("Authorization","Basic "+base64Encoder(user+":"+pass));break;case"auto":this.username=user,this.password=pass;break;case"bearer":this.set("Authorization","Bearer "+user)}return this},RequestBase.prototype.withCredentials=function(on){return void 0==on&&(on=!0),this._withCredentials=on,this},RequestBase.prototype.redirects=function(n){return this._maxRedirects=n,this},RequestBase.prototype.maxResponseSize=function(n){if("number"!=typeof n)throw TypeError("Invalid argument");return this._maxResponseSize=n,this},RequestBase.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},RequestBase.prototype.send=function(data){var isObj=isObject(data),type=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),isObj&&!this._data)Array.isArray(data)?this._data=[]:this._isHost(data)||(this._data={});else if(data&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(isObj&&isObject(this._data))for(var key in data)this._data[key]=data[key];else"string"==typeof data?(type||this.type("form"),type=this._header["content-type"],this._data="application/x-www-form-urlencoded"==type?this._data?this._data+"&"+data:data:(this._data||"")+data):this._data=data;return!isObj||this._isHost(data)?this:(type||this.type("json"),this)},RequestBase.prototype.sortQuery=function(sort){return this._sort=void 0===sort||sort,this},RequestBase.prototype._finalizeQueryString=function(){var query=this._query.join("&");if(query&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+query),this._query.length=0,this._sort){var index=this.url.indexOf("?");if(index>=0){var queryArr=this.url.substring(index+1).split("&");"function"==typeof this._sort?queryArr.sort(this._sort):queryArr.sort(),this.url=this.url.substring(0,index)+"?"+queryArr.join("&")}}},RequestBase.prototype._appendQueryString=function(){console.trace("Unsupported")},RequestBase.prototype._timeoutError=function(reason,timeout,errno){if(!this._aborted){var err=new Error(reason+timeout+"ms exceeded");err.timeout=timeout,err.code="ECONNABORTED",err.errno=errno,this.timedout=!0,this.abort(),this.callback(err)}},RequestBase.prototype._setTimeouts=function(){var self=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){self._timeoutError("Timeout of ",self._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){self._timeoutError("Response timeout of ",self._responseTimeout,"ETIMEDOUT")},this._responseTimeout))}},{"./is-object":46}],48:[function(require,module,exports){"use strict";var utils=require("./utils");function ResponseBase(obj){if(obj)return function(obj){for(var key in ResponseBase.prototype)obj[key]=ResponseBase.prototype[key];return obj}(obj)}module.exports=ResponseBase,ResponseBase.prototype.get=function(field){return this.header[field.toLowerCase()]},ResponseBase.prototype._setHeaderProperties=function(header){var ct=header["content-type"]||"";this.type=utils.type(ct);var params=utils.params(ct);for(var key in params)this[key]=params[key];this.links={};try{header.link&&(this.links=utils.parseLinks(header.link))}catch(err){}},ResponseBase.prototype._setStatusProperties=function(status){var type=status/100|0;this.status=this.statusCode=status,this.statusType=type,this.info=1==type,this.ok=2==type,this.redirect=3==type,this.clientError=4==type,this.serverError=5==type,this.error=(4==type||5==type)&&this.toError(),this.created=201==status,this.accepted=202==status,this.noContent=204==status,this.badRequest=400==status,this.unauthorized=401==status,this.notAcceptable=406==status,this.forbidden=403==status,this.notFound=404==status,this.unprocessableEntity=422==status}},{"./utils":49}],49:[function(require,module,exports){"use strict";exports.type=function(str){return str.split(/ *; */).shift()},exports.params=function(str){return str.split(/ *; */).reduce(function(obj,str){var parts=str.split(/ *= */),key=parts.shift(),val=parts.shift();return key&&val&&(obj[key]=val),obj},{})},exports.parseLinks=function(str){return str.split(/ *, */).reduce(function(obj,str){var parts=str.split(/ *; */),url=parts[0].slice(1,-1);return obj[parts[1].split(/ *= */)[1].slice(1,-1)]=url,obj},{})},exports.cleanHeader=function(header,changesOrigin){return delete header["content-type"],delete header["content-length"],delete header["transfer-encoding"],delete header.host,changesOrigin&&(delete header.authorization,delete header.cookie),header}},{}]},{},[26])(26)});
  