diff --git a/bundle/sipgate-io.js b/bundle/sipgate-io.js new file mode 100644 index 0000000..1d62f0f --- /dev/null +++ b/bundle/sipgate-io.js @@ -0,0 +1,262 @@ +require=(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i({initiate(r){return __awaiter(this,void 0,void 0,function*(){const a=validateCallData_1.validateCallData(r);if(!a.isValid)throw new Error(a.cause);const t={callee:"to"in r?r.to:r.callee,caller:"from"in r?r.from:r.caller,callerId:r.callerId,deviceId:r.deviceId};return e.post("/sessions/calls",t).then(e=>e.data).catch(e=>Promise.reject(handleError(e)))})}}));const handleError=e=>e.response&&400===e.response.status?new Error(ErrorMessage_1.ErrorMessage.CALL_BAD_REQUEST):e.response&&402===e.response.status?new Error(ErrorMessage_1.ErrorMessage.CALL_INSUFFICIENT_FUNDS):e.response&&403===e.response.status?new Error(ErrorMessage_1.ErrorMessage.CALL_INVALID_EXTENSION):handleError_1.default(e); + +},{"../core/errors/handleError":10,"./errors/ErrorMessage":2,"./validators/validateCallData":4}],2:[function(require,module,exports){ +"use strict";var ErrorMessage;Object.defineProperty(exports,"__esModule",{value:!0}),function(e){e.CALL_INVALID_EXTENSION="Cannot access extension - not found or forbidden",e.CALL_INSUFFICIENT_FUNDS="Insufficient funds",e.CALL_BAD_REQUEST="Invalid Call object"}(ErrorMessage=exports.ErrorMessage||(exports.ErrorMessage={})); + +},{}],3:[function(require,module,exports){ +"use strict";function __export(e){for(var r in e)exports.hasOwnProperty(r)||(exports[r]=e[r])}Object.defineProperty(exports,"__esModule",{value:!0}),__export(require("./call")); + +},{"./call":1}],4:[function(require,module,exports){ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const errors_1=require("../../core/errors"),validateExtension_1=require("../../core/validator/validateExtension"),validatePhoneNumber_1=require("../../core/validator/validatePhoneNumber"),validateCallData=e=>{const a=validatePhoneNumber_1.validatePhoneNumber("to"in e?e.to:e.callee);if(!a.isValid)return{isValid:!1,cause:a.cause};const i=validatePhoneNumber_1.validatePhoneNumber("from"in e?e.from:e.caller),r=validateExtension_1.validateExtension("from"in e?e.from:e.caller,[validateExtension_1.ExtensionType.MOBILE,validateExtension_1.ExtensionType.PERSON,validateExtension_1.ExtensionType.EXTERNAL,validateExtension_1.ExtensionType.REGISTER]);if(!i.isValid&&!r.isValid)return{isValid:!1,cause:errors_1.ErrorMessage.VALIDATOR_INVALID_CALLER};if(e.deviceId){if(!validateExtension_1.validateExtension(e.deviceId,[validateExtension_1.ExtensionType.MOBILE,validateExtension_1.ExtensionType.PERSON,validateExtension_1.ExtensionType.EXTERNAL,validateExtension_1.ExtensionType.REGISTER]).isValid)return{isValid:!1,cause:errors_1.ErrorMessage.VALIDATOR_INVALID_EXTENSION}}else if(!r.isValid)return{isValid:!1,cause:errors_1.ErrorMessage.VALIDATOR_INVALID_DEVICE_ID};if(e.callerId){if(!validatePhoneNumber_1.validatePhoneNumber(e.callerId).isValid)return{isValid:!1,cause:errors_1.ErrorMessage.VALIDATOR_INVALID_CALLER_ID}}return{isValid:!0}};exports.validateCallData=validateCallData; + +},{"../../core/errors":11,"../../core/validator/validateExtension":20,"../../core/validator/validatePhoneNumber":23}],5:[function(require,module,exports){ +"use strict";var __awaiter=this&&this.__awaiter||function(e,r,t,s){return new(t||(t=Promise))(function(n,a){function o(e){try{d(s.next(e))}catch(e){a(e)}}function i(e){try{d(s.throw(e))}catch(e){a(e)}}function d(e){var r;e.done?n(e.value):(r=e.value,r instanceof t?r:new t(function(e){e(r)})).then(o,i)}d((s=s.apply(e,r||[])).next())})},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const ErrorMessage_1=require("./errors/ErrorMessage"),json2csv_1=require("json2csv"),vCardHelper_1=require("./helpers/vCardHelper"),btoa_1=__importDefault(require("btoa")),handleError_1=__importDefault(require("../core/errors/handleError"));exports.createContactsModule=(e=>({importFromCsvString(r){return __awaiter(this,void 0,void 0,function*(){const t=projectCsvString(r),s={base64Content:btoa_1.default(t)};yield e.post("/contacts/import/csv",s).catch(e=>Promise.reject(handleError(e)))})},import(r,t){return __awaiter(this,void 0,void 0,function*(){const{firstname:s,lastname:n,organization:a,address:o,email:i,phone:d}=r;if(""===s&&""===n)throw new Error(ErrorMessage_1.ErrorMessage.CONTACTS_MISSING_NAME_ATTRIBUTE);const c={name:`${s} ${n}`,family:n,given:s,organization:a?[a]:[],picture:null,scope:t,addresses:o?[o]:[],emails:i?[i]:[],numbers:d?[d]:[]};yield e.post("/contacts",c).catch(e=>Promise.reject(handleError(e)))})},importVCardString(r,t){return __awaiter(this,void 0,void 0,function*(){const s=vCardHelper_1.parseVCard(r),n=[];s.address&&n.push(s.address);const a=[];s.email&&a.push({email:s.email,type:[]});const o={name:`${s.firstname} ${s.lastname}`,family:s.lastname,given:s.firstname,organization:[s.organization],picture:null,scope:t,addresses:n,emails:a,numbers:[{number:s.phoneNumber,type:[]}]};yield e.post("/contacts",o).catch(e=>Promise.reject(handleError(e)))})},exportAsCsv(r){return __awaiter(this,void 0,void 0,function*(){const t=yield e.get("contacts");t.data.items=t.data.items.filter(e=>e.scope===r);const s={fields:["id","name","emails","numbers","addresses","organizations"]},n=t.data.items.map(e=>({id:e.id,name:e.name,emails:e.emails.map(e=>e.email),numbers:e.numbers.map(e=>e.number),addresses:e.addresses,organizations:e.organization}));try{return new json2csv_1.Parser(s).parse(n)}catch(e){throw Error(e)}})},exportAsSingleVCard(e){return __awaiter(this,void 0,void 0,function*(){return(yield this.exportAsVCards(e)).join("\r\n")})},exportAsVCards(r){return __awaiter(this,void 0,void 0,function*(){const t=yield e.get("contacts");t.data.items=t.data.items.filter(e=>e.scope===r);const s=t.data.items.map(e=>({firstname:e.name,lastname:"",organizations:e.organization,phoneNumbers:e.numbers,emails:e.emails,addresses:e.addresses.map(e=>Object.assign(Object.assign({},e),{type:["home"]}))}));return vCardHelper_1.createVCards(s)})}}));const findColumnIndex=(e,r)=>{const t=e.indexOf(r);if(t<0)throw new Error(`${ErrorMessage_1.ErrorMessage.CONTACTS_MISSING_HEADER_FIELD}: ${r}`);return t},projectCsvString=e=>{const r=e.split(/\n|\r\n/).filter(e=>""!==e);if(r.length<1)throw new Error(ErrorMessage_1.ErrorMessage.CONTACTS_INVALID_CSV);r.length<2&&console.log("WARNING: no lines to import");const t=r[0].split(",").map(e=>e.toLowerCase()),s=findColumnIndex(t,"firstname"),n=findColumnIndex(t,"lastname"),a=findColumnIndex(t,"number");return r.shift(),["firstname,lastname,number",...r.map(e=>e.split(",")).map((e,r)=>{if(e.length!==t.length)throw Error(ErrorMessage_1.ErrorMessage.CONTACTS_MISSING_VALUES);const o=e[s],i=e[n],d=e[a];return o&&i&&d?[o,i,d].join(","):(console.log(`WARNING: record at position ${r+1} is empty`),"")})].join("\n")},handleError=e=>e.response&&500===e.response.status?Error(`${ErrorMessage_1.ErrorMessage.CONTACTS_INVALID_CSV}`):handleError_1.default(e); + +},{"../core/errors/handleError":10,"./errors/ErrorMessage":6,"./helpers/vCardHelper":7,"btoa":65,"json2csv":76}],6:[function(require,module,exports){ +"use strict";var ErrorMessage;Object.defineProperty(exports,"__esModule",{value:!0}),function(e){e.CONTACTS_INVALID_CSV="Invalid CSV string",e.CONTACTS_MISSING_HEADER_FIELD="Missing header field in CSV",e.CONTACTS_MISSING_VALUES="Missing values in CSV",e.CONTACTS_VCARD_MISSING_BEGIN="vCard does not contain a valid BEGIN tag",e.CONTACTS_VCARD_MISSING_END="vCard does not contain a valid END tag",e.CONTACTS_INVALID_VCARD_VERSION="Invalid VCard Version given",e.CONTACTS_MISSING_NAME_ATTRIBUTE="Names not given",e.CONTACTS_MISSING_TEL_ATTRIBUTE="No phone number given",e.CONTACTS_INVALID_AMOUNT_OF_NAMES="Missing Name Fields",e.CONTACTS_INVALID_AMOUNT_OF_PHONE_NUMBERS="Only one phone number is allowed",e.CONTACTS_INVALID_AMOUNT_OF_ADDRESSES="Only one address is allowed",e.CONTACTS_INVALID_AMOUNT_OF_ADDRESS_VALUES="Address Fields are invalid",e.CONTACTS_INVALID_AMOUNT_OF_EMAILS="Only one email is allowed"}(ErrorMessage=exports.ErrorMessage||(exports.ErrorMessage={})); + +},{}],7:[function(require,module,exports){ +"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const ErrorMessage_1=require("../errors/ErrorMessage"),vcf_1=__importDefault(require("vcf"));exports.parseVCard=(e=>{let r;try{r=(new vcf_1.default).parse(e)}catch(e){if(e instanceof SyntaxError){if(e.message.includes('Expected "BEGIN:VCARD"'))throw new Error(ErrorMessage_1.ErrorMessage.CONTACTS_VCARD_MISSING_BEGIN);if(e.message.includes('Expected "END:VCARD"'))throw new Error(ErrorMessage_1.ErrorMessage.CONTACTS_VCARD_MISSING_END)}throw new Error(e)}if("4.0"!==r.version)throw new Error(ErrorMessage_1.ErrorMessage.CONTACTS_INVALID_VCARD_VERSION);const t=r.get("n"),s=r.get("tel"),o=r.get("email"),a=r.get("adr"),n=r.get("org");if(void 0===t)throw new Error(ErrorMessage_1.ErrorMessage.CONTACTS_MISSING_NAME_ATTRIBUTE);if(void 0===s)throw new Error(ErrorMessage_1.ErrorMessage.CONTACTS_MISSING_TEL_ATTRIBUTE);const d=t.toString().replace(/(.*)N(.*):/,"").split(";");validateAmountOfNames(d);const[i,_]=d;let E;validateAmountOfPhoneNumbers(s),validateAmountOfAddresses(a),a&&(E=a.toString().replace(/(.*)ADR(.*):/,"").split(";")),validateAtLeastRequiredAddressLength(E),validateAmountOfEmails(o);let l={firstname:_,lastname:i,phoneNumber:s.valueOf().toString(),email:o?o.valueOf().toString():void 0,organization:n.toString().replace(/(.*)ORG(.*):/,"").split(";")};return a&&(l=Object.assign(Object.assign({},l),{address:{poBox:E?E[0]:"",extendedAddress:E?E[1]:"",streetAddress:E?E[2]:"",locality:E?E[3]:"",region:E?E[4]:"",postalCode:E?E[5]:"",country:E?E[6]:""}})),l}),exports.createVCards=(e=>{const r=[];return e.map(e=>{const t=new vcf_1.default;if(t.add("n",`${e.firstname};${e.lastname}`),e.organizations.forEach(e=>{t.add("org",e.join(";"))}),e.phoneNumbers.forEach(e=>{t.add("tel",e.number,{type:e.type})}),void 0!==e.emails&&e.emails.forEach(e=>{t.add("email",e.email,{type:e.type})}),void 0!==e.addresses){const{addresses:r}=e;r.forEach(e=>{t.add("addr",`${e.poBox?e.poBox:""};${e.extendedAddress?e.extendedAddress:""};${e.streetAddress?e.streetAddress:""};${e.locality?e.locality:""};${e.region?e.region:""};${e.postalCode?e.postalCode:""};${e.country?e.country:""}`,{type:e.type})})}r.push(t.toString("4.0"))}),r});const validateAtLeastRequiredAddressLength=e=>{if(e&&e.length<7)throw new Error(ErrorMessage_1.ErrorMessage.CONTACTS_INVALID_AMOUNT_OF_ADDRESS_VALUES)},validateAmountOfAddresses=e=>{if(e&&"object"==typeof e.valueOf())throw new Error(ErrorMessage_1.ErrorMessage.CONTACTS_INVALID_AMOUNT_OF_ADDRESSES)},validateAmountOfEmails=e=>{if(e&&"object"==typeof e.valueOf())throw new Error(ErrorMessage_1.ErrorMessage.CONTACTS_INVALID_AMOUNT_OF_EMAILS)},validateAmountOfPhoneNumbers=e=>{if("object"==typeof e.valueOf())throw new Error(ErrorMessage_1.ErrorMessage.CONTACTS_INVALID_AMOUNT_OF_PHONE_NUMBERS)},validateAmountOfNames=e=>{if(e.length<2)throw new Error(ErrorMessage_1.ErrorMessage.CONTACTS_INVALID_AMOUNT_OF_NAMES)}; + +},{"../errors/ErrorMessage":6,"vcf":80}],8:[function(require,module,exports){ +"use strict";function __export(e){for(var r in e)exports.hasOwnProperty(r)||(exports[r]=e[r])}Object.defineProperty(exports,"__esModule",{value:!0}),__export(require("./contacts")); + +},{"./contacts":5}],9:[function(require,module,exports){ +"use strict";var ErrorMessage;Object.defineProperty(exports,"__esModule",{value:!0}),function(e){e.VALIDATOR_INVALID_EXTENSION="Invalid extension",e.VALIDATOR_INVALID_EMAIL="Invalid email",e.VALIDATOR_INVALID_PASSWORD="Invalid password",e.VALIDATOR_INVALID_PHONE_NUMBER="Invalid phone number (please provide number in E.164 format):",e.VALIDATOR_INVALID_CALLER="Caller is not a valid extension or phone number",e.VALIDATOR_INVALID_CALLER_ID="CallerId is not a valid phone number",e.VALIDATOR_INVALID_DEVICE_ID="DeviceId is required if caller is not a extension",e.VALIDATOR_INVALID_OAUTH_TOKEN="The provided OAuth token is invalid",e.HTTP_401="Unauthorized",e.HTTP_403="Forbidden"}(ErrorMessage=exports.ErrorMessage||(exports.ErrorMessage={})); + +},{}],10:[function(require,module,exports){ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const ErrorMessage_1=require("./ErrorMessage");exports.default=(e=>e.response&&401===e.response.status?new Error(ErrorMessage_1.ErrorMessage.HTTP_401):e.response&&403===e.response.status?new Error(ErrorMessage_1.ErrorMessage.HTTP_403):new Error(e.message)); + +},{"./ErrorMessage":9}],11:[function(require,module,exports){ +"use strict";function __export(r){for(var e in r)exports.hasOwnProperty(e)||(exports[e]=r[e])}Object.defineProperty(exports,"__esModule",{value:!0}),__export(require("./ErrorMessage")),__export(require("./handleError")); + +},{"./ErrorMessage":9,"./handleError":10}],12:[function(require,module,exports){ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getAuthenticatedWebuser=(e=>e.get("authorization/userinfo").then(e=>e.data.sub)); + +},{}],13:[function(require,module,exports){ +"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const detect_browser_1=require("detect-browser"),validator_1=require("../validator"),validateOAuthToken_1=require("../validator/validateOAuthToken"),version_json_1=require("../../version.json"),axios_1=__importDefault(require("axios")),btoa_1=__importDefault(require("btoa"));exports.createHttpClient=(e=>{const t=getAuthHeader(e),r=detect_browser_1.detect(),a=axios_1.default.create({baseURL:"https://api.sipgate.com/v2",headers:{Authorization:t,"X-Sipgate-Client":JSON.stringify(r),"X-Sipgate-Version":version_json_1.version,"Content-Type":"application/json"}});return{delete:(e,t)=>a.delete(e,t),get:(e,t)=>a.get(e,t),patch:(e,t,r)=>a.patch(e,t,r),post:(e,t,r)=>a.post(e,t,r),put:(e,t,r)=>a.put(e,t,r)}});const getAuthHeader=e=>{if("token"in e){const t=validateOAuthToken_1.validateOAuthToken(e.token);if(!t.isValid)throw new Error(t.cause);return`Bearer ${e.token}`}const t=validator_1.validateEmail(e.username);if(!t.isValid)throw new Error(t.cause);const r=validator_1.validatePassword(e.password);if(!r.isValid)throw new Error(r.cause);return`Basic ${btoa_1.default(`${e.username}:${e.password}`)}`}; + +},{"../../version.json":32,"../validator":18,"../validator/validateOAuthToken":21,"axios":38,"btoa":65,"detect-browser":68}],14:[function(require,module,exports){ +"use strict";function __export(e){for(var r in e)exports.hasOwnProperty(r)||(exports[r]=e[r])}Object.defineProperty(exports,"__esModule",{value:!0}),__export(require("./httpClient")); + +},{"./httpClient":13}],15:[function(require,module,exports){ +"use strict";function __export(e){for(var r in e)exports.hasOwnProperty(r)||(exports[r]=e[r])}Object.defineProperty(exports,"__esModule",{value:!0}),__export(require("./errors")),__export(require("./httpClient/httpClient")),__export(require("./sipgateIOClient")); + +},{"./errors":11,"./httpClient/httpClient":13,"./sipgateIOClient":16}],16:[function(require,module,exports){ +"use strict";function __export(e){for(var r in e)exports.hasOwnProperty(r)||(exports[r]=e[r])}Object.defineProperty(exports,"__esModule",{value:!0}),__export(require("./sipgateIOClient")); + +},{"./sipgateIOClient":17}],17:[function(require,module,exports){ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const httpClient_1=require("../httpClient");exports.sipgateIO=(t=>httpClient_1.createHttpClient(t)); + +},{"../httpClient":14}],18:[function(require,module,exports){ +"use strict";function __export(e){for(var r in e)exports.hasOwnProperty(r)||(exports[r]=e[r])}Object.defineProperty(exports,"__esModule",{value:!0}),__export(require("./validateEmail")),__export(require("./validateExtension")),__export(require("./validateOAuthToken")),__export(require("./validatePassword")),__export(require("./validatePhoneNumber")); + +},{"./validateEmail":19,"./validateExtension":20,"./validateOAuthToken":21,"./validatePassword":22,"./validatePhoneNumber":23}],19:[function(require,module,exports){ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const errors_1=require("../errors"),validateEmail=e=>{return new RegExp(/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i).test(e)?{isValid:!0}:{cause:`${errors_1.ErrorMessage.VALIDATOR_INVALID_EMAIL}: ${e}`,isValid:!1}};exports.validateEmail=validateEmail; + +},{"../errors":11}],20:[function(require,module,exports){ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const errors_1=require("../errors");var ExtensionType;!function(e){e.APPLICATION="a",e.CONFERENCE_ROOM="c",e.REGISTER="e",e.FAX="f",e.GROUP="g",e.IVR="h",e.SIM="i",e.SMS="s",e.PERSON="p",e.QUEUE="q",e.CALLTHROUGH="r",e.TRUNKING="t",e.VOICEMAIL="v",e.WEBUSER="w",e.EXTERNAL="x",e.MOBILE="y"}(ExtensionType||(ExtensionType={})),exports.ExtensionType=ExtensionType;const validateExtension=(e,r)=>{for(const s of r){if(new RegExp(`^${s}(0|[1-9][0-9]*)$`).test(e))return{isValid:!0}}return{cause:`${errors_1.ErrorMessage.VALIDATOR_INVALID_EXTENSION}: ${e}`,isValid:!1}};exports.validateExtension=validateExtension; + +},{"../errors":11}],21:[function(require,module,exports){ +"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const errors_1=require("../errors"),atob_1=__importDefault(require("atob"));exports.validateOAuthToken=(e=>isValidToken(e)?{isValid:!0}:{isValid:!1,cause:errors_1.ErrorMessage.VALIDATOR_INVALID_OAUTH_TOKEN});const isValidToken=e=>{try{const r=e.split(".")[1].replace("-","+").replace("_","/");return JSON.parse(atob_1.default(r)),!0}catch(e){return!1}}; + +},{"../errors":11,"atob":37}],22:[function(require,module,exports){ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const errors_1=require("../errors"),validatePassword=e=>{return e.length>0&&!e.includes(" ")?{isValid:!0}:{isValid:!1,cause:errors_1.ErrorMessage.VALIDATOR_INVALID_PASSWORD}};exports.validatePassword=validatePassword; + +},{"../errors":11}],23:[function(require,module,exports){ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const errors_1=require("../errors"),google_libphonenumber_1=require("google-libphonenumber"),validatePhoneNumber=e=>{const r=google_libphonenumber_1.PhoneNumberUtil.getInstance();try{const o=r.parse(e);return r.format(o,google_libphonenumber_1.PhoneNumberFormat.E164),{isValid:!0}}catch(r){return{cause:`${errors_1.ErrorMessage.VALIDATOR_INVALID_PHONE_NUMBER}: ${e}`,isValid:!1}}};exports.validatePhoneNumber=validatePhoneNumber; + +},{"../errors":11,"google-libphonenumber":73}],24:[function(require,module,exports){ +"use strict";var ErrorMessage;Object.defineProperty(exports,"__esModule",{value:!0}),function(e){e.VALIDATOR_INVALID_PDF_MIME_TYPE="Invalid PDF file",e.FAX_NOT_FOUND="Fax was not found",e.FAX_NOT_A_FAX="History item is not a fax"}(ErrorMessage=exports.ErrorMessage||(exports.ErrorMessage={})); + +},{}],25:[function(require,module,exports){ +"use strict";var __awaiter=this&&this.__awaiter||function(e,r,t,n){return new(t||(t=Promise))(function(a,o){function i(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var r;e.done?a(e.value):(r=e.value,r instanceof t?r:new t(function(e){e(r)})).then(i,s)}l((n=n.apply(e,r||[])).next())})},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const ErrorMessage_1=require("./errors/ErrorMessage"),validatePdfFileContent_1=require("./validators/validatePdfFileContent"),handleError_1=__importDefault(require("../core/errors/handleError"));exports.createFaxModule=(e=>({send(r){return __awaiter(this,void 0,void 0,function*(){const t=r,n=validatePdfFileContent_1.validatePdfFileContent(t.fileContent);if(!n.isValid)throw new Error(n.cause);t.filename||(t.filename=generateFilename());const a={base64Content:t.fileContent.toString("base64"),faxlineId:t.faxlineId,filename:t.filename,recipient:"to"in t?t.to:t.recipient};return yield e.post("/sessions/fax",a).then(e=>e.data).catch(e=>Promise.reject(handleError(e)))})},getFaxStatus(r){return __awaiter(this,void 0,void 0,function*(){return e.get(`/history/${r}`).then(({data:e})=>{if(!e.type||"FAX"!==e.type)throw new Error(ErrorMessage_1.ErrorMessage.FAX_NOT_A_FAX);return e.faxStatusType}).catch(e=>Promise.reject(handleError(e)))})}}));const generateFilename=()=>{return`Fax_${(new Date).toJSON().replace(/T/g,"_").replace(/[.:-]/g,"").slice(0,-6)}`},handleError=e=>e.response&&404===e.response.status?new Error(ErrorMessage_1.ErrorMessage.FAX_NOT_FOUND):handleError_1.default(e); + +},{"../core/errors/handleError":10,"./errors/ErrorMessage":24,"./validators/validatePdfFileContent":27}],26:[function(require,module,exports){ +"use strict";function __export(e){for(var r in e)exports.hasOwnProperty(r)||(exports[r]=e[r])}Object.defineProperty(exports,"__esModule",{value:!0}),__export(require("./fax")); + +},{"./fax":25}],27:[function(require,module,exports){ +"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const ErrorMessage_1=require("../errors/ErrorMessage"),file_type_1=__importDefault(require("file-type")),validatePdfFileContent=e=>{const t=file_type_1.default(e);return t&&"application/pdf"===t.mime?{isValid:!0}:{cause:ErrorMessage_1.ErrorMessage.VALIDATOR_INVALID_PDF_MIME_TYPE,isValid:!1}};exports.validatePdfFileContent=validatePdfFileContent; + +},{"../errors/ErrorMessage":24,"file-type":69}],28:[function(require,module,exports){ +"use strict";var ErrorMessage;Object.defineProperty(exports,"__esModule",{value:!0}),function(e){e.SMS_INVALID_MESSAGE="Invalid SMS message",e.SMS_INVALID_EXTENSION="Invalid SMS extension",e.SMS_TIME_MUST_BE_IN_FUTURE="Scheduled time must be in future",e.SMS_TIME_TOO_FAR_IN_FUTURE="Scheduled time should not be further than 30 days in the future",e.SMS_TIME_INVALID="Invalid date format",e.SMS_NO_ASSIGNED_ID="smsId must be assigned",e.SMS_NO_DEFAULT_SENDER_ID="No default SmsId set",e.SMS_NUMBER_NOT_VERIFIED="Number is not verified yet",e.SMS_NUMBER_NOT_REGISTERED="Number is not registered as a sender ID in your account"}(ErrorMessage=exports.ErrorMessage||(exports.ErrorMessage={})); + +},{}],29:[function(require,module,exports){ +"use strict";function __export(e){for(var r in e)exports.hasOwnProperty(r)||(exports[r]=e[r])}Object.defineProperty(exports,"__esModule",{value:!0}),__export(require("./sms")); + +},{"./sms":30}],30:[function(require,module,exports){ +"use strict";var __awaiter=this&&this.__awaiter||function(e,r,t,o){return new(t||(t=Promise))(function(s,i){function n(e){try{d(o.next(e))}catch(e){i(e)}}function a(e){try{d(o.throw(e))}catch(e){i(e)}}function d(e){var r;e.done?s(e.value):(r=e.value,r instanceof t?r:new t(function(e){e(r)})).then(n,a)}d((o=o.apply(e,r||[])).next())})},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const ErrorMessage_1=require("./errors/ErrorMessage"),validator_1=require("../core/validator"),authorizationInfo_1=require("../core/helpers/authorizationInfo"),validateSendAt_1=require("./validators/validateSendAt"),handleError_1=__importDefault(require("../core/errors/handleError"));exports.createSMSModule=(e=>({send(r,t){return __awaiter(this,void 0,void 0,function*(){const o={smsId:"",message:r.message,recipient:"to"in r?r.to:r.recipient};if(t){const e=validateSendAt_1.validateSendAt(t);if(!e.isValid)throw new Error(e.cause);o.sendAt=t.getTime()/1e3}return void 0!==("from"in r?r.from:r.phoneNumber)?yield sendSmsByPhoneNumber(e,r,o):yield sendSmsBySmsId(r,o,e)})}})),exports.sendSms=((e,r)=>__awaiter(void 0,void 0,void 0,function*(){return e.post("/sessions/sms",r).then(()=>{}).catch(e=>Promise.reject(handleError(e)))})),exports.getUserSmsExtension=((e,r)=>__awaiter(void 0,void 0,void 0,function*(){return e.get(`${r}/sms`).then(e=>e.data.items[0].id).catch(e=>Promise.reject(handleError(e)))})),exports.getSmsCallerIds=((e,r,t)=>__awaiter(void 0,void 0,void 0,function*(){return e.get(`${r}/sms/${t}/callerids`).then(e=>e.data.items).catch(e=>Promise.reject(handleError(e)))})),exports.setDefaultSenderId=((e,r,t,o)=>__awaiter(void 0,void 0,void 0,function*(){return e.put(`${r}/sms/${t}/callerids/${o.id}`,{defaultNumber:"true"}).then(()=>{}).catch(e=>Promise.reject(handleError(e)))})),exports.containsPhoneNumber=((e,r)=>{const t=e.find(e=>e.phonenumber===r);return!!t&&t.verified});const handleError=e=>e.response&&403===e.response.status?new Error(ErrorMessage_1.ErrorMessage.SMS_INVALID_EXTENSION):handleError_1.default(e);function sendSmsByPhoneNumber(e,r,t){return __awaiter(this,void 0,void 0,function*(){const o=yield authorizationInfo_1.getAuthenticatedWebuser(e),s=yield exports.getUserSmsExtension(e,o),i=yield exports.getSmsCallerIds(e,o,s),n=i.find(e=>e.phonenumber===("from"in r?r.from:r.phoneNumber));if(void 0===n)throw new Error(ErrorMessage_1.ErrorMessage.SMS_NUMBER_NOT_REGISTERED);if(!n.verified)throw new Error(ErrorMessage_1.ErrorMessage.SMS_NUMBER_NOT_VERIFIED);const a=i.find(e=>e.defaultNumber);if(void 0===a)throw new Error(ErrorMessage_1.ErrorMessage.SMS_NO_DEFAULT_SENDER_ID);return t.smsId=s,yield exports.setDefaultSenderId(e,o,s,n),yield exports.sendSms(e,t).then(()=>__awaiter(this,void 0,void 0,function*(){return yield exports.setDefaultSenderId(e,o,s,a)})).catch(e=>Promise.reject(handleError(e)))})}function sendSmsBySmsId(e,r,t){return __awaiter(this,void 0,void 0,function*(){if(void 0===e.smsId)throw new Error("smsId is undefined");const o=validator_1.validateExtension(e.smsId,[validator_1.ExtensionType.SMS]);if(!o.isValid)throw new Error(o.cause);r.smsId=e.smsId;const s=validator_1.validatePhoneNumber("to"in e?e.to:e.recipient);if(!s.isValid)throw new Error(s.cause);if(""===e.message)throw new Error(ErrorMessage_1.ErrorMessage.SMS_INVALID_MESSAGE);return yield exports.sendSms(t,r).then(()=>{}).catch(e=>Promise.reject(handleError(e)))})} + +},{"../core/errors/handleError":10,"../core/helpers/authorizationInfo":12,"../core/validator":18,"./errors/ErrorMessage":28,"./validators/validateSendAt":31}],31:[function(require,module,exports){ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const ErrorMessage_1=require("../errors/ErrorMessage"),validateSendAt=e=>Number.isNaN(e.getTime())?{cause:ErrorMessage_1.ErrorMessage.SMS_TIME_INVALID,isValid:!1}:e.getTime()Date.now()+2592e6?{cause:ErrorMessage_1.ErrorMessage.SMS_TIME_TOO_FAR_IN_FUTURE,isValid:!1}:{isValid:!0};exports.validateSendAt=validateSendAt; + +},{"../errors/ErrorMessage":28}],32:[function(require,module,exports){ +module.exports={ "version": "1.1.0" } + +},{}],33:[function(require,module,exports){ +"use strict";var ErrorMessage;Object.defineProperty(exports,"__esModule",{value:!0}),function(e){e.VALIDATOR_INVALID_EXTENSION_FOR_WEBHOOKS="Whitelist allows only 'p' and 'g' extensions",e.VALIDATOR_INVALID_WEBHOOK_URL="Invalid webhook URL",e.WEBHOOK_SETTINGS_FEATURE_NOT_BOOKED="sipgateIO is not booked for your account"}(ErrorMessage=exports.ErrorMessage||(exports.ErrorMessage={})); + +},{}],34:[function(require,module,exports){ +"use strict";function __export(e){for(var r in e)exports.hasOwnProperty(r)||(exports[r]=e[r])}Object.defineProperty(exports,"__esModule",{value:!0}),__export(require("./webhookSettings")); + +},{"./webhookSettings":36}],35:[function(require,module,exports){ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const ErrorMessage_1=require("../errors/ErrorMessage"),validateWebhookUrl=e=>{return new RegExp(/^(http|https):\/\//i).test(e)?{isValid:!0}:{cause:`${ErrorMessage_1.ErrorMessage.VALIDATOR_INVALID_WEBHOOK_URL}: ${e}`,isValid:!1}};exports.validateWebhookUrl=validateWebhookUrl; + +},{"../errors/ErrorMessage":33}],36:[function(require,module,exports){ +"use strict";var __awaiter=this&&this.__awaiter||function(e,t,i,o){return new(i||(i=Promise))(function(r,n){function a(e){try{l(o.next(e))}catch(e){n(e)}}function s(e){try{l(o.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(a,s)}l((o=o.apply(e,t||[])).next())})},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const ErrorMessage_1=require("./errors/ErrorMessage"),validator_1=require("../core/validator"),validateWebhookUrl_1=require("./validators/validateWebhookUrl"),handleError_1=__importDefault(require("../core/errors/handleError")),SETTINGS_ENDPOINT="settings/sipgateio";exports.createSettingsModule=(e=>({setIncomingUrl(t){return __awaiter(this,void 0,void 0,function*(){const i=validateWebhookUrl_1.validateWebhookUrl(t);if(!i.isValid)throw new Error(i.cause);yield modifyWebhookSettings(e,e=>e.incomingUrl=t)})},setOutgoingUrl(t){return __awaiter(this,void 0,void 0,function*(){const i=validateWebhookUrl_1.validateWebhookUrl(t);if(!i.isValid)throw new Error(i.cause);yield modifyWebhookSettings(e,e=>e.outgoingUrl=t)})},setWhitelist(t){return __awaiter(this,void 0,void 0,function*(){validateWhitelistExtensions(t),yield modifyWebhookSettings(e,e=>e.whitelist=t)})},setLog(t){return __awaiter(this,void 0,void 0,function*(){yield modifyWebhookSettings(e,e=>e.log=t)})},clearIncomingUrl(){return __awaiter(this,void 0,void 0,function*(){yield modifyWebhookSettings(e,e=>e.incomingUrl="")})},clearOutgoingUrl(){return __awaiter(this,void 0,void 0,function*(){yield modifyWebhookSettings(e,e=>e.outgoingUrl="")})},clearWhitelist(){return __awaiter(this,void 0,void 0,function*(){yield modifyWebhookSettings(e,e=>e.whitelist=[])})},disableWhitelist(){return __awaiter(this,void 0,void 0,function*(){yield modifyWebhookSettings(e,e=>e.whitelist=null)})}}));const getWebhookSettings=e=>__awaiter(void 0,void 0,void 0,function*(){return e.get(SETTINGS_ENDPOINT).then(e=>e.data).catch(e=>handleError(e))}),modifyWebhookSettings=(e,t)=>__awaiter(void 0,void 0,void 0,function*(){yield getWebhookSettings(e).then(i=>(t(i),e.put(SETTINGS_ENDPOINT,i))).catch(e=>handleError(e))}),validateWhitelistExtensions=e=>{e.forEach(e=>{const t=validator_1.validateExtension(e,[validator_1.ExtensionType.PERSON,validator_1.ExtensionType.GROUP]);if(!t.isValid)throw new Error(`${ErrorMessage_1.ErrorMessage.VALIDATOR_INVALID_EXTENSION_FOR_WEBHOOKS}\n${t.cause}: ${e}`)})},handleError=e=>e.response&&403===e.response.status?new Error(ErrorMessage_1.ErrorMessage.WEBHOOK_SETTINGS_FEATURE_NOT_BOOKED):handleError_1.default(e); + +},{"../core/errors/handleError":10,"../core/validator":18,"./errors/ErrorMessage":33,"./validators/validateWebhookUrl":35}],37:[function(require,module,exports){ +(function (Buffer){ +!function(o){"use strict";var e,r="function"==typeof(e=o.atob)?e:"function"==typeof Buffer?function(o){return new Buffer(o,"base64").toString("binary")}:"object"==typeof o.base64js?function(e){var r=o.base64js.b64ToByteArray(e);return Array.prototype.map.call(r,function(o){return String.fromCharCode(o)}).join("")}:function(){throw new Error("You're probably in an old browser or an iOS webworker. It might help to include beatgammit's base64-js.")};o.atob=r,"object"==typeof module&&module&&module.exports&&(module.exports=r)}(window); + +}).call(this,require("buffer").Buffer) +},{"buffer":66}],38:[function(require,module,exports){ +module.exports=require("./lib/axios"); + +},{"./lib/axios":40}],39:[function(require,module,exports){ +"use strict";var utils=require("./../utils"),settle=require("./../core/settle"),buildURL=require("./../helpers/buildURL"),parseHeaders=require("./../helpers/parseHeaders"),isURLSameOrigin=require("./../helpers/isURLSameOrigin"),createError=require("../core/createError");module.exports=function(e){return new Promise(function(r,t){var s=e.data,o=e.headers;utils.isFormData(s)&&delete o["Content-Type"];var n=new XMLHttpRequest;if(e.auth){var a=e.auth.username||"",i=e.auth.password||"";o.Authorization="Basic "+btoa(a+":"+i)}if(n.open(e.method.toUpperCase(),buildURL(e.url,e.params,e.paramsSerializer),!0),n.timeout=e.timeout,n.onreadystatechange=function(){if(n&&4===n.readyState&&(0!==n.status||n.responseURL&&0===n.responseURL.indexOf("file:"))){var s="getAllResponseHeaders"in n?parseHeaders(n.getAllResponseHeaders()):null,o={data:e.responseType&&"text"!==e.responseType?n.response:n.responseText,status:n.status,statusText:n.statusText,headers:s,config:e,request:n};settle(r,t,o),n=null}},n.onabort=function(){n&&(t(createError("Request aborted",e,"ECONNABORTED",n)),n=null)},n.onerror=function(){t(createError("Network Error",e,null,n)),n=null},n.ontimeout=function(){t(createError("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",n)),n=null},utils.isStandardBrowserEnv()){var u=require("./../helpers/cookies"),l=(e.withCredentials||isURLSameOrigin(e.url))&&e.xsrfCookieName?u.read(e.xsrfCookieName):void 0;l&&(o[e.xsrfHeaderName]=l)}if("setRequestHeader"in n&&utils.forEach(o,function(e,r){void 0===s&&"content-type"===r.toLowerCase()?delete o[r]:n.setRequestHeader(r,e)}),e.withCredentials&&(n.withCredentials=!0),e.responseType)try{n.responseType=e.responseType}catch(r){if("json"!==e.responseType)throw r}"function"==typeof e.onDownloadProgress&&n.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&n.upload&&n.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){n&&(n.abort(),t(e),n=null)}),void 0===s&&(s=null),n.send(s)})}; + +},{"../core/createError":46,"./../core/settle":50,"./../helpers/buildURL":54,"./../helpers/cookies":56,"./../helpers/isURLSameOrigin":58,"./../helpers/parseHeaders":60,"./../utils":62}],40:[function(require,module,exports){ +"use strict";var utils=require("./utils"),bind=require("./helpers/bind"),Axios=require("./core/Axios"),mergeConfig=require("./core/mergeConfig"),defaults=require("./defaults");function createInstance(e){var r=new Axios(e),i=bind(Axios.prototype.request,r);return utils.extend(i,Axios.prototype,r),utils.extend(i,r),i}var axios=createInstance(defaults);axios.Axios=Axios,axios.create=function(e){return createInstance(mergeConfig(axios.defaults,e))},axios.Cancel=require("./cancel/Cancel"),axios.CancelToken=require("./cancel/CancelToken"),axios.isCancel=require("./cancel/isCancel"),axios.all=function(e){return Promise.all(e)},axios.spread=require("./helpers/spread"),module.exports=axios,module.exports.default=axios; + +},{"./cancel/Cancel":41,"./cancel/CancelToken":42,"./cancel/isCancel":43,"./core/Axios":44,"./core/mergeConfig":49,"./defaults":52,"./helpers/bind":53,"./helpers/spread":61,"./utils":62}],41:[function(require,module,exports){ +"use strict";function Cancel(e){this.message=e}Cancel.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},Cancel.prototype.__CANCEL__=!0,module.exports=Cancel; + +},{}],42:[function(require,module,exports){ +"use strict";var Cancel=require("./Cancel");function CancelToken(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var n;this.promise=new Promise(function(e){n=e});var o=this;e(function(e){o.reason||(o.reason=new Cancel(e),n(o.reason))})}CancelToken.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},CancelToken.source=function(){var e;return{token:new CancelToken(function(n){e=n}),cancel:e}},module.exports=CancelToken; + +},{"./Cancel":41}],43:[function(require,module,exports){ +"use strict";module.exports=function(t){return!(!t||!t.__CANCEL__)}; + +},{}],44:[function(require,module,exports){ +"use strict";var utils=require("./../utils"),buildURL=require("../helpers/buildURL"),InterceptorManager=require("./InterceptorManager"),dispatchRequest=require("./dispatchRequest"),mergeConfig=require("./mergeConfig");function Axios(e){this.defaults=e,this.interceptors={request:new InterceptorManager,response:new InterceptorManager}}Axios.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=mergeConfig(this.defaults,e)).method=e.method?e.method.toLowerCase():"get";var t=[dispatchRequest,void 0],r=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)r=r.then(t.shift(),t.shift());return r},Axios.prototype.getUri=function(e){return e=mergeConfig(this.defaults,e),buildURL(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},utils.forEach(["delete","get","head","options"],function(e){Axios.prototype[e]=function(t,r){return this.request(utils.merge(r||{},{method:e,url:t}))}}),utils.forEach(["post","put","patch"],function(e){Axios.prototype[e]=function(t,r,i){return this.request(utils.merge(i||{},{method:e,url:t,data:r}))}}),module.exports=Axios; + +},{"../helpers/buildURL":54,"./../utils":62,"./InterceptorManager":45,"./dispatchRequest":47,"./mergeConfig":49}],45:[function(require,module,exports){ +"use strict";var utils=require("./../utils");function InterceptorManager(){this.handlers=[]}InterceptorManager.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},InterceptorManager.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},InterceptorManager.prototype.forEach=function(e){utils.forEach(this.handlers,function(t){null!==t&&e(t)})},module.exports=InterceptorManager; + +},{"./../utils":62}],46:[function(require,module,exports){ +"use strict";var enhanceError=require("./enhanceError");module.exports=function(r,e,n,o,a){var c=new Error(r);return enhanceError(c,e,n,o,a)}; + +},{"./enhanceError":48}],47:[function(require,module,exports){ +"use strict";var utils=require("./../utils"),transformData=require("./transformData"),isCancel=require("../cancel/isCancel"),defaults=require("../defaults"),isAbsoluteURL=require("./../helpers/isAbsoluteURL"),combineURLs=require("./../helpers/combineURLs");function throwIfCancellationRequested(e){e.cancelToken&&e.cancelToken.throwIfRequested()}module.exports=function(e){return throwIfCancellationRequested(e),e.baseURL&&!isAbsoluteURL(e.url)&&(e.url=combineURLs(e.baseURL,e.url)),e.headers=e.headers||{},e.data=transformData(e.data,e.headers,e.transformRequest),e.headers=utils.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),utils.forEach(["delete","get","head","post","put","patch","common"],function(a){delete e.headers[a]}),(e.adapter||defaults.adapter)(e).then(function(a){return throwIfCancellationRequested(e),a.data=transformData(a.data,a.headers,e.transformResponse),a},function(a){return isCancel(a)||(throwIfCancellationRequested(e),a&&a.response&&(a.response.data=transformData(a.response.data,a.response.headers,e.transformResponse))),Promise.reject(a)})}; + +},{"../cancel/isCancel":43,"../defaults":52,"./../helpers/combineURLs":55,"./../helpers/isAbsoluteURL":57,"./../utils":62,"./transformData":51}],48:[function(require,module,exports){ +"use strict";module.exports=function(e,i,s,t,n){return e.config=i,s&&(e.code=s),e.request=t,e.response=n,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}; + +},{}],49:[function(require,module,exports){ +"use strict";var utils=require("../utils");module.exports=function(e,t){t=t||{};var s={};return utils.forEach(["url","method","params","data"],function(e){void 0!==t[e]&&(s[e]=t[e])}),utils.forEach(["headers","auth","proxy"],function(r){utils.isObject(t[r])?s[r]=utils.deepMerge(e[r],t[r]):void 0!==t[r]?s[r]=t[r]:utils.isObject(e[r])?s[r]=utils.deepMerge(e[r]):void 0!==e[r]&&(s[r]=e[r])}),utils.forEach(["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"],function(r){void 0!==t[r]?s[r]=t[r]:void 0!==e[r]&&(s[r]=e[r])}),s}; + +},{"../utils":62}],50:[function(require,module,exports){ +"use strict";var createError=require("./createError");module.exports=function(r,t,e){var a=e.config.validateStatus;!a||a(e.status)?r(e):t(createError("Request failed with status code "+e.status,e.config,null,e.request,e))}; + +},{"./createError":46}],51:[function(require,module,exports){ +"use strict";var utils=require("./../utils");module.exports=function(t,u,r){return utils.forEach(r,function(r){t=r(t,u)}),t}; + +},{"./../utils":62}],52:[function(require,module,exports){ +(function (process){ +"use strict";var utils=require("./utils"),normalizeHeaderName=require("./helpers/normalizeHeaderName"),DEFAULT_CONTENT_TYPE={"Content-Type":"application/x-www-form-urlencoded"};function setContentTypeIfUnset(e,t){!utils.isUndefined(e)&&utils.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}function getDefaultAdapter(){var e;return"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process)?e=require("./adapters/http"):"undefined"!=typeof XMLHttpRequest&&(e=require("./adapters/xhr")),e}var defaults={adapter:getDefaultAdapter(),transformRequest:[function(e,t){return normalizeHeaderName(t,"Accept"),normalizeHeaderName(t,"Content-Type"),utils.isFormData(e)||utils.isArrayBuffer(e)||utils.isBuffer(e)||utils.isStream(e)||utils.isFile(e)||utils.isBlob(e)?e:utils.isArrayBufferView(e)?e.buffer:utils.isURLSearchParams(e)?(setContentTypeIfUnset(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):utils.isObject(e)?(setContentTypeIfUnset(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};utils.forEach(["delete","get","head"],function(e){defaults.headers[e]={}}),utils.forEach(["post","put","patch"],function(e){defaults.headers[e]=utils.merge(DEFAULT_CONTENT_TYPE)}),module.exports=defaults; + +}).call(this,require('_process')) +},{"./adapters/http":39,"./adapters/xhr":39,"./helpers/normalizeHeaderName":59,"./utils":62,"_process":77}],53:[function(require,module,exports){ +"use strict";module.exports=function(r,n){return function(){for(var t=new Array(arguments.length),e=0;e=0)return;o[e]="set-cookie"===e?(o[e]?o[e]:[]).concat([i]):o[e]?o[e]+", "+i:i}}),o):o}; + +},{"./../utils":62}],61:[function(require,module,exports){ +"use strict";module.exports=function(n){return function(t){return n.apply(null,t)}}; + +},{}],62:[function(require,module,exports){ +"use strict";var bind=require("./helpers/bind"),isBuffer=require("is-buffer"),toString=Object.prototype.toString;function isArray(e){return"[object Array]"===toString.call(e)}function isArrayBuffer(e){return"[object ArrayBuffer]"===toString.call(e)}function isFormData(e){return"undefined"!=typeof FormData&&e instanceof FormData}function isArrayBufferView(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function isString(e){return"string"==typeof e}function isNumber(e){return"number"==typeof e}function isUndefined(e){return void 0===e}function isObject(e){return null!==e&&"object"==typeof e}function isDate(e){return"[object Date]"===toString.call(e)}function isFile(e){return"[object File]"===toString.call(e)}function isBlob(e){return"[object Blob]"===toString.call(e)}function isFunction(e){return"[object Function]"===toString.call(e)}function isStream(e){return isObject(e)&&isFunction(e.pipe)}function isURLSearchParams(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams}function trim(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function isStandardBrowserEnv(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)}function forEach(e,r){if(null!=e)if("object"!=typeof e&&(e=[e]),isArray(e))for(var t=0,n=e.length;t0)throw new Error("Invalid string. Length must be a multiple of 4");var e=o.indexOf("=");return-1===e&&(e=r),[e,e===r?0:4-e%4]}function byteLength(o){var r=getLens(o),e=r[0],t=r[1];return 3*(e+t)/4-t}function _byteLength(o,r,e){return 3*(r+e)/4-e}function toByteArray(o){var r,e,t=getLens(o),n=t[0],u=t[1],p=new Arr(_byteLength(o,n,u)),a=0,h=u>0?n-4:n;for(e=0;e>16&255,p[a++]=r>>8&255,p[a++]=255&r;return 2===u&&(r=revLookup[o.charCodeAt(e)]<<2|revLookup[o.charCodeAt(e+1)]>>4,p[a++]=255&r),1===u&&(r=revLookup[o.charCodeAt(e)]<<10|revLookup[o.charCodeAt(e+1)]<<4|revLookup[o.charCodeAt(e+2)]>>2,p[a++]=r>>8&255,p[a++]=255&r),p}function tripletToBase64(o){return lookup[o>>18&63]+lookup[o>>12&63]+lookup[o>>6&63]+lookup[63&o]}function encodeChunk(o,r,e){for(var t,n=[],u=r;up?p:u+16383));return 1===t?(r=o[e-1],n.push(lookup[r>>2]+lookup[r<<4&63]+"==")):2===t&&(r=(o[e-2]<<8)+o[e-1],n.push(lookup[r>>10]+lookup[r>>4&63]+lookup[r<<2&63]+"=")),n.join("")}revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63; + +},{}],65:[function(require,module,exports){ +(function (Buffer){ +!function(){"use strict";module.exports=function(t){return(t instanceof Buffer?t:Buffer.from(t.toString(),"binary")).toString("base64")}}(); + +}).call(this,require("buffer").Buffer) +},{"buffer":66}],66:[function(require,module,exports){ +(function (Buffer){ +"use strict";var base64=require("base64-js"),ieee754=require("ieee754"),customInspectSymbol="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;exports.Buffer=Buffer,exports.SlowBuffer=SlowBuffer,exports.INSPECT_MAX_BYTES=50;var K_MAX_LENGTH=2147483647;function typedArraySupport(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}function createBuffer(e){if(e>K_MAX_LENGTH)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,Buffer.prototype),t}function Buffer(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return allocUnsafe(e)}return from(e,t,r)}function from(e,t,r){if("string"==typeof e)return fromString(e,t);if(ArrayBuffer.isView(e))return fromArrayLike(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(isInstance(e,ArrayBuffer)||e&&isInstance(e.buffer,ArrayBuffer))return fromArrayBuffer(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return Buffer.from(n,t,r);var f=fromObject(e);if(f)return f;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return Buffer.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function assertSize(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function alloc(e,t,r){return assertSize(e),e<=0?createBuffer(e):void 0!==t?"string"==typeof r?createBuffer(e).fill(t,r):createBuffer(e).fill(t):createBuffer(e)}function allocUnsafe(e){return assertSize(e),createBuffer(e<0?0:0|checked(e))}function fromString(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!Buffer.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|byteLength(e,t),n=createBuffer(r),f=n.write(e,t);return f!==r&&(n=n.slice(0,f)),n}function fromArrayLike(e){for(var t=e.length<0?0:0|checked(e.length),r=createBuffer(t),n=0;n=K_MAX_LENGTH)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+K_MAX_LENGTH.toString(16)+" bytes");return 0|e}function SlowBuffer(e){return+e!=e&&(e=0),Buffer.alloc(+e)}function byteLength(e,t){if(Buffer.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||isInstance(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var f=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return utf8ToBytes(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return base64ToBytes(e).length;default:if(f)return n?-1:utf8ToBytes(e).length;t=(""+t).toLowerCase(),f=!0}}function slowToString(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return hexSlice(this,t,r);case"utf8":case"utf-8":return utf8Slice(this,t,r);case"ascii":return asciiSlice(this,t,r);case"latin1":case"binary":return latin1Slice(this,t,r);case"base64":return base64Slice(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function swap(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function bidirectionalIndexOf(e,t,r,n,f){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),numberIsNaN(r=+r)&&(r=f?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(f)return-1;r=e.length-1}else if(r<0){if(!f)return-1;r=0}if("string"==typeof t&&(t=Buffer.from(t,n)),Buffer.isBuffer(t))return 0===t.length?-1:arrayIndexOf(e,t,r,n,f);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?f?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):arrayIndexOf(e,[t],r,n,f);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,r,n,f){var i,o=1,u=e.length,s=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;o=2,u/=2,s/=2,r/=2}function a(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(f){var h=-1;for(i=r;iu&&(r=u-s),i=r;i>=0;i--){for(var c=!0,l=0;lf&&(n=f):n=f;var i=t.length;n>i/2&&(n=i/2);for(var o=0;o239?4:a>223?3:a>191?2:1;if(f+c<=r)switch(c){case 1:a<128&&(h=a);break;case 2:128==(192&(i=e[f+1]))&&(s=(31&a)<<6|63&i)>127&&(h=s);break;case 3:i=e[f+1],o=e[f+2],128==(192&i)&&128==(192&o)&&(s=(15&a)<<12|(63&i)<<6|63&o)>2047&&(s<55296||s>57343)&&(h=s);break;case 4:i=e[f+1],o=e[f+2],u=e[f+3],128==(192&i)&&128==(192&o)&&128==(192&u)&&(s=(15&a)<<18|(63&i)<<12|(63&o)<<6|63&u)>65535&&s<1114112&&(h=s)}null===h?(h=65533,c=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),f+=c}return decodeCodePointsArray(n)}exports.kMaxLength=K_MAX_LENGTH,Buffer.TYPED_ARRAY_SUPPORT=typedArraySupport(),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",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.buffer}}),Object.defineProperty(Buffer.prototype,"offset",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=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(e,t,r){return from(e,t,r)},Object.setPrototypeOf(Buffer.prototype,Uint8Array.prototype),Object.setPrototypeOf(Buffer,Uint8Array),Buffer.alloc=function(e,t,r){return alloc(e,t,r)},Buffer.allocUnsafe=function(e){return allocUnsafe(e)},Buffer.allocUnsafeSlow=function(e){return allocUnsafe(e)},Buffer.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==Buffer.prototype},Buffer.compare=function(e,t){if(isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),isInstance(t,Uint8Array)&&(t=Buffer.from(t,t.offset,t.byteLength)),!Buffer.isBuffer(e)||!Buffer.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,n=t.length,f=0,i=Math.min(r,n);ft&&(e+=" ... "),""},customInspectSymbol&&(Buffer.prototype[customInspectSymbol]=Buffer.prototype.inspect),Buffer.prototype.compare=function(e,t,r,n,f){if(isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),!Buffer.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===f&&(f=this.length),t<0||r>e.length||n<0||f>this.length)throw new RangeError("out of range index");if(n>=f&&t>=r)return 0;if(n>=f)return-1;if(t>=r)return 1;if(this===e)return 0;for(var i=(f>>>=0)-(n>>>=0),o=(r>>>=0)-(t>>>=0),u=Math.min(i,o),s=this.slice(n,f),a=e.slice(t,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var f=this.length-t;if((void 0===r||r>f)&&(r=f),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return hexWrite(this,e,t,r);case"utf8":case"utf-8":return utf8Write(this,e,t,r);case"ascii":return asciiWrite(this,e,t,r);case"latin1":case"binary":return latin1Write(this,e,t,r);case"base64":return base64Write(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(e){var t=e.length;if(t<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,e);for(var r="",n=0;nn)&&(r=n);for(var f="",i=t;ir)throw new RangeError("Trying to access beyond buffer length")}function checkInt(e,t,r,n,f,i){if(!Buffer.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>f||te.length)throw new RangeError("Index out of range")}function checkIEEE754(e,t,r,n,f,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function writeFloat(e,t,r,n,f){return t=+t,r>>>=0,f||checkIEEE754(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),ieee754.write(e,t,r,n,23,4),r+4}function writeDouble(e,t,r,n,f){return t=+t,r>>>=0,f||checkIEEE754(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),ieee754.write(e,t,r,n,52,8),r+8}Buffer.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=this[e],f=1,i=0;++i>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=this[e+--t],f=1;t>0&&(f*=256);)n+=this[e+--t]*f;return n},Buffer.prototype.readUInt8=function(e,t){return e>>>=0,t||checkOffset(e,1,this.length),this[e]},Buffer.prototype.readUInt16LE=function(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]|this[e+1]<<8},Buffer.prototype.readUInt16BE=function(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]<<8|this[e+1]},Buffer.prototype.readUInt32LE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer.prototype.readUInt32BE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=this[e],f=1,i=0;++i=(f*=128)&&(n-=Math.pow(2,8*t)),n},Buffer.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=t,f=1,i=this[e+--n];n>0&&(f*=256);)i+=this[e+--n]*f;return i>=(f*=128)&&(i-=Math.pow(2,8*t)),i},Buffer.prototype.readInt8=function(e,t){return e>>>=0,t||checkOffset(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Buffer.prototype.readInt16LE=function(e,t){e>>>=0,t||checkOffset(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(e,t){e>>>=0,t||checkOffset(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer.prototype.readInt32BE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer.prototype.readFloatLE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),ieee754.read(this,e,!0,23,4)},Buffer.prototype.readFloatBE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),ieee754.read(this,e,!1,23,4)},Buffer.prototype.readDoubleLE=function(e,t){return e>>>=0,t||checkOffset(e,8,this.length),ieee754.read(this,e,!0,52,8)},Buffer.prototype.readDoubleBE=function(e,t){return e>>>=0,t||checkOffset(e,8,this.length),ieee754.read(this,e,!1,52,8)},Buffer.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||checkInt(this,e,t,r,Math.pow(2,8*r)-1,0);var f=1,i=0;for(this[t]=255&e;++i>>=0,r>>>=0,n)||checkInt(this,e,t,r,Math.pow(2,8*r)-1,0);var f=r-1,i=1;for(this[t+f]=255&e;--f>=0&&(i*=256);)this[t+f]=e/i&255;return t+r},Buffer.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,1,255,0),this[t]=255&e,t+1},Buffer.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},Buffer.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var f=Math.pow(2,8*r-1);checkInt(this,e,t,r,f-1,-f)}var i=0,o=1,u=0;for(this[t]=255&e;++i>0)-u&255;return t+r},Buffer.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var f=Math.pow(2,8*r-1);checkInt(this,e,t,r,f-1,-f)}var i=r-1,o=1,u=0;for(this[t+i]=255&e;--i>=0&&(o*=256);)e<0&&0===u&&0!==this[t+i+1]&&(u=1),this[t+i]=(e/o>>0)-u&255;return t+r},Buffer.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},Buffer.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},Buffer.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeFloatLE=function(e,t,r){return writeFloat(this,e,t,!0,r)},Buffer.prototype.writeFloatBE=function(e,t,r){return writeFloat(this,e,t,!1,r)},Buffer.prototype.writeDoubleLE=function(e,t,r){return writeDouble(this,e,t,!0,r)},Buffer.prototype.writeDoubleBE=function(e,t,r){return writeDouble(this,e,t,!1,r)},Buffer.prototype.copy=function(e,t,r,n){if(!Buffer.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return f},Buffer.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Buffer.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){var f=e.charCodeAt(0);("utf8"===n&&f<128||"latin1"===n)&&(e=f)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i55295&&r<57344){if(!f){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&i.push(239,191,189);continue}f=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),f=r;continue}r=65536+(f-55296<<10|r-56320)}else f&&(t-=3)>-1&&i.push(239,191,189);if(f=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function asciiToBytes(e){for(var t=[],r=0;r>8,f=r%256,i.push(f),i.push(n);return i}function base64ToBytes(e){return base64.toByteArray(base64clean(e))}function blitBuffer(e,t,r,n){for(var f=0;f=t.length||f>=e.length);++f)t[f+r]=e[f];return f}function isInstance(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function numberIsNaN(e){return e!=e}var hexSliceLookupTable=function(){for(var e=new Array(256),t=0;t<16;++t)for(var r=16*t,n=0;n<16;++n)e[r+n]="0123456789abcdef"[t]+"0123456789abcdef"[n];return e}(); + +}).call(this,require("buffer").Buffer) +},{"base64-js":64,"buffer":66,"ieee754":74}],67:[function(require,module,exports){ +"use strict";const preserveCamelCase=e=>{let r=!1,s=!1,t=!1;for(let a=0;a{if("string"!=typeof e&&!Array.isArray(e))throw new TypeError("Expected the input to be `string | string[]`");r=Object.assign({pascalCase:!1},r);return 0===(e=Array.isArray(e)?e.map(e=>e.trim()).filter(e=>e.length).join("-"):e.trim()).length?"":1===e.length?r.pascalCase?e.toUpperCase():e.toLowerCase():(e!==e.toLowerCase()&&(e=preserveCamelCase(e)),(e=>r.pascalCase?e.charAt(0).toUpperCase()+e.slice(1):e)(e=e.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(e,r)=>r.toUpperCase()).replace(/\d+(\w|$)/g,e=>e.toUpperCase())))};module.exports=camelCase,module.exports.default=camelCase; + +},{}],68:[function(require,module,exports){ +(function (process){ +"use strict";var __spreadArrays=this&&this.__spreadArrays||function(){for(var e=0,r=0,o=arguments.length;r{if(!(e instanceof Uint8Array||e instanceof ArrayBuffer||Buffer.isBuffer(e)))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`Buffer\` or \`ArrayBuffer\`, got \`${typeof e}\``);const t=e instanceof Uint8Array?e:new Uint8Array(e);if(!(t&&t.length>1))return;const i=(e,i)=>{i={offset:0,...i};for(let m=0;mi(stringToBytes(e),t);if(i([255,216,255]))return{ext:"jpg",mime:"image/jpeg"};if(i([137,80,78,71,13,10,26,10])){const e=33,i=t.findIndex((i,m)=>m>=e&&73===t[m]&&68===t[m+1]&&65===t[m+2]&&84===t[m+3]),m=t.subarray(e,i);return m.findIndex((e,t)=>97===m[t]&&99===m[t+1]&&84===m[t+2]&&76===m[t+3])>=0?{ext:"apng",mime:"image/apng"}:{ext:"png",mime:"image/png"}}if(i([71,73,70]))return{ext:"gif",mime:"image/gif"};if(i([87,69,66,80],{offset:8}))return{ext:"webp",mime:"image/webp"};if(i([70,76,73,70]))return{ext:"flif",mime:"image/flif"};if((i([73,73,42,0])||i([77,77,0,42]))&&i([67,82],{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(i([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(i([73,73,42,0])&&(i([16,251,134,1],{offset:4})||i([8,0,0,0],{offset:4}))&&i([0,254,0,4,0,1,0,0,0,1,0,0,0,3,1],{offset:9}))return{ext:"arw",mime:"image/x-sony-arw"};if(i([73,73,42,0,8,0,0,0])&&(i([45,0,254,0],{offset:8})||i([39,0,254,0],{offset:8})))return{ext:"dng",mime:"image/x-adobe-dng"};if(i([73,73,42,0])&&i([28,0,254,0],{offset:8}))return{ext:"nef",mime:"image/x-nikon-nef"};if(i([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(m("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(i([73,73,42,0])||i([77,77,0,42]))return{ext:"tif",mime:"image/tiff"};if(i([66,77]))return{ext:"bmp",mime:"image/bmp"};if(i([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(i([56,66,80,83]))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};const r=[80,75,3,4];if(i(r)){if(i([109,105,109,101,116,121,112,101,97,112,112,108,105,99,97,116,105,111,110,47,101,112,117,98,43,122,105,112],{offset:30}))return{ext:"epub",mime:"application/epub+zip"};if(i(xpiZipFilename,{offset:30}))return{ext:"xpi",mime:"application/x-xpinstall"};if(m("mimetypeapplication/vnd.oasis.opendocument.text",{offset:30}))return{ext:"odt",mime:"application/vnd.oasis.opendocument.text"};if(m("mimetypeapplication/vnd.oasis.opendocument.spreadsheet",{offset:30}))return{ext:"ods",mime:"application/vnd.oasis.opendocument.spreadsheet"};if(m("mimetypeapplication/vnd.oasis.opendocument.presentation",{offset:30}))return{ext:"odp",mime:"application/vnd.oasis.opendocument.presentation"};let e,a=0,o=!1;do{const f=a+30;if(o||(o=i(oxmlContentTypes,{offset:f})||i(oxmlRels,{offset:f})),e||(m("word/",{offset:f})?e={ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}:m("ppt/",{offset:f})?e={ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"}:m("xl/",{offset:f})&&(e={ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})),o&&e)return e;a=multiByteIndexOf(t,r,f)}while(a>=0);if(e)return e}if(i([80,75])&&(3===t[2]||5===t[2]||7===t[2])&&(4===t[3]||6===t[3]||8===t[3]))return{ext:"zip",mime:"application/zip"};if(i([48,48,48,48,48,48],{offset:148,mask:[248,248,248,248,248,248]})&&tarHeaderChecksumMatches(t))return{ext:"tar",mime:"application/x-tar"};if(i([82,97,114,33,26,7])&&(0===t[6]||1===t[6]))return{ext:"rar",mime:"application/x-rar-compressed"};if(i([31,139,8]))return{ext:"gz",mime:"application/gzip"};if(i([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(i([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(i([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(i([102,114,101,101],{offset:4})||i([109,100,97,116],{offset:4})||i([109,111,111,118],{offset:4})||i([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(i([102,116,121,112],{offset:4})&&0!=(96&t[8])&&0!=(96&t[9])&&0!=(96&t[10])&&0!=(96&t[11])){const e=uint8ArrayUtf8ByteString(t,8,12);switch(e){case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt ":return{ext:"mov",mime:"video/quicktime"};case"M4V ":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P ":return{ext:"m4p",mime:"video/mp4"};case"M4B ":return{ext:"m4b",mime:"audio/mp4"};case"M4A ":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V ":return{ext:"f4v",mime:"video/mp4"};case"F4P ":return{ext:"f4p",mime:"video/mp4"};case"F4A ":return{ext:"f4a",mime:"audio/mp4"};case"F4B ":return{ext:"f4b",mime:"audio/mp4"};default:return e.startsWith("3g")?e.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(i([77,84,104,100]))return{ext:"mid",mime:"audio/midi"};if(i([26,69,223,163])){const e=t.subarray(4,4100),i=e.findIndex((e,t,i)=>66===i[t]&&130===i[t+1]);if(-1!==i){const t=i+3,m=i=>[...i].every((i,m)=>e[t+m]===i.charCodeAt(0));if(m("matroska"))return{ext:"mkv",mime:"video/x-matroska"};if(m("webm"))return{ext:"webm",mime:"video/webm"}}}if(i([82,73,70,70])){if(i([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(i([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/vnd.wave"};if(i([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(i([48,38,178,117,142,102,207,17,166,217])){let e=30;do{const m=readUInt64LE(t,e+16);if(i([145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101],{offset:e})){if(i([64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43],{offset:e+24}))return{ext:"wma",mime:"audio/x-ms-wma"};if(i([192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43],{offset:e+24}))return{ext:"wmv",mime:"video/x-ms-asf"};break}e+=m}while(e+24<=t.length);return{ext:"asf",mime:"application/vnd.ms-asf"}}if(i([0,0,1,186])||i([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};for(let e=0;e<2&&enew Promise((resolve,reject)=>{const stream=eval("require")("stream");readableStream.on("error",reject),readableStream.once("readable",()=>{const e=new stream.PassThrough,t=readableStream.read(module.exports.minimumBytes)||readableStream.read();try{e.fileType=fileType(t)}catch(e){reject(e)}readableStream.unshift(t),stream.pipeline?resolve(stream.pipeline(readableStream,e,()=>{})):resolve(readableStream.pipe(e))})})),Object.defineProperty(fileType,"extensions",{get:()=>new Set(supported.extensions)}),Object.defineProperty(fileType,"mimeTypes",{get:()=>new Set(supported.mimeTypes)}); + +}).call(this,{"isBuffer":require("../is-buffer/index.js")}) +},{"../is-buffer/index.js":75,"./supported":70,"./util":71}],70:[function(require,module,exports){ +"use strict";module.exports={extensions:["jpg","png","apng","gif","webp","flif","cr2","orf","arw","dng","nef","rw2","raf","tif","bmp","jxr","psd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","msi","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","wmv","wma","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp"],mimeTypes:["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-canon-cr2","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/epub+zip","application/x-xpinstall","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/x-apache-arrow","video/mp4","audio/midi","video/x-matroska","video/webm","video/quicktime","video/vnd.avi","audio/vnd.wave","audio/qcelp","audio/x-ms-wma","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","audio/opus","video/ogg","audio/ogg","application/ogg","audio/x-flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","image/x-icon","video/x-flv","application/postscript","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-msi","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/ktx","application/dicom","audio/x-musepack","text/calendar","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape"]}; + +},{}],71:[function(require,module,exports){ +(function (Buffer){ +"use strict";exports.stringToBytes=(t=>[...t].map(t=>t.charCodeAt(0)));const uint8ArrayUtf8ByteString=(t,r,e)=>String.fromCharCode(...t.slice(r,e));exports.readUInt64LE=((t,r=0)=>{let e=t[r],n=1,f=0;for(;++f<8;)n*=256,e+=t[r+f]*n;return e}),exports.tarHeaderChecksumMatches=(t=>{if(t.length<512)return!1;let r=256,e=0;for(let n=0;n<148;n++){const f=t[n];r+=f,e+=128&f}for(let n=156;n<512;n++){const f=t[n];r+=f,e+=128&f}const n=parseInt(uint8ArrayUtf8ByteString(t,148,154),8);return n===r||n===r-(e<<1)}),exports.multiByteIndexOf=((t,r,e=0)=>{if(Buffer&&Buffer.isBuffer(t))return t.indexOf(Buffer.from(r),e);const n=(t,r,e)=>{for(let n=1;n=0;){if(n(t,r,f))return f;f=t.indexOf(r[0],f+1)}return-1}),exports.uint8ArrayUtf8ByteString=uint8ArrayUtf8ByteString; + +}).call(this,require("buffer").Buffer) +},{"buffer":66}],72:[function(require,module,exports){ +const CRLF="\r\n",SP=" ",MAX_LINE_LENGTH=998,DEFAULT_LINE_LENGTH=78,MIN_LINE_LENGTH=2;function foldLine(e,n,L){if(null!=n&&nMAX_LINE_LENGTH)throw new Error("Maximum length must not exceed "+MAX_LINE_LENGTH);if(n=n||DEFAULT_LINE_LENGTH,(e=e.replace(/[\r\n]+/g,"")).length<=n)return e;for(var r="",l=0,E=0,t=e.length,N=0,o=0;ll?(r+=e.slice(l,E)+CRLF+SP,l=E):(r+=e.slice(l,l+n-o)+CRLF+SP,l=l+n-o,L=!0):(r+=e.slice(l,l+n-o)+CRLF+SP,l=l+n-o),t-l>>0),goog.uidCounter_=0,goog.getHashCode=goog.getUid,goog.removeHashCode=goog.removeUid,goog.cloneObject=function(e){var o=goog.typeOf(e);if("object"==o||"array"==o){if("function"==typeof e.clone)return e.clone();for(var t in o="array"==o?[]:{},e)o[t]=goog.cloneObject(e[t]);return o}return e},goog.bindNative_=function(e,o,t){return e.call.apply(e.bind,arguments)},goog.bindJs_=function(e,o,t){if(!e)throw Error();if(2{"use strict";class X{constructor(){if(new.target!=String)throw 1;this.x=42}}let q=Reflect.construct(X,[],String);if(q.x!=42||!(q instanceof String))throw 1;for(const a of[2,3]){if(a==2)continue;function f(z={a}){let a=0;return z.a}{function f(){return 0;}}return f()==3}})()')}),a("es7",function(){return b("2 ** 2 == 4")}),a("es8",function(){return b("async () => 1, true")}),a("es9",function(){return b("({...rest} = {}), true")}),a("es_next",function(){return!1}),{target:c,map:d}},goog.Transpiler.prototype.needsTranspile=function(e,o){if("always"==goog.TRANSPILE)return!0;if("never"==goog.TRANSPILE)return!1;if(!this.requiresTranspilation_){var t=this.createRequiresTranspilation_();this.requiresTranspilation_=t.map,this.transpilationTarget_=this.transpilationTarget_||t.target}if(e in this.requiresTranspilation_)return!!this.requiresTranspilation_[e]||!(!goog.inHtmlDocument_()||"es6"!=o||"noModule"in goog.global.document.createElement("script"));throw Error("Unknown language mode: "+e)},goog.Transpiler.prototype.transpile=function(e,o){return goog.transpile_(e,o,this.transpilationTarget_)},goog.transpiler_=new goog.Transpiler,goog.protectScriptTag_=function(e){return e.replace(/<\/(SCRIPT)/gi,"\\x3c/$1")},goog.DebugLoader_=function(){this.dependencies_={},this.idToPath_={},this.written_={},this.loadingDeps_=[],this.depsToLoad_=[],this.paused_=!1,this.factory_=new goog.DependencyFactory(goog.transpiler_),this.deferredCallbacks_={},this.deferredQueue_=[]},goog.DebugLoader_.prototype.bootstrap=function(e,o){function t(){r&&(goog.global.setTimeout(r,0),r=null)}var r=o;if(e.length){for(var n=[],d=0;d<\/script>",o.write(goog.TRUSTED_TYPES_POLICY_?goog.TRUSTED_TYPES_POLICY_.createHTML(r):r)}else{var n=o.createElement("script");n.defer=goog.Dependency.defer_,n.async=!1,n.type="text/javascript",(r=goog.getScriptNonce())&&n.setAttribute("nonce",r),goog.DebugLoader_.IS_OLD_IE_?(e.pause(),n.onreadystatechange=function(){"loaded"!=n.readyState&&"complete"!=n.readyState||(e.loaded(),e.resume())}):n.onload=function(){n.onload=null,e.loaded()},n.src=goog.TRUSTED_TYPES_POLICY_?goog.TRUSTED_TYPES_POLICY_.createScriptURL(this.path):this.path,o.head.appendChild(n)}}else goog.logToConsole_("Cannot use default debug loader outside of HTML documents."),"deps.js"==this.relativePath?(goog.logToConsole_("Consider setting CLOSURE_IMPORT_SCRIPT before loading base.js, or setting CLOSURE_NO_DEPS to true."),e.loaded()):e.pause()},goog.Es6ModuleDependency=function(e,o,t,r,n){goog.Dependency.call(this,e,o,t,r,n)},goog.inherits(goog.Es6ModuleDependency,goog.Dependency),goog.Es6ModuleDependency.prototype.load=function(e){if(goog.global.CLOSURE_IMPORT_SCRIPT)goog.global.CLOSURE_IMPORT_SCRIPT(this.path)?e.loaded():e.pause();else if(goog.inHtmlDocument_()){var o=goog.global.document,t=this;if(goog.isDocumentLoading_()){var r=function(e,t){var r=t?'