text: !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,(t.MbedCloudSDK||(t.MbedCloudSDK={})).UpdateApi=e()}}(function(){return function(){function e(t,r,n){function i(a,s){if(!r[a]){if(!t[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var p=new Error("Cannot find module '"+a+"'");throw p.code="MODULE_NOT_FOUND",p}var c=r[a]={exports:{}};t[a][0].call(c.exports,function(e){return i(t[a][1][e]||e)},c,c.exports,e,t,r,n)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;a<n.length;a++)i(n[a]);return i}return e}()({1:[function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(r,"__esModule",{value:!0});var i=e("../common/apiBase"),o=e("../common/sdkError"),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.firmwareImageCreate=function(e,t,r,n,i){if(null===e||void 0===e)return void(n&&n(new o.SDKError("Required parameter 'datafile' missing.")));if(null===t||void 0===t)return void(n&&n(new o.SDKError("Required parameter 'name' missing.")));var a={},s={},u=!1,p={};void 0!==e&&(p.datafile=e),u=!0,void 0!==r&&(p.description=r),void 0!==t&&(p.name=t);var c=["multipart/form-data"],d=["application/json"];return this.request({url:"/v3/firmware-images/",method:"POST",headers:a,query:s,formParams:p,useFormData:u,contentTypes:c,acceptTypes:d,requestOptions:i},n)},t.prototype.firmwareImageDestroy=function(e,t,r){if(null===e||void 0===e)return void(t&&t(new o.SDKError("Required parameter 'imageId' missing.")));var n={},i={},a={},s=[],u=["application/json"];return this.request({url:"/v3/firmware-images/{image_id}/".replace("{image_id}",String(e)),method:"DELETE",headers:n,query:i,formParams:a,useFormData:!1,contentTypes:s,acceptTypes:u,requestOptions:r},t)},t.prototype.firmwareImageList=function(e,t,r,n,i,o,a){var s={},u={};void 0!==e&&(u.limit=e),void 0!==t&&(u.order=t),void 0!==r&&(u.after=r),void 0!==n&&(u.filter=n),void 0!==i&&(u.include=i);var p={},c=[],d=["application/json"];return this.request({url:"/v3/firmware-images/",method:"GET",headers:s,query:u,formParams:p,useFormData:!1,contentTypes:c,acceptTypes:d,requestOptions:a},o)},t.prototype.firmwareImageRetrieve=function(e,t,r){if(null===e||void 0===e)return void(t&&t(new o.SDKError("Required parameter 'imageId' missing.")));var n={},i={},a={},s=[],u=["application/json"];return this.request({url:"/v3/firmware-images/{image_id}/".replace("{image_id}",String(e)),method:"GET",headers:n,query:i,formParams:a,useFormData:!1,contentTypes:s,acceptTypes:u,requestOptions:r},t)},t.prototype.firmwareManifestCreate=function(e,t,r,n,i,a){if(null===e||void 0===e)return void(i&&i(new o.SDKError("Required parameter 'datafile' missing.")));if(null===t||void 0===t)return void(i&&i(new o.SDKError("Required parameter 'name' missing.")));var s={},u={},p=!1,c={};void 0!==e&&(c.datafile=e),p=!0,void 0!==r&&(c.description=r),void 0!==n&&(c.key_table=n),p=!0,void 0!==t&&(c.name=t);var d=["multipart/form-data"],f=["application/json"];return this.request({url:"/v3/firmware-manifests/",method:"POST",headers:s,query:u,formParams:c,useFormData:p,contentTypes:d,acceptTypes:f,requestOptions:a},i)},t.prototype.firmwareManifestDestroy=function(e,t,r){if(null===e||void 0===e)return void(t&&t(new o.SDKError("Required parameter 'manifestId' missing.")));var n={},i={},a={},s=[],u=["application/json"];return this.request({url:"/v3/firmware-manifests/{manifest_id}/".replace("{manifest_id}",String(e)),method:"DELETE",headers:n,query:i,formParams:a,useFormData:!1,contentTypes:s,acceptTypes:u,requestOptions:r},t)},t.prototype.firmwareManifestList=function(e,t,r,n,i,o,a){var s={},u={};void 0!==e&&(u.limit=e),void 0!==t&&(u.order=t),void 0!==r&&(u.after=r),void 0!==n&&(u.filter=n),void 0!==i&&(u.include=i);var p={},c=[],d=["application/json"];return this.request({url:"/v3/firmware-manifests/",method:"GET",headers:s,query:u,formParams:p,useFormData:!1,contentTypes:c,acceptTypes:d,requestOptions:a},o)},t.prototype.firmwareManifestRetrieve=function(e,t,r){if(null===e||void 0===e)return void(t&&t(new o.SDKError("Required parameter 'manifestId' missing.")));var n={},i={},a={},s=[],u=["application/json"];return this.request({url:"/v3/firmware-manifests/{manifest_id}/".replace("{manifest_id}",String(e)),method:"GET",headers:n,query:i,formParams:a,useFormData:!1,contentTypes:s,acceptTypes:u,requestOptions:r},t)},t.prototype.updateCampaignCreate=function(e,t,r){if(null===e||void 0===e)return void(t&&t(new o.SDKError("Required parameter 'campaign' missing.")));var n={},i={},a={},s=[],u=["application/json"];return this.request({url:"/v3/update-campaigns/",method:"POST",headers:n,query:i,formParams:a,useFormData:!1,contentTypes:s,acceptTypes:u,requestOptions:r,body:e},t)},t.prototype.updateCampaignDestroy=function(e,t,r){if(null===e||void 0===e)return void(t&&t(new o.SDKError("Required parameter 'campaignId' missing.")));var n={},i={},a={},s=[],u=["application/json"];return this.request({url:"/v3/update-campaigns/{campaign_id}/".replace("{campaign_id}",String(e)),method:"DELETE",headers:n,query:i,formParams:a,useFormData:!1,contentTypes:s,acceptTypes:u,requestOptions:r},t)},t.prototype.updateCampaignList=function(e,t,r,n,i,o,a){var s={},u={};void 0!==e&&(u.limit=e),void 0!==t&&(u.order=t),void 0!==r&&(u.after=r),void 0!==n&&(u.filter=n),void 0!==i&&(u.include=i);var p={},c=[],d=["application/json"];return this.request({url:"/v3/update-campaigns/",method:"GET",headers:s,query:u,formParams:p,useFormData:!1,contentTypes:c,acceptTypes:d,requestOptions:a},o)},t.prototype.updateCampaignMetadataList=function(e,t,r,n,i,a,s){if(null===e||void 0===e)return void(a&&a(new o.SDKError("Required parameter 'campaignId' missing.")));var u={},p={};void 0!==t&&(p.limit=t),void 0!==r&&(p.order=r),void 0!==n&&(p.after=n),void 0!==i&&(p.include=i);var c={},d=[],f=["application/json"];return this.request({url:"/v3/update-campaigns/{campaign_id}/campaign-device-metadata/".replace("{campaign_id}",String(e)),method:"GET",headers:u,query:p,formParams:c,useFormData:!1,contentTypes:d,acceptTypes:f,requestOptions:s},a)},t.prototype.updateCampaignMetadataRetrieve=function(e,t,r,n){if(null===e||void 0===e)return void(r&&r(new o.SDKError("Required parameter 'campaignId' missing.")));if(null===t||void 0===t)return void(r&&r(new o.SDKError("Required parameter 'campaignDeviceMetadataId' missing.")));var i={},a={},s={},u=[],p=["application/json"];return this.request({url:"/v3/update-campaigns/{campaign_id}/campaign-device-metadata/{campaign_device_metadata_id}/".replace("{campaign_id}",String(e)).replace("{campaign_device_metadata_id}",String(t)),method:"GET",headers:i,query:a,formParams:s,useFormData:!1,contentTypes:u,acceptTypes:p,requestOptions:n},r)},t.prototype.updateCampaignMetadataStop=function(e,t,r){if(null===e||void 0===e)return void(t&&t(new o.SDKError("Required parameter 'campaignId' missing.")));var n={},i={},a={},s=[],u=["application/json"];return this.request({url:"/v3/update-campaigns/{campaign_id}/stop".replace("{campaign_id}",String(e)),method:"POST",headers:n,query:i,formParams:a,useFormData:!1,contentTypes:s,acceptTypes:u,requestOptions:r},t)},t.prototype.updateCampaignRetrieve=function(e,t,r){if(null===e||void 0===e)return void(t&&t(new o.SDKError("Required parameter 'campaignId' missing.")));var n={},i={},a={},s=[],u=["application/json"];return this.request({url:"/v3/update-campaigns/{campaign_id}/".replace("{campaign_id}",String(e)),method:"GET",headers:n,query:i,formParams:a,useFormData:!1,contentTypes:s,acceptTypes:u,requestOptions:r},t)},t.prototype.updateCampaignUpdate=function(e,t,r,n){if(null===e||void 0===e)return void(r&&r(new o.SDKError("Required parameter 'campaignId' missing.")));if(null===t||void 0===t)return void(r&&r(new o.SDKError("Required parameter 'campaign' missing.")));var i={},a={},s={},u=[],p=["application/json"];return this.request({url:"/v3/update-campaigns/{campaign_id}/".replace("{campaign_id}",String(e)),method:"PUT",headers:i,query:a,formParams:s,useFormData:!1,contentTypes:u,acceptTypes:p,requestOptions:n,body:t},r)},t}(i.ApiBase);r.DefaultApi=a},{"../common/apiBase":2,"../common/sdkError":7}],2:[function(e,t,r){(function(t,n){"use strict";/*
  * Mbed Cloud JavaScript SDK
  * Copyright Arm Limited 2017
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  Object.defineProperty(r,"__esModule",{value:!0});var i=e("superagent"),o=e("./sdkError"),a=e("../../package.json"),s=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*))(?:Z|(\+|-)([\d|:]*))?$/,u=/^application\/json(;.*)?$/i,p=/^text\/plain(;.*)?$/i,c=a.is_published?a.version:a.version+"+dev",d=a.name+"-javascript / "+c,f=function(){function r(e,t,r){void 0===t&&(t="https://api.us-east-1.mbedcloud.com"),void 0===r&&(r=null),this.host=t,this.responseHandler=r,this.apiKey="",e&&"bearer"!==e.substr(0,6).toLowerCase()&&(e="Bearer "+e),this.apiKey=e}return r.normalizeParams=function(e){var t={};for(var n in e)if(e.hasOwnProperty(n)&&void 0!==e[n]&&null!==e[n]){var i=e[n];this.isFileParam(i)||Array.isArray(i)?t[n]=i:t[n]=r.paramToString(i)}return t},r.isFileParam=function(t){return!!("undefined"==typeof window&&"function"==typeof e&&e("fs")&&t instanceof e("fs").ReadStream)||("function"==typeof n&&t instanceof n||("function"==typeof Blob&&t instanceof Blob||"function"==typeof File&&t instanceof File))},r.paramToString=function(e){return void 0===e||null===e?"":e instanceof Date?e.toJSON():e.toString()},r.chooseType=function(e,t){if(void 0===t&&(t=null),!e.length)return t;var r=e[0]||t;return e.some(function(e){if(p.test(e))return r=e,!0}),r},r.debugLog=function(e,r){t&&t.env&&"superagent"===t.env.DEBUG&&(t.stdout.write("  [1m[35msuperagent[0m "+e.toUpperCase()+" "),console.log(r))},r.prototype.request=function(e,t){var n=this,o=e.requestOptions||{};o.timeout=o.timeout||6e4,o.method=o.method||e.method,o.query=o.query||r.normalizeParams(e.query),o.headers=o.headers||r.normalizeParams(e.headers),o.acceptHeader=o.acceptHeader||r.chooseType(e.acceptTypes),o.url=o.url||e.url.replace(/([:])?\/+/g,function(e,t){return t?e:"/"});var a=i(o.method,this.host+o.url);a.query(o.query),o.headers.Authorization=this.apiKey,o.headers["User-Agent"]=d,a.set(o.headers),a.timeout(o.timeout),o.acceptHeader&&a.accept(o.acceptHeader);var s=null;if(Object.keys(e.formParams).length>0)if(e.useFormData){var p=r.normalizeParams(e.formParams);for(var c in p)p.hasOwnProperty(c)&&(r.isFileParam(p[c])?a.attach(c,p[c]):a.field(c,p[c]))}else o.contentType=o.contentType||"application/x-www-form-urlencoded",a.type(o.contentType),a.send(r.normalizeParams(e.formParams));else e.body&&(s=e.body,o.contentType=o.contentType||r.chooseType(e.contentTypes,"application/json"),a.type(o.contentType),s&&s.constructor==={}.constructor&&u.test(o.contentType)&&(s=Object.keys(s).reduce(function(e,t){return null!==s[t]&&void 0!==s[t]&&(e[t]=s[t]),e},{})),a.send(s));return s&&r.debugLog("body",s),a.end(function(e,r){n.complete(e,r,o.acceptHeader,t)}),a},r.prototype.complete=function(e,t,r,n){var i=null;if(e){var a=e.message,p=e,c="";t&&(t.error&&(a=t.error.message),t.body&&t.body.message&&(a=t.body.message,a.error&&(a=a.error)),p=t.error||e,c=t.body||t.text),i=new o.SDKError(a,p,c,e.status)}if(this.responseHandler&&this.responseHandler(i,t),n){var d=null;t&&!i&&(d=t.body||t.text),d&&d.constructor==={}.constructor&&u.test(r)&&(d=JSON.parse(JSON.stringify(d),function(e,t){return s.test(t)?new Date(t):t})),n(i,d)}},r}();r.ApiBase=f}).call(this,e("_process"),e("buffer").Buffer)},{"../../package.json":31,"./sdkError":7,_process:24,buffer:22,fs:22,superagent:26}],3:[function(e,t,r){"use strict";/*
  * Mbed Cloud JavaScript SDK
  * Copyright Arm Limited 2017
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function e(e,t,r,n,i){this.statusCode=e,this.errorMessage=t,r&&(this.headers=r,this.date=r.date?new Date(r.date):new Date,this.requestId=r["x-request-id"]),n&&(this.object=n.object,this.etag=n.etag),i&&(this.method=i.method,this.url=i.url)}return e}();r.ApiMetadata=n},{}],4:[function(e,t,r){"use strict";/*
  * Mbed Cloud JavaScript SDK
  * Copyright Arm Limited 2017
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  Object.defineProperty(r,"__esModule",{value:!0});var n=e("./apiMetadata"),i=function(){function e(){}return e.prototype.responseHandler=function(e,t){var r=null,i=null,o=null,a=null,s=null;e&&(r=e.code,i=e.message,s=e.innerError),t&&(r=t.statusCode,o=t.headers,a=t.body||t.text,s=t.request||t.req),this.lastMeta=new n.ApiMetadata(r,i,o,a,s)},e.prototype.getLastMeta=function(){return this.lastMeta},e}();r.EndpointsBase=i},{"./apiMetadata":3}],5:[function(e,t,r){(function(t){"use strict";function n(e,t){if(!t)return new Promise(function(t,r){try{e(function(e,n){e?r(e):t(n)})}catch(e){r(new l.SDKError(e.message,e))}});try{e(t)}catch(e){t(new l.SDKError(e.message,e))}}function i(e,t,r,i){return void 0===i&&(i=!1),n(function(r){try{e(function(e,n){if(e)return i||404!==e.code?r(e):r(null,null);if(!t)return r(null,n);try{t(n,r)}catch(e){r(new l.SDKError(e.message,e))}})}catch(e){r(new l.SDKError(e.message,e))}},r)}function o(e,r){var n="";if(n="function"==typeof atob?atob(e):new t(e,"base64").toString("binary"),r&&r.indexOf("tlv")>-1)try{return m.decodeTlv(n)}catch(e){}return n}function a(e){return e&&e.length?e.map(u).join(","):null}function s(e){return e.replace(/(\_\w)/g,function(e){return e[1].toUpperCase()})}function u(e){return e.replace(/([A-Z]+?)/g,function(e){return"_"+e.toLowerCase()})}function p(e,t,r){if(void 0===r&&(r=null),e&&e[t]){var n=e[t];if(n.constructor!=={}.constructor)return n;if(n.$eq)return n.$eq}return r}function c(e,t,r){function n(e,r,n,i){if(void 0===i&&(i=""),n instanceof Date&&(n=n.toISOString()),"boolean"==typeof n&&(n=n.toString()),i)i=u(i),i+="__";else{var o=t.from.indexOf(e);e=o>-1?t.to[o]:u(e)}var a=r.replace("$","");return"ne"===a&&(a="neq"),"eq"===a&&(a=""),a&&(a="__"+a),""+i+e+a+"="+n}return void 0===t&&(t={from:[],to:[]}),void 0===r&&(r=[]),e?Object.keys(e).map(function(t){return e[t].constructor!=={}.constructor?n(t,"",e[t]):Object.keys(e[t]).map(function(i){return r.indexOf(t)>-1?e[t][i].constructor!=={}.constructor?n(i,"",e[t][i],t):Object.keys(e[t][i]).map(function(r){return n(i,r,e[t][i][r],t)}).join("&"):n(t,i,e[t][i])}).join("&")}).join("&"):""}function d(e,t,r){function n(e){var r=t.to.indexOf(e);return r>-1?t.from[r]:s(e)}function i(e,t,r){t||(t="eq"),"neq"===t&&(t="ne"),t="$"+t,e[t]=r}void 0===t&&(t={from:[],to:[]}),void 0===r&&(r=[]);var o={};return e=decodeURIComponent(e),e.split("&").forEach(function(e){var t=e.match(/^(.+)=(.+)$/);if(t){var a=t[2],s=t[1].split("__"),u=n(s[0]);if(o[u]||(o[u]={}),r.indexOf(u)>-1){var p=s[1];return o[u][p]||(o[u][p]={}),void i(o[u][p],s[2],a)}i(o[u],s[1],a)}}),o}function f(e){return e instanceof Array?e:[e]}/*
  * Mbed Cloud JavaScript SDK
  * Copyright Arm Limited 2017
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  Object.defineProperty(r,"__esModule",{value:!0});var l=e("./sdkError"),m=e("./tlvDecoder");r.asyncStyle=n,r.apiWrapper=i,r.decodeBase64=o,r.encodeInclude=a,r.snakeToCamel=s,r.camelToSnake=u,r.extractFilter=p,r.encodeFilter=c,r.decodeFilter=d,r.ensureArray=f}).call(this,e("buffer").Buffer)},{"./sdkError":7,"./tlvDecoder":8,buffer:22}],6:[function(e,t,r){"use strict";/*
  * Mbed Cloud JavaScript SDK
  * Copyright Arm Limited 2017
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function e(e,t){this.after=e.after,this.hasMore=e.has_more,this.limit=e.limit,this.order=e.order,this.totalCount=e.total_count,this.data=t||[]}return e}();r.ListResponse=n},{}],7:[function(e,t,r){"use strict";/*
  * Mbed Cloud JavaScript SDK
  * Copyright Arm Limited 2017
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(r,"__esModule",{value:!0});var i=function(e){function t(t,r,n,i){var o=e.call(this,t)||this;return o.innerError=r,o.details=n,o.code=i,o}return n(t,e),t}(Error);r.SDKError=i},{}],8:[function(e,t,r){"use strict";function n(e){return(e&u)===u?2:1}function i(e){return(e&p)===f.ONE_BYTE?1:(e&p)===f.TWO_BYTE?2:(e&p)===f.TRE_BYTE?3:e&c}function o(e,t,r){if(void 0===t&&(t={}),void 0===r&&(r=""),!e||e.length<1)return t;var a=e[0],u=a&s,c=n(a),l=i(a),m=function(e){return String.fromCharCode(e)},h=function(e,t,r,n){return e+(t<<8*(n.length-r-1))},y=1,v=e.slice(y,y+c).reduce(h,0);y+=c;var _=l;if((a&p)!==f.OTR_BYTE&&(_=e.slice(y,y+l).reduce(h,0),y+=l),u===d.MULT_RESOURCE)o(e.slice(y,y+_),t,r+"/"+v);else{var g=e.slice(y,y+_),w=g.some(function(e){return 0===e}),T=w?g.reduce(h,0):g.map(m).join("");t[r+"/"+v]=T}return y+=_,o(e.slice(y),t,r),t}function a(e){return o(e.split("").map(function(e){return e.charCodeAt(0)}))}/*
  * Mbed Cloud JavaScript SDK
  * Copyright Arm Limited 2017
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  Object.defineProperty(r,"__esModule",{value:!0});var s=parseInt("11000000",2),u=parseInt("00100000",2),p=parseInt("00011000",2),c=parseInt("00000111",2),d={OBJECT_INSTAN:parseInt("00000000",2),RESOURCE_INST:parseInt("01000000",2),MULT_RESOURCE:parseInt("10000000",2),RESOURCE_VALU:parseInt("11000000",2)},f={ONE_BYTE:parseInt("00001000",2),TWO_BYTE:parseInt("00010000",2),TRE_BYTE:parseInt("00011000",2),OTR_BYTE:parseInt("00000000",2)};r.decodeTlv=a},{}],9:[function(e,t,r){"use strict";/*
  * Mbed Cloud JavaScript SDK
  * Copyright Arm Limited 2017
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function e(){}return e.NESTED_FILTERS=["customAttributes"],e.DEVICE_FILTER_MAP={from:["alias","bootstrapCertificateExpiration","certificateFingerprint","certificateIssuerId","connectorCertificateExpiration","deviceType"],to:["endpoint_name","bootstrap_expiration_date","device_key","ca_id","connector_expiration_date","endpoint_type"]},e.DEVICE_EVENT_FILTER_MAP={from:["eventDate","type"],to:["date_time","event_type"]},e.EMPTY_FILTER_MAP={from:[],to:[]},e}();r.Filters=n},{}],10:[function(e,t,r){"use strict";/*
  * Mbed Cloud JavaScript SDK
  * Copyright Arm Limited 2017
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(r,"__esModule",{value:!0});var i=e("../_api/update_service"),o=e("../common/endpointsBase"),a=function(e){function t(t){var r=e.call(this)||this;return r.update=new i.DefaultApi(t.apiKey,t.host,r.responseHandler.bind(r)),r}return n(t,e),t}(o.EndpointsBase);r.Endpoints=a},{"../_api/update_service":1,"../common/endpointsBase":4}],11:[function(e,t,r){"use strict";/*
  * Mbed Cloud JavaScript SDK
  * Copyright Arm Limited 2017
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function e(){}return e.CAMPAIGN_FILTER_MAP={from:["finishedAt","manifestId","manifestUrl","scheduledAt"],to:["finished","root_manifest_id","root_manifest_url","when"]},e.EMPTY_FILTER_MAP={from:[],to:[]},e}();r.Filters=n},{}],12:[function(e,t,r){"use strict";/*
  * Mbed Cloud JavaScript SDK
  * Copyright Arm Limited 2017
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  var n=e("./updateApi");t.exports=n.UpdateApi},{"./updateApi":21}],13:[function(e,t,r){"use strict";/*
  * Mbed Cloud JavaScript SDK
  * Copyright Arm Limited 2017
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  Object.defineProperty(r,"__esModule",{value:!0});var n=e("../../common/functions"),i=function(){function e(e,t){this._api=t;for(var r in e)e.hasOwnProperty(r)&&(this[r]=e[r])}return e.prototype.update=function(e){var t=this;return n.asyncStyle(function(e){t._api.updateCampaign(t,e)},e)},e.prototype.start=function(e){var t=this;return n.asyncStyle(function(e){t._api.startCampaign(t.id,e)},e)},e.prototype.stop=function(e){var t=this;return n.asyncStyle(function(e){t._api.stopCampaign(t.id,e)},e)},e.prototype.listDeviceStates=function(e,t){var r=this;return e=e||{},"function"==typeof e&&(t=e,e={}),n.asyncStyle(function(t){r._api.listCampaignDeviceStates(r.id,e,t)},t)},e.prototype.delete=function(e){var t=this;return n.asyncStyle(function(e){t._api.deleteCampaign(t.id,e)},e)},e}();r.Campaign=i},{"../../common/functions":5}],14:[function(e,t,r){"use strict";/*
  * Mbed Cloud JavaScript SDK
  * Copyright Arm Limited 2017
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  Object.defineProperty(r,"__esModule",{value:!0});var n=e("../../common/functions"),i=e("../../deviceDirectory/filters"),o=e("./campaign"),a=function(){function e(){}return e.map=function(e,t){return new o.Campaign({deviceFilter:n.decodeFilter(e.device_filter,i.Filters.DEVICE_FILTER_MAP,i.Filters.NESTED_FILTERS),createdAt:e.created_at,description:e.description,finishedAt:e.finished,id:e.id,manifestId:e.root_manifest_id,manifestUrl:e.root_manifest_url,name:e.name,startedAt:e.started_at,state:e.state,scheduledAt:e.when,updatedAt:e.updated_at},t)},e.addMap=function(e){return{description:e.description,device_filter:n.encodeFilter(e.deviceFilter,i.Filters.DEVICE_FILTER_MAP,i.Filters.NESTED_FILTERS)||null,name:e.name,root_manifest_id:e.manifestId,state:e.state,when:e.scheduledAt,object:e.object}},e.updateMap=function(e){return{description:e.description,device_filter:n.encodeFilter(e.deviceFilter,i.Filters.DEVICE_FILTER_MAP,i.Filters.NESTED_FILTERS)||null,name:e.name,root_manifest_id:e.manifestId,state:e.state,when:e.scheduledAt,object:e.object}},e}();r.CampaignAdapter=a},{"../../common/functions":5,"../../deviceDirectory/filters":9,"./campaign":13}],15:[function(e,t,r){"use strict";/*
  * Mbed Cloud JavaScript SDK
  * Copyright Arm Limited 2017
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function e(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t])}return e}();r.CampaignDeviceState=n},{}],16:[function(e,t,r){"use strict";/*
  * Mbed Cloud JavaScript SDK
  * Copyright Arm Limited 2017
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  Object.defineProperty(r,"__esModule",{value:!0});var n=e("./campaignDeviceState"),i=function(){function e(){}return e.map=function(e){return new n.CampaignDeviceState({id:e.id,deviceId:e.device_id,campaignId:e.campaign,state:e.deployment_state,name:e.name,description:e.description,createdAt:e.created_at,updatedAt:e.updated_at,mechanism:e.mechanism,mechanismUrl:e.mechanism_url})},e}();r.CampaignDeviceStateAdapter=i},{"./campaignDeviceState":15}],17:[function(e,t,r){"use strict";/*
  * Mbed Cloud JavaScript SDK
  * Copyright Arm Limited 2017
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  Object.defineProperty(r,"__esModule",{value:!0});var n=e("../../common/functions"),i=function(){function e(e,t){this._api=t;for(var r in e)e.hasOwnProperty(r)&&(this[r]=e[r])}return e.prototype.delete=function(e){var t=this;return n.asyncStyle(function(e){t._api.deleteFirmwareImage(t.id,e)},e)},e}();r.FirmwareImage=i},{"../../common/functions":5}],18:[function(e,t,r){"use strict";/*
  * Mbed Cloud JavaScript SDK
  * Copyright Arm Limited 2017
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  Object.defineProperty(r,"__esModule",{value:!0});var n=e("./firmwareImage"),i=function(){function e(){}return e.map=function(e,t){return new n.FirmwareImage({createdAt:e.created_at,url:e.datafile,datafileChecksum:e.datafile_checksum,datafileSize:e.datafile_size,description:e.description,id:e.id,name:e.name,updatedAt:e.updated_at},t)},e}();r.FirmwareImageAdapter=i},{"./firmwareImage":17}],19:[function(e,t,r){"use strict";/*
  * Mbed Cloud JavaScript SDK
  * Copyright Arm Limited 2017
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  Object.defineProperty(r,"__esModule",{value:!0});var n=e("../../common/functions"),i=function(){function e(e,t){this._api=t;for(var r in e)e.hasOwnProperty(r)&&(this[r]=e[r])}return e.prototype.delete=function(e){var t=this;return n.asyncStyle(function(e){t._api.deleteFirmwareManifest(t.id,e)},e)},e}();r.FirmwareManifest=i},{"../../common/functions":5}],20:[function(e,t,r){"use strict";/*
  * Mbed Cloud JavaScript SDK
  * Copyright Arm Limited 2017
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  Object.defineProperty(r,"__esModule",{value:!0});var n=e("./firmwareManifest"),i=function(){function e(){}return e.map=function(e,t){return new n.FirmwareManifest({createdAt:e.created_at,url:e.datafile,datafileSize:e.datafile_size,description:e.description,deviceClass:e.device_class,id:e.id,name:e.name,timestamp:e.timestamp,updatedAt:e.updated_at},t)},e}();r.FirmwareManifestAdapter=i},{"./firmwareManifest":19}],21:[function(e,t,r){"use strict";/*
  * Mbed Cloud JavaScript SDK
  * Copyright Arm Limited 2017
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  Object.defineProperty(r,"__esModule",{value:!0});var n=e("../common/functions"),i=e("../common/listResponse"),o=e("./models/firmwareImageAdapter"),a=e("./models/firmwareManifestAdapter"),s=e("./models/campaignAdapter"),u=e("./models/campaignDeviceStateAdapter"),p=e("./endpoints"),c=e("./filters"),d=function(){function e(e){this._endpoints=new p.Endpoints(e)}return e.prototype.listFirmwareImages=function(e,t){var r=this;return e=e||{},"function"==typeof e&&(t=e,e={}),n.apiWrapper(function(t){var i=e,o=i.limit,a=i.order,s=i.after,u=i.include,p=i.filter;r._endpoints.update.firmwareImageList(o,a,s,n.encodeFilter(p,c.Filters.EMPTY_FILTER_MAP),n.encodeInclude(u),t)},function(e,t){var n;e.data&&e.data.length&&(n=e.data.map(function(e){return o.FirmwareImageAdapter.map(e,r)})),t(null,new i.ListResponse(e,n))},t)},e.prototype.getFirmwareImage=function(e,t){var r=this;return n.apiWrapper(function(t){r._endpoints.update.firmwareImageRetrieve(e,t)},function(e,t){t(null,o.FirmwareImageAdapter.map(e,r))},t)},e.prototype.addFirmwareImage=function(e,t){var r=this;return n.apiWrapper(function(t){r._endpoints.update.firmwareImageCreate(e.dataFile,e.name,e.description,t)},function(e,t){t(null,o.FirmwareImageAdapter.map(e,r))},t)},e.prototype.deleteFirmwareImage=function(e,t){var r=this;return n.apiWrapper(function(t){r._endpoints.update.firmwareImageDestroy(e,t)},function(e,t){t(null,e)},t)},e.prototype.listFirmwareManifests=function(e,t){var r=this;return e=e||{},"function"==typeof e&&(t=e,e={}),n.apiWrapper(function(t){var i=e,o=i.limit,a=i.order,s=i.after,u=i.include,p=i.filter;r._endpoints.update.firmwareManifestList(o,a,s,n.encodeFilter(p,c.Filters.EMPTY_FILTER_MAP),n.encodeInclude(u),t)},function(e,t){var n;e.data&&e.data.length&&(n=e.data.map(function(e){return a.FirmwareManifestAdapter.map(e,r)})),t(null,new i.ListResponse(e,n))},t)},e.prototype.getFirmwareManifest=function(e,t){var r=this;return n.apiWrapper(function(t){r._endpoints.update.firmwareManifestRetrieve(e,t)},function(e,t){t(null,a.FirmwareManifestAdapter.map(e,r))},t)},e.prototype.addFirmwareManifest=function(e,t){var r=this;return n.apiWrapper(function(t){r._endpoints.update.firmwareManifestCreate(e.dataFile,e.name,e.description,null,t)},function(e,t){t(null,a.FirmwareManifestAdapter.map(e,r))},t)},e.prototype.deleteFirmwareManifest=function(e,t){var r=this;return n.apiWrapper(function(t){r._endpoints.update.firmwareManifestDestroy(e,t)},function(e,t){t(null,e)},t)},e.prototype.listCampaigns=function(e,t){var r=this;return e=e||{},"function"==typeof e&&(t=e,e={}),n.apiWrapper(function(t){var i=e,o=i.limit,a=i.order,s=i.after,u=i.include,p=i.filter;r._endpoints.update.updateCampaignList(o,a,s,n.encodeFilter(p,c.Filters.CAMPAIGN_FILTER_MAP),n.encodeInclude(u),t)},function(e,t){var n;e.data&&e.data.length&&(n=e.data.map(function(e){return s.CampaignAdapter.map(e,r)})),t(null,new i.ListResponse(e,n))},t)},e.prototype.getCampaign=function(e,t){var r=this;return n.apiWrapper(function(t){r._endpoints.update.updateCampaignRetrieve(e,t)},function(e,t){t(null,s.CampaignAdapter.map(e,r))},t)},e.prototype.addCampaign=function(e,t){var r=this;return n.apiWrapper(function(t){r._endpoints.update.updateCampaignCreate(s.CampaignAdapter.addMap(e),t)},function(e,t){t(null,s.CampaignAdapter.map(e,r))},t)},e.prototype.updateCampaign=function(e,t){var r=this;return n.apiWrapper(function(t){r._endpoints.update.updateCampaignUpdate(e.id,s.CampaignAdapter.updateMap(e),t)},function(e,t){t(null,s.CampaignAdapter.map(e,r))},t)},e.prototype.deleteCampaign=function(e,t){var r=this;return n.apiWrapper(function(t){r._endpoints.update.updateCampaignDestroy(e,t)},function(e,t){t(null,e)},t)},e.prototype.startCampaign=function(e,t){var r=this;return n.apiWrapper(function(t){r.updateCampaign({id:e,state:"scheduled"},t)},function(e,t){t(null,e)},t)},e.prototype.stopCampaign=function(e,t){var r=this;return n.apiWrapper(function(t){r.updateCampaign({id:e,state:"draft"},t)},function(e,t){t(null,e)},t)},e.prototype.listCampaignDeviceStates=function(e,t,r){var o=this;return t=t||{},"function"==typeof t&&(r=t,t={}),n.apiWrapper(function(r){var i=t.limit,a=t.order,s=t.after,u=t.include;o._endpoints.update.updateCampaignMetadataList(e,i,a,s,n.encodeInclude(u),r)},function(e,t){var r;e.data&&e.data.length&&(r=e.data.map(function(e){return u.CampaignDeviceStateAdapter.map(e)})),t(null,new i.ListResponse(e,r))},r)},e.prototype.getLastApiMetadata=function(e){var t=this;return n.asyncStyle(function(e){e(null,t._endpoints.getLastMeta())},e)},e}();r.UpdateApi=d},{"../common/functions":5,"../common/listResponse":6,"./endpoints":10,"./filters":11,"./models/campaignAdapter":14,"./models/campaignDeviceStateAdapter":16,"./models/firmwareImageAdapter":18,"./models/firmwareManifestAdapter":20}],22:[function(e,t,r){},{}],23:[function(e,t,r){function n(e){if(e)return i(e)}function i(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}void 0!==t&&(t.exports=n),n.prototype.on=n.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},n.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var n,i=0;i<r.length;i++)if((n=r[i])===t||n.fn===t){r.splice(i,1);break}return this},n.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),r=this._callbacks["$"+e];if(r){r=r.slice(0);for(var n=0,i=r.length;n<i;++n)r[n].apply(this,t)}return this},n.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},n.prototype.hasListeners=function(e){return!!this.listeners(e).length}},{}],24:[function(e,t,r){function n(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function o(e){if(d===setTimeout)return setTimeout(e,0);if((d===n||!d)&&setTimeout)return d=setTimeout,setTimeout(e,0);try{return d(e,0)}catch(t){try{return d.call(null,e,0)}catch(t){return d.call(this,e,0)}}}function a(e){if(f===clearTimeout)return clearTimeout(e);if((f===i||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(e);try{return f(e)}catch(t){try{return f.call(null,e)}catch(t){return f.call(this,e)}}}function s(){y&&m&&(y=!1,m.length?h=m.concat(h):v=-1,h.length&&u())}function u(){if(!y){var e=o(s);y=!0;for(var t=h.length;t;){for(m=h,h=[];++v<t;)m&&m[v].run();v=-1,t=h.length}m=null,y=!1,a(e)}}function p(e,t){this.fun=e,this.array=t}function c(){}var d,f,l=t.exports={};!function(){try{d="function"==typeof setTimeout?setTimeout:n}catch(e){d=n}try{f="function"==typeof clearTimeout?clearTimeout:i}catch(e){f=i}}();var m,h=[],y=!1,v=-1;l.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];h.push(new p(e,t)),1!==h.length||y||o(u)},p.prototype.run=function(){this.fun.apply(null,this.array)},l.title="browser",l.browser=!0,l.env={},l.argv=[],l.version="",l.versions={},l.on=c,l.addListener=c,l.once=c,l.off=c,l.removeListener=c,l.removeAllListeners=c,l.emit=c,l.prependListener=c,l.prependOnceListener=c,l.listeners=function(e){return[]},l.binding=function(e){throw new Error("process.binding is not supported")},l.cwd=function(){return"/"},l.chdir=function(e){throw new Error("process.chdir is not supported")},l.umask=function(){return 0}},{}],25:[function(e,t,r){function n(){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(e){n.prototype[e]=function(){return this._defaults.push({fn:e,arguments:arguments}),this}}),n.prototype._setDefaults=function(e){this._defaults.forEach(function(t){e[t.fn].apply(e,t.arguments)})},t.exports=n},{}],26:[function(e,t,r){function n(){}function i(e){if(!h(e))return e;var t=[];for(var r in e)o(t,r,e[r]);return t.join("&")}function o(e,t,r){if(null!=r)if(Array.isArray(r))r.forEach(function(r){o(e,t,r)});else if(h(r))for(var n in r)o(e,t+"["+n+"]",r[n]);else e.push(encodeURIComponent(t)+"="+encodeURIComponent(r));else null===r&&e.push(encodeURIComponent(t))}function a(e){for(var t,r,n={},i=e.split("&"),o=0,a=i.length;o<a;++o)t=i[o],r=t.indexOf("="),-1==r?n[decodeURIComponent(t)]="":n[decodeURIComponent(t.slice(0,r))]=decodeURIComponent(t.slice(r+1));return n}function s(e){for(var t,r,n,i,o=e.split(/\r?\n/),a={},s=0,u=o.length;s<u;++s)r=o[s],-1!==(t=r.indexOf(":"))&&(n=r.slice(0,t).toLowerCase(),i=g(r.slice(t+1)),a[n]=i);return a}function u(e){return/[\/+]json($|[^-\w])/.test(e)}function p(e){this.req=e,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 t=this.xhr.status;1223===t&&(t=204),this._setStatusProperties(t),this.header=this.headers=s(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this._setHeaderProperties(this.header),null===this.text&&e._responseType?this.body=this.xhr.response:this.body="HEAD"!=this.req.method?this._parseBody(this.text?this.text:this.xhr.response):null}function c(e,t){var r=this;this._query=this._query||[],this.method=e,this.url=t,this.header={},this._header={},this.on("end",function(){var e=null,t=null;try{t=new p(r)}catch(t){return e=new Error("Parser is unable to parse the response"),e.parse=!0,e.original=t,r.xhr?(e.rawResponse=void 0===r.xhr.responseType?r.xhr.responseText:r.xhr.response,e.status=r.xhr.status?r.xhr.status:null,e.statusCode=e.status):(e.rawResponse=null,e.status=null),r.callback(e)}r.emit("response",t);var n;try{r._isResponseOK(t)||(n=new Error(t.statusText||"Unsuccessful HTTP response"))}catch(e){n=e}n?(n.original=e,n.response=t,n.status=t.status,r.callback(n,t)):r.callback(null,t)})}function d(e,t,r){var n=_("DELETE",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n}var f;"undefined"!=typeof window?f=window:"undefined"!=typeof self?f=self:(console.warn("Using browser-only version of superagent in non-browser environment"),f=this);var l=e("component-emitter"),m=e("./request-base"),h=e("./is-object"),y=e("./response-base"),v=e("./agent-base"),_=r=t.exports=function(e,t){return"function"==typeof t?new r.Request("GET",e).end(t):1==arguments.length?new r.Request("GET",e):new r.Request(e,t)};r.Request=c,_.getXHR=function(){if(!(!f.XMLHttpRequest||f.location&&"file:"==f.location.protocol&&f.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 g="".trim?function(e){return e.trim()}:function(e){return e.replace(/(^\s*|\s*$)/g,"")};_.serializeObject=i,_.parseString=a,_.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"},_.serialize={"application/x-www-form-urlencoded":i,"application/json":JSON.stringify},_.parse={"application/x-www-form-urlencoded":a,"application/json":JSON.parse},y(p.prototype),p.prototype._parseBody=function(e){var t=_.parse[this.type];return this.req._parser?this.req._parser(this,e):(!t&&u(this.type)&&(t=_.parse["application/json"]),t&&e&&(e.length||e instanceof Object)?t(e):null)},p.prototype.toError=function(){var e=this.req,t=e.method,r=e.url,n="cannot "+t+" "+r+" ("+this.status+")",i=new Error(n);return i.status=this.status,i.method=t,i.url=r,i},_.Response=p,l(c.prototype),m(c.prototype),c.prototype.type=function(e){return this.set("Content-Type",_.types[e]||e),this},c.prototype.accept=function(e){return this.set("Accept",_.types[e]||e),this},c.prototype.auth=function(e,t,r){1===arguments.length&&(t=""),"object"==typeof t&&null!==t&&(r=t,t=""),r||(r={type:"function"==typeof btoa?"basic":"auto"});var n=function(e){if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(e,t,r,n)},c.prototype.query=function(e){return"string"!=typeof e&&(e=i(e)),e&&this._query.push(e),this},c.prototype.attach=function(e,t,r){if(t){if(this._data)throw Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,r||t.name)}return this},c.prototype._getFormData=function(){return this._formData||(this._formData=new f.FormData),this._formData},c.prototype.callback=function(e,t){if(this._shouldRetry(e,t))return this._retry();var r=this._callback;this.clearTimeout(),e&&(this._maxRetries&&(e.retries=this._retries-1),this.emit("error",e)),r(e,t)},c.prototype.crossDomainError=function(){var e=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.");e.crossDomain=!0,e.status=this.status,e.method=this.method,e.url=this.url,this.callback(e)},c.prototype.buffer=c.prototype.ca=c.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},c.prototype.pipe=c.prototype.write=function(){throw Error("Streaming is not supported in browser version of superagent")},c.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},c.prototype.end=function(e){return this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||n,this._finalizeQueryString(),this._end()},c.prototype._end=function(){var e=this,t=this.xhr=_.getXHR(),r=this._formData||this._data;this._setTimeouts(),t.onreadystatechange=function(){var r=t.readyState;if(r>=2&&e._responseTimeoutTimer&&clearTimeout(e._responseTimeoutTimer),4==r){var n;try{n=t.status}catch(e){n=0}if(!n){if(e.timedout||e._aborted)return;return e.crossDomainError()}e.emit("end")}};var n=function(t,r){r.total>0&&(r.percent=r.loaded/r.total*100),r.direction=t,e.emit("progress",r)};if(this.hasListeners("progress"))try{t.onprogress=n.bind(null,"download"),t.upload&&(t.upload.onprogress=n.bind(null,"upload"))}catch(e){}try{this.username&&this.password?t.open(this.method,this.url,!0,this.username,this.password):t.open(this.method,this.url,!0)}catch(e){return this.callback(e)}if(this._withCredentials&&(t.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof r&&!this._isHost(r)){var i=this._header["content-type"],o=this._serializer||_.serialize[i?i.split(";")[0]:""];!o&&u(i)&&(o=_.serialize["application/json"]),o&&(r=o(r))}for(var a in this.header)null!=this.header[a]&&this.header.hasOwnProperty(a)&&t.setRequestHeader(a,this.header[a]);return this._responseType&&(t.responseType=this._responseType),this.emit("request",this),t.send(void 0!==r?r:null),this},_.agent=function(){return new v},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(e){v.prototype[e.toLowerCase()]=function(t,r){var n=new _.Request(e,t);return this._setDefaults(n),r&&n.end(r),n}}),v.prototype.del=v.prototype.delete,_.get=function(e,t,r){var n=_("GET",e);return"function"==typeof t&&(r=t,t=null),t&&n.query(t),r&&n.end(r),n},_.head=function(e,t,r){var n=_("HEAD",e);return"function"==typeof t&&(r=t,t=null),t&&n.query(t),r&&n.end(r),n},_.options=function(e,t,r){var n=_("OPTIONS",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},_.del=d,_.delete=d,_.patch=function(e,t,r){var n=_("PATCH",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},_.post=function(e,t,r){var n=_("POST",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n},_.put=function(e,t,r){var n=_("PUT",e);return"function"==typeof t&&(r=t,t=null),t&&n.send(t),r&&n.end(r),n}},{"./agent-base":25,"./is-object":27,"./request-base":28,"./response-base":29,"component-emitter":23}],27:[function(e,t,r){"use strict";function n(e){return null!==e&&"object"==typeof e}t.exports=n},{}],28:[function(e,t,r){"use strict";function n(e){if(e)return i(e)}function i(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}var o=e("./is-object");t.exports=n,n.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this},n.prototype.parse=function(e){return this._parser=e,this},n.prototype.responseType=function(e){return this._responseType=e,this},n.prototype.serialize=function(e){return this._serializer=e,this},n.prototype.timeout=function(e){if(!e||"object"!=typeof e)return this._timeout=e,this._responseTimeout=0,this;for(var t in e)switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;default:console.warn("Unknown timeout option",t)}return this},n.prototype.retry=function(e,t){return 0!==arguments.length&&!0!==e||(e=1),e<=0&&(e=0),this._maxRetries=e,this._retries=0,this._retryCallback=t,this};var a=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];n.prototype._shouldRetry=function(e,t){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(e,t);if(!0===r)return!0;if(!1===r)return!1}catch(e){console.error(e)}if(t&&t.status&&t.status>=500&&501!=t.status)return!0;if(e){if(e.code&&~a.indexOf(e.code))return!0;if(e.timeout&&"ECONNABORTED"==e.code)return!0;if(e.crossDomain)return!0}return!1},n.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},n.prototype.then=function(e,t){if(!this._fullfilledPromise){var r=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(e,t){r.end(function(r,n){r?t(r):e(n)})})}return this._fullfilledPromise.then(e,t)},n.prototype.catch=function(e){return this.then(void 0,e)},n.prototype.use=function(e){return e(this),this},n.prototype.ok=function(e){if("function"!=typeof e)throw Error("Callback required");return this._okCallback=e,this},n.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):e.status>=200&&e.status<300)},n.prototype.get=function(e){return this._header[e.toLowerCase()]},n.prototype.getHeader=n.prototype.get,n.prototype.set=function(e,t){if(o(e)){for(var r in e)this.set(r,e[r]);return this}return this._header[e.toLowerCase()]=t,this.header[e]=t,this},n.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},n.prototype.field=function(e,t){if(null===e||void 0===e)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()"),o(e)){for(var r in e)this.field(r,e[r]);return this}if(Array.isArray(t)){for(var n in t)this.field(e,t[n]);return this}if(null===t||void 0===t)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof t&&(t=""+t),this._getFormData().append(e,t),this},n.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)},n.prototype._auth=function(e,t,r,n){switch(r.type){case"basic":this.set("Authorization","Basic "+n(e+":"+t));break;case"auto":this.username=e,this.password=t;break;case"bearer":this.set("Authorization","Bearer "+e)}return this},n.prototype.withCredentials=function(e){return void 0==e&&(e=!0),this._withCredentials=e,this},n.prototype.redirects=function(e){return this._maxRedirects=e,this},n.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw TypeError("Invalid argument");return this._maxResponseSize=e,this},n.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},n.prototype.send=function(e){var t=o(e),r=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()"),t&&!this._data)Array.isArray(e)?this._data=[]:this._isHost(e)||(this._data={});else if(e&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(t&&o(this._data))for(var n in e)this._data[n]=e[n];else"string"==typeof e?(r||this.type("form"),r=this._header["content-type"],this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+e:e:(this._data||"")+e):this._data=e;return!t||this._isHost(e)?this:(r||this.type("json"),this)},n.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},n.prototype._finalizeQueryString=function(){var e=this._query.join("&");if(e&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+e),this._query.length=0,this._sort){var t=this.url.indexOf("?");if(t>=0){var r=this.url.substring(t+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.substring(0,t)+"?"+r.join("&")}}},n.prototype._appendQueryString=function(){console.trace("Unsupported")},n.prototype._timeoutError=function(e,t,r){if(!this._aborted){var n=new Error(e+t+"ms exceeded");n.timeout=t,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.abort(),this.callback(n)}},n.prototype._setTimeouts=function(){var e=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){e._timeoutError("Timeout of ",e._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")},this._responseTimeout))}},{"./is-object":27}],29:[function(e,t,r){"use strict";function n(e){if(e)return i(e)}function i(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}var o=e("./utils");t.exports=n,n.prototype.get=function(e){return this.header[e.toLowerCase()]},n.prototype._setHeaderProperties=function(e){var t=e["content-type"]||"";this.type=o.type(t);var r=o.params(t);for(var n in r)this[n]=r[n];this.links={};try{e.link&&(this.links=o.parseLinks(e.link))}catch(e){}},n.prototype._setStatusProperties=function(e){var t=e/100|0;this.status=this.statusCode=e,this.statusType=t,this.info=1==t,this.ok=2==t,this.redirect=3==t,this.clientError=4==t,this.serverError=5==t,this.error=(4==t||5==t)&&this.toError(),this.accepted=202==e,this.noContent=204==e,this.badRequest=400==e,this.unauthorized=401==e,this.notAcceptable=406==e,this.forbidden=403==e,this.notFound=404==e}},{"./utils":30}],30:[function(e,t,r){"use strict";r.type=function(e){return e.split(/ *; */).shift()},r.params=function(e){return e.split(/ *; */).reduce(function(e,t){var r=t.split(/ *= */),n=r.shift(),i=r.shift();return n&&i&&(e[n]=i),e},{})},r.parseLinks=function(e){return e.split(/ *, */).reduce(function(e,t){var r=t.split(/ *; */),n=r[0].slice(1,-1);return e[r[1].split(/ *= */)[1].slice(1,-1)]=n,e},{})},r.cleanHeader=function(e,t){return delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e}},{}],31:[function(e,t,r){t.exports={name:"mbed-cloud-sdk",version:"1.2.8",description:"Mbed Cloud SDK for JavaScript",homepage:"https://www.mbed.com",author:"Rob Moran <rob.moran@arm.com>",license:"Apache-2.0",types:"./types/index.d.ts",main:"./index.js",browser:{"./index.js":"./bundles/index.min.js"},repository:{type:"git",url:"git://github.com/ARMmbed/mbed-cloud-sdk-javascript.git"},keywords:["Mbed","SDK"],engines:{node:">=4.8.0"},scripts:{start:"node examples/proxy/server.js",gulp:"gulp",tpip:"nlf --csv --no-dev --reach 1 > tpip.csv",test:"intern","build-test-server":"node tests/build.js && tsc -p tests && cp intern.json ./tests/server/ && cp package.json ./tests/server/","start-test-server":"node tests/server/tests/codeCoverage.js"},devDependencies:{"@types/express":"^4.0.37","@types/memory-cache":"^0.2.0","@types/node":"^7.0.4","@types/superagent":"^2.0.36","body-parser":"^1.18.2",browserify:"^14.0.0",del:"^2.2.2",express:"^4.14.1",gulp:"^3.9.1","gulp-buffer":"0.0.2","gulp-sourcemaps":"^2.4.0","gulp-tap":"^0.1.3","gulp-tslint":"^8.1.2","gulp-typedoc":"^2.0.2","gulp-typescript":"^3.1.6","gulp-uglify":"^2.0.1",intern:"4.1.2","memory-cache":"^0.2.0",merge2:"^1.0.3",nlf:"^2.0.0",nyc:"^11.3.0",rimraf:"2.6.2",tslint:"5.8.0","tslint-eslint-rules":"^4.1.1",typedoc:"^0.7.1",typescript:"~2.6.2","typescript-logging":"^0.5.0","source-map-merger":"~0.2.0"},dependencies:{superagent:"^3.4.1"}}},{}]},{},[12])(12)});
  //# sourceMappingURL=update.min.js.map
  