comprodls-sdk 2.89.0 → 2.90.3-development

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- !function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).ComproDLS=e()}(function(){return function n(o,i,s){function a(r,e){if(!i[r]){if(!o[r]){var t="function"==typeof require&&require;if(!e&&t)return t(r,!0);if(c)return c(r,!0);e=new Error("Cannot find module '"+r+"'");throw e.code="MODULE_NOT_FOUND",e}t=i[r]={exports:{}};o[r][0].call(t.exports,function(e){var t=o[r][1][e];return a(t||e)},t,t.exports,n,o,i,s)}return i[r].exports}for(var c="function"==typeof require&&require,e=0;e<s.length;e++)a(s[e]);return a}({1:[function(e,t,r){var n=e("./token"),o=e("./helpers"),i=e("./services/auth"),s=e("./services/authextn"),a=e("./services/activity"),c=e("./services/analytics"),u=e("./services/collab"),d=e("./services/product"),l=e("./services/xapi"),p=e("./services/attempts"),f=e("./services/pushX"),h=e("./services/pub"),g=e("./services/spaces"),y=e("./services/spacesextn"),m=e("./config"),R=e("./open_access"),_=e("./services/superuser"),A=e("./services/invitations"),b=e("./services/workflows"),v=e("./services/integrations"),I=e("./token/validations"),T=e("./services/drive"),E=e("./services/taxonomy"),S=e("./services/rules"),e=e("./services/datasyncmanager");function P(t,r,e){e=e||{},t=t||"production",r=r||"global",this.token=null,this.orgId=null,this.traceid=e.traceid;try{if(m.DEFAULT_HOSTS=m.REALM_HOSTS[r.toUpperCase()][t.toUpperCase()],!m.DEFAULT_HOSTS)throw"Invalid Environment"}catch(e){var n=m.REALM_HOSTS[r.toUpperCase()];throw n?n[t.toUpperCase()]||(o=new Error("Invalid Environment: "+t)):o=new Error("Invalid Realm: "+r),o}if(this.config=m,this.environment=t,e.orgid&&e.token){var o;if(o=I.authWithToken(e.orgid,e.token,{}))throw o;this.token=e.token,this.orgId=e.orgid}else e.orgid&&(this.orgId=e.orgid)}r.init=function(e,t,r){return new P(e,t,r)},P.prototype.authWithCredentials=n.authWithCredentials,P.prototype.authWithToken=n.authWithToken,P.prototype.authWithExtUser=n.authWithExtUser,P.prototype.getClassEnrolmentsStat=R.getClassEnrolmentsStat,P.prototype.getSingleInvitation=R.getSingleInvitation,P.prototype.request=o.api.genericAPICaller,P.prototype.Auth=i,P.prototype.AuthExtn=s,P.prototype.Activity=a,P.prototype.Analytics=c,P.prototype.Collab=u,P.prototype.Product=d,P.prototype.Xapi=l,P.prototype.Attempts=p,P.prototype.Pub=h,P.prototype.PushX=f,P.prototype.Spaces=g,P.prototype.SpacesExtn=y,P.prototype.Superuser=_,P.prototype.Invitations=A,P.prototype.Workflows=b,P.prototype.Integrations=v,P.prototype.Drive=T,P.prototype.Taxonomy=E,P.prototype.Rules=S,P.prototype.Datasyncmanager=e},{"./config":2,"./helpers":3,"./open_access":10,"./services/activity":13,"./services/analytics":14,"./services/attempts":15,"./services/auth":16,"./services/authextn":17,"./services/collab":18,"./services/datasyncmanager":19,"./services/drive":20,"./services/integrations":21,"./services/invitations":22,"./services/product":23,"./services/pub":24,"./services/pushX":25,"./services/rules":27,"./services/spaces":28,"./services/spacesextn":29,"./services/superuser":30,"./services/taxonomy":31,"./services/workflows":32,"./services/xapi":33,"./token":34,"./token/validations":35}],2:[function(e,t,r){r.REALM_HOSTS={GLOBAL:{PROD1:{PUB:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-drive"}},ASGARD:{THOR:{PUB:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-drive"}},CUP:{ALPHA:{PUB:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-drive"},PROD1:{PUB:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-drive"},QA:{PUB:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-drive"},HFX:{PUB:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-drive"},REL:{PUB:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-drive"}}},r.AUTH_API_URLS={getSettings:"/org/{orgId}/settings",getTokenAPI:"/auth/{orgId}/token",getExtUserTokenAPI:"/auth/{orgId}/ext-users/token",userInfoAPI:"/org/{orgId}/users/{userId}",pisImportAPI:"/org/{orgId}/pis_imports",getAllUsersAPI:"/org/{orgId}/users/all",updateUserRoleAPI:"/org/{orgId}/users/{userId}/update-role",getSettingsField:"/org/{orgId}/settings/{field}",getClassUsersAPI:"/org/{orgId}/class/{classId}/users",getUserClassesAPI:"/org/{orgId}/users/{userId}/classes",getUserClassesV2API:"/org/{orgid}/users/{userid}/class-enrollments",getAllJobs:"/accounts/{accountId}/ext-users/{extUserId}/jobs",getJob:"/accounts/{accountId}/ext-users/{extUserId}/jobs/{jobId}",getAllClassesAPI:"/org/{orgId}/classes",getParticularClassAPI:"/org/{orgId}/classes/{classId}",getParticularShadowClassAPI:"/org/{orgId}/shadow/classes/{extClassId}",classProductAssociation:"/org/{orgId}/classes/{classId}/associate-product/{productcode}",multiClassProductAssociations:"/org/{orgId}/classes/{classId}/associate-product/multi",classMaterialAssociation:"/org/{orgId}/classes/{classId}/associate-materials/multi",enrollUsertoClass:"/org/{orgId}/classes/{classId}/enroll-user/{userId}",enrollSelftoClass:"/org/{orgId}/classes/{classId}/enroll-self",enrollMultiUserstoClass:"/org/{orgId}/classes/{classId}/enroll-user/multi",createClass:"/org/{orgId}/classes",createMultipleClasses:"/org/{orgId}/classes/multi",specificClass:"/org/{orgId}/classes/{classId}",cloneClass:"/org/{orgId}/classes/{classId}/clone",ClassAppdata:"/org/{orgId}/classes/{classid}/appdata",generateClassCode:"/org/{orgId}/classes/{classId}/class-code/generate",getUserSpaces:"/accounts/{accountid}/ext-users/{extuserid}/spaces",validateSpaceCode:"/accounts/{accountid}/space-code/validate",validateClassCode:"/accounts/{accountid}/class-code/validate",joinInstituteSpace:"/accounts/{accountid}/join-institute-space",provisionSpacesToStudent:"/accounts/{accountId}/student/provision-spaces",provisionSpacesToTeacher:"/accounts/{accountId}/teacher/provision-spaces",shadowProvision:"/org/{orgId}/shadow-provision",provisionBulkSpaces:"/org/{orgId}/provision-spaces/bulk",entitleUserToProduct:"/accounts/{accountId}/entitle-user",microEntitleUserToProduct:"/accounts/{accountId}/entitle-user/micro",bulkMicroEntitleProductToUser:"/accounts/{accountId}/entitle-user/micro/bulk",enrollUserInClass:"/accounts/{accountId}/enroll-with-classcode",getExtProductAPI:"/accounts/{accountId}/products/{extProductId}",getSpaceDetails:"/accounts/{accountId}/spaces/{spacekey}",updateUserInformation:"/accounts/{accountId}/update-user-information",updateUserSpace:"/accounts/{accountid}/ext-users/{extuserid}/spaces/{spacekey}",getInvitationsByEmail:"/accounts/{accountid}/invitations-by-email",generateSpaceCode:"/accounts/{accountid}/space-code/generate",changeSpaceCode:"/accounts/{accountid}/space-code/{spacecode}/change",updateInstituteTitle:"/accounts/{accountId}/institute-spaces/{instituteSpaceCode}",getAllInstitutions:"/su/accounts/{accountid}/spaces",getInstitution:"/su/accounts/{accountid}/spaces/{spacecode}",provisionSpacesToSuperAdmin:"/su/accounts/{accountid}/superadmin/provision-spaces",sendInvitations:"/org/{orgId}/invitations",getMultiInvitations:"/org/{orgId}/invitations",getSingleInvitation:"/org/{orgId}/invitations/{invitationId}",revokeSingleInvitation:"/org/{orgId}/invitations/{invitationid}/revoke",completeSingleInvitation:"/org/{orgId}/invitations/{invitationid}/complete",resendSingleInvitation:"/org/{orgId}/invitations/{invitationid}/resend",createAssignedPath:"/org/{orgId}/classes/{classId}/assigned-paths",deleteAssignedPath:"/org/{orgId}/classes/{classId}/assigned-paths/{assignedPathId}",workflows:"/accounts/{accountid}/workflows",getAllWorkflowOfAUser:"/accounts/{accountid}/workflows/workflows-by-user",getAWorkflow:"/accounts/{accountid}/workflows/{workflowid}",acceptAWorkflow:"/accounts/{accountid}/workflows/{workflowid}/accept",processAWorkflow:"/accounts/{accountid}/workflows/{workflowid}/process",revokeAWorkflow:"/accounts/{accountid}/workflows/{workflowid}/revoke",completeAWorkflow:"/accounts/{accountid}/workflows/{workflowid}/complete",allGroups:"/org/{orgId}/groups",aParticularGroup:"/org/{orgId}/groups/{groupId}",getAllMembersOfAGroup:"/org/{orgId}/groups/{groupId}/memberships",getAllGroupMembersByPath:"/org/{orgId}/groups/memberships",userGroupMembership:"/org/{orgId}/groups/{groupId}/enroll-user/multi",getMyAllMemberships:"/org/{orgId}/users/{userId}/groups",archiveAParticularGroup:"/org/{orgId}/groups/{groupId}/archive",unarchiveAParticularGroup:"/org/{orgId}/groups/{groupId}/unarchive",showcaseItems:"/org/{orgId}/classes/{classId}/showcase/item",createDataSyncManager:"/accounts/{accountid}/data-sync-managers",dataSyncManager:"/accounts/{accountid}/data-sync-managers/{dsmid}",getAllDataSyncManagersOfAGroup:"/accounts/{accountid}/dsm-groups/{dsm_groupid}/data-sync-managers",createOrGetGradebookMeta:"/org/{orgId}/classes/{classId}/gradebooks",updateOrDeleteGradebookMeta:"/org/{orgId}/classes/{classId}/gradebooks/{gradebook_id}",gradebookColumns:"/org/{orgId}/classes/{classId}/gradebooks/{gradebook_id}/columns",getAllClassesOfAComponent:"/org/{orgId}/components/{component_code}/classes",removeAllGradebookColumnsOfCustomComponent:"/org/{orgId}/gradebook/columns/custom-components/{component_code}",customComponents:"/org/{orgid}/custom-components",particularCustomComponent:"/org/{orgid}/custom-components/{custom_component_code}"},r.AUTHEXTN_API_URLS={gradeFormat:"/org/{orgid}/gradeformats",particularGradeFormat:"/org/{orgid}/gradeformats/{gradeformat_id}",classGradeformatAssociation:"/org/{orgid}/classes/{classid}/associate-gradeformats/{gradeformat_id}",classGradeformats:"/org/{orgid}/classes/{classid}/gradeformats",gradeformatClasses:"/org/{orgid}/gradeformats/{gradeformat_id}/classes",entitleBulkUsersToProducts:"/accounts/{accountid}/entitle-users/bulk",userAssignedPaths:"/org/{orgid}/classes/{classid}/assigned-paths/{assignedpathid}/enroll-user/multi",particularClass:"/org/{orgId}/classes/{classId}",orgProductEntitlement:"/org/{orgid}/org-entitlements",setupUser:"/accounts/{accountId}/user/setup"},r.ACTIVITY_API_URLS={newAttemptAPI:"/{orgId}/products/{productId}/activities/{activityId}/start",activityDetailsAPI:"/{orgId}/products/{productId}/activities/{activityId}",existingAttemptAPI:"/{orgId}/products/{productId}/activities/{activityId}/attempts/{attemptId}",userResponseAPI:"/{orgId}/products/{productId}/activities/{activityId}/attempts/{attemptId}/response",submitAttemptAPI:"/{orgId}/products/{productId}/activities/{activityId}/attempts/{attemptId}/submit"},r.ANALYTICS_API_URLS={archiveUserAnalytics:"/{orgId}/archive/user/product",getOrgAnalyticsStat:"/{orgId}/organization/{type}/stat",getAnalyticProductItems:"/{orgId}/user/product/progress/items",getAnalyticProductSummary:"/{orgId}/user/product/progress/summary",getExternalDataForUserAnalyticItem:"/{orgId}/user/product/progress/items/external-data",searchUserProductAnalytics:"/{orgId}/user/product/progress/search",getAnalyticProductById:"/{orgId}/user/product/userprogress/{userProgressId}",getArchivedUserAnalytics:"/{orgId}/archive",getClassAnalytics:"/{orgId}/class/{analyticsDataType}/{type}",getClassEnrolmentsStat:"/{orgId}/class/enrolments/stat",getClassRecord:"/{orgId}/class/product/class-record",getClassRecordItemAggregations:"/{orgId}/class/product/item-aggregations",getClassProductRecentPendingSubmissions:"/{orgId}/class/product/recent-pending-submissions",getStudentsWithEvaluatedOnce:"/{orgId}/class/product/students-with-evaluations",getShowcaseRecordOfAClass:"/{orgId}/class/showcase",getGroupRecord:"/{orgId}/class/group/product/group-record",getClassGroupsRecentPendingSubmissions:"/{orgId}/class/group/product/recent-pending-submissions",getGroupsWithEvaluatedOnce:"/{orgId}/class/group/product/groups-with-evaluations",getClassRecordUserAggregations:"/{orgId}/class/product/user-aggregations",getUserClassRecentSubmissions:"/{orgId}/user/product/class/recent-submissions",appState:"/{orgId}/user/product/progress/state",getUserProductAllState:"/{orgId}/user/product/progress/state/all",updateUserProductMultiState:"/{orgId}/user/product/progress/state/multi",getAllAssignedPathsOfClass:"/{orgId}/class/assigned-paths",getMyAssignedPathsOfClass:"/{orgId}/user/class/assigned-paths",getAssignedPathAnalytics:"/{orgId}/class/assigned-paths/aggregations",timeseriesAnalytics:"/progress/timeseries",getClassCustomComponentRecord:"/{orgId}/class/custom-component/class-record",getClassCustomComponentUserSubmission:"/{orgId}/class/custom-component/class-record/evaluations",getCrossProductAggregation:"/{orgId}/class/cross-product-aggregation"},r.COLLAB_API_URLS={postsInClassAPI:"/{orgId}/post/classes/{classId}",postsInProductAPI:"/{orgId}/post/products/{productId}",getMyFollowers:"/{orgId}/connections/me/followers",getUsersFollowedByMe:"/{orgId}/connections/me/following",connectionURL:"/{orgId}/connections/me/follow/{userId}"},r.PRODUCT_API_URLS={getProductAPI:"/accounts/{accountId}/products/{productCode}",getEntitlementsOfAUser:"/accounts/{accountId}/ext-users/{extUserId}/entitlements",getMicroEntitlementsOfAUser:"/accounts/{accountId}/ext-users/{extUserId}/entitlements/micro",getAllBundles:"/accounts/{accountId}/bundles",getSingleBundle:"/accounts/{accountId}/bundles/{bundleCode}",getAllProductFamilies:"/accounts/{accountId}/families",getSingleProductFamily:"/accounts/{accountId}/families/{familyCode}"},r.XAPI_API_URLS={postMultiStatements:"/{orgId}/statements/multi",postExternalMultiStatements:"/{orgId}/external/statements/multi"},r.ATTEMPTS_API_URLS={userAttempts:"/org/{orgId}/user/{userId}/activities/{activityId}/attempts",getUserAttemptStatsForActivity:"/org/{orgId}/user/{userId}/activities/{activityId}/attempts/stats",getUserAttemptForActivity:"/org/{orgId}/user/{userId}/activities/{activityId}/attempts/{attemptId}",getUserFirstAttemptForActivity:"/org/{orgId}/user/{userId}/activities/{activityId}/attempts/first",getUserLastAttemptForActivity:"/org/{orgId}/user/{userId}/activities/{activityId}/attempts/last",getUserActivityMeta:"/org/{orgId}/user/{userId}/activities/{activityId}/meta"},r.PUB_API_URLS={promoteAPI:"/{orgId}/products/{productcode}/promote",registerProductAPI:"/{orgId}/products/register",ingestByCodeAPI:"/{orgId}/products/{productcode}/ingest",createBundle:"/{orgid}/stage/{stage}/bundles",updateBundle:"/{orgid}/stage/{stage}/bundles/{bundleCode}",getAllBundles:"/{orgid}/bundles",getSingleBundle:"/{orgid}/bundles/{bundleCode}",createProductFamily:"/{orgid}/stage/{stage}/families",updateProductFamily:"/{orgid}/stage/{stage}/families/{familyCode}",getSingleProductFamily:"/{orgid}/families/{familyCode}",getAllProductFamilies:"/{orgid}/families"},r.PUSHX_API_URLS={grantByUserOrgId:"/orgs/{orgId}/grants",grantByAccountId:"/accounts/{accountId}/grants",grantV2:"/ver/v2/grants",getPushedEvents:"/accounts/{accountId}/pushed-events/channels"},r.INTEGRATIONS_API_URLS={getGetStreamCredentials:"/accounts/{accountId}/getstream/credentials",queryDataFromSearch:"/search/indices/{index}",auditTrail:"/accounts/{accountId}/audit-trail",customEvents:"/accounts/{accountId}/custom-events",schedules:"/accounts/{accountId}/context/{context}/schedule",particularSchedule:"/accounts/{accountId}/context/{context}/schedule/{scheduleId}"},r.DRIVE_API_URLS={getAParticularDocument:"/accounts/{accountid}/users/{extuserid}/documents/{documentid}",getAllDocumentsInAFolder:"/accounts/{accountid}/users/{extuserid}/documents",documents:"/accounts/{accountid}/users/{userid}/documents/multi"},r.TAXONOMY_API_URLS={associateTagsWithEntity:"/org/{orgId}/taxonomy/associate-tags-with-entity",tags:"/org/{orgId}/context/{context}/taxonomy/{taxonomyId}/tags"},r.RULES_API_URLS={rules:"/org/{orgId}/context/{context}/rule_type/{ruleType}/rules",particularRule:"/org/{orgId}/context/{context}/rule_type/{ruleType}/rules/{ruleId}",updateRuleDisplay:"/org/{orgId}/context/{context}/rule_type/{ruleType}/rules/{ruleId}/update-rule-display",getUserRule:"/org/{orgId}/context/{context}/rule_type/{ruleType}/users/{userId}/rules"}},{}],3:[function(e,t,r){r.api=e("./lib/api"),r.errors=e("./lib/errors"),r.utils=e("./lib/utils"),r.validations=e("./lib/validator")},{"./lib/api":5,"./lib/errors":7,"./lib/utils":8,"./lib/validator":9}],4:[function(e,t,r){var n=e("../errors").DLSError;t.exports={convertUserResponse:function(e){var t=(e=e.data).roles;if(Array.isArray(t)){var r,n={};for(r in t)n[t[r]]=[];e.roles=n}return e},convertClassResponse:function(e){var t,r,n;return!1===(e=e.data).hasOwnProperty("pk")?e:(t={uuid:e.classid,type:"group"},Object.assign(t,e),r=e.class.instructor.first_name,n=e.class.instructor.last_name,t.class.instructor.uuid=e.class.instructor.dls_user_id,(r||n)&&(t.class.instructor.name=r||"",n)&&(t.class.instructor.name+=r?" "+n:n),t)},convertEnrollmetsResponse:function(e){var t,r=e.data;for(t in r){var n=r[t],o=n.first_name,i=n.last_name;(o||i)&&(n.name=o||"",i)&&(n.name+=o?" "+i:i),n.uuid=n.dls_user_id,n.username&&(n.ext_username=n.username),n.username=n.userid+"--ACCOUNT"}return r},convertElasticsearchErrResponse:function(e){var t=e.err,e=new n(e.type,t);return t.response&&t.response.body&&t.response.body.meta&&t.response.body.meta.body&&(e.message="Elasticsearch Error. Please refer data field for more information",e.data=t.response.body.meta.body),e}}},{"../errors":7}],5:[function(e,t,r){var s=e("superagent"),a=e("q"),n=e("string-template"),c=e("../../../config"),u=e("../../../helpers"),d=e("../errors"),l=d.DLSError,p=e("./validations");function f(e,t){return e.set("Authorization",t.access_token)}r.genericAPICaller=function(e,t,r,n){var o=a.defer(),i=p.genericAPICaller(e,t,r,n)||u.validations.isAuthenticated(this.orgId,this.token);i?o.reject(i):(r=c.DEFAULT_HOSTS[e.toUpperCase()]+r,i=f(i=s(t="DELETE"===t?"DEL":t,r),this.token),(i=Object.keys(n).length?"GET"===t||"HEAD"===t?i.query(n):i.send(n):i).end(function(e,t){e?(e=new l(d.ERROR_TYPES.API_ERROR,e),o.reject(e)):o.resolve(t.body)}));return o.promise},r.constructAPIUrl=function(e,t){return n(e,t)},r.setupAPIToken=f,r.addClassIdQueryParam=function(e,t){var r="";null!=t&&(r="?classId="+t);return e+r}},{"../../../config":2,"../../../helpers":3,"../errors":7,"./validations":6,q:42,"string-template":43,superagent:45}],6:[function(e,t,r){var o=e("../validator").validate;r.genericAPICaller=function(e,t,r,n){return o({apiName:e,method:t,url:r,params:n},{apiName:{isString:!0,presence:!0,inclusion:{within:["AUTH","PRODUCT","COLLAB","ANALYTICS","ACTIVITY","XAPI"],message:"^Enter a valid API Name"}},method:{isString:!0,presence:!0,inclusion:{within:["GET","POST","PUT","DELETE"],message:"^Enter a valid HTTP method"}},url:{isString:!0,presence:!0,format:{pattern:"^/.*$",message:"^Url should start with a /"}},params:{isObject:!0}})}},{"../validator":9}],7:[function(e,t,r){var i={API_ERROR:"API_ERROR",SDK_ERROR:"SDK_ERROR",CHANNEL_SUBSCRIPTION:"CHANNEL_SUBSCRIPTION"},n={PUSHX:"PUSHX"},o="ERROR";r.DLSError=function(e,t){if((this.type=e)===i.API_ERROR){var r,n;if(null!=t.response){if(r=t.response.body.message||t.response.body.dbErrorBody||t.response.body.code,n=t.response.body.dbErrorDescription,t.response.body.results&&t.response.body.results.errors)for(var o in r="",t.response.body.results.errors)r+=t.response.body.results.errors[o].message+" ";t.response.body.server&&(this.server=t.response.body.server)}else r=t.message||"",n=t.description||"";this.message=r,this.description=n}else e===i.PUSHX_ERROR?this.message=t.message:(this.message=t.message||"",this.description=t.description||"",delete t.message,delete t.description),this.data=t;e!==i.API_ERROR&&e!==i.PUSHX_ERROR||(this.httpcode=t.status)},r.PUSHXError=function(e,t){e===n.PUSHX?(this.category=n.PUSHX,this.type=t.type||i.CHANNEL_SUBSCRIPTION,this.status=o,this.message=t.message,this.data=t,this.httpcode=t.errorDetails&&t.errorDetails.statusCode?t.errorDetails.statusCode:500):this.message="PUSHXError called for incorrect category."},r.ERROR_TYPES=i,r.ERROR_CATEGORY=n},{}],8:[function(e,t,r){r.isBrowser="undefined"!=typeof window},{}],9:[function(e,t,r){var i=e("validate.js"),s=e("./errors"),a=s.DLSError;function n(e,t){var r={},n=i(e,t);if(n)for(var o in n)return r.message=r.description=n[o][0],r=new a(s.ERROR_TYPES.SDK_ERROR,r)}r.validate=n,r.isAuthenticated=function(e,t){return n({organization:e,token:t},{organization:{presence:{message:"^SDK Instance does not have valid orgid or token. Please authenticate using authWithCredentials or authWithToken method."}},token:{presence:{message:"^SDK Instance does not have valid orgid or token. Please authenticate using authWithCredentials or authWithToken method."}}})},i.validators.isString=function(e,t){if(!i.isString(e))return t.message||"is not a valid string"},i.validators.isObject=function(e,t){if(!i.isObject(e))return t.message||"is not a valid object"},i.validators.contains=function(e,t){if(i.isArray(t)){for(var r in t)if(!e||!e.hasOwnProperty(t[r]))return t.message||"does not contain "+t[r]}else if(i.isString(t)&&(!e||!e.hasOwnProperty(t)))return t.message||"does not contain "+t}},{"./errors":7,"validate.js":50}],10:[function(e,t,r){var i=e("q"),s=e("superagent"),a=e("../helpers"),c=a.errors.DLSError;r.getClassEnrolmentsStat=function(e,t){var r=i.defer(),n={};{var o;e&&t&&t.classid?(o=this.config.DEFAULT_HOSTS.ANALYTICS+this.config.ANALYTICS_API_URLS.getClassEnrolmentsStat,o=a.api.constructAPIUrl(o,{orgId:e}),e=s.get(o).query(t),this.traceid&&e.set("X-Amzn-Trace-Id",this.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Mandatory params not found in request body : [orgid, classid]",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise},r.getSingleInvitation=function(e,t){var r={},n=i.defer();{var o;e&&t&&t.context_id&&t.context&&t.invitationid?(o=this.config.DEFAULT_HOSTS.AUTH+this.config.AUTH_API_URLS.getSingleInvitation,o=a.api.constructAPIUrl(o,{orgId:e,invitationId:t.invitationid}),e={context:t.context,context_id:t.context_id},t=s.get(o).query(e),this.traceid&&t.set("X-Amzn-Trace-Id",this.traceid),t.end(function(e,t){e?(r=new c(a.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):(r.message=r.description="organizationId or context_id or context or invitationid not found in request options.",r=new c(a.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}},{"../helpers":3,q:42,superagent:45}],11:[function(e,t,r){var n=e("superagent"),o=e("q"),i=e("../../helpers"),s=i.errors.DLSError,a=(e("extend"),t.exports=c,e("./attempt"));function c(e,t,r){var n;if(!(this instanceof c))return(n=new c(e,t,r)).token=this.token,n.orgId=this.orgId,n.config=this.config,n;this.productId=e,this.activityId=t,this.classId=r}c.prototype.getDetails=function(){var e=this,r=o.defer(),t=i.validations.isAuthenticated(this.orgId,this.token);return t?r.reject(t):(t=e.config.DEFAULT_HOSTS.ACTIVITY+e.config.ACTIVITY_API_URLS.activityDetailsAPI,t=i.api.constructAPIUrl(t,{orgId:e.orgId,productId:e.productId,activityId:e.activityId}),t=i.api.addClassIdQueryParam(t,e.classId),t=n.get(t),t=i.api.setupAPIToken(t,e.token),e.traceid&&t.set("X-Amzn-Trace-Id",e.traceid),t.end(function(e,t){e?(e=new s(i.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):(e=t.body,(t=new Object).activity=e,r.resolve(t))})),r.promise},c.prototype.loadAttempt=function(e){e=new a(this.productId,this.activityId,e,null,this.classId,this.config);return e.setAuthCredentials(this.orgId,this.token),e.getAttemptInfo()},c.prototype.getAttempt=function(e){e=new a(this.productId,this.activityId,e,null,this.classId,this.config);return e.setAuthCredentials(this.orgId,this.token),e},c.prototype.newAttempt=function(e){var t=new a(this.productId,this.activityId,null,null,this.classId,this.config);return t.setAuthCredentials(this.orgId,this.token),t.start(e)},c.prototype.getAllQuestions=function(){var e=this,r=o.defer(),t=i.validations.isAuthenticated(this.orgId,this.token);return t?r.reject(t):(t=e.config.DEFAULT_HOSTS.PRODUCT+e.config.PRODUCT_API_URLS.activityAPI,t=i.api.constructAPIUrl(t,{orgId:e.orgId,productId:e.productId,activityId:e.activityId}),t=i.api.addClassIdQueryParam(t,e.classId),t=n.get(t),t=i.api.setupAPIToken(t,e.token),e.traceid&&t.set("X-Amzn-Trace-Id",e.traceid),t.end(function(e,t){e?(e=new s(i.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):(e=t.body,(t=new Object).questions=e.items,r.resolve(t))})),r.promise},c.prototype.getQuestionsCount=function(){var e=this,r=o.defer(),t=i.validations.isAuthenticated(this.orgId,this.token);return t?r.reject(t):(t=e.config.DEFAULT_HOSTS.PRODUCT+e.config.PRODUCT_API_URLS.activityAPI,t=i.api.constructAPIUrl(t,{orgId:e.orgId,productId:e.productId,activityId:e.activityId}),t=i.api.addClassIdQueryParam(t,e.classId),t=n.get(t),t=i.api.setupAPIToken(t,e.token),e.traceid&&t.set("X-Amzn-Trace-Id",e.traceid),t.end(function(e,t){e?(e=new s(i.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):(e={count:t.body.items.length},(t=new Object).count=e,r.resolve(t))})),r.promise}},{"../../helpers":3,"./attempt":12,extend:39,q:42,superagent:45}],12:[function(e,t,r){var s=e("superagent"),a=e("q"),c=e("../../helpers"),u=c.errors.DLSError,d=e("extend");function l(e,t,r,n,o,i){this.productId=e,this.activityId=t,this.attemptId=r,this.classId=o,this.config=i,l.prototype.getAuthCredentials=function(){return function(){return this.authCredentials}()},l.prototype.setAuthCredentials=function(e,t){var r=new Object;r.orgId=e,r.token=t,function(e){this.authCredentials=e}(r)}}(t.exports=l).prototype.start=function(e){var r=this,t=this.getAuthCredentials().orgId,n=this.getAuthCredentials().token,o=a.defer(),i=c.validations.isAuthenticated(t,n);return i?o.reject(i):(i=r.config.DEFAULT_HOSTS.ACTIVITY+r.config.ACTIVITY_API_URLS.newAttemptAPI,i=c.api.constructAPIUrl(i,{orgId:t,productId:r.productId,activityId:r.activityId}),i=c.api.addClassIdQueryParam(i,r.classId),null==e&&(e={}),t=s.post(i).send(e),t=c.api.setupAPIToken(t,n),r.traceid&&t.set("X-Amzn-Trace-Id",r.traceid),t.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),o.reject(e)):(e=t.body,r.attemptId=e.uuid,d(!0,r,e),(t=new Object).attempt=r,o.resolve(t))})),o.promise},l.prototype.getAttemptInfo=function(){var e=this.getAuthCredentials().orgId,t=this.getAuthCredentials().token,r=this,n=a.defer(),o=c.validations.isAuthenticated(e,t);return o?n.reject(o):(o=r.config.DEFAULT_HOSTS.ACTIVITY+r.config.ACTIVITY_API_URLS.existingAttemptAPI,o=c.api.constructAPIUrl(o,{orgId:e,productId:r.productId,activityId:r.activityId,attemptId:r.attemptId}),o=c.api.addClassIdQueryParam(o,r.classId),e=s.get(o),e=c.api.setupAPIToken(e,t),r.traceid&&e.set("X-Amzn-Trace-Id",r.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):(e=t.body,r.attemptId=e.uuid,d(!0,r,e),(t=new Object).attempt=r,n.resolve(t))})),n.promise},l.prototype.getState=function(){var e=this.getAuthCredentials().orgId,t=this.getAuthCredentials().token,r=this,n=a.defer(),o=c.validations.isAuthenticated(e,t);return o?n.reject(o):(o=r.config.DEFAULT_HOSTS.ACTIVITY+r.config.ACTIVITY_API_URLS.existingAttemptAPI,o=c.api.constructAPIUrl(o,{orgId:e,productId:r.productId,activityId:r.activityId,attemptId:r.attemptId}),o=c.api.addClassIdQueryParam(o,r.classId),e=s.get(o),e=c.api.setupAPIToken(e,t),r.traceid&&e.set("X-Amzn-Trace-Id",r.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):(e=t.body,(t=new Object).state=e.data.savedstate.state,n.resolve(t))})),n.promise},l.prototype.saveState=function(e){var t=this.getAuthCredentials().orgId,r=this.getAuthCredentials().token,n=this,o=a.defer(),i=c.validations.isAuthenticated(t,r);return i?o.reject(i):(i=n.config.DEFAULT_HOSTS.ACTIVITY+n.config.ACTIVITY_API_URLS.existingAttemptAPI,i=c.api.constructAPIUrl(i,{orgId:t,productId:n.productId,activityId:n.activityId,attemptId:n.attemptId}),i=c.api.addClassIdQueryParam(i,n.classId),t=s.put(i).send(e),t=c.api.setupAPIToken(t,r),n.traceid&&t.set("X-Amzn-Trace-Id",n.traceid),t.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),o.reject(e)):(e=t.body,(t=new Object).status=e,o.resolve(t))})),o.promise},l.prototype.getUserResponse=function(){var e=this.getAuthCredentials().orgId,t=this.getAuthCredentials().token,r=this,n=a.defer(),o=c.validations.isAuthenticated(e,t);return o?n.reject(o):(o=r.config.DEFAULT_HOSTS.ACTIVITY+r.config.ACTIVITY_API_URLS.userResponseAPI,o=c.api.constructAPIUrl(o,{orgId:e,productId:r.productId,activityId:r.activityId,attemptId:r.attemptId}),o=c.api.addClassIdQueryParam(o,r.classId),e=s.get(o),e=c.api.setupAPIToken(e,t),r.traceid&&e.set("X-Amzn-Trace-Id",r.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):(e=t.body,(t=new Object).userresponse=e,n.resolve(t))})),n.promise},l.prototype.saveUserResponse=function(e){var t=this.getAuthCredentials().orgId,r=this.getAuthCredentials().token,n=this,o=a.defer(),i=c.validations.isAuthenticated(t,r);return i?o.reject(i):(i=n.config.DEFAULT_HOSTS.ACTIVITY+n.config.ACTIVITY_API_URLS.userResponseAPI,i=c.api.constructAPIUrl(i,{orgId:t,productId:n.productId,activityId:n.activityId,attemptId:n.attemptId}),i=c.api.addClassIdQueryParam(i,n.classId),t=s.put(i).send(e),t=c.api.setupAPIToken(t,r),n.traceid&&t.set("X-Amzn-Trace-Id",n.traceid),t.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),o.reject(e)):(e=t.body,(t=new Object).status=e,o.resolve(t))})),o.promise},l.prototype.submit=function(e){var t=this.getAuthCredentials().orgId,r=this.getAuthCredentials().token,n=this,o=a.defer(),i=c.validations.isAuthenticated(t,r);return i?o.reject(i):(i=n.config.DEFAULT_HOSTS.ACTIVITY+n.config.ACTIVITY_API_URLS.submitAttemptAPI,i=c.api.constructAPIUrl(i,{orgId:t,productId:n.productId,activityId:n.activityId,attemptId:n.attemptId}),i=c.api.addClassIdQueryParam(i,n.classId),t=null==e?s.post(i).send({}):s.post(i).send(e),t=c.api.setupAPIToken(t,r),n.traceid&&t.set("X-Amzn-Trace-Id",n.traceid),t.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),o.reject(e)):(e=t.body,(t=new Object).status=e,o.resolve(t))})),o.promise}},{"../../helpers":3,extend:39,q:42,superagent:45}],13:[function(e,t,r){t.exports=e("./activity")},{"./activity":11}],14:[function(e,t,r){var s=e("q"),a=e("superagent"),n=e("agentkeepalive"),c=e("../../helpers"),u=c.errors.DLSError,d=(t.exports=function(){return{archiveUserAnalytics:function(e){var t=this,r={},n=s.defer();{var o,i;e&&e.userid&&e.productid?(r=c.validations.isAuthenticated(t.orgId,t.token))?n.reject(r):(o={},i=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.archiveUserAnalytics,i=c.api.constructAPIUrl(i,{orgId:t.orgId}),e.userid&&(o.userid=e.userid),e.productid&&(o.productid=e.productid),e.classid&&(o.classid=e.classid),e=a.post(i).query(o).set("Content-Type","application/json"),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):n.resolve(t.body)})):(r.message=r.description="Mandatory parameter [userid, productid] not found in request options",r=new u(c.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),getArchivedUserAnalytics:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.useranalyticid?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getArchivedUserAnalytics,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={useranalyticid:e.useranalyticid},e&&(e.cursor&&(i.cursor=e.cursor),e.limit)&&(i.limit=e.limit),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Mandatory field 'useranalyticid' not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getOrgAnalyticsStat:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.type?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(n={},-1<["users","classes"].indexOf(e.type)?(i=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getOrgAnalyticsStat,i=c.api.constructAPIUrl(i,{orgId:t.orgId,type:e.type}),o={},e&&(e.range&&(o.range=e.range),e.start&&(o.start=e.start),e.end&&(o.end=e.end),e.role&&(o.role=e.role),e.shadow)&&(o.shadow=e.shadow),i=a.get(i).query(o),i=c.api.setupAPIToken(i,t.token),t.traceid&&i.set("X-Amzn-Trace-Id",t.traceid),i.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Type: "+e.type+" is not supported",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))):(n.message=n.description="type not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getClassAnalytics:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.type&&e.analyticsDataType&&e.classid?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(n={},!e.range&&!e.interval||e.range&&"stat"===e.type||e.interval&&"timeseries"===e.type?-1<["enrolments","logins"].indexOf(e.analyticsDataType)?(i=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getClassAnalytics,i=c.api.constructAPIUrl(i,{orgId:t.orgId,type:e.type,analyticsDataType:e.analyticsDataType}),o={classid:e.classid},e&&(e.range&&(o.range=e.range),e.start&&(o.start=e.start),e.end&&(o.end=e.end),e.interval)&&(o.interval=e.interval),i=a.get(i).query(o),i=c.api.setupAPIToken(i,t.token),t.traceid&&i.set("X-Amzn-Trace-Id",t.traceid),i.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="analyticsDataType: "+e.analyticsDataType+" is not supported",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n)):(n.message=n.description='Range should be defined for type - "stat" and Interval should be defined for type - "timeseries"',n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))):(n.message=n.description='Required options ["type", "analyticsDataType", "classid"] not found in request options',n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getClassProductRecentPendingSubmissions:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.classid&&e.productcode?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getClassProductRecentPendingSubmissions,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={classid:e.classid,productcode:e.productcode},e.details&&(i.details=e.details),e.limit&&(i.limit=e.limit),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description='Mandatory parameters ["classid", "productcode"] not found in request options.',n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getClassRecordUserAggregations:function(e){var t=this,r={},n=s.defer();{var o;e&&e.classid&&e.productcode?(r=c.validations.isAuthenticated(t.orgId,t.token))?n.reject(r):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getClassRecordUserAggregations,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),e={classid:e.classid,productcode:e.productcode,userid:e.userid},o=a.get(o).query(e),o=c.api.setupAPIToken(o,t.token),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(r=new u(c.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):(r.message=r.description="Required parameter classid or productcode not found in request options.",r=new u(c.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),getClassRecord:function(e){var t=this,r=s.defer(),n={};{var o;e&&e.classid&&e.productcode?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getClassRecord,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),e={classid:e.classid,productcode:e.productcode,userids:e.userids,includeContext:e.includeContext},o=a.get(o).query(e),o=c.api.setupAPIToken(o,t.token),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description="Required parameter classid or productcode not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getClassRecordItemAggregations:function(e){var t=this,r=s.defer(),n={};{var o;e&&e.classid&&e.productcode?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getClassRecordItemAggregations,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),e={classid:e.classid,productcode:e.productcode,"item-code":e["item-code"]},o=a.get(o).query(e),o=c.api.setupAPIToken(o,t.token),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description="Required parameter classid or productcode not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getShowcaseRecordOfAClass:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.classid?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getShowcaseRecordOfAClass,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={classid:e.classid},e.productcode&&(i.productcode=e.productcode),e.groupid&&(i.groupid=e.groupid),e["item-code"]&&(i["item-code"]=e["item-code"]),e.id&&(i.id=e.id),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description="Required parameter classid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getGroupRecord:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.classid&&e.productcode&&e.groupid?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getGroupRecord,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={classid:e.classid,productcode:e.productcode,groupid:e.groupid},e.itemcode&&(i.itemcode=e.itemcode),e.history&&(i.history=e.history),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description="Required parameter classid or productcode or groupid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getClassGroupsRecentPendingSubmissions:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.classid&&e.productcode?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getClassGroupsRecentPendingSubmissions,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={classid:e.classid,productcode:e.productcode},e.details&&(i.details=e.details),e.limit&&(i.limit=e.limit),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description='Mandatory parameters ["classid", "productcode"] not found in request options.',n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getGroupsWithEvaluatedOnce:function(e){var t=this,r={},n=s.defer();{var o;e&&e.classid&&e.productcode?(r=c.validations.isAuthenticated(t.orgId,t.token))?n.reject(r):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getGroupsWithEvaluatedOnce,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),e={classid:e.classid,productcode:e.productcode},o=a.get(o).query(e),o=c.api.setupAPIToken(o,t.token),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(r=new u(c.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):(r.message=r.description="Required parameter classid or productcode not found in request options.",r=new u(c.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),getUserProductAnalytics:function(e){var t=this,r=s.defer(),n={};if(e&&e.type&&e.userid&&e.productcode)if(n=c.validations.isAuthenticated(t.orgId,t.token))r.reject(n);else{var o=t.config.DEFAULT_HOSTS.ANALYTICS;if(-1<["items","summary"].indexOf(e.type)){switch(e.type){case"items":o+=t.config.ANALYTICS_API_URLS.getAnalyticProductItems;break;case"summary":o+=t.config.ANALYTICS_API_URLS.getAnalyticProductSummary}o=c.api.constructAPIUrl(o,{orgId:t.orgId});var i={userid:e.userid,productcode:e.productcode},i=(e.classid&&(i.classid=e.classid),e.itemcode&&(i.itemcode=e.itemcode),e.metrics&&(i.metrics=e.metrics),e.history&&(i.history=e.history),e.group&&(i.group=e.group),e.externalData&&(i.externalData=e.externalData),e.expiredView&&"items"===e.type&&(i.expiredView=e.expiredView),a.get(o).query(i));i=c.api.setupAPIToken(i,t.token),t.traceid&&i.set("X-Amzn-Trace-Id",t.traceid),i.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})}else n.message=n.description=e.type+" is not a valid value of option 'type'",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n)}else n.message=n.description="Required parameter 'type' or 'userid' or 'productcode' not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n);return r.promise}.bind(this),getUserProductAnalyticById:function(e){var t=this,r=s.defer(),n={};{var o;e&&e.userprogressid?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getAnalyticProductById,o=c.api.constructAPIUrl(o,{orgId:t.orgId,userProgressId:e.userprogressid}),e=a.get(o),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Required parameter 'userprogressid' not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getExternalDataForUserAnalyticItem:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.ext_user_id&&e.productcode&&e.itemcode&&(e.submission_order||e.ext_link_id)&&e.part?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getExternalDataForUserAnalyticItem,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={ext_user_id:e.ext_user_id,productcode:e.productcode,itemcode:e.itemcode,part:e.part},e.submission_order&&(i.submission_order=e.submission_order),e.ext_link_id&&(i.ext_link_id=e.ext_link_id),e.classid&&(i.classid=e.classid),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Required parameters 'ext_user_id' or 'productcode' or 'itemcode' or (either 'submission_order' OR 'ext_link_id') or 'part'are not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),searchUserProductAnalytics:function(e){var t=this,r={},n=s.defer();{var o;(r=c.validations.isAuthenticated(t.orgId,t.token))?n.reject(r):(r={},o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.searchUserProductAnalytics,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),e.userid&&(r.userid=e.userid),e.productid&&(r.productid=e.productid),e.classid&&(r.classid=e.classid),e.lookup&&(r.lookup=e.lookup),e.cursor&&(r.cursor=e.cursor),e.limit&&(r.limit=e.limit),e=a.get(o).query(r),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):n.resolve(t.body)}))}return n.promise}.bind(this),getUserClassRecentSubmissions:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.classid&&e.productcode&&e.userid?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getUserClassRecentSubmissions,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={userid:e.userid,classid:e.classid,productcode:e.productcode},e.gradingStatus&&(i.gradingStatus=e.gradingStatus),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description='Mandatory parameters ["classid", "productcode", "userid"] not found in request options.',n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getStudentsWithEvaluatedOnce:function(e){var t=this,r={},n=s.defer();{var o;e&&e.classid&&e.productcode?(r=c.validations.isAuthenticated(t.orgId,t.token))?n.reject(r):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getStudentsWithEvaluatedOnce,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),e={classid:e.classid,productcode:e.productcode},o=a.get(o).query(e),o=c.api.setupAPIToken(o,t.token),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(r=new u(c.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):(r.message=r.description="Required parameter classid or productcode not found in request options.",r=new u(c.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),getAppState:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.userid&&e.productcode?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.appState,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={userid:e.userid,productcode:e.productcode},e.classid&&(i.classid=e.classid),e.itemcode&&(i.itemcode=e.itemcode),e.key&&(i.key=e.key),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Required parameters 'userid' or 'productcode' are not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateAppState:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.userid&&e.productcode&&e.appdata?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(i=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.appState,i=c.api.constructAPIUrl(i,{orgId:t.orgId}),o={userid:e.userid,productcode:e.productcode},e.classid&&(o.classid=e.classid),e.itemcode&&(o.itemcode=e.itemcode),i=a.put(i).query(o).set("Content-Type","application/json").set("Accept","application/json").send(e.appdata),i=c.api.setupAPIToken(i,t.token),t.traceid&&i.set("X-Amzn-Trace-Id",t.traceid),i.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Required parameters 'userid' or 'appdata' or 'productcode' are not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),deleteAppState:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.userid&&e.productcode?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.appState,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={userid:e.userid,productcode:e.productcode},e.classid&&(i.classid=e.classid),e.itemcode&&(i.itemcode=e.itemcode),e.key&&(i.key=e.key),e=a.delete(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Required parameters 'userid' or 'productcode' are not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getUserProductAllState:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.userid&&e.productcode?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getUserProductAllState,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={userid:e.userid,productcode:e.productcode},e.classid&&(i.classid=e.classid),e.itemcode&&(i.itemcode=e.itemcode),e.model&&(i.model=e.model),e.key&&(i.key=e.key),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Required parameters 'userid' or 'productcode' are not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateUserProductMultiState:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.userid&&e.productcode&&e.data?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(i=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.updateUserProductMultiState,i=c.api.constructAPIUrl(i,{orgId:t.orgId}),o={userid:e.userid,productcode:e.productcode},e.classid&&(o.classid=e.classid),i=a.put(i).query(o).set("Content-Type","application/json").set("Accept","application/json").send(e.data),i=c.api.setupAPIToken(i,t.token),t.traceid&&i.set("X-Amzn-Trace-Id",t.traceid),i.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t)})):(n.message=n.description="Required parameters 'userid' or 'data' or 'productcode' are not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getQuestionProgressByLearningObjective:function(e){for(var t,r,n={},o=0;o<e.length;o++)for(var i,s,a=e[o]["learning-objectives"],c=0;c<a.length;c++)n[a[c]]?(s=n[a[c]],"correct"===(t=e[o].__analytics).statusEvaluation&&(r=s.status.correct,s.status.correct=r+1),i=s.status.total,s.status.total=i+1,i={"question-code":e[o].questionCode,analytics:t},s.questions.push(i),n[a[c]]=s):(r=0,"correct"===(t=e[o].__analytics).statusEvaluation&&r++,s={status:{correct:r,total:1},questions:[]},i={"question-code":e[o].questionCode,analytics:t},s.questions.push(i),n[a[c]]=s);return n}.bind(this),getAllAssignedPathsOfClass:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid?(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getAllAssignedPathsOfClass,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),e={classid:e.classid,status_not_started:e.status_not_started,status_active:e.status_active,status_expired:e.status_expired,limit:e.limit,cursor:e.cursor},o=a.get(o).query(e),o=c.api.setupAPIToken(o,t.token),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.agent(d).end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory param - classid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getMyAssignedPathsOfClass:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.classid&&e.userid?(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getMyAssignedPathsOfClass,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={userid:e.userid,classid:e.classid},e.progress&&(i.progress=e.progress),e.group&&(i.group=e.group),e.expiredView&&(i.expiredView=e.expiredView),e.status_not_started&&(i.status_not_started=e.status_not_started),e.status_active&&(i.status_active=e.status_active),e.status_expired&&(i.status_expired=e.status_expired),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.agent(d).end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - classid, userid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getUserAssignedPathsOfClass:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.classid&&e.userid?(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getMyAssignedPathsOfClass,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={userid:e.userid,classid:e.classid},e.progress&&(i.progress=e.progress),e.group&&(i.group=e.group),e.expiredView&&(i.expiredView=e.expiredView),e.status_not_started&&(i.status_not_started=e.status_not_started),e.status_active&&(i.status_active=e.status_active),e.status_expired&&(i.status_expired=e.status_expired),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.agent(d).end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - classid, userid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAssignedPathAnalytics:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid&&e.productcode?(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getAssignedPathAnalytics,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),e={classid:e.classid,assignedpathid:e.assignedPathId,ext_assignedpathid:e.ext_assignedpathid,productcode:e.productcode},o=a.get(o).query(e),o=c.api.setupAPIToken(o,t.token),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - classid or productcode not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getMyParticularAssignedPathOfClass:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.classid&&e.userid?(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getMyAssignedPathsOfClass,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={assignedpathid:e.assignedPathId,classid:e.classid,userid:e.userid},e.progress&&(i.progress=e.progress),e.group&&(i.group=e.group),e.assignedpathid&&(i.assignedpathid=e.assignedpathid),e.ext_assignedpathid&&(i.ext_assignedpathid=e.ext_assignedpathid),e.expiredView&&(i.expiredView=e.expiredView),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - classid, userid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getParticularAssignedPathOfClass:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.classid&&(e.assignedpathid||e.ext_assignedpathid)?(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getAllAssignedPathsOfClass,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={classid:e.classid},e.assignedpathid&&(i.assignedpathid=e.assignedpathid),e.ext_assignedpathid&&(i.ext_assignedpathid=e.ext_assignedpathid),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.agent(d).end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body.entities[0])})):((n={}).message=n.description="Mandatory params - 'classid', 'assignedpathid'/'ext_assignedpathid' not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getTimeseriesAnalytics:function(e){var r,n=s.defer();{var t,o;e&&e.query?(t=this.config.DEFAULT_HOSTS.ANALYTICS+this.config.ANALYTICS_API_URLS.timeseriesAnalytics,o={query:e.query},e.cursor&&(o.cursor=e.cursor),e=a.get(t).query(o),this.traceid&&e.set("X-Amzn-Trace-Id",this.traceid),e.agent(d).end(function(e,t){e?(r=new u(c.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):((r={}).message=r.description="Mandatory params query not found in request options.",r=new u(c.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),postProgressTimeseries:function(e){var r,n=s.defer();{var t;e&&e.body&&e.body.query?(t=this.config.DEFAULT_HOSTS.ANALYTICS+this.config.ANALYTICS_API_URLS.timeseriesAnalytics,t=a.post(t).send(e.body),e.cursor&&(e={cursor:e.cursor},t.query(e)),this.traceid&&t.set("X-Amzn-Trace-Id",this.traceid),t.agent(d).end(function(e,t){e?(r=new u(c.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):((r={}).message=r.description="Mandatory options.body.query not found in request options.",r=new u(c.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),getClassCustomComponentRecord:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.classid?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getClassCustomComponentRecord,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={classid:e.classid},e.custom_component_code&&(i.custom_component_code=e.custom_component_code),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?((n=new u(c.errors.ERROR_TYPES.API_ERROR,e)).message=e.response.res.text,r.reject(n)):r.resolve(t.body)})):(n.message=n.description="Required parameter classid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getClassCustomComponentUserSubmission:function(e){var t=this,r=s.defer(),n={};{var o;e&&e.classid&&e.custom_component_code&&e.userid&&e.item_code?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getClassCustomComponentUserSubmission,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),e={classid:e.classid,userid:e.userid,custom_component_code:e.custom_component_code,item_code:e.item_code},o=a.get(o).query(e),o=c.api.setupAPIToken(o,t.token),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?((n=new u(c.errors.ERROR_TYPES.API_ERROR,e)).message=e.response.res.text,r.reject(n)):r.resolve(t.body)})):(n.message=n.description="Required parameter classid or custom-component-code or userid or item-code not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getCrossProductAggregation:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.classid?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getCrossProductAggregation,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={classid:e.classid},e.userid&&(i.userid=e.userid),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description="Required parameter classid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this)}},new n({timeout:6e4,freeSocketTimeout:3e4}))},{"../../helpers":3,agentkeepalive:36,q:42,superagent:45}],15:[function(e,t,r){var i=e("q"),s=e("superagent"),a=e("../../helpers"),c=a.errors.DLSError;t.exports=function(){return{getUserAllAttemptsForActivity:function(e){var t=this,r=i.defer();{var n,o;e&&e.userid&&e.activityid?(n=t.config.DEFAULT_HOSTS.ATTEMPTS+t.config.ATTEMPTS_API_URLS.userAttempts,n=a.api.constructAPIUrl(n,{orgId:t.orgId,userId:e.userid,activityId:e.activityid}),o={},e.allorgs&&(o.allorgs=e.allorgs),e.classid&&(o.classid=e.classid),e.assignmentid&&(o.assignmentid=e.assignmentid),e.productcode&&(o.productcode=e.productcode),e.cursor&&(o.cursor=e.cursor),e.limit&&(o.limit=e.limit),e.sortOrder&&(o.sortOrder=e.sortOrder),e=s.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - userid or activityid not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createUserAttemptForActivity:function(e){var t=this,r=i.defer();{var n;e&&e.userid&&e.activityid&&e.body?(n=t.config.DEFAULT_HOSTS.ATTEMPTS+t.config.ATTEMPTS_API_URLS.userAttempts,n=a.api.constructAPIUrl(n,{orgId:t.orgId,userId:e.userid,activityId:e.activityid}),n=s.post(n).send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory params - userid or activityid or body not found in request options.",e=new c(a.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),getUserAttemptStatsForActivity:function(e){var t=this,r=i.defer();{var n,o;e&&e.userid&&e.activityid?(n=t.config.DEFAULT_HOSTS.ATTEMPTS+t.config.ATTEMPTS_API_URLS.getUserAttemptStatsForActivity,n=a.api.constructAPIUrl(n,{orgId:t.orgId,userId:e.userid,activityId:e.activityid}),o={},e.allorgs&&(o.allorgs=e.allorgs),e.classid&&(o.classid=e.classid),e.assignmentid&&(o.assignmentid=e.assignmentid),e=s.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - userid or activityid not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getUserAttemptForActivity:function(e){var t=this,r=i.defer();{var n,o;e&&e.userid&&e.activityid&&e.attemptid?(n=t.config.DEFAULT_HOSTS.ATTEMPTS+t.config.ATTEMPTS_API_URLS.getUserAttemptForActivity,n=a.api.constructAPIUrl(n,{orgId:t.orgId,userId:e.userid,activityId:e.activityid,attemptId:e.attemptid}),o={},e.details&&(o.details=e.details),e=s.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - userid or activityid or attemptid not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getUserFirstAttemptForActivity:function(e){var t=this,r=i.defer();{var n,o;e&&e.userid&&e.activityid?(n=t.config.DEFAULT_HOSTS.ATTEMPTS+t.config.ATTEMPTS_API_URLS.getUserFirstAttemptForActivity,n=a.api.constructAPIUrl(n,{orgId:t.orgId,userId:e.userid,activityId:e.activityid}),o={},e.details&&(o.details=e.details),e.classid&&(o.classid=e.classid),e.assignmentid&&(o.assignmentid=e.assignmentid),e=s.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - userid or activityid not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getUserLastAttemptForActivity:function(e){var t=this,r=i.defer();{var n,o;e&&e.userid&&e.activityid?(n=t.config.DEFAULT_HOSTS.ATTEMPTS+t.config.ATTEMPTS_API_URLS.getUserLastAttemptForActivity,n=a.api.constructAPIUrl(n,{orgId:t.orgId,userId:e.userid,activityId:e.activityid}),o={},e.details&&(o.details=e.details),e.classid&&(o.classid=e.classid),e.assignmentid&&(o.assignmentid=e.assignmentid),e=s.get(n).query(o),console.log(n,o,e),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - userid or activityid not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateUserAttemptForActivity:function(e){var t=this,r=i.defer();{var n;e&&e.userid&&e.activityid&&e.attemptid&&e.body?(n=t.config.DEFAULT_HOSTS.ATTEMPTS+t.config.ATTEMPTS_API_URLS.getUserAttemptForActivity,n=a.api.constructAPIUrl(n,{orgId:t.orgId,userId:e.userid,activityId:e.activityid,attemptId:e.attemptid}),e=e.body,n=s.put(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory params - userid or activityid or attemptid or body not found in request options.",e=new c(a.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),getUserActivityMeta:function(e){var t=this,r=i.defer();{var n,o;e&&e.userid&&e.activityid?(n=t.config.DEFAULT_HOSTS.ATTEMPTS+t.config.ATTEMPTS_API_URLS.getUserActivityMeta,n=a.api.constructAPIUrl(n,{orgId:t.orgId,userId:e.userid,activityId:e.activityid}),o={},e.classid&&(o.classid=e.classid),e.assignmentid&&(o.assignmentid=e.assignmentid),e=s.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - userid or activityid not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this)}}},{"../../helpers":3,q:42,superagent:45}],16:[function(e,t,r){var m=e("q"),R=e("superagent"),n=e("agentkeepalive"),_=e("../../helpers"),A=e("../../helpers/lib/api/converter"),b=_.errors.DLSError,d=(t.exports=function(){return{pisImport:function(e){var t,r=this,n=m.defer(),o=_.validations.isAuthenticated(r.orgId,r.token);{var i;o?n.reject(o):(o=r.config.DEFAULT_HOSTS.AUTH+r.config.AUTH_API_URLS.pisImportAPI,o=_.api.constructAPIUrl(o,{orgId:r.orgId}),i={},e&&(e.extension&&(i.extension=e.extension),e.import_type&&(i.import_type=e.import_type),e.upfile)&&(t=e.upfile),e=R.post(o).query(i).set("Content-Type","multipart/form-data").attach("upfile",t),r.traceid&&e.set("X-Amzn-Trace-Id",r.traceid),(e=_.api.setupAPIToken(e,r.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):n.resolve(t.body)}))}return n.promise}.bind(this),getAllUsers:function(s){var a=this,c=m.defer(),e=_.validations.isAuthenticated(a.orgId,a.token);if(e)c.reject(e);else{e='orgid:"'+a.orgId+'"';if(s.lookup&&s["lookup-operator"]&&(n=s.lookup,n=(n=n.replace(/ext_/gi,"")).split(",").map(function(e){var e=e.trim(),t=e.split(":");return e="("+e+" OR "+t[0]+".keyword:"+t[1]+")"}),e=e+" AND ("+n.join(" "+s["lookup-operator"]+" ")+")"),s.role){var t,r=s.role.split(",").map(function(e){return e.trim()});for(t in r)r[t]="roles:"+r[t];e=e+" AND ("+r.join(" OR ")+")"}s.search&&(e=e+' AND (email:"'+s.search+'" OR first_name:"'+s.search+'" OR last_name:"'+s.search+'" OR username:"'+s.search+'" OR userid:"'+s.search+'")');var n=s.sortField||"",o=(n=n.replace(/ext_/gi,"").split(",").shift().trim()||"last_name",s.sortOrder||"asc"),i=("created"!==n&&(n+=".keyword"),{}),u=[],n=(i[n]=o,u.push(i),{query:{query_string:{query:e}},sort:u}),o=(s.cursor&&(n.search_after=JSON.parse(s.cursor)),s.limit?n.size=s.limit:s.limit=10,a.config.DEFAULT_HOSTS.INTEGRATION+a.config.INTEGRATIONS_API_URLS.queryDataFromSearch),i=(o=_.api.constructAPIUrl(o,{index:"users"}),{query:JSON.stringify(n)}),e=R.get(o).query(i);a.traceid&&e.set("X-Amzn-Trace-Id",a.traceid),(e=_.api.setupAPIToken(e,a.token)).end(function(e,t){if(e){e={type:_.errors.ERROR_TYPES.API_ERROR,err:e},e=A.convertElasticsearchErrResponse(e);c.reject(e)}else{var r,n={entities:[]};for(r in n.count=t.body.hits.hits.length,n.count&&s.limit===n.count&&(e=t.body.hits.hits[t.body.hits.hits.length-1].sort,n.cursor=JSON.stringify(e)),t.body.hits.hits){var o=t.body.hits.hits[r]._source,i={uuid:o.dls_user_id,name:o.first_name+" "+o.last_name,email:o.email||o.ext_email,username:o.userid+"--ACCOUNT",created:o.created,org:{id:a.orgId}};o.roles&&(i.roles=o.roles),o.provision_method&&(i.provision_method=o.provision_method),o.first_name&&(i.first_name=o.first_name),o.last_name&&(i.last_name=o.last_name),o.ext_parent_id&&(i.ext_parent_id=o.ext_parent_id),o.username&&(i.ext_username=o.username),o.userid&&(i.ext_user_id=o.userid),o.address&&(i.address=o.address),n.entities.push(i)}c.resolve(n)}})}return c.promise}.bind(this),getAllUsersV2:function(s){var e,t,a=this,c=m.defer(),r=_.validations.isAuthenticated(a.orgId,a.token);if(r)c.reject(r);else{var n={query:{bool:{must:[]}},size:s.limit||10},o='orgid:"'+a.orgId+'"';if(s.role){for(var i in h=s.role,e=h.split(",").map(function(e){return e.trim()}))e[i]="roles:"+e[i];o=o+" AND ("+e.join(" OR ")+")"}if(n.query.bool.must.push({query_string:{query:o}}),s.lookup&&s["lookup-operator"]){h=s.lookup.replace(/ext_/gi,""),t=h.split(",");var u,d={bool:{}};for(u in t){var l,p=t[u].trim().split(":"),f={wildcard:{}};if(l=p[0]+".keyword",p=p[1],f.wildcard[l]="email.keyword"==l?{value:p,case_insensitive:!0}:{value:p,case_insensitive:!1},"OR"!==s["lookup-operator"])return(r={}).message=r.description="The value 'AND' for the field 'lookup-operator' is currently NOT supported",r=new b(_.errors.ERROR_TYPES.SDK_ERROR,r),c.reject(r),c.promise;d.bool.should||(d.bool.should=[]),d.bool.should.push(f)}n.query.bool.must.push(d)}var o={},h=[],g=(y=s.sortOrder||"asc","created"!==(g=(g=s.sortField||"last_name").replace(/ext_/gi,"").split(",").shift().trim())&&(g+=".keyword"),o[g]=y,h.push(o),n.sort=h,s.cursor&&(n.search_after=JSON.parse(s.cursor)),a.config.DEFAULT_HOSTS.INTEGRATION+a.config.INTEGRATIONS_API_URLS.queryDataFromSearch),y=(g=_.api.constructAPIUrl(g,{index:"users"}),{query:JSON.stringify(n)}),o=R.get(g).query(y);a.traceid&&o.set("X-Amzn-Trace-Id",a.traceid),(o=_.api.setupAPIToken(o,a.token)).end(function(e,t){if(e){e={type:_.errors.ERROR_TYPES.API_ERROR,err:e},e=A.convertElasticsearchErrResponse(e);c.reject(e)}else{var r,n={entities:[],count:t.body.hits.hits.length};for(r in n.count&&s.limit===n.count&&(e=t.body.hits.hits[t.body.hits.hits.length-1].sort,n.cursor=JSON.stringify(e)),t.body.hits.hits){var o=t.body.hits.hits[r]._source,i={uuid:o.dls_user_id,name:o.first_name+" "+o.last_name,email:o.email||o.ext_email,username:o.userid+"--ACCOUNT",created:o.created,org:{id:a.orgId}};o.roles&&(i.roles=o.roles),o.provision_method&&(i.provision_method=o.provision_method),o.first_name&&(i.first_name=o.first_name),o.last_name&&(i.last_name=o.last_name),o.ext_parent_id&&(i.ext_parent_id=o.ext_parent_id),o.username&&(i.ext_username=o.username),o.userid&&(i.ext_user_id=o.userid),o.address&&(i.address=o.address),n.entities.push(i)}c.resolve(n)}})}return c.promise}.bind(this),getUserProfile:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):(n="me",e&&e.userid&&(n=e.userid),e=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.userInfoAPI,e=_.api.constructAPIUrl(e,{orgId:t.orgId,userId:n}),n=R.get(e).query({}),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=_.api.setupAPIToken(n,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):(e=A.convertUserResponse({data:t.body}),r.resolve(e))}));return r.promise}.bind(this),deleteUserProfile:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e.userid?(e=e.userid,o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.userInfoAPI,o=_.api.constructAPIUrl(o,{orgId:t.orgId,userId:e}),e=R.delete(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory parameter userid not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateUserRole:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.userid&&e.target_role?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.updateUserRoleAPI,n=_.api.constructAPIUrl(n,{orgId:t.orgId,userId:e.userid}),e={ext_data:e.ext_data,target_role:e.target_role},n=R.put(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=_.api.setupAPIToken(n,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t)})):((e={}).message=e.description="Mandatory parameter options, userid or target_role, not found in request options.",e=new b(_.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e));return r.promise}.bind(this),getUserClasses:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):(n="me",e&&e.userid&&(n=e.userid),o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getUserClassesAPI,o=_.api.constructAPIUrl(o,{orgId:t.orgId,userId:n}),n={},e&&(e.search&&(n.search="title:"+e.search),e.details&&(n.details=e.details),e.enrollmentType&&(n.enrollmentType=e.enrollmentType),e.sortField&&(n.sortField=e.sortField),e.sortOrder&&(n.sortOrder=e.sortOrder),e.cursor&&(n.cursor=e.cursor),e.limit&&(n.limit=e.limit),e.teacherId&&(n.lookup="class.class.instructor.uuid:"+e.teacherId),e.bundleDetails)&&(n.bundleDetails=e.bundleDetails),e=R.get(o).query(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}))}return r.promise}.bind(this),getUserClassesV2:function(e){var t=this,r=t.orgId,n=t.token,o=m.defer(),i=_.validations.isAuthenticated(r,n);{var s,a;i?o.reject(i):e&&e.userid?(a=e.userid,s=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getUserClassesV2API,s=_.api.constructAPIUrl(s,{orgid:r,userid:a}),r={},e&&(void 0!==e.shadow&&(r.shadow=e.shadow),void 0!==e.hidden&&(r.hidden=e.hidden),e.status_active&&(r.status_active=e.status_active),e.status_ended&&(r.status_ended=e.status_ended),e.status_expired&&(r.status_expired=e.status_expired),e.details&&(r.details=e.details),e.bundleDetails&&(r.bundleDetails=e.bundleDetails),e.limit&&(r.limit=e.limit),e.cursor)&&(r.cursor=e.cursor),a=R.get(s).query(r),t.traceid&&a.set("X-Amzn-Trace-Id",t.traceid),(a=_.api.setupAPIToken(a,n)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),o.reject(e)):o.resolve(t.body)})):((i={}).message=i.description="Required parameter 'userid' is not found in request options.",i=new b(_.errors.ERROR_TYPES.SDK_ERROR,i),o.reject(i))}return o.promise}.bind(this),getClassUsers:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.classid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getClassUsersAPI,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid}),i={},e.search&&(i.search=e.search),e.cursor&&(i.cursor=e.cursor),e.limit&&(i.limit=e.limit),e.sortField&&(i.sortField=e.sortField),e.sortOrder&&(i.sortOrder=e.sortOrder),e=R.get(o).query(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):(t.body.entities=A.convertEnrollmetsResponse({data:t.body.entities}),r.resolve(t.body))})):((n={}).message=n.description="Required parameter classid is not defined.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),enrollUsertoClass:function(e){var t=this,r={},n=m.defer();{var o;e&&e.classid&&e.userid?(r=_.validations.isAuthenticated(t.orgId,t.token))?n.reject(r):(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.enrollUsertoClass,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid,userId:e.userid}),e=R.post(o).set("Content-Type","application/json").set("Accept","application/json").query({}),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):n.resolve(t.body)})):(r.message=r.description="Mandatory parameter classid or userid not found in request options",r=new b(_.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),enrollSelftoClass:function(e){var t=this,r={},n=m.defer();{var o;e&&e.classid?(r=_.validations.isAuthenticated(t.orgId,t.token))?n.reject(r):(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.enrollSelftoClass,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid}),e={classrole:e.classrole},o=R.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):n.resolve(t.body)})):(r.message=r.description="Mandatory parameter classid not found in request options",r=new b(_.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),enrollMultiUserstoClass:function(e){var t=this,r={},n=m.defer();{var o;e&&e.classid&&e.users?(r=_.validations.isAuthenticated(t.orgId,t.token))?n.reject(r):(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.enrollMultiUserstoClass,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid}),e={users:e.users},o=R.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):n.resolve(t.body)})):(r.message=r.description="Mandatory parameter classid or users array not found in request options",r=new b(_.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),unEnrollMultiUserstoClass:function(e){var t=this,r={},n=m.defer();{var o;e&&e.classid&&e.users?(r=_.validations.isAuthenticated(t.orgId,t.token))?n.reject(r):(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.enrollMultiUserstoClass,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid}),e={users:e.users},o=R.delete(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):n.resolve(t.body)})):(r.message=r.description="Mandatory parameter classid or users array not found in request options",r=new b(_.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),unEnrollUsertoClass:function(e){var t=this,r={},n=m.defer();{var o;e&&e.classid&&e.userid?(r=_.validations.isAuthenticated(t.orgId,t.token))?n.reject(r):(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.enrollUsertoClass,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid,userId:e.userid}),e=R.delete(o).query({}),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):n.resolve(t.body)})):(r.message=r.description="Mandatory parameter classid or userid not found in request options",r=new b(_.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),getOrgSettings:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getSettings,n=_.api.constructAPIUrl(n,{orgId:t.orgId}),e&&e.field&&(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getSettingsField,n=_.api.constructAPIUrl(n,{orgId:t.orgId,field:e.field})),e=R.get(n).query({}),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}));return r.promise}.bind(this),updateOrgSettings:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getSettings,n=_.api.constructAPIUrl(n,{orgId:t.orgId}),n=R.put(n),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),e.body&&(e.body.sis&&!e.body.sis.productid&&(e.body.sis.productid=[]),n.send(e.body)),(n=_.api.setupAPIToken(n,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}));return r.promise}.bind(this),generateClassCode:function(e){var t,r=this,n=m.defer();{var o;e&&e.classid?(t=_.validations.isAuthenticated(r.orgId,r.token))?n.reject(t):(o=r.config.DEFAULT_HOSTS.AUTH+r.config.AUTH_API_URLS.generateClassCode,o=_.api.constructAPIUrl(o,{orgId:r.orgId,classId:e.classid}),e=R.post(o),r.traceid&&e.set("X-Amzn-Trace-Id",r.traceid),(e=_.api.setupAPIToken(e,r.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):n.resolve(t.body)})):((t={}).message=t.description="classid not found in request options.",t=new b(_.errors.ERROR_TYPES.SDK_ERROR,t),n.reject(t))}return n.promise}.bind(this),getAllJobs:function(e){var r=m.defer();{var t,n,o;e&&e.accountId&&e.extUserId?(t=this.config.DEFAULT_HOSTS.AUTH+this.config.AUTH_API_URLS.getAllJobs,t=_.api.constructAPIUrl(t,{accountId:e.accountId,extUserId:e.extUserId}),n={},e.jobType&&(n.jobType=e.jobType),e.details&&(n.details=e.details),e=R.get(t).query(n),this.traceid&&e.set("X-Amzn-Trace-Id",this.traceid),e.end(function(e,t){e?(o=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={}).message=o.description="accountId or extUserId not found in request options.",o=new b(_.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),getJob:function(e){var r=m.defer();{var t,n;e&&e.accountId&&e.extUserId&&e.jobId&&e.jobType?(t=this.config.DEFAULT_HOSTS.AUTH+this.config.AUTH_API_URLS.getJob,t=_.api.constructAPIUrl(t,{accountId:e.accountId,extUserId:e.extUserId,jobId:e.jobId}),e={jobType:e.jobType},t=R.get(t).query(e),this.traceid&&t.set("X-Amzn-Trace-Id",this.traceid),t.end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="accountId or extUserId or jobType or jobId or not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createClass:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.title&&e.startdate&&e.enddate?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.createClass,o=_.api.constructAPIUrl(o,{orgId:t.orgId}),i={title:e.title,startdate:e.startdate,enddate:e.enddate},e.description&&(i.description=e.description),e.class_ownership&&(i.class_ownership=e.class_ownership),e.ext_data&&(i.ext_data=e.ext_data),e.analyticsharingmodel&&(i.analyticsharingmodel=e.analyticsharingmodel),e.limits&&(i.limits=e.limits),e=R.post(o).send(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):(e=A.convertClassResponse({data:t.body}),r.resolve(e))})):((n={}).message=n.description="title or startdate or enddate not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateClass:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.specificClass,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid}),o=R.put(o).send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory parameter 'classid' is not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createMultipleClasses:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e.classes&&0<e.classes.length||e.clone_classes&&0<e.clone_classes.length?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.createMultipleClasses,o=_.api.constructAPIUrl(o,{orgId:t.orgId}),o=R.post(o).send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory parameters - [classes, clone_classes], not found in request options",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),deleteClass:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid&&e.body?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.specificClass,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid}),o=R.delete(o).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - classid or body not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),cloneClass:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.title&&e.startdate&&e.enddate&&e.instructor&&e.classid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.cloneClass,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid}),o=R.post(o).send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="title or startdate or enddate or instructor or classid not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAllClasses:function(c){var e=this,u=m.defer(),t=_.validations.isAuthenticated(e.orgId,e.token);{var r,n,o,i;t?u.reject(t):(t='orgid:"'+e.orgId+'"',c.lookup&&c["lookup-operator"]&&(n=c.lookup.split(",").map(function(e){e=e.trim().split(":");return"("+e[0]+".keyword:"+e[1]+")"}),t+=" AND ("+n.join(" "+c["lookup-operator"]+" ")+")"),c.search&&(t=t+' AND (title:"'+c.search+'" OR class.instructor.first_name:"'+c.search+'" OR class.instructor.last_name:"'+c.search+'" OR description:"'+c.search+'")'),"title"===(n="enddate"!==(n=(n=c.sortField||"").replace(/ext_/gi,"").split(",").shift().trim()||"created")&&"startdate"!==n?n:"class."+n)&&(n+=".keyword"),"tagname_1"===n&&(n+=".keyword"),o=c.sortOrder||"desc",r=[],(i={})[n]=o,r.push(i),n={query:{query_string:{query:t}},sort:r},c.cursor&&(n.search_after=JSON.parse(c.cursor)),c.limit?n.size=c.limit:c.limit=10,o=e.config.DEFAULT_HOSTS.INTEGRATION+e.config.INTEGRATIONS_API_URLS.queryDataFromSearch,o=_.api.constructAPIUrl(o,{index:"classes"}),i={query:JSON.stringify(n)},t=R.get(o).query(i),e.traceid&&t.set("X-Amzn-Trace-Id",e.traceid),(t=_.api.setupAPIToken(t,e.token)).agent(d).end(function(e,t){if(e){e={type:_.errors.ERROR_TYPES.API_ERROR,err:e},e=A.convertElasticsearchErrResponse(e);u.reject(e)}else{var r,n={entities:[]};for(r in n.count=t.body.hits.hits.length,n.count&&c.limit===n.count&&(e=t.body.hits.hits[t.body.hits.hits.length-1].sort,n.cursor=JSON.stringify(e)),t.body.hits.hits){var o=t.body.hits.hits[r]._source,i={uuid:o.classid,created:o.created,modified:o.modified,path:o.path,category:o.category,class:{enddate:o.class.enddate,instructor:{name:o.class.instructor.first_name+" "+o.class.instructor.last_name,last_name:o.class.instructor.last_name,first_name:o.class.instructor.first_name,uuid:o.class.instructor.dls_user_id,email:o.class.instructor.email,username:o.class.instructor.userid+"--ACCOUNT"},startdate:o.class.startdate},"class.settings.active":o["class.settings.active"],class_code:o.class_code,class_ownership:o.class_ownership||{owner_status:"ENROLLED",model:"STRICT"},description:o.description,provision_method:o.class.provision_method,title:o.title,analyticsharingmodel:o.analyticsharingmodel,analytics_score_aggregation_type:o.analytics_score_aggregation_type,hidden:o.hidden,studentCount:o.studentCount,teacherCount:o.teacherCount};o.limits&&(i.limits=o.limits),o.hasOwnProperty("assignedPathCount")&&(i.assignedPathCount=o.assignedPathCount);for(var s=1;s<=10;s++){var a="tagid_"+s;o[a]&&(i[a]=o[a],i["tagname_"+s]=o["tagname_"+s],i["taglookup_"+s]=o["taglookup_"+s])}n.entities.push(i)}u.resolve(n)}}))}return u.promise}.bind(this),getParticularClass:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classId?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getParticularClassAPI,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classId}),e=R.get(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="classId not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getParticularShadowClass:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.ext_classid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getParticularShadowClassAPI,o=_.api.constructAPIUrl(o,{orgId:t.orgId,extClassId:e.ext_classid}),e=R.get(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="ext_classid not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createClassProductAssociation:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classId&&e.productcode?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.classProductAssociation,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classId,productcode:e.productcode}),e=R.post(o).set("Content-Type","application/json").set("Accept","application/json"),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="classId or productcode not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),removeClassProductAssociation:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classId&&e.productcode?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.classProductAssociation,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classId,productcode:e.productcode}),e=R.delete(o).query({}),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="classId or productcode not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createMultiClassProductAssociations:function(e){var r=m.defer(),t=this,n=_.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.classId&&e.productcodes?(o=t.config.DEFAULT_HOSTS.AUTH,i=t.config.AUTH_API_URLS.multiClassProductAssociations,o=o+i,i={productcodes:e.productcodes},o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classId}),e=R.post(o).set("Content-Type","application/json").set("Accept","application/json").send(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Missing mandaotry fields 'classId' or 'productcodes' in request.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),associateMaterialsWithClass:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classId&&e.body&&(e.body.productcodes||e.body.bundlecodes)?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.classMaterialAssociation,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classId}),e=R.post(o).set("Content-Type","application/json").set("Accept","application/json"),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="classId or productcodes or bundlecodes not found inrequest options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),unassociateMaterialsWithClass:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classId&&e.body&&(e.body.productcodes||e.body.bundlecodes)?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.classMaterialAssociation,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classId}),e=R.delete(o).set("Content-Type","application/json").set("Accept","application/json"),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=o="classId or productcodes or bundlecodes not found in request options.",n.description=o,n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),addItemsToShowcaseOfAClass:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classId&&e.body?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.showcaseItems,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classId}),o=R.post(o),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.send(e.body),(o=_.api.setupAPIToken(o,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory param - classId or body not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),deleteItemsFromShowcaseOfAClass:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classId&&e.body?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.showcaseItems,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classId}),o=R.delete(o),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.send(e.body),(o=_.api.setupAPIToken(o,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory param - classId or body not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getClassAppdata:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.ClassAppdata,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classid:e.classid}),e=R.get(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="classid not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),putClassAppdata:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid&&e.appdata?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.ClassAppdata,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classid:e.classid}),o=R.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e.appdata),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="classid or appdata not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),deleteClassAppdata:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.ClassAppdata,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classid:e.classid}),e=R.delete(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="classid not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),encodeURLParameter:function(e){var t,r={};for(t in e)r[e[t]]=encodeURIComponent(e[t]);return r}.bind(this),createAssignedPath:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid&&e.data&&e.data.title&&e.data.items&&0<e.data.items.length?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.createAssignedPath,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid}),o=R.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e.data),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - title or classid or items not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),deleteAssignedPath:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid&&e.assignedpathid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.deleteAssignedPath,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid,assignedPathId:e.assignedpathid}),e=R.delete(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - classid or assignedpathid not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateAssignedPath:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid&&e.assignedpathid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.deleteAssignedPath,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid,assignedPathId:e.assignedpathid}),o=R.put(o),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),e.data&&o.send(e.data),(o=_.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - classid or assignedpathid not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createGroup:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.title&&e.startdate&&e.enddate?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.allGroups,o=_.api.constructAPIUrl(o,{orgId:t.orgId}),o=R.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t)})):((n={}).message=n.description="title or startdate or enddate not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAllGroupsByPath:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.path?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.allGroups,o=_.api.constructAPIUrl(o,{orgId:t.orgId}),i={path:e.path},e.cursor&&(i.cursor=e.cursor),e=R.get(o).query(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t)})):((n={}).message=n.description="Mandatory params - path not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAGroup:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.groupId?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.aParticularGroup,o=_.api.constructAPIUrl(o,{orgId:t.orgId,groupId:e.groupId}),e=R.get(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t)})):((n={}).message=n.description="Mandatory params - groupId not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateGroup:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.groupId?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.aParticularGroup,o=_.api.constructAPIUrl(o,{orgId:t.orgId,groupId:e.groupId}),o=R.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t)})):((n={}).message=n.description="Mandatory params - groupId not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),deleteGroup:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.groupId?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.aParticularGroup,o=_.api.constructAPIUrl(o,{orgId:t.orgId,groupId:e.groupId}),e=R.delete(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t)})):((n={}).message=n.description="Mandatory params - groupId not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAllMembersOfAGroup:function(e){var t=this,r=m.defer(),n={},o=_.validations.isAuthenticated(t.orgId,t.token);{var i;o?r.reject(o):e&&e.groupId?(i=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getAllMembersOfAGroup,i=_.api.constructAPIUrl(i,{orgId:t.orgId,groupId:e.groupId}),e.cursor&&(n.cursor=e.cursor),e=R.get(i).set("Content-Type","application/json").set("Accept","application/json").send(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(o=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t)})):((o={}).message=o.description="Mandatory param - groupId not found in request options.",o=new b(_.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),getAllGroupMembersByPath:function(e){var t=this,r=m.defer(),n={},o=_.validations.isAuthenticated(t.orgId,t.token);{var i;o?r.reject(o):e&&e.path?(i=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getAllGroupMembersByPath,i=_.api.constructAPIUrl(i,{orgId:t.orgId}),n.path=e.path,e.cursor&&(n.cursor=e.cursor),e=R.get(i).set("Content-Type","application/json").set("Accept","application/json").query(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(o=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t)})):((o={}).message=o.description="Mandatory param - path not found in request options.",o=new b(_.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),createMultiUserGroupMembership:function(e){var t=this,r=m.defer(),n={},o=_.validations.isAuthenticated(t.orgId,t.token);{var i;o?r.reject(o):e&&e.groupId&&e.body&&e.body.users&&0<e.body.users.length?(i=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.userGroupMembership,i=_.api.constructAPIUrl(i,{orgId:t.orgId,groupId:e.groupId}),n=e.body,e=R.post(i).set("Content-Type","application/json").set("Accept","application/json").send(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(o=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t)})):((o={}).message=o.description="Mandatory param - groupId or body or body.users(min. 1 user) not found in request options.",o=new b(_.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),deleteMultiUserGroupMembership:function(e){var t=this,r=m.defer(),n={},o=_.validations.isAuthenticated(t.orgId,t.token);{var i;o?r.reject(o):e&&e.groupId&&e.body&&e.body.users&&0<e.body.users.length?(i=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.userGroupMembership,i=_.api.constructAPIUrl(i,{orgId:t.orgId,groupId:e.groupId}),n=e.body,e=R.delete(i).set("Content-Type","application/json").set("Accept","application/json").send(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(o=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t)})):((o={}).message=o.description="Mandatory param - groupId or body or body.users(min. 1 user) not found in request options.",o=new b(_.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),getMyAllMemberships:function(e){var t=this,r=m.defer(),n={},o=_.validations.isAuthenticated(t.orgId,t.token);{var i;o?r.reject(o):e&&e.userId&&e.path?(i=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getMyAllMemberships,i=_.api.constructAPIUrl(i,{orgId:t.orgId,userId:e.userId}),n.path=e.path,e.cursor&&(n.cursor=e.cursor),e=R.get(i).set("Content-Type","application/json").set("Accept","application/json").query(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(o=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t)})):((o={}).message=o.description="Mandatory param - userId or path not found in request options.",o=new b(_.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),archiveGroup:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.groupId?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.archiveAParticularGroup,o=_.api.constructAPIUrl(o,{orgId:t.orgId,groupId:e.groupId}),e=R.put(o).set("Content-Type","application/json").set("Accept","application/json").send({}),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory param - groupId not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),unarchiveGroup:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.groupId?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.unarchiveAParticularGroup,o=_.api.constructAPIUrl(o,{orgId:t.orgId,groupId:e.groupId}),e=R.put(o).set("Content-Type","application/json").set("Accept","application/json").send({}),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory param - groupId not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createGradebookMeta:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.classid&&e.body?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.createOrGetGradebookMeta,n=_.api.constructAPIUrl(n,{orgId:t.orgId,classId:e.classid}),n=R.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=_.api.setupAPIToken(n,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory param - classid or body not found in request options.",e=new b(_.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e));return r.promise}.bind(this),updateGradebookMeta:function(e){var r=m.defer(),t=this,n={},o=_.validations.isAuthenticated(t.orgId,t.token);o?r.reject(o):e&&e.classid&&e.gradebook_id&&e.body?0!==Object.keys(e.body).length?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.updateOrDeleteGradebookMeta,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid,gradebook_id:e.gradebook_id}),e=e.body,o=R.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Body of the request cannot be empty.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n)):(n.message=n.description="Mandatory params: classid, gradebook_id or body not found in the request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n));return r.promise}.bind(this),deleteGradebookMeta:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.classid&&e.gradebook_id?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.updateOrDeleteGradebookMeta,n=_.api.constructAPIUrl(n,{orgId:t.orgId,classId:e.classid,gradebook_id:e.gradebook_id}),e=R.delete(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - classid or gradebook_id not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n));return r.promise}.bind(this),getParticularGradebookMetaOfAClass:function(e){var r=m.defer(),t=this,n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.classid&&e.gradebook_id?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.createOrGetGradebookMeta,n=_.api.constructAPIUrl(n,{orgId:t.orgId,classId:e.classid}),e={gradebook_id:e.gradebook_id},n=R.get(n).query(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=_.api.setupAPIToken(n,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):t.body.entities?r.resolve(t.body.entities[0]):r.resolve()})):((e={}).message=e.description="Mandatory params: classid or gradebook_id not found in request options.",e=new b(_.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e));return r.promise}.bind(this),getAllGradebooksMetaOfAClass:function(e){var r=m.defer(),t=this,n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.createOrGetGradebookMeta,n=_.api.constructAPIUrl(n,{orgId:t.orgId,classId:e.classid}),o={},e.cursor&&(o.cursor=e.cursor),e=R.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params: classid not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),addGradebookColumns:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.classid&&e.gradebook_id&&e.body?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.gradebookColumns,n=_.api.constructAPIUrl(n,{orgId:t.orgId,classId:e.classid,gradebook_id:e.gradebook_id}),n=R.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=_.api.setupAPIToken(n,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory param - classid, gradebook_id or body not found in request options.",e=new b(_.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e));return r.promise}.bind(this),updateMultipleGradebookColumns:function(e){var r=m.defer(),t=this,n={},o=_.validations.isAuthenticated(t.orgId,t.token);o?r.reject(o):e&&e.classid&&e.gradebook_id&&e.body&&e.body.columns?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.gradebookColumns,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid,gradebook_id:e.gradebook_id}),e=e.body,o=R.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Mandatory params: classid, gradebook_id, body or body.columns not found in the request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n));return r.promise}.bind(this),removeGradebookColumns:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.classid&&e.gradebook_id&&e.body?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.gradebookColumns,n=_.api.constructAPIUrl(n,{orgId:t.orgId,classId:e.classid,gradebook_id:e.gradebook_id}),n=R.delete(n).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=_.api.setupAPIToken(n,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory params - classid, gradebook_id or body not found in request options.",e=new b(_.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e));return r.promise}.bind(this),getParticularColumnOfAGradebook:function(e){var r=m.defer(),t=this,n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.classid&&e.gradebook_id&&e.column_id?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.gradebookColumns,n=_.api.constructAPIUrl(n,{orgId:t.orgId,classId:e.classid,gradebook_id:e.gradebook_id}),e={column_id:e.column_id},n=R.get(n).query(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=_.api.setupAPIToken(n,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body.entities[0])})):((e={}).message=e.description="Mandatory params: classid, gradebook_id or column_id not found in request options.",e=new b(_.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e));return r.promise}.bind(this),getAllColumnsOfAGradebook:function(e){var r=m.defer(),t=this,n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid&&e.gradebook_id?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.gradebookColumns,n=_.api.constructAPIUrl(n,{orgId:t.orgId,classId:e.classid,gradebook_id:e.gradebook_id}),o={},e.cursor&&(o.cursor=e.cursor),e=R.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params: classid or gradebook_id not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAllClassesOfAComponent:function(e){var r=m.defer(),t=this,n={},o=_.validations.isAuthenticated(t.orgId,t.token);{var i;o?r.reject(o):e&&e.component_code?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getAllClassesOfAComponent,o=_.api.constructAPIUrl(o,{orgId:t.orgId,component_code:e.component_code}),i={},e.cursor&&(i.cursor=e.cursor),e=R.get(o).query(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Mandatory params: component_code not found in the request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),removeAllGradebookColumnsOfCustomComponent:function(e){var r=m.defer(),t=this,n={},o=_.validations.isAuthenticated(t.orgId,t.token);o?r.reject(o):e&&e.component_code?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.removeAllGradebookColumnsOfCustomComponent,o=_.api.constructAPIUrl(o,{orgId:t.orgId,component_code:e.component_code}),o=R.delete(o).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Mandatory params: component_code not found in the request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n));return r.promise}.bind(this),createCustomComponent:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.body?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.customComponents,n=_.api.constructAPIUrl(n,{orgid:t.orgId}),n=R.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=_.api.setupAPIToken(n,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory param - 'body' not found in request options.",e=new b(_.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e));return r.promise}.bind(this),updateCustomComponent:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.custom_component_code&&e.body?0===Object.keys(e.body).length?(n.message=n.description="Mandatory params: 'custom_component_code' or 'body' not found in the request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n)):(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.particularCustomComponent,o=_.api.constructAPIUrl(o,{orgid:t.orgId,custom_component_code:e.custom_component_code}),e=e.body,o=R.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params: 'custom_component_code' or 'body' not found in the request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),deleteCustomComponent:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.custom_component_code?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.particularCustomComponent,n=_.api.constructAPIUrl(n,{orgid:t.orgId,custom_component_code:e.custom_component_code}),e=R.delete(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - 'custom_component_code' not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n));return r.promise}.bind(this),getParticularCustomComponent:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.custom_component_code?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.particularCustomComponent,n=_.api.constructAPIUrl(n,{orgid:t.orgId,custom_component_code:e.custom_component_code}),e=R.get(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params: 'custom_component_code' not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n));return r.promise}.bind(this),getAllCustomComponents:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.customComponents,n=_.api.constructAPIUrl(n,{orgid:t.orgId}),o={},e&&e.cursor&&(o.cursor=e.cursor),e=R.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}))}return r.promise}.bind(this)}},new n({timeout:6e4,freeSocketTimeout:3e4}))},{"../../helpers":3,"../../helpers/lib/api/converter":4,agentkeepalive:36,q:42,superagent:45}],17:[function(e,t,r){var s=e("q"),a=e("superagent"),c=e("../../helpers"),e=e("agentkeepalive"),u=c.errors.DLSError,d=(t.exports=function(){return{createGradeformat:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.body?(n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.gradeFormat,n=c.api.constructAPIUrl(n,{orgid:t.orgId}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=c.api.setupAPIToken(n,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory param - body not found in request options.",e=new u(c.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e));return r.promise}.bind(this),updateGradeformat:function(e){var r=s.defer(),t=this,n={},o=c.validations.isAuthenticated(t.orgId,t.token);o?r.reject(o):e&&e.gradeformat_id&&e.body?0!==Object.keys(e.body).length?(o=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.particularGradeFormat,o=c.api.constructAPIUrl(o,{orgid:t.orgId,gradeformat_id:e.gradeformat_id}),e=e.body,o=a.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Body of the request cannot be empty.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n)):(n.message=n.description="Mandatory params: gradeformat_id or body not found in the request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n));return r.promise}.bind(this),deleteGradeformat:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.gradeformat_id?(n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.particularGradeFormat,n=c.api.constructAPIUrl(n,{orgid:t.orgId,gradeformat_id:e.gradeformat_id}),e=a.delete(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=c.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - gradeformat_id not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n));return r.promise}.bind(this),getAllGradeformats:function(e){var r=s.defer(),t=this,n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):(n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.gradeFormat,n=c.api.constructAPIUrl(n,{orgid:t.orgId}),o={},e&&e.cursor&&(o.cursor=e.cursor),e=a.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=c.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}))}return r.promise}.bind(this),getParticularGradeformat:function(e){var r=s.defer(),t=this,n=c.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.gradeformat_id?(n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.gradeFormat,n=c.api.constructAPIUrl(n,{orgid:t.orgId}),e={gradeformat_id:e.gradeformat_id},n=a.get(n).query(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=c.api.setupAPIToken(n,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body.entities[0])})):((e={}).message=e.description="Mandatory params: gradeformat_id not found in request options.",e=new u(c.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e));return r.promise}.bind(this),associateGradeformatToClass:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid&&e.gradeformat_id&&e.body?(o=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.classGradeformatAssociation,o=c.api.constructAPIUrl(o,{orgid:t.orgId,classid:e.classid,gradeformat_id:e.gradeformat_id}),o=a.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - classid or gradeformat_id or body not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),unassociateGradeformatFromClass:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid&&e.gradeformat_id?(o=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.classGradeformatAssociation,o=c.api.constructAPIUrl(o,{orgid:t.orgId,classid:e.classid,gradeformat_id:e.gradeformat_id}),e=a.delete(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=c.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - classid or gradeformat_id not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateClassGradeformatAssociation:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid&&e.gradeformat_id&&e.body?(o=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.classGradeformatAssociation,o=c.api.constructAPIUrl(o,{orgid:t.orgId,classid:e.classid,gradeformat_id:e.gradeformat_id}),e=e.body,o=a.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params: classid or gradeformat_id or body not found in the request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getParticularGradeformatOfAClass:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid&&e.gradeformat_id?(o=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.classGradeformats,o=c.api.constructAPIUrl(o,{orgid:t.orgId,classid:e.classid}),e={gradeformat_id:e.gradeformat_id},o=a.get(o).query(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body.entities[0])})):((n={}).message=n.description="Mandatory params: classid or gradeformat_id not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAllGradeformatsOfAClass:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.classid?(o=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.classGradeformats,o=c.api.constructAPIUrl(o,{orgid:t.orgId,classid:e.classid}),i={},e.cursor&&(i.cursor=e.cursor),e=a.get(o).query(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=c.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params: classid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getClassesOfAGradeformat:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.gradeformat_id?(o=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.gradeformatClasses,o=c.api.constructAPIUrl(o,{orgid:t.orgId,gradeformat_id:e.gradeformat_id}),i={},e.cursor&&(i.cursor=e.cursor),e=a.get(o).query(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=c.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params: gradeformat_id not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createUserAssignedPathEnrollments:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.classid&&e.assignedpathid&&e.body?(n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.userAssignedPaths,n=c.api.constructAPIUrl(n,{orgid:t.orgId,classid:e.classid,assignedpathid:e.assignedpathid}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=c.api.setupAPIToken(n,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory param: classid, assignedpathid, body not found in request options.",e=new u(c.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e));return r.promise}.bind(this),deleteUserAssignedPathEnrollments:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.classid&&e.assignedpathid&&e.body?(n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.userAssignedPaths,n=c.api.constructAPIUrl(n,{orgid:t.orgId,classid:e.classid,assignedpathid:e.assignedpathid}),n=a.delete(n).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=c.api.setupAPIToken(n,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory param: classid, assignedpathid, body not found in request options.",e=new u(c.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e));return r.promise}.bind(this),getParticularClassV2:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classId?(o=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.particularClass,o=c.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classId}),e={productDetails:e.productDetails,bundleDetails:e.bundleDetails},o=a.get(o).query(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory field 'classId' not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createOrgProductEntitlement:function(e){var t=this,r=s.defer();{var n,o;t.orgId?e&&e.productcode?(n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.orgProductEntitlement,n=c.api.constructAPIUrl(n,{orgid:t.orgId}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((o={}).message=o.description="Mandatory param: productcode not found in request options.",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o)):((o={}).message=o.description="Mandatory param: orgid not found in options while initializing comprodls-sdk.",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),updateOrgProductEntitlement:function(e){var t=this,r=s.defer();{var n,o;t.orgId?e&&e.productcode?(n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.orgProductEntitlement,n=c.api.constructAPIUrl(n,{orgid:t.orgId}),n=a.put(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((o={}).message=o.description="Mandatory param: productcode not found in request options.",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o)):((o={}).message=o.description="Mandatory param: orgid not found in options while initializing comprodls-sdk.",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),getParticularOrgProductEntitlement:function(e){var t=this,r=s.defer();{var n;e&&e.productcode?(n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.orgProductEntitlement,n=c.api.constructAPIUrl(n,{orgid:t.orgId}),e={productcode:e.productcode},n=a.get(n).query(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory field 'productcode' not found in request options.",e=new u(c.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),getAllOrgProductEntitlements:function(e){var t=this,r=s.defer(),n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.orgProductEntitlement,o=(n=c.api.constructAPIUrl(n,{orgid:t.orgId}),{productcode:e.productcode});e.status&&(o.status=e.status);e.hasOwnProperty("expired")&&(o.expired=e.expired);e.cursor&&(o.cursor=e.cursor);e=a.get(n).query(o);t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid);return e.agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}),r.promise}.bind(this)}},new e({timeout:6e4,freeSocketTimeout:3e4}))},{"../../helpers":3,agentkeepalive:36,q:42,superagent:45}],18:[function(e,t,r){var c=e("superagent"),u=e("q"),d=e("../../helpers"),l=d.errors.DLSError;function n(e,t,r,n,o){var i,s=u.defer(),a={};return n&&n.userid?(a=d.validations.isAuthenticated(e,t))?s.reject(a):(r=r.DEFAULT_HOSTS.COLLAB+r.COLLAB_API_URLS.connectionURL,r=d.api.constructAPIUrl(r,{orgId:e,userId:n.userid}),"create"===o?i=c.post(r).set("Content-Type","application/json"):"delete"===o&&(i=c.delete(r).set("Content-Type","application/json")),(i=d.api.setupAPIToken(i,t)).end(function(e,t){e?(a=new l(d.errors.ERROR_TYPES.API_ERROR,e),s.reject(a)):s.resolve(t.body)})):(a.message=a.description='Mandatory parameter "userid" not found in request options',a=new l(d.errors.ERROR_TYPES.SDK_ERROR,a),s.reject(a)),s.promise}t.exports=function(){return{getPostsInClass:function(e){var t=this,r=u.defer(),n={};{var o,i;e&&e.classid?(n=d.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.COLLAB+t.config.COLLAB_API_URLS.postsInClassAPI,o=d.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid}),i={},e.cursor&&(i.cursor=e.cursor),e.limit&&(i.limit=e.limit),e=c.get(o).query(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=d.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new l(d.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description='Mandatory parameter "classid" not found in request options',n=new l(d.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createPostInClass:function(e){var t=this,r=u.defer(),n={};{var o,i;e&&e.verb&&e.classid?(n=d.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.COLLAB+t.config.COLLAB_API_URLS.postsInClassAPI,o=d.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid}),i={verb:e.verb},e.post&&(i.post=e.post),e.name&&(i.name=e.name),e.email&&(i.email=e.email),e.userid&&(i.userid=e.userid),e=c.post(o).send(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=d.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new l(d.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description='Mandatory parameter "verb" or "classid" not found in request options',n=new l(d.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getPostsInProduct:function(e){var t=this,r=u.defer(),n={};{var o,i;e&&e.productid?(n=d.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.COLLAB+t.config.COLLAB_API_URLS.postsInProductAPI,o=d.api.constructAPIUrl(o,{orgId:t.orgId,productId:e.productid}),i={},e.cursor&&(i.cursor=e.cursor),e.limit&&(i.limit=e.limit),e=c.get(o).query(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=d.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new l(d.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description='Mandatory parameter "productid" not found in request options',n=new l(d.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createPostInProduct:function(e){var t=this,r=u.defer(),n={};{var o,i;e&&e.verb&&e.productid?(n=d.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.COLLAB+t.config.COLLAB_API_URLS.postsInProductAPI,o=d.api.constructAPIUrl(o,{orgId:t.orgId,productId:e.productid}),i={verb:e.verb},e.post&&(i.post=e.post),e.name&&(i.name=e.name),e.email&&(i.email=e.email),e.userid&&(i.userid=e.userid),e=c.post(o).send(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=d.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new l(d.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description='Mandatory parameter "verb" or "productid" not found in request options',n=new l(d.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getMyFollowers:function(e){var t=this,r=u.defer(),n={};{var o,i;(n=d.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.COLLAB+t.config.COLLAB_API_URLS.getMyFollowers,o=d.api.constructAPIUrl(o,{orgId:t.orgId}),i={},e.cursor&&(i.cursor=e.cursor),e.limit&&(i.limit=e.limit),e=c.get(o).query(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=d.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new l(d.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)}))}return r.promise}.bind(this),getUsersFollowedByMe:function(e){var t=this,r=u.defer(),n={};{var o,i;(n=d.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.COLLAB+t.config.COLLAB_API_URLS.getUsersFollowedByMe,o=d.api.constructAPIUrl(o,{orgId:t.orgId}),i={},e.cursor&&(i.cursor=e.cursor),e.limit&&(i.limit=e.limit),e=c.get(o).query(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=d.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new l(d.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)}))}return r.promise}.bind(this),followUser:function(e){var t=u.defer();return n(this.orgId,this.token,this.config,e,"create").then(function(e){t.resolve(e)}).catch(function(e){t.reject(e)}).done(),t.promise}.bind(this),unfollowUser:function(e){var t=u.defer();return n(this.orgId,this.token,this.config,e,"delete").then(function(e){t.resolve(e)}).catch(function(e){t.reject(e)}).done(),t.promise}.bind(this)}}},{"../../helpers":3,q:42,superagent:45}],19:[function(e,t,r){var i=e("q"),s=e("superagent"),n=e("agentkeepalive"),a=e("../../helpers"),c=a.errors.DLSError,u=(t.exports=function(e){return this.accountId=e,{createDataSyncManager:function(e){var t=this,r=i.defer();{var n;e&&e.body?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.createDataSyncManager,n=a.api.constructAPIUrl(n,{accountid:t.accountId}),n=s.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.agent(u).end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory param - body not found in request options.",e=new c(a.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),updateDataSyncManager:function(e){var r=i.defer(),t=this;{var n,o;e&&e.dsmid&&e.body?(o=t.config.DEFAULT_HOSTS.AUTH,n=t.config.AUTH_API_URLS.dataSyncManager,o=o+n,o=a.api.constructAPIUrl(o,{accountid:t.accountId,dsmid:e.dsmid}),n=e.body,e=s.put(o).set("Content-Type","application/json").set("Accept","application/json").send(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.agent(u).end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((o={}).message=o.description="Mandatory params: dsmid, body not found in the request options.",o=new c(a.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),deleteDataSyncManager:function(e){var t=this,r=i.defer();{var n;e&&e.dsmid&&e.body?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.dataSyncManager,n=a.api.constructAPIUrl(n,{accountid:t.accountId,dsmid:e.dsmid}),n=s.delete(n).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.agent(u).end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory params - dsmid or body not found in request options.",e=new c(a.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),getParticularDataSyncManager:function(e){var r=i.defer(),t=this;{var n,o;e&&e.dsmid?(n=t.config.DEFAULT_HOSTS.AUTH,o=t.config.AUTH_API_URLS.dataSyncManager,n=n+o,n=a.api.constructAPIUrl(n,{accountid:t.accountId,dsmid:e.dsmid}),o=s.get(n),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.agent(u).end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory params: dsmid not found in request options.",e=new c(a.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),getAllDataSyncManagersOfAGroup:function(e){var r=i.defer(),t=this;{var n,o;e&&e.dsm_groupid?(n=t.config.DEFAULT_HOSTS.AUTH,o=t.config.AUTH_API_URLS.getAllDataSyncManagersOfAGroup,n=n+o,n=a.api.constructAPIUrl(n,{accountid:t.accountId,dsm_groupid:e.dsm_groupid}),o=s.get(n),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.agent(u).end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory params: dsm_groupid not found in request options.",e=new c(a.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this)}},new n({timeout:6e4,freeSocketTimeout:3e4}))},{"../../helpers":3,agentkeepalive:36,q:42,superagent:45}],20:[function(e,t,r){var o=e("q"),i=e("superagent"),n=e("agentkeepalive"),s=e("../../helpers"),a=s.errors.DLSError,c=(t.exports=function(){return{getAParticularDocument:function(e){var r=o.defer();{var t,n;e&&e.accountid&&e.extuserid&&e.documentid&&e.folderid?(n=this.config.DEFAULT_HOSTS.DRIVE+this.config.DRIVE_API_URLS.getAParticularDocument,t={accountid:e.accountid,extuserid:e.extuserid,documentid:e.documentid},n=s.api.constructAPIUrl(n,t),t={folderid:e.folderid},e=i.get(n).query(t),this.traceid&&e.set("X-Amzn-Trace-Id",this.traceid),e.end(function(e,t){e?(e=new a(s.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - accountid or extuserid or documentid or folderid not found in request options.",n=new a(s.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAllDocumentsInAFolder:function(e){var r=o.defer();{var t,n;e&&e.accountid&&e.extuserid&&e.folderid?(n=this.config.DEFAULT_HOSTS.DRIVE+this.config.DRIVE_API_URLS.getAllDocumentsInAFolder,n=s.api.constructAPIUrl(n,{accountid:e.accountid,extuserid:e.extuserid}),t={folderid:e.folderid},e.classid&&(t.classid=e.classid),e.productcode&&(t.productcode=e.productcode),e.assigned_path_id&&(t.assigned_path_id=e.assigned_path_id),e["item-code"]&&(t["item-code"]=e["item-code"]),e.cursor&&(t.cursor=e.cursor),e=i.get(n).query(t),this.traceid&&e.set("X-Amzn-Trace-Id",this.traceid),e.end(function(e,t){e?(e=new a(s.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - accountid or extuserid or folderid not found in request options.",n=new a(s.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createMultipleDocuments:function(e){var r=o.defer();{var t;e&&e.accountid&&e.extuserid&&e.body?(t=this.config.DEFAULT_HOSTS.DRIVE+this.config.DRIVE_API_URLS.documents,t=s.api.constructAPIUrl(t,{accountid:e.accountid,userid:e.extuserid}),t=i.post(t).set("Content-Type","application/json").set("Accept","application/json").send(e.body),this.traceid&&t.set("X-Amzn-Trace-Id",this.traceid),t.agent(c).end(function(e,t){e?(e=new a(s.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory param - accountid, extuserid or body not found in request options.",e=new a(s.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),updateMultipleDocuments:function(e){var r=o.defer(),t={};{var n;e&&e.accountid&&e.extuserid&&e.body?(n=this.config.DEFAULT_HOSTS.DRIVE+this.config.DRIVE_API_URLS.documents,n=s.api.constructAPIUrl(n,{accountid:e.accountid,userid:e.extuserid}),n=i.put(n).set("Content-Type","application/json").set("Accept","application/json").send(e.body),this.traceid&&n.set("X-Amzn-Trace-Id",this.traceid),n.agent(c).end(function(e,t){e?(e=new a(s.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(t.message=t.description="Mandatory param - accountid, extuserid or body not found in the request options.",t=new a(s.errors.ERROR_TYPES.SDK_ERROR,t),r.reject(t))}return r.promise}.bind(this),deleteMultipleDocuments:function(e){var r=o.defer();{var t;e&&e.accountid&&e.extuserid&&e.body?(t=this.config.DEFAULT_HOSTS.DRIVE+this.config.DRIVE_API_URLS.documents,t=s.api.constructAPIUrl(t,{accountid:e.accountid,userid:e.extuserid}),t=i.delete(t).set("Content-Type","application/json").set("Accept","application/json").send(e.body),this.traceid&&t.set("X-Amzn-Trace-Id",this.traceid),t.agent(c).end(function(e,t){e?(e=new a(s.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory param - accountid, extuserid or body not found in request options.",e=new a(s.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this)}},new n({timeout:6e4,freeSocketTimeout:3e4}))},{"../../helpers":3,agentkeepalive:36,q:42,superagent:45}],21:[function(e,t,r){var i=e("q"),s=e("superagent"),n=e("agentkeepalive"),a=e("../../helpers"),o=e("../../helpers/lib/api/converter"),c=a.errors.DLSError,u=(t.exports=function(e){return this.accountId=e,{getGetStreamCredentials:function(){var r,e=this,n=i.defer(),t=e.config.DEFAULT_HOSTS.INTEGRATION+e.config.INTEGRATIONS_API_URLS.getGetStreamCredentials,t=(t=a.api.constructAPIUrl(t,{accountId:e.accountId}),s.post(t).set("Content-Type","application/json").set("Accept","application/json").send());e.traceid&&t.set("X-Amzn-Trace-Id",e.traceid);return t.end(function(e,t){e?(r=new c(a.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t)}),n.promise}.bind(this),queryDataFromSearch:function(e){var r=i.defer();{var t;e&&e.index&&e.query?(t=this.config.DEFAULT_HOSTS.INTEGRATION+this.config.INTEGRATIONS_API_URLS.queryDataFromSearch,t=a.api.constructAPIUrl(t,{index:e.index}),e={query:e.query},t=s.get(t).query(e),this.traceid&&t.set("X-Amzn-Trace-Id",this.traceid),t.end(function(e,t){e?(e={type:a.errors.ERROR_TYPES.API_ERROR,err:e},e=o.convertElasticsearchErrResponse(e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory params - index, type or query not found in request options.",e=new c(a.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),getAuditTrailForAttempts:function(e){var r=i.defer();{var t,n;e&&e.accountid&&e.action&&e.userid&&e.productcode&&e["item-code"]?(t=this.config.DEFAULT_HOSTS.INTEGRATION+this.config.INTEGRATIONS_API_URLS.auditTrail,t=a.api.constructAPIUrl(t,{accountId:e.accountid}),n={audit_context:"ATTEMPT-"+e.accountid+"#"+e.userid,target_context:"PRODUCT-"+e.productcode+"#"+e["item-code"],action:e.action},e.cursor&&(n.cursor=e.cursor),e.sortOrder&&(n.sortOrder=e.sortOrder),e=s.get(t).query(n),this.traceid&&e.set("X-Amzn-Trace-Id",this.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((t={}).message=t.description="Mandatory params - accountid, action, userid, productcode or item-code not found in request options.",t=new c(a.errors.ERROR_TYPES.SDK_ERROR,t),r.reject(t))}return r.promise}.bind(this),getAuditTrailForEntitlements:function(e){var r=i.defer();{var t,n;e&&e.accountid&&e.action&&e.userid&&e.productcode?(t=this.config.DEFAULT_HOSTS.INTEGRATION+this.config.INTEGRATIONS_API_URLS.auditTrail,t=a.api.constructAPIUrl(t,{accountId:e.accountid}),n={audit_context:"ENTITLEMENT-"+e.accountid+"#"+e.userid,target_context:"PRODUCT-"+e.productcode,type:"entitlement",action:e.action},e.cursor&&(n.cursor=e.cursor),e.sortOrder&&(n.sortOrder=e.sortOrder),e=s.get(t).query(n),this.traceid&&e.set("X-Amzn-Trace-Id",this.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((t={}).message=t.description="Mandatory params - accountid, userid or productcode not found in request options.",t=new c(a.errors.ERROR_TYPES.SDK_ERROR,t),r.reject(t))}return r.promise}.bind(this),getAuditTrailForMicroEntitlements:function(e){var r=i.defer();{var t,n;e&&e.accountid&&e.action&&e.userid&&e.productcode&&e.context?(t=this.config.DEFAULT_HOSTS.INTEGRATION+this.config.INTEGRATIONS_API_URLS.auditTrail,t=a.api.constructAPIUrl(t,{accountId:e.accountid}),n={audit_context:"ENTITLEMENT-"+e.accountid+"#"+e.userid,target_context:"PRODUCT-"+e.productcode+"#"+e.context,type:"micro-entitlement",action:e.action},e.cursor&&(n.cursor=e.cursor),e.sortOrder&&(n.sortOrder=e.sortOrder),e=s.get(t).query(n),this.traceid&&e.set("X-Amzn-Trace-Id",this.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((t={}).message=t.description="Mandatory params - accountid, action, userid, productcode or context not found in request options.",t=new c(a.errors.ERROR_TYPES.SDK_ERROR,t),r.reject(t))}return r.promise}.bind(this),publishCustomEvents:function(e){var r,n=i.defer(),t=this;{var o;e&&e.events?(o=t.config.DEFAULT_HOSTS.INTEGRATION+t.config.INTEGRATIONS_API_URLS.customEvents,o=a.api.constructAPIUrl(o,{accountId:t.accountId}),o=s.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(r=new c(a.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):((r={}).message=r.description="Mandatory params - events not found in request options.",r=new c(a.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),createSchedule:function(e){var r,n=i.defer();{var t;e&&e.context&&e.accountid&&e.body&&0<Object.keys(e.body).length&&e.body.scheduleid&&e.body.actorid&&e.body.category&&e.body.schedule_time?(t=this.config.DEFAULT_HOSTS.INTEGRATION+this.config.INTEGRATIONS_API_URLS.schedules,t=a.api.constructAPIUrl(t,{accountId:e.accountid,context:e.context}),t=s.post(t).set("Content-Type","application/json").set("Accept","application/json").send(e.body),this.traceid&&t.set("X-Amzn-Trace-Id",this.traceid),t.end(function(e,t){e?(r=new c(a.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):((r={}).message=r.description="Mandatory param - accountid or context or body(scheduleid or actorid or category or schedule_time) not found in request options.",r=new c(a.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),getSchedule:function(e){var r,n=i.defer();{var t,o;e&&e.context&&e.accountid?(t=this.config.DEFAULT_HOSTS.INTEGRATION+this.config.INTEGRATIONS_API_URLS.schedules,t=a.api.constructAPIUrl(t,{accountId:e.accountid,context:e.context}),o={},e.cursor&&(o.cursor=e.cursor),e.category&&(o.category=e.category),e.scheduleid&&(o.scheduleid=e.scheduleid),e=s.get(t).query(o),this.traceid&&e.set("X-Amzn-Trace-Id",this.traceid),e.end(function(e,t){e?(r=new c(a.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):((r={}).message=r.description="Mandatory params - accountid or context not found in request options.",r=new c(a.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),updateSchedule:function(e){var r,n=i.defer();{var t;e&&e.context&&e.accountid&&e.scheduleid&&e.body&&0<Object.keys(e.body).length&&e.body.actorid&&e.body.category?(t=this.config.DEFAULT_HOSTS.INTEGRATION+this.config.INTEGRATIONS_API_URLS.particularSchedule,t=a.api.constructAPIUrl(t,{accountId:e.accountid,context:e.context,scheduleId:e.scheduleid}),t=s.put(t).set("Content-Type","application/json").set("Accept","application/json").send(e.body),this.traceid&&t.set("X-Amzn-Trace-Id",this.traceid),t.end(function(e,t){e?(r=new c(a.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):((r={}).message=r.description="Mandatory param - accountid or context or scheduleid or body(category or actorid) not found in request options.",r=new c(a.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),deleteSchedule:function(e){var r,n=i.defer();{var t;e&&e.context&&e.accountid&&e.scheduleid&&e.body?(t=this.config.DEFAULT_HOSTS.INTEGRATION+this.config.INTEGRATIONS_API_URLS.particularSchedule,t=a.api.constructAPIUrl(t,{accountId:e.accountid,context:e.context,scheduleId:e.scheduleid}),t=s.delete(t).set("Content-Type","application/json").set("Accept","application/json").send(e.body),this.traceid&&t.set("X-Amzn-Trace-Id",this.traceid),t.agent(u).end(function(e,t){e?(r=new c(a.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):((r={}).message=r.description="Mandatory param - accountid or context or scheduleid or body not found in request options.",r=new c(a.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this)}},new n({timeout:6e4,freeSocketTimeout:3e4}))},{"../../helpers":3,"../../helpers/lib/api/converter":4,agentkeepalive:36,q:42,superagent:45}],22:[function(e,t,r){var a=e("q"),c=e("superagent"),u=e("../../helpers"),d=u.errors.DLSError;t.exports=function(){return{sendInvitations:function(e){var t=this,r=a.defer(),n=u.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.created&&e.invitation_data?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.sendInvitations,o=u.api.constructAPIUrl(o,{orgId:t.orgId}),o=c.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e),o=u.api.setupAPIToken(o,t.token),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(n={},n=new d(u.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="One or more required field(s) missing: context, created or invitation_data",n=new d(u.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getMultiInvitations:function(e){var t=this,r=a.defer(),n=u.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.context_id?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getMultiInvitations,o=u.api.constructAPIUrl(o,{orgId:t.orgId}),i={context_id:e.context_id},e.context&&(i.context=e.context),e.status&&(i.status=e.status),e.cursor&&(i.cursor=e.cursor),e=c.get(o).query(i),e=u.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n={},n=new d(u.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="context_id not found in request options.",n=new d(u.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),revokeSingleInvitation:function(e){var t=this,r=a.defer(),n=u.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context_id&&e.invitationid&&e.context?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.revokeSingleInvitation,o=u.api.constructAPIUrl(o,{orgId:t.orgId,invitationid:e.invitationid}),e={context:e.context,context_id:e.context_id},o=c.delete(o).query(e),o=u.api.setupAPIToken(o,t.token),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(n={},n=new d(u.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="context_id or context or invitationid not found in request options.",n=new d(u.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),completeSingleInvitation:function(e){var t=this,r=a.defer(),n=u.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context_id&&e.invitationid&&e.context?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.completeSingleInvitation,o=u.api.constructAPIUrl(o,{orgId:t.orgId,invitationid:e.invitationid}),e={context:e.context,context_id:e.context_id},o=c.put(o).query(e).set("Content-Type","application/json").set("Accept","application/json").send({}),o=u.api.setupAPIToken(o,t.token),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(n={},n=new d(u.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="context_id or context or invitationid not found in request options.",n=new d(u.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),resendSingleInvitation:function(e){var t=this,r=a.defer(),n=u.validations.isAuthenticated(t.orgId,t.token);{var o,i,s;n?r.reject(n):e&&e.invitationid&&e.context&&e.context_id?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.resendSingleInvitation,o=u.api.constructAPIUrl(o,{orgId:t.orgId,invitationid:e.invitationid}),i={context:e.context,context_id:e.context_id},s={},e.space_title&&(s.space_title=e.space_title),e=c.put(o).query(i).set("Content-Type","application/json").set("Accept","application/json").send(s),e=u.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n={},n=new d(u.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="context_id or context or invitationid not found in request options.",n=new d(u.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this)}}},{"../../helpers":3,q:42,superagent:45}],23:[function(e,t,r){var s=e("superagent"),a=e("q"),c=e("../../helpers"),u=c.errors.DLSError;t.exports=function(e){return this.accountId=e,{getProduct:function(e){var r=a.defer(),t=this,n={};{var o,i;e&&e.productcode?(o=t.config.DEFAULT_HOSTS.PRODUCT+t.config.PRODUCT_API_URLS.getProductAPI,o=c.api.constructAPIUrl(o,{accountId:t.accountId,productCode:e.productcode}),i={},e.details&&(i.details=e.details),e.stage&&(i.stage=e.stage),e=s.get(o).query(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="productcode not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getGlobalEntitlementsForAUser:function(e){var t=this,r=a.defer();{var n,o;e&&e.extUserId?(o=t.config.DEFAULT_HOSTS.PRODUCT+t.config.PRODUCT_API_URLS.getEntitlementsOfAUser,o=c.api.constructAPIUrl(o,{accountId:t.accountId,extUserId:e.extUserId}),n={},e.productDetails&&(n.productDetails=e.productDetails),e.bundleDetails&&(n.bundleDetails=e.bundleDetails),e=s.get(o).query(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((o={}).message=o.description="Mandatory parameter extUserId not found in request options",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),getMicroEntitlementsForAUser:function(e){var t=this,r=a.defer();{var n,o;e&&e.extuserid&&e.productcode?(o=t.config.DEFAULT_HOSTS.PRODUCT+t.config.PRODUCT_API_URLS.getMicroEntitlementsOfAUser,o=c.api.constructAPIUrl(o,{accountId:t.accountId,extUserId:e.extuserid}),(n={}).productcode=e.productcode,e.context&&(n.context=e.context),e.feature_key&&(n.feature_key=e.feature_key),e.cursor&&(n.cursor=e.cursor),e=s.get(o).query(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((o={}).message=o.description="Mandatory parameter extuserid or productcodenot found in request options",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),getAllBundles:function(e){var t=this,r=a.defer(),n=t.config.DEFAULT_HOSTS.PRODUCT+t.config.PRODUCT_API_URLS.getAllBundles,o=(n=c.api.constructAPIUrl(n,{accountId:t.accountId}),{});e&&(e.stage&&(o.stage=e.stage),e.target_role)&&(o.target_role=e.target_role);e=s.get(n).query(o);t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid);return e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}),r.promise}.bind(this),getSingleBundle:function(e){var t=this,r=a.defer();{var n,o;e&&e["bundle-code"]?(n=t.config.DEFAULT_HOSTS.PRODUCT+t.config.PRODUCT_API_URLS.getSingleBundle,n=c.api.constructAPIUrl(n,{accountId:t.accountId,bundleCode:e["bundle-code"]}),o={},e.stage&&(o.stage=e.stage),e=s.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Required parameter bundle-code not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getSingleProductFamily:function(e){var t=this,r=a.defer();{var n,o;e&&e["family-code"]?(n=t.config.DEFAULT_HOSTS.PRODUCT+t.config.PRODUCT_API_URLS.getSingleProductFamily,n=c.api.constructAPIUrl(n,{accountId:t.accountId,familyCode:e["family-code"]}),o={},e.stage&&(o.stage=e.stage),e=s.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Required parameter family-code not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAllProductFamilies:function(e){var t=this,r=a.defer(),n=t.config.DEFAULT_HOSTS.PRODUCT+t.config.PRODUCT_API_URLS.getAllProductFamilies,o=(n=c.api.constructAPIUrl(n,{accountId:t.accountId}),{});e&&e.stage&&(o.stage=e.stage);e=s.get(n).query(o);t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid);return e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}),r.promise}.bind(this)}}},{"../../helpers":3,q:42,superagent:45}],24:[function(e,t,r){var i=e("superagent"),s=e("q"),a=e("../../helpers"),c=a.errors.DLSError;t.exports=function(){return{promoteProduct:function(e){var t=this,r=s.defer(),n=t.config.DEFAULT_HOSTS.PUB+t.config.PUB_API_URLS.promoteAPI,o=(n=a.api.constructAPIUrl(n,{orgId:t.orgId,productcode:e.productcode}),{source:{},target:{}});e&&(e.source&&e.source.stage&&(o.source.stage=e.source.stage),e.target&&(e.target.org&&(o.target.org=e.target.org),e.target.stage)&&(o.target.stage=e.target.stage),e.externalrefid)&&(o.externalrefid=e.externalrefid);e=i.post(n).send(o);t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid);return e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t)}),r.promise}.bind(this),registerProduct:function(e){var t=this,r=s.defer(),n=t.config.DEFAULT_HOSTS.PUB+t.config.PUB_API_URLS.registerProductAPI,o=(n=a.api.constructAPIUrl(n,{orgId:t.orgId}),{});e&&(e.targetorg&&(o.targetorgid=e.targetorg),e.repositorytype&&(o.repositorytype=e.repositorytype),e.producttitle&&(o.producttitle=e.producttitle),e.producttype&&(o.producttype=e.producttype),e.productcode&&(o.productcode=e.productcode),e.github&&(o.github=e.github),e.s3&&(o.s3=e.s3),e.externalrefid&&(o.externalrefid=e.externalrefid),e["bundle-codes"])&&(o["bundle-codes"]=e["bundle-codes"]);e=i.post(n).send(o);t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid);return e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t)}),r.promise}.bind(this),ingestProduct:function(e){var t=this,r=s.defer();e&&e.productcode&&(o=e.productcode);var n=t.config.DEFAULT_HOSTS.PUB+t.config.PUB_API_URLS.ingestByCodeAPI,o=(n=a.api.constructAPIUrl(n,{orgId:t.orgId,productcode:o}),{});e&&(e.branchref&&(o.branchref=e.branchref),e.externalrefid&&(o.externalrefid=e.externalrefid),e["bundle-codes"])&&(o["bundle-codes"]=e["bundle-codes"]);e=i.post(n).send(o);t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid);return e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t)}),r.promise}.bind(this),createBundle:function(e){var t=this,r=s.defer();{var n;e&&e.stage&&e["bundle-code"]&&e.body&&e.body.title&&e.body.products?(n=t.config.DEFAULT_HOSTS.PUB+t.config.PUB_API_URLS.createBundle,n=a.api.constructAPIUrl(n,{orgid:t.orgId,stage:e.stage}),e.body["bundle-code"]=e["bundle-code"],n=i.post(n).send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Required parameter stage or bundle-code or title or products not found in request options",e=new c(a.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),updateBundle:function(e){var t=this,r=s.defer();{var n;e&&e.stage&&e["bundle-code"]&&e.body&&e.body.products?(n=t.config.DEFAULT_HOSTS.PUB+t.config.PUB_API_URLS.updateBundle,n=a.api.constructAPIUrl(n,{orgid:t.orgId,stage:e.stage,bundleCode:e["bundle-code"]}),n=i.put(n).send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Required parameter stage or bundle-code or products not found in request options",e=new c(a.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),getAllBundles:function(e){var t=this,r=s.defer(),n=t.config.DEFAULT_HOSTS.PUB+t.config.PUB_API_URLS.getAllBundles,o=(n=a.api.constructAPIUrl(n,{orgid:t.orgId}),{});e&&(e.stage&&(o.stage=e.stage),e.target_role)&&(o.target_role=e.target_role);e=i.get(n).query(o);t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid);return e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}),r.promise}.bind(this),getSingleBundle:function(e){var t=this,r=s.defer();{var n,o;e&&e["bundle-code"]?(n=t.config.DEFAULT_HOSTS.PUB+t.config.PUB_API_URLS.getSingleBundle,n=a.api.constructAPIUrl(n,{orgid:t.orgId,bundleCode:e["bundle-code"]}),o={},e&&e.stage&&(o.stage=e.stage),e=i.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Required parameter bundle-code not found in request options",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createProductFamily:function(e){var t=this,r=s.defer();{var n;e&&e.stage&&e.body&&e.body["family-code"]?(n=t.config.DEFAULT_HOSTS.PUB+t.config.PUB_API_URLS.createProductFamily,n=a.api.constructAPIUrl(n,{orgid:t.orgId,stage:e.stage}),n=i.post(n).send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Required parameter stage or family-code not found in request options",e=new c(a.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),updateProductFamily:function(e){var t=this,r=s.defer();{var n;e&&e.stage&&e["family-code"]?(n=t.config.DEFAULT_HOSTS.PUB+t.config.PUB_API_URLS.updateProductFamily,n=a.api.constructAPIUrl(n,{orgid:t.orgId,stage:e.stage,familyCode:e["family-code"]}),n=i.put(n).send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Required parameter stage or family-code not found in request options",e=new c(a.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),getSingleProductFamily:function(e){var t=this,r=s.defer();{var n,o;e&&e["family-code"]?(n=t.config.DEFAULT_HOSTS.PUB+t.config.PUB_API_URLS.getSingleProductFamily,n=a.api.constructAPIUrl(n,{orgid:t.orgId,familyCode:e["family-code"]}),o={},e.stage&&(o.stage=e.stage),e=i.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Required parameter family-code not found in request options",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAllProductFamilies:function(e){var t=this,r=s.defer(),n=t.config.DEFAULT_HOSTS.PUB+t.config.PUB_API_URLS.getAllProductFamilies,o=(n=a.api.constructAPIUrl(n,{orgid:t.orgId}),{});e&&e.stage&&(o.stage=e.stage);e=i.get(n).query(o);t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid);return e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}),r.promise}.bind(this)}}},{"../../helpers":3,q:42,superagent:45}],25:[function(e,t,r){var s=e("q"),a=e("superagent"),n=e("agentkeepalive"),c=e("../../helpers"),o=e("./pubnubClientWrapper"),u=c.errors.DLSError,d=(t.exports=function(){var e=o();return{connect:function(e,t){if(t.userid)return e.setup({userid:t.userid,accountid:t.accountid,token:t.token,pubnub:{publishKey:t.publishKey,subscribeKey:t.subscribeKey,ssl:!0,suppressLeaveEvents:!0},pollingEndpoint:t.pollingEndpoint,pollingIterations:t.pollingIterations||10,pollingInterval:t.pollingInterval});e={};throw e.message=e.description="Mandatory parameter userid not found in request options.",e=new u(c.errors.ERROR_TYPES.PUSHX_ERROR,e)}.bind(this,e),cleanup:function(e){e.cleanup()}.bind(this,e),grantByUserOrgId:function(e){var t,r=s.defer(),n=["jobs","systemevents"],o="o-"+this.orgId+"\\$u-"+this.token.access_token+"\\$",i=[];for(t in n)i.push(o+n[t]+"\\..*");return e.channels={},e.channels.patterns=i,l.call(this,e).then(function(e){r.resolve(e)}).catch(function(e){r.reject(e)}),r.promise}.bind(this),grantByAccountId:function(e){var t={},r=s.defer();{var n;e.accountId&&e.refId?(n=["a-"+e.accountId+"$refid."+e.refId],e.channels={},e.channels.exactMatch=n,l.call(this,e).then(function(e){r.resolve(e)}).catch(function(e){r.reject(e)})):(t.message=t.description="Required parameter ['accountId', 'refId'] not found in request options",t=new u(c.errors.ERROR_TYPES.SDK_ERROR,t),r.reject(t))}return r.promise}.bind(this),grantByAccountIdOnExtUserId:function(e){var t={},r=s.defer();{var n;e.accountId&&e.extUserId?(n=["a-"+e.accountId+"$u-"+e.extUserId],e.channels={},e.channels.exactMatch=n,l.call(this,e).then(function(e){r.resolve(e)}).catch(function(e){r.reject(e)})):(t.message=t.description="Required parameter ['accountId', 'extUserId'] not found in request options",t=new u(c.errors.ERROR_TYPES.SDK_ERROR,t),r.reject(t))}return r.promise}.bind(this),grantV2:l.bind(this),getPushedEvents:function(e){var r=s.defer(),t=e.accountid,n=e.channelname,o=e.starttime,e=e.endtime;{var i;t&&n&&o&&e?(i=this.config.DEFAULT_HOSTS.PUSHX+this.config.PUSHX_API_URLS.getPushedEvents,i=c.api.constructAPIUrl(i,{accountId:t}),t={channelname:n,starttime:o,endtime:e},n=a.get(i).query(t),this.traceid&&n.set("X-Amzn-Trace-Id",this.traceid),n.agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((o={}).message=o.description="Mandatory parameters [accountId, channelname, starttime, endtime] not found in request options",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this)}},new n({timeout:6e4,freeSocketTimeout:3e4}));function l(e){var t={},r=s.defer(),n={channels:{}};return e.channels?(n.channels=e.channels,e=this.config.DEFAULT_HOSTS.PUSHX+this.config.PUSHX_API_URLS.grantV2,e=a.post(e).set("Content-Type","application/json").set("Accept","application/json"),this.traceid&&e.set("X-Amzn-Trace-Id",this.traceid),e.send(n),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(t.message=t.description="channels not given in input body.",t=new u(c.errors.ERROR_TYPES.SDK_ERROR,t),r.reject(t)),r.promise}},{"../../helpers":3,"./pubnubClientWrapper":26,agentkeepalive:36,q:42,superagent:45}],26:[function(e,t,r){var R=e("pubnub"),_=e("superagent"),A=e("events").EventEmitter,b=e("../../helpers"),v=b.errors.PUSHXError;t.exports=function(){var n,u,o,i,d,l=new A,s=[],p={},a=!1,f=!1,h=function(){return JSON.parse(JSON.stringify(p))},g=function(e){n.subscribe({channels:[e]})},y=function(){var e={accountid:u.accountid,channelname:s[0],starttime:i,endtime:Date.now()};e.channelname&&e.starttime&&_.get(u.pollingEndpoint).query(e).end(function(e,t){var r;e||(0===d&&(p[s[0]]&&(p[s[0]].status="subscribed"),r={category:"PUSHX",type:"CHANNEL_SUBSCRIPTION",status:"SUCCESS",message:"Success: Subscribed successfully.",httpcode:200,data:{payload:{channels:s},message:"Success: Subscribed successfully."}},l.emit("pushx_status",r)),c(t.body),d++),d>u.pollingIterations?(e=new v(b.errors.ERROR_CATEGORY.PUSHX,e={message:"Polling error: Polling limit exceeded",status:429}),l.emit("pushx_status",e)):(r=u.pollingInterval?60*u.pollingInterval*1e3:parseInt(10*Math.pow(1.3,d)*1e3,10))&&(o=setTimeout(y,r))})},c=function(e){for(var t=m(),r=t.events,t=t.key,n=0;n<e.entities.length;n++){var o=e.entities[n],i=o.pk+"_"+o.sk;r[i]||(r[i]=o.context.start_time,l.emit(s[0],o))}sessionStorage.setItem(t,JSON.stringify(r))},m=function(){var e="comprodls.old_pushx_events."+u.userid+"."+s[0],t=sessionStorage.getItem(e);if(t){try{t=JSON.parse(t)}catch(e){t={}}for(var r=Object.keys(t),n=0;n<r.length;n++){var o=r[n];t[o]<i&&delete t[o]}r.length!==Object.keys(t).length&&sessionStorage.setItem(e,JSON.stringify(t))}else t={};return{key:e,events:t}};return{setup:function(e){var t=e.pubnub,c=(t.uuid=e.userid,e.accountid),r=e.token;return n||!t?new Error("Already Initialized"):((n=new R(t)).setToken(r),u=e,n.addListener({message:function(e){var t;t=e.subscribedChannel,l.emit(t,e.message)},status:function(e){var t,r=e,n={accountId:c},o=[];if(!f)switch(r.category){case"PNConnectedCategory":if("PNSubscribeOperation"===r.operation){for(var i in o=r.subscribedChannels)p[o[i]]&&(p[o[i]].status="subscribed");l.emit("pushx_status",{category:"PUSHX",type:"CHANNEL_SUBSCRIPTION",status:"SUCCESS",message:"Success: Subscribed successfully.",httpcode:200,data:{payload:{channels:r.subscribedChannels},message:"Success: Subscribed successfully."}})}break;case"PNAccessDeniedCategory":if("PNSubscribeOperation"===r.operation){var s,a=r.errorData.response&&r.errorData.response.text,a=a?JSON.parse(a):void 0,a={payload:a&&a.payload||r.errorData.payload,message:"Forbidden: Subscription failed.",errorDetails:{operation:r.operation,category:r.category,statusCode:r.statusCode}};for(s in o=a.payload.channels)p[o[s]]&&(p[o[s]].status="error",p[o[s]].error=t);t=new v(b.errors.ERROR_CATEGORY.PUSHX,a),l.emit("pushx_status",t)}break;case"PNBadRequestCategory":case"PNNetworkDownCategory":case"PNNetworkUpCategory":t={message:"PushX Error",status:r.statusCode,pushXError:r},t=new v(b.errors.ERROR_CATEGORY.PUSHX,t),l.emit("pushx_status",t);break;case"PNNetworkIssuesCategory":if("PNSubscribeOperation"===r.operation){if(!n.accountId||!u.pollingEndpoint){t={message:"Polling initiation error: Missing mandatory parameters to initiate polling operation - [accountId, pollingEndpoint]",status:r.statusCode},t=new v(b.errors.ERROR_CATEGORY.PUSHX,t),l.emit("pushx_status",t);break}d=0,y(),f=!0}break;case"PNReconnectedCategory":break;default:t={message:"PushX Error: unexpected error",status:r.statusCode,pushXError:r},t=new v(b.errors.ERROR_CATEGORY.PUSHX,t),l.emit("pushx_status",t)}}}),{on:function(e,t){i=Date.now();var r=[];e.orgid||e.userid||e.accountid||e.productid||e.classid?(e.accountid?r.push("a-"+e.accountid):(e.orgid&&r.push("o-"+e.orgid),e.userid&&r.push("u-"+e.userid),e.productid&&r.push("p-"+e.productid),e.classid&&r.push("c-"+e.classid)),r=r.join("$")+"$"+e.channel,s.includes(r)||(s.push(r),p[r]={status:"pending"},l.on(r,t),g(r))):"pushx_status"!==e.channel||a||(l.on(e.channel,t),a=!0),m()},getMySubscriptionStatus:h})},cleanup:function(){n&&(n.unsubscribeAll(),n.stop(),a=!(s=[]),f=!(p={})),n=void 0,o&&(clearTimeout(o),i=Date.now(),m(),i=d=o=void 0)}}}},{"../../helpers":3,events:38,pubnub:41,superagent:45}],27:[function(e,t,r){var i=e("q"),s=e("superagent"),a=e("../../helpers"),e=e("agentkeepalive"),c=a.errors.DLSError,o=(t.exports=function(){return{getRules:function(e){var t=this,r=i.defer(),n=a.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.ruleType?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.RULES_API_URLS.rules,o=a.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),ruleType:e.ruleType}),e={cursor:e.cursor},o=s.get(o).set("Content-Type","application/json").set("Accept","application/json").query(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=a.api.setupAPIToken(o,t.token)).end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="context or ruleType not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getParticularRule:function(e){var t=this,r=i.defer(),n=a.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.ruleType&&e.ruleId?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.RULES_API_URLS.particularRule,o=a.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),ruleType:e.ruleType,ruleId:e.ruleId}),e=s.get(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=a.api.setupAPIToken(e,t.token)).end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="context or ruleType or ruleId not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getUserRule:function(e){var t=this,r=i.defer();{var n;e&&e.orgId&&e.context&&e.ruleType&&e.userId?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.RULES_API_URLS.getUserRule,n=a.api.constructAPIUrl(n,{orgId:t.orgId,context:encodeURIComponent(e.context),ruleType:e.ruleType,userId:e.userId}),e=s.get(n).set("Content-Type","application/json").set("Accept","application/json"),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=a.api.setupAPIToken(e,t.token)).agent(o).end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - orgId or context or ruleType or userId not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateRuleDisplay:function(e){var t=this,r=i.defer(),n=a.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.ruleType&&e.ruleId&&e.body&&e.body.rule_display?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.RULES_API_URLS.updateRuleDisplay,o=a.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),ruleType:e.ruleType,ruleId:e.ruleId}),o=s.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=a.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - context or ruleType or ruleId or body.rule_display not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createRule:function(e){var t=this,r=i.defer(),n=a.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.ruleType&&e.body?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.RULES_API_URLS.rules,o=a.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),ruleType:e.ruleType}),o=s.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=a.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - context or ruleType or body not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateRule:function(e){var t=this,r=i.defer(),n=a.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.ruleType&&e.ruleId&&e.body?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.RULES_API_URLS.particularRule,o=a.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),ruleType:e.ruleType,ruleId:e.ruleId}),o=s.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=a.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - context or ruleType or ruleId or body not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),deleteRule:function(e){var t=this,r=i.defer(),n=a.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.ruleType&&e.ruleId?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.RULES_API_URLS.particularRule,o=a.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),ruleType:e.ruleType,ruleId:e.ruleId}),e=s.delete(o),e=a.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n={},n=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - context or ruleType or ruleId not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this)}},new e({timeout:6e4,freeSocketTimeout:3e4}))},{"../../helpers":3,agentkeepalive:36,q:42,superagent:45}],28:[function(e,t,r){var s=e("q"),a=e("superagent"),n=e("agentkeepalive"),c=e("../../helpers"),u=c.errors.DLSError,i=(t.exports=function(e){return this.accountId=e,{getUserSpaces:function(e){var t=this,r=s.defer();{var n,o,i;e&&e.extuserid?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getUserSpaces,n=c.api.constructAPIUrl(n,{accountid:t.accountId,extuserid:e.extuserid}),o={},e.spaceRole&&(o.spaceRole=e.spaceRole),e.spaceType&&(o.spaceType=e.spaceType),e.spaceOrgContext&&(o.spaceOrgContext=e.spaceOrgContext),e.details&&(o.details=e.details),e.cursor&&(o.cursor=e.cursor),e=a.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(i=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(i)):r.resolve(t.body)})):((i={}).message=i.description="extuserid not found in request options.",i=new u(c.errors.ERROR_TYPES.SDK_ERROR,i),r.reject(i))}return r.promise}.bind(this),validateSpaceCode:function(e){var t=this,r=s.defer();{var n,o;e&&e.spaceCodeBody&&e.spaceCodeBody.space_code?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.validateSpaceCode,n=c.api.constructAPIUrl(n,{accountid:t.accountId}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e.spaceCodeBody),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(o=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={}).message=o.description="spaceCodeBody or space_code not found in request options.",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),validateClassCode:function(e){var t=this,r=s.defer();{var n,o,i;e&&e.classCodeBody&&e.classCodeBody.class_code?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.validateClassCode,o=c.api.constructAPIUrl(o,{accountid:t.accountId}),n={},e.details&&(n.details=e.details),o=a.post(o).set("Content-Type","application/json").set("Accept","application/json").query(n).send(e.classCodeBody),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(i=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(i)):r.resolve(t.body)})):((i={}).message=i.description="classCodeBody or class_code not found in request options.",i=new u(c.errors.ERROR_TYPES.SDK_ERROR,i),r.reject(i))}return r.promise}.bind(this),generateSpaceCode:function(e){var t=this,r=s.defer(),n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.generateSpaceCode,o=(n=c.api.constructAPIUrl(n,{accountid:t.accountId}),{});e.ignore_words&&(o.ignore_words=e.ignore_words);e=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(o);t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid);return e.end(function(e,t){e?(err=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(err)):r.resolve(t)}),r.promise}.bind(this),changeSpaceCode:function(e){var t=this,r=s.defer();{var n,o,i;e&&e.ext_user_id&&e.spacecode?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.changeSpaceCode,n=c.api.constructAPIUrl(n,{accountid:t.accountId,spacecode:e.spacecode}),o={ext_user_id:e.ext_user_id},e.ignore_words&&(o.ignore_words=e.ignore_words),e=a.put(n).set("Content-Type","application/json").set("Accept","application/json").send(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(i=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(i)):r.resolve(t)})):((i={}).message=i.description="Mandatory parameter options, ext_user_id or spacecode, not found in request options.",i=new u(c.errors.ERROR_TYPES.SDK_ERROR,i),r.reject(i))}return r.promise}.bind(this),joinInstituteSpace:function(e){var t=this,r=s.defer();{var n,o;e&&e.ext_user_id&&e.ext_role&&e.space_code?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.joinInstituteSpace,n=c.api.constructAPIUrl(n,{accountid:t.accountId}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(o=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={}).message=o.description="ext_user_id or ext_role or space_code not found in request options.",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),provisionSpacesToStudent:function(e){var t=this,r=s.defer(),n={};{var o;e&&e.ext_user_id&&e.ext_role?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.provisionSpacesToStudent,o=c.api.constructAPIUrl(o,{accountId:t.accountId}),o=a.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description="ext_user_id or ext_role not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),provisionSpacesToTeacher:function(e){var t=this,r=s.defer();{var n,o;e&&e.ext_user_id&&e.ext_role?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.provisionSpacesToTeacher,n=c.api.constructAPIUrl(n,{accountId:t.accountId}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(o=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={}).message=o.description="Mandatory parameters [rxt_user_id, ext_role] not found in request options.",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),provisionBulkSpaces:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.users&&e.space_title?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.provisionBulkSpaces,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),o=a.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory parameters: space_title or users not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),shadowProvision:function(e){var t=this,r=s.defer(),n={};{var o;e&&e.ext_user_id&&e.ext_role?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.shadowProvision,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),o=a.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.agent(i).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Mandatory parameters: ext_user_id or ext_role not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),entitleUserToProduct:function(e){var t=this,r=s.defer();{var n,o;e&&e.ext_user_id&&e.ext_role&&(e.productcode||e.ext_product_id)?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.entitleUserToProduct,n=c.api.constructAPIUrl(n,{accountId:t.accountId}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(o=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={description:"Missing mandatory keys in request options. 'ext_user_id', 'ext_role' and either of 'ext_product_id' or 'productcode' must be present."}).message=o.description,o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),unentitleUserToProduct:function(e){var t=this,r=s.defer();{var n;e&&e.ext_user_id&&e.productcode&&e.ext_actor_id&&void 0!==e.audit?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.entitleUserToProduct,n=c.api.constructAPIUrl(n,{accountId:t.accountId}),n=a.delete(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Missing mandatory keys in request options. 'ext_user_id', 'ext_actor_id', 'productcode' and 'audit' must be present",e=new u(c.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),revokeMicroEntitlementOfAUser:function(e){var t=this,r=s.defer(),n={description:"",message:""};{var o;e&&e.ext_user_id&&e.context&&e.feature_key&&e.ext_actor_id&&void 0!==e.audit&&(e.productcode||e.ext_product_id)?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.microEntitleUserToProduct,o=c.api.constructAPIUrl(o,{accountId:t.accountId}),o=a.delete(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.description="ext_user_id or context or feature_key or ext_actor_id or audit field not found or is empty in request options. Either productcode or ext_product_id must be provided.",n.message=n.description,n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),microEntitleUserToProduct:function(e){var t=this,r=s.defer(),n=!0,o={description:"",message:""};e&&e.ext_user_id&&e.context&&e.feature_key&&e.feature_id||(n=!1,o.description="ext_user_id or context or feature_key or feature_id not found in request options. ");n&&(e.productcode||e.ext_product_id)?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.microEntitleUserToProduct,n=c.api.constructAPIUrl(n,{accountId:t.accountId}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(o=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):(e.productcode||e.ext_product_id||(o.description+="Either of ext_product_id or productcode must be present in request options."),o.message=o.description,o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o));return r.promise}.bind(this),bulkMicroEntitleProductToUser:function(e){var t=this,r=s.defer();{var n,o;e&&e["micro-entitlements"]?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.bulkMicroEntitleProductToUser,n=c.api.constructAPIUrl(n,{accountId:t.accountId}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(o=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={description:"Missing mandatory keys in request options. 'micro-entitlements' must be present."}).message=o.description,o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),enrollUserInClass:function(e){var t=this,r=s.defer();{var n,o;e&&e.ext_user_id&&e.ext_role&&e.class_code?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.enrollUserInClass,n=c.api.constructAPIUrl(n,{accountId:t.accountId}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(o=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={}).message=o.description="ext_user_id or ext_role or class_code not found in request options.",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),getExtProduct:function(e){var t=this,r=s.defer();{var n,o;e&&e.ext_product_id?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getExtProductAPI,n=c.api.constructAPIUrl(n,{accountId:t.accountId,extProductId:e.ext_product_id}),e=a.get(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(o=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={}).message=o.description="ext_product_id not found in request options.",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),getSpaceDetails:function(e){var t=this,r=s.defer();{var n,o;e&&e.spacekey?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getSpaceDetails,n=c.api.constructAPIUrl(n,{accountId:t.accountId,spacekey:e.spacekey}),e={orgid:t.orgId},n=a.get(n).query(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=c.api.setupAPIToken(n,t.token)).end(function(e,t){e?(o=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={}).message=o.description="spacekey not found in request options.",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),updateUserInformation:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.ext_user_id?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.updateUserInformation,o=c.api.constructAPIUrl(o,{accountId:t.accountId}),i={ext_user_id:e.ext_user_id},e.ref_id&&(i.ref_id=e.ref_id),e.ext_email&&(i.ext_email=e.ext_email),e.ext_first_name&&(i.ext_first_name=e.ext_first_name),e.ext_last_name&&(i.ext_last_name=e.ext_last_name),e.address&&(i.address=e.address),e=a.put(o).set("Content-Type","application/json").set("Accept","application/json").send(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description='Mandatory parameters not found in request options: ["ext_user_id"]',n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateUserSpace:function(e){var r,t=this,n=s.defer();{var o;e&&e.extuserid&&e.spacekey&&e.body?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.updateUserSpace,o=c.api.constructAPIUrl(o,{accountid:t.accountId,extuserid:e.extuserid,spacekey:e.spacekey}),o=a.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.agent(i).end(function(e,t){e?(r=new u(c.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):((e={}).message=e.description="Missing mandatory params: 'extuserid' or 'spacekey' or 'body' not found in the request options.",r=new u(c.errors.ERROR_TYPES.SDK_ERROR,e),n.reject(r))}return n.promise}.bind(this),getInvitationsByEmail:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.email?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getInvitationsByEmail,o=c.api.constructAPIUrl(o,{accountid:t.accountId}),i={email:e.email},e.status&&(i.status=e.status),e=a.get(o).query(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description="email not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateInstituteTitle:function(e){var t=this,r=s.defer(),n={};{var o;e&&e.space_code&&e.body&&e.body.ext_actor_id?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.updateInstituteTitle,o=c.api.constructAPIUrl(o,{accountId:t.accountId,instituteSpaceCode:e.space_code}),o=a.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description="space_code or ext_actor_id not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this)}},new n({timeout:6e4,freeSocketTimeout:3e4}))},{"../../helpers":3,agentkeepalive:36,q:42,superagent:45}],29:[function(e,t,r){var o=e("q"),i=e("superagent"),n=e("agentkeepalive"),s=e("../../helpers"),a=s.errors.DLSError,c=(t.exports=function(e){return this.accountId=e,{entitleBulkUsersToProducts:function(e){var t=this,r=o.defer();{var n;e&&e.users&&e.ext_actor_id?(n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.entitleBulkUsersToProducts,n=s.api.constructAPIUrl(n,{accountid:t.accountId}),n=i.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.agent(c).end(function(e,t){e?(e=new a(s.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={description:"Mandatory params: 'users', 'ext_actor_id' not found in request options."}).message=e.description,e=new a(s.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),setupUser:function(e){var t=this,r=o.defer();{var n;e&&e.ext_user_id&&e.workflow_type?(n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.setupUser,n=s.api.constructAPIUrl(n,{accountId:t.accountId}),n=i.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.agent(c).end(function(e,t){e?(e=new a(s.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory field 'ext_user_id' or 'workflow_type' not found in the request options.",e=new a(s.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this)}},new n({timeout:6e4,freeSocketTimeout:3e4}))},{"../../helpers":3,agentkeepalive:36,q:42,superagent:45}],30:[function(e,t,r){var i=e("q"),s=e("superagent"),a=e("../../helpers"),c=a.errors.DLSError;t.exports=function(e){return this.accountId=e,{getAllInstitutions:function(e){var t=this,r=i.defer(),n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getAllInstitutions,o=(n=a.api.constructAPIUrl(n,{accountid:t.accountId}),{});e&&(e.lookup&&(o.lookup=e.lookup),e.cursor&&(o.cursor=e.cursor),e.limit)&&(o.limit=e.limit);e=s.get(n).query(o);t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid);return e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}),r.promise}.bind(this),getInstitution:function(e){var t=this,r=i.defer();{var n,o;e&&e.spacecode?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getInstitution,n=a.api.constructAPIUrl(n,{accountid:t.accountId,spacecode:e.spacecode}),e=s.get(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(o=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={}).message=o.description="spacecode not found in request options.",o=new c(a.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),provisionSpacesToSuperAdmin:function(e){var t=this,r=i.defer();{var n,o;e&&e.ext_user_id&&e.ext_role&&e.ext_email&&e.ext_first_name&&e.ext_last_name?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.provisionSpacesToSuperAdmin,n=a.api.constructAPIUrl(n,{accountid:t.accountId}),n=s.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(o=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={}).message=o.description="Missing required input data",o=new c(a.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this)}}},{"../../helpers":3,q:42,superagent:45}],31:[function(e,t,r){var s=e("q"),a=e("superagent"),c=e("../../helpers"),u=c.errors.DLSError;t.exports=function(){return{associateTagsWithEntity:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.entity_type&&e.entity_id&&e.tags?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.TAXONOMY_API_URLS.associateTagsWithEntity,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),o=a.put(o).send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="entity_id or entity_type or tags not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createTags:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.taxonomyid&&e.body&&e.body.tags&&0<e.body.tags.length?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.TAXONOMY_API_URLS.tags,o=c.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),taxonomyId:e.taxonomyid}),o=a.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory param - context or taxonomyid or body.tags(min. 1 tag) not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateTags:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.taxonomyid&&e.body&&e.body.tagid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.TAXONOMY_API_URLS.tags,o=c.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),taxonomyId:e.taxonomyid}),o=a.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - context or taxonomyid or tagid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),deleteTags:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.context&&e.taxonomyid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.TAXONOMY_API_URLS.tags,o=c.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),taxonomyId:e.taxonomyid}),i={},e.tagid&&(i.tagid=e.tagid),e=a.delete(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n={},n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="context or taxonomyid or tagid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getTag:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.taxonomyid&&e.tagid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.TAXONOMY_API_URLS.tags,o=c.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),taxonomyId:e.taxonomyid}),e={hierarchy:!1,tagid:e.tagid},o=a.get(o).set("Content-Type","application/json").set("Accept","application/json").query(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory param - context or taxonomyid or tagid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getTagHierarchy:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.taxonomyid&&e.tagid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.TAXONOMY_API_URLS.tags,o=c.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),taxonomyId:e.taxonomyid}),e={hierarchy:!0,tagid:e.tagid},o=a.get(o).set("Content-Type","application/json").set("Accept","application/json").query(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory param - context or taxonomyid or tagid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAllTags:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.taxonomyid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.TAXONOMY_API_URLS.tags,o=c.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),taxonomyId:e.taxonomyid}),e=a.get(o).set("Content-Type","application/json").set("Accept","application/json").query({hierarchy:!0}),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=c.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory param - context or taxonomyid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this)}}},{"../../helpers":3,q:42,superagent:45}],32:[function(e,t,r){var s=e("q"),a=e("superagent"),c=e("./../../helpers"),u=c.errors.DLSError;t.exports=function(e){return this.accountId=e,{createWorkflow:function(e){var t=this,r=s.defer();{var n,o;e&&e.ext_user_id&&e.workflow_type?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.workflows,n=c.api.constructAPIUrl(n,{accountid:t.accountId}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(o=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={}).message=o.description="ext_user_id or workflow_type not found in request options.",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),getAllWorkflow:function(e){var t=this,r=s.defer();{var n,o;e&&e.workflow_type&&e.status?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.workflows,n=c.api.constructAPIUrl(n,{accountid:t.accountId}),o={workflow_type:e.workflow_type,status:e.status},e.start&&(o.start=e.start),e.end&&(o.end=e.end),e.cursor&&(o.cursor=e.cursor),e=a.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(err=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(err)):r.resolve(t.body)})):((err={}).message=err.description="Mandatory params - workflow_type, status not found in request options.",err=new u(c.errors.ERROR_TYPES.SDK_ERROR,err),r.reject(err))}return r.promise}.bind(this),getAllWorkflowOfAUser:function(e){var t=this,r=s.defer();{var n,o;e&&e.workflow_type&&e.status&&e.ext_user_id?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getAllWorkflowOfAUser,n=c.api.constructAPIUrl(n,{accountid:t.accountId}),o={workflow_type:e.workflow_type,status:e.status,ext_user_id:e.ext_user_id},e.start&&(o.start=e.start),e.end&&(o.end=e.end),e.cursor&&(o.cursor=e.cursor),e=a.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(err=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(err)):r.resolve(t.body)})):((err={}).message=err.description="Mandatory params - workflow_type, status, ext_user_id not found in request options.",err=new u(c.errors.ERROR_TYPES.SDK_ERROR,err),r.reject(err))}return r.promise}.bind(this),getAWorkflow:function(e){var t=this,r=s.defer();{var n;e&&e.workflowid&&e.context_id?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getAWorkflow,n=c.api.constructAPIUrl(n,{accountid:t.accountId,workflowid:e.workflowid}),e={context_id:e.context_id},n=a.get(n).query(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(err=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(err)):r.resolve(t.body)})):((err={}).message=err.description="Mandatory params - workflow_type, status not found in request options.",err=new u(c.errors.ERROR_TYPES.SDK_ERROR,err),r.reject(err))}return r.promise}.bind(this),acceptAWorkflow:function(e){var t=this,r=s.defer();{var n;e&&e.workflowid&&e.body&&e.body.context_id?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.acceptAWorkflow,n=c.api.constructAPIUrl(n,{accountid:t.accountId,workflowid:e.workflowid}),e=e.body,n=a.put(n).send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(err=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(err)):r.resolve(t)})):((err={}).message=err.description="Mandatory params - workflowid, body or body.context_id not found in request options.",err=new u(c.errors.ERROR_TYPES.SDK_ERROR,err),r.reject(err))}return r.promise}.bind(this),processAWorkflow:function(e){var t=this,r=s.defer();{var n;e&&e.workflowid&&e.body&&e.body.context_id&&e.body.org_id?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.processAWorkflow,n=c.api.constructAPIUrl(n,{accountid:t.accountId,workflowid:e.workflowid}),e=e.body,n=a.put(n).send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(err=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(err)):r.resolve(t)})):((err={}).message=err.description="Mandatory params - workflowid, body, body.context_id, body.org_id in request options.",err=new u(c.errors.ERROR_TYPES.SDK_ERROR,err),r.reject(err))}return r.promise}.bind(this),revokeAWorkflow:function(e){var t=this,r=s.defer();{var n;e&&e.workflowid&&e.body&&e.body.context_id?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.revokeAWorkflow,n=c.api.constructAPIUrl(n,{accountid:t.accountId,workflowid:e.workflowid}),e=e.body,n=a.put(n).send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(err=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(err)):r.resolve(t)})):((err={}).message=err.description="Mandatory params - workflowid, body or body.context_id not found in request options.",err=new u(c.errors.ERROR_TYPES.SDK_ERROR,err),r.reject(err))}return r.promise}.bind(this),completeAWorkflow:function(e){var t=this,r=s.defer();{var n;e&&e.workflowid&&e.body&&e.body.context_id?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.completeAWorkflow,n=c.api.constructAPIUrl(n,{accountid:t.accountId,workflowid:e.workflowid}),e=e.body,n=a.put(n).send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(err=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(err)):r.resolve(t)})):((err={}).message=err.description="Mandatory params - workflowid, body or body.context_id not found in request options.",err=new u(c.errors.ERROR_TYPES.SDK_ERROR,err),r.reject(err))}return r.promise}.bind(this),updateWorkflowRequest:function(e){var t=this,r=s.defer();{var n,o,i;e&&e.context_id&&e.body.ext_user_id&&e.body.workflow_type&&e.workflowid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getAWorkflow,o=c.api.constructAPIUrl(o,{accountid:t.accountId,workflowid:e.workflowid}),n={context_id:e.context_id},o=a.put(o).set("Content-Type","application/json").set("Accept","application/json").query(n).send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(i=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(i)):r.resolve(t)})):((i={}).message=i.description="context_id or ext_user_id or workflow_type or workflowid not found in request options.",i=new u(c.errors.ERROR_TYPES.SDK_ERROR,i),r.reject(i))}return r.promise}.bind(this)}}},{"./../../helpers":3,q:42,superagent:45}],33:[function(e,t,r){var o=e("q"),i=e("superagent"),s=e("../../helpers"),a=s.errors.DLSError;t.exports=function(e){return this.accountId=e,{postStatement:function(e){var t=this,r=o.defer(),n={};(n=s.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(n=t.config.DEFAULT_HOSTS.XAPI+t.config.XAPI_API_URLS.postMultiStatements,n=s.api.constructAPIUrl(n,{orgId:t.orgId}),e=e,n=i.post(n).send(e),n=s.api.setupAPIToken(n,t.token),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(e=new a(s.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}));return r.promise}.bind(this),postExternalStatements:function(e){var t=this,r=o.defer(),n=t.config.DEFAULT_HOSTS.XAPI+t.config.XAPI_API_URLS.postExternalMultiStatements,n=(n=s.api.constructAPIUrl(n,{orgId:t.orgId}),i.post(n).send(e));t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid);return n.end(function(e,t){e?(e=new a(s.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}),r.promise}.bind(this)}}},{"../../helpers":3,q:42,superagent:45}],34:[function(e,t,r){var i=e("superagent"),s=e("q"),a=e("../helpers"),c=a.errors.DLSError,u=e("./validations");r.authWithExtUser=function(e,t){var n=this,o=s.defer(),r=u.validateAuthWithExtUser(e,t);r?o.reject(r):(r=this.config.DEFAULT_HOSTS.AUTH+this.config.AUTH_API_URLS.getExtUserTokenAPI,r=a.api.constructAPIUrl(r,{orgId:e}),e={ext_user_id:t.ext_user_id},i.post(r).send(e).end(function(e,t){var r;e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),o.reject(e)):(t={token:e={access_token:t.body.access_token},user:r=t.body.user,metrics:t.body.metrics},n.token=e,n.orgId=r.org.id,o.resolve(t))}));return o.promise},r.authWithToken=function(e,t,r){var n=this,o=s.defer(),i=u.authWithToken(e,t,r);i?o.reject(i):(n.token=t,n.orgId=e,r&&r.getuserdetails?n.Auth().getUserProfile().then(function(e){e={token:n.token,user:e};o.resolve(e)},function(e){e=new c(a.errors.ERROR_TYPES.API_ERROR,e),o.reject(e)}):o.resolve(n.token));return o.promise}},{"../helpers":3,"./validations":35,q:42,superagent:45}],35:[function(e,t,r){var n=e("../helpers").validations.validate;r.authWithToken=function(e,t,r){return n({organization:e,token:t,options:r},{organization:{isString:!0,presence:!0},token:{isObject:!0,presence:!0,contains:["access_token"]},"token.access_token":{isString:!0,presence:!0},options:{isObject:!0}})},r.validateAuthWithExtUser=function(e,t){return n({organization:e,options:t},{organization:{isString:!0,presence:!0},options:{isObject:!0,presence:!0,contains:["ext_user_id"]},"options.ext_user_id":{isString:!0,presence:!0}})}},{"../helpers":3}],36:[function(e,t,r){function n(){}t.exports=n,t.exports.HttpsAgent=n},{}],37:[function(e,t,r){function n(e){if(e){var t,r=e;for(t in n.prototype)r[t]=n.prototype[t];return r}}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)this._callbacks={};else{var r=this._callbacks["$"+e];if(r)if(1==arguments.length)delete this._callbacks["$"+e];else{for(var n,o=0;o<r.length;o++)if((n=r[o])===t||n.fn===t){r.splice(o,1);break}0===r.length&&delete this._callbacks["$"+e]}}return this},n.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks["$"+e],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(r)for(var n=0,o=(r=r.slice(0)).length;n<o;++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}},{}],38:[function(e,t,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function a(e){return"function"==typeof e}function c(e){return"object"==typeof e&&null!==e}function u(e){return void 0===e}((t.exports=n).EventEmitter=n).prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,r,n,o,i,s;if(this._events||(this._events={}),"error"===e&&(!this._events.error||c(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(u(r=this._events[e]))return!1;if(a(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:for(n=arguments.length,o=new Array(n-1),i=1;i<n;i++)o[i-1]=arguments[i];r.apply(this,o)}else if(c(r)){for(n=arguments.length,o=new Array(n-1),i=1;i<n;i++)o[i-1]=arguments[i];for(n=(s=r.slice()).length,i=0;i<n;i++)s[i].apply(this,o)}return!0},n.prototype.on=n.prototype.addListener=function(e,t){if(a(t))return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,a(t.listener)?t.listener:t),this._events[e]?c(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,c(this._events[e])&&!this._events[e].warned&&(t=u(this._maxListeners)?n.defaultMaxListeners:this._maxListeners)&&0<t&&this._events[e].length>t&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace)&&console.trace(),this;throw TypeError("listener must be a function")},n.prototype.once=function(e,t){var r;if(a(t))return r=!1,n.listener=t,this.on(e,n),this;throw TypeError("listener must be a function");function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}},n.prototype.removeListener=function(e,t){var r,n,o,i;if(!a(t))throw TypeError("listener must be a function");if(this._events&&this._events[e])if(o=(r=this._events[e]).length,n=-1,r===t||a(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(c(r)){for(i=o;0<i--;)if(r[i]===t||r[i].listener&&r[i].listener===t){n=i;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,r;if(this._events)if(this._events.removeListener)if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);this.removeAllListeners("removeListener"),this._events={}}else{if(a(r=this._events[e]))this.removeListener(e,r);else for(;r.length;)this.removeListener(e,r[r.length-1]);delete this._events[e]}else 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e];return this},n.prototype.listeners=function(e){e=this._events&&this._events[e]?a(this._events[e])?[this._events[e]]:this._events[e].slice():[];return e},n.listenerCount=function(e,t){e=e._events&&e._events[t]?a(e._events[t])?1:e._events[t].length:0;return e}},{}],39:[function(e,t,r){function d(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===i.call(e)}function l(e){if(e&&"[object Object]"===i.call(e)){var t,r=o.call(e,"constructor"),n=e.constructor&&e.constructor.prototype&&o.call(e.constructor.prototype,"isPrototypeOf");if(!e.constructor||r||n){for(t in e);return void 0===t||o.call(e,t)}}}function p(e,t){n&&"__proto__"===t.name?n(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue}function f(e,t){if("__proto__"===t){if(!o.call(e,t))return;if(s)return s(e,t).value}return e[t]}var o=Object.prototype.hasOwnProperty,i=Object.prototype.toString,n=Object.defineProperty,s=Object.getOwnPropertyDescriptor;t.exports=function e(){var t,r,n,o,i,s=arguments[0],a=1,c=arguments.length,u=!1;for("boolean"==typeof s&&(u=s,s=arguments[1]||{},a=2),(null==s||"object"!=typeof s&&"function"!=typeof s)&&(s={});a<c;++a)if(null!=(t=arguments[a]))for(r in t)i=f(s,r),s!==(n=f(t,r))&&(u&&n&&(l(n)||(o=d(n)))?(i=o?(o=!1,i&&d(i)?i:[]):i&&l(i)?i:{},p(s,{name:r,newValue:e(u,i,n)})):void 0!==n&&p(s,{name:r,newValue:n}));return s}},{}],40:[function(e,t,r){var n,o,t=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{o="function"==typeof clearTimeout?clearTimeout:s}catch(e){o=s}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===i||!n)&&setTimeout)return(n=setTimeout)(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}var c,u=[],d=!1,l=-1;function p(){d&&c&&(d=!1,c.length?u=c.concat(u):l=-1,u.length)&&f()}function f(){if(!d){for(var e=a(p),t=(d=!0,u.length);t;){for(c=u,u=[];++l<t;)c&&c[l].run();l=-1,t=u.length}c=null,d=!1,!function(t){if(o===clearTimeout)return clearTimeout(t);if((o===s||!o)&&clearTimeout)return(o=clearTimeout)(t);try{o(t)}catch(e){try{return o.call(null,t)}catch(e){return o.call(this,t)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function g(){}t.nextTick=function(e){var t=new Array(arguments.length-1);if(1<arguments.length)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];u.push(new h(e,t)),1!==u.length||d||a(f)},h.prototype.run=function(){this.fun.apply(null,this.array)},t.title="browser",t.browser=!0,t.env={},t.argv=[],t.version="",t.versions={},t.on=g,t.addListener=g,t.once=g,t.off=g,t.removeListener=g,t.removeAllListeners=g,t.emit=g,t.prependListener=g,t.prependOnceListener=g,t.listeners=function(e){return[]},t.binding=function(e){throw new Error("process.binding is not supported")},t.cwd=function(){return"/"},t.chdir=function(e){throw new Error("process.chdir is not supported")},t.umask=function(){return 0}},{}],41:[function(e,r,n){!function(Ua,ka){var e,t;e=this,t=function(){var x=function(e,t){return(x=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,t){e.__proto__=t}:function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}))(e,t)};function D(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}x(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var R=function(){return(R=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function L(e,t){var r={};for(o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]]);return r}function _(e,s,a,c){return new(a=a||Promise)(function(r,t){function n(e){try{i(c.next(e))}catch(e){t(e)}}function o(e){try{i(c.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?r(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(n,o)}i((c=c.apply(e,s||[])).next())})}function F(n,o){var i,s,a,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(r){return function(e){var t=[r,e];if(i)throw new TypeError("Generator is already executing.");for(;c;)try{if(i=1,s&&(a=2&t[0]?s.return:t[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,t[1])).done)return a;switch(s=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return c.label++,{value:t[1],done:!1};case 5:c.label++,s=t[1],t=[0];continue;case 7:t=c.ops.pop(),c.trys.pop();continue;default:if(!((a=0<(a=c.trys).length&&a[a.length-1])||6!==t[0]&&2!==t[0])){c=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3]))c.label=t[1];else if(6===t[0]&&c.label<a[1])c.label=a[1],a=t;else{if(!(a&&c.label<a[2])){a[2]&&c.ops.pop(),c.trys.pop();continue}c.label=a[2],c.ops.push(t)}}t=o.call(n,c)}catch(e){t=[6,e],s=0}finally{i=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}}function N(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return{value:(e=e&&n>=e.length?void 0:e)&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function A(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),s=[];try{for(;(void 0===t||0<t--)&&!(n=i.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function b(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||((n=n||Array.prototype.slice.call(t,0,o))[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}var H="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==ka?ka:"undefined"!=typeof self?self:{};var M,Y,K,z,G,p={exports:{}},X=(f=p,h=H,Y=Math.pow(2,-24),K=Math.pow(2,32),z=Math.pow(2,53),t={encode:function(e){var s,a=new ArrayBuffer(256),c=new DataView(a),u=0;function d(e){for(var t=a.byteLength,r=u+e;t<r;)t*=2;if(t!==a.byteLength){var n=c;a=new ArrayBuffer(t),c=new DataView(a);for(var o=u+3>>2,i=0;i<o;++i)c.setUint32(4*i,n.getUint32(4*i))}return s=e,c}function l(){u+=s}function p(e){l(d(1).setUint8(u,e))}function f(e){for(var t=d(e.length),r=0;r<e.length;++r)t.setUint8(u+r,e[r]);l()}function h(e,t){var r,n;t<24?p(e<<5|t):t<256?(p(e<<5|24),p(t)):t<65536?(p(e<<5|25),n=t,l(d(2).setUint16(u,n))):t<4294967296?(p(e<<5|26),n=t,l(d(4).setUint32(u,n))):(p(e<<5|27),t=(t-(e=t%K))/K,(r=d(8)).setUint32(u,t),r.setUint32(u+4,e),l())}if(function e(t){var r,n;if(!1===t)return p(244);if(!0===t)return p(245);if(null===t)return p(246);if(t===M)return p(247);switch(typeof t){case"number":if(Math.floor(t)===t){if(0<=t&&t<=z)return h(0,t);if(-z<=t&&t<0)return h(1,-(t+1))}return p(251),n=t,l(d(8).setFloat64(u,n));case"string":for(var o=[],i=0;i<t.length;++i){var s=t.charCodeAt(i);s<128?o.push(s):(s<2048?o.push(192|s>>6):(s<55296?o.push(224|s>>12):(s=(1023&s)<<10,s|=1023&t.charCodeAt(++i),o.push(240|(s+=65536)>>18),o.push(128|s>>12&63)),o.push(128|s>>6&63)),o.push(128|63&s))}return h(3,o.length),f(o);default:if(Array.isArray(t))for(h(4,r=t.length),i=0;i<r;++i)e(t[i]);else if(t instanceof Uint8Array)h(2,t.length),f(t);else{var a=Object.keys(t);for(h(5,r=a.length),i=0;i<r;++i){var c=a[i];e(c),e(t[c])}}}}(e),"slice"in a)return a.slice(0,u);for(var e=new ArrayBuffer(u),t=new DataView(e),r=0;r<u;++r)t.setUint8(r,c.getUint8(r));return e},decode:function(t,y,m){var R=new DataView(t),_=0;function A(e,t){return _+=t,e}function b(e){return A(new Uint8Array(t,_,e),e)}function v(){return A(R.getUint8(_),1)}function I(){return A(R.getUint16(_),2)}function r(){return A(R.getUint32(_),4)}function T(){return 255===R.getUint8(_)&&(_+=1,1)}function E(e){if(e<24)return e;if(24===e)return v();if(25===e)return I();if(26===e)return r();if(27===e)return r()*K+r();if(31===e)return-1;throw"Invalid length encoding"}function S(e){var t=v();if(255===t)return-1;var r=E(31&t);if(r<0||t>>5!==e)throw"Invalid indefinite length element";return r}function P(e,t){for(var r=0;r<t;++r){var n=v();128&n&&(n<224?(n=(31&n)<<6|63&v(),--t):n<240?(n=(15&n)<<12|(63&v())<<6|63&v(),t-=2):(n=(15&n)<<18|(63&v())<<12|(63&v())<<6|63&v(),t-=3)),n<65536?e.push(n):(n-=65536,e.push(55296|n>>10),e.push(56320|1023&n))}}"function"!=typeof y&&(y=function(e){return e}),"function"!=typeof m&&(m=function(){return M});var e=function e(){var t,r,n=v(),o=n>>5,n=31&n;if(7==o)switch(n){case 25:var i=new ArrayBuffer(4),i=new DataView(i),s=I(),a=31744&s,c=1023&s;if(31744===a)a=261120;else if(0!==a)a+=114688;else if(0!=c)return c*Y;return i.setUint32(0,(32768&s)<<16|a<<13|c<<13),i.getFloat32(0);case 26:return A(R.getFloat32(_),4);case 27:return A(R.getFloat64(_),8)}if((t=E(n))<0&&(o<2||6<o))throw"Invalid length";switch(o){case 0:return t;case 1:return-1-t;case 2:if(t<0){for(var u=[],d=0;0<=(t=S(o));)d+=t,u.push(b(t));for(var l=new Uint8Array(d),p=0,f=0;f<u.length;++f)l.set(u[f],p),p+=u[f].length;return l}return b(t);case 3:var h=[];if(t<0)for(;0<=(t=S(o));)P(h,t);else P(h,t);return String.fromCharCode.apply(null,h);case 4:if(t<0)for(r=[];!T();)r.push(e());else for(r=new Array(t),f=0;f<t;++f)r[f]=e();return r;case 5:var g={};for(f=0;f<t||t<0&&!T();++f)g[e()]=e();return g;case 6:return y(e(),t);case 7:switch(t){case 20:return!1;case 21:return!0;case 22:return null;case 23:return M;default:return m(t)}}}();if(_!==t.byteLength)throw"Remaining bytes";return e}},f.exports?f.exports=t:h.CBOR||(h.CBOR=t),p.exports),f={exports:{}};function B(){for(var e,t="",r=0;r<32;r++)e=16*Math.random()|0,8!==r&&12!==r&&16!==r&&20!==r||(t+="-"),t+=(12===r?4:16===r?3&e|8:e).toString(16);return t}function V(e,t){t=G[t||"all"];return t&&t.test(e)||!1}p=t=(h=f).exports,G={3:/^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,4:/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,5:/^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,all:/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i},B.isUUID=V,B.VERSION="0.1.0",p.uuid=B,p.isUUID=V,null!==h&&(h.exports=t.uuid);var W=f.exports,J=function(){return W.uuid?W.uuid():W()},$=(e.prototype.getAuthKey=function(){return this.authKey},e.prototype.setAuthKey=function(e){return this.authKey=e,this},e.prototype.setCipherKey=function(e,t,r){return this.cipherKey=e,this.cipherKey&&(this.cryptoModule=null!=(e=t.cryptoModule)?e:t.initCryptoModule({cipherKey:this.cipherKey,useRandomIVs:this.useRandomIVs}),r)&&(r.cryptoModule=this.cryptoModule),this},e.prototype.getUUID=function(){return this.UUID},e.prototype.setUUID=function(e){if(e&&"string"==typeof e&&0!==e.trim().length)return this.UUID=e,this;throw new Error("Missing uuid parameter. Provide a valid string uuid")},e.prototype.getUserId=function(){return this.UUID},e.prototype.setUserId=function(e){if(e&&"string"==typeof e&&0!==e.trim().length)return this.UUID=e,this;throw new Error("Missing or invalid userId parameter. Provide a valid string userId")},e.prototype.getFilterExpression=function(){return this.filterExpression},e.prototype.setFilterExpression=function(e){return this.filterExpression=e,this},e.prototype.getPresenceTimeout=function(){return this._presenceTimeout},e.prototype.setPresenceTimeout=function(e){return 20<=e?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.5.0"},e.prototype._setRetryConfiguration=function(e){if(e.minimumdelay<2)throw new Error("Minimum delay can not be set less than 2 seconds for retry");if(150<e.maximumDelay)throw new Error("Maximum delay can not be set more than 150 seconds for retry");if(e.maximumDelay&&6<maximumRetry)throw new Error("Maximum retry for exponential retry policy can not be more than 6");if(10<e.maximumRetry)throw new Error("Maximum retry for linear retry policy can not be more than 10");this.retryConfiguration=e},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(r){var n=this;return Object.keys(this._PNSDKSuffix).reduce(function(e,t){return e+r+n._PNSDKSuffix[t]},"")},e);function e(e){var t,e=e.setup;if(this._PNSDKSuffix={},this.instanceId="pn-".concat(J()),this.secretKey=e.secretKey||e.secret_key,this.subscribeKey=e.subscribeKey||e.subscribe_key,this.publishKey=e.publishKey||e.publish_key,this.sdkName=e.sdkName,this.sdkFamily=e.sdkFamily,this.partnerId=e.partnerId,this.setAuthKey(e.authKey),this.cryptoModule=e.cryptoModule,this.setFilterExpression(e.filterExpression),"string"!=typeof e.origin&&!Array.isArray(e.origin)&&void 0!==e.origin)throw new Error("Origin must be either undefined, a string or a list of strings.");if(this.origin=e.origin||Array.from({length:20},function(e,t){return"ps".concat(t+1,".pndsn.com")}),this.secure=e.ssl||!1,this.restore=e.restore||!1,this.proxy=e.proxy,this.keepAlive=e.keepAlive,this.keepAliveSettings=e.keepAliveSettings,this.autoNetworkDetection=e.autoNetworkDetection||!1,this.dedupeOnSubscribe=e.dedupeOnSubscribe||!1,this.maximumCacheSize=e.maximumCacheSize||100,this.customEncrypt=e.customEncrypt,this.customDecrypt=e.customDecrypt,this.fileUploadPublishRetryLimit=null!=(t=e.fileUploadPublishRetryLimit)?t:5,this.useRandomIVs=null==(t=e.useRandomIVs)||t,this.enableEventEngine=null!=(t=e.enableEventEngine)&&t,this.maintainPresenceState=null==(t=e.maintainPresenceState)||t,"undefined"!=typeof location&&"https:"===location.protocol&&(this.secure=!0),this.logVerbosity=e.logVerbosity||!1,this.suppressLeaveEvents=e.suppressLeaveEvents||!1,this.announceFailedHeartbeats=e.announceFailedHeartbeats||!0,this.announceSuccessfulHeartbeats=e.announceSuccessfulHeartbeats||!1,this.useInstanceId=e.useInstanceId||!1,this.useRequestId=e.useRequestId||!1,this.requestMessageCountThreshold=e.requestMessageCountThreshold,e.retryConfiguration&&this._setRetryConfiguration(e.retryConfiguration),this.setTransactionTimeout(e.transactionalRequestTimeout||15e3),this.setSubscribeTimeout(e.subscribeRequestTimeout||31e4),this.setSendBeaconConfig(e.useSendBeacon||!0),e.presenceTimeout?this.setPresenceTimeout(e.presenceTimeout):this._presenceTimeout=300,null!=e.heartbeatInterval&&this.setHeartbeatInterval(e.heartbeatInterval),"string"==typeof e.userId){if("string"==typeof e.uuid)throw new Error("Only one of the following configuration options has to be provided: `uuid` or `userId`");this.setUserId(e.userId)}else{if("string"!=typeof e.uuid)throw new Error("One of the following configuration options has to be provided: `uuid` or `userId`");this.setUUID(e.uuid)}this.setCipherKey(e.cipherKey,e)}function Q(e){var t=e.replace(/==?$/,""),r=Math.floor(t.length/4*3),e=new ArrayBuffer(r),n=new Uint8Array(e),o=0;function i(){var e=t.charAt(o++),e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===e)throw new Error("Illegal character at ".concat(o,": ").concat(t.charAt(o-1)));return e}for(var s=0;s<r;s+=3){var a=i(),c=i(),u=i(),d=i(),l=(15&c)<<4|u>>2,p=(3&u)<<6|d>>0;n[s]=(63&a)<<2|c>>4,64!=u&&(n[s+1]=l),64!=d&&(n[s+2]=p)}return e}function Z(e){for(var t,r="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=new Uint8Array(e),e=o.byteLength,i=e%3,s=e-i,a=0;a<s;a+=3)r+=n[(16515072&(t=o[a]<<16|o[a+1]<<8|o[a+2]))>>18]+n[(258048&t)>>12]+n[(4032&t)>>6]+n[63&t];return 1==i?r+=n[(252&(t=o[s]))>>2]+n[(3&t)<<4]+"==":2==i&&(r+=n[(64512&(t=o[s]<<8|o[1+s]))>>10]+n[(1008&t)>>4]+n[(15&t)<<2]+"="),r}re=Math,h=(p={}).lib={},ne=h.Base={extend:function(e){Ae.prototype=this;var t=new Ae;return e&&t.mixIn(e),t.hasOwnProperty("init")||(t.init=function(){t.$super.init.apply(this,arguments)}),(t.init.prototype=t).$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},oe=h.WordArray=ne.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||ie).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes;if(e=e.sigBytes,this.clamp(),n%4)for(var o=0;o<e;o++)t[n+o>>>2]|=(r[o>>>2]>>>24-o%4*8&255)<<24-(n+o)%4*8;else if(65535<r.length)for(o=0;o<e;o+=4)t[n+o>>>2]=r[o>>>2];else t.push.apply(t,r);return this.sigBytes+=e,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=re.ceil(t/4)},clone:function(){var e=ne.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(4294967296*re.random()|0);return new oe.init(t,e)}}),t=p.enc={},ie=t.Hex={stringify:function(e){var t=e.words;e=e.sigBytes;for(var r=[],n=0;n<e;n++){var o=t[n>>>2]>>>24-n%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new oe.init(r,t/2)}},se=t.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var r=[],n=0;n<e;n++)r.push(String.fromCharCode(t[n>>>2]>>>24-n%4*8&255));return r.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new oe.init(r,t)}},ae=t.Utf8={stringify:function(e){try{return decodeURIComponent(escape(se.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return se.parse(unescape(encodeURIComponent(e)))}},ce=h.BufferedBlockAlgorithm=ne.extend({reset:function(){this._data=new oe.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=ae.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t=this._data,r=t.words,n=t.sigBytes,o=this.blockSize,i=n/(4*o);if(e=(e?re.ceil(i):re.max((0|i)-this._minBufferSize,0))*o,n=re.min(4*e,n),e){for(var s=0;s<e;s+=o)this._doProcessBlock(r,s);s=r.splice(0,e),t.sigBytes-=n}return new oe.init(s,n)},clone:function(){var e=ne.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),h.Hasher=ce.extend({cfg:ne.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){ce.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(r){return function(e,t){return new r.init(t).finalize(e)}},_createHmacHelper:function(r){return function(e,t){return new ue.HMAC.init(r,t).finalize(e)}}}),ue=p.algo={};var ee,te,re,ne,oe,ie,se,ae,ce,ue,de,le,pe,fe,he,ge,ye,me,Re,_e,f=p;function Ae(){}for(var be=Math,t=f,ve=(h=t.lib).WordArray,Ie=h.Hasher,h=t.algo,Te=[],Ee=[],Se=function(e){return 4294967296*(e-(0|e))|0},Pe=2,Oe=0;Oe<64;){e:{for(var we=Pe,Ue=be.sqrt(we),ke=2;ke<=Ue;ke++)if(!(we%ke)){we=!1;break e}we=!0}we&&(Oe<8&&(Te[Oe]=Se(be.pow(Pe,.5))),Ee[Oe]=Se(be.pow(Pe,1/3)),Oe++),Pe++}var je=[],h=h.SHA256=Ie.extend({_doReset:function(){this._hash=new ve.init(Te.slice(0))},_doProcessBlock:function(e,t){for(var r,n,o=this._hash.words,i=o[0],s=o[1],a=o[2],c=o[3],u=o[4],d=o[5],l=o[6],p=o[7],f=0;f<64;f++)je[f]=f<16?0|e[t+f]:(((r=je[f-15])<<25|r>>>7)^(r<<14|r>>>18)^r>>>3)+je[f-7]+(((n=je[f-2])<<15|n>>>17)^(n<<13|n>>>19)^n>>>10)+je[f-16],r=p+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&d^~u&l)+Ee[f]+je[f],n=((i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22))+(i&s^i&a^s&a),p=l,l=d,d=u,u=c+r|0,c=a,a=s,s=i,i=r+n|0;o[0]=o[0]+i|0,o[1]=o[1]+s|0,o[2]=o[2]+a|0,o[3]=o[3]+c|0,o[4]=o[4]+u|0,o[5]=o[5]+d|0,o[6]=o[6]+l|0,o[7]=o[7]+p|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(64+n>>>9<<4)]=be.floor(r/4294967296),t[15+(64+n>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=Ie.clone.call(this);return e._hash=this._hash.clone(),e}}),Ce=(t.SHA256=Ie._createHelper(h),t.HmacSHA256=Ie._createHmacHelper(h),ee=(p=f).enc.Utf8,p.algo.HMAC=p.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=ee.parse(t));var r=e.blockSize,n=4*r;(t=t.sigBytes>n?e.finalize(t):t).clamp();for(var e=this._oKey=t.clone(),t=this._iKey=t.clone(),o=e.words,i=t.words,s=0;s<r;s++)o[s]^=1549556828,i[s]^=909522486;e.sigBytes=t.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher;return e=t.finalize(e),t.reset(),t.finalize(this._oKey.clone().concat(e))}}),te=f.lib.WordArray,f.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp(),e=[];for(var o=0;o<r;o+=3)for(var i=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,s=0;s<4&&o+.75*s<r;s++)e.push(n.charAt(i>>>6*(3-s)&63));if(t=n.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,r=this._map;(i=r.charAt(64))&&-1!=(i=e.indexOf(i))&&(t=i);for(var n,o,i=[],s=0,a=0;a<t;a++)a%4&&(n=r.indexOf(e.charAt(a-1))<<a%4*2,o=r.indexOf(e.charAt(a))>>>6-a%4*2,i[s>>>2]|=(n|o)<<24-s%4*8,s++);return te.create(i,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},Math);function I(e,t,r,n,o,i,s){return((e=e+(t&r|~t&n)+o+s)<<i|e>>>32-i)+t}function T(e,t,r,n,o,i,s){return((e=e+(t&n|r&~n)+o+s)<<i|e>>>32-i)+t}function E(e,t,r,n,o,i,s){return((e=e+(t^r^n)+o+s)<<i|e>>>32-i)+t}function S(e,t,r,n,o,i,s){return((e=e+(r^(t|~n))+o+s)<<i|e>>>32-i)+t}for(var t=f,xe=(h=t.lib).WordArray,De=h.Hasher,h=t.algo,P=[],Le=0;Le<64;Le++)P[Le]=4294967296*Ce.abs(Ce.sin(Le+1))|0;h=h.MD5=De.extend({_doReset:function(){this._hash=new xe.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=e[o=t+r];e[o]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var r=this._hash.words,o=e[t+0],i=e[t+2],s=e[t+3],a=e[t+4],c=e[t+5],u=e[t+6],d=e[t+7],l=e[t+8],p=e[t+9],f=e[t+10],h=e[t+11],g=e[t+12],y=e[t+13],m=e[t+14],R=e[t+15],_=I(r[0],v=r[1],b=r[2],A=r[3],o,7,P[0]),A=I(A,_,v,b,n=e[t+1],12,P[1]),b=I(b,A,_,v,i,17,P[2]),v=I(v,b,A,_,s,22,P[3]),_=I(_,v,b,A,a,7,P[4]),A=I(A,_,v,b,c,12,P[5]),b=I(b,A,_,v,u,17,P[6]),v=I(v,b,A,_,d,22,P[7]);_=I(_,v,b,A,l,7,P[8]),A=I(A,_,v,b,p,12,P[9]),b=I(b,A,_,v,f,17,P[10]),v=I(v,b,A,_,h,22,P[11]),_=I(_,v,b,A,g,7,P[12]),A=I(A,_,v,b,y,12,P[13]),b=I(b,A,_,v,m,17,P[14]),_=T(_,v=I(v,b,A,_,R,22,P[15]),b,A,n,5,P[16]),A=T(A,_,v,b,u,9,P[17]),b=T(b,A,_,v,h,14,P[18]),v=T(v,b,A,_,o,20,P[19]),_=T(_,v,b,A,c,5,P[20]),A=T(A,_,v,b,f,9,P[21]),b=T(b,A,_,v,R,14,P[22]),v=T(v,b,A,_,a,20,P[23]),_=T(_,v,b,A,p,5,P[24]),A=T(A,_,v,b,m,9,P[25]),b=T(b,A,_,v,s,14,P[26]),v=T(v,b,A,_,l,20,P[27]),_=T(_,v,b,A,y,5,P[28]),A=T(A,_,v,b,i,9,P[29]),b=T(b,A,_,v,d,14,P[30]),_=E(_,v=T(v,b,A,_,g,20,P[31]),b,A,c,4,P[32]),A=E(A,_,v,b,l,11,P[33]),b=E(b,A,_,v,h,16,P[34]),v=E(v,b,A,_,m,23,P[35]),_=E(_,v,b,A,n,4,P[36]),A=E(A,_,v,b,a,11,P[37]),b=E(b,A,_,v,d,16,P[38]),v=E(v,b,A,_,f,23,P[39]),_=E(_,v,b,A,y,4,P[40]),A=E(A,_,v,b,o,11,P[41]),b=E(b,A,_,v,s,16,P[42]),v=E(v,b,A,_,u,23,P[43]),_=E(_,v,b,A,p,4,P[44]),A=E(A,_,v,b,g,11,P[45]),b=E(b,A,_,v,R,16,P[46]),_=S(_,v=E(v,b,A,_,i,23,P[47]),b,A,o,6,P[48]),A=S(A,_,v,b,d,10,P[49]),b=S(b,A,_,v,m,15,P[50]),v=S(v,b,A,_,c,21,P[51]),_=S(_,v,b,A,g,6,P[52]),A=S(A,_,v,b,s,10,P[53]),b=S(b,A,_,v,f,15,P[54]),v=S(v,b,A,_,n,21,P[55]),_=S(_,v,b,A,l,6,P[56]),A=S(A,_,v,b,R,10,P[57]),b=S(b,A,_,v,u,15,P[58]),v=S(v,b,A,_,y,21,P[59]),_=S(_,v,b,A,a,6,P[60]),A=S(A,_,v,b,h,10,P[61]),b=S(b,A,_,v,i,15,P[62]),v=S(v,b,A,_,p,21,P[63]),r[0]=r[0]+_|0,r[1]=r[1]+v|0,r[2]=r[2]+b|0,r[3]=r[3]+A|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes,o=(t[n>>>5]|=128<<24-n%32,Ce.floor(r/4294967296));for(t[15+(64+n>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),t[14+(64+n>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),e.sigBytes=4*(t.length+1),this._process(),t=(e=this._hash).words,r=0;r<4;r++)n=t[r],t[r]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8);return e},clone:function(){var e=De.clone.call(this);return e._hash=this._hash.clone(),e}}),t.MD5=De._createHelper(h),t.HmacMD5=De._createHmacHelper(h),h=(t=(p=f).lib).Base,Re=t.WordArray,_e=(t=p.algo).EvpKDF=h.extend({cfg:h.extend({keySize:4,hasher:t.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r=(s=this.cfg).hasher.create(),n=Re.create(),o=n.words,i=s.keySize,s=s.iterations;o.length<i;){a&&r.update(a);var a=r.update(e).finalize(t);r.reset();for(var c=1;c<s;c++)a=r.finalize(a),r.reset();n.concat(a)}return n.sigBytes=4*i,n}}),p.EvpKDF=function(e,t,r){return _e.create(r).compute(e,t)},f.lib.Cipher||(t=(h=f).lib,p=t.Base,de=t.WordArray,le=t.BufferedBlockAlgorithm,pe=h.enc.Base64,fe=h.algo.EvpKDF,he=t.Cipher=le.extend({cfg:p.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){le.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(n){return{encrypt:function(e,t,r){return("string"==typeof t?me:ye).encrypt(n,e,t,r)},decrypt:function(e,t,r){return("string"==typeof t?me:ye).decrypt(n,e,t,r)}}}}),t.StreamCipher=he.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),He=h.mode={},(Ne=(t.BlockCipherMode=p.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}})).extend()).Encryptor=Ne.extend({processBlock:function(e,t){var r=this._cipher,n=r.blockSize;it.call(this,e,t,n),r.encryptBlock(e,t),this._prevBlock=e.slice(t,t+n)}}),Ne.Decryptor=Ne.extend({processBlock:function(e,t){var r=this._cipher,n=r.blockSize,o=e.slice(t,t+n);r.decryptBlock(e,t),it.call(this,e,t,n),this._prevBlock=o}}),He=He.CBC=Ne,Ne=(h.pad={}).Pkcs7={pad:function(e,t){for(var r,n=(r=(r=4*t)-e.sigBytes%r)<<24|r<<16|r<<8|r,o=[],i=0;i<r;i+=4)o.push(n);r=de.create(o,r),e.concat(r)},unpad:function(e){e.sigBytes-=255&e.words[e.sigBytes-1>>>2]}},t.BlockCipher=he.extend({cfg:he.cfg.extend({mode:He,padding:Ne}),reset:function(){he.reset.call(this);var e,t=(r=this.cfg).iv,r=r.mode;this._xformMode==this._ENC_XFORM_MODE?e=r.createEncryptor:(e=r.createDecryptor,this._minBufferSize=1),this._mode=e.call(r,this,t&&t.words)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4}),ge=t.CipherParams=p.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),He=(h.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?de.create([1398893684,1701076831]).concat(e).concat(t):t).toString(pe)},parse:function(e){var t,r=(e=pe.parse(e)).words;return 1398893684==r[0]&&1701076831==r[1]&&(t=de.create(r.slice(2,4)),r.splice(0,4),e.sigBytes-=16),ge.create({ciphertext:e,salt:t})}},ye=t.SerializableCipher=p.extend({cfg:p.extend({format:He}),encrypt:function(e,t,r,n){n=this.cfg.extend(n);var o=e.createEncryptor(r,n);return t=o.finalize(t),o=o.cfg,ge.create({ciphertext:t,key:r,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(r,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),h=(h.kdf={}).OpenSSL={execute:function(e,t,r,n){return n=n||de.random(8),e=fe.create({keySize:t+r}).compute(e,n),r=de.create(e.words.slice(t),4*r),e.sigBytes=4*t,ge.create({key:e,iv:r,salt:n})}},me=t.PasswordBasedCipher=ye.extend({cfg:ye.cfg.extend({kdf:h}),encrypt:function(e,t,r,n){return r=(n=this.cfg.extend(n)).kdf.execute(r,e.keySize,e.ivSize),n.iv=r.iv,(e=ye.encrypt.call(this,e,t,r.key,n)).mixIn(r),e},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),r=n.kdf.execute(r,e.keySize,e.ivSize,t.salt),n.iv=r.iv,ye.decrypt.call(this,e,t,r.key,n)}}));for(var Ne=f,p=Ne.lib.BlockCipher,He=Ne.algo,Me=[],Fe=[],qe=[],Ye=[],Ke=[],ze=[],Ge=[],Xe=[],Be=[],Ve=[],We=[],Je=0;Je<256;Je++)We[Je]=Je<128?Je<<1:Je<<1^283;for(var $e=0,Qe=0,Je=0;Je<256;Je++){var Ze=(Ze=Qe^Qe<<1^Qe<<2^Qe<<3^Qe<<4)>>>8^255&Ze^99,et=We[Fe[Me[$e]=Ze]=$e],tt=We[et],rt=We[tt],nt=257*We[Ze]^16843008*Ze;qe[$e]=nt<<24|nt>>>8,Ye[$e]=nt<<16|nt>>>16,Ke[$e]=nt<<8|nt>>>24,ze[$e]=nt,Ge[Ze]=(nt=16843009*rt^65537*tt^257*et^16843008*$e)<<24|nt>>>8,Xe[Ze]=nt<<16|nt>>>16,Be[Ze]=nt<<8|nt>>>24,Ve[Ze]=nt,$e?($e=et^We[We[We[rt^et]]],Qe^=We[We[Qe]]):$e=Qe=1}var ot=[0,1,2,4,8,16,32,64,128,27,54],He=He.AES=p.extend({_doReset:function(){for(var e,t=(n=this._key).words,r=n.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],i=0;i<n;i++)i<r?o[i]=t[i]:(e=o[i-1],i%r?6<r&&4==i%r&&(e=Me[e>>>24]<<24|Me[e>>>16&255]<<16|Me[e>>>8&255]<<8|Me[255&e]):(e=Me[(e=e<<8|e>>>24)>>>24]<<24|Me[e>>>16&255]<<16|Me[e>>>8&255]<<8|Me[255&e],e^=ot[i/r|0]<<24),o[i]=o[i-r]^e);for(t=this._invKeySchedule=[],r=0;r<n;r++)i=n-r,e=r%4?o[i]:o[i-4],t[r]=r<4||i<=4?e:Ge[Me[e>>>24]]^Xe[Me[e>>>16&255]]^Be[Me[e>>>8&255]]^Ve[Me[255&e]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,qe,Ye,Ke,ze,Me)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,Ge,Xe,Be,Ve,Fe),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,n,o,i,s,a){for(var c=this._nRounds,u=e[t]^r[0],d=e[t+1]^r[1],l=e[t+2]^r[2],p=e[t+3]^r[3],f=4,h=1;h<c;h++)var g=n[u>>>24]^o[d>>>16&255]^i[l>>>8&255]^s[255&p]^r[f++],y=n[d>>>24]^o[l>>>16&255]^i[p>>>8&255]^s[255&u]^r[f++],m=n[l>>>24]^o[p>>>16&255]^i[u>>>8&255]^s[255&d]^r[f++],p=n[p>>>24]^o[u>>>16&255]^i[d>>>8&255]^s[255&l]^r[f++],u=g,d=y,l=m;g=(a[u>>>24]<<24|a[d>>>16&255]<<16|a[l>>>8&255]<<8|a[255&p])^r[f++],y=(a[d>>>24]<<24|a[l>>>16&255]<<16|a[p>>>8&255]<<8|a[255&u])^r[f++],m=(a[l>>>24]<<24|a[p>>>16&255]<<16|a[u>>>8&255]<<8|a[255&d])^r[f++],p=(a[p>>>24]<<24|a[u>>>16&255]<<16|a[d>>>8&255]<<8|a[255&l])^r[f++],e[t]=g,e[t+1]=y,e[t+2]=m,e[t+3]=p},keySize:8});function it(e,t,r){var n=this._iv;n?this._iv=void 0:n=this._prevBlock;for(var o=0;o<r;o++)e[t+o]^=n[o]}Ne.AES=p._createHelper(He),f.mode.ECB=((t=f.lib.BlockCipherMode.extend()).Encryptor=t.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),t.Decryptor=t.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),t);var c=f;function st(e){for(var t=[],r=0;r<e.length;r+=1)t[r/4|0]|=e[r]<<24-8*r;return c.lib.WordArray.create(t,e.length)}pt.prototype.HMACSHA256=function(e){return c.HmacSHA256(e,this._config.secretKey).toString(c.enc.Base64)},pt.prototype.SHA256=function(e){return c.SHA256(e).toString(c.enc.Hex)},pt.prototype._parseOptions=function(e){e=e||{};return e.hasOwnProperty("encryptKey")||(e.encryptKey=this._defaultOptions.encryptKey),e.hasOwnProperty("keyEncoding")||(e.keyEncoding=this._defaultOptions.keyEncoding),e.hasOwnProperty("keyLength")||(e.keyLength=this._defaultOptions.keyLength),e.hasOwnProperty("mode")||(e.mode=this._defaultOptions.mode),-1===this._allowedKeyEncodings.indexOf(e.keyEncoding.toLowerCase())&&(e.keyEncoding=this._defaultOptions.keyEncoding),-1===this._allowedKeyLengths.indexOf(parseInt(e.keyLength,10))&&(e.keyLength=this._defaultOptions.keyLength),-1===this._allowedModes.indexOf(e.mode.toLowerCase())&&(e.mode=this._defaultOptions.mode),e},pt.prototype._decodeKey=function(e,t){return"base64"===t.keyEncoding?c.enc.Base64.parse(e):"hex"===t.keyEncoding?c.enc.Hex.parse(e):e},pt.prototype._getPaddedKey=function(e,t){return e=this._decodeKey(e,t),t.encryptKey?c.enc.Utf8.parse(this.SHA256(e).slice(0,32)):e},pt.prototype._getMode=function(e){return"ecb"===e.mode?c.mode.ECB:c.mode.CBC},pt.prototype._getIV=function(e){return"cbc"===e.mode?c.enc.Utf8.parse(this._iv):null},pt.prototype._getRandomIV=function(){return c.lib.WordArray.random(16)},pt.prototype.encrypt=function(e,t,r){return this._config.customEncrypt?this._config.customEncrypt(e):this.pnEncrypt(e,t,r)},pt.prototype.decrypt=function(e,t,r){return this._config.customDecrypt?this._config.customDecrypt(e):this.pnDecrypt(e,t,r)},pt.prototype.pnEncrypt=function(e,t,r){if(!t&&!this._config.cipherKey)return e;r=this._parseOptions(r);var n,o,i=this._getMode(r),t=this._getPaddedKey(t||this._config.cipherKey,r);return this._config.useRandomIVs?(o=this._getRandomIV(),n=c.AES.encrypt(e,t,{iv:o,mode:i}).ciphertext,o.clone().concat(n.clone()).toString(c.enc.Base64)):(o=this._getIV(r),c.AES.encrypt(e,t,{iv:o,mode:i}).ciphertext.toString(c.enc.Base64)||e)},pt.prototype.pnDecrypt=function(e,t,r){if(!t&&!this._config.cipherKey)return e;r=this._parseOptions(r);var n=this._getMode(r),t=this._getPaddedKey(t||this._config.cipherKey,r);if(this._config.useRandomIVs){var o=st((a=new Uint8ClampedArray(Q(e))).slice(0,16)),i=st(a.slice(16));try{var s=c.AES.decrypt({ciphertext:i},t,{iv:o,mode:n}).toString(c.enc.Utf8);return JSON.parse(s)}catch(e){return null}}else{o=this._getIV(r);try{var a=c.enc.Base64.parse(e),s=c.AES.decrypt({ciphertext:a},t,{iv:o,mode:n}).toString(c.enc.Utf8);return JSON.parse(s)}catch(e){return null}}};var at=pt,ct=(lt.prototype.onReconnection=function(e){this._reconnectionCallback=e},lt.prototype.startPolling=function(){this._timeTimer=setInterval(this._performTimeLoop.bind(this),3e3)},lt.prototype.stopPolling=function(){clearInterval(this._timeTimer)},lt.prototype._performTimeLoop=function(){var t=this;this._timeEndpoint(function(e){e.error||(clearInterval(t._timeTimer),t._reconnectionCallback())})},lt),ut=(dt.prototype.getKey=function(e){var t=(e=>{var t=0;if(0!==e.length)for(var r=0;r<e.length;r+=1)t=(t<<5)-t+e.charCodeAt(r),t&=t;return t})(JSON.stringify(e.payload)).toString(),e=e.publishMetaData.publishTimetoken;return"".concat(e,"-").concat(t)},dt.prototype.isDuplicate=function(e){return this.hashHistory.includes(this.getKey(e))},dt.prototype.addEntry=function(e){this.hashHistory.length>=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},dt.prototype.clearHistory=function(){this.hashHistory=[]},dt);function dt(e){e=e.config;this.hashHistory=[],this._config=e}function lt(e){e=e.timeEndpoint;this._timeEndpoint=e}function pt(e){e=e.config;this._config=e,this._iv="0123456789012345",this._allowedKeyEncodings=["hex","utf8","base64","binary"],this._allowedKeyLengths=[128,256],this._allowedModes=["ecb","cbc"],this._defaultOptions={encryptKey:!0,keyEncoding:"utf8",keyLength:256,mode:"cbc"}}function ft(e){return encodeURIComponent(e).replace(/[!~*'()]/g,function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())})}var ht,gt,yt,mt,m={signPamFromParams:function(t){return e=t,r=[],Object.keys(e).forEach(function(e){return r.push(e)}),r.sort().map(function(e){return"".concat(e,"=").concat(ft(t[e]))}).join("&");var e,r},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var r,n;return{promise:new Promise(function(e,t){r=e,n=t}),reject:n,fulfill:r}},encodeString:ft,stringToArrayBuffer:function(e){for(var t=new ArrayBuffer(2*e.length),r=new Uint16Array(t),n=0,o=e.length;n<o;n++)r[n]=e.charCodeAt(n);return t}},v={PNNetworkUpCategory:"PNNetworkUpCategory",PNNetworkDownCategory:"PNNetworkDownCategory",PNNetworkIssuesCategory:"PNNetworkIssuesCategory",PNTimeoutCategory:"PNTimeoutCategory",PNBadRequestCategory:"PNBadRequestCategory",PNAccessDeniedCategory:"PNAccessDeniedCategory",PNUnknownCategory:"PNUnknownCategory",PNReconnectedCategory:"PNReconnectedCategory",PNConnectedCategory:"PNConnectedCategory",PNRequestMessageCountExceededCategory:"PNRequestMessageCountExceededCategory",PNDisconnectedCategory:"PNDisconnectedCategory",PNConnectionErrorCategory:"PNConnectionErrorCategory",PNDisconnectedUnexpectedlyCategory:"PNDisconnectedUnexpectedlyCategory"},Rt=(n.prototype.adaptStateChange=function(e,t){var r,n=this,o=e.state,i=e.channels,i=void 0===i?[]:i,s=e.channelGroups,s=void 0===s?[]:s,e=e.withHeartbeat,e=void 0!==e&&e;return i.forEach(function(e){e in n._channels&&(n._channels[e].state=o)}),s.forEach(function(e){e in n._channelGroups&&(n._channelGroups[e].state=o)}),e?(r={},i.forEach(function(e){return r[e]=o}),s.forEach(function(e){return r[e]=o}),this._heartbeatEndpoint({channels:i,channelGroups:s,state:r},t)):this._setStateEndpoint({state:o,channels:i,channelGroups:s},t)},n.prototype.adaptPresenceChange=function(e){var t=this,r=e.connected,n=e.channels,n=void 0===n?[]:n,e=e.channelGroups,e=void 0===e?[]:e;r?(n.forEach(function(e){t._heartbeatChannels[e]={state:{}}}),e.forEach(function(e){t._heartbeatChannelGroups[e]={state:{}}})):(n.forEach(function(e){e in t._heartbeatChannels&&delete t._heartbeatChannels[e]}),e.forEach(function(e){e in t._heartbeatChannelGroups&&delete t._heartbeatChannelGroups[e]}),!1===this._config.suppressLeaveEvents&&this._leaveEndpoint({channels:n,channelGroups:e},function(e){t._listenerManager.announceStatus(e)})),this.reconnect()},n.prototype.adaptSubscribeChange=function(e){var t=this,r=e.timetoken,n=e.channels,n=void 0===n?[]:n,o=e.channelGroups,o=void 0===o?[]:o,i=e.withPresence,s=void 0!==i&&i,i=e.withHeartbeats,a=void 0!==i&&i;this._config.subscribeKey&&""!==this._config.subscribeKey?(r&&(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=r),"0"!==this._currentTimetoken&&0!==this._currentTimetoken&&(this._storedTimetoken=this._currentTimetoken,this._currentTimetoken=0),n.forEach(function(e){t._channels[e]={state:{}},s&&(t._presenceChannels[e]={}),(a||t._config.getHeartbeatInterval())&&(t._heartbeatChannels[e]={}),t._pendingChannelSubscriptions.push(e)}),o.forEach(function(e){t._channelGroups[e]={state:{}},s&&(t._presenceChannelGroups[e]={}),(a||t._config.getHeartbeatInterval())&&(t._heartbeatChannelGroups[e]={}),t._pendingChannelGroupSubscriptions.push(e)}),this._subscriptionStatusAnnounced=!1,this.reconnect()):console&&console.log&&console.log("subscribe key missing; aborting subscribe")},n.prototype.adaptUnsubscribeChange=function(e,t){var r=this,n=e.channels,n=void 0===n?[]:n,e=e.channelGroups,e=void 0===e?[]:e,o=[],i=[];n.forEach(function(e){e in r._channels&&(delete r._channels[e],o.push(e),e in r._heartbeatChannels)&&delete r._heartbeatChannels[e],e in r._presenceChannels&&(delete r._presenceChannels[e],o.push(e))}),e.forEach(function(e){e in r._channelGroups&&(delete r._channelGroups[e],i.push(e),e in r._heartbeatChannelGroups)&&delete r._heartbeatChannelGroups[e],e in r._presenceChannelGroups&&(delete r._presenceChannelGroups[e],i.push(e))}),0===o.length&&0===i.length||(!1!==this._config.suppressLeaveEvents||t||this._leaveEndpoint({channels:o,channelGroups:i},function(e){e.affectedChannels=o,e.affectedChannelGroups=i,e.currentTimetoken=r._currentTimetoken,e.lastTimetoken=r._lastTimetoken,r._listenerManager.announceStatus(e)}),0===Object.keys(this._channels).length&&0===Object.keys(this._presenceChannels).length&&0===Object.keys(this._channelGroups).length&&0===Object.keys(this._presenceChannelGroups).length&&(this._lastTimetoken=0,this._currentTimetoken=0,this._storedTimetoken=null,this._region=null,this._reconnectionManager.stopPolling()),this.reconnect())},n.prototype.unsubscribeAll=function(e){this.adaptUnsubscribeChange({channels:this.getSubscribedChannels(),channelGroups:this.getSubscribedChannelGroups()},e)},n.prototype.getHeartbeatChannels=function(){return Object.keys(this._heartbeatChannels)},n.prototype.getHeartbeatChannelGroups=function(){return Object.keys(this._heartbeatChannelGroups)},n.prototype.getSubscribedChannels=function(){return Object.keys(this._channels)},n.prototype.getSubscribedChannelGroups=function(){return Object.keys(this._channelGroups)},n.prototype.reconnect=function(){this._startSubscribeLoop(),this._registerHeartbeatTimer()},n.prototype.disconnect=function(){this._stopSubscribeLoop(),this._stopHeartbeatTimer(),this._reconnectionManager.stopPolling()},n.prototype._registerHeartbeatTimer=function(){this._stopHeartbeatTimer(),0!==this._config.getHeartbeatInterval()&&void 0!==this._config.getHeartbeatInterval()&&(this._performHeartbeatLoop(),this._heartbeatTimer=setInterval(this._performHeartbeatLoop.bind(this),1e3*this._config.getHeartbeatInterval()))},n.prototype._stopHeartbeatTimer=function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=null)},n.prototype._performHeartbeatLoop=function(){var r=this,e=this.getHeartbeatChannels(),t=this.getHeartbeatChannelGroups(),n={};0===e.length&&0===t.length||(this.getSubscribedChannels().forEach(function(e){var t=r._channels[e].state;Object.keys(t).length&&(n[e]=t)}),this.getSubscribedChannelGroups().forEach(function(e){var t=r._channelGroups[e].state;Object.keys(t).length&&(n[e]=t)}),this._heartbeatEndpoint({channels:e,channelGroups:t,state:n},function(e){e.error&&r._config.announceFailedHeartbeats&&r._listenerManager.announceStatus(e),e.error&&r._config.autoNetworkDetection&&r._isOnline&&(r._isOnline=!1,r.disconnect(),r._listenerManager.announceNetworkDown(),r.reconnect()),!e.error&&r._config.announceSuccessfulHeartbeats&&r._listenerManager.announceStatus(e)}.bind(this)))},n.prototype._startSubscribeLoop=function(){var e,r=this,n=(this._stopSubscribeLoop(),{}),o=[],i=[];Object.keys(this._channels).forEach(function(e){var t=r._channels[e].state;Object.keys(t).length&&(n[e]=t),o.push(e)}),Object.keys(this._presenceChannels).forEach(function(e){o.push("".concat(e,"-pnpres"))}),Object.keys(this._channelGroups).forEach(function(e){var t=r._channelGroups[e].state;Object.keys(t).length&&(n[e]=t),i.push(e)}),Object.keys(this._presenceChannelGroups).forEach(function(e){i.push("".concat(e,"-pnpres"))}),0===o.length&&0===i.length||(e={channels:o,channelGroups:i,state:n,timetoken:this._currentTimetoken,filterExpression:this._config.filterExpression,region:this._region},this._subscribeCall=this._subscribeEndpoint(e,this._processSubscribeResponse.bind(this)))},n.prototype._processSubscribeResponse=function(t,e){var r,n,l,o,p=this;t.error?t.errorData&&"Aborted"===t.errorData.message||(t.category===v.PNTimeoutCategory?this._startSubscribeLoop():(t.category===v.PNNetworkIssuesCategory?(this.disconnect(),t.error&&this._config.autoNetworkDetection&&this._isOnline&&(this._isOnline=!1,this._listenerManager.announceNetworkDown()),this._reconnectionManager.onReconnection(function(){p._config.autoNetworkDetection&&!p._isOnline&&(p._isOnline=!0,p._listenerManager.announceNetworkUp()),p.reconnect(),p._subscriptionStatusAnnounced=!0;var e={category:v.PNReconnectedCategory,operation:t.operation,lastTimetoken:p._lastTimetoken,currentTimetoken:p._currentTimetoken};p._listenerManager.announceStatus(e)}),this._reconnectionManager.startPolling()):t.category===v.PNBadRequestCategory&&this._stopHeartbeatTimer(),this._listenerManager.announceStatus(t))):(this._storedTimetoken?(this._currentTimetoken=this._storedTimetoken,this._storedTimetoken=null):(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=e.metadata.timetoken),this._subscriptionStatusAnnounced||((r={}).category=v.PNConnectedCategory,r.operation=t.operation,r.affectedChannels=this._pendingChannelSubscriptions,r.subscribedChannels=this.getSubscribedChannels(),r.affectedChannelGroups=this._pendingChannelGroupSubscriptions,r.lastTimetoken=this._lastTimetoken,r.currentTimetoken=this._currentTimetoken,this._subscriptionStatusAnnounced=!0,this._listenerManager.announceStatus(r),this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[]),r=e.messages||[],n=(o=this._config).requestMessageCountThreshold,l=o.dedupeOnSubscribe,n&&r.length>=n&&((o={}).category=v.PNRequestMessageCountExceededCategory,o.operation=t.operation,this._listenerManager.announceStatus(o)),r.forEach(function(e){var t,r,n,o,i=e.channel,s=e.subscriptionMatch,a=e.publishMetaData;if(i===s&&(s=null),l){if(p._dedupingManager.isDuplicate(e))return;p._dedupingManager.addEntry(e)}if(m.endsWith(e.channel,"-pnpres"))(o={channel:null,subscription:null}).actualChannel=null!=s?i:null,o.subscribedChannel=null!=s?s:i,i&&(o.channel=i.substring(0,i.lastIndexOf("-pnpres"))),s&&(o.subscription=s.substring(0,s.lastIndexOf("-pnpres"))),o.action=e.payload.action,o.state=e.payload.data,o.timetoken=a.publishTimetoken,o.occupancy=e.payload.occupancy,o.uuid=e.payload.uuid,o.timestamp=e.payload.timestamp,e.payload.join&&(o.join=e.payload.join),e.payload.leave&&(o.leave=e.payload.leave),e.payload.timeout&&(o.timeout=e.payload.timeout),p._listenerManager.announcePresence(o);else if(1===e.messageType)(o={channel:null,subscription:null}).channel=i,o.subscription=s,o.timetoken=a.publishTimetoken,o.publisher=e.issuingClientId,e.userMetadata&&(o.userMetadata=e.userMetadata),o.message=e.payload,p._listenerManager.announceSignal(o);else if(2===e.messageType)(o={channel:null,subscription:null}).channel=i,o.subscription=s,o.timetoken=a.publishTimetoken,o.publisher=e.issuingClientId,e.userMetadata&&(o.userMetadata=e.userMetadata),o.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},p._listenerManager.announceObjects(o),"uuid"===e.payload.type?(t=p._renameChannelField(o),p._listenerManager.announceUser(R(R({},t),{message:R(R({},t.message),{event:p._renameEvent(t.message.event),type:"user"})}))):"channel"===e.payload.type?(t=p._renameChannelField(o),p._listenerManager.announceSpace(R(R({},t),{message:R(R({},t.message),{event:p._renameEvent(t.message.event),type:"space"})}))):"membership"===e.payload.type&&(c=(n=(t=p._renameChannelField(o)).message.data).uuid,r=n.channel,(n=L(n,["uuid","channel"])).user=c,n.space=r,p._listenerManager.announceMembership(R(R({},t),{message:R(R({},t.message),{event:p._renameEvent(t.message.event),data:n})})));else if(3===e.messageType)(o={}).channel=i,o.subscription=s,o.timetoken=a.publishTimetoken,o.publisher=e.issuingClientId,o.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},o.event=e.payload.event,p._listenerManager.announceMessageAction(o);else if(4===e.messageType){(o={}).channel=i,o.subscription=s,o.timetoken=a.publishTimetoken,o.publisher=e.issuingClientId;var c=e.payload;if(p._cryptoModule){var u=void 0;try{u=(d=p._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(p._decoder.decode(d)):d}catch(e){u=null,o.error="Error while decrypting message content: ".concat(e.message)}null!==u&&(c=u)}e.userMetadata&&(o.userMetadata=e.userMetadata),o.message=c.message,o.file={id:c.file.id,name:c.file.name,url:p._getFileUrl({id:c.file.id,name:c.file.name,channel:i})},p._listenerManager.announceFile(o)}else{if((o={channel:null,subscription:null}).actualChannel=null!=s?i:null,o.subscribedChannel=null!=s?s:i,o.channel=i,o.subscription=s,o.timetoken=a.publishTimetoken,o.publisher=e.issuingClientId,e.userMetadata&&(o.userMetadata=e.userMetadata),p._cryptoModule){u=void 0;try{var d,u=(d=p._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(p._decoder.decode(d)):d}catch(e){u=null,o.error="Error while decrypting message content: ".concat(e.message)}o.message=null!=u?u:e.payload}else o.message=e.payload;p._listenerManager.announceMessage(o)}}),this._region=e.metadata.region,this._startSubscribeLoop())},n.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},n.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},n.prototype._renameChannelField=function(e){var t=e.channel,e=L(e,["channel"]);return e.spaceId=t,e},n),O={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},_t=(Ct.prototype.operationsLatencyForRequest=function(){var r=this,n={};return Object.keys(this._latencies).forEach(function(e){var t=r._latencies[e],t=r._averageLatency(t);0<t&&(n["l_".concat(e)]=t)}),n},Ct.prototype.startLatencyMeasure=function(e,t){e!==O.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},Ct.prototype.stopLatencyMeasure=function(e,t){var r,n;e!==O.PNSubscribeOperation&&t&&(e=this._endpointName(e),r=this._latencies[e],n=this._trackedLatencies[t],r||(this._latencies[e]=[],r=this._latencies[e]),r.push(Date.now()-n),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t])},Ct.prototype._averageLatency=function(e){return Math.floor(e.reduce(function(e,t){return e+t},0)/e.length)},Ct.prototype._endpointName=function(e){var t=null;switch(e){case O.PNPublishOperation:t="pub";break;case O.PNSignalOperation:t="sig";break;case O.PNHistoryOperation:case O.PNFetchMessagesOperation:case O.PNDeleteMessagesOperation:case O.PNMessageCounts:t="hist";break;case O.PNUnsubscribeOperation:case O.PNWhereNowOperation:case O.PNHereNowOperation:case O.PNHeartbeatOperation:case O.PNSetStateOperation:case O.PNGetStateOperation:t="pres";break;case O.PNAddChannelsToGroupOperation:case O.PNRemoveChannelsFromGroupOperation:case O.PNChannelGroupsOperation:case O.PNRemoveGroupOperation:case O.PNChannelsForGroupOperation:t="cg";break;case O.PNPushNotificationEnabledChannelsOperation:case O.PNRemoveAllPushNotificationsOperation:t="push";break;case O.PNCreateUserOperation:case O.PNUpdateUserOperation:case O.PNDeleteUserOperation:case O.PNGetUserOperation:case O.PNGetUsersOperation:case O.PNCreateSpaceOperation:case O.PNUpdateSpaceOperation:case O.PNDeleteSpaceOperation:case O.PNGetSpaceOperation:case O.PNGetSpacesOperation:case O.PNGetMembersOperation:case O.PNUpdateMembersOperation:case O.PNGetMembershipsOperation:case O.PNUpdateMembershipsOperation:t="obj";break;case O.PNAddMessageActionOperation:case O.PNRemoveMessageActionOperation:case O.PNGetMessageActionsOperation:t="msga";break;case O.PNAccessManagerGrant:case O.PNAccessManagerAudit:t="pam";break;case O.PNAccessManagerGrantToken:case O.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},Ct),h=(Object.defineProperty(jt.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(jt.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(jt.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(jt.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(jt.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(jt.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),jt.prototype._setDefaultPayloadStructure=function(){},jt.prototype.toObject=function(){return{}},jt),At=(D(kt,mt=h),Object.defineProperty(kt.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(kt.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(kt.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(kt.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(kt.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(kt.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(kt.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(kt.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),kt.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},kt.prototype.toObject=function(){var t=this,e=R({},this._payload),r=e.aps,n=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var o=[];this._configurations.forEach(function(e){o.push(t._objectFromAPNS2Configuration(e))}),o.length&&(e.pn_push=o)}return n&&Object.keys(n).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,n={}),this._isSilent||Object.keys(n).length?e:null},kt.prototype._objectFromAPNS2Configuration=function(e){var t,r,n,o=this;if(e.targets&&e.targets.length)return t=[],e.targets.forEach(function(e){t.push(o._objectFromAPNSTarget(e))}),r=e.collapseId,e=e.expirationDate,n={auth_method:"token",targets:t,version:"v2"},r&&r.length&&(n.collapse_id=r),e&&(n.expiration=e.toISOString()),n;throw new ReferenceError("At least one APNS2 target should be provided")},kt.prototype._objectFromAPNSTarget=function(e){var t;if(e.topic&&e.topic.length)return t={topic:e.topic,environment:void 0===(t=e.environment)?"development":t},(e=void 0===(e=e.excludedDevices)?[]:e).length&&(t.excluded_devices=e),t;throw new TypeError("Target 'topic' undefined.")},kt),bt=(D(Ut,yt=h),Object.defineProperty(Ut.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(Ut.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(Ut.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(Ut.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(Ut.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(Ut.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(Ut.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(Ut.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),Ut.prototype.toObject=function(){return Object.keys(this._payload).length?R({},this._payload):null},Ut),vt=(D(wt,gt=h),Object.defineProperty(wt.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(wt.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(wt.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(wt.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(wt.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(wt.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(wt.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(wt.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),wt.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},wt.prototype.toObject=function(){var e,t=R({},this._payload.data),r=null,n={};return 2<Object.keys(this._payload).length&&((e=this._payload).notification,e=L(e,["notification","data"]),t=R(R({},t),e)),this._isSilent?t.notification=this._payload.notification:r=this._payload.notification,Object.keys(t).length&&(n.data=t),r&&Object.keys(r).length&&(n.notification=r),Object.keys(n).length?n:null},wt),It=(Object.defineProperty(Ot.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(Ot.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(Ot.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(Ot.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(Ot.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(Ot.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),Ot.prototype.buildPayload=function(e){var t,r={};return(e.includes("apns")||e.includes("apns2"))&&(this.apns._apnsPushType=e.includes("apns")?"apns":"apns2",t=this.apns.toObject())&&Object.keys(t).length&&(r.pn_apns=t),e.includes("mpns")&&(t=this.mpns.toObject())&&Object.keys(t).length&&(r.pn_mpns=t),e.includes("fcm")&&(t=this.fcm.toObject())&&Object.keys(t).length&&(r.pn_gcm=t),Object.keys(r).length&&this._debugging&&(r.pn_debug=!0),r},Ot),Tt=(r.prototype.addListener=function(e){this._listeners.includes(e)||this._listeners.push(e)},r.prototype.removeListener=function(t){var r=[];this._listeners.forEach(function(e){e!==t&&r.push(e)}),this._listeners=r},r.prototype.removeAllListeners=function(){this._listeners=[]},r.prototype.announcePresence=function(t){this._listeners.forEach(function(e){e.presence&&e.presence(t)})},r.prototype.announceStatus=function(t){this._listeners.forEach(function(e){e.status&&e.status(t)})},r.prototype.announceMessage=function(t){this._listeners.forEach(function(e){e.message&&e.message(t)})},r.prototype.announceSignal=function(t){this._listeners.forEach(function(e){e.signal&&e.signal(t)})},r.prototype.announceMessageAction=function(t){this._listeners.forEach(function(e){e.messageAction&&e.messageAction(t)})},r.prototype.announceFile=function(t){this._listeners.forEach(function(e){e.file&&e.file(t)})},r.prototype.announceObjects=function(t){this._listeners.forEach(function(e){e.objects&&e.objects(t)})},r.prototype.announceUser=function(t){this._listeners.forEach(function(e){e.user&&e.user(t)})},r.prototype.announceSpace=function(t){this._listeners.forEach(function(e){e.space&&e.space(t)})},r.prototype.announceMembership=function(t){this._listeners.forEach(function(e){e.membership&&e.membership(t)})},r.prototype.announceNetworkUp=function(){var e={};e.category=v.PNNetworkUpCategory,this.announceStatus(e)},r.prototype.announceNetworkDown=function(){var e={};e.category=v.PNNetworkDownCategory,this.announceStatus(e)},r),Et=(Pt.prototype.setToken=function(e){e&&0<e.length?this._token=e:this._token=void 0},Pt.prototype.getToken=function(){return this._token},Pt.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},Pt.prototype.parseToken=function(e){var t,r,n,o,i,s,a,c,u,d=this,l=this._cbor.decodeToken(e);if(void 0!==l)return e=l.res.uuid?Object.keys(l.res.uuid):[],t=Object.keys(l.res.chan),r=Object.keys(l.res.grp),n=l.pat.uuid?Object.keys(l.pat.uuid):[],o=Object.keys(l.pat.chan),i=Object.keys(l.pat.grp),s={version:l.v,timestamp:l.t,ttl:l.ttl,authorized_uuid:l.uuid},c=0<e.length,u=0<t.length,a=0<r.length,(c||u||a)&&(s.resources={},c&&(s.resources.uuids={},e.forEach(function(e){s.resources.uuids[e]=d.extractPermissions(l.res.uuid[e])})),u&&(s.resources.channels={},t.forEach(function(e){s.resources.channels[e]=d.extractPermissions(l.res.chan[e])})),a)&&(s.resources.groups={},r.forEach(function(e){s.resources.groups[e]=d.extractPermissions(l.res.grp[e])})),c=0<n.length,e=0<o.length,u=0<i.length,(c||e||u)&&(s.patterns={},c&&(s.patterns.uuids={},n.forEach(function(e){s.patterns.uuids[e]=d.extractPermissions(l.pat.uuid[e])})),e&&(s.patterns.channels={},o.forEach(function(e){s.patterns.channels[e]=d.extractPermissions(l.pat.chan[e])})),u)&&(s.patterns.groups={},i.forEach(function(e){s.patterns.groups[e]=d.extractPermissions(l.pat.grp[e])})),0<Object.keys(l.meta).length&&(s.meta=l.meta),s.signature=l.sig,s},Pt),q=(D(St,ht=Error),St);function St(e,t){var r=this.constructor,n=ht.call(this,e)||this;return n.name=n.constructor.name,n.status=t,n.message=e,Object.setPrototypeOf(n,r.prototype),n}function Pt(e,t){this._config=e,this._cbor=t}function r(){this._listeners=[]}function Ot(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new At(this._payload.apns,e,t),this.mpns=new bt(this._payload.mpns,e,t),this.fcm=new vt(this._payload.fcm,e,t)}function wt(){return null!==gt&&gt.apply(this,arguments)||this}function Ut(){return null!==yt&&yt.apply(this,arguments)||this}function kt(){return null!==mt&&mt.apply(this,arguments)||this}function jt(e,t,r){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=r}function Ct(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}function n(e){var t=e.subscribeEndpoint,r=e.leaveEndpoint,n=e.heartbeatEndpoint,o=e.setStateEndpoint,i=e.timeEndpoint,s=e.getFileUrl,a=e.config,c=e.crypto,u=e.cryptoModule;this._listenerManager=e.listenerManager,this._config=a,this._leaveEndpoint=r,this._heartbeatEndpoint=n,this._setStateEndpoint=o,this._subscribeEndpoint=t,this._getFileUrl=s,this._crypto=c,this._cryptoModule=u,this._channels={},this._presenceChannels={},this._heartbeatChannels={},this._heartbeatChannelGroups={},this._channelGroups={},this._presenceChannelGroups={},this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[],this._currentTimetoken=0,this._lastTimetoken=0,this._storedTimetoken=null,this._subscriptionStatusAnnounced=!1,this._isOnline=!0,this._reconnectionManager=new ct({timeEndpoint:i}),this._dedupingManager=new ut({config:a}),this._cryptoModule&&(this._decoder=new TextDecoder)}function xt(e){return{message:e,type:"validationError",error:!0}}function Dt(e){var t;return e.sdkName||(t="PubNub-JS-".concat(e.sdkFamily),e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion()),0<(e=e._getPnsdkSuffix(" ")).length&&(t+=e),t)}function Lt(e,t,r){return t.usePost&&t.usePost(e,r)?"POST":t.usePatch&&t.usePatch(e,r)?"PATCH":t.useDelete&&t.useDelete(e,r)?"DELETE":t.useGetFile&&t.useGetFile(e,r)?"GETFILE":"GET"}function Nt(e,t,r,n,o){var i,s=e.config,a=e.crypto,c=Lt(e,o,n),s=(r.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===o.getOperation()&&o.usePost&&o.usePost(e,n)&&(c="GET"),"".concat(c="GETFILE"===c?"GET":c,"\n").concat(s.publishKey,"\n").concat(t,"\n").concat(m.signPamFromParams(r),"\n"));"POST"===c?s+="string"==typeof(i=o.postPayload(e,n))?i:JSON.stringify(i):"PATCH"===c&&(s+="string"==typeof(i=o.patchPayload(e,n))?i:JSON.stringify(i));t=(t=(t=(t="v2.".concat(a.HMACSHA256(s))).replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,"");r.signature=t}function w(r,n){for(var e=[],t=2;t<arguments.length;t++)e[t-2]=arguments[t];var o,i,s,a,c=r.networking,u=r.config,d=r.telemetryManager,l=r.tokenManager,p=J(),f=null,h=null,g={},f=n.getOperation()===O.PNTimeOperation||n.getOperation()===O.PNChannelGroupsOperation?e[0]:(g=e[0],e[1]),y=("undefined"==typeof Promise||f||(h=m.createPromise()),n.validateParams(r,g));return y?f?f(xt(y)):h?(h.reject(new q("Validation failed, check status for details",xt(y))),h.promise):void 0:(y=n.prepareParams(r,g),i=r,a=g,i={url:o=(o=n).usePost&&o.usePost(i,a)?o.postURL(i,a):o.usePatch&&o.usePatch(i,a)?o.patchURL(i,a):o.useGetFile&&o.useGetFile(i,a)?o.getFileURL(i,a):o.getURL(i,a),operation:n.getOperation(),timeout:n.getRequestTimeout(r),headers:n.getRequestHeaders?n.getRequestHeaders():{},ignoreBody:"function"==typeof n.ignoreBody&&n.ignoreBody(r),forceBuffered:"function"==typeof n.forceBuffered?n.forceBuffered(r,g):null,abortSignal:"function"==typeof n.getAbortSignal?n.getAbortSignal(r,g):null},y.uuid=u.UUID,y.pnsdk=Dt(u),a=d.operationsLatencyForRequest(),Object.keys(a).length&&(y=R(R({},y),a)),u.useInstanceId&&(y.instanceid=u.instanceId),u.useRequestId&&(y.requestid=p),n.isAuthSupported()&&(a=l.getToken()||u.getAuthKey())&&(y.auth=a),u.secretKey&&Nt(r,o,y,g,n),l=function(t,e){t.error?(n.handleError&&n.handleError(r,g,t),f?f(t):h&&h.reject(new q("PubNub call failed, check status for details",t))):(d.stopLatencyMeasure(n.getOperation(),p),(e="function"!=typeof(null==(e=n.handleResponse(r,e,g))?void 0:e.then)?Promise.resolve(e):e).then(function(e){f?f(t,e):h&&h.fulfill(e)}).catch(function(e){var t;f?(t=e,n.getOperation()===O.PNSubscribeOperation&&(t={statusCode:400,error:!0,operation:n.getOperation(),errorData:e,category:v.PNUnknownCategory}),f(t,null)):h&&h.reject(new q("PubNub call failed, check status for details",e))}))},d.startLatencyMeasure(n.getOperation(),p),a="POST"===Lt(r,n,g)?(s=n.postPayload(r,g),c.POST(y,s,i,l)):"PATCH"===Lt(r,n,g)?(s=n.patchPayload(r,g),c.PATCH(y,s,i,l)):"DELETE"===Lt(r,n,g)?c.DELETE(y,i,l):"GETFILE"===Lt(r,n,g)?c.GETFILE(y,i,l):c.GET(y,i,l),n.getOperation()===O.PNSubscribeOperation?a:h?h.promise:void 0)}function Ht(e,t){var r,n=t.channel,o=t.id,t=t.name,i=e.config,s=e.networking,a=e.tokenManager;if(!n)throw new q("Validation failed, check status for details",xt("channel can't be empty"));if(!o)throw new q("Validation failed, check status for details",xt("file id can't be empty"));if(t)return n="/v1/files/".concat(i.subscribeKey,"/channels/").concat(m.encodeString(n),"/files/").concat(o,"/").concat(t),(r={}).uuid=i.getUUID(),r.pnsdk=Dt(i),(o=a.getToken()||i.getAuthKey())&&(r.auth=o),i.secretKey&&Nt(e,n,r,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}}),""!==(t=Object.keys(r).map(function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(r[e]))}).join("&"))?"".concat(s.getStandardOrigin()).concat(n,"?").concat(t):"".concat(s.getStandardOrigin()).concat(n);throw new q("Validation failed, check status for details",xt("file name can't be empty"))}var Mt=Object.freeze({__proto__:null,getOperation:function(){return O.PNAddChannelsToGroupOperation},validateParams:function(e,t){var r=t.channels,e=e.config;return t.channelGroup?r&&0!==r.length?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing Channel Group"},getURL:function(e,t){t=t.channelGroup,e=e.config;return"/v1/channel-registration/sub-key/".concat(e.subscribeKey,"/channel-group/").concat(m.encodeString(t))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){t=t.channels;return{add:(void 0===t?[]:t).join(",")}},handleResponse:function(){return{}}}),Ft=Object.freeze({__proto__:null,getOperation:function(){return O.PNRemoveChannelsFromGroupOperation},validateParams:function(e,t){var r=t.channels,e=e.config;return t.channelGroup?r&&0!==r.length?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing Channel Group"},getURL:function(e,t){t=t.channelGroup,e=e.config;return"/v1/channel-registration/sub-key/".concat(e.subscribeKey,"/channel-group/").concat(m.encodeString(t))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){t=t.channels;return{remove:(void 0===t?[]:t).join(",")}},handleResponse:function(){return{}}}),qt=Object.freeze({__proto__:null,getOperation:function(){return O.PNRemoveGroupOperation},validateParams:function(e,t){t=t.channelGroup,e=e.config;return t?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channel Group"},getURL:function(e,t){t=t.channelGroup,e=e.config;return"/v1/channel-registration/sub-key/".concat(e.subscribeKey,"/channel-group/").concat(m.encodeString(t),"/remove")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},handleResponse:function(){return{}}}),Yt=Object.freeze({__proto__:null,getOperation:function(){return O.PNChannelGroupsOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){e=e.config;return"/v1/channel-registration/sub-key/".concat(e.subscribeKey,"/channel-group")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{groups:t.payload.groups}}}),Kt=Object.freeze({__proto__:null,getOperation:function(){return O.PNChannelsForGroupOperation},validateParams:function(e,t){t=t.channelGroup,e=e.config;return t?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channel Group"},getURL:function(e,t){t=t.channelGroup,e=e.config;return"/v1/channel-registration/sub-key/".concat(e.subscribeKey,"/channel-group/").concat(m.encodeString(t))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{channels:t.payload.channels}}}),zt=Object.freeze({__proto__:null,getOperation:function(){return O.PNPushNotificationEnabledChannelsOperation},validateParams:function(e,t){var r=t.device,n=t.pushGateway,o=t.channels,e=e.config;return r?n?"apns2"!==n||t.topic?o&&0!==o.length?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing APNS2 topic":"Missing GW Type (pushGateway: gcm, apns or apns2)":"Missing Device ID (device)"},getURL:function(e,t){var r=t.device,e=e.config;return("apns2"===t.pushGateway?"/v2/push/sub-key/".concat(e.subscribeKey,"/devices-apns2/"):"/v1/push/sub-key/".concat(e.subscribeKey,"/devices/")).concat(r)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.pushGateway,n=t.channels,n=void 0===n?[]:n,o=t.environment,o=void 0===o?"development":o,t=t.topic,n={type:r,add:n.join(",")};return"apns2"===r&&delete(n=R(R({},n),{environment:o,topic:t})).type,n},handleResponse:function(){return{}}}),Gt=Object.freeze({__proto__:null,getOperation:function(){return O.PNPushNotificationEnabledChannelsOperation},validateParams:function(e,t){var r=t.device,n=t.pushGateway,o=t.channels,e=e.config;return r?n?"apns2"!==n||t.topic?o&&0!==o.length?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing APNS2 topic":"Missing GW Type (pushGateway: gcm, apns or apns2)":"Missing Device ID (device)"},getURL:function(e,t){var r=t.device,e=e.config;return("apns2"===t.pushGateway?"/v2/push/sub-key/".concat(e.subscribeKey,"/devices-apns2/"):"/v1/push/sub-key/".concat(e.subscribeKey,"/devices/")).concat(r)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.pushGateway,n=t.channels,n=void 0===n?[]:n,o=t.environment,o=void 0===o?"development":o,t=t.topic,n={type:r,remove:n.join(",")};return"apns2"===r&&delete(n=R(R({},n),{environment:o,topic:t})).type,n},handleResponse:function(){return{}}}),Xt=Object.freeze({__proto__:null,getOperation:function(){return O.PNPushNotificationEnabledChannelsOperation},validateParams:function(e,t){var r=t.device,n=t.pushGateway,e=e.config;return r?n?"apns2"!==n||t.topic?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing APNS2 topic":"Missing GW Type (pushGateway: gcm, apns or apns2)":"Missing Device ID (device)"},getURL:function(e,t){var r=t.device,e=e.config;return("apns2"===t.pushGateway?"/v2/push/sub-key/".concat(e.subscribeKey,"/devices-apns2/"):"/v1/push/sub-key/".concat(e.subscribeKey,"/devices/")).concat(r)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.pushGateway,n=t.environment,n=void 0===n?"development":n,t=t.topic,o={type:r};return"apns2"===r&&delete(o=R(R({},o),{environment:n,topic:t})).type,o},handleResponse:function(e,t){return{channels:t}}}),Bt=Object.freeze({__proto__:null,getOperation:function(){return O.PNRemoveAllPushNotificationsOperation},validateParams:function(e,t){var r=t.device,n=t.pushGateway,e=e.config;return r?n?"apns2"!==n||t.topic?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing APNS2 topic":"Missing GW Type (pushGateway: gcm, apns or apns2)":"Missing Device ID (device)"},getURL:function(e,t){var r=t.device,e=e.config;return("apns2"===t.pushGateway?"/v2/push/sub-key/".concat(e.subscribeKey,"/devices-apns2/"):"/v1/push/sub-key/".concat(e.subscribeKey,"/devices/")).concat(r,"/remove")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.pushGateway,n=t.environment,n=void 0===n?"development":n,t=t.topic,o={type:r};return"apns2"===r&&delete(o=R(R({},o),{environment:n,topic:t})).type,o},handleResponse:function(){return{}}}),Vt=Object.freeze({__proto__:null,getOperation:function(){return O.PNUnsubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){e=e.config,t=t.channels,t=void 0===t?[]:t,t=0<t.length?t.join(","):",";return"/v2/presence/sub-key/".concat(e.subscribeKey,"/channel/").concat(m.encodeString(t),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var t=t.channelGroups,t=void 0===t?[]:t,r={};return 0<t.length&&(r["channel-group"]=t.join(",")),r},handleResponse:function(){return{}}}),Wt=Object.freeze({__proto__:null,getOperation:function(){return O.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){e=e.config,t=t.uuid,t=void 0===t?e.UUID:t;return"/v2/presence/sub-key/".concat(e.subscribeKey,"/uuid/").concat(m.encodeString(t))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}}),Jt=Object.freeze({__proto__:null,getOperation:function(){return O.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){e=e.config,t=t.channels,t=void 0===t?[]:t,t=0<t.length?t.join(","):",";return"/v2/presence/sub-key/".concat(e.subscribeKey,"/channel/").concat(m.encodeString(t),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var r=t.channelGroups,r=void 0===r?[]:r,t=t.state,e=e.config,n={};return 0<r.length&&(n["channel-group"]=r.join(",")),t&&(n.state=JSON.stringify(t)),n.heartbeat=e.getPresenceTimeout(),n},handleResponse:function(){return{}}}),$t=Object.freeze({__proto__:null,getOperation:function(){return O.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var e=e.config,r=t.uuid,r=void 0===r?e.UUID:r,t=t.channels,t=void 0===t?[]:t,t=0<t.length?t.join(","):",";return"/v2/presence/sub-key/".concat(e.subscribeKey,"/channel/").concat(m.encodeString(t),"/uuid/").concat(r)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var t=t.channelGroups,t=void 0===t?[]:t,r={};return 0<t.length&&(r["channel-group"]=t.join(",")),r},handleResponse:function(e,t,r){var n=r.channels,n=void 0===n?[]:n,r=r.channelGroups,o={};return 1===n.length&&0===(void 0===r?[]:r).length?o[n[0]]=t.payload:o=t.payload,{channels:o}}}),Qt=Object.freeze({__proto__:null,getOperation:function(){return O.PNSetStateOperation},validateParams:function(e,t){var e=e.config,r=t.state,n=t.channels,t=t.channelGroups;return r?e.subscribeKey?0===(void 0===n?[]:n).length&&0===(void 0===t?[]:t).length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){e=e.config,t=t.channels,t=void 0===t?[]:t,t=0<t.length?t.join(","):",";return"/v2/presence/sub-key/".concat(e.subscribeKey,"/channel/").concat(m.encodeString(t),"/uuid/").concat(m.encodeString(e.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.state,t=t.channelGroups,t=void 0===t?[]:t,n={};return n.state=JSON.stringify(r),0<t.length&&(n["channel-group"]=t.join(",")),n},handleResponse:function(e,t){return{state:t.payload}}}),Zt=Object.freeze({__proto__:null,getOperation:function(){return O.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var e=e.config,r=t.channels,r=void 0===r?[]:r,t=t.channelGroups,t=void 0===t?[]:t,e="/v2/presence/sub-key/".concat(e.subscribeKey);return(0<r.length||0<t.length)&&(t=0<r.length?r.join(","):",",e+="/channel/".concat(m.encodeString(t))),e},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,r=void 0===r?[]:r,n=t.includeUUIDs,o=t.includeState,o=void 0!==o&&o,t=t.queryParameters,t=void 0===t?{}:t,i={};return void 0===n||n||(i.disable_uuids=1),o&&(i.state=1),0<r.length&&(i["channel-group"]=r.join(",")),R(R({},i),t)},handleResponse:function(e,n,t){var r,o,i=t.channels,i=void 0===i?[]:i,s=t.channelGroups,s=void 0===s?[]:s,a=t.includeUUIDs,c=void 0===a||a,a=t.includeState,u=void 0!==a&&a;return 1<i.length||0<s.length||0===s.length&&0===i.length?((o={}).totalChannels=n.payload.total_channels,o.totalOccupancy=n.payload.total_occupancy,o.channels={},Object.keys(n.payload.channels).forEach(function(e){var t=n.payload.channels[e],r=[];return o.channels[e]={occupants:r,name:e,occupancy:t.occupancy},c&&t.uuids.forEach(function(e){u?r.push({state:e.state,uuid:e.uuid}):r.push({state:null,uuid:e})}),o}),o):(r=[],(t={}).totalChannels=1,t.totalOccupancy=n.occupancy,t.channels={},t.channels[i[0]]={occupants:r,name:i[0],occupancy:n.occupancy},c&&n.uuids&&n.uuids.forEach(function(e){u?r.push({state:e.state,uuid:e.uuid}):r.push({state:null,uuid:e})}),t)},handleError:function(e,t,r){402!==r.statusCode||this.getURL(e,t).includes("channel")||(r.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}}),er=Object.freeze({__proto__:null,getOperation:function(){return O.PNAddMessageActionOperation},validateParams:function(e,t){var e=e.config,r=t.action;return t.messageTimetoken?e.subscribeKey?t.channel?r?r.value?r.type?15<r.type.length?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var e=e.config,r=t.channel,t=t.messageTimetoken;return"/v1/message-actions/".concat(e.subscribeKey,"/channel/").concat(m.encodeString(r),"/message/").concat(t)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}}),tr=Object.freeze({__proto__:null,getOperation:function(){return O.PNRemoveMessageActionOperation},validateParams:function(e,t){var e=e.config,r=t.channel;return t.messageTimetoken?t.actionTimetoken?e.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var e=e.config,r=t.channel,n=t.actionTimetoken,t=t.messageTimetoken;return"/v1/message-actions/".concat(e.subscribeKey,"/channel/").concat(m.encodeString(r),"/message/").concat(t,"/action/").concat(n)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}}),rr=Object.freeze({__proto__:null,getOperation:function(){return O.PNGetMessageActionsOperation},validateParams:function(e,t){e=e.config,t=t.channel;return e.subscribeKey?t?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){e=e.config,t=t.channel;return"/v1/message-actions/".concat(e.subscribeKey,"/channel/").concat(m.encodeString(t))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.limit,n=t.start,t=t.end,o={};return r&&(o.limit=r),n&&(o.start=n),t&&(o.end=t),o},handleResponse:function(e,t){t={data:t.data,start:null,end:null};return t.data.length&&(t.end=t.data[t.data.length-1].actionTimetoken,t.start=t.data[0].actionTimetoken),t}}),nr={getOperation:function(){return O.PNListFilesOperation},validateParams:function(e,t){if(null==t||!t.channel)return"channel can't be empty"},getURL:function(e,t){e=e.config;return"/v1/files/".concat(e.subscribeKey,"/channels/").concat(m.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r={};return t.limit&&(r.limit=t.limit),t.next&&(r.next=t.next),r},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},or={getOperation:function(){return O.PNGenerateUploadUrlOperation},validateParams:function(e,t){return null!=t&&t.channel?null!=t&&t.name?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){e=e.config;return"/v1/files/".concat(e.subscribeKey,"/channels/").concat(m.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},ir={getOperation:function(){return O.PNPublishFileOperation},validateParams:function(e,t){return null!=t&&t.channel?null!=t&&t.fileId?null!=t&&t.fileName?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var r=e.config,n=r.publishKey,r=r.subscribeKey,e=((e,t)=>(t=JSON.stringify(t),e.cryptoModule&&(t="string"==typeof(e=e.cryptoModule.encrypt(t))?e:Z(e),t=JSON.stringify(t)),t||""))(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(n,"/").concat(r,"/0/").concat(m.encodeString(t.channel),"/0/").concat(m.encodeString(e))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r={};return t.ttl&&(r.ttl=t.ttl),void 0!==t.storeInHistory&&(r.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(r.meta=JSON.stringify(t.meta)),r},handleResponse:function(e,t){return{timetoken:t[2]}}},sr={getOperation:function(){return O.PNDownloadFileOperation},validateParams:function(e,t){return null!=t&&t.channel?null!=t&&t.name?null!=t&&t.id?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){e=e.config;return"/v1/files/".concat(e.subscribeKey,"/channels/").concat(m.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,o,i){var s=e.PubNubFile,a=e.config,c=e.cryptography,u=e.cryptoModule;return _(void 0,void 0,void 0,function(){var t,r,n;return F(this,function(e){switch(e.label){case 0:return t=o.response.body,s.supportsEncryptFile&&(i.cipherKey||u)?null!=i.cipherKey?[3,2]:[4,u.decryptFile(s.create({data:t,name:i.name}),s)]:[3,5];case 1:return r=e.sent().data,[3,4];case 2:return[4,c.decrypt(null!=(n=i.cipherKey)?n:a.cipherKey,t)];case 3:r=e.sent(),e.label=4;case 4:t=r,e.label=5;case 5:return[2,s.create({data:t,name:null!=(n=o.response.name)?n:i.name,mimeType:o.response.type})]}})})}},ar={getOperation:function(){return O.PNListFilesOperation},validateParams:function(e,t){return null!=t&&t.channel?null!=t&&t.id?null!=t&&t.name?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){e=e.config;return"/v1/files/".concat(e.subscribeKey,"/channels/").concat(m.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},cr={getOperation:function(){return O.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r,n={include:["status","type"]};return null!=t&&t.include&&null!=(r=t.include)&&r.customFields&&n.include.push("custom"),n.include=n.include.join(","),null!=(r=null==t?void 0:t.include)&&r.totalCount&&(n.count=null==(r=t.include)?void 0:r.totalCount),null!=(r=null==t?void 0:t.page)&&r.next&&(n.start=null==(r=t.page)?void 0:r.next),null!=(r=null==t?void 0:t.page)&&r.prev&&(n.end=null==(r=t.page)?void 0:r.prev),null!=t&&t.filter&&(n.filter=t.filter),n.limit=null!=(r=null==t?void 0:t.limit)?r:100,null!=t&&t.sort&&(n.sort=Object.entries(null!=(r=t.sort)?r:{}).map(function(e){var e=A(e,2),t=e[0],e=e[1];return"asc"===e||"desc"===e?"".concat(t,":").concat(e):t})),n},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},ur={getOperation:function(){return O.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/uuids/").concat(m.encodeString(null!=(t=null==t?void 0:t.uuid)?t:e.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r,e=e.config,n={};return n.uuid=null!=(r=null==t?void 0:t.uuid)?r:e.getUUID(),n.include=["status","type","custom"],null!=t&&t.include&&!1===(null==(r=t.include)?void 0:r.customFields)&&n.include.pop(),n.include=n.include.join(","),n},handleResponse:function(e,t){return{status:t.status,data:t.data}}},dr={getOperation:function(){return O.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(null==t||!t.data)return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/uuids/").concat(m.encodeString(null!=(t=t.uuid)?t:e.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r,e=e.config,n={};return n.uuid=null!=(r=null==t?void 0:t.uuid)?r:e.getUUID(),n.include=["status","type","custom"],null!=t&&t.include&&!1===(null==(r=t.include)?void 0:r.customFields)&&n.include.pop(),n.include=n.include.join(","),n},handleResponse:function(e,t){return{status:t.status,data:t.data}}},lr={getOperation:function(){return O.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/uuids/").concat(m.encodeString(null!=(t=null==t?void 0:t.uuid)?t:e.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){e=e.config;return{uuid:null!=(t=null==t?void 0:t.uuid)?t:e.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},pr={getOperation:function(){return O.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r,n={include:["status","type"]};return null!=t&&t.include&&null!=(r=t.include)&&r.customFields&&n.include.push("custom"),n.include=n.include.join(","),null!=(r=null==t?void 0:t.include)&&r.totalCount&&(n.count=null==(r=t.include)?void 0:r.totalCount),null!=(r=null==t?void 0:t.page)&&r.next&&(n.start=null==(r=t.page)?void 0:r.next),null!=(r=null==t?void 0:t.page)&&r.prev&&(n.end=null==(r=t.page)?void 0:r.prev),null!=t&&t.filter&&(n.filter=t.filter),n.limit=null!=(r=null==t?void 0:t.limit)?r:100,null!=t&&t.sort&&(n.sort=Object.entries(null!=(r=t.sort)?r:{}).map(function(e){var e=A(e,2),t=e[0],e=e[1];return"asc"===e||"desc"===e?"".concat(t,":").concat(e):t})),n},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},fr={getOperation:function(){return O.PNGetChannelMetadataOperation},validateParams:function(e,t){if(null==t||!t.channel)return"Channel cannot be empty"},getURL:function(e,t){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/channels/").concat(m.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r={include:["status","type","custom"]};return null!=t&&t.include&&!1===(null==(t=t.include)?void 0:t.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},hr={getOperation:function(){return O.PNSetChannelMetadataOperation},validateParams:function(e,t){return null!=t&&t.channel?null!=t&&t.data?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/channels/").concat(m.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r={include:["status","type","custom"]};return null!=t&&t.include&&!1===(null==(t=t.include)?void 0:t.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},gr={getOperation:function(){return O.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(null==t||!t.channel)return"Channel cannot be empty"},getURL:function(e,t){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/channels/").concat(m.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},yr={getOperation:function(){return O.PNGetMembersOperation},validateParams:function(e,t){if(null==t||!t.channel)return"channel cannot be empty"},getURL:function(e,t){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/channels/").concat(m.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r,n={include:[]};return null!=t&&t.include&&(null!=(r=t.include)&&r.statusField&&n.include.push("status"),null!=(r=t.include)&&r.customFields&&n.include.push("custom"),null!=(r=t.include)&&r.UUIDFields&&n.include.push("uuid"),null!=(r=t.include)&&r.customUUIDFields&&n.include.push("uuid.custom"),null!=(r=t.include)&&r.UUIDStatusField&&n.include.push("uuid.status"),null!=(r=t.include))&&r.UUIDTypeField&&n.include.push("uuid.type"),n.include=n.include.join(","),null!=(r=null==t?void 0:t.include)&&r.totalCount&&(n.count=null==(r=t.include)?void 0:r.totalCount),null!=(r=null==t?void 0:t.page)&&r.next&&(n.start=null==(r=t.page)?void 0:r.next),null!=(r=null==t?void 0:t.page)&&r.prev&&(n.end=null==(r=t.page)?void 0:r.prev),null!=t&&t.filter&&(n.filter=t.filter),n.limit=null!=(r=null==t?void 0:t.limit)?r:100,null!=t&&t.sort&&(n.sort=Object.entries(null!=(r=t.sort)?r:{}).map(function(e){var e=A(e,2),t=e[0],e=e[1];return"asc"===e||"desc"===e?"".concat(t,":").concat(e):t})),n},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},mr={getOperation:function(){return O.PNSetMembersOperation},validateParams:function(e,t){return null!=t&&t.channel?null!=t&&t.uuids&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/channels/").concat(m.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var r;return(r={set:[],delete:[]})[t.type]=t.uuids.map(function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}}),r},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r,n={include:["uuid.status","uuid.type","type"]};return null!=t&&t.include&&(null!=(r=t.include)&&r.customFields&&n.include.push("custom"),null!=(r=t.include)&&r.customUUIDFields&&n.include.push("uuid.custom"),null!=(r=t.include))&&r.UUIDFields&&n.include.push("uuid"),n.include=n.include.join(","),null!=(r=null==t?void 0:t.include)&&r.totalCount&&(n.count=!0),null!=(r=null==t?void 0:t.page)&&r.next&&(n.start=null==(r=t.page)?void 0:r.next),null!=(r=null==t?void 0:t.page)&&r.prev&&(n.end=null==(r=t.page)?void 0:r.prev),null!=t&&t.filter&&(n.filter=t.filter),null!=t.limit&&(n.limit=t.limit),null!=t&&t.sort&&(n.sort=Object.entries(null!=(r=t.sort)?r:{}).map(function(e){var e=A(e,2),t=e[0],e=e[1];return"asc"===e||"desc"===e?"".concat(t,":").concat(e):t})),n},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Rr={getOperation:function(){return O.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/uuids/").concat(m.encodeString(null!=(t=null==t?void 0:t.uuid)?t:e.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r,n={include:[]};return null!=t&&t.include&&(null!=(r=t.include)&&r.statusField&&n.include.push("status"),null!=(r=t.include)&&r.customFields&&n.include.push("custom"),null!=(r=t.include)&&r.channelFields&&n.include.push("channel"),null!=(r=t.include)&&r.customChannelFields&&n.include.push("channel.custom"),null!=(r=t.include)&&r.channelStatusField&&n.include.push("channel.status"),null!=(r=t.include))&&r.channelTypeField&&n.include.push("channel.type"),n.include=n.include.join(","),null!=(r=null==t?void 0:t.include)&&r.totalCount&&(n.count=null==(r=t.include)?void 0:r.totalCount),null!=(r=null==t?void 0:t.page)&&r.next&&(n.start=null==(r=t.page)?void 0:r.next),null!=(r=null==t?void 0:t.page)&&r.prev&&(n.end=null==(r=t.page)?void 0:r.prev),null!=t&&t.filter&&(n.filter=t.filter),n.limit=null!=(r=null==t?void 0:t.limit)?r:100,null!=t&&t.sort&&(n.sort=Object.entries(null!=(r=t.sort)?r:{}).map(function(e){var e=A(e,2),t=e[0],e=e[1];return"asc"===e||"desc"===e?"".concat(t,":").concat(e):t})),n},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},_r={getOperation:function(){return O.PNSetMembershipsOperation},validateParams:function(e,t){if(null==t||!t.channels||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/uuids/").concat(m.encodeString(null!=(t=t.uuid)?t:e.getUUID()),"/channels")},patchPayload:function(e,t){var r;return(r={set:[],delete:[]})[t.type]=t.channels.map(function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}}),r},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r,n={include:["channel.status","channel.type","status"]};return null!=t&&t.include&&(null!=(r=t.include)&&r.customFields&&n.include.push("custom"),null!=(r=t.include)&&r.customChannelFields&&n.include.push("channel.custom"),null!=(r=t.include))&&r.channelFields&&n.include.push("channel"),n.include=n.include.join(","),null!=(r=null==t?void 0:t.include)&&r.totalCount&&(n.count=!0),null!=(r=null==t?void 0:t.page)&&r.next&&(n.start=null==(r=t.page)?void 0:r.next),null!=(r=null==t?void 0:t.page)&&r.prev&&(n.end=null==(r=t.page)?void 0:r.prev),null!=t&&t.filter&&(n.filter=t.filter),null!=t.limit&&(n.limit=t.limit),null!=t&&t.sort&&(n.sort=Object.entries(null!=(r=t.sort)?r:{}).map(function(e){var e=A(e,2),t=e[0],e=e[1];return"asc"===e||"desc"===e?"".concat(t,":").concat(e):t})),n},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ar=Object.freeze({__proto__:null,getOperation:function(){return O.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){e=e.config;return"/v2/auth/audit/sub-key/".concat(e.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var r=t.channel,n=t.channelGroup,t=t.authKeys,t=void 0===t?[]:t,o={};return r&&(o.channel=r),n&&(o["channel-group"]=n),0<t.length&&(o.auth=t.join(",")),o},handleResponse:function(e,t){return t.payload}}),br=Object.freeze({__proto__:null,getOperation:function(){return O.PNAccessManagerGrant},validateParams:function(e,t){e=e.config;return e.subscribeKey?e.publishKey?e.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){e=e.config;return"/v2/auth/grant/sub-key/".concat(e.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var r=t.channels,r=void 0===r?[]:r,n=t.channelGroups,n=void 0===n?[]:n,o=t.uuids,o=void 0===o?[]:o,i=t.ttl,s=t.read,a=t.write,a=void 0!==a&&a,c=t.manage,c=void 0!==c&&c,u=t.get,u=void 0!==u&&u,d=t.join,d=void 0!==d&&d,l=t.update,l=void 0!==l&&l,p=t.authKeys,p=void 0===p?[]:p,t=t.delete,f={};return f.r=void 0!==s&&s?"1":"0",f.w=a?"1":"0",f.m=c?"1":"0",f.d=t?"1":"0",f.g=u?"1":"0",f.j=d?"1":"0",f.u=l?"1":"0",0<r.length&&(f.channel=r.join(",")),0<n.length&&(f["channel-group"]=n.join(",")),0<p.length&&(f.auth=p.join(",")),0<o.length&&(f["target-uuid"]=o.join(",")),!i&&0!==i||(f.ttl=i),f},handleResponse:function(){return{}}});function vr(e){var t=void 0!==(null==e?void 0:e.authorizedUserId),r=void 0!==(null==(r=null==e?void 0:e.resources)?void 0:r.users),n=void 0!==(null==(n=null==e?void 0:e.resources)?void 0:n.spaces),o=void 0!==(null==(o=null==e?void 0:e.patterns)?void 0:o.users),e=void 0!==(null==(e=null==e?void 0:e.patterns)?void 0:e.spaces);return o||r||e||n||t}function Ir(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}var Tr=Object.freeze({__proto__:null,getOperation:function(){return O.PNAccessManagerGrantToken},extractPermissions:Ir,validateParams:function(e,t){var r,n,o,i,s,a,e=e.config;return e.subscribeKey?e.publishKey?e.secretKey?t.resources||t.patterns?(e=void 0!==(null==t?void 0:t.authorized_uuid),r=void 0!==(null==(r=null==t?void 0:t.resources)?void 0:r.uuids),n=void 0!==(null==(n=null==t?void 0:t.resources)?void 0:n.channels),o=void 0!==(null==(o=null==t?void 0:t.resources)?void 0:o.groups),i=void 0!==(null==(i=null==t?void 0:t.patterns)?void 0:i.uuids),s=void 0!==(null==(s=null==t?void 0:t.patterns)?void 0:s.channels),a=void 0!==(null==(a=null==t?void 0:t.patterns)?void 0:a.groups),vr(t)&&(e||r||i||n||s||o||a)?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."):"Missing either Resources or Patterns.":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},postURL:function(e){e=e.config;return"/v3/pam/".concat(e.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return vr(t=t)?(p=t.ttl,u=t.resources,l=t.patterns,f=t.meta,d=t.authorizedUserId,c={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}},u&&(r=u.users,n=u.spaces,o=u.groups,r&&Object.keys(r).forEach(function(e){c.permissions.resources.uuids[e]=Ir(r[e])}),n&&Object.keys(n).forEach(function(e){c.permissions.resources.channels[e]=Ir(n[e])}),o)&&Object.keys(o).forEach(function(e){c.permissions.resources.groups[e]=Ir(o[e])}),l&&(i=l.users,s=l.spaces,a=l.groups,i&&Object.keys(i).forEach(function(e){c.permissions.patterns.uuids[e]=Ir(i[e])}),s&&Object.keys(s).forEach(function(e){c.permissions.patterns.channels[e]=Ir(s[e])}),a)&&Object.keys(a).forEach(function(e){c.permissions.patterns.groups[e]=Ir(a[e])}),!p&&0!==p||(c.ttl=p),f&&(c.permissions.meta=f),d&&(c.permissions.uuid="".concat(d)),c):(u=t.ttl,l=t.patterns,p=t.meta,f=t.authorized_uuid,h={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}},(d=t.resources)&&(g=d.uuids,y=d.channels,m=d.groups,g&&Object.keys(g).forEach(function(e){h.permissions.resources.uuids[e]=Ir(g[e])}),y&&Object.keys(y).forEach(function(e){h.permissions.resources.channels[e]=Ir(y[e])}),m)&&Object.keys(m).forEach(function(e){h.permissions.resources.groups[e]=Ir(m[e])}),l&&(R=l.uuids,_=l.channels,A=l.groups,R&&Object.keys(R).forEach(function(e){h.permissions.patterns.uuids[e]=Ir(R[e])}),_&&Object.keys(_).forEach(function(e){h.permissions.patterns.channels[e]=Ir(_[e])}),A)&&Object.keys(A).forEach(function(e){h.permissions.patterns.groups[e]=Ir(A[e])}),!u&&0!==u||(h.ttl=u),p&&(h.permissions.meta=p),f&&(h.permissions.uuid="".concat(f)),h);var r,n,o,i,s,a,c,u,d,l,p,f,h,g,y,m,R,_,A},handleResponse:function(e,t){return t.data.token}}),Er={getOperation:function(){return O.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){e=e.config;return"/v3/pam/".concat(e.subscribeKey,"/grant/").concat(m.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Sr(e,t){t=JSON.stringify(t);return e.cryptoModule&&(t="string"==typeof(e=e.cryptoModule.encrypt(t))?e:Z(e),t=JSON.stringify(t)),t||""}var Pr,Or=Object.freeze({__proto__:null,getOperation:function(){return O.PNPublishOperation},validateParams:function(e,t){var e=e.config,r=t.message;return t.channel?r?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){t=t.sendByPost;return void 0!==t&&t},getURL:function(e,t){var r=e.config,n=t.channel,e=Sr(e,t.message);return"/publish/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(m.encodeString(n),"/0/").concat(m.encodeString(e))},postURL:function(e,t){e=e.config,t=t.channel;return"/publish/".concat(e.publishKey,"/").concat(e.subscribeKey,"/0/").concat(m.encodeString(t),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Sr(e,t.message)},prepareParams:function(e,t){var r=t.meta,n=t.replicate,n=void 0===n||n,o=t.storeInHistory,t=t.ttl,i={};return null!=o&&(i.store=o?"1":"0"),t&&(i.ttl=t),!1===n&&(i.norep="true"),r&&"object"==typeof r&&(i.meta=JSON.stringify(r)),i},handleResponse:function(e,t){return{timetoken:t[2]}}}),wr=Object.freeze({__proto__:null,getOperation:function(){return O.PNSignalOperation},validateParams:function(e,t){var e=e.config,r=t.message;return t.channel?r?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var e=e.config,r=t.channel,t=JSON.stringify(t.message);return"/signal/".concat(e.publishKey,"/").concat(e.subscribeKey,"/0/").concat(m.encodeString(r),"/0/").concat(m.encodeString(t))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}}),Ur=Object.freeze({__proto__:null,getOperation:function(){return O.PNHistoryOperation},validateParams:function(e,t){t=t.channel,e=e.config;return t?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){t=t.channel,e=e.config;return"/v2/history/sub-key/".concat(e.subscribeKey,"/channel/").concat(m.encodeString(t))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.start,n=t.end,o=t.reverse,i=t.count,s=t.stringifiedTimeToken,s=void 0!==s&&s,t=t.includeMeta,t=void 0!==t&&t,a={include_token:"true"};return a.count=void 0===i?100:i,r&&(a.start=r),n&&(a.end=n),s&&(a.string_message_token="true"),null!=o&&(a.reverse=o.toString()),t&&(a.include_meta="true"),a},handleResponse:function(n,e){var o={messages:[],startTimeToken:e[1],endTimeToken:e[2]};return Array.isArray(e[0])&&e[0].forEach(function(e){var t=((e,t)=>{var r={};if(e.cryptoModule)try{var n=e.cryptoModule.decrypt(t),o=n instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(n)):n;r.payload=o}catch(n){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",n.message),r.payload=t,r.error="Error while decrypting message content: ".concat(n.message)}else r.payload=t;return r})(n,e.message),r={timetoken:e.timetoken,entry:t.payload};e.meta&&(r.meta=e.meta),t.error&&(r.error=t.error),o.messages.push(r)}),o}}),kr=Object.freeze({__proto__:null,getOperation:function(){return O.PNDeleteMessagesOperation},validateParams:function(e,t){t=t.channel,e=e.config;return t?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){t=t.channel,e=e.config;return"/v3/history/sub-key/".concat(e.subscribeKey,"/channel/").concat(m.encodeString(t))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.start,t=t.end,n={};return r&&(n.start=r),t&&(n.end=t),n},handleResponse:function(e,t){return t.payload}}),jr=Object.freeze({__proto__:null,getOperation:function(){return O.PNMessageCounts},validateParams:function(e,t){var r=t.channels,n=t.channelTimetokens,e=e.config;return r?t.timetoken&&n?"timetoken and channelTimetokens are incompatible together":n&&1<n.length&&r.length!==n.length?"Length of channelTimetokens and channels do not match":e.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){t=t.channels,e=e.config,t=t.join(",");return"/v3/history/sub-key/".concat(e.subscribeKey,"/message-counts/").concat(m.encodeString(t))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r,n=t.timetoken,t=t.channelTimetokens,o={};return t&&1===t.length?(r=A(t,1)[0],o.timetoken=r):t?o.channelsTimetoken=t.join(","):n&&(o.timetoken=n),o},handleResponse:function(e,t){return{channels:t.channels}}}),Cr=Object.freeze({__proto__:null,getOperation:function(){return O.PNFetchMessagesOperation},validateParams:function(e,t){var r=t.channels,t=t.includeMessageActions,e=e.config;if(!r||0===r.length)return"Missing channels";if(!e.subscribeKey)return"Missing Subscribe Key";if(void 0!==t&&t&&1<r.length)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var r=t.channels,r=void 0===r?[]:r,t=t.includeMessageActions,e=e.config,t=void 0!==t&&t?"history-with-actions":"history",r=0<r.length?r.join(","):",";return"/v3/".concat(t,"/sub-key/").concat(e.subscribeKey,"/channel/").concat(m.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channels,n=t.start,o=t.end,i=t.stringifiedTimeToken,i=void 0!==i&&i,s=t.includeMeta,s=void 0!==s&&s,a=t.includeUuid,c=t.includeUUID,c=void 0===c||c,u=t.includeMessageType,u=void 0===u||u,d={};return d.max=t.count||(1<r.length||!0===t.includeMessageActions?25:100),n&&(d.start=n),o&&(d.end=o),i&&(d.string_message_token="true"),s&&(d.include_meta="true"),c&&!1!==a&&(d.include_uuid="true"),u&&(d.include_message_type="true"),d},handleResponse:function(o,e){var i={channels:{}};return Object.keys(e.channels||{}).forEach(function(n){i.channels[n]=[],(e.channels[n]||[]).forEach(function(e){var t={},r=((e,t)=>{var r={};if(e.cryptoModule)try{var n=e.cryptoModule.decrypt(t),o=n instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(n)):n;r.payload=o}catch(n){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",n.message),r.payload=t,r.error="Error while decrypting message content: ".concat(n.message)}else r.payload=t;return r})(o,e.message);t.channel=n,t.timetoken=e.timetoken,t.message=r.payload,t.messageType=e.message_type,t.uuid=e.uuid,e.actions&&(t.actions=e.actions,t.data=e.actions),e.meta&&(t.meta=e.meta),r.error&&(t.error=r.error),i.channels[n].push(t)})}),e.more&&(i.more=e.more),i}}),xr=Object.freeze({__proto__:null,getOperation:function(){return O.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}}),Dr=Object.freeze({__proto__:null,getOperation:function(){return O.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){e=e.config,t=t.channels,t=void 0===t?[]:t,t=0<t.length?t.join(","):",";return"/v2/subscribe/".concat(e.subscribeKey,"/").concat(m.encodeString(t),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var e=e.config,r=t.state,n=t.channelGroups,n=void 0===n?[]:n,o=t.timetoken,i=t.filterExpression,t=t.region,e={heartbeat:e.getPresenceTimeout()};return 0<n.length&&(e["channel-group"]=n.join(",")),i&&0<i.length&&(e["filter-expr"]=i),Object.keys(r).length&&(e.state=JSON.stringify(r)),o&&(e.tt=o),t&&(e.tr=t),e},handleResponse:function(e,t){var r=[],t=(t.m.forEach(function(e){var t={publishTimetoken:e.p.t,region:e.p.r},e={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};r.push(e)}),{timetoken:t.t.t,region:t.t.r});return{messages:r,metadata:t}}}),Lr={getOperation:function(){return O.PNHandshakeOperation},validateParams:function(e,t){if(!(null!=t&&t.channels||null!=t&&t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){e=e.config,t=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(e.subscribeKey,"/").concat(m.encodeString(t),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r={};return t.channelGroups&&0<t.channelGroups.length&&(r["channel-group"]=t.channelGroups.join(",")),r.tt=0,t.state&&(r.state=JSON.stringify(t.state)),t.filterExpression&&0<t.filterExpression.length&&(r["filter-expr"]=t.filterExpression),r.ee="",r},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},Nr={getOperation:function(){return O.PNReceiveMessagesOperation},validateParams:function(e,t){return null!=t&&t.channels||null!=t&&t.channelGroups?null!=t&&t.timetoken?null!=t&&t.region?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){e=e.config,t=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(e.subscribeKey,"/").concat(m.encodeString(t),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var r={};return t.channelGroups&&0<t.channelGroups.length&&(r["channel-group"]=t.channelGroups.join(",")),t.filterExpression&&0<t.filterExpression.length&&(r["filter-expr"]=t.filterExpression),r.tt=t.timetoken,r.tr=t.region,r.ee="",r},handleResponse:function(e,t){var r=[];return t.m.forEach(function(e){e={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};r.push(e)}),{messages:r,metadata:{region:t.t.r,timetoken:t.t.t}}}},p=(Yr.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},Yr.prototype.notify=function(t){function e(){r.listeners.forEach(function(e){e(t)})}var r=this;this.sync?e():setTimeout(e,0)},Yr),o=(qr.prototype.transition=function(e,t){var r;return!this.transitionMap.has(t.type)||null==(r=this.transitionMap.get(t.type))?void 0:r(e,t)},qr.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},qr.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},qr.prototype.onEnter=function(e){return this.enterEffects.push(e),this},qr.prototype.onExit=function(e){return this.exitEffects.push(e),this},qr),Hr=(D(Fr,Pr=p),Fr.prototype.describe=function(e){return new o(e)},Fr.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},Fr.prototype.transition=function(e){var t,r,n,o;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var i=this.currentState.transition(this.currentContext,e);if(i){var i=A(i,3),s=i[0],a=i[1],i=i[2];try{for(var c=N(this.currentState.exitEffects),u=c.next();!u.done;u=c.next()){var d=u.value;this.notify({type:"invocationDispatched",invocation:d(this.currentContext)})}}catch(e){p={error:e}}finally{try{u&&!u.done&&(l=c.return)&&l.call(c)}finally{if(p)throw p.error}}var l=this.currentState,p=(this.currentState=s,this.currentContext);this.currentContext=a,this.notify({type:"transitionDone",fromState:l,fromContext:p,toState:s,toContext:a,event:e});try{for(var f=N(i),h=f.next();!h.done;h=f.next())d=h.value,this.notify({type:"invocationDispatched",invocation:d})}catch(e){t={error:e}}finally{try{h&&!h.done&&(r=f.return)&&r.call(f)}finally{if(t)throw t.error}}try{for(var g=N(this.currentState.enterEffects),y=g.next();!y.done;y=g.next())d=y.value,this.notify({type:"invocationDispatched",invocation:d(this.currentContext)})}catch(e){n={error:e}}finally{try{y&&!y.done&&(o=g.return)&&o.call(g)}finally{if(n)throw n.error}}}},Fr),t=(Mr.prototype.on=function(e,t){this.handlers.set(e,t)},Mr.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));t=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,t),t.start()}else this.instances.has(e.payload)&&(null!=(t=this.instances.get(e.payload))&&t.cancel(),this.instances.delete(e.payload))},Mr.prototype.dispose=function(){var e,t;try{for(var r=N(this.instances.entries()),n=r.next();!n.done;n=r.next()){var o=A(n.value,2),i=o[0];o[1].cancel(),this.instances.delete(i)}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},Mr);function Mr(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}function Fr(){return null!==Pr&&Pr.apply(this,arguments)||this}function qr(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}function Yr(e){this.sync=e=void 0===e?!1:e,this.listeners=new Set}function i(r,n){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return{type:r,payload:null==n?void 0:n.apply(void 0,b([],A(e),!1))}}return e.type=r,e}function Kr(r,n){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return{type:r,payload:n.apply(void 0,b([],A(e),!1)),managed:!1}}return e.type=r,e}function zr(r,n){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return{type:r,payload:n.apply(void 0,b([],A(e),!1)),managed:!0}}return e.type=r,e.cancel={type:"CANCEL",payload:r,managed:!1},e}function Gr(r){return function(e,t){return new Qr(e,t,r)}}D(En,Wr=Error);var Xr,Br,Vr,Wr,Jr=En,$r=(D(Tn,Vr=p),Object.defineProperty(Tn.prototype,"aborted",{get:function(){return this._aborted},enumerable:!1,configurable:!0}),Tn.prototype.throwIfAborted=function(){if(this._aborted)throw new Jr},Tn.prototype.abort=function(){this._aborted=!0,this.notify(new Jr)},Tn),Qr=(D(In,Br=function(e,t){this.payload=e,this.dependencies=t}),In.prototype.start=function(){this.asyncFunction(this.payload,this.abortSignal,this.dependencies).catch(function(e){})},In.prototype.cancel=function(){this.abortSignal.abort()},In),Zr=zr("HANDSHAKE",function(e,t){return{channels:e,groups:t}}),en=zr("RECEIVE_MESSAGES",function(e,t,r){return{channels:e,groups:t,cursor:r}}),tn=Kr("EMIT_MESSAGES",function(e){return e}),rn=Kr("EMIT_STATUS",function(e){return e}),nn=zr("RECEIVE_RECONNECT",function(e){return e}),on=zr("HANDSHAKE_RECONNECT",function(e){return e}),sn=i("SUBSCRIPTION_CHANGED",function(e,t){return{channels:e,groups:t}}),an=i("SUBSCRIPTION_RESTORED",function(e,t,r,n){return{channels:e,groups:t,cursor:{timetoken:r,region:null!=n?n:0}}}),cn=i("HANDSHAKE_SUCCESS",function(e){return e}),un=i("HANDSHAKE_FAILURE",function(e){return e}),dn=i("HANDSHAKE_RECONNECT_SUCCESS",function(e){return{cursor:e}}),ln=i("HANDSHAKE_RECONNECT_FAILURE",function(e){return e}),pn=i("HANDSHAKE_RECONNECT_GIVEUP",function(e){return e}),fn=i("RECEIVE_SUCCESS",function(e,t){return{cursor:e,events:t}}),hn=i("RECEIVE_FAILURE",function(e){return e}),gn=i("RECEIVE_RECONNECT_SUCCESS",function(e,t){return{cursor:e,events:t}}),yn=i("RECEIVE_RECONNECT_FAILURE",function(e){return e}),mn=i("RECEIVING_RECONNECT_GIVEUP",function(e){return e}),Rn=i("DISCONNECT",function(){return{}}),_n=i("RECONNECT",function(e,t){return{cursor:{timetoken:null!=e?e:"",region:null!=t?t:0}}}),f=i("UNSUBSCRIBE_ALL",function(){return{}}),An=(D(vn,Xr=t),vn),bn=new o("HANDSHAKE_FAILED");function vn(c,e){var u=Xr.call(this,e)||this;return u.on(Zr.type,Gr(function(r,n,e){var o=e.handshake,i=e.presenceState,s=e.config;return _(u,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:n.throwIfAborted(),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,o(R({abortSignal:n,channels:r.channels,channelGroups:r.groups,filterExpression:s.filterExpression},s.maintainPresenceState&&{state:i}))];case 2:return t=e.sent(),[2,c.transition(cn(t))];case 3:return(t=e.sent())instanceof Error&&"Aborted"===t.message?[2]:t instanceof q?[2,c.transition(un(t))]:[3,4];case 4:return[2]}})})})),u.on(en.type,Gr(function(r,n,e){var o=e.receiveMessages,i=e.config;return _(u,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:n.throwIfAborted(),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,o({abortSignal:n,channels:r.channels,channelGroups:r.groups,timetoken:r.cursor.timetoken,region:r.cursor.region,filterExpression:i.filterExpression})];case 2:return t=e.sent(),c.transition(fn(t.metadata,t.messages)),[3,4];case 3:return(t=e.sent())instanceof Error&&"Aborted"===t.message?[2]:t instanceof q&&!n.aborted?[2,c.transition(hn(t))]:[3,4];case 4:return[2]}})})})),u.on(tn.type,Gr(function(t,e,r){var n=r.emitMessages;return _(u,void 0,void 0,function(){return F(this,function(e){return 0<t.length&&n(t),[2]})})})),u.on(rn.type,Gr(function(t,e,r){var n=r.emitStatus;return _(u,void 0,void 0,function(){return F(this,function(e){return n(t),[2]})})})),u.on(nn.type,Gr(function(r,n,e){var o=e.receiveMessages,i=e.delay,s=e.config;return _(u,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:return s.retryConfiguration&&s.retryConfiguration.shouldRetry(r.reason,r.attempts)?(n.throwIfAborted(),[4,i(s.retryConfiguration.getDelay(r.attempts,r.reason))]):[3,6];case 1:e.sent(),n.throwIfAborted(),e.label=2;case 2:return e.trys.push([2,4,,5]),[4,o({abortSignal:n,channels:r.channels,channelGroups:r.groups,timetoken:r.cursor.timetoken,region:r.cursor.region,filterExpression:s.filterExpression})];case 3:return t=e.sent(),[2,c.transition(gn(t.metadata,t.messages))];case 4:return(t=e.sent())instanceof Error&&"Aborted"===t.message?[2]:t instanceof q?[2,c.transition(yn(t))]:[3,5];case 5:return[3,7];case 6:return[2,c.transition(mn(new q(s.retryConfiguration.getGiveupReason(r.reason,r.attempts))))];case 7:return[2]}})})})),u.on(on.type,Gr(function(r,n,e){var o=e.handshake,i=e.delay,s=e.presenceState,a=e.config;return _(u,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:return a.retryConfiguration&&a.retryConfiguration.shouldRetry(r.reason,r.attempts)?(n.throwIfAborted(),[4,i(a.retryConfiguration.getDelay(r.attempts,r.reason))]):[3,6];case 1:e.sent(),n.throwIfAborted(),e.label=2;case 2:return e.trys.push([2,4,,5]),[4,o(R({abortSignal:n,channels:r.channels,channelGroups:r.groups,filterExpression:a.filterExpression},a.maintainPresenceState&&{state:s}))];case 3:return t=e.sent(),[2,c.transition(dn(t))];case 4:return(t=e.sent())instanceof Error&&"Aborted"===t.message?[2]:t instanceof q?[2,c.transition(ln(t))]:[3,5];case 5:return[3,7];case 6:return[2,c.transition(pn(new q(a.retryConfiguration.getGiveupReason(r.reason,r.attempts))))];case 7:return[2]}})})})),u}function In(e,t,r){e=Br.call(this,e,t)||this;return e.asyncFunction=r,e.abortSignal=new $r,e}function Tn(){var e=null!==Vr&&Vr.apply(this,arguments)||this;return e._aborted=!1,e}function En(){var e=this.constructor,t=Wr.call(this,"The operation was aborted.")||this;return t.name="AbortError",Object.setPrototypeOf(t,e.prototype),t}bn.on(sn.type,function(e,t){return a.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})}),bn.on(_n.type,function(e,t){return a.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor||e.cursor})}),bn.on(an.type,function(e,t){return a.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||(null!=(e=null==(t=null==e?void 0:e.cursor)?void 0:t.region)?e:0)}})}),bn.on(f.type,function(e){return jn.with()});var Sn,Pn=new o("HANDSHAKE_STOPPED"),On=(Pn.on(sn.type,function(e,t){return Pn.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})}),Pn.on(_n.type,function(e,t){return a.with(R(R({},e),{cursor:t.payload.cursor||e.cursor}))}),Pn.on(an.type,function(e,t){return Pn.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||(null==(t=null==e?void 0:e.cursor)?void 0:t.region)||0}})}),Pn.on(f.type,function(e){return jn.with()}),new o("RECEIVE_FAILED")),wn=(On.on(_n.type,function(e,t){var r;return a.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null==(r=t.payload.cursor)?void 0:r.timetoken:e.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})}),On.on(sn.type,function(e,t){return a.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})}),On.on(an.type,function(e,t){return a.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})}),On.on(f.type,function(e){return jn.with(void 0)}),new o("RECEIVE_STOPPED")),Un=(wn.on(sn.type,function(e,t){return wn.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})}),wn.on(an.type,function(e,t){return wn.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})}),wn.on(_n.type,function(e,t){var r;return a.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null==(r=t.payload.cursor)?void 0:r.timetoken:e.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})}),wn.on(f.type,function(){return jn.with(void 0)}),new o("RECEIVE_RECONNECTING")),s=(Un.onEnter(function(e){return nn(e)}),Un.onExit(function(){return nn.cancel}),Un.on(gn.type,function(e,t){return s.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[tn(t.payload.events)])}),Un.on(yn.type,function(e,t){return Un.with(R(R({},e),{attempts:e.attempts+1,reason:t.payload}))}),Un.on(mn.type,function(e,t){return On.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[rn({category:v.PNDisconnectedUnexpectedlyCategory,error:null==(e=t.payload)?void 0:e.message})])}),Un.on(Rn.type,function(e){return wn.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[rn({category:v.PNDisconnectedCategory})])}),Un.on(an.type,function(e,t){return s.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})}),Un.on(sn.type,function(e,t){return s.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})}),Un.on(f.type,function(e){return jn.with(void 0,[rn({category:v.PNDisconnectedCategory})])}),new o("RECEIVING")),kn=(s.onEnter(function(e){return en(e.channels,e.groups,e.cursor)}),s.onExit(function(){return en.cancel}),s.on(fn.type,function(e,t){return s.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[tn(t.payload.events)])}),s.on(sn.type,function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?jn.with(void 0):s.with({cursor:e.cursor,channels:t.payload.channels,groups:t.payload.groups})}),s.on(an.type,function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?jn.with(void 0):s.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})}),s.on(hn.type,function(e,t){return Un.with(R(R({},e),{attempts:0,reason:t.payload}))}),s.on(Rn.type,function(e){return wn.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[rn({category:v.PNDisconnectedCategory})])}),s.on(f.type,function(e){return jn.with(void 0,[rn({category:v.PNDisconnectedCategory})])}),new o("HANDSHAKE_RECONNECTING")),a=(kn.onEnter(function(e){return on(e)}),kn.onExit(function(){return on.cancel}),kn.on(dn.type,function(e,t){var r={timetoken:null!=(r=e.cursor)&&r.timetoken?null==(r=e.cursor)?void 0:r.timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region};return s.with({channels:e.channels,groups:e.groups,cursor:r},[rn({category:v.PNConnectedCategory})])}),kn.on(ln.type,function(e,t){return kn.with(R(R({},e),{attempts:e.attempts+1,reason:t.payload}))}),kn.on(pn.type,function(e,t){return bn.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[rn({category:v.PNConnectionErrorCategory,error:null==(e=t.payload)?void 0:e.message})])}),kn.on(Rn.type,function(e){return Pn.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}),kn.on(sn.type,function(e,t){return a.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})}),kn.on(an.type,function(e,t){return a.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:(null==(t=t.payload.cursor)?void 0:t.region)||(null==(t=null==e?void 0:e.cursor)?void 0:t.region)||0}})}),kn.on(f.type,function(e){return jn.with(void 0)}),new o("HANDSHAKING")),jn=(a.onEnter(function(e){return Zr(e.channels,e.groups)}),a.onExit(function(){return Zr.cancel}),a.on(sn.type,function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?jn.with(void 0):a.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})}),a.on(cn.type,function(e,t){var r;return s.with({channels:e.channels,groups:e.groups,cursor:{timetoken:null!=(r=null==e?void 0:e.cursor)&&r.timetoken?null==(r=null==e?void 0:e.cursor)?void 0:r.timetoken:t.payload.timetoken,region:t.payload.region}},[rn({category:v.PNConnectedCategory})])}),a.on(un.type,function(e,t){return kn.with({channels:e.channels,groups:e.groups,cursor:e.cursor,attempts:0,reason:t.payload})}),a.on(Rn.type,function(e){return Pn.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}),a.on(an.type,function(e,t){return a.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||(null==(t=null==e?void 0:e.cursor)?void 0:t.region)||0}})}),a.on(f.type,function(e){return jn.with()}),new o("UNSUBSCRIBED")),Cn=(jn.on(sn.type,function(e,t){return a.with({channels:t.payload.channels,groups:t.payload.groups})}),jn.on(an.type,function(e,t){return a.with({channels:t.payload.channels,groups:t.payload.groups,cursor:t.payload.cursor})}),Object.defineProperty(Wn.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),Wn.prototype.subscribe=function(e){var t=this,r=e.channels,n=e.channelGroups,o=e.timetoken,e=e.withPresence;this.channels=b(b([],A(this.channels),!1),A(null!=r?r:[]),!1),this.groups=b(b([],A(this.groups),!1),A(null!=n?n:[]),!1),e&&(this.channels.map(function(e){return t.channels.push("".concat(e,"-pnpres"))}),this.groups.map(function(e){return t.groups.push("".concat(e,"-pnpres"))})),o?this.engine.transition(an(this.channels,this.groups,o)):this.engine.transition(sn(this.channels,this.groups)),this.dependencies.join&&this.dependencies.join({channels:this.channels.filter(function(e){return!e.endsWith("-pnpres")}),groups:this.groups.filter(function(e){return!e.endsWith("-pnpres")})})},Wn.prototype.unsubscribe=function(e){var t=this,r=e.channels,e=e.groups,n=null==r?void 0:r.slice(0),o=(null!=r&&r.map(function(e){return n.push("".concat(e,"-pnpres"))}),this.channels=this.channels.filter(function(e){return!(null!=n&&n.includes(e))}),null==e?void 0:e.slice(0));null!=e&&e.map(function(e){return o.push("".concat(e,"-pnpres"))}),this.groups=this.groups.filter(function(e){return!(null!=o&&o.includes(e))}),this.dependencies.presenceState&&(null!=r&&r.forEach(function(e){return delete t.dependencies.presenceState[e]}),null!=e)&&e.forEach(function(e){return delete t.dependencies.presenceState[e]}),this.engine.transition(sn(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leave&&this.dependencies.leave({channels:r,groups:e})},Wn.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.dependencies.presenceState&&(this.dependencies.presenceState={}),this.engine.transition(sn(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leaveAll&&this.dependencies.leaveAll()},Wn.prototype.reconnect=function(e){var t=e.timetoken;this.engine.transition(_n(t,e.region))},Wn.prototype.disconnect=function(){this.engine.transition(Rn()),this.dependencies.leaveAll&&this.dependencies.leaveAll()},Wn.prototype.getSubscribedChannels=function(){return this.channels.slice(0)},Wn.prototype.getSubscribedChannelGroups=function(){return this.groups.slice(0)},Wn.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},Wn),h=i("RECONNECT",function(){return{}}),p=i("DISCONNECT",function(){return{}}),xn=i("JOINED",function(e,t){return{channels:e,groups:t}}),Dn=i("LEFT",function(e,t){return{channels:e,groups:t}}),Ln=i("LEFT_ALL",function(){return{}}),Nn=i("HEARTBEAT_SUCCESS",function(e){return{statusCode:e}}),Hn=i("HEARTBEAT_FAILURE",function(e){return e}),Mn=i("HEARTBEAT_GIVEUP",function(){return{}}),Fn=i("TIMES_UP",function(){return{}}),qn=Kr("HEARTBEAT",function(e,t){return{channels:e,groups:t}}),Yn=Kr("LEAVE",function(e,t){return{channels:e,groups:t}}),Kn=Kr("EMIT_STATUS",function(e){return e}),zn=zr("WAIT",function(){return{}}),Gn=zr("DELAYED_HEARTBEAT",function(e){return e}),Xn=(D(Vn,Sn=t),Vn),Bn=new o("HEARTBEAT_STOPPED");function Vn(c,e){var u=Sn.call(this,e)||this;return u.on(qn.type,Gr(function(r,e,t){var n=t.heartbeat,o=t.presenceState,i=t.config;return _(u,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,n(R({channels:r.channels,channelGroups:r.groups},i.maintainPresenceState&&{state:o}))];case 1:return e.sent(),c.transition(Nn(200)),[3,3];case 2:return(t=e.sent())instanceof q?[2,c.transition(Hn(t))]:[3,3];case 3:return[2]}})})})),u.on(Yn.type,Gr(function(t,e,r){var n=r.leave,o=r.config;return _(u,void 0,void 0,function(){return F(this,function(e){switch(e.label){case 0:if(o.suppressLeaveEvents)return[3,4];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,n({channels:t.channels,channelGroups:t.groups})];case 2:case 3:return e.sent(),[3,4];case 4:return[2]}})})})),u.on(zn.type,Gr(function(e,t,r){var n=r.heartbeatDelay;return _(u,void 0,void 0,function(){return F(this,function(e){switch(e.label){case 0:return t.throwIfAborted(),[4,n()];case 1:return e.sent(),t.throwIfAborted(),[2,c.transition(Fn())]}})})})),u.on(Gn.type,Gr(function(r,n,e){var o=e.heartbeat,i=e.retryDelay,s=e.presenceState,a=e.config;return _(u,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:return a.retryConfiguration&&a.retryConfiguration.shouldRetry(r.reason,r.attempts)?(n.throwIfAborted(),[4,i(a.retryConfiguration.getDelay(r.attempts,r.reason))]):[3,6];case 1:e.sent(),n.throwIfAborted(),e.label=2;case 2:return e.trys.push([2,4,,5]),[4,o(R({channels:r.channels,channelGroups:r.groups},a.maintainPresenceState&&{state:s}))];case 3:return e.sent(),[2,c.transition(Nn(200))];case 4:return(t=e.sent())instanceof Error&&"Aborted"===t.message?[2]:t instanceof q?[2,c.transition(Hn(t))]:[3,5];case 5:return[3,7];case 6:return[2,c.transition(Mn())];case 7:return[2]}})})})),u.on(Kn.type,Gr(function(r,e,t){var n=t.emitStatus,o=t.config;return _(u,void 0,void 0,function(){var t;return F(this,function(e){return o.announceFailedHeartbeats&&!0===(null==(t=null==r?void 0:r.status)?void 0:t.error)?n(r.status):o.announceSuccessfulHeartbeats&&200===r.statusCode&&n(R(R({},r),{operation:O.PNHeartbeatOperation,error:!1})),[2]})})})),u}function Wn(e){var t=this;this.engine=new Hr,this.channels=[],this.groups=[],this.dependencies=e,this.dispatcher=new An(this.engine,e),this._unsubscribeEngine=this.engine.subscribe(function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)}),this.engine.start(jn,void 0)}Bn.on(xn.type,function(e,t){return Bn.with({channels:b(b([],A(e.channels),!1),A(t.payload.channels),!1),groups:b(b([],A(e.groups),!1),A(t.payload.groups),!1)})}),Bn.on(Dn.type,function(e,t){return Bn.with({channels:e.channels.filter(function(e){return!t.payload.channels.includes(e)}),groups:e.groups.filter(function(e){return!t.payload.groups.includes(e)})})}),Bn.on(h.type,function(e,t){return u.with({channels:e.channels,groups:e.groups})}),Bn.on(Ln.type,function(e,t){return Zn.with(void 0)});var Jn=new o("HEARTBEAT_COOLDOWN"),$n=(Jn.onEnter(function(){return zn()}),Jn.onExit(function(){return zn.cancel}),Jn.on(Fn.type,function(e,t){return u.with({channels:e.channels,groups:e.groups})}),Jn.on(xn.type,function(e,t){return u.with({channels:b(b([],A(e.channels),!1),A(t.payload.channels),!1),groups:b(b([],A(e.groups),!1),A(t.payload.groups),!1)})}),Jn.on(Dn.type,function(e,t){return u.with({channels:e.channels.filter(function(e){return!t.payload.channels.includes(e)}),groups:e.groups.filter(function(e){return!t.payload.groups.includes(e)})},[Yn(t.payload.channels,t.payload.groups)])}),Jn.on(p.type,function(e){return Bn.with({channels:e.channels,groups:e.groups},[Yn(e.channels,e.groups)])}),Jn.on(Ln.type,function(e,t){return Zn.with(void 0,[Yn(e.channels,e.groups)])}),new o("HEARTBEAT_FAILED")),Qn=($n.on(xn.type,function(e,t){return u.with({channels:b(b([],A(e.channels),!1),A(t.payload.channels),!1),groups:b(b([],A(e.groups),!1),A(t.payload.groups),!1)})}),$n.on(Dn.type,function(e,t){return u.with({channels:e.channels.filter(function(e){return!t.payload.channels.includes(e)}),groups:e.groups.filter(function(e){return!t.payload.groups.includes(e)})},[Yn(t.payload.channels,t.payload.groups)])}),$n.on(h.type,function(e,t){return u.with({channels:e.channels,groups:e.groups})}),$n.on(p.type,function(e,t){return Bn.with({channels:e.channels,groups:e.groups},[Yn(e.channels,e.groups)])}),$n.on(Ln.type,function(e,t){return Zn.with(void 0,[Yn(e.channels,e.groups)])}),new o("HEARBEAT_RECONNECTING")),u=(Qn.onEnter(function(e){return Gn(e)}),Qn.onExit(function(){return Gn.cancel}),Qn.on(xn.type,function(e,t){return u.with({channels:b(b([],A(e.channels),!1),A(t.payload.channels),!1),groups:b(b([],A(e.groups),!1),A(t.payload.groups),!1)})}),Qn.on(Dn.type,function(e,t){return u.with({channels:e.channels.filter(function(e){return!t.payload.channels.includes(e)}),groups:e.groups.filter(function(e){return!t.payload.groups.includes(e)})},[Yn(t.payload.channels,t.payload.groups)])}),Qn.on(p.type,function(e,t){Bn.with({channels:e.channels,groups:e.groups},[Yn(e.channels,e.groups)])}),Qn.on(Nn.type,function(e,t){return Jn.with({channels:e.channels,groups:e.groups})}),Qn.on(Hn.type,function(e,t){return Qn.with(R(R({},e),{attempts:e.attempts+1,reason:t.payload}))}),Qn.on(Mn.type,function(e,t){return $n.with({channels:e.channels,groups:e.groups})}),Qn.on(Ln.type,function(e,t){return Zn.with(void 0,[Yn(e.channels,e.groups)])}),new o("HEARTBEATING")),Zn=(u.onEnter(function(e){return qn(e.channels,e.groups)}),u.on(Nn.type,function(e,t){return Jn.with({channels:e.channels,groups:e.groups})}),u.on(xn.type,function(e,t){return u.with({channels:b(b([],A(e.channels),!1),A(t.payload.channels),!1),groups:b(b([],A(e.groups),!1),A(t.payload.groups),!1)})}),u.on(Dn.type,function(e,t){return u.with({channels:e.channels.filter(function(e){return!t.payload.channels.includes(e)}),groups:e.groups.filter(function(e){return!t.payload.groups.includes(e)})},[Yn(t.payload.channels,t.payload.groups)])}),u.on(Hn.type,function(e,t){return Qn.with(R(R({},e),{attempts:0,reason:t.payload}))}),u.on(p.type,function(e){return Bn.with({channels:e.channels,groups:e.groups},[Yn(e.channels,e.groups)])}),u.on(Ln.type,function(e,t){return Zn.with(void 0,[Yn(e.channels,e.groups)])}),new o("HEARTBEAT_INACTIVE")),eo=(Zn.on(xn.type,function(e,t){return u.with({channels:t.payload.channels,groups:t.payload.groups})}),Object.defineProperty(ao.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),ao.prototype.join=function(e){var t=e.channels,e=e.groups;this.channels=b(b([],A(this.channels),!1),A(null!=t?t:[]),!1),this.groups=b(b([],A(this.groups),!1),A(null!=e?e:[]),!1),this.engine.transition(xn(this.channels.slice(0),this.groups.slice(0)))},ao.prototype.leave=function(e){var t=this,r=e.channels,e=e.groups;this.dependencies.presenceState&&(null!=r&&r.forEach(function(e){return delete t.dependencies.presenceState[e]}),null!=e)&&e.forEach(function(e){return delete t.dependencies.presenceState[e]}),this.engine.transition(Dn(null!=r?r:[],null!=e?e:[]))},ao.prototype.leaveAll=function(){this.engine.transition(Ln())},ao.prototype.dispose=function(){this._unsubscribeEngine(),this.dispatcher.dispose()},ao),f=(so.LinearRetryPolicy=function(e){return{delay:e.delay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){return 403!==(null==(e=null==e?void 0:e.status)?void 0:e.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){return 1e3*((null!=(t=t.retryAfter)?t:this.delay)+Math.random())},getGiveupReason:function(e,t){return this.maximumRetry<=t?"retry attempts exhaused.":403===(null==(t=null==e?void 0:e.status)?void 0:t.statusCode)?"forbidden operation.":"unknown error"}}},so.ExponentialRetryPolicy=function(e){return{minimumDelay:e.minimumDelay,maximumDelay:e.maximumDelay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){return 403!==(null==(e=null==e?void 0:e.status)?void 0:e.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){return 1e3*((null!=(t=t.retryAfter)?t:Math.min(Math.pow(2,e),this.maximumDelay))+Math.random())},getGiveupReason:function(e,t){return this.maximumRetry<=t?"retry attempts exhaused.":403===(null==(t=null==e?void 0:e.status)?void 0:t.statusCode)?"forbidden operation.":"unknown error"}}},so),to=(io.prototype.emitEvent=function(e){var t,r,n,o=e.channel,i=e.publishMetaData,s=e.subscriptionMatch;if(o===s&&(s=null),e.channel.endsWith("-pnpres")){var a={channel:null,subscription:null};o&&(a.channel=o.substring(0,o.lastIndexOf("-pnpres"))),s&&(a.subscription=s.substring(0,s.lastIndexOf("-pnpres"))),a.action=e.payload.action,a.state=e.payload.data,a.timetoken=i.publishTimetoken,a.occupancy=e.payload.occupancy,a.uuid=e.payload.uuid,a.timestamp=e.payload.timestamp,e.payload.join&&(a.join=e.payload.join),e.payload.leave&&(a.leave=e.payload.leave),e.payload.timeout&&(a.timeout=e.payload.timeout),this.listenerManager.announcePresence(a)}else if(1===e.messageType)(a={channel:null,subscription:null}).channel=o,a.subscription=s,a.timetoken=i.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=e.payload,this.listenerManager.announceSignal(a);else if(2===e.messageType)(a={channel:null,subscription:null}).channel=o,a.subscription=s,a.timetoken=i.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},this.listenerManager.announceObjects(a),"uuid"===e.payload.type?(t=this._renameChannelField(a),this.listenerManager.announceUser(R(R({},t),{message:R(R({},t.message),{event:this._renameEvent(t.message.event),type:"user"})}))):"channel"===message.payload.type?(t=this._renameChannelField(a),this.listenerManager.announceSpace(R(R({},t),{message:R(R({},t.message),{event:this._renameEvent(t.message.event),type:"space"})}))):"membership"===message.payload.type&&(c=(n=(t=this._renameChannelField(a)).message.data).uuid,r=n.channel,(n=L(n,["uuid","channel"])).user=c,n.space=r,this.listenerManager.announceMembership(R(R({},t),{message:R(R({},t.message),{event:this._renameEvent(t.message.event),data:n})})));else if(3===e.messageType)(a={}).channel=o,a.subscription=s,a.timetoken=i.publishTimetoken,a.publisher=e.issuingClientId,a.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},a.event=e.payload.event,this.listenerManager.announceMessageAction(a);else if(4===e.messageType){(a={}).channel=o,a.subscription=s,a.timetoken=i.publishTimetoken,a.publisher=e.issuingClientId;var c=e.payload;if(this.modules.cryptoModule){var u=void 0;try{u=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){u=null,a.error="Error while decrypting message content: ".concat(e.message)}null!==u&&(c=u)}e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=c.message,a.file={id:c.file.id,name:c.file.name,url:this.getFileUrl({id:c.file.id,name:c.file.name,channel:o})},this.listenerManager.announceFile(a)}else{if((a={channel:null,subscription:null}).channel=o,a.subscription=s,a.timetoken=i.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),this.modules.cryptoModule){u=void 0;try{var d,u=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){u=null,a.error="Error while decrypting message content: ".concat(e.message)}a.message=null!=u?u:e.payload}else a.message=e.payload;this.listenerManager.announceMessage(a)}},io.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},io.prototype._renameChannelField=function(e){var t=e.channel,e=L(e,["channel"]);return e.spaceId=t,e},io),t=(oo.prototype.getVersion=function(){return this._config.getVersion()},oo.prototype._addPnsdkSuffix=function(e,t){this._config._addPnsdkSuffix(e,t)},oo.prototype.networkDownDetected=function(){this._listenerManager.announceNetworkDown(),this._config.restore?this.disconnect():this.destroy(!0)},oo.prototype.networkUpDetected=function(){this._listenerManager.announceNetworkUp(),this.reconnect()},oo.notificationPayload=function(e,t){return new It(e,t)},oo.generateUUID=function(){return J()},oo.OPERATIONS=O,oo.CATEGORIES=v,oo.LinearRetryPolicy=f.LinearRetryPolicy,oo.ExponentialRetryPolicy=f.ExponentialRetryPolicy,oo),ro=(no.prototype.init=function(e){this._config=e,Array.isArray(this._config.origin)?this._currentSubDomain=Math.floor(Math.random()*this._config.origin.length):this._currentSubDomain=0,this._coreParams={},this.shiftStandardOrigin()},no.prototype.nextOrigin=function(){var e=this._config.secure?"https://":"http://";if("string"==typeof this._config.origin)return"".concat(e).concat(this._config.origin);this._currentSubDomain+=1,this._currentSubDomain>=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},no.prototype.hasModule=function(e){return e in this._modules},no.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},no.prototype.getStandardOrigin=function(){return this._standardOrigin},no.prototype.POSTFILE=function(e,t,r){return this._modules.postfile(e,t,r)},no.prototype.GETFILE=function(e,t,r){return this._modules.getfile(e,t,r)},no.prototype.POST=function(e,t,r,n){return this._modules.post(e,t,r,n)},no.prototype.PATCH=function(e,t,r,n){return this._modules.patch(e,t,r,n)},no.prototype.GET=function(e,t,r){return this._modules.get(e,t,r)},no.prototype.DELETE=function(e,t,r){return this._modules.del(e,t,r)},no.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return v.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return v.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return v.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return v.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return v.PNNetworkIssuesCategory;if(e.timeout)return v.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return v.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return v.PNBadRequestCategory;if(e.response.forbidden)return v.PNAccessDeniedCategory}return v.PNUnknownCategory},no);function no(t){var r=this;this._modules={},Object.keys(t).forEach(function(e){r._modules[e]=t[e].bind(r)})}function oo(t){var r,n,o,s=this,e=t.networking,i=t.cbor,a=new $({setup:t}),c=(this._config=a,new at({config:a})),u=t.cryptography,i=(e.init(a),new Et(a,i)),d=(this._tokenManager=i,new _t({maximumSamplesCount:6e4})),l=(this._telemetryManager=d,this._config.cryptoModule),p={config:a,networking:e,crypto:c,cryptography:u,tokenManager:i,telemetryManager:d,PubNubFile:t.PubNubFile,cryptoModule:l},d=(this.File=t.PubNubFile,this.encryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&p.cryptoModule?p.cryptoModule.encryptFile(t=e,this.File):u.encryptFile(e,t,this.File)},this.decryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&p.cryptoModule?p.cryptoModule.decryptFile(t=e,this.File):u.decryptFile(e,t,this.File)},w.bind(this,p,xr)),f=w.bind(this,p,Vt),h=w.bind(this,p,Jt),g=w.bind(this,p,Qt),y=w.bind(this,p,Dr),m=new Tt,a=(this._listenerManager=m,this.iAmHere=w.bind(this,p,Jt),this.iAmAway=w.bind(this,p,Vt),this.setPresenceState=w.bind(this,p,Qt),this.handshake=w.bind(this,p,Lr),this.receiveMessages=w.bind(this,p,Nr),!0===a.enableEventEngine?(this._eventEmitter=new to({modules:p,listenerManager:this._listenerManager,getFileUrl:function(e){return Ht(p,e)}}),a.maintainPresenceState&&(this.presenceState={},this.setState=function(t){var e;return null!=(e=t.channels)&&e.forEach(function(e){return s.presenceState[e]=t.state}),null!=(e=t.channelGroups)&&e.forEach(function(e){return s.presenceState[e]=t.state}),s.setPresenceState({channels:t.channels,channelGroups:t.channelGroups,state:s.presenceState})}),a.getHeartbeatInterval()&&(a=new eo({heartbeat:this.iAmHere,leave:this.iAmAway,heartbeatDelay:function(){return new Promise(function(e){return setTimeout(e,1e3*p.config.getHeartbeatInterval())})},retryDelay:function(t){return new Promise(function(e){return setTimeout(e,t)})},config:p.config,presenceState:this.presenceState,emitStatus:function(e){m.announceStatus(e)}}),this.presenceEventEngine=a,this.join=this.presenceEventEngine.join.bind(a),this.leave=this.presenceEventEngine.leave.bind(a),this.leaveAll=this.presenceEventEngine.leaveAll.bind(a)),a=new Cn({handshake:this.handshake,receiveMessages:this.receiveMessages,delay:function(t){return new Promise(function(e){return setTimeout(e,t)})},join:this.join,leave:this.leave,leaveAll:this.leaveAll,presenceState:this.presenceState,config:p.config,emitMessages:function(e){var t,r;try{for(var n=N(e),o=n.next();!o.done;o=n.next()){var i=o.value;s._eventEmitter.emitEvent(i)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}},emitStatus:function(e){m.announceStatus(e)}}),this.subscribe=a.subscribe.bind(a),this.unsubscribe=a.unsubscribe.bind(a),this.unsubscribeAll=a.unsubscribeAll.bind(a),this.reconnect=a.reconnect.bind(a),this.disconnect=a.disconnect.bind(a),this.destroy=a.dispose.bind(a),this.getSubscribedChannels=a.getSubscribedChannels.bind(a),this.getSubscribedChannelGroups=a.getSubscribedChannelGroups.bind(a),this.eventEngine=a):(r=new Rt({timeEndpoint:d,leaveEndpoint:f,heartbeatEndpoint:h,setStateEndpoint:g,subscribeEndpoint:y,crypto:p.crypto,config:p.config,listenerManager:m,getFileUrl:function(e){return Ht(p,e)},cryptoModule:p.cryptoModule}),this.subscribe=r.adaptSubscribeChange.bind(r),this.unsubscribe=r.adaptUnsubscribeChange.bind(r),this.disconnect=r.disconnect.bind(r),this.reconnect=r.reconnect.bind(r),this.unsubscribeAll=r.unsubscribeAll.bind(r),this.getSubscribedChannels=r.getSubscribedChannels.bind(r),this.getSubscribedChannelGroups=r.getSubscribedChannelGroups.bind(r),this.setState=r.adaptStateChange.bind(r),this.presence=r.adaptPresenceChange.bind(r),this.destroy=function(e){r.unsubscribeAll(e),r.disconnect()}),this.addListener=m.addListener.bind(m),this.removeListener=m.removeListener.bind(m),this.removeAllListeners=m.removeAllListeners.bind(m),this.parseToken=i.parseToken.bind(i),this.setToken=i.setToken.bind(i),this.getToken=i.getToken.bind(i),this.channelGroups={listGroups:w.bind(this,p,Yt),listChannels:w.bind(this,p,Kt),addChannels:w.bind(this,p,Mt),removeChannels:w.bind(this,p,Ft),deleteGroup:w.bind(this,p,qt)},this.push={addChannels:w.bind(this,p,zt),removeChannels:w.bind(this,p,Gt),deleteDevice:w.bind(this,p,Bt),listChannels:w.bind(this,p,Xt)},this.hereNow=w.bind(this,p,Zt),this.whereNow=w.bind(this,p,Wt),this.getState=w.bind(this,p,$t),this.grant=w.bind(this,p,br),this.grantToken=w.bind(this,p,Tr),this.audit=w.bind(this,p,Ar),this.revokeToken=w.bind(this,p,Er),this.publish=w.bind(this,p,Or),this.fire=function(e,t){return e.replicate=!1,e.storeInHistory=!1,s.publish(e,t)},this.signal=w.bind(this,p,wr),this.history=w.bind(this,p,Ur),this.deleteMessages=w.bind(this,p,kr),this.messageCounts=w.bind(this,p,jr),this.fetchMessages=w.bind(this,p,Cr),this.addMessageAction=w.bind(this,p,er),this.removeMessageAction=w.bind(this,p,tr),this.getMessageActions=w.bind(this,p,rr),this.listFiles=w.bind(this,p,nr),w.bind(this,p,or));this.publishFile=w.bind(this,p,ir),this.sendFile=(n={generateUploadUrl:a,publishFile:this.publishFile,modules:p},o=function(){var t=this,C=n.generateUploadUrl,x=n.publishFile,e=n.modules,D=e.PubNubFile,L=e.config,N=e.cryptography,H=e.cryptoModule,M=e.networking;return function(e){var S=e.channel,P=e.file,O=e.message,w=e.cipherKey,U=e.meta,k=e.ttl,j=e.storeInHistory;return _(t,void 0,void 0,function(){var t,r,n,o,i,s,a,c,u,d,l,p,f,h,g,y,m,R,_,A,b,v,I,T,E;return F(this,function(e){switch(e.label){case 0:if(!S)throw new q("Validation failed, check status for details",xt("channel can't be empty"));if(P)return t=D.create(P),[4,C({channel:S,name:t.name})];throw new q("Validation failed, check status for details",xt("file can't be empty"));case 1:return i=e.sent(),n=i.file_upload_request,r=n.url,n=n.form_fields,o=(i=i.data).id,i=i.name,D.supportsEncryptFile&&(w||H)?null!=w?[3,3]:[4,H.encryptFile(t,D)]:[3,6];case 2:return s=e.sent(),[3,5];case 3:return[4,N.encryptFile(w,t,D)];case 4:s=e.sent(),e.label=5;case 5:t=s,e.label=6;case 6:a=n,t.mimeType&&(a=n.map(function(e){return"Content-Type"===e.key?{key:e.key,value:t.mimeType}:e})),e.label=7;case 7:return e.trys.push([7,21,,22]),D.supportsFileUri&&P.uri?(d=(u=M).POSTFILE,l=[r,a],[4,t.toFileUri()]):[3,10];case 8:return[4,d.apply(u,l.concat([e.sent()]))];case 9:return c=e.sent(),[3,20];case 10:return D.supportsFile?(f=(p=M).POSTFILE,h=[r,a],[4,t.toFile()]):[3,13];case 11:return[4,f.apply(p,h.concat([e.sent()]))];case 12:return c=e.sent(),[3,20];case 13:return D.supportsBuffer?(y=(g=M).POSTFILE,m=[r,a],[4,t.toBuffer()]):[3,16];case 14:return[4,y.apply(g,m.concat([e.sent()]))];case 15:return c=e.sent(),[3,20];case 16:return D.supportsBlob?(_=(R=M).POSTFILE,A=[r,a],[4,t.toBlob()]):[3,19];case 17:return[4,_.apply(R,A.concat([e.sent()]))];case 18:return c=e.sent(),[3,20];case 19:throw new Error("Unsupported environment");case 20:return[3,22];case 21:throw(b=e.sent()).response&&"string"==typeof b.response.text?(v=b.response.text,v=/<Message>(.*)<\/Message>/gi.exec(v),new q(v?"Upload to bucket failed: ".concat(v[1]):"Upload to bucket failed.",b)):new q("Upload to bucket failed.",b);case 22:if(204!==c.status)throw new q("Upload to bucket was unsuccessful",c);I=L.fileUploadPublishRetryLimit,T=!1,E={timetoken:"0"},e.label=23;case 23:return e.trys.push([23,25,,26]),[4,x({channel:S,message:O,fileId:o,fileName:i,meta:U,storeInHistory:j,ttl:k})];case 24:return E=e.sent(),T=!0,[3,26];case 25:return e.sent(),--I,[3,26];case 26:if(!T&&0<I)return[3,23];e.label=27;case 27:if(T)return[2,{timetoken:E.timetoken,id:o,name:i}];throw new q("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:S,id:o,name:i})}})})}}(),function(e,t){e=o(e);return"function"==typeof t&&e.then(function(e){return t(null,e)}).catch(function(e){return t(e,null)}),e}),this.getFileUrl=function(e){return Ht(p,e)},this.downloadFile=w.bind(this,p,sr),this.deleteFile=w.bind(this,p,ar),this.objects={getAllUUIDMetadata:w.bind(this,p,cr),getUUIDMetadata:w.bind(this,p,ur),setUUIDMetadata:w.bind(this,p,dr),removeUUIDMetadata:w.bind(this,p,lr),getAllChannelMetadata:w.bind(this,p,pr),getChannelMetadata:w.bind(this,p,fr),setChannelMetadata:w.bind(this,p,hr),removeChannelMetadata:w.bind(this,p,gr),getChannelMembers:w.bind(this,p,yr),setChannelMembers:function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return w.call.apply(w,b([s,p,mr,R({type:"set"},e)],A(t),!1))},removeChannelMembers:function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return w.call.apply(w,b([s,p,mr,R({type:"delete"},e)],A(t),!1))},getMemberships:w.bind(this,p,Rr),setMemberships:function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return w.call.apply(w,b([s,p,_r,R({type:"set"},e)],A(t),!1))},removeMemberships:function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return w.call.apply(w,b([s,p,_r,R({type:"delete"},e)],A(t),!1))}},this.createUser=function(e){return s.objects.setUUIDMetadata({uuid:e.userId,data:e.data,include:e.include})},this.updateUser=this.createUser,this.removeUser=function(e){return s.objects.removeUUIDMetadata({uuid:null==e?void 0:e.userId})},this.fetchUser=function(e){return s.objects.getUUIDMetadata({uuid:null==e?void 0:e.userId,include:null==e?void 0:e.include})},this.fetchUsers=this.objects.getAllUUIDMetadata,this.createSpace=function(e){return s.objects.setChannelMetadata({channel:e.spaceId,data:e.data,include:e.include})},this.updateSpace=this.createSpace,this.removeSpace=function(e){return s.objects.removeChannelMetadata({channel:e.spaceId})},this.fetchSpace=function(e){return s.objects.getChannelMetadata({channel:e.spaceId,include:e.include})},this.fetchSpaces=this.objects.getAllChannelMetadata,this.addMemberships=function(e){var t;return"string"==typeof e.spaceId?s.objects.setChannelMembers({channel:e.spaceId,uuids:null==(t=e.users)?void 0:t.map(function(e){return"string"==typeof e?e:{id:e.userId,custom:e.custom,status:e.status}}),limit:0}):s.objects.setMemberships({uuid:e.userId,channels:null==(t=e.spaces)?void 0:t.map(function(e){return"string"==typeof e?e:{id:e.spaceId,custom:e.custom,status:e.status}}),limit:0})},this.updateMemberships=this.addMemberships,this.removeMemberships=function(e){return"string"==typeof e.spaceId?s.objects.removeChannelMembers({channel:e.spaceId,uuids:e.userIds,limit:0}):s.objects.removeMemberships({uuid:e.userId,channels:e.spaceIds,limit:0})},this.fetchMemberships=function(e){return"string"==typeof e.spaceId?s.objects.getChannelMembers({channel:e.spaceId,filter:e.filter,limit:e.limit,page:e.page,include:{customFields:e.include.customFields,UUIDFields:e.include.userFields,customUUIDFields:e.include.customUserFields,statusField:e.include.statusField,UUIDStatusField:e.include.userStatusField,UUIDTypeField:e.include.userTypeField,totalCount:e.include.totalCount},sort:null!=e.sort?Object.fromEntries(Object.entries(e.sort).map(function(e){var e=A(e,2),t=e[0],e=e[1];return[t.replace("user","uuid"),e]})):null}).then(function(e){var t;return e.data=null==(t=e.data)?void 0:t.map(function(e){return{user:e.uuid,custom:e.custom,updated:e.updated,eTag:e.eTag}}),e}):s.objects.getMemberships({uuid:e.userId,filter:e.filter,limit:e.limit,page:e.page,include:{customFields:e.include.customFields,channelFields:e.include.spaceFields,customChannelFields:e.include.customSpaceFields,statusField:e.include.statusField,channelStatusField:e.include.spaceStatusField,channelTypeField:e.include.spaceTypeField,totalCount:e.include.totalCount},sort:null!=e.sort?Object.fromEntries(Object.entries(e.sort).map(function(e){var e=A(e,2),t=e[0],e=e[1];return[t.replace("space","channel"),e]})):null}).then(function(e){var t;return e.data=null==(t=e.data)?void 0:t.map(function(e){return{space:e.channel,custom:e.custom,updated:e.updated,eTag:e.eTag}}),e})},this.time=d,this.stop=this.destroy,this.encrypt=function(e,t){var r;return void 0===t&&p.cryptoModule?"string"==typeof(r=p.cryptoModule.encrypt(e))?r:Z(r):c.encrypt(e,t)},this.decrypt=function(e,t){var r;return void 0===t&&l?(r=p.cryptoModule.decrypt(e))instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r:c.decrypt(e,t)},this.getAuthKey=p.config.getAuthKey.bind(p.config),this.setAuthKey=p.config.setAuthKey.bind(p.config),this.getUUID=p.config.getUUID.bind(p.config),this.setUUID=p.config.setUUID.bind(p.config),this.getUserId=p.config.getUserId.bind(p.config),this.setUserId=p.config.setUserId.bind(p.config),this.getFilterExpression=p.config.getFilterExpression.bind(p.config),this.setFilterExpression=p.config.setFilterExpression.bind(p.config),this.setCipherKey=function(e){return p.config.setCipherKey(e,t,p)},this.setHeartbeatInterval=p.config.setHeartbeatInterval.bind(p.config),e.hasModule("proxy")&&(this.setProxy=function(e){p.config.setProxy(e),s.reconnect()})}function io(e){var t=e.modules,r=e.listenerManager,e=e.getFileUrl;this.modules=t,this.listenerManager=r,this.getFileUrl=e,t.cryptoModule&&(this._decoder=new TextDecoder)}function so(){}function ao(e){var t=this;this.engine=new Hr,this.channels=[],this.groups=[],this.dispatcher=new Xn(this.engine,e),this.dependencies=e,this._unsubscribeEngine=this.engine.subscribe(function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)}),this.engine.start(Zn,void 0)}function co(o){function i(e){return e&&"object"==typeof e&&e.constructor===Object}var s;return i(o)?(s={},Object.keys(o).forEach(function(e){var t="string"==typeof e||e instanceof String,r=e,n=o[e];Array.isArray(e)||t&&0<=e.indexOf(",")?r=(t?e.split(","):e).reduce(function(e,t){return e+String.fromCharCode(t)},""):("number"==typeof e&&isFinite(e)||t&&!isNaN(e))&&(r=String.fromCharCode(t?parseInt(e,10):10)),s[r]=i(n)?co(n):n}),s):o}lo.prototype.decodeToken=function(e){var t="",e=(e.length%4==3?t="=":e.length%4==2&&(t="=="),e.replace(/-/gi,"+").replace(/_/gi,"/")+t),t=this._decode(this._base64ToBinary(e));if("object"==typeof t)return t};var uo=lo,h={exports:{}},p={exports:{}};function lo(e,t){this._base64ToBinary=t,this._decode=e}function po(e){if(e){var t,r=e;for(t in po.prototype)r[t]=po.prototype[t];return r}}(p.exports=po).prototype.on=po.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},po.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},po.prototype.off=po.prototype.removeListener=po.prototype.removeAllListeners=po.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)this._callbacks={};else{var r,n=this._callbacks["$"+e];if(n)if(1==arguments.length)delete this._callbacks["$"+e];else{for(var o=0;o<n.length;o++)if((r=n[o])===t||r.fn===t){n.splice(o,1);break}0===n.length&&delete this._callbacks["$"+e]}}return this},po.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks["$"+e],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(r)for(var n=0,o=(r=r.slice(0)).length;n<o;++n)r[n].apply(this,t);return this},po.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},po.prototype.hasListeners=function(e){return!!this.listeners(e).length};var f=Ro,fo=((Ro.default=Ro).stable=bo,Ro.stableStringify=bo,"[...]"),ho="[Circular]",go=[],yo=[];function mo(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function Ro(e,t,r,n){var o;(function e(t,r,n,o,i,s,a){var c;if(s+=1,"object"==typeof t&&null!==t){for(c=0;c<o.length;c++)if(o[c]===t)return void _o(ho,t,r,i);if(void 0!==a.depthLimit&&s>a.depthLimit)_o(fo,t,r,i);else if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)_o(fo,t,r,i);else{if(o.push(t),Array.isArray(t))for(c=0;c<t.length;c++)e(t[c],c,c,o,t,s,a);else{var u=Object.keys(t);for(c=0;c<u.length;c++){var d=u[c];e(t[d],d,c,o,t,s,a)}}o.pop()}}})(e,"",0,[],void 0,0,n=void 0===n?mo():n);try{o=0===yo.length?JSON.stringify(e,t,r):JSON.stringify(e,vo(t),r)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==go.length;){var i=go.pop();4===i.length?Object.defineProperty(i[0],i[1],i[3]):i[0][i[1]]=i[2]}}return o}function _o(e,t,r,n){var o=Object.getOwnPropertyDescriptor(n,r);void 0!==o.get?o.configurable?(Object.defineProperty(n,r,{value:e}),go.push([n,r,t,o])):yo.push([t,r,e]):(n[r]=e,go.push([n,r,t]))}function Ao(e,t){return e<t?-1:t<e?1:0}function bo(e,t,r,n){var o,n=function e(t,r,n,o,i,s,a){var c;if(s+=1,"object"==typeof t&&null!==t){for(c=0;c<o.length;c++)if(o[c]===t)return void _o(ho,t,r,i);try{if("function"==typeof t.toJSON)return}catch(t){return}if(void 0!==a.depthLimit&&s>a.depthLimit)_o(fo,t,r,i);else if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)_o(fo,t,r,i);else{if(o.push(t),Array.isArray(t))for(c=0;c<t.length;c++)e(t[c],c,c,o,t,s,a);else{var u={},d=Object.keys(t).sort(Ao);for(c=0;c<d.length;c++){var l=d[c];e(t[l],l,c,o,t,s,a),u[l]=t[l]}if(void 0===i)return u;go.push([i,r,t]),i[r]=u}o.pop()}}}(e,"",0,[],void 0,0,n=void 0===n?mo():n)||e;try{o=0===yo.length?JSON.stringify(n,t,r):JSON.stringify(n,vo(t),r)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==go.length;){var i=go.pop();4===i.length?Object.defineProperty(i[0],i[1],i[3]):i[0][i[1]]=i[2]}}return o}function vo(o){return o=void 0!==o?o:function(e,t){return t},function(e,t){if(0<yo.length)for(var r=0;r<yo.length;r++){var n=yo[r];if(n[1]===e&&n[0]===t){t=n[2],yo.splice(r,1);break}}return o.call(this,e,t)}}var g="undefined"!=typeof Symbol&&Symbol,Io=Array.prototype.slice,To=Object.prototype.toString,Eo=Function.prototype.bind||function(t){var r=this;if("function"!=typeof r||"[object Function]"!==To.call(r))throw new TypeError("Function.prototype.bind called on incompatible "+r);for(var n=Io.call(arguments,1),e=Math.max(0,r.length-n.length),o=[],i=0;i<e;i++)o.push("$"+i);var s,a=Function("binder","return function ("+o.join(",")+"){ return binder.apply(this,arguments); }")(function(){var e;return this instanceof a?(e=r.apply(this,n.concat(Io.call(arguments))),Object(e)===e?e:this):r.apply(t,n.concat(Io.call(arguments)))});return r.prototype&&((s=function(){}).prototype=r.prototype,a.prototype=new s,s.prototype=null),a},So=Eo.call(Function.call,Object.prototype.hasOwnProperty),Po=SyntaxError,Oo=Function,wo=TypeError,Uo=function(e){try{return Oo('"use strict"; return ('+e+").constructor;")()}catch(e){}},ko=Object.getOwnPropertyDescriptor;if(ko)try{ko({},"")}catch(x){ko=null}function jo(){throw new wo}function Co(e,t){if("string"!=typeof e||0===e.length)throw new wo("intrinsic name must be a non-empty string");if(1<arguments.length&&"boolean"!=typeof t)throw new wo('"allowMissing" argument must be a boolean');var r=(e=>{var t=Go(e,0,1),r=Go(e,-1);if("%"===t&&"%"!==r)throw new Po("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new Po("invalid intrinsic syntax, expected opening `%`");var o=[];return zo(e,Xo,function(e,t,r,n){o[o.length]=r?zo(n,Bo,"$1"):t||e}),o})(e),n=0<r.length?r[0]:"",o=((e,t)=>{var r,n=e;if(qo(Fo,n)&&(n="%"+(r=Fo[n])[0]+"%"),qo(Ho,n)){var o=Ho[n];if(void 0!==(o=o===Lo?Mo(n):o)||t)return{alias:r,name:n,value:o};throw new wo("intrinsic "+e+" exists, but is not available. Please file an issue!")}throw new Po("intrinsic "+e+" does not exist!")})("%"+n+"%",t),i=(o.name,o.value),s=!1;(o=o.alias)&&(n=o[0],Ko(r,Yo([0,1],o)));for(var a=1,c=!0;a<r.length;a+=1){var u=r[a],d=Go(u,0,1),l=Go(u,-1);if(('"'===d||"'"===d||"`"===d||'"'===l||"'"===l||"`"===l)&&d!==l)throw new Po("property names with quotes must have matching quotes");if("constructor"!==u&&c||(s=!0),qo(Ho,d="%"+(n+="."+u)+"%"))i=Ho[d];else if(null!=i){if(!(u in i)){if(t)return;throw new wo("base intrinsic for "+e+" exists, but the property is not available.")}i=ko&&a+1>=r.length?(c=!!(l=ko(i,u)))&&"get"in l&&!("originalValue"in l.get)?l.get:i[u]:(c=qo(i,u),i[u]),c&&!s&&(Ho[d]=i)}}return i}var xo=ko?function(){try{return jo}catch(e){try{return ko(arguments,"callee").get}catch(e){return jo}}}():jo,g="function"==typeof g&&"function"==typeof Symbol&&"symbol"==typeof g("foo")&&"symbol"==typeof Symbol("bar")&&(()=>{if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"!=typeof Symbol.iterator){var e={},t=Symbol("test"),r=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;r=Object.getOwnPropertySymbols(e);if(1!==r.length||r[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){r=Object.getOwnPropertyDescriptor(e,t);if(42!==r.value||!0!==r.enumerable)return!1}}return!0})(),Do=Object.getPrototypeOf||function(e){return e.__proto__},Lo={},No="undefined"==typeof Uint8Array?d:Do(Uint8Array),Ho={"%AggregateError%":"undefined"==typeof AggregateError?d:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?d:ArrayBuffer,"%ArrayIteratorPrototype%":g?Do([][Symbol.iterator]()):d,"%AsyncFromSyncIteratorPrototype%":d,"%AsyncFunction%":Lo,"%AsyncGenerator%":Lo,"%AsyncGeneratorFunction%":Lo,"%AsyncIteratorPrototype%":Lo,"%Atomics%":"undefined"==typeof Atomics?d:Atomics,"%BigInt%":"undefined"==typeof BigInt?d:BigInt,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?d:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":"undefined"==typeof Float32Array?d:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?d:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?d:FinalizationRegistry,"%Function%":Oo,"%GeneratorFunction%":Lo,"%Int8Array%":"undefined"==typeof Int8Array?d:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?d:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?d:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":g?Do(Do([][Symbol.iterator]())):d,"%JSON%":"object"==typeof JSON?JSON:d,"%Map%":"undefined"==typeof Map?d:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&g?Do((new Map)[Symbol.iterator]()):d,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?d:Promise,"%Proxy%":"undefined"==typeof Proxy?d:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":"undefined"==typeof Reflect?d:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?d:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&g?Do((new Set)[Symbol.iterator]()):d,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?d:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":g?Do(""[Symbol.iterator]()):d,"%Symbol%":g?Symbol:d,"%SyntaxError%":Po,"%ThrowTypeError%":xo,"%TypedArray%":No,"%TypeError%":wo,"%Uint8Array%":"undefined"==typeof Uint8Array?d:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?d:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?d:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?d:Uint32Array,"%URIError%":URIError,"%WeakMap%":"undefined"==typeof WeakMap?d:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?d:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?d:WeakSet},Mo=function e(t){var r,n;return"%AsyncFunction%"===t?r=Uo("async function () {}"):"%GeneratorFunction%"===t?r=Uo("function* () {}"):"%AsyncGeneratorFunction%"===t?r=Uo("async function* () {}"):"%AsyncGenerator%"===t?(n=e("%AsyncGeneratorFunction%"))&&(r=n.prototype):"%AsyncIteratorPrototype%"===t&&(n=e("%AsyncGenerator%"))&&(r=Do(n.prototype)),Ho[t]=r},Fo={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},g=Eo,qo=So,Yo=g.call(Function.call,Array.prototype.concat),Ko=g.call(Function.apply,Array.prototype.splice),zo=g.call(Function.call,String.prototype.replace),Go=g.call(Function.call,String.prototype.slice),Xo=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Bo=/\\(\\)?/g,xo={exports:{}},Vo=xo,Wo=Eo,No=Co,Jo=No("%Function.prototype.apply%"),$o=No("%Function.prototype.call%"),Qo=No("%Reflect.apply%",!0)||Wo.call($o,Jo),Zo=No("%Object.getOwnPropertyDescriptor%",!0),ei=No("%Object.defineProperty%",!0),ti=No("%Math.max%");if(ei)try{ei({},"a",{value:1})}catch(Vo){ei=null}function ri(){return Qo(Wo,Jo,arguments)}Vo.exports=function(e){var t=Qo(Wo,$o,arguments);return Zo&&ei&&Zo(t,"length").configurable&&ei(t,"length",{value:1+ti(0,e.length-(arguments.length-1))}),t},ei?ei(Vo.exports,"apply",{value:ri}):Vo.exports.apply=ri;var ni,oi,ii=Co,si=xo.exports,ai=si(ii("String.prototype.indexOf")),d=(ni=Object.freeze({__proto__:null,default:{}})).__esModule?ni:(oi=Object.defineProperty({},"__esModule",{value:!0}),Object.keys(ni).forEach(function(e){var t=Object.getOwnPropertyDescriptor(ni,e);Object.defineProperty(oi,e,t.get?t:{enumerable:!0,get:function(){return ni[e]}})}),oi),So="function"==typeof Map&&Map.prototype,g=Object.getOwnPropertyDescriptor&&So?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,ci=So&&g&&"function"==typeof g.get?g.get:null,ui=So&&Map.prototype.forEach,Eo="function"==typeof Set&&Set.prototype,No=Object.getOwnPropertyDescriptor&&Eo?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,di=Eo&&No&&"function"==typeof No.get?No.get:null,li=Eo&&Set.prototype.forEach,pi="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,fi="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,hi="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,gi=Boolean.prototype.valueOf,yi=Object.prototype.toString,mi=Function.prototype.toString,Ri=String.prototype.match,_i=String.prototype.slice,Ai=String.prototype.replace,bi=String.prototype.toUpperCase,vi=String.prototype.toLowerCase,Ii=RegExp.prototype.test,Ti=Array.prototype.concat,Ei=Array.prototype.join,Si=Array.prototype.slice,Pi=Math.floor,Oi="function"==typeof BigInt?BigInt.prototype.valueOf:null,wi=Object.getOwnPropertySymbols,Ui="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,ki="function"==typeof Symbol&&"object"==typeof Symbol.iterator,ji="function"==typeof Symbol&&Symbol.toStringTag&&(Symbol.toStringTag,1)?Symbol.toStringTag:null,Ci=Object.prototype.propertyIsEnumerable,xi=("function"==typeof Reflect?Reflect:Object).getPrototypeOf||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function Di(e,t){if(e===1/0||e===-1/0||e!=e||e&&-1e3<e&&e<1e3||Ii.call(/e/,t))return t;var r=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var n=e<0?-Pi(-e):Pi(e);if(n!==e)return e=String(n),n=_i.call(t,e.length+1),Ai.call(e,r,"$&_")+"."+Ai.call(Ai.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}return Ai.call(t,r,"$&_")}var Li=d,xo=Li.custom,Ni=qi(xo)?xo:null;function Hi(e,t,r){r="double"===(r.quoteStyle||t)?'"':"'";return r+e+r}function Mi(e){return!("[object Array]"!==zi(e)||ji&&"object"==typeof e&&ji in e)}function Fi(e){return!("[object RegExp]"!==zi(e)||ji&&"object"==typeof e&&ji in e)}function qi(e){if(ki)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return 1;if(e&&"object"==typeof e&&Ui)try{return Ui.call(e),1}catch(e){}}var Yi=Object.prototype.hasOwnProperty||function(e){return e in this};function Ki(e,t){return Yi.call(e,t)}function zi(e){return yi.call(e)}function Gi(e,t){if(e.indexOf)return e.indexOf(t);for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}function Xi(e){var e=e.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+bi.call(e.toString(16))}function Bi(e){return"Object("+e+")"}function Vi(e){return e+" { ? }"}function Wi(e,t,r,n){return e+" ("+t+") {"+(n?Ji(r,n):Ei.call(r,", "))+"}"}function Ji(e,t){var r;return 0===e.length?"":(r="\n"+t.prev+t.base)+Ei.call(e,","+r)+"\n"+t.prev}function $i(e,t){var r=Mi(e),n=[];if(r){n.length=e.length;for(var o=0;o<e.length;o++)n[o]=Ki(e,o)?t(e[o],e):""}var i,s="function"==typeof wi?wi(e):[];if(ki)for(var a={},c=0;c<s.length;c++)a["$"+s[c]]=s[c];for(i in e)!Ki(e,i)||r&&String(Number(i))===i&&i<e.length||ki&&a["$"+i]instanceof Symbol||(Ii.call(/[^\w$]/,i)?n.push(t(i,e)+": "+t(e[i],e)):n.push(i+": "+t(e[i],e)));if("function"==typeof wi)for(var u=0;u<s.length;u++)Ci.call(e,s[u])&&n.push("["+t(s[u])+"]: "+t(e[s[u]],e));return n}function Qi(e,t){return"function"==typeof(t=ii(e,!!t))&&-1<ai(e,".prototype.")?si(t):t}function Zi(e,t){for(var r=t&&t.plainObjects?Object.create(null):{},n=0;n<e.length;++n)void 0!==e[n]&&(r[n]=e[n]);return r}function es(e,t,r,n,o,i,s,a,c,u,d,l,p,f,h,g){for(var y=e,m=g,R=0,_=!1;void 0!==(m=m.get(Us))&&!_;){var A=m.get(e);if(R+=1,void 0!==A){if(A===R)throw new RangeError("Cyclic object value");_=!0}void 0===m.get(Us)&&(R=0)}if("function"==typeof a?y=a(t,y):y instanceof Date?y=d(y):"comma"===r&&Es(y)&&(y=bs.maybeMap(y,function(e){return e instanceof Date?d(e):e})),null===y){if(o)return s&&!f?s(t,ws.encoder,h,"key",l):t;y=""}if("string"==typeof y||"number"==typeof y||"boolean"==typeof y||"symbol"==typeof y||"bigint"==typeof y||bs.isBuffer(y))return s?[p(f?t:s(t,ws.encoder,h,"key",l))+"="+p(s(y,ws.encoder,h,"value",l))]:[p(t)+"="+p(String(y))];var b,v,I=[];if(void 0!==y){v="comma"===r&&Es(y)?[{value:0<(y=f&&s?bs.maybeMap(y,s):y).length?y.join(",")||null:void 0}]:Es(a)?a:(b=Object.keys(y),c?b.sort(c):b);for(var T=n&&Es(y)&&1===y.length?t+"[]":t,E=0;E<v.length;++E){var S,P=v[E],O="object"==typeof P&&void 0!==P.value?P.value:y[P];i&&null===O||(P=Es(y)?"function"==typeof r?r(T,P):T:T+(u?"."+P:"["+P+"]"),g.set(e,R),(S=As()).set(Us,g),Ps(I,es(O,P,r,n,o,i,"comma"===r&&f&&Es(y)?null:s,a,c,u,d,l,p,f,h,S)))}}return I}function ts(e,t){return e&&"string"==typeof e&&t.comma&&-1<e.indexOf(",")?e.split(","):e}var rs,g=Co,ns=function n(r,e,o,i){var s=e||{};if(Ki(s,"quoteStyle")&&"single"!==s.quoteStyle&&"double"!==s.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Ki(s,"maxStringLength")&&("number"==typeof s.maxStringLength?s.maxStringLength<0&&s.maxStringLength!==1/0:null!==s.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');e=!Ki(s,"customInspect")||s.customInspect;if("boolean"!=typeof e&&"symbol"!==e)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Ki(s,"indent")&&null!==s.indent&&"\t"!==s.indent&&!(parseInt(s.indent,10)===s.indent&&0<s.indent))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Ki(s,"numericSeparator")&&"boolean"!=typeof s.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var t=s.numericSeparator;if(void 0===r)return"undefined";if(null===r)return"null";if("boolean"==typeof r)return r?"true":"false";if("string"==typeof r)return function e(t,r){var n;return t.length>r.maxStringLength?(n="... "+(n=t.length-r.maxStringLength)+" more character"+(1<n?"s":""),e(_i.call(t,0,r.maxStringLength),r)+n):Hi(Ai.call(Ai.call(t,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,Xi),"single",r)}(r,s);if("number"==typeof r)return 0===r?0<1/0/r?"0":"-0":(y=String(r),t?Di(r,y):y);if("bigint"==typeof r)return y=String(r)+"n",t?Di(r,y):y;t=void 0===s.depth?5:s.depth;if(t<=(o=void 0===o?0:o)&&0<t&&"object"==typeof r)return Mi(r)?"[Array]":"[Object]";var a,c,u,d,l,p,f,h,g,y=(e=>{var t;if("\t"===s.indent)t="\t";else{if(!("number"==typeof s.indent&&0<s.indent))return null;t=Ei.call(Array(s.indent+1)," ")}return{base:t,prev:Ei.call(Array(e+1),t)}})(o);if(void 0===i)i=[];else if(0<=Gi(i,r))return"[Circular]";function m(e,t,r){return t&&(i=Si.call(i)).push(t),r?(t={depth:s.depth},Ki(s,"quoteStyle")&&(t.quoteStyle=s.quoteStyle),n(e,t,o+1,i)):n(e,s,o+1,i)}if("function"==typeof r&&!Fi(r))return"[Function"+((a=r.name||((a=Ri.call(mi.call(r),/^function\s*([\w$]+)/))?a[1]:null))?": "+a:" (anonymous)")+"]"+(0<(u=$i(r,m)).length?" { "+Ei.call(u,", ")+" }":"");if(qi(r))return u=ki?Ai.call(String(r),/^(Symbol\(.*\))_[^)]*$/,"$1"):Ui.call(r),"object"!=typeof r||ki?u:Bi(u);if((u=r)&&"object"==typeof u&&("undefined"!=typeof HTMLElement&&u instanceof HTMLElement||"string"==typeof u.nodeName&&"function"==typeof u.getAttribute)){for(var R="<"+vi.call(String(r.nodeName)),_=r.attributes||[],A=0;A<_.length;A++)R+=" "+_[A].name+"="+Hi((c=_[A].value,Ai.call(String(c),/"/g,"&quot;")),"double",s);return R+=">",r.childNodes&&r.childNodes.length&&(R+="..."),R+("</"+vi.call(String(r.nodeName)))+">"}if(Mi(r))return 0===r.length?"[]":(d=$i(r,m),y&&!(e=>{for(var t=0;t<e.length;t++)if(0<=Gi(e[t],"\n"))return;return 1})(d)?"["+Ji(d,y)+"]":"[ "+Ei.call(d,", ")+" ]");if(!("[object Error]"!==zi(d=r)||ji&&"object"==typeof d&&ji in d))return f=$i(r,m),"cause"in Error.prototype||!("cause"in r)||Ci.call(r,"cause")?0===f.length?"["+String(r)+"]":"{ ["+String(r)+"] "+Ei.call(f,", ")+" }":"{ ["+String(r)+"] "+Ei.call(Ti.call("[cause]: "+m(r.cause),f),", ")+" }";if("object"==typeof r&&e){if(Ni&&"function"==typeof r[Ni]&&Li)return Li(r,{depth:t-o});if("symbol"!==e&&"function"==typeof r.inspect)return r.inspect()}return(e=>{if(ci&&e&&"object"==typeof e)try{ci.call(e);try{di.call(e)}catch(e){return 1}return e instanceof Map}catch(e){}})(r)?(l=[],ui&&ui.call(r,function(e,t){l.push(m(t,r,!0)+" => "+m(e,r))}),Wi("Map",ci.call(r),l,y)):(e=>{if(di&&e&&"object"==typeof e)try{di.call(e);try{ci.call(e)}catch(e){return 1}return e instanceof Set}catch(e){}})(r)?(p=[],li&&li.call(r,function(e){p.push(m(e,r))}),Wi("Set",di.call(r),p,y)):(e=>{if(pi&&e&&"object"==typeof e)try{pi.call(e,pi);try{fi.call(e,fi)}catch(e){return 1}return e instanceof WeakMap}catch(e){}})(r)?Vi("WeakMap"):(e=>{if(fi&&e&&"object"==typeof e)try{fi.call(e,fi);try{pi.call(e,pi)}catch(e){return 1}return e instanceof WeakSet}catch(e){}})(r)?Vi("WeakSet"):(e=>{if(hi&&e&&"object"==typeof e)try{return hi.call(e),1}catch(e){}})(r)?Vi("WeakRef"):"[object Number]"!==zi(f=r)||ji&&"object"==typeof f&&ji in f?(e=>{if(e&&"object"==typeof e&&Oi)try{return Oi.call(e),1}catch(e){}})(r)?Bi(m(Oi.call(r))):"[object Boolean]"!==zi(t=r)||ji&&"object"==typeof t&&ji in t?"[object String]"!==zi(e=r)||ji&&"object"==typeof e&&ji in e?"undefined"!=typeof window&&r===window?"{ [object Window] }":r===H?"{ [object globalThis] }":("[object Date]"!==zi(t=r)||ji&&"object"==typeof t&&ji in t)&&!Fi(r)?(e=$i(r,m),t=xi?xi(r)===Object.prototype:r instanceof Object||r.constructor===Object,h=r instanceof Object?"":"null prototype",g=!t&&ji&&Object(r)===r&&ji in r?_i.call(zi(r),8,-1):h?"Object":"",t=(!t&&"function"==typeof r.constructor&&r.constructor.name?r.constructor.name+" ":"")+(g||h?"["+Ei.call(Ti.call([],g||[],h||[]),": ")+"] ":""),0===e.length?t+"{}":y?t+"{"+Ji(e,y)+"}":t+"{ "+Ei.call(e,", ")+" }"):String(r):Bi(m(String(r))):Bi(gi.call(r)):Bi(m(Number(r)))},os=g("%TypeError%"),is=g("%WeakMap%",!0),ss=g("%Map%",!0),as=Qi("WeakMap.prototype.get",!0),cs=Qi("WeakMap.prototype.set",!0),us=Qi("WeakMap.prototype.has",!0),ds=Qi("Map.prototype.get",!0),ls=Qi("Map.prototype.set",!0),ps=Qi("Map.prototype.has",!0),fs=function(e,t){for(var r,n=e;null!==(r=n.next);n=r)if(r.key===t)return n.next=r.next,r.next=e.next,e.next=r},hs=String.prototype.replace,gs=/%20/g,So={default:"RFC3986",formatters:{RFC1738:function(e){return hs.call(e,gs,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:"RFC3986"},ys=So,ms=Object.prototype.hasOwnProperty,Rs=Array.isArray,_s=(()=>{for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})(),No={arrayToObject:Zi,assign:function(e,r){return Object.keys(r).reduce(function(e,t){return e[t]=r[t],e},e)},combine:function(e,t){return[].concat(e,t)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],r=[],n=0;n<t.length;++n)for(var o=t[n],i=o.obj[o.prop],s=Object.keys(i),a=0;a<s.length;++a){var c=s[a],u=i[c];"object"==typeof u&&null!==u&&-1===r.indexOf(u)&&(t.push({obj:i,prop:c}),r.push(u))}for(var d=t;1<d.length;){var l=d.pop(),p=l.obj[l.prop];if(Rs(p)){for(var f=[],h=0;h<p.length;++h)void 0!==p[h]&&f.push(p[h]);l.obj[l.prop]=f}}return e},decode:function(e,t,r){var n=e.replace(/\+/g," ");if("iso-8859-1"===r)return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch(e){return n}},encode:function(e,t,r,n,o){if(0===e.length)return e;var i=e;if("symbol"==typeof e?i=Symbol.prototype.toString.call(e):"string"!=typeof e&&(i=String(e)),"iso-8859-1"===r)return escape(i).replace(/%u[0-9a-f]{4}/gi,function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"});for(var s="",a=0;a<i.length;++a){var c=i.charCodeAt(a);45===c||46===c||95===c||126===c||48<=c&&c<=57||65<=c&&c<=90||97<=c&&c<=122||o===ys.RFC1738&&(40===c||41===c)?s+=i.charAt(a):c<128?s+=_s[c]:c<2048?s+=_s[192|c>>6]+_s[128|63&c]:c<55296||57344<=c?s+=_s[224|c>>12]+_s[128|c>>6&63]+_s[128|63&c]:(a+=1,c=65536+((1023&c)<<10|1023&i.charCodeAt(a)),s+=_s[240|c>>18]+_s[128|c>>12&63]+_s[128|c>>6&63]+_s[128|63&c])}return s},isBuffer:function(e){return!(!e||"object"!=typeof e||!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e)))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(Rs(e)){for(var r=[],n=0;n<e.length;n+=1)r.push(t(e[n]));return r}return t(e)},merge:function n(o,i,s){if(!i)return o;if("object"!=typeof i){if(Rs(o))o.push(i);else{if(!o||"object"!=typeof o)return[o,i];(s&&(s.plainObjects||s.allowPrototypes)||!ms.call(Object.prototype,i))&&(o[i]=!0)}return o}var e;return o&&"object"==typeof o?(Rs(e=o)&&!Rs(i)&&(e=Zi(o,s)),Rs(o)&&Rs(i)?(i.forEach(function(e,t){var r;ms.call(o,t)?(r=o[t])&&"object"==typeof r&&e&&"object"==typeof e?o[t]=n(r,e,s):o.push(e):o[t]=e}),o):Object.keys(i).reduce(function(e,t){var r=i[t];return ms.call(e,t)?e[t]=n(e[t],r,s):e[t]=r,e},e)):[o].concat(i)}},As=function(){var o,i,s,t={assert:function(e){if(!t.has(e))throw new os("Side channel does not contain "+ns(e))},get:function(e){if(is&&e&&("object"==typeof e||"function"==typeof e)){if(o)return as(o,e)}else if(ss){if(i)return ds(i,e)}else if(s)return(e=fs(s,e))&&e.value},has:function(e){if(is&&e&&("object"==typeof e||"function"==typeof e)){if(o)return us(o,e)}else if(ss){if(i)return ps(i,e)}else if(s)return!!fs(s,e);return!1},set:function(e,t){var r,n;is&&e&&("object"==typeof e||"function"==typeof e)?(o=o||new is,cs(o,e,t)):ss?(i=i||new ss,ls(i,e,t)):(t=t,(n=fs(r=s=s||{key:{},next:null},e=e))?n.value=t:r.next={key:e,next:r.next,value:t})}};return t},bs=No,vs=So,Is=Object.prototype.hasOwnProperty,Ts={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},Es=Array.isArray,Ss=Array.prototype.push,Ps=function(e,t){Ss.apply(e,Es(t)?t:[t])},Os=Date.prototype.toISOString,Eo=vs.default,ws={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:bs.encode,encodeValuesOnly:!1,format:Eo,formatter:vs.formatters[Eo],indices:!1,serializeDate:function(e){return Os.call(e)},skipNulls:!1,strictNullHandling:!1},Us={},ks=No,js=Object.prototype.hasOwnProperty,Cs=Array.isArray,l={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:ks.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},xo={formats:So,parse:function(e,t){var r=(e=>{if(!e)return l;if(null!=e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=(void 0===e.charset?l:e).charset;return{allowDots:void 0===e.allowDots?l.allowDots:!!e.allowDots,allowPrototypes:("boolean"==typeof e.allowPrototypes?e:l).allowPrototypes,allowSparse:("boolean"==typeof e.allowSparse?e:l).allowSparse,arrayLimit:("number"==typeof e.arrayLimit?e:l).arrayLimit,charset:t,charsetSentinel:("boolean"==typeof e.charsetSentinel?e:l).charsetSentinel,comma:("boolean"==typeof e.comma?e:l).comma,decoder:("function"==typeof e.decoder?e:l).decoder,delimiter:("string"==typeof e.delimiter||ks.isRegExp(e.delimiter)?e:l).delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:l.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:("boolean"==typeof e.interpretNumericEntities?e:l).interpretNumericEntities,parameterLimit:("number"==typeof e.parameterLimit?e:l).parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:("boolean"==typeof e.plainObjects?e:l).plainObjects,strictNullHandling:("boolean"==typeof e.strictNullHandling?e:l).strictNullHandling}})(t);if(""===e||null==e)return r.plainObjects?Object.create(null):{};for(var n="string"==typeof e?((e,t)=>{var r,n,o,i,s={__proto__:null},e=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,a=t.parameterLimit===1/0?void 0:t.parameterLimit,c=e.split(t.delimiter,a),u=-1,d=t.charset;if(t.charsetSentinel)for(r=0;r<c.length;++r)0===c[r].indexOf("utf8=")&&("utf8=%E2%9C%93"===c[r]?d="utf-8":"utf8=%26%2310003%3B"===c[r]&&(d="iso-8859-1"),u=r,r=c.length);for(r=0;r<c.length;++r)r!==u&&((i=-1===(i=-1===(i=(o=c[r]).indexOf("]="))?o.indexOf("="):i+1)?(n=t.decoder(o,l.decoder,d,"key"),t.strictNullHandling?null:""):(n=t.decoder(o.slice(0,i),l.decoder,d,"key"),ks.maybeMap(ts(o.slice(i+1),t),function(e){return t.decoder(e,l.decoder,d,"value")})))&&t.interpretNumericEntities&&"iso-8859-1"===d&&(i=i.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})),-1<o.indexOf("[]=")&&(i=Cs(i)?[i]:i),js.call(s,n)?s[n]=ks.combine(s[n],i):s[n]=i);return s})(e,r):e,o=r.plainObjects?Object.create(null):{},i=Object.keys(n),s=0;s<i.length;++s)var a=i[s],a=((e,t,r,n)=>{if(e){var o=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,s=0<r.depth&&/(\[[^[\]]*])/.exec(o),e=s?o.slice(0,s.index):o,a=[];if(e){if(!r.plainObjects&&js.call(Object.prototype,e)&&!r.allowPrototypes)return;a.push(e)}for(var c=0;0<r.depth&&null!==(s=i.exec(o))&&c<r.depth;){if(c+=1,!r.plainObjects&&js.call(Object.prototype,s[1].slice(1,-1))&&!r.allowPrototypes)return;a.push(s[1])}s&&a.push("["+o.slice(s.index)+"]");for(var u=a,d=r,l=n?t:ts(t,d),p=u.length-1;0<=p;--p){var f,h,g,y=u[p];"[]"===y&&d.parseArrays?f=[].concat(l):(f=d.plainObjects?Object.create(null):{},h="["===y.charAt(0)&&"]"===y.charAt(y.length-1)?y.slice(1,-1):y,g=parseInt(h,10),d.parseArrays||""!==h?!isNaN(g)&&y!==h&&String(g)===h&&0<=g&&d.parseArrays&&g<=d.arrayLimit?(f=[])[g]=l:"__proto__"!==h&&(f[h]=l):f={0:l}),l=f}return l}})(a,n[a],r,"string"==typeof e),o=ks.merge(o,a,r);return!0===r.allowSparse?o:ks.compact(o)},stringify:function(e,t){var r=e,n=(e=>{if(!e)return ws;if(null!=e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||ws.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=vs.default;if(void 0!==e.format){if(!Is.call(vs.formatters,e.format))throw new TypeError("Unknown format option provided.");r=e.format}var n=vs.formatters[r],o=ws.filter;return"function"!=typeof e.filter&&!Es(e.filter)||(o=e.filter),{addQueryPrefix:("boolean"==typeof e.addQueryPrefix?e:ws).addQueryPrefix,allowDots:void 0===e.allowDots?ws.allowDots:!!e.allowDots,charset:t,charsetSentinel:("boolean"==typeof e.charsetSentinel?e:ws).charsetSentinel,delimiter:(void 0===e.delimiter?ws:e).delimiter,encode:("boolean"==typeof e.encode?e:ws).encode,encoder:("function"==typeof e.encoder?e:ws).encoder,encodeValuesOnly:("boolean"==typeof e.encodeValuesOnly?e:ws).encodeValuesOnly,filter:o,format:r,formatter:n,serializeDate:("function"==typeof e.serializeDate?e:ws).serializeDate,skipNulls:("boolean"==typeof e.skipNulls?e:ws).skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:("boolean"==typeof e.strictNullHandling?e:ws).strictNullHandling}})(t);"function"==typeof n.filter?r=(0,n.filter)("",r):Es(n.filter)&&(a=n.filter);var o=[];if("object"!=typeof r||null===r)return"";var e=t&&t.arrayFormat in Ts?t.arrayFormat:!(t&&"indices"in t)||t.indices?"indices":"repeat",i=Ts[e];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var s="comma"===i&&t&&t.commaRoundTrip,a=a||Object.keys(r);n.sort&&a.sort(n.sort);for(var c=As(),u=0;u<a.length;++u){var d=a[u];n.skipNulls&&null===r[d]||Ps(o,es(r[d],d,i,s,n.strictNullHandling,n.skipNulls,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset,c))}e=o.join(n.delimiter),t=!0===n.addQueryPrefix?"?":"";return n.charsetSentinel&&("iso-8859-1"===n.charset?t+="utf8=%26%2310003%3B&":t+="utf8=%E2%9C%93&"),0<e.length?t+e:""}},g={};function xs(e,t){var r,n,o,i,s="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(s)return o=!(n=!0),{s:function(){s=s.call(e)},n:function(){var e=s.next();return n=e.done,e},e:function(e){o=!0,r=e},f:function(){try{n||null==s.return||s.return()}finally{if(o)throw r}}};if(Array.isArray(e)||(s=(e=>{var t;if(e)return"string"==typeof e?Ds(e,void 0):"Map"===(t="Object"===(t=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Ds(e,void 0):void 0})(e))||t&&e&&"number"==typeof e.length)return s&&(e=s),i=0,{s:t=function(){},n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ds(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}(rs=g).type=e=>e.split(/ *; */).shift(),rs.params=e=>{var n,o={},t=xs(e.split(/ *; */));try{for(t.s();!(n=t.n()).done;){let e=n.value.split(/ *= */),t=e.shift(),r=e.shift();t&&r&&(o[t]=r)}}catch(e){t.e(e)}finally{t.f()}return o},rs.parseLinks=e=>{var r,n={},t=xs(e.split(/ *, */));try{for(t.s();!(r=t.n()).done;){let e=r.value.split(/ *; */),t=e[0].slice(1,-1);n[e[1].split(/ *= */)[1].slice(1,-1)]=t}}catch(e){t.e(e)}finally{t.f()}return n},rs.cleanHeader=(e,t)=>(delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e),rs.isObject=e=>null!==e&&"object"==typeof e,rs.hasOwn=Object.hasOwn||function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(new Object(e),t)},rs.mixin=(e,t)=>{for(var r in t)rs.hasOwn(t,r)&&(e[r]=t[r])};let Ls=d,Ns=g.isObject,Hs=g.hasOwn;Eo=y;function y(){}y.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},y.prototype.parse=function(e){return this._parser=e,this},y.prototype.responseType=function(e){return this._responseType=e,this},y.prototype.serialize=function(e){return this._serializer=e,this},y.prototype.timeout=function(e){if(e&&"object"==typeof e){for(var t in e)if(Hs(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}}else this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0;return this},y.prototype.retry=function(e,t){return this._maxRetries=e=(e=0!==arguments.length&&!0!==e?e:1)<=0?0:e,this._retries=0,this._retryCallback=t,this};let Ms=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),Fs=new Set([408,413,429,500,502,503,504,521,522,524]),qs=(y.prototype._shouldRetry=function(e,t){if(this._maxRetries&&!(this._retries++>=this._maxRetries)){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&&Fs.has(t.status))return!0;if(e){if(e.code&&Ms.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}}return!1},y.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},y.prototype.then=function(e,t){if(!this._fullfilledPromise){let e=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((r,n)=>{e.on("abort",()=>{var e;this._maxRetries&&this._maxRetries>this._retries||(this.timedout&&this.timedoutError?n(this.timedoutError):((e=new Error("Aborted")).code="ABORTED",e.status=this.status,e.method=this.method,e.url=this.url,n(e)))}),e.end((e,t)=>{e?n(e):r(t)})})}return this._fullfilledPromise.then(e,t)},y.prototype.catch=function(e){return this.then(void 0,e)},y.prototype.use=function(e){return e(this),this},y.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},y.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):200<=e.status&&e.status<300)},y.prototype.getHeader=y.prototype.get=function(e){return this._header[e.toLowerCase()]},y.prototype.set=function(t,e){if(Ns(t))for(let e in t)Hs(t,e)&&this.set(e,t[e]);else this._header[t.toLowerCase()]=e,this.header[t]=e;return this},y.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},y.prototype.field=function(t,r,e){if(null==t)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(Ns(t))for(let e in t)Hs(t,e)&&this.field(e,t[e]);else if(Array.isArray(r))for(let e in r)Hs(r,e)&&this.field(t,r[e]);else{if(null==r)throw new Error(".field(name, val) val can not be empty");"boolean"==typeof r&&(r=String(r)),e?this._getFormData().append(t,r,e):this._getFormData().append(t,r)}return this},y.prototype.abort=function(){if(!this._aborted){if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(Ls.gte(Ua.version,"v13.0.0")&&Ls.lt(Ua.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");this.req.abort()}this.clearTimeout(),this.emit("abort")}return this},y.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},y.prototype.withCredentials=function(e){return this._withCredentials=e=void 0===e?!0:e,this},y.prototype.redirects=function(e){return this._maxRedirects=e,this},y.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},y.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},y.prototype.send=function(t){let e=Ns(t),r=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(e&&!this._data)Array.isArray(t)?this._data=[]:this._isHost(t)||(this._data={});else if(t&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(e&&Ns(this._data))for(let e in t){if("bigint"==typeof t[e]&&!t[e].toJSON)throw new Error("Cannot serialize BigInt value to json");Hs(t,e)&&(this._data[e]=t[e])}else{if("bigint"==typeof t)throw new Error("Cannot send value of type BigInt");"string"==typeof t?(r||this.type("form"),r=(r=this._header["content-type"])&&r.toLowerCase().trim(),this._data="application/x-www-form-urlencoded"===r?this._data?this._data+"&"+t:t:(this._data||"")+t):this._data=t}return!e||this._isHost(t)||r||this.type("json"),this},y.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},y.prototype._finalizeQueryString=function(){let e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){let e=this.url.indexOf("?");var t;0<=e&&(t=this.url.slice(e+1).split("&"),"function"==typeof this._sort?t.sort(this._sort):t.sort(),this.url=this.url.slice(0,e)+"?"+t.join("&"))}},y.prototype._appendQueryString=()=>{console.warn("Unsupported")},y.prototype._timeoutError=function(e,t,r){this._aborted||((e=new Error(e+t+"ms exceeded")).timeout=t,e.code="ECONNABORTED",e.errno=r,this.timedout=!0,this.timedoutError=e,this.abort(),this.callback(e))},y.prototype._setTimeouts=function(){let e=this;this._timeout&&!this._timer&&(this._timer=setTimeout(()=>{e._timeoutError("Timeout of ",e._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(()=>{e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")},this._responseTimeout))},g);No=Ys;function Ys(){}function Ks(e,t){var r,n,o,i,s="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(s)return o=!(n=!0),{s:function(){s=s.call(e)},n:function(){var e=s.next();return n=e.done,e},e:function(e){o=!0,r=e},f:function(){try{n||null==s.return||s.return()}finally{if(o)throw r}}};if(Array.isArray(e)||(s=(e=>{var t;if(e)return"string"==typeof e?zs(e,void 0):"Map"===(t="Object"===(t=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?zs(e,void 0):void 0})(e))||t&&e&&"number"==typeof e.length)return s&&(e=s),i=0,{s:t=function(){},n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function zs(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Gs(){this._defaults=[]}Ys.prototype.get=function(e){return this.header[e.toLowerCase()]},Ys.prototype._setHeaderProperties=function(e){var t=e["content-type"]||"",r=(this.type=qs.type(t),qs.params(t));for(let e in r)Object.prototype.hasOwnProperty.call(r,e)&&(this[e]=r[e]);this.links={};try{e.link&&(this.links=qs.parseLinks(e.link))}catch(e){}},Ys.prototype._setStatusProperties=function(e){var t=Math.trunc(e/100);this.statusCode=e,this.status=this.statusCode,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.created=201===e,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,this.unprocessableEntity=422===e};for(var Xs=0,Bs=["use","on","once","set","query","type","accept","auth","withCredentials","sortQuery","retry","ok","redirects","timeout","buffer","serialize","parse","ca","key","pfx","cert","disableTLSCerts"];Xs<Bs.length;Xs++){let n=Bs[Xs];Gs.prototype[n]=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return this._defaults.push({fn:n,args:t}),this}}Gs.prototype._setDefaults=function(t){var r,e=Ks(this._defaults);try{for(e.s();!(r=e.n()).done;){let e=r.value;t[e.fn](...e.args)}}catch(t){e.e(t)}finally{e.f()}};So=Gs;{var Vs=h,Ws=h.exports;function Js(e,t){var r,n,o,i,s="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(s)return o=!(n=!0),{s:function(){s=s.call(e)},n:function(){var e=s.next();return n=e.done,e},e:function(e){o=!0,r=e},f:function(){try{n||null==s.return||s.return()}finally{if(o)throw r}}};if(Array.isArray(e)||(s=(e=>{var t;if(e)return"string"==typeof e?$s(e,void 0):"Map"===(t="Object"===(t=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?$s(e,void 0):void 0})(e))||t&&e&&"number"==typeof e.length)return s&&(e=s),i=0,{s:t=function(){},n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function $s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}let e,t=(e="undefined"!=typeof window?window:"undefined"==typeof self?void console.warn("Using browser-only version of superagent in non-browser environment"):self,p.exports),r=f,n=xo,o=Eo,s=g.isObject,i=g.mixin,a=g.hasOwn,c=No,u=So;function Qs(){}Vs.exports=function(e,t){return"function"==typeof t?new Ws.Request("GET",e).end(t):1===arguments.length?new Ws.Request("GET",e):new Ws.Request(e,t)};let d=Ws=Vs.exports,l=(Ws.Request=U,d.getXHR=()=>{if(e.XMLHttpRequest)return new e.XMLHttpRequest;throw new Error("Browser-only version of superagent could not find XHR")},"".trim?e=>e.trim():e=>e.replace(/(^\s*|\s*$)/g,""));function Zs(e){if(!s(e))return e;var t,r=[];for(t in e)a(e,t)&&function t(r,n,o){if(void 0!==o)if(null!==o)if(Array.isArray(o)){var e,i=Js(o);try{for(i.s();!(e=i.n()).done;)t(r,n,e.value)}catch(r){i.e(r)}finally{i.f()}}else if(s(o))for(let e in o)a(o,e)&&t(r,`${n}[${e}]`,o[e]);else r.push(encodeURI(n)+"="+encodeURIComponent(o));else r.push(encodeURI(n))}(r,t,e[t]);return r.join("&")}function ea(e){var r,n,o={},i=e.split("&");for(let e=0,t=i.length;e<t;++e)-1===(n=(r=i[e]).indexOf("="))?o[decodeURIComponent(r)]="":o[decodeURIComponent(r.slice(0,n))]=decodeURIComponent(r.slice(n+1));return o}function ta(e){return/[/+]json($|[^-\w])/i.test(e)}function ra(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;let t=this.xhr.status;1223===t&&(t=204),this._setStatusProperties(t),this.headers=(e=>{var r,n,o,i=e.split(/\r?\n/),s={};for(let e=0,t=i.length;e<t;++e)-1!==(r=(o=i[e]).indexOf(":"))&&(n=o.slice(0,r).toLowerCase(),o=l(o.slice(r+1)),s[n]=o);return s})(this.xhr.getAllResponseHeaders()),this.header=this.headers,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?null:this._parseBody(this.text||this.xhr.response)}function U(e,t){let n=this;this._query=this._query||[],this.method=e,this.url=t,this.header={},this._header={},this.on("end",()=>{let e,t=null,r=null;try{r=new ra(n)}catch(e){return(t=new Error("Parser is unable to parse the response")).parse=!0,t.original=e,n.xhr?(t.rawResponse=void 0===n.xhr.responseType?n.xhr.responseText:n.xhr.response,t.status=n.xhr.status||null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),n.callback(t)}n.emit("response",r);try{n._isResponseOK(r)||(e=new Error(r.statusText||r.text||"Unsuccessful HTTP response"))}catch(t){e=t}e?(e.original=t,e.response=r,e.status=e.status||r.status,n.callback(e,r)):n.callback(null,r)})}d.serializeObject=Zs,d.parseString=ea,d.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"},d.serialize={"application/x-www-form-urlencoded":n.stringify,"application/json":r},d.parse={"application/x-www-form-urlencoded":ea,"application/json":JSON.parse},i(ra.prototype,c.prototype),ra.prototype._parseBody=function(e){let t=d.parse[this.type];return this.req._parser?this.req._parser(this,e):(t=!t&&ta(this.type)?d.parse["application/json"]:t)&&e&&(0<e.length||e instanceof Object)?t(e):null},ra.prototype.toError=function(){var e=this.req,t=e.method,e=e.url,r=`cannot ${t} ${e} (${this.status})`,r=new Error(r);return r.status=this.status,r.method=t,r.url=e,r},d.Response=ra,t(U.prototype),i(U.prototype,o.prototype),U.prototype.type=function(e){return this.set("Content-Type",d.types[e]||e),this},U.prototype.accept=function(e){return this.set("Accept",d.types[e]||e),this},U.prototype.auth=function(e,t,r){"object"==typeof(t=1===arguments.length?"":t)&&null!==t&&(r=t,t="");var n=(r=r||{type:"function"==typeof btoa?"basic":"auto"}).encoder||(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)},U.prototype.query=function(e){return(e="string"!=typeof e?Zs(e):e)&&this._query.push(e),this},U.prototype.attach=function(e,t,r){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,r||t.name)}return this},U.prototype._getFormData=function(){return this._formData||(this._formData=new e.FormData),this._formData},U.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)},U.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)},U.prototype.buffer=U.prototype.ca=U.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},U.prototype.pipe=U.prototype.write=()=>{throw new Error("Streaming is not supported in browser version of superagent")},U.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},U.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||Qs,this._finalizeQueryString(),this._end()},U.prototype._setUploadTimeout=function(){let e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout(()=>{e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")},this._uploadTimeout))},U.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));let r=this,n=(this.xhr=d.getXHR(),this.xhr),o=this._formData||this._data;this._setTimeouts(),n.addEventListener("readystatechange",()=>{var e=n.readyState;if(2<=e&&r._responseTimeoutTimer&&clearTimeout(r._responseTimeoutTimer),4===e){let t;try{t=n.status}catch(e){t=0}if(!t)return r.timedout||r._aborted?void 0:r.crossDomainError();r.emit("end")}});var e=(e,t)=>{0<t.total&&(t.percent=t.loaded/t.total*100,100===t.percent)&&clearTimeout(r._uploadTimeoutTimer),t.direction=e,r.emit("progress",t)};if(this.hasListeners("progress"))try{n.addEventListener("progress",e.bind(null,"download")),n.upload&&n.upload.addEventListener("progress",e.bind(null,"upload"))}catch(r){}n.upload&&this._setUploadTimeout();try{this.username&&this.password?n.open(this.method,this.url,!0,this.username,this.password):n.open(this.method,this.url,!0)}catch(r){return this.callback(r)}if(this._withCredentials&&(n.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof o&&!this._isHost(o)){let e=this._header["content-type"],t=this._serializer||d.serialize[e?e.split(";")[0]:""];(t=!t&&ta(e)?d.serialize["application/json"]:t)&&(o=t(o))}for(let e in this.header)null!==this.header[e]&&a(this.header,e)&&n.setRequestHeader(e,this.header[e]);this._responseType&&(n.responseType=this._responseType),this.emit("request",this),n.send(void 0===o?null:o)},d.agent=()=>new u;for(var na=0,oa=["GET","POST","OPTIONS","PATCH","PUT","DELETE"];na<oa.length;na++){let r=oa[na];u.prototype[r.toLowerCase()]=function(e,t){e=new d.Request(r,e);return this._setDefaults(e),t&&e.end(t),e}}function ia(e,t,r){e=d("DELETE",e);return"function"==typeof t&&(r=t,t=null),t&&e.send(t),r&&e.end(r),e}u.prototype.del=u.prototype.delete,d.get=(e,t,r)=>{e=d("GET",e);return"function"==typeof t&&(r=t,t=null),t&&e.query(t),r&&e.end(r),e},d.head=(e,t,r)=>{e=d("HEAD",e);return"function"==typeof t&&(r=t,t=null),t&&e.query(t),r&&e.end(r),e},d.options=(e,t,r)=>{e=d("OPTIONS",e);return"function"==typeof t&&(r=t,t=null),t&&e.send(t),r&&e.end(r),e},d.del=ia,d.delete=ia,d.patch=(e,t,r)=>{e=d("PATCH",e);return"function"==typeof t&&(r=t,t=null),t&&e.send(t),r&&e.end(r),e},d.post=(e,t,r)=>{e=d("POST",e);return"function"==typeof t&&(r=t,t=null),t&&e.send(t),r&&e.end(r),e},d.put=(e,t,r)=>{e=d("PUT",e);return"function"==typeof t&&(r=t,t=null),t&&e.send(t),r&&e.end(r),e}}var sa=h.exports;function aa(n){var o=(new Date).getTime(),e=(new Date).toISOString(),i=(!console||!console.log)&&window&&window.console&&window.console.log?window.console:console;i.log("<<<<<"),i.log("[".concat(e,"]"),"\n",n.url,"\n",n.qs),i.log("-----"),n.on("response",function(e){var t=(new Date).getTime()-o,r=(new Date).toISOString();i.log(">>>>>>"),i.log("[".concat(r," / ").concat(t,"]"),"\n",n.url,"\n",n.qs,"\n",e.text),i.log("-----")})}function ca(e,o,i){var t,s=this,r=(this._config.logVerbosity&&(e=e.use(aa)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),e=this._config.keepAlive&&this._modules.keepAlive?this._modules.keepAlive(e):e);return o.abortSignal&&(t=o.abortSignal.subscribe(function(){r.abort(),t()})),!0===o.forceBuffered?r=("undefined"==typeof Blob?r.buffer():r).responseType("arraybuffer"):!1===o.forceBuffered&&(r=r.buffer(!1)),(r=r.timeout(o.timeout)).on("abort",function(){return i({category:v.PNUnknownCategory,error:!0,operation:o.operation,errorData:new Error("Aborted")},null)}),r.end(function(t,e){var r,n={};if(n.error=null!==t,n.operation=o.operation,e&&e.status&&(n.statusCode=e.status),t){if(t.response&&t.response.text&&!s._config.logVerbosity)try{n.errorData=JSON.parse(t.response.text)}catch(e){n.errorData=t}else n.errorData=t;return n.category=s._detectErrorCategory(t),i(n,null)}if(o.ignoreBody)r={headers:e.headers,redirects:e.redirects,response:e};else try{r=JSON.parse(e.text)}catch(t){return n.errorData=e,n.error=!0,i(n,null)}return r.error&&1===r.error&&r.status&&r.message&&r.service?(n.errorData=r,n.statusCode=r.status,n.error=!0,n.category=s._detectErrorCategory(n),i(n,null)):(r.error&&r.error.message&&(n.errorData=r.error),i(n,r))}),r}function ua(t,n,o){return _(this,void 0,void 0,function(){var r;return F(this,function(e){switch(e.label){case 0:return r=sa.post(t),n.forEach(function(e){var t=e.key;r=r.field(t,e.value)}),r.attach("file",o,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,e.sent()]}})})}function da(e,t,r){e=sa.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ca.call(this,e,t,r)}function la(e,t,r){e=sa.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ca.call(this,e,t,r)}function pa(e,t,r,n){e=sa.post(this.getStandardOrigin()+r.url).query(e).set(r.headers).send(t);return ca.call(this,e,r,n)}function fa(e,t,r,n){e=sa.patch(this.getStandardOrigin()+r.url).query(e).set(r.headers).send(t);return ca.call(this,e,r,n)}function ha(e,t,r){e=sa.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ca.call(this,e,t,r)}function ga(e,t){var r=new Uint8Array(e.byteLength+t.byteLength);return r.set(new Uint8Array(e),0),r.set(new Uint8Array(t),e.byteLength),r.buffer}Object.defineProperty(C.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),C.prototype.encrypt=function(r,n){return _(this,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:return[4,this.getKey(r)];case 1:if(t=e.sent(),n instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(t,n)];if("string"==typeof n)return[2,this.encryptString(t,n)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}})})},C.prototype.decrypt=function(r,n){return _(this,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:return[4,this.getKey(r)];case 1:if(t=e.sent(),n instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(t,n)];if("string"==typeof n)return[2,this.decryptString(t,n)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}})})},C.prototype.encryptFile=function(n,o,i){return _(this,void 0,void 0,function(){var t,r;return F(this,function(e){switch(e.label){case 0:if(o.data.byteLength<=0)throw new Error("encryption error. empty content");return[4,this.getKey(n)];case 1:return t=e.sent(),[4,o.data.arrayBuffer()];case 2:return r=e.sent(),[4,this.encryptArrayBuffer(t,r)];case 3:return r=e.sent(),[2,i.create({name:o.name,mimeType:"application/octet-stream",data:r})]}})})},C.prototype.decryptFile=function(n,o,i){return _(this,void 0,void 0,function(){var t,r;return F(this,function(e){switch(e.label){case 0:return[4,this.getKey(n)];case 1:return t=e.sent(),[4,o.data.arrayBuffer()];case 2:return r=e.sent(),[4,this.decryptArrayBuffer(t,r)];case 3:return r=e.sent(),[2,i.create({name:o.name,data:r})]}})})},C.prototype.getKey=function(r){return _(this,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:return[4,crypto.subtle.digest("SHA-256",C.encoder.encode(r))];case 1:return t=e.sent(),t=Array.from(new Uint8Array(t)).map(function(e){return e.toString(16).padStart(2,"0")}).join(""),t=C.encoder.encode(t.slice(0,32)).buffer,[2,crypto.subtle.importKey("raw",t,"AES-CBC",!0,["encrypt","decrypt"])]}})})},C.prototype.encryptArrayBuffer=function(o,i){return _(this,void 0,void 0,function(){var t,r,n;return F(this,function(e){switch(e.label){case 0:return t=crypto.getRandomValues(new Uint8Array(16)),r=ga,n=[t.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:t},o,i)];case 1:return[2,r.apply(void 0,n.concat([e.sent()]))]}})})},C.prototype.decryptArrayBuffer=function(r,n){return _(this,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:if(t=n.slice(0,16),n.slice(C.IV_LENGTH).byteLength<=0)throw new Error("decryption error: empty content");return[4,crypto.subtle.decrypt({name:"AES-CBC",iv:t},r,n.slice(C.IV_LENGTH))];case 1:return[2,e.sent()]}})})},C.prototype.encryptString=function(o,i){return _(this,void 0,void 0,function(){var t,r,n;return F(this,function(e){switch(e.label){case 0:return t=crypto.getRandomValues(new Uint8Array(16)),r=C.encoder.encode(i).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:t},o,r)];case 1:return r=e.sent(),n=ga(t.buffer,r),[2,C.decoder.decode(n)]}})})},C.prototype.decryptString=function(n,o){return _(this,void 0,void 0,function(){var t,r;return F(this,function(e){switch(e.label){case 0:return t=C.encoder.encode(o).buffer,r=t.slice(0,16),t=t.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},n,t)];case 1:return r=e.sent(),[2,C.decoder.decode(r)]}})})},C.IV_LENGTH=16,C.encoder=new TextEncoder,C.decoder=new TextDecoder;var ya,ma=C,Ra=(Pa.create=function(e){return new this(e)},Pa.prototype.toBuffer=function(){return _(this,void 0,void 0,function(){return F(this,function(e){throw new Error("This feature is only supported in Node.js environments.")})})},Pa.prototype.toStream=function(){return _(this,void 0,void 0,function(){return F(this,function(e){throw new Error("This feature is only supported in Node.js environments.")})})},Pa.prototype.toFileUri=function(){return _(this,void 0,void 0,function(){return F(this,function(e){throw new Error("This feature is only supported in react native environments.")})})},Pa.prototype.toBlob=function(){return _(this,void 0,void 0,function(){return F(this,function(e){return[2,this.data]})})},Pa.prototype.toArrayBuffer=function(){return _(this,void 0,void 0,function(){var n=this;return F(this,function(e){return[2,new Promise(function(e,t){var r=new FileReader;r.addEventListener("load",function(){if(r.result instanceof ArrayBuffer)return e(r.result)}),r.addEventListener("error",function(){t(r.error)}),r.readAsArrayBuffer(n.data)})]})})},Pa.prototype.toString=function(){return _(this,void 0,void 0,function(){var n=this;return F(this,function(e){return[2,new Promise(function(e,t){var r=new FileReader;r.addEventListener("load",function(){if("string"==typeof r.result)return e(r.result)}),r.addEventListener("error",function(){t(r.error)}),r.readAsBinaryString(n.data)})]})})},Pa.prototype.toFile=function(){return _(this,void 0,void 0,function(){return F(this,function(e){return[2,this.data]})})},(d=Pa).supportsFile="undefined"!=typeof File,d.supportsBlob="undefined"!=typeof Blob,d.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,d.supportsBuffer=!1,d.supportsStream=!1,d.supportsString=!0,d.supportsEncryptFile=!0,d.supportsFileUri=!1,d),_a=(Object.defineProperty(Sa.prototype,"identifier",{get:function(){return""},enumerable:!1,configurable:!0}),Sa.prototype.encrypt=function(e){e="string"==typeof e?e:(new TextDecoder).decode(e);return{data:this.cryptor.encrypt(e),metadata:null}},Sa.prototype.decrypt=function(e){e="string"==typeof e.data?e.data:Z(e.data);return this.cryptor.decrypt(e)},Sa.prototype.encryptFile=function(t,r){var n;return _(this,void 0,void 0,function(){return F(this,function(e){return[2,this.fileCryptor.encryptFile(null==(n=this.config)?void 0:n.cipherKey,t,r)]})})},Sa.prototype.decryptFile=function(t,r){return _(this,void 0,void 0,function(){return F(this,function(e){return[2,this.fileCryptor.decryptFile(this.config.cipherKey,t,r)]})})},Sa),Aa=(Object.defineProperty(j.prototype,"algo",{get:function(){return"AES-CBC"},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"identifier",{get:function(){return"ACRH"},enumerable:!1,configurable:!0}),j.prototype.getIv=function(){return crypto.getRandomValues(new Uint8Array(j.BLOCK_SIZE))},j.prototype.getKey=function(){return _(this,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:return t=j.encoder.encode(this.cipherKey),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return t=e.sent(),[2,crypto.subtle.importKey("raw",t,this.algo,!0,["encrypt","decrypt"])]}})})},j.prototype.encrypt=function(e){if(0===("string"==typeof e?e:j.decoder.decode(e)).length)throw new Error("encryption error. empty content");var t=this.getIv();return{metadata:t,data:Q(this.CryptoJS.AES.encrypt(e,this.encryptedKey,{iv:this.bufferToWordArray(t),mode:this.CryptoJS.mode.CBC}).ciphertext.toString(this.CryptoJS.enc.Base64))}},j.prototype.decrypt=function(e){var t=this.bufferToWordArray(new Uint8ClampedArray(e.metadata)),e=this.bufferToWordArray(new Uint8ClampedArray(e.data));return j.encoder.encode(this.CryptoJS.AES.decrypt({ciphertext:e},this.encryptedKey,{iv:t,mode:this.CryptoJS.mode.CBC}).toString(this.CryptoJS.enc.Utf8)).buffer},j.prototype.encryptFileData=function(o){return _(this,void 0,void 0,function(){var t,r,n;return F(this,function(e){switch(e.label){case 0:return[4,this.getKey()];case 1:return t=e.sent(),r=this.getIv(),n={},[4,crypto.subtle.encrypt({name:this.algo,iv:r},t,o)];case 2:return[2,(n.data=e.sent(),n.metadata=r,n)]}})})},j.prototype.decryptFileData=function(r){return _(this,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:return[4,this.getKey()];case 1:return t=e.sent(),[2,crypto.subtle.decrypt({name:this.algo,iv:r.metadata},t,r.data)]}})})},j.prototype.bufferToWordArray=function(e){for(var t=[],r=0;r<e.length;r+=1)t[r/4|0]|=e[r]<<24-8*r;return this.CryptoJS.lib.WordArray.create(t,e.length)},j.BLOCK_SIZE=16,j.encoder=new TextEncoder,j.decoder=new TextDecoder,j),ba=(k.legacyCryptoModule=function(e){var t;return new this({default:new _a({cipherKey:e.cipherKey,useRandomIVs:null==(t=e.useRandomIVs)||t}),cryptors:[new Aa({cipherKey:e.cipherKey})]})},k.aesCbcCryptoModule=function(e){return new this({default:new Aa({cipherKey:e.cipherKey}),cryptors:[new _a({cipherKey:e.cipherKey,useRandomIVs:null==(e=e.useRandomIVs)||e})]})},k.withDefaultCryptor=function(e){return new this({default:e})},k.prototype.getAllCryptors=function(){return b([this.defaultCryptor],A(this.cryptors),!1)},k.prototype.encrypt=function(e){var t,e=this.defaultCryptor.encrypt(e);return e.metadata?(t=this.getHeaderData(e),this.concatArrayBuffer(t,e.data)):e.data},k.prototype.decrypt=function(e){var e="string"==typeof e?Q(e):e,t=va.tryParse(e),r=this.getCryptor(t),n=0<t.length?e.slice(t.length-t.metadataLength,t.length):null;if(e.slice(t.length).byteLength<=0)throw new Error("decryption error. empty content");return r.decrypt({data:e.slice(t.length),metadata:n})},k.prototype.encryptFile=function(r,n){return _(this,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:return this.defaultCryptor.identifier===va.LEGACY_IDENTIFIER?[2,this.defaultCryptor.encryptFile(r,n)]:[4,this.getFileData(r.data)];case 1:return t=e.sent(),[4,this.defaultCryptor.encryptFileData(t)];case 2:return t=e.sent(),[2,n.create({name:r.name,mimeType:"application/octet-stream",data:this.concatArrayBuffer(this.getHeaderData(t),t.data)})]}})})},k.prototype.decryptFile=function(c,u){return _(this,void 0,void 0,function(){var t,r,n,o,i,s,a;return F(this,function(e){switch(e.label){case 0:return[4,c.data.arrayBuffer()];case 1:return t=e.sent(),r=va.tryParse(t),(null==(n=this.getCryptor(r))?void 0:n.identifier)===k.LEGACY_IDENTIFIER?[2,n.decryptFile(c,u)]:[4,this.getFileData(t)];case 2:return n=e.sent(),o=n.slice(r.length-r.metadataLength,r.length),s=(i=u).create,a={name:c.name},[4,this.defaultCryptor.decryptFileData({data:t.slice(r.length),metadata:o})];case 3:return[2,s.apply(i,[(a.data=e.sent(),a)])]}})})},k.prototype.getCryptor=function(e){if(""===e){var t=this.getAllCryptors().find(function(e){return""===e.identifier});if(t)return t;throw new Error("unknown cryptor error")}if(e instanceof Ia)return this.getCryptorFromId(e.identifier)},k.prototype.getCryptorFromId=function(t){var e=this.getAllCryptors().find(function(e){return t===e.identifier});if(e)return e;throw Error("unknown cryptor error")},k.prototype.concatArrayBuffer=function(e,t){var r=new Uint8Array(e.byteLength+t.byteLength);return r.set(new Uint8Array(e),0),r.set(new Uint8Array(t),e.byteLength),r.buffer},k.prototype.getHeaderData=function(e){var t,r,n;if(e.metadata)return t=va.from(this.defaultCryptor.identifier,e.metadata),(r=new Uint8Array(t.length)).set(t.data,n=0),n+=t.length-e.metadata.byteLength,r.set(new Uint8Array(e.metadata),n),r.buffer},k.prototype.getFileData=function(t){return _(this,void 0,void 0,function(){return F(this,function(e){switch(e.label){case 0:return t instanceof Blob?[4,t.arrayBuffer()]:[3,2];case 1:return[2,e.sent()];case 2:if(t instanceof ArrayBuffer)return[2,t];if("string"==typeof t)return[2,k.encoder.encode(t)];throw new Error("Cannot decrypt/encrypt file. In browsers file encrypt/decrypt supported for string, ArrayBuffer or Blob")}})})},k.LEGACY_IDENTIFIER="",k.encoder=new TextEncoder,k.decoder=new TextDecoder,k),va=(Ea.from=function(e,t){if(e!==Ea.LEGACY_IDENTIFIER)return new Ia(e,t.byteLength)},Ea.tryParse=function(e){e=new Uint8Array(e);if(4<=e.byteLength&&(t=e.slice(0,4),this.decoder.decode(t)!==Ea.SENTINEL))return"";if(!(5<=e.byteLength))throw new Error("decryption error. invalid header version");if(Ea.MAX_VERSION<e[4])throw new Error("unknown cryptor error");var t=5+Ea.IDENTIFIER_LENGTH;if(!(t<=e.byteLength))throw new Error("decryption error. invalid crypto identifier");var r=e.slice(5,t),n=null;if(e.byteLength>=t+1)return n=e[t],t+=1,255===n&&e.byteLength>=t+2&&(n=new Uint16Array(e.slice(t,t+2)).reduce(function(e,t){return(e<<8)+t},0),0),new Ia(this.decoder.decode(r),n);throw new Error("decryption error. invalid metadata length")},Ea.SENTINEL="PNED",Ea.LEGACY_IDENTIFIER="",Ea.IDENTIFIER_LENGTH=4,Ea.VERSION=1,Ea.MAX_VERSION=1,Ea.decoder=new TextDecoder,Ea),Ia=(Object.defineProperty(Ta.prototype,"identifier",{get:function(){return this._identifier},set:function(e){this._identifier=e},enumerable:!1,configurable:!0}),Object.defineProperty(Ta.prototype,"metadataLength",{get:function(){return this._metadataLength},set:function(e){this._metadataLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(Ta.prototype,"version",{get:function(){return va.VERSION},enumerable:!1,configurable:!0}),Object.defineProperty(Ta.prototype,"length",{get:function(){return va.SENTINEL.length+1+va.IDENTIFIER_LENGTH+(this.metadataLength<255?1:3)+this.metadataLength},enumerable:!1,configurable:!0}),Object.defineProperty(Ta.prototype,"data",{get:function(){var e=0,t=new Uint8Array(this.length),r=new TextEncoder,r=(t.set(r.encode(va.SENTINEL)),t[e+=va.SENTINEL.length]=this.version,e++,this.identifier&&t.set(r.encode(this.identifier),e),e+=va.IDENTIFIER_LENGTH,this.metadataLength);return r<255?t[e]=r:t.set([255,r>>8,255&r],e),t},enumerable:!1,configurable:!0}),Ta.IDENTIFIER_LENGTH=4,Ta.SENTINEL="PNED",Ta);function Ta(e,t){this._identifier=e,this._metadataLength=t}function Ea(){}function k(e){this.defaultCryptor=e.default,this.cryptors=null!=(e=e.cryptors)?e:[]}function j(e){this.cipherKey=e.cipherKey,this.CryptoJS=c,this.encryptedKey=this.CryptoJS.SHA256(this.cipherKey)}function Sa(e){this.config=e,this.cryptor=new at({config:e}),this.fileCryptor=new ma}function Pa(e){var t;if(e instanceof File?(this.data=e,this.name=this.data.name,this.mimeType=this.data.type):e.data&&(t=e.data,this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType)&&(this.mimeType=e.mimeType),void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}function C(){}function Oa(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}function wa(e){var t=this,r=e.listenToBrowserNetworkEvents,r=void 0===r||r;return e.sdkFamily="Web",e.networking=new ro({del:ha,get:la,post:pa,patch:fa,sendBeacon:Oa,getfile:da,postfile:ua}),e.cbor=new uo(function(e){return co(X.decode(e))},Q),e.PubNubFile=Ra,e.cryptography=new ma,e.initCryptoModule=function(e){return new ba({default:new _a({cipherKey:e.cipherKey,useRandomIVs:e.useRandomIVs}),cryptors:[new Aa({cipherKey:e.cipherKey})]})},t=ya.call(this,e)||this,r&&(window.addEventListener("offline",function(){t.networkDownDetected()}),window.addEventListener("online",function(){t.networkUpDetected()})),t}return D(wa,ya=t),wa.CryptoModule=ba,wa},"object"==typeof n&&void 0!==r?r.exports=t():(e="undefined"!=typeof globalThis?globalThis:e||self).PubNub=t()}.call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:40}],42:[function(e,n,o){!function(te){function e(){var a=!1;try{throw new Error}catch(e){a=!!e.stack}function t(){}var i,e,r,n,o,s,c,u,d,l,L=z();function p(){for(var e,t;o.next;)e=(o=o.next).task,o.task=void 0,(t=o.domain)&&(o.domain=void 0,t.enter()),f(e,t);for(;l.length;)f(e=l.pop());c=!1}function f(e,t){try{e()}catch(e){if(d)throw t&&t.exit(),setTimeout(p,0),t&&t.enter(),e;setTimeout(function(){throw e},0)}t&&t.exit()}s=o={task:void 0,next:null},u=void 0,d=c=!1,l=[],e=function(e){s=s.next={task:e,domain:d&&te.domain,next:null},c||(c=!0,u())},u="object"==typeof te&&"[object process]"===te.toString()&&te.nextTick?(d=!0,function(){te.nextTick(p)}):"function"==typeof setImmediate?"undefined"!=typeof window?setImmediate.bind(window,p):function(){setImmediate(p)}:"undefined"!=typeof MessageChannel?((r=new MessageChannel).port1.onmessage=function(){u=n,(r.port1.onmessage=p)()},n=function(){r.port2.postMessage(0)},function(){setTimeout(p,0),n()}):function(){setTimeout(p,0)},e.runAfter=function(e){l.push(e),c||(c=!0,u())};var N=Function.call;function h(e){return function(){return N.apply(e,arguments)}}var g=h(Array.prototype.slice),y=h(Array.prototype.reduce||function(e,t){var r=0,n=this.length;if(1===arguments.length)for(;;){if(r in this){t=this[r++];break}if(++r>=n)throw new TypeError}for(;r<n;r++)r in this&&(t=e(t,this[r],r));return t}),m=h(Array.prototype.indexOf||function(e){for(var t=0;t<this.length;t++)if(this[t]===e)return t;return-1}),R=h(Array.prototype.map||function(n,o){var i=this,s=[];return y(i,function(e,t,r){s.push(n.call(o,t,r,i))},void 0),s}),_=Object.create||function(e){function t(){}return t.prototype=e,new t},H=h(Object.prototype.hasOwnProperty),M=Object.keys||function(e){var t,r=[];for(t in e)H(e,t)&&r.push(t);return r},F=h(Object.prototype.toString),A="undefined"!=typeof ReturnValue?ReturnValue:function(e){this.value=e},q="From previous event:";function Y(e,t){if(a&&t.stack&&"object"==typeof e&&null!==e&&e.stack&&-1===e.stack.indexOf(q)){for(var r=[],n=t;n;n=n.source)n.stack&&r.unshift(n.stack);r.unshift(e.stack);t=r.join("\n"+q+"\n");e.stack=(e=>{for(var t=e.split("\n"),r=[],n=0;n<t.length;++n){var o=t[n];(e=>{var t;return(e=K(e))&&(t=e[0],e=e[1],t===i)&&L<=e&&e<=ee})(o)||(e=>-1!==e.indexOf("(module.js:")||-1!==e.indexOf("(node.js:"))(o)||!o||r.push(o)}return r.join("\n")})(t)}}function K(e){var t=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(e);return(t=t||/at ([^ ]+):(\d+):(?:\d+)$/.exec(e))?[t[1],Number(t[2])]:(t=/.*@(.+):(\d+)$/.exec(e))?[t[1],Number(t[2])]:void 0}function z(){if(a)try{throw new Error}catch(e){var t=e.stack.split("\n"),t=K(0<t[0].indexOf("@")?t[1]:t[2]);if(t)return i=t[0],t[1]}}function b(e){return e instanceof T?e:B(e)?(t=e,r=v(),b.nextTick(function(){try{t.then(r.resolve,r.reject,r.notify)}catch(e){r.reject(e)}}),r.promise):x(e);var t,r}function v(){var o,i=[],s=[],e=_(v.prototype),t=_(T.prototype);if(t.promiseDispatch=function(e,t,r){var n=g(arguments);i?(i.push(n),"when"===t&&r[1]&&s.push(r[1])):b.nextTick(function(){o.promiseDispatch.apply(o,n)})},t.valueOf=function(){var e;return i?t:(S(e=X(o))&&(o=e),e)},t.inspect=function(){return o?o.inspect():{state:"pending"}},b.longStackSupport&&a)try{throw new Error}catch(e){t.stack=e.stack.substring(e.stack.indexOf("\n")+1)}function r(r){o=r,t.source=r,y(i,function(e,t){b.nextTick(function(){r.promiseDispatch.apply(r,t)})},void 0),s=i=void 0}return e.promise=t,e.resolve=function(e){o||r(b(e))},e.fulfill=function(e){o||r(x(e))},e.reject=function(e){o||r(C(e))},e.notify=function(r){o||y(s,function(e,t){b.nextTick(function(){t(r)})},void 0)},e}function I(e){if("function"!=typeof e)throw new TypeError("resolver must be a function.");var t=v();try{e(t.resolve,t.reject,t.notify)}catch(e){t.reject(e)}return t.promise}function G(o){return I(function(e,t){for(var r=0,n=o.length;r<n;r++)b(o[r]).then(e,t)})}function T(o,i,t){void 0===i&&(i=function(e){return C(new Error("Promise does not support operation: "+e))}),void 0===t&&(t=function(){return{state:"unknown"}});var e,s=_(T.prototype);return s.promiseDispatch=function(e,t,r){var n;try{n=o[t]?o[t].apply(s,r):i.call(s,t,r)}catch(e){n=C(e)}e&&e(n)},(s.inspect=t)&&("rejected"===(e=t()).state&&(s.exception=e.reason),s.valueOf=function(){var e=t();return"pending"===e.state||"rejected"===e.state?s:e.value}),s}function E(e,t,r,n){return b(e).then(t,r,n)}function X(e){if(S(e)){var t=e.inspect();if("fulfilled"===t.state)return t.value}return e}function S(e){return e instanceof T}function B(e){return e===Object(e)&&"function"==typeof e.then}(b.resolve=b).nextTick=e,b.longStackSupport=!1,"object"==typeof te&&te&&te.env&&te.env.Q_DEBUG&&(b.longStackSupport=!0),(b.defer=v).prototype.makeNodeResolver=function(){var r=this;return function(e,t){e?r.reject(e):2<arguments.length?r.resolve(g(arguments,1)):r.resolve(t)}},b.Promise=I,(b.promise=I).race=G,I.all=D,I.reject=C,(I.resolve=b).passByCopy=function(e){return e},T.prototype.passByCopy=function(){return this},b.join=function(e,t){return b(e).join(t)},T.prototype.join=function(e){return b([this,e]).spread(function(e,t){if(e===t)return e;throw new Error("Can't join: not the same: "+e+" "+t)})},b.race=G,T.prototype.race=function(){return this.then(b.race)},(b.makePromise=T).prototype.toString=function(){return"[object Promise]"},T.prototype.then=function(t,r,o){var n=this,i=v(),s=!1;return b.nextTick(function(){n.promiseDispatch(function(e){s||(s=!0,i.resolve((e=>{try{return"function"==typeof t?t(e):e}catch(e){return C(e)}})(e)))},"when",[function(e){s||(s=!0,i.resolve((e=>{if("function"==typeof r){Y(e,n);try{return r(e)}catch(e){return C(e)}}return C(e)})(e)))}])}),n.promiseDispatch(void 0,"when",[void 0,function(e){var t,r,n=!1;try{r=e,t="function"==typeof o?o(r):r}catch(e){if(n=!0,!b.onerror)throw e;b.onerror(e)}n||i.notify(t)}]),i.promise},b.tap=function(e,t){return b(e).tap(t)},T.prototype.tap=function(t){return t=b(t),this.then(function(e){return t.fcall(e).thenResolve(e)})},b.when=E,T.prototype.thenResolve=function(e){return this.then(function(){return e})},b.thenResolve=function(e,t){return b(e).thenResolve(t)},T.prototype.thenReject=function(e){return this.then(function(){throw e})},b.thenReject=function(e,t){return b(e).thenReject(t)},b.nearer=X,b.isPromise=S,b.isPromiseAlike=B,b.isPending=function(e){return S(e)&&"pending"===e.inspect().state},T.prototype.isPending=function(){return"pending"===this.inspect().state},b.isFulfilled=function(e){return!S(e)||"fulfilled"===e.inspect().state},T.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},b.isRejected=function(e){return S(e)&&"rejected"===e.inspect().state},T.prototype.isRejected=function(){return"rejected"===this.inspect().state};var P,V,W,O=[],w=[],U=[],k=!0;function j(){O.length=0,w.length=0,k=k||!0}function C(n){var e,t,r=T({when:function(e){var t,r;return e&&(t=this,k)&&-1!==(r=m(w,t))&&("object"==typeof te&&"function"==typeof te.emit&&b.nextTick.runAfter(function(){var e=m(U,t);-1!==e&&(te.emit("rejectionHandled",O[r],t),U.splice(e,1))}),w.splice(r,1),O.splice(r,1)),e?e(n):this}},function(){return this},function(){return{state:"rejected",reason:n}});return e=r,t=n,k&&("object"==typeof te&&"function"==typeof te.emit&&b.nextTick.runAfter(function(){-1!==m(w,e)&&(te.emit("unhandledRejection",t,e),U.push(e))}),w.push(e),t&&void 0!==t.stack?O.push(t.stack):O.push("(no stack) "+t)),r}function x(r){return T({when:function(){return r},get:function(e){return r[e]},set:function(e,t){r[e]=t},delete:function(e){delete r[e]},post:function(e,t){return null==e?r.apply(void 0,t):r[e].apply(r,t)},apply:function(e,t){return r.apply(e,t)},keys:function(){return M(r)}},void 0,function(){return{state:"fulfilled",value:r}})}function J(e,t,r){return b(e).spread(t,r)}function $(e,t,r){return b(e).dispatch(t,r)}function D(e){return E(e,function(o){var i=0,s=v();return y(o,function(e,t,r){var n;S(t)&&"fulfilled"===(n=t.inspect()).state?o[r]=n.value:(++i,E(t,function(e){o[r]=e,0==--i&&s.resolve(o)},s.reject,function(e){s.notify({index:r,value:e})}))},void 0),0===i&&s.resolve(o),s.promise})}function Q(o){var i,s;return 0===o.length?b.resolve():(i=b.defer(),y(o,function(e,t,r){var n=o[r];s++,E(n,function(e){i.resolve(e)},function(){0==--s&&i.reject(new Error("Can't get fulfillment value from any promise, all promises were rejected."))},function(e){i.notify({index:r,value:e})})},void(s=0)),i.promise)}function Z(e){return E(e,function(e){return e=R(e,b),E(D(R(e,function(e){return E(e,t,t)})),function(){return e})})}b.resetUnhandledRejections=j,b.getUnhandledReasons=function(){return O.slice()},b.stopUnhandledRejectionTracking=function(){j(),k=!1},j(),b.reject=C,b.fulfill=x,b.master=function(r){return T({isDef:function(){}},function(e,t){return $(r,e,t)},function(){return b(r).inspect()})},b.spread=J,T.prototype.spread=function(t,e){return this.all().then(function(e){return t.apply(void 0,e)},e)},b.async=function(t){return function(){function e(t,e){var r;if("undefined"==typeof StopIteration){try{r=n[t](e)}catch(e){return C(e)}return r.done?b(r.value):E(r.value,o,i)}try{r=n[t](e)}catch(e){return"[object StopIteration]"===F(t=e)||t instanceof A?b(e.value):C(e)}return E(r,o,i)}var n=t.apply(this,arguments),o=e.bind(e,"next"),i=e.bind(e,"throw");return o()}},b.spawn=function(e){b.done(b.async(e)())},b.return=function(e){throw new A(e)},b.promised=function(r){return function(){return J([this,D(arguments)],function(e,t){return r.apply(e,t)})}},b.dispatch=$,T.prototype.dispatch=function(e,t){var r=this,n=v();return b.nextTick(function(){r.promiseDispatch(n.resolve,e,t)}),n.promise},b.get=function(e,t){return b(e).dispatch("get",[t])},T.prototype.get=function(e){return this.dispatch("get",[e])},b.set=function(e,t,r){return b(e).dispatch("set",[t,r])},T.prototype.set=function(e,t){return this.dispatch("set",[e,t])},b.del=b.delete=function(e,t){return b(e).dispatch("delete",[t])},T.prototype.del=T.prototype.delete=function(e){return this.dispatch("delete",[e])},b.mapply=b.post=function(e,t,r){return b(e).dispatch("post",[t,r])},T.prototype.mapply=T.prototype.post=function(e,t){return this.dispatch("post",[e,t])},b.send=b.mcall=b.invoke=function(e,t){return b(e).dispatch("post",[t,g(arguments,2)])},T.prototype.send=T.prototype.mcall=T.prototype.invoke=function(e){return this.dispatch("post",[e,g(arguments,1)])},b.fapply=function(e,t){return b(e).dispatch("apply",[void 0,t])},T.prototype.fapply=function(e){return this.dispatch("apply",[void 0,e])},b.try=b.fcall=function(e){return b(e).dispatch("apply",[void 0,g(arguments,1)])},T.prototype.fcall=function(){return this.dispatch("apply",[void 0,g(arguments)])},b.fbind=function(e){var t=b(e),r=g(arguments,1);return function(){return t.dispatch("apply",[this,r.concat(g(arguments))])}},T.prototype.fbind=function(){var e=this,t=g(arguments);return function(){return e.dispatch("apply",[this,t.concat(g(arguments))])}},b.keys=function(e){return b(e).dispatch("keys",[])},T.prototype.keys=function(){return this.dispatch("keys",[])},b.all=D,T.prototype.all=function(){return D(this)},b.any=Q,T.prototype.any=function(){return Q(this)},b.allResolved=(P=Z,V="allResolved",W="allSettled",function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(V+" is deprecated, use "+W+" instead.",new Error("").stack),P.apply(P,arguments)}),T.prototype.allResolved=function(){return Z(this)},b.allSettled=function(e){return b(e).allSettled()},T.prototype.allSettled=function(){return this.then(function(e){return D(R(e,function(e){function t(){return e.inspect()}return(e=b(e)).then(t,t)}))})},b.fail=b.catch=function(e,t){return b(e).then(void 0,t)},T.prototype.fail=T.prototype.catch=function(e){return this.then(void 0,e)},b.progress=function(e,t){return b(e).then(void 0,void 0,t)},T.prototype.progress=function(e){return this.then(void 0,void 0,e)},b.fin=b.finally=function(e,t){return b(e).finally(t)},T.prototype.fin=T.prototype.finally=function(t){return t=b(t),this.then(function(e){return t.fcall().then(function(){return e})},function(e){return t.fcall().then(function(){throw e})})},b.done=function(e,t,r,n){return b(e).done(t,r,n)},T.prototype.done=function(e,t,r){var n=function(e){b.nextTick(function(){if(Y(e,o),!b.onerror)throw e;b.onerror(e)})},o=e||t||r?this.then(e,t,r):this;"object"==typeof te&&te&&te.domain&&(n=te.domain.bind(n)),o.then(void 0,n)},b.timeout=function(e,t,r){return b(e).timeout(t,r)},T.prototype.timeout=function(e,t){var r=v(),n=setTimeout(function(){t&&"string"!=typeof t||((t=new Error(t||"Timed out after "+e+" ms")).code="ETIMEDOUT"),r.reject(t)},e);return this.then(function(e){clearTimeout(n),r.resolve(e)},function(e){clearTimeout(n),r.reject(e)},r.notify),r.promise},b.delay=function(e,t){return void 0===t&&(t=e,e=void 0),b(e).delay(t)},T.prototype.delay=function(r){return this.then(function(e){var t=v();return setTimeout(function(){t.resolve(e)},r),t.promise})},b.nfapply=function(e,t){return b(e).nfapply(t)},T.prototype.nfapply=function(e){var t=v(),e=g(e);return e.push(t.makeNodeResolver()),this.fapply(e).fail(t.reject),t.promise},b.nfcall=function(e){var t=g(arguments,1);return b(e).nfapply(t)},T.prototype.nfcall=function(){var e=g(arguments),t=v();return e.push(t.makeNodeResolver()),this.fapply(e).fail(t.reject),t.promise},b.nfbind=b.denodeify=function(r){var n=g(arguments,1);return function(){var e=n.concat(g(arguments)),t=v();return e.push(t.makeNodeResolver()),b(r).fapply(e).fail(t.reject),t.promise}},T.prototype.nfbind=T.prototype.denodeify=function(){var e=g(arguments);return e.unshift(this),b.denodeify.apply(void 0,e)},b.nbind=function(r,n){var o=g(arguments,2);return function(){var e=o.concat(g(arguments)),t=v();return e.push(t.makeNodeResolver()),b(function(){return r.apply(n,arguments)}).fapply(e).fail(t.reject),t.promise}},T.prototype.nbind=function(){var e=g(arguments,0);return e.unshift(this),b.nbind.apply(void 0,e)},b.nmapply=b.npost=function(e,t,r){return b(e).npost(t,r)},T.prototype.nmapply=T.prototype.npost=function(e,t){var t=g(t||[]),r=v();return t.push(r.makeNodeResolver()),this.dispatch("post",[e,t]).fail(r.reject),r.promise},b.nsend=b.nmcall=b.ninvoke=function(e,t){var r=g(arguments,2),n=v();return r.push(n.makeNodeResolver()),b(e).dispatch("post",[t,r]).fail(n.reject),n.promise},T.prototype.nsend=T.prototype.nmcall=T.prototype.ninvoke=function(e){var t=g(arguments,1),r=v();return t.push(r.makeNodeResolver()),this.dispatch("post",[e,t]).fail(r.reject),r.promise},b.nodeify=function(e,t){return b(e).nodeify(t)},T.prototype.nodeify=function(t){if(!t)return this;this.then(function(e){b.nextTick(function(){t(null,e)})},function(e){b.nextTick(function(){t(e)})})},b.noConflict=function(){throw new Error("Q.noConflict only works when Q is used as a global")};var ee=z();return b}if("function"==typeof bootstrap)bootstrap("promise",e);else if("object"==typeof o&&"object"==typeof n)n.exports=e();else if("undefined"!=typeof ses)ses.ok()&&(ses.makeQ=e);else{if("undefined"==typeof window&&"undefined"==typeof self)throw new Error("This environment was not anticipated by Q. Please file a bug.");var t="undefined"!=typeof window?window:self,r=t.Q;t.Q=e(),t.Q.noConflict=function(){return t.Q=r,this}}}.call(this,e("_process"))},{_process:40}],43:[function(e,t,r){var i=/\{([0-9a-zA-Z_]+)\}/g;t.exports=function(n){var o;if(2===arguments.length&&"object"==typeof arguments[1])o=arguments[1];else{o=new Array(arguments.length-1);for(var e=1;e<arguments.length;++e)o[e-1]=arguments[e]}o&&o.hasOwnProperty||(o={});return n.replace(i,function(e,t,r){return"{"===n[r-1]&&"}"===n[r+e.length]?t:null==(r=o.hasOwnProperty(t)?o[t]:null)?"":r})}},{}],44:[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(t){this._defaults.forEach(function(e){t[e.fn].apply(t,e.arguments)})},t.exports=n},{}],45:[function(e,t,r){var n="undefined"!=typeof window?window:"undefined"!=typeof self?self:(console.warn("Using browser-only version of superagent in non-browser environment"),this),o=e("component-emitter"),i=e("./request-base"),s=e("./is-object"),a=e("./response-base"),c=e("./agent-base");function u(){}var d=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)},l=(r.Request=y,d.getXHR=function(){if(!(!n.XMLHttpRequest||n.location&&"file:"==n.location.protocol&&n.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")},"".trim?function(e){return e.trim()}:function(e){return e.replace(/(^\s*|\s*$)/g,"")});function p(e){if(!s(e))return e;var t,r=[];for(t in e)!function t(r,n,e){if(null!=e)if(Array.isArray(e))e.forEach(function(e){t(r,n,e)});else if(s(e))for(var o in e)t(r,n+"["+o+"]",e[o]);else r.push(encodeURIComponent(n)+"="+encodeURIComponent(e));else null===e&&r.push(encodeURIComponent(n))}(r,t,e[t]);return r.join("&")}function f(e){for(var t,r,n={},o=e.split("&"),i=0,s=o.length;i<s;++i)-1==(r=(t=o[i]).indexOf("="))?n[decodeURIComponent(t)]="":n[decodeURIComponent(t.slice(0,r))]=decodeURIComponent(t.slice(r+1));return n}function h(e){return/[\/+]json($|[^-\w])/.test(e)}function g(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;this._setStatusProperties(t=1223===t?204:t),this.header=this.headers=(e=>{for(var t,r,n,o=e.split(/\r?\n/),i={},s=0,a=o.length;s<a;++s)-1!==(t=(n=o[s]).indexOf(":"))&&(r=n.slice(0,t).toLowerCase(),n=l(n.slice(t+1)),i[r]=n);return i})(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.xhr.response):null}function y(e,t){var n=this;this._query=this._query||[],this.method=e,this.url=t,this.header={},this._header={},this.on("end",function(){var t,r=null,e=null;try{e=new g(n)}catch(e){return(r=new Error("Parser is unable to parse the response")).parse=!0,r.original=e,n.xhr?(r.rawResponse=void 0===n.xhr.responseType?n.xhr.responseText:n.xhr.response,r.status=n.xhr.status||null,r.statusCode=r.status):(r.rawResponse=null,r.status=null),n.callback(r)}n.emit("response",e);try{n._isResponseOK(e)||(t=new Error(e.statusText||"Unsuccessful HTTP response"))}catch(e){t=e}t?(t.original=r,t.response=e,t.status=e.status,n.callback(t,e)):n.callback(null,e)})}function m(e,t,r){e=d("DELETE",e);return"function"==typeof t&&(r=t,t=null),t&&e.send(t),r&&e.end(r),e}d.serializeObject=p,d.parseString=f,d.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"},d.serialize={"application/x-www-form-urlencoded":p,"application/json":JSON.stringify},d.parse={"application/x-www-form-urlencoded":f,"application/json":JSON.parse},a(g.prototype),g.prototype._parseBody=function(e){var t=d.parse[this.type];return this.req._parser?this.req._parser(this,e):(t=!t&&h(this.type)?d.parse["application/json"]:t)&&e&&(e.length||e instanceof Object)?t(e):null},g.prototype.toError=function(){var e=this.req,t=e.method,e=e.url,r="cannot "+t+" "+e+" ("+this.status+")",r=new Error(r);return r.status=this.status,r.method=t,r.url=e,r},d.Response=g,o(y.prototype),i(y.prototype),y.prototype.type=function(e){return this.set("Content-Type",d.types[e]||e),this},y.prototype.accept=function(e){return this.set("Accept",d.types[e]||e),this},y.prototype.auth=function(e,t,r){"object"==typeof(t=1===arguments.length?"":t)&&null!==t&&(r=t,t=""),r=r||{type:"function"==typeof btoa?"basic":"auto"};return this._auth(e,t,r,function(e){if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")})},y.prototype.query=function(e){return(e="string"!=typeof e?p(e):e)&&this._query.push(e),this},y.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},y.prototype._getFormData=function(){return this._formData||(this._formData=new n.FormData),this._formData},y.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)},y.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)},y.prototype.buffer=y.prototype.ca=y.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},y.prototype.pipe=y.prototype.write=function(){throw Error("Streaming is not supported in browser version of superagent")},y.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},y.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||u,this._finalizeQueryString(),this._end()},y.prototype._end=function(){function e(e,t){0<t.total&&(t.percent=t.loaded/t.total*100),t.direction=e,o.emit("progress",t)}var t,r,n,o=this,i=this.xhr=d.getXHR(),s=this._formData||this._data;this._setTimeouts(),i.onreadystatechange=function(){var t,e=i.readyState;if(2<=e&&o._responseTimeoutTimer&&clearTimeout(o._responseTimeoutTimer),4==e){try{t=i.status}catch(e){t=0}if(!t)return o.timedout||o._aborted?void 0:o.crossDomainError();o.emit("end")}};if(this.hasListeners("progress"))try{i.onprogress=e.bind(null,"download"),i.upload&&(i.upload.onprogress=e.bind(null,"upload"))}catch(e){}try{this.username&&this.password?i.open(this.method,this.url,!0,this.username,this.password):i.open(this.method,this.url,!0)}catch(e){return this.callback(e)}for(n in this._withCredentials&&(i.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof s&&!this._isHost(s)&&(t=this._header["content-type"],r=!(r=this._serializer||d.serialize[t?t.split(";")[0]:""])&&h(t)?d.serialize["application/json"]:r)&&(s=r(s)),this.header)null!=this.header[n]&&this.header.hasOwnProperty(n)&&i.setRequestHeader(n,this.header[n]);return this._responseType&&(i.responseType=this._responseType),this.emit("request",this),i.send(void 0!==s?s:null),this},d.agent=function(){return new c},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(r){c.prototype[r.toLowerCase()]=function(e,t){e=new d.Request(r,e);return this._setDefaults(e),t&&e.end(t),e}}),c.prototype.del=c.prototype.delete,d.get=function(e,t,r){e=d("GET",e);return"function"==typeof t&&(r=t,t=null),t&&e.query(t),r&&e.end(r),e},d.head=function(e,t,r){e=d("HEAD",e);return"function"==typeof t&&(r=t,t=null),t&&e.query(t),r&&e.end(r),e},d.options=function(e,t,r){e=d("OPTIONS",e);return"function"==typeof t&&(r=t,t=null),t&&e.send(t),r&&e.end(r),e},d.del=m,d.delete=m,d.patch=function(e,t,r){e=d("PATCH",e);return"function"==typeof t&&(r=t,t=null),t&&e.send(t),r&&e.end(r),e},d.post=function(e,t,r){e=d("POST",e);return"function"==typeof t&&(r=t,t=null),t&&e.send(t),r&&e.end(r),e},d.put=function(e,t,r){e=d("PUT",e);return"function"==typeof t&&(r=t,t=null),t&&e.send(t),r&&e.end(r),e}},{"./agent-base":44,"./is-object":46,"./request-base":47,"./response-base":48,"component-emitter":37}],46:[function(e,t,r){t.exports=function(e){return null!==e&&"object"==typeof e}},{}],47:[function(e,t,r){var o=e("./is-object");function n(e){if(e){var t,r=e;for(t in n.prototype)r[t]=n.prototype[t];return r}}(t.exports=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)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)}else this._timeout=e,this._responseTimeout=0;return this},n.prototype.retry=function(e,t){return this._maxRetries=e=(e=0!==arguments.length&&!0!==e?e:1)<=0?0:e,this._retries=0,this._retryCallback=t,this};var i=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];n.prototype._shouldRetry=function(e,t){if(this._maxRetries&&!(this._retries++>=this._maxRetries)){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&&500<=t.status&&501!=t.status)return!0;if(e){if(e.code&&~i.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){var o;return this._fullfilledPromise||((o=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(r,n){o.end(function(e,t){e?n(e):r(t)})})),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):200<=e.status&&e.status<300)},n.prototype.getHeader=n.prototype.get=function(e){return this._header[e.toLowerCase()]},n.prototype.set=function(e,t){if(o(e))for(var r in e)this.set(r,e[r]);else this._header[e.toLowerCase()]=t,this.header[e]=t;return 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)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]);else if(Array.isArray(t))for(var n in t)this.field(e,t[n]);else{if(null==t)throw new Error(".field(name, val) val can not be empty");"boolean"==typeof t&&(t=""+t),this._getFormData().append(e,t)}return this},n.prototype.abort=function(){return this._aborted||(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 this._withCredentials=e=null==e?!0: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)||r||this.type("json"),this},n.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},n.prototype._finalizeQueryString=function(){var e,t=this._query.join("&");t&&(this.url+=(0<=this.url.indexOf("?")?"&":"?")+t),this._query.length=0,this._sort&&0<=(t=this.url.indexOf("?"))&&(e=this.url.substring(t+1).split("&"),"function"==typeof this._sort?e.sort(this._sort):e.sort(),this.url=this.url.substring(0,t)+"?"+e.join("&"))},n.prototype._appendQueryString=function(){console.trace("Unsupported")},n.prototype._timeoutError=function(e,t,r){this._aborted||((e=new Error(e+t+"ms exceeded")).timeout=t,e.code="ECONNABORTED",e.errno=r,this.timedout=!0,this.abort(),this.callback(e))},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":46}],48:[function(e,t,r){var o=e("./utils");function n(e){if(e){var t,r=e;for(t in n.prototype)r[t]=n.prototype[t];return r}}(t.exports=n).prototype.get=function(e){return this.header[e.toLowerCase()]},n.prototype._setHeaderProperties=function(e){var t,r=e["content-type"]||"",n=(this.type=o.type(r),o.params(r));for(t in n)this[t]=n[t];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.created=201==e,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,this.unprocessableEntity=422==e}},{"./utils":49}],49:[function(e,t,r){r.type=function(e){return e.split(/ *; */).shift()},r.params=function(e){return e.split(/ *; */).reduce(function(e,t){var t=t.split(/ *= */),r=t.shift(),t=t.shift();return r&&t&&(e[r]=t),e},{})},r.parseLinks=function(e){return e.split(/ *, */).reduce(function(e,t){var t=t.split(/ *; */),r=t[0].slice(1,-1);return e[t[1].split(/ *= */)[1].slice(1,-1)]=r,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}},{}],50:[function(e,t,r){!function(e,t,r){function s(e,t,r){r=d.extend({},d.options,r);var n,o,i=d.runValidations(e,t,r);for(n in i)for(o in i[n])if(d.isPromise(i[n][o]))throw new Error("Use validate.async if you want support for promises");return s.processValidationResults(i,r)}var d=s;d.extend=function(r){return[].slice.call(arguments,1).forEach(function(e){for(var t in e)r[t]=e[t]}),r},d.extend(s,{version:{major:0,minor:9,patch:0,metadata:null,toString:function(){var e=d.format("%{major}.%{minor}.%{patch}",d.version);return d.isEmpty(d.version.metadata)||(e+="+"+d.version.metadata),e}},Promise:"undefined"!=typeof Promise?Promise:null,EMPTY_STRING_REGEXP:/^\s*$/,runValidations:function(e,t,r){var n,o,i,s,a,c,u=[];for(n in(d.isDomElement(e)||d.isJqueryElement(e))&&(e=d.collectFormValues(e)),t)for(o in i=d.getDeepObjectValue(e,n),s=d.result(t[n],i,e,n,r,t)){if(!(a=d.validators[o]))throw c=d.format("Unknown validator %{name}",{name:o}),new Error(c);c=s[o],(c=d.result(c,i,e,n,r,t))&&u.push({attribute:n,value:i,validator:o,globalOptions:r,attributes:e,options:c,error:a.call(a,i,c,n,e,r)})}return u},processValidationResults:function(e,t){switch(e=d.pruneEmptyErrors(e,t),e=d.expandMultipleErrors(e,t),e=d.convertErrorMessages(e,t),t.format||"grouped"){case"detailed":break;case"flat":e=d.flattenErrorsToArray(e);break;case"grouped":for(var r in e=d.groupErrorsByAttribute(e))e[r]=d.flattenErrorsToArray(e[r]);break;default:throw new Error(d.format("Unknown format %{format}",t))}return d.isEmpty(e)?void 0:e},async:function(n,o,i){var s=(i=d.extend({},d.async.options,i)).wrapErrors||function(e){return e},a=(!1!==i.cleanAttributes&&(n=d.cleanAttributes(n,o)),d.runValidations(n,o,i));return new d.Promise(function(t,r){d.waitForResults(a).then(function(){var e=d.processValidationResults(a,i);e?r(new s(e,i,n,o)):t(n)},function(e){r(e)})})},single:function(e,t,r){return r=d.extend({},d.single.options,r,{format:"flat",fullMessages:!1}),d({single:e},{single:t},r)},waitForResults:function(e){return e.reduce(function(e,t){return d.isPromise(t.error)?e.then(function(){return t.error.then(function(e){t.error=e||null},function(e){if(e instanceof Error)throw e;d.error("Rejecting promises with the result is deprecated. Please use the resolve callback instead."),t.error=e})}):e},new d.Promise(function(e){e()}))},result:function(e){var t=[].slice.call(arguments,1);return e="function"==typeof e?e.apply(null,t):e},isNumber:function(e){return"number"==typeof e&&!isNaN(e)},isFunction:function(e){return"function"==typeof e},isInteger:function(e){return d.isNumber(e)&&e%1==0},isObject:function(e){return e===Object(e)},isDate:function(e){return e instanceof Date},isDefined:function(e){return null!=e},isPromise:function(e){return!!e&&d.isFunction(e.then)},isJqueryElement:function(e){return e&&d.isString(e.jquery)},isDomElement:function(e){return!!e&&!(!d.isFunction(e.querySelectorAll)||!d.isFunction(e.querySelector))&&(!(!d.isObject(document)||e!==document)||("object"==typeof HTMLElement?e instanceof HTMLElement:e&&"object"==typeof e&&null!==e&&1===e.nodeType&&"string"==typeof e.nodeName))},isEmpty:function(e){if(!d.isDefined(e))return!0;if(!d.isFunction(e)){if(d.isString(e))return d.EMPTY_STRING_REGEXP.test(e);if(d.isArray(e))return 0===e.length;if(!d.isDate(e)&&d.isObject(e)){for(var t in e)return!1;return!0}}return!1},format:d.extend(function(e,n){return d.isString(e)?e.replace(d.format.FORMAT_REGEXP,function(e,t,r){return"%"===t?"%{"+r+"}":String(n[r])}):e},{FORMAT_REGEXP:/(%?)%\{([^\}]+)\}/g}),prettify:function(e){return d.isNumber(e)?100*e%1==0?""+e:parseFloat(Math.round(100*e)/100).toFixed(2):d.isArray(e)?e.map(function(e){return d.prettify(e)}).join(", "):d.isObject(e)?e.toString():(e=""+e).replace(/([^\s])\.([^\s])/g,"$1 $2").replace(/\\+/g,"").replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,function(e,t,r){return t+" "+r.toLowerCase()}).toLowerCase()},stringifyValue:function(e){return d.prettify(e)},isString:function(e){return"string"==typeof e},isArray:function(e){return"[object Array]"==={}.toString.call(e)},contains:function(e,t){return!!d.isDefined(e)&&(d.isArray(e)?-1!==e.indexOf(t):t in e)},forEachKeyInKeypath:function(e,t,r){if(d.isString(t)){for(var n="",o=!1,i=0;i<t.length;++i)switch(t[i]){case".":o?(o=!1,n+="."):(e=r(e,n,!1),n="");break;case"\\":o?(o=!1,n+="\\"):o=!0;break;default:o=!1,n+=t[i]}return r(e,n,!0)}},getDeepObjectValue:function(e,t){if(d.isObject(e))return d.forEachKeyInKeypath(e,t,function(e,t){if(d.isObject(e))return e[t]})},collectFormValues:function(e,t){var r,n,o,i,s={};if(e=d.isJqueryElement(e)?e[0]:e){for(t=t||{},o=e.querySelectorAll("input[name], textarea[name]"),r=0;r<o.length;++r)n=o.item(r),d.isDefined(n.getAttribute("data-ignored"))||(i=d.sanitizeFormValue(n.value,t),"number"===n.type?i=i?+i:null:"checkbox"===n.type?n.attributes.value?n.checked||(i=s[n.name]||null):i=n.checked:"radio"!==n.type||n.checked||(i=s[n.name]||null),s[n.name]=i);for(o=e.querySelectorAll("select[name]"),r=0;r<o.length;++r)n=o.item(r),i=d.sanitizeFormValue(n.options[n.selectedIndex].value,t),s[n.name]=i}return s},sanitizeFormValue:function(e,t){return t.trim&&d.isString(e)&&(e=e.trim()),!1!==t.nullify&&""===e?null:e},capitalize:function(e){return d.isString(e)?e[0].toUpperCase()+e.slice(1):e},pruneEmptyErrors:function(e){return e.filter(function(e){return!d.isEmpty(e.error)})},expandMultipleErrors:function(e){var r=[];return e.forEach(function(t){d.isArray(t.error)?t.error.forEach(function(e){r.push(d.extend({},t,{error:e}))}):r.push(t)}),r},convertErrorMessages:function(e,r){r=r||{};var n=[];return e.forEach(function(e){var t=d.result(e.error,e.value,e.attribute,e.options,e.attributes,e.globalOptions);d.isString(t)?("^"===t[0]?t=t.slice(1):!1!==r.fullMessages&&(t=d.capitalize(d.prettify(e.attribute))+" "+t),t=t.replace(/\\\^/g,"^"),t=d.format(t,{value:d.stringifyValue(e.value)}),n.push(d.extend({},e,{error:t}))):n.push(e)}),n},groupErrorsByAttribute:function(e){var r={};return e.forEach(function(e){var t=r[e.attribute];t?t.push(e):r[e.attribute]=[e]}),r},flattenErrorsToArray:function(e){return e.map(function(e){return e.error})},cleanAttributes:function(e,t){function n(e,t,r){return d.isObject(e[t])?e[t]:e[t]=!!r||{}}return d.isObject(t)&&d.isObject(e)?function e(t,r){if(!d.isObject(t))return t;var n,o,i=d.extend({},t);for(o in t)n=r[o],d.isObject(n)?i[o]=e(i[o],n):n||delete i[o];return i}(e,t=(e=>{var t,r={};for(t in e)e[t]&&d.forEachKeyInKeypath(r,t,n);return r})(t)):{}},exposeModule:function(e,t,r,n,o){r?(r=n&&n.exports?n.exports=e:r).validate=e:(t.validate=e).isFunction(o)&&o.amd&&o([],function(){return e})},warn:function(e){"undefined"!=typeof console&&console.warn&&console.warn("[validate.js] "+e)},error:function(e){"undefined"!=typeof console&&console.error&&console.error("[validate.js] "+e)}}),s.validators={presence:function(e,t){if(t=d.extend({},this.options,t),d.isEmpty(e))return t.message||this.message||"can't be blank"},length:function(e,t,r){var n,o,i,s,a;if(!d.isEmpty(e))return n=(t=d.extend({},this.options,t)).is,o=t.maximum,i=t.minimum,a=[],e=(e=(t.tokenizer||function(e){return e})(e)).length,d.isNumber(e)?(d.isNumber(n)&&e!==n&&(s=t.wrongLength||this.wrongLength||"is the wrong length (should be %{count} characters)",a.push(d.format(s,{count:n}))),d.isNumber(i)&&e<i&&(s=t.tooShort||this.tooShort||"is too short (minimum is %{count} characters)",a.push(d.format(s,{count:i}))),d.isNumber(o)&&o<e&&(s=t.tooLong||this.tooLong||"is too long (maximum is %{count} characters)",a.push(d.format(s,{count:o}))),0<a.length?t.message||a:void 0):(d.error(d.format("Attribute %{attr} has a non numeric value for `length`",{attr:r})),t.message||this.notValid||"has an incorrect length")},numericality:function(e,t){if(!d.isEmpty(e)){var r,n=[],o={greaterThan:function(e,t){return t<e},greaterThanOrEqualTo:function(e,t){return t<=e},equalTo:function(e,t){return e===t},lessThan:function(e,t){return e<t},lessThanOrEqualTo:function(e,t){return e<=t}};if(!0!==(t=d.extend({},this.options,t)).noStrings&&d.isString(e)&&(e=+e),!d.isNumber(e))return t.message||t.notValid||this.notValid||"is not a number";if(t.onlyInteger&&!d.isInteger(e))return t.message||t.notInteger||this.notInteger||"must be an integer";for(r in o){var i,s=t[r];d.isNumber(s)&&!o[r](e,s)&&(i=t[i="not"+d.capitalize(r)]||this[i]||"must be %{type} %{count}",n.push(d.format(i,{count:s,type:d.prettify(r)})))}return t.odd&&e%2!=1&&n.push(t.notOdd||this.notOdd||"must be odd"),t.even&&e%2!=0&&n.push(t.notEven||this.notEven||"must be even"),n.length?t.message||n:void 0}},datetime:d.extend(function(e,t){if(!d.isFunction(this.parse)||!d.isFunction(this.format))throw new Error("Both the parse and format functions needs to be set to use the datetime/date validator");var r,n,o,i;if(!d.isEmpty(e))return n=[],o=(t=d.extend({},this.options,t)).earliest?this.parse(t.earliest,t):NaN,i=t.latest?this.parse(t.latest,t):NaN,e=this.parse(e,t),isNaN(e)||t.dateOnly&&e%864e5!=0?t.message||this.notValid||"must be a valid date":(!isNaN(o)&&e<o&&(r=this.tooEarly||"must be no earlier than %{date}",r=d.format(r,{date:this.format(o,t)}),n.push(r)),!isNaN(i)&&i<e&&(r=this.tooLate||"must be no later than %{date}",r=d.format(r,{date:this.format(i,t)}),n.push(r)),n.length?t.message||n:void 0)},{parse:null,format:null}),date:function(e,t){return t=d.extend({},t,{dateOnly:!0}),d.validators.datetime.call(d.validators.datetime,e,t)},format:function(e,t){(d.isString(t)||t instanceof RegExp)&&(t={pattern:t});var r=(t=d.extend({},this.options,t)).message||this.message||"is invalid",n=t.pattern;return d.isEmpty(e)||d.isString(e)&&(t=(n=d.isString(n)?new RegExp(t.pattern,t.flags):n).exec(e))&&t[0].length==e.length?void 0:r},inclusion:function(e,t){if(!d.isEmpty(e)&&(d.isArray(t)&&(t={within:t}),t=d.extend({},this.options,t),!d.contains(t.within,e)))return t=t.message||this.message||"^%{value} is not included in the list",d.format(t,{value:e})},exclusion:function(e,t){if(!d.isEmpty(e)&&(d.isArray(t)&&(t={within:t}),t=d.extend({},this.options,t),d.contains(t.within,e)))return t=t.message||this.message||"^%{value} is restricted",d.format(t,{value:e})},email:d.extend(function(e,t){t=(t=d.extend({},this.options,t)).message||this.message||"is not a valid email";return d.isEmpty(e)||d.isString(e)&&this.PATTERN.exec(e)?void 0:t},{PATTERN:/^[a-z0-9\u007F-\uffff!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9\u007F-\uffff!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/i}),equality:function(e,t,r,n){if(!d.isEmpty(e)){d.isString(t)&&(t={attribute:t});var o=(t=d.extend({},this.options,t)).message||this.message||"is not equal to %{attribute}";if(d.isEmpty(t.attribute)||!d.isString(t.attribute))throw new Error("The attribute must be a non empty string");var i=d.getDeepObjectValue(n,t.attribute);return(t.comparator||function(e,t){return e===t})(e,i,t,r,n)?void 0:d.format(o,{attribute:d.prettify(t.attribute)})}},url:function(e,t){var r,n,o;if(!d.isEmpty(e))return r=(t=d.extend({},this.options,t)).message||this.message||"is not a valid url",n=t.schemes||this.schemes||["http","https"],t=t.allowLocal||this.allowLocal||!1,d.isString(e)&&(n="^(?:(?:"+n.join("|")+"):\\/\\/)(?:\\S+(?::\\S*)?@)?",n+="(?:",o="(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))",t?o="(?:localhost|"+o+")":n+="(?!10(?:\\.\\d{1,3}){3})(?!127(?:\\.\\d{1,3}){3})(?!169\\.254(?:\\.\\d{1,3}){2})(?!192\\.168(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})",n+="(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|"+o+"(?::\\d{2,5})?(?:\\/[^\\s]*)?$",new RegExp(n,"i").exec(e))?void 0:r}},s.exposeModule(s,this,e,t,r)}.call(this,void 0!==r?r:null,void 0!==t?t:null,null)},{}]},{},[1])(1)});
1
+ !function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).ComproDLS=e()}(function(){return function n(o,i,s){function a(r,e){if(!i[r]){if(!o[r]){var t="function"==typeof require&&require;if(!e&&t)return t(r,!0);if(c)return c(r,!0);e=new Error("Cannot find module '"+r+"'");throw e.code="MODULE_NOT_FOUND",e}t=i[r]={exports:{}};o[r][0].call(t.exports,function(e){var t=o[r][1][e];return a(t||e)},t,t.exports,n,o,i,s)}return i[r].exports}for(var c="function"==typeof require&&require,e=0;e<s.length;e++)a(s[e]);return a}({1:[function(e,t,r){var n=e("./token"),o=e("./helpers"),i=e("./services/auth"),s=e("./services/authextn"),a=e("./services/activity"),c=e("./services/analytics"),u=e("./services/collab"),d=e("./services/product"),p=e("./services/xapi"),l=e("./services/attempts"),f=e("./services/pushX"),h=e("./services/pub"),g=e("./services/spaces"),y=e("./services/spacesextn"),m=e("./config"),R=e("./open_access"),_=e("./services/superuser"),A=e("./services/invitations"),b=e("./services/workflows"),v=e("./services/integrations"),I=e("./token/validations"),T=e("./services/drive"),E=e("./services/taxonomy"),S=e("./services/rules"),e=e("./services/datasyncmanager");function P(t,r,e){e=e||{},t=t||"production",r=r||"global",this.token=null,this.orgId=null,this.traceid=e.traceid;try{if(m.DEFAULT_HOSTS=m.REALM_HOSTS[r.toUpperCase()][t.toUpperCase()],!m.DEFAULT_HOSTS)throw"Invalid Environment"}catch(e){var n=m.REALM_HOSTS[r.toUpperCase()];throw n?n[t.toUpperCase()]||(o=new Error("Invalid Environment: "+t)):o=new Error("Invalid Realm: "+r),o}if(this.config=m,this.environment=t,e.orgid&&e.token){var o;if(o=I.authWithToken(e.orgid,e.token,{}))throw o;this.token=e.token,this.orgId=e.orgid}else e.orgid&&(this.orgId=e.orgid)}r.init=function(e,t,r){return new P(e,t,r)},P.prototype.authWithCredentials=n.authWithCredentials,P.prototype.authWithToken=n.authWithToken,P.prototype.authWithExtUser=n.authWithExtUser,P.prototype.getClassEnrolmentsStat=R.getClassEnrolmentsStat,P.prototype.getSingleInvitation=R.getSingleInvitation,P.prototype.request=o.api.genericAPICaller,P.prototype.Auth=i,P.prototype.AuthExtn=s,P.prototype.Activity=a,P.prototype.Analytics=c,P.prototype.Collab=u,P.prototype.Product=d,P.prototype.Xapi=p,P.prototype.Attempts=l,P.prototype.Pub=h,P.prototype.PushX=f,P.prototype.Spaces=g,P.prototype.SpacesExtn=y,P.prototype.Superuser=_,P.prototype.Invitations=A,P.prototype.Workflows=b,P.prototype.Integrations=v,P.prototype.Drive=T,P.prototype.Taxonomy=E,P.prototype.Rules=S,P.prototype.Datasyncmanager=e},{"./config":2,"./helpers":3,"./open_access":10,"./services/activity":13,"./services/analytics":14,"./services/attempts":15,"./services/auth":16,"./services/authextn":17,"./services/collab":18,"./services/datasyncmanager":19,"./services/drive":20,"./services/integrations":21,"./services/invitations":22,"./services/product":23,"./services/pub":24,"./services/pushX":25,"./services/rules":27,"./services/spaces":28,"./services/spacesextn":29,"./services/superuser":30,"./services/taxonomy":31,"./services/workflows":32,"./services/xapi":33,"./token":34,"./token/validations":35}],2:[function(e,t,r){r.REALM_HOSTS={GLOBAL:{PROD1:{PUB:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://internal-dls-global-prod1-1755536919.us-west-2.elb.amazonaws.com/lb-drive"}},ASGARD:{THOR:{PUB:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://dls-asgard-thor-1453383019.us-west-2.elb.amazonaws.com/lb-drive"}},CUP:{ALPHA:{PUB:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://dls-cup-alpha-2093819659.us-west-2.elb.amazonaws.com/lb-drive"},PROD1:{PUB:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://internal-dls-cup-prod1-284466545.us-west-2.elb.amazonaws.com/lb-drive"},QA:{PUB:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://internal-dls-cup-qa-41690511.us-west-2.elb.amazonaws.com/lb-drive"},HFX:{PUB:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://internal-dls-cup-hfx-908523553.us-west-2.elb.amazonaws.com/lb-drive"},REL:{PUB:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-pub",AUTH:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-auth",AUTHEXTN:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-authextn",PUSHX:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-pushx",XAPI:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-xapi",ATTEMPTS:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-attempts",PRODUCT:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-product",ANALYTICS:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-analytics",INTEGRATION:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-integrations",DRIVE:"http://internal-dls-cup-rel-1458752944.us-west-2.elb.amazonaws.com/lb-drive"}}},r.AUTH_API_URLS={getSettings:"/org/{orgId}/settings",getTokenAPI:"/auth/{orgId}/token",getExtUserTokenAPI:"/auth/{orgId}/ext-users/token",userInfoAPI:"/org/{orgId}/users/{userId}",pisImportAPI:"/org/{orgId}/pis_imports",getAllUsersAPI:"/org/{orgId}/users/all",updateUserRoleAPI:"/org/{orgId}/users/{userId}/update-role",getSettingsField:"/org/{orgId}/settings/{field}",getClassUsersAPI:"/org/{orgId}/class/{classId}/users",getUserClassesAPI:"/org/{orgId}/users/{userId}/classes",getUserClassesV2API:"/org/{orgid}/users/{userid}/class-enrollments",getAllJobs:"/accounts/{accountId}/ext-users/{extUserId}/jobs",getJob:"/accounts/{accountId}/ext-users/{extUserId}/jobs/{jobId}",getAllClassesAPI:"/org/{orgId}/classes",getParticularClassAPI:"/org/{orgId}/classes/{classId}",getParticularShadowClassAPI:"/org/{orgId}/shadow/classes/{extClassId}",classProductAssociation:"/org/{orgId}/classes/{classId}/associate-product/{productcode}",multiClassProductAssociations:"/org/{orgId}/classes/{classId}/associate-product/multi",enrollUsertoClass:"/org/{orgId}/classes/{classId}/enroll-user/{userId}",enrollSelftoClass:"/org/{orgId}/classes/{classId}/enroll-self",enrollMultiUserstoClass:"/org/{orgId}/classes/{classId}/enroll-user/multi",createClass:"/org/{orgId}/classes",createMultipleClasses:"/org/{orgId}/classes/multi",specificClass:"/org/{orgId}/classes/{classId}",cloneClass:"/org/{orgId}/classes/{classId}/clone",ClassAppdata:"/org/{orgId}/classes/{classid}/appdata",generateClassCode:"/org/{orgId}/classes/{classId}/class-code/generate",getUserSpaces:"/accounts/{accountid}/ext-users/{extuserid}/spaces",validateSpaceCode:"/accounts/{accountid}/space-code/validate",validateClassCode:"/accounts/{accountid}/class-code/validate",joinInstituteSpace:"/accounts/{accountid}/join-institute-space",provisionSpacesToStudent:"/accounts/{accountId}/student/provision-spaces",provisionSpacesToTeacher:"/accounts/{accountId}/teacher/provision-spaces",shadowProvision:"/org/{orgId}/shadow-provision",provisionBulkSpaces:"/org/{orgId}/provision-spaces/bulk",entitleUserToProduct:"/accounts/{accountId}/entitle-user",microEntitleUserToProduct:"/accounts/{accountId}/entitle-user/micro",bulkMicroEntitleProductToUser:"/accounts/{accountId}/entitle-user/micro/bulk",enrollUserInClass:"/accounts/{accountId}/enroll-with-classcode",getExtProductAPI:"/accounts/{accountId}/products/{extProductId}",getSpaceDetails:"/accounts/{accountId}/spaces/{spacekey}",updateUserInformation:"/accounts/{accountId}/update-user-information",updateUserSpace:"/accounts/{accountid}/ext-users/{extuserid}/spaces/{spacekey}",getInvitationsByEmail:"/accounts/{accountid}/invitations-by-email",generateSpaceCode:"/accounts/{accountid}/space-code/generate",changeSpaceCode:"/accounts/{accountid}/space-code/{spacecode}/change",updateInstituteTitle:"/accounts/{accountId}/institute-spaces/{instituteSpaceCode}",getAllInstitutions:"/su/accounts/{accountid}/spaces",getInstitution:"/su/accounts/{accountid}/spaces/{spacecode}",provisionSpacesToSuperAdmin:"/su/accounts/{accountid}/superadmin/provision-spaces",sendInvitations:"/org/{orgId}/invitations",getMultiInvitations:"/org/{orgId}/invitations",getSingleInvitation:"/org/{orgId}/invitations/{invitationId}",revokeSingleInvitation:"/org/{orgId}/invitations/{invitationid}/revoke",completeSingleInvitation:"/org/{orgId}/invitations/{invitationid}/complete",resendSingleInvitation:"/org/{orgId}/invitations/{invitationid}/resend",createAssignedPath:"/org/{orgId}/classes/{classId}/assigned-paths",deleteAssignedPath:"/org/{orgId}/classes/{classId}/assigned-paths/{assignedPathId}",workflows:"/accounts/{accountid}/workflows",getAllWorkflowOfAUser:"/accounts/{accountid}/workflows/workflows-by-user",getAWorkflow:"/accounts/{accountid}/workflows/{workflowid}",acceptAWorkflow:"/accounts/{accountid}/workflows/{workflowid}/accept",processAWorkflow:"/accounts/{accountid}/workflows/{workflowid}/process",revokeAWorkflow:"/accounts/{accountid}/workflows/{workflowid}/revoke",completeAWorkflow:"/accounts/{accountid}/workflows/{workflowid}/complete",allGroups:"/org/{orgId}/groups",aParticularGroup:"/org/{orgId}/groups/{groupId}",getAllMembersOfAGroup:"/org/{orgId}/groups/{groupId}/memberships",getAllGroupMembersByPath:"/org/{orgId}/groups/memberships",userGroupMembership:"/org/{orgId}/groups/{groupId}/enroll-user/multi",getMyAllMemberships:"/org/{orgId}/users/{userId}/groups",archiveAParticularGroup:"/org/{orgId}/groups/{groupId}/archive",unarchiveAParticularGroup:"/org/{orgId}/groups/{groupId}/unarchive",showcaseItems:"/org/{orgId}/classes/{classId}/showcase/item",createDataSyncManager:"/accounts/{accountid}/data-sync-managers",dataSyncManager:"/accounts/{accountid}/data-sync-managers/{dsmid}",getAllDataSyncManagersOfAGroup:"/accounts/{accountid}/dsm-groups/{dsm_groupid}/data-sync-managers",createOrGetGradebookMeta:"/org/{orgId}/classes/{classId}/gradebooks",updateOrDeleteGradebookMeta:"/org/{orgId}/classes/{classId}/gradebooks/{gradebook_id}",gradebookColumns:"/org/{orgId}/classes/{classId}/gradebooks/{gradebook_id}/columns",getAllClassesOfAComponent:"/org/{orgId}/components/{component_code}/classes",removeAllGradebookColumnsOfCustomComponent:"/org/{orgId}/gradebook/columns/custom-components/{component_code}",customComponents:"/org/{orgid}/custom-components",particularCustomComponent:"/org/{orgid}/custom-components/{custom_component_code}"},r.AUTHEXTN_API_URLS={gradeFormat:"/org/{orgid}/gradeformats",particularGradeFormat:"/org/{orgid}/gradeformats/{gradeformat_id}",classGradeformatAssociation:"/org/{orgid}/classes/{classid}/associate-gradeformats/{gradeformat_id}",classGradeformats:"/org/{orgid}/classes/{classid}/gradeformats",gradeformatClasses:"/org/{orgid}/gradeformats/{gradeformat_id}/classes",entitleBulkUsersToProducts:"/accounts/{accountid}/entitle-users/bulk",userAssignedPaths:"/org/{orgid}/classes/{classid}/assigned-paths/{assignedpathid}/enroll-user/multi",particularClass:"/org/{orgId}/classes/{classId}",orgProductEntitlement:"/org/{orgid}/org-entitlements",setupUser:"/accounts/{accountId}/user/setup"},r.ACTIVITY_API_URLS={newAttemptAPI:"/{orgId}/products/{productId}/activities/{activityId}/start",activityDetailsAPI:"/{orgId}/products/{productId}/activities/{activityId}",existingAttemptAPI:"/{orgId}/products/{productId}/activities/{activityId}/attempts/{attemptId}",userResponseAPI:"/{orgId}/products/{productId}/activities/{activityId}/attempts/{attemptId}/response",submitAttemptAPI:"/{orgId}/products/{productId}/activities/{activityId}/attempts/{attemptId}/submit"},r.ANALYTICS_API_URLS={archiveUserAnalytics:"/{orgId}/archive/user/product",getOrgAnalyticsStat:"/{orgId}/organization/{type}/stat",getAnalyticProductItems:"/{orgId}/user/product/progress/items",getAnalyticProductSummary:"/{orgId}/user/product/progress/summary",getExternalDataForUserAnalyticItem:"/{orgId}/user/product/progress/items/external-data",searchUserProductAnalytics:"/{orgId}/user/product/progress/search",getAnalyticProductById:"/{orgId}/user/product/userprogress/{userProgressId}",getArchivedUserAnalytics:"/{orgId}/archive",getClassAnalytics:"/{orgId}/class/{analyticsDataType}/{type}",getClassEnrolmentsStat:"/{orgId}/class/enrolments/stat",getClassRecord:"/{orgId}/class/product/class-record",getClassRecordItemAggregations:"/{orgId}/class/product/item-aggregations",getClassProductRecentPendingSubmissions:"/{orgId}/class/product/recent-pending-submissions",getStudentsWithEvaluatedOnce:"/{orgId}/class/product/students-with-evaluations",getShowcaseRecordOfAClass:"/{orgId}/class/showcase",getGroupRecord:"/{orgId}/class/group/product/group-record",getClassGroupsRecentPendingSubmissions:"/{orgId}/class/group/product/recent-pending-submissions",getGroupsWithEvaluatedOnce:"/{orgId}/class/group/product/groups-with-evaluations",getClassRecordUserAggregations:"/{orgId}/class/product/user-aggregations",getUserClassRecentSubmissions:"/{orgId}/user/product/class/recent-submissions",appState:"/{orgId}/user/product/progress/state",getUserProductAllState:"/{orgId}/user/product/progress/state/all",updateUserProductMultiState:"/{orgId}/user/product/progress/state/multi",getAllAssignedPathsOfClass:"/{orgId}/class/assigned-paths",getMyAssignedPathsOfClass:"/{orgId}/user/class/assigned-paths",getAssignedPathAnalytics:"/{orgId}/class/assigned-paths/aggregations",timeseriesAnalytics:"/progress/timeseries",getClassCustomComponentRecord:"/{orgId}/class/custom-component/class-record",getClassCustomComponentUserSubmission:"/{orgId}/class/custom-component/class-record/evaluations",getCrossProductAggregation:"/{orgId}/class/cross-product-aggregation"},r.COLLAB_API_URLS={postsInClassAPI:"/{orgId}/post/classes/{classId}",postsInProductAPI:"/{orgId}/post/products/{productId}",getMyFollowers:"/{orgId}/connections/me/followers",getUsersFollowedByMe:"/{orgId}/connections/me/following",connectionURL:"/{orgId}/connections/me/follow/{userId}"},r.PRODUCT_API_URLS={getProductAPI:"/accounts/{accountId}/products/{productCode}",getEntitlementsOfAUser:"/accounts/{accountId}/ext-users/{extUserId}/entitlements",getMicroEntitlementsOfAUser:"/accounts/{accountId}/ext-users/{extUserId}/entitlements/micro",getAllBundles:"/accounts/{accountId}/bundles",getSingleBundle:"/accounts/{accountId}/bundles/{bundleCode}",getAllProductFamilies:"/accounts/{accountId}/families",getSingleProductFamily:"/accounts/{accountId}/families/{familyCode}"},r.XAPI_API_URLS={postMultiStatements:"/{orgId}/statements/multi",postExternalMultiStatements:"/{orgId}/external/statements/multi",resetUserProductProgress:"/accounts/{accountId}/progress/user/product/reset"},r.ATTEMPTS_API_URLS={userAttempts:"/org/{orgId}/user/{userId}/activities/{activityId}/attempts",getUserAttemptStatsForActivity:"/org/{orgId}/user/{userId}/activities/{activityId}/attempts/stats",getUserAttemptForActivity:"/org/{orgId}/user/{userId}/activities/{activityId}/attempts/{attemptId}",getUserFirstAttemptForActivity:"/org/{orgId}/user/{userId}/activities/{activityId}/attempts/first",getUserLastAttemptForActivity:"/org/{orgId}/user/{userId}/activities/{activityId}/attempts/last",getUserActivityMeta:"/org/{orgId}/user/{userId}/activities/{activityId}/meta"},r.PUB_API_URLS={promoteAPI:"/{orgId}/products/{productcode}/promote",registerProductAPI:"/{orgId}/products/register",ingestByCodeAPI:"/{orgId}/products/{productcode}/ingest",createBundle:"/{orgid}/stage/{stage}/bundles",updateBundle:"/{orgid}/stage/{stage}/bundles/{bundleCode}",getAllBundles:"/{orgid}/bundles",getSingleBundle:"/{orgid}/bundles/{bundleCode}",createProductFamily:"/{orgid}/stage/{stage}/families",updateProductFamily:"/{orgid}/stage/{stage}/families/{familyCode}",getSingleProductFamily:"/{orgid}/families/{familyCode}",getAllProductFamilies:"/{orgid}/families"},r.PUSHX_API_URLS={grantByUserOrgId:"/orgs/{orgId}/grants",grantByAccountId:"/accounts/{accountId}/grants"},r.INTEGRATIONS_API_URLS={getGetStreamCredentials:"/accounts/{accountId}/getstream/credentials",queryDataFromSearch:"/search/indices/{index}",auditTrail:"/accounts/{accountId}/audit-trail",customEvents:"/accounts/{accountId}/custom-events",schedules:"/accounts/{accountId}/context/{context}/schedule",particularSchedule:"/accounts/{accountId}/context/{context}/schedule/{scheduleId}"},r.DRIVE_API_URLS={getAParticularDocument:"/accounts/{accountid}/users/{extuserid}/documents/{documentid}",getAllDocumentsInAFolder:"/accounts/{accountid}/users/{extuserid}/documents",documents:"/accounts/{accountid}/users/{userid}/documents/multi"},r.TAXONOMY_API_URLS={associateTagsWithEntity:"/org/{orgId}/taxonomy/associate-tags-with-entity",tags:"/org/{orgId}/context/{context}/taxonomy/{taxonomyId}/tags"},r.RULES_API_URLS={rules:"/org/{orgId}/context/{context}/rule_type/{ruleType}/rules",particularRule:"/org/{orgId}/context/{context}/rule_type/{ruleType}/rules/{ruleId}",updateRuleDisplay:"/org/{orgId}/context/{context}/rule_type/{ruleType}/rules/{ruleId}/update-rule-display",getUserRule:"/org/{orgId}/context/{context}/rule_type/{ruleType}/users/{userId}/rules"}},{}],3:[function(e,t,r){r.api=e("./lib/api"),r.errors=e("./lib/errors"),r.utils=e("./lib/utils"),r.validations=e("./lib/validator")},{"./lib/api":5,"./lib/errors":7,"./lib/utils":8,"./lib/validator":9}],4:[function(e,t,r){var n=e("../errors").DLSError;t.exports={convertUserResponse:function(e){var t=(e=e.data).roles;if(Array.isArray(t)){var r,n={};for(r in t)n[t[r]]=[];e.roles=n}return e},convertClassResponse:function(e){var t,r,n;return!1===(e=e.data).hasOwnProperty("pk")?e:(t={uuid:e.classid,type:"group"},Object.assign(t,e),r=e.class.instructor.first_name,n=e.class.instructor.last_name,t.class.instructor.uuid=e.class.instructor.dls_user_id,(r||n)&&(t.class.instructor.name=r||"",n)&&(t.class.instructor.name+=r?" "+n:n),t)},convertEnrollmetsResponse:function(e){var t,r=e.data;for(t in r){var n=r[t],o=n.first_name,i=n.last_name;(o||i)&&(n.name=o||"",i)&&(n.name+=o?" "+i:i),n.uuid=n.dls_user_id,n.username&&(n.ext_username=n.username),n.username=n.userid+"--ACCOUNT"}return r},convertElasticsearchErrResponse:function(e){var t=e.err,e=new n(e.type,t);return t.response&&t.response.body&&t.response.body.meta&&t.response.body.meta.body&&(e.message="Elasticsearch Error. Please refer data field for more information",e.data=t.response.body.meta.body),e}}},{"../errors":7}],5:[function(e,t,r){var s=e("superagent"),a=e("q"),n=e("string-template"),c=e("../../../config"),u=e("../../../helpers"),d=e("../errors"),p=d.DLSError,l=e("./validations");function f(e,t){return e.set("Authorization",t.access_token)}r.genericAPICaller=function(e,t,r,n){var o=a.defer(),i=l.genericAPICaller(e,t,r,n)||u.validations.isAuthenticated(this.orgId,this.token);i?o.reject(i):(r=c.DEFAULT_HOSTS[e.toUpperCase()]+r,i=f(i=s(t="DELETE"===t?"DEL":t,r),this.token),(i=Object.keys(n).length?"GET"===t||"HEAD"===t?i.query(n):i.send(n):i).end(function(e,t){e?(e=new p(d.ERROR_TYPES.API_ERROR,e),o.reject(e)):o.resolve(t.body)}));return o.promise},r.constructAPIUrl=function(e,t){return n(e,t)},r.setupAPIToken=f,r.addClassIdQueryParam=function(e,t){var r="";null!=t&&(r="?classId="+t);return e+r}},{"../../../config":2,"../../../helpers":3,"../errors":7,"./validations":6,q:42,"string-template":43,superagent:45}],6:[function(e,t,r){var o=e("../validator").validate;r.genericAPICaller=function(e,t,r,n){return o({apiName:e,method:t,url:r,params:n},{apiName:{isString:!0,presence:!0,inclusion:{within:["AUTH","PRODUCT","COLLAB","ANALYTICS","ACTIVITY","XAPI"],message:"^Enter a valid API Name"}},method:{isString:!0,presence:!0,inclusion:{within:["GET","POST","PUT","DELETE"],message:"^Enter a valid HTTP method"}},url:{isString:!0,presence:!0,format:{pattern:"^/.*$",message:"^Url should start with a /"}},params:{isObject:!0}})}},{"../validator":9}],7:[function(e,t,r){var i={API_ERROR:"API_ERROR",SDK_ERROR:"SDK_ERROR",CHANNEL_SUBSCRIPTION:"CHANNEL_SUBSCRIPTION"},n={PUSHX:"PUSHX"},o="ERROR";r.DLSError=function(e,t){if((this.type=e)===i.API_ERROR){var r,n;if(null!=t.response){if(r=t.response.body.message||t.response.body.dbErrorBody||t.response.body.code,n=t.response.body.dbErrorDescription,t.response.body.results&&t.response.body.results.errors)for(var o in r="",t.response.body.results.errors)r+=t.response.body.results.errors[o].message+" ";t.response.body.server&&(this.server=t.response.body.server)}else r=t.message||"",n=t.description||"";this.message=r,this.description=n}else e===i.PUSHX_ERROR?this.message=t.message:(this.message=t.message||"",this.description=t.description||"",delete t.message,delete t.description),this.data=t;e!==i.API_ERROR&&e!==i.PUSHX_ERROR||(this.httpcode=t.status)},r.PUSHXError=function(e,t){e===n.PUSHX?(this.category=n.PUSHX,this.type=i.CHANNEL_SUBSCRIPTION,this.status=o,this.message=t.message,this.data=t,this.httpcode=t.errorDetails&&t.errorDetails.statusCode?t.errorDetails.statusCode:500):this.message="PUSHXError called for incorrect category."},r.ERROR_TYPES=i,r.ERROR_CATEGORY=n},{}],8:[function(e,t,r){r.isBrowser="undefined"!=typeof window},{}],9:[function(e,t,r){var i=e("validate.js"),s=e("./errors"),a=s.DLSError;function n(e,t){var r={},n=i(e,t);if(n)for(var o in n)return r.message=r.description=n[o][0],r=new a(s.ERROR_TYPES.SDK_ERROR,r)}r.validate=n,r.isAuthenticated=function(e,t){return n({organization:e,token:t},{organization:{presence:{message:"^SDK Instance does not have valid orgid or token. Please authenticate using authWithCredentials or authWithToken method."}},token:{presence:{message:"^SDK Instance does not have valid orgid or token. Please authenticate using authWithCredentials or authWithToken method."}}})},i.validators.isString=function(e,t){if(!i.isString(e))return t.message||"is not a valid string"},i.validators.isObject=function(e,t){if(!i.isObject(e))return t.message||"is not a valid object"},i.validators.contains=function(e,t){if(i.isArray(t)){for(var r in t)if(!e||!e.hasOwnProperty(t[r]))return t.message||"does not contain "+t[r]}else if(i.isString(t)&&(!e||!e.hasOwnProperty(t)))return t.message||"does not contain "+t}},{"./errors":7,"validate.js":50}],10:[function(e,t,r){var i=e("q"),s=e("superagent"),a=e("../helpers"),c=a.errors.DLSError;r.getClassEnrolmentsStat=function(e,t){var r=i.defer(),n={};{var o;e&&t&&t.classid?(o=this.config.DEFAULT_HOSTS.ANALYTICS+this.config.ANALYTICS_API_URLS.getClassEnrolmentsStat,o=a.api.constructAPIUrl(o,{orgId:e}),e=s.get(o).query(t),this.traceid&&e.set("X-Amzn-Trace-Id",this.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Mandatory params not found in request body : [orgid, classid]",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise},r.getSingleInvitation=function(e,t){var r={},n=i.defer();{var o;e&&t&&t.context_id&&t.context&&t.invitationid?(o=this.config.DEFAULT_HOSTS.AUTH+this.config.AUTH_API_URLS.getSingleInvitation,o=a.api.constructAPIUrl(o,{orgId:e,invitationId:t.invitationid}),e={context:t.context,context_id:t.context_id},t=s.get(o).query(e),this.traceid&&t.set("X-Amzn-Trace-Id",this.traceid),t.end(function(e,t){e?(r=new c(a.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):(r.message=r.description="organizationId or context_id or context or invitationid not found in request options.",r=new c(a.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}},{"../helpers":3,q:42,superagent:45}],11:[function(e,t,r){var n=e("superagent"),o=e("q"),i=e("../../helpers"),s=i.errors.DLSError,a=(e("extend"),t.exports=c,e("./attempt"));function c(e,t,r){var n;if(!(this instanceof c))return(n=new c(e,t,r)).token=this.token,n.orgId=this.orgId,n.config=this.config,n;this.productId=e,this.activityId=t,this.classId=r}c.prototype.getDetails=function(){var e=this,r=o.defer(),t=i.validations.isAuthenticated(this.orgId,this.token);return t?r.reject(t):(t=e.config.DEFAULT_HOSTS.ACTIVITY+e.config.ACTIVITY_API_URLS.activityDetailsAPI,t=i.api.constructAPIUrl(t,{orgId:e.orgId,productId:e.productId,activityId:e.activityId}),t=i.api.addClassIdQueryParam(t,e.classId),t=n.get(t),t=i.api.setupAPIToken(t,e.token),e.traceid&&t.set("X-Amzn-Trace-Id",e.traceid),t.end(function(e,t){e?(e=new s(i.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):(e=t.body,(t=new Object).activity=e,r.resolve(t))})),r.promise},c.prototype.loadAttempt=function(e){e=new a(this.productId,this.activityId,e,null,this.classId,this.config);return e.setAuthCredentials(this.orgId,this.token),e.getAttemptInfo()},c.prototype.getAttempt=function(e){e=new a(this.productId,this.activityId,e,null,this.classId,this.config);return e.setAuthCredentials(this.orgId,this.token),e},c.prototype.newAttempt=function(e){var t=new a(this.productId,this.activityId,null,null,this.classId,this.config);return t.setAuthCredentials(this.orgId,this.token),t.start(e)},c.prototype.getAllQuestions=function(){var e=this,r=o.defer(),t=i.validations.isAuthenticated(this.orgId,this.token);return t?r.reject(t):(t=e.config.DEFAULT_HOSTS.PRODUCT+e.config.PRODUCT_API_URLS.activityAPI,t=i.api.constructAPIUrl(t,{orgId:e.orgId,productId:e.productId,activityId:e.activityId}),t=i.api.addClassIdQueryParam(t,e.classId),t=n.get(t),t=i.api.setupAPIToken(t,e.token),e.traceid&&t.set("X-Amzn-Trace-Id",e.traceid),t.end(function(e,t){e?(e=new s(i.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):(e=t.body,(t=new Object).questions=e.items,r.resolve(t))})),r.promise},c.prototype.getQuestionsCount=function(){var e=this,r=o.defer(),t=i.validations.isAuthenticated(this.orgId,this.token);return t?r.reject(t):(t=e.config.DEFAULT_HOSTS.PRODUCT+e.config.PRODUCT_API_URLS.activityAPI,t=i.api.constructAPIUrl(t,{orgId:e.orgId,productId:e.productId,activityId:e.activityId}),t=i.api.addClassIdQueryParam(t,e.classId),t=n.get(t),t=i.api.setupAPIToken(t,e.token),e.traceid&&t.set("X-Amzn-Trace-Id",e.traceid),t.end(function(e,t){e?(e=new s(i.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):(e={count:t.body.items.length},(t=new Object).count=e,r.resolve(t))})),r.promise}},{"../../helpers":3,"./attempt":12,extend:39,q:42,superagent:45}],12:[function(e,t,r){var s=e("superagent"),a=e("q"),c=e("../../helpers"),u=c.errors.DLSError,d=e("extend");function p(e,t,r,n,o,i){this.productId=e,this.activityId=t,this.attemptId=r,this.classId=o,this.config=i,p.prototype.getAuthCredentials=function(){return function(){return this.authCredentials}()},p.prototype.setAuthCredentials=function(e,t){var r=new Object;r.orgId=e,r.token=t,function(e){this.authCredentials=e}(r)}}(t.exports=p).prototype.start=function(e){var r=this,t=this.getAuthCredentials().orgId,n=this.getAuthCredentials().token,o=a.defer(),i=c.validations.isAuthenticated(t,n);return i?o.reject(i):(i=r.config.DEFAULT_HOSTS.ACTIVITY+r.config.ACTIVITY_API_URLS.newAttemptAPI,i=c.api.constructAPIUrl(i,{orgId:t,productId:r.productId,activityId:r.activityId}),i=c.api.addClassIdQueryParam(i,r.classId),null==e&&(e={}),t=s.post(i).send(e),t=c.api.setupAPIToken(t,n),r.traceid&&t.set("X-Amzn-Trace-Id",r.traceid),t.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),o.reject(e)):(e=t.body,r.attemptId=e.uuid,d(!0,r,e),(t=new Object).attempt=r,o.resolve(t))})),o.promise},p.prototype.getAttemptInfo=function(){var e=this.getAuthCredentials().orgId,t=this.getAuthCredentials().token,r=this,n=a.defer(),o=c.validations.isAuthenticated(e,t);return o?n.reject(o):(o=r.config.DEFAULT_HOSTS.ACTIVITY+r.config.ACTIVITY_API_URLS.existingAttemptAPI,o=c.api.constructAPIUrl(o,{orgId:e,productId:r.productId,activityId:r.activityId,attemptId:r.attemptId}),o=c.api.addClassIdQueryParam(o,r.classId),e=s.get(o),e=c.api.setupAPIToken(e,t),r.traceid&&e.set("X-Amzn-Trace-Id",r.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):(e=t.body,r.attemptId=e.uuid,d(!0,r,e),(t=new Object).attempt=r,n.resolve(t))})),n.promise},p.prototype.getState=function(){var e=this.getAuthCredentials().orgId,t=this.getAuthCredentials().token,r=this,n=a.defer(),o=c.validations.isAuthenticated(e,t);return o?n.reject(o):(o=r.config.DEFAULT_HOSTS.ACTIVITY+r.config.ACTIVITY_API_URLS.existingAttemptAPI,o=c.api.constructAPIUrl(o,{orgId:e,productId:r.productId,activityId:r.activityId,attemptId:r.attemptId}),o=c.api.addClassIdQueryParam(o,r.classId),e=s.get(o),e=c.api.setupAPIToken(e,t),r.traceid&&e.set("X-Amzn-Trace-Id",r.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):(e=t.body,(t=new Object).state=e.data.savedstate.state,n.resolve(t))})),n.promise},p.prototype.saveState=function(e){var t=this.getAuthCredentials().orgId,r=this.getAuthCredentials().token,n=this,o=a.defer(),i=c.validations.isAuthenticated(t,r);return i?o.reject(i):(i=n.config.DEFAULT_HOSTS.ACTIVITY+n.config.ACTIVITY_API_URLS.existingAttemptAPI,i=c.api.constructAPIUrl(i,{orgId:t,productId:n.productId,activityId:n.activityId,attemptId:n.attemptId}),i=c.api.addClassIdQueryParam(i,n.classId),t=s.put(i).send(e),t=c.api.setupAPIToken(t,r),n.traceid&&t.set("X-Amzn-Trace-Id",n.traceid),t.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),o.reject(e)):(e=t.body,(t=new Object).status=e,o.resolve(t))})),o.promise},p.prototype.getUserResponse=function(){var e=this.getAuthCredentials().orgId,t=this.getAuthCredentials().token,r=this,n=a.defer(),o=c.validations.isAuthenticated(e,t);return o?n.reject(o):(o=r.config.DEFAULT_HOSTS.ACTIVITY+r.config.ACTIVITY_API_URLS.userResponseAPI,o=c.api.constructAPIUrl(o,{orgId:e,productId:r.productId,activityId:r.activityId,attemptId:r.attemptId}),o=c.api.addClassIdQueryParam(o,r.classId),e=s.get(o),e=c.api.setupAPIToken(e,t),r.traceid&&e.set("X-Amzn-Trace-Id",r.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):(e=t.body,(t=new Object).userresponse=e,n.resolve(t))})),n.promise},p.prototype.saveUserResponse=function(e){var t=this.getAuthCredentials().orgId,r=this.getAuthCredentials().token,n=this,o=a.defer(),i=c.validations.isAuthenticated(t,r);return i?o.reject(i):(i=n.config.DEFAULT_HOSTS.ACTIVITY+n.config.ACTIVITY_API_URLS.userResponseAPI,i=c.api.constructAPIUrl(i,{orgId:t,productId:n.productId,activityId:n.activityId,attemptId:n.attemptId}),i=c.api.addClassIdQueryParam(i,n.classId),t=s.put(i).send(e),t=c.api.setupAPIToken(t,r),n.traceid&&t.set("X-Amzn-Trace-Id",n.traceid),t.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),o.reject(e)):(e=t.body,(t=new Object).status=e,o.resolve(t))})),o.promise},p.prototype.submit=function(e){var t=this.getAuthCredentials().orgId,r=this.getAuthCredentials().token,n=this,o=a.defer(),i=c.validations.isAuthenticated(t,r);return i?o.reject(i):(i=n.config.DEFAULT_HOSTS.ACTIVITY+n.config.ACTIVITY_API_URLS.submitAttemptAPI,i=c.api.constructAPIUrl(i,{orgId:t,productId:n.productId,activityId:n.activityId,attemptId:n.attemptId}),i=c.api.addClassIdQueryParam(i,n.classId),t=null==e?s.post(i).send({}):s.post(i).send(e),t=c.api.setupAPIToken(t,r),n.traceid&&t.set("X-Amzn-Trace-Id",n.traceid),t.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),o.reject(e)):(e=t.body,(t=new Object).status=e,o.resolve(t))})),o.promise}},{"../../helpers":3,extend:39,q:42,superagent:45}],13:[function(e,t,r){t.exports=e("./activity")},{"./activity":11}],14:[function(e,t,r){var s=e("q"),a=e("superagent"),n=e("agentkeepalive"),c=e("../../helpers"),u=c.errors.DLSError,d=(t.exports=function(){return{archiveUserAnalytics:function(e){var t=this,r={},n=s.defer();{var o,i;e&&e.userid&&e.productid?(r=c.validations.isAuthenticated(t.orgId,t.token))?n.reject(r):(o={},i=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.archiveUserAnalytics,i=c.api.constructAPIUrl(i,{orgId:t.orgId}),e.userid&&(o.userid=e.userid),e.productid&&(o.productid=e.productid),e.classid&&(o.classid=e.classid),e=a.post(i).query(o).set("Content-Type","application/json"),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):n.resolve(t.body)})):(r.message=r.description="Mandatory parameter [userid, productid] not found in request options",r=new u(c.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),getArchivedUserAnalytics:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.useranalyticid?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getArchivedUserAnalytics,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={useranalyticid:e.useranalyticid},e&&(e.cursor&&(i.cursor=e.cursor),e.limit)&&(i.limit=e.limit),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Mandatory field 'useranalyticid' not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getOrgAnalyticsStat:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.type?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(n={},-1<["users","classes"].indexOf(e.type)?(i=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getOrgAnalyticsStat,i=c.api.constructAPIUrl(i,{orgId:t.orgId,type:e.type}),o={},e&&(e.range&&(o.range=e.range),e.start&&(o.start=e.start),e.end&&(o.end=e.end),e.role&&(o.role=e.role),e.shadow)&&(o.shadow=e.shadow),i=a.get(i).query(o),i=c.api.setupAPIToken(i,t.token),t.traceid&&i.set("X-Amzn-Trace-Id",t.traceid),i.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Type: "+e.type+" is not supported",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))):(n.message=n.description="type not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getClassAnalytics:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.type&&e.analyticsDataType&&e.classid?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(n={},!e.range&&!e.interval||e.range&&"stat"===e.type||e.interval&&"timeseries"===e.type?-1<["enrolments","logins"].indexOf(e.analyticsDataType)?(i=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getClassAnalytics,i=c.api.constructAPIUrl(i,{orgId:t.orgId,type:e.type,analyticsDataType:e.analyticsDataType}),o={classid:e.classid},e&&(e.range&&(o.range=e.range),e.start&&(o.start=e.start),e.end&&(o.end=e.end),e.interval)&&(o.interval=e.interval),i=a.get(i).query(o),i=c.api.setupAPIToken(i,t.token),t.traceid&&i.set("X-Amzn-Trace-Id",t.traceid),i.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="analyticsDataType: "+e.analyticsDataType+" is not supported",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n)):(n.message=n.description='Range should be defined for type - "stat" and Interval should be defined for type - "timeseries"',n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))):(n.message=n.description='Required options ["type", "analyticsDataType", "classid"] not found in request options',n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getClassProductRecentPendingSubmissions:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.classid&&e.productcode?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getClassProductRecentPendingSubmissions,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={classid:e.classid,productcode:e.productcode},e.details&&(i.details=e.details),e.limit&&(i.limit=e.limit),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description='Mandatory parameters ["classid", "productcode"] not found in request options.',n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getClassRecordUserAggregations:function(e){var t=this,r={},n=s.defer();{var o;e&&e.classid&&e.productcode?(r=c.validations.isAuthenticated(t.orgId,t.token))?n.reject(r):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getClassRecordUserAggregations,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),e={classid:e.classid,productcode:e.productcode,userid:e.userid},o=a.get(o).query(e),o=c.api.setupAPIToken(o,t.token),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(r=new u(c.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):(r.message=r.description="Required parameter classid or productcode not found in request options.",r=new u(c.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),getClassRecord:function(e){var t=this,r=s.defer(),n={};{var o;e&&e.classid&&e.productcode?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getClassRecord,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),e={classid:e.classid,productcode:e.productcode,userids:e.userids,includeContext:e.includeContext},o=a.get(o).query(e),o=c.api.setupAPIToken(o,t.token),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description="Required parameter classid or productcode not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getClassRecordItemAggregations:function(e){var t=this,r=s.defer(),n={};{var o;e&&e.classid&&e.productcode?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getClassRecordItemAggregations,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),e={classid:e.classid,productcode:e.productcode,"item-code":e["item-code"]},o=a.get(o).query(e),o=c.api.setupAPIToken(o,t.token),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description="Required parameter classid or productcode not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getShowcaseRecordOfAClass:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.classid?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getShowcaseRecordOfAClass,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={classid:e.classid},e.productcode&&(i.productcode=e.productcode),e.groupid&&(i.groupid=e.groupid),e["item-code"]&&(i["item-code"]=e["item-code"]),e.id&&(i.id=e.id),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description="Required parameter classid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getGroupRecord:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.classid&&e.productcode&&e.groupid?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getGroupRecord,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={classid:e.classid,productcode:e.productcode,groupid:e.groupid},e.itemcode&&(i.itemcode=e.itemcode),e.history&&(i.history=e.history),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description="Required parameter classid or productcode or groupid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getClassGroupsRecentPendingSubmissions:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.classid&&e.productcode?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getClassGroupsRecentPendingSubmissions,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={classid:e.classid,productcode:e.productcode},e.details&&(i.details=e.details),e.limit&&(i.limit=e.limit),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description='Mandatory parameters ["classid", "productcode"] not found in request options.',n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getGroupsWithEvaluatedOnce:function(e){var t=this,r={},n=s.defer();{var o;e&&e.classid&&e.productcode?(r=c.validations.isAuthenticated(t.orgId,t.token))?n.reject(r):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getGroupsWithEvaluatedOnce,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),e={classid:e.classid,productcode:e.productcode},o=a.get(o).query(e),o=c.api.setupAPIToken(o,t.token),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(r=new u(c.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):(r.message=r.description="Required parameter classid or productcode not found in request options.",r=new u(c.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),getUserProductAnalytics:function(e){var t=this,r=s.defer(),n={};if(e&&e.type&&e.userid&&e.productcode)if(n=c.validations.isAuthenticated(t.orgId,t.token))r.reject(n);else{var o=t.config.DEFAULT_HOSTS.ANALYTICS;if(-1<["items","summary"].indexOf(e.type)){switch(e.type){case"items":o+=t.config.ANALYTICS_API_URLS.getAnalyticProductItems;break;case"summary":o+=t.config.ANALYTICS_API_URLS.getAnalyticProductSummary}o=c.api.constructAPIUrl(o,{orgId:t.orgId});var i={userid:e.userid,productcode:e.productcode},i=(e.classid&&(i.classid=e.classid),e.itemcode&&(i.itemcode=e.itemcode),e.metrics&&(i.metrics=e.metrics),e.history&&(i.history=e.history),e.group&&(i.group=e.group),e.externalData&&(i.externalData=e.externalData),e.expiredView&&"items"===e.type&&(i.expiredView=e.expiredView),a.get(o).query(i));i=c.api.setupAPIToken(i,t.token),t.traceid&&i.set("X-Amzn-Trace-Id",t.traceid),i.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})}else n.message=n.description=e.type+" is not a valid value of option 'type'",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n)}else n.message=n.description="Required parameter 'type' or 'userid' or 'productcode' not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n);return r.promise}.bind(this),getUserProductAnalyticById:function(e){var t=this,r=s.defer(),n={};{var o;e&&e.userprogressid?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getAnalyticProductById,o=c.api.constructAPIUrl(o,{orgId:t.orgId,userProgressId:e.userprogressid}),e=a.get(o),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Required parameter 'userprogressid' not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getExternalDataForUserAnalyticItem:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.ext_user_id&&e.productcode&&e.itemcode&&(e.submission_order||e.ext_link_id)&&e.part?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getExternalDataForUserAnalyticItem,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={ext_user_id:e.ext_user_id,productcode:e.productcode,itemcode:e.itemcode,part:e.part},e.submission_order&&(i.submission_order=e.submission_order),e.ext_link_id&&(i.ext_link_id=e.ext_link_id),e.classid&&(i.classid=e.classid),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Required parameters 'ext_user_id' or 'productcode' or 'itemcode' or (either 'submission_order' OR 'ext_link_id') or 'part'are not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),searchUserProductAnalytics:function(e){var t=this,r={},n=s.defer();{var o;(r=c.validations.isAuthenticated(t.orgId,t.token))?n.reject(r):(r={},o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.searchUserProductAnalytics,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),e.userid&&(r.userid=e.userid),e.productid&&(r.productid=e.productid),e.classid&&(r.classid=e.classid),e.lookup&&(r.lookup=e.lookup),e.cursor&&(r.cursor=e.cursor),e.limit&&(r.limit=e.limit),e=a.get(o).query(r),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):n.resolve(t.body)}))}return n.promise}.bind(this),getUserClassRecentSubmissions:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.classid&&e.productcode&&e.userid?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getUserClassRecentSubmissions,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={userid:e.userid,classid:e.classid,productcode:e.productcode},e.gradingStatus&&(i.gradingStatus=e.gradingStatus),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description='Mandatory parameters ["classid", "productcode", "userid"] not found in request options.',n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getStudentsWithEvaluatedOnce:function(e){var t=this,r={},n=s.defer();{var o;e&&e.classid&&e.productcode?(r=c.validations.isAuthenticated(t.orgId,t.token))?n.reject(r):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getStudentsWithEvaluatedOnce,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),e={classid:e.classid,productcode:e.productcode},o=a.get(o).query(e),o=c.api.setupAPIToken(o,t.token),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(r=new u(c.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):(r.message=r.description="Required parameter classid or productcode not found in request options.",r=new u(c.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),getAppState:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.userid&&e.productcode?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.appState,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={userid:e.userid,productcode:e.productcode},e.classid&&(i.classid=e.classid),e.itemcode&&(i.itemcode=e.itemcode),e.key&&(i.key=e.key),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Required parameters 'userid' or 'productcode' are not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateAppState:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.userid&&e.productcode&&e.appdata?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(i=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.appState,i=c.api.constructAPIUrl(i,{orgId:t.orgId}),o={userid:e.userid,productcode:e.productcode},e.classid&&(o.classid=e.classid),e.itemcode&&(o.itemcode=e.itemcode),i=a.put(i).query(o).set("Content-Type","application/json").set("Accept","application/json").send(e.appdata),i=c.api.setupAPIToken(i,t.token),t.traceid&&i.set("X-Amzn-Trace-Id",t.traceid),i.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Required parameters 'userid' or 'appdata' or 'productcode' are not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),deleteAppState:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.userid&&e.productcode?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.appState,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={userid:e.userid,productcode:e.productcode},e.classid&&(i.classid=e.classid),e.itemcode&&(i.itemcode=e.itemcode),e.key&&(i.key=e.key),e=a.delete(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Required parameters 'userid' or 'productcode' are not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getUserProductAllState:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.userid&&e.productcode?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getUserProductAllState,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={userid:e.userid,productcode:e.productcode},e.classid&&(i.classid=e.classid),e.itemcode&&(i.itemcode=e.itemcode),e.model&&(i.model=e.model),e.key&&(i.key=e.key),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Required parameters 'userid' or 'productcode' are not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateUserProductMultiState:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.userid&&e.productcode&&e.data?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(i=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.updateUserProductMultiState,i=c.api.constructAPIUrl(i,{orgId:t.orgId}),o={userid:e.userid,productcode:e.productcode},e.classid&&(o.classid=e.classid),i=a.put(i).query(o).set("Content-Type","application/json").set("Accept","application/json").send(e.data),i=c.api.setupAPIToken(i,t.token),t.traceid&&i.set("X-Amzn-Trace-Id",t.traceid),i.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t)})):(n.message=n.description="Required parameters 'userid' or 'data' or 'productcode' are not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getQuestionProgressByLearningObjective:function(e){for(var t,r,n={},o=0;o<e.length;o++)for(var i,s,a=e[o]["learning-objectives"],c=0;c<a.length;c++)n[a[c]]?(s=n[a[c]],"correct"===(t=e[o].__analytics).statusEvaluation&&(r=s.status.correct,s.status.correct=r+1),i=s.status.total,s.status.total=i+1,i={"question-code":e[o].questionCode,analytics:t},s.questions.push(i),n[a[c]]=s):(r=0,"correct"===(t=e[o].__analytics).statusEvaluation&&r++,s={status:{correct:r,total:1},questions:[]},i={"question-code":e[o].questionCode,analytics:t},s.questions.push(i),n[a[c]]=s);return n}.bind(this),getAllAssignedPathsOfClass:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid?(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getAllAssignedPathsOfClass,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),e={classid:e.classid,status_not_started:e.status_not_started,status_active:e.status_active,status_expired:e.status_expired,limit:e.limit,cursor:e.cursor},o=a.get(o).query(e),o=c.api.setupAPIToken(o,t.token),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.agent(d).end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory param - classid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getMyAssignedPathsOfClass:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.classid&&e.userid?(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getMyAssignedPathsOfClass,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={userid:e.userid,classid:e.classid},e.progress&&(i.progress=e.progress),e.group&&(i.group=e.group),e.expiredView&&(i.expiredView=e.expiredView),e.status_not_started&&(i.status_not_started=e.status_not_started),e.status_active&&(i.status_active=e.status_active),e.status_expired&&(i.status_expired=e.status_expired),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.agent(d).end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - classid, userid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getUserAssignedPathsOfClass:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.classid&&e.userid?(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getMyAssignedPathsOfClass,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={userid:e.userid,classid:e.classid},e.progress&&(i.progress=e.progress),e.group&&(i.group=e.group),e.expiredView&&(i.expiredView=e.expiredView),e.status_not_started&&(i.status_not_started=e.status_not_started),e.status_active&&(i.status_active=e.status_active),e.status_expired&&(i.status_expired=e.status_expired),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.agent(d).end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - classid, userid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAssignedPathAnalytics:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid&&e.productcode?(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getAssignedPathAnalytics,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),e={classid:e.classid,assignedpathid:e.assignedPathId,ext_assignedpathid:e.ext_assignedpathid,productcode:e.productcode},o=a.get(o).query(e),o=c.api.setupAPIToken(o,t.token),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - classid or productcode not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getMyParticularAssignedPathOfClass:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.classid&&e.userid?(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getMyAssignedPathsOfClass,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={assignedpathid:e.assignedPathId,classid:e.classid,userid:e.userid},e.progress&&(i.progress=e.progress),e.group&&(i.group=e.group),e.assignedpathid&&(i.assignedpathid=e.assignedpathid),e.ext_assignedpathid&&(i.ext_assignedpathid=e.ext_assignedpathid),e.expiredView&&(i.expiredView=e.expiredView),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - classid, userid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getParticularAssignedPathOfClass:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.classid&&(e.assignedpathid||e.ext_assignedpathid)?(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getAllAssignedPathsOfClass,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={classid:e.classid},e.assignedpathid&&(i.assignedpathid=e.assignedpathid),e.ext_assignedpathid&&(i.ext_assignedpathid=e.ext_assignedpathid),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.agent(d).end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body.entities[0])})):((n={}).message=n.description="Mandatory params - 'classid', 'assignedpathid'/'ext_assignedpathid' not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getTimeseriesAnalytics:function(e){var r,n=s.defer();{var t,o;e&&e.query?(t=this.config.DEFAULT_HOSTS.ANALYTICS+this.config.ANALYTICS_API_URLS.timeseriesAnalytics,o={query:e.query},e.cursor&&(o.cursor=e.cursor),e=a.get(t).query(o),this.traceid&&e.set("X-Amzn-Trace-Id",this.traceid),e.agent(d).end(function(e,t){e?(r=new u(c.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):((r={}).message=r.description="Mandatory params query not found in request options.",r=new u(c.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),postProgressTimeseries:function(e){var r,n=s.defer();{var t;e&&e.body&&e.body.query?(t=this.config.DEFAULT_HOSTS.ANALYTICS+this.config.ANALYTICS_API_URLS.timeseriesAnalytics,t=a.post(t).send(e.body),e.cursor&&(e={cursor:e.cursor},t.query(e)),this.traceid&&t.set("X-Amzn-Trace-Id",this.traceid),t.agent(d).end(function(e,t){e?(r=new u(c.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):((r={}).message=r.description="Mandatory options.body.query not found in request options.",r=new u(c.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),getClassCustomComponentRecord:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.classid?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getClassCustomComponentRecord,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={classid:e.classid},e.custom_component_code&&(i.custom_component_code=e.custom_component_code),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?((n=new u(c.errors.ERROR_TYPES.API_ERROR,e)).message=e.response.res.text,r.reject(n)):r.resolve(t.body)})):(n.message=n.description="Required parameter classid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getClassCustomComponentUserSubmission:function(e){var t=this,r=s.defer(),n={};{var o;e&&e.classid&&e.custom_component_code&&e.userid&&e.item_code?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getClassCustomComponentUserSubmission,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),e={classid:e.classid,userid:e.userid,custom_component_code:e.custom_component_code,item_code:e.item_code},o=a.get(o).query(e),o=c.api.setupAPIToken(o,t.token),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?((n=new u(c.errors.ERROR_TYPES.API_ERROR,e)).message=e.response.res.text,r.reject(n)):r.resolve(t.body)})):(n.message=n.description="Required parameter classid or custom-component-code or userid or item-code not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getCrossProductAggregation:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.classid?(n=c.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.ANALYTICS+t.config.ANALYTICS_API_URLS.getCrossProductAggregation,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),i={classid:e.classid},e.userid&&(i.userid=e.userid),e=a.get(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description="Required parameter classid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this)}},new n({timeout:6e4,freeSocketTimeout:3e4}))},{"../../helpers":3,agentkeepalive:36,q:42,superagent:45}],15:[function(e,t,r){var i=e("q"),s=e("superagent"),a=e("../../helpers"),c=a.errors.DLSError;t.exports=function(){return{getUserAllAttemptsForActivity:function(e){var t=this,r=i.defer();{var n,o;e&&e.userid&&e.activityid?(n=t.config.DEFAULT_HOSTS.ATTEMPTS+t.config.ATTEMPTS_API_URLS.userAttempts,n=a.api.constructAPIUrl(n,{orgId:t.orgId,userId:e.userid,activityId:e.activityid}),o={},e.allorgs&&(o.allorgs=e.allorgs),e.classid&&(o.classid=e.classid),e.assignmentid&&(o.assignmentid=e.assignmentid),e.productcode&&(o.productcode=e.productcode),e.cursor&&(o.cursor=e.cursor),e.limit&&(o.limit=e.limit),e.sortOrder&&(o.sortOrder=e.sortOrder),e=s.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - userid or activityid not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createUserAttemptForActivity:function(e){var t=this,r=i.defer();{var n;e&&e.userid&&e.activityid&&e.body?(n=t.config.DEFAULT_HOSTS.ATTEMPTS+t.config.ATTEMPTS_API_URLS.userAttempts,n=a.api.constructAPIUrl(n,{orgId:t.orgId,userId:e.userid,activityId:e.activityid}),n=s.post(n).send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory params - userid or activityid or body not found in request options.",e=new c(a.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),getUserAttemptStatsForActivity:function(e){var t=this,r=i.defer();{var n,o;e&&e.userid&&e.activityid?(n=t.config.DEFAULT_HOSTS.ATTEMPTS+t.config.ATTEMPTS_API_URLS.getUserAttemptStatsForActivity,n=a.api.constructAPIUrl(n,{orgId:t.orgId,userId:e.userid,activityId:e.activityid}),o={},e.allorgs&&(o.allorgs=e.allorgs),e.classid&&(o.classid=e.classid),e.assignmentid&&(o.assignmentid=e.assignmentid),e=s.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - userid or activityid not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getUserAttemptForActivity:function(e){var t=this,r=i.defer();{var n,o;e&&e.userid&&e.activityid&&e.attemptid?(n=t.config.DEFAULT_HOSTS.ATTEMPTS+t.config.ATTEMPTS_API_URLS.getUserAttemptForActivity,n=a.api.constructAPIUrl(n,{orgId:t.orgId,userId:e.userid,activityId:e.activityid,attemptId:e.attemptid}),o={},e.details&&(o.details=e.details),e=s.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - userid or activityid or attemptid not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getUserFirstAttemptForActivity:function(e){var t=this,r=i.defer();{var n,o;e&&e.userid&&e.activityid?(n=t.config.DEFAULT_HOSTS.ATTEMPTS+t.config.ATTEMPTS_API_URLS.getUserFirstAttemptForActivity,n=a.api.constructAPIUrl(n,{orgId:t.orgId,userId:e.userid,activityId:e.activityid}),o={},e.details&&(o.details=e.details),e.classid&&(o.classid=e.classid),e.assignmentid&&(o.assignmentid=e.assignmentid),e=s.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - userid or activityid not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getUserLastAttemptForActivity:function(e){var t=this,r=i.defer();{var n,o;e&&e.userid&&e.activityid?(n=t.config.DEFAULT_HOSTS.ATTEMPTS+t.config.ATTEMPTS_API_URLS.getUserLastAttemptForActivity,n=a.api.constructAPIUrl(n,{orgId:t.orgId,userId:e.userid,activityId:e.activityid}),o={},e.details&&(o.details=e.details),e.classid&&(o.classid=e.classid),e.assignmentid&&(o.assignmentid=e.assignmentid),e=s.get(n).query(o),console.log(n,o,e),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - userid or activityid not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateUserAttemptForActivity:function(e){var t=this,r=i.defer();{var n;e&&e.userid&&e.activityid&&e.attemptid&&e.body?(n=t.config.DEFAULT_HOSTS.ATTEMPTS+t.config.ATTEMPTS_API_URLS.getUserAttemptForActivity,n=a.api.constructAPIUrl(n,{orgId:t.orgId,userId:e.userid,activityId:e.activityid,attemptId:e.attemptid}),e=e.body,n=s.put(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory params - userid or activityid or attemptid or body not found in request options.",e=new c(a.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),getUserActivityMeta:function(e){var t=this,r=i.defer();{var n,o;e&&e.userid&&e.activityid?(n=t.config.DEFAULT_HOSTS.ATTEMPTS+t.config.ATTEMPTS_API_URLS.getUserActivityMeta,n=a.api.constructAPIUrl(n,{orgId:t.orgId,userId:e.userid,activityId:e.activityid}),o={},e.classid&&(o.classid=e.classid),e.assignmentid&&(o.assignmentid=e.assignmentid),e=s.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - userid or activityid not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this)}}},{"../../helpers":3,q:42,superagent:45}],16:[function(e,t,r){var m=e("q"),R=e("superagent"),n=e("agentkeepalive"),_=e("../../helpers"),A=e("../../helpers/lib/api/converter"),b=_.errors.DLSError,d=(t.exports=function(){return{pisImport:function(e){var t,r=this,n=m.defer(),o=_.validations.isAuthenticated(r.orgId,r.token);{var i;o?n.reject(o):(o=r.config.DEFAULT_HOSTS.AUTH+r.config.AUTH_API_URLS.pisImportAPI,o=_.api.constructAPIUrl(o,{orgId:r.orgId}),i={},e&&(e.extension&&(i.extension=e.extension),e.import_type&&(i.import_type=e.import_type),e.upfile)&&(t=e.upfile),e=R.post(o).query(i).set("Content-Type","multipart/form-data").attach("upfile",t),r.traceid&&e.set("X-Amzn-Trace-Id",r.traceid),(e=_.api.setupAPIToken(e,r.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):n.resolve(t.body)}))}return n.promise}.bind(this),getAllUsers:function(s){var a=this,c=m.defer(),e=_.validations.isAuthenticated(a.orgId,a.token);if(e)c.reject(e);else{e='orgid:"'+a.orgId+'"';if(s.lookup&&s["lookup-operator"]&&(n=s.lookup,n=(n=n.replace(/ext_/gi,"")).split(",").map(function(e){var e=e.trim(),t=e.split(":");return e="("+e+" OR "+t[0]+".keyword:"+t[1]+")"}),e=e+" AND ("+n.join(" "+s["lookup-operator"]+" ")+")"),s.role){var t,r=s.role.split(",").map(function(e){return e.trim()});for(t in r)r[t]="roles:"+r[t];e=e+" AND ("+r.join(" OR ")+")"}s.search&&(e=e+' AND (email:"'+s.search+'" OR first_name:"'+s.search+'" OR last_name:"'+s.search+'" OR username:"'+s.search+'" OR userid:"'+s.search+'")');var n=s.sortField||"",o=(n=n.replace(/ext_/gi,"").split(",").shift().trim()||"last_name",s.sortOrder||"asc"),i=("created"!==n&&(n+=".keyword"),{}),u=[],n=(i[n]=o,u.push(i),{query:{query_string:{query:e}},sort:u}),o=(s.cursor&&(n.search_after=JSON.parse(s.cursor)),s.limit?n.size=s.limit:s.limit=10,a.config.DEFAULT_HOSTS.INTEGRATION+a.config.INTEGRATIONS_API_URLS.queryDataFromSearch),i=(o=_.api.constructAPIUrl(o,{index:"users"}),{query:JSON.stringify(n)}),e=R.get(o).query(i);a.traceid&&e.set("X-Amzn-Trace-Id",a.traceid),(e=_.api.setupAPIToken(e,a.token)).end(function(e,t){if(e){e={type:_.errors.ERROR_TYPES.API_ERROR,err:e},e=A.convertElasticsearchErrResponse(e);c.reject(e)}else{var r,n={entities:[]};for(r in n.count=t.body.hits.hits.length,n.count&&s.limit===n.count&&(e=t.body.hits.hits[t.body.hits.hits.length-1].sort,n.cursor=JSON.stringify(e)),t.body.hits.hits){var o=t.body.hits.hits[r]._source,i={uuid:o.dls_user_id,name:o.first_name+" "+o.last_name,email:o.email||o.ext_email,username:o.userid+"--ACCOUNT",created:o.created,org:{id:a.orgId}};o.roles&&(i.roles=o.roles),o.provision_method&&(i.provision_method=o.provision_method),o.first_name&&(i.first_name=o.first_name),o.last_name&&(i.last_name=o.last_name),o.ext_parent_id&&(i.ext_parent_id=o.ext_parent_id),o.username&&(i.ext_username=o.username),o.userid&&(i.ext_user_id=o.userid),o.address&&(i.address=o.address),n.entities.push(i)}c.resolve(n)}})}return c.promise}.bind(this),getAllUsersV2:function(s){var e,t,a=this,c=m.defer(),r=_.validations.isAuthenticated(a.orgId,a.token);if(r)c.reject(r);else{var n={query:{bool:{must:[]}},size:s.limit||10},o='orgid:"'+a.orgId+'"';if(s.role){for(var i in h=s.role,e=h.split(",").map(function(e){return e.trim()}))e[i]="roles:"+e[i];o=o+" AND ("+e.join(" OR ")+")"}if(n.query.bool.must.push({query_string:{query:o}}),s.lookup&&s["lookup-operator"]){h=s.lookup.replace(/ext_/gi,""),t=h.split(",");var u,d={bool:{}};for(u in t){var p,l=t[u].trim().split(":"),f={wildcard:{}};if(p=l[0]+".keyword",l=l[1],f.wildcard[p]="email.keyword"==p?{value:l,case_insensitive:!0}:{value:l,case_insensitive:!1},"OR"!==s["lookup-operator"])return(r={}).message=r.description="The value 'AND' for the field 'lookup-operator' is currently NOT supported",r=new b(_.errors.ERROR_TYPES.SDK_ERROR,r),c.reject(r),c.promise;d.bool.should||(d.bool.should=[]),d.bool.should.push(f)}n.query.bool.must.push(d)}var o={},h=[],g=(y=s.sortOrder||"asc","created"!==(g=(g=s.sortField||"last_name").replace(/ext_/gi,"").split(",").shift().trim())&&(g+=".keyword"),o[g]=y,h.push(o),n.sort=h,s.cursor&&(n.search_after=JSON.parse(s.cursor)),a.config.DEFAULT_HOSTS.INTEGRATION+a.config.INTEGRATIONS_API_URLS.queryDataFromSearch),y=(g=_.api.constructAPIUrl(g,{index:"users"}),{query:JSON.stringify(n)}),o=R.get(g).query(y);a.traceid&&o.set("X-Amzn-Trace-Id",a.traceid),(o=_.api.setupAPIToken(o,a.token)).end(function(e,t){if(e){e={type:_.errors.ERROR_TYPES.API_ERROR,err:e},e=A.convertElasticsearchErrResponse(e);c.reject(e)}else{var r,n={entities:[],count:t.body.hits.hits.length};for(r in n.count&&s.limit===n.count&&(e=t.body.hits.hits[t.body.hits.hits.length-1].sort,n.cursor=JSON.stringify(e)),t.body.hits.hits){var o=t.body.hits.hits[r]._source,i={uuid:o.dls_user_id,name:o.first_name+" "+o.last_name,email:o.email||o.ext_email,username:o.userid+"--ACCOUNT",created:o.created,org:{id:a.orgId}};o.roles&&(i.roles=o.roles),o.provision_method&&(i.provision_method=o.provision_method),o.first_name&&(i.first_name=o.first_name),o.last_name&&(i.last_name=o.last_name),o.ext_parent_id&&(i.ext_parent_id=o.ext_parent_id),o.username&&(i.ext_username=o.username),o.userid&&(i.ext_user_id=o.userid),o.address&&(i.address=o.address),n.entities.push(i)}c.resolve(n)}})}return c.promise}.bind(this),getUserProfile:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):(n="me",e&&e.userid&&(n=e.userid),e=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.userInfoAPI,e=_.api.constructAPIUrl(e,{orgId:t.orgId,userId:n}),n=R.get(e).query({}),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=_.api.setupAPIToken(n,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):(e=A.convertUserResponse({data:t.body}),r.resolve(e))}));return r.promise}.bind(this),deleteUserProfile:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e.userid?(e=e.userid,o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.userInfoAPI,o=_.api.constructAPIUrl(o,{orgId:t.orgId,userId:e}),e=R.delete(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory parameter userid not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateUserRole:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.userid&&e.target_role?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.updateUserRoleAPI,n=_.api.constructAPIUrl(n,{orgId:t.orgId,userId:e.userid}),e={ext_data:e.ext_data,target_role:e.target_role},n=R.put(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=_.api.setupAPIToken(n,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t)})):((e={}).message=e.description="Mandatory parameter options, userid or target_role, not found in request options.",e=new b(_.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e));return r.promise}.bind(this),getUserClasses:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):(n="me",e&&e.userid&&(n=e.userid),o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getUserClassesAPI,o=_.api.constructAPIUrl(o,{orgId:t.orgId,userId:n}),n={},e&&(e.search&&(n.search="title:"+e.search),e.details&&(n.details=e.details),e.enrollmentType&&(n.enrollmentType=e.enrollmentType),e.sortField&&(n.sortField=e.sortField),e.sortOrder&&(n.sortOrder=e.sortOrder),e.cursor&&(n.cursor=e.cursor),e.limit&&(n.limit=e.limit),e.teacherId&&(n.lookup="class.class.instructor.uuid:"+e.teacherId),e.bundleDetails)&&(n.bundleDetails=e.bundleDetails),e=R.get(o).query(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}))}return r.promise}.bind(this),getUserClassesV2:function(e){var t=this,r=t.orgId,n=t.token,o=m.defer(),i=_.validations.isAuthenticated(r,n);{var s,a;i?o.reject(i):e&&e.userid?(a=e.userid,s=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getUserClassesV2API,s=_.api.constructAPIUrl(s,{orgid:r,userid:a}),r={},e&&(void 0!==e.shadow&&(r.shadow=e.shadow),void 0!==e.hidden&&(r.hidden=e.hidden),e.status_active&&(r.status_active=e.status_active),e.status_ended&&(r.status_ended=e.status_ended),e.status_expired&&(r.status_expired=e.status_expired),e.details&&(r.details=e.details),e.bundleDetails&&(r.bundleDetails=e.bundleDetails),e.limit&&(r.limit=e.limit),e.cursor)&&(r.cursor=e.cursor),a=R.get(s).query(r),t.traceid&&a.set("X-Amzn-Trace-Id",t.traceid),(a=_.api.setupAPIToken(a,n)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),o.reject(e)):o.resolve(t.body)})):((i={}).message=i.description="Required parameter 'userid' is not found in request options.",i=new b(_.errors.ERROR_TYPES.SDK_ERROR,i),o.reject(i))}return o.promise}.bind(this),getClassUsers:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.classid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getClassUsersAPI,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid}),i={},e.search&&(i.search=e.search),e.cursor&&(i.cursor=e.cursor),e.limit&&(i.limit=e.limit),e.sortField&&(i.sortField=e.sortField),e.sortOrder&&(i.sortOrder=e.sortOrder),e=R.get(o).query(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):(t.body.entities=A.convertEnrollmetsResponse({data:t.body.entities}),r.resolve(t.body))})):((n={}).message=n.description="Required parameter classid is not defined.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),enrollUsertoClass:function(e){var t=this,r={},n=m.defer();{var o;e&&e.classid&&e.userid?(r=_.validations.isAuthenticated(t.orgId,t.token))?n.reject(r):(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.enrollUsertoClass,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid,userId:e.userid}),e=R.post(o).set("Content-Type","application/json").set("Accept","application/json").query({}),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):n.resolve(t.body)})):(r.message=r.description="Mandatory parameter classid or userid not found in request options",r=new b(_.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),enrollSelftoClass:function(e){var t=this,r={},n=m.defer();{var o;e&&e.classid?(r=_.validations.isAuthenticated(t.orgId,t.token))?n.reject(r):(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.enrollSelftoClass,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid}),e={classrole:e.classrole},o=R.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):n.resolve(t.body)})):(r.message=r.description="Mandatory parameter classid not found in request options",r=new b(_.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),enrollMultiUserstoClass:function(e){var t=this,r={},n=m.defer();{var o;e&&e.classid&&e.users?(r=_.validations.isAuthenticated(t.orgId,t.token))?n.reject(r):(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.enrollMultiUserstoClass,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid}),e={users:e.users},o=R.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):n.resolve(t.body)})):(r.message=r.description="Mandatory parameter classid or users array not found in request options",r=new b(_.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),unEnrollMultiUserstoClass:function(e){var t=this,r={},n=m.defer();{var o;e&&e.classid&&e.users?(r=_.validations.isAuthenticated(t.orgId,t.token))?n.reject(r):(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.enrollMultiUserstoClass,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid}),e={users:e.users},o=R.delete(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):n.resolve(t.body)})):(r.message=r.description="Mandatory parameter classid or users array not found in request options",r=new b(_.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),unEnrollUsertoClass:function(e){var t=this,r={},n=m.defer();{var o;e&&e.classid&&e.userid?(r=_.validations.isAuthenticated(t.orgId,t.token))?n.reject(r):(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.enrollUsertoClass,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid,userId:e.userid}),e=R.delete(o).query({}),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):n.resolve(t.body)})):(r.message=r.description="Mandatory parameter classid or userid not found in request options",r=new b(_.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),getOrgSettings:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getSettings,n=_.api.constructAPIUrl(n,{orgId:t.orgId}),e&&e.field&&(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getSettingsField,n=_.api.constructAPIUrl(n,{orgId:t.orgId,field:e.field})),e=R.get(n).query({}),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}));return r.promise}.bind(this),updateOrgSettings:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getSettings,n=_.api.constructAPIUrl(n,{orgId:t.orgId}),n=R.put(n),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),e.body&&(e.body.sis&&!e.body.sis.productid&&(e.body.sis.productid=[]),n.send(e.body)),(n=_.api.setupAPIToken(n,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}));return r.promise}.bind(this),generateClassCode:function(e){var t,r=this,n=m.defer();{var o;e&&e.classid?(t=_.validations.isAuthenticated(r.orgId,r.token))?n.reject(t):(o=r.config.DEFAULT_HOSTS.AUTH+r.config.AUTH_API_URLS.generateClassCode,o=_.api.constructAPIUrl(o,{orgId:r.orgId,classId:e.classid}),e=R.post(o),r.traceid&&e.set("X-Amzn-Trace-Id",r.traceid),(e=_.api.setupAPIToken(e,r.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),n.reject(e)):n.resolve(t.body)})):((t={}).message=t.description="classid not found in request options.",t=new b(_.errors.ERROR_TYPES.SDK_ERROR,t),n.reject(t))}return n.promise}.bind(this),getAllJobs:function(e){var r=m.defer();{var t,n,o;e&&e.accountId&&e.extUserId?(t=this.config.DEFAULT_HOSTS.AUTH+this.config.AUTH_API_URLS.getAllJobs,t=_.api.constructAPIUrl(t,{accountId:e.accountId,extUserId:e.extUserId}),n={},e.jobType&&(n.jobType=e.jobType),e.details&&(n.details=e.details),e=R.get(t).query(n),this.traceid&&e.set("X-Amzn-Trace-Id",this.traceid),e.end(function(e,t){e?(o=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={}).message=o.description="accountId or extUserId not found in request options.",o=new b(_.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),getJob:function(e){var r=m.defer();{var t,n;e&&e.accountId&&e.extUserId&&e.jobId&&e.jobType?(t=this.config.DEFAULT_HOSTS.AUTH+this.config.AUTH_API_URLS.getJob,t=_.api.constructAPIUrl(t,{accountId:e.accountId,extUserId:e.extUserId,jobId:e.jobId}),e={jobType:e.jobType},t=R.get(t).query(e),this.traceid&&t.set("X-Amzn-Trace-Id",this.traceid),t.end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="accountId or extUserId or jobType or jobId or not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createClass:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.title&&e.startdate&&e.enddate?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.createClass,o=_.api.constructAPIUrl(o,{orgId:t.orgId}),i={title:e.title,startdate:e.startdate,enddate:e.enddate},e.description&&(i.description=e.description),e.class_ownership&&(i.class_ownership=e.class_ownership),e.ext_data&&(i.ext_data=e.ext_data),e.analyticsharingmodel&&(i.analyticsharingmodel=e.analyticsharingmodel),e.limits&&(i.limits=e.limits),e=R.post(o).send(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):(e=A.convertClassResponse({data:t.body}),r.resolve(e))})):((n={}).message=n.description="title or startdate or enddate not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateClass:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.specificClass,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid}),o=R.put(o).send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory parameter 'classid' is not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createMultipleClasses:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e.classes&&0<e.classes.length||e.clone_classes&&0<e.clone_classes.length?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.createMultipleClasses,o=_.api.constructAPIUrl(o,{orgId:t.orgId}),o=R.post(o).send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory parameters - [classes, clone_classes], not found in request options",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),deleteClass:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid&&e.body?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.specificClass,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid}),o=R.delete(o).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - classid or body not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),cloneClass:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.title&&e.startdate&&e.enddate&&e.instructor&&e.classid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.cloneClass,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid}),o=R.post(o).send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="title or startdate or enddate or instructor or classid not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAllClasses:function(c){var e=this,u=m.defer(),t=_.validations.isAuthenticated(e.orgId,e.token);{var r,n,o,i;t?u.reject(t):(t='orgid:"'+e.orgId+'"',c.lookup&&c["lookup-operator"]&&(n=c.lookup.split(",").map(function(e){e=e.trim().split(":");return"("+e[0]+".keyword:"+e[1]+")"}),t+=" AND ("+n.join(" "+c["lookup-operator"]+" ")+")"),c.search&&(t=t+' AND (title:"'+c.search+'" OR class.instructor.first_name:"'+c.search+'" OR class.instructor.last_name:"'+c.search+'" OR description:"'+c.search+'")'),"title"===(n="enddate"!==(n=(n=c.sortField||"").replace(/ext_/gi,"").split(",").shift().trim()||"created")&&"startdate"!==n?n:"class."+n)&&(n+=".keyword"),"tagname_1"===n&&(n+=".keyword"),o=c.sortOrder||"desc",r=[],(i={})[n]=o,r.push(i),n={query:{query_string:{query:t}},sort:r},c.cursor&&(n.search_after=JSON.parse(c.cursor)),c.limit?n.size=c.limit:c.limit=10,o=e.config.DEFAULT_HOSTS.INTEGRATION+e.config.INTEGRATIONS_API_URLS.queryDataFromSearch,o=_.api.constructAPIUrl(o,{index:"classes"}),i={query:JSON.stringify(n)},t=R.get(o).query(i),e.traceid&&t.set("X-Amzn-Trace-Id",e.traceid),(t=_.api.setupAPIToken(t,e.token)).agent(d).end(function(e,t){if(e){e={type:_.errors.ERROR_TYPES.API_ERROR,err:e},e=A.convertElasticsearchErrResponse(e);u.reject(e)}else{var r,n={entities:[]};for(r in n.count=t.body.hits.hits.length,n.count&&c.limit===n.count&&(e=t.body.hits.hits[t.body.hits.hits.length-1].sort,n.cursor=JSON.stringify(e)),t.body.hits.hits){var o=t.body.hits.hits[r]._source,i={uuid:o.classid,created:o.created,modified:o.modified,path:o.path,category:o.category,class:{enddate:o.class.enddate,instructor:{name:o.class.instructor.first_name+" "+o.class.instructor.last_name,last_name:o.class.instructor.last_name,first_name:o.class.instructor.first_name,uuid:o.class.instructor.dls_user_id,email:o.class.instructor.email,username:o.class.instructor.userid+"--ACCOUNT"},startdate:o.class.startdate},"class.settings.active":o["class.settings.active"],class_code:o.class_code,class_ownership:o.class_ownership||{owner_status:"ENROLLED",model:"STRICT"},description:o.description,provision_method:o.class.provision_method,title:o.title,analyticsharingmodel:o.analyticsharingmodel,analytics_score_aggregation_type:o.analytics_score_aggregation_type,hidden:o.hidden,studentCount:o.studentCount,teacherCount:o.teacherCount};o.limits&&(i.limits=o.limits),o.hasOwnProperty("assignedPathCount")&&(i.assignedPathCount=o.assignedPathCount);for(var s=1;s<=10;s++){var a="tagid_"+s;o[a]&&(i[a]=o[a],i["tagname_"+s]=o["tagname_"+s],i["taglookup_"+s]=o["taglookup_"+s])}n.entities.push(i)}u.resolve(n)}}))}return u.promise}.bind(this),getParticularClass:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classId?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getParticularClassAPI,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classId}),e=R.get(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="classId not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getParticularShadowClass:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.ext_classid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getParticularShadowClassAPI,o=_.api.constructAPIUrl(o,{orgId:t.orgId,extClassId:e.ext_classid}),e=R.get(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="ext_classid not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createClassProductAssociation:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classId&&e.productcode?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.classProductAssociation,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classId,productcode:e.productcode}),e=R.post(o).set("Content-Type","application/json").set("Accept","application/json"),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="classId or productcode not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),removeClassProductAssociation:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classId&&e.productcode?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.classProductAssociation,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classId,productcode:e.productcode}),e=R.delete(o).query({}),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="classId or productcode not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createMultiClassProductAssociations:function(e){var r=m.defer(),t=this,n=_.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.classId&&e.productcodes?(o=t.config.DEFAULT_HOSTS.AUTH,i=t.config.AUTH_API_URLS.multiClassProductAssociations,o=o+i,i={productcodes:e.productcodes},o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classId}),e=R.post(o).set("Content-Type","application/json").set("Accept","application/json").send(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Missing mandaotry fields 'classId' or 'productcodes' in request.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),addItemsToShowcaseOfAClass:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classId&&e.body?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.showcaseItems,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classId}),o=R.post(o),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.send(e.body),(o=_.api.setupAPIToken(o,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory param - classId or body not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),deleteItemsFromShowcaseOfAClass:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classId&&e.body?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.showcaseItems,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classId}),o=R.delete(o),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.send(e.body),(o=_.api.setupAPIToken(o,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory param - classId or body not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getClassAppdata:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.ClassAppdata,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classid:e.classid}),e=R.get(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="classid not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),putClassAppdata:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid&&e.appdata?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.ClassAppdata,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classid:e.classid}),o=R.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e.appdata),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="classid or appdata not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),deleteClassAppdata:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.ClassAppdata,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classid:e.classid}),e=R.delete(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="classid not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),encodeURLParameter:function(e){var t,r={};for(t in e)r[e[t]]=encodeURIComponent(e[t]);return r}.bind(this),createAssignedPath:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid&&e.data&&e.data.title&&e.data.items&&0<e.data.items.length?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.createAssignedPath,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid}),o=R.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e.data),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - title or classid or items not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),deleteAssignedPath:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid&&e.assignedpathid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.deleteAssignedPath,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid,assignedPathId:e.assignedpathid}),e=R.delete(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - classid or assignedpathid not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateAssignedPath:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid&&e.assignedpathid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.deleteAssignedPath,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid,assignedPathId:e.assignedpathid}),o=R.put(o),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),e.data&&o.send(e.data),(o=_.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - classid or assignedpathid not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createGroup:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.title&&e.startdate&&e.enddate?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.allGroups,o=_.api.constructAPIUrl(o,{orgId:t.orgId}),o=R.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t)})):((n={}).message=n.description="title or startdate or enddate not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAllGroupsByPath:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.path?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.allGroups,o=_.api.constructAPIUrl(o,{orgId:t.orgId}),i={path:e.path},e.cursor&&(i.cursor=e.cursor),e=R.get(o).query(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t)})):((n={}).message=n.description="Mandatory params - path not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAGroup:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.groupId?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.aParticularGroup,o=_.api.constructAPIUrl(o,{orgId:t.orgId,groupId:e.groupId}),e=R.get(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t)})):((n={}).message=n.description="Mandatory params - groupId not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateGroup:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.groupId?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.aParticularGroup,o=_.api.constructAPIUrl(o,{orgId:t.orgId,groupId:e.groupId}),o=R.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t)})):((n={}).message=n.description="Mandatory params - groupId not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),deleteGroup:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.groupId?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.aParticularGroup,o=_.api.constructAPIUrl(o,{orgId:t.orgId,groupId:e.groupId}),e=R.delete(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t)})):((n={}).message=n.description="Mandatory params - groupId not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAllMembersOfAGroup:function(e){var t=this,r=m.defer(),n={},o=_.validations.isAuthenticated(t.orgId,t.token);{var i;o?r.reject(o):e&&e.groupId?(i=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getAllMembersOfAGroup,i=_.api.constructAPIUrl(i,{orgId:t.orgId,groupId:e.groupId}),e.cursor&&(n.cursor=e.cursor),e=R.get(i).set("Content-Type","application/json").set("Accept","application/json").send(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(o=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t)})):((o={}).message=o.description="Mandatory param - groupId not found in request options.",o=new b(_.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),getAllGroupMembersByPath:function(e){var t=this,r=m.defer(),n={},o=_.validations.isAuthenticated(t.orgId,t.token);{var i;o?r.reject(o):e&&e.path?(i=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getAllGroupMembersByPath,i=_.api.constructAPIUrl(i,{orgId:t.orgId}),n.path=e.path,e.cursor&&(n.cursor=e.cursor),e=R.get(i).set("Content-Type","application/json").set("Accept","application/json").query(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(o=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t)})):((o={}).message=o.description="Mandatory param - path not found in request options.",o=new b(_.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),createMultiUserGroupMembership:function(e){var t=this,r=m.defer(),n={},o=_.validations.isAuthenticated(t.orgId,t.token);{var i;o?r.reject(o):e&&e.groupId&&e.body&&e.body.users&&0<e.body.users.length?(i=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.userGroupMembership,i=_.api.constructAPIUrl(i,{orgId:t.orgId,groupId:e.groupId}),n=e.body,e=R.post(i).set("Content-Type","application/json").set("Accept","application/json").send(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(o=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t)})):((o={}).message=o.description="Mandatory param - groupId or body or body.users(min. 1 user) not found in request options.",o=new b(_.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),deleteMultiUserGroupMembership:function(e){var t=this,r=m.defer(),n={},o=_.validations.isAuthenticated(t.orgId,t.token);{var i;o?r.reject(o):e&&e.groupId&&e.body&&e.body.users&&0<e.body.users.length?(i=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.userGroupMembership,i=_.api.constructAPIUrl(i,{orgId:t.orgId,groupId:e.groupId}),n=e.body,e=R.delete(i).set("Content-Type","application/json").set("Accept","application/json").send(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(o=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t)})):((o={}).message=o.description="Mandatory param - groupId or body or body.users(min. 1 user) not found in request options.",o=new b(_.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),getMyAllMemberships:function(e){var t=this,r=m.defer(),n={},o=_.validations.isAuthenticated(t.orgId,t.token);{var i;o?r.reject(o):e&&e.userId&&e.path?(i=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getMyAllMemberships,i=_.api.constructAPIUrl(i,{orgId:t.orgId,userId:e.userId}),n.path=e.path,e.cursor&&(n.cursor=e.cursor),e=R.get(i).set("Content-Type","application/json").set("Accept","application/json").query(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(o=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t)})):((o={}).message=o.description="Mandatory param - userId or path not found in request options.",o=new b(_.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),archiveGroup:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.groupId?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.archiveAParticularGroup,o=_.api.constructAPIUrl(o,{orgId:t.orgId,groupId:e.groupId}),e=R.put(o).set("Content-Type","application/json").set("Accept","application/json").send({}),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory param - groupId not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),unarchiveGroup:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.groupId?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.unarchiveAParticularGroup,o=_.api.constructAPIUrl(o,{orgId:t.orgId,groupId:e.groupId}),e=R.put(o).set("Content-Type","application/json").set("Accept","application/json").send({}),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory param - groupId not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createGradebookMeta:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.classid&&e.body?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.createOrGetGradebookMeta,n=_.api.constructAPIUrl(n,{orgId:t.orgId,classId:e.classid}),n=R.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=_.api.setupAPIToken(n,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory param - classid or body not found in request options.",e=new b(_.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e));return r.promise}.bind(this),updateGradebookMeta:function(e){var r=m.defer(),t=this,n={},o=_.validations.isAuthenticated(t.orgId,t.token);o?r.reject(o):e&&e.classid&&e.gradebook_id&&e.body?0!==Object.keys(e.body).length?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.updateOrDeleteGradebookMeta,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid,gradebook_id:e.gradebook_id}),e=e.body,o=R.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Body of the request cannot be empty.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n)):(n.message=n.description="Mandatory params: classid, gradebook_id or body not found in the request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n));return r.promise}.bind(this),deleteGradebookMeta:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.classid&&e.gradebook_id?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.updateOrDeleteGradebookMeta,n=_.api.constructAPIUrl(n,{orgId:t.orgId,classId:e.classid,gradebook_id:e.gradebook_id}),e=R.delete(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - classid or gradebook_id not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n));return r.promise}.bind(this),getParticularGradebookMetaOfAClass:function(e){var r=m.defer(),t=this,n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.classid&&e.gradebook_id?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.createOrGetGradebookMeta,n=_.api.constructAPIUrl(n,{orgId:t.orgId,classId:e.classid}),e={gradebook_id:e.gradebook_id},n=R.get(n).query(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=_.api.setupAPIToken(n,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):t.body.entities?r.resolve(t.body.entities[0]):r.resolve()})):((e={}).message=e.description="Mandatory params: classid or gradebook_id not found in request options.",e=new b(_.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e));return r.promise}.bind(this),getAllGradebooksMetaOfAClass:function(e){var r=m.defer(),t=this,n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.createOrGetGradebookMeta,n=_.api.constructAPIUrl(n,{orgId:t.orgId,classId:e.classid}),o={},e.cursor&&(o.cursor=e.cursor),e=R.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params: classid not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),addGradebookColumns:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.classid&&e.gradebook_id&&e.body?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.gradebookColumns,n=_.api.constructAPIUrl(n,{orgId:t.orgId,classId:e.classid,gradebook_id:e.gradebook_id}),n=R.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=_.api.setupAPIToken(n,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory param - classid, gradebook_id or body not found in request options.",e=new b(_.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e));return r.promise}.bind(this),updateMultipleGradebookColumns:function(e){var r=m.defer(),t=this,n={},o=_.validations.isAuthenticated(t.orgId,t.token);o?r.reject(o):e&&e.classid&&e.gradebook_id&&e.body&&e.body.columns?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.gradebookColumns,o=_.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid,gradebook_id:e.gradebook_id}),e=e.body,o=R.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Mandatory params: classid, gradebook_id, body or body.columns not found in the request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n));return r.promise}.bind(this),removeGradebookColumns:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.classid&&e.gradebook_id&&e.body?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.gradebookColumns,n=_.api.constructAPIUrl(n,{orgId:t.orgId,classId:e.classid,gradebook_id:e.gradebook_id}),n=R.delete(n).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=_.api.setupAPIToken(n,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory params - classid, gradebook_id or body not found in request options.",e=new b(_.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e));return r.promise}.bind(this),getParticularColumnOfAGradebook:function(e){var r=m.defer(),t=this,n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.classid&&e.gradebook_id&&e.column_id?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.gradebookColumns,n=_.api.constructAPIUrl(n,{orgId:t.orgId,classId:e.classid,gradebook_id:e.gradebook_id}),e={column_id:e.column_id},n=R.get(n).query(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=_.api.setupAPIToken(n,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body.entities[0])})):((e={}).message=e.description="Mandatory params: classid, gradebook_id or column_id not found in request options.",e=new b(_.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e));return r.promise}.bind(this),getAllColumnsOfAGradebook:function(e){var r=m.defer(),t=this,n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid&&e.gradebook_id?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.gradebookColumns,n=_.api.constructAPIUrl(n,{orgId:t.orgId,classId:e.classid,gradebook_id:e.gradebook_id}),o={},e.cursor&&(o.cursor=e.cursor),e=R.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params: classid or gradebook_id not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAllClassesOfAComponent:function(e){var r=m.defer(),t=this,n={},o=_.validations.isAuthenticated(t.orgId,t.token);{var i;o?r.reject(o):e&&e.component_code?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getAllClassesOfAComponent,o=_.api.constructAPIUrl(o,{orgId:t.orgId,component_code:e.component_code}),i={},e.cursor&&(i.cursor=e.cursor),e=R.get(o).query(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Mandatory params: component_code not found in the request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),removeAllGradebookColumnsOfCustomComponent:function(e){var r=m.defer(),t=this,n={},o=_.validations.isAuthenticated(t.orgId,t.token);o?r.reject(o):e&&e.component_code?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.removeAllGradebookColumnsOfCustomComponent,o=_.api.constructAPIUrl(o,{orgId:t.orgId,component_code:e.component_code}),o=R.delete(o).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Mandatory params: component_code not found in the request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n));return r.promise}.bind(this),createCustomComponent:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.body?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.customComponents,n=_.api.constructAPIUrl(n,{orgid:t.orgId}),n=R.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=_.api.setupAPIToken(n,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory param - 'body' not found in request options.",e=new b(_.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e));return r.promise}.bind(this),updateCustomComponent:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.custom_component_code&&e.body?0===Object.keys(e.body).length?(n.message=n.description="Mandatory params: 'custom_component_code' or 'body' not found in the request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n)):(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.particularCustomComponent,o=_.api.constructAPIUrl(o,{orgid:t.orgId,custom_component_code:e.custom_component_code}),e=e.body,o=R.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=_.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params: 'custom_component_code' or 'body' not found in the request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),deleteCustomComponent:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.custom_component_code?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.particularCustomComponent,n=_.api.constructAPIUrl(n,{orgid:t.orgId,custom_component_code:e.custom_component_code}),e=R.delete(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - 'custom_component_code' not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n));return r.promise}.bind(this),getParticularCustomComponent:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.custom_component_code?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.particularCustomComponent,n=_.api.constructAPIUrl(n,{orgid:t.orgId,custom_component_code:e.custom_component_code}),e=R.get(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params: 'custom_component_code' not found in request options.",n=new b(_.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n));return r.promise}.bind(this),getAllCustomComponents:function(e){var t=this,r=m.defer(),n=_.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.customComponents,n=_.api.constructAPIUrl(n,{orgid:t.orgId}),o={},e&&e.cursor&&(o.cursor=e.cursor),e=R.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=_.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new b(_.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}))}return r.promise}.bind(this)}},new n({timeout:6e4,freeSocketTimeout:3e4}))},{"../../helpers":3,"../../helpers/lib/api/converter":4,agentkeepalive:36,q:42,superagent:45}],17:[function(e,t,r){var s=e("q"),a=e("superagent"),c=e("../../helpers"),e=e("agentkeepalive"),u=c.errors.DLSError,d=(t.exports=function(e){return this.accountId=e,{createGradeformat:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.body?(n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.gradeFormat,n=c.api.constructAPIUrl(n,{orgid:t.orgId}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=c.api.setupAPIToken(n,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory param - body not found in request options.",e=new u(c.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e));return r.promise}.bind(this),updateGradeformat:function(e){var r=s.defer(),t=this,n={},o=c.validations.isAuthenticated(t.orgId,t.token);o?r.reject(o):e&&e.gradeformat_id&&e.body?0!==Object.keys(e.body).length?(o=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.particularGradeFormat,o=c.api.constructAPIUrl(o,{orgid:t.orgId,gradeformat_id:e.gradeformat_id}),e=e.body,o=a.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Body of the request cannot be empty.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n)):(n.message=n.description="Mandatory params: gradeformat_id or body not found in the request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n));return r.promise}.bind(this),deleteGradeformat:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.gradeformat_id?(n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.particularGradeFormat,n=c.api.constructAPIUrl(n,{orgid:t.orgId,gradeformat_id:e.gradeformat_id}),e=a.delete(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=c.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - gradeformat_id not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n));return r.promise}.bind(this),getAllGradeformats:function(e){var r=s.defer(),t=this,n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):(n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.gradeFormat,n=c.api.constructAPIUrl(n,{orgid:t.orgId}),o={},e&&e.cursor&&(o.cursor=e.cursor),e=a.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=c.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}))}return r.promise}.bind(this),getParticularGradeformat:function(e){var r=s.defer(),t=this,n=c.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.gradeformat_id?(n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.gradeFormat,n=c.api.constructAPIUrl(n,{orgid:t.orgId}),e={gradeformat_id:e.gradeformat_id},n=a.get(n).query(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=c.api.setupAPIToken(n,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body.entities[0])})):((e={}).message=e.description="Mandatory params: gradeformat_id not found in request options.",e=new u(c.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e));return r.promise}.bind(this),associateGradeformatToClass:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid&&e.gradeformat_id&&e.body?(o=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.classGradeformatAssociation,o=c.api.constructAPIUrl(o,{orgid:t.orgId,classid:e.classid,gradeformat_id:e.gradeformat_id}),o=a.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - classid or gradeformat_id or body not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),unassociateGradeformatFromClass:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid&&e.gradeformat_id?(o=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.classGradeformatAssociation,o=c.api.constructAPIUrl(o,{orgid:t.orgId,classid:e.classid,gradeformat_id:e.gradeformat_id}),e=a.delete(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=c.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - classid or gradeformat_id not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateClassGradeformatAssociation:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid&&e.gradeformat_id&&e.body?(o=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.classGradeformatAssociation,o=c.api.constructAPIUrl(o,{orgid:t.orgId,classid:e.classid,gradeformat_id:e.gradeformat_id}),e=e.body,o=a.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params: classid or gradeformat_id or body not found in the request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getParticularGradeformatOfAClass:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classid&&e.gradeformat_id?(o=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.classGradeformats,o=c.api.constructAPIUrl(o,{orgid:t.orgId,classid:e.classid}),e={gradeformat_id:e.gradeformat_id},o=a.get(o).query(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body.entities[0])})):((n={}).message=n.description="Mandatory params: classid or gradeformat_id not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAllGradeformatsOfAClass:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.classid?(o=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.classGradeformats,o=c.api.constructAPIUrl(o,{orgid:t.orgId,classid:e.classid}),i={},e.cursor&&(i.cursor=e.cursor),e=a.get(o).query(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=c.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params: classid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getClassesOfAGradeformat:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.gradeformat_id?(o=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.gradeformatClasses,o=c.api.constructAPIUrl(o,{orgid:t.orgId,gradeformat_id:e.gradeformat_id}),i={},e.cursor&&(i.cursor=e.cursor),e=a.get(o).query(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=c.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params: gradeformat_id not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createUserAssignedPathEnrollments:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.classid&&e.assignedpathid&&e.body?(n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.userAssignedPaths,n=c.api.constructAPIUrl(n,{orgid:t.orgId,classid:e.classid,assignedpathid:e.assignedpathid}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=c.api.setupAPIToken(n,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory param: classid, assignedpathid, body not found in request options.",e=new u(c.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e));return r.promise}.bind(this),deleteUserAssignedPathEnrollments:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);n?r.reject(n):e&&e.classid&&e.assignedpathid&&e.body?(n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.userAssignedPaths,n=c.api.constructAPIUrl(n,{orgid:t.orgId,classid:e.classid,assignedpathid:e.assignedpathid}),n=a.delete(n).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=c.api.setupAPIToken(n,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory param: classid, assignedpathid, body not found in request options.",e=new u(c.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e));return r.promise}.bind(this),getParticularClassV2:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.classId?(o=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.particularClass,o=c.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classId}),e={productDetails:e.productDetails,bundleDetails:e.bundleDetails},o=a.get(o).query(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory field 'classId' not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createOrgProductEntitlement:function(e){var t=this,r=s.defer();{var n,o;t.orgId?e&&e.productcode?(n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.orgProductEntitlement,n=c.api.constructAPIUrl(n,{orgid:t.orgId}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((o={}).message=o.description="Mandatory param: productcode not found in request options.",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o)):((o={}).message=o.description="Mandatory param: orgid not found in options while initializing comprodls-sdk.",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),updateOrgProductEntitlement:function(e){var t=this,r=s.defer();{var n,o;t.orgId?e&&e.productcode?(n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.orgProductEntitlement,n=c.api.constructAPIUrl(n,{orgid:t.orgId}),n=a.put(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((o={}).message=o.description="Mandatory param: productcode not found in request options.",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o)):((o={}).message=o.description="Mandatory param: orgid not found in options while initializing comprodls-sdk.",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),getParticularOrgProductEntitlement:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.productcode?(o=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.orgProductEntitlement,o=c.api.constructAPIUrl(o,{orgid:t.orgId}),e={productcode:e.productcode},o=a.get(o).query(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory field 'productcode' not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAllOrgProductEntitlements:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):(n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.orgProductEntitlement,n=c.api.constructAPIUrl(n,{orgid:t.orgId}),o={productcode:e.productcode},e.status&&(o.status=e.status),e.hasOwnProperty("expired")&&(o.expired=e.expired),e.cursor&&(o.cursor=e.cursor),e=a.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=c.api.setupAPIToken(e,t.token)).agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}))}return r.promise}.bind(this),setupUser:function(e){var t=this,r=s.defer();{var n;e&&e.ext_user_id&&e.workflow_type?(n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.setupUser,n=c.api.constructAPIUrl(n,{accountId:t.accountId}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.agent(d).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((err={}).message=err.description="Mandatory field 'ext_user_id' or 'workflow_type' not found in the request options.",err=new u(c.errors.ERROR_TYPES.SDK_ERROR,err),r.reject(err))}return r.promise}.bind(this)}},new e({timeout:6e4,freeSocketTimeout:3e4}))},{"../../helpers":3,agentkeepalive:36,q:42,superagent:45}],18:[function(e,t,r){var c=e("superagent"),u=e("q"),d=e("../../helpers"),p=d.errors.DLSError;function n(e,t,r,n,o){var i,s=u.defer(),a={};return n&&n.userid?(a=d.validations.isAuthenticated(e,t))?s.reject(a):(r=r.DEFAULT_HOSTS.COLLAB+r.COLLAB_API_URLS.connectionURL,r=d.api.constructAPIUrl(r,{orgId:e,userId:n.userid}),"create"===o?i=c.post(r).set("Content-Type","application/json"):"delete"===o&&(i=c.delete(r).set("Content-Type","application/json")),(i=d.api.setupAPIToken(i,t)).end(function(e,t){e?(a=new p(d.errors.ERROR_TYPES.API_ERROR,e),s.reject(a)):s.resolve(t.body)})):(a.message=a.description='Mandatory parameter "userid" not found in request options',a=new p(d.errors.ERROR_TYPES.SDK_ERROR,a),s.reject(a)),s.promise}t.exports=function(){return{getPostsInClass:function(e){var t=this,r=u.defer(),n={};{var o,i;e&&e.classid?(n=d.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.COLLAB+t.config.COLLAB_API_URLS.postsInClassAPI,o=d.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid}),i={},e.cursor&&(i.cursor=e.cursor),e.limit&&(i.limit=e.limit),e=c.get(o).query(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=d.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new p(d.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description='Mandatory parameter "classid" not found in request options',n=new p(d.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createPostInClass:function(e){var t=this,r=u.defer(),n={};{var o,i;e&&e.verb&&e.classid?(n=d.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.COLLAB+t.config.COLLAB_API_URLS.postsInClassAPI,o=d.api.constructAPIUrl(o,{orgId:t.orgId,classId:e.classid}),i={verb:e.verb},e.post&&(i.post=e.post),e.name&&(i.name=e.name),e.email&&(i.email=e.email),e.userid&&(i.userid=e.userid),e=c.post(o).send(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=d.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new p(d.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description='Mandatory parameter "verb" or "classid" not found in request options',n=new p(d.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getPostsInProduct:function(e){var t=this,r=u.defer(),n={};{var o,i;e&&e.productid?(n=d.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.COLLAB+t.config.COLLAB_API_URLS.postsInProductAPI,o=d.api.constructAPIUrl(o,{orgId:t.orgId,productId:e.productid}),i={},e.cursor&&(i.cursor=e.cursor),e.limit&&(i.limit=e.limit),e=c.get(o).query(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=d.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new p(d.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description='Mandatory parameter "productid" not found in request options',n=new p(d.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createPostInProduct:function(e){var t=this,r=u.defer(),n={};{var o,i;e&&e.verb&&e.productid?(n=d.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.COLLAB+t.config.COLLAB_API_URLS.postsInProductAPI,o=d.api.constructAPIUrl(o,{orgId:t.orgId,productId:e.productid}),i={verb:e.verb},e.post&&(i.post=e.post),e.name&&(i.name=e.name),e.email&&(i.email=e.email),e.userid&&(i.userid=e.userid),e=c.post(o).send(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=d.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new p(d.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description='Mandatory parameter "verb" or "productid" not found in request options',n=new p(d.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getMyFollowers:function(e){var t=this,r=u.defer(),n={};{var o,i;(n=d.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.COLLAB+t.config.COLLAB_API_URLS.getMyFollowers,o=d.api.constructAPIUrl(o,{orgId:t.orgId}),i={},e.cursor&&(i.cursor=e.cursor),e.limit&&(i.limit=e.limit),e=c.get(o).query(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=d.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new p(d.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)}))}return r.promise}.bind(this),getUsersFollowedByMe:function(e){var t=this,r=u.defer(),n={};{var o,i;(n=d.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(o=t.config.DEFAULT_HOSTS.COLLAB+t.config.COLLAB_API_URLS.getUsersFollowedByMe,o=d.api.constructAPIUrl(o,{orgId:t.orgId}),i={},e.cursor&&(i.cursor=e.cursor),e.limit&&(i.limit=e.limit),e=c.get(o).query(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=d.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new p(d.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)}))}return r.promise}.bind(this),followUser:function(e){var t=u.defer();return n(this.orgId,this.token,this.config,e,"create").then(function(e){t.resolve(e)}).catch(function(e){t.reject(e)}).done(),t.promise}.bind(this),unfollowUser:function(e){var t=u.defer();return n(this.orgId,this.token,this.config,e,"delete").then(function(e){t.resolve(e)}).catch(function(e){t.reject(e)}).done(),t.promise}.bind(this)}}},{"../../helpers":3,q:42,superagent:45}],19:[function(e,t,r){var i=e("q"),s=e("superagent"),n=e("agentkeepalive"),a=e("../../helpers"),c=a.errors.DLSError,u=(t.exports=function(e){return this.accountId=e,{createDataSyncManager:function(e){var t=this,r=i.defer();{var n;e&&e.body?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.createDataSyncManager,n=a.api.constructAPIUrl(n,{accountid:t.accountId}),n=s.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.agent(u).end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory param - body not found in request options.",e=new c(a.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),updateDataSyncManager:function(e){var r=i.defer(),t=this;{var n,o;e&&e.dsmid&&e.body?(o=t.config.DEFAULT_HOSTS.AUTH,n=t.config.AUTH_API_URLS.dataSyncManager,o=o+n,o=a.api.constructAPIUrl(o,{accountid:t.accountId,dsmid:e.dsmid}),n=e.body,e=s.put(o).set("Content-Type","application/json").set("Accept","application/json").send(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.agent(u).end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((o={}).message=o.description="Mandatory params: dsmid, body not found in the request options.",o=new c(a.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),deleteDataSyncManager:function(e){var t=this,r=i.defer();{var n;e&&e.dsmid&&e.body?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.dataSyncManager,n=a.api.constructAPIUrl(n,{accountid:t.accountId,dsmid:e.dsmid}),n=s.delete(n).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.agent(u).end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory params - dsmid or body not found in request options.",e=new c(a.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),getParticularDataSyncManager:function(e){var r=i.defer(),t=this;{var n,o;e&&e.dsmid?(n=t.config.DEFAULT_HOSTS.AUTH,o=t.config.AUTH_API_URLS.dataSyncManager,n=n+o,n=a.api.constructAPIUrl(n,{accountid:t.accountId,dsmid:e.dsmid}),o=s.get(n),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.agent(u).end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory params: dsmid not found in request options.",e=new c(a.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),getAllDataSyncManagersOfAGroup:function(e){var r=i.defer(),t=this;{var n,o;e&&e.dsm_groupid?(n=t.config.DEFAULT_HOSTS.AUTH,o=t.config.AUTH_API_URLS.getAllDataSyncManagersOfAGroup,n=n+o,n=a.api.constructAPIUrl(n,{accountid:t.accountId,dsm_groupid:e.dsm_groupid}),o=s.get(n),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.agent(u).end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory params: dsm_groupid not found in request options.",e=new c(a.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this)}},new n({timeout:6e4,freeSocketTimeout:3e4}))},{"../../helpers":3,agentkeepalive:36,q:42,superagent:45}],20:[function(e,t,r){var o=e("q"),i=e("superagent"),n=e("agentkeepalive"),s=e("../../helpers"),a=s.errors.DLSError,c=(t.exports=function(){return{getAParticularDocument:function(e){var r=o.defer();{var t,n;e&&e.accountid&&e.extuserid&&e.documentid&&e.folderid?(n=this.config.DEFAULT_HOSTS.DRIVE+this.config.DRIVE_API_URLS.getAParticularDocument,t={accountid:e.accountid,extuserid:e.extuserid,documentid:e.documentid},n=s.api.constructAPIUrl(n,t),t={folderid:e.folderid},e=i.get(n).query(t),this.traceid&&e.set("X-Amzn-Trace-Id",this.traceid),e.end(function(e,t){e?(e=new a(s.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - accountid or extuserid or documentid or folderid not found in request options.",n=new a(s.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAllDocumentsInAFolder:function(e){var r=o.defer();{var t,n;e&&e.accountid&&e.extuserid&&e.folderid?(n=this.config.DEFAULT_HOSTS.DRIVE+this.config.DRIVE_API_URLS.getAllDocumentsInAFolder,n=s.api.constructAPIUrl(n,{accountid:e.accountid,extuserid:e.extuserid}),t={folderid:e.folderid},e.classid&&(t.classid=e.classid),e.productcode&&(t.productcode=e.productcode),e.assigned_path_id&&(t.assigned_path_id=e.assigned_path_id),e["item-code"]&&(t["item-code"]=e["item-code"]),e.cursor&&(t.cursor=e.cursor),e=i.get(n).query(t),this.traceid&&e.set("X-Amzn-Trace-Id",this.traceid),e.end(function(e,t){e?(e=new a(s.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - accountid or extuserid or folderid not found in request options.",n=new a(s.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createMultipleDocuments:function(e){var r=o.defer();{var t;e&&e.accountid&&e.extuserid&&e.body?(t=this.config.DEFAULT_HOSTS.DRIVE+this.config.DRIVE_API_URLS.documents,t=s.api.constructAPIUrl(t,{accountid:e.accountid,userid:e.extuserid}),t=i.post(t).set("Content-Type","application/json").set("Accept","application/json").send(e.body),this.traceid&&t.set("X-Amzn-Trace-Id",this.traceid),t.agent(c).end(function(e,t){e?(e=new a(s.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory param - accountid, extuserid or body not found in request options.",e=new a(s.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),updateMultipleDocuments:function(e){var r=o.defer(),t={};{var n;e&&e.accountid&&e.extuserid&&e.body?(n=this.config.DEFAULT_HOSTS.DRIVE+this.config.DRIVE_API_URLS.documents,n=s.api.constructAPIUrl(n,{accountid:e.accountid,userid:e.extuserid}),n=i.put(n).set("Content-Type","application/json").set("Accept","application/json").send(e.body),this.traceid&&n.set("X-Amzn-Trace-Id",this.traceid),n.agent(c).end(function(e,t){e?(e=new a(s.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(t.message=t.description="Mandatory param - accountid, extuserid or body not found in the request options.",t=new a(s.errors.ERROR_TYPES.SDK_ERROR,t),r.reject(t))}return r.promise}.bind(this),deleteMultipleDocuments:function(e){var r=o.defer();{var t;e&&e.accountid&&e.extuserid&&e.body?(t=this.config.DEFAULT_HOSTS.DRIVE+this.config.DRIVE_API_URLS.documents,t=s.api.constructAPIUrl(t,{accountid:e.accountid,userid:e.extuserid}),t=i.delete(t).set("Content-Type","application/json").set("Accept","application/json").send(e.body),this.traceid&&t.set("X-Amzn-Trace-Id",this.traceid),t.agent(c).end(function(e,t){e?(e=new a(s.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory param - accountid, extuserid or body not found in request options.",e=new a(s.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this)}},new n({timeout:6e4,freeSocketTimeout:3e4}))},{"../../helpers":3,agentkeepalive:36,q:42,superagent:45}],21:[function(e,t,r){var i=e("q"),s=e("superagent"),n=e("agentkeepalive"),a=e("../../helpers"),o=e("../../helpers/lib/api/converter"),c=a.errors.DLSError,u=(t.exports=function(e){return this.accountId=e,{getGetStreamCredentials:function(){var r,e=this,n=i.defer(),t=e.config.DEFAULT_HOSTS.INTEGRATION+e.config.INTEGRATIONS_API_URLS.getGetStreamCredentials,t=(t=a.api.constructAPIUrl(t,{accountId:e.accountId}),s.post(t).set("Content-Type","application/json").set("Accept","application/json").send());e.traceid&&t.set("X-Amzn-Trace-Id",e.traceid);return t.end(function(e,t){e?(r=new c(a.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t)}),n.promise}.bind(this),queryDataFromSearch:function(e){var r=i.defer();{var t;e&&e.index&&e.query?(t=this.config.DEFAULT_HOSTS.INTEGRATION+this.config.INTEGRATIONS_API_URLS.queryDataFromSearch,t=a.api.constructAPIUrl(t,{index:e.index}),e={query:e.query},t=s.get(t).query(e),this.traceid&&t.set("X-Amzn-Trace-Id",this.traceid),t.end(function(e,t){e?(e={type:a.errors.ERROR_TYPES.API_ERROR,err:e},e=o.convertElasticsearchErrResponse(e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Mandatory params - index, type or query not found in request options.",e=new c(a.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),getAuditTrailForAttempts:function(e){var r=i.defer();{var t,n;e&&e.accountid&&e.action&&e.userid&&e.productcode&&e["item-code"]?(t=this.config.DEFAULT_HOSTS.INTEGRATION+this.config.INTEGRATIONS_API_URLS.auditTrail,t=a.api.constructAPIUrl(t,{accountId:e.accountid}),n={audit_context:"ATTEMPT-"+e.accountid+"#"+e.userid,target_context:"PRODUCT-"+e.productcode+"#"+e["item-code"],action:e.action},e.cursor&&(n.cursor=e.cursor),e.sortOrder&&(n.sortOrder=e.sortOrder),e=s.get(t).query(n),this.traceid&&e.set("X-Amzn-Trace-Id",this.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((t={}).message=t.description="Mandatory params - accountid, action, userid, productcode or item-code not found in request options.",t=new c(a.errors.ERROR_TYPES.SDK_ERROR,t),r.reject(t))}return r.promise}.bind(this),getAuditTrailForEntitlements:function(e){var r=i.defer();{var t,n;e&&e.accountid&&e.action&&e.userid&&e.productcode?(t=this.config.DEFAULT_HOSTS.INTEGRATION+this.config.INTEGRATIONS_API_URLS.auditTrail,t=a.api.constructAPIUrl(t,{accountId:e.accountid}),n={audit_context:"ENTITLEMENT-"+e.accountid+"#"+e.userid,target_context:"PRODUCT-"+e.productcode,type:"entitlement",action:e.action},e.cursor&&(n.cursor=e.cursor),e.sortOrder&&(n.sortOrder=e.sortOrder),e=s.get(t).query(n),this.traceid&&e.set("X-Amzn-Trace-Id",this.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((t={}).message=t.description="Mandatory params - accountid, userid or productcode not found in request options.",t=new c(a.errors.ERROR_TYPES.SDK_ERROR,t),r.reject(t))}return r.promise}.bind(this),getAuditTrailForMicroEntitlements:function(e){var r=i.defer();{var t,n;e&&e.accountid&&e.action&&e.userid&&e.productcode&&e.context?(t=this.config.DEFAULT_HOSTS.INTEGRATION+this.config.INTEGRATIONS_API_URLS.auditTrail,t=a.api.constructAPIUrl(t,{accountId:e.accountid}),n={audit_context:"ENTITLEMENT-"+e.accountid+"#"+e.userid,target_context:"PRODUCT-"+e.productcode+"#"+e.context,type:"micro-entitlement",action:e.action},e.cursor&&(n.cursor=e.cursor),e.sortOrder&&(n.sortOrder=e.sortOrder),e=s.get(t).query(n),this.traceid&&e.set("X-Amzn-Trace-Id",this.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((t={}).message=t.description="Mandatory params - accountid, action, userid, productcode or context not found in request options.",t=new c(a.errors.ERROR_TYPES.SDK_ERROR,t),r.reject(t))}return r.promise}.bind(this),publishCustomEvents:function(e){var r,n=i.defer(),t=this;{var o;e&&e.events?(o=t.config.DEFAULT_HOSTS.INTEGRATION+t.config.INTEGRATIONS_API_URLS.customEvents,o=a.api.constructAPIUrl(o,{accountId:t.accountId}),o=s.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(r=new c(a.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):((r={}).message=r.description="Mandatory params - events not found in request options.",r=new c(a.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),createSchedule:function(e){var r,n=i.defer();{var t;e&&e.context&&e.accountid&&e.body&&0<Object.keys(e.body).length&&e.body.scheduleid&&e.body.actorid&&e.body.category&&e.body.schedule_time?(t=this.config.DEFAULT_HOSTS.INTEGRATION+this.config.INTEGRATIONS_API_URLS.schedules,t=a.api.constructAPIUrl(t,{accountId:e.accountid,context:e.context}),t=s.post(t).set("Content-Type","application/json").set("Accept","application/json").send(e.body),this.traceid&&t.set("X-Amzn-Trace-Id",this.traceid),t.end(function(e,t){e?(r=new c(a.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):((r={}).message=r.description="Mandatory param - accountid or context or body(scheduleid or actorid or category or schedule_time) not found in request options.",r=new c(a.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),getSchedule:function(e){var r,n=i.defer();{var t,o;e&&e.context&&e.accountid?(t=this.config.DEFAULT_HOSTS.INTEGRATION+this.config.INTEGRATIONS_API_URLS.schedules,t=a.api.constructAPIUrl(t,{accountId:e.accountid,context:e.context}),o={},e.cursor&&(o.cursor=e.cursor),e.category&&(o.category=e.category),e.scheduleid&&(o.scheduleid=e.scheduleid),e=s.get(t).query(o),this.traceid&&e.set("X-Amzn-Trace-Id",this.traceid),e.end(function(e,t){e?(r=new c(a.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):((r={}).message=r.description="Mandatory params - accountid or context not found in request options.",r=new c(a.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),updateSchedule:function(e){var r,n=i.defer();{var t;e&&e.context&&e.accountid&&e.scheduleid&&e.body&&0<Object.keys(e.body).length&&e.body.actorid&&e.body.category?(t=this.config.DEFAULT_HOSTS.INTEGRATION+this.config.INTEGRATIONS_API_URLS.particularSchedule,t=a.api.constructAPIUrl(t,{accountId:e.accountid,context:e.context,scheduleId:e.scheduleid}),t=s.put(t).set("Content-Type","application/json").set("Accept","application/json").send(e.body),this.traceid&&t.set("X-Amzn-Trace-Id",this.traceid),t.end(function(e,t){e?(r=new c(a.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):((r={}).message=r.description="Mandatory param - accountid or context or scheduleid or body(category or actorid) not found in request options.",r=new c(a.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this),deleteSchedule:function(e){var r,n=i.defer();{var t;e&&e.context&&e.accountid&&e.scheduleid&&e.body?(t=this.config.DEFAULT_HOSTS.INTEGRATION+this.config.INTEGRATIONS_API_URLS.particularSchedule,t=a.api.constructAPIUrl(t,{accountId:e.accountid,context:e.context,scheduleId:e.scheduleid}),t=s.delete(t).set("Content-Type","application/json").set("Accept","application/json").send(e.body),this.traceid&&t.set("X-Amzn-Trace-Id",this.traceid),t.agent(u).end(function(e,t){e?(r=new c(a.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):((r={}).message=r.description="Mandatory param - accountid or context or scheduleid or body not found in request options.",r=new c(a.errors.ERROR_TYPES.SDK_ERROR,r),n.reject(r))}return n.promise}.bind(this)}},new n({timeout:6e4,freeSocketTimeout:3e4}))},{"../../helpers":3,"../../helpers/lib/api/converter":4,agentkeepalive:36,q:42,superagent:45}],22:[function(e,t,r){var a=e("q"),c=e("superagent"),u=e("../../helpers"),d=u.errors.DLSError;t.exports=function(){return{sendInvitations:function(e){var t=this,r=a.defer(),n=u.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.created&&e.invitation_data?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.sendInvitations,o=u.api.constructAPIUrl(o,{orgId:t.orgId}),o=c.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e),o=u.api.setupAPIToken(o,t.token),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(n={},n=new d(u.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="One or more required field(s) missing: context, created or invitation_data",n=new d(u.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getMultiInvitations:function(e){var t=this,r=a.defer(),n=u.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.context_id?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getMultiInvitations,o=u.api.constructAPIUrl(o,{orgId:t.orgId}),i={context_id:e.context_id},e.context&&(i.context=e.context),e.status&&(i.status=e.status),e.cursor&&(i.cursor=e.cursor),e=c.get(o).query(i),e=u.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n={},n=new d(u.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="context_id not found in request options.",n=new d(u.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),revokeSingleInvitation:function(e){var t=this,r=a.defer(),n=u.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context_id&&e.invitationid&&e.context?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.revokeSingleInvitation,o=u.api.constructAPIUrl(o,{orgId:t.orgId,invitationid:e.invitationid}),e={context:e.context,context_id:e.context_id},o=c.delete(o).query(e),o=u.api.setupAPIToken(o,t.token),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(n={},n=new d(u.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="context_id or context or invitationid not found in request options.",n=new d(u.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),completeSingleInvitation:function(e){var t=this,r=a.defer(),n=u.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context_id&&e.invitationid&&e.context?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.completeSingleInvitation,o=u.api.constructAPIUrl(o,{orgId:t.orgId,invitationid:e.invitationid}),e={context:e.context,context_id:e.context_id},o=c.put(o).query(e).set("Content-Type","application/json").set("Accept","application/json").send({}),o=u.api.setupAPIToken(o,t.token),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(n={},n=new d(u.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="context_id or context or invitationid not found in request options.",n=new d(u.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),resendSingleInvitation:function(e){var t=this,r=a.defer(),n=u.validations.isAuthenticated(t.orgId,t.token);{var o,i,s;n?r.reject(n):e&&e.invitationid&&e.context&&e.context_id?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.resendSingleInvitation,o=u.api.constructAPIUrl(o,{orgId:t.orgId,invitationid:e.invitationid}),i={context:e.context,context_id:e.context_id},s={},e.space_title&&(s.space_title=e.space_title),e=c.put(o).query(i).set("Content-Type","application/json").set("Accept","application/json").send(s),e=u.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n={},n=new d(u.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="context_id or context or invitationid not found in request options.",n=new d(u.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this)}}},{"../../helpers":3,q:42,superagent:45}],23:[function(e,t,r){var s=e("superagent"),a=e("q"),c=e("../../helpers"),u=c.errors.DLSError;t.exports=function(e){return this.accountId=e,{getProduct:function(e){var r=a.defer(),t=this,n={};{var o,i;e&&e.productcode?(o=t.config.DEFAULT_HOSTS.PRODUCT+t.config.PRODUCT_API_URLS.getProductAPI,o=c.api.constructAPIUrl(o,{accountId:t.accountId,productCode:e.productcode}),i={},e.details&&(i.details=e.details),e.stage&&(i.stage=e.stage),e=s.get(o).query(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="productcode not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getGlobalEntitlementsForAUser:function(e){var t=this,r=a.defer();{var n,o;e&&e.extUserId?(o=t.config.DEFAULT_HOSTS.PRODUCT+t.config.PRODUCT_API_URLS.getEntitlementsOfAUser,o=c.api.constructAPIUrl(o,{accountId:t.accountId,extUserId:e.extUserId}),n={},e.productDetails&&(n.productDetails=e.productDetails),e.bundleDetails&&(n.bundleDetails=e.bundleDetails),e=s.get(o).query(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((o={}).message=o.description="Mandatory parameter extUserId not found in request options",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),getMicroEntitlementsForAUser:function(e){var t=this,r=a.defer();{var n,o;e&&e.extuserid&&e.productcode?(o=t.config.DEFAULT_HOSTS.PRODUCT+t.config.PRODUCT_API_URLS.getMicroEntitlementsOfAUser,o=c.api.constructAPIUrl(o,{accountId:t.accountId,extUserId:e.extuserid}),(n={}).productcode=e.productcode,e.context&&(n.context=e.context),e.feature_key&&(n.feature_key=e.feature_key),e.cursor&&(n.cursor=e.cursor),e=s.get(o).query(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((o={}).message=o.description="Mandatory parameter extuserid or productcodenot found in request options",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),getAllBundles:function(e){var t=this,r=a.defer(),n=t.config.DEFAULT_HOSTS.PRODUCT+t.config.PRODUCT_API_URLS.getAllBundles,o=(n=c.api.constructAPIUrl(n,{accountId:t.accountId}),{});e&&e.stage&&(o.stage=e.stage);e=s.get(n).query(o);t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid);return e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}),r.promise}.bind(this),getSingleBundle:function(e){var t=this,r=a.defer();{var n,o;e&&e["bundle-code"]?(n=t.config.DEFAULT_HOSTS.PRODUCT+t.config.PRODUCT_API_URLS.getSingleBundle,n=c.api.constructAPIUrl(n,{accountId:t.accountId,bundleCode:e["bundle-code"]}),o={},e.stage&&(o.stage=e.stage),e=s.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Required parameter bundle-code not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getSingleProductFamily:function(e){var t=this,r=a.defer();{var n,o;e&&e["family-code"]?(n=t.config.DEFAULT_HOSTS.PRODUCT+t.config.PRODUCT_API_URLS.getSingleProductFamily,n=c.api.constructAPIUrl(n,{accountId:t.accountId,familyCode:e["family-code"]}),o={},e.stage&&(o.stage=e.stage),e=s.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Required parameter family-code not found in request options",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAllProductFamilies:function(e){var t=this,r=a.defer(),n=t.config.DEFAULT_HOSTS.PRODUCT+t.config.PRODUCT_API_URLS.getAllProductFamilies,o=(n=c.api.constructAPIUrl(n,{accountId:t.accountId}),{});e&&e.stage&&(o.stage=e.stage);e=s.get(n).query(o);t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid);return e.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}),r.promise}.bind(this)}}},{"../../helpers":3,q:42,superagent:45}],24:[function(e,t,r){var i=e("superagent"),s=e("q"),a=e("../../helpers"),c=a.errors.DLSError;t.exports=function(){return{promoteProduct:function(e){var t=this,r=s.defer(),n=t.config.DEFAULT_HOSTS.PUB+t.config.PUB_API_URLS.promoteAPI,o=(n=a.api.constructAPIUrl(n,{orgId:t.orgId,productcode:e.productcode}),{source:{},target:{}});e&&(e.source&&e.source.stage&&(o.source.stage=e.source.stage),e.target&&(e.target.org&&(o.target.org=e.target.org),e.target.stage)&&(o.target.stage=e.target.stage),e.externalrefid)&&(o.externalrefid=e.externalrefid);e=i.post(n).send(o);t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid);return e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t)}),r.promise}.bind(this),registerProduct:function(e){var t=this,r=s.defer(),n=t.config.DEFAULT_HOSTS.PUB+t.config.PUB_API_URLS.registerProductAPI,o=(n=a.api.constructAPIUrl(n,{orgId:t.orgId}),{});e&&(e.targetorg&&(o.targetorgid=e.targetorg),e.repositorytype&&(o.repositorytype=e.repositorytype),e.producttitle&&(o.producttitle=e.producttitle),e.producttype&&(o.producttype=e.producttype),e.productcode&&(o.productcode=e.productcode),e.github&&(o.github=e.github),e.s3&&(o.s3=e.s3),e.externalrefid&&(o.externalrefid=e.externalrefid),e["bundle-codes"])&&(o["bundle-codes"]=e["bundle-codes"]);e=i.post(n).send(o);t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid);return e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t)}),r.promise}.bind(this),ingestProduct:function(e){var t=this,r=s.defer();e&&e.productcode&&(o=e.productcode);var n=t.config.DEFAULT_HOSTS.PUB+t.config.PUB_API_URLS.ingestByCodeAPI,o=(n=a.api.constructAPIUrl(n,{orgId:t.orgId,productcode:o}),{});e&&(e.branchref&&(o.branchref=e.branchref),e.externalrefid&&(o.externalrefid=e.externalrefid),e["bundle-codes"])&&(o["bundle-codes"]=e["bundle-codes"]);e=i.post(n).send(o);t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid);return e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t)}),r.promise}.bind(this),createBundle:function(e){var t=this,r=s.defer();{var n;e&&e.stage&&e["bundle-code"]&&e.body&&e.body.title&&e.body.products?(n=t.config.DEFAULT_HOSTS.PUB+t.config.PUB_API_URLS.createBundle,n=a.api.constructAPIUrl(n,{orgid:t.orgId,stage:e.stage}),e.body["bundle-code"]=e["bundle-code"],n=i.post(n).send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Required parameter stage or bundle-code or title or products not found in request options",e=new c(a.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),updateBundle:function(e){var t=this,r=s.defer();{var n;e&&e.stage&&e["bundle-code"]&&e.body&&e.body.products?(n=t.config.DEFAULT_HOSTS.PUB+t.config.PUB_API_URLS.updateBundle,n=a.api.constructAPIUrl(n,{orgid:t.orgId,stage:e.stage,bundleCode:e["bundle-code"]}),n=i.put(n).send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Required parameter stage or bundle-code or products not found in request options",e=new c(a.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),getAllBundles:function(e){var t=this,r=s.defer(),n=t.config.DEFAULT_HOSTS.PUB+t.config.PUB_API_URLS.getAllBundles,o=(n=a.api.constructAPIUrl(n,{orgid:t.orgId}),{});e&&e.stage&&(o.stage=e.stage);e=i.get(n).query(o);t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid);return e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}),r.promise}.bind(this),getSingleBundle:function(e){var t=this,r=s.defer();{var n,o;e&&e["bundle-code"]?(n=t.config.DEFAULT_HOSTS.PUB+t.config.PUB_API_URLS.getSingleBundle,n=a.api.constructAPIUrl(n,{orgid:t.orgId,bundleCode:e["bundle-code"]}),o={},e&&e.stage&&(o.stage=e.stage),e=i.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Required parameter bundle-code not found in request options",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createProductFamily:function(e){var t=this,r=s.defer();{var n;e&&e.stage&&e.body&&e.body["family-code"]?(n=t.config.DEFAULT_HOSTS.PUB+t.config.PUB_API_URLS.createProductFamily,n=a.api.constructAPIUrl(n,{orgid:t.orgId,stage:e.stage}),n=i.post(n).send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Required parameter stage or family-code not found in request options",e=new c(a.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),updateProductFamily:function(e){var t=this,r=s.defer();{var n;e&&e.stage&&e["family-code"]?(n=t.config.DEFAULT_HOSTS.PUB+t.config.PUB_API_URLS.updateProductFamily,n=a.api.constructAPIUrl(n,{orgid:t.orgId,stage:e.stage,familyCode:e["family-code"]}),n=i.put(n).send(e.body),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Required parameter stage or family-code not found in request options",e=new c(a.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),getSingleProductFamily:function(e){var t=this,r=s.defer();{var n,o;e&&e["family-code"]?(n=t.config.DEFAULT_HOSTS.PUB+t.config.PUB_API_URLS.getSingleProductFamily,n=a.api.constructAPIUrl(n,{orgid:t.orgId,familyCode:e["family-code"]}),o={},e.stage&&(o.stage=e.stage),e=i.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Required parameter family-code not found in request options",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAllProductFamilies:function(e){var t=this,r=s.defer(),n=t.config.DEFAULT_HOSTS.PUB+t.config.PUB_API_URLS.getAllProductFamilies,o=(n=a.api.constructAPIUrl(n,{orgid:t.orgId}),{});e&&e.stage&&(o.stage=e.stage);e=i.get(n).query(o);t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid);return e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}),r.promise}.bind(this)}}},{"../../helpers":3,q:42,superagent:45}],25:[function(e,t,r){var i=e("q"),s=e("superagent"),a=e("../../helpers"),n=e("./pubnubClientWrapper"),c=a.errors.DLSError;t.exports=function(){var e=n();return{connect:function(e,t){if(t.userid)return e.setup({userid:t.userid,pubnub:{publishKey:t.publishKey,subscribeKey:t.subscribeKey,authKey:t.authKey,ssl:!0}});e={};throw e.message=e.description="Mandatory parameter userid not found in request options.",e=new c(a.errors.ERROR_TYPES.PUSHX_ERROR,e)}.bind(this,e),cleanup:function(e){e.cleanup()}.bind(this,e),grantByUserOrgId:function(e){var t=this,r=i.defer(),n=a.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):(n=t.config.DEFAULT_HOSTS.PUSHX+t.config.PUSHX_API_URLS.grantByUserOrgId,n=a.api.constructAPIUrl(n,{orgId:t.orgId}),n=s.post(n).set("Content-Type","application/json").set("Accept","application/json"),o={},e.authKey&&(o.authKey=e.authKey),n.send(o),n=a.api.setupAPIToken(n,t.token),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}))}return r.promise}.bind(this),grantByAccountId:function(e){var t={},r=i.defer();{var n,o;e.accountId&&e.refId?(n=this.config.DEFAULT_HOSTS.PUSHX+this.config.PUSHX_API_URLS.grantByAccountId,n=a.api.constructAPIUrl(n,{accountId:e.accountId}),n=s.post(n).set("Content-Type","application/json").set("Accept","application/json"),this.traceid&&n.set("X-Amzn-Trace-Id",this.traceid),o={refId:e.refId},e.authKey&&(o.authKey=e.authKey),n.send(o),n.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(t.message=t.description="Required parameter ['accountId', 'refId'] not found in request options",t=new c(a.errors.ERROR_TYPES.SDK_ERROR,t),r.reject(t))}return r.promise}.bind(this),grantByAccountIdOnExtUserId:function(e){var t={},r=i.defer();{var n,o;e.accountId&&e.extUserId?(n=this.config.DEFAULT_HOSTS.PUSHX+this.config.PUSHX_API_URLS.grantByAccountId,n=a.api.constructAPIUrl(n,{accountId:e.accountId}),n=s.post(n).set("Content-Type","application/json").set("Accept","application/json"),this.traceid&&n.set("X-Amzn-Trace-Id",this.traceid),o={extUserId:e.extUserId},e.authKey&&(o.authKey=e.authKey),n.send(o),n.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(t.message=t.description="Required parameter ['accountId', 'extUserId'] not found in request options",t=new c(a.errors.ERROR_TYPES.SDK_ERROR,t),r.reject(t))}return r.promise}.bind(this)}}},{"../../helpers":3,"./pubnubClientWrapper":26,q:42,superagent:45}],26:[function(e,t,r){var u=e("pubnub"),d=e("events").EventEmitter,p=e("../../helpers"),l=p.errors.PUSHXError;t.exports=function(){var r,a=new d,n=[],c={},o=!1,i=function(){return JSON.parse(JSON.stringify(c))},s=function(e){r.subscribe({channels:[e]})};return{setup:function(e){var t=e.pubnub;return t.uuid=e.userid,r||!t?new Error("Already Initialized"):(r=new u(t),r.addListener({message:function(e){var t;t=e.subscribedChannel,a.emit(t,e.message)},status:function(e){var t,r=e,n=[];switch(r.category){case"PNConnectedCategory":if("PNSubscribeOperation"===r.operation){for(var o in n=r.subscribedChannels)c[n[o]]&&(c[n[o]].status="subscribed");a.emit("pushx_status",{category:"PUSHX",type:"CHANNEL_SUBSCRIPTION",status:"SUCCESS",message:"Success: Subscribed successfully.",httpcode:200,data:{payload:{channels:r.subscribedChannels},message:"Success: Subscribed successfully."}})}break;case"PNAccessDeniedCategory":if("PNSubscribeOperation"===r.operation){var i,s={payload:JSON.parse(r.errorData.response.text).payload,message:"Forbidden: Subscription failed.",errorDetails:{operation:r.operation,category:r.category,statusCode:r.statusCode}};for(i in n=s.payload.channels)c[n[i]]&&(c[n[i]].status="error",c[n[i]].error=t);t=new l(p.errors.ERROR_CATEGORY.PUSHX,s),a.emit("pushx_status",t)}break;case"PNBadRequestCategory":case"PNNetworkDownCategory":case"PNNetworkUpCategory":t={message:"PushX Error",status:r.statusCode,pushXError:r},t=new l(p.errors.ERROR_CATEGORY.PUSHX,t),a.emit("pushx_status",t)}}}),{on:function(e,t){var r=[];e.orgid||e.userid||e.accountid||e.productid||e.classid?(e.accountid?r.push("a-"+e.accountid):(e.orgid&&r.push("o-"+e.orgid),e.userid&&r.push("u-"+e.userid),e.productid&&r.push("p-"+e.productid),e.classid&&r.push("c-"+e.classid)),r=r.join("$")+"$"+e.channel,n.includes(r)||(n.push(r),c[r]={status:"pending"},a.on(r,t),s(r))):"pushx_status"!==e.channel||o||(a.on(e.channel,t),o=!0)},getMySubscriptionStatus:i})},cleanup:function(){r&&(r.unsubscribeAll(),r.stop(),o=!(n=[]),c={}),r=void 0}}}},{"../../helpers":3,events:38,pubnub:41}],27:[function(e,t,r){var i=e("q"),s=e("superagent"),a=e("../../helpers"),e=e("agentkeepalive"),c=a.errors.DLSError,o=(t.exports=function(){return{getRules:function(e){var t=this,r=i.defer(),n=a.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.ruleType?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.RULES_API_URLS.rules,o=a.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),ruleType:e.ruleType}),e={cursor:e.cursor},o=s.get(o).set("Content-Type","application/json").set("Accept","application/json").query(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=a.api.setupAPIToken(o,t.token)).end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="context or ruleType not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getParticularRule:function(e){var t=this,r=i.defer(),n=a.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.ruleType&&e.ruleId?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.RULES_API_URLS.particularRule,o=a.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),ruleType:e.ruleType,ruleId:e.ruleId}),e=s.get(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=a.api.setupAPIToken(e,t.token)).end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="context or ruleType or ruleId not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getUserRule:function(e){var t=this,r=i.defer();{var n;e&&e.orgId&&e.context&&e.ruleType&&e.userId?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.RULES_API_URLS.getUserRule,n=a.api.constructAPIUrl(n,{orgId:t.orgId,context:encodeURIComponent(e.context),ruleType:e.ruleType,userId:e.userId}),e=s.get(n).set("Content-Type","application/json").set("Accept","application/json"),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=a.api.setupAPIToken(e,t.token)).agent(o).end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - orgId or context or ruleType or userId not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateRuleDisplay:function(e){var t=this,r=i.defer(),n=a.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.ruleType&&e.ruleId&&e.body&&e.body.rule_display?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.RULES_API_URLS.updateRuleDisplay,o=a.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),ruleType:e.ruleType,ruleId:e.ruleId}),o=s.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=a.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - context or ruleType or ruleId or body.rule_display not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createRule:function(e){var t=this,r=i.defer(),n=a.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.ruleType&&e.body?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.RULES_API_URLS.rules,o=a.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),ruleType:e.ruleType}),o=s.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=a.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - context or ruleType or body not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateRule:function(e){var t=this,r=i.defer(),n=a.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.ruleType&&e.ruleId&&e.body?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.RULES_API_URLS.particularRule,o=a.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),ruleType:e.ruleType,ruleId:e.ruleId}),o=s.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=a.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - context or ruleType or ruleId or body not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),deleteRule:function(e){var t=this,r=i.defer(),n=a.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.ruleType&&e.ruleId?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.RULES_API_URLS.particularRule,o=a.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),ruleType:e.ruleType,ruleId:e.ruleId}),e=s.delete(o),e=a.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n={},n=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - context or ruleType or ruleId not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this)}},new e({timeout:6e4,freeSocketTimeout:3e4}))},{"../../helpers":3,agentkeepalive:36,q:42,superagent:45}],28:[function(e,t,r){var s=e("q"),a=e("superagent"),n=e("agentkeepalive"),c=e("../../helpers"),u=c.errors.DLSError,i=(t.exports=function(e){return this.accountId=e,{getUserSpaces:function(e){var t=this,r=s.defer();{var n,o,i;e&&e.extuserid?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getUserSpaces,n=c.api.constructAPIUrl(n,{accountid:t.accountId,extuserid:e.extuserid}),o={},e.spaceRole&&(o.spaceRole=e.spaceRole),e.spaceType&&(o.spaceType=e.spaceType),e.spaceOrgContext&&(o.spaceOrgContext=e.spaceOrgContext),e.details&&(o.details=e.details),e.cursor&&(o.cursor=e.cursor),e=a.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(i=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(i)):r.resolve(t.body)})):((i={}).message=i.description="extuserid not found in request options.",i=new u(c.errors.ERROR_TYPES.SDK_ERROR,i),r.reject(i))}return r.promise}.bind(this),validateSpaceCode:function(e){var t=this,r=s.defer();{var n,o;e&&e.spaceCodeBody&&e.spaceCodeBody.space_code?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.validateSpaceCode,n=c.api.constructAPIUrl(n,{accountid:t.accountId}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e.spaceCodeBody),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(o=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={}).message=o.description="spaceCodeBody or space_code not found in request options.",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),validateClassCode:function(e){var t=this,r=s.defer();{var n,o,i;e&&e.classCodeBody&&e.classCodeBody.class_code?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.validateClassCode,o=c.api.constructAPIUrl(o,{accountid:t.accountId}),n={},e.details&&(n.details=e.details),o=a.post(o).set("Content-Type","application/json").set("Accept","application/json").query(n).send(e.classCodeBody),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(i=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(i)):r.resolve(t.body)})):((i={}).message=i.description="classCodeBody or class_code not found in request options.",i=new u(c.errors.ERROR_TYPES.SDK_ERROR,i),r.reject(i))}return r.promise}.bind(this),generateSpaceCode:function(e){var t=this,r=s.defer(),n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.generateSpaceCode,o=(n=c.api.constructAPIUrl(n,{accountid:t.accountId}),{});e.ignore_words&&(o.ignore_words=e.ignore_words);e=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(o);t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid);return e.end(function(e,t){e?(err=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(err)):r.resolve(t)}),r.promise}.bind(this),changeSpaceCode:function(e){var t=this,r=s.defer();{var n,o,i;e&&e.ext_user_id&&e.spacecode?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.changeSpaceCode,n=c.api.constructAPIUrl(n,{accountid:t.accountId,spacecode:e.spacecode}),o={ext_user_id:e.ext_user_id},e.ignore_words&&(o.ignore_words=e.ignore_words),e=a.put(n).set("Content-Type","application/json").set("Accept","application/json").send(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(i=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(i)):r.resolve(t)})):((i={}).message=i.description="Mandatory parameter options, ext_user_id or spacecode, not found in request options.",i=new u(c.errors.ERROR_TYPES.SDK_ERROR,i),r.reject(i))}return r.promise}.bind(this),joinInstituteSpace:function(e){var t=this,r=s.defer();{var n,o;e&&e.ext_user_id&&e.ext_role&&e.space_code?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.joinInstituteSpace,n=c.api.constructAPIUrl(n,{accountid:t.accountId}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(o=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={}).message=o.description="ext_user_id or ext_role or space_code not found in request options.",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),provisionSpacesToStudent:function(e){var t=this,r=s.defer(),n={};{var o;e&&e.ext_user_id&&e.ext_role?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.provisionSpacesToStudent,o=c.api.constructAPIUrl(o,{accountId:t.accountId}),o=a.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description="ext_user_id or ext_role not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),provisionSpacesToTeacher:function(e){var t=this,r=s.defer();{var n,o;e&&e.ext_user_id&&e.ext_role?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.provisionSpacesToTeacher,n=c.api.constructAPIUrl(n,{accountId:t.accountId}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(o=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={}).message=o.description="Mandatory parameters [rxt_user_id, ext_role] not found in request options.",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),provisionBulkSpaces:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.users&&e.space_title?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.provisionBulkSpaces,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),o=a.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory parameters: space_title or users not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),shadowProvision:function(e){var t=this,r=s.defer(),n={};{var o;e&&e.ext_user_id&&e.ext_role?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.shadowProvision,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),o=a.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.agent(i).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):(n.message=n.description="Mandatory parameters: ext_user_id or ext_role not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),entitleUserToProduct:function(e){var t=this,r=s.defer();{var n,o;e&&e.ext_user_id&&e.ext_role&&(e.productcode||e.ext_product_id)?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.entitleUserToProduct,n=c.api.constructAPIUrl(n,{accountId:t.accountId}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(o=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={description:"Missing mandatory keys in request options. 'ext_user_id', 'ext_role' and either of 'ext_product_id' or 'productcode' must be present."}).message=o.description,o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),unentitleUserToProduct:function(e){var t=this,r=s.defer();{var n;e&&e.ext_user_id&&e.productcode&&e.ext_actor_id&&void 0!==e.audit?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.entitleUserToProduct,n=c.api.constructAPIUrl(n,{accountId:t.accountId}),n=a.delete(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={}).message=e.description="Missing mandatory keys in request options. 'ext_user_id', 'ext_actor_id', 'productcode' and 'audit' must be present",e=new u(c.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this),revokeMicroEntitlementOfAUser:function(e){var t=this,r=s.defer(),n={description:"",message:""};{var o;e&&e.ext_user_id&&e.context&&e.feature_key&&e.ext_actor_id&&void 0!==e.audit&&(e.productcode||e.ext_product_id)?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.microEntitleUserToProduct,o=c.api.constructAPIUrl(o,{accountId:t.accountId}),o=a.delete(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.description="ext_user_id or context or feature_key or ext_actor_id or audit field not found or is empty in request options. Either productcode or ext_product_id must be provided.",n.message=n.description,n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),microEntitleUserToProduct:function(e){var t=this,r=s.defer(),n=!0,o={description:"",message:""};e&&e.ext_user_id&&e.context&&e.feature_key&&e.feature_id||(n=!1,o.description="ext_user_id or context or feature_key or feature_id not found in request options. ");n&&(e.productcode||e.ext_product_id)?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.microEntitleUserToProduct,n=c.api.constructAPIUrl(n,{accountId:t.accountId}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(o=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):(e.productcode||e.ext_product_id||(o.description+="Either of ext_product_id or productcode must be present in request options."),o.message=o.description,o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o));return r.promise}.bind(this),bulkMicroEntitleProductToUser:function(e){var t=this,r=s.defer();{var n,o;e&&e["micro-entitlements"]?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.bulkMicroEntitleProductToUser,n=c.api.constructAPIUrl(n,{accountId:t.accountId}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(o=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={description:"Missing mandatory keys in request options. 'micro-entitlements' must be present."}).message=o.description,o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),enrollUserInClass:function(e){var t=this,r=s.defer();{var n,o;e&&e.ext_user_id&&e.ext_role&&e.class_code?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.enrollUserInClass,n=c.api.constructAPIUrl(n,{accountId:t.accountId}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(o=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={}).message=o.description="ext_user_id or ext_role or class_code not found in request options.",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),getExtProduct:function(e){var t=this,r=s.defer();{var n,o;e&&e.ext_product_id?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getExtProductAPI,n=c.api.constructAPIUrl(n,{accountId:t.accountId,extProductId:e.ext_product_id}),e=a.get(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(o=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={}).message=o.description="ext_product_id not found in request options.",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),getSpaceDetails:function(e){var t=this,r=s.defer();{var n,o;e&&e.spacekey?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getSpaceDetails,n=c.api.constructAPIUrl(n,{accountId:t.accountId,spacekey:e.spacekey}),e={orgid:t.orgId},n=a.get(n).query(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),(n=c.api.setupAPIToken(n,t.token)).end(function(e,t){e?(o=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={}).message=o.description="spacekey not found in request options.",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),updateUserInformation:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.ext_user_id?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.updateUserInformation,o=c.api.constructAPIUrl(o,{accountId:t.accountId}),i={ext_user_id:e.ext_user_id},e.ref_id&&(i.ref_id=e.ref_id),e.ext_email&&(i.ext_email=e.ext_email),e.ext_first_name&&(i.ext_first_name=e.ext_first_name),e.ext_last_name&&(i.ext_last_name=e.ext_last_name),e.address&&(i.address=e.address),e=a.put(o).set("Content-Type","application/json").set("Accept","application/json").send(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description='Mandatory parameters not found in request options: ["ext_user_id"]',n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateUserSpace:function(e){var r,t=this,n=s.defer();{var o;e&&e.extuserid&&e.spacekey&&e.body?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.updateUserSpace,o=c.api.constructAPIUrl(o,{accountid:t.accountId,extuserid:e.extuserid,spacekey:e.spacekey}),o=a.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.agent(i).end(function(e,t){e?(r=new u(c.errors.ERROR_TYPES.API_ERROR,e),n.reject(r)):n.resolve(t.body)})):((e={}).message=e.description="Missing mandatory params: 'extuserid' or 'spacekey' or 'body' not found in the request options.",r=new u(c.errors.ERROR_TYPES.SDK_ERROR,e),n.reject(r))}return n.promise}.bind(this),getInvitationsByEmail:function(e){var t=this,r=s.defer(),n={};{var o,i;e&&e.email?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getInvitationsByEmail,o=c.api.constructAPIUrl(o,{accountid:t.accountId}),i={email:e.email},e.status&&(i.status=e.status),e=a.get(o).query(i),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description="email not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateInstituteTitle:function(e){var t=this,r=s.defer(),n={};{var o;e&&e.space_code&&e.body&&e.body.ext_actor_id?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.updateInstituteTitle,o=c.api.constructAPIUrl(o,{accountId:t.accountId,instituteSpaceCode:e.space_code}),o=a.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description="space_code or ext_actor_id not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this)}},new n({timeout:6e4,freeSocketTimeout:3e4}))},{"../../helpers":3,agentkeepalive:36,q:42,superagent:45}],29:[function(e,t,r){var o=e("q"),i=e("superagent"),n=e("agentkeepalive"),s=e("../../helpers"),a=s.errors.DLSError,c=(t.exports=function(e){return this.accountId=e,{entitleBulkUsersToProducts:function(e){var t=this,r=o.defer();{var n;e&&e.users&&e.ext_actor_id?(n=t.config.DEFAULT_HOSTS.AUTHEXTN+t.config.AUTHEXTN_API_URLS.entitleBulkUsersToProducts,n=s.api.constructAPIUrl(n,{accountid:t.accountId}),n=i.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.agent(c).end(function(e,t){e?(e=new a(s.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((e={description:"Mandatory params: 'users', 'ext_actor_id' not found in request options."}).message=e.description,e=new a(s.errors.ERROR_TYPES.SDK_ERROR,e),r.reject(e))}return r.promise}.bind(this)}},new n({timeout:6e4,freeSocketTimeout:3e4}))},{"../../helpers":3,agentkeepalive:36,q:42,superagent:45}],30:[function(e,t,r){var i=e("q"),s=e("superagent"),a=e("../../helpers"),c=a.errors.DLSError;t.exports=function(e){return this.accountId=e,{getAllInstitutions:function(e){var t=this,r=i.defer(),n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getAllInstitutions,o=(n=a.api.constructAPIUrl(n,{accountid:t.accountId}),{});e&&(e.lookup&&(o.lookup=e.lookup),e.cursor&&(o.cursor=e.cursor),e.limit)&&(o.limit=e.limit);e=s.get(n).query(o);t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid);return e.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}),r.promise}.bind(this),getInstitution:function(e){var t=this,r=i.defer();{var n,o;e&&e.spacecode?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getInstitution,n=a.api.constructAPIUrl(n,{accountid:t.accountId,spacecode:e.spacecode}),e=s.get(n),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(o=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={}).message=o.description="spacecode not found in request options.",o=new c(a.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),provisionSpacesToSuperAdmin:function(e){var t=this,r=i.defer();{var n,o;e&&e.ext_user_id&&e.ext_role&&e.ext_email&&e.ext_first_name&&e.ext_last_name?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.provisionSpacesToSuperAdmin,n=a.api.constructAPIUrl(n,{accountid:t.accountId}),n=s.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(o=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={}).message=o.description="Missing required input data",o=new c(a.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this)}}},{"../../helpers":3,q:42,superagent:45}],31:[function(e,t,r){var s=e("q"),a=e("superagent"),c=e("../../helpers"),u=c.errors.DLSError;t.exports=function(){return{associateTagsWithEntity:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.entity_type&&e.entity_id&&e.tags?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.TAXONOMY_API_URLS.associateTagsWithEntity,o=c.api.constructAPIUrl(o,{orgId:t.orgId}),o=a.put(o).send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).end(function(e,t){e?(e=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)})):((n={}).message=n.description="entity_id or entity_type or tags not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),createTags:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.taxonomyid&&e.body&&e.body.tags&&0<e.body.tags.length?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.TAXONOMY_API_URLS.tags,o=c.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),taxonomyId:e.taxonomyid}),o=a.post(o).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory param - context or taxonomyid or body.tags(min. 1 tag) not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),updateTags:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.taxonomyid&&e.body&&e.body.tagid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.TAXONOMY_API_URLS.tags,o=c.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),taxonomyId:e.taxonomyid}),o=a.put(o).set("Content-Type","application/json").set("Accept","application/json").send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory params - context or taxonomyid or tagid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),deleteTags:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o,i;n?r.reject(n):e&&e.context&&e.taxonomyid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.TAXONOMY_API_URLS.tags,o=c.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),taxonomyId:e.taxonomyid}),i={},e.tagid&&(i.tagid=e.tagid),e=a.delete(o).query(i),e=c.api.setupAPIToken(e,t.token),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(n={},n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="context or taxonomyid or tagid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getTag:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.taxonomyid&&e.tagid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.TAXONOMY_API_URLS.tags,o=c.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),taxonomyId:e.taxonomyid}),e={hierarchy:!1,tagid:e.tagid},o=a.get(o).set("Content-Type","application/json").set("Accept","application/json").query(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory param - context or taxonomyid or tagid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getTagHierarchy:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.taxonomyid&&e.tagid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.TAXONOMY_API_URLS.tags,o=c.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),taxonomyId:e.taxonomyid}),e={hierarchy:!0,tagid:e.tagid},o=a.get(o).set("Content-Type","application/json").set("Accept","application/json").query(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),(o=c.api.setupAPIToken(o,t.token)).end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory param - context or taxonomyid or tagid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this),getAllTags:function(e){var t=this,r=s.defer(),n=c.validations.isAuthenticated(t.orgId,t.token);{var o;n?r.reject(n):e&&e.context&&e.taxonomyid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.TAXONOMY_API_URLS.tags,o=c.api.constructAPIUrl(o,{orgId:t.orgId,context:encodeURIComponent(e.context),taxonomyId:e.taxonomyid}),e=a.get(o).set("Content-Type","application/json").set("Accept","application/json").query({hierarchy:!0}),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),(e=c.api.setupAPIToken(e,t.token)).end(function(e,t){e?(n=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):((n={}).message=n.description="Mandatory param - context or taxonomyid not found in request options.",n=new u(c.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this)}}},{"../../helpers":3,q:42,superagent:45}],32:[function(e,t,r){var s=e("q"),a=e("superagent"),c=e("./../../helpers"),u=c.errors.DLSError;t.exports=function(e){return this.accountId=e,{createWorkflow:function(e){var t=this,r=s.defer();{var n,o;e&&e.ext_user_id&&e.workflow_type?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.workflows,n=c.api.constructAPIUrl(n,{accountid:t.accountId}),n=a.post(n).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(o=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(o)):r.resolve(t.body)})):((o={}).message=o.description="ext_user_id or workflow_type not found in request options.",o=new u(c.errors.ERROR_TYPES.SDK_ERROR,o),r.reject(o))}return r.promise}.bind(this),getAllWorkflow:function(e){var t=this,r=s.defer();{var n,o;e&&e.workflow_type&&e.status?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.workflows,n=c.api.constructAPIUrl(n,{accountid:t.accountId}),o={workflow_type:e.workflow_type,status:e.status},e.start&&(o.start=e.start),e.end&&(o.end=e.end),e.cursor&&(o.cursor=e.cursor),e=a.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(err=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(err)):r.resolve(t.body)})):((err={}).message=err.description="Mandatory params - workflow_type, status not found in request options.",err=new u(c.errors.ERROR_TYPES.SDK_ERROR,err),r.reject(err))}return r.promise}.bind(this),getAllWorkflowOfAUser:function(e){var t=this,r=s.defer();{var n,o;e&&e.workflow_type&&e.status&&e.ext_user_id?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getAllWorkflowOfAUser,n=c.api.constructAPIUrl(n,{accountid:t.accountId}),o={workflow_type:e.workflow_type,status:e.status,ext_user_id:e.ext_user_id},e.start&&(o.start=e.start),e.end&&(o.end=e.end),e.cursor&&(o.cursor=e.cursor),e=a.get(n).query(o),t.traceid&&e.set("X-Amzn-Trace-Id",t.traceid),e.end(function(e,t){e?(err=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(err)):r.resolve(t.body)})):((err={}).message=err.description="Mandatory params - workflow_type, status, ext_user_id not found in request options.",err=new u(c.errors.ERROR_TYPES.SDK_ERROR,err),r.reject(err))}return r.promise}.bind(this),getAWorkflow:function(e){var t=this,r=s.defer();{var n;e&&e.workflowid&&e.context_id?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getAWorkflow,n=c.api.constructAPIUrl(n,{accountid:t.accountId,workflowid:e.workflowid}),e={context_id:e.context_id},n=a.get(n).query(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(err=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(err)):r.resolve(t.body)})):((err={}).message=err.description="Mandatory params - workflow_type, status not found in request options.",err=new u(c.errors.ERROR_TYPES.SDK_ERROR,err),r.reject(err))}return r.promise}.bind(this),acceptAWorkflow:function(e){var t=this,r=s.defer();{var n;e&&e.workflowid&&e.body&&e.body.context_id?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.acceptAWorkflow,n=c.api.constructAPIUrl(n,{accountid:t.accountId,workflowid:e.workflowid}),e=e.body,n=a.put(n).send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(err=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(err)):r.resolve(t)})):((err={}).message=err.description="Mandatory params - workflowid, body or body.context_id not found in request options.",err=new u(c.errors.ERROR_TYPES.SDK_ERROR,err),r.reject(err))}return r.promise}.bind(this),processAWorkflow:function(e){var t=this,r=s.defer();{var n;e&&e.workflowid&&e.body&&e.body.context_id&&e.body.org_id?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.processAWorkflow,n=c.api.constructAPIUrl(n,{accountid:t.accountId,workflowid:e.workflowid}),e=e.body,n=a.put(n).send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(err=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(err)):r.resolve(t)})):((err={}).message=err.description="Mandatory params - workflowid, body, body.context_id, body.org_id in request options.",err=new u(c.errors.ERROR_TYPES.SDK_ERROR,err),r.reject(err))}return r.promise}.bind(this),revokeAWorkflow:function(e){var t=this,r=s.defer();{var n;e&&e.workflowid&&e.body&&e.body.context_id?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.revokeAWorkflow,n=c.api.constructAPIUrl(n,{accountid:t.accountId,workflowid:e.workflowid}),e=e.body,n=a.put(n).send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(err=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(err)):r.resolve(t)})):((err={}).message=err.description="Mandatory params - workflowid, body or body.context_id not found in request options.",err=new u(c.errors.ERROR_TYPES.SDK_ERROR,err),r.reject(err))}return r.promise}.bind(this),completeAWorkflow:function(e){var t=this,r=s.defer();{var n;e&&e.workflowid&&e.body&&e.body.context_id?(n=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.completeAWorkflow,n=c.api.constructAPIUrl(n,{accountid:t.accountId,workflowid:e.workflowid}),e=e.body,n=a.put(n).send(e),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(err=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(err)):r.resolve(t)})):((err={}).message=err.description="Mandatory params - workflowid, body or body.context_id not found in request options.",err=new u(c.errors.ERROR_TYPES.SDK_ERROR,err),r.reject(err))}return r.promise}.bind(this),updateWorkflowRequest:function(e){var t=this,r=s.defer();{var n,o,i;e&&e.context_id&&e.body.ext_user_id&&e.body.workflow_type&&e.workflowid?(o=t.config.DEFAULT_HOSTS.AUTH+t.config.AUTH_API_URLS.getAWorkflow,o=c.api.constructAPIUrl(o,{accountid:t.accountId,workflowid:e.workflowid}),n={context_id:e.context_id},o=a.put(o).set("Content-Type","application/json").set("Accept","application/json").query(n).send(e.body),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(i=new u(c.errors.ERROR_TYPES.API_ERROR,e),r.reject(i)):r.resolve(t)})):((i={}).message=i.description="context_id or ext_user_id or workflow_type or workflowid not found in request options.",i=new u(c.errors.ERROR_TYPES.SDK_ERROR,i),r.reject(i))}return r.promise}.bind(this)}}},{"./../../helpers":3,q:42,superagent:45}],33:[function(e,t,r){var i=e("q"),s=e("superagent"),a=e("../../helpers"),c=a.errors.DLSError;t.exports=function(e){return this.accountId=e,{postStatement:function(e){var t=this,r=i.defer(),n={};(n=a.validations.isAuthenticated(t.orgId,t.token))?r.reject(n):(n=t.config.DEFAULT_HOSTS.XAPI+t.config.XAPI_API_URLS.postMultiStatements,n=a.api.constructAPIUrl(n,{orgId:t.orgId}),e=e,n=s.post(n).send(e),n=a.api.setupAPIToken(n,t.token),t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid),n.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}));return r.promise}.bind(this),postExternalStatements:function(e){var t=this,r=i.defer(),n=t.config.DEFAULT_HOSTS.XAPI+t.config.XAPI_API_URLS.postExternalMultiStatements,n=(n=a.api.constructAPIUrl(n,{orgId:t.orgId}),s.post(n).send(e));t.traceid&&n.set("X-Amzn-Trace-Id",t.traceid);return n.end(function(e,t){e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(e)):r.resolve(t.body)}),r.promise}.bind(this),resetUserProductProgress:function(e){var t=this,r=i.defer(),n={};{var o;e&&e.userid&&e.productcode&&e.actorid?(o=t.config.DEFAULT_HOSTS.XAPI+t.config.XAPI_API_URLS.resetUserProductProgress,o=a.api.constructAPIUrl(o,{accountId:t.accountId}),o=s.delete(o).set("Content-Type","application/json").set("Accept","application/json").send(e),t.traceid&&o.set("X-Amzn-Trace-Id",t.traceid),o.end(function(e,t){e?(n=new c(a.errors.ERROR_TYPES.API_ERROR,e),r.reject(n)):r.resolve(t.body)})):(n.message=n.description="userid, productcode or actorid not found in request options.",n=new c(a.errors.ERROR_TYPES.SDK_ERROR,n),r.reject(n))}return r.promise}.bind(this)}}},{"../../helpers":3,q:42,superagent:45}],34:[function(e,t,r){var i=e("superagent"),s=e("q"),a=e("../helpers"),c=a.errors.DLSError,u=e("./validations");r.authWithExtUser=function(e,t){var n=this,o=s.defer(),r=u.validateAuthWithExtUser(e,t);r?o.reject(r):(r=this.config.DEFAULT_HOSTS.AUTH+this.config.AUTH_API_URLS.getExtUserTokenAPI,r=a.api.constructAPIUrl(r,{orgId:e}),e={ext_user_id:t.ext_user_id},i.post(r).send(e).end(function(e,t){var r;e?(e=new c(a.errors.ERROR_TYPES.API_ERROR,e),o.reject(e)):(t={token:e={access_token:t.body.access_token},user:r=t.body.user,metrics:t.body.metrics},n.token=e,n.orgId=r.org.id,o.resolve(t))}));return o.promise},r.authWithToken=function(e,t,r){var n=this,o=s.defer(),i=u.authWithToken(e,t,r);i?o.reject(i):(n.token=t,n.orgId=e,r&&r.getuserdetails?n.Auth().getUserProfile().then(function(e){e={token:n.token,user:e};o.resolve(e)},function(e){e=new c(a.errors.ERROR_TYPES.API_ERROR,e),o.reject(e)}):o.resolve(n.token));return o.promise}},{"../helpers":3,"./validations":35,q:42,superagent:45}],35:[function(e,t,r){var n=e("../helpers").validations.validate;r.authWithToken=function(e,t,r){return n({organization:e,token:t,options:r},{organization:{isString:!0,presence:!0},token:{isObject:!0,presence:!0,contains:["access_token"]},"token.access_token":{isString:!0,presence:!0},options:{isObject:!0}})},r.validateAuthWithExtUser=function(e,t){return n({organization:e,options:t},{organization:{isString:!0,presence:!0},options:{isObject:!0,presence:!0,contains:["ext_user_id"]},"options.ext_user_id":{isString:!0,presence:!0}})}},{"../helpers":3}],36:[function(e,t,r){function n(){}t.exports=n,t.exports.HttpsAgent=n},{}],37:[function(e,t,r){function n(e){if(e){var t,r=e;for(t in n.prototype)r[t]=n.prototype[t];return r}}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)this._callbacks={};else{var r=this._callbacks["$"+e];if(r)if(1==arguments.length)delete this._callbacks["$"+e];else{for(var n,o=0;o<r.length;o++)if((n=r[o])===t||n.fn===t){r.splice(o,1);break}0===r.length&&delete this._callbacks["$"+e]}}return this},n.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks["$"+e],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(r)for(var n=0,o=(r=r.slice(0)).length;n<o;++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}},{}],38:[function(e,t,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function a(e){return"function"==typeof e}function c(e){return"object"==typeof e&&null!==e}function u(e){return void 0===e}((t.exports=n).EventEmitter=n).prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,r,n,o,i,s;if(this._events||(this._events={}),"error"===e&&(!this._events.error||c(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(u(r=this._events[e]))return!1;if(a(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:for(n=arguments.length,o=new Array(n-1),i=1;i<n;i++)o[i-1]=arguments[i];r.apply(this,o)}else if(c(r)){for(n=arguments.length,o=new Array(n-1),i=1;i<n;i++)o[i-1]=arguments[i];for(n=(s=r.slice()).length,i=0;i<n;i++)s[i].apply(this,o)}return!0},n.prototype.on=n.prototype.addListener=function(e,t){if(a(t))return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,a(t.listener)?t.listener:t),this._events[e]?c(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,c(this._events[e])&&!this._events[e].warned&&(t=u(this._maxListeners)?n.defaultMaxListeners:this._maxListeners)&&0<t&&this._events[e].length>t&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace)&&console.trace(),this;throw TypeError("listener must be a function")},n.prototype.once=function(e,t){var r;if(a(t))return r=!1,n.listener=t,this.on(e,n),this;throw TypeError("listener must be a function");function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}},n.prototype.removeListener=function(e,t){var r,n,o,i;if(!a(t))throw TypeError("listener must be a function");if(this._events&&this._events[e])if(o=(r=this._events[e]).length,n=-1,r===t||a(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(c(r)){for(i=o;0<i--;)if(r[i]===t||r[i].listener&&r[i].listener===t){n=i;break}if(n<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,r;if(this._events)if(this._events.removeListener)if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);this.removeAllListeners("removeListener"),this._events={}}else{if(a(r=this._events[e]))this.removeListener(e,r);else for(;r.length;)this.removeListener(e,r[r.length-1]);delete this._events[e]}else 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e];return this},n.prototype.listeners=function(e){e=this._events&&this._events[e]?a(this._events[e])?[this._events[e]]:this._events[e].slice():[];return e},n.listenerCount=function(e,t){e=e._events&&e._events[t]?a(e._events[t])?1:e._events[t].length:0;return e}},{}],39:[function(e,t,r){function d(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===i.call(e)}function p(e){if(e&&"[object Object]"===i.call(e)){var t,r=o.call(e,"constructor"),n=e.constructor&&e.constructor.prototype&&o.call(e.constructor.prototype,"isPrototypeOf");if(!e.constructor||r||n){for(t in e);return void 0===t||o.call(e,t)}}}function l(e,t){n&&"__proto__"===t.name?n(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue}function f(e,t){if("__proto__"===t){if(!o.call(e,t))return;if(s)return s(e,t).value}return e[t]}var o=Object.prototype.hasOwnProperty,i=Object.prototype.toString,n=Object.defineProperty,s=Object.getOwnPropertyDescriptor;t.exports=function e(){var t,r,n,o,i,s=arguments[0],a=1,c=arguments.length,u=!1;for("boolean"==typeof s&&(u=s,s=arguments[1]||{},a=2),(null==s||"object"!=typeof s&&"function"!=typeof s)&&(s={});a<c;++a)if(null!=(t=arguments[a]))for(r in t)i=f(s,r),s!==(n=f(t,r))&&(u&&n&&(p(n)||(o=d(n)))?(i=o?(o=!1,i&&d(i)?i:[]):i&&p(i)?i:{},l(s,{name:r,newValue:e(u,i,n)})):void 0!==n&&l(s,{name:r,newValue:n}));return s}},{}],40:[function(e,t,r){var n,o,t=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{o="function"==typeof clearTimeout?clearTimeout:s}catch(e){o=s}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===i||!n)&&setTimeout)return(n=setTimeout)(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}var c,u=[],d=!1,p=-1;function l(){d&&c&&(d=!1,c.length?u=c.concat(u):p=-1,u.length)&&f()}function f(){if(!d){for(var e=a(l),t=(d=!0,u.length);t;){for(c=u,u=[];++p<t;)c&&c[p].run();p=-1,t=u.length}c=null,d=!1,!function(t){if(o===clearTimeout)return clearTimeout(t);if((o===s||!o)&&clearTimeout)return(o=clearTimeout)(t);try{o(t)}catch(e){try{return o.call(null,t)}catch(e){return o.call(this,t)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function g(){}t.nextTick=function(e){var t=new Array(arguments.length-1);if(1<arguments.length)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];u.push(new h(e,t)),1!==u.length||d||a(f)},h.prototype.run=function(){this.fun.apply(null,this.array)},t.title="browser",t.browser=!0,t.env={},t.argv=[],t.version="",t.versions={},t.on=g,t.addListener=g,t.once=g,t.off=g,t.removeListener=g,t.removeAllListeners=g,t.emit=g,t.prependListener=g,t.prependOnceListener=g,t.listeners=function(e){return[]},t.binding=function(e){throw new Error("process.binding is not supported")},t.cwd=function(){return"/"},t.chdir=function(e){throw new Error("process.chdir is not supported")},t.umask=function(){return 0}},{}],41:[function(e,r,n){!function(Ua,ka){var e,t;e=this,t=function(){var x=function(e,t){return(x=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,t){e.__proto__=t}:function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}))(e,t)};function D(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}x(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var R=function(){return(R=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function L(e,t){var r={};for(o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var n=0,o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]]);return r}function _(e,s,a,c){return new(a=a||Promise)(function(r,t){function n(e){try{i(c.next(e))}catch(e){t(e)}}function o(e){try{i(c.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?r(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(n,o)}i((c=c.apply(e,s||[])).next())})}function F(n,o){var i,s,a,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},e={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(r){return function(e){var t=[r,e];if(i)throw new TypeError("Generator is already executing.");for(;c;)try{if(i=1,s&&(a=2&t[0]?s.return:t[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,t[1])).done)return a;switch(s=0,(t=a?[2&t[0],a.value]:t)[0]){case 0:case 1:a=t;break;case 4:return c.label++,{value:t[1],done:!1};case 5:c.label++,s=t[1],t=[0];continue;case 7:t=c.ops.pop(),c.trys.pop();continue;default:if(!((a=0<(a=c.trys).length&&a[a.length-1])||6!==t[0]&&2!==t[0])){c=0;continue}if(3===t[0]&&(!a||t[1]>a[0]&&t[1]<a[3]))c.label=t[1];else if(6===t[0]&&c.label<a[1])c.label=a[1],a=t;else{if(!(a&&c.label<a[2])){a[2]&&c.ops.pop(),c.trys.pop();continue}c.label=a[2],c.ops.push(t)}}t=o.call(n,c)}catch(e){t=[6,e],s=0}finally{i=a=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}}}function N(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return{value:(e=e&&n>=e.length?void 0:e)&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function A(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),s=[];try{for(;(void 0===t||0<t--)&&!(n=i.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function b(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||((n=n||Array.prototype.slice.call(t,0,o))[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}var H="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==ka?ka:"undefined"!=typeof self?self:{};var M,Y,K,z,G,l={exports:{}},X=(f=l,h=H,Y=Math.pow(2,-24),K=Math.pow(2,32),z=Math.pow(2,53),t={encode:function(e){var s,a=new ArrayBuffer(256),c=new DataView(a),u=0;function d(e){for(var t=a.byteLength,r=u+e;t<r;)t*=2;if(t!==a.byteLength){var n=c;a=new ArrayBuffer(t),c=new DataView(a);for(var o=u+3>>2,i=0;i<o;++i)c.setUint32(4*i,n.getUint32(4*i))}return s=e,c}function p(){u+=s}function l(e){p(d(1).setUint8(u,e))}function f(e){for(var t=d(e.length),r=0;r<e.length;++r)t.setUint8(u+r,e[r]);p()}function h(e,t){var r,n;t<24?l(e<<5|t):t<256?(l(e<<5|24),l(t)):t<65536?(l(e<<5|25),n=t,p(d(2).setUint16(u,n))):t<4294967296?(l(e<<5|26),n=t,p(d(4).setUint32(u,n))):(l(e<<5|27),t=(t-(e=t%K))/K,(r=d(8)).setUint32(u,t),r.setUint32(u+4,e),p())}if(function e(t){var r,n;if(!1===t)return l(244);if(!0===t)return l(245);if(null===t)return l(246);if(t===M)return l(247);switch(typeof t){case"number":if(Math.floor(t)===t){if(0<=t&&t<=z)return h(0,t);if(-z<=t&&t<0)return h(1,-(t+1))}return l(251),n=t,p(d(8).setFloat64(u,n));case"string":for(var o=[],i=0;i<t.length;++i){var s=t.charCodeAt(i);s<128?o.push(s):(s<2048?o.push(192|s>>6):(s<55296?o.push(224|s>>12):(s=(1023&s)<<10,s|=1023&t.charCodeAt(++i),o.push(240|(s+=65536)>>18),o.push(128|s>>12&63)),o.push(128|s>>6&63)),o.push(128|63&s))}return h(3,o.length),f(o);default:if(Array.isArray(t))for(h(4,r=t.length),i=0;i<r;++i)e(t[i]);else if(t instanceof Uint8Array)h(2,t.length),f(t);else{var a=Object.keys(t);for(h(5,r=a.length),i=0;i<r;++i){var c=a[i];e(c),e(t[c])}}}}(e),"slice"in a)return a.slice(0,u);for(var e=new ArrayBuffer(u),t=new DataView(e),r=0;r<u;++r)t.setUint8(r,c.getUint8(r));return e},decode:function(t,y,m){var R=new DataView(t),_=0;function A(e,t){return _+=t,e}function b(e){return A(new Uint8Array(t,_,e),e)}function v(){return A(R.getUint8(_),1)}function I(){return A(R.getUint16(_),2)}function r(){return A(R.getUint32(_),4)}function T(){return 255===R.getUint8(_)&&(_+=1,1)}function E(e){if(e<24)return e;if(24===e)return v();if(25===e)return I();if(26===e)return r();if(27===e)return r()*K+r();if(31===e)return-1;throw"Invalid length encoding"}function S(e){var t=v();if(255===t)return-1;var r=E(31&t);if(r<0||t>>5!==e)throw"Invalid indefinite length element";return r}function P(e,t){for(var r=0;r<t;++r){var n=v();128&n&&(n<224?(n=(31&n)<<6|63&v(),--t):n<240?(n=(15&n)<<12|(63&v())<<6|63&v(),t-=2):(n=(15&n)<<18|(63&v())<<12|(63&v())<<6|63&v(),t-=3)),n<65536?e.push(n):(n-=65536,e.push(55296|n>>10),e.push(56320|1023&n))}}"function"!=typeof y&&(y=function(e){return e}),"function"!=typeof m&&(m=function(){return M});var e=function e(){var t,r,n=v(),o=n>>5,n=31&n;if(7==o)switch(n){case 25:var i=new ArrayBuffer(4),i=new DataView(i),s=I(),a=31744&s,c=1023&s;if(31744===a)a=261120;else if(0!==a)a+=114688;else if(0!=c)return c*Y;return i.setUint32(0,(32768&s)<<16|a<<13|c<<13),i.getFloat32(0);case 26:return A(R.getFloat32(_),4);case 27:return A(R.getFloat64(_),8)}if((t=E(n))<0&&(o<2||6<o))throw"Invalid length";switch(o){case 0:return t;case 1:return-1-t;case 2:if(t<0){for(var u=[],d=0;0<=(t=S(o));)d+=t,u.push(b(t));for(var p=new Uint8Array(d),l=0,f=0;f<u.length;++f)p.set(u[f],l),l+=u[f].length;return p}return b(t);case 3:var h=[];if(t<0)for(;0<=(t=S(o));)P(h,t);else P(h,t);return String.fromCharCode.apply(null,h);case 4:if(t<0)for(r=[];!T();)r.push(e());else for(r=new Array(t),f=0;f<t;++f)r[f]=e();return r;case 5:var g={};for(f=0;f<t||t<0&&!T();++f)g[e()]=e();return g;case 6:return y(e(),t);case 7:switch(t){case 20:return!1;case 21:return!0;case 22:return null;case 23:return M;default:return m(t)}}}();if(_!==t.byteLength)throw"Remaining bytes";return e}},f.exports?f.exports=t:h.CBOR||(h.CBOR=t),l.exports),f={exports:{}};function B(){for(var e,t="",r=0;r<32;r++)e=16*Math.random()|0,8!==r&&12!==r&&16!==r&&20!==r||(t+="-"),t+=(12===r?4:16===r?3&e|8:e).toString(16);return t}function V(e,t){t=G[t||"all"];return t&&t.test(e)||!1}l=t=(h=f).exports,G={3:/^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,4:/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,5:/^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,all:/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i},B.isUUID=V,B.VERSION="0.1.0",l.uuid=B,l.isUUID=V,null!==h&&(h.exports=t.uuid);var W=f.exports,J=function(){return W.uuid?W.uuid():W()},$=(e.prototype.getAuthKey=function(){return this.authKey},e.prototype.setAuthKey=function(e){return this.authKey=e,this},e.prototype.setCipherKey=function(e,t,r){return this.cipherKey=e,this.cipherKey&&(this.cryptoModule=null!=(e=t.cryptoModule)?e:t.initCryptoModule({cipherKey:this.cipherKey,useRandomIVs:this.useRandomIVs}),r)&&(r.cryptoModule=this.cryptoModule),this},e.prototype.getUUID=function(){return this.UUID},e.prototype.setUUID=function(e){if(e&&"string"==typeof e&&0!==e.trim().length)return this.UUID=e,this;throw new Error("Missing uuid parameter. Provide a valid string uuid")},e.prototype.getUserId=function(){return this.UUID},e.prototype.setUserId=function(e){if(e&&"string"==typeof e&&0!==e.trim().length)return this.UUID=e,this;throw new Error("Missing or invalid userId parameter. Provide a valid string userId")},e.prototype.getFilterExpression=function(){return this.filterExpression},e.prototype.setFilterExpression=function(e){return this.filterExpression=e,this},e.prototype.getPresenceTimeout=function(){return this._presenceTimeout},e.prototype.setPresenceTimeout=function(e){return 20<=e?this._presenceTimeout=e:(this._presenceTimeout=20,console.log("WARNING: Presence timeout is less than the minimum. Using minimum value: ",this._presenceTimeout)),this.setHeartbeatInterval(this._presenceTimeout/2-1),this},e.prototype.setProxy=function(e){this.proxy=e},e.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},e.prototype.setHeartbeatInterval=function(e){return this._heartbeatInterval=e,this},e.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},e.prototype.setSubscribeTimeout=function(e){return this._subscribeRequestTimeout=e,this},e.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},e.prototype.setTransactionTimeout=function(e){return this._transactionalRequestTimeout=e,this},e.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},e.prototype.setSendBeaconConfig=function(e){return this._useSendBeacon=e,this},e.prototype.getVersion=function(){return"7.5.0"},e.prototype._setRetryConfiguration=function(e){if(e.minimumdelay<2)throw new Error("Minimum delay can not be set less than 2 seconds for retry");if(150<e.maximumDelay)throw new Error("Maximum delay can not be set more than 150 seconds for retry");if(e.maximumDelay&&6<maximumRetry)throw new Error("Maximum retry for exponential retry policy can not be more than 6");if(10<e.maximumRetry)throw new Error("Maximum retry for linear retry policy can not be more than 10");this.retryConfiguration=e},e.prototype._addPnsdkSuffix=function(e,t){this._PNSDKSuffix[e]=t},e.prototype._getPnsdkSuffix=function(r){var n=this;return Object.keys(this._PNSDKSuffix).reduce(function(e,t){return e+r+n._PNSDKSuffix[t]},"")},e);function e(e){var t,e=e.setup;if(this._PNSDKSuffix={},this.instanceId="pn-".concat(J()),this.secretKey=e.secretKey||e.secret_key,this.subscribeKey=e.subscribeKey||e.subscribe_key,this.publishKey=e.publishKey||e.publish_key,this.sdkName=e.sdkName,this.sdkFamily=e.sdkFamily,this.partnerId=e.partnerId,this.setAuthKey(e.authKey),this.cryptoModule=e.cryptoModule,this.setFilterExpression(e.filterExpression),"string"!=typeof e.origin&&!Array.isArray(e.origin)&&void 0!==e.origin)throw new Error("Origin must be either undefined, a string or a list of strings.");if(this.origin=e.origin||Array.from({length:20},function(e,t){return"ps".concat(t+1,".pndsn.com")}),this.secure=e.ssl||!1,this.restore=e.restore||!1,this.proxy=e.proxy,this.keepAlive=e.keepAlive,this.keepAliveSettings=e.keepAliveSettings,this.autoNetworkDetection=e.autoNetworkDetection||!1,this.dedupeOnSubscribe=e.dedupeOnSubscribe||!1,this.maximumCacheSize=e.maximumCacheSize||100,this.customEncrypt=e.customEncrypt,this.customDecrypt=e.customDecrypt,this.fileUploadPublishRetryLimit=null!=(t=e.fileUploadPublishRetryLimit)?t:5,this.useRandomIVs=null==(t=e.useRandomIVs)||t,this.enableEventEngine=null!=(t=e.enableEventEngine)&&t,this.maintainPresenceState=null==(t=e.maintainPresenceState)||t,"undefined"!=typeof location&&"https:"===location.protocol&&(this.secure=!0),this.logVerbosity=e.logVerbosity||!1,this.suppressLeaveEvents=e.suppressLeaveEvents||!1,this.announceFailedHeartbeats=e.announceFailedHeartbeats||!0,this.announceSuccessfulHeartbeats=e.announceSuccessfulHeartbeats||!1,this.useInstanceId=e.useInstanceId||!1,this.useRequestId=e.useRequestId||!1,this.requestMessageCountThreshold=e.requestMessageCountThreshold,e.retryConfiguration&&this._setRetryConfiguration(e.retryConfiguration),this.setTransactionTimeout(e.transactionalRequestTimeout||15e3),this.setSubscribeTimeout(e.subscribeRequestTimeout||31e4),this.setSendBeaconConfig(e.useSendBeacon||!0),e.presenceTimeout?this.setPresenceTimeout(e.presenceTimeout):this._presenceTimeout=300,null!=e.heartbeatInterval&&this.setHeartbeatInterval(e.heartbeatInterval),"string"==typeof e.userId){if("string"==typeof e.uuid)throw new Error("Only one of the following configuration options has to be provided: `uuid` or `userId`");this.setUserId(e.userId)}else{if("string"!=typeof e.uuid)throw new Error("One of the following configuration options has to be provided: `uuid` or `userId`");this.setUUID(e.uuid)}this.setCipherKey(e.cipherKey,e)}function Q(e){var t=e.replace(/==?$/,""),r=Math.floor(t.length/4*3),e=new ArrayBuffer(r),n=new Uint8Array(e),o=0;function i(){var e=t.charAt(o++),e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(e);if(-1===e)throw new Error("Illegal character at ".concat(o,": ").concat(t.charAt(o-1)));return e}for(var s=0;s<r;s+=3){var a=i(),c=i(),u=i(),d=i(),p=(15&c)<<4|u>>2,l=(3&u)<<6|d>>0;n[s]=(63&a)<<2|c>>4,64!=u&&(n[s+1]=p),64!=d&&(n[s+2]=l)}return e}function Z(e){for(var t,r="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=new Uint8Array(e),e=o.byteLength,i=e%3,s=e-i,a=0;a<s;a+=3)r+=n[(16515072&(t=o[a]<<16|o[a+1]<<8|o[a+2]))>>18]+n[(258048&t)>>12]+n[(4032&t)>>6]+n[63&t];return 1==i?r+=n[(252&(t=o[s]))>>2]+n[(3&t)<<4]+"==":2==i&&(r+=n[(64512&(t=o[s]<<8|o[1+s]))>>10]+n[(1008&t)>>4]+n[(15&t)<<2]+"="),r}re=Math,h=(l={}).lib={},ne=h.Base={extend:function(e){Ae.prototype=this;var t=new Ae;return e&&t.mixIn(e),t.hasOwnProperty("init")||(t.init=function(){t.$super.init.apply(this,arguments)}),(t.init.prototype=t).$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},oe=h.WordArray=ne.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||ie).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes;if(e=e.sigBytes,this.clamp(),n%4)for(var o=0;o<e;o++)t[n+o>>>2]|=(r[o>>>2]>>>24-o%4*8&255)<<24-(n+o)%4*8;else if(65535<r.length)for(o=0;o<e;o+=4)t[n+o>>>2]=r[o>>>2];else t.push.apply(t,r);return this.sigBytes+=e,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=re.ceil(t/4)},clone:function(){var e=ne.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(4294967296*re.random()|0);return new oe.init(t,e)}}),t=l.enc={},ie=t.Hex={stringify:function(e){var t=e.words;e=e.sigBytes;for(var r=[],n=0;n<e;n++){var o=t[n>>>2]>>>24-n%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new oe.init(r,t/2)}},se=t.Latin1={stringify:function(e){var t=e.words;e=e.sigBytes;for(var r=[],n=0;n<e;n++)r.push(String.fromCharCode(t[n>>>2]>>>24-n%4*8&255));return r.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new oe.init(r,t)}},ae=t.Utf8={stringify:function(e){try{return decodeURIComponent(escape(se.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return se.parse(unescape(encodeURIComponent(e)))}},ce=h.BufferedBlockAlgorithm=ne.extend({reset:function(){this._data=new oe.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=ae.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t=this._data,r=t.words,n=t.sigBytes,o=this.blockSize,i=n/(4*o);if(e=(e?re.ceil(i):re.max((0|i)-this._minBufferSize,0))*o,n=re.min(4*e,n),e){for(var s=0;s<e;s+=o)this._doProcessBlock(r,s);s=r.splice(0,e),t.sigBytes-=n}return new oe.init(s,n)},clone:function(){var e=ne.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),h.Hasher=ce.extend({cfg:ne.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){ce.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(r){return function(e,t){return new r.init(t).finalize(e)}},_createHmacHelper:function(r){return function(e,t){return new ue.HMAC.init(r,t).finalize(e)}}}),ue=l.algo={};var ee,te,re,ne,oe,ie,se,ae,ce,ue,de,pe,le,fe,he,ge,ye,me,Re,_e,f=l;function Ae(){}for(var be=Math,t=f,ve=(h=t.lib).WordArray,Ie=h.Hasher,h=t.algo,Te=[],Ee=[],Se=function(e){return 4294967296*(e-(0|e))|0},Pe=2,Oe=0;Oe<64;){e:{for(var we=Pe,Ue=be.sqrt(we),ke=2;ke<=Ue;ke++)if(!(we%ke)){we=!1;break e}we=!0}we&&(Oe<8&&(Te[Oe]=Se(be.pow(Pe,.5))),Ee[Oe]=Se(be.pow(Pe,1/3)),Oe++),Pe++}var je=[],h=h.SHA256=Ie.extend({_doReset:function(){this._hash=new ve.init(Te.slice(0))},_doProcessBlock:function(e,t){for(var r,n,o=this._hash.words,i=o[0],s=o[1],a=o[2],c=o[3],u=o[4],d=o[5],p=o[6],l=o[7],f=0;f<64;f++)je[f]=f<16?0|e[t+f]:(((r=je[f-15])<<25|r>>>7)^(r<<14|r>>>18)^r>>>3)+je[f-7]+(((n=je[f-2])<<15|n>>>17)^(n<<13|n>>>19)^n>>>10)+je[f-16],r=l+((u<<26|u>>>6)^(u<<21|u>>>11)^(u<<7|u>>>25))+(u&d^~u&p)+Ee[f]+je[f],n=((i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22))+(i&s^i&a^s&a),l=p,p=d,d=u,u=c+r|0,c=a,a=s,s=i,i=r+n|0;o[0]=o[0]+i|0,o[1]=o[1]+s|0,o[2]=o[2]+a|0,o[3]=o[3]+c|0,o[4]=o[4]+u|0,o[5]=o[5]+d|0,o[6]=o[6]+p|0,o[7]=o[7]+l|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(64+n>>>9<<4)]=be.floor(r/4294967296),t[15+(64+n>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=Ie.clone.call(this);return e._hash=this._hash.clone(),e}}),Ce=(t.SHA256=Ie._createHelper(h),t.HmacSHA256=Ie._createHmacHelper(h),ee=(l=f).enc.Utf8,l.algo.HMAC=l.lib.Base.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=ee.parse(t));var r=e.blockSize,n=4*r;(t=t.sigBytes>n?e.finalize(t):t).clamp();for(var e=this._oKey=t.clone(),t=this._iKey=t.clone(),o=e.words,i=t.words,s=0;s<r;s++)o[s]^=1549556828,i[s]^=909522486;e.sigBytes=t.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher;return e=t.finalize(e),t.reset(),t.finalize(this._oKey.clone().concat(e))}}),te=f.lib.WordArray,f.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp(),e=[];for(var o=0;o<r;o+=3)for(var i=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,s=0;s<4&&o+.75*s<r;s++)e.push(n.charAt(i>>>6*(3-s)&63));if(t=n.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var t=e.length,r=this._map;(i=r.charAt(64))&&-1!=(i=e.indexOf(i))&&(t=i);for(var n,o,i=[],s=0,a=0;a<t;a++)a%4&&(n=r.indexOf(e.charAt(a-1))<<a%4*2,o=r.indexOf(e.charAt(a))>>>6-a%4*2,i[s>>>2]|=(n|o)<<24-s%4*8,s++);return te.create(i,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},Math);function I(e,t,r,n,o,i,s){return((e=e+(t&r|~t&n)+o+s)<<i|e>>>32-i)+t}function T(e,t,r,n,o,i,s){return((e=e+(t&n|r&~n)+o+s)<<i|e>>>32-i)+t}function E(e,t,r,n,o,i,s){return((e=e+(t^r^n)+o+s)<<i|e>>>32-i)+t}function S(e,t,r,n,o,i,s){return((e=e+(r^(t|~n))+o+s)<<i|e>>>32-i)+t}for(var t=f,xe=(h=t.lib).WordArray,De=h.Hasher,h=t.algo,P=[],Le=0;Le<64;Le++)P[Le]=4294967296*Ce.abs(Ce.sin(Le+1))|0;h=h.MD5=De.extend({_doReset:function(){this._hash=new xe.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=e[o=t+r];e[o]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var r=this._hash.words,o=e[t+0],i=e[t+2],s=e[t+3],a=e[t+4],c=e[t+5],u=e[t+6],d=e[t+7],p=e[t+8],l=e[t+9],f=e[t+10],h=e[t+11],g=e[t+12],y=e[t+13],m=e[t+14],R=e[t+15],_=I(r[0],v=r[1],b=r[2],A=r[3],o,7,P[0]),A=I(A,_,v,b,n=e[t+1],12,P[1]),b=I(b,A,_,v,i,17,P[2]),v=I(v,b,A,_,s,22,P[3]),_=I(_,v,b,A,a,7,P[4]),A=I(A,_,v,b,c,12,P[5]),b=I(b,A,_,v,u,17,P[6]),v=I(v,b,A,_,d,22,P[7]);_=I(_,v,b,A,p,7,P[8]),A=I(A,_,v,b,l,12,P[9]),b=I(b,A,_,v,f,17,P[10]),v=I(v,b,A,_,h,22,P[11]),_=I(_,v,b,A,g,7,P[12]),A=I(A,_,v,b,y,12,P[13]),b=I(b,A,_,v,m,17,P[14]),_=T(_,v=I(v,b,A,_,R,22,P[15]),b,A,n,5,P[16]),A=T(A,_,v,b,u,9,P[17]),b=T(b,A,_,v,h,14,P[18]),v=T(v,b,A,_,o,20,P[19]),_=T(_,v,b,A,c,5,P[20]),A=T(A,_,v,b,f,9,P[21]),b=T(b,A,_,v,R,14,P[22]),v=T(v,b,A,_,a,20,P[23]),_=T(_,v,b,A,l,5,P[24]),A=T(A,_,v,b,m,9,P[25]),b=T(b,A,_,v,s,14,P[26]),v=T(v,b,A,_,p,20,P[27]),_=T(_,v,b,A,y,5,P[28]),A=T(A,_,v,b,i,9,P[29]),b=T(b,A,_,v,d,14,P[30]),_=E(_,v=T(v,b,A,_,g,20,P[31]),b,A,c,4,P[32]),A=E(A,_,v,b,p,11,P[33]),b=E(b,A,_,v,h,16,P[34]),v=E(v,b,A,_,m,23,P[35]),_=E(_,v,b,A,n,4,P[36]),A=E(A,_,v,b,a,11,P[37]),b=E(b,A,_,v,d,16,P[38]),v=E(v,b,A,_,f,23,P[39]),_=E(_,v,b,A,y,4,P[40]),A=E(A,_,v,b,o,11,P[41]),b=E(b,A,_,v,s,16,P[42]),v=E(v,b,A,_,u,23,P[43]),_=E(_,v,b,A,l,4,P[44]),A=E(A,_,v,b,g,11,P[45]),b=E(b,A,_,v,R,16,P[46]),_=S(_,v=E(v,b,A,_,i,23,P[47]),b,A,o,6,P[48]),A=S(A,_,v,b,d,10,P[49]),b=S(b,A,_,v,m,15,P[50]),v=S(v,b,A,_,c,21,P[51]),_=S(_,v,b,A,g,6,P[52]),A=S(A,_,v,b,s,10,P[53]),b=S(b,A,_,v,f,15,P[54]),v=S(v,b,A,_,n,21,P[55]),_=S(_,v,b,A,p,6,P[56]),A=S(A,_,v,b,R,10,P[57]),b=S(b,A,_,v,u,15,P[58]),v=S(v,b,A,_,y,21,P[59]),_=S(_,v,b,A,a,6,P[60]),A=S(A,_,v,b,h,10,P[61]),b=S(b,A,_,v,i,15,P[62]),v=S(v,b,A,_,l,21,P[63]),r[0]=r[0]+_|0,r[1]=r[1]+v|0,r[2]=r[2]+b|0,r[3]=r[3]+A|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes,o=(t[n>>>5]|=128<<24-n%32,Ce.floor(r/4294967296));for(t[15+(64+n>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),t[14+(64+n>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),e.sigBytes=4*(t.length+1),this._process(),t=(e=this._hash).words,r=0;r<4;r++)n=t[r],t[r]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8);return e},clone:function(){var e=De.clone.call(this);return e._hash=this._hash.clone(),e}}),t.MD5=De._createHelper(h),t.HmacMD5=De._createHmacHelper(h),h=(t=(l=f).lib).Base,Re=t.WordArray,_e=(t=l.algo).EvpKDF=h.extend({cfg:h.extend({keySize:4,hasher:t.MD5,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r=(s=this.cfg).hasher.create(),n=Re.create(),o=n.words,i=s.keySize,s=s.iterations;o.length<i;){a&&r.update(a);var a=r.update(e).finalize(t);r.reset();for(var c=1;c<s;c++)a=r.finalize(a),r.reset();n.concat(a)}return n.sigBytes=4*i,n}}),l.EvpKDF=function(e,t,r){return _e.create(r).compute(e,t)},f.lib.Cipher||(t=(h=f).lib,l=t.Base,de=t.WordArray,pe=t.BufferedBlockAlgorithm,le=h.enc.Base64,fe=h.algo.EvpKDF,he=t.Cipher=pe.extend({cfg:l.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){pe.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(n){return{encrypt:function(e,t,r){return("string"==typeof t?me:ye).encrypt(n,e,t,r)},decrypt:function(e,t,r){return("string"==typeof t?me:ye).decrypt(n,e,t,r)}}}}),t.StreamCipher=he.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),He=h.mode={},(Ne=(t.BlockCipherMode=l.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}})).extend()).Encryptor=Ne.extend({processBlock:function(e,t){var r=this._cipher,n=r.blockSize;it.call(this,e,t,n),r.encryptBlock(e,t),this._prevBlock=e.slice(t,t+n)}}),Ne.Decryptor=Ne.extend({processBlock:function(e,t){var r=this._cipher,n=r.blockSize,o=e.slice(t,t+n);r.decryptBlock(e,t),it.call(this,e,t,n),this._prevBlock=o}}),He=He.CBC=Ne,Ne=(h.pad={}).Pkcs7={pad:function(e,t){for(var r,n=(r=(r=4*t)-e.sigBytes%r)<<24|r<<16|r<<8|r,o=[],i=0;i<r;i+=4)o.push(n);r=de.create(o,r),e.concat(r)},unpad:function(e){e.sigBytes-=255&e.words[e.sigBytes-1>>>2]}},t.BlockCipher=he.extend({cfg:he.cfg.extend({mode:He,padding:Ne}),reset:function(){he.reset.call(this);var e,t=(r=this.cfg).iv,r=r.mode;this._xformMode==this._ENC_XFORM_MODE?e=r.createEncryptor:(e=r.createDecryptor,this._minBufferSize=1),this._mode=e.call(r,this,t&&t.words)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4}),ge=t.CipherParams=l.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),He=(h.format={}).OpenSSL={stringify:function(e){var t=e.ciphertext;return((e=e.salt)?de.create([1398893684,1701076831]).concat(e).concat(t):t).toString(le)},parse:function(e){var t,r=(e=le.parse(e)).words;return 1398893684==r[0]&&1701076831==r[1]&&(t=de.create(r.slice(2,4)),r.splice(0,4),e.sigBytes-=16),ge.create({ciphertext:e,salt:t})}},ye=t.SerializableCipher=l.extend({cfg:l.extend({format:He}),encrypt:function(e,t,r,n){n=this.cfg.extend(n);var o=e.createEncryptor(r,n);return t=o.finalize(t),o=o.cfg,ge.create({ciphertext:t,key:r,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(r,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),h=(h.kdf={}).OpenSSL={execute:function(e,t,r,n){return n=n||de.random(8),e=fe.create({keySize:t+r}).compute(e,n),r=de.create(e.words.slice(t),4*r),e.sigBytes=4*t,ge.create({key:e,iv:r,salt:n})}},me=t.PasswordBasedCipher=ye.extend({cfg:ye.cfg.extend({kdf:h}),encrypt:function(e,t,r,n){return r=(n=this.cfg.extend(n)).kdf.execute(r,e.keySize,e.ivSize),n.iv=r.iv,(e=ye.encrypt.call(this,e,t,r.key,n)).mixIn(r),e},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),r=n.kdf.execute(r,e.keySize,e.ivSize,t.salt),n.iv=r.iv,ye.decrypt.call(this,e,t,r.key,n)}}));for(var Ne=f,l=Ne.lib.BlockCipher,He=Ne.algo,Me=[],Fe=[],qe=[],Ye=[],Ke=[],ze=[],Ge=[],Xe=[],Be=[],Ve=[],We=[],Je=0;Je<256;Je++)We[Je]=Je<128?Je<<1:Je<<1^283;for(var $e=0,Qe=0,Je=0;Je<256;Je++){var Ze=(Ze=Qe^Qe<<1^Qe<<2^Qe<<3^Qe<<4)>>>8^255&Ze^99,et=We[Fe[Me[$e]=Ze]=$e],tt=We[et],rt=We[tt],nt=257*We[Ze]^16843008*Ze;qe[$e]=nt<<24|nt>>>8,Ye[$e]=nt<<16|nt>>>16,Ke[$e]=nt<<8|nt>>>24,ze[$e]=nt,Ge[Ze]=(nt=16843009*rt^65537*tt^257*et^16843008*$e)<<24|nt>>>8,Xe[Ze]=nt<<16|nt>>>16,Be[Ze]=nt<<8|nt>>>24,Ve[Ze]=nt,$e?($e=et^We[We[We[rt^et]]],Qe^=We[We[Qe]]):$e=Qe=1}var ot=[0,1,2,4,8,16,32,64,128,27,54],He=He.AES=l.extend({_doReset:function(){for(var e,t=(n=this._key).words,r=n.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],i=0;i<n;i++)i<r?o[i]=t[i]:(e=o[i-1],i%r?6<r&&4==i%r&&(e=Me[e>>>24]<<24|Me[e>>>16&255]<<16|Me[e>>>8&255]<<8|Me[255&e]):(e=Me[(e=e<<8|e>>>24)>>>24]<<24|Me[e>>>16&255]<<16|Me[e>>>8&255]<<8|Me[255&e],e^=ot[i/r|0]<<24),o[i]=o[i-r]^e);for(t=this._invKeySchedule=[],r=0;r<n;r++)i=n-r,e=r%4?o[i]:o[i-4],t[r]=r<4||i<=4?e:Ge[Me[e>>>24]]^Xe[Me[e>>>16&255]]^Be[Me[e>>>8&255]]^Ve[Me[255&e]]},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,qe,Ye,Ke,ze,Me)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,Ge,Xe,Be,Ve,Fe),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,n,o,i,s,a){for(var c=this._nRounds,u=e[t]^r[0],d=e[t+1]^r[1],p=e[t+2]^r[2],l=e[t+3]^r[3],f=4,h=1;h<c;h++)var g=n[u>>>24]^o[d>>>16&255]^i[p>>>8&255]^s[255&l]^r[f++],y=n[d>>>24]^o[p>>>16&255]^i[l>>>8&255]^s[255&u]^r[f++],m=n[p>>>24]^o[l>>>16&255]^i[u>>>8&255]^s[255&d]^r[f++],l=n[l>>>24]^o[u>>>16&255]^i[d>>>8&255]^s[255&p]^r[f++],u=g,d=y,p=m;g=(a[u>>>24]<<24|a[d>>>16&255]<<16|a[p>>>8&255]<<8|a[255&l])^r[f++],y=(a[d>>>24]<<24|a[p>>>16&255]<<16|a[l>>>8&255]<<8|a[255&u])^r[f++],m=(a[p>>>24]<<24|a[l>>>16&255]<<16|a[u>>>8&255]<<8|a[255&d])^r[f++],l=(a[l>>>24]<<24|a[u>>>16&255]<<16|a[d>>>8&255]<<8|a[255&p])^r[f++],e[t]=g,e[t+1]=y,e[t+2]=m,e[t+3]=l},keySize:8});function it(e,t,r){var n=this._iv;n?this._iv=void 0:n=this._prevBlock;for(var o=0;o<r;o++)e[t+o]^=n[o]}Ne.AES=l._createHelper(He),f.mode.ECB=((t=f.lib.BlockCipherMode.extend()).Encryptor=t.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),t.Decryptor=t.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),t);var c=f;function st(e){for(var t=[],r=0;r<e.length;r+=1)t[r/4|0]|=e[r]<<24-8*r;return c.lib.WordArray.create(t,e.length)}lt.prototype.HMACSHA256=function(e){return c.HmacSHA256(e,this._config.secretKey).toString(c.enc.Base64)},lt.prototype.SHA256=function(e){return c.SHA256(e).toString(c.enc.Hex)},lt.prototype._parseOptions=function(e){e=e||{};return e.hasOwnProperty("encryptKey")||(e.encryptKey=this._defaultOptions.encryptKey),e.hasOwnProperty("keyEncoding")||(e.keyEncoding=this._defaultOptions.keyEncoding),e.hasOwnProperty("keyLength")||(e.keyLength=this._defaultOptions.keyLength),e.hasOwnProperty("mode")||(e.mode=this._defaultOptions.mode),-1===this._allowedKeyEncodings.indexOf(e.keyEncoding.toLowerCase())&&(e.keyEncoding=this._defaultOptions.keyEncoding),-1===this._allowedKeyLengths.indexOf(parseInt(e.keyLength,10))&&(e.keyLength=this._defaultOptions.keyLength),-1===this._allowedModes.indexOf(e.mode.toLowerCase())&&(e.mode=this._defaultOptions.mode),e},lt.prototype._decodeKey=function(e,t){return"base64"===t.keyEncoding?c.enc.Base64.parse(e):"hex"===t.keyEncoding?c.enc.Hex.parse(e):e},lt.prototype._getPaddedKey=function(e,t){return e=this._decodeKey(e,t),t.encryptKey?c.enc.Utf8.parse(this.SHA256(e).slice(0,32)):e},lt.prototype._getMode=function(e){return"ecb"===e.mode?c.mode.ECB:c.mode.CBC},lt.prototype._getIV=function(e){return"cbc"===e.mode?c.enc.Utf8.parse(this._iv):null},lt.prototype._getRandomIV=function(){return c.lib.WordArray.random(16)},lt.prototype.encrypt=function(e,t,r){return this._config.customEncrypt?this._config.customEncrypt(e):this.pnEncrypt(e,t,r)},lt.prototype.decrypt=function(e,t,r){return this._config.customDecrypt?this._config.customDecrypt(e):this.pnDecrypt(e,t,r)},lt.prototype.pnEncrypt=function(e,t,r){if(!t&&!this._config.cipherKey)return e;r=this._parseOptions(r);var n,o,i=this._getMode(r),t=this._getPaddedKey(t||this._config.cipherKey,r);return this._config.useRandomIVs?(o=this._getRandomIV(),n=c.AES.encrypt(e,t,{iv:o,mode:i}).ciphertext,o.clone().concat(n.clone()).toString(c.enc.Base64)):(o=this._getIV(r),c.AES.encrypt(e,t,{iv:o,mode:i}).ciphertext.toString(c.enc.Base64)||e)},lt.prototype.pnDecrypt=function(e,t,r){if(!t&&!this._config.cipherKey)return e;r=this._parseOptions(r);var n=this._getMode(r),t=this._getPaddedKey(t||this._config.cipherKey,r);if(this._config.useRandomIVs){var o=st((a=new Uint8ClampedArray(Q(e))).slice(0,16)),i=st(a.slice(16));try{var s=c.AES.decrypt({ciphertext:i},t,{iv:o,mode:n}).toString(c.enc.Utf8);return JSON.parse(s)}catch(e){return null}}else{o=this._getIV(r);try{var a=c.enc.Base64.parse(e),s=c.AES.decrypt({ciphertext:a},t,{iv:o,mode:n}).toString(c.enc.Utf8);return JSON.parse(s)}catch(e){return null}}};var at=lt,ct=(pt.prototype.onReconnection=function(e){this._reconnectionCallback=e},pt.prototype.startPolling=function(){this._timeTimer=setInterval(this._performTimeLoop.bind(this),3e3)},pt.prototype.stopPolling=function(){clearInterval(this._timeTimer)},pt.prototype._performTimeLoop=function(){var t=this;this._timeEndpoint(function(e){e.error||(clearInterval(t._timeTimer),t._reconnectionCallback())})},pt),ut=(dt.prototype.getKey=function(e){var t=(e=>{var t=0;if(0!==e.length)for(var r=0;r<e.length;r+=1)t=(t<<5)-t+e.charCodeAt(r),t&=t;return t})(JSON.stringify(e.payload)).toString(),e=e.publishMetaData.publishTimetoken;return"".concat(e,"-").concat(t)},dt.prototype.isDuplicate=function(e){return this.hashHistory.includes(this.getKey(e))},dt.prototype.addEntry=function(e){this.hashHistory.length>=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))},dt.prototype.clearHistory=function(){this.hashHistory=[]},dt);function dt(e){e=e.config;this.hashHistory=[],this._config=e}function pt(e){e=e.timeEndpoint;this._timeEndpoint=e}function lt(e){e=e.config;this._config=e,this._iv="0123456789012345",this._allowedKeyEncodings=["hex","utf8","base64","binary"],this._allowedKeyLengths=[128,256],this._allowedModes=["ecb","cbc"],this._defaultOptions={encryptKey:!0,keyEncoding:"utf8",keyLength:256,mode:"cbc"}}function ft(e){return encodeURIComponent(e).replace(/[!~*'()]/g,function(e){return"%".concat(e.charCodeAt(0).toString(16).toUpperCase())})}var ht,gt,yt,mt,m={signPamFromParams:function(t){return e=t,r=[],Object.keys(e).forEach(function(e){return r.push(e)}),r.sort().map(function(e){return"".concat(e,"=").concat(ft(t[e]))}).join("&");var e,r},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var r,n;return{promise:new Promise(function(e,t){r=e,n=t}),reject:n,fulfill:r}},encodeString:ft,stringToArrayBuffer:function(e){for(var t=new ArrayBuffer(2*e.length),r=new Uint16Array(t),n=0,o=e.length;n<o;n++)r[n]=e.charCodeAt(n);return t}},v={PNNetworkUpCategory:"PNNetworkUpCategory",PNNetworkDownCategory:"PNNetworkDownCategory",PNNetworkIssuesCategory:"PNNetworkIssuesCategory",PNTimeoutCategory:"PNTimeoutCategory",PNBadRequestCategory:"PNBadRequestCategory",PNAccessDeniedCategory:"PNAccessDeniedCategory",PNUnknownCategory:"PNUnknownCategory",PNReconnectedCategory:"PNReconnectedCategory",PNConnectedCategory:"PNConnectedCategory",PNRequestMessageCountExceededCategory:"PNRequestMessageCountExceededCategory",PNDisconnectedCategory:"PNDisconnectedCategory",PNConnectionErrorCategory:"PNConnectionErrorCategory",PNDisconnectedUnexpectedlyCategory:"PNDisconnectedUnexpectedlyCategory"},Rt=(n.prototype.adaptStateChange=function(e,t){var r,n=this,o=e.state,i=e.channels,i=void 0===i?[]:i,s=e.channelGroups,s=void 0===s?[]:s,e=e.withHeartbeat,e=void 0!==e&&e;return i.forEach(function(e){e in n._channels&&(n._channels[e].state=o)}),s.forEach(function(e){e in n._channelGroups&&(n._channelGroups[e].state=o)}),e?(r={},i.forEach(function(e){return r[e]=o}),s.forEach(function(e){return r[e]=o}),this._heartbeatEndpoint({channels:i,channelGroups:s,state:r},t)):this._setStateEndpoint({state:o,channels:i,channelGroups:s},t)},n.prototype.adaptPresenceChange=function(e){var t=this,r=e.connected,n=e.channels,n=void 0===n?[]:n,e=e.channelGroups,e=void 0===e?[]:e;r?(n.forEach(function(e){t._heartbeatChannels[e]={state:{}}}),e.forEach(function(e){t._heartbeatChannelGroups[e]={state:{}}})):(n.forEach(function(e){e in t._heartbeatChannels&&delete t._heartbeatChannels[e]}),e.forEach(function(e){e in t._heartbeatChannelGroups&&delete t._heartbeatChannelGroups[e]}),!1===this._config.suppressLeaveEvents&&this._leaveEndpoint({channels:n,channelGroups:e},function(e){t._listenerManager.announceStatus(e)})),this.reconnect()},n.prototype.adaptSubscribeChange=function(e){var t=this,r=e.timetoken,n=e.channels,n=void 0===n?[]:n,o=e.channelGroups,o=void 0===o?[]:o,i=e.withPresence,s=void 0!==i&&i,i=e.withHeartbeats,a=void 0!==i&&i;this._config.subscribeKey&&""!==this._config.subscribeKey?(r&&(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=r),"0"!==this._currentTimetoken&&0!==this._currentTimetoken&&(this._storedTimetoken=this._currentTimetoken,this._currentTimetoken=0),n.forEach(function(e){t._channels[e]={state:{}},s&&(t._presenceChannels[e]={}),(a||t._config.getHeartbeatInterval())&&(t._heartbeatChannels[e]={}),t._pendingChannelSubscriptions.push(e)}),o.forEach(function(e){t._channelGroups[e]={state:{}},s&&(t._presenceChannelGroups[e]={}),(a||t._config.getHeartbeatInterval())&&(t._heartbeatChannelGroups[e]={}),t._pendingChannelGroupSubscriptions.push(e)}),this._subscriptionStatusAnnounced=!1,this.reconnect()):console&&console.log&&console.log("subscribe key missing; aborting subscribe")},n.prototype.adaptUnsubscribeChange=function(e,t){var r=this,n=e.channels,n=void 0===n?[]:n,e=e.channelGroups,e=void 0===e?[]:e,o=[],i=[];n.forEach(function(e){e in r._channels&&(delete r._channels[e],o.push(e),e in r._heartbeatChannels)&&delete r._heartbeatChannels[e],e in r._presenceChannels&&(delete r._presenceChannels[e],o.push(e))}),e.forEach(function(e){e in r._channelGroups&&(delete r._channelGroups[e],i.push(e),e in r._heartbeatChannelGroups)&&delete r._heartbeatChannelGroups[e],e in r._presenceChannelGroups&&(delete r._presenceChannelGroups[e],i.push(e))}),0===o.length&&0===i.length||(!1!==this._config.suppressLeaveEvents||t||this._leaveEndpoint({channels:o,channelGroups:i},function(e){e.affectedChannels=o,e.affectedChannelGroups=i,e.currentTimetoken=r._currentTimetoken,e.lastTimetoken=r._lastTimetoken,r._listenerManager.announceStatus(e)}),0===Object.keys(this._channels).length&&0===Object.keys(this._presenceChannels).length&&0===Object.keys(this._channelGroups).length&&0===Object.keys(this._presenceChannelGroups).length&&(this._lastTimetoken=0,this._currentTimetoken=0,this._storedTimetoken=null,this._region=null,this._reconnectionManager.stopPolling()),this.reconnect())},n.prototype.unsubscribeAll=function(e){this.adaptUnsubscribeChange({channels:this.getSubscribedChannels(),channelGroups:this.getSubscribedChannelGroups()},e)},n.prototype.getHeartbeatChannels=function(){return Object.keys(this._heartbeatChannels)},n.prototype.getHeartbeatChannelGroups=function(){return Object.keys(this._heartbeatChannelGroups)},n.prototype.getSubscribedChannels=function(){return Object.keys(this._channels)},n.prototype.getSubscribedChannelGroups=function(){return Object.keys(this._channelGroups)},n.prototype.reconnect=function(){this._startSubscribeLoop(),this._registerHeartbeatTimer()},n.prototype.disconnect=function(){this._stopSubscribeLoop(),this._stopHeartbeatTimer(),this._reconnectionManager.stopPolling()},n.prototype._registerHeartbeatTimer=function(){this._stopHeartbeatTimer(),0!==this._config.getHeartbeatInterval()&&void 0!==this._config.getHeartbeatInterval()&&(this._performHeartbeatLoop(),this._heartbeatTimer=setInterval(this._performHeartbeatLoop.bind(this),1e3*this._config.getHeartbeatInterval()))},n.prototype._stopHeartbeatTimer=function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=null)},n.prototype._performHeartbeatLoop=function(){var r=this,e=this.getHeartbeatChannels(),t=this.getHeartbeatChannelGroups(),n={};0===e.length&&0===t.length||(this.getSubscribedChannels().forEach(function(e){var t=r._channels[e].state;Object.keys(t).length&&(n[e]=t)}),this.getSubscribedChannelGroups().forEach(function(e){var t=r._channelGroups[e].state;Object.keys(t).length&&(n[e]=t)}),this._heartbeatEndpoint({channels:e,channelGroups:t,state:n},function(e){e.error&&r._config.announceFailedHeartbeats&&r._listenerManager.announceStatus(e),e.error&&r._config.autoNetworkDetection&&r._isOnline&&(r._isOnline=!1,r.disconnect(),r._listenerManager.announceNetworkDown(),r.reconnect()),!e.error&&r._config.announceSuccessfulHeartbeats&&r._listenerManager.announceStatus(e)}.bind(this)))},n.prototype._startSubscribeLoop=function(){var e,r=this,n=(this._stopSubscribeLoop(),{}),o=[],i=[];Object.keys(this._channels).forEach(function(e){var t=r._channels[e].state;Object.keys(t).length&&(n[e]=t),o.push(e)}),Object.keys(this._presenceChannels).forEach(function(e){o.push("".concat(e,"-pnpres"))}),Object.keys(this._channelGroups).forEach(function(e){var t=r._channelGroups[e].state;Object.keys(t).length&&(n[e]=t),i.push(e)}),Object.keys(this._presenceChannelGroups).forEach(function(e){i.push("".concat(e,"-pnpres"))}),0===o.length&&0===i.length||(e={channels:o,channelGroups:i,state:n,timetoken:this._currentTimetoken,filterExpression:this._config.filterExpression,region:this._region},this._subscribeCall=this._subscribeEndpoint(e,this._processSubscribeResponse.bind(this)))},n.prototype._processSubscribeResponse=function(t,e){var r,n,p,o,l=this;t.error?t.errorData&&"Aborted"===t.errorData.message||(t.category===v.PNTimeoutCategory?this._startSubscribeLoop():(t.category===v.PNNetworkIssuesCategory?(this.disconnect(),t.error&&this._config.autoNetworkDetection&&this._isOnline&&(this._isOnline=!1,this._listenerManager.announceNetworkDown()),this._reconnectionManager.onReconnection(function(){l._config.autoNetworkDetection&&!l._isOnline&&(l._isOnline=!0,l._listenerManager.announceNetworkUp()),l.reconnect(),l._subscriptionStatusAnnounced=!0;var e={category:v.PNReconnectedCategory,operation:t.operation,lastTimetoken:l._lastTimetoken,currentTimetoken:l._currentTimetoken};l._listenerManager.announceStatus(e)}),this._reconnectionManager.startPolling()):t.category===v.PNBadRequestCategory&&this._stopHeartbeatTimer(),this._listenerManager.announceStatus(t))):(this._storedTimetoken?(this._currentTimetoken=this._storedTimetoken,this._storedTimetoken=null):(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=e.metadata.timetoken),this._subscriptionStatusAnnounced||((r={}).category=v.PNConnectedCategory,r.operation=t.operation,r.affectedChannels=this._pendingChannelSubscriptions,r.subscribedChannels=this.getSubscribedChannels(),r.affectedChannelGroups=this._pendingChannelGroupSubscriptions,r.lastTimetoken=this._lastTimetoken,r.currentTimetoken=this._currentTimetoken,this._subscriptionStatusAnnounced=!0,this._listenerManager.announceStatus(r),this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[]),r=e.messages||[],n=(o=this._config).requestMessageCountThreshold,p=o.dedupeOnSubscribe,n&&r.length>=n&&((o={}).category=v.PNRequestMessageCountExceededCategory,o.operation=t.operation,this._listenerManager.announceStatus(o)),r.forEach(function(e){var t,r,n,o,i=e.channel,s=e.subscriptionMatch,a=e.publishMetaData;if(i===s&&(s=null),p){if(l._dedupingManager.isDuplicate(e))return;l._dedupingManager.addEntry(e)}if(m.endsWith(e.channel,"-pnpres"))(o={channel:null,subscription:null}).actualChannel=null!=s?i:null,o.subscribedChannel=null!=s?s:i,i&&(o.channel=i.substring(0,i.lastIndexOf("-pnpres"))),s&&(o.subscription=s.substring(0,s.lastIndexOf("-pnpres"))),o.action=e.payload.action,o.state=e.payload.data,o.timetoken=a.publishTimetoken,o.occupancy=e.payload.occupancy,o.uuid=e.payload.uuid,o.timestamp=e.payload.timestamp,e.payload.join&&(o.join=e.payload.join),e.payload.leave&&(o.leave=e.payload.leave),e.payload.timeout&&(o.timeout=e.payload.timeout),l._listenerManager.announcePresence(o);else if(1===e.messageType)(o={channel:null,subscription:null}).channel=i,o.subscription=s,o.timetoken=a.publishTimetoken,o.publisher=e.issuingClientId,e.userMetadata&&(o.userMetadata=e.userMetadata),o.message=e.payload,l._listenerManager.announceSignal(o);else if(2===e.messageType)(o={channel:null,subscription:null}).channel=i,o.subscription=s,o.timetoken=a.publishTimetoken,o.publisher=e.issuingClientId,e.userMetadata&&(o.userMetadata=e.userMetadata),o.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},l._listenerManager.announceObjects(o),"uuid"===e.payload.type?(t=l._renameChannelField(o),l._listenerManager.announceUser(R(R({},t),{message:R(R({},t.message),{event:l._renameEvent(t.message.event),type:"user"})}))):"channel"===e.payload.type?(t=l._renameChannelField(o),l._listenerManager.announceSpace(R(R({},t),{message:R(R({},t.message),{event:l._renameEvent(t.message.event),type:"space"})}))):"membership"===e.payload.type&&(c=(n=(t=l._renameChannelField(o)).message.data).uuid,r=n.channel,(n=L(n,["uuid","channel"])).user=c,n.space=r,l._listenerManager.announceMembership(R(R({},t),{message:R(R({},t.message),{event:l._renameEvent(t.message.event),data:n})})));else if(3===e.messageType)(o={}).channel=i,o.subscription=s,o.timetoken=a.publishTimetoken,o.publisher=e.issuingClientId,o.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},o.event=e.payload.event,l._listenerManager.announceMessageAction(o);else if(4===e.messageType){(o={}).channel=i,o.subscription=s,o.timetoken=a.publishTimetoken,o.publisher=e.issuingClientId;var c=e.payload;if(l._cryptoModule){var u=void 0;try{u=(d=l._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(l._decoder.decode(d)):d}catch(e){u=null,o.error="Error while decrypting message content: ".concat(e.message)}null!==u&&(c=u)}e.userMetadata&&(o.userMetadata=e.userMetadata),o.message=c.message,o.file={id:c.file.id,name:c.file.name,url:l._getFileUrl({id:c.file.id,name:c.file.name,channel:i})},l._listenerManager.announceFile(o)}else{if((o={channel:null,subscription:null}).actualChannel=null!=s?i:null,o.subscribedChannel=null!=s?s:i,o.channel=i,o.subscription=s,o.timetoken=a.publishTimetoken,o.publisher=e.issuingClientId,e.userMetadata&&(o.userMetadata=e.userMetadata),l._cryptoModule){u=void 0;try{var d,u=(d=l._cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(l._decoder.decode(d)):d}catch(e){u=null,o.error="Error while decrypting message content: ".concat(e.message)}o.message=null!=u?u:e.payload}else o.message=e.payload;l._listenerManager.announceMessage(o)}}),this._region=e.metadata.region,this._startSubscribeLoop())},n.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},n.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},n.prototype._renameChannelField=function(e){var t=e.channel,e=L(e,["channel"]);return e.spaceId=t,e},n),O={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNSignalOperation:"PNSignalOperation",PNAddMessageActionOperation:"PNAddActionOperation",PNRemoveMessageActionOperation:"PNRemoveMessageActionOperation",PNGetMessageActionsOperation:"PNGetMessageActionsOperation",PNCreateUserOperation:"PNCreateUserOperation",PNUpdateUserOperation:"PNUpdateUserOperation",PNDeleteUserOperation:"PNDeleteUserOperation",PNGetUserOperation:"PNGetUsersOperation",PNGetUsersOperation:"PNGetUsersOperation",PNCreateSpaceOperation:"PNCreateSpaceOperation",PNUpdateSpaceOperation:"PNUpdateSpaceOperation",PNDeleteSpaceOperation:"PNDeleteSpaceOperation",PNGetSpaceOperation:"PNGetSpacesOperation",PNGetSpacesOperation:"PNGetSpacesOperation",PNGetMembersOperation:"PNGetMembersOperation",PNUpdateMembersOperation:"PNUpdateMembersOperation",PNGetMembershipsOperation:"PNGetMembershipsOperation",PNUpdateMembershipsOperation:"PNUpdateMembershipsOperation",PNListFilesOperation:"PNListFilesOperation",PNGenerateUploadUrlOperation:"PNGenerateUploadUrlOperation",PNPublishFileOperation:"PNPublishFileOperation",PNGetFileUrlOperation:"PNGetFileUrlOperation",PNDownloadFileOperation:"PNDownloadFileOperation",PNGetAllUUIDMetadataOperation:"PNGetAllUUIDMetadataOperation",PNGetUUIDMetadataOperation:"PNGetUUIDMetadataOperation",PNSetUUIDMetadataOperation:"PNSetUUIDMetadataOperation",PNRemoveUUIDMetadataOperation:"PNRemoveUUIDMetadataOperation",PNGetAllChannelMetadataOperation:"PNGetAllChannelMetadataOperation",PNGetChannelMetadataOperation:"PNGetChannelMetadataOperation",PNSetChannelMetadataOperation:"PNSetChannelMetadataOperation",PNRemoveChannelMetadataOperation:"PNRemoveChannelMetadataOperation",PNSetMembersOperation:"PNSetMembersOperation",PNSetMembershipsOperation:"PNSetMembershipsOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerGrantToken:"PNAccessManagerGrantToken",PNAccessManagerAudit:"PNAccessManagerAudit",PNAccessManagerRevokeToken:"PNAccessManagerRevokeToken",PNHandshakeOperation:"PNHandshakeOperation",PNReceiveMessagesOperation:"PNReceiveMessagesOperation"},_t=(Ct.prototype.operationsLatencyForRequest=function(){var r=this,n={};return Object.keys(this._latencies).forEach(function(e){var t=r._latencies[e],t=r._averageLatency(t);0<t&&(n["l_".concat(e)]=t)}),n},Ct.prototype.startLatencyMeasure=function(e,t){e!==O.PNSubscribeOperation&&t&&(this._trackedLatencies[t]=Date.now())},Ct.prototype.stopLatencyMeasure=function(e,t){var r,n;e!==O.PNSubscribeOperation&&t&&(e=this._endpointName(e),r=this._latencies[e],n=this._trackedLatencies[t],r||(this._latencies[e]=[],r=this._latencies[e]),r.push(Date.now()-n),r.length>this._maximumSamplesCount&&r.splice(0,r.length-this._maximumSamplesCount),delete this._trackedLatencies[t])},Ct.prototype._averageLatency=function(e){return Math.floor(e.reduce(function(e,t){return e+t},0)/e.length)},Ct.prototype._endpointName=function(e){var t=null;switch(e){case O.PNPublishOperation:t="pub";break;case O.PNSignalOperation:t="sig";break;case O.PNHistoryOperation:case O.PNFetchMessagesOperation:case O.PNDeleteMessagesOperation:case O.PNMessageCounts:t="hist";break;case O.PNUnsubscribeOperation:case O.PNWhereNowOperation:case O.PNHereNowOperation:case O.PNHeartbeatOperation:case O.PNSetStateOperation:case O.PNGetStateOperation:t="pres";break;case O.PNAddChannelsToGroupOperation:case O.PNRemoveChannelsFromGroupOperation:case O.PNChannelGroupsOperation:case O.PNRemoveGroupOperation:case O.PNChannelsForGroupOperation:t="cg";break;case O.PNPushNotificationEnabledChannelsOperation:case O.PNRemoveAllPushNotificationsOperation:t="push";break;case O.PNCreateUserOperation:case O.PNUpdateUserOperation:case O.PNDeleteUserOperation:case O.PNGetUserOperation:case O.PNGetUsersOperation:case O.PNCreateSpaceOperation:case O.PNUpdateSpaceOperation:case O.PNDeleteSpaceOperation:case O.PNGetSpaceOperation:case O.PNGetSpacesOperation:case O.PNGetMembersOperation:case O.PNUpdateMembersOperation:case O.PNGetMembershipsOperation:case O.PNUpdateMembershipsOperation:t="obj";break;case O.PNAddMessageActionOperation:case O.PNRemoveMessageActionOperation:case O.PNGetMessageActionsOperation:t="msga";break;case O.PNAccessManagerGrant:case O.PNAccessManagerAudit:t="pam";break;case O.PNAccessManagerGrantToken:case O.PNAccessManagerRevokeToken:t="pamv3";break;default:t="time"}return t},Ct),h=(Object.defineProperty(jt.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(jt.prototype,"title",{set:function(e){this._title=e},enumerable:!1,configurable:!0}),Object.defineProperty(jt.prototype,"subtitle",{set:function(e){this._subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(jt.prototype,"body",{set:function(e){this._body=e},enumerable:!1,configurable:!0}),Object.defineProperty(jt.prototype,"badge",{set:function(e){this._badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(jt.prototype,"sound",{set:function(e){this._sound=e},enumerable:!1,configurable:!0}),jt.prototype._setDefaultPayloadStructure=function(){},jt.prototype.toObject=function(){return{}},jt),At=(D(kt,mt=h),Object.defineProperty(kt.prototype,"configurations",{set:function(e){e&&e.length&&(this._configurations=e)},enumerable:!1,configurable:!0}),Object.defineProperty(kt.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(kt.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.aps.alert.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(kt.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){e&&e.length&&(this._payload.aps.alert.subtitle=e,this._subtitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(kt.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.aps.alert.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(kt.prototype,"badge",{get:function(){return this._badge},set:function(e){null!=e&&(this._payload.aps.badge=e,this._badge=e)},enumerable:!1,configurable:!0}),Object.defineProperty(kt.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.aps.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(kt.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),kt.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},kt.prototype.toObject=function(){var t=this,e=R({},this._payload),r=e.aps,n=r.alert;if(this._isSilent&&(r["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var o=[];this._configurations.forEach(function(e){o.push(t._objectFromAPNS2Configuration(e))}),o.length&&(e.pn_push=o)}return n&&Object.keys(n).length||delete r.alert,this._isSilent&&(delete r.alert,delete r.badge,delete r.sound,n={}),this._isSilent||Object.keys(n).length?e:null},kt.prototype._objectFromAPNS2Configuration=function(e){var t,r,n,o=this;if(e.targets&&e.targets.length)return t=[],e.targets.forEach(function(e){t.push(o._objectFromAPNSTarget(e))}),r=e.collapseId,e=e.expirationDate,n={auth_method:"token",targets:t,version:"v2"},r&&r.length&&(n.collapse_id=r),e&&(n.expiration=e.toISOString()),n;throw new ReferenceError("At least one APNS2 target should be provided")},kt.prototype._objectFromAPNSTarget=function(e){var t;if(e.topic&&e.topic.length)return t={topic:e.topic,environment:void 0===(t=e.environment)?"development":t},(e=void 0===(e=e.excludedDevices)?[]:e).length&&(t.excluded_devices=e),t;throw new TypeError("Target 'topic' undefined.")},kt),bt=(D(Ut,yt=h),Object.defineProperty(Ut.prototype,"backContent",{get:function(){return this._backContent},set:function(e){e&&e.length&&(this._payload.back_content=e,this._backContent=e)},enumerable:!1,configurable:!0}),Object.defineProperty(Ut.prototype,"backTitle",{get:function(){return this._backTitle},set:function(e){e&&e.length&&(this._payload.back_title=e,this._backTitle=e)},enumerable:!1,configurable:!0}),Object.defineProperty(Ut.prototype,"count",{get:function(){return this._count},set:function(e){null!=e&&(this._payload.count=e,this._count=e)},enumerable:!1,configurable:!0}),Object.defineProperty(Ut.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(Ut.prototype,"type",{get:function(){return this._type},set:function(e){e&&e.length&&(this._payload.type=e,this._type=e)},enumerable:!1,configurable:!0}),Object.defineProperty(Ut.prototype,"subtitle",{get:function(){return this.backTitle},set:function(e){this.backTitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(Ut.prototype,"body",{get:function(){return this.backContent},set:function(e){this.backContent=e},enumerable:!1,configurable:!0}),Object.defineProperty(Ut.prototype,"badge",{get:function(){return this.count},set:function(e){this.count=e},enumerable:!1,configurable:!0}),Ut.prototype.toObject=function(){return Object.keys(this._payload).length?R({},this._payload):null},Ut),vt=(D(wt,gt=h),Object.defineProperty(wt.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(wt.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(wt.prototype,"title",{get:function(){return this._title},set:function(e){e&&e.length&&(this._payload.notification.title=e,this._title=e)},enumerable:!1,configurable:!0}),Object.defineProperty(wt.prototype,"body",{get:function(){return this._body},set:function(e){e&&e.length&&(this._payload.notification.body=e,this._body=e)},enumerable:!1,configurable:!0}),Object.defineProperty(wt.prototype,"sound",{get:function(){return this._sound},set:function(e){e&&e.length&&(this._payload.notification.sound=e,this._sound=e)},enumerable:!1,configurable:!0}),Object.defineProperty(wt.prototype,"icon",{get:function(){return this._icon},set:function(e){e&&e.length&&(this._payload.notification.icon=e,this._icon=e)},enumerable:!1,configurable:!0}),Object.defineProperty(wt.prototype,"tag",{get:function(){return this._tag},set:function(e){e&&e.length&&(this._payload.notification.tag=e,this._tag=e)},enumerable:!1,configurable:!0}),Object.defineProperty(wt.prototype,"silent",{set:function(e){this._isSilent=e},enumerable:!1,configurable:!0}),wt.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},wt.prototype.toObject=function(){var e,t=R({},this._payload.data),r=null,n={};return 2<Object.keys(this._payload).length&&((e=this._payload).notification,e=L(e,["notification","data"]),t=R(R({},t),e)),this._isSilent?t.notification=this._payload.notification:r=this._payload.notification,Object.keys(t).length&&(n.data=t),r&&Object.keys(r).length&&(n.notification=r),Object.keys(n).length?n:null},wt),It=(Object.defineProperty(Ot.prototype,"debugging",{set:function(e){this._debugging=e},enumerable:!1,configurable:!0}),Object.defineProperty(Ot.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(Ot.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(Ot.prototype,"subtitle",{get:function(){return this._subtitle},set:function(e){this._subtitle=e,this.apns.subtitle=e,this.mpns.subtitle=e,this.fcm.subtitle=e},enumerable:!1,configurable:!0}),Object.defineProperty(Ot.prototype,"badge",{get:function(){return this._badge},set:function(e){this._badge=e,this.apns.badge=e,this.mpns.badge=e,this.fcm.badge=e},enumerable:!1,configurable:!0}),Object.defineProperty(Ot.prototype,"sound",{get:function(){return this._sound},set:function(e){this._sound=e,this.apns.sound=e,this.mpns.sound=e,this.fcm.sound=e},enumerable:!1,configurable:!0}),Ot.prototype.buildPayload=function(e){var t,r={};return(e.includes("apns")||e.includes("apns2"))&&(this.apns._apnsPushType=e.includes("apns")?"apns":"apns2",t=this.apns.toObject())&&Object.keys(t).length&&(r.pn_apns=t),e.includes("mpns")&&(t=this.mpns.toObject())&&Object.keys(t).length&&(r.pn_mpns=t),e.includes("fcm")&&(t=this.fcm.toObject())&&Object.keys(t).length&&(r.pn_gcm=t),Object.keys(r).length&&this._debugging&&(r.pn_debug=!0),r},Ot),Tt=(r.prototype.addListener=function(e){this._listeners.includes(e)||this._listeners.push(e)},r.prototype.removeListener=function(t){var r=[];this._listeners.forEach(function(e){e!==t&&r.push(e)}),this._listeners=r},r.prototype.removeAllListeners=function(){this._listeners=[]},r.prototype.announcePresence=function(t){this._listeners.forEach(function(e){e.presence&&e.presence(t)})},r.prototype.announceStatus=function(t){this._listeners.forEach(function(e){e.status&&e.status(t)})},r.prototype.announceMessage=function(t){this._listeners.forEach(function(e){e.message&&e.message(t)})},r.prototype.announceSignal=function(t){this._listeners.forEach(function(e){e.signal&&e.signal(t)})},r.prototype.announceMessageAction=function(t){this._listeners.forEach(function(e){e.messageAction&&e.messageAction(t)})},r.prototype.announceFile=function(t){this._listeners.forEach(function(e){e.file&&e.file(t)})},r.prototype.announceObjects=function(t){this._listeners.forEach(function(e){e.objects&&e.objects(t)})},r.prototype.announceUser=function(t){this._listeners.forEach(function(e){e.user&&e.user(t)})},r.prototype.announceSpace=function(t){this._listeners.forEach(function(e){e.space&&e.space(t)})},r.prototype.announceMembership=function(t){this._listeners.forEach(function(e){e.membership&&e.membership(t)})},r.prototype.announceNetworkUp=function(){var e={};e.category=v.PNNetworkUpCategory,this.announceStatus(e)},r.prototype.announceNetworkDown=function(){var e={};e.category=v.PNNetworkDownCategory,this.announceStatus(e)},r),Et=(Pt.prototype.setToken=function(e){e&&0<e.length?this._token=e:this._token=void 0},Pt.prototype.getToken=function(){return this._token},Pt.prototype.extractPermissions=function(e){var t={read:!1,write:!1,manage:!1,delete:!1,get:!1,update:!1,join:!1};return 128==(128&e)&&(t.join=!0),64==(64&e)&&(t.update=!0),32==(32&e)&&(t.get=!0),8==(8&e)&&(t.delete=!0),4==(4&e)&&(t.manage=!0),2==(2&e)&&(t.write=!0),1==(1&e)&&(t.read=!0),t},Pt.prototype.parseToken=function(e){var t,r,n,o,i,s,a,c,u,d=this,p=this._cbor.decodeToken(e);if(void 0!==p)return e=p.res.uuid?Object.keys(p.res.uuid):[],t=Object.keys(p.res.chan),r=Object.keys(p.res.grp),n=p.pat.uuid?Object.keys(p.pat.uuid):[],o=Object.keys(p.pat.chan),i=Object.keys(p.pat.grp),s={version:p.v,timestamp:p.t,ttl:p.ttl,authorized_uuid:p.uuid},c=0<e.length,u=0<t.length,a=0<r.length,(c||u||a)&&(s.resources={},c&&(s.resources.uuids={},e.forEach(function(e){s.resources.uuids[e]=d.extractPermissions(p.res.uuid[e])})),u&&(s.resources.channels={},t.forEach(function(e){s.resources.channels[e]=d.extractPermissions(p.res.chan[e])})),a)&&(s.resources.groups={},r.forEach(function(e){s.resources.groups[e]=d.extractPermissions(p.res.grp[e])})),c=0<n.length,e=0<o.length,u=0<i.length,(c||e||u)&&(s.patterns={},c&&(s.patterns.uuids={},n.forEach(function(e){s.patterns.uuids[e]=d.extractPermissions(p.pat.uuid[e])})),e&&(s.patterns.channels={},o.forEach(function(e){s.patterns.channels[e]=d.extractPermissions(p.pat.chan[e])})),u)&&(s.patterns.groups={},i.forEach(function(e){s.patterns.groups[e]=d.extractPermissions(p.pat.grp[e])})),0<Object.keys(p.meta).length&&(s.meta=p.meta),s.signature=p.sig,s},Pt),q=(D(St,ht=Error),St);function St(e,t){var r=this.constructor,n=ht.call(this,e)||this;return n.name=n.constructor.name,n.status=t,n.message=e,Object.setPrototypeOf(n,r.prototype),n}function Pt(e,t){this._config=e,this._cbor=t}function r(){this._listeners=[]}function Ot(e,t){this._payload={apns:{},mpns:{},fcm:{}},this._title=e,this._body=t,this.apns=new At(this._payload.apns,e,t),this.mpns=new bt(this._payload.mpns,e,t),this.fcm=new vt(this._payload.fcm,e,t)}function wt(){return null!==gt&&gt.apply(this,arguments)||this}function Ut(){return null!==yt&&yt.apply(this,arguments)||this}function kt(){return null!==mt&&mt.apply(this,arguments)||this}function jt(e,t,r){this._payload=e,this._setDefaultPayloadStructure(),this.title=t,this.body=r}function Ct(e){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=e.maximumSamplesCount||this._maximumSamplesCount}function n(e){var t=e.subscribeEndpoint,r=e.leaveEndpoint,n=e.heartbeatEndpoint,o=e.setStateEndpoint,i=e.timeEndpoint,s=e.getFileUrl,a=e.config,c=e.crypto,u=e.cryptoModule;this._listenerManager=e.listenerManager,this._config=a,this._leaveEndpoint=r,this._heartbeatEndpoint=n,this._setStateEndpoint=o,this._subscribeEndpoint=t,this._getFileUrl=s,this._crypto=c,this._cryptoModule=u,this._channels={},this._presenceChannels={},this._heartbeatChannels={},this._heartbeatChannelGroups={},this._channelGroups={},this._presenceChannelGroups={},this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[],this._currentTimetoken=0,this._lastTimetoken=0,this._storedTimetoken=null,this._subscriptionStatusAnnounced=!1,this._isOnline=!0,this._reconnectionManager=new ct({timeEndpoint:i}),this._dedupingManager=new ut({config:a}),this._cryptoModule&&(this._decoder=new TextDecoder)}function xt(e){return{message:e,type:"validationError",error:!0}}function Dt(e){var t;return e.sdkName||(t="PubNub-JS-".concat(e.sdkFamily),e.partnerId&&(t+="-".concat(e.partnerId)),t+="/".concat(e.getVersion()),0<(e=e._getPnsdkSuffix(" ")).length&&(t+=e),t)}function Lt(e,t,r){return t.usePost&&t.usePost(e,r)?"POST":t.usePatch&&t.usePatch(e,r)?"PATCH":t.useDelete&&t.useDelete(e,r)?"DELETE":t.useGetFile&&t.useGetFile(e,r)?"GETFILE":"GET"}function Nt(e,t,r,n,o){var i,s=e.config,a=e.crypto,c=Lt(e,o,n),s=(r.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===o.getOperation()&&o.usePost&&o.usePost(e,n)&&(c="GET"),"".concat(c="GETFILE"===c?"GET":c,"\n").concat(s.publishKey,"\n").concat(t,"\n").concat(m.signPamFromParams(r),"\n"));"POST"===c?s+="string"==typeof(i=o.postPayload(e,n))?i:JSON.stringify(i):"PATCH"===c&&(s+="string"==typeof(i=o.patchPayload(e,n))?i:JSON.stringify(i));t=(t=(t=(t="v2.".concat(a.HMACSHA256(s))).replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,"");r.signature=t}function w(r,n){for(var e=[],t=2;t<arguments.length;t++)e[t-2]=arguments[t];var o,i,s,a,c=r.networking,u=r.config,d=r.telemetryManager,p=r.tokenManager,l=J(),f=null,h=null,g={},f=n.getOperation()===O.PNTimeOperation||n.getOperation()===O.PNChannelGroupsOperation?e[0]:(g=e[0],e[1]),y=("undefined"==typeof Promise||f||(h=m.createPromise()),n.validateParams(r,g));return y?f?f(xt(y)):h?(h.reject(new q("Validation failed, check status for details",xt(y))),h.promise):void 0:(y=n.prepareParams(r,g),i=r,a=g,i={url:o=(o=n).usePost&&o.usePost(i,a)?o.postURL(i,a):o.usePatch&&o.usePatch(i,a)?o.patchURL(i,a):o.useGetFile&&o.useGetFile(i,a)?o.getFileURL(i,a):o.getURL(i,a),operation:n.getOperation(),timeout:n.getRequestTimeout(r),headers:n.getRequestHeaders?n.getRequestHeaders():{},ignoreBody:"function"==typeof n.ignoreBody&&n.ignoreBody(r),forceBuffered:"function"==typeof n.forceBuffered?n.forceBuffered(r,g):null,abortSignal:"function"==typeof n.getAbortSignal?n.getAbortSignal(r,g):null},y.uuid=u.UUID,y.pnsdk=Dt(u),a=d.operationsLatencyForRequest(),Object.keys(a).length&&(y=R(R({},y),a)),u.useInstanceId&&(y.instanceid=u.instanceId),u.useRequestId&&(y.requestid=l),n.isAuthSupported()&&(a=p.getToken()||u.getAuthKey())&&(y.auth=a),u.secretKey&&Nt(r,o,y,g,n),p=function(t,e){t.error?(n.handleError&&n.handleError(r,g,t),f?f(t):h&&h.reject(new q("PubNub call failed, check status for details",t))):(d.stopLatencyMeasure(n.getOperation(),l),(e="function"!=typeof(null==(e=n.handleResponse(r,e,g))?void 0:e.then)?Promise.resolve(e):e).then(function(e){f?f(t,e):h&&h.fulfill(e)}).catch(function(e){var t;f?(t=e,n.getOperation()===O.PNSubscribeOperation&&(t={statusCode:400,error:!0,operation:n.getOperation(),errorData:e,category:v.PNUnknownCategory}),f(t,null)):h&&h.reject(new q("PubNub call failed, check status for details",e))}))},d.startLatencyMeasure(n.getOperation(),l),a="POST"===Lt(r,n,g)?(s=n.postPayload(r,g),c.POST(y,s,i,p)):"PATCH"===Lt(r,n,g)?(s=n.patchPayload(r,g),c.PATCH(y,s,i,p)):"DELETE"===Lt(r,n,g)?c.DELETE(y,i,p):"GETFILE"===Lt(r,n,g)?c.GETFILE(y,i,p):c.GET(y,i,p),n.getOperation()===O.PNSubscribeOperation?a:h?h.promise:void 0)}function Ht(e,t){var r,n=t.channel,o=t.id,t=t.name,i=e.config,s=e.networking,a=e.tokenManager;if(!n)throw new q("Validation failed, check status for details",xt("channel can't be empty"));if(!o)throw new q("Validation failed, check status for details",xt("file id can't be empty"));if(t)return n="/v1/files/".concat(i.subscribeKey,"/channels/").concat(m.encodeString(n),"/files/").concat(o,"/").concat(t),(r={}).uuid=i.getUUID(),r.pnsdk=Dt(i),(o=a.getToken()||i.getAuthKey())&&(r.auth=o),i.secretKey&&Nt(e,n,r,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}}),""!==(t=Object.keys(r).map(function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(r[e]))}).join("&"))?"".concat(s.getStandardOrigin()).concat(n,"?").concat(t):"".concat(s.getStandardOrigin()).concat(n);throw new q("Validation failed, check status for details",xt("file name can't be empty"))}var Mt=Object.freeze({__proto__:null,getOperation:function(){return O.PNAddChannelsToGroupOperation},validateParams:function(e,t){var r=t.channels,e=e.config;return t.channelGroup?r&&0!==r.length?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing Channel Group"},getURL:function(e,t){t=t.channelGroup,e=e.config;return"/v1/channel-registration/sub-key/".concat(e.subscribeKey,"/channel-group/").concat(m.encodeString(t))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){t=t.channels;return{add:(void 0===t?[]:t).join(",")}},handleResponse:function(){return{}}}),Ft=Object.freeze({__proto__:null,getOperation:function(){return O.PNRemoveChannelsFromGroupOperation},validateParams:function(e,t){var r=t.channels,e=e.config;return t.channelGroup?r&&0!==r.length?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing Channel Group"},getURL:function(e,t){t=t.channelGroup,e=e.config;return"/v1/channel-registration/sub-key/".concat(e.subscribeKey,"/channel-group/").concat(m.encodeString(t))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){t=t.channels;return{remove:(void 0===t?[]:t).join(",")}},handleResponse:function(){return{}}}),qt=Object.freeze({__proto__:null,getOperation:function(){return O.PNRemoveGroupOperation},validateParams:function(e,t){t=t.channelGroup,e=e.config;return t?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channel Group"},getURL:function(e,t){t=t.channelGroup,e=e.config;return"/v1/channel-registration/sub-key/".concat(e.subscribeKey,"/channel-group/").concat(m.encodeString(t),"/remove")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},handleResponse:function(){return{}}}),Yt=Object.freeze({__proto__:null,getOperation:function(){return O.PNChannelGroupsOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){e=e.config;return"/v1/channel-registration/sub-key/".concat(e.subscribeKey,"/channel-group")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{groups:t.payload.groups}}}),Kt=Object.freeze({__proto__:null,getOperation:function(){return O.PNChannelsForGroupOperation},validateParams:function(e,t){t=t.channelGroup,e=e.config;return t?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channel Group"},getURL:function(e,t){t=t.channelGroup,e=e.config;return"/v1/channel-registration/sub-key/".concat(e.subscribeKey,"/channel-group/").concat(m.encodeString(t))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{channels:t.payload.channels}}}),zt=Object.freeze({__proto__:null,getOperation:function(){return O.PNPushNotificationEnabledChannelsOperation},validateParams:function(e,t){var r=t.device,n=t.pushGateway,o=t.channels,e=e.config;return r?n?"apns2"!==n||t.topic?o&&0!==o.length?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing APNS2 topic":"Missing GW Type (pushGateway: gcm, apns or apns2)":"Missing Device ID (device)"},getURL:function(e,t){var r=t.device,e=e.config;return("apns2"===t.pushGateway?"/v2/push/sub-key/".concat(e.subscribeKey,"/devices-apns2/"):"/v1/push/sub-key/".concat(e.subscribeKey,"/devices/")).concat(r)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.pushGateway,n=t.channels,n=void 0===n?[]:n,o=t.environment,o=void 0===o?"development":o,t=t.topic,n={type:r,add:n.join(",")};return"apns2"===r&&delete(n=R(R({},n),{environment:o,topic:t})).type,n},handleResponse:function(){return{}}}),Gt=Object.freeze({__proto__:null,getOperation:function(){return O.PNPushNotificationEnabledChannelsOperation},validateParams:function(e,t){var r=t.device,n=t.pushGateway,o=t.channels,e=e.config;return r?n?"apns2"!==n||t.topic?o&&0!==o.length?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing APNS2 topic":"Missing GW Type (pushGateway: gcm, apns or apns2)":"Missing Device ID (device)"},getURL:function(e,t){var r=t.device,e=e.config;return("apns2"===t.pushGateway?"/v2/push/sub-key/".concat(e.subscribeKey,"/devices-apns2/"):"/v1/push/sub-key/".concat(e.subscribeKey,"/devices/")).concat(r)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.pushGateway,n=t.channels,n=void 0===n?[]:n,o=t.environment,o=void 0===o?"development":o,t=t.topic,n={type:r,remove:n.join(",")};return"apns2"===r&&delete(n=R(R({},n),{environment:o,topic:t})).type,n},handleResponse:function(){return{}}}),Xt=Object.freeze({__proto__:null,getOperation:function(){return O.PNPushNotificationEnabledChannelsOperation},validateParams:function(e,t){var r=t.device,n=t.pushGateway,e=e.config;return r?n?"apns2"!==n||t.topic?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing APNS2 topic":"Missing GW Type (pushGateway: gcm, apns or apns2)":"Missing Device ID (device)"},getURL:function(e,t){var r=t.device,e=e.config;return("apns2"===t.pushGateway?"/v2/push/sub-key/".concat(e.subscribeKey,"/devices-apns2/"):"/v1/push/sub-key/".concat(e.subscribeKey,"/devices/")).concat(r)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.pushGateway,n=t.environment,n=void 0===n?"development":n,t=t.topic,o={type:r};return"apns2"===r&&delete(o=R(R({},o),{environment:n,topic:t})).type,o},handleResponse:function(e,t){return{channels:t}}}),Bt=Object.freeze({__proto__:null,getOperation:function(){return O.PNRemoveAllPushNotificationsOperation},validateParams:function(e,t){var r=t.device,n=t.pushGateway,e=e.config;return r?n?"apns2"!==n||t.topic?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing APNS2 topic":"Missing GW Type (pushGateway: gcm, apns or apns2)":"Missing Device ID (device)"},getURL:function(e,t){var r=t.device,e=e.config;return("apns2"===t.pushGateway?"/v2/push/sub-key/".concat(e.subscribeKey,"/devices-apns2/"):"/v1/push/sub-key/".concat(e.subscribeKey,"/devices/")).concat(r,"/remove")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.pushGateway,n=t.environment,n=void 0===n?"development":n,t=t.topic,o={type:r};return"apns2"===r&&delete(o=R(R({},o),{environment:n,topic:t})).type,o},handleResponse:function(){return{}}}),Vt=Object.freeze({__proto__:null,getOperation:function(){return O.PNUnsubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){e=e.config,t=t.channels,t=void 0===t?[]:t,t=0<t.length?t.join(","):",";return"/v2/presence/sub-key/".concat(e.subscribeKey,"/channel/").concat(m.encodeString(t),"/leave")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var t=t.channelGroups,t=void 0===t?[]:t,r={};return 0<t.length&&(r["channel-group"]=t.join(",")),r},handleResponse:function(){return{}}}),Wt=Object.freeze({__proto__:null,getOperation:function(){return O.PNWhereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){e=e.config,t=t.uuid,t=void 0===t?e.UUID:t;return"/v2/presence/sub-key/".concat(e.subscribeKey,"/uuid/").concat(m.encodeString(t))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return t.payload?{channels:t.payload.channels}:{channels:[]}}}),Jt=Object.freeze({__proto__:null,getOperation:function(){return O.PNHeartbeatOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){e=e.config,t=t.channels,t=void 0===t?[]:t,t=0<t.length?t.join(","):",";return"/v2/presence/sub-key/".concat(e.subscribeKey,"/channel/").concat(m.encodeString(t),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(e,t){var r=t.channelGroups,r=void 0===r?[]:r,t=t.state,e=e.config,n={};return 0<r.length&&(n["channel-group"]=r.join(",")),t&&(n.state=JSON.stringify(t)),n.heartbeat=e.getPresenceTimeout(),n},handleResponse:function(){return{}}}),$t=Object.freeze({__proto__:null,getOperation:function(){return O.PNGetStateOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var e=e.config,r=t.uuid,r=void 0===r?e.UUID:r,t=t.channels,t=void 0===t?[]:t,t=0<t.length?t.join(","):",";return"/v2/presence/sub-key/".concat(e.subscribeKey,"/channel/").concat(m.encodeString(t),"/uuid/").concat(r)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var t=t.channelGroups,t=void 0===t?[]:t,r={};return 0<t.length&&(r["channel-group"]=t.join(",")),r},handleResponse:function(e,t,r){var n=r.channels,n=void 0===n?[]:n,r=r.channelGroups,o={};return 1===n.length&&0===(void 0===r?[]:r).length?o[n[0]]=t.payload:o=t.payload,{channels:o}}}),Qt=Object.freeze({__proto__:null,getOperation:function(){return O.PNSetStateOperation},validateParams:function(e,t){var e=e.config,r=t.state,n=t.channels,t=t.channelGroups;return r?e.subscribeKey?0===(void 0===n?[]:n).length&&0===(void 0===t?[]:t).length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(e,t){e=e.config,t=t.channels,t=void 0===t?[]:t,t=0<t.length?t.join(","):",";return"/v2/presence/sub-key/".concat(e.subscribeKey,"/channel/").concat(m.encodeString(t),"/uuid/").concat(m.encodeString(e.UUID),"/data")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.state,t=t.channelGroups,t=void 0===t?[]:t,n={};return n.state=JSON.stringify(r),0<t.length&&(n["channel-group"]=t.join(",")),n},handleResponse:function(e,t){return{state:t.payload}}}),Zt=Object.freeze({__proto__:null,getOperation:function(){return O.PNHereNowOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){var e=e.config,r=t.channels,r=void 0===r?[]:r,t=t.channelGroups,t=void 0===t?[]:t,e="/v2/presence/sub-key/".concat(e.subscribeKey);return(0<r.length||0<t.length)&&(t=0<r.length?r.join(","):",",e+="/channel/".concat(m.encodeString(t))),e},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channelGroups,r=void 0===r?[]:r,n=t.includeUUIDs,o=t.includeState,o=void 0!==o&&o,t=t.queryParameters,t=void 0===t?{}:t,i={};return void 0===n||n||(i.disable_uuids=1),o&&(i.state=1),0<r.length&&(i["channel-group"]=r.join(",")),R(R({},i),t)},handleResponse:function(e,n,t){var r,o,i=t.channels,i=void 0===i?[]:i,s=t.channelGroups,s=void 0===s?[]:s,a=t.includeUUIDs,c=void 0===a||a,a=t.includeState,u=void 0!==a&&a;return 1<i.length||0<s.length||0===s.length&&0===i.length?((o={}).totalChannels=n.payload.total_channels,o.totalOccupancy=n.payload.total_occupancy,o.channels={},Object.keys(n.payload.channels).forEach(function(e){var t=n.payload.channels[e],r=[];return o.channels[e]={occupants:r,name:e,occupancy:t.occupancy},c&&t.uuids.forEach(function(e){u?r.push({state:e.state,uuid:e.uuid}):r.push({state:null,uuid:e})}),o}),o):(r=[],(t={}).totalChannels=1,t.totalOccupancy=n.occupancy,t.channels={},t.channels[i[0]]={occupants:r,name:i[0],occupancy:n.occupancy},c&&n.uuids&&n.uuids.forEach(function(e){u?r.push({state:e.state,uuid:e.uuid}):r.push({state:null,uuid:e})}),t)},handleError:function(e,t,r){402!==r.statusCode||this.getURL(e,t).includes("channel")||(r.errorData.message="You have tried to perform a Global Here Now operation, your keyset configuration does not support that. Please provide a channel, or enable the Global Here Now feature from the Portal.")}}),er=Object.freeze({__proto__:null,getOperation:function(){return O.PNAddMessageActionOperation},validateParams:function(e,t){var e=e.config,r=t.action;return t.messageTimetoken?e.subscribeKey?t.channel?r?r.value?r.type?15<r.type.length?"Action.type value exceed maximum length of 15":void 0:"Missing Action.type":"Missing Action.value":"Missing Action":"Missing message channel":"Missing Subscribe Key":"Missing message timetoken"},usePost:function(){return!0},postURL:function(e,t){var e=e.config,r=t.channel,t=t.messageTimetoken;return"/v1/message-actions/".concat(e.subscribeKey,"/channel/").concat(m.encodeString(r),"/message/").concat(t)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(e,t){return t.action},handleResponse:function(e,t){return{data:t.data}}}),tr=Object.freeze({__proto__:null,getOperation:function(){return O.PNRemoveMessageActionOperation},validateParams:function(e,t){var e=e.config,r=t.channel;return t.messageTimetoken?t.actionTimetoken?e.subscribeKey?r?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(e,t){var e=e.config,r=t.channel,n=t.actionTimetoken,t=t.messageTimetoken;return"/v1/message-actions/".concat(e.subscribeKey,"/channel/").concat(m.encodeString(r),"/message/").concat(t,"/action/").concat(n)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{data:t.data}}}),rr=Object.freeze({__proto__:null,getOperation:function(){return O.PNGetMessageActionsOperation},validateParams:function(e,t){e=e.config,t=t.channel;return e.subscribeKey?t?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(e,t){e=e.config,t=t.channel;return"/v1/message-actions/".concat(e.subscribeKey,"/channel/").concat(m.encodeString(t))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.limit,n=t.start,t=t.end,o={};return r&&(o.limit=r),n&&(o.start=n),t&&(o.end=t),o},handleResponse:function(e,t){t={data:t.data,start:null,end:null};return t.data.length&&(t.end=t.data[t.data.length-1].actionTimetoken,t.start=t.data[0].actionTimetoken),t}}),nr={getOperation:function(){return O.PNListFilesOperation},validateParams:function(e,t){if(null==t||!t.channel)return"channel can't be empty"},getURL:function(e,t){e=e.config;return"/v1/files/".concat(e.subscribeKey,"/channels/").concat(m.encodeString(t.channel),"/files")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r={};return t.limit&&(r.limit=t.limit),t.next&&(r.next=t.next),r},handleResponse:function(e,t){return{status:t.status,data:t.data,next:t.next,count:t.count}}},or={getOperation:function(){return O.PNGenerateUploadUrlOperation},validateParams:function(e,t){return null!=t&&t.channel?null!=t&&t.name?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(e,t){e=e.config;return"/v1/files/".concat(e.subscribeKey,"/channels/").concat(m.encodeString(t.channel),"/generate-upload-url")},postPayload:function(e,t){return{name:t.name}},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data,file_upload_request:t.file_upload_request}}},ir={getOperation:function(){return O.PNPublishFileOperation},validateParams:function(e,t){return null!=t&&t.channel?null!=t&&t.fileId?null!=t&&t.fileName?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(e,t){var r=e.config,n=r.publishKey,r=r.subscribeKey,e=((e,t)=>(t=JSON.stringify(t),e.cryptoModule&&(t="string"==typeof(e=e.cryptoModule.encrypt(t))?e:Z(e),t=JSON.stringify(t)),t||""))(e,{message:t.message,file:{name:t.fileName,id:t.fileId}});return"/v1/files/publish-file/".concat(n,"/").concat(r,"/0/").concat(m.encodeString(t.channel),"/0/").concat(m.encodeString(e))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r={};return t.ttl&&(r.ttl=t.ttl),void 0!==t.storeInHistory&&(r.store=t.storeInHistory?"1":"0"),t.meta&&"object"==typeof t.meta&&(r.meta=JSON.stringify(t.meta)),r},handleResponse:function(e,t){return{timetoken:t[2]}}},sr={getOperation:function(){return O.PNDownloadFileOperation},validateParams:function(e,t){return null!=t&&t.channel?null!=t&&t.name?null!=t&&t.id?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(e,t){e=e.config;return"/v1/files/".concat(e.subscribeKey,"/channels/").concat(m.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,o,i){var s=e.PubNubFile,a=e.config,c=e.cryptography,u=e.cryptoModule;return _(void 0,void 0,void 0,function(){var t,r,n;return F(this,function(e){switch(e.label){case 0:return t=o.response.body,s.supportsEncryptFile&&(i.cipherKey||u)?null!=i.cipherKey?[3,2]:[4,u.decryptFile(s.create({data:t,name:i.name}),s)]:[3,5];case 1:return r=e.sent().data,[3,4];case 2:return[4,c.decrypt(null!=(n=i.cipherKey)?n:a.cipherKey,t)];case 3:r=e.sent(),e.label=4;case 4:t=r,e.label=5;case 5:return[2,s.create({data:t,name:null!=(n=o.response.name)?n:i.name,mimeType:o.response.type})]}})})}},ar={getOperation:function(){return O.PNListFilesOperation},validateParams:function(e,t){return null!=t&&t.channel?null!=t&&t.id?null!=t&&t.name?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},useDelete:function(){return!0},getURL:function(e,t){e=e.config;return"/v1/files/".concat(e.subscribeKey,"/channels/").concat(m.encodeString(t.channel),"/files/").concat(t.id,"/").concat(t.name)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status}}},cr={getOperation:function(){return O.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(e){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r,n={include:["status","type"]};return null!=t&&t.include&&null!=(r=t.include)&&r.customFields&&n.include.push("custom"),n.include=n.include.join(","),null!=(r=null==t?void 0:t.include)&&r.totalCount&&(n.count=null==(r=t.include)?void 0:r.totalCount),null!=(r=null==t?void 0:t.page)&&r.next&&(n.start=null==(r=t.page)?void 0:r.next),null!=(r=null==t?void 0:t.page)&&r.prev&&(n.end=null==(r=t.page)?void 0:r.prev),null!=t&&t.filter&&(n.filter=t.filter),n.limit=null!=(r=null==t?void 0:t.limit)?r:100,null!=t&&t.sort&&(n.sort=Object.entries(null!=(r=t.sort)?r:{}).map(function(e){var e=A(e,2),t=e[0],e=e[1];return"asc"===e||"desc"===e?"".concat(t,":").concat(e):t})),n},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,next:t.next,prev:t.prev}}},ur={getOperation:function(){return O.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/uuids/").concat(m.encodeString(null!=(t=null==t?void 0:t.uuid)?t:e.getUUID()))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r,e=e.config,n={};return n.uuid=null!=(r=null==t?void 0:t.uuid)?r:e.getUUID(),n.include=["status","type","custom"],null!=t&&t.include&&!1===(null==(r=t.include)?void 0:r.customFields)&&n.include.pop(),n.include=n.include.join(","),n},handleResponse:function(e,t){return{status:t.status,data:t.data}}},dr={getOperation:function(){return O.PNSetUUIDMetadataOperation},validateParams:function(e,t){if(null==t||!t.data)return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/uuids/").concat(m.encodeString(null!=(t=t.uuid)?t:e.getUUID()))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r,e=e.config,n={};return n.uuid=null!=(r=null==t?void 0:t.uuid)?r:e.getUUID(),n.include=["status","type","custom"],null!=t&&t.include&&!1===(null==(r=t.include)?void 0:r.customFields)&&n.include.pop(),n.include=n.include.join(","),n},handleResponse:function(e,t){return{status:t.status,data:t.data}}},pr={getOperation:function(){return O.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(e,t){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/uuids/").concat(m.encodeString(null!=(t=null==t?void 0:t.uuid)?t:e.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){e=e.config;return{uuid:null!=(t=null==t?void 0:t.uuid)?t:e.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},lr={getOperation:function(){return O.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(e){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r,n={include:["status","type"]};return null!=t&&t.include&&null!=(r=t.include)&&r.customFields&&n.include.push("custom"),n.include=n.include.join(","),null!=(r=null==t?void 0:t.include)&&r.totalCount&&(n.count=null==(r=t.include)?void 0:r.totalCount),null!=(r=null==t?void 0:t.page)&&r.next&&(n.start=null==(r=t.page)?void 0:r.next),null!=(r=null==t?void 0:t.page)&&r.prev&&(n.end=null==(r=t.page)?void 0:r.prev),null!=t&&t.filter&&(n.filter=t.filter),n.limit=null!=(r=null==t?void 0:t.limit)?r:100,null!=t&&t.sort&&(n.sort=Object.entries(null!=(r=t.sort)?r:{}).map(function(e){var e=A(e,2),t=e[0],e=e[1];return"asc"===e||"desc"===e?"".concat(t,":").concat(e):t})),n},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},fr={getOperation:function(){return O.PNGetChannelMetadataOperation},validateParams:function(e,t){if(null==t||!t.channel)return"Channel cannot be empty"},getURL:function(e,t){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/channels/").concat(m.encodeString(t.channel))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r={include:["status","type","custom"]};return null!=t&&t.include&&!1===(null==(t=t.include)?void 0:t.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},hr={getOperation:function(){return O.PNSetChannelMetadataOperation},validateParams:function(e,t){return null!=t&&t.channel?null!=t&&t.data?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/channels/").concat(m.encodeString(t.channel))},patchPayload:function(e,t){return t.data},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r={include:["status","type","custom"]};return null!=t&&t.include&&!1===(null==(t=t.include)?void 0:t.customFields)&&r.include.pop(),r.include=r.include.join(","),r},handleResponse:function(e,t){return{status:t.status,data:t.data}}},gr={getOperation:function(){return O.PNRemoveChannelMetadataOperation},validateParams:function(e,t){if(null==t||!t.channel)return"Channel cannot be empty"},getURL:function(e,t){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/channels/").concat(m.encodeString(t.channel))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{status:t.status,data:t.data}}},yr={getOperation:function(){return O.PNGetMembersOperation},validateParams:function(e,t){if(null==t||!t.channel)return"channel cannot be empty"},getURL:function(e,t){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/channels/").concat(m.encodeString(t.channel),"/uuids")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r,n={include:[]};return null!=t&&t.include&&(null!=(r=t.include)&&r.statusField&&n.include.push("status"),null!=(r=t.include)&&r.customFields&&n.include.push("custom"),null!=(r=t.include)&&r.UUIDFields&&n.include.push("uuid"),null!=(r=t.include)&&r.customUUIDFields&&n.include.push("uuid.custom"),null!=(r=t.include)&&r.UUIDStatusField&&n.include.push("uuid.status"),null!=(r=t.include))&&r.UUIDTypeField&&n.include.push("uuid.type"),n.include=n.include.join(","),null!=(r=null==t?void 0:t.include)&&r.totalCount&&(n.count=null==(r=t.include)?void 0:r.totalCount),null!=(r=null==t?void 0:t.page)&&r.next&&(n.start=null==(r=t.page)?void 0:r.next),null!=(r=null==t?void 0:t.page)&&r.prev&&(n.end=null==(r=t.page)?void 0:r.prev),null!=t&&t.filter&&(n.filter=t.filter),n.limit=null!=(r=null==t?void 0:t.limit)?r:100,null!=t&&t.sort&&(n.sort=Object.entries(null!=(r=t.sort)?r:{}).map(function(e){var e=A(e,2),t=e[0],e=e[1];return"asc"===e||"desc"===e?"".concat(t,":").concat(e):t})),n},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},mr={getOperation:function(){return O.PNSetMembersOperation},validateParams:function(e,t){return null!=t&&t.channel?null!=t&&t.uuids&&0!==(null==t?void 0:t.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/channels/").concat(m.encodeString(t.channel),"/uuids")},patchPayload:function(e,t){var r;return(r={set:[],delete:[]})[t.type]=t.uuids.map(function(e){return"string"==typeof e?{uuid:{id:e}}:{uuid:{id:e.id},custom:e.custom,status:e.status}}),r},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r,n={include:["uuid.status","uuid.type","type"]};return null!=t&&t.include&&(null!=(r=t.include)&&r.customFields&&n.include.push("custom"),null!=(r=t.include)&&r.customUUIDFields&&n.include.push("uuid.custom"),null!=(r=t.include))&&r.UUIDFields&&n.include.push("uuid"),n.include=n.include.join(","),null!=(r=null==t?void 0:t.include)&&r.totalCount&&(n.count=!0),null!=(r=null==t?void 0:t.page)&&r.next&&(n.start=null==(r=t.page)?void 0:r.next),null!=(r=null==t?void 0:t.page)&&r.prev&&(n.end=null==(r=t.page)?void 0:r.prev),null!=t&&t.filter&&(n.filter=t.filter),null!=t.limit&&(n.limit=t.limit),null!=t&&t.sort&&(n.sort=Object.entries(null!=(r=t.sort)?r:{}).map(function(e){var e=A(e,2),t=e[0],e=e[1];return"asc"===e||"desc"===e?"".concat(t,":").concat(e):t})),n},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Rr={getOperation:function(){return O.PNGetMembershipsOperation},validateParams:function(){},getURL:function(e,t){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/uuids/").concat(m.encodeString(null!=(t=null==t?void 0:t.uuid)?t:e.getUUID()),"/channels")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r,n={include:[]};return null!=t&&t.include&&(null!=(r=t.include)&&r.statusField&&n.include.push("status"),null!=(r=t.include)&&r.customFields&&n.include.push("custom"),null!=(r=t.include)&&r.channelFields&&n.include.push("channel"),null!=(r=t.include)&&r.customChannelFields&&n.include.push("channel.custom"),null!=(r=t.include)&&r.channelStatusField&&n.include.push("channel.status"),null!=(r=t.include))&&r.channelTypeField&&n.include.push("channel.type"),n.include=n.include.join(","),null!=(r=null==t?void 0:t.include)&&r.totalCount&&(n.count=null==(r=t.include)?void 0:r.totalCount),null!=(r=null==t?void 0:t.page)&&r.next&&(n.start=null==(r=t.page)?void 0:r.next),null!=(r=null==t?void 0:t.page)&&r.prev&&(n.end=null==(r=t.page)?void 0:r.prev),null!=t&&t.filter&&(n.filter=t.filter),n.limit=null!=(r=null==t?void 0:t.limit)?r:100,null!=t&&t.sort&&(n.sort=Object.entries(null!=(r=t.sort)?r:{}).map(function(e){var e=A(e,2),t=e[0],e=e[1];return"asc"===e||"desc"===e?"".concat(t,":").concat(e):t})),n},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},_r={getOperation:function(){return O.PNSetMembershipsOperation},validateParams:function(e,t){if(null==t||!t.channels||0===(null==t?void 0:t.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(e,t){e=e.config;return"/v2/objects/".concat(e.subscribeKey,"/uuids/").concat(m.encodeString(null!=(t=t.uuid)?t:e.getUUID()),"/channels")},patchPayload:function(e,t){var r;return(r={set:[],delete:[]})[t.type]=t.channels.map(function(e){return"string"==typeof e?{channel:{id:e}}:{channel:{id:e.id},custom:e.custom,status:e.status}}),r},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r,n={include:["channel.status","channel.type","status"]};return null!=t&&t.include&&(null!=(r=t.include)&&r.customFields&&n.include.push("custom"),null!=(r=t.include)&&r.customChannelFields&&n.include.push("channel.custom"),null!=(r=t.include))&&r.channelFields&&n.include.push("channel"),n.include=n.include.join(","),null!=(r=null==t?void 0:t.include)&&r.totalCount&&(n.count=!0),null!=(r=null==t?void 0:t.page)&&r.next&&(n.start=null==(r=t.page)?void 0:r.next),null!=(r=null==t?void 0:t.page)&&r.prev&&(n.end=null==(r=t.page)?void 0:r.prev),null!=t&&t.filter&&(n.filter=t.filter),null!=t.limit&&(n.limit=t.limit),null!=t&&t.sort&&(n.sort=Object.entries(null!=(r=t.sort)?r:{}).map(function(e){var e=A(e,2),t=e[0],e=e[1];return"asc"===e||"desc"===e?"".concat(t,":").concat(e):t})),n},handleResponse:function(e,t){return{status:t.status,data:t.data,totalCount:t.totalCount,prev:t.prev,next:t.next}}},Ar=Object.freeze({__proto__:null,getOperation:function(){return O.PNAccessManagerAudit},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e){e=e.config;return"/v2/auth/audit/sub-key/".concat(e.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var r=t.channel,n=t.channelGroup,t=t.authKeys,t=void 0===t?[]:t,o={};return r&&(o.channel=r),n&&(o["channel-group"]=n),0<t.length&&(o.auth=t.join(",")),o},handleResponse:function(e,t){return t.payload}}),br=Object.freeze({__proto__:null,getOperation:function(){return O.PNAccessManagerGrant},validateParams:function(e,t){e=e.config;return e.subscribeKey?e.publishKey?e.secretKey?null==t.uuids||t.authKeys?null==t.uuids||null==t.channels&&null==t.channelGroups?void 0:"Both channel/channelgroup and uuid cannot be used in the same request":"authKeys are required for grant request on uuids":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},getURL:function(e){e=e.config;return"/v2/auth/grant/sub-key/".concat(e.subscribeKey)},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e,t){var r=t.channels,r=void 0===r?[]:r,n=t.channelGroups,n=void 0===n?[]:n,o=t.uuids,o=void 0===o?[]:o,i=t.ttl,s=t.read,a=t.write,a=void 0!==a&&a,c=t.manage,c=void 0!==c&&c,u=t.get,u=void 0!==u&&u,d=t.join,d=void 0!==d&&d,p=t.update,p=void 0!==p&&p,l=t.authKeys,l=void 0===l?[]:l,t=t.delete,f={};return f.r=void 0!==s&&s?"1":"0",f.w=a?"1":"0",f.m=c?"1":"0",f.d=t?"1":"0",f.g=u?"1":"0",f.j=d?"1":"0",f.u=p?"1":"0",0<r.length&&(f.channel=r.join(",")),0<n.length&&(f["channel-group"]=n.join(",")),0<l.length&&(f.auth=l.join(",")),0<o.length&&(f["target-uuid"]=o.join(",")),!i&&0!==i||(f.ttl=i),f},handleResponse:function(){return{}}});function vr(e){var t=void 0!==(null==e?void 0:e.authorizedUserId),r=void 0!==(null==(r=null==e?void 0:e.resources)?void 0:r.users),n=void 0!==(null==(n=null==e?void 0:e.resources)?void 0:n.spaces),o=void 0!==(null==(o=null==e?void 0:e.patterns)?void 0:o.users),e=void 0!==(null==(e=null==e?void 0:e.patterns)?void 0:e.spaces);return o||r||e||n||t}function Ir(e){var t=0;return e.join&&(t|=128),e.update&&(t|=64),e.get&&(t|=32),e.delete&&(t|=8),e.manage&&(t|=4),e.write&&(t|=2),e.read&&(t|=1),t}var Tr=Object.freeze({__proto__:null,getOperation:function(){return O.PNAccessManagerGrantToken},extractPermissions:Ir,validateParams:function(e,t){var r,n,o,i,s,a,e=e.config;return e.subscribeKey?e.publishKey?e.secretKey?t.resources||t.patterns?(e=void 0!==(null==t?void 0:t.authorized_uuid),r=void 0!==(null==(r=null==t?void 0:t.resources)?void 0:r.uuids),n=void 0!==(null==(n=null==t?void 0:t.resources)?void 0:n.channels),o=void 0!==(null==(o=null==t?void 0:t.resources)?void 0:o.groups),i=void 0!==(null==(i=null==t?void 0:t.patterns)?void 0:i.uuids),s=void 0!==(null==(s=null==t?void 0:t.patterns)?void 0:s.channels),a=void 0!==(null==(a=null==t?void 0:t.patterns)?void 0:a.groups),vr(t)&&(e||r||i||n||s||o||a)?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!t.resources||t.resources.uuids&&0!==Object.keys(t.resources.uuids).length||t.resources.channels&&0!==Object.keys(t.resources.channels).length||t.resources.groups&&0!==Object.keys(t.resources.groups).length||t.resources.users&&0!==Object.keys(t.resources.users).length||t.resources.spaces&&0!==Object.keys(t.resources.spaces).length)&&(!t.patterns||t.patterns.uuids&&0!==Object.keys(t.patterns.uuids).length||t.patterns.channels&&0!==Object.keys(t.patterns.channels).length||t.patterns.groups&&0!==Object.keys(t.patterns.groups).length||t.patterns.users&&0!==Object.keys(t.patterns.users).length||t.patterns.spaces&&0!==Object.keys(t.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."):"Missing either Resources or Patterns.":"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"},postURL:function(e){e=e.config;return"/v3/pam/".concat(e.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(e,t){return vr(t=t)?(l=t.ttl,u=t.resources,p=t.patterns,f=t.meta,d=t.authorizedUserId,c={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}},u&&(r=u.users,n=u.spaces,o=u.groups,r&&Object.keys(r).forEach(function(e){c.permissions.resources.uuids[e]=Ir(r[e])}),n&&Object.keys(n).forEach(function(e){c.permissions.resources.channels[e]=Ir(n[e])}),o)&&Object.keys(o).forEach(function(e){c.permissions.resources.groups[e]=Ir(o[e])}),p&&(i=p.users,s=p.spaces,a=p.groups,i&&Object.keys(i).forEach(function(e){c.permissions.patterns.uuids[e]=Ir(i[e])}),s&&Object.keys(s).forEach(function(e){c.permissions.patterns.channels[e]=Ir(s[e])}),a)&&Object.keys(a).forEach(function(e){c.permissions.patterns.groups[e]=Ir(a[e])}),!l&&0!==l||(c.ttl=l),f&&(c.permissions.meta=f),d&&(c.permissions.uuid="".concat(d)),c):(u=t.ttl,p=t.patterns,l=t.meta,f=t.authorized_uuid,h={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}},(d=t.resources)&&(g=d.uuids,y=d.channels,m=d.groups,g&&Object.keys(g).forEach(function(e){h.permissions.resources.uuids[e]=Ir(g[e])}),y&&Object.keys(y).forEach(function(e){h.permissions.resources.channels[e]=Ir(y[e])}),m)&&Object.keys(m).forEach(function(e){h.permissions.resources.groups[e]=Ir(m[e])}),p&&(R=p.uuids,_=p.channels,A=p.groups,R&&Object.keys(R).forEach(function(e){h.permissions.patterns.uuids[e]=Ir(R[e])}),_&&Object.keys(_).forEach(function(e){h.permissions.patterns.channels[e]=Ir(_[e])}),A)&&Object.keys(A).forEach(function(e){h.permissions.patterns.groups[e]=Ir(A[e])}),!u&&0!==u||(h.ttl=u),l&&(h.permissions.meta=l),f&&(h.permissions.uuid="".concat(f)),h);var r,n,o,i,s,a,c,u,d,p,l,f,h,g,y,m,R,_,A},handleResponse:function(e,t){return t.data.token}}),Er={getOperation:function(){return O.PNAccessManagerRevokeToken},validateParams:function(e,t){return e.config.secretKey?t?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(e,t){e=e.config;return"/v3/pam/".concat(e.subscribeKey,"/grant/").concat(m.encodeString(t))},useDelete:function(){return!0},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(e){return{uuid:e.config.getUUID()}},handleResponse:function(e,t){return{status:t.status,data:t.data}}};function Sr(e,t){t=JSON.stringify(t);return e.cryptoModule&&(t="string"==typeof(e=e.cryptoModule.encrypt(t))?e:Z(e),t=JSON.stringify(t)),t||""}var Pr,Or=Object.freeze({__proto__:null,getOperation:function(){return O.PNPublishOperation},validateParams:function(e,t){var e=e.config,r=t.message;return t.channel?r?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(e,t){t=t.sendByPost;return void 0!==t&&t},getURL:function(e,t){var r=e.config,n=t.channel,e=Sr(e,t.message);return"/publish/".concat(r.publishKey,"/").concat(r.subscribeKey,"/0/").concat(m.encodeString(n),"/0/").concat(m.encodeString(e))},postURL:function(e,t){e=e.config,t=t.channel;return"/publish/".concat(e.publishKey,"/").concat(e.subscribeKey,"/0/").concat(m.encodeString(t),"/0")},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(e,t){return Sr(e,t.message)},prepareParams:function(e,t){var r=t.meta,n=t.replicate,n=void 0===n||n,o=t.storeInHistory,t=t.ttl,i={};return null!=o&&(i.store=o?"1":"0"),t&&(i.ttl=t),!1===n&&(i.norep="true"),r&&"object"==typeof r&&(i.meta=JSON.stringify(r)),i},handleResponse:function(e,t){return{timetoken:t[2]}}}),wr=Object.freeze({__proto__:null,getOperation:function(){return O.PNSignalOperation},validateParams:function(e,t){var e=e.config,r=t.message;return t.channel?r?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(e,t){var e=e.config,r=t.channel,t=JSON.stringify(t.message);return"/signal/".concat(e.publishKey,"/").concat(e.subscribeKey,"/0/").concat(m.encodeString(r),"/0/").concat(m.encodeString(t))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(e,t){return{timetoken:t[2]}}}),Ur=Object.freeze({__proto__:null,getOperation:function(){return O.PNHistoryOperation},validateParams:function(e,t){t=t.channel,e=e.config;return t?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){t=t.channel,e=e.config;return"/v2/history/sub-key/".concat(e.subscribeKey,"/channel/").concat(m.encodeString(t))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.start,n=t.end,o=t.reverse,i=t.count,s=t.stringifiedTimeToken,s=void 0!==s&&s,t=t.includeMeta,t=void 0!==t&&t,a={include_token:"true"};return a.count=void 0===i?100:i,r&&(a.start=r),n&&(a.end=n),s&&(a.string_message_token="true"),null!=o&&(a.reverse=o.toString()),t&&(a.include_meta="true"),a},handleResponse:function(n,e){var o={messages:[],startTimeToken:e[1],endTimeToken:e[2]};return Array.isArray(e[0])&&e[0].forEach(function(e){var t=((e,t)=>{var r={};if(e.cryptoModule)try{var n=e.cryptoModule.decrypt(t),o=n instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(n)):n;r.payload=o}catch(n){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",n.message),r.payload=t,r.error="Error while decrypting message content: ".concat(n.message)}else r.payload=t;return r})(n,e.message),r={timetoken:e.timetoken,entry:t.payload};e.meta&&(r.meta=e.meta),t.error&&(r.error=t.error),o.messages.push(r)}),o}}),kr=Object.freeze({__proto__:null,getOperation:function(){return O.PNDeleteMessagesOperation},validateParams:function(e,t){t=t.channel,e=e.config;return t?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(e,t){t=t.channel,e=e.config;return"/v3/history/sub-key/".concat(e.subscribeKey,"/channel/").concat(m.encodeString(t))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.start,t=t.end,n={};return r&&(n.start=r),t&&(n.end=t),n},handleResponse:function(e,t){return t.payload}}),jr=Object.freeze({__proto__:null,getOperation:function(){return O.PNMessageCounts},validateParams:function(e,t){var r=t.channels,n=t.channelTimetokens,e=e.config;return r?t.timetoken&&n?"timetoken and channelTimetokens are incompatible together":n&&1<n.length&&r.length!==n.length?"Length of channelTimetokens and channels do not match":e.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(e,t){t=t.channels,e=e.config,t=t.join(",");return"/v3/history/sub-key/".concat(e.subscribeKey,"/message-counts/").concat(m.encodeString(t))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r,n=t.timetoken,t=t.channelTimetokens,o={};return t&&1===t.length?(r=A(t,1)[0],o.timetoken=r):t?o.channelsTimetoken=t.join(","):n&&(o.timetoken=n),o},handleResponse:function(e,t){return{channels:t.channels}}}),Cr=Object.freeze({__proto__:null,getOperation:function(){return O.PNFetchMessagesOperation},validateParams:function(e,t){var r=t.channels,t=t.includeMessageActions,e=e.config;if(!r||0===r.length)return"Missing channels";if(!e.subscribeKey)return"Missing Subscribe Key";if(void 0!==t&&t&&1<r.length)throw new TypeError("History can return actions data for a single channel only. Either pass a single channel or disable the includeMessageActions flag.")},getURL:function(e,t){var r=t.channels,r=void 0===r?[]:r,t=t.includeMessageActions,e=e.config,t=void 0!==t&&t?"history-with-actions":"history",r=0<r.length?r.join(","):",";return"/v3/".concat(t,"/sub-key/").concat(e.subscribeKey,"/channel/").concat(m.encodeString(r))},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r=t.channels,n=t.start,o=t.end,i=t.stringifiedTimeToken,i=void 0!==i&&i,s=t.includeMeta,s=void 0!==s&&s,a=t.includeUuid,c=t.includeUUID,c=void 0===c||c,u=t.includeMessageType,u=void 0===u||u,d={};return d.max=t.count||(1<r.length||!0===t.includeMessageActions?25:100),n&&(d.start=n),o&&(d.end=o),i&&(d.string_message_token="true"),s&&(d.include_meta="true"),c&&!1!==a&&(d.include_uuid="true"),u&&(d.include_message_type="true"),d},handleResponse:function(o,e){var i={channels:{}};return Object.keys(e.channels||{}).forEach(function(n){i.channels[n]=[],(e.channels[n]||[]).forEach(function(e){var t={},r=((e,t)=>{var r={};if(e.cryptoModule)try{var n=e.cryptoModule.decrypt(t),o=n instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(n)):n;r.payload=o}catch(n){e.config.logVerbosity&&console&&console.log&&console.log("decryption error",n.message),r.payload=t,r.error="Error while decrypting message content: ".concat(n.message)}else r.payload=t;return r})(o,e.message);t.channel=n,t.timetoken=e.timetoken,t.message=r.payload,t.messageType=e.message_type,t.uuid=e.uuid,e.actions&&(t.actions=e.actions,t.data=e.actions),e.meta&&(t.meta=e.meta),r.error&&(t.error=r.error),i.channels[n].push(t)})}),e.more&&(i.more=e.more),i}}),xr=Object.freeze({__proto__:null,getOperation:function(){return O.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(e){return e.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(e,t){return{timetoken:t[0]}},validateParams:function(){}}),Dr=Object.freeze({__proto__:null,getOperation:function(){return O.PNSubscribeOperation},validateParams:function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(e,t){e=e.config,t=t.channels,t=void 0===t?[]:t,t=0<t.length?t.join(","):",";return"/v2/subscribe/".concat(e.subscribeKey,"/").concat(m.encodeString(t),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var e=e.config,r=t.state,n=t.channelGroups,n=void 0===n?[]:n,o=t.timetoken,i=t.filterExpression,t=t.region,e={heartbeat:e.getPresenceTimeout()};return 0<n.length&&(e["channel-group"]=n.join(",")),i&&0<i.length&&(e["filter-expr"]=i),Object.keys(r).length&&(e.state=JSON.stringify(r)),o&&(e.tt=o),t&&(e.tr=t),e},handleResponse:function(e,t){var r=[],t=(t.m.forEach(function(e){var t={publishTimetoken:e.p.t,region:e.p.r},e={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};r.push(e)}),{timetoken:t.t.t,region:t.t.r});return{messages:r,metadata:t}}}),Lr={getOperation:function(){return O.PNHandshakeOperation},validateParams:function(e,t){if(!(null!=t&&t.channels||null!=t&&t.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(e,t){e=e.config,t=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(e.subscribeKey,"/").concat(m.encodeString(t),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(e,t){var r={};return t.channelGroups&&0<t.channelGroups.length&&(r["channel-group"]=t.channelGroups.join(",")),r.tt=0,t.state&&(r.state=JSON.stringify(t.state)),t.filterExpression&&0<t.filterExpression.length&&(r["filter-expr"]=t.filterExpression),r.ee="",r},handleResponse:function(e,t){return{region:t.t.r,timetoken:t.t.t}}},Nr={getOperation:function(){return O.PNReceiveMessagesOperation},validateParams:function(e,t){return null!=t&&t.channels||null!=t&&t.channelGroups?null!=t&&t.timetoken?null!=t&&t.region?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(e,t){e=e.config,t=t.channels?t.channels.join(","):",";return"/v2/subscribe/".concat(e.subscribeKey,"/").concat(m.encodeString(t),"/0")},getRequestTimeout:function(e){return e.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(e,t){return t.abortSignal},prepareParams:function(e,t){var r={};return t.channelGroups&&0<t.channelGroups.length&&(r["channel-group"]=t.channelGroups.join(",")),t.filterExpression&&0<t.filterExpression.length&&(r["filter-expr"]=t.filterExpression),r.tt=t.timetoken,r.tr=t.region,r.ee="",r},handleResponse:function(e,t){var r=[];return t.m.forEach(function(e){e={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,messageType:e.e,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,publishMetaData:{timetoken:e.p.t,region:e.p.r}};r.push(e)}),{messages:r,metadata:{region:t.t.r,timetoken:t.t.t}}}},l=(Yr.prototype.subscribe=function(e){var t=this;return this.listeners.add(e),function(){t.listeners.delete(e)}},Yr.prototype.notify=function(t){function e(){r.listeners.forEach(function(e){e(t)})}var r=this;this.sync?e():setTimeout(e,0)},Yr),o=(qr.prototype.transition=function(e,t){var r;return!this.transitionMap.has(t.type)||null==(r=this.transitionMap.get(t.type))?void 0:r(e,t)},qr.prototype.on=function(e,t){return this.transitionMap.set(e,t),this},qr.prototype.with=function(e,t){return[this,e,null!=t?t:[]]},qr.prototype.onEnter=function(e){return this.enterEffects.push(e),this},qr.prototype.onExit=function(e){return this.exitEffects.push(e),this},qr),Hr=(D(Fr,Pr=l),Fr.prototype.describe=function(e){return new o(e)},Fr.prototype.start=function(e,t){this.currentState=e,this.currentContext=t,this.notify({type:"engineStarted",state:e,context:t})},Fr.prototype.transition=function(e){var t,r,n,o;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:e});var i=this.currentState.transition(this.currentContext,e);if(i){var i=A(i,3),s=i[0],a=i[1],i=i[2];try{for(var c=N(this.currentState.exitEffects),u=c.next();!u.done;u=c.next()){var d=u.value;this.notify({type:"invocationDispatched",invocation:d(this.currentContext)})}}catch(e){l={error:e}}finally{try{u&&!u.done&&(p=c.return)&&p.call(c)}finally{if(l)throw l.error}}var p=this.currentState,l=(this.currentState=s,this.currentContext);this.currentContext=a,this.notify({type:"transitionDone",fromState:p,fromContext:l,toState:s,toContext:a,event:e});try{for(var f=N(i),h=f.next();!h.done;h=f.next())d=h.value,this.notify({type:"invocationDispatched",invocation:d})}catch(e){t={error:e}}finally{try{h&&!h.done&&(r=f.return)&&r.call(f)}finally{if(t)throw t.error}}try{for(var g=N(this.currentState.enterEffects),y=g.next();!y.done;y=g.next())d=y.value,this.notify({type:"invocationDispatched",invocation:d(this.currentContext)})}catch(e){n={error:e}}finally{try{y&&!y.done&&(o=g.return)&&o.call(g)}finally{if(n)throw n.error}}}},Fr),t=(Mr.prototype.on=function(e,t){this.handlers.set(e,t)},Mr.prototype.dispatch=function(e){if("CANCEL"!==e.type){var t=this.handlers.get(e.type);if(!t)throw new Error("Unhandled invocation '".concat(e.type,"'"));t=t(e.payload,this.dependencies);e.managed&&this.instances.set(e.type,t),t.start()}else this.instances.has(e.payload)&&(null!=(t=this.instances.get(e.payload))&&t.cancel(),this.instances.delete(e.payload))},Mr.prototype.dispose=function(){var e,t;try{for(var r=N(this.instances.entries()),n=r.next();!n.done;n=r.next()){var o=A(n.value,2),i=o[0];o[1].cancel(),this.instances.delete(i)}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},Mr);function Mr(e){this.dependencies=e,this.instances=new Map,this.handlers=new Map}function Fr(){return null!==Pr&&Pr.apply(this,arguments)||this}function qr(e){this.label=e,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}function Yr(e){this.sync=e=void 0===e?!1:e,this.listeners=new Set}function i(r,n){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return{type:r,payload:null==n?void 0:n.apply(void 0,b([],A(e),!1))}}return e.type=r,e}function Kr(r,n){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return{type:r,payload:n.apply(void 0,b([],A(e),!1)),managed:!1}}return e.type=r,e}function zr(r,n){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return{type:r,payload:n.apply(void 0,b([],A(e),!1)),managed:!0}}return e.type=r,e.cancel={type:"CANCEL",payload:r,managed:!1},e}function Gr(r){return function(e,t){return new Qr(e,t,r)}}D(En,Wr=Error);var Xr,Br,Vr,Wr,Jr=En,$r=(D(Tn,Vr=l),Object.defineProperty(Tn.prototype,"aborted",{get:function(){return this._aborted},enumerable:!1,configurable:!0}),Tn.prototype.throwIfAborted=function(){if(this._aborted)throw new Jr},Tn.prototype.abort=function(){this._aborted=!0,this.notify(new Jr)},Tn),Qr=(D(In,Br=function(e,t){this.payload=e,this.dependencies=t}),In.prototype.start=function(){this.asyncFunction(this.payload,this.abortSignal,this.dependencies).catch(function(e){})},In.prototype.cancel=function(){this.abortSignal.abort()},In),Zr=zr("HANDSHAKE",function(e,t){return{channels:e,groups:t}}),en=zr("RECEIVE_MESSAGES",function(e,t,r){return{channels:e,groups:t,cursor:r}}),tn=Kr("EMIT_MESSAGES",function(e){return e}),rn=Kr("EMIT_STATUS",function(e){return e}),nn=zr("RECEIVE_RECONNECT",function(e){return e}),on=zr("HANDSHAKE_RECONNECT",function(e){return e}),sn=i("SUBSCRIPTION_CHANGED",function(e,t){return{channels:e,groups:t}}),an=i("SUBSCRIPTION_RESTORED",function(e,t,r,n){return{channels:e,groups:t,cursor:{timetoken:r,region:null!=n?n:0}}}),cn=i("HANDSHAKE_SUCCESS",function(e){return e}),un=i("HANDSHAKE_FAILURE",function(e){return e}),dn=i("HANDSHAKE_RECONNECT_SUCCESS",function(e){return{cursor:e}}),pn=i("HANDSHAKE_RECONNECT_FAILURE",function(e){return e}),ln=i("HANDSHAKE_RECONNECT_GIVEUP",function(e){return e}),fn=i("RECEIVE_SUCCESS",function(e,t){return{cursor:e,events:t}}),hn=i("RECEIVE_FAILURE",function(e){return e}),gn=i("RECEIVE_RECONNECT_SUCCESS",function(e,t){return{cursor:e,events:t}}),yn=i("RECEIVE_RECONNECT_FAILURE",function(e){return e}),mn=i("RECEIVING_RECONNECT_GIVEUP",function(e){return e}),Rn=i("DISCONNECT",function(){return{}}),_n=i("RECONNECT",function(e,t){return{cursor:{timetoken:null!=e?e:"",region:null!=t?t:0}}}),f=i("UNSUBSCRIBE_ALL",function(){return{}}),An=(D(vn,Xr=t),vn),bn=new o("HANDSHAKE_FAILED");function vn(c,e){var u=Xr.call(this,e)||this;return u.on(Zr.type,Gr(function(r,n,e){var o=e.handshake,i=e.presenceState,s=e.config;return _(u,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:n.throwIfAborted(),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,o(R({abortSignal:n,channels:r.channels,channelGroups:r.groups,filterExpression:s.filterExpression},s.maintainPresenceState&&{state:i}))];case 2:return t=e.sent(),[2,c.transition(cn(t))];case 3:return(t=e.sent())instanceof Error&&"Aborted"===t.message?[2]:t instanceof q?[2,c.transition(un(t))]:[3,4];case 4:return[2]}})})})),u.on(en.type,Gr(function(r,n,e){var o=e.receiveMessages,i=e.config;return _(u,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:n.throwIfAborted(),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,o({abortSignal:n,channels:r.channels,channelGroups:r.groups,timetoken:r.cursor.timetoken,region:r.cursor.region,filterExpression:i.filterExpression})];case 2:return t=e.sent(),c.transition(fn(t.metadata,t.messages)),[3,4];case 3:return(t=e.sent())instanceof Error&&"Aborted"===t.message?[2]:t instanceof q&&!n.aborted?[2,c.transition(hn(t))]:[3,4];case 4:return[2]}})})})),u.on(tn.type,Gr(function(t,e,r){var n=r.emitMessages;return _(u,void 0,void 0,function(){return F(this,function(e){return 0<t.length&&n(t),[2]})})})),u.on(rn.type,Gr(function(t,e,r){var n=r.emitStatus;return _(u,void 0,void 0,function(){return F(this,function(e){return n(t),[2]})})})),u.on(nn.type,Gr(function(r,n,e){var o=e.receiveMessages,i=e.delay,s=e.config;return _(u,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:return s.retryConfiguration&&s.retryConfiguration.shouldRetry(r.reason,r.attempts)?(n.throwIfAborted(),[4,i(s.retryConfiguration.getDelay(r.attempts,r.reason))]):[3,6];case 1:e.sent(),n.throwIfAborted(),e.label=2;case 2:return e.trys.push([2,4,,5]),[4,o({abortSignal:n,channels:r.channels,channelGroups:r.groups,timetoken:r.cursor.timetoken,region:r.cursor.region,filterExpression:s.filterExpression})];case 3:return t=e.sent(),[2,c.transition(gn(t.metadata,t.messages))];case 4:return(t=e.sent())instanceof Error&&"Aborted"===t.message?[2]:t instanceof q?[2,c.transition(yn(t))]:[3,5];case 5:return[3,7];case 6:return[2,c.transition(mn(new q(s.retryConfiguration.getGiveupReason(r.reason,r.attempts))))];case 7:return[2]}})})})),u.on(on.type,Gr(function(r,n,e){var o=e.handshake,i=e.delay,s=e.presenceState,a=e.config;return _(u,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:return a.retryConfiguration&&a.retryConfiguration.shouldRetry(r.reason,r.attempts)?(n.throwIfAborted(),[4,i(a.retryConfiguration.getDelay(r.attempts,r.reason))]):[3,6];case 1:e.sent(),n.throwIfAborted(),e.label=2;case 2:return e.trys.push([2,4,,5]),[4,o(R({abortSignal:n,channels:r.channels,channelGroups:r.groups,filterExpression:a.filterExpression},a.maintainPresenceState&&{state:s}))];case 3:return t=e.sent(),[2,c.transition(dn(t))];case 4:return(t=e.sent())instanceof Error&&"Aborted"===t.message?[2]:t instanceof q?[2,c.transition(pn(t))]:[3,5];case 5:return[3,7];case 6:return[2,c.transition(ln(new q(a.retryConfiguration.getGiveupReason(r.reason,r.attempts))))];case 7:return[2]}})})})),u}function In(e,t,r){e=Br.call(this,e,t)||this;return e.asyncFunction=r,e.abortSignal=new $r,e}function Tn(){var e=null!==Vr&&Vr.apply(this,arguments)||this;return e._aborted=!1,e}function En(){var e=this.constructor,t=Wr.call(this,"The operation was aborted.")||this;return t.name="AbortError",Object.setPrototypeOf(t,e.prototype),t}bn.on(sn.type,function(e,t){return a.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})}),bn.on(_n.type,function(e,t){return a.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor||e.cursor})}),bn.on(an.type,function(e,t){return a.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||(null!=(e=null==(t=null==e?void 0:e.cursor)?void 0:t.region)?e:0)}})}),bn.on(f.type,function(e){return jn.with()});var Sn,Pn=new o("HANDSHAKE_STOPPED"),On=(Pn.on(sn.type,function(e,t){return Pn.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})}),Pn.on(_n.type,function(e,t){return a.with(R(R({},e),{cursor:t.payload.cursor||e.cursor}))}),Pn.on(an.type,function(e,t){return Pn.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||(null==(t=null==e?void 0:e.cursor)?void 0:t.region)||0}})}),Pn.on(f.type,function(e){return jn.with()}),new o("RECEIVE_FAILED")),wn=(On.on(_n.type,function(e,t){var r;return a.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null==(r=t.payload.cursor)?void 0:r.timetoken:e.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})}),On.on(sn.type,function(e,t){return a.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})}),On.on(an.type,function(e,t){return a.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})}),On.on(f.type,function(e){return jn.with(void 0)}),new o("RECEIVE_STOPPED")),Un=(wn.on(sn.type,function(e,t){return wn.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})}),wn.on(an.type,function(e,t){return wn.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})}),wn.on(_n.type,function(e,t){var r;return a.with({channels:e.channels,groups:e.groups,cursor:{timetoken:t.payload.cursor.timetoken?null==(r=t.payload.cursor)?void 0:r.timetoken:e.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})}),wn.on(f.type,function(){return jn.with(void 0)}),new o("RECEIVE_RECONNECTING")),s=(Un.onEnter(function(e){return nn(e)}),Un.onExit(function(){return nn.cancel}),Un.on(gn.type,function(e,t){return s.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[tn(t.payload.events)])}),Un.on(yn.type,function(e,t){return Un.with(R(R({},e),{attempts:e.attempts+1,reason:t.payload}))}),Un.on(mn.type,function(e,t){return On.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[rn({category:v.PNDisconnectedUnexpectedlyCategory,error:null==(e=t.payload)?void 0:e.message})])}),Un.on(Rn.type,function(e){return wn.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[rn({category:v.PNDisconnectedCategory})])}),Un.on(an.type,function(e,t){return s.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})}),Un.on(sn.type,function(e,t){return s.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})}),Un.on(f.type,function(e){return jn.with(void 0,[rn({category:v.PNDisconnectedCategory})])}),new o("RECEIVING")),kn=(s.onEnter(function(e){return en(e.channels,e.groups,e.cursor)}),s.onExit(function(){return en.cancel}),s.on(fn.type,function(e,t){return s.with({channels:e.channels,groups:e.groups,cursor:t.payload.cursor},[tn(t.payload.events)])}),s.on(sn.type,function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?jn.with(void 0):s.with({cursor:e.cursor,channels:t.payload.channels,groups:t.payload.groups})}),s.on(an.type,function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?jn.with(void 0):s.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||e.cursor.region}})}),s.on(hn.type,function(e,t){return Un.with(R(R({},e),{attempts:0,reason:t.payload}))}),s.on(Rn.type,function(e){return wn.with({channels:e.channels,groups:e.groups,cursor:e.cursor},[rn({category:v.PNDisconnectedCategory})])}),s.on(f.type,function(e){return jn.with(void 0,[rn({category:v.PNDisconnectedCategory})])}),new o("HANDSHAKE_RECONNECTING")),a=(kn.onEnter(function(e){return on(e)}),kn.onExit(function(){return on.cancel}),kn.on(dn.type,function(e,t){var r={timetoken:null!=(r=e.cursor)&&r.timetoken?null==(r=e.cursor)?void 0:r.timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region};return s.with({channels:e.channels,groups:e.groups,cursor:r},[rn({category:v.PNConnectedCategory})])}),kn.on(pn.type,function(e,t){return kn.with(R(R({},e),{attempts:e.attempts+1,reason:t.payload}))}),kn.on(ln.type,function(e,t){return bn.with({groups:e.groups,channels:e.channels,cursor:e.cursor,reason:t.payload},[rn({category:v.PNConnectionErrorCategory,error:null==(e=t.payload)?void 0:e.message})])}),kn.on(Rn.type,function(e){return Pn.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}),kn.on(sn.type,function(e,t){return a.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})}),kn.on(an.type,function(e,t){return a.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:(null==(t=t.payload.cursor)?void 0:t.region)||(null==(t=null==e?void 0:e.cursor)?void 0:t.region)||0}})}),kn.on(f.type,function(e){return jn.with(void 0)}),new o("HANDSHAKING")),jn=(a.onEnter(function(e){return Zr(e.channels,e.groups)}),a.onExit(function(){return Zr.cancel}),a.on(sn.type,function(e,t){return 0===t.payload.channels.length&&0===t.payload.groups.length?jn.with(void 0):a.with({channels:t.payload.channels,groups:t.payload.groups,cursor:e.cursor})}),a.on(cn.type,function(e,t){var r;return s.with({channels:e.channels,groups:e.groups,cursor:{timetoken:null!=(r=null==e?void 0:e.cursor)&&r.timetoken?null==(r=null==e?void 0:e.cursor)?void 0:r.timetoken:t.payload.timetoken,region:t.payload.region}},[rn({category:v.PNConnectedCategory})])}),a.on(un.type,function(e,t){return kn.with({channels:e.channels,groups:e.groups,cursor:e.cursor,attempts:0,reason:t.payload})}),a.on(Rn.type,function(e){return Pn.with({channels:e.channels,groups:e.groups,cursor:e.cursor})}),a.on(an.type,function(e,t){return a.with({channels:t.payload.channels,groups:t.payload.groups,cursor:{timetoken:t.payload.cursor.timetoken,region:t.payload.cursor.region||(null==(t=null==e?void 0:e.cursor)?void 0:t.region)||0}})}),a.on(f.type,function(e){return jn.with()}),new o("UNSUBSCRIBED")),Cn=(jn.on(sn.type,function(e,t){return a.with({channels:t.payload.channels,groups:t.payload.groups})}),jn.on(an.type,function(e,t){return a.with({channels:t.payload.channels,groups:t.payload.groups,cursor:t.payload.cursor})}),Object.defineProperty(Wn.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),Wn.prototype.subscribe=function(e){var t=this,r=e.channels,n=e.channelGroups,o=e.timetoken,e=e.withPresence;this.channels=b(b([],A(this.channels),!1),A(null!=r?r:[]),!1),this.groups=b(b([],A(this.groups),!1),A(null!=n?n:[]),!1),e&&(this.channels.map(function(e){return t.channels.push("".concat(e,"-pnpres"))}),this.groups.map(function(e){return t.groups.push("".concat(e,"-pnpres"))})),o?this.engine.transition(an(this.channels,this.groups,o)):this.engine.transition(sn(this.channels,this.groups)),this.dependencies.join&&this.dependencies.join({channels:this.channels.filter(function(e){return!e.endsWith("-pnpres")}),groups:this.groups.filter(function(e){return!e.endsWith("-pnpres")})})},Wn.prototype.unsubscribe=function(e){var t=this,r=e.channels,e=e.groups,n=null==r?void 0:r.slice(0),o=(null!=r&&r.map(function(e){return n.push("".concat(e,"-pnpres"))}),this.channels=this.channels.filter(function(e){return!(null!=n&&n.includes(e))}),null==e?void 0:e.slice(0));null!=e&&e.map(function(e){return o.push("".concat(e,"-pnpres"))}),this.groups=this.groups.filter(function(e){return!(null!=o&&o.includes(e))}),this.dependencies.presenceState&&(null!=r&&r.forEach(function(e){return delete t.dependencies.presenceState[e]}),null!=e)&&e.forEach(function(e){return delete t.dependencies.presenceState[e]}),this.engine.transition(sn(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leave&&this.dependencies.leave({channels:r,groups:e})},Wn.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.dependencies.presenceState&&(this.dependencies.presenceState={}),this.engine.transition(sn(this.channels.slice(0),this.groups.slice(0))),this.dependencies.leaveAll&&this.dependencies.leaveAll()},Wn.prototype.reconnect=function(e){var t=e.timetoken;this.engine.transition(_n(t,e.region))},Wn.prototype.disconnect=function(){this.engine.transition(Rn()),this.dependencies.leaveAll&&this.dependencies.leaveAll()},Wn.prototype.getSubscribedChannels=function(){return this.channels.slice(0)},Wn.prototype.getSubscribedChannelGroups=function(){return this.groups.slice(0)},Wn.prototype.dispose=function(){this.disconnect(),this._unsubscribeEngine(),this.dispatcher.dispose()},Wn),h=i("RECONNECT",function(){return{}}),l=i("DISCONNECT",function(){return{}}),xn=i("JOINED",function(e,t){return{channels:e,groups:t}}),Dn=i("LEFT",function(e,t){return{channels:e,groups:t}}),Ln=i("LEFT_ALL",function(){return{}}),Nn=i("HEARTBEAT_SUCCESS",function(e){return{statusCode:e}}),Hn=i("HEARTBEAT_FAILURE",function(e){return e}),Mn=i("HEARTBEAT_GIVEUP",function(){return{}}),Fn=i("TIMES_UP",function(){return{}}),qn=Kr("HEARTBEAT",function(e,t){return{channels:e,groups:t}}),Yn=Kr("LEAVE",function(e,t){return{channels:e,groups:t}}),Kn=Kr("EMIT_STATUS",function(e){return e}),zn=zr("WAIT",function(){return{}}),Gn=zr("DELAYED_HEARTBEAT",function(e){return e}),Xn=(D(Vn,Sn=t),Vn),Bn=new o("HEARTBEAT_STOPPED");function Vn(c,e){var u=Sn.call(this,e)||this;return u.on(qn.type,Gr(function(r,e,t){var n=t.heartbeat,o=t.presenceState,i=t.config;return _(u,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,n(R({channels:r.channels,channelGroups:r.groups},i.maintainPresenceState&&{state:o}))];case 1:return e.sent(),c.transition(Nn(200)),[3,3];case 2:return(t=e.sent())instanceof q?[2,c.transition(Hn(t))]:[3,3];case 3:return[2]}})})})),u.on(Yn.type,Gr(function(t,e,r){var n=r.leave,o=r.config;return _(u,void 0,void 0,function(){return F(this,function(e){switch(e.label){case 0:if(o.suppressLeaveEvents)return[3,4];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,n({channels:t.channels,channelGroups:t.groups})];case 2:case 3:return e.sent(),[3,4];case 4:return[2]}})})})),u.on(zn.type,Gr(function(e,t,r){var n=r.heartbeatDelay;return _(u,void 0,void 0,function(){return F(this,function(e){switch(e.label){case 0:return t.throwIfAborted(),[4,n()];case 1:return e.sent(),t.throwIfAborted(),[2,c.transition(Fn())]}})})})),u.on(Gn.type,Gr(function(r,n,e){var o=e.heartbeat,i=e.retryDelay,s=e.presenceState,a=e.config;return _(u,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:return a.retryConfiguration&&a.retryConfiguration.shouldRetry(r.reason,r.attempts)?(n.throwIfAborted(),[4,i(a.retryConfiguration.getDelay(r.attempts,r.reason))]):[3,6];case 1:e.sent(),n.throwIfAborted(),e.label=2;case 2:return e.trys.push([2,4,,5]),[4,o(R({channels:r.channels,channelGroups:r.groups},a.maintainPresenceState&&{state:s}))];case 3:return e.sent(),[2,c.transition(Nn(200))];case 4:return(t=e.sent())instanceof Error&&"Aborted"===t.message?[2]:t instanceof q?[2,c.transition(Hn(t))]:[3,5];case 5:return[3,7];case 6:return[2,c.transition(Mn())];case 7:return[2]}})})})),u.on(Kn.type,Gr(function(r,e,t){var n=t.emitStatus,o=t.config;return _(u,void 0,void 0,function(){var t;return F(this,function(e){return o.announceFailedHeartbeats&&!0===(null==(t=null==r?void 0:r.status)?void 0:t.error)?n(r.status):o.announceSuccessfulHeartbeats&&200===r.statusCode&&n(R(R({},r),{operation:O.PNHeartbeatOperation,error:!1})),[2]})})})),u}function Wn(e){var t=this;this.engine=new Hr,this.channels=[],this.groups=[],this.dependencies=e,this.dispatcher=new An(this.engine,e),this._unsubscribeEngine=this.engine.subscribe(function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)}),this.engine.start(jn,void 0)}Bn.on(xn.type,function(e,t){return Bn.with({channels:b(b([],A(e.channels),!1),A(t.payload.channels),!1),groups:b(b([],A(e.groups),!1),A(t.payload.groups),!1)})}),Bn.on(Dn.type,function(e,t){return Bn.with({channels:e.channels.filter(function(e){return!t.payload.channels.includes(e)}),groups:e.groups.filter(function(e){return!t.payload.groups.includes(e)})})}),Bn.on(h.type,function(e,t){return u.with({channels:e.channels,groups:e.groups})}),Bn.on(Ln.type,function(e,t){return Zn.with(void 0)});var Jn=new o("HEARTBEAT_COOLDOWN"),$n=(Jn.onEnter(function(){return zn()}),Jn.onExit(function(){return zn.cancel}),Jn.on(Fn.type,function(e,t){return u.with({channels:e.channels,groups:e.groups})}),Jn.on(xn.type,function(e,t){return u.with({channels:b(b([],A(e.channels),!1),A(t.payload.channels),!1),groups:b(b([],A(e.groups),!1),A(t.payload.groups),!1)})}),Jn.on(Dn.type,function(e,t){return u.with({channels:e.channels.filter(function(e){return!t.payload.channels.includes(e)}),groups:e.groups.filter(function(e){return!t.payload.groups.includes(e)})},[Yn(t.payload.channels,t.payload.groups)])}),Jn.on(l.type,function(e){return Bn.with({channels:e.channels,groups:e.groups},[Yn(e.channels,e.groups)])}),Jn.on(Ln.type,function(e,t){return Zn.with(void 0,[Yn(e.channels,e.groups)])}),new o("HEARTBEAT_FAILED")),Qn=($n.on(xn.type,function(e,t){return u.with({channels:b(b([],A(e.channels),!1),A(t.payload.channels),!1),groups:b(b([],A(e.groups),!1),A(t.payload.groups),!1)})}),$n.on(Dn.type,function(e,t){return u.with({channels:e.channels.filter(function(e){return!t.payload.channels.includes(e)}),groups:e.groups.filter(function(e){return!t.payload.groups.includes(e)})},[Yn(t.payload.channels,t.payload.groups)])}),$n.on(h.type,function(e,t){return u.with({channels:e.channels,groups:e.groups})}),$n.on(l.type,function(e,t){return Bn.with({channels:e.channels,groups:e.groups},[Yn(e.channels,e.groups)])}),$n.on(Ln.type,function(e,t){return Zn.with(void 0,[Yn(e.channels,e.groups)])}),new o("HEARBEAT_RECONNECTING")),u=(Qn.onEnter(function(e){return Gn(e)}),Qn.onExit(function(){return Gn.cancel}),Qn.on(xn.type,function(e,t){return u.with({channels:b(b([],A(e.channels),!1),A(t.payload.channels),!1),groups:b(b([],A(e.groups),!1),A(t.payload.groups),!1)})}),Qn.on(Dn.type,function(e,t){return u.with({channels:e.channels.filter(function(e){return!t.payload.channels.includes(e)}),groups:e.groups.filter(function(e){return!t.payload.groups.includes(e)})},[Yn(t.payload.channels,t.payload.groups)])}),Qn.on(l.type,function(e,t){Bn.with({channels:e.channels,groups:e.groups},[Yn(e.channels,e.groups)])}),Qn.on(Nn.type,function(e,t){return Jn.with({channels:e.channels,groups:e.groups})}),Qn.on(Hn.type,function(e,t){return Qn.with(R(R({},e),{attempts:e.attempts+1,reason:t.payload}))}),Qn.on(Mn.type,function(e,t){return $n.with({channels:e.channels,groups:e.groups})}),Qn.on(Ln.type,function(e,t){return Zn.with(void 0,[Yn(e.channels,e.groups)])}),new o("HEARTBEATING")),Zn=(u.onEnter(function(e){return qn(e.channels,e.groups)}),u.on(Nn.type,function(e,t){return Jn.with({channels:e.channels,groups:e.groups})}),u.on(xn.type,function(e,t){return u.with({channels:b(b([],A(e.channels),!1),A(t.payload.channels),!1),groups:b(b([],A(e.groups),!1),A(t.payload.groups),!1)})}),u.on(Dn.type,function(e,t){return u.with({channels:e.channels.filter(function(e){return!t.payload.channels.includes(e)}),groups:e.groups.filter(function(e){return!t.payload.groups.includes(e)})},[Yn(t.payload.channels,t.payload.groups)])}),u.on(Hn.type,function(e,t){return Qn.with(R(R({},e),{attempts:0,reason:t.payload}))}),u.on(l.type,function(e){return Bn.with({channels:e.channels,groups:e.groups},[Yn(e.channels,e.groups)])}),u.on(Ln.type,function(e,t){return Zn.with(void 0,[Yn(e.channels,e.groups)])}),new o("HEARTBEAT_INACTIVE")),eo=(Zn.on(xn.type,function(e,t){return u.with({channels:t.payload.channels,groups:t.payload.groups})}),Object.defineProperty(ao.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),ao.prototype.join=function(e){var t=e.channels,e=e.groups;this.channels=b(b([],A(this.channels),!1),A(null!=t?t:[]),!1),this.groups=b(b([],A(this.groups),!1),A(null!=e?e:[]),!1),this.engine.transition(xn(this.channels.slice(0),this.groups.slice(0)))},ao.prototype.leave=function(e){var t=this,r=e.channels,e=e.groups;this.dependencies.presenceState&&(null!=r&&r.forEach(function(e){return delete t.dependencies.presenceState[e]}),null!=e)&&e.forEach(function(e){return delete t.dependencies.presenceState[e]}),this.engine.transition(Dn(null!=r?r:[],null!=e?e:[]))},ao.prototype.leaveAll=function(){this.engine.transition(Ln())},ao.prototype.dispose=function(){this._unsubscribeEngine(),this.dispatcher.dispose()},ao),f=(so.LinearRetryPolicy=function(e){return{delay:e.delay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){return 403!==(null==(e=null==e?void 0:e.status)?void 0:e.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){return 1e3*((null!=(t=t.retryAfter)?t:this.delay)+Math.random())},getGiveupReason:function(e,t){return this.maximumRetry<=t?"retry attempts exhaused.":403===(null==(t=null==e?void 0:e.status)?void 0:t.statusCode)?"forbidden operation.":"unknown error"}}},so.ExponentialRetryPolicy=function(e){return{minimumDelay:e.minimumDelay,maximumDelay:e.maximumDelay,maximumRetry:e.maximumRetry,shouldRetry:function(e,t){return 403!==(null==(e=null==e?void 0:e.status)?void 0:e.statusCode)&&this.maximumRetry>t},getDelay:function(e,t){return 1e3*((null!=(t=t.retryAfter)?t:Math.min(Math.pow(2,e),this.maximumDelay))+Math.random())},getGiveupReason:function(e,t){return this.maximumRetry<=t?"retry attempts exhaused.":403===(null==(t=null==e?void 0:e.status)?void 0:t.statusCode)?"forbidden operation.":"unknown error"}}},so),to=(io.prototype.emitEvent=function(e){var t,r,n,o=e.channel,i=e.publishMetaData,s=e.subscriptionMatch;if(o===s&&(s=null),e.channel.endsWith("-pnpres")){var a={channel:null,subscription:null};o&&(a.channel=o.substring(0,o.lastIndexOf("-pnpres"))),s&&(a.subscription=s.substring(0,s.lastIndexOf("-pnpres"))),a.action=e.payload.action,a.state=e.payload.data,a.timetoken=i.publishTimetoken,a.occupancy=e.payload.occupancy,a.uuid=e.payload.uuid,a.timestamp=e.payload.timestamp,e.payload.join&&(a.join=e.payload.join),e.payload.leave&&(a.leave=e.payload.leave),e.payload.timeout&&(a.timeout=e.payload.timeout),this.listenerManager.announcePresence(a)}else if(1===e.messageType)(a={channel:null,subscription:null}).channel=o,a.subscription=s,a.timetoken=i.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=e.payload,this.listenerManager.announceSignal(a);else if(2===e.messageType)(a={channel:null,subscription:null}).channel=o,a.subscription=s,a.timetoken=i.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),a.message={event:e.payload.event,type:e.payload.type,data:e.payload.data},this.listenerManager.announceObjects(a),"uuid"===e.payload.type?(t=this._renameChannelField(a),this.listenerManager.announceUser(R(R({},t),{message:R(R({},t.message),{event:this._renameEvent(t.message.event),type:"user"})}))):"channel"===message.payload.type?(t=this._renameChannelField(a),this.listenerManager.announceSpace(R(R({},t),{message:R(R({},t.message),{event:this._renameEvent(t.message.event),type:"space"})}))):"membership"===message.payload.type&&(c=(n=(t=this._renameChannelField(a)).message.data).uuid,r=n.channel,(n=L(n,["uuid","channel"])).user=c,n.space=r,this.listenerManager.announceMembership(R(R({},t),{message:R(R({},t.message),{event:this._renameEvent(t.message.event),data:n})})));else if(3===e.messageType)(a={}).channel=o,a.subscription=s,a.timetoken=i.publishTimetoken,a.publisher=e.issuingClientId,a.data={messageTimetoken:e.payload.data.messageTimetoken,actionTimetoken:e.payload.data.actionTimetoken,type:e.payload.data.type,uuid:e.issuingClientId,value:e.payload.data.value},a.event=e.payload.event,this.listenerManager.announceMessageAction(a);else if(4===e.messageType){(a={}).channel=o,a.subscription=s,a.timetoken=i.publishTimetoken,a.publisher=e.issuingClientId;var c=e.payload;if(this.modules.cryptoModule){var u=void 0;try{u=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){u=null,a.error="Error while decrypting message content: ".concat(e.message)}null!==u&&(c=u)}e.userMetadata&&(a.userMetadata=e.userMetadata),a.message=c.message,a.file={id:c.file.id,name:c.file.name,url:this.getFileUrl({id:c.file.id,name:c.file.name,channel:o})},this.listenerManager.announceFile(a)}else{if((a={channel:null,subscription:null}).channel=o,a.subscription=s,a.timetoken=i.publishTimetoken,a.publisher=e.issuingClientId,e.userMetadata&&(a.userMetadata=e.userMetadata),this.modules.cryptoModule){u=void 0;try{var d,u=(d=this.modules.cryptoModule.decrypt(e.payload))instanceof ArrayBuffer?JSON.parse(this._decoder.decode(d)):d}catch(e){u=null,a.error="Error while decrypting message content: ".concat(e.message)}a.message=null!=u?u:e.payload}else a.message=e.payload;this.listenerManager.announceMessage(a)}},io.prototype._renameEvent=function(e){return"set"===e?"updated":"removed"},io.prototype._renameChannelField=function(e){var t=e.channel,e=L(e,["channel"]);return e.spaceId=t,e},io),t=(oo.prototype.getVersion=function(){return this._config.getVersion()},oo.prototype._addPnsdkSuffix=function(e,t){this._config._addPnsdkSuffix(e,t)},oo.prototype.networkDownDetected=function(){this._listenerManager.announceNetworkDown(),this._config.restore?this.disconnect():this.destroy(!0)},oo.prototype.networkUpDetected=function(){this._listenerManager.announceNetworkUp(),this.reconnect()},oo.notificationPayload=function(e,t){return new It(e,t)},oo.generateUUID=function(){return J()},oo.OPERATIONS=O,oo.CATEGORIES=v,oo.LinearRetryPolicy=f.LinearRetryPolicy,oo.ExponentialRetryPolicy=f.ExponentialRetryPolicy,oo),ro=(no.prototype.init=function(e){this._config=e,Array.isArray(this._config.origin)?this._currentSubDomain=Math.floor(Math.random()*this._config.origin.length):this._currentSubDomain=0,this._coreParams={},this.shiftStandardOrigin()},no.prototype.nextOrigin=function(){var e=this._config.secure?"https://":"http://";if("string"==typeof this._config.origin)return"".concat(e).concat(this._config.origin);this._currentSubDomain+=1,this._currentSubDomain>=this._config.origin.length&&(this._currentSubDomain=0);var t=this._config.origin[this._currentSubDomain];return"".concat(e).concat(t)},no.prototype.hasModule=function(e){return e in this._modules},no.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},no.prototype.getStandardOrigin=function(){return this._standardOrigin},no.prototype.POSTFILE=function(e,t,r){return this._modules.postfile(e,t,r)},no.prototype.GETFILE=function(e,t,r){return this._modules.getfile(e,t,r)},no.prototype.POST=function(e,t,r,n){return this._modules.post(e,t,r,n)},no.prototype.PATCH=function(e,t,r,n){return this._modules.patch(e,t,r,n)},no.prototype.GET=function(e,t,r){return this._modules.get(e,t,r)},no.prototype.DELETE=function(e,t,r){return this._modules.del(e,t,r)},no.prototype._detectErrorCategory=function(e){if("ENOTFOUND"===e.code)return v.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return v.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return v.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return v.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return v.PNNetworkIssuesCategory;if(e.timeout)return v.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return v.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return v.PNBadRequestCategory;if(e.response.forbidden)return v.PNAccessDeniedCategory}return v.PNUnknownCategory},no);function no(t){var r=this;this._modules={},Object.keys(t).forEach(function(e){r._modules[e]=t[e].bind(r)})}function oo(t){var r,n,o,s=this,e=t.networking,i=t.cbor,a=new $({setup:t}),c=(this._config=a,new at({config:a})),u=t.cryptography,i=(e.init(a),new Et(a,i)),d=(this._tokenManager=i,new _t({maximumSamplesCount:6e4})),p=(this._telemetryManager=d,this._config.cryptoModule),l={config:a,networking:e,crypto:c,cryptography:u,tokenManager:i,telemetryManager:d,PubNubFile:t.PubNubFile,cryptoModule:p},d=(this.File=t.PubNubFile,this.encryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&l.cryptoModule?l.cryptoModule.encryptFile(t=e,this.File):u.encryptFile(e,t,this.File)},this.decryptFile=function(e,t){return 1==arguments.length&&"string"!=typeof e&&l.cryptoModule?l.cryptoModule.decryptFile(t=e,this.File):u.decryptFile(e,t,this.File)},w.bind(this,l,xr)),f=w.bind(this,l,Vt),h=w.bind(this,l,Jt),g=w.bind(this,l,Qt),y=w.bind(this,l,Dr),m=new Tt,a=(this._listenerManager=m,this.iAmHere=w.bind(this,l,Jt),this.iAmAway=w.bind(this,l,Vt),this.setPresenceState=w.bind(this,l,Qt),this.handshake=w.bind(this,l,Lr),this.receiveMessages=w.bind(this,l,Nr),!0===a.enableEventEngine?(this._eventEmitter=new to({modules:l,listenerManager:this._listenerManager,getFileUrl:function(e){return Ht(l,e)}}),a.maintainPresenceState&&(this.presenceState={},this.setState=function(t){var e;return null!=(e=t.channels)&&e.forEach(function(e){return s.presenceState[e]=t.state}),null!=(e=t.channelGroups)&&e.forEach(function(e){return s.presenceState[e]=t.state}),s.setPresenceState({channels:t.channels,channelGroups:t.channelGroups,state:s.presenceState})}),a.getHeartbeatInterval()&&(a=new eo({heartbeat:this.iAmHere,leave:this.iAmAway,heartbeatDelay:function(){return new Promise(function(e){return setTimeout(e,1e3*l.config.getHeartbeatInterval())})},retryDelay:function(t){return new Promise(function(e){return setTimeout(e,t)})},config:l.config,presenceState:this.presenceState,emitStatus:function(e){m.announceStatus(e)}}),this.presenceEventEngine=a,this.join=this.presenceEventEngine.join.bind(a),this.leave=this.presenceEventEngine.leave.bind(a),this.leaveAll=this.presenceEventEngine.leaveAll.bind(a)),a=new Cn({handshake:this.handshake,receiveMessages:this.receiveMessages,delay:function(t){return new Promise(function(e){return setTimeout(e,t)})},join:this.join,leave:this.leave,leaveAll:this.leaveAll,presenceState:this.presenceState,config:l.config,emitMessages:function(e){var t,r;try{for(var n=N(e),o=n.next();!o.done;o=n.next()){var i=o.value;s._eventEmitter.emitEvent(i)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}},emitStatus:function(e){m.announceStatus(e)}}),this.subscribe=a.subscribe.bind(a),this.unsubscribe=a.unsubscribe.bind(a),this.unsubscribeAll=a.unsubscribeAll.bind(a),this.reconnect=a.reconnect.bind(a),this.disconnect=a.disconnect.bind(a),this.destroy=a.dispose.bind(a),this.getSubscribedChannels=a.getSubscribedChannels.bind(a),this.getSubscribedChannelGroups=a.getSubscribedChannelGroups.bind(a),this.eventEngine=a):(r=new Rt({timeEndpoint:d,leaveEndpoint:f,heartbeatEndpoint:h,setStateEndpoint:g,subscribeEndpoint:y,crypto:l.crypto,config:l.config,listenerManager:m,getFileUrl:function(e){return Ht(l,e)},cryptoModule:l.cryptoModule}),this.subscribe=r.adaptSubscribeChange.bind(r),this.unsubscribe=r.adaptUnsubscribeChange.bind(r),this.disconnect=r.disconnect.bind(r),this.reconnect=r.reconnect.bind(r),this.unsubscribeAll=r.unsubscribeAll.bind(r),this.getSubscribedChannels=r.getSubscribedChannels.bind(r),this.getSubscribedChannelGroups=r.getSubscribedChannelGroups.bind(r),this.setState=r.adaptStateChange.bind(r),this.presence=r.adaptPresenceChange.bind(r),this.destroy=function(e){r.unsubscribeAll(e),r.disconnect()}),this.addListener=m.addListener.bind(m),this.removeListener=m.removeListener.bind(m),this.removeAllListeners=m.removeAllListeners.bind(m),this.parseToken=i.parseToken.bind(i),this.setToken=i.setToken.bind(i),this.getToken=i.getToken.bind(i),this.channelGroups={listGroups:w.bind(this,l,Yt),listChannels:w.bind(this,l,Kt),addChannels:w.bind(this,l,Mt),removeChannels:w.bind(this,l,Ft),deleteGroup:w.bind(this,l,qt)},this.push={addChannels:w.bind(this,l,zt),removeChannels:w.bind(this,l,Gt),deleteDevice:w.bind(this,l,Bt),listChannels:w.bind(this,l,Xt)},this.hereNow=w.bind(this,l,Zt),this.whereNow=w.bind(this,l,Wt),this.getState=w.bind(this,l,$t),this.grant=w.bind(this,l,br),this.grantToken=w.bind(this,l,Tr),this.audit=w.bind(this,l,Ar),this.revokeToken=w.bind(this,l,Er),this.publish=w.bind(this,l,Or),this.fire=function(e,t){return e.replicate=!1,e.storeInHistory=!1,s.publish(e,t)},this.signal=w.bind(this,l,wr),this.history=w.bind(this,l,Ur),this.deleteMessages=w.bind(this,l,kr),this.messageCounts=w.bind(this,l,jr),this.fetchMessages=w.bind(this,l,Cr),this.addMessageAction=w.bind(this,l,er),this.removeMessageAction=w.bind(this,l,tr),this.getMessageActions=w.bind(this,l,rr),this.listFiles=w.bind(this,l,nr),w.bind(this,l,or));this.publishFile=w.bind(this,l,ir),this.sendFile=(n={generateUploadUrl:a,publishFile:this.publishFile,modules:l},o=function(){var t=this,C=n.generateUploadUrl,x=n.publishFile,e=n.modules,D=e.PubNubFile,L=e.config,N=e.cryptography,H=e.cryptoModule,M=e.networking;return function(e){var S=e.channel,P=e.file,O=e.message,w=e.cipherKey,U=e.meta,k=e.ttl,j=e.storeInHistory;return _(t,void 0,void 0,function(){var t,r,n,o,i,s,a,c,u,d,p,l,f,h,g,y,m,R,_,A,b,v,I,T,E;return F(this,function(e){switch(e.label){case 0:if(!S)throw new q("Validation failed, check status for details",xt("channel can't be empty"));if(P)return t=D.create(P),[4,C({channel:S,name:t.name})];throw new q("Validation failed, check status for details",xt("file can't be empty"));case 1:return i=e.sent(),n=i.file_upload_request,r=n.url,n=n.form_fields,o=(i=i.data).id,i=i.name,D.supportsEncryptFile&&(w||H)?null!=w?[3,3]:[4,H.encryptFile(t,D)]:[3,6];case 2:return s=e.sent(),[3,5];case 3:return[4,N.encryptFile(w,t,D)];case 4:s=e.sent(),e.label=5;case 5:t=s,e.label=6;case 6:a=n,t.mimeType&&(a=n.map(function(e){return"Content-Type"===e.key?{key:e.key,value:t.mimeType}:e})),e.label=7;case 7:return e.trys.push([7,21,,22]),D.supportsFileUri&&P.uri?(d=(u=M).POSTFILE,p=[r,a],[4,t.toFileUri()]):[3,10];case 8:return[4,d.apply(u,p.concat([e.sent()]))];case 9:return c=e.sent(),[3,20];case 10:return D.supportsFile?(f=(l=M).POSTFILE,h=[r,a],[4,t.toFile()]):[3,13];case 11:return[4,f.apply(l,h.concat([e.sent()]))];case 12:return c=e.sent(),[3,20];case 13:return D.supportsBuffer?(y=(g=M).POSTFILE,m=[r,a],[4,t.toBuffer()]):[3,16];case 14:return[4,y.apply(g,m.concat([e.sent()]))];case 15:return c=e.sent(),[3,20];case 16:return D.supportsBlob?(_=(R=M).POSTFILE,A=[r,a],[4,t.toBlob()]):[3,19];case 17:return[4,_.apply(R,A.concat([e.sent()]))];case 18:return c=e.sent(),[3,20];case 19:throw new Error("Unsupported environment");case 20:return[3,22];case 21:throw(b=e.sent()).response&&"string"==typeof b.response.text?(v=b.response.text,v=/<Message>(.*)<\/Message>/gi.exec(v),new q(v?"Upload to bucket failed: ".concat(v[1]):"Upload to bucket failed.",b)):new q("Upload to bucket failed.",b);case 22:if(204!==c.status)throw new q("Upload to bucket was unsuccessful",c);I=L.fileUploadPublishRetryLimit,T=!1,E={timetoken:"0"},e.label=23;case 23:return e.trys.push([23,25,,26]),[4,x({channel:S,message:O,fileId:o,fileName:i,meta:U,storeInHistory:j,ttl:k})];case 24:return E=e.sent(),T=!0,[3,26];case 25:return e.sent(),--I,[3,26];case 26:if(!T&&0<I)return[3,23];e.label=27;case 27:if(T)return[2,{timetoken:E.timetoken,id:o,name:i}];throw new q("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:S,id:o,name:i})}})})}}(),function(e,t){e=o(e);return"function"==typeof t&&e.then(function(e){return t(null,e)}).catch(function(e){return t(e,null)}),e}),this.getFileUrl=function(e){return Ht(l,e)},this.downloadFile=w.bind(this,l,sr),this.deleteFile=w.bind(this,l,ar),this.objects={getAllUUIDMetadata:w.bind(this,l,cr),getUUIDMetadata:w.bind(this,l,ur),setUUIDMetadata:w.bind(this,l,dr),removeUUIDMetadata:w.bind(this,l,pr),getAllChannelMetadata:w.bind(this,l,lr),getChannelMetadata:w.bind(this,l,fr),setChannelMetadata:w.bind(this,l,hr),removeChannelMetadata:w.bind(this,l,gr),getChannelMembers:w.bind(this,l,yr),setChannelMembers:function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return w.call.apply(w,b([s,l,mr,R({type:"set"},e)],A(t),!1))},removeChannelMembers:function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return w.call.apply(w,b([s,l,mr,R({type:"delete"},e)],A(t),!1))},getMemberships:w.bind(this,l,Rr),setMemberships:function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return w.call.apply(w,b([s,l,_r,R({type:"set"},e)],A(t),!1))},removeMemberships:function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return w.call.apply(w,b([s,l,_r,R({type:"delete"},e)],A(t),!1))}},this.createUser=function(e){return s.objects.setUUIDMetadata({uuid:e.userId,data:e.data,include:e.include})},this.updateUser=this.createUser,this.removeUser=function(e){return s.objects.removeUUIDMetadata({uuid:null==e?void 0:e.userId})},this.fetchUser=function(e){return s.objects.getUUIDMetadata({uuid:null==e?void 0:e.userId,include:null==e?void 0:e.include})},this.fetchUsers=this.objects.getAllUUIDMetadata,this.createSpace=function(e){return s.objects.setChannelMetadata({channel:e.spaceId,data:e.data,include:e.include})},this.updateSpace=this.createSpace,this.removeSpace=function(e){return s.objects.removeChannelMetadata({channel:e.spaceId})},this.fetchSpace=function(e){return s.objects.getChannelMetadata({channel:e.spaceId,include:e.include})},this.fetchSpaces=this.objects.getAllChannelMetadata,this.addMemberships=function(e){var t;return"string"==typeof e.spaceId?s.objects.setChannelMembers({channel:e.spaceId,uuids:null==(t=e.users)?void 0:t.map(function(e){return"string"==typeof e?e:{id:e.userId,custom:e.custom,status:e.status}}),limit:0}):s.objects.setMemberships({uuid:e.userId,channels:null==(t=e.spaces)?void 0:t.map(function(e){return"string"==typeof e?e:{id:e.spaceId,custom:e.custom,status:e.status}}),limit:0})},this.updateMemberships=this.addMemberships,this.removeMemberships=function(e){return"string"==typeof e.spaceId?s.objects.removeChannelMembers({channel:e.spaceId,uuids:e.userIds,limit:0}):s.objects.removeMemberships({uuid:e.userId,channels:e.spaceIds,limit:0})},this.fetchMemberships=function(e){return"string"==typeof e.spaceId?s.objects.getChannelMembers({channel:e.spaceId,filter:e.filter,limit:e.limit,page:e.page,include:{customFields:e.include.customFields,UUIDFields:e.include.userFields,customUUIDFields:e.include.customUserFields,statusField:e.include.statusField,UUIDStatusField:e.include.userStatusField,UUIDTypeField:e.include.userTypeField,totalCount:e.include.totalCount},sort:null!=e.sort?Object.fromEntries(Object.entries(e.sort).map(function(e){var e=A(e,2),t=e[0],e=e[1];return[t.replace("user","uuid"),e]})):null}).then(function(e){var t;return e.data=null==(t=e.data)?void 0:t.map(function(e){return{user:e.uuid,custom:e.custom,updated:e.updated,eTag:e.eTag}}),e}):s.objects.getMemberships({uuid:e.userId,filter:e.filter,limit:e.limit,page:e.page,include:{customFields:e.include.customFields,channelFields:e.include.spaceFields,customChannelFields:e.include.customSpaceFields,statusField:e.include.statusField,channelStatusField:e.include.spaceStatusField,channelTypeField:e.include.spaceTypeField,totalCount:e.include.totalCount},sort:null!=e.sort?Object.fromEntries(Object.entries(e.sort).map(function(e){var e=A(e,2),t=e[0],e=e[1];return[t.replace("space","channel"),e]})):null}).then(function(e){var t;return e.data=null==(t=e.data)?void 0:t.map(function(e){return{space:e.channel,custom:e.custom,updated:e.updated,eTag:e.eTag}}),e})},this.time=d,this.stop=this.destroy,this.encrypt=function(e,t){var r;return void 0===t&&l.cryptoModule?"string"==typeof(r=l.cryptoModule.encrypt(e))?r:Z(r):c.encrypt(e,t)},this.decrypt=function(e,t){var r;return void 0===t&&p?(r=l.cryptoModule.decrypt(e))instanceof ArrayBuffer?JSON.parse((new TextDecoder).decode(r)):r:c.decrypt(e,t)},this.getAuthKey=l.config.getAuthKey.bind(l.config),this.setAuthKey=l.config.setAuthKey.bind(l.config),this.getUUID=l.config.getUUID.bind(l.config),this.setUUID=l.config.setUUID.bind(l.config),this.getUserId=l.config.getUserId.bind(l.config),this.setUserId=l.config.setUserId.bind(l.config),this.getFilterExpression=l.config.getFilterExpression.bind(l.config),this.setFilterExpression=l.config.setFilterExpression.bind(l.config),this.setCipherKey=function(e){return l.config.setCipherKey(e,t,l)},this.setHeartbeatInterval=l.config.setHeartbeatInterval.bind(l.config),e.hasModule("proxy")&&(this.setProxy=function(e){l.config.setProxy(e),s.reconnect()})}function io(e){var t=e.modules,r=e.listenerManager,e=e.getFileUrl;this.modules=t,this.listenerManager=r,this.getFileUrl=e,t.cryptoModule&&(this._decoder=new TextDecoder)}function so(){}function ao(e){var t=this;this.engine=new Hr,this.channels=[],this.groups=[],this.dispatcher=new Xn(this.engine,e),this.dependencies=e,this._unsubscribeEngine=this.engine.subscribe(function(e){"invocationDispatched"===e.type&&t.dispatcher.dispatch(e.invocation)}),this.engine.start(Zn,void 0)}function co(o){function i(e){return e&&"object"==typeof e&&e.constructor===Object}var s;return i(o)?(s={},Object.keys(o).forEach(function(e){var t="string"==typeof e||e instanceof String,r=e,n=o[e];Array.isArray(e)||t&&0<=e.indexOf(",")?r=(t?e.split(","):e).reduce(function(e,t){return e+String.fromCharCode(t)},""):("number"==typeof e&&isFinite(e)||t&&!isNaN(e))&&(r=String.fromCharCode(t?parseInt(e,10):10)),s[r]=i(n)?co(n):n}),s):o}po.prototype.decodeToken=function(e){var t="",e=(e.length%4==3?t="=":e.length%4==2&&(t="=="),e.replace(/-/gi,"+").replace(/_/gi,"/")+t),t=this._decode(this._base64ToBinary(e));if("object"==typeof t)return t};var uo=po,h={exports:{}},l={exports:{}};function po(e,t){this._base64ToBinary=t,this._decode=e}function lo(e){if(e){var t,r=e;for(t in lo.prototype)r[t]=lo.prototype[t];return r}}(l.exports=lo).prototype.on=lo.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},lo.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},lo.prototype.off=lo.prototype.removeListener=lo.prototype.removeAllListeners=lo.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)this._callbacks={};else{var r,n=this._callbacks["$"+e];if(n)if(1==arguments.length)delete this._callbacks["$"+e];else{for(var o=0;o<n.length;o++)if((r=n[o])===t||r.fn===t){n.splice(o,1);break}0===n.length&&delete this._callbacks["$"+e]}}return this},lo.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks["$"+e],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(r)for(var n=0,o=(r=r.slice(0)).length;n<o;++n)r[n].apply(this,t);return this},lo.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},lo.prototype.hasListeners=function(e){return!!this.listeners(e).length};var f=Ro,fo=((Ro.default=Ro).stable=bo,Ro.stableStringify=bo,"[...]"),ho="[Circular]",go=[],yo=[];function mo(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function Ro(e,t,r,n){var o;(function e(t,r,n,o,i,s,a){var c;if(s+=1,"object"==typeof t&&null!==t){for(c=0;c<o.length;c++)if(o[c]===t)return void _o(ho,t,r,i);if(void 0!==a.depthLimit&&s>a.depthLimit)_o(fo,t,r,i);else if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)_o(fo,t,r,i);else{if(o.push(t),Array.isArray(t))for(c=0;c<t.length;c++)e(t[c],c,c,o,t,s,a);else{var u=Object.keys(t);for(c=0;c<u.length;c++){var d=u[c];e(t[d],d,c,o,t,s,a)}}o.pop()}}})(e,"",0,[],void 0,0,n=void 0===n?mo():n);try{o=0===yo.length?JSON.stringify(e,t,r):JSON.stringify(e,vo(t),r)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==go.length;){var i=go.pop();4===i.length?Object.defineProperty(i[0],i[1],i[3]):i[0][i[1]]=i[2]}}return o}function _o(e,t,r,n){var o=Object.getOwnPropertyDescriptor(n,r);void 0!==o.get?o.configurable?(Object.defineProperty(n,r,{value:e}),go.push([n,r,t,o])):yo.push([t,r,e]):(n[r]=e,go.push([n,r,t]))}function Ao(e,t){return e<t?-1:t<e?1:0}function bo(e,t,r,n){var o,n=function e(t,r,n,o,i,s,a){var c;if(s+=1,"object"==typeof t&&null!==t){for(c=0;c<o.length;c++)if(o[c]===t)return void _o(ho,t,r,i);try{if("function"==typeof t.toJSON)return}catch(t){return}if(void 0!==a.depthLimit&&s>a.depthLimit)_o(fo,t,r,i);else if(void 0!==a.edgesLimit&&n+1>a.edgesLimit)_o(fo,t,r,i);else{if(o.push(t),Array.isArray(t))for(c=0;c<t.length;c++)e(t[c],c,c,o,t,s,a);else{var u={},d=Object.keys(t).sort(Ao);for(c=0;c<d.length;c++){var p=d[c];e(t[p],p,c,o,t,s,a),u[p]=t[p]}if(void 0===i)return u;go.push([i,r,t]),i[r]=u}o.pop()}}}(e,"",0,[],void 0,0,n=void 0===n?mo():n)||e;try{o=0===yo.length?JSON.stringify(n,t,r):JSON.stringify(n,vo(t),r)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==go.length;){var i=go.pop();4===i.length?Object.defineProperty(i[0],i[1],i[3]):i[0][i[1]]=i[2]}}return o}function vo(o){return o=void 0!==o?o:function(e,t){return t},function(e,t){if(0<yo.length)for(var r=0;r<yo.length;r++){var n=yo[r];if(n[1]===e&&n[0]===t){t=n[2],yo.splice(r,1);break}}return o.call(this,e,t)}}var g="undefined"!=typeof Symbol&&Symbol,Io=Array.prototype.slice,To=Object.prototype.toString,Eo=Function.prototype.bind||function(t){var r=this;if("function"!=typeof r||"[object Function]"!==To.call(r))throw new TypeError("Function.prototype.bind called on incompatible "+r);for(var n=Io.call(arguments,1),e=Math.max(0,r.length-n.length),o=[],i=0;i<e;i++)o.push("$"+i);var s,a=Function("binder","return function ("+o.join(",")+"){ return binder.apply(this,arguments); }")(function(){var e;return this instanceof a?(e=r.apply(this,n.concat(Io.call(arguments))),Object(e)===e?e:this):r.apply(t,n.concat(Io.call(arguments)))});return r.prototype&&((s=function(){}).prototype=r.prototype,a.prototype=new s,s.prototype=null),a},So=Eo.call(Function.call,Object.prototype.hasOwnProperty),Po=SyntaxError,Oo=Function,wo=TypeError,Uo=function(e){try{return Oo('"use strict"; return ('+e+").constructor;")()}catch(e){}},ko=Object.getOwnPropertyDescriptor;if(ko)try{ko({},"")}catch(x){ko=null}function jo(){throw new wo}function Co(e,t){if("string"!=typeof e||0===e.length)throw new wo("intrinsic name must be a non-empty string");if(1<arguments.length&&"boolean"!=typeof t)throw new wo('"allowMissing" argument must be a boolean');var r=(e=>{var t=Go(e,0,1),r=Go(e,-1);if("%"===t&&"%"!==r)throw new Po("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new Po("invalid intrinsic syntax, expected opening `%`");var o=[];return zo(e,Xo,function(e,t,r,n){o[o.length]=r?zo(n,Bo,"$1"):t||e}),o})(e),n=0<r.length?r[0]:"",o=((e,t)=>{var r,n=e;if(qo(Fo,n)&&(n="%"+(r=Fo[n])[0]+"%"),qo(Ho,n)){var o=Ho[n];if(void 0!==(o=o===Lo?Mo(n):o)||t)return{alias:r,name:n,value:o};throw new wo("intrinsic "+e+" exists, but is not available. Please file an issue!")}throw new Po("intrinsic "+e+" does not exist!")})("%"+n+"%",t),i=(o.name,o.value),s=!1;(o=o.alias)&&(n=o[0],Ko(r,Yo([0,1],o)));for(var a=1,c=!0;a<r.length;a+=1){var u=r[a],d=Go(u,0,1),p=Go(u,-1);if(('"'===d||"'"===d||"`"===d||'"'===p||"'"===p||"`"===p)&&d!==p)throw new Po("property names with quotes must have matching quotes");if("constructor"!==u&&c||(s=!0),qo(Ho,d="%"+(n+="."+u)+"%"))i=Ho[d];else if(null!=i){if(!(u in i)){if(t)return;throw new wo("base intrinsic for "+e+" exists, but the property is not available.")}i=ko&&a+1>=r.length?(c=!!(p=ko(i,u)))&&"get"in p&&!("originalValue"in p.get)?p.get:i[u]:(c=qo(i,u),i[u]),c&&!s&&(Ho[d]=i)}}return i}var xo=ko?function(){try{return jo}catch(e){try{return ko(arguments,"callee").get}catch(e){return jo}}}():jo,g="function"==typeof g&&"function"==typeof Symbol&&"symbol"==typeof g("foo")&&"symbol"==typeof Symbol("bar")&&(()=>{if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"!=typeof Symbol.iterator){var e={},t=Symbol("test"),r=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;r=Object.getOwnPropertySymbols(e);if(1!==r.length||r[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){r=Object.getOwnPropertyDescriptor(e,t);if(42!==r.value||!0!==r.enumerable)return!1}}return!0})(),Do=Object.getPrototypeOf||function(e){return e.__proto__},Lo={},No="undefined"==typeof Uint8Array?d:Do(Uint8Array),Ho={"%AggregateError%":"undefined"==typeof AggregateError?d:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?d:ArrayBuffer,"%ArrayIteratorPrototype%":g?Do([][Symbol.iterator]()):d,"%AsyncFromSyncIteratorPrototype%":d,"%AsyncFunction%":Lo,"%AsyncGenerator%":Lo,"%AsyncGeneratorFunction%":Lo,"%AsyncIteratorPrototype%":Lo,"%Atomics%":"undefined"==typeof Atomics?d:Atomics,"%BigInt%":"undefined"==typeof BigInt?d:BigInt,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?d:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":"undefined"==typeof Float32Array?d:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?d:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?d:FinalizationRegistry,"%Function%":Oo,"%GeneratorFunction%":Lo,"%Int8Array%":"undefined"==typeof Int8Array?d:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?d:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?d:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":g?Do(Do([][Symbol.iterator]())):d,"%JSON%":"object"==typeof JSON?JSON:d,"%Map%":"undefined"==typeof Map?d:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&g?Do((new Map)[Symbol.iterator]()):d,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?d:Promise,"%Proxy%":"undefined"==typeof Proxy?d:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":"undefined"==typeof Reflect?d:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?d:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&g?Do((new Set)[Symbol.iterator]()):d,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?d:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":g?Do(""[Symbol.iterator]()):d,"%Symbol%":g?Symbol:d,"%SyntaxError%":Po,"%ThrowTypeError%":xo,"%TypedArray%":No,"%TypeError%":wo,"%Uint8Array%":"undefined"==typeof Uint8Array?d:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?d:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?d:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?d:Uint32Array,"%URIError%":URIError,"%WeakMap%":"undefined"==typeof WeakMap?d:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?d:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?d:WeakSet},Mo=function e(t){var r,n;return"%AsyncFunction%"===t?r=Uo("async function () {}"):"%GeneratorFunction%"===t?r=Uo("function* () {}"):"%AsyncGeneratorFunction%"===t?r=Uo("async function* () {}"):"%AsyncGenerator%"===t?(n=e("%AsyncGeneratorFunction%"))&&(r=n.prototype):"%AsyncIteratorPrototype%"===t&&(n=e("%AsyncGenerator%"))&&(r=Do(n.prototype)),Ho[t]=r},Fo={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},g=Eo,qo=So,Yo=g.call(Function.call,Array.prototype.concat),Ko=g.call(Function.apply,Array.prototype.splice),zo=g.call(Function.call,String.prototype.replace),Go=g.call(Function.call,String.prototype.slice),Xo=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Bo=/\\(\\)?/g,xo={exports:{}},Vo=xo,Wo=Eo,No=Co,Jo=No("%Function.prototype.apply%"),$o=No("%Function.prototype.call%"),Qo=No("%Reflect.apply%",!0)||Wo.call($o,Jo),Zo=No("%Object.getOwnPropertyDescriptor%",!0),ei=No("%Object.defineProperty%",!0),ti=No("%Math.max%");if(ei)try{ei({},"a",{value:1})}catch(Vo){ei=null}function ri(){return Qo(Wo,Jo,arguments)}Vo.exports=function(e){var t=Qo(Wo,$o,arguments);return Zo&&ei&&Zo(t,"length").configurable&&ei(t,"length",{value:1+ti(0,e.length-(arguments.length-1))}),t},ei?ei(Vo.exports,"apply",{value:ri}):Vo.exports.apply=ri;var ni,oi,ii=Co,si=xo.exports,ai=si(ii("String.prototype.indexOf")),d=(ni=Object.freeze({__proto__:null,default:{}})).__esModule?ni:(oi=Object.defineProperty({},"__esModule",{value:!0}),Object.keys(ni).forEach(function(e){var t=Object.getOwnPropertyDescriptor(ni,e);Object.defineProperty(oi,e,t.get?t:{enumerable:!0,get:function(){return ni[e]}})}),oi),So="function"==typeof Map&&Map.prototype,g=Object.getOwnPropertyDescriptor&&So?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,ci=So&&g&&"function"==typeof g.get?g.get:null,ui=So&&Map.prototype.forEach,Eo="function"==typeof Set&&Set.prototype,No=Object.getOwnPropertyDescriptor&&Eo?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,di=Eo&&No&&"function"==typeof No.get?No.get:null,pi=Eo&&Set.prototype.forEach,li="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,fi="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,hi="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,gi=Boolean.prototype.valueOf,yi=Object.prototype.toString,mi=Function.prototype.toString,Ri=String.prototype.match,_i=String.prototype.slice,Ai=String.prototype.replace,bi=String.prototype.toUpperCase,vi=String.prototype.toLowerCase,Ii=RegExp.prototype.test,Ti=Array.prototype.concat,Ei=Array.prototype.join,Si=Array.prototype.slice,Pi=Math.floor,Oi="function"==typeof BigInt?BigInt.prototype.valueOf:null,wi=Object.getOwnPropertySymbols,Ui="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,ki="function"==typeof Symbol&&"object"==typeof Symbol.iterator,ji="function"==typeof Symbol&&Symbol.toStringTag&&(Symbol.toStringTag,1)?Symbol.toStringTag:null,Ci=Object.prototype.propertyIsEnumerable,xi=("function"==typeof Reflect?Reflect:Object).getPrototypeOf||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function Di(e,t){if(e===1/0||e===-1/0||e!=e||e&&-1e3<e&&e<1e3||Ii.call(/e/,t))return t;var r=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var n=e<0?-Pi(-e):Pi(e);if(n!==e)return e=String(n),n=_i.call(t,e.length+1),Ai.call(e,r,"$&_")+"."+Ai.call(Ai.call(n,/([0-9]{3})/g,"$&_"),/_$/,"")}return Ai.call(t,r,"$&_")}var Li=d,xo=Li.custom,Ni=qi(xo)?xo:null;function Hi(e,t,r){r="double"===(r.quoteStyle||t)?'"':"'";return r+e+r}function Mi(e){return!("[object Array]"!==zi(e)||ji&&"object"==typeof e&&ji in e)}function Fi(e){return!("[object RegExp]"!==zi(e)||ji&&"object"==typeof e&&ji in e)}function qi(e){if(ki)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return 1;if(e&&"object"==typeof e&&Ui)try{return Ui.call(e),1}catch(e){}}var Yi=Object.prototype.hasOwnProperty||function(e){return e in this};function Ki(e,t){return Yi.call(e,t)}function zi(e){return yi.call(e)}function Gi(e,t){if(e.indexOf)return e.indexOf(t);for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}function Xi(e){var e=e.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+bi.call(e.toString(16))}function Bi(e){return"Object("+e+")"}function Vi(e){return e+" { ? }"}function Wi(e,t,r,n){return e+" ("+t+") {"+(n?Ji(r,n):Ei.call(r,", "))+"}"}function Ji(e,t){var r;return 0===e.length?"":(r="\n"+t.prev+t.base)+Ei.call(e,","+r)+"\n"+t.prev}function $i(e,t){var r=Mi(e),n=[];if(r){n.length=e.length;for(var o=0;o<e.length;o++)n[o]=Ki(e,o)?t(e[o],e):""}var i,s="function"==typeof wi?wi(e):[];if(ki)for(var a={},c=0;c<s.length;c++)a["$"+s[c]]=s[c];for(i in e)!Ki(e,i)||r&&String(Number(i))===i&&i<e.length||ki&&a["$"+i]instanceof Symbol||(Ii.call(/[^\w$]/,i)?n.push(t(i,e)+": "+t(e[i],e)):n.push(i+": "+t(e[i],e)));if("function"==typeof wi)for(var u=0;u<s.length;u++)Ci.call(e,s[u])&&n.push("["+t(s[u])+"]: "+t(e[s[u]],e));return n}function Qi(e,t){return"function"==typeof(t=ii(e,!!t))&&-1<ai(e,".prototype.")?si(t):t}function Zi(e,t){for(var r=t&&t.plainObjects?Object.create(null):{},n=0;n<e.length;++n)void 0!==e[n]&&(r[n]=e[n]);return r}function es(e,t,r,n,o,i,s,a,c,u,d,p,l,f,h,g){for(var y=e,m=g,R=0,_=!1;void 0!==(m=m.get(Us))&&!_;){var A=m.get(e);if(R+=1,void 0!==A){if(A===R)throw new RangeError("Cyclic object value");_=!0}void 0===m.get(Us)&&(R=0)}if("function"==typeof a?y=a(t,y):y instanceof Date?y=d(y):"comma"===r&&Es(y)&&(y=bs.maybeMap(y,function(e){return e instanceof Date?d(e):e})),null===y){if(o)return s&&!f?s(t,ws.encoder,h,"key",p):t;y=""}if("string"==typeof y||"number"==typeof y||"boolean"==typeof y||"symbol"==typeof y||"bigint"==typeof y||bs.isBuffer(y))return s?[l(f?t:s(t,ws.encoder,h,"key",p))+"="+l(s(y,ws.encoder,h,"value",p))]:[l(t)+"="+l(String(y))];var b,v,I=[];if(void 0!==y){v="comma"===r&&Es(y)?[{value:0<(y=f&&s?bs.maybeMap(y,s):y).length?y.join(",")||null:void 0}]:Es(a)?a:(b=Object.keys(y),c?b.sort(c):b);for(var T=n&&Es(y)&&1===y.length?t+"[]":t,E=0;E<v.length;++E){var S,P=v[E],O="object"==typeof P&&void 0!==P.value?P.value:y[P];i&&null===O||(P=Es(y)?"function"==typeof r?r(T,P):T:T+(u?"."+P:"["+P+"]"),g.set(e,R),(S=As()).set(Us,g),Ps(I,es(O,P,r,n,o,i,"comma"===r&&f&&Es(y)?null:s,a,c,u,d,p,l,f,h,S)))}}return I}function ts(e,t){return e&&"string"==typeof e&&t.comma&&-1<e.indexOf(",")?e.split(","):e}var rs,g=Co,ns=function n(r,e,o,i){var s=e||{};if(Ki(s,"quoteStyle")&&"single"!==s.quoteStyle&&"double"!==s.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Ki(s,"maxStringLength")&&("number"==typeof s.maxStringLength?s.maxStringLength<0&&s.maxStringLength!==1/0:null!==s.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');e=!Ki(s,"customInspect")||s.customInspect;if("boolean"!=typeof e&&"symbol"!==e)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Ki(s,"indent")&&null!==s.indent&&"\t"!==s.indent&&!(parseInt(s.indent,10)===s.indent&&0<s.indent))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Ki(s,"numericSeparator")&&"boolean"!=typeof s.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var t=s.numericSeparator;if(void 0===r)return"undefined";if(null===r)return"null";if("boolean"==typeof r)return r?"true":"false";if("string"==typeof r)return function e(t,r){var n;return t.length>r.maxStringLength?(n="... "+(n=t.length-r.maxStringLength)+" more character"+(1<n?"s":""),e(_i.call(t,0,r.maxStringLength),r)+n):Hi(Ai.call(Ai.call(t,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,Xi),"single",r)}(r,s);if("number"==typeof r)return 0===r?0<1/0/r?"0":"-0":(y=String(r),t?Di(r,y):y);if("bigint"==typeof r)return y=String(r)+"n",t?Di(r,y):y;t=void 0===s.depth?5:s.depth;if(t<=(o=void 0===o?0:o)&&0<t&&"object"==typeof r)return Mi(r)?"[Array]":"[Object]";var a,c,u,d,p,l,f,h,g,y=(e=>{var t;if("\t"===s.indent)t="\t";else{if(!("number"==typeof s.indent&&0<s.indent))return null;t=Ei.call(Array(s.indent+1)," ")}return{base:t,prev:Ei.call(Array(e+1),t)}})(o);if(void 0===i)i=[];else if(0<=Gi(i,r))return"[Circular]";function m(e,t,r){return t&&(i=Si.call(i)).push(t),r?(t={depth:s.depth},Ki(s,"quoteStyle")&&(t.quoteStyle=s.quoteStyle),n(e,t,o+1,i)):n(e,s,o+1,i)}if("function"==typeof r&&!Fi(r))return"[Function"+((a=r.name||((a=Ri.call(mi.call(r),/^function\s*([\w$]+)/))?a[1]:null))?": "+a:" (anonymous)")+"]"+(0<(u=$i(r,m)).length?" { "+Ei.call(u,", ")+" }":"");if(qi(r))return u=ki?Ai.call(String(r),/^(Symbol\(.*\))_[^)]*$/,"$1"):Ui.call(r),"object"!=typeof r||ki?u:Bi(u);if((u=r)&&"object"==typeof u&&("undefined"!=typeof HTMLElement&&u instanceof HTMLElement||"string"==typeof u.nodeName&&"function"==typeof u.getAttribute)){for(var R="<"+vi.call(String(r.nodeName)),_=r.attributes||[],A=0;A<_.length;A++)R+=" "+_[A].name+"="+Hi((c=_[A].value,Ai.call(String(c),/"/g,"&quot;")),"double",s);return R+=">",r.childNodes&&r.childNodes.length&&(R+="..."),R+("</"+vi.call(String(r.nodeName)))+">"}if(Mi(r))return 0===r.length?"[]":(d=$i(r,m),y&&!(e=>{for(var t=0;t<e.length;t++)if(0<=Gi(e[t],"\n"))return;return 1})(d)?"["+Ji(d,y)+"]":"[ "+Ei.call(d,", ")+" ]");if(!("[object Error]"!==zi(d=r)||ji&&"object"==typeof d&&ji in d))return f=$i(r,m),"cause"in Error.prototype||!("cause"in r)||Ci.call(r,"cause")?0===f.length?"["+String(r)+"]":"{ ["+String(r)+"] "+Ei.call(f,", ")+" }":"{ ["+String(r)+"] "+Ei.call(Ti.call("[cause]: "+m(r.cause),f),", ")+" }";if("object"==typeof r&&e){if(Ni&&"function"==typeof r[Ni]&&Li)return Li(r,{depth:t-o});if("symbol"!==e&&"function"==typeof r.inspect)return r.inspect()}return(e=>{if(ci&&e&&"object"==typeof e)try{ci.call(e);try{di.call(e)}catch(e){return 1}return e instanceof Map}catch(e){}})(r)?(p=[],ui&&ui.call(r,function(e,t){p.push(m(t,r,!0)+" => "+m(e,r))}),Wi("Map",ci.call(r),p,y)):(e=>{if(di&&e&&"object"==typeof e)try{di.call(e);try{ci.call(e)}catch(e){return 1}return e instanceof Set}catch(e){}})(r)?(l=[],pi&&pi.call(r,function(e){l.push(m(e,r))}),Wi("Set",di.call(r),l,y)):(e=>{if(li&&e&&"object"==typeof e)try{li.call(e,li);try{fi.call(e,fi)}catch(e){return 1}return e instanceof WeakMap}catch(e){}})(r)?Vi("WeakMap"):(e=>{if(fi&&e&&"object"==typeof e)try{fi.call(e,fi);try{li.call(e,li)}catch(e){return 1}return e instanceof WeakSet}catch(e){}})(r)?Vi("WeakSet"):(e=>{if(hi&&e&&"object"==typeof e)try{return hi.call(e),1}catch(e){}})(r)?Vi("WeakRef"):"[object Number]"!==zi(f=r)||ji&&"object"==typeof f&&ji in f?(e=>{if(e&&"object"==typeof e&&Oi)try{return Oi.call(e),1}catch(e){}})(r)?Bi(m(Oi.call(r))):"[object Boolean]"!==zi(t=r)||ji&&"object"==typeof t&&ji in t?"[object String]"!==zi(e=r)||ji&&"object"==typeof e&&ji in e?"undefined"!=typeof window&&r===window?"{ [object Window] }":r===H?"{ [object globalThis] }":("[object Date]"!==zi(t=r)||ji&&"object"==typeof t&&ji in t)&&!Fi(r)?(e=$i(r,m),t=xi?xi(r)===Object.prototype:r instanceof Object||r.constructor===Object,h=r instanceof Object?"":"null prototype",g=!t&&ji&&Object(r)===r&&ji in r?_i.call(zi(r),8,-1):h?"Object":"",t=(!t&&"function"==typeof r.constructor&&r.constructor.name?r.constructor.name+" ":"")+(g||h?"["+Ei.call(Ti.call([],g||[],h||[]),": ")+"] ":""),0===e.length?t+"{}":y?t+"{"+Ji(e,y)+"}":t+"{ "+Ei.call(e,", ")+" }"):String(r):Bi(m(String(r))):Bi(gi.call(r)):Bi(m(Number(r)))},os=g("%TypeError%"),is=g("%WeakMap%",!0),ss=g("%Map%",!0),as=Qi("WeakMap.prototype.get",!0),cs=Qi("WeakMap.prototype.set",!0),us=Qi("WeakMap.prototype.has",!0),ds=Qi("Map.prototype.get",!0),ps=Qi("Map.prototype.set",!0),ls=Qi("Map.prototype.has",!0),fs=function(e,t){for(var r,n=e;null!==(r=n.next);n=r)if(r.key===t)return n.next=r.next,r.next=e.next,e.next=r},hs=String.prototype.replace,gs=/%20/g,So="RFC3986",No={default:So,formatters:{RFC1738:function(e){return hs.call(e,gs,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:So},ys=No,ms=Object.prototype.hasOwnProperty,Rs=Array.isArray,_s=(()=>{for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})(),Eo={arrayToObject:Zi,assign:function(e,r){return Object.keys(r).reduce(function(e,t){return e[t]=r[t],e},e)},combine:function(e,t){return[].concat(e,t)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],r=[],n=0;n<t.length;++n)for(var o=t[n],i=o.obj[o.prop],s=Object.keys(i),a=0;a<s.length;++a){var c=s[a],u=i[c];"object"==typeof u&&null!==u&&-1===r.indexOf(u)&&(t.push({obj:i,prop:c}),r.push(u))}for(var d=t;1<d.length;){var p=d.pop(),l=p.obj[p.prop];if(Rs(l)){for(var f=[],h=0;h<l.length;++h)void 0!==l[h]&&f.push(l[h]);p.obj[p.prop]=f}}return e},decode:function(e,t,r){var n=e.replace(/\+/g," ");if("iso-8859-1"===r)return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch(e){return n}},encode:function(e,t,r,n,o){if(0===e.length)return e;var i=e;if("symbol"==typeof e?i=Symbol.prototype.toString.call(e):"string"!=typeof e&&(i=String(e)),"iso-8859-1"===r)return escape(i).replace(/%u[0-9a-f]{4}/gi,function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"});for(var s="",a=0;a<i.length;++a){var c=i.charCodeAt(a);45===c||46===c||95===c||126===c||48<=c&&c<=57||65<=c&&c<=90||97<=c&&c<=122||o===ys.RFC1738&&(40===c||41===c)?s+=i.charAt(a):c<128?s+=_s[c]:c<2048?s+=_s[192|c>>6]+_s[128|63&c]:c<55296||57344<=c?s+=_s[224|c>>12]+_s[128|c>>6&63]+_s[128|63&c]:(a+=1,c=65536+((1023&c)<<10|1023&i.charCodeAt(a)),s+=_s[240|c>>18]+_s[128|c>>12&63]+_s[128|c>>6&63]+_s[128|63&c])}return s},isBuffer:function(e){return!(!e||"object"!=typeof e||!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e)))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(Rs(e)){for(var r=[],n=0;n<e.length;n+=1)r.push(t(e[n]));return r}return t(e)},merge:function n(o,i,s){if(!i)return o;if("object"!=typeof i){if(Rs(o))o.push(i);else{if(!o||"object"!=typeof o)return[o,i];(s&&(s.plainObjects||s.allowPrototypes)||!ms.call(Object.prototype,i))&&(o[i]=!0)}return o}var e;return o&&"object"==typeof o?(Rs(e=o)&&!Rs(i)&&(e=Zi(o,s)),Rs(o)&&Rs(i)?(i.forEach(function(e,t){var r;ms.call(o,t)?(r=o[t])&&"object"==typeof r&&e&&"object"==typeof e?o[t]=n(r,e,s):o.push(e):o[t]=e}),o):Object.keys(i).reduce(function(e,t){var r=i[t];return ms.call(e,t)?e[t]=n(e[t],r,s):e[t]=r,e},e)):[o].concat(i)}},As=function(){var o,i,s,t={assert:function(e){if(!t.has(e))throw new os("Side channel does not contain "+ns(e))},get:function(e){if(is&&e&&("object"==typeof e||"function"==typeof e)){if(o)return as(o,e)}else if(ss){if(i)return ds(i,e)}else if(s)return(e=fs(s,e))&&e.value},has:function(e){if(is&&e&&("object"==typeof e||"function"==typeof e)){if(o)return us(o,e)}else if(ss){if(i)return ls(i,e)}else if(s)return!!fs(s,e);return!1},set:function(e,t){var r,n;is&&e&&("object"==typeof e||"function"==typeof e)?(o=o||new is,cs(o,e,t)):ss?(i=i||new ss,ps(i,e,t)):(t=t,(n=fs(r=s=s||{key:{},next:null},e=e))?n.value=t:r.next={key:e,next:r.next,value:t})}};return t},bs=Eo,vs=No,Is=Object.prototype.hasOwnProperty,Ts={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},Es=Array.isArray,Ss=Array.prototype.push,Ps=function(e,t){Ss.apply(e,Es(t)?t:[t])},Os=Date.prototype.toISOString,xo=vs.default,ws={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:bs.encode,encodeValuesOnly:!1,format:xo,formatter:vs.formatters[xo],indices:!1,serializeDate:function(e){return Os.call(e)},skipNulls:!1,strictNullHandling:!1},Us={},ks=Eo,js=Object.prototype.hasOwnProperty,Cs=Array.isArray,p={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:ks.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},g={formats:No,parse:function(e,t){var r=(e=>{if(!e)return p;if(null!=e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=(void 0===e.charset?p:e).charset;return{allowDots:void 0===e.allowDots?p.allowDots:!!e.allowDots,allowPrototypes:("boolean"==typeof e.allowPrototypes?e:p).allowPrototypes,allowSparse:("boolean"==typeof e.allowSparse?e:p).allowSparse,arrayLimit:("number"==typeof e.arrayLimit?e:p).arrayLimit,charset:t,charsetSentinel:("boolean"==typeof e.charsetSentinel?e:p).charsetSentinel,comma:("boolean"==typeof e.comma?e:p).comma,decoder:("function"==typeof e.decoder?e:p).decoder,delimiter:("string"==typeof e.delimiter||ks.isRegExp(e.delimiter)?e:p).delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:p.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:("boolean"==typeof e.interpretNumericEntities?e:p).interpretNumericEntities,parameterLimit:("number"==typeof e.parameterLimit?e:p).parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:("boolean"==typeof e.plainObjects?e:p).plainObjects,strictNullHandling:("boolean"==typeof e.strictNullHandling?e:p).strictNullHandling}})(t);if(""===e||null==e)return r.plainObjects?Object.create(null):{};for(var n="string"==typeof e?((e,t)=>{var r,n,o,i,s={__proto__:null},e=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,a=t.parameterLimit===1/0?void 0:t.parameterLimit,c=e.split(t.delimiter,a),u=-1,d=t.charset;if(t.charsetSentinel)for(r=0;r<c.length;++r)0===c[r].indexOf("utf8=")&&("utf8=%E2%9C%93"===c[r]?d="utf-8":"utf8=%26%2310003%3B"===c[r]&&(d="iso-8859-1"),u=r,r=c.length);for(r=0;r<c.length;++r)r!==u&&((i=-1===(i=-1===(i=(o=c[r]).indexOf("]="))?o.indexOf("="):i+1)?(n=t.decoder(o,p.decoder,d,"key"),t.strictNullHandling?null:""):(n=t.decoder(o.slice(0,i),p.decoder,d,"key"),ks.maybeMap(ts(o.slice(i+1),t),function(e){return t.decoder(e,p.decoder,d,"value")})))&&t.interpretNumericEntities&&"iso-8859-1"===d&&(i=i.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})),-1<o.indexOf("[]=")&&(i=Cs(i)?[i]:i),js.call(s,n)?s[n]=ks.combine(s[n],i):s[n]=i);return s})(e,r):e,o=r.plainObjects?Object.create(null):{},i=Object.keys(n),s=0;s<i.length;++s)var a=i[s],a=((e,t,r,n)=>{if(e){var o=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,s=0<r.depth&&/(\[[^[\]]*])/.exec(o),e=s?o.slice(0,s.index):o,a=[];if(e){if(!r.plainObjects&&js.call(Object.prototype,e)&&!r.allowPrototypes)return;a.push(e)}for(var c=0;0<r.depth&&null!==(s=i.exec(o))&&c<r.depth;){if(c+=1,!r.plainObjects&&js.call(Object.prototype,s[1].slice(1,-1))&&!r.allowPrototypes)return;a.push(s[1])}s&&a.push("["+o.slice(s.index)+"]");for(var u=a,d=r,p=n?t:ts(t,d),l=u.length-1;0<=l;--l){var f,h,g,y=u[l];"[]"===y&&d.parseArrays?f=[].concat(p):(f=d.plainObjects?Object.create(null):{},h="["===y.charAt(0)&&"]"===y.charAt(y.length-1)?y.slice(1,-1):y,g=parseInt(h,10),d.parseArrays||""!==h?!isNaN(g)&&y!==h&&String(g)===h&&0<=g&&d.parseArrays&&g<=d.arrayLimit?(f=[])[g]=p:"__proto__"!==h&&(f[h]=p):f={0:p}),p=f}return p}})(a,n[a],r,"string"==typeof e),o=ks.merge(o,a,r);return!0===r.allowSparse?o:ks.compact(o)},stringify:function(e,t){var r=e,n=(e=>{if(!e)return ws;if(null!=e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||ws.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=vs.default;if(void 0!==e.format){if(!Is.call(vs.formatters,e.format))throw new TypeError("Unknown format option provided.");r=e.format}var n=vs.formatters[r],o=ws.filter;return"function"!=typeof e.filter&&!Es(e.filter)||(o=e.filter),{addQueryPrefix:("boolean"==typeof e.addQueryPrefix?e:ws).addQueryPrefix,allowDots:void 0===e.allowDots?ws.allowDots:!!e.allowDots,charset:t,charsetSentinel:("boolean"==typeof e.charsetSentinel?e:ws).charsetSentinel,delimiter:(void 0===e.delimiter?ws:e).delimiter,encode:("boolean"==typeof e.encode?e:ws).encode,encoder:("function"==typeof e.encoder?e:ws).encoder,encodeValuesOnly:("boolean"==typeof e.encodeValuesOnly?e:ws).encodeValuesOnly,filter:o,format:r,formatter:n,serializeDate:("function"==typeof e.serializeDate?e:ws).serializeDate,skipNulls:("boolean"==typeof e.skipNulls?e:ws).skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:("boolean"==typeof e.strictNullHandling?e:ws).strictNullHandling}})(t);"function"==typeof n.filter?r=(0,n.filter)("",r):Es(n.filter)&&(a=n.filter);var o=[];if("object"!=typeof r||null===r)return"";var e=t&&t.arrayFormat in Ts?t.arrayFormat:!(t&&"indices"in t)||t.indices?"indices":"repeat",i=Ts[e];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var s="comma"===i&&t&&t.commaRoundTrip,a=a||Object.keys(r);n.sort&&a.sort(n.sort);for(var c=As(),u=0;u<a.length;++u){var d=a[u];n.skipNulls&&null===r[d]||Ps(o,es(r[d],d,i,s,n.strictNullHandling,n.skipNulls,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset,c))}e=o.join(n.delimiter),t=!0===n.addQueryPrefix?"?":"";return n.charsetSentinel&&("iso-8859-1"===n.charset?t+="utf8=%26%2310003%3B&":t+="utf8=%E2%9C%93&"),0<e.length?t+e:""}},So={};function xs(e,t){var r,n,o,i,s="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(s)return o=!(n=!0),{s:function(){s=s.call(e)},n:function(){var e=s.next();return n=e.done,e},e:function(e){o=!0,r=e},f:function(){try{n||null==s.return||s.return()}finally{if(o)throw r}}};if(Array.isArray(e)||(s=(e=>{var t;if(e)return"string"==typeof e?Ds(e,void 0):"Map"===(t="Object"===(t=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Ds(e,void 0):void 0})(e))||t&&e&&"number"==typeof e.length)return s&&(e=s),i=0,{s:t=function(){},n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ds(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}(rs=So).type=e=>e.split(/ *; */).shift(),rs.params=e=>{var n,o={},t=xs(e.split(/ *; */));try{for(t.s();!(n=t.n()).done;){let e=n.value.split(/ *= */),t=e.shift(),r=e.shift();t&&r&&(o[t]=r)}}catch(e){t.e(e)}finally{t.f()}return o},rs.parseLinks=e=>{var r,n={},t=xs(e.split(/ *, */));try{for(t.s();!(r=t.n()).done;){let e=r.value.split(/ *; */),t=e[0].slice(1,-1);n[e[1].split(/ *= */)[1].slice(1,-1)]=t}}catch(e){t.e(e)}finally{t.f()}return n},rs.cleanHeader=(e,t)=>(delete e["content-type"],delete e["content-length"],delete e["transfer-encoding"],delete e.host,t&&(delete e.authorization,delete e.cookie),e),rs.isObject=e=>null!==e&&"object"==typeof e,rs.hasOwn=Object.hasOwn||function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(new Object(e),t)},rs.mixin=(e,t)=>{for(var r in t)rs.hasOwn(t,r)&&(e[r]=t[r])};let Ls=d,Ns=So.isObject,Hs=So.hasOwn;xo=y;function y(){}y.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},y.prototype.parse=function(e){return this._parser=e,this},y.prototype.responseType=function(e){return this._responseType=e,this},y.prototype.serialize=function(e){return this._serializer=e,this},y.prototype.timeout=function(e){if(e&&"object"==typeof e){for(var t in e)if(Hs(e,t))switch(t){case"deadline":this._timeout=e.deadline;break;case"response":this._responseTimeout=e.response;break;case"upload":this._uploadTimeout=e.upload;break;default:console.warn("Unknown timeout option",t)}}else this._timeout=e,this._responseTimeout=0,this._uploadTimeout=0;return this},y.prototype.retry=function(e,t){return this._maxRetries=e=(e=0!==arguments.length&&!0!==e?e:1)<=0?0:e,this._retries=0,this._retryCallback=t,this};let Ms=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),Fs=new Set([408,413,429,500,502,503,504,521,522,524]),qs=(y.prototype._shouldRetry=function(e,t){if(this._maxRetries&&!(this._retries++>=this._maxRetries)){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&&Fs.has(t.status))return!0;if(e){if(e.code&&Ms.has(e.code))return!0;if(e.timeout&&"ECONNABORTED"===e.code)return!0;if(e.crossDomain)return!0}}return!1},y.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()},y.prototype.then=function(e,t){if(!this._fullfilledPromise){let e=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((r,n)=>{e.on("abort",()=>{var e;this._maxRetries&&this._maxRetries>this._retries||(this.timedout&&this.timedoutError?n(this.timedoutError):((e=new Error("Aborted")).code="ABORTED",e.status=this.status,e.method=this.method,e.url=this.url,n(e)))}),e.end((e,t)=>{e?n(e):r(t)})})}return this._fullfilledPromise.then(e,t)},y.prototype.catch=function(e){return this.then(void 0,e)},y.prototype.use=function(e){return e(this),this},y.prototype.ok=function(e){if("function"!=typeof e)throw new Error("Callback required");return this._okCallback=e,this},y.prototype._isResponseOK=function(e){return!!e&&(this._okCallback?this._okCallback(e):200<=e.status&&e.status<300)},y.prototype.getHeader=y.prototype.get=function(e){return this._header[e.toLowerCase()]},y.prototype.set=function(t,e){if(Ns(t))for(let e in t)Hs(t,e)&&this.set(e,t[e]);else this._header[t.toLowerCase()]=e,this.header[t]=e;return this},y.prototype.unset=function(e){return delete this._header[e.toLowerCase()],delete this.header[e],this},y.prototype.field=function(t,r,e){if(null==t)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(Ns(t))for(let e in t)Hs(t,e)&&this.field(e,t[e]);else if(Array.isArray(r))for(let e in r)Hs(r,e)&&this.field(t,r[e]);else{if(null==r)throw new Error(".field(name, val) val can not be empty");"boolean"==typeof r&&(r=String(r)),e?this._getFormData().append(t,r,e):this._getFormData().append(t,r)}return this},y.prototype.abort=function(){if(!this._aborted){if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(Ls.gte(Ua.version,"v13.0.0")&&Ls.lt(Ua.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");this.req.abort()}this.clearTimeout(),this.emit("abort")}return this},y.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},y.prototype.withCredentials=function(e){return this._withCredentials=e=void 0===e?!0:e,this},y.prototype.redirects=function(e){return this._maxRedirects=e,this},y.prototype.maxResponseSize=function(e){if("number"!=typeof e)throw new TypeError("Invalid argument");return this._maxResponseSize=e,this},y.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},y.prototype.send=function(t){let e=Ns(t),r=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(e&&!this._data)Array.isArray(t)?this._data=[]:this._isHost(t)||(this._data={});else if(t&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(e&&Ns(this._data))for(let e in t){if("bigint"==typeof t[e]&&!t[e].toJSON)throw new Error("Cannot serialize BigInt value to json");Hs(t,e)&&(this._data[e]=t[e])}else{if("bigint"==typeof t)throw new Error("Cannot send value of type BigInt");"string"==typeof t?(r||this.type("form"),r=(r=this._header["content-type"])&&r.toLowerCase().trim(),this._data="application/x-www-form-urlencoded"===r?this._data?this._data+"&"+t:t:(this._data||"")+t):this._data=t}return!e||this._isHost(t)||r||this.type("json"),this},y.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},y.prototype._finalizeQueryString=function(){let e=this._query.join("&");if(e&&(this.url+=(this.url.includes("?")?"&":"?")+e),this._query.length=0,this._sort){let e=this.url.indexOf("?");var t;0<=e&&(t=this.url.slice(e+1).split("&"),"function"==typeof this._sort?t.sort(this._sort):t.sort(),this.url=this.url.slice(0,e)+"?"+t.join("&"))}},y.prototype._appendQueryString=()=>{console.warn("Unsupported")},y.prototype._timeoutError=function(e,t,r){this._aborted||((e=new Error(e+t+"ms exceeded")).timeout=t,e.code="ECONNABORTED",e.errno=r,this.timedout=!0,this.timedoutError=e,this.abort(),this.callback(e))},y.prototype._setTimeouts=function(){let e=this;this._timeout&&!this._timer&&(this._timer=setTimeout(()=>{e._timeoutError("Timeout of ",e._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(()=>{e._timeoutError("Response timeout of ",e._responseTimeout,"ETIMEDOUT")},this._responseTimeout))},So);Eo=Ys;function Ys(){}function Ks(e,t){var r,n,o,i,s="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(s)return o=!(n=!0),{s:function(){s=s.call(e)},n:function(){var e=s.next();return n=e.done,e},e:function(e){o=!0,r=e},f:function(){try{n||null==s.return||s.return()}finally{if(o)throw r}}};if(Array.isArray(e)||(s=(e=>{var t;if(e)return"string"==typeof e?zs(e,void 0):"Map"===(t="Object"===(t=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?zs(e,void 0):void 0})(e))||t&&e&&"number"==typeof e.length)return s&&(e=s),i=0,{s:t=function(){},n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function zs(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Gs(){this._defaults=[]}Ys.prototype.get=function(e){return this.header[e.toLowerCase()]},Ys.prototype._setHeaderProperties=function(e){var t=e["content-type"]||"",r=(this.type=qs.type(t),qs.params(t));for(let e in r)Object.prototype.hasOwnProperty.call(r,e)&&(this[e]=r[e]);this.links={};try{e.link&&(this.links=qs.parseLinks(e.link))}catch(e){}},Ys.prototype._setStatusProperties=function(e){var t=Math.trunc(e/100);this.statusCode=e,this.status=this.statusCode,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.created=201===e,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,this.unprocessableEntity=422===e};for(var Xs=0,Bs=["use","on","once","set","query","type","accept","auth","withCredentials","sortQuery","retry","ok","redirects","timeout","buffer","serialize","parse","ca","key","pfx","cert","disableTLSCerts"];Xs<Bs.length;Xs++){let n=Bs[Xs];Gs.prototype[n]=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return this._defaults.push({fn:n,args:t}),this}}Gs.prototype._setDefaults=function(t){var r,e=Ks(this._defaults);try{for(e.s();!(r=e.n()).done;){let e=r.value;t[e.fn](...e.args)}}catch(t){e.e(t)}finally{e.f()}};No=Gs;{var Vs=h,Ws=h.exports;function Js(e,t){var r,n,o,i,s="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(s)return o=!(n=!0),{s:function(){s=s.call(e)},n:function(){var e=s.next();return n=e.done,e},e:function(e){o=!0,r=e},f:function(){try{n||null==s.return||s.return()}finally{if(o)throw r}}};if(Array.isArray(e)||(s=(e=>{var t;if(e)return"string"==typeof e?$s(e,void 0):"Map"===(t="Object"===(t=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?$s(e,void 0):void 0})(e))||t&&e&&"number"==typeof e.length)return s&&(e=s),i=0,{s:t=function(){},n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function $s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}let e,t=(e="undefined"!=typeof window?window:"undefined"==typeof self?void console.warn("Using browser-only version of superagent in non-browser environment"):self,l.exports),r=f,n=g,o=xo,s=So.isObject,i=So.mixin,a=So.hasOwn,c=Eo,u=No;function Qs(){}Vs.exports=function(e,t){return"function"==typeof t?new Ws.Request("GET",e).end(t):1===arguments.length?new Ws.Request("GET",e):new Ws.Request(e,t)};let d=Ws=Vs.exports,p=(Ws.Request=U,d.getXHR=()=>{if(e.XMLHttpRequest)return new e.XMLHttpRequest;throw new Error("Browser-only version of superagent could not find XHR")},"".trim?e=>e.trim():e=>e.replace(/(^\s*|\s*$)/g,""));function Zs(e){if(!s(e))return e;var t,r=[];for(t in e)a(e,t)&&function t(r,n,o){if(void 0!==o)if(null!==o)if(Array.isArray(o)){var e,i=Js(o);try{for(i.s();!(e=i.n()).done;)t(r,n,e.value)}catch(r){i.e(r)}finally{i.f()}}else if(s(o))for(let e in o)a(o,e)&&t(r,`${n}[${e}]`,o[e]);else r.push(encodeURI(n)+"="+encodeURIComponent(o));else r.push(encodeURI(n))}(r,t,e[t]);return r.join("&")}function ea(e){var r,n,o={},i=e.split("&");for(let e=0,t=i.length;e<t;++e)-1===(n=(r=i[e]).indexOf("="))?o[decodeURIComponent(r)]="":o[decodeURIComponent(r.slice(0,n))]=decodeURIComponent(r.slice(n+1));return o}function ta(e){return/[/+]json($|[^-\w])/i.test(e)}function ra(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;let t=this.xhr.status;1223===t&&(t=204),this._setStatusProperties(t),this.headers=(e=>{var r,n,o,i=e.split(/\r?\n/),s={};for(let e=0,t=i.length;e<t;++e)-1!==(r=(o=i[e]).indexOf(":"))&&(n=o.slice(0,r).toLowerCase(),o=p(o.slice(r+1)),s[n]=o);return s})(this.xhr.getAllResponseHeaders()),this.header=this.headers,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?null:this._parseBody(this.text||this.xhr.response)}function U(e,t){let n=this;this._query=this._query||[],this.method=e,this.url=t,this.header={},this._header={},this.on("end",()=>{let e,t=null,r=null;try{r=new ra(n)}catch(e){return(t=new Error("Parser is unable to parse the response")).parse=!0,t.original=e,n.xhr?(t.rawResponse=void 0===n.xhr.responseType?n.xhr.responseText:n.xhr.response,t.status=n.xhr.status||null,t.statusCode=t.status):(t.rawResponse=null,t.status=null),n.callback(t)}n.emit("response",r);try{n._isResponseOK(r)||(e=new Error(r.statusText||r.text||"Unsuccessful HTTP response"))}catch(t){e=t}e?(e.original=t,e.response=r,e.status=e.status||r.status,n.callback(e,r)):n.callback(null,r)})}d.serializeObject=Zs,d.parseString=ea,d.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"},d.serialize={"application/x-www-form-urlencoded":n.stringify,"application/json":r},d.parse={"application/x-www-form-urlencoded":ea,"application/json":JSON.parse},i(ra.prototype,c.prototype),ra.prototype._parseBody=function(e){let t=d.parse[this.type];return this.req._parser?this.req._parser(this,e):(t=!t&&ta(this.type)?d.parse["application/json"]:t)&&e&&(0<e.length||e instanceof Object)?t(e):null},ra.prototype.toError=function(){var e=this.req,t=e.method,e=e.url,r=`cannot ${t} ${e} (${this.status})`,r=new Error(r);return r.status=this.status,r.method=t,r.url=e,r},d.Response=ra,t(U.prototype),i(U.prototype,o.prototype),U.prototype.type=function(e){return this.set("Content-Type",d.types[e]||e),this},U.prototype.accept=function(e){return this.set("Accept",d.types[e]||e),this},U.prototype.auth=function(e,t,r){"object"==typeof(t=1===arguments.length?"":t)&&null!==t&&(r=t,t="");var n=(r=r||{type:"function"==typeof btoa?"basic":"auto"}).encoder||(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)},U.prototype.query=function(e){return(e="string"!=typeof e?Zs(e):e)&&this._query.push(e),this},U.prototype.attach=function(e,t,r){if(t){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(e,t,r||t.name)}return this},U.prototype._getFormData=function(){return this._formData||(this._formData=new e.FormData),this._formData},U.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)},U.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)},U.prototype.buffer=U.prototype.ca=U.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},U.prototype.pipe=U.prototype.write=()=>{throw new Error("Streaming is not supported in browser version of superagent")},U.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},U.prototype.end=function(e){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=e||Qs,this._finalizeQueryString(),this._end()},U.prototype._setUploadTimeout=function(){let e=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout(()=>{e._timeoutError("Upload timeout of ",e._uploadTimeout,"ETIMEDOUT")},this._uploadTimeout))},U.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));let r=this,n=(this.xhr=d.getXHR(),this.xhr),o=this._formData||this._data;this._setTimeouts(),n.addEventListener("readystatechange",()=>{var e=n.readyState;if(2<=e&&r._responseTimeoutTimer&&clearTimeout(r._responseTimeoutTimer),4===e){let t;try{t=n.status}catch(e){t=0}if(!t)return r.timedout||r._aborted?void 0:r.crossDomainError();r.emit("end")}});var e=(e,t)=>{0<t.total&&(t.percent=t.loaded/t.total*100,100===t.percent)&&clearTimeout(r._uploadTimeoutTimer),t.direction=e,r.emit("progress",t)};if(this.hasListeners("progress"))try{n.addEventListener("progress",e.bind(null,"download")),n.upload&&n.upload.addEventListener("progress",e.bind(null,"upload"))}catch(r){}n.upload&&this._setUploadTimeout();try{this.username&&this.password?n.open(this.method,this.url,!0,this.username,this.password):n.open(this.method,this.url,!0)}catch(r){return this.callback(r)}if(this._withCredentials&&(n.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof o&&!this._isHost(o)){let e=this._header["content-type"],t=this._serializer||d.serialize[e?e.split(";")[0]:""];(t=!t&&ta(e)?d.serialize["application/json"]:t)&&(o=t(o))}for(let e in this.header)null!==this.header[e]&&a(this.header,e)&&n.setRequestHeader(e,this.header[e]);this._responseType&&(n.responseType=this._responseType),this.emit("request",this),n.send(void 0===o?null:o)},d.agent=()=>new u;for(var na=0,oa=["GET","POST","OPTIONS","PATCH","PUT","DELETE"];na<oa.length;na++){let r=oa[na];u.prototype[r.toLowerCase()]=function(e,t){e=new d.Request(r,e);return this._setDefaults(e),t&&e.end(t),e}}function ia(e,t,r){e=d("DELETE",e);return"function"==typeof t&&(r=t,t=null),t&&e.send(t),r&&e.end(r),e}u.prototype.del=u.prototype.delete,d.get=(e,t,r)=>{e=d("GET",e);return"function"==typeof t&&(r=t,t=null),t&&e.query(t),r&&e.end(r),e},d.head=(e,t,r)=>{e=d("HEAD",e);return"function"==typeof t&&(r=t,t=null),t&&e.query(t),r&&e.end(r),e},d.options=(e,t,r)=>{e=d("OPTIONS",e);return"function"==typeof t&&(r=t,t=null),t&&e.send(t),r&&e.end(r),e},d.del=ia,d.delete=ia,d.patch=(e,t,r)=>{e=d("PATCH",e);return"function"==typeof t&&(r=t,t=null),t&&e.send(t),r&&e.end(r),e},d.post=(e,t,r)=>{e=d("POST",e);return"function"==typeof t&&(r=t,t=null),t&&e.send(t),r&&e.end(r),e},d.put=(e,t,r)=>{e=d("PUT",e);return"function"==typeof t&&(r=t,t=null),t&&e.send(t),r&&e.end(r),e}}var sa=h.exports;function aa(n){var o=(new Date).getTime(),e=(new Date).toISOString(),i=(!console||!console.log)&&window&&window.console&&window.console.log?window.console:console;i.log("<<<<<"),i.log("[".concat(e,"]"),"\n",n.url,"\n",n.qs),i.log("-----"),n.on("response",function(e){var t=(new Date).getTime()-o,r=(new Date).toISOString();i.log(">>>>>>"),i.log("[".concat(r," / ").concat(t,"]"),"\n",n.url,"\n",n.qs,"\n",e.text),i.log("-----")})}function ca(e,o,i){var t,s=this,r=(this._config.logVerbosity&&(e=e.use(aa)),this._config.proxy&&this._modules.proxy&&(e=this._modules.proxy.call(this,e)),e=this._config.keepAlive&&this._modules.keepAlive?this._modules.keepAlive(e):e);return o.abortSignal&&(t=o.abortSignal.subscribe(function(){r.abort(),t()})),!0===o.forceBuffered?r=("undefined"==typeof Blob?r.buffer():r).responseType("arraybuffer"):!1===o.forceBuffered&&(r=r.buffer(!1)),(r=r.timeout(o.timeout)).on("abort",function(){return i({category:v.PNUnknownCategory,error:!0,operation:o.operation,errorData:new Error("Aborted")},null)}),r.end(function(t,e){var r,n={};if(n.error=null!==t,n.operation=o.operation,e&&e.status&&(n.statusCode=e.status),t){if(t.response&&t.response.text&&!s._config.logVerbosity)try{n.errorData=JSON.parse(t.response.text)}catch(e){n.errorData=t}else n.errorData=t;return n.category=s._detectErrorCategory(t),i(n,null)}if(o.ignoreBody)r={headers:e.headers,redirects:e.redirects,response:e};else try{r=JSON.parse(e.text)}catch(t){return n.errorData=e,n.error=!0,i(n,null)}return r.error&&1===r.error&&r.status&&r.message&&r.service?(n.errorData=r,n.statusCode=r.status,n.error=!0,n.category=s._detectErrorCategory(n),i(n,null)):(r.error&&r.error.message&&(n.errorData=r.error),i(n,r))}),r}function ua(t,n,o){return _(this,void 0,void 0,function(){var r;return F(this,function(e){switch(e.label){case 0:return r=sa.post(t),n.forEach(function(e){var t=e.key;r=r.field(t,e.value)}),r.attach("file",o,{contentType:"application/octet-stream"}),[4,r];case 1:return[2,e.sent()]}})})}function da(e,t,r){e=sa.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ca.call(this,e,t,r)}function pa(e,t,r){e=sa.get(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ca.call(this,e,t,r)}function la(e,t,r,n){e=sa.post(this.getStandardOrigin()+r.url).query(e).set(r.headers).send(t);return ca.call(this,e,r,n)}function fa(e,t,r,n){e=sa.patch(this.getStandardOrigin()+r.url).query(e).set(r.headers).send(t);return ca.call(this,e,r,n)}function ha(e,t,r){e=sa.delete(this.getStandardOrigin()+t.url).set(t.headers).query(e);return ca.call(this,e,t,r)}function ga(e,t){var r=new Uint8Array(e.byteLength+t.byteLength);return r.set(new Uint8Array(e),0),r.set(new Uint8Array(t),e.byteLength),r.buffer}Object.defineProperty(C.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),C.prototype.encrypt=function(r,n){return _(this,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:return[4,this.getKey(r)];case 1:if(t=e.sent(),n instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(t,n)];if("string"==typeof n)return[2,this.encryptString(t,n)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}})})},C.prototype.decrypt=function(r,n){return _(this,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:return[4,this.getKey(r)];case 1:if(t=e.sent(),n instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(t,n)];if("string"==typeof n)return[2,this.decryptString(t,n)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}})})},C.prototype.encryptFile=function(n,o,i){return _(this,void 0,void 0,function(){var t,r;return F(this,function(e){switch(e.label){case 0:if(o.data.byteLength<=0)throw new Error("encryption error. empty content");return[4,this.getKey(n)];case 1:return t=e.sent(),[4,o.data.arrayBuffer()];case 2:return r=e.sent(),[4,this.encryptArrayBuffer(t,r)];case 3:return r=e.sent(),[2,i.create({name:o.name,mimeType:"application/octet-stream",data:r})]}})})},C.prototype.decryptFile=function(n,o,i){return _(this,void 0,void 0,function(){var t,r;return F(this,function(e){switch(e.label){case 0:return[4,this.getKey(n)];case 1:return t=e.sent(),[4,o.data.arrayBuffer()];case 2:return r=e.sent(),[4,this.decryptArrayBuffer(t,r)];case 3:return r=e.sent(),[2,i.create({name:o.name,data:r})]}})})},C.prototype.getKey=function(r){return _(this,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:return[4,crypto.subtle.digest("SHA-256",C.encoder.encode(r))];case 1:return t=e.sent(),t=Array.from(new Uint8Array(t)).map(function(e){return e.toString(16).padStart(2,"0")}).join(""),t=C.encoder.encode(t.slice(0,32)).buffer,[2,crypto.subtle.importKey("raw",t,"AES-CBC",!0,["encrypt","decrypt"])]}})})},C.prototype.encryptArrayBuffer=function(o,i){return _(this,void 0,void 0,function(){var t,r,n;return F(this,function(e){switch(e.label){case 0:return t=crypto.getRandomValues(new Uint8Array(16)),r=ga,n=[t.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:t},o,i)];case 1:return[2,r.apply(void 0,n.concat([e.sent()]))]}})})},C.prototype.decryptArrayBuffer=function(r,n){return _(this,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:if(t=n.slice(0,16),n.slice(C.IV_LENGTH).byteLength<=0)throw new Error("decryption error: empty content");return[4,crypto.subtle.decrypt({name:"AES-CBC",iv:t},r,n.slice(C.IV_LENGTH))];case 1:return[2,e.sent()]}})})},C.prototype.encryptString=function(o,i){return _(this,void 0,void 0,function(){var t,r,n;return F(this,function(e){switch(e.label){case 0:return t=crypto.getRandomValues(new Uint8Array(16)),r=C.encoder.encode(i).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:t},o,r)];case 1:return r=e.sent(),n=ga(t.buffer,r),[2,C.decoder.decode(n)]}})})},C.prototype.decryptString=function(n,o){return _(this,void 0,void 0,function(){var t,r;return F(this,function(e){switch(e.label){case 0:return t=C.encoder.encode(o).buffer,r=t.slice(0,16),t=t.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:r},n,t)];case 1:return r=e.sent(),[2,C.decoder.decode(r)]}})})},C.IV_LENGTH=16,C.encoder=new TextEncoder,C.decoder=new TextDecoder;var ya,ma=C,Ra=(Pa.create=function(e){return new this(e)},Pa.prototype.toBuffer=function(){return _(this,void 0,void 0,function(){return F(this,function(e){throw new Error("This feature is only supported in Node.js environments.")})})},Pa.prototype.toStream=function(){return _(this,void 0,void 0,function(){return F(this,function(e){throw new Error("This feature is only supported in Node.js environments.")})})},Pa.prototype.toFileUri=function(){return _(this,void 0,void 0,function(){return F(this,function(e){throw new Error("This feature is only supported in react native environments.")})})},Pa.prototype.toBlob=function(){return _(this,void 0,void 0,function(){return F(this,function(e){return[2,this.data]})})},Pa.prototype.toArrayBuffer=function(){return _(this,void 0,void 0,function(){var n=this;return F(this,function(e){return[2,new Promise(function(e,t){var r=new FileReader;r.addEventListener("load",function(){if(r.result instanceof ArrayBuffer)return e(r.result)}),r.addEventListener("error",function(){t(r.error)}),r.readAsArrayBuffer(n.data)})]})})},Pa.prototype.toString=function(){return _(this,void 0,void 0,function(){var n=this;return F(this,function(e){return[2,new Promise(function(e,t){var r=new FileReader;r.addEventListener("load",function(){if("string"==typeof r.result)return e(r.result)}),r.addEventListener("error",function(){t(r.error)}),r.readAsBinaryString(n.data)})]})})},Pa.prototype.toFile=function(){return _(this,void 0,void 0,function(){return F(this,function(e){return[2,this.data]})})},(d=Pa).supportsFile="undefined"!=typeof File,d.supportsBlob="undefined"!=typeof Blob,d.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,d.supportsBuffer=!1,d.supportsStream=!1,d.supportsString=!0,d.supportsEncryptFile=!0,d.supportsFileUri=!1,d),_a=(Object.defineProperty(Sa.prototype,"identifier",{get:function(){return""},enumerable:!1,configurable:!0}),Sa.prototype.encrypt=function(e){e="string"==typeof e?e:(new TextDecoder).decode(e);return{data:this.cryptor.encrypt(e),metadata:null}},Sa.prototype.decrypt=function(e){e="string"==typeof e.data?e.data:Z(e.data);return this.cryptor.decrypt(e)},Sa.prototype.encryptFile=function(t,r){var n;return _(this,void 0,void 0,function(){return F(this,function(e){return[2,this.fileCryptor.encryptFile(null==(n=this.config)?void 0:n.cipherKey,t,r)]})})},Sa.prototype.decryptFile=function(t,r){return _(this,void 0,void 0,function(){return F(this,function(e){return[2,this.fileCryptor.decryptFile(this.config.cipherKey,t,r)]})})},Sa),Aa=(Object.defineProperty(j.prototype,"algo",{get:function(){return"AES-CBC"},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"identifier",{get:function(){return"ACRH"},enumerable:!1,configurable:!0}),j.prototype.getIv=function(){return crypto.getRandomValues(new Uint8Array(j.BLOCK_SIZE))},j.prototype.getKey=function(){return _(this,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:return t=j.encoder.encode(this.cipherKey),[4,crypto.subtle.digest("SHA-256",t.buffer)];case 1:return t=e.sent(),[2,crypto.subtle.importKey("raw",t,this.algo,!0,["encrypt","decrypt"])]}})})},j.prototype.encrypt=function(e){if(0===("string"==typeof e?e:j.decoder.decode(e)).length)throw new Error("encryption error. empty content");var t=this.getIv();return{metadata:t,data:Q(this.CryptoJS.AES.encrypt(e,this.encryptedKey,{iv:this.bufferToWordArray(t),mode:this.CryptoJS.mode.CBC}).ciphertext.toString(this.CryptoJS.enc.Base64))}},j.prototype.decrypt=function(e){var t=this.bufferToWordArray(new Uint8ClampedArray(e.metadata)),e=this.bufferToWordArray(new Uint8ClampedArray(e.data));return j.encoder.encode(this.CryptoJS.AES.decrypt({ciphertext:e},this.encryptedKey,{iv:t,mode:this.CryptoJS.mode.CBC}).toString(this.CryptoJS.enc.Utf8)).buffer},j.prototype.encryptFileData=function(o){return _(this,void 0,void 0,function(){var t,r,n;return F(this,function(e){switch(e.label){case 0:return[4,this.getKey()];case 1:return t=e.sent(),r=this.getIv(),n={},[4,crypto.subtle.encrypt({name:this.algo,iv:r},t,o)];case 2:return[2,(n.data=e.sent(),n.metadata=r,n)]}})})},j.prototype.decryptFileData=function(r){return _(this,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:return[4,this.getKey()];case 1:return t=e.sent(),[2,crypto.subtle.decrypt({name:this.algo,iv:r.metadata},t,r.data)]}})})},j.prototype.bufferToWordArray=function(e){for(var t=[],r=0;r<e.length;r+=1)t[r/4|0]|=e[r]<<24-8*r;return this.CryptoJS.lib.WordArray.create(t,e.length)},j.BLOCK_SIZE=16,j.encoder=new TextEncoder,j.decoder=new TextDecoder,j),ba=(k.legacyCryptoModule=function(e){var t;return new this({default:new _a({cipherKey:e.cipherKey,useRandomIVs:null==(t=e.useRandomIVs)||t}),cryptors:[new Aa({cipherKey:e.cipherKey})]})},k.aesCbcCryptoModule=function(e){return new this({default:new Aa({cipherKey:e.cipherKey}),cryptors:[new _a({cipherKey:e.cipherKey,useRandomIVs:null==(e=e.useRandomIVs)||e})]})},k.withDefaultCryptor=function(e){return new this({default:e})},k.prototype.getAllCryptors=function(){return b([this.defaultCryptor],A(this.cryptors),!1)},k.prototype.encrypt=function(e){var t,e=this.defaultCryptor.encrypt(e);return e.metadata?(t=this.getHeaderData(e),this.concatArrayBuffer(t,e.data)):e.data},k.prototype.decrypt=function(e){var e="string"==typeof e?Q(e):e,t=va.tryParse(e),r=this.getCryptor(t),n=0<t.length?e.slice(t.length-t.metadataLength,t.length):null;if(e.slice(t.length).byteLength<=0)throw new Error("decryption error. empty content");return r.decrypt({data:e.slice(t.length),metadata:n})},k.prototype.encryptFile=function(r,n){return _(this,void 0,void 0,function(){var t;return F(this,function(e){switch(e.label){case 0:return this.defaultCryptor.identifier===va.LEGACY_IDENTIFIER?[2,this.defaultCryptor.encryptFile(r,n)]:[4,this.getFileData(r.data)];case 1:return t=e.sent(),[4,this.defaultCryptor.encryptFileData(t)];case 2:return t=e.sent(),[2,n.create({name:r.name,mimeType:"application/octet-stream",data:this.concatArrayBuffer(this.getHeaderData(t),t.data)})]}})})},k.prototype.decryptFile=function(c,u){return _(this,void 0,void 0,function(){var t,r,n,o,i,s,a;return F(this,function(e){switch(e.label){case 0:return[4,c.data.arrayBuffer()];case 1:return t=e.sent(),r=va.tryParse(t),(null==(n=this.getCryptor(r))?void 0:n.identifier)===k.LEGACY_IDENTIFIER?[2,n.decryptFile(c,u)]:[4,this.getFileData(t)];case 2:return n=e.sent(),o=n.slice(r.length-r.metadataLength,r.length),s=(i=u).create,a={name:c.name},[4,this.defaultCryptor.decryptFileData({data:t.slice(r.length),metadata:o})];case 3:return[2,s.apply(i,[(a.data=e.sent(),a)])]}})})},k.prototype.getCryptor=function(e){if(""===e){var t=this.getAllCryptors().find(function(e){return""===e.identifier});if(t)return t;throw new Error("unknown cryptor error")}if(e instanceof Ia)return this.getCryptorFromId(e.identifier)},k.prototype.getCryptorFromId=function(t){var e=this.getAllCryptors().find(function(e){return t===e.identifier});if(e)return e;throw Error("unknown cryptor error")},k.prototype.concatArrayBuffer=function(e,t){var r=new Uint8Array(e.byteLength+t.byteLength);return r.set(new Uint8Array(e),0),r.set(new Uint8Array(t),e.byteLength),r.buffer},k.prototype.getHeaderData=function(e){var t,r,n;if(e.metadata)return t=va.from(this.defaultCryptor.identifier,e.metadata),(r=new Uint8Array(t.length)).set(t.data,n=0),n+=t.length-e.metadata.byteLength,r.set(new Uint8Array(e.metadata),n),r.buffer},k.prototype.getFileData=function(t){return _(this,void 0,void 0,function(){return F(this,function(e){switch(e.label){case 0:return t instanceof Blob?[4,t.arrayBuffer()]:[3,2];case 1:return[2,e.sent()];case 2:if(t instanceof ArrayBuffer)return[2,t];if("string"==typeof t)return[2,k.encoder.encode(t)];throw new Error("Cannot decrypt/encrypt file. In browsers file encrypt/decrypt supported for string, ArrayBuffer or Blob")}})})},k.LEGACY_IDENTIFIER="",k.encoder=new TextEncoder,k.decoder=new TextDecoder,k),va=(Ea.from=function(e,t){if(e!==Ea.LEGACY_IDENTIFIER)return new Ia(e,t.byteLength)},Ea.tryParse=function(e){e=new Uint8Array(e);if(4<=e.byteLength&&(t=e.slice(0,4),this.decoder.decode(t)!==Ea.SENTINEL))return"";if(!(5<=e.byteLength))throw new Error("decryption error. invalid header version");if(Ea.MAX_VERSION<e[4])throw new Error("unknown cryptor error");var t=5+Ea.IDENTIFIER_LENGTH;if(!(t<=e.byteLength))throw new Error("decryption error. invalid crypto identifier");var r=e.slice(5,t),n=null;if(e.byteLength>=t+1)return n=e[t],t+=1,255===n&&e.byteLength>=t+2&&(n=new Uint16Array(e.slice(t,t+2)).reduce(function(e,t){return(e<<8)+t},0),0),new Ia(this.decoder.decode(r),n);throw new Error("decryption error. invalid metadata length")},Ea.SENTINEL="PNED",Ea.LEGACY_IDENTIFIER="",Ea.IDENTIFIER_LENGTH=4,Ea.VERSION=1,Ea.MAX_VERSION=1,Ea.decoder=new TextDecoder,Ea),Ia=(Object.defineProperty(Ta.prototype,"identifier",{get:function(){return this._identifier},set:function(e){this._identifier=e},enumerable:!1,configurable:!0}),Object.defineProperty(Ta.prototype,"metadataLength",{get:function(){return this._metadataLength},set:function(e){this._metadataLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(Ta.prototype,"version",{get:function(){return va.VERSION},enumerable:!1,configurable:!0}),Object.defineProperty(Ta.prototype,"length",{get:function(){return va.SENTINEL.length+1+va.IDENTIFIER_LENGTH+(this.metadataLength<255?1:3)+this.metadataLength},enumerable:!1,configurable:!0}),Object.defineProperty(Ta.prototype,"data",{get:function(){var e=0,t=new Uint8Array(this.length),r=new TextEncoder,r=(t.set(r.encode(va.SENTINEL)),t[e+=va.SENTINEL.length]=this.version,e++,this.identifier&&t.set(r.encode(this.identifier),e),e+=va.IDENTIFIER_LENGTH,this.metadataLength);return r<255?t[e]=r:t.set([255,r>>8,255&r],e),t},enumerable:!1,configurable:!0}),Ta.IDENTIFIER_LENGTH=4,Ta.SENTINEL="PNED",Ta);function Ta(e,t){this._identifier=e,this._metadataLength=t}function Ea(){}function k(e){this.defaultCryptor=e.default,this.cryptors=null!=(e=e.cryptors)?e:[]}function j(e){this.cipherKey=e.cipherKey,this.CryptoJS=c,this.encryptedKey=this.CryptoJS.SHA256(this.cipherKey)}function Sa(e){this.config=e,this.cryptor=new at({config:e}),this.fileCryptor=new ma}function Pa(e){var t;if(e instanceof File?(this.data=e,this.name=this.data.name,this.mimeType=this.data.type):e.data&&(t=e.data,this.data=new File([t],e.name,{type:e.mimeType}),this.name=e.name,e.mimeType)&&(this.mimeType=e.mimeType),void 0===this.data)throw new Error("Couldn't construct a file out of supplied options.");if(void 0===this.name)throw new Error("Couldn't guess filename out of the options. Please provide one.")}function C(){}function Oa(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}function wa(e){var t=this,r=e.listenToBrowserNetworkEvents,r=void 0===r||r;return e.sdkFamily="Web",e.networking=new ro({del:ha,get:pa,post:la,patch:fa,sendBeacon:Oa,getfile:da,postfile:ua}),e.cbor=new uo(function(e){return co(X.decode(e))},Q),e.PubNubFile=Ra,e.cryptography=new ma,e.initCryptoModule=function(e){return new ba({default:new _a({cipherKey:e.cipherKey,useRandomIVs:e.useRandomIVs}),cryptors:[new Aa({cipherKey:e.cipherKey})]})},t=ya.call(this,e)||this,r&&(window.addEventListener("offline",function(){t.networkDownDetected()}),window.addEventListener("online",function(){t.networkUpDetected()})),t}return D(wa,ya=t),wa.CryptoModule=ba,wa},"object"==typeof n&&void 0!==r?r.exports=t():(e="undefined"!=typeof globalThis?globalThis:e||self).PubNub=t()}.call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:40}],42:[function(e,n,o){!function(te){function e(){var a=!1;try{throw new Error}catch(e){a=!!e.stack}function t(){}var i,e,r,n,o,s,c,u,d,p,L=z();function l(){for(var e,t;o.next;)e=(o=o.next).task,o.task=void 0,(t=o.domain)&&(o.domain=void 0,t.enter()),f(e,t);for(;p.length;)f(e=p.pop());c=!1}function f(e,t){try{e()}catch(e){if(d)throw t&&t.exit(),setTimeout(l,0),t&&t.enter(),e;setTimeout(function(){throw e},0)}t&&t.exit()}s=o={task:void 0,next:null},u=void 0,d=c=!1,p=[],e=function(e){s=s.next={task:e,domain:d&&te.domain,next:null},c||(c=!0,u())},u="object"==typeof te&&"[object process]"===te.toString()&&te.nextTick?(d=!0,function(){te.nextTick(l)}):"function"==typeof setImmediate?"undefined"!=typeof window?setImmediate.bind(window,l):function(){setImmediate(l)}:"undefined"!=typeof MessageChannel?((r=new MessageChannel).port1.onmessage=function(){u=n,(r.port1.onmessage=l)()},n=function(){r.port2.postMessage(0)},function(){setTimeout(l,0),n()}):function(){setTimeout(l,0)},e.runAfter=function(e){p.push(e),c||(c=!0,u())};var N=Function.call;function h(e){return function(){return N.apply(e,arguments)}}var g=h(Array.prototype.slice),y=h(Array.prototype.reduce||function(e,t){var r=0,n=this.length;if(1===arguments.length)for(;;){if(r in this){t=this[r++];break}if(++r>=n)throw new TypeError}for(;r<n;r++)r in this&&(t=e(t,this[r],r));return t}),m=h(Array.prototype.indexOf||function(e){for(var t=0;t<this.length;t++)if(this[t]===e)return t;return-1}),R=h(Array.prototype.map||function(n,o){var i=this,s=[];return y(i,function(e,t,r){s.push(n.call(o,t,r,i))},void 0),s}),_=Object.create||function(e){function t(){}return t.prototype=e,new t},H=h(Object.prototype.hasOwnProperty),M=Object.keys||function(e){var t,r=[];for(t in e)H(e,t)&&r.push(t);return r},F=h(Object.prototype.toString),A="undefined"!=typeof ReturnValue?ReturnValue:function(e){this.value=e},q="From previous event:";function Y(e,t){if(a&&t.stack&&"object"==typeof e&&null!==e&&e.stack&&-1===e.stack.indexOf(q)){for(var r=[],n=t;n;n=n.source)n.stack&&r.unshift(n.stack);r.unshift(e.stack);t=r.join("\n"+q+"\n");e.stack=(e=>{for(var t=e.split("\n"),r=[],n=0;n<t.length;++n){var o=t[n];(e=>{var t;return(e=K(e))&&(t=e[0],e=e[1],t===i)&&L<=e&&e<=ee})(o)||(e=>-1!==e.indexOf("(module.js:")||-1!==e.indexOf("(node.js:"))(o)||!o||r.push(o)}return r.join("\n")})(t)}}function K(e){var t=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(e);return(t=t||/at ([^ ]+):(\d+):(?:\d+)$/.exec(e))?[t[1],Number(t[2])]:(t=/.*@(.+):(\d+)$/.exec(e))?[t[1],Number(t[2])]:void 0}function z(){if(a)try{throw new Error}catch(e){var t=e.stack.split("\n"),t=K(0<t[0].indexOf("@")?t[1]:t[2]);if(t)return i=t[0],t[1]}}function b(e){return e instanceof T?e:B(e)?(t=e,r=v(),b.nextTick(function(){try{t.then(r.resolve,r.reject,r.notify)}catch(e){r.reject(e)}}),r.promise):x(e);var t,r}function v(){var o,i=[],s=[],e=_(v.prototype),t=_(T.prototype);if(t.promiseDispatch=function(e,t,r){var n=g(arguments);i?(i.push(n),"when"===t&&r[1]&&s.push(r[1])):b.nextTick(function(){o.promiseDispatch.apply(o,n)})},t.valueOf=function(){var e;return i?t:(S(e=X(o))&&(o=e),e)},t.inspect=function(){return o?o.inspect():{state:"pending"}},b.longStackSupport&&a)try{throw new Error}catch(e){t.stack=e.stack.substring(e.stack.indexOf("\n")+1)}function r(r){o=r,t.source=r,y(i,function(e,t){b.nextTick(function(){r.promiseDispatch.apply(r,t)})},void 0),s=i=void 0}return e.promise=t,e.resolve=function(e){o||r(b(e))},e.fulfill=function(e){o||r(x(e))},e.reject=function(e){o||r(C(e))},e.notify=function(r){o||y(s,function(e,t){b.nextTick(function(){t(r)})},void 0)},e}function I(e){if("function"!=typeof e)throw new TypeError("resolver must be a function.");var t=v();try{e(t.resolve,t.reject,t.notify)}catch(e){t.reject(e)}return t.promise}function G(o){return I(function(e,t){for(var r=0,n=o.length;r<n;r++)b(o[r]).then(e,t)})}function T(o,i,t){void 0===i&&(i=function(e){return C(new Error("Promise does not support operation: "+e))}),void 0===t&&(t=function(){return{state:"unknown"}});var e,s=_(T.prototype);return s.promiseDispatch=function(e,t,r){var n;try{n=o[t]?o[t].apply(s,r):i.call(s,t,r)}catch(e){n=C(e)}e&&e(n)},(s.inspect=t)&&("rejected"===(e=t()).state&&(s.exception=e.reason),s.valueOf=function(){var e=t();return"pending"===e.state||"rejected"===e.state?s:e.value}),s}function E(e,t,r,n){return b(e).then(t,r,n)}function X(e){if(S(e)){var t=e.inspect();if("fulfilled"===t.state)return t.value}return e}function S(e){return e instanceof T}function B(e){return e===Object(e)&&"function"==typeof e.then}(b.resolve=b).nextTick=e,b.longStackSupport=!1,"object"==typeof te&&te&&te.env&&te.env.Q_DEBUG&&(b.longStackSupport=!0),(b.defer=v).prototype.makeNodeResolver=function(){var r=this;return function(e,t){e?r.reject(e):2<arguments.length?r.resolve(g(arguments,1)):r.resolve(t)}},b.Promise=I,(b.promise=I).race=G,I.all=D,I.reject=C,(I.resolve=b).passByCopy=function(e){return e},T.prototype.passByCopy=function(){return this},b.join=function(e,t){return b(e).join(t)},T.prototype.join=function(e){return b([this,e]).spread(function(e,t){if(e===t)return e;throw new Error("Can't join: not the same: "+e+" "+t)})},b.race=G,T.prototype.race=function(){return this.then(b.race)},(b.makePromise=T).prototype.toString=function(){return"[object Promise]"},T.prototype.then=function(t,r,o){var n=this,i=v(),s=!1;return b.nextTick(function(){n.promiseDispatch(function(e){s||(s=!0,i.resolve((e=>{try{return"function"==typeof t?t(e):e}catch(e){return C(e)}})(e)))},"when",[function(e){s||(s=!0,i.resolve((e=>{if("function"==typeof r){Y(e,n);try{return r(e)}catch(e){return C(e)}}return C(e)})(e)))}])}),n.promiseDispatch(void 0,"when",[void 0,function(e){var t,r,n=!1;try{r=e,t="function"==typeof o?o(r):r}catch(e){if(n=!0,!b.onerror)throw e;b.onerror(e)}n||i.notify(t)}]),i.promise},b.tap=function(e,t){return b(e).tap(t)},T.prototype.tap=function(t){return t=b(t),this.then(function(e){return t.fcall(e).thenResolve(e)})},b.when=E,T.prototype.thenResolve=function(e){return this.then(function(){return e})},b.thenResolve=function(e,t){return b(e).thenResolve(t)},T.prototype.thenReject=function(e){return this.then(function(){throw e})},b.thenReject=function(e,t){return b(e).thenReject(t)},b.nearer=X,b.isPromise=S,b.isPromiseAlike=B,b.isPending=function(e){return S(e)&&"pending"===e.inspect().state},T.prototype.isPending=function(){return"pending"===this.inspect().state},b.isFulfilled=function(e){return!S(e)||"fulfilled"===e.inspect().state},T.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},b.isRejected=function(e){return S(e)&&"rejected"===e.inspect().state},T.prototype.isRejected=function(){return"rejected"===this.inspect().state};var P,V,W,O=[],w=[],U=[],k=!0;function j(){O.length=0,w.length=0,k=k||!0}function C(n){var e,t,r=T({when:function(e){var t,r;return e&&(t=this,k)&&-1!==(r=m(w,t))&&("object"==typeof te&&"function"==typeof te.emit&&b.nextTick.runAfter(function(){var e=m(U,t);-1!==e&&(te.emit("rejectionHandled",O[r],t),U.splice(e,1))}),w.splice(r,1),O.splice(r,1)),e?e(n):this}},function(){return this},function(){return{state:"rejected",reason:n}});return e=r,t=n,k&&("object"==typeof te&&"function"==typeof te.emit&&b.nextTick.runAfter(function(){-1!==m(w,e)&&(te.emit("unhandledRejection",t,e),U.push(e))}),w.push(e),t&&void 0!==t.stack?O.push(t.stack):O.push("(no stack) "+t)),r}function x(r){return T({when:function(){return r},get:function(e){return r[e]},set:function(e,t){r[e]=t},delete:function(e){delete r[e]},post:function(e,t){return null==e?r.apply(void 0,t):r[e].apply(r,t)},apply:function(e,t){return r.apply(e,t)},keys:function(){return M(r)}},void 0,function(){return{state:"fulfilled",value:r}})}function J(e,t,r){return b(e).spread(t,r)}function $(e,t,r){return b(e).dispatch(t,r)}function D(e){return E(e,function(o){var i=0,s=v();return y(o,function(e,t,r){var n;S(t)&&"fulfilled"===(n=t.inspect()).state?o[r]=n.value:(++i,E(t,function(e){o[r]=e,0==--i&&s.resolve(o)},s.reject,function(e){s.notify({index:r,value:e})}))},void 0),0===i&&s.resolve(o),s.promise})}function Q(o){var i,s;return 0===o.length?b.resolve():(i=b.defer(),y(o,function(e,t,r){var n=o[r];s++,E(n,function(e){i.resolve(e)},function(){0==--s&&i.reject(new Error("Can't get fulfillment value from any promise, all promises were rejected."))},function(e){i.notify({index:r,value:e})})},void(s=0)),i.promise)}function Z(e){return E(e,function(e){return e=R(e,b),E(D(R(e,function(e){return E(e,t,t)})),function(){return e})})}b.resetUnhandledRejections=j,b.getUnhandledReasons=function(){return O.slice()},b.stopUnhandledRejectionTracking=function(){j(),k=!1},j(),b.reject=C,b.fulfill=x,b.master=function(r){return T({isDef:function(){}},function(e,t){return $(r,e,t)},function(){return b(r).inspect()})},b.spread=J,T.prototype.spread=function(t,e){return this.all().then(function(e){return t.apply(void 0,e)},e)},b.async=function(t){return function(){function e(t,e){var r;if("undefined"==typeof StopIteration){try{r=n[t](e)}catch(e){return C(e)}return r.done?b(r.value):E(r.value,o,i)}try{r=n[t](e)}catch(e){return"[object StopIteration]"===F(t=e)||t instanceof A?b(e.value):C(e)}return E(r,o,i)}var n=t.apply(this,arguments),o=e.bind(e,"next"),i=e.bind(e,"throw");return o()}},b.spawn=function(e){b.done(b.async(e)())},b.return=function(e){throw new A(e)},b.promised=function(r){return function(){return J([this,D(arguments)],function(e,t){return r.apply(e,t)})}},b.dispatch=$,T.prototype.dispatch=function(e,t){var r=this,n=v();return b.nextTick(function(){r.promiseDispatch(n.resolve,e,t)}),n.promise},b.get=function(e,t){return b(e).dispatch("get",[t])},T.prototype.get=function(e){return this.dispatch("get",[e])},b.set=function(e,t,r){return b(e).dispatch("set",[t,r])},T.prototype.set=function(e,t){return this.dispatch("set",[e,t])},b.del=b.delete=function(e,t){return b(e).dispatch("delete",[t])},T.prototype.del=T.prototype.delete=function(e){return this.dispatch("delete",[e])},b.mapply=b.post=function(e,t,r){return b(e).dispatch("post",[t,r])},T.prototype.mapply=T.prototype.post=function(e,t){return this.dispatch("post",[e,t])},b.send=b.mcall=b.invoke=function(e,t){return b(e).dispatch("post",[t,g(arguments,2)])},T.prototype.send=T.prototype.mcall=T.prototype.invoke=function(e){return this.dispatch("post",[e,g(arguments,1)])},b.fapply=function(e,t){return b(e).dispatch("apply",[void 0,t])},T.prototype.fapply=function(e){return this.dispatch("apply",[void 0,e])},b.try=b.fcall=function(e){return b(e).dispatch("apply",[void 0,g(arguments,1)])},T.prototype.fcall=function(){return this.dispatch("apply",[void 0,g(arguments)])},b.fbind=function(e){var t=b(e),r=g(arguments,1);return function(){return t.dispatch("apply",[this,r.concat(g(arguments))])}},T.prototype.fbind=function(){var e=this,t=g(arguments);return function(){return e.dispatch("apply",[this,t.concat(g(arguments))])}},b.keys=function(e){return b(e).dispatch("keys",[])},T.prototype.keys=function(){return this.dispatch("keys",[])},b.all=D,T.prototype.all=function(){return D(this)},b.any=Q,T.prototype.any=function(){return Q(this)},b.allResolved=(P=Z,V="allResolved",W="allSettled",function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(V+" is deprecated, use "+W+" instead.",new Error("").stack),P.apply(P,arguments)}),T.prototype.allResolved=function(){return Z(this)},b.allSettled=function(e){return b(e).allSettled()},T.prototype.allSettled=function(){return this.then(function(e){return D(R(e,function(e){function t(){return e.inspect()}return(e=b(e)).then(t,t)}))})},b.fail=b.catch=function(e,t){return b(e).then(void 0,t)},T.prototype.fail=T.prototype.catch=function(e){return this.then(void 0,e)},b.progress=function(e,t){return b(e).then(void 0,void 0,t)},T.prototype.progress=function(e){return this.then(void 0,void 0,e)},b.fin=b.finally=function(e,t){return b(e).finally(t)},T.prototype.fin=T.prototype.finally=function(t){return t=b(t),this.then(function(e){return t.fcall().then(function(){return e})},function(e){return t.fcall().then(function(){throw e})})},b.done=function(e,t,r,n){return b(e).done(t,r,n)},T.prototype.done=function(e,t,r){var n=function(e){b.nextTick(function(){if(Y(e,o),!b.onerror)throw e;b.onerror(e)})},o=e||t||r?this.then(e,t,r):this;"object"==typeof te&&te&&te.domain&&(n=te.domain.bind(n)),o.then(void 0,n)},b.timeout=function(e,t,r){return b(e).timeout(t,r)},T.prototype.timeout=function(e,t){var r=v(),n=setTimeout(function(){t&&"string"!=typeof t||((t=new Error(t||"Timed out after "+e+" ms")).code="ETIMEDOUT"),r.reject(t)},e);return this.then(function(e){clearTimeout(n),r.resolve(e)},function(e){clearTimeout(n),r.reject(e)},r.notify),r.promise},b.delay=function(e,t){return void 0===t&&(t=e,e=void 0),b(e).delay(t)},T.prototype.delay=function(r){return this.then(function(e){var t=v();return setTimeout(function(){t.resolve(e)},r),t.promise})},b.nfapply=function(e,t){return b(e).nfapply(t)},T.prototype.nfapply=function(e){var t=v(),e=g(e);return e.push(t.makeNodeResolver()),this.fapply(e).fail(t.reject),t.promise},b.nfcall=function(e){var t=g(arguments,1);return b(e).nfapply(t)},T.prototype.nfcall=function(){var e=g(arguments),t=v();return e.push(t.makeNodeResolver()),this.fapply(e).fail(t.reject),t.promise},b.nfbind=b.denodeify=function(r){var n=g(arguments,1);return function(){var e=n.concat(g(arguments)),t=v();return e.push(t.makeNodeResolver()),b(r).fapply(e).fail(t.reject),t.promise}},T.prototype.nfbind=T.prototype.denodeify=function(){var e=g(arguments);return e.unshift(this),b.denodeify.apply(void 0,e)},b.nbind=function(r,n){var o=g(arguments,2);return function(){var e=o.concat(g(arguments)),t=v();return e.push(t.makeNodeResolver()),b(function(){return r.apply(n,arguments)}).fapply(e).fail(t.reject),t.promise}},T.prototype.nbind=function(){var e=g(arguments,0);return e.unshift(this),b.nbind.apply(void 0,e)},b.nmapply=b.npost=function(e,t,r){return b(e).npost(t,r)},T.prototype.nmapply=T.prototype.npost=function(e,t){var t=g(t||[]),r=v();return t.push(r.makeNodeResolver()),this.dispatch("post",[e,t]).fail(r.reject),r.promise},b.nsend=b.nmcall=b.ninvoke=function(e,t){var r=g(arguments,2),n=v();return r.push(n.makeNodeResolver()),b(e).dispatch("post",[t,r]).fail(n.reject),n.promise},T.prototype.nsend=T.prototype.nmcall=T.prototype.ninvoke=function(e){var t=g(arguments,1),r=v();return t.push(r.makeNodeResolver()),this.dispatch("post",[e,t]).fail(r.reject),r.promise},b.nodeify=function(e,t){return b(e).nodeify(t)},T.prototype.nodeify=function(t){if(!t)return this;this.then(function(e){b.nextTick(function(){t(null,e)})},function(e){b.nextTick(function(){t(e)})})},b.noConflict=function(){throw new Error("Q.noConflict only works when Q is used as a global")};var ee=z();return b}if("function"==typeof bootstrap)bootstrap("promise",e);else if("object"==typeof o&&"object"==typeof n)n.exports=e();else if("undefined"!=typeof ses)ses.ok()&&(ses.makeQ=e);else{if("undefined"==typeof window&&"undefined"==typeof self)throw new Error("This environment was not anticipated by Q. Please file a bug.");var t="undefined"!=typeof window?window:self,r=t.Q;t.Q=e(),t.Q.noConflict=function(){return t.Q=r,this}}}.call(this,e("_process"))},{_process:40}],43:[function(e,t,r){var i=/\{([0-9a-zA-Z_]+)\}/g;t.exports=function(n){var o;if(2===arguments.length&&"object"==typeof arguments[1])o=arguments[1];else{o=new Array(arguments.length-1);for(var e=1;e<arguments.length;++e)o[e-1]=arguments[e]}o&&o.hasOwnProperty||(o={});return n.replace(i,function(e,t,r){return"{"===n[r-1]&&"}"===n[r+e.length]?t:null==(r=o.hasOwnProperty(t)?o[t]:null)?"":r})}},{}],44:[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(t){this._defaults.forEach(function(e){t[e.fn].apply(t,e.arguments)})},t.exports=n},{}],45:[function(e,t,r){var n="undefined"!=typeof window?window:"undefined"!=typeof self?self:(console.warn("Using browser-only version of superagent in non-browser environment"),this),o=e("component-emitter"),i=e("./request-base"),s=e("./is-object"),a=e("./response-base"),c=e("./agent-base");function u(){}var d=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)},p=(r.Request=y,d.getXHR=function(){if(!(!n.XMLHttpRequest||n.location&&"file:"==n.location.protocol&&n.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")},"".trim?function(e){return e.trim()}:function(e){return e.replace(/(^\s*|\s*$)/g,"")});function l(e){if(!s(e))return e;var t,r=[];for(t in e)!function t(r,n,e){if(null!=e)if(Array.isArray(e))e.forEach(function(e){t(r,n,e)});else if(s(e))for(var o in e)t(r,n+"["+o+"]",e[o]);else r.push(encodeURIComponent(n)+"="+encodeURIComponent(e));else null===e&&r.push(encodeURIComponent(n))}(r,t,e[t]);return r.join("&")}function f(e){for(var t,r,n={},o=e.split("&"),i=0,s=o.length;i<s;++i)-1==(r=(t=o[i]).indexOf("="))?n[decodeURIComponent(t)]="":n[decodeURIComponent(t.slice(0,r))]=decodeURIComponent(t.slice(r+1));return n}function h(e){return/[\/+]json($|[^-\w])/.test(e)}function g(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;this._setStatusProperties(t=1223===t?204:t),this.header=this.headers=(e=>{for(var t,r,n,o=e.split(/\r?\n/),i={},s=0,a=o.length;s<a;++s)-1!==(t=(n=o[s]).indexOf(":"))&&(r=n.slice(0,t).toLowerCase(),n=p(n.slice(t+1)),i[r]=n);return i})(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.xhr.response):null}function y(e,t){var n=this;this._query=this._query||[],this.method=e,this.url=t,this.header={},this._header={},this.on("end",function(){var t,r=null,e=null;try{e=new g(n)}catch(e){return(r=new Error("Parser is unable to parse the response")).parse=!0,r.original=e,n.xhr?(r.rawResponse=void 0===n.xhr.responseType?n.xhr.responseText:n.xhr.response,r.status=n.xhr.status||null,r.statusCode=r.status):(r.rawResponse=null,r.status=null),n.callback(r)}n.emit("response",e);try{n._isResponseOK(e)||(t=new Error(e.statusText||"Unsuccessful HTTP response"))}catch(e){t=e}t?(t.original=r,t.response=e,t.status=e.status,n.callback(t,e)):n.callback(null,e)})}function m(e,t,r){e=d("DELETE",e);return"function"==typeof t&&(r=t,t=null),t&&e.send(t),r&&e.end(r),e}d.serializeObject=l,d.parseString=f,d.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"},d.serialize={"application/x-www-form-urlencoded":l,"application/json":JSON.stringify},d.parse={"application/x-www-form-urlencoded":f,"application/json":JSON.parse},a(g.prototype),g.prototype._parseBody=function(e){var t=d.parse[this.type];return this.req._parser?this.req._parser(this,e):(t=!t&&h(this.type)?d.parse["application/json"]:t)&&e&&(e.length||e instanceof Object)?t(e):null},g.prototype.toError=function(){var e=this.req,t=e.method,e=e.url,r="cannot "+t+" "+e+" ("+this.status+")",r=new Error(r);return r.status=this.status,r.method=t,r.url=e,r},d.Response=g,o(y.prototype),i(y.prototype),y.prototype.type=function(e){return this.set("Content-Type",d.types[e]||e),this},y.prototype.accept=function(e){return this.set("Accept",d.types[e]||e),this},y.prototype.auth=function(e,t,r){"object"==typeof(t=1===arguments.length?"":t)&&null!==t&&(r=t,t=""),r=r||{type:"function"==typeof btoa?"basic":"auto"};return this._auth(e,t,r,function(e){if("function"==typeof btoa)return btoa(e);throw new Error("Cannot use basic auth, btoa is not a function")})},y.prototype.query=function(e){return(e="string"!=typeof e?l(e):e)&&this._query.push(e),this},y.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},y.prototype._getFormData=function(){return this._formData||(this._formData=new n.FormData),this._formData},y.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)},y.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)},y.prototype.buffer=y.prototype.ca=y.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},y.prototype.pipe=y.prototype.write=function(){throw Error("Streaming is not supported in browser version of superagent")},y.prototype._isHost=function(e){return e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"!==Object.prototype.toString.call(e)},y.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||u,this._finalizeQueryString(),this._end()},y.prototype._end=function(){function e(e,t){0<t.total&&(t.percent=t.loaded/t.total*100),t.direction=e,o.emit("progress",t)}var t,r,n,o=this,i=this.xhr=d.getXHR(),s=this._formData||this._data;this._setTimeouts(),i.onreadystatechange=function(){var t,e=i.readyState;if(2<=e&&o._responseTimeoutTimer&&clearTimeout(o._responseTimeoutTimer),4==e){try{t=i.status}catch(e){t=0}if(!t)return o.timedout||o._aborted?void 0:o.crossDomainError();o.emit("end")}};if(this.hasListeners("progress"))try{i.onprogress=e.bind(null,"download"),i.upload&&(i.upload.onprogress=e.bind(null,"upload"))}catch(e){}try{this.username&&this.password?i.open(this.method,this.url,!0,this.username,this.password):i.open(this.method,this.url,!0)}catch(e){return this.callback(e)}for(n in this._withCredentials&&(i.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof s&&!this._isHost(s)&&(t=this._header["content-type"],r=!(r=this._serializer||d.serialize[t?t.split(";")[0]:""])&&h(t)?d.serialize["application/json"]:r)&&(s=r(s)),this.header)null!=this.header[n]&&this.header.hasOwnProperty(n)&&i.setRequestHeader(n,this.header[n]);return this._responseType&&(i.responseType=this._responseType),this.emit("request",this),i.send(void 0!==s?s:null),this},d.agent=function(){return new c},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(r){c.prototype[r.toLowerCase()]=function(e,t){e=new d.Request(r,e);return this._setDefaults(e),t&&e.end(t),e}}),c.prototype.del=c.prototype.delete,d.get=function(e,t,r){e=d("GET",e);return"function"==typeof t&&(r=t,t=null),t&&e.query(t),r&&e.end(r),e},d.head=function(e,t,r){e=d("HEAD",e);return"function"==typeof t&&(r=t,t=null),t&&e.query(t),r&&e.end(r),e},d.options=function(e,t,r){e=d("OPTIONS",e);return"function"==typeof t&&(r=t,t=null),t&&e.send(t),r&&e.end(r),e},d.del=m,d.delete=m,d.patch=function(e,t,r){e=d("PATCH",e);return"function"==typeof t&&(r=t,t=null),t&&e.send(t),r&&e.end(r),e},d.post=function(e,t,r){e=d("POST",e);return"function"==typeof t&&(r=t,t=null),t&&e.send(t),r&&e.end(r),e},d.put=function(e,t,r){e=d("PUT",e);return"function"==typeof t&&(r=t,t=null),t&&e.send(t),r&&e.end(r),e}},{"./agent-base":44,"./is-object":46,"./request-base":47,"./response-base":48,"component-emitter":37}],46:[function(e,t,r){t.exports=function(e){return null!==e&&"object"==typeof e}},{}],47:[function(e,t,r){var o=e("./is-object");function n(e){if(e){var t,r=e;for(t in n.prototype)r[t]=n.prototype[t];return r}}(t.exports=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)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)}else this._timeout=e,this._responseTimeout=0;return this},n.prototype.retry=function(e,t){return this._maxRetries=e=(e=0!==arguments.length&&!0!==e?e:1)<=0?0:e,this._retries=0,this._retryCallback=t,this};var i=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];n.prototype._shouldRetry=function(e,t){if(this._maxRetries&&!(this._retries++>=this._maxRetries)){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&&500<=t.status&&501!=t.status)return!0;if(e){if(e.code&&~i.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){var o;return this._fullfilledPromise||((o=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(r,n){o.end(function(e,t){e?n(e):r(t)})})),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):200<=e.status&&e.status<300)},n.prototype.getHeader=n.prototype.get=function(e){return this._header[e.toLowerCase()]},n.prototype.set=function(e,t){if(o(e))for(var r in e)this.set(r,e[r]);else this._header[e.toLowerCase()]=t,this.header[e]=t;return 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)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]);else if(Array.isArray(t))for(var n in t)this.field(e,t[n]);else{if(null==t)throw new Error(".field(name, val) val can not be empty");"boolean"==typeof t&&(t=""+t),this._getFormData().append(e,t)}return this},n.prototype.abort=function(){return this._aborted||(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 this._withCredentials=e=null==e?!0: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)||r||this.type("json"),this},n.prototype.sortQuery=function(e){return this._sort=void 0===e||e,this},n.prototype._finalizeQueryString=function(){var e,t=this._query.join("&");t&&(this.url+=(0<=this.url.indexOf("?")?"&":"?")+t),this._query.length=0,this._sort&&0<=(t=this.url.indexOf("?"))&&(e=this.url.substring(t+1).split("&"),"function"==typeof this._sort?e.sort(this._sort):e.sort(),this.url=this.url.substring(0,t)+"?"+e.join("&"))},n.prototype._appendQueryString=function(){console.trace("Unsupported")},n.prototype._timeoutError=function(e,t,r){this._aborted||((e=new Error(e+t+"ms exceeded")).timeout=t,e.code="ECONNABORTED",e.errno=r,this.timedout=!0,this.abort(),this.callback(e))},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":46}],48:[function(e,t,r){var o=e("./utils");function n(e){if(e){var t,r=e;for(t in n.prototype)r[t]=n.prototype[t];return r}}(t.exports=n).prototype.get=function(e){return this.header[e.toLowerCase()]},n.prototype._setHeaderProperties=function(e){var t,r=e["content-type"]||"",n=(this.type=o.type(r),o.params(r));for(t in n)this[t]=n[t];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.created=201==e,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,this.unprocessableEntity=422==e}},{"./utils":49}],49:[function(e,t,r){r.type=function(e){return e.split(/ *; */).shift()},r.params=function(e){return e.split(/ *; */).reduce(function(e,t){var t=t.split(/ *= */),r=t.shift(),t=t.shift();return r&&t&&(e[r]=t),e},{})},r.parseLinks=function(e){return e.split(/ *, */).reduce(function(e,t){var t=t.split(/ *; */),r=t[0].slice(1,-1);return e[t[1].split(/ *= */)[1].slice(1,-1)]=r,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}},{}],50:[function(e,t,r){!function(e,t,r){function s(e,t,r){r=d.extend({},d.options,r);var n,o,i=d.runValidations(e,t,r);for(n in i)for(o in i[n])if(d.isPromise(i[n][o]))throw new Error("Use validate.async if you want support for promises");return s.processValidationResults(i,r)}var d=s;d.extend=function(r){return[].slice.call(arguments,1).forEach(function(e){for(var t in e)r[t]=e[t]}),r},d.extend(s,{version:{major:0,minor:9,patch:0,metadata:null,toString:function(){var e=d.format("%{major}.%{minor}.%{patch}",d.version);return d.isEmpty(d.version.metadata)||(e+="+"+d.version.metadata),e}},Promise:"undefined"!=typeof Promise?Promise:null,EMPTY_STRING_REGEXP:/^\s*$/,runValidations:function(e,t,r){var n,o,i,s,a,c,u=[];for(n in(d.isDomElement(e)||d.isJqueryElement(e))&&(e=d.collectFormValues(e)),t)for(o in i=d.getDeepObjectValue(e,n),s=d.result(t[n],i,e,n,r,t)){if(!(a=d.validators[o]))throw c=d.format("Unknown validator %{name}",{name:o}),new Error(c);c=s[o],(c=d.result(c,i,e,n,r,t))&&u.push({attribute:n,value:i,validator:o,globalOptions:r,attributes:e,options:c,error:a.call(a,i,c,n,e,r)})}return u},processValidationResults:function(e,t){switch(e=d.pruneEmptyErrors(e,t),e=d.expandMultipleErrors(e,t),e=d.convertErrorMessages(e,t),t.format||"grouped"){case"detailed":break;case"flat":e=d.flattenErrorsToArray(e);break;case"grouped":for(var r in e=d.groupErrorsByAttribute(e))e[r]=d.flattenErrorsToArray(e[r]);break;default:throw new Error(d.format("Unknown format %{format}",t))}return d.isEmpty(e)?void 0:e},async:function(n,o,i){var s=(i=d.extend({},d.async.options,i)).wrapErrors||function(e){return e},a=(!1!==i.cleanAttributes&&(n=d.cleanAttributes(n,o)),d.runValidations(n,o,i));return new d.Promise(function(t,r){d.waitForResults(a).then(function(){var e=d.processValidationResults(a,i);e?r(new s(e,i,n,o)):t(n)},function(e){r(e)})})},single:function(e,t,r){return r=d.extend({},d.single.options,r,{format:"flat",fullMessages:!1}),d({single:e},{single:t},r)},waitForResults:function(e){return e.reduce(function(e,t){return d.isPromise(t.error)?e.then(function(){return t.error.then(function(e){t.error=e||null},function(e){if(e instanceof Error)throw e;d.error("Rejecting promises with the result is deprecated. Please use the resolve callback instead."),t.error=e})}):e},new d.Promise(function(e){e()}))},result:function(e){var t=[].slice.call(arguments,1);return e="function"==typeof e?e.apply(null,t):e},isNumber:function(e){return"number"==typeof e&&!isNaN(e)},isFunction:function(e){return"function"==typeof e},isInteger:function(e){return d.isNumber(e)&&e%1==0},isObject:function(e){return e===Object(e)},isDate:function(e){return e instanceof Date},isDefined:function(e){return null!=e},isPromise:function(e){return!!e&&d.isFunction(e.then)},isJqueryElement:function(e){return e&&d.isString(e.jquery)},isDomElement:function(e){return!!e&&!(!d.isFunction(e.querySelectorAll)||!d.isFunction(e.querySelector))&&(!(!d.isObject(document)||e!==document)||("object"==typeof HTMLElement?e instanceof HTMLElement:e&&"object"==typeof e&&null!==e&&1===e.nodeType&&"string"==typeof e.nodeName))},isEmpty:function(e){if(!d.isDefined(e))return!0;if(!d.isFunction(e)){if(d.isString(e))return d.EMPTY_STRING_REGEXP.test(e);if(d.isArray(e))return 0===e.length;if(!d.isDate(e)&&d.isObject(e)){for(var t in e)return!1;return!0}}return!1},format:d.extend(function(e,n){return d.isString(e)?e.replace(d.format.FORMAT_REGEXP,function(e,t,r){return"%"===t?"%{"+r+"}":String(n[r])}):e},{FORMAT_REGEXP:/(%?)%\{([^\}]+)\}/g}),prettify:function(e){return d.isNumber(e)?100*e%1==0?""+e:parseFloat(Math.round(100*e)/100).toFixed(2):d.isArray(e)?e.map(function(e){return d.prettify(e)}).join(", "):d.isObject(e)?e.toString():(e=""+e).replace(/([^\s])\.([^\s])/g,"$1 $2").replace(/\\+/g,"").replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,function(e,t,r){return t+" "+r.toLowerCase()}).toLowerCase()},stringifyValue:function(e){return d.prettify(e)},isString:function(e){return"string"==typeof e},isArray:function(e){return"[object Array]"==={}.toString.call(e)},contains:function(e,t){return!!d.isDefined(e)&&(d.isArray(e)?-1!==e.indexOf(t):t in e)},forEachKeyInKeypath:function(e,t,r){if(d.isString(t)){for(var n="",o=!1,i=0;i<t.length;++i)switch(t[i]){case".":o?(o=!1,n+="."):(e=r(e,n,!1),n="");break;case"\\":o?(o=!1,n+="\\"):o=!0;break;default:o=!1,n+=t[i]}return r(e,n,!0)}},getDeepObjectValue:function(e,t){if(d.isObject(e))return d.forEachKeyInKeypath(e,t,function(e,t){if(d.isObject(e))return e[t]})},collectFormValues:function(e,t){var r,n,o,i,s={};if(e=d.isJqueryElement(e)?e[0]:e){for(t=t||{},o=e.querySelectorAll("input[name], textarea[name]"),r=0;r<o.length;++r)n=o.item(r),d.isDefined(n.getAttribute("data-ignored"))||(i=d.sanitizeFormValue(n.value,t),"number"===n.type?i=i?+i:null:"checkbox"===n.type?n.attributes.value?n.checked||(i=s[n.name]||null):i=n.checked:"radio"!==n.type||n.checked||(i=s[n.name]||null),s[n.name]=i);for(o=e.querySelectorAll("select[name]"),r=0;r<o.length;++r)n=o.item(r),i=d.sanitizeFormValue(n.options[n.selectedIndex].value,t),s[n.name]=i}return s},sanitizeFormValue:function(e,t){return t.trim&&d.isString(e)&&(e=e.trim()),!1!==t.nullify&&""===e?null:e},capitalize:function(e){return d.isString(e)?e[0].toUpperCase()+e.slice(1):e},pruneEmptyErrors:function(e){return e.filter(function(e){return!d.isEmpty(e.error)})},expandMultipleErrors:function(e){var r=[];return e.forEach(function(t){d.isArray(t.error)?t.error.forEach(function(e){r.push(d.extend({},t,{error:e}))}):r.push(t)}),r},convertErrorMessages:function(e,r){r=r||{};var n=[];return e.forEach(function(e){var t=d.result(e.error,e.value,e.attribute,e.options,e.attributes,e.globalOptions);d.isString(t)?("^"===t[0]?t=t.slice(1):!1!==r.fullMessages&&(t=d.capitalize(d.prettify(e.attribute))+" "+t),t=t.replace(/\\\^/g,"^"),t=d.format(t,{value:d.stringifyValue(e.value)}),n.push(d.extend({},e,{error:t}))):n.push(e)}),n},groupErrorsByAttribute:function(e){var r={};return e.forEach(function(e){var t=r[e.attribute];t?t.push(e):r[e.attribute]=[e]}),r},flattenErrorsToArray:function(e){return e.map(function(e){return e.error})},cleanAttributes:function(e,t){function n(e,t,r){return d.isObject(e[t])?e[t]:e[t]=!!r||{}}return d.isObject(t)&&d.isObject(e)?function e(t,r){if(!d.isObject(t))return t;var n,o,i=d.extend({},t);for(o in t)n=r[o],d.isObject(n)?i[o]=e(i[o],n):n||delete i[o];return i}(e,t=(e=>{var t,r={};for(t in e)e[t]&&d.forEachKeyInKeypath(r,t,n);return r})(t)):{}},exposeModule:function(e,t,r,n,o){r?(r=n&&n.exports?n.exports=e:r).validate=e:(t.validate=e).isFunction(o)&&o.amd&&o([],function(){return e})},warn:function(e){"undefined"!=typeof console&&console.warn&&console.warn("[validate.js] "+e)},error:function(e){"undefined"!=typeof console&&console.error&&console.error("[validate.js] "+e)}}),s.validators={presence:function(e,t){if(t=d.extend({},this.options,t),d.isEmpty(e))return t.message||this.message||"can't be blank"},length:function(e,t,r){var n,o,i,s,a;if(!d.isEmpty(e))return n=(t=d.extend({},this.options,t)).is,o=t.maximum,i=t.minimum,a=[],e=(e=(t.tokenizer||function(e){return e})(e)).length,d.isNumber(e)?(d.isNumber(n)&&e!==n&&(s=t.wrongLength||this.wrongLength||"is the wrong length (should be %{count} characters)",a.push(d.format(s,{count:n}))),d.isNumber(i)&&e<i&&(s=t.tooShort||this.tooShort||"is too short (minimum is %{count} characters)",a.push(d.format(s,{count:i}))),d.isNumber(o)&&o<e&&(s=t.tooLong||this.tooLong||"is too long (maximum is %{count} characters)",a.push(d.format(s,{count:o}))),0<a.length?t.message||a:void 0):(d.error(d.format("Attribute %{attr} has a non numeric value for `length`",{attr:r})),t.message||this.notValid||"has an incorrect length")},numericality:function(e,t){if(!d.isEmpty(e)){var r,n=[],o={greaterThan:function(e,t){return t<e},greaterThanOrEqualTo:function(e,t){return t<=e},equalTo:function(e,t){return e===t},lessThan:function(e,t){return e<t},lessThanOrEqualTo:function(e,t){return e<=t}};if(!0!==(t=d.extend({},this.options,t)).noStrings&&d.isString(e)&&(e=+e),!d.isNumber(e))return t.message||t.notValid||this.notValid||"is not a number";if(t.onlyInteger&&!d.isInteger(e))return t.message||t.notInteger||this.notInteger||"must be an integer";for(r in o){var i,s=t[r];d.isNumber(s)&&!o[r](e,s)&&(i=t[i="not"+d.capitalize(r)]||this[i]||"must be %{type} %{count}",n.push(d.format(i,{count:s,type:d.prettify(r)})))}return t.odd&&e%2!=1&&n.push(t.notOdd||this.notOdd||"must be odd"),t.even&&e%2!=0&&n.push(t.notEven||this.notEven||"must be even"),n.length?t.message||n:void 0}},datetime:d.extend(function(e,t){if(!d.isFunction(this.parse)||!d.isFunction(this.format))throw new Error("Both the parse and format functions needs to be set to use the datetime/date validator");var r,n,o,i;if(!d.isEmpty(e))return n=[],o=(t=d.extend({},this.options,t)).earliest?this.parse(t.earliest,t):NaN,i=t.latest?this.parse(t.latest,t):NaN,e=this.parse(e,t),isNaN(e)||t.dateOnly&&e%864e5!=0?t.message||this.notValid||"must be a valid date":(!isNaN(o)&&e<o&&(r=this.tooEarly||"must be no earlier than %{date}",r=d.format(r,{date:this.format(o,t)}),n.push(r)),!isNaN(i)&&i<e&&(r=this.tooLate||"must be no later than %{date}",r=d.format(r,{date:this.format(i,t)}),n.push(r)),n.length?t.message||n:void 0)},{parse:null,format:null}),date:function(e,t){return t=d.extend({},t,{dateOnly:!0}),d.validators.datetime.call(d.validators.datetime,e,t)},format:function(e,t){(d.isString(t)||t instanceof RegExp)&&(t={pattern:t});var r=(t=d.extend({},this.options,t)).message||this.message||"is invalid",n=t.pattern;return d.isEmpty(e)||d.isString(e)&&(t=(n=d.isString(n)?new RegExp(t.pattern,t.flags):n).exec(e))&&t[0].length==e.length?void 0:r},inclusion:function(e,t){if(!d.isEmpty(e)&&(d.isArray(t)&&(t={within:t}),t=d.extend({},this.options,t),!d.contains(t.within,e)))return t=t.message||this.message||"^%{value} is not included in the list",d.format(t,{value:e})},exclusion:function(e,t){if(!d.isEmpty(e)&&(d.isArray(t)&&(t={within:t}),t=d.extend({},this.options,t),d.contains(t.within,e)))return t=t.message||this.message||"^%{value} is restricted",d.format(t,{value:e})},email:d.extend(function(e,t){t=(t=d.extend({},this.options,t)).message||this.message||"is not a valid email";return d.isEmpty(e)||d.isString(e)&&this.PATTERN.exec(e)?void 0:t},{PATTERN:/^[a-z0-9\u007F-\uffff!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9\u007F-\uffff!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/i}),equality:function(e,t,r,n){if(!d.isEmpty(e)){d.isString(t)&&(t={attribute:t});var o=(t=d.extend({},this.options,t)).message||this.message||"is not equal to %{attribute}";if(d.isEmpty(t.attribute)||!d.isString(t.attribute))throw new Error("The attribute must be a non empty string");var i=d.getDeepObjectValue(n,t.attribute);return(t.comparator||function(e,t){return e===t})(e,i,t,r,n)?void 0:d.format(o,{attribute:d.prettify(t.attribute)})}},url:function(e,t){var r,n,o;if(!d.isEmpty(e))return r=(t=d.extend({},this.options,t)).message||this.message||"is not a valid url",n=t.schemes||this.schemes||["http","https"],t=t.allowLocal||this.allowLocal||!1,d.isString(e)&&(n="^(?:(?:"+n.join("|")+"):\\/\\/)(?:\\S+(?::\\S*)?@)?",n+="(?:",o="(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))",t?o="(?:localhost|"+o+")":n+="(?!10(?:\\.\\d{1,3}){3})(?!127(?:\\.\\d{1,3}){3})(?!169\\.254(?:\\.\\d{1,3}){2})(?!192\\.168(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})",n+="(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|"+o+"(?::\\d{2,5})?(?:\\/[^\\s]*)?$",new RegExp(n,"i").exec(e))?void 0:r}},s.exposeModule(s,this,e,t,r)}.call(this,void 0!==r?r:null,void 0!==t?t:null,null)},{}]},{},[1])(1)});