comprodls-sdk 2.84.0 → 2.86.0-alpha

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,16 @@
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(t,e){if(!i[t]){if(!o[t]){var r="function"==typeof require&&require;if(!e&&r)return r(t,!0);if(c)return c(t,!0);throw(e=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",e}r=i[t]={exports:{}},o[t][0].call(r.exports,function(e){return a(o[t][1][e]||e)},r,r.exports,n,o,i,s)}return i[t].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"),T=e("./token/validations"),I=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=T.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=I,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",UNEXPECTED_ERROR:"UNEXPECTED_ERROR",POLLING_INITIATION:"POLLING_INITIATION"},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":51}],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}});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 l=e("pubnub"),c=e("events").EventEmitter,p=e("../../helpers"),f=p.errors.PUSHXError;t.exports=function(){var n,u=new c,o=[],d={},i=!1,s=function(){return JSON.parse(JSON.stringify(d))},a=function(e){n.subscribe({channels:[e]})};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 l(t)).setToken(r),n.addListener({message:function(e){var t;t=e.subscribedChannel,u.emit(t,e.message)},status:function(e){var t,r=e,n={accountId:c},o=[];switch(r.category){case"PNConnectedCategory":if("PNSubscribeOperation"===r.operation){for(var i in o=r.subscribedChannels)d[o[i]]&&(d[o[i]].status="subscribed");u.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)d[o[s]]&&(d[o[s]].status="error",d[o[s]].error=t);t=new f(p.errors.ERROR_CATEGORY.PUSHX,a),u.emit("pushx_status",t)}break;case"PNBadRequestCategory":case"PNNetworkDownCategory":case"PNNetworkUpCategory":t={message:"PushX Error",status:r.statusCode,pushXError:r},t=new f(p.errors.ERROR_CATEGORY.PUSHX,t),u.emit("pushx_status",t);break;case"PNNetworkIssuesCategory":"PNSubscribeOperation"!==r.operation||n.accountId||(t={message:"Missing mandatory parameters to initiate polling operation - accountId",status:r.statusCode,type:p.errors.ERROR_TYPES.POLLING_INITIATION},t=new f(p.errors.ERROR_CATEGORY.PUSHX,t),u.emit("pushx_status",t));break;case"PNReconnectedCategory":break;default:t={message:"PushX Error",status:r.statusCode,type:p.errors.ERROR_TYPES.UNEXPECTED_ERROR,pushXError:r},t=new f(p.errors.ERROR_CATEGORY.PUSHX,t),u.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,o.includes(r)||(o.push(r),d[r]={status:"pending"},u.on(r,t),a(r))):"pushx_status"!==e.channel||i||(u.on(e.channel,t),i=!0)},getMySubscriptionStatus:s})},cleanup:function(){n&&(n.unsubscribeAll(),n.stop(),i=!(o=[]),d={}),n=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),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){var n="object"==typeof Reflect?Reflect:null,c=n&&"function"==typeof n.apply?n.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};var o=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)},i=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}t.exports=s,t.exports.once=function(a,c){return new Promise(function(e,t){function r(e){a.removeListener(c,n),t(e)}function n(){"function"==typeof a.removeListener&&a.removeListener("error",r),e([].slice.call(arguments))}var o,i,s;y(a,c,n,{once:!0}),"error"!==c&&(i=r,s={once:!0},"function"==typeof(o=a).on)&&y(o,"error",i,s)})},(s.EventEmitter=s).prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var a=10;function u(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function d(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function l(e,t,r,n){var o,i;return u(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener||r),o=e._events),i=o[t]),void 0===i?(i=o[t]=r,++e._eventsCount):("function"==typeof i?i=o[t]=n?[r,i]:[i,r]:n?i.unshift(r):i.push(r),0<(o=d(e))&&i.length>o&&!i.warned&&(i.warned=!0,(n=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit")).name="MaxListenersExceededWarning",n.emitter=e,n.type=t,n.count=i.length,r=n,console)&&console.warn&&console.warn(r)),e}function p(e,t,r){e={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},t=function(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}.bind(e);return t.listener=r,e.wrapFn=t}function f(e,t,r){e=e._events;if(void 0===e)return[];e=e[t];if(void 0===e)return[];if("function"==typeof e)return r?[e.listener||e]:[e];if(r){for(var n=e,o=new Array(n.length),i=0;i<o.length;++i)o[i]=n[i].listener||n[i];return o}return g(e,e.length)}function h(e){var t=this._events;if(void 0!==t){t=t[e];if("function"==typeof t)return 1;if(void 0!==t)return t.length}return 0}function g(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function y(r,n,o,i){if("function"==typeof r.on)i.once?r.once(n,o):r.on(n,o);else{if("function"!=typeof r.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof r);r.addEventListener(n,function e(t){i.once&&r.removeEventListener(n,e),o(t)})}}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=e}}),s.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return d(this)},s.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n="error"===e,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){if((i=0<t.length?t[0]:i)instanceof Error)throw i;n=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw n.context=i,n}var i=o[e];if(void 0===i)return!1;if("function"==typeof i)c(i,this,t);else for(var s=i.length,a=g(i,s),r=0;r<s;++r)c(a[r],this,t);return!0},s.prototype.on=s.prototype.addListener=function(e,t){return l(this,e,t,!1)},s.prototype.prependListener=function(e,t){return l(this,e,t,!0)},s.prototype.once=function(e,t){return u(t),this.on(e,p(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return u(t),this.prependListener(e,p(this,e,t)),this},s.prototype.off=s.prototype.removeListener=function(e,t){var r,n,o,i,s;if(u(t),void 0!==(n=this._events)&&void 0!==(r=n[e]))if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(o=-1,i=r.length-1;0<=i;i--)if(r[i]===t||r[i].listener===t){s=r[i].listener,o=i;break}if(o<0)return this;if(0===o)r.shift();else{for(var a=r,c=o;c+1<a.length;c++)a[c]=a[c+1];a.pop()}1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,s||t)}return this},s.prototype.removeAllListeners=function(e){var t,r=this._events;if(void 0!==r)if(void 0===r.removeListener)0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]);else if(0===arguments.length){for(var n,o=Object.keys(r),i=0;i<o.length;++i)"removeListener"!==(n=o[i])&&this.removeAllListeners(n);this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0}else if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;0<=i;i--)this.removeListener(e,t[i]);return this},s.prototype.listeners=function(e){return f(this,e,!0)},s.prototype.rawListeners=function(e){return f(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h,s.prototype.eventNames=function(){return 0<this._eventsCount?o(this._events):[]}},{}],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){!function(){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 T(){return A(R.getUint16(_),2)}function r(){return A(R.getUint32(_),4)}function I(){return 255===R.getUint8(_)&&(_+=1,1)}function E(e){if(e<24)return e;if(24===e)return v();if(25===e)return T();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=T(),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=[];!I();)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&&!I();++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,Te=h.Hasher,h=t.algo,Ie=[],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&&(Ie[Oe]=Se(be.pow(Pe,.5))),Ee[Oe]=Se(be.pow(Pe,1/3)),Oe++),Pe++}var je=[],h=h.SHA256=Te.extend({_doReset:function(){this._hash=new ve.init(Ie.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=Te.clone.call(this);return e._hash=this._hash.clone(),e}}),Ce=(t.SHA256=Te._createHelper(h),t.HmacSHA256=Te._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 T(e,t,r,n,o,i,s){return((e=e+(t&r|~t&n)+o+s)<<i|e>>>32-i)+t}function I(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],_=T(r[0],v=r[1],b=r[2],A=r[3],o,7,P[0]),A=T(A,_,v,b,n=e[t+1],12,P[1]),b=T(b,A,_,v,i,17,P[2]),v=T(v,b,A,_,s,22,P[3]),_=T(_,v,b,A,a,7,P[4]),A=T(A,_,v,b,c,12,P[5]),b=T(b,A,_,v,u,17,P[6]),v=T(v,b,A,_,d,22,P[7]);_=T(_,v,b,A,l,7,P[8]),A=T(A,_,v,b,p,12,P[9]),b=T(b,A,_,v,f,17,P[10]),v=T(v,b,A,_,h,22,P[11]),_=T(_,v,b,A,g,7,P[12]),A=T(A,_,v,b,y,12,P[13]),b=T(b,A,_,v,m,17,P[14]),_=I(_,v=T(v,b,A,_,R,22,P[15]),b,A,n,5,P[16]),A=I(A,_,v,b,u,9,P[17]),b=I(b,A,_,v,h,14,P[18]),v=I(v,b,A,_,o,20,P[19]),_=I(_,v,b,A,c,5,P[20]),A=I(A,_,v,b,f,9,P[21]),b=I(b,A,_,v,R,14,P[22]),v=I(v,b,A,_,a,20,P[23]),_=I(_,v,b,A,p,5,P[24]),A=I(A,_,v,b,m,9,P[25]),b=I(b,A,_,v,s,14,P[26]),v=I(v,b,A,_,l,20,P[27]),_=I(_,v,b,A,y,5,P[28]),A=I(A,_,v,b,i,9,P[29]),b=I(b,A,_,v,d,14,P[30]),_=E(_,v=I(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),Tt=(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),It=(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 Tr(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 Ir=Object.freeze({__proto__:null,getOperation:function(){return O.PNAccessManagerGrantToken},extractPermissions:Tr,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]=Tr(r[e])}),n&&Object.keys(n).forEach(function(e){c.permissions.resources.channels[e]=Tr(n[e])}),o)&&Object.keys(o).forEach(function(e){c.permissions.resources.groups[e]=Tr(o[e])}),l&&(i=l.users,s=l.spaces,a=l.groups,i&&Object.keys(i).forEach(function(e){c.permissions.patterns.uuids[e]=Tr(i[e])}),s&&Object.keys(s).forEach(function(e){c.permissions.patterns.channels[e]=Tr(s[e])}),a)&&Object.keys(a).forEach(function(e){c.permissions.patterns.groups[e]=Tr(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]=Tr(g[e])}),y&&Object.keys(y).forEach(function(e){h.permissions.resources.channels[e]=Tr(y[e])}),m)&&Object.keys(m).forEach(function(e){h.permissions.resources.groups[e]=Tr(m[e])}),l&&(R=l.uuids,_=l.channels,A=l.groups,R&&Object.keys(R).forEach(function(e){h.permissions.patterns.uuids[e]=Tr(R[e])}),_&&Object.keys(_).forEach(function(e){h.permissions.patterns.channels[e]=Tr(_[e])}),A)&&Object.keys(A).forEach(function(e){h.permissions.patterns.groups[e]=Tr(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(In,Vr=p),Object.defineProperty(In.prototype,"aborted",{get:function(){return this._aborted},enumerable:!1,configurable:!0}),In.prototype.throwIfAborted=function(){if(this._aborted)throw new Jr},In.prototype.abort=function(){this._aborted=!0,this.notify(new Jr)},In),Qr=(D(Tn,Br=function(e,t){this.payload=e,this.dependencies=t}),Tn.prototype.start=function(){this.asyncFunction(this.payload,this.abortSignal,this.dependencies).catch(function(e){})},Tn.prototype.cancel=function(){this.abortSignal.abort()},Tn),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 Tn(e,t,r){e=Br.call(this,e,t)||this;return e.asyncFunction=r,e.abortSignal=new $r,e}function In(){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 Tt(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 It,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,Ir),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,T,I,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);T=L.fileUploadPublishRetryLimit,I=!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(),I=!0,[3,26];case 25:return e.sent(),--T,[3,26];case 26:if(!I&&0<T)return[3,23];e.label=27;case 27:if(I)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,To=Array.prototype.slice,Io=Object.prototype.toString,Eo=Function.prototype.bind||function(t){var r=this;if("function"!=typeof r||"[object Function]"!==Io.call(r))throw new TypeError("Function.prototype.bind called on incompatible "+r);for(var n=To.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(To.call(arguments))),Object(e)===e?e:this):r.apply(t,n.concat(To.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,Ti=RegExp.prototype.test,Ii=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||Ti.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||(Ti.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,T=[];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 I=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(I,P):I:I+(u?"."+P:"["+P+"]"),g.set(e,R),(S=As()).set(Us,g),Ps(T,es(O,P,r,n,o,i,"comma"===r&&f&&Es(y)?null:s,a,c,u,d,l,p,f,h,S)))}}return T}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(Ii.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(Ii.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,Ts=Object.prototype.hasOwnProperty,Is={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(!Ts.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 Is?t.arrayFormat:!(t&&"indices"in t)||t.indices?"indices":"repeat",i=Is[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 Ta)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 Ta(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 Ta(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),Ta=(Object.defineProperty(Ia.prototype,"identifier",{get:function(){return this._identifier},set:function(e){this._identifier=e},enumerable:!1,configurable:!0}),Object.defineProperty(Ia.prototype,"metadataLength",{get:function(){return this._metadataLength},set:function(e){this._metadataLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(Ia.prototype,"version",{get:function(){return va.VERSION},enumerable:!1,configurable:!0}),Object.defineProperty(Ia.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(Ia.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}),Ia.IDENTIFIER_LENGTH=4,Ia.SENTINEL="PNED",Ia);function Ia(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)}.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,re){!function(){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 re?"undefined"!=typeof window?re.bind(window,p):function(){re(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 I?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=_(I.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 T(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 T(function(e,t){for(var r=0,n=o.length;r<n;r++)b(o[r]).then(e,t)})}function I(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=_(I.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 I}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=T,(b.promise=T).race=G,T.all=D,T.reject=C,(T.resolve=b).passByCopy=function(e){return e},I.prototype.passByCopy=function(){return this},b.join=function(e,t){return b(e).join(t)},I.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,I.prototype.race=function(){return this.then(b.race)},(b.makePromise=I).prototype.toString=function(){return"[object Promise]"},I.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)},I.prototype.tap=function(t){return t=b(t),this.then(function(e){return t.fcall(e).thenResolve(e)})},b.when=E,I.prototype.thenResolve=function(e){return this.then(function(){return e})},b.thenResolve=function(e,t){return b(e).thenResolve(t)},I.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},I.prototype.isPending=function(){return"pending"===this.inspect().state},b.isFulfilled=function(e){return!S(e)||"fulfilled"===e.inspect().state},I.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},b.isRejected=function(e){return S(e)&&"rejected"===e.inspect().state},I.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=I({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 I({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 I({isDef:function(){}},function(e,t){return $(r,e,t)},function(){return b(r).inspect()})},b.spread=J,I.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=$,I.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])},I.prototype.get=function(e){return this.dispatch("get",[e])},b.set=function(e,t,r){return b(e).dispatch("set",[t,r])},I.prototype.set=function(e,t){return this.dispatch("set",[e,t])},b.del=b.delete=function(e,t){return b(e).dispatch("delete",[t])},I.prototype.del=I.prototype.delete=function(e){return this.dispatch("delete",[e])},b.mapply=b.post=function(e,t,r){return b(e).dispatch("post",[t,r])},I.prototype.mapply=I.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)])},I.prototype.send=I.prototype.mcall=I.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])},I.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)])},I.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))])}},I.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",[])},I.prototype.keys=function(){return this.dispatch("keys",[])},b.all=D,I.prototype.all=function(){return D(this)},b.any=Q,I.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)}),I.prototype.allResolved=function(){return Z(this)},b.allSettled=function(e){return b(e).allSettled()},I.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)},I.prototype.fail=I.prototype.catch=function(e){return this.then(void 0,e)},b.progress=function(e,t){return b(e).then(void 0,void 0,t)},I.prototype.progress=function(e){return this.then(void 0,void 0,e)},b.fin=b.finally=function(e,t){return b(e).finally(t)},I.prototype.fin=I.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)},I.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)},I.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)},I.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)},I.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)},I.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}},I.prototype.nfbind=I.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}},I.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)},I.prototype.nmapply=I.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},I.prototype.nsend=I.prototype.nmcall=I.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)},I.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)}.call(this,e("_process"),e("timers").setImmediate)},{_process:40,timers:50}],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(c,e,u){!function(r,a){!function(){var n=c("process/browser.js").nextTick,e=Function.prototype.apply,o=Array.prototype.slice,i={},s=0;function t(e,t){this._id=e,this._clearFn=t}u.setTimeout=function(){return new t(e.call(setTimeout,window,arguments),clearTimeout)},u.setInterval=function(){return new t(e.call(setInterval,window,arguments),clearInterval)},u.clearTimeout=u.clearInterval=function(e){e.close()},t.prototype.unref=t.prototype.ref=function(){},t.prototype.close=function(){this._clearFn.call(window,this._id)},u.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},u.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},u._unrefActive=u.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;0<=t&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},u.setImmediate="function"==typeof r?r:function(e){var t=s++,r=!(arguments.length<2)&&o.call(arguments,1);return i[t]=!0,n(function(){i[t]&&(r?e.apply(null,r):e.call(null),u.clearImmediate(t))}),t},u.clearImmediate="function"==typeof a?a:function(e){delete i[e]}}.call(this)}.call(this,c("timers").setImmediate,c("timers").clearImmediate)},{"process/browser.js":40,timers:50}],51:[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(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.ComproDLS=a()}}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};a[g][0].call(k.exports,function(b){var c=a[g][1][b];return e(c?c:b)},k,k.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){function d(a,b,c){return new e(a,b,c)}function e(a,b,c){c=c||{},a=a||"production",b=b||"global",this.token=null,this.orgId=null,this.traceid=c.traceid;try{if(t.DEFAULT_HOSTS=t.REALM_HOSTS[b.toUpperCase()][a.toUpperCase()],!t.DEFAULT_HOSTS)throw"Invalid Environment"}catch(d){var e,f=t.REALM_HOSTS[b.toUpperCase()];throw f?f[a.toUpperCase()]||(e=new Error("Invalid Environment: "+a)):e=new Error("Invalid Realm: "+b),e}if(this.config=t,this.environment=a,c.orgid&&c.token){var e=z.authWithToken(c.orgid,c.token,{});if(e)throw e;this.token=c.token,this.orgId=c.orgid}else c.orgid&&(this.orgId=c.orgid)}var f=a("./token"),g=a("./helpers"),h=a("./services/auth"),i=a("./services/authextn"),j=a("./services/activity"),k=a("./services/analytics"),l=a("./services/collab"),m=a("./services/product"),n=a("./services/xapi"),o=a("./services/attempts"),p=a("./services/pushX"),q=a("./services/pub"),r=a("./services/spaces"),s=a("./services/spacesextn"),t=a("./config"),u=a("./open_access"),v=a("./services/superuser"),w=a("./services/invitations"),x=a("./services/workflows"),y=a("./services/integrations"),z=a("./token/validations"),A=a("./services/drive"),B=a("./services/taxonomy"),C=a("./services/rules"),D=a("./services/datasyncmanager");c.init=d,e.prototype.authWithCredentials=f.authWithCredentials,e.prototype.authWithToken=f.authWithToken,e.prototype.authWithExtUser=f.authWithExtUser,e.prototype.getClassEnrolmentsStat=u.getClassEnrolmentsStat,e.prototype.getSingleInvitation=u.getSingleInvitation,e.prototype.request=g.api.genericAPICaller,e.prototype.Auth=h,e.prototype.AuthExtn=i,e.prototype.Activity=j,e.prototype.Analytics=k,e.prototype.Collab=l,e.prototype.Product=m,e.prototype.Xapi=n,e.prototype.Attempts=o,e.prototype.Pub=q,e.prototype.PushX=p,e.prototype.Spaces=r,e.prototype.SpacesExtn=s,e.prototype.Superuser=v,e.prototype.Invitations=w,e.prototype.Workflows=x,e.prototype.Integrations=y,e.prototype.Drive=A,e.prototype.Taxonomy=B,e.prototype.Rules=C,e.prototype.Datasyncmanager=D},{"./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(a,b,c){c.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"}}},c.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}"},c.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"},c.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"},c.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"},c.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}"},c.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}"},c.XAPI_API_URLS={postMultiStatements:"/{orgId}/statements/multi",postExternalMultiStatements:"/{orgId}/external/statements/multi"},c.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"},c.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"},c.PUSHX_API_URLS={grantByUserOrgId:"/orgs/{orgId}/grants",grantByAccountId:"/accounts/{accountId}/grants",grantV2:"/ver/v2/grants",getPushedEvents:"/accounts/{accountId}/pushed-events/channels"},c.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}"},c.DRIVE_API_URLS={getAParticularDocument:"/accounts/{accountid}/users/{extuserid}/documents/{documentid}",getAllDocumentsInAFolder:"/accounts/{accountid}/users/{extuserid}/documents",documents:"/accounts/{accountid}/users/{userid}/documents/multi"},c.TAXONOMY_API_URLS={associateTagsWithEntity:"/org/{orgId}/taxonomy/associate-tags-with-entity",tags:"/org/{orgId}/context/{context}/taxonomy/{taxonomyId}/tags"},c.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(a,b,c){c.api=a("./lib/api"),c.errors=a("./lib/errors"),c.utils=a("./lib/utils"),c.validations=a("./lib/validator")},{"./lib/api":5,"./lib/errors":7,"./lib/utils":8,"./lib/validator":9}],4:[function(a,b,c){function d(a){var b=a.data,c=b.roles;if(Array.isArray(c)){var d={};for(var e in c)d[c[e]]=[];b.roles=d}return b}function e(a){var b=a.data;if(b.hasOwnProperty("pk")===!1)return b;var c={uuid:b.classid,type:"group"};Object.assign(c,b);var d=b["class"].instructor.first_name,e=b["class"].instructor.last_name;return c["class"].instructor.uuid=b["class"].instructor.dls_user_id,(d||e)&&(c["class"].instructor.name=d?d:"",e&&(c["class"].instructor.name+=d?" "+e:e)),c}function f(a){var b=a.data;for(var c in b){var d=b[c],e=d.first_name,f=d.last_name;(e||f)&&(d.name=e?e:"",f&&(d.name+=e?" "+f:f)),d.uuid=d.dls_user_id,d.username&&(d.ext_username=d.username),d.username=d.userid+"--ACCOUNT"}return b}function g(a){var b=a.err,c=a.type,d=new i(c,b);return b.response&&b.response.body&&b.response.body.meta&&b.response.body.meta.body&&(d.message="Elasticsearch Error. Please refer data field for more information",d.data=b.response.body.meta.body),d}var h=a("../errors"),i=h.DLSError;b.exports={convertUserResponse:d,convertClassResponse:e,convertEnrollmetsResponse:f,convertElasticsearchErrResponse:g}},{"../errors":7}],5:[function(a,b,c){function d(a,b,c,d){var e=this,f=i.defer(),j=o.genericAPICaller(a,b,c,d)||l.validations.isAuthenticated(e.orgId,e.token);if(j)f.reject(j);else{var c=k.DEFAULT_HOSTS[a.toUpperCase()]+c;"DELETE"===b&&(b="DEL");var p=h(b,c);p=g(p,e.token),Object.keys(d).length&&(p="GET"===b||"HEAD"===b?p.query(d):p.send(d)),p.end(function(a,b){a?(a=new n(m.ERROR_TYPES.API_ERROR,a),f.reject(a)):f.resolve(b.body)})}return f.promise}function e(a,b){return j(a,b)}function f(a,b){var c="";return"undefined"!=typeof b&&null!==b&&(c="?classId="+b),a+c}function g(a,b){return a.set("Authorization",b.access_token)}var h=a("superagent"),i=a("q"),j=a("string-template"),k=a("../../../config"),l=a("../../../helpers"),m=a("../errors"),n=m.DLSError,o=a("./validations");c.genericAPICaller=d,c.constructAPIUrl=e,c.setupAPIToken=g,c.addClassIdQueryParam=f},{"../../../config":2,"../../../helpers":3,"../errors":7,"./validations":6,q:46,"string-template":48,superagent:49}],6:[function(a,b,c){function d(a,b,c,d){var f={apiName:a,method:b,url:c,params:d},g={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}};return e(f,g)}var e=a("../validator").validate;c.genericAPICaller=d},{"../validator":9}],7:[function(a,b,c){function d(a,b){if(this.type=a,a===f.API_ERROR){var c,d;if(void 0!=b.response){if(c=b.response.body.message||b.response.body.dbErrorBody||b.response.body.code,d=b.response.body.dbErrorDescription,b.response.body.results&&b.response.body.results.errors){c="";for(var e in b.response.body.results.errors)c+=b.response.body.results.errors[e].message+" "}b.response.body.server&&(this.server=b.response.body.server)}else c=b.message?b.message:"",d=b.description?b.description:"";this.message=c,this.description=d}else a===f.PUSHX_ERROR?(this.message=b.message,this.data=b):(this.message=b.message?b.message:"",this.description=b.description?b.description:"",delete b.message,delete b.description,this.data=b);a!==f.API_ERROR&&a!==f.PUSHX_ERROR||(this.httpcode=b.status)}function e(a,b){a===g.PUSHX?(this.category=g.PUSHX,this.type=b.type||f.CHANNEL_SUBSCRIPTION,this.status=h.ERROR,this.message=b.message,this.data=b,this.httpcode=b.errorDetails&&b.errorDetails.statusCode?b.errorDetails.statusCode:500):this.message="PUSHXError called for incorrect category."}var f={API_ERROR:"API_ERROR",SDK_ERROR:"SDK_ERROR",CHANNEL_SUBSCRIPTION:"CHANNEL_SUBSCRIPTION"},g={PUSHX:"PUSHX"},h={ERROR:"ERROR"};c.DLSError=d,c.PUSHXError=e,c.ERROR_TYPES=f,c.ERROR_CATEGORY=g},{}],8:[function(a,b,c){c.isBrowser="undefined"!=typeof window},{}],9:[function(a,b,c){function d(a,b){var c={},d=f(a,b);if(d)for(var e in d)return c.message=c.description=d[e][0],c=new h(g.ERROR_TYPES.SDK_ERROR,c)}function e(a,b){var c={organization:a,token:b},e={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."}}};return d(c,e)}var f=a("validate.js"),g=a("./errors"),h=g.DLSError;c.validate=d,c.isAuthenticated=e,f.validators.isString=function(a,b){if(!f.isString(a))return b.message||"is not a valid string"},f.validators.isObject=function(a,b){if(!f.isObject(a))return b.message||"is not a valid object"},f.validators.contains=function(a,b){if(f.isArray(b)){for(var c in b)if(!a||!a.hasOwnProperty(b[c]))return b.message||"does not contain "+b[c]}else if(f.isString(b)&&(!a||!a.hasOwnProperty(b)))return b.message||"does not contain "+b}},{"./errors":7,"validate.js":53}],10:[function(a,b,c){function d(a,b){var c=this,d=f.defer(),e={};if(a&&b&&b.classid){var j=c.config.DEFAULT_HOSTS.ANALYTICS+c.config.ANALYTICS_API_URLS.getClassEnrolmentsStat;j=h.api.constructAPIUrl(j,{orgId:a});var k=g.get(j).query(b);c.traceid&&k.set("X-Amzn-Trace-Id",c.traceid),k.end(function(a,b){a?(a=new i(h.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else e.message=e.description="Mandatory params not found in request body : [orgid, classid]",e=new i(h.errors.ERROR_TYPES.SDK_ERROR,e),d.reject(e);return d.promise}function e(a,b){var c=this,d={},e=f.defer();if(a&&b&&b.context_id&&b.context&&b.invitationid){var j=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.getSingleInvitation;j=h.api.constructAPIUrl(j,{orgId:a,invitationId:b.invitationid});var k={context:b.context,context_id:b.context_id},l=g.get(j).query(k);c.traceid&&l.set("X-Amzn-Trace-Id",c.traceid),l.end(function(a,b){a?(d=new i(h.errors.ERROR_TYPES.API_ERROR,a),e.reject(d)):e.resolve(b.body)})}else d.message=d.description="organizationId or context_id or context or invitationid not found in request options.",d=new i(h.errors.ERROR_TYPES.SDK_ERROR,d),e.reject(d);return e.promise}var f=a("q"),g=a("superagent"),h=a("../helpers"),i=h.errors.DLSError;c.getClassEnrolmentsStat=d,c.getSingleInvitation=e},{"../helpers":3,q:46,superagent:49}],11:[function(a,b,c){function d(a,b,c){if(!(this instanceof d)){var e=new d(a,b,c);return e.token=this.token,e.orgId=this.orgId,e.config=this.config,e}this.productId=a,this.activityId=b,this.classId=c}var e=a("superagent"),f=a("q"),g=a("../../helpers"),h=g.errors.DLSError;a("extend");b.exports=d;var i=a("./attempt");d.prototype.getDetails=function(){var a=this,b=f.defer(),c=g.validations.isAuthenticated(this.orgId,this.token);if(c)b.reject(c);else{var d=a.config.DEFAULT_HOSTS.ACTIVITY+a.config.ACTIVITY_API_URLS.activityDetailsAPI;d=g.api.constructAPIUrl(d,{orgId:a.orgId,productId:a.productId,activityId:a.activityId}),d=g.api.addClassIdQueryParam(d,a.classId);var i=e.get(d);i=g.api.setupAPIToken(i,a.token),a.traceid&&i.set("X-Amzn-Trace-Id",a.traceid),i.end(function(a,c){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),b.reject(a);else{var d=c.body,e=new Object;e.activity=d,b.resolve(e)}})}return b.promise},d.prototype.loadAttempt=function(a){var b=new i(this.productId,this.activityId,a,null,this.classId,this.config);return b.setAuthCredentials(this.orgId,this.token),b.getAttemptInfo()},d.prototype.getAttempt=function(a){var b=new i(this.productId,this.activityId,a,null,this.classId,this.config);return b.setAuthCredentials(this.orgId,this.token),b},d.prototype.newAttempt=function(a){var b=new i(this.productId,this.activityId,null,null,this.classId,this.config);return b.setAuthCredentials(this.orgId,this.token),b.start(a)},d.prototype.getAllQuestions=function(){var a=this,b=f.defer(),c=g.validations.isAuthenticated(this.orgId,this.token);if(c)b.reject(c);else{var d=a.config.DEFAULT_HOSTS.PRODUCT+a.config.PRODUCT_API_URLS.activityAPI;d=g.api.constructAPIUrl(d,{orgId:a.orgId,productId:a.productId,activityId:a.activityId}),d=g.api.addClassIdQueryParam(d,a.classId);var i=e.get(d);i=g.api.setupAPIToken(i,a.token),a.traceid&&i.set("X-Amzn-Trace-Id",a.traceid),i.end(function(a,c){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),b.reject(a);else{var d=c.body,e=new Object;e.questions=d.items,b.resolve(e)}})}return b.promise},d.prototype.getQuestionsCount=function(){var a=this,b=f.defer(),c=g.validations.isAuthenticated(this.orgId,this.token);if(c)b.reject(c);else{var d=a.config.DEFAULT_HOSTS.PRODUCT+a.config.PRODUCT_API_URLS.activityAPI;d=g.api.constructAPIUrl(d,{orgId:a.orgId,productId:a.productId,activityId:a.activityId}),d=g.api.addClassIdQueryParam(d,a.classId);var i=e.get(d);i=g.api.setupAPIToken(i,a.token),a.traceid&&i.set("X-Amzn-Trace-Id",a.traceid),i.end(function(a,c){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),b.reject(a);else{var d={count:c.body.items.length},e=new Object;e.count=d,b.resolve(e)}})}return b.promise}},{"../../helpers":3,"./attempt":12,extend:42,q:46,superagent:49}],12:[function(a,b,c){function d(a,b,c,e,f,g){function h(){return this.authCredentials}function i(a){this.authCredentials=a}this.productId=a,this.activityId=b,this.attemptId=c,this.classId=f,this.config=g;d.prototype.getAuthCredentials=function(){return h()},d.prototype.setAuthCredentials=function(a,b){var c=new Object;c.orgId=a,c.token=b,i(c)}}var e=a("superagent"),f=a("q"),g=a("../../helpers"),h=g.errors.DLSError,i=a("extend");b.exports=d,d.prototype.start=function(a){var b=this,c=this.getAuthCredentials().orgId,d=this.getAuthCredentials().token,j=f.defer(),k=g.validations.isAuthenticated(c,d);if(k)j.reject(k);else{var l=b.config.DEFAULT_HOSTS.ACTIVITY+b.config.ACTIVITY_API_URLS.newAttemptAPI;l=g.api.constructAPIUrl(l,{orgId:c,productId:b.productId,activityId:b.activityId}),l=g.api.addClassIdQueryParam(l,b.classId),void 0!=a&&null!=a||(a={});var m=e.post(l).send(a);m=g.api.setupAPIToken(m,d),b.traceid&&m.set("X-Amzn-Trace-Id",b.traceid),m.end(function(a,c){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),j.reject(a);else{var d=c.body;b.attemptId=d.uuid,i(!0,b,d);var e=new Object;e.attempt=b,j.resolve(e)}})}return j.promise},d.prototype.getAttemptInfo=function(){
2
+ var a=this.getAuthCredentials().orgId,b=this.getAuthCredentials().token,c=this,d=f.defer(),j=g.validations.isAuthenticated(a,b);if(j)d.reject(j);else{var k=c.config.DEFAULT_HOSTS.ACTIVITY+c.config.ACTIVITY_API_URLS.existingAttemptAPI;k=g.api.constructAPIUrl(k,{orgId:a,productId:c.productId,activityId:c.activityId,attemptId:c.attemptId}),k=g.api.addClassIdQueryParam(k,c.classId);var l=e.get(k);l=g.api.setupAPIToken(l,b),c.traceid&&l.set("X-Amzn-Trace-Id",c.traceid),l.end(function(a,b){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),d.reject(a);else{var e=b.body;c.attemptId=e.uuid,i(!0,c,e);var f=new Object;f.attempt=c,d.resolve(f)}})}return d.promise},d.prototype.getState=function(){var a=this.getAuthCredentials().orgId,b=this.getAuthCredentials().token,c=this,d=f.defer(),i=g.validations.isAuthenticated(a,b);if(i)d.reject(i);else{var j=c.config.DEFAULT_HOSTS.ACTIVITY+c.config.ACTIVITY_API_URLS.existingAttemptAPI;j=g.api.constructAPIUrl(j,{orgId:a,productId:c.productId,activityId:c.activityId,attemptId:c.attemptId}),j=g.api.addClassIdQueryParam(j,c.classId);var k=e.get(j);k=g.api.setupAPIToken(k,b),c.traceid&&k.set("X-Amzn-Trace-Id",c.traceid),k.end(function(a,b){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),d.reject(a);else{var c=b.body,e=new Object;e.state=c.data.savedstate.state,d.resolve(e)}})}return d.promise},d.prototype.saveState=function(a){var b=this.getAuthCredentials().orgId,c=this.getAuthCredentials().token,d=this,i=f.defer(),j=g.validations.isAuthenticated(b,c);if(j)i.reject(j);else{var k=d.config.DEFAULT_HOSTS.ACTIVITY+d.config.ACTIVITY_API_URLS.existingAttemptAPI;k=g.api.constructAPIUrl(k,{orgId:b,productId:d.productId,activityId:d.activityId,attemptId:d.attemptId}),k=g.api.addClassIdQueryParam(k,d.classId);var l=e.put(k).send(a);l=g.api.setupAPIToken(l,c),d.traceid&&l.set("X-Amzn-Trace-Id",d.traceid),l.end(function(a,b){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),i.reject(a);else{var c=b.body,d=new Object;d.status=c,i.resolve(d)}})}return i.promise},d.prototype.getUserResponse=function(){var a=this.getAuthCredentials().orgId,b=this.getAuthCredentials().token,c=this,d=f.defer(),i=g.validations.isAuthenticated(a,b);if(i)d.reject(i);else{var j=c.config.DEFAULT_HOSTS.ACTIVITY+c.config.ACTIVITY_API_URLS.userResponseAPI;j=g.api.constructAPIUrl(j,{orgId:a,productId:c.productId,activityId:c.activityId,attemptId:c.attemptId}),j=g.api.addClassIdQueryParam(j,c.classId);var k=e.get(j);k=g.api.setupAPIToken(k,b),c.traceid&&k.set("X-Amzn-Trace-Id",c.traceid),k.end(function(a,b){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),d.reject(a);else{var c=b.body,e=new Object;e.userresponse=c,d.resolve(e)}})}return d.promise},d.prototype.saveUserResponse=function(a){var b=this.getAuthCredentials().orgId,c=this.getAuthCredentials().token,d=this,i=f.defer(),j=g.validations.isAuthenticated(b,c);if(j)i.reject(j);else{var k=d.config.DEFAULT_HOSTS.ACTIVITY+d.config.ACTIVITY_API_URLS.userResponseAPI;k=g.api.constructAPIUrl(k,{orgId:b,productId:d.productId,activityId:d.activityId,attemptId:d.attemptId}),k=g.api.addClassIdQueryParam(k,d.classId);var l=e.put(k).send(a);l=g.api.setupAPIToken(l,c),d.traceid&&l.set("X-Amzn-Trace-Id",d.traceid),l.end(function(a,b){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),i.reject(a);else{var c=b.body,d=new Object;d.status=c,i.resolve(d)}})}return i.promise},d.prototype.submit=function(a){var b=this.getAuthCredentials().orgId,c=this.getAuthCredentials().token,d=this,i=f.defer(),j=g.validations.isAuthenticated(b,c);if(j)i.reject(j);else{var k=d.config.DEFAULT_HOSTS.ACTIVITY+d.config.ACTIVITY_API_URLS.submitAttemptAPI;k=g.api.constructAPIUrl(k,{orgId:b,productId:d.productId,activityId:d.activityId,attemptId:d.attemptId}),k=g.api.addClassIdQueryParam(k,d.classId);var l;l=void 0==a||null==a?e.post(k).send({}):e.post(k).send(a),l=g.api.setupAPIToken(l,c),d.traceid&&l.set("X-Amzn-Trace-Id",d.traceid),l.end(function(a,b){if(a)a=new h(g.errors.ERROR_TYPES.API_ERROR,a),i.reject(a);else{var c=b.body,d=new Object;d.status=c,i.resolve(d)}})}return i.promise}},{"../../helpers":3,extend:42,q:46,superagent:49}],13:[function(a,b,c){b.exports=a("./activity")},{"./activity":11}],14:[function(a,b,c){function d(){return{archiveUserAnalytics:i.bind(this),getArchivedUserAnalytics:A.bind(this),getOrgAnalyticsStat:e.bind(this),getClassAnalytics:z.bind(this),getClassProductRecentPendingSubmissions:r.bind(this),getClassRecordUserAggregations:y.bind(this),getClassRecord:s.bind(this),getClassRecordItemAggregations:t.bind(this),getShowcaseRecordOfAClass:u.bind(this),getGroupRecord:v.bind(this),getClassGroupsRecentPendingSubmissions:w.bind(this),getGroupsWithEvaluatedOnce:x.bind(this),getUserProductAnalytics:f.bind(this),getUserProductAnalyticById:g.bind(this),getExternalDataForUserAnalyticItem:h.bind(this),searchUserProductAnalytics:j.bind(this),getUserClassRecentSubmissions:k.bind(this),getStudentsWithEvaluatedOnce:l.bind(this),getAppState:m.bind(this),updateAppState:n.bind(this),deleteAppState:o.bind(this),getUserProductAllState:p.bind(this),updateUserProductMultiState:q.bind(this),getQuestionProgressByLearningObjective:B.bind(this),getAllAssignedPathsOfClass:C.bind(this),getMyAssignedPathsOfClass:E.bind(this),getUserAssignedPathsOfClass:F.bind(this),getAssignedPathAnalytics:D.bind(this),getMyParticularAssignedPathOfClass:G.bind(this),getParticularAssignedPathOfClass:H.bind(this),getTimeseriesAnalytics:I.bind(this),postProgressTimeseries:J.bind(this),getClassCustomComponentRecord:K.bind(this),getClassCustomComponentUserSubmission:L.bind(this),getCrossProductAggregation:M.bind(this)}}function e(a){var b=this,c=N.defer(),d={};if(a&&a.type)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{d={};var e=["users","classes"];if(e.indexOf(a.type)>-1){var f=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getOrgAnalyticsStat;f=Q.api.constructAPIUrl(f,{orgId:b.orgId,type:a.type});var g={};a&&(a.range&&(g.range=a.range),a.start&&(g.start=a.start),a.end&&(g.end=a.end),a.role&&(g.role=a.role),a.shadow&&(g.shadow=a.shadow));var h=O.get(f).query(g);h=Q.api.setupAPIToken(h,b.token),b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d.message=d.description="Type: "+a.type+" is not supported",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d)}else d.message=d.description="type not found in request options",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function f(a){var b=this,c=N.defer(),d={};if(a&&a.type&&a.userid&&a.productcode)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=["items","summary"],f=b.config.DEFAULT_HOSTS.ANALYTICS;if(e.indexOf(a.type)>-1){switch(a.type){case"items":f+=b.config.ANALYTICS_API_URLS.getAnalyticProductItems;break;case"summary":f+=b.config.ANALYTICS_API_URLS.getAnalyticProductSummary}f=Q.api.constructAPIUrl(f,{orgId:b.orgId});var g={userid:a.userid,productcode:a.productcode};a.classid&&(g.classid=a.classid),a.itemcode&&(g.itemcode=a.itemcode),a.metrics&&(g.metrics=a.metrics),a.history&&(g.history=a.history),a.group&&(g.group=a.group),a.externalData&&(g.externalData=a.externalData),a.expiredView&&"items"===a.type&&(g.expiredView=a.expiredView);var h=O.get(f).query(g);h=Q.api.setupAPIToken(h,b.token),b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d.message=d.description=a.type+" is not a valid value of option 'type'",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d)}else d.message=d.description="Required parameter 'type' or 'userid' or 'productcode' not found in request options",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function g(a){var b=this,c=N.defer(),d={};if(a&&a.userprogressid)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getAnalyticProductById;e=Q.api.constructAPIUrl(e,{orgId:b.orgId,userProgressId:a.userprogressid});var f=O.get(e);f=Q.api.setupAPIToken(f,b.token),b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d.message=d.description="Required parameter 'userprogressid' not found in request options",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function h(a){var b=this,c=N.defer(),d={};if(a&&a.ext_user_id&&a.productcode&&a.itemcode&&(a.submission_order||a.ext_link_id)&&a.part)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getExternalDataForUserAnalyticItem;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={ext_user_id:a.ext_user_id,productcode:a.productcode,itemcode:a.itemcode,part:a.part};a.submission_order&&(f.submission_order=a.submission_order),a.ext_link_id&&(f.ext_link_id=a.ext_link_id),a.classid&&(f.classid=a.classid);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d.message=d.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",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function i(a){var b=this,c={},d=N.defer();if(a&&a.userid&&a.productid)if(c=Q.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e={},f=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.archiveUserAnalytics;f=Q.api.constructAPIUrl(f,{orgId:b.orgId}),a.userid&&(e.userid=a.userid),a.productid&&(e.productid=a.productid),a.classid&&(e.classid=a.classid);var g=O.post(f).query(e).set("Content-Type","application/json");g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else c.message=c.description="Mandatory parameter [userid, productid] not found in request options",c=new R(Q.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function j(a){var b=this,c={},d=N.defer();if(c=Q.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e={},f=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.searchUserProductAnalytics;f=Q.api.constructAPIUrl(f,{orgId:b.orgId}),a.userid&&(e.userid=a.userid),a.productid&&(e.productid=a.productid),a.classid&&(e.classid=a.classid),a.lookup&&(e.lookup=a.lookup),a.cursor&&(e.cursor=a.cursor),a.limit&&(e.limit=a.limit);var g=O.get(f).query(e);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}return d.promise}function k(a){var b=this,c=N.defer(),d={};if(a&&a.classid&&a.productcode&&a.userid)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getUserClassRecentSubmissions;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={userid:a.userid,classid:a.classid,productcode:a.productcode};a.gradingStatus&&(f.gradingStatus=a.gradingStatus);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description='Mandatory parameters ["classid", "productcode", "userid"] not found in request options.',d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function l(a){var b=this,c={},d=N.defer();if(a&&a.classid&&a.productcode)if(c=Q.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getStudentsWithEvaluatedOnce;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode},g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(c=new R(Q.errors.ERROR_TYPES.API_ERROR,a),d.reject(c)):d.resolve(b.body)})}else c.message=c.description="Required parameter classid or productcode not found in request options.",c=new R(Q.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function m(a){var b=this,c=N.defer(),d={};if(a&&a.userid&&a.productcode)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.appState;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={userid:a.userid,productcode:a.productcode};a.classid&&(f.classid=a.classid),a.itemcode&&(f.itemcode=a.itemcode),a.key&&(f.key=a.key);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d.message=d.description="Required parameters 'userid' or 'productcode' are not found in request options",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function n(a){var b=this,c=N.defer(),d={};if(a&&a.userid&&a.productcode&&a.appdata)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.appState;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={userid:a.userid,productcode:a.productcode};a.classid&&(f.classid=a.classid),a.itemcode&&(f.itemcode=a.itemcode);var g=O.put(e).query(f).set("Content-Type","application/json").set("Accept","application/json").send(a.appdata);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d.message=d.description="Required parameters 'userid' or 'appdata' or 'productcode' are not found in request options",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function o(a){var b=this,c=N.defer(),d={};if(a&&a.userid&&a.productcode)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.appState;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={userid:a.userid,productcode:a.productcode};a.classid&&(f.classid=a.classid),a.itemcode&&(f.itemcode=a.itemcode),a.key&&(f.key=a.key);var g=O["delete"](e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d.message=d.description="Required parameters 'userid' or 'productcode' are not found in request options",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function p(a){var b=this,c=N.defer(),d={};if(a&&a.userid&&a.productcode)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getUserProductAllState;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={userid:a.userid,productcode:a.productcode};a.classid&&(f.classid=a.classid),a.itemcode&&(f.itemcode=a.itemcode),a.model&&(f.model=a.model),a.key&&(f.key=a.key);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d.message=d.description="Required parameters 'userid' or 'productcode' are not found in request options",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function q(a){var b=this,c=N.defer(),d={};if(a&&a.userid&&a.productcode&&a.data)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.updateUserProductMultiState;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={userid:a.userid,productcode:a.productcode};a.classid&&(f.classid=a.classid);var g=O.put(e).query(f).set("Content-Type","application/json").set("Accept","application/json").send(a.data);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b)})}else d.message=d.description="Required parameters 'userid' or 'data' or 'productcode' are not found in request options",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function r(a){var b=this,c=N.defer(),d={};if(a&&a.classid&&a.productcode)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassProductRecentPendingSubmissions;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode};a.details&&(f.details=a.details),a.limit&&(f.limit=a.limit);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description='Mandatory parameters ["classid", "productcode"] not found in request options.',d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function s(a){var b=this,c=N.defer(),d={};if(a&&a.classid&&a.productcode)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassRecord;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode,userids:a.userids,includeContext:a.includeContext},g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description="Required parameter classid or productcode not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function t(a){var b=this,c=N.defer(),d={};if(a&&a.classid&&a.productcode)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassRecordItemAggregations;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode,"item-code":a["item-code"]},g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description="Required parameter classid or productcode not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function u(a){var b=this,c=N.defer(),d={};if(a&&a.classid)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getShowcaseRecordOfAClass;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid};a.productcode&&(f.productcode=a.productcode),a.groupid&&(f.groupid=a.groupid),a["item-code"]&&(f["item-code"]=a["item-code"]),a.id&&(f.id=a.id);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description="Required parameter classid not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function v(a){var b=this,c=N.defer(),d={};if(a&&a.classid&&a.productcode&&a.groupid)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getGroupRecord;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode,groupid:a.groupid};a.itemcode&&(f.itemcode=a.itemcode),a.history&&(f.history=a.history);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description="Required parameter classid or productcode or groupid not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function w(a){var b=this,c=N.defer(),d={};if(a&&a.classid&&a.productcode)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassGroupsRecentPendingSubmissions;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode};a.details&&(f.details=a.details),a.limit&&(f.limit=a.limit);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description='Mandatory parameters ["classid", "productcode"] not found in request options.',d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function x(a){var b=this,c={},d=N.defer();if(a&&a.classid&&a.productcode)if(c=Q.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getGroupsWithEvaluatedOnce;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode},g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(c=new R(Q.errors.ERROR_TYPES.API_ERROR,a),d.reject(c)):d.resolve(b.body)})}else c.message=c.description="Required parameter classid or productcode not found in request options.",c=new R(Q.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function y(a){var b=this,c={},d=N.defer();if(a&&a.classid&&a.productcode)if(c=Q.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassRecordUserAggregations;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode,userid:a.userid},g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(c=new R(Q.errors.ERROR_TYPES.API_ERROR,a),d.reject(c)):d.resolve(b.body)})}else c.message=c.description="Required parameter classid or productcode not found in request options.",c=new R(Q.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function z(a){var b=this,c=N.defer(),d={};if(a&&a.type&&a.analyticsDataType&&a.classid)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else if(d={},!a.range&&!a.interval||a.range&&"stat"===a.type||a.interval&&"timeseries"===a.type){var e=["enrolments","logins"];if(e.indexOf(a.analyticsDataType)>-1){var f=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassAnalytics;f=Q.api.constructAPIUrl(f,{orgId:b.orgId,type:a.type,analyticsDataType:a.analyticsDataType});var g={classid:a.classid};a&&(a.range&&(g.range=a.range),a.start&&(g.start=a.start),a.end&&(g.end=a.end),a.interval&&(g.interval=a.interval));var h=O.get(f).query(g);h=Q.api.setupAPIToken(h,b.token),b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d.message=d.description="analyticsDataType: "+a.analyticsDataType+" is not supported",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d)}else d.message=d.description='Range should be defined for type - "stat" and Interval should be defined for type - "timeseries"',d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);else d.message=d.description='Required options ["type", "analyticsDataType", "classid"] not found in request options',d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function A(a){var b=this,c=N.defer(),d={};if(a&&a.useranalyticid)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getArchivedUserAnalytics;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={useranalyticid:a.useranalyticid};a&&(a.cursor&&(f.cursor=a.cursor),a.limit&&(f.limit=a.limit));var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d.message=d.description="Mandatory field 'useranalyticid' not found in request options",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function B(a){for(var b={},c=0;c<a.length;c++)for(var d=a[c]["learning-objectives"],e=0;e<d.length;e++){var f,g,h;if(b[d[e]]){var i=b[d[e]];f=a[c].__analytics,"correct"===f.statusEvaluation&&(g=i.status.correct,i.status.correct=g+1);var j=i.status.total;i.status.total=j+1,h={"question-code":a[c].questionCode,analytics:f},i.questions.push(h),b[d[e]]=i}else{g=0,f=a[c].__analytics,"correct"===f.statusEvaluation&&g++;var k={status:{correct:g,total:1},questions:[]};h={"question-code":a[c].questionCode,analytics:f},k.questions.push(h),b[d[e]]=k}}return b}function C(a){var b=this,c=N.defer(),d=Q.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid){var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getAllAssignedPathsOfClass;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,status_not_started:a.status_not_started,status_active:a.status_active,status_expired:a.status_expired,limit:a.limit,cursor:a.cursor},g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.agent(S).end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory param - classid not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function D(a){var b=this,c=N.defer(),d=Q.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.productcode){var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getAssignedPathAnalytics;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,assignedpathid:a.assignedPathId,ext_assignedpathid:a.ext_assignedpathid,productcode:a.productcode},g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - classid or productcode not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function E(a){var b=this,c=N.defer(),d=Q.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.userid){var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getMyAssignedPathsOfClass;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={userid:a.userid,classid:a.classid};a.progress&&(f.progress=a.progress),a.group&&(f.group=a.group),a.expiredView&&(f.expiredView=a.expiredView),a.status_not_started&&(f.status_not_started=a.status_not_started),a.status_active&&(f.status_active=a.status_active),a.status_expired&&(f.status_expired=a.status_expired);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.agent(S).end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - classid, userid not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function F(a){var b=this,c=N.defer(),d=Q.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.userid){var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getMyAssignedPathsOfClass;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={userid:a.userid,classid:a.classid};a.progress&&(f.progress=a.progress),a.group&&(f.group=a.group),a.expiredView&&(f.expiredView=a.expiredView),a.status_not_started&&(f.status_not_started=a.status_not_started),a.status_active&&(f.status_active=a.status_active),a.status_expired&&(f.status_expired=a.status_expired);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.agent(S).end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - classid, userid not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function G(a){var b=this,c=N.defer(),d=Q.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.userid){var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getMyAssignedPathsOfClass;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={assignedpathid:a.assignedPathId,classid:a.classid,userid:a.userid};a.progress&&(f.progress=a.progress),a.group&&(f.group=a.group),a.assignedpathid&&(f.assignedpathid=a.assignedpathid),a.ext_assignedpathid&&(f.ext_assignedpathid=a.ext_assignedpathid),a.expiredView&&(f.expiredView=a.expiredView);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - classid, userid not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function H(a){var b=this,c=N.defer(),d=Q.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&(a.assignedpathid||a.ext_assignedpathid)){var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getAllAssignedPathsOfClass;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid};a.assignedpathid&&(f.assignedpathid=a.assignedpathid),a.ext_assignedpathid&&(f.ext_assignedpathid=a.ext_assignedpathid);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.agent(S).end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body.entities[0])})}else d={},d.message=d.description="Mandatory params - 'classid', 'assignedpathid'/'ext_assignedpathid' not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function I(a){var b,c=this,d=N.defer();if(a&&a.query){var e=c.config.DEFAULT_HOSTS.ANALYTICS+c.config.ANALYTICS_API_URLS.timeseriesAnalytics,f={query:a.query};a.cursor&&(f.cursor=a.cursor);var g=O.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.agent(S).end(function(a,c){a?(b=new R(Q.errors.ERROR_TYPES.API_ERROR,a),d.reject(b)):d.resolve(c.body)})}else b={},b.message=b.description="Mandatory params query not found in request options.",b=new R(Q.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function J(a){var b,c=this,d=N.defer();if(a&&a.body&&a.body.query){var e=c.config.DEFAULT_HOSTS.ANALYTICS+c.config.ANALYTICS_API_URLS.timeseriesAnalytics,f=O.post(e).send(a.body);if(a.cursor){var g={cursor:a.cursor};f.query(g)}c.traceid&&f.set("X-Amzn-Trace-Id",c.traceid),f.agent(S).end(function(a,c){a?(b=new R(Q.errors.ERROR_TYPES.API_ERROR,a),d.reject(b)):d.resolve(c.body)})}else b={},b.message=b.description="Mandatory options.body.query not found in request options.",b=new R(Q.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function K(a){var b=this,c=N.defer(),d={};if(a&&a.classid)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassCustomComponentRecord;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid};a.custom_component_code&&(f.custom_component_code=a.custom_component_code);
3
+ var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),d.message=a.response.res.text,c.reject(d)):c.resolve(b.body)})}else d.message=d.description="Required parameter classid not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function L(a){var b=this,c=N.defer(),d={};if(a&&a.classid&&a.custom_component_code&&a.userid&&a.item_code)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassCustomComponentUserSubmission;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,userid:a.userid,custom_component_code:a.custom_component_code,item_code:a.item_code},g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),d.message=a.response.res.text,c.reject(d)):c.resolve(b.body)})}else d.message=d.description="Required parameter classid or custom-component-code or userid or item-code not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function M(a){var b=this,c=N.defer(),d={};if(a&&a.classid)if(d=Q.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getCrossProductAggregation;e=Q.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid};a.userid&&(f.userid=a.userid);var g=O.get(e).query(f);g=Q.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new R(Q.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description="Required parameter classid not found in request options.",d=new R(Q.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}var N=a("q"),O=a("superagent"),P=a("agentkeepalive"),Q=a("../../helpers"),R=Q.errors.DLSError;b.exports=d;var S=new P({timeout:6e4,freeSocketTimeout:3e4})},{"../../helpers":3,agentkeepalive:36,q:46,superagent:49}],15:[function(a,b,c){function d(){return{getUserAllAttemptsForActivity:e.bind(this),createUserAttemptForActivity:f.bind(this),getUserAttemptStatsForActivity:g.bind(this),getUserAttemptForActivity:h.bind(this),getUserFirstAttemptForActivity:i.bind(this),getUserLastAttemptForActivity:j.bind(this),updateUserAttemptForActivity:k.bind(this),getUserActivityMeta:l.bind(this)}}function e(a){var b,c=this,d=m.defer();if(a&&a.userid&&a.activityid){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.userAttempts;e=o.api.constructAPIUrl(e,{orgId:c.orgId,userId:a.userid,activityId:a.activityid});var f={};a.allorgs&&(f.allorgs=a.allorgs),a.classid&&(f.classid=a.classid),a.assignmentid&&(f.assignmentid=a.assignmentid),a.productcode&&(f.productcode=a.productcode),a.cursor&&(f.cursor=a.cursor),a.limit&&(f.limit=a.limit),a.sortOrder&&(f.sortOrder=a.sortOrder);var g=n.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new p(o.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - userid or activityid not found in request options.",b=new p(o.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function f(a){var b,c=this,d=m.defer();if(a&&a.userid&&a.activityid&&a.body){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.userAttempts;e=o.api.constructAPIUrl(e,{orgId:c.orgId,userId:a.userid,activityId:a.activityid});var f=n.post(e).send(a.body);c.traceid&&f.set("X-Amzn-Trace-Id",c.traceid),f.end(function(a,b){a?(a=new p(o.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - userid or activityid or body not found in request options.",b=new p(o.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function g(a){var b,c=this,d=m.defer();if(a&&a.userid&&a.activityid){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.getUserAttemptStatsForActivity;e=o.api.constructAPIUrl(e,{orgId:c.orgId,userId:a.userid,activityId:a.activityid});var f={};a.allorgs&&(f.allorgs=a.allorgs),a.classid&&(f.classid=a.classid),a.assignmentid&&(f.assignmentid=a.assignmentid);var g=n.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new p(o.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - userid or activityid not found in request options.",b=new p(o.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function h(a){var b,c=this,d=m.defer();if(a&&a.userid&&a.activityid&&a.attemptid){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.getUserAttemptForActivity;e=o.api.constructAPIUrl(e,{orgId:c.orgId,userId:a.userid,activityId:a.activityid,attemptId:a.attemptid});var f={};a.details&&(f.details=a.details);var g=n.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new p(o.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - userid or activityid or attemptid not found in request options.",b=new p(o.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function i(a){var b,c=this,d=m.defer();if(a&&a.userid&&a.activityid){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.getUserFirstAttemptForActivity;e=o.api.constructAPIUrl(e,{orgId:c.orgId,userId:a.userid,activityId:a.activityid});var f={};a.details&&(f.details=a.details),a.classid&&(f.classid=a.classid),a.assignmentid&&(f.assignmentid=a.assignmentid);var g=n.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new p(o.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - userid or activityid not found in request options.",b=new p(o.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function j(a){var b,c=this,d=m.defer();if(a&&a.userid&&a.activityid){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.getUserLastAttemptForActivity;e=o.api.constructAPIUrl(e,{orgId:c.orgId,userId:a.userid,activityId:a.activityid});var f={};a.details&&(f.details=a.details),a.classid&&(f.classid=a.classid),a.assignmentid&&(f.assignmentid=a.assignmentid);var g=n.get(e).query(f);console.log(e,f,g),c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new p(o.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - userid or activityid not found in request options.",b=new p(o.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function k(a){var b,c=this,d=m.defer();if(a&&a.userid&&a.activityid&&a.attemptid&&a.body){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.getUserAttemptForActivity;e=o.api.constructAPIUrl(e,{orgId:c.orgId,userId:a.userid,activityId:a.activityid,attemptId:a.attemptid});var f=a.body,g=n.put(e).set("Content-Type","application/json").set("Accept","application/json").send(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new p(o.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - userid or activityid or attemptid or body not found in request options.",b=new p(o.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function l(a){var b,c=this,d=m.defer();if(a&&a.userid&&a.activityid){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.getUserActivityMeta;e=o.api.constructAPIUrl(e,{orgId:c.orgId,userId:a.userid,activityId:a.activityid});var f={};a.classid&&(f.classid=a.classid),a.assignmentid&&(f.assignmentid=a.assignmentid);var g=n.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new p(o.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - userid or activityid not found in request options.",b=new p(o.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}var m=a("q"),n=a("superagent"),o=a("../../helpers"),p=o.errors.DLSError;b.exports=d},{"../../helpers":3,q:46,superagent:49}],16:[function(a,b,c){function d(){return{pisImport:m.bind(this),getAllUsers:g.bind(this),getAllUsersV2:h.bind(this),getUserProfile:e.bind(this),deleteUserProfile:f.bind(this),updateUserRole:i.bind(this),getUserClasses:j.bind(this),getUserClassesV2:k.bind(this),getClassUsers:l.bind(this),enrollUsertoClass:D.bind(this),enrollSelftoClass:E.bind(this),enrollMultiUserstoClass:F.bind(this),unEnrollMultiUserstoClass:G.bind(this),unEnrollUsertoClass:H.bind(this),getOrgSettings:n.bind(this),updateOrgSettings:o.bind(this),generateClassCode:p.bind(this),getAllJobs:q.bind(this),getJob:r.bind(this),createClass:J.bind(this),updateClass:K.bind(this),createMultipleClasses:L.bind(this),deleteClass:M.bind(this),cloneClass:ca.bind(this),getAllClasses:s.bind(this),getParticularClass:t.bind(this),getParticularShadowClass:u.bind(this),createClassProductAssociation:v.bind(this),removeClassProductAssociation:y.bind(this),createMultiClassProductAssociations:z.bind(this),associateMaterialsWithClass:w.bind(this),unassociateMaterialsWithClass:x.bind(this),addItemsToShowcaseOfAClass:aa.bind(this),deleteItemsFromShowcaseOfAClass:ba.bind(this),getClassAppdata:A.bind(this),putClassAppdata:B.bind(this),deleteClassAppdata:C.bind(this),encodeURLParameter:I.bind(this),createAssignedPath:N.bind(this),deleteAssignedPath:O.bind(this),updateAssignedPath:P.bind(this),createGroup:Q.bind(this),getAllGroupsByPath:R.bind(this),getAGroup:S.bind(this),updateGroup:T.bind(this),deleteGroup:U.bind(this),getAllMembersOfAGroup:V.bind(this),getAllGroupMembersByPath:W.bind(this),createMultiUserGroupMembership:X.bind(this),deleteMultiUserGroupMembership:Y.bind(this),getMyAllMemberships:_.bind(this),archiveGroup:Z.bind(this),unarchiveGroup:$.bind(this),createGradebookMeta:da.bind(this),updateGradebookMeta:ea.bind(this),deleteGradebookMeta:fa.bind(this),getParticularGradebookMetaOfAClass:ga.bind(this),getAllGradebooksMetaOfAClass:ha.bind(this),addGradebookColumns:ia.bind(this),updateMultipleGradebookColumns:ja.bind(this),removeGradebookColumns:ka.bind(this),getParticularColumnOfAGradebook:la.bind(this),getAllColumnsOfAGradebook:ma.bind(this),getAllClassesOfAComponent:na.bind(this),removeAllGradebookColumnsOfCustomComponent:oa.bind(this),createCustomComponent:pa.bind(this),updateCustomComponent:qa.bind(this),deleteCustomComponent:ra.bind(this),getParticularCustomComponent:sa.bind(this),getAllCustomComponents:ta.bind(this)}}function e(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else{var e="me";a&&a.userid&&(e=a.userid);var f=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.userInfoAPI;f=xa.api.constructAPIUrl(f,{orgId:b.orgId,userId:e});var g={},h=va.get(f).query(g);b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h=xa.api.setupAPIToken(h,b.token),h.end(function(a,b){if(a)a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a);else{var d=ya.convertUserResponse({data:b.body});c.resolve(d)}})}return c.promise}function f(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a.userid){var e=a.userid,f=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.userInfoAPI;f=xa.api.constructAPIUrl(f,{orgId:b.orgId,userId:e});var g=va["delete"](f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=xa.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory parameter userid not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function g(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else{var e='orgid:"'+b.orgId+'"';if(a.lookup&&a["lookup-operator"]){var f=a.lookup;f=f.replace(/ext_/gi,"");var g=f.split(",").map(function(a){var b=a.trim(),c=b.split(":");return b="("+b+" OR "+c[0]+".keyword:"+c[1]+")"});e=e+" AND ("+g.join(" "+a["lookup-operator"]+" ")+")"}if(a.role){var h=a.role,i=h.split(",").map(function(a){return a.trim()});for(var j in i)i[j]="roles:"+i[j];e=e+" AND ("+i.join(" OR ")+")"}a.search&&(e=e+' AND (email:"'+a.search+'" OR first_name:"'+a.search+'" OR last_name:"'+a.search+'" OR username:"'+a.search+'" OR userid:"'+a.search+'")');var k=a.sortField||"";k=k.replace(/ext_/gi,"").split(",").shift().trim()||"last_name";var l=a.sortOrder||"asc";"created"!==k&&(k+=".keyword");var m={},n=[];m[k]=l,n.push(m);var o={query:{query_string:{query:e}},sort:n};a.cursor&&(o.search_after=JSON.parse(a.cursor)),a.limit?o.size=a.limit:a.limit=10;var p=b.config.DEFAULT_HOSTS.INTEGRATION+b.config.INTEGRATIONS_API_URLS.queryDataFromSearch;p=xa.api.constructAPIUrl(p,{index:"users"});var q={query:JSON.stringify(o)},r=va.get(p).query(q);b.traceid&&r.set("X-Amzn-Trace-Id",b.traceid),r=xa.api.setupAPIToken(r,b.token),r.end(function(d,e){if(d){var f={type:xa.errors.ERROR_TYPES.API_ERROR,err:d},g=ya.convertElasticsearchErrResponse(f);c.reject(g)}else{var h={entities:[]};if(h.count=e.body.hits.hits.length,h.count&&a.limit===h.count){var i=e.body.hits.hits[e.body.hits.hits.length-1].sort;h.cursor=JSON.stringify(i)}for(var j in e.body.hits.hits){var k=e.body.hits.hits[j]._source,l={uuid:k.dls_user_id,name:k.first_name+" "+k.last_name,email:k.email||k.ext_email,username:k.userid+"--ACCOUNT",created:k.created,org:{id:b.orgId}};k.roles&&(l.roles=k.roles),k.provision_method&&(l.provision_method=k.provision_method),k.first_name&&(l.first_name=k.first_name),k.last_name&&(l.last_name=k.last_name),k.ext_parent_id&&(l.ext_parent_id=k.ext_parent_id),k.username&&(l.ext_username=k.username),k.userid&&(l.ext_user_id=k.userid),k.address&&(l.address=k.address),h.entities.push(l)}c.resolve(h)}})}return c.promise}function h(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else{var e={query:{bool:{must:[]}},size:a.limit||10},f='orgid:"'+b.orgId+'"';if(a.role){var g,h;g=a.role,h=g.split(",").map(function(a){return a.trim()});for(var i in h)h[i]="roles:"+h[i];f=f+" AND ("+h.join(" OR ")+")"}if(e.query.bool.must.push({query_string:{query:f}}),a.lookup&&a["lookup-operator"]){var j,k;j=a.lookup.replace(/ext_/gi,""),k=j.split(",");var l={bool:{}};for(var m in k){var n,o,p=k[m].trim(),q=p.split(":"),r={wildcard:{}};if(n=q[0]+".keyword",o=q[1],"email.keyword"===n?r.wildcard[n]={value:o,case_insensitive:!0}:r.wildcard[n]={value:o,case_insensitive:!1},"OR"!==a["lookup-operator"]){var s="The value 'AND' for the field 'lookup-operator' is currently NOT supported";return d={},d.message=d.description=s,d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d),c.promise}l.bool.should||(l.bool.should=[]),l.bool.should.push(r)}e.query.bool.must.push(l)}var t,u,v={},w=[];t=a.sortField||"last_name",u=a.sortOrder||"asc",t=t.replace(/ext_/gi,"").split(",").shift().trim(),"created"!==t&&(t+=".keyword"),v[t]=u,w.push(v),e.sort=w,a.cursor&&(e.search_after=JSON.parse(a.cursor));var x=b.config.DEFAULT_HOSTS.INTEGRATION+b.config.INTEGRATIONS_API_URLS.queryDataFromSearch;x=xa.api.constructAPIUrl(x,{index:"users"});var y={query:JSON.stringify(e)},z=va.get(x).query(y);b.traceid&&z.set("X-Amzn-Trace-Id",b.traceid),z=xa.api.setupAPIToken(z,b.token),z.end(function(d,e){if(d){var f={type:xa.errors.ERROR_TYPES.API_ERROR,err:d},g=ya.convertElasticsearchErrResponse(f);c.reject(g)}else{var h={entities:[],count:e.body.hits.hits.length};if(h.count&&a.limit===h.count){var i=e.body.hits.hits[e.body.hits.hits.length-1].sort;h.cursor=JSON.stringify(i)}for(var j in e.body.hits.hits){var k=e.body.hits.hits[j]._source,l={uuid:k.dls_user_id,name:k.first_name+" "+k.last_name,email:k.email||k.ext_email,username:k.userid+"--ACCOUNT",created:k.created,org:{id:b.orgId}};k.roles&&(l.roles=k.roles),k.provision_method&&(l.provision_method=k.provision_method),k.first_name&&(l.first_name=k.first_name),k.last_name&&(l.last_name=k.last_name),k.ext_parent_id&&(l.ext_parent_id=k.ext_parent_id),k.username&&(l.ext_username=k.username),k.userid&&(l.ext_user_id=k.userid),k.address&&(l.address=k.address),h.entities.push(l)}c.resolve(h)}})}return c.promise}function i(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.userid&&a.target_role){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.updateUserRoleAPI;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,userId:a.userid});var f={ext_data:a.ext_data,target_role:a.target_role},g=va.put(e).set("Content-Type","application/json").set("Accept","application/json").send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=xa.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b)})}else{var h={};h.message=h.description="Mandatory parameter options, userid or target_role, not found in request options.",h=new za(xa.errors.ERROR_TYPES.SDK_ERROR,h),c.reject(h)}return c.promise}function j(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else{var e="me";a&&a.userid&&(e=a.userid);var f=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getUserClassesAPI;f=xa.api.constructAPIUrl(f,{orgId:b.orgId,userId:e});var g={};a&&(a.search&&(g.search="title:"+a.search),a.details&&(g.details=a.details),a.enrollmentType&&(g.enrollmentType=a.enrollmentType),a.sortField&&(g.sortField=a.sortField),a.sortOrder&&(g.sortOrder=a.sortOrder),a.cursor&&(g.cursor=a.cursor),a.limit&&(g.limit=a.limit),a.teacherId&&(g.lookup="class.class.instructor.uuid:"+a.teacherId),a.bundleDetails&&(g.bundleDetails=a.bundleDetails));var h=va.get(f).query(g);b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h=xa.api.setupAPIToken(h,b.token),h.agent(Aa).end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}return c.promise}function k(a){var b=this,c=b.orgId,d=b.token,e=ua.defer(),f=xa.validations.isAuthenticated(c,d);if(f)e.reject(f);else if(a&&a.userid){var g=a.userid,h=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getUserClassesV2API;h=xa.api.constructAPIUrl(h,{orgid:c,userid:g});var i={};a&&(void 0!==a.shadow&&(i.shadow=a.shadow),void 0!==a.hidden&&(i.hidden=a.hidden),a.status_active&&(i.status_active=a.status_active),a.status_ended&&(i.status_ended=a.status_ended),a.status_expired&&(i.status_expired=a.status_expired),a.details&&(i.details=a.details),a.bundleDetails&&(i.bundleDetails=a.bundleDetails),a.limit&&(i.limit=a.limit),a.cursor&&(i.cursor=a.cursor));var j=va.get(h).query(i);b.traceid&&j.set("X-Amzn-Trace-Id",b.traceid),j=xa.api.setupAPIToken(j,d),j.agent(Aa).end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),e.reject(a)):e.resolve(b.body)})}else f={},f.message=f.description="Required parameter 'userid' is not found in request options.",f=new za(xa.errors.ERROR_TYPES.SDK_ERROR,f),e.reject(f);return e.promise}function l(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getClassUsersAPI;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f={};a.search&&(f.search=a.search),a.cursor&&(f.cursor=a.cursor),a.limit&&(f.limit=a.limit),a.sortField&&(f.sortField=a.sortField),a.sortOrder&&(f.sortOrder=a.sortOrder);var g=va.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=xa.api.setupAPIToken(g,b.token),g.agent(Aa).end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):(b.body.entities=ya.convertEnrollmetsResponse({data:b.body.entities}),c.resolve(b.body))})}else d={},d.message=d.description="Required parameter classid is not defined.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function m(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.pisImportAPI;e=xa.api.constructAPIUrl(e,{orgId:b.orgId});var f,g={};a&&(a.extension&&(g.extension=a.extension),a.import_type&&(g.import_type=a.import_type),a.upfile&&(f=a.upfile));var h=va.post(e).query(g).set("Content-Type","multipart/form-data").attach("upfile",f);b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h=xa.api.setupAPIToken(h,b.token),h.end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}return c.promise}function n(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getSettings;e=xa.api.constructAPIUrl(e,{orgId:b.orgId});var f={};a&&a.field&&(e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getSettingsField,e=xa.api.constructAPIUrl(e,{orgId:b.orgId,field:a.field}));var g=va.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=xa.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}return c.promise}function o(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getSettings;e=xa.api.constructAPIUrl(e,{orgId:b.orgId});var f=va.put(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),a.body&&(a.body.sis&&!a.body.sis.productid&&(a.body.sis.productid=[]),f.send(a.body)),f=xa.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}return c.promise}function p(a){var b,c=this,d=ua.defer();if(a&&a.classid)if(b=xa.validations.isAuthenticated(c.orgId,c.token))d.reject(b);else{var e=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.generateClassCode;e=xa.api.constructAPIUrl(e,{orgId:c.orgId,classId:a.classid});var f=va.post(e);c.traceid&&f.set("X-Amzn-Trace-Id",c.traceid),f=xa.api.setupAPIToken(f,c.token),f.end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="classid not found in request options.",b=new za(xa.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function q(a){var b=this,c=ua.defer();if(a&&a.accountId&&a.extUserId){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getAllJobs;d=xa.api.constructAPIUrl(d,{accountId:a.accountId,extUserId:a.extUserId});var e={};a.jobType&&(e.jobType=a.jobType),a.details&&(e.details=a.details);var f=va.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(g=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(g)):c.resolve(b.body)})}else{var g={};g.message=g.description="accountId or extUserId not found in request options.",g=new za(xa.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function r(a){var b=this,c=ua.defer();if(a&&a.accountId&&a.extUserId&&a.jobId&&a.jobType){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getJob;d=xa.api.constructAPIUrl(d,{accountId:a.accountId,extUserId:a.extUserId,jobId:a.jobId});var e={jobType:a.jobType},f=va.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(g=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(g)):c.resolve(b.body)})}else{var g={};g.message=g.description="accountId or extUserId or jobType or jobId or not found in request options.",g=new za(xa.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function s(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else{var e='orgid:"'+b.orgId+'"';if(a.lookup&&a["lookup-operator"]){var f=a.lookup,g=f.split(",").map(function(a){var b=a.trim(),c=b.split(":");return b="("+c[0]+".keyword:"+c[1]+")"});e+=" AND ("+g.join(" "+a["lookup-operator"]+" ")+")"}a.search&&(e=e+' AND (title:"'+a.search+'" OR class.instructor.first_name:"'+a.search+'" OR class.instructor.last_name:"'+a.search+'" OR description:"'+a.search+'")');var h=a.sortField||"";h=h.replace(/ext_/gi,"").split(",").shift().trim()||"created","enddate"!==h&&"startdate"!==h||(h="class."+h),"title"===h&&(h+=".keyword"),"tagname_1"===h&&(h+=".keyword");var i=a.sortOrder||"desc",j={},k=[];j[h]=i,k.push(j);var l={query:{query_string:{query:e}},sort:k};a.cursor&&(l.search_after=JSON.parse(a.cursor)),a.limit?l.size=a.limit:a.limit=10;var m=b.config.DEFAULT_HOSTS.INTEGRATION+b.config.INTEGRATIONS_API_URLS.queryDataFromSearch;m=xa.api.constructAPIUrl(m,{index:"classes"});var n={query:JSON.stringify(l)},o=va.get(m).query(n);b.traceid&&o.set("X-Amzn-Trace-Id",b.traceid),o=xa.api.setupAPIToken(o,b.token),o.agent(Aa).end(function(b,d){if(b){var e={type:xa.errors.ERROR_TYPES.API_ERROR,err:b},f=ya.convertElasticsearchErrResponse(e);c.reject(f)}else{var g={entities:[]};if(g.count=d.body.hits.hits.length,g.count&&a.limit===g.count){var h=d.body.hits.hits[d.body.hits.hits.length-1].sort;g.cursor=JSON.stringify(h)}for(var i in d.body.hits.hits){var j=d.body.hits.hits[i]._source,k={uuid:j.classid,created:j.created,modified:j.modified,path:j.path,category:j.category,"class":{enddate:j["class"].enddate,instructor:{name:j["class"].instructor.first_name+" "+j["class"].instructor.last_name,last_name:j["class"].instructor.last_name,first_name:j["class"].instructor.first_name,uuid:j["class"].instructor.dls_user_id,email:j["class"].instructor.email,username:j["class"].instructor.userid+"--ACCOUNT"},startdate:j["class"].startdate},"class.settings.active":j["class.settings.active"],class_code:j.class_code,class_ownership:j.class_ownership||{owner_status:"ENROLLED",model:"STRICT"},description:j.description,provision_method:j["class"].provision_method,title:j.title,analyticsharingmodel:j.analyticsharingmodel,analytics_score_aggregation_type:j.analytics_score_aggregation_type,hidden:j.hidden,studentCount:j.studentCount,teacherCount:j.teacherCount};j.limits&&(k.limits=j.limits),j.hasOwnProperty("assignedPathCount")&&(k.assignedPathCount=j.assignedPathCount);for(var l=1;l<=10;l++){var m="tagid_"+l;j[m]&&(k[m]=j[m],k["tagname_"+l]=j["tagname_"+l],k["taglookup_"+l]=j["taglookup_"+l])}g.entities.push(k)}c.resolve(g)}})}return c.promise}function t(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classId){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getParticularClassAPI;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId});var f=va.get(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.agent(Aa).end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="classId not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function u(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.ext_classid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getParticularShadowClassAPI;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,extClassId:a.ext_classid});var f=va.get(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="ext_classid not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function v(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classId&&a.productcode){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.classProductAssociation;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId,productcode:a.productcode});var f=va.post(e).set("Content-Type","application/json").set("Accept","application/json");b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="classId or productcode not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function w(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classId&&a.body&&(a.body.productcodes||a.body.bundlecodes)){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.classMaterialAssociation;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId});var f=va.post(e).set("Content-Type","application/json").set("Accept","application/json");b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.agent(Aa).end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="classId or productcodes or bundlecodes not found inrequest options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function x(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classId&&a.body&&(a.body.productcodes||a.body.bundlecodes)){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.classMaterialAssociation;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId});var f=va["delete"](e).set("Content-Type","application/json").set("Accept","application/json");b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.agent(Aa).end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else{d={};const g="classId or productcodes or bundlecodes not found in request options.";d.message=g,d.description=g,d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d)}return c.promise}function y(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classId&&a.productcode){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.classProductAssociation;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId,productcode:a.productcode});var f={},g=va["delete"](e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=xa.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="classId or productcode not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function z(a){var b=ua.defer(),c=this,d=xa.validations.isAuthenticated(c.orgId,c.token);if(d)b.reject(d);else if(a&&a.classId&&a.productcodes){var e=c.config.DEFAULT_HOSTS.AUTH,f=c.config.AUTH_API_URLS.multiClassProductAssociations,g=e+f,h={productcodes:a.productcodes};g=xa.api.constructAPIUrl(g,{orgId:c.orgId,classId:a.classId});var i=va.post(g).set("Content-Type","application/json").set("Accept","application/json").send(h);c.traceid&&i.set("X-Amzn-Trace-Id",c.traceid),i=xa.api.setupAPIToken(i,c.token),i.end(function(a,c){a?(d=new za(xa.errors.ERROR_TYPES.API_ERROR,a),b.reject(d)):b.resolve(c.body)})}else d={},d.message=d.description="Missing mandaotry fields 'classId' or 'productcodes' in request.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),b.reject(d);return b.promise}function A(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.ClassAppdata;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classid:a.classid});var f=va.get(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="classid not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function B(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);
4
+ if(d)c.reject(d);else if(a&&a.classid&&a.appdata){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.ClassAppdata;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classid:a.classid});var f=va.put(e).set("Content-Type","application/json").set("Accept","application/json").send(a.appdata);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="classid or appdata not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function C(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.ClassAppdata;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classid:a.classid});var f=va["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="classid not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function D(a){var b=this,c={},d=ua.defer();if(a&&a.classid&&a.userid)if(c=xa.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.enrollUsertoClass;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid,userId:a.userid});var f={},g=va.post(e).set("Content-Type","application/json").set("Accept","application/json").query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=xa.api.setupAPIToken(g,b.token),g.agent(Aa).end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else c.message=c.description="Mandatory parameter classid or userid not found in request options",c=new za(xa.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function E(a){var b=this,c={},d=ua.defer();if(a&&a.classid)if(c=xa.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.enrollSelftoClass;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f={classrole:a.classrole},g=va.post(e).set("Content-Type","application/json").set("Accept","application/json").send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=xa.api.setupAPIToken(g,b.token),g.agent(Aa).end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else c.message=c.description="Mandatory parameter classid not found in request options",c=new za(xa.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function F(a){var b=this,c={},d=ua.defer();if(a&&a.classid&&a.users)if(c=xa.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.enrollMultiUserstoClass;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f={users:a.users},g=va.post(e).set("Content-Type","application/json").set("Accept","application/json").send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=xa.api.setupAPIToken(g,b.token),g.agent(Aa).end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else c.message=c.description="Mandatory parameter classid or users array not found in request options",c=new za(xa.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function G(a){var b=this,c={},d=ua.defer();if(a&&a.classid&&a.users)if(c=xa.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.enrollMultiUserstoClass;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f={users:a.users},g=va["delete"](e).set("Content-Type","application/json").set("Accept","application/json").send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=xa.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else c.message=c.description="Mandatory parameter classid or users array not found in request options",c=new za(xa.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function H(a){var b=this,c={},d=ua.defer();if(a&&a.classid&&a.userid)if(c=xa.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.enrollUsertoClass;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid,userId:a.userid});var f={},g=va["delete"](e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=xa.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else c.message=c.description="Mandatory parameter classid or userid not found in request options",c=new za(xa.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function I(a){var b={};for(var c in a)b[a[c]]=encodeURIComponent(a[c]);return b}function J(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.title&&a.startdate&&a.enddate){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.createClass;e=xa.api.constructAPIUrl(e,{orgId:b.orgId});var f={title:a.title,startdate:a.startdate,enddate:a.enddate};a.description&&(f.description=a.description),a.class_ownership&&(f.class_ownership=a.class_ownership),a.ext_data&&(f.ext_data=a.ext_data),a.analyticsharingmodel&&(f.analyticsharingmodel=a.analyticsharingmodel),a.limits&&(f.limits=a.limits);var g=va.post(e).send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=xa.api.setupAPIToken(g,b.token),g.agent(Aa).end(function(a,b){if(a)a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a);else{var d=ya.convertClassResponse({data:b.body});c.resolve(d)}})}else d={},d.message=d.description="title or startdate or enddate not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function K(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.specificClass;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f=va.put(e).send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.agent(Aa).end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory parameter 'classid' is not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function L(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a.classes&&a.classes.length>0||a.clone_classes&&a.clone_classes.length>0){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.createMultipleClasses;e=xa.api.constructAPIUrl(e,{orgId:b.orgId});var f=va.post(e).send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.agent(Aa).end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory parameters - [classes, clone_classes], not found in request options",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function M(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.body){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.specificClass;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f=va["delete"](e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - classid or body not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function N(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.data&&a.data.title&&a.data.items&&a.data.items.length>0){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.createAssignedPath;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f=va.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a.data);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - title or classid or items not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function O(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.assignedpathid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.deleteAssignedPath;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid,assignedPathId:a.assignedpathid});var f=va["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - classid or assignedpathid not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function P(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.assignedpathid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.deleteAssignedPath;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid,assignedPathId:a.assignedpathid});var f=va.put(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),a.data&&f.send(a.data),f=xa.api.setupAPIToken(f,b.token),f.agent(Aa).end(function(a,b){a?(d=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - classid or assignedpathid not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function Q(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.title&&a.startdate&&a.enddate){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.allGroups;e=xa.api.constructAPIUrl(e,{orgId:b.orgId});var f=va.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b)})}else d={},d.message=d.description="title or startdate or enddate not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function R(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.path){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.allGroups;e=xa.api.constructAPIUrl(e,{orgId:b.orgId});var f={path:a.path};a.cursor&&(f.cursor=a.cursor);var g=va.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=xa.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(d=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b)})}else d={},d.message=d.description="Mandatory params - path not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function S(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.groupId){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.aParticularGroup;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,groupId:a.groupId});var f=va.get(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b)})}else d={},d.message=d.description="Mandatory params - groupId not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function T(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.groupId){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.aParticularGroup;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,groupId:a.groupId});var f=va.put(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b)})}else d={},d.message=d.description="Mandatory params - groupId not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function U(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.groupId){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.aParticularGroup;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,groupId:a.groupId});var f=va["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b)})}else d={},d.message=d.description="Mandatory params - groupId not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function V(a){var b=this,c=ua.defer(),d={},e=xa.validations.isAuthenticated(b.orgId,b.token);if(e)c.reject(e);else if(a&&a.groupId){var f=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getAllMembersOfAGroup;f=xa.api.constructAPIUrl(f,{orgId:b.orgId,groupId:a.groupId}),a.cursor&&(d.cursor=a.cursor);var g=va.get(f).set("Content-Type","application/json").set("Accept","application/json").send(d);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=xa.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(e=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(e)):c.resolve(b)})}else e={},e.message=e.description="Mandatory param - groupId not found in request options.",e=new za(xa.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function W(a){var b=this,c=ua.defer(),d={},e=xa.validations.isAuthenticated(b.orgId,b.token);if(e)c.reject(e);else if(a&&a.path){var f=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getAllGroupMembersByPath;f=xa.api.constructAPIUrl(f,{orgId:b.orgId}),d.path=a.path,a.cursor&&(d.cursor=a.cursor);var g=va.get(f).set("Content-Type","application/json").set("Accept","application/json").query(d);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=xa.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(e=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(e)):c.resolve(b)})}else e={},e.message=e.description="Mandatory param - path not found in request options.",e=new za(xa.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function X(a){var b=this,c=ua.defer(),d={},e=xa.validations.isAuthenticated(b.orgId,b.token);if(e)c.reject(e);else if(a&&a.groupId&&a.body&&a.body.users&&a.body.users.length>0){var f=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.userGroupMembership;f=xa.api.constructAPIUrl(f,{orgId:b.orgId,groupId:a.groupId}),d=a.body;var g=va.post(f).set("Content-Type","application/json").set("Accept","application/json").send(d);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=xa.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(e=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(e)):c.resolve(b)})}else e={},e.message=e.description="Mandatory param - groupId or body or body.users(min. 1 user) not found in request options.",e=new za(xa.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function Y(a){var b=this,c=ua.defer(),d={},e=xa.validations.isAuthenticated(b.orgId,b.token);if(e)c.reject(e);else if(a&&a.groupId&&a.body&&a.body.users&&a.body.users.length>0){var f=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.userGroupMembership;f=xa.api.constructAPIUrl(f,{orgId:b.orgId,groupId:a.groupId}),d=a.body;var g=va["delete"](f).set("Content-Type","application/json").set("Accept","application/json").send(d);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=xa.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(e=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(e)):c.resolve(b)})}else e={},e.message=e.description="Mandatory param - groupId or body or body.users(min. 1 user) not found in request options.",e=new za(xa.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function Z(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.groupId){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.archiveAParticularGroup;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,groupId:a.groupId});var f=va.put(e).set("Content-Type","application/json").set("Accept","application/json").send({});b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory param - groupId not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function $(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.groupId){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.unarchiveAParticularGroup;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,groupId:a.groupId});var f=va.put(e).set("Content-Type","application/json").set("Accept","application/json").send({});b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory param - groupId not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function _(a){var b=this,c=ua.defer(),d={},e=xa.validations.isAuthenticated(b.orgId,b.token);if(e)c.reject(e);else if(a&&a.userId&&a.path){var f=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getMyAllMemberships;f=xa.api.constructAPIUrl(f,{orgId:b.orgId,userId:a.userId}),d.path=a.path,a.cursor&&(d.cursor=a.cursor);var g=va.get(f).set("Content-Type","application/json").set("Accept","application/json").query(d);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=xa.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(e=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(e)):c.resolve(b)})}else e={},e.message=e.description="Mandatory param - userId or path not found in request options.",e=new za(xa.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function aa(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classId&&a.body){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.showcaseItems;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId});var f=va.post(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.send(a.body),f=xa.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory param - classId or body not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function ba(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classId&&a.body){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.showcaseItems;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId});var f=va["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.send(a.body),f=xa.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory param - classId or body not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function ca(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.title&&a.startdate&&a.enddate&&a.instructor&&a.classid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.cloneClass;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f=va.post(e).send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.agent(Aa).end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="title or startdate or enddate or instructor or classid not found in request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function da(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.body){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.createOrGetGradebookMeta;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f=va.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.agent(Aa).end(function(a,b){if(a){var d=new za(xa.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory param - classid or body not found in request options.",g=new za(xa.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function ea(a){var b=ua.defer(),c=this,d={},e=xa.validations.isAuthenticated(c.orgId,c.token);if(e)b.reject(e);else if(a&&a.classid&&a.gradebook_id&&a.body)if(0!==Object.keys(a.body).length){var f=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.updateOrDeleteGradebookMeta;f=xa.api.constructAPIUrl(f,{orgId:c.orgId,classId:a.classid,gradebook_id:a.gradebook_id});var g=a.body,h=va.put(f).set("Content-Type","application/json").set("Accept","application/json").send(g);c.traceid&&h.set("X-Amzn-Trace-Id",c.traceid),h=xa.api.setupAPIToken(h,c.token),h.agent(Aa).end(function(a,c){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else d.message=d.description="Body of the request cannot be empty.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),b.reject(d);else d.message=d.description="Mandatory params: classid, gradebook_id or body not found in the request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),b.reject(d);return b.promise}function fa(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.gradebook_id){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.updateOrDeleteGradebookMeta;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid,gradebook_id:a.gradebook_id});var f=va["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.agent(Aa).end(function(a,b){if(a){var d=new za(xa.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory params - classid or gradebook_id not found in request options.",g=new za(xa.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function ga(a){var b=ua.defer(),c=this,d=xa.validations.isAuthenticated(c.orgId,c.token);if(d)b.reject(d);else if(a&&a.classid&&a.gradebook_id){var e=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.createOrGetGradebookMeta;e=xa.api.constructAPIUrl(e,{orgId:c.orgId,classId:a.classid});var f={gradebook_id:a.gradebook_id},g=va.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g=xa.api.setupAPIToken(g,c.token),g.agent(Aa).end(function(a,c){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):c.body.entities?b.resolve(c.body.entities[0]):b.resolve()})}else{var h={};h.message=h.description="Mandatory params: classid or gradebook_id not found in request options.",h=new za(xa.errors.ERROR_TYPES.SDK_ERROR,h),b.reject(h)}return b.promise}function ha(a){var b=ua.defer(),c=this,d=xa.validations.isAuthenticated(c.orgId,c.token);if(d)b.reject(d);else if(a&&a.classid){var e=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.createOrGetGradebookMeta;e=xa.api.constructAPIUrl(e,{orgId:c.orgId,classId:a.classid});var f={};a.cursor&&(f.cursor=a.cursor);var g=va.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g=xa.api.setupAPIToken(g,c.token),g.agent(Aa).end(function(a,c){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else{var h={};h.message=h.description="Mandatory params: classid not found in request options.",h=new za(xa.errors.ERROR_TYPES.SDK_ERROR,h),b.reject(h)}return b.promise}function ia(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.gradebook_id&&a.body){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.gradebookColumns;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid,gradebook_id:a.gradebook_id});var f=va.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.agent(Aa).end(function(a,b){if(a){var d=new za(xa.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory param - classid, gradebook_id or body not found in request options.",g=new za(xa.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function ja(a){var b=ua.defer(),c=this,d={},e=xa.validations.isAuthenticated(c.orgId,c.token);if(e)b.reject(e);else if(a&&a.classid&&a.gradebook_id&&a.body&&a.body.columns){var f=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.gradebookColumns;f=xa.api.constructAPIUrl(f,{orgId:c.orgId,classId:a.classid,gradebook_id:a.gradebook_id});var g=a.body,h=va.put(f).set("Content-Type","application/json").set("Accept","application/json").send(g);c.traceid&&h.set("X-Amzn-Trace-Id",c.traceid),h=xa.api.setupAPIToken(h,c.token),h.agent(Aa).end(function(a,c){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else d.message=d.description="Mandatory params: classid, gradebook_id, body or body.columns not found in the request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),b.reject(d);return b.promise}function ka(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.gradebook_id&&a.body){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.gradebookColumns;e=xa.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid,gradebook_id:a.gradebook_id});var f=va["delete"](e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.agent(Aa).end(function(a,b){if(a){var d=new za(xa.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory params - classid, gradebook_id or body not found in request options.",g=new za(xa.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function la(a){var b=ua.defer(),c=this,d=xa.validations.isAuthenticated(c.orgId,c.token);if(d)b.reject(d);else if(a&&a.classid&&a.gradebook_id&&a.column_id){var e=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.gradebookColumns;e=xa.api.constructAPIUrl(e,{orgId:c.orgId,classId:a.classid,gradebook_id:a.gradebook_id});var f={column_id:a.column_id},g=va.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g=xa.api.setupAPIToken(g,c.token),g.agent(Aa).end(function(a,c){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body.entities[0])})}else{var h={};h.message=h.description="Mandatory params: classid, gradebook_id or column_id not found in request options.",h=new za(xa.errors.ERROR_TYPES.SDK_ERROR,h),b.reject(h)}return b.promise}function ma(a){var b=ua.defer(),c=this,d=xa.validations.isAuthenticated(c.orgId,c.token);if(d)b.reject(d);else if(a&&a.classid&&a.gradebook_id){var e=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.gradebookColumns;e=xa.api.constructAPIUrl(e,{orgId:c.orgId,classId:a.classid,gradebook_id:a.gradebook_id});var f={};a.cursor&&(f.cursor=a.cursor);var g=va.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g=xa.api.setupAPIToken(g,c.token),g.agent(Aa).end(function(a,c){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else{var h={};h.message=h.description="Mandatory params: classid or gradebook_id not found in request options.",h=new za(xa.errors.ERROR_TYPES.SDK_ERROR,h),b.reject(h)}return b.promise}function na(a){var b=ua.defer(),c=this,d={},e=xa.validations.isAuthenticated(c.orgId,c.token);if(e)b.reject(e);else if(a&&a.component_code){var f=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.getAllClassesOfAComponent;f=xa.api.constructAPIUrl(f,{orgId:c.orgId,component_code:a.component_code});var g={};a.cursor&&(g.cursor=a.cursor);var h=va.get(f).query(g);c.traceid&&h.set("X-Amzn-Trace-Id",c.traceid),h=xa.api.setupAPIToken(h,c.token),h.agent(Aa).end(function(a,c){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else d.message=d.description="Mandatory params: component_code not found in the request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),b.reject(d);return b.promise}function oa(a){var b=ua.defer(),c=this,d={},e=xa.validations.isAuthenticated(c.orgId,c.token);if(e)b.reject(e);else if(a&&a.component_code){var f=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.removeAllGradebookColumnsOfCustomComponent;f=xa.api.constructAPIUrl(f,{orgId:c.orgId,component_code:a.component_code});var g=va["delete"](f).set("Content-Type","application/json").set("Accept","application/json").send(a.body);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g=xa.api.setupAPIToken(g,c.token),g.agent(Aa).end(function(a,c){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else d.message=d.description="Mandatory params: component_code not found in the request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),b.reject(d);return b.promise}function pa(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.body){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.customComponents;e=xa.api.constructAPIUrl(e,{orgid:b.orgId});var f=va.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.agent(Aa).end(function(a,b){if(a){var d=new za(xa.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory param - 'body' not found in request options.",g=new za(xa.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function qa(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.custom_component_code&&a.body)if(0===Object.keys(a.body).length)d.message=d.description="Mandatory params: 'custom_component_code' or 'body' not found in the request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.particularCustomComponent;e=xa.api.constructAPIUrl(e,{orgid:b.orgId,custom_component_code:a.custom_component_code});var f=a.body,g=va.put(e).set("Content-Type","application/json").set("Accept","application/json").send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=xa.api.setupAPIToken(g,b.token),g.agent(Aa).end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params: 'custom_component_code' or 'body' not found in the request options.",d=new za(xa.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);
5
+ return c.promise}function ra(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.custom_component_code){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.particularCustomComponent;e=xa.api.constructAPIUrl(e,{orgid:b.orgId,custom_component_code:a.custom_component_code});var f=va["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.agent(Aa).end(function(a,b){if(a){var d=new za(xa.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory params - 'custom_component_code' not found in request options.",g=new za(xa.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function sa(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.custom_component_code){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.particularCustomComponent;e=xa.api.constructAPIUrl(e,{orgid:b.orgId,custom_component_code:a.custom_component_code});var f=va.get(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=xa.api.setupAPIToken(f,b.token),f.agent(Aa).end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory params: 'custom_component_code' not found in request options.",g=new za(xa.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function ta(a){var b=this,c=ua.defer(),d=xa.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.customComponents;e=xa.api.constructAPIUrl(e,{orgid:b.orgId});var f={};a&&a.cursor&&(f.cursor=a.cursor);var g=va.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=xa.api.setupAPIToken(g,b.token),g.agent(Aa).end(function(a,b){a?(a=new za(xa.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}return c.promise}var ua=a("q"),va=a("superagent"),wa=a("agentkeepalive"),xa=a("../../helpers"),ya=a("../../helpers/lib/api/converter"),za=xa.errors.DLSError;b.exports=d;var Aa=new wa({timeout:6e4,freeSocketTimeout:3e4})},{"../../helpers":3,"../../helpers/lib/api/converter":4,agentkeepalive:36,q:46,superagent:49}],17:[function(a,b,c){function d(){return{createGradeformat:e.bind(this),updateGradeformat:f.bind(this),deleteGradeformat:g.bind(this),getAllGradeformats:i.bind(this),getParticularGradeformat:h.bind(this),associateGradeformatToClass:j.bind(this),unassociateGradeformatFromClass:k.bind(this),updateClassGradeformatAssociation:l.bind(this),getParticularGradeformatOfAClass:m.bind(this),getAllGradeformatsOfAClass:n.bind(this),getClassesOfAGradeformat:o.bind(this),createUserAssignedPathEnrollments:p.bind(this),deleteUserAssignedPathEnrollments:q.bind(this),getParticularClassV2:r.bind(this),createOrgProductEntitlement:s.bind(this),updateOrgProductEntitlement:t.bind(this),getParticularOrgProductEntitlement:u.bind(this),getAllOrgProductEntitlements:v.bind(this)}}function e(a){var b=this,c=w.defer(),d=y.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.body){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.gradeFormat;e=y.api.constructAPIUrl(e,{orgid:b.orgId});var f=x.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=y.api.setupAPIToken(f,b.token),f.agent(B).end(function(a,b){if(a){var d=new A(y.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory param - body not found in request options.",g=new A(y.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function f(a){var b=w.defer(),c=this,d={},e=y.validations.isAuthenticated(c.orgId,c.token);if(e)b.reject(e);else if(a&&a.gradeformat_id&&a.body)if(0!==Object.keys(a.body).length){var f=c.config.DEFAULT_HOSTS.AUTHEXTN+c.config.AUTHEXTN_API_URLS.particularGradeFormat;f=y.api.constructAPIUrl(f,{orgid:c.orgId,gradeformat_id:a.gradeformat_id});var g=a.body,h=x.put(f).set("Content-Type","application/json").set("Accept","application/json").send(g);c.traceid&&h.set("X-Amzn-Trace-Id",c.traceid),h=y.api.setupAPIToken(h,c.token),h.agent(B).end(function(a,c){a?(a=new A(y.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else d.message=d.description="Body of the request cannot be empty.",d=new A(y.errors.ERROR_TYPES.SDK_ERROR,d),b.reject(d);else d.message=d.description="Mandatory params: gradeformat_id or body not found in the request options.",d=new A(y.errors.ERROR_TYPES.SDK_ERROR,d),b.reject(d);return b.promise}function g(a){var b=this,c=w.defer(),d=y.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.gradeformat_id){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.particularGradeFormat;e=y.api.constructAPIUrl(e,{orgid:b.orgId,gradeformat_id:a.gradeformat_id});var f=x["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=y.api.setupAPIToken(f,b.token),f.agent(B).end(function(a,b){if(a){var d=new A(y.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory params - gradeformat_id not found in request options.",g=new A(y.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function h(a){var b=w.defer(),c=this,d=y.validations.isAuthenticated(c.orgId,c.token);if(d)b.reject(d);else if(a&&a.gradeformat_id){var e=c.config.DEFAULT_HOSTS.AUTHEXTN+c.config.AUTHEXTN_API_URLS.gradeFormat;e=y.api.constructAPIUrl(e,{orgid:c.orgId});var f={gradeformat_id:a.gradeformat_id},g=x.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g=y.api.setupAPIToken(g,c.token),g.agent(B).end(function(a,c){a?(a=new A(y.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body.entities[0])})}else{var h={};h.message=h.description="Mandatory params: gradeformat_id not found in request options.",h=new A(y.errors.ERROR_TYPES.SDK_ERROR,h),b.reject(h)}return b.promise}function i(a){var b=w.defer(),c=this,d=y.validations.isAuthenticated(c.orgId,c.token);if(d)b.reject(d);else{var e=c.config.DEFAULT_HOSTS.AUTHEXTN+c.config.AUTHEXTN_API_URLS.gradeFormat;e=y.api.constructAPIUrl(e,{orgid:c.orgId});var f={};a&&a.cursor&&(f.cursor=a.cursor);var g=x.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g=y.api.setupAPIToken(g,c.token),g.agent(B).end(function(a,c){a?(a=new A(y.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}return b.promise}function j(a){var b=this,c=w.defer(),d=y.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.gradeformat_id&&a.body){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.classGradeformatAssociation;e=y.api.constructAPIUrl(e,{orgid:b.orgId,classid:a.classid,gradeformat_id:a.gradeformat_id});var f=x.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=y.api.setupAPIToken(f,b.token),f.agent(B).end(function(a,b){a?(a=new A(y.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - classid or gradeformat_id or body not found in request options.",d=new A(y.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function k(a){var b=this,c=w.defer(),d=y.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.gradeformat_id){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.classGradeformatAssociation;e=y.api.constructAPIUrl(e,{orgid:b.orgId,classid:a.classid,gradeformat_id:a.gradeformat_id});var f=x["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=y.api.setupAPIToken(f,b.token),f.agent(B).end(function(a,b){a?(a=new A(y.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - classid or gradeformat_id not found in request options.",d=new A(y.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function l(a){var b=this,c=w.defer(),d=y.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.gradeformat_id&&a.body){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.classGradeformatAssociation;e=y.api.constructAPIUrl(e,{orgid:b.orgId,classid:a.classid,gradeformat_id:a.gradeformat_id});var f=a.body,g=x.put(e).set("Content-Type","application/json").set("Accept","application/json").send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=y.api.setupAPIToken(g,b.token),g.agent(B).end(function(a,b){a?(a=new A(y.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params: classid or gradeformat_id or body not found in the request options.",d=new A(y.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function m(a){var b=this,c=w.defer(),d=y.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.gradeformat_id){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.classGradeformats;e=y.api.constructAPIUrl(e,{orgid:b.orgId,classid:a.classid});var f={gradeformat_id:a.gradeformat_id},g=x.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=y.api.setupAPIToken(g,b.token),g.agent(B).end(function(a,b){a?(a=new A(y.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body.entities[0])})}else d={},d.message=d.description="Mandatory params: classid or gradeformat_id not found in request options.",d=new A(y.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function n(a){var b=this,c=w.defer(),d=y.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.classGradeformats;e=y.api.constructAPIUrl(e,{orgid:b.orgId,classid:a.classid});var f={};a.cursor&&(f.cursor=a.cursor);var g=x.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=y.api.setupAPIToken(g,b.token),g.agent(B).end(function(a,b){a?(a=new A(y.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params: classid not found in request options.",d=new A(y.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function o(a){var b=this,c=w.defer(),d=y.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.gradeformat_id){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.gradeformatClasses;e=y.api.constructAPIUrl(e,{orgid:b.orgId,gradeformat_id:a.gradeformat_id});var f={};a.cursor&&(f.cursor=a.cursor);var g=x.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=y.api.setupAPIToken(g,b.token),g.agent(B).end(function(a,b){a?(a=new A(y.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params: gradeformat_id not found in request options.",d=new A(y.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function p(a){var b=this,c=w.defer(),d=y.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.assignedpathid&&a.body){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.userAssignedPaths;e=y.api.constructAPIUrl(e,{orgid:b.orgId,classid:a.classid,assignedpathid:a.assignedpathid});var f=x.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=y.api.setupAPIToken(f,b.token),f.agent(B).end(function(a,b){if(a){var d=new A(y.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory param: classid, assignedpathid, body not found in request options.",g=new A(y.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function q(a){var b=this,c=w.defer(),d=y.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.assignedpathid&&a.body){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.userAssignedPaths;e=y.api.constructAPIUrl(e,{orgid:b.orgId,classid:a.classid,assignedpathid:a.assignedpathid});var f=x["delete"](e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=y.api.setupAPIToken(f,b.token),f.agent(B).end(function(a,b){if(a){var d=new A(y.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory param: classid, assignedpathid, body not found in request options.",g=new A(y.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function r(a){var b=this,c=w.defer(),d=y.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classId){var e=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.particularClass;e=y.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId});var f={productDetails:a.productDetails,bundleDetails:a.bundleDetails},g=x.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=y.api.setupAPIToken(g,b.token),g.agent(B).end(function(a,b){a?(a=new A(y.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory field 'classId' not found in request options.",d=new A(y.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function s(a){var b=this,c=w.defer();if(b.orgId)if(a&&a.productcode){var d=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.orgProductEntitlement;d=y.api.constructAPIUrl(d,{orgid:b.orgId});var e=x.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.agent(B).end(function(a,b){if(a){var d=new A(y.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var f={};f.message=f.description="Mandatory param: productcode not found in request options.",f=new A(y.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}else{var f={};f.message=f.description="Mandatory param: orgid not found in options while initializing comprodls-sdk.",f=new A(y.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function t(a){var b=this,c=w.defer();if(b.orgId)if(a&&a.productcode){var d=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.orgProductEntitlement;d=y.api.constructAPIUrl(d,{orgid:b.orgId});var e=x.put(d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.agent(B).end(function(a,b){if(a){var d=new A(y.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var f={};f.message=f.description="Mandatory param: productcode not found in request options.",f=new A(y.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}else{var f={};f.message=f.description="Mandatory param: orgid not found in options while initializing comprodls-sdk.",f=new A(y.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function u(a){var b=this,c=w.defer();if(a&&a.productcode){var d=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.orgProductEntitlement;d=y.api.constructAPIUrl(d,{orgid:b.orgId});var e={productcode:a.productcode},f=x.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.agent(B).end(function(a,b){a?(a=new A(y.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory field 'productcode' not found in request options.",g=new A(y.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function v(a){var b=this,c=w.defer(),d=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.orgProductEntitlement;d=y.api.constructAPIUrl(d,{orgid:b.orgId});var e={productcode:a.productcode};a.status&&(e.status=a.status),a.hasOwnProperty("expired")&&(e.expired=a.expired),a.cursor&&(e.cursor=a.cursor);var f=x.get(d).query(e);return b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.agent(B).end(function(a,b){a?(a=new A(y.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)}),c.promise}var w=a("q"),x=a("superagent"),y=a("../../helpers"),z=a("agentkeepalive"),A=y.errors.DLSError;b.exports=d;var B=new z({timeout:6e4,freeSocketTimeout:3e4})},{"../../helpers":3,agentkeepalive:36,q:46,superagent:49}],18:[function(a,b,c){function d(){return{getPostsInClass:e.bind(this),createPostInClass:f.bind(this),getPostsInProduct:g.bind(this),createPostInProduct:h.bind(this),getMyFollowers:i.bind(this),getUsersFollowedByMe:j.bind(this),followUser:k.bind(this),unfollowUser:l.bind(this)}}function e(a){var b=this,c=o.defer(),d={};if(a&&a.classid)if(d=p.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.COLLAB+b.config.COLLAB_API_URLS.postsInClassAPI;e=p.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f={};a.cursor&&(f.cursor=a.cursor),a.limit&&(f.limit=a.limit);var g=n.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=p.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(d=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description='Mandatory parameter "classid" not found in request options',d=new q(p.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function f(a){var b=this,c=o.defer(),d={};if(a&&a.verb&&a.classid)if(d=p.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.COLLAB+b.config.COLLAB_API_URLS.postsInClassAPI;e=p.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f={verb:a.verb};a.post&&(f.post=a.post),a.name&&(f.name=a.name),a.email&&(f.email=a.email),a.userid&&(f.userid=a.userid);var g=n.post(e).send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=p.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(d=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description='Mandatory parameter "verb" or "classid" not found in request options',d=new q(p.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function g(a){var b=this,c=o.defer(),d={};if(a&&a.productid)if(d=p.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.COLLAB+b.config.COLLAB_API_URLS.postsInProductAPI;e=p.api.constructAPIUrl(e,{orgId:b.orgId,productId:a.productid});var f={};a.cursor&&(f.cursor=a.cursor),a.limit&&(f.limit=a.limit);var g=n.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=p.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(d=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description='Mandatory parameter "productid" not found in request options',d=new q(p.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function h(a){var b=this,c=o.defer(),d={};if(a&&a.verb&&a.productid)if(d=p.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.COLLAB+b.config.COLLAB_API_URLS.postsInProductAPI;e=p.api.constructAPIUrl(e,{orgId:b.orgId,productId:a.productid});var f={verb:a.verb};a.post&&(f.post=a.post),a.name&&(f.name=a.name),a.email&&(f.email=a.email),a.userid&&(f.userid=a.userid);var g=n.post(e).send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=p.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(d=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description='Mandatory parameter "verb" or "productid" not found in request options',d=new q(p.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function i(a){var b=this,c=o.defer(),d={};if(d=p.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.COLLAB+b.config.COLLAB_API_URLS.getMyFollowers;e=p.api.constructAPIUrl(e,{orgId:b.orgId});var f={};a.cursor&&(f.cursor=a.cursor),a.limit&&(f.limit=a.limit);var g=n.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=p.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(d=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}return c.promise}function j(a){var b=this,c=o.defer(),d={};if(d=p.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.COLLAB+b.config.COLLAB_API_URLS.getUsersFollowedByMe;e=p.api.constructAPIUrl(e,{orgId:b.orgId});var f={};a.cursor&&(f.cursor=a.cursor),a.limit&&(f.limit=a.limit);var g=n.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=p.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(d=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}return c.promise}function k(a){var b=o.defer();return m(this.orgId,this.token,this.config,a,"create").then(function(a){b.resolve(a)})["catch"](function(a){b.reject(a)}).done(),b.promise}function l(a){var b=o.defer();return m(this.orgId,this.token,this.config,a,"delete").then(function(a){b.resolve(a)})["catch"](function(a){b.reject(a)}).done(),b.promise}function m(a,b,c,d,e){var f=o.defer(),g={};if(d&&d.userid)if(g=p.validations.isAuthenticated(a,b))f.reject(g);else{var h=c.DEFAULT_HOSTS.COLLAB+c.COLLAB_API_URLS.connectionURL;h=p.api.constructAPIUrl(h,{orgId:a,userId:d.userid});var i;"create"===e?i=n.post(h).set("Content-Type","application/json"):"delete"===e&&(i=n["delete"](h).set("Content-Type","application/json")),i=p.api.setupAPIToken(i,b),i.end(function(a,b){a?(g=new q(p.errors.ERROR_TYPES.API_ERROR,a),f.reject(g)):f.resolve(b.body)})}else g.message=g.description='Mandatory parameter "userid" not found in request options',g=new q(p.errors.ERROR_TYPES.SDK_ERROR,g),f.reject(g);return f.promise}var n=a("superagent"),o=a("q"),p=a("../../helpers"),q=p.errors.DLSError;b.exports=d},{"../../helpers":3,q:46,superagent:49}],19:[function(a,b,c){function d(a){return this.accountId=a,{createDataSyncManager:e.bind(this),updateDataSyncManager:f.bind(this),deleteDataSyncManager:g.bind(this),getParticularDataSyncManager:h.bind(this),getAllDataSyncManagersOfAGroup:i.bind(this)}}function e(a){var b=this,c=j.defer();if(a&&a.body){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.createDataSyncManager;d=m.api.constructAPIUrl(d,{accountid:b.accountId});var e=k.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.agent(o).end(function(a,b){if(a){var d=new n(m.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var f={};f.message=f.description="Mandatory param - body not found in request options.",f=new n(m.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function f(a){var b=j.defer(),c=this;if(a&&a.dsmid&&a.body){var d=c.config.DEFAULT_HOSTS.AUTH,e=c.config.AUTH_API_URLS.dataSyncManager,f=d+e;f=m.api.constructAPIUrl(f,{accountid:c.accountId,dsmid:a.dsmid});var g=a.body,h=k.put(f).set("Content-Type","application/json").set("Accept","application/json").send(g);c.traceid&&h.set("X-Amzn-Trace-Id",c.traceid),h.agent(o).end(function(a,c){a?(a=new n(m.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else{var i={};i.message=i.description="Mandatory params: dsmid, body not found in the request options.",i=new n(m.errors.ERROR_TYPES.SDK_ERROR,i),b.reject(i)}return b.promise}function g(a){var b=this,c=j.defer();if(a&&a.dsmid&&a.body){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.dataSyncManager;d=m.api.constructAPIUrl(d,{accountid:b.accountId,dsmid:a.dsmid});var e=k["delete"](d).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.agent(o).end(function(a,b){if(a){var d=new n(m.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var f={};f.message=f.description="Mandatory params - dsmid or body not found in request options.",f=new n(m.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function h(a){var b=j.defer(),c=this;if(a&&a.dsmid){var d=c.config.DEFAULT_HOSTS.AUTH,e=c.config.AUTH_API_URLS.dataSyncManager,f=d+e;f=m.api.constructAPIUrl(f,{accountid:c.accountId,dsmid:a.dsmid});var g=k.get(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.agent(o).end(function(a,c){a?(a=new n(m.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else{var h={};h.message=h.description="Mandatory params: dsmid not found in request options.",h=new n(m.errors.ERROR_TYPES.SDK_ERROR,h),b.reject(h)}return b.promise}function i(a){var b=j.defer(),c=this;if(a&&a.dsm_groupid){var d=c.config.DEFAULT_HOSTS.AUTH,e=c.config.AUTH_API_URLS.getAllDataSyncManagersOfAGroup,f=d+e;f=m.api.constructAPIUrl(f,{accountid:c.accountId,dsm_groupid:a.dsm_groupid});var g=k.get(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.agent(o).end(function(a,c){a?(a=new n(m.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else{var h={};h.message=h.description="Mandatory params: dsm_groupid not found in request options.",h=new n(m.errors.ERROR_TYPES.SDK_ERROR,h),b.reject(h)}return b.promise}var j=a("q"),k=a("superagent"),l=a("agentkeepalive"),m=a("../../helpers"),n=m.errors.DLSError;b.exports=d;var o=new l({timeout:6e4,freeSocketTimeout:3e4})},{"../../helpers":3,agentkeepalive:36,q:46,superagent:49}],20:[function(a,b,c){function d(){return{getAParticularDocument:e.bind(this),getAllDocumentsInAFolder:f.bind(this),createMultipleDocuments:g.bind(this),updateMultipleDocuments:h.bind(this),deleteMultipleDocuments:i.bind(this)}}function e(a){var b=this,c=j.defer();if(a&&a.accountid&&a.extuserid&&a.documentid&&a.folderid){var d=b.config.DEFAULT_HOSTS.DRIVE+b.config.DRIVE_API_URLS.getAParticularDocument,e={accountid:a.accountid,extuserid:a.extuserid,documentid:a.documentid};d=m.api.constructAPIUrl(d,e);var f={folderid:a.folderid},g=k.get(d).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new n(m.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else{var h={};h.message=h.description="Mandatory params - accountid or extuserid or documentid or folderid not found in request options.",h=new n(m.errors.ERROR_TYPES.SDK_ERROR,h),c.reject(h)}return c.promise}function f(a){var b=this,c=j.defer();if(a&&a.accountid&&a.extuserid&&a.folderid){var d=b.config.DEFAULT_HOSTS.DRIVE+b.config.DRIVE_API_URLS.getAllDocumentsInAFolder;d=m.api.constructAPIUrl(d,{accountid:a.accountid,extuserid:a.extuserid});var e={folderid:a.folderid};a.classid&&(e.classid=a.classid),a.productcode&&(e.productcode=a.productcode),a.assigned_path_id&&(e.assigned_path_id=a.assigned_path_id),a["item-code"]&&(e["item-code"]=a["item-code"]),a.cursor&&(e.cursor=a.cursor);var f=k.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new n(m.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory params - accountid or extuserid or folderid not found in request options.",g=new n(m.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function g(a){var b=this,c=j.defer();if(a&&a.accountid&&a.extuserid&&a.body){var d=b.config.DEFAULT_HOSTS.DRIVE+b.config.DRIVE_API_URLS.documents;d=m.api.constructAPIUrl(d,{accountid:a.accountid,userid:a.extuserid});var e=k.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.agent(o).end(function(a,b){if(a){var d=new n(m.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var f={};f.message=f.description="Mandatory param - accountid, extuserid or body not found in request options.",f=new n(m.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function h(a){var b=j.defer(),c=this,d={};if(a&&a.accountid&&a.extuserid&&a.body){var e=c.config.DEFAULT_HOSTS.DRIVE+c.config.DRIVE_API_URLS.documents;e=m.api.constructAPIUrl(e,{accountid:a.accountid,userid:a.extuserid});var f=k.put(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);c.traceid&&f.set("X-Amzn-Trace-Id",c.traceid),f.agent(o).end(function(a,c){a?(a=new n(m.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else d.message=d.description="Mandatory param - accountid, extuserid or body not found in the request options.",d=new n(m.errors.ERROR_TYPES.SDK_ERROR,d),b.reject(d);return b.promise}function i(a){var b=this,c=j.defer();if(a&&a.accountid&&a.extuserid&&a.body){var d=b.config.DEFAULT_HOSTS.DRIVE+b.config.DRIVE_API_URLS.documents;d=m.api.constructAPIUrl(d,{accountid:a.accountid,userid:a.extuserid});var e=k["delete"](d).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.agent(o).end(function(a,b){if(a){var d=new n(m.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var f={};f.message=f.description="Mandatory param - accountid, extuserid or body not found in request options.",f=new n(m.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}var j=a("q"),k=a("superagent"),l=a("agentkeepalive"),m=a("../../helpers"),n=m.errors.DLSError;b.exports=d;var o=new l({timeout:6e4,freeSocketTimeout:3e4})},{"../../helpers":3,agentkeepalive:36,q:46,superagent:49}],21:[function(a,b,c){function d(a){return this.accountId=a,{getGetStreamCredentials:e.bind(this),queryDataFromSearch:f.bind(this),getAuditTrailForAttempts:g.bind(this),getAuditTrailForEntitlements:h.bind(this),getAuditTrailForMicroEntitlements:i.bind(this),publishCustomEvents:j.bind(this),createSchedule:k.bind(this),getSchedule:l.bind(this),updateSchedule:m.bind(this),deleteSchedule:n.bind(this)}}function e(){var a,b=this,c=o.defer(),d=b.config.DEFAULT_HOSTS.INTEGRATION+b.config.INTEGRATIONS_API_URLS.getGetStreamCredentials;d=r.api.constructAPIUrl(d,{accountId:b.accountId});var e=p.post(d).set("Content-Type","application/json").set("Accept","application/json").send();return b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(b,d){b?(a=new t(r.errors.ERROR_TYPES.API_ERROR,b),c.reject(a)):c.resolve(d)}),c.promise}function f(a){var b,c=this,d=o.defer();if(a&&a.index&&a.query){var e=c.config.DEFAULT_HOSTS.INTEGRATION+c.config.INTEGRATIONS_API_URLS.queryDataFromSearch;e=r.api.constructAPIUrl(e,{index:a.index});var f={query:a.query},g=p.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){if(a){var c={type:r.errors.ERROR_TYPES.API_ERROR,err:a},e=s.convertElasticsearchErrResponse(c);d.reject(e)}else d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - index, type or query not found in request options.",b=new t(r.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function g(a){var b,c=this,d=o.defer();if(a&&a.accountid&&a.action&&a.userid&&a.productcode&&a["item-code"]){var e=c.config.DEFAULT_HOSTS.INTEGRATION+c.config.INTEGRATIONS_API_URLS.auditTrail;e=r.api.constructAPIUrl(e,{accountId:a.accountid});var f={audit_context:"ATTEMPT-"+a.accountid+"#"+a.userid,target_context:"PRODUCT-"+a.productcode+"#"+a["item-code"],action:a.action};a.cursor&&(f.cursor=a.cursor),a.sortOrder&&(f.sortOrder=a.sortOrder);var g=p.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new t(r.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - accountid, action, userid, productcode or item-code not found in request options.",b=new t(r.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function h(a){var b,c=this,d=o.defer();if(a&&a.accountid&&a.action&&a.userid&&a.productcode){var e=c.config.DEFAULT_HOSTS.INTEGRATION+c.config.INTEGRATIONS_API_URLS.auditTrail;e=r.api.constructAPIUrl(e,{accountId:a.accountid});var f={audit_context:"ENTITLEMENT-"+a.accountid+"#"+a.userid,target_context:"PRODUCT-"+a.productcode,type:"entitlement",action:a.action};a.cursor&&(f.cursor=a.cursor),a.sortOrder&&(f.sortOrder=a.sortOrder);var g=p.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new t(r.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - accountid, userid or productcode not found in request options.",b=new t(r.errors.ERROR_TYPES.SDK_ERROR,b),
6
+ d.reject(b);return d.promise}function i(a){var b,c=this,d=o.defer();if(a&&a.accountid&&a.action&&a.userid&&a.productcode&&a.context){var e=c.config.DEFAULT_HOSTS.INTEGRATION+c.config.INTEGRATIONS_API_URLS.auditTrail;e=r.api.constructAPIUrl(e,{accountId:a.accountid});var f={audit_context:"ENTITLEMENT-"+a.accountid+"#"+a.userid,target_context:"PRODUCT-"+a.productcode+"#"+a.context,type:"micro-entitlement",action:a.action};a.cursor&&(f.cursor=a.cursor),a.sortOrder&&(f.sortOrder=a.sortOrder);var g=p.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new t(r.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Mandatory params - accountid, action, userid, productcode or context not found in request options.",b=new t(r.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function j(a){var b,c=o.defer(),d=this;if(a&&a.events){var e=d.config.DEFAULT_HOSTS.INTEGRATION+d.config.INTEGRATIONS_API_URLS.customEvents;e=r.api.constructAPIUrl(e,{accountId:d.accountId});var f=p.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a);d.traceid&&f.set("X-Amzn-Trace-Id",d.traceid),f.end(function(a,d){a?(b=new t(r.errors.ERROR_TYPES.API_ERROR,a),c.reject(b)):c.resolve(d.body)})}else b={},b.message=b.description="Mandatory params - events not found in request options.",b=new t(r.errors.ERROR_TYPES.SDK_ERROR,b),c.reject(b);return c.promise}function k(a){var b,c=o.defer(),d=this;if(a&&a.context&&a.accountid&&a.body&&Object.keys(a.body).length>0&&a.body.scheduleid&&a.body.actorid&&a.body.category&&a.body.schedule_time){var e=d.config.DEFAULT_HOSTS.INTEGRATION+d.config.INTEGRATIONS_API_URLS.schedules;e=r.api.constructAPIUrl(e,{accountId:a.accountid,context:a.context});var f=p.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);d.traceid&&f.set("X-Amzn-Trace-Id",d.traceid),f.end(function(a,d){a?(b=new t(r.errors.ERROR_TYPES.API_ERROR,a),c.reject(b)):c.resolve(d.body)})}else b={},b.message=b.description="Mandatory param - accountid or context or body(scheduleid or actorid or category or schedule_time) not found in request options.",b=new t(r.errors.ERROR_TYPES.SDK_ERROR,b),c.reject(b);return c.promise}function l(a){var b,c=o.defer(),d=this;if(a&&a.context&&a.accountid){var e=d.config.DEFAULT_HOSTS.INTEGRATION+d.config.INTEGRATIONS_API_URLS.schedules;e=r.api.constructAPIUrl(e,{accountId:a.accountid,context:a.context});var f={};a.cursor&&(f.cursor=a.cursor),a.category&&(f.category=a.category),a.scheduleid&&(f.scheduleid=a.scheduleid);var g=p.get(e).query(f);d.traceid&&g.set("X-Amzn-Trace-Id",d.traceid),g.end(function(a,d){a?(b=new t(r.errors.ERROR_TYPES.API_ERROR,a),c.reject(b)):c.resolve(d.body)})}else b={},b.message=b.description="Mandatory params - accountid or context not found in request options.",b=new t(r.errors.ERROR_TYPES.SDK_ERROR,b),c.reject(b);return c.promise}function m(a){var b,c=o.defer(),d=this;if(a&&a.context&&a.accountid&&a.scheduleid&&a.body&&Object.keys(a.body).length>0&&a.body.actorid&&a.body.category){var e=d.config.DEFAULT_HOSTS.INTEGRATION+d.config.INTEGRATIONS_API_URLS.particularSchedule;e=r.api.constructAPIUrl(e,{accountId:a.accountid,context:a.context,scheduleId:a.scheduleid});var f=p.put(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);d.traceid&&f.set("X-Amzn-Trace-Id",d.traceid),f.end(function(a,d){a?(b=new t(r.errors.ERROR_TYPES.API_ERROR,a),c.reject(b)):c.resolve(d.body)})}else b={},b.message=b.description="Mandatory param - accountid or context or scheduleid or body(category or actorid) not found in request options.",b=new t(r.errors.ERROR_TYPES.SDK_ERROR,b),c.reject(b);return c.promise}function n(a){var b,c=o.defer(),d=this;if(a&&a.context&&a.accountid&&a.scheduleid&&a.body){var e=d.config.DEFAULT_HOSTS.INTEGRATION+d.config.INTEGRATIONS_API_URLS.particularSchedule;e=r.api.constructAPIUrl(e,{accountId:a.accountid,context:a.context,scheduleId:a.scheduleid});var f=p["delete"](e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);d.traceid&&f.set("X-Amzn-Trace-Id",d.traceid),f.agent(u).end(function(a,d){a?(b=new t(r.errors.ERROR_TYPES.API_ERROR,a),c.reject(b)):c.resolve(d.body)})}else b={},b.message=b.description="Mandatory param - accountid or context or scheduleid or body not found in request options.",b=new t(r.errors.ERROR_TYPES.SDK_ERROR,b),c.reject(b);return c.promise}var o=a("q"),p=a("superagent"),q=a("agentkeepalive"),r=a("../../helpers"),s=a("../../helpers/lib/api/converter"),t=r.errors.DLSError;b.exports=d;var u=new q({timeout:6e4,freeSocketTimeout:3e4})},{"../../helpers":3,"../../helpers/lib/api/converter":4,agentkeepalive:36,q:46,superagent:49}],22:[function(a,b,c){function d(){return{sendInvitations:e.bind(this),getMultiInvitations:f.bind(this),revokeSingleInvitation:g.bind(this),completeSingleInvitation:h.bind(this),resendSingleInvitation:i.bind(this)}}function e(a){var b=this,c=j.defer(),d=l.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.created&&a.invitation_data){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.sendInvitations;e=l.api.constructAPIUrl(e,{orgId:b.orgId});var f=k.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a);f=l.api.setupAPIToken(f,b.token),b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(d={},d=new m(l.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="One or more required field(s) missing: context, created or invitation_data",d=new m(l.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function f(a){var b=this,c=j.defer(),d=l.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context_id){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getMultiInvitations;e=l.api.constructAPIUrl(e,{orgId:b.orgId});var f={context_id:a.context_id};a.context&&(f.context=a.context),a.status&&(f.status=a.status),a.cursor&&(f.cursor=a.cursor);var g=k.get(e).query(f);g=l.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d={},d=new m(l.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="context_id not found in request options.",d=new m(l.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function g(a){var b=this,c=j.defer(),d=l.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context_id&&a.invitationid&&a.context){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.revokeSingleInvitation;e=l.api.constructAPIUrl(e,{orgId:b.orgId,invitationid:a.invitationid});var f={context:a.context,context_id:a.context_id},g=k["delete"](e).query(f);g=l.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d={},d=new m(l.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="context_id or context or invitationid not found in request options.",d=new m(l.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function h(a){var b=this,c=j.defer(),d=l.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context_id&&a.invitationid&&a.context){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.completeSingleInvitation;e=l.api.constructAPIUrl(e,{orgId:b.orgId,invitationid:a.invitationid});var f={context:a.context,context_id:a.context_id},g=k.put(e).query(f).set("Content-Type","application/json").set("Accept","application/json").send({});g=l.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d={},d=new m(l.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="context_id or context or invitationid not found in request options.",d=new m(l.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function i(a){var b=this,c=j.defer(),d=l.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.invitationid&&a.context&&a.context_id){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.resendSingleInvitation;e=l.api.constructAPIUrl(e,{orgId:b.orgId,invitationid:a.invitationid});var f={context:a.context,context_id:a.context_id},g={};a.space_title&&(g.space_title=a.space_title);var h=k.put(e).query(f).set("Content-Type","application/json").set("Accept","application/json").send(g);h=l.api.setupAPIToken(h,b.token),b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h.end(function(a,b){a?(d={},d=new m(l.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="context_id or context or invitationid not found in request options.",d=new m(l.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}var j=a("q"),k=a("superagent"),l=a("../../helpers"),m=l.errors.DLSError;b.exports=d},{"../../helpers":3,q:46,superagent:49}],23:[function(a,b,c){function d(a){return this.accountId=a,{getProduct:e.bind(this),getGlobalEntitlementsForAUser:f.bind(this),getMicroEntitlementsForAUser:g.bind(this),getAllBundles:h.bind(this),getSingleBundle:i.bind(this),getSingleProductFamily:k.bind(this),getAllProductFamilies:j.bind(this)}}function e(a){var b=m.defer(),c=this,d={};if(a&&a.productcode){var e=c.config.DEFAULT_HOSTS.PRODUCT+c.config.PRODUCT_API_URLS.getProductAPI;e=n.api.constructAPIUrl(e,{accountId:c.accountId,productCode:a.productcode});var f={};a.details&&(f.details=a.details),a.stage&&(f.stage=a.stage);var g=l.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,c){a?(a=new o(n.errors.ERROR_TYPES.API_ERROR,a),b.reject(a)):b.resolve(c.body)})}else d.message=d.description="productcode not found in request options",d=new o(n.errors.ERROR_TYPES.SDK_ERROR,d),b.reject(d);return b.promise}function f(a){var b=this,c=m.defer();if(a&&a.extUserId){var d=b.config.DEFAULT_HOSTS.PRODUCT+b.config.PRODUCT_API_URLS.getEntitlementsOfAUser;d=n.api.constructAPIUrl(d,{accountId:b.accountId,extUserId:a.extUserId});var e={};a.productDetails&&(e.productDetails=a.productDetails),a.bundleDetails&&(e.bundleDetails=a.bundleDetails);var f=l.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory parameter extUserId not found in request options",g=new o(n.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function g(a){var b=this,c=m.defer();if(a&&a.extuserid&&a.productcode){var d=b.config.DEFAULT_HOSTS.PRODUCT+b.config.PRODUCT_API_URLS.getMicroEntitlementsOfAUser;d=n.api.constructAPIUrl(d,{accountId:b.accountId,extUserId:a.extuserid});var e={};e.productcode=a.productcode,a.context&&(e.context=a.context),a.feature_key&&(e.feature_key=a.feature_key),a.cursor&&(e.cursor=a.cursor);var f=l.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory parameter extuserid or productcodenot found in request options",g=new o(n.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function h(a){var b=this,c=m.defer(),d=b.config.DEFAULT_HOSTS.PRODUCT+b.config.PRODUCT_API_URLS.getAllBundles;d=n.api.constructAPIUrl(d,{accountId:b.accountId});var e={};a&&(a.stage&&(e.stage=a.stage),a.target_role&&(e.target_role=a.target_role));var f=l.get(d).query(e);return b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)}),c.promise}function i(a){var b,c=this,d=m.defer();if(a&&a["bundle-code"]){var e=c.config.DEFAULT_HOSTS.PRODUCT+c.config.PRODUCT_API_URLS.getSingleBundle;e=n.api.constructAPIUrl(e,{accountId:c.accountId,bundleCode:a["bundle-code"]});var f={};a.stage&&(f.stage=a.stage);var g=l.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new o(n.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Required parameter bundle-code not found in request options",b=new o(n.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function j(a){var b=this,c=m.defer(),d=b.config.DEFAULT_HOSTS.PRODUCT+b.config.PRODUCT_API_URLS.getAllProductFamilies;d=n.api.constructAPIUrl(d,{accountId:b.accountId});var e={};a&&a.stage&&(e.stage=a.stage);var f=l.get(d).query(e);return b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)}),c.promise}function k(a){var b,c=this,d=m.defer();if(a&&a["family-code"]){var e=c.config.DEFAULT_HOSTS.PRODUCT+c.config.PRODUCT_API_URLS.getSingleProductFamily;e=n.api.constructAPIUrl(e,{accountId:c.accountId,familyCode:a["family-code"]});var f={};a.stage&&(f.stage=a.stage);var g=l.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new o(n.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Required parameter family-code not found in request options",b=new o(n.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}var l=a("superagent"),m=a("q"),n=a("../../helpers"),o=n.errors.DLSError;b.exports=d},{"../../helpers":3,q:46,superagent:49}],24:[function(a,b,c){function d(){return{promoteProduct:e.bind(this),registerProduct:f.bind(this),ingestProduct:g.bind(this),createBundle:h.bind(this),updateBundle:i.bind(this),getAllBundles:j.bind(this),getSingleBundle:k.bind(this),createProductFamily:l.bind(this),updateProductFamily:m.bind(this),getSingleProductFamily:n.bind(this),getAllProductFamilies:o.bind(this)}}function e(a){var b=this,c=q.defer(),d=b.config.DEFAULT_HOSTS.PUB+b.config.PUB_API_URLS.promoteAPI;d=r.api.constructAPIUrl(d,{orgId:b.orgId,productcode:a.productcode});var e={source:{},target:{}};a&&(a.source&&a.source.stage&&(e.source.stage=a.source.stage),a.target&&(a.target.org&&(e.target.org=a.target.org),a.target.stage&&(e.target.stage=a.target.stage)),a.externalrefid&&(e.externalrefid=a.externalrefid));var f=p.post(d).send(e);return b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new s(r.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b)}),c.promise}function f(a){var b=this,c=q.defer(),d=b.config.DEFAULT_HOSTS.PUB+b.config.PUB_API_URLS.registerProductAPI;d=r.api.constructAPIUrl(d,{orgId:b.orgId});var e={};a&&(a.targetorg&&(e.targetorgid=a.targetorg),a.repositorytype&&(e.repositorytype=a.repositorytype),a.producttitle&&(e.producttitle=a.producttitle),a.producttype&&(e.producttype=a.producttype),a.productcode&&(e.productcode=a.productcode),a.github&&(e.github=a.github),a.s3&&(e.s3=a.s3),a.externalrefid&&(e.externalrefid=a.externalrefid),a["bundle-codes"]&&(e["bundle-codes"]=a["bundle-codes"]));var f=p.post(d).send(e);return b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new s(r.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b)}),c.promise}function g(a){var b,c=this,d=q.defer();a&&a.productcode&&(b=a.productcode);var e=c.config.DEFAULT_HOSTS.PUB+c.config.PUB_API_URLS.ingestByCodeAPI;e=r.api.constructAPIUrl(e,{orgId:c.orgId,productcode:b});var f={};a&&(a.branchref&&(f.branchref=a.branchref),a.externalrefid&&(f.externalrefid=a.externalrefid),a["bundle-codes"]&&(f["bundle-codes"]=a["bundle-codes"]));var g=p.post(e).send(f);return c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new s(r.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b)}),d.promise}function h(a){var b,c=this,d=q.defer();if(a&&a.stage&&a["bundle-code"]&&a.body&&a.body.title&&a.body.products){var e=c.config.DEFAULT_HOSTS.PUB+c.config.PUB_API_URLS.createBundle;e=r.api.constructAPIUrl(e,{orgid:c.orgId,stage:a.stage}),a.body["bundle-code"]=a["bundle-code"];var f=p.post(e).send(a.body);c.traceid&&f.set("X-Amzn-Trace-Id",c.traceid),f.end(function(a,b){a?(a=new s(r.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Required parameter stage or bundle-code or title or products not found in request options",b=new s(r.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function i(a){var b,c=this,d=q.defer();if(a&&a.stage&&a["bundle-code"]&&a.body&&a.body.products){var e=c.config.DEFAULT_HOSTS.PUB+c.config.PUB_API_URLS.updateBundle;e=r.api.constructAPIUrl(e,{orgid:c.orgId,stage:a.stage,bundleCode:a["bundle-code"]});var f=p.put(e).send(a.body);c.traceid&&f.set("X-Amzn-Trace-Id",c.traceid),f.end(function(a,b){a?(a=new s(r.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Required parameter stage or bundle-code or products not found in request options",b=new s(r.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function j(a){var b=this,c=q.defer(),d=b.config.DEFAULT_HOSTS.PUB+b.config.PUB_API_URLS.getAllBundles;d=r.api.constructAPIUrl(d,{orgid:b.orgId});var e={};a&&(a.stage&&(e.stage=a.stage),a.target_role&&(e.target_role=a.target_role));var f=p.get(d).query(e);return b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new s(r.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)}),c.promise}function k(a){var b,c=this,d=q.defer();if(a&&a["bundle-code"]){var e=c.config.DEFAULT_HOSTS.PUB+c.config.PUB_API_URLS.getSingleBundle;e=r.api.constructAPIUrl(e,{orgid:c.orgId,bundleCode:a["bundle-code"]});var f={};a&&a.stage&&(f.stage=a.stage);var g=p.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new s(r.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Required parameter bundle-code not found in request options",b=new s(r.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function l(a){var b,c=this,d=q.defer();if(a&&a.stage&&a.body&&a.body["family-code"]){var e=c.config.DEFAULT_HOSTS.PUB+c.config.PUB_API_URLS.createProductFamily;e=r.api.constructAPIUrl(e,{orgid:c.orgId,stage:a.stage});var f=p.post(e).send(a.body);c.traceid&&f.set("X-Amzn-Trace-Id",c.traceid),f.end(function(a,b){a?(a=new s(r.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Required parameter stage or family-code not found in request options",b=new s(r.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function m(a){var b,c=this,d=q.defer();if(a&&a.stage&&a["family-code"]){var e=c.config.DEFAULT_HOSTS.PUB+c.config.PUB_API_URLS.updateProductFamily;e=r.api.constructAPIUrl(e,{orgid:c.orgId,stage:a.stage,familyCode:a["family-code"]});var f=p.put(e).send(a.body);c.traceid&&f.set("X-Amzn-Trace-Id",c.traceid),f.end(function(a,b){a?(a=new s(r.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Required parameter stage or family-code not found in request options",b=new s(r.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function n(a){var b,c=this,d=q.defer();if(a&&a["family-code"]){var e=c.config.DEFAULT_HOSTS.PUB+c.config.PUB_API_URLS.getSingleProductFamily;e=r.api.constructAPIUrl(e,{orgid:c.orgId,familyCode:a["family-code"]});var f={};a.stage&&(f.stage=a.stage);var g=p.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new s(r.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else b={},b.message=b.description="Required parameter family-code not found in request options",b=new s(r.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function o(a){var b=this,c=q.defer(),d=b.config.DEFAULT_HOSTS.PUB+b.config.PUB_API_URLS.getAllProductFamilies;d=r.api.constructAPIUrl(d,{orgid:b.orgId});var e={};a&&a.stage&&(e.stage=a.stage);var f=p.get(d).query(e);return b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new s(r.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)}),c.promise}var p=a("superagent"),q=a("q"),r=a("../../helpers"),s=r.errors.DLSError;b.exports=d},{"../../helpers":3,q:46,superagent:49}],25:[function(a,b,c){function d(){var a=p();return{connect:e.bind(this,a),cleanup:f.bind(this,a),grantByUserOrgId:g.bind(this),grantByAccountId:h.bind(this),grantByAccountIdOnExtUserId:i.bind(this),grantV2:j.bind(this),getPushedEvents:k.bind(this)}}function e(a,b){var c=!0;if(c&&!b.userid){var d={};throw d.message=d.description="Mandatory parameter userid not found in request options.",d=new q(o.errors.ERROR_TYPES.PUSHX_ERROR,d)}return a.setup({userid:b.userid,accountid:b.accountid,token:b.token,pubnub:{publishKey:b.publishKey,subscribeKey:b.subscribeKey,ssl:!0,suppressLeaveEvents:!0},pollingEndpoint:b.pollingEndpoint,pollingIterations:b.pollingIterations||10,pollingInterval:b.pollingInterval})}function f(a){a.cleanup()}function g(a){var b=l.defer(),c=["jobs","systemevents"],d="o-"+this.orgId+"\\$u-"+this.token.access_token+"\\$",e=[];for(var f in c){var g=d+c[f]+"\\..*";e.push(g)}return a.channels={},a.channels.patterns=e,j.call(this,a).then(function(a){b.resolve(a)})["catch"](function(a){b.reject(a)}),b.promise}function h(a){var b={},c=l.defer();if(a.accountId&&a.refId){var d="a-"+a.accountId+"$refid."+a.refId,e=[d];a.channels={},a.channels.exactMatch=e,j.call(this,a).then(function(a){c.resolve(a)})["catch"](function(a){c.reject(a)})}else b.message=b.description="Required parameter ['accountId', 'refId'] not found in request options",b=new q(o.errors.ERROR_TYPES.SDK_ERROR,b),c.reject(b);return c.promise}function i(a){var b={},c=l.defer();if(a.accountId&&a.extUserId){var d="a-"+a.accountId+"$u-"+a.extUserId,e=[d];a.channels={},a.channels.exactMatch=e,j.call(this,a).then(function(a){c.resolve(a)})["catch"](function(a){c.reject(a)})}else b.message=b.description="Required parameter ['accountId', 'extUserId'] not found in request options",b=new q(o.errors.ERROR_TYPES.SDK_ERROR,b),c.reject(b);return c.promise}function j(a){var b=this,c={},d=l.defer(),e={channels:{}};if(!a.channels)return c.message=c.description="channels not given in input body.",c=new q(o.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c),d.promise;e.channels=a.channels;var f=b.config.DEFAULT_HOSTS.PUSHX+b.config.PUSHX_API_URLS.grantV2,g=m.post(f).set("Content-Type","application/json").set("Accept","application/json");return b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.send(e),g.end(function(a,b){a?(a=new q(o.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)}),d.promise}function k(a){var b=this,c=l.defer(),d=a.accountid,e=a.channelname,f=a.starttime,g=a.endtime;if(d&&e&&f&&g){var h=b.config.DEFAULT_HOSTS.PUSHX+b.config.PUSHX_API_URLS.getPushedEvents;h=o.api.constructAPIUrl(h,{accountId:d});var i={channelname:e,starttime:f,endtime:g},j=m.get(h).query(i);b.traceid&&j.set("X-Amzn-Trace-Id",b.traceid),j.agent(r).end(function(a,b){a?(a=new q(o.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else{var k={};k.message=k.description="Mandatory parameters [accountId, channelname, starttime, endtime] not found in request options",k=new q(o.errors.ERROR_TYPES.SDK_ERROR,k),c.reject(k)}return c.promise}var l=a("q"),m=a("superagent"),n=a("agentkeepalive"),o=a("../../helpers"),p=a("./pubnubClientWrapper"),q=o.errors.DLSError;b.exports=d;var r=new n({timeout:6e4,freeSocketTimeout:3e4})},{"../../helpers":3,"./pubnubClientWrapper":26,agentkeepalive:36,q:46,superagent:49}],26:[function(a,b,c){var d=a("pubnub"),e=a("superagent"),f=a("events").EventEmitter,g=a("../../helpers"),h=g.errors.PUSHXError,i="$";b.exports=function(){"use strict";var a,b,c,j,k,l=new f,m=[],n={},o=!1,p=!1,q=function(){return{on:function(a,b){j=Date.now();var c,d=[];a.orgid||a.userid||a.accountid||a.productid||a.classid?(a.accountid?d.push("a-"+a.accountid):(a.orgid&&d.push("o-"+a.orgid),a.userid&&d.push("u-"+a.userid),a.productid&&d.push("p-"+a.productid),a.classid&&d.push("c-"+a.classid)),c=d.join(i)+i+a.channel,m.includes(c)||(m.push(c),n[c]={status:"pending"},l.on(c,b),u(c))):"pushx_status"!==a.channel||o||(l.on(a.channel,b),o=!0),z()},getMySubscriptionStatus:t}},r=function(a){var b=a.subscribedChannel,c=a.message;l.emit(b,c)},s=function(a,c){var d,e,f=[];if(!p)switch(a.category){case"PNConnectedCategory":if("PNSubscribeOperation"===a.operation){f=a.subscribedChannels;for(var i in f)n[f[i]]&&(n[f[i]].status="subscribed");e={category:"PUSHX",type:"CHANNEL_SUBSCRIPTION",status:"SUCCESS",message:"Success: Subscribed successfully.",httpcode:200,data:{payload:{channels:a.subscribedChannels},message:"Success: Subscribed successfully."}},l.emit("pushx_status",e)}break;case"PNAccessDeniedCategory":if("PNSubscribeOperation"===a.operation){var j=a.errorData.response&&a.errorData.response.text,m=j?JSON.parse(j):void 0,o={payload:m&&m.payload||a.errorData.payload,message:"Forbidden: Subscription failed.",errorDetails:{operation:a.operation,category:a.category,statusCode:a.statusCode}};f=o.payload.channels;for(var q in f)n[f[q]]&&(n[f[q]].status="error",n[f[q]].error=d);d=new h(g.errors.ERROR_CATEGORY.PUSHX,o),l.emit("pushx_status",d)}break;case"PNBadRequestCategory":case"PNNetworkDownCategory":case"PNNetworkUpCategory":d={message:"PushX Error",status:a.statusCode,pushXError:a},d=new h(g.errors.ERROR_CATEGORY.PUSHX,d),l.emit("pushx_status",d);break;case"PNNetworkIssuesCategory":if("PNSubscribeOperation"===a.operation){if(!c.accountId||!b.pollingEndpoint){d={message:"Polling initiation error: Missing mandatory parameters to initiate polling operation - [accountId, pollingEndpoint]",status:a.statusCode},d=new h(g.errors.ERROR_CATEGORY.PUSHX,d),l.emit("pushx_status",d);break}k=0,x(),p=!0}break;case"PNReconnectedCategory":break;default:d={message:"PushX Error: unexpected error",status:a.statusCode,pushXError:a},d=new h(g.errors.ERROR_CATEGORY.PUSHX,d),l.emit("pushx_status",d)}},t=function(){return JSON.parse(JSON.stringify(n))},u=function(b){a.subscribe({channels:[b]})},v=function(c){function e(){b=c,a.addListener({message:function(a){r(a)},status:function(a){var b={accountId:g};s(a,b)}})}var f=c.pubnub;f.uuid=c.userid;var g=c.accountid,h=c.token;return a||!f?new Error("Already Initialized"):(a=new d(f),a.setToken(h),e(),q())},w=function(){a&&(a.unsubscribeAll(),a.stop(),m=[],o=!1,n={},p=!1),a=void 0,c&&(clearTimeout(c),j=Date.now(),z(),c=void 0,k=void 0,j=void 0)},x=function(){var a={accountid:b.accountid,channelname:m[0],starttime:j,endtime:Date.now()};if(a.channelname&&a.starttime){var d=e.get(b.pollingEndpoint).query(a);d.end(function(a,d){if(!a){if(0===k){n[m[0]]&&(n[m[0]].status="subscribed");var e={category:"PUSHX",type:"CHANNEL_SUBSCRIPTION",status:"SUCCESS",message:"Success: Subscribed successfully.",httpcode:200,data:{payload:{channels:m},message:"Success: Subscribed successfully."}};l.emit("pushx_status",e)}y(d.body),k++}if(k>b.pollingIterations){var a={message:"Polling error: Polling limit exceeded",status:429};a=new h(g.errors.ERROR_CATEGORY.PUSHX,a),l.emit("pushx_status",a)}else{var f;f=b.pollingInterval?60*b.pollingInterval*1e3:parseInt(10*Math.pow(1.3,k)*1e3,10),f&&(c=setTimeout(x,f))}})}},y=function(a){for(var b=z(),c=b.events,d=b.key,e=0;e<a.entities.length;e++){var f=a.entities[e],g=f.pk+"_"+f.sk;c[g]||(c[g]=f.context.start_time,l.emit(m[0],f))}sessionStorage.setItem(d,JSON.stringify(c))},z=function(){var a="comprodls.old_pushx_events."+b.userid+"."+m[0],c=sessionStorage.getItem(a);if(c){try{c=JSON.parse(c)}catch(d){c={}}for(var e=Object.keys(c),f=0;f<e.length;f++){var g=e[f];c[g]<j&&delete c[g]}e.length!==Object.keys(c).length&&sessionStorage.setItem(a,JSON.stringify(c))}else c={};return{key:a,events:c}};return{setup:v,cleanup:w}}},{"../../helpers":3,events:41,pubnub:45,superagent:49}],27:[function(a,b,c){function d(){return{getRules:e.bind(this),getParticularRule:f.bind(this),getUserRule:g.bind(this),updateRuleDisplay:h.bind(this),createRule:i.bind(this),updateRule:j.bind(this),deleteRule:k.bind(this)}}function e(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.ruleType){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.RULES_API_URLS.rules;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),ruleType:a.ruleType});var f={cursor:a.cursor},g=m.get(e).set("Content-Type","application/json").set("Accept","application/json").query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=n.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new p(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="context or ruleType not found in request options.",d=new p(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function f(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.ruleType&&a.ruleId){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.RULES_API_URLS.particularRule;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),ruleType:a.ruleType,ruleId:a.ruleId});var f=m.get(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=n.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new p(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="context or ruleType or ruleId not found in request options.",d=new p(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function g(a){var b=this,c=l.defer();if(a&&a.orgId&&a.context&&a.ruleType&&a.userId){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.RULES_API_URLS.getUserRule;d=n.api.constructAPIUrl(d,{orgId:b.orgId,context:encodeURIComponent(a.context),ruleType:a.ruleType,userId:a.userId});var e=m.get(d).set("Content-Type","application/json").set("Accept","application/json");b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e=n.api.setupAPIToken(e,b.token),e.agent(q).end(function(a,b){a?(a=new p(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else{var f={};f.message=f.description="Mandatory params - orgId or context or ruleType or userId not found in request options.",f=new p(n.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function h(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.ruleType&&a.ruleId&&a.body&&a.body.rule_display){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.RULES_API_URLS.updateRuleDisplay;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),ruleType:a.ruleType,ruleId:a.ruleId});var f=m.put(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=n.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new p(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - context or ruleType or ruleId or body.rule_display not found in request options.",d=new p(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function i(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.ruleType&&a.body){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.RULES_API_URLS.rules;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),ruleType:a.ruleType});var f=m.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=n.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new p(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - context or ruleType or body not found in request options.",d=new p(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function j(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.ruleType&&a.ruleId&&a.body){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.RULES_API_URLS.particularRule;e=n.api.constructAPIUrl(e,{
7
+ orgId:b.orgId,context:encodeURIComponent(a.context),ruleType:a.ruleType,ruleId:a.ruleId});var f=m.put(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=n.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new p(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - context or ruleType or ruleId or body not found in request options.",d=new p(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function k(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.ruleType&&a.ruleId){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.RULES_API_URLS.particularRule;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),ruleType:a.ruleType,ruleId:a.ruleId});var f=m["delete"](e);f=n.api.setupAPIToken(f,b.token),b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(d={},d=new p(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - context or ruleType or ruleId not found in request options.",d=new p(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}var l=a("q"),m=a("superagent"),n=a("../../helpers"),o=a("agentkeepalive"),p=n.errors.DLSError;b.exports=d;var q=new o({timeout:6e4,freeSocketTimeout:3e4})},{"../../helpers":3,agentkeepalive:36,q:46,superagent:49}],28:[function(a,b,c){function d(a){return this.accountId=a,{getUserSpaces:e.bind(this),validateSpaceCode:f.bind(this),validateClassCode:g.bind(this),generateSpaceCode:h.bind(this),changeSpaceCode:i.bind(this),joinInstituteSpace:j.bind(this),provisionSpacesToStudent:k.bind(this),provisionSpacesToTeacher:l.bind(this),provisionBulkSpaces:m.bind(this),shadowProvision:n.bind(this),entitleUserToProduct:o.bind(this),unentitleUserToProduct:p.bind(this),revokeMicroEntitlementOfAUser:s.bind(this),microEntitleUserToProduct:q.bind(this),bulkMicroEntitleProductToUser:r.bind(this),enrollUserInClass:v.bind(this),getExtProduct:t.bind(this),getSpaceDetails:u.bind(this),updateUserInformation:w.bind(this),updateUserSpace:x.bind(this),getInvitationsByEmail:y.bind(this),updateInstituteTitle:z.bind(this)}}function e(a){var b=this,c=A.defer();if(a&&a.extuserid){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getUserSpaces;d=D.api.constructAPIUrl(d,{accountid:b.accountId,extuserid:a.extuserid});var e={};a.spaceRole&&(e.spaceRole=a.spaceRole),a.spaceType&&(e.spaceType=a.spaceType),a.spaceOrgContext&&(e.spaceOrgContext=a.spaceOrgContext),a.details&&(e.details=a.details),a.cursor&&(e.cursor=a.cursor);var f=B.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(g=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(g)):c.resolve(b.body)})}else{var g={};g.message=g.description="extuserid not found in request options.",g=new E(D.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function f(a){var b=this,c=A.defer();if(a&&a.spaceCodeBody&&a.spaceCodeBody.space_code){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.validateSpaceCode;d=D.api.constructAPIUrl(d,{accountid:b.accountId});var e=B.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a.spaceCodeBody);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(f=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(f)):c.resolve(b.body)})}else{var f={};f.message=f.description="spaceCodeBody or space_code not found in request options.",f=new E(D.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function g(a){var b=this,c=A.defer();if(a&&a.classCodeBody&&a.classCodeBody.class_code){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.validateClassCode;d=D.api.constructAPIUrl(d,{accountid:b.accountId});var e={};a.details&&(e.details=a.details);var f=B.post(d).set("Content-Type","application/json").set("Accept","application/json").query(e).send(a.classCodeBody);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(g=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(g)):c.resolve(b.body)})}else{var g={};g.message=g.description="classCodeBody or class_code not found in request options.",g=new E(D.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function h(a){var b=this,c=A.defer(),d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.generateSpaceCode;d=D.api.constructAPIUrl(d,{accountid:b.accountId});var e={};a.ignore_words&&(e.ignore_words=a.ignore_words);var f=B.post(d).set("Content-Type","application/json").set("Accept","application/json").send(e);return b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(err=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(err)):c.resolve(b)}),c.promise}function i(a){var b=this,c=A.defer();if(a&&a.ext_user_id&&a.spacecode){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.changeSpaceCode;d=D.api.constructAPIUrl(d,{accountid:b.accountId,spacecode:a.spacecode});var e={ext_user_id:a.ext_user_id};a.ignore_words&&(e.ignore_words=a.ignore_words);var f=B.put(d).set("Content-Type","application/json").set("Accept","application/json").send(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(g=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(g)):c.resolve(b)})}else{var g={};g.message=g.description="Mandatory parameter options, ext_user_id or spacecode, not found in request options.",g=new E(D.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function j(a){var b=this,c=A.defer();if(a&&a.ext_user_id&&a.ext_role&&a.space_code){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.joinInstituteSpace;d=D.api.constructAPIUrl(d,{accountid:b.accountId});var e=B.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(f=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(f)):c.resolve(b.body)})}else{var f={};f.message=f.description="ext_user_id or ext_role or space_code not found in request options.",f=new E(D.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function k(a){var b=this,c=A.defer(),d={};if(a&&a.ext_user_id&&a.ext_role){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.provisionSpacesToStudent;e=D.api.constructAPIUrl(e,{accountId:b.accountId});var f=B.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(d=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description="ext_user_id or ext_role not found in request options.",d=new E(D.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function l(a){var b=this,c=A.defer();if(a&&a.ext_user_id&&a.ext_role){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.provisionSpacesToTeacher;d=D.api.constructAPIUrl(d,{accountId:b.accountId});var e=B.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(f=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(f)):c.resolve(b.body)})}else{var f={};f.message=f.description="Mandatory parameters [rxt_user_id, ext_role] not found in request options.",f=new E(D.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function m(a){var b=this,c=A.defer(),d=D.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.users&&a.space_title){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.provisionBulkSpaces;e=D.api.constructAPIUrl(e,{orgId:b.orgId});var f=B.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=D.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory parameters: space_title or users not found in request options.",d=new E(D.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function n(a){var b=this,c=A.defer(),d={};if(a&&a.ext_user_id&&a.ext_role){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.shadowProvision;e=D.api.constructAPIUrl(e,{orgId:b.orgId});var f=B.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.agent(F).end(function(a,b){a?(a=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d.message=d.description="Mandatory parameters: ext_user_id or ext_role not found in request options.",d=new E(D.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function o(a){var b=this,c=A.defer();if(a&&a.ext_user_id&&a.ext_role&&(a.productcode||a.ext_product_id)){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.entitleUserToProduct;d=D.api.constructAPIUrl(d,{accountId:b.accountId});var e=B.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(f=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(f)):c.resolve(b.body)})}else{var f={};f.description="Missing mandatory keys in request options. 'ext_user_id', 'ext_role' and either of 'ext_product_id' or 'productcode' must be present.",f.message=f.description,f=new E(D.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function p(a){var b=this,c=A.defer();if(a&&a.ext_user_id&&a.productcode&&a.ext_actor_id&&void 0!==a.audit){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.entitleUserToProduct;d=D.api.constructAPIUrl(d,{accountId:b.accountId});var e=B["delete"](d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){if(a){var d=new E(D.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var f={};f.message=f.description="Missing mandatory keys in request options. 'ext_user_id', 'ext_actor_id', 'productcode' and 'audit' must be present",f=new E(D.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function q(a){var b=this,c=A.defer(),d=!0,e={description:"",message:""};if(a&&a.ext_user_id&&a.context&&a.feature_key&&a.feature_id||(d=!1,e.description="ext_user_id or context or feature_key or feature_id not found in request options. "),d&&(a.productcode||a.ext_product_id)){var f=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.microEntitleUserToProduct;f=D.api.constructAPIUrl(f,{accountId:b.accountId});var g=B.post(f).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(e=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(e)):c.resolve(b.body)})}else a.productcode||a.ext_product_id||(e.description+="Either of ext_product_id or productcode must be present in request options."),e.message=e.description,e=new E(D.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function r(a){var b=this,c=A.defer();if(a&&a["micro-entitlements"]){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.bulkMicroEntitleProductToUser;d=D.api.constructAPIUrl(d,{accountId:b.accountId});var e=B.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(f=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(f)):c.resolve(b.body)})}else{var f={};f.description="Missing mandatory keys in request options. 'micro-entitlements' must be present.",f.message=f.description,f=new E(D.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function s(a){var b=this,c=A.defer(),d={description:"",message:""};if(a&&a.ext_user_id&&a.context&&a.feature_key&&a.ext_actor_id&&void 0!==a.audit&&(a.productcode||a.ext_product_id)){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.microEntitleUserToProduct;e=D.api.constructAPIUrl(e,{accountId:b.accountId});var f=B["delete"](e).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(d=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.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.",d.message=d.description,d=new E(D.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function t(a){var b=this,c=A.defer();if(a&&a.ext_product_id){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getExtProductAPI;d=D.api.constructAPIUrl(d,{accountId:b.accountId,extProductId:a.ext_product_id});var e=B.get(d);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(f=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(f)):c.resolve(b.body)})}else{var f={};f.message=f.description="ext_product_id not found in request options.",f=new E(D.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function u(a){var b=this,c=A.defer();if(a&&a.spacekey){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getSpaceDetails;d=D.api.constructAPIUrl(d,{accountId:b.accountId,spacekey:a.spacekey});var e={orgid:b.orgId},f=B.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=D.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(g=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(g)):c.resolve(b.body)})}else{var g={};g.message=g.description="spacekey not found in request options.",g=new E(D.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function v(a){var b=this,c=A.defer();if(a&&a.ext_user_id&&a.ext_role&&a.class_code){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.enrollUserInClass;d=D.api.constructAPIUrl(d,{accountId:b.accountId});var e=B.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(f=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(f)):c.resolve(b.body)})}else{var f={};f.message=f.description="ext_user_id or ext_role or class_code not found in request options.",f=new E(D.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function w(a){var b=this,c=A.defer(),d={};if(a&&a.ext_user_id){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.updateUserInformation;e=D.api.constructAPIUrl(e,{accountId:b.accountId});var f={ext_user_id:a.ext_user_id};a.ref_id&&(f.ref_id=a.ref_id),a.ext_email&&(f.ext_email=a.ext_email),a.ext_first_name&&(f.ext_first_name=a.ext_first_name),a.ext_last_name&&(f.ext_last_name=a.ext_last_name),a.address&&(f.address=a.address);var g=B.put(e).set("Content-Type","application/json").set("Accept","application/json").send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description='Mandatory parameters not found in request options: ["ext_user_id"]',d=new E(D.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function x(a){var b,c=this,d=A.defer();if(a&&a.extuserid&&a.spacekey&&a.body){var e=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.updateUserSpace;e=D.api.constructAPIUrl(e,{accountid:c.accountId,extuserid:a.extuserid,spacekey:a.spacekey});var f=B.put(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);c.traceid&&f.set("X-Amzn-Trace-Id",c.traceid),f.agent(F).end(function(a,c){a?(b=new E(D.errors.ERROR_TYPES.API_ERROR,a),d.reject(b)):d.resolve(c.body)})}else{var g={};g.message=g.description="Missing mandatory params: 'extuserid' or 'spacekey' or 'body' not found in the request options.",b=new E(D.errors.ERROR_TYPES.SDK_ERROR,g),d.reject(b)}return d.promise}function y(a){var b=this,c=A.defer(),d={};if(a&&a.email){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getInvitationsByEmail;e=D.api.constructAPIUrl(e,{accountid:b.accountId});var f={email:a.email};a.status&&(f.status=a.status);var g=B.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description="email not found in request options.",d=new E(D.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function z(a){var b=this,c=A.defer(),d={};if(a&&a.space_code&&a.body&&a.body.ext_actor_id){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.updateInstituteTitle;e=D.api.constructAPIUrl(e,{accountId:b.accountId,instituteSpaceCode:a.space_code});var f=B.put(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(d=new E(D.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description="space_code or ext_actor_id not found in request options.",d=new E(D.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}var A=a("q"),B=a("superagent"),C=a("agentkeepalive"),D=a("../../helpers"),E=D.errors.DLSError;b.exports=d;var F=new C({timeout:6e4,freeSocketTimeout:3e4})},{"../../helpers":3,agentkeepalive:36,q:46,superagent:49}],29:[function(a,b,c){function d(a){return this.accountId=a,{entitleBulkUsersToProducts:e.bind(this),setupUser:f.bind(this)}}function e(a){var b=this,c=g.defer();if(a&&a.users&&a.ext_actor_id){var d=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.entitleBulkUsersToProducts;d=j.api.constructAPIUrl(d,{accountid:b.accountId});var e=h.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.agent(l).end(function(a,b){if(a){var d=new k(j.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else c.resolve(b.body)})}else{var f={};f.description="Mandatory params: 'users', 'ext_actor_id' not found in request options.",f.message=f.description,f=new k(j.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function f(a){var b=this,c=g.defer();if(a&&a.ext_user_id&&a.workflow_type){var d=b.config.DEFAULT_HOSTS.AUTHEXTN+b.config.AUTHEXTN_API_URLS.setupUser;d=j.api.constructAPIUrl(d,{accountId:b.accountId});var e=h.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.agent(l).end(function(a,b){a?(a=new k(j.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else{var f={};f.message=f.description="Mandatory field 'ext_user_id' or 'workflow_type' not found in the request options.",f=new k(j.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}var g=a("q"),h=a("superagent"),i=a("agentkeepalive"),j=a("../../helpers"),k=j.errors.DLSError;b.exports=d;var l=new i({timeout:6e4,freeSocketTimeout:3e4})},{"../../helpers":3,agentkeepalive:36,q:46,superagent:49}],30:[function(a,b,c){function d(a){return this.accountId=a,{getAllInstitutions:e.bind(this),getInstitution:f.bind(this),provisionSpacesToSuperAdmin:g.bind(this)}}function e(a){var b=this,c=h.defer(),d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getAllInstitutions;d=j.api.constructAPIUrl(d,{accountid:b.accountId});var e={};a&&(a.lookup&&(e.lookup=a.lookup),a.cursor&&(e.cursor=a.cursor),a.limit&&(e.limit=a.limit));var f=i.get(d).query(e);return b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new k(j.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)}),c.promise}function f(a){var b=this,c=h.defer();if(a&&a.spacecode){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getInstitution;d=j.api.constructAPIUrl(d,{accountid:b.accountId,spacecode:a.spacecode});var e=i.get(d);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(f=new k(j.errors.ERROR_TYPES.API_ERROR,a),c.reject(f)):c.resolve(b.body)})}else{var f={};f.message=f.description="spacecode not found in request options.",f=new k(j.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function g(a){var b=this,c=h.defer();if(a&&a.ext_user_id&&a.ext_role&&a.ext_email&&a.ext_first_name&&a.ext_last_name){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.provisionSpacesToSuperAdmin;d=j.api.constructAPIUrl(d,{accountid:b.accountId});var e=i.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(f=new k(j.errors.ERROR_TYPES.API_ERROR,a),c.reject(f)):c.resolve(b.body)})}else{var f={};f.message=f.description="Missing required input data",f=new k(j.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}var h=a("q"),i=a("superagent"),j=a("../../helpers"),k=j.errors.DLSError;b.exports=d},{"../../helpers":3,q:46,superagent:49}],31:[function(a,b,c){function d(){return{associateTagsWithEntity:e.bind(this),createTags:f.bind(this),updateTags:g.bind(this),deleteTags:h.bind(this),getTag:i.bind(this),getTagHierarchy:j.bind(this),getAllTags:k.bind(this)}}function e(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.entity_type&&a.entity_id&&a.tags){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.TAXONOMY_API_URLS.associateTagsWithEntity;e=n.api.constructAPIUrl(e,{orgId:b.orgId});var f=m.put(e).send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=n.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else d={},d.message=d.description="entity_id or entity_type or tags not found in request options.",d=new o(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function f(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.taxonomyid&&a.body&&a.body.tags&&a.body.tags.length>0){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.TAXONOMY_API_URLS.tags;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),taxonomyId:a.taxonomyid});var f=m.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=n.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory param - context or taxonomyid or body.tags(min. 1 tag) not found in request options.",d=new o(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function g(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.taxonomyid&&a.body&&a.body.tagid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.TAXONOMY_API_URLS.tags;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),taxonomyId:a.taxonomyid});var f=m.put(e).set("Content-Type","application/json").set("Accept","application/json").send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=n.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - context or taxonomyid or tagid not found in request options.",d=new o(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function h(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.taxonomyid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.TAXONOMY_API_URLS.tags;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),taxonomyId:a.taxonomyid});var f={};a.tagid&&(f.tagid=a.tagid);var g=m["delete"](e).query(f);g=n.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d={},d=new o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="context or taxonomyid or tagid not found in request options.",d=new o(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function i(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.taxonomyid&&a.tagid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.TAXONOMY_API_URLS.tags;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),taxonomyId:a.taxonomyid});var f={hierarchy:!1,tagid:a.tagid},g=m.get(e).set("Content-Type","application/json").set("Accept","application/json").query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=n.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(d=new o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory param - context or taxonomyid or tagid not found in request options.",d=new o(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function j(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.taxonomyid&&a.tagid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.TAXONOMY_API_URLS.tags;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),taxonomyId:a.taxonomyid});var f={hierarchy:!0,tagid:a.tagid},g=m.get(e).set("Content-Type","application/json").set("Accept","application/json").query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=n.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(d=new o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory param - context or taxonomyid or tagid not found in request options.",d=new o(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function k(a){var b=this,c=l.defer(),d=n.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.context&&a.taxonomyid){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.TAXONOMY_API_URLS.tags;e=n.api.constructAPIUrl(e,{orgId:b.orgId,context:encodeURIComponent(a.context),taxonomyId:a.taxonomyid});var f={hierarchy:!0},g=m.get(e).set("Content-Type","application/json").set("Accept","application/json").query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=n.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(d=new o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory param - context or taxonomyid not found in request options.",d=new o(n.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}var l=a("q"),m=a("superagent"),n=a("../../helpers"),o=n.errors.DLSError;b.exports=d},{"../../helpers":3,q:46,superagent:49}],32:[function(a,b,c){function d(a){return this.accountId=a,{createWorkflow:e.bind(this),getAllWorkflow:f.bind(this),getAllWorkflowOfAUser:g.bind(this),getAWorkflow:h.bind(this),acceptAWorkflow:i.bind(this),processAWorkflow:j.bind(this),revokeAWorkflow:k.bind(this),completeAWorkflow:l.bind(this),updateWorkflowRequest:m.bind(this)}}function e(a){var b=this,c=n.defer();if(a&&a.ext_user_id&&a.workflow_type){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.workflows;d=p.api.constructAPIUrl(d,{accountid:b.accountId});var e=o.post(d).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(f=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(f)):c.resolve(b.body)})}else{var f={};f.message=f.description="ext_user_id or workflow_type not found in request options.",f=new q(p.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function f(a){var b=this,c=n.defer();if(a&&a.workflow_type&&a.status){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.workflows;d=p.api.constructAPIUrl(d,{accountid:b.accountId});var e={workflow_type:a.workflow_type,status:a.status};a.start&&(e.start=a.start),a.end&&(e.end=a.end),a.cursor&&(e.cursor=a.cursor);var f=o.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(err=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(err)):c.resolve(b.body)})}else err={},err.message=err.description="Mandatory params - workflow_type, status not found in request options.",err=new q(p.errors.ERROR_TYPES.SDK_ERROR,err),c.reject(err);return c.promise}function g(a){var b=this,c=n.defer();if(a&&a.workflow_type&&a.status&&a.ext_user_id){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getAllWorkflowOfAUser;d=p.api.constructAPIUrl(d,{accountid:b.accountId});var e={workflow_type:a.workflow_type,status:a.status,ext_user_id:a.ext_user_id};a.start&&(e.start=a.start),a.end&&(e.end=a.end),a.cursor&&(e.cursor=a.cursor);var f=o.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(err=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(err)):c.resolve(b.body)})}else err={},err.message=err.description="Mandatory params - workflow_type, status, ext_user_id not found in request options.",err=new q(p.errors.ERROR_TYPES.SDK_ERROR,err),c.reject(err);return c.promise}function h(a){var b=this,c=n.defer();if(a&&a.workflowid&&a.context_id){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getAWorkflow;d=p.api.constructAPIUrl(d,{accountid:b.accountId,workflowid:a.workflowid});var e={context_id:a.context_id},f=o.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(err=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(err)):c.resolve(b.body)})}else err={},err.message=err.description="Mandatory params - workflow_type, status not found in request options.",err=new q(p.errors.ERROR_TYPES.SDK_ERROR,err),c.reject(err);return c.promise}function i(a){var b=this,c=n.defer();if(a&&a.workflowid&&a.body&&a.body.context_id){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.acceptAWorkflow;d=p.api.constructAPIUrl(d,{accountid:b.accountId,workflowid:a.workflowid});var e=a.body,f=o.put(d).send(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(err=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(err)):c.resolve(b)})}else err={},err.message=err.description="Mandatory params - workflowid, body or body.context_id not found in request options.",err=new q(p.errors.ERROR_TYPES.SDK_ERROR,err),c.reject(err);return c.promise}function j(a){var b=this,c=n.defer();if(a&&a.workflowid&&a.body&&a.body.context_id&&a.body.org_id){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.processAWorkflow;d=p.api.constructAPIUrl(d,{accountid:b.accountId,workflowid:a.workflowid});var e=a.body,f=o.put(d).send(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(err=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(err)):c.resolve(b)})}else err={},err.message=err.description="Mandatory params - workflowid, body, body.context_id, body.org_id in request options.",err=new q(p.errors.ERROR_TYPES.SDK_ERROR,err),c.reject(err);return c.promise}function k(a){var b=this,c=n.defer();if(a&&a.workflowid&&a.body&&a.body.context_id){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.revokeAWorkflow;d=p.api.constructAPIUrl(d,{accountid:b.accountId,workflowid:a.workflowid});var e=a.body,f=o.put(d).send(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(err=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(err)):c.resolve(b)})}else err={},err.message=err.description="Mandatory params - workflowid, body or body.context_id not found in request options.",err=new q(p.errors.ERROR_TYPES.SDK_ERROR,err),c.reject(err);return c.promise}function l(a){var b=this,c=n.defer();if(a&&a.workflowid&&a.body&&a.body.context_id){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.completeAWorkflow;d=p.api.constructAPIUrl(d,{accountid:b.accountId,workflowid:a.workflowid});var e=a.body,f=o.put(d).send(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(err=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(err)):c.resolve(b)})}else err={},err.message=err.description="Mandatory params - workflowid, body or body.context_id not found in request options.",err=new q(p.errors.ERROR_TYPES.SDK_ERROR,err),c.reject(err);return c.promise}function m(a){var b=this,c=n.defer();if(a&&a.context_id&&a.body.ext_user_id&&a.body.workflow_type&&a.workflowid){
8
+ var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getAWorkflow;d=p.api.constructAPIUrl(d,{accountid:b.accountId,workflowid:a.workflowid});var e={context_id:a.context_id},f=o.put(d).set("Content-Type","application/json").set("Accept","application/json").query(e).send(a.body);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(g=new q(p.errors.ERROR_TYPES.API_ERROR,a),c.reject(g)):c.resolve(b)})}else{var g={};g.message=g.description="context_id or ext_user_id or workflow_type or workflowid not found in request options.",g=new q(p.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}var n=a("q"),o=a("superagent"),p=a("./../../helpers"),q=p.errors.DLSError;b.exports=d},{"./../../helpers":3,q:46,superagent:49}],33:[function(a,b,c){function d(a){return this.accountId=a,{postStatement:e.bind(this),postExternalStatements:f.bind(this)}}function e(a){var b,c=this,d=g.defer(),e={};if(e=i.validations.isAuthenticated(c.orgId,c.token))d.reject(e);else{b=c.config.DEFAULT_HOSTS.XAPI+c.config.XAPI_API_URLS.postMultiStatements,b=i.api.constructAPIUrl(b,{orgId:c.orgId});var f=a,k=h.post(b).send(f);k=i.api.setupAPIToken(k,c.token),c.traceid&&k.set("X-Amzn-Trace-Id",c.traceid),k.end(function(a,b){a?(a=new j(i.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}return d.promise}function f(a){var b=this,c=g.defer(),d=b.config.DEFAULT_HOSTS.XAPI+b.config.XAPI_API_URLS.postExternalMultiStatements;d=i.api.constructAPIUrl(d,{orgId:b.orgId});var e=h.post(d).send(a);return b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(a=new j(i.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)}),c.promise}var g=a("q"),h=a("superagent"),i=a("../../helpers"),j=i.errors.DLSError;b.exports=d},{"../../helpers":3,q:46,superagent:49}],34:[function(a,b,c){function d(a,b){var c=this,d=g.defer(),e=j.validateAuthWithExtUser(a,b);if(e)d.reject(e);else{var k=this.config.DEFAULT_HOSTS.AUTH+this.config.AUTH_API_URLS.getExtUserTokenAPI;k=h.api.constructAPIUrl(k,{orgId:a});var l={ext_user_id:b.ext_user_id};f.post(k).send(l).end(function(a,b){if(a)a=new i(h.errors.ERROR_TYPES.API_ERROR,a),d.reject(a);else{var e={access_token:b.body.access_token},f=b.body.user,g={token:e,user:f,metrics:b.body.metrics};c.token=e,c.orgId=f.org.id,d.resolve(g)}})}return d.promise}function e(a,b,c){var d=this,e=g.defer(),f=j.authWithToken(a,b,c);return f?e.reject(f):(d.token=b,d.orgId=a,c&&c.getuserdetails?d.Auth().getUserProfile().then(function(a){var b={token:d.token,user:a};e.resolve(b)},function(a){a=new i(h.errors.ERROR_TYPES.API_ERROR,a),e.reject(a)}):e.resolve(d.token)),e.promise}var f=a("superagent"),g=a("q"),h=a("../helpers"),i=h.errors.DLSError,j=a("./validations");c.authWithExtUser=d,c.authWithToken=e},{"../helpers":3,"./validations":35,q:46,superagent:49}],35:[function(a,b,c){function d(a,b,c){var d={organization:a,token:b,options:c},e={organization:{isString:!0,presence:!0},token:{isObject:!0,presence:!0,contains:["access_token"]},"token.access_token":{isString:!0,presence:!0},options:{isObject:!0}};return f(d,e)}function e(a,b){var c={organization:a,options:b},d={organization:{isString:!0,presence:!0},options:{isObject:!0,presence:!0,contains:["ext_user_id"]},"options.ext_user_id":{isString:!0,presence:!0}};return f(c,d)}var f=a("../helpers").validations.validate;c.authWithToken=d,c.validateAuthWithExtUser=e},{"../helpers":3}],36:[function(a,b,c){function d(){}b.exports=d,b.exports.HttpsAgent=d},{}],37:[function(a,b,c){var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(a){"use strict";function b(a){var b=a.charCodeAt(0);return b===g||b===l?62:b===h||b===m?63:b<i?-1:b<i+10?b-i+26+26:b<k+26?b-k:b<j+26?b-j+26:void 0}function c(a){function c(a){j[l++]=a}var d,e,g,h,i,j;if(a.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var k=a.length;i="="===a.charAt(k-2)?2:"="===a.charAt(k-1)?1:0,j=new f(3*a.length/4-i),g=i>0?a.length-4:a.length;var l=0;for(d=0,e=0;d<g;d+=4,e+=3)h=b(a.charAt(d))<<18|b(a.charAt(d+1))<<12|b(a.charAt(d+2))<<6|b(a.charAt(d+3)),c((16711680&h)>>16),c((65280&h)>>8),c(255&h);return 2===i?(h=b(a.charAt(d))<<2|b(a.charAt(d+1))>>4,c(255&h)):1===i&&(h=b(a.charAt(d))<<10|b(a.charAt(d+1))<<4|b(a.charAt(d+2))>>2,c(h>>8&255),c(255&h)),j}function e(a){function b(a){return d.charAt(a)}function c(a){return b(a>>18&63)+b(a>>12&63)+b(a>>6&63)+b(63&a)}var e,f,g,h=a.length%3,i="";for(e=0,g=a.length-h;e<g;e+=3)f=(a[e]<<16)+(a[e+1]<<8)+a[e+2],i+=c(f);switch(h){case 1:f=a[a.length-1],i+=b(f>>2),i+=b(f<<4&63),i+="==";break;case 2:f=(a[a.length-2]<<8)+a[a.length-1],i+=b(f>>10),i+=b(f>>4&63),i+=b(f<<2&63),i+="="}return i}var f="undefined"!=typeof Uint8Array?Uint8Array:Array,g="+".charCodeAt(0),h="/".charCodeAt(0),i="0".charCodeAt(0),j="a".charCodeAt(0),k="A".charCodeAt(0),l="-".charCodeAt(0),m="_".charCodeAt(0);a.toByteArray=c,a.fromByteArray=e}("undefined"==typeof c?this.base64js={}:c)},{}],38:[function(a,b,c){(function(b){"use strict";function d(){function a(){}try{var b=new Uint8Array(1);return b.foo=function(){return 42},b.constructor=a,42===b.foo()&&b.constructor===a&&"function"==typeof b.subarray&&0===b.subarray(1,1).byteLength}catch(c){return!1}}function e(){return f.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function f(a){return this instanceof f?(f.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof a?g(this,a):"string"==typeof a?h(this,a,arguments.length>1?arguments[1]:"utf8"):i(this,a)):arguments.length>1?new f(a,arguments[1]):new f(a)}function g(a,b){if(a=p(a,b<0?0:0|q(b)),!f.TYPED_ARRAY_SUPPORT)for(var c=0;c<b;c++)a[c]=0;return a}function h(a,b,c){"string"==typeof c&&""!==c||(c="utf8");var d=0|s(b,c);return a=p(a,d),a.write(b,c),a}function i(a,b){if(f.isBuffer(b))return j(a,b);if(Y(b))return k(a,b);if(null==b)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(b.buffer instanceof ArrayBuffer)return l(a,b);if(b instanceof ArrayBuffer)return m(a,b)}return b.length?n(a,b):o(a,b)}function j(a,b){var c=0|q(b.length);return a=p(a,c),b.copy(a,0,0,c),a}function k(a,b){var c=0|q(b.length);a=p(a,c);for(var d=0;d<c;d+=1)a[d]=255&b[d];return a}function l(a,b){var c=0|q(b.length);a=p(a,c);for(var d=0;d<c;d+=1)a[d]=255&b[d];return a}function m(a,b){return f.TYPED_ARRAY_SUPPORT?(b.byteLength,a=f._augment(new Uint8Array(b))):a=l(a,new Uint8Array(b)),a}function n(a,b){var c=0|q(b.length);a=p(a,c);for(var d=0;d<c;d+=1)a[d]=255&b[d];return a}function o(a,b){var c,d=0;"Buffer"===b.type&&Y(b.data)&&(c=b.data,d=0|q(c.length)),a=p(a,d);for(var e=0;e<d;e+=1)a[e]=255&c[e];return a}function p(a,b){f.TYPED_ARRAY_SUPPORT?(a=f._augment(new Uint8Array(b)),a.__proto__=f.prototype):(a.length=b,a._isBuffer=!0);var c=0!==b&&b<=f.poolSize>>>1;return c&&(a.parent=Z),a}function q(a){if(a>=e())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+e().toString(16)+" bytes");return 0|a}function r(a,b){if(!(this instanceof r))return new r(a,b);var c=new f(a,b);return delete c.parent,c}function s(a,b){"string"!=typeof a&&(a=""+a);var c=a.length;if(0===c)return 0;for(var d=!1;;)switch(b){case"ascii":case"binary":case"raw":case"raws":return c;case"utf8":case"utf-8":return R(a).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*c;case"hex":return c>>>1;case"base64":return U(a).length;default:if(d)return R(a).length;b=(""+b).toLowerCase(),d=!0}}function t(a,b,c){var d=!1;if(b=0|b,c=void 0===c||c===1/0?this.length:0|c,a||(a="utf8"),b<0&&(b=0),c>this.length&&(c=this.length),c<=b)return"";for(;;)switch(a){case"hex":return F(this,b,c);case"utf8":case"utf-8":return B(this,b,c);case"ascii":return D(this,b,c);case"binary":return E(this,b,c);case"base64":return A(this,b,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return G(this,b,c);default:if(d)throw new TypeError("Unknown encoding: "+a);a=(a+"").toLowerCase(),d=!0}}function u(a,b,c,d){c=Number(c)||0;var e=a.length-c;d?(d=Number(d),d>e&&(d=e)):d=e;var f=b.length;if(f%2!==0)throw new Error("Invalid hex string");d>f/2&&(d=f/2);for(var g=0;g<d;g++){var h=parseInt(b.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");a[c+g]=h}return g}function v(a,b,c,d){return V(R(b,a.length-c),a,c,d)}function w(a,b,c,d){return V(S(b),a,c,d)}function x(a,b,c,d){return w(a,b,c,d)}function y(a,b,c,d){return V(U(b),a,c,d)}function z(a,b,c,d){return V(T(b,a.length-c),a,c,d)}function A(a,b,c){return 0===b&&c===a.length?W.fromByteArray(a):W.fromByteArray(a.slice(b,c))}function B(a,b,c){c=Math.min(a.length,c);for(var d=[],e=b;e<c;){var f=a[e],g=null,h=f>239?4:f>223?3:f>191?2:1;if(e+h<=c){var i,j,k,l;switch(h){case 1:f<128&&(g=f);break;case 2:i=a[e+1],128===(192&i)&&(l=(31&f)<<6|63&i,l>127&&(g=l));break;case 3:i=a[e+1],j=a[e+2],128===(192&i)&&128===(192&j)&&(l=(15&f)<<12|(63&i)<<6|63&j,l>2047&&(l<55296||l>57343)&&(g=l));break;case 4:i=a[e+1],j=a[e+2],k=a[e+3],128===(192&i)&&128===(192&j)&&128===(192&k)&&(l=(15&f)<<18|(63&i)<<12|(63&j)<<6|63&k,l>65535&&l<1114112&&(g=l))}}null===g?(g=65533,h=1):g>65535&&(g-=65536,d.push(g>>>10&1023|55296),g=56320|1023&g),d.push(g),e+=h}return C(d)}function C(a){var b=a.length;if(b<=$)return String.fromCharCode.apply(String,a);for(var c="",d=0;d<b;)c+=String.fromCharCode.apply(String,a.slice(d,d+=$));return c}function D(a,b,c){var d="";c=Math.min(a.length,c);for(var e=b;e<c;e++)d+=String.fromCharCode(127&a[e]);return d}function E(a,b,c){var d="";c=Math.min(a.length,c);for(var e=b;e<c;e++)d+=String.fromCharCode(a[e]);return d}function F(a,b,c){var d=a.length;(!b||b<0)&&(b=0),(!c||c<0||c>d)&&(c=d);for(var e="",f=b;f<c;f++)e+=Q(a[f]);return e}function G(a,b,c){for(var d=a.slice(b,c),e="",f=0;f<d.length;f+=2)e+=String.fromCharCode(d[f]+256*d[f+1]);return e}function H(a,b,c){if(a%1!==0||a<0)throw new RangeError("offset is not uint");if(a+b>c)throw new RangeError("Trying to access beyond buffer length")}function I(a,b,c,d,e,g){if(!f.isBuffer(a))throw new TypeError("buffer must be a Buffer instance");if(b>e||b<g)throw new RangeError("value is out of bounds");if(c+d>a.length)throw new RangeError("index out of range")}function J(a,b,c,d){b<0&&(b=65535+b+1);for(var e=0,f=Math.min(a.length-c,2);e<f;e++)a[c+e]=(b&255<<8*(d?e:1-e))>>>8*(d?e:1-e)}function K(a,b,c,d){b<0&&(b=4294967295+b+1);for(var e=0,f=Math.min(a.length-c,4);e<f;e++)a[c+e]=b>>>8*(d?e:3-e)&255}function L(a,b,c,d,e,f){if(b>e||b<f)throw new RangeError("value is out of bounds");if(c+d>a.length)throw new RangeError("index out of range");if(c<0)throw new RangeError("index out of range")}function M(a,b,c,d,e){return e||L(a,b,c,4,3.4028234663852886e38,-3.4028234663852886e38),X.write(a,b,c,d,23,4),c+4}function N(a,b,c,d,e){return e||L(a,b,c,8,1.7976931348623157e308,-1.7976931348623157e308),X.write(a,b,c,d,52,8),c+8}function O(a){if(a=P(a).replace(aa,""),a.length<2)return"";for(;a.length%4!==0;)a+="=";return a}function P(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function Q(a){return a<16?"0"+a.toString(16):a.toString(16)}function R(a,b){b=b||1/0;for(var c,d=a.length,e=null,f=[],g=0;g<d;g++){if(c=a.charCodeAt(g),c>55295&&c<57344){if(!e){if(c>56319){(b-=3)>-1&&f.push(239,191,189);continue}if(g+1===d){(b-=3)>-1&&f.push(239,191,189);continue}e=c;continue}if(c<56320){(b-=3)>-1&&f.push(239,191,189),e=c;continue}c=(e-55296<<10|c-56320)+65536}else e&&(b-=3)>-1&&f.push(239,191,189);if(e=null,c<128){if((b-=1)<0)break;f.push(c)}else if(c<2048){if((b-=2)<0)break;f.push(c>>6|192,63&c|128)}else if(c<65536){if((b-=3)<0)break;f.push(c>>12|224,c>>6&63|128,63&c|128)}else{if(!(c<1114112))throw new Error("Invalid code point");if((b-=4)<0)break;f.push(c>>18|240,c>>12&63|128,c>>6&63|128,63&c|128)}}return f}function S(a){for(var b=[],c=0;c<a.length;c++)b.push(255&a.charCodeAt(c));return b}function T(a,b){for(var c,d,e,f=[],g=0;g<a.length&&!((b-=2)<0);g++)c=a.charCodeAt(g),d=c>>8,e=c%256,f.push(e),f.push(d);return f}function U(a){return W.toByteArray(O(a))}function V(a,b,c,d){for(var e=0;e<d&&!(e+c>=b.length||e>=a.length);e++)b[e+c]=a[e];return e}var W=a("base64-js"),X=a("ieee754"),Y=a("isarray");c.Buffer=f,c.SlowBuffer=r,c.INSPECT_MAX_BYTES=50,f.poolSize=8192;var Z={};f.TYPED_ARRAY_SUPPORT=void 0!==b.TYPED_ARRAY_SUPPORT?b.TYPED_ARRAY_SUPPORT:d(),f.TYPED_ARRAY_SUPPORT?(f.prototype.__proto__=Uint8Array.prototype,f.__proto__=Uint8Array):(f.prototype.length=void 0,f.prototype.parent=void 0),f.isBuffer=function(a){return!(null==a||!a._isBuffer)},f.compare=function(a,b){if(!f.isBuffer(a)||!f.isBuffer(b))throw new TypeError("Arguments must be Buffers");if(a===b)return 0;for(var c=a.length,d=b.length,e=0,g=Math.min(c,d);e<g&&a[e]===b[e];)++e;return e!==g&&(c=a[e],d=b[e]),c<d?-1:d<c?1:0},f.isEncoding=function(a){switch(String(a).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},f.concat=function(a,b){if(!Y(a))throw new TypeError("list argument must be an Array of Buffers.");if(0===a.length)return new f(0);var c;if(void 0===b)for(b=0,c=0;c<a.length;c++)b+=a[c].length;var d=new f(b),e=0;for(c=0;c<a.length;c++){var g=a[c];g.copy(d,e),e+=g.length}return d},f.byteLength=s,f.prototype.toString=function(){var a=0|this.length;return 0===a?"":0===arguments.length?B(this,0,a):t.apply(this,arguments)},f.prototype.equals=function(a){if(!f.isBuffer(a))throw new TypeError("Argument must be a Buffer");return this===a||0===f.compare(this,a)},f.prototype.inspect=function(){var a="",b=c.INSPECT_MAX_BYTES;return this.length>0&&(a=this.toString("hex",0,b).match(/.{2}/g).join(" "),this.length>b&&(a+=" ... ")),"<Buffer "+a+">"},f.prototype.compare=function(a){if(!f.isBuffer(a))throw new TypeError("Argument must be a Buffer");return this===a?0:f.compare(this,a)},f.prototype.indexOf=function(a,b){function c(a,b,c){for(var d=-1,e=0;c+e<a.length;e++)if(a[c+e]===b[d===-1?0:e-d]){if(d===-1&&(d=e),e-d+1===b.length)return c+d}else d=-1;return-1}if(b>2147483647?b=2147483647:b<-2147483648&&(b=-2147483648),b>>=0,0===this.length)return-1;if(b>=this.length)return-1;if(b<0&&(b=Math.max(this.length+b,0)),"string"==typeof a)return 0===a.length?-1:String.prototype.indexOf.call(this,a,b);if(f.isBuffer(a))return c(this,a,b);if("number"==typeof a)return f.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,a,b):c(this,[a],b);throw new TypeError("val must be string, number or Buffer")},f.prototype.get=function(a){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(a)},f.prototype.set=function(a,b){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(a,b)},f.prototype.write=function(a,b,c,d){if(void 0===b)d="utf8",c=this.length,b=0;else if(void 0===c&&"string"==typeof b)d=b,c=this.length,b=0;else if(isFinite(b))b=0|b,isFinite(c)?(c=0|c,void 0===d&&(d="utf8")):(d=c,c=void 0);else{var e=d;d=b,b=0|c,c=e}var f=this.length-b;if((void 0===c||c>f)&&(c=f),a.length>0&&(c<0||b<0)||b>this.length)throw new RangeError("attempt to write outside buffer bounds");d||(d="utf8");for(var g=!1;;)switch(d){case"hex":return u(this,a,b,c);case"utf8":case"utf-8":return v(this,a,b,c);case"ascii":return w(this,a,b,c);case"binary":return x(this,a,b,c);case"base64":return y(this,a,b,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return z(this,a,b,c);default:if(g)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),g=!0}},f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var $=4096;f.prototype.slice=function(a,b){var c=this.length;a=~~a,b=void 0===b?c:~~b,a<0?(a+=c,a<0&&(a=0)):a>c&&(a=c),b<0?(b+=c,b<0&&(b=0)):b>c&&(b=c),b<a&&(b=a);var d;if(f.TYPED_ARRAY_SUPPORT)d=f._augment(this.subarray(a,b));else{var e=b-a;d=new f(e,(void 0));for(var g=0;g<e;g++)d[g]=this[g+a]}return d.length&&(d.parent=this.parent||this),d},f.prototype.readUIntLE=function(a,b,c){a=0|a,b=0|b,c||H(a,b,this.length);for(var d=this[a],e=1,f=0;++f<b&&(e*=256);)d+=this[a+f]*e;return d},f.prototype.readUIntBE=function(a,b,c){a=0|a,b=0|b,c||H(a,b,this.length);for(var d=this[a+--b],e=1;b>0&&(e*=256);)d+=this[a+--b]*e;return d},f.prototype.readUInt8=function(a,b){return b||H(a,1,this.length),this[a]},f.prototype.readUInt16LE=function(a,b){return b||H(a,2,this.length),this[a]|this[a+1]<<8},f.prototype.readUInt16BE=function(a,b){return b||H(a,2,this.length),this[a]<<8|this[a+1]},f.prototype.readUInt32LE=function(a,b){return b||H(a,4,this.length),(this[a]|this[a+1]<<8|this[a+2]<<16)+16777216*this[a+3]},f.prototype.readUInt32BE=function(a,b){return b||H(a,4,this.length),16777216*this[a]+(this[a+1]<<16|this[a+2]<<8|this[a+3])},f.prototype.readIntLE=function(a,b,c){a=0|a,b=0|b,c||H(a,b,this.length);for(var d=this[a],e=1,f=0;++f<b&&(e*=256);)d+=this[a+f]*e;return e*=128,d>=e&&(d-=Math.pow(2,8*b)),d},f.prototype.readIntBE=function(a,b,c){a=0|a,b=0|b,c||H(a,b,this.length);for(var d=b,e=1,f=this[a+--d];d>0&&(e*=256);)f+=this[a+--d]*e;return e*=128,f>=e&&(f-=Math.pow(2,8*b)),f},f.prototype.readInt8=function(a,b){return b||H(a,1,this.length),128&this[a]?(255-this[a]+1)*-1:this[a]},f.prototype.readInt16LE=function(a,b){b||H(a,2,this.length);var c=this[a]|this[a+1]<<8;return 32768&c?4294901760|c:c},f.prototype.readInt16BE=function(a,b){b||H(a,2,this.length);var c=this[a+1]|this[a]<<8;return 32768&c?4294901760|c:c},f.prototype.readInt32LE=function(a,b){return b||H(a,4,this.length),this[a]|this[a+1]<<8|this[a+2]<<16|this[a+3]<<24},f.prototype.readInt32BE=function(a,b){return b||H(a,4,this.length),this[a]<<24|this[a+1]<<16|this[a+2]<<8|this[a+3]},f.prototype.readFloatLE=function(a,b){return b||H(a,4,this.length),X.read(this,a,!0,23,4)},f.prototype.readFloatBE=function(a,b){return b||H(a,4,this.length),X.read(this,a,!1,23,4)},f.prototype.readDoubleLE=function(a,b){return b||H(a,8,this.length),X.read(this,a,!0,52,8)},f.prototype.readDoubleBE=function(a,b){return b||H(a,8,this.length),X.read(this,a,!1,52,8)},f.prototype.writeUIntLE=function(a,b,c,d){a=+a,b=0|b,c=0|c,d||I(this,a,b,c,Math.pow(2,8*c),0);var e=1,f=0;for(this[b]=255&a;++f<c&&(e*=256);)this[b+f]=a/e&255;return b+c},f.prototype.writeUIntBE=function(a,b,c,d){a=+a,b=0|b,c=0|c,d||I(this,a,b,c,Math.pow(2,8*c),0);var e=c-1,f=1;for(this[b+e]=255&a;--e>=0&&(f*=256);)this[b+e]=a/f&255;return b+c},f.prototype.writeUInt8=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,1,255,0),f.TYPED_ARRAY_SUPPORT||(a=Math.floor(a)),this[b]=255&a,b+1},f.prototype.writeUInt16LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[b]=255&a,this[b+1]=a>>>8):J(this,a,b,!0),b+2},f.prototype.writeUInt16BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,65535,0),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>8,this[b+1]=255&a):J(this,a,b,!1),b+2},f.prototype.writeUInt32LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[b+3]=a>>>24,this[b+2]=a>>>16,this[b+1]=a>>>8,this[b]=255&a):K(this,a,b,!0),b+4},f.prototype.writeUInt32BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,4294967295,0),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>24,this[b+1]=a>>>16,this[b+2]=a>>>8,this[b+3]=255&a):K(this,a,b,!1),b+4},f.prototype.writeIntLE=function(a,b,c,d){if(a=+a,b=0|b,!d){var e=Math.pow(2,8*c-1);I(this,a,b,c,e-1,-e)}var f=0,g=1,h=a<0?1:0;for(this[b]=255&a;++f<c&&(g*=256);)this[b+f]=(a/g>>0)-h&255;return b+c},f.prototype.writeIntBE=function(a,b,c,d){if(a=+a,b=0|b,!d){var e=Math.pow(2,8*c-1);I(this,a,b,c,e-1,-e)}var f=c-1,g=1,h=a<0?1:0;for(this[b+f]=255&a;--f>=0&&(g*=256);)this[b+f]=(a/g>>0)-h&255;return b+c},f.prototype.writeInt8=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,1,127,-128),f.TYPED_ARRAY_SUPPORT||(a=Math.floor(a)),a<0&&(a=255+a+1),this[b]=255&a,b+1},f.prototype.writeInt16LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[b]=255&a,this[b+1]=a>>>8):J(this,a,b,!0),b+2},f.prototype.writeInt16BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,2,32767,-32768),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>8,this[b+1]=255&a):J(this,a,b,!1),b+2},f.prototype.writeInt32LE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,2147483647,-2147483648),f.TYPED_ARRAY_SUPPORT?(this[b]=255&a,this[b+1]=a>>>8,this[b+2]=a>>>16,this[b+3]=a>>>24):K(this,a,b,!0),b+4},f.prototype.writeInt32BE=function(a,b,c){return a=+a,b=0|b,c||I(this,a,b,4,2147483647,-2147483648),a<0&&(a=4294967295+a+1),f.TYPED_ARRAY_SUPPORT?(this[b]=a>>>24,this[b+1]=a>>>16,this[b+2]=a>>>8,this[b+3]=255&a):K(this,a,b,!1),b+4},f.prototype.writeFloatLE=function(a,b,c){return M(this,a,b,!0,c)},f.prototype.writeFloatBE=function(a,b,c){return M(this,a,b,!1,c)},f.prototype.writeDoubleLE=function(a,b,c){return N(this,a,b,!0,c)},f.prototype.writeDoubleBE=function(a,b,c){return N(this,a,b,!1,c)},f.prototype.copy=function(a,b,c,d){if(c||(c=0),d||0===d||(d=this.length),b>=a.length&&(b=a.length),b||(b=0),d>0&&d<c&&(d=c),d===c)return 0;if(0===a.length||0===this.length)return 0;if(b<0)throw new RangeError("targetStart out of bounds");if(c<0||c>=this.length)throw new RangeError("sourceStart out of bounds");if(d<0)throw new RangeError("sourceEnd out of bounds");d>this.length&&(d=this.length),a.length-b<d-c&&(d=a.length-b+c);var e,g=d-c;if(this===a&&c<b&&b<d)for(e=g-1;e>=0;e--)a[e+b]=this[e+c];else if(g<1e3||!f.TYPED_ARRAY_SUPPORT)for(e=0;e<g;e++)a[e+b]=this[e+c];else a._set(this.subarray(c,c+g),b);return g},f.prototype.fill=function(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),c<b)throw new RangeError("end < start");if(c!==b&&0!==this.length){if(b<0||b>=this.length)throw new RangeError("start out of bounds");if(c<0||c>this.length)throw new RangeError("end out of bounds");var d;if("number"==typeof a)for(d=b;d<c;d++)this[d]=a;else{var e=R(a.toString()),f=e.length;for(d=b;d<c;d++)this[d]=e[d%f]}return this}},f.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(f.TYPED_ARRAY_SUPPORT)return new f(this).buffer;for(var a=new Uint8Array(this.length),b=0,c=a.length;b<c;b+=1)a[b]=this[b];return a.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var _=f.prototype;f._augment=function(a){return a.constructor=f,a._isBuffer=!0,a._set=a.set,a.get=_.get,a.set=_.set,a.write=_.write,a.toString=_.toString,a.toLocaleString=_.toString,a.toJSON=_.toJSON,a.equals=_.equals,a.compare=_.compare,a.indexOf=_.indexOf,a.copy=_.copy,a.slice=_.slice,a.readUIntLE=_.readUIntLE,a.readUIntBE=_.readUIntBE,a.readUInt8=_.readUInt8,a.readUInt16LE=_.readUInt16LE,a.readUInt16BE=_.readUInt16BE,a.readUInt32LE=_.readUInt32LE,a.readUInt32BE=_.readUInt32BE,a.readIntLE=_.readIntLE,a.readIntBE=_.readIntBE,a.readInt8=_.readInt8,a.readInt16LE=_.readInt16LE,a.readInt16BE=_.readInt16BE,a.readInt32LE=_.readInt32LE,a.readInt32BE=_.readInt32BE,a.readFloatLE=_.readFloatLE,a.readFloatBE=_.readFloatBE,a.readDoubleLE=_.readDoubleLE,a.readDoubleBE=_.readDoubleBE,a.writeUInt8=_.writeUInt8,a.writeUIntLE=_.writeUIntLE,a.writeUIntBE=_.writeUIntBE,a.writeUInt16LE=_.writeUInt16LE,a.writeUInt16BE=_.writeUInt16BE,a.writeUInt32LE=_.writeUInt32LE,a.writeUInt32BE=_.writeUInt32BE,a.writeIntLE=_.writeIntLE,a.writeIntBE=_.writeIntBE,a.writeInt8=_.writeInt8,a.writeInt16LE=_.writeInt16LE,a.writeInt16BE=_.writeInt16BE,a.writeInt32LE=_.writeInt32LE,a.writeInt32BE=_.writeInt32BE,a.writeFloatLE=_.writeFloatLE,a.writeFloatBE=_.writeFloatBE,a.writeDoubleLE=_.writeDoubleLE,a.writeDoubleBE=_.writeDoubleBE,a.fill=_.fill,a.inspect=_.inspect,a.toArrayBuffer=_.toArrayBuffer,a};var aa=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":37,ieee754:43,isarray:39}],39:[function(a,b,c){var d={}.toString;b.exports=Array.isArray||function(a){return"[object Array]"==d.call(a)}},{}],40:[function(a,b,c){function d(a){if(a)return e(a)}function e(a){for(var b in d.prototype)a[b]=d.prototype[b];return a}"undefined"!=typeof b&&(b.exports=d),d.prototype.on=d.prototype.addEventListener=function(a,b){return this._callbacks=this._callbacks||{},(this._callbacks["$"+a]=this._callbacks["$"+a]||[]).push(b),this},d.prototype.once=function(a,b){function c(){this.off(a,c),b.apply(this,arguments)}return c.fn=b,this.on(a,c),this},d.prototype.off=d.prototype.removeListener=d.prototype.removeAllListeners=d.prototype.removeEventListener=function(a,b){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var c=this._callbacks["$"+a];if(!c)return this;if(1==arguments.length)return delete this._callbacks["$"+a],this;for(var d,e=0;e<c.length;e++)if(d=c[e],d===b||d.fn===b){c.splice(e,1);break}return 0===c.length&&delete this._callbacks["$"+a],this},d.prototype.emit=function(a){this._callbacks=this._callbacks||{};for(var b=new Array(arguments.length-1),c=this._callbacks["$"+a],d=1;d<arguments.length;d++)b[d-1]=arguments[d];if(c){c=c.slice(0);for(var d=0,e=c.length;d<e;++d)c[d].apply(this,b)}return this},d.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks["$"+a]||[]},d.prototype.hasListeners=function(a){return!!this.listeners(a).length}},{}],41:[function(a,b,c){function d(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function e(a){return"function"==typeof a}function f(a){return"number"==typeof a}function g(a){return"object"==typeof a&&null!==a}function h(a){return void 0===a}b.exports=d,d.EventEmitter=d,d.prototype._events=void 0,d.prototype._maxListeners=void 0,d.defaultMaxListeners=10,d.prototype.setMaxListeners=function(a){if(!f(a)||a<0||isNaN(a))throw TypeError("n must be a positive number");return this._maxListeners=a,this},d.prototype.emit=function(a){var b,c,d,f,i,j;if(this._events||(this._events={}),"error"===a&&(!this._events.error||g(this._events.error)&&!this._events.error.length)){if(b=arguments[1],b instanceof Error)throw b;throw TypeError('Uncaught, unspecified "error" event.')}if(c=this._events[a],h(c))return!1;if(e(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(d=arguments.length,f=new Array(d-1),i=1;i<d;i++)f[i-1]=arguments[i];c.apply(this,f)}else if(g(c)){for(d=arguments.length,f=new Array(d-1),i=1;i<d;i++)f[i-1]=arguments[i];for(j=c.slice(),d=j.length,i=0;i<d;i++)j[i].apply(this,f)}return!0},d.prototype.addListener=function(a,b){var c;if(!e(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,e(b.listener)?b.listener:b),this._events[a]?g(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,g(this._events[a])&&!this._events[a].warned){var c;c=h(this._maxListeners)?d.defaultMaxListeners:this._maxListeners,c&&c>0&&this._events[a].length>c&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),"function"==typeof console.trace&&console.trace())}return this},d.prototype.on=d.prototype.addListener,d.prototype.once=function(a,b){function c(){this.removeListener(a,c),d||(d=!0,b.apply(this,arguments))}if(!e(b))throw TypeError("listener must be a function");var d=!1;return c.listener=b,this.on(a,c),this},d.prototype.removeListener=function(a,b){var c,d,f,h;if(!e(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],f=c.length,d=-1,c===b||e(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(g(c)){for(h=f;h-- >0;)if(c[h]===b||c[h].listener&&c[h].listener===b){d=h;break}if(d<0)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(d,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},d.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],e(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},d.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?e(this._events[a])?[this._events[a]]:this._events[a].slice():[]},d.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?e(a._events[b])?1:a._events[b].length:0}},{}],42:[function(a,b,c){"use strict";var d=Object.prototype.hasOwnProperty,e=Object.prototype.toString,f=Object.defineProperty,g=Object.getOwnPropertyDescriptor,h=function(a){return"function"==typeof Array.isArray?Array.isArray(a):"[object Array]"===e.call(a)},i=function(a){if(!a||"[object Object]"!==e.call(a))return!1;var b=d.call(a,"constructor"),c=a.constructor&&a.constructor.prototype&&d.call(a.constructor.prototype,"isPrototypeOf");if(a.constructor&&!b&&!c)return!1;var f;for(f in a);return"undefined"==typeof f||d.call(a,f)},j=function(a,b){f&&"__proto__"===b.name?f(a,b.name,{enumerable:!0,configurable:!0,value:b.newValue,writable:!0}):a[b.name]=b.newValue},k=function(a,b){if("__proto__"===b){if(!d.call(a,b))return;if(g)return g(a,b).value}return a[b]};b.exports=function l(){var a,b,c,d,e,f,g=arguments[0],m=1,n=arguments.length,o=!1;for("boolean"==typeof g&&(o=g,g=arguments[1]||{},m=2),(null==g||"object"!=typeof g&&"function"!=typeof g)&&(g={});m<n;++m)if(a=arguments[m],null!=a)for(b in a)c=k(g,b),d=k(a,b),g!==d&&(o&&d&&(i(d)||(e=h(d)))?(e?(e=!1,f=c&&h(c)?c:[]):f=c&&i(c)?c:{},j(g,{name:b,newValue:l(o,f,d)})):"undefined"!=typeof d&&j(g,{name:b,newValue:d}));return g}},{}],43:[function(a,b,c){c.read=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<<h)-1,j=i>>1,k=-7,l=c?e-1:0,m=c?-1:1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?NaN:(n?-1:1)*(1/0);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.write=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<<j)-1,l=k>>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?0:f-1,o=d?1:-1,p=b<0||0===b&&1/b<0?1:0;for(b=Math.abs(b),isNaN(b)||b===1/0?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<<e|h,j+=e;j>0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],44:[function(a,b,c){function d(){throw new Error("setTimeout has not been defined")}function e(){throw new Error("clearTimeout has not been defined")}function f(a){if(l===setTimeout)return setTimeout(a,0);if((l===d||!l)&&setTimeout)return l=setTimeout,setTimeout(a,0);try{return l(a,0)}catch(b){try{return l.call(null,a,0)}catch(b){return l.call(this,a,0)}}}function g(a){if(m===clearTimeout)return clearTimeout(a);if((m===e||!m)&&clearTimeout)return m=clearTimeout,clearTimeout(a);try{return m(a)}catch(b){try{return m.call(null,a)}catch(b){return m.call(this,a)}}}function h(){q&&o&&(q=!1,o.length?p=o.concat(p):r=-1,p.length&&i())}function i(){if(!q){var a=f(h);q=!0;for(var b=p.length;b;){for(o=p,p=[];++r<b;)o&&o[r].run();r=-1,b=p.length}o=null,q=!1,g(a)}}function j(a,b){this.fun=a,this.array=b}function k(){}var l,m,n=b.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:d}catch(a){l=d}try{m="function"==typeof clearTimeout?clearTimeout:e}catch(a){m=e}}();var o,p=[],q=!1,r=-1;n.nextTick=function(a){var b=new Array(arguments.length-1);if(arguments.length>1)for(var c=1;c<arguments.length;c++)b[c-1]=arguments[c];p.push(new j(a,b)),1!==p.length||q||f(i)},j.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,
9
+ n.env={},n.argv=[],n.version="",n.versions={},n.on=k,n.addListener=k,n.once=k,n.off=k,n.removeListener=k,n.removeAllListeners=k,n.emit=k,n.prependListener=k,n.prependOnceListener=k,n.listeners=function(a){return[]},n.binding=function(a){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(a){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},{}],45:[function(b,c,d){(function(b,e){!function(b,e){"object"==typeof d&&"undefined"!=typeof c?c.exports=e():"function"==typeof a&&a.amd?a(e):(b="undefined"!=typeof globalThis?globalThis:b||self).PubNub=e()}(this,function(){"use strict";function a(a,b){function c(){this.constructor=a}if("function"!=typeof b&&null!==b)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");aa(a,b),a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)}function c(a,b){var c={};for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&b.indexOf(d)<0&&(c[d]=a[d]);if(null!=a&&"function"==typeof Object.getOwnPropertySymbols){var e=0;for(d=Object.getOwnPropertySymbols(a);e<d.length;e++)b.indexOf(d[e])<0&&Object.prototype.propertyIsEnumerable.call(a,d[e])&&(c[d[e]]=a[d[e]])}return c}function d(a,b,c,d){return new(c||(c=Promise))(function(e,f){function g(a){try{i(d.next(a))}catch(a){f(a)}}function h(a){try{i(d["throw"](a))}catch(a){f(a)}}function i(a){var b;a.done?e(a.value):(b=a.value,b instanceof c?b:new c(function(a){a(b)})).then(g,h)}i((d=d.apply(a,b||[])).next())})}function f(a,b){function c(a){return function(c){return function(a){if(d)throw new TypeError("Generator is already executing.");for(;h;)try{if(d=1,e&&(f=2&a[0]?e["return"]:a[0]?e["throw"]||((f=e["return"])&&f.call(e),0):e.next)&&!(f=f.call(e,a[1])).done)return f;switch(e=0,f&&(a=[2&a[0],f.value]),a[0]){case 0:case 1:f=a;break;case 4:return h.label++,{value:a[1],done:!1};case 5:h.label++,e=a[1],a=[0];continue;case 7:a=h.ops.pop(),h.trys.pop();continue;default:if(f=h.trys,!((f=f.length>0&&f[f.length-1])||6!==a[0]&&2!==a[0])){h=0;continue}if(3===a[0]&&(!f||a[1]>f[0]&&a[1]<f[3])){h.label=a[1];break}if(6===a[0]&&h.label<f[1]){h.label=f[1],f=a;break}if(f&&h.label<f[2]){h.label=f[2],h.ops.push(a);break}f[2]&&h.ops.pop(),h.trys.pop();continue}a=b.call(c,h)}catch(c){a=[6,c],e=0}finally{d=f=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}var d,e,f,g,h={label:0,sent:function(){if(1&f[0])throw f[1];return f[1]},trys:[],ops:[]};return g={next:c(0),"throw":c(1),"return":c(2)},"function"==typeof Symbol&&(g[Symbol.iterator]=function(){return this}),g}function g(a){var b="function"==typeof Symbol&&Symbol.iterator,c=b&&a[b],d=0;if(c)return c.call(a);if(a&&"number"==typeof a.length)return{next:function(){return a&&d>=a.length&&(a=void 0),{value:a&&a[d++],done:!a}}};throw new TypeError(b?"Object is not iterable.":"Symbol.iterator is not defined.")}function h(a,b){var c="function"==typeof Symbol&&a[Symbol.iterator];if(!c)return a;var d,e,f=c.call(a),g=[];try{for(;(void 0===b||b-- >0)&&!(d=f.next()).done;)g.push(d.value)}catch(a){e={error:a}}finally{try{d&&!d.done&&(c=f["return"])&&c.call(f)}finally{if(e)throw e.error}}return g}function i(a,b,c){if(c||2===arguments.length)for(var d,e=0,f=b.length;e<f;e++)!d&&e in b||(d||(d=Array.prototype.slice.call(b,0,e)),d[e]=b[e]);return a.concat(d||Array.prototype.slice.call(b))}function j(a){function b(){var a=c.charAt(g++),b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a);if(-1===b)throw new Error("Illegal character at ".concat(g,": ").concat(c.charAt(g-1)));return b}for(var c=a.replace(/==?$/,""),d=Math.floor(c.length/4*3),e=new ArrayBuffer(d),f=new Uint8Array(e),g=0,h=0;h<d;h+=3){var i=b(),j=b(),k=b(),l=b(),m=(63&i)<<2|j>>4,n=(15&j)<<4|k>>2,o=(3&k)<<6|l>>0;f[h]=m,64!=k&&(f[h+1]=n),64!=l&&(f[h+2]=o)}return e}function k(a){var b,c=[];for(b=0;b<a.length;b+=1)c[b/4|0]|=a[b]<<24-8*b;return sa.lib.WordArray.create(c,a.length)}function l(a){return encodeURIComponent(a).replace(/[!~*'()]/g,function(a){return"%".concat(a.charCodeAt(0).toString(16).toUpperCase())})}function m(a){return function(a){var b=[];return Object.keys(a).forEach(function(a){return b.push(a)}),b}(a).sort()}function n(a){return(b={message:a}).type="validationError",b.error=!0,b;var b}function o(a,b,c){return a.usePost&&a.usePost(b,c)?a.postURL(b,c):a.usePatch&&a.usePatch(b,c)?a.patchURL(b,c):a.useGetFile&&a.useGetFile(b,c)?a.getFileURL(b,c):a.getURL(b,c)}function p(a){if(a.sdkName)return a.sdkName;var b="PubNub-JS-".concat(a.sdkFamily);a.partnerId&&(b+="-".concat(a.partnerId)),b+="/".concat(a.getVersion());var c=a._getPnsdkSuffix(" ");return c.length>0&&(b+=c),b}function q(a,b,c){return b.usePost&&b.usePost(a,c)?"POST":b.usePatch&&b.usePatch(a,c)?"PATCH":b.useDelete&&b.useDelete(a,c)?"DELETE":b.useGetFile&&b.useGetFile(a,c)?"GETFILE":"GET"}function r(a,b,c,d,e){var f=a.config,g=a.crypto,h=q(a,e,d);c.timestamp=Math.floor((new Date).getTime()/1e3),"PNPublishOperation"===e.getOperation()&&e.usePost&&e.usePost(a,d)&&(h="GET"),"GETFILE"===h&&(h="GET");var i="".concat(h,"\n").concat(f.publishKey,"\n").concat(b,"\n").concat(wa.signPamFromParams(c),"\n");if("POST"===h)i+="string"==typeof(j=e.postPayload(a,d))?j:JSON.stringify(j);else if("PATCH"===h){var j;i+="string"==typeof(j=e.patchPayload(a,d))?j:JSON.stringify(j)}var k="v2.".concat(g.HMACSHA256(i));k=(k=(k=k.replace(/\+/g,"-")).replace(/\//g,"_")).replace(/=+$/,""),c.signature=k}function s(a,b){for(var c=[],d=2;d<arguments.length;d++)c[d-2]=arguments[d];var e=a.networking,f=a.config,g=a.telemetryManager,h=a.tokenManager,i=ma(),j=null,k=null,l={};b.getOperation()===za.PNTimeOperation||b.getOperation()===za.PNChannelGroupsOperation?j=c[0]:(l=c[0],j=c[1]),"undefined"==typeof Promise||j||(k=wa.createPromise());var m=b.validateParams(a,l);if(m)return j?j(n(m)):k?(k.reject(new Ia("Validation failed, check status for details",n(m))),k.promise):void 0;var s,t=b.prepareParams(a,l),u=o(b,a,l),v={url:u,operation:b.getOperation(),timeout:b.getRequestTimeout(a),headers:b.getRequestHeaders?b.getRequestHeaders():{},ignoreBody:"function"==typeof b.ignoreBody&&b.ignoreBody(a),forceBuffered:"function"==typeof b.forceBuffered?b.forceBuffered(a,l):null,abortSignal:"function"==typeof b.getAbortSignal?b.getAbortSignal(a,l):null};t.uuid=f.UUID,t.pnsdk=p(f);var w=g.operationsLatencyForRequest();if(Object.keys(w).length&&(t=ba(ba({},t),w)),f.useInstanceId&&(t.instanceid=f.instanceId),f.useRequestId&&(t.requestid=i),b.isAuthSupported()){var x=h.getToken()||f.getAuthKey();x&&(t.auth=x)}f.secretKey&&r(a,u,t,l,b);var y=function(c,d){if(c.error)return b.handleError&&b.handleError(a,l,c),void(j?j(c):k&&k.reject(new Ia("PubNub call failed, check status for details",c)));g.stopLatencyMeasure(b.getOperation(),i);var e=b.handleResponse(a,d,l);"function"!=typeof(null==e?void 0:e.then)&&(e=Promise.resolve(e)),e.then(function(a){j?j(c,a):k&&k.fulfill(a)})["catch"](function(a){if(j){var c=a;b.getOperation()===za.PNSubscribeOperation&&(c={statusCode:400,error:!0,operation:b.getOperation(),errorData:a,category:xa.PNUnknownCategory}),j(c,null)}else k&&k.reject(new Ia("PubNub call failed, check status for details",a))})};if(g.startLatencyMeasure(b.getOperation(),i),"POST"===q(a,b,l)){var z=b.postPayload(a,l);s=e.POST(t,z,v,y)}else"PATCH"===q(a,b,l)?(z=b.patchPayload(a,l),s=e.PATCH(t,z,v,y)):s="DELETE"===q(a,b,l)?e.DELETE(t,v,y):"GETFILE"===q(a,b,l)?e.GETFILE(t,v,y):e.GET(t,v,y);return b.getOperation()===za.PNSubscribeOperation?s:k?k.promise:void 0}function t(a){var b,c,d,e,f=void 0!==(null==a?void 0:a.authorizedUserId),g=void 0!==(null===(b=null==a?void 0:a.resources)||void 0===b?void 0:b.users),h=void 0!==(null===(c=null==a?void 0:a.resources)||void 0===c?void 0:c.spaces),i=void 0!==(null===(d=null==a?void 0:a.patterns)||void 0===d?void 0:d.users),j=void 0!==(null===(e=null==a?void 0:a.patterns)||void 0===e?void 0:e.spaces);return i||g||j||h||f}function u(a){var b=0;return a.join&&(b|=128),a.update&&(b|=64),a.get&&(b|=32),a["delete"]&&(b|=8),a.manage&&(b|=4),a.write&&(b|=2),a.read&&(b|=1),b}function v(a,b){if(t(b))return function(a,b){var c=b.ttl,d=b.resources,e=b.patterns,f=b.meta,g=b.authorizedUserId,h={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(d){var i=d.users,j=d.spaces,k=d.groups;i&&Object.keys(i).forEach(function(a){h.permissions.resources.uuids[a]=u(i[a])}),j&&Object.keys(j).forEach(function(a){h.permissions.resources.channels[a]=u(j[a])}),k&&Object.keys(k).forEach(function(a){h.permissions.resources.groups[a]=u(k[a])})}if(e){var l=e.users,m=e.spaces,n=e.groups;l&&Object.keys(l).forEach(function(a){h.permissions.patterns.uuids[a]=u(l[a])}),m&&Object.keys(m).forEach(function(a){h.permissions.patterns.channels[a]=u(m[a])}),n&&Object.keys(n).forEach(function(a){h.permissions.patterns.groups[a]=u(n[a])})}return(c||0===c)&&(h.ttl=c),f&&(h.permissions.meta=f),g&&(h.permissions.uuid="".concat(g)),h}(0,b);var c=b.ttl,d=b.resources,e=b.patterns,f=b.meta,g=b.authorized_uuid,h={ttl:0,permissions:{resources:{channels:{},groups:{},uuids:{},users:{},spaces:{}},patterns:{channels:{},groups:{},uuids:{},users:{},spaces:{}},meta:{}}};if(d){var i=d.uuids,j=d.channels,k=d.groups;i&&Object.keys(i).forEach(function(a){h.permissions.resources.uuids[a]=u(i[a])}),j&&Object.keys(j).forEach(function(a){h.permissions.resources.channels[a]=u(j[a])}),k&&Object.keys(k).forEach(function(a){h.permissions.resources.groups[a]=u(k[a])})}if(e){var l=e.uuids,m=e.channels,n=e.groups;l&&Object.keys(l).forEach(function(a){h.permissions.patterns.uuids[a]=u(l[a])}),m&&Object.keys(m).forEach(function(a){h.permissions.patterns.channels[a]=u(m[a])}),n&&Object.keys(n).forEach(function(a){h.permissions.patterns.groups[a]=u(n[a])})}return(c||0===c)&&(h.ttl=c),f&&(h.permissions.meta=f),g&&(h.permissions.uuid="".concat(g)),h}function w(a,b){var c=a.crypto,d=a.config,e=JSON.stringify(b);return d.cipherKey&&(e=c.encrypt(e),e=JSON.stringify(e)),e}function x(a,b){var c=a.config,d=a.crypto;if(!c.cipherKey)return b;try{return d.decrypt(b)}catch(a){return b}}function y(a,b){var c=function(){for(var c=[],d=0;d<arguments.length;d++)c[d]=arguments[d];return{type:a,payload:null==b?void 0:b.apply(void 0,i([],h(c),!1))}};return c.type=a,c}function z(a,b){var c=function(){for(var c=[],d=0;d<arguments.length;d++)c[d]=arguments[d];return{type:a,payload:b.apply(void 0,i([],h(c),!1)),managed:!0}};return c.type=a,c.cancel={type:"CANCEL",payload:a,managed:!1},c}function A(a){var b=function(a){return a&&"object"==typeof a&&a.constructor===Object};if(!b(a))return a;var c={};return Object.keys(a).forEach(function(d){var e=function(a){return"string"==typeof a||a instanceof String}(d),f=d,g=a[d];Array.isArray(d)||e&&d.indexOf(",")>=0?f=(e?d.split(","):d).reduce(function(a,b){return a+=String.fromCharCode(b)},""):(function(a){return"number"==typeof a&&isFinite(a)}(d)||e&&!isNaN(d))&&(f=String.fromCharCode(e?parseInt(d,10):10)),c[f]=b(g)?A(g):g}),c}function B(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function C(a,b,c,d){var e;void 0===d&&(d=B()),E(a,"",0,[],void 0,0,d);try{e=0===Ac.length?JSON.stringify(a,b,c):JSON.stringify(a,I(b),c)}catch(a){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==zc.length;){var f=zc.pop();4===f.length?Object.defineProperty(f[0],f[1],f[3]):f[0][f[1]]=f[2]}}return e}function D(a,b,c,d){var e=Object.getOwnPropertyDescriptor(d,c);void 0!==e.get?e.configurable?(Object.defineProperty(d,c,{value:a}),zc.push([d,c,b,e])):Ac.push([b,c,a]):(d[c]=a,zc.push([d,c,b]))}function E(a,b,c,d,e,f,g){var h;if(f+=1,"object"==typeof a&&null!==a){for(h=0;h<d.length;h++)if(d[h]===a)return void D(yc,a,b,e);if(void 0!==g.depthLimit&&f>g.depthLimit)return void D(xc,a,b,e);if(void 0!==g.edgesLimit&&c+1>g.edgesLimit)return void D(xc,a,b,e);if(d.push(a),Array.isArray(a))for(h=0;h<a.length;h++)E(a[h],h,h,d,a,f,g);else{var i=Object.keys(a);for(h=0;h<i.length;h++){var j=i[h];E(a[j],j,h,d,a,f,g)}}d.pop()}}function F(a,b){return a<b?-1:a>b?1:0}function G(a,b,c,d){void 0===d&&(d=B());var e,f=H(a,"",0,[],void 0,0,d)||a;try{e=0===Ac.length?JSON.stringify(f,b,c):JSON.stringify(f,I(b),c)}catch(a){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==zc.length;){var g=zc.pop();4===g.length?Object.defineProperty(g[0],g[1],g[3]):g[0][g[1]]=g[2]}}return e}function H(a,b,c,d,e,f,g){var h;if(f+=1,"object"==typeof a&&null!==a){for(h=0;h<d.length;h++)if(d[h]===a)return void D(yc,a,b,e);try{if("function"==typeof a.toJSON)return}catch(a){return}if(void 0!==g.depthLimit&&f>g.depthLimit)return void D(xc,a,b,e);if(void 0!==g.edgesLimit&&c+1>g.edgesLimit)return void D(xc,a,b,e);if(d.push(a),Array.isArray(a))for(h=0;h<a.length;h++)H(a[h],h,h,d,a,f,g);else{var i={},j=Object.keys(a).sort(F);for(h=0;h<j.length;h++){var k=j[h];H(a[k],k,h,d,a,f,g),i[k]=a[k]}if(void 0===e)return i;zc.push([e,b,a]),e[b]=i}d.pop()}}function I(a){return a=void 0!==a?a:function(a,b){return b},function(b,c){if(Ac.length>0)for(var d=0;d<Ac.length;d++){var e=Ac[d];if(e[1]===b&&e[0]===c){c=e[2],Ac.splice(d,1);break}}return a.call(this,b,c)}}function J(a){return(J="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function K(a){return(K="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function L(a){if(a)return function(a){for(var b in L.prototype)Object.prototype.hasOwnProperty.call(L.prototype,b)&&(a[b]=L.prototype[b]);return a}(a)}function M(a,b){var c;if("undefined"==typeof Symbol||null==a[Symbol.iterator]){if(Array.isArray(a)||(c=function(a,b){if(a){if("string"==typeof a)return N(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?N(a,b):void 0}}(a))||b&&a&&"number"==typeof a.length){c&&(a=c);var d=0,e=function(){};return{s:e,n:function(){return d>=a.length?{done:!0}:{done:!1,value:a[d++]}},e:function(a){throw a},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var f,g=!0,h=!1;return{s:function(){c=a[Symbol.iterator]()},n:function(){var a=c.next();return g=a.done,a},e:function(a){h=!0,f=a},f:function(){try{g||null==c["return"]||c["return"]()}finally{if(h)throw f}}}}function N(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=new Array(b);c<b;c++)d[c]=a[c];return d}function O(a){if(a)return function(a){for(var b in O.prototype)Object.prototype.hasOwnProperty.call(O.prototype,b)&&(a[b]=O.prototype[b]);return a}(a)}function P(a){return function(a){if(Array.isArray(a))return Q(a)}(a)||function(a){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(a))return Array.from(a)}(a)||function(a,b){if(a){if("string"==typeof a)return Q(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?Q(a,b):void 0}}(a)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Q(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=new Array(b);c<b;c++)d[c]=a[c];return d}function R(){this._defaults=[]}function S(a){var b=(new Date).getTime(),c=(new Date).toISOString(),d=console&&console.log?console:window&&window.console&&window.console.log?window.console:console;d.log("<<<<<"),d.log("[".concat(c,"]"),"\n",a.url,"\n",a.qs),d.log("-----"),a.on("response",function(c){var e=(new Date).getTime()-b,f=(new Date).toISOString();d.log(">>>>>>"),d.log("[".concat(f," / ").concat(e,"]"),"\n",a.url,"\n",a.qs,"\n",c.text),d.log("-----")})}function T(a,b,c){var d=this;this._config.logVerbosity&&(a=a.use(S)),this._config.proxy&&this._modules.proxy&&(a=this._modules.proxy.call(this,a)),this._config.keepAlive&&this._modules.keepAlive&&(a=this._modules.keepAlive(a));var e=a;if(b.abortSignal)var f=b.abortSignal.subscribe(function(){e.abort(),f()});return!0===b.forceBuffered?e="undefined"==typeof Blob?e.buffer().responseType("arraybuffer"):e.responseType("arraybuffer"):!1===b.forceBuffered&&(e=e.buffer(!1)),(e=e.timeout(b.timeout)).on("abort",function(){return c({category:xa.PNUnknownCategory,error:!0,operation:b.operation,errorData:new Error("Aborted")},null)}),e.end(function(a,b){var e,f={};if(f.error=null!==a,f.operation=g.operation,b&&b.status&&(f.statusCode=b.status),a){if(a.response&&a.response.text&&!d._config.logVerbosity)try{f.errorData=JSON.parse(a.response.text)}catch(g){f.errorData=a}else f.errorData=a;return f.category=d._detectErrorCategory(a),c(f,null)}if(g.ignoreBody)e={headers:b.headers,redirects:b.redirects,response:b};else try{e=JSON.parse(b.text)}catch(a){return f.errorData=b,f.error=!0,c(f,null)}return e.error&&1===e.error&&e.status&&e.message&&e.service?(f.errorData=e,f.statusCode=e.status,f.error=!0,f.category=d._detectErrorCategory(f),c(f,null)):(e.error&&e.error.message&&(f.errorData=e.error),c(f,e))}),e}function U(a,b,c){return d(this,void 0,void 0,function(){var d;return f(this,function(e){switch(e.label){case 0:return d=nd.post(a),b.forEach(function(a){var b=a.key,c=a.value;d=d.field(b,c)}),d.attach("file",c,{contentType:"application/octet-stream"}),[4,d];case 1:return[2,e.sent()]}})})}function V(a,b,c){var d=nd.get(this.getStandardOrigin()+b.url).set(b.headers).query(a);return T.call(this,d,b,c)}function W(a,b,c){var d=nd.get(this.getStandardOrigin()+b.url).set(b.headers).query(a);return T.call(this,d,b,c)}function X(a,b,c,d){var e=nd.post(this.getStandardOrigin()+c.url).query(a).set(c.headers).send(b);return T.call(this,e,c,d)}function Y(a,b,c,d){var e=nd.patch(this.getStandardOrigin()+c.url).query(a).set(c.headers).send(b);return T.call(this,e,c,d)}function Z(a,b,c){var d=nd["delete"](this.getStandardOrigin()+b.url).set(b.headers).query(a);return T.call(this,d,b,c)}function $(a,b){var c=new Uint8Array(a.byteLength+b.byteLength);return c.set(new Uint8Array(a),0),c.set(new Uint8Array(b),a.byteLength),c.buffer}function _(a){return!(!navigator||!navigator.sendBeacon)&&void navigator.sendBeacon(a)}var aa=function(a,b){return(aa=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,b){a.__proto__=b}||function(a,b){for(var c in b)Object.prototype.hasOwnProperty.call(b,c)&&(a[c]=b[c])})(a,b)},ba=function(){return ba=Object.assign||function(a){for(var b,c=1,d=arguments.length;c<d;c++)for(var e in b=arguments[c])Object.prototype.hasOwnProperty.call(b,e)&&(a[e]=b[e]);return a},ba.apply(this,arguments)},ca="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof b?b:"undefined"!=typeof self?self:{},da={exports:{}};!function(a){!function(b,c){var d=Math.pow(2,-24),e=Math.pow(2,32),f=Math.pow(2,53),g={encode:function(a){function b(a){for(var b=k.byteLength,c=m+a;b<c;)b*=2;if(b!==k.byteLength){var d=l;k=new ArrayBuffer(b),l=new DataView(k);for(var e=m+3>>2,f=0;f<e;++f)l.setUint32(4*f,d.getUint32(4*f))}return j=a,l}function d(){m+=j}function g(a){d(b(1).setUint8(m,a))}function h(a){for(var c=b(a.length),e=0;e<a.length;++e)c.setUint8(m+e,a[e]);d()}function i(a,c){c<24?g(a<<5|c):c<256?(g(a<<5|24),g(c)):c<65536?(g(a<<5|25),function(a){d(b(2).setUint16(m,a))}(c)):c<4294967296?(g(a<<5|26),function(a){d(b(4).setUint32(m,a))}(c)):(g(a<<5|27),function(a){var c=a%e,f=(a-c)/e,g=b(8);g.setUint32(m,f),g.setUint32(m+4,c),d()}(c))}var j,k=new ArrayBuffer(256),l=new DataView(k),m=0;if(function q(a){var e;if(!1===a)return g(244);if(!0===a)return g(245);if(null===a)return g(246);if(a===c)return g(247);switch(typeof a){case"number":if(Math.floor(a)===a){if(0<=a&&a<=f)return i(0,a);if(-f<=a&&a<0)return i(1,-(a+1))}return g(251),function(a){d(b(8).setFloat64(m,a))}(a);case"string":var j=[];for(e=0;e<a.length;++e){var k=a.charCodeAt(e);k<128?j.push(k):k<2048?(j.push(192|k>>6),j.push(128|63&k)):k<55296?(j.push(224|k>>12),j.push(128|k>>6&63),j.push(128|63&k)):(k=(1023&k)<<10,k|=1023&a.charCodeAt(++e),k+=65536,j.push(240|k>>18),j.push(128|k>>12&63),j.push(128|k>>6&63),j.push(128|63&k))}return i(3,j.length),h(j);default:var l;if(Array.isArray(a))for(i(4,l=a.length),e=0;e<l;++e)q(a[e]);else if(a instanceof Uint8Array)i(2,a.length),h(a);else{var n=Object.keys(a);for(i(5,l=n.length),e=0;e<l;++e){var o=n[e];q(o),q(a[o])}}}}(a),"slice"in k)return k.slice(0,m);for(var n=new ArrayBuffer(m),o=new DataView(n),p=0;p<m;++p)o.setUint8(p,l.getUint8(p));return n},decode:function(a,b,f){function g(a,b){return q+=b,a}function h(b){return g(new Uint8Array(a,q,b),b)}function i(){return g(p.getUint8(q),1)}function j(){return g(p.getUint16(q),2)}function k(){return g(p.getUint32(q),4)}function l(){return 255===p.getUint8(q)&&(q+=1,!0)}function m(a){if(a<24)return a;if(24===a)return i();if(25===a)return j();if(26===a)return k();if(27===a)return k()*e+k();if(31===a)return-1;throw"Invalid length encoding"}function n(a){var b=i();if(255===b)return-1;var c=m(31&b);if(c<0||b>>5!==a)throw"Invalid indefinite length element";return c}function o(a,b){for(var c=0;c<b;++c){var d=i();128&d&&(d<224?(d=(31&d)<<6|63&i(),b-=1):d<240?(d=(15&d)<<12|(63&i())<<6|63&i(),b-=2):(d=(15&d)<<18|(63&i())<<12|(63&i())<<6|63&i(),b-=3)),d<65536?a.push(d):(d-=65536,a.push(55296|d>>10),a.push(56320|1023&d))}}var p=new DataView(a),q=0;"function"!=typeof b&&(b=function(a){return a}),"function"!=typeof f&&(f=function(){return c});var r=function s(){var a,e,k=i(),r=k>>5,t=31&k;if(7===r)switch(t){case 25:return function(){var a=new ArrayBuffer(4),b=new DataView(a),c=j(),e=32768&c,f=31744&c,g=1023&c;if(31744===f)f=261120;else if(0!==f)f+=114688;else if(0!==g)return g*d;return b.setUint32(0,e<<16|f<<13|g<<13),b.getFloat32(0)}();case 26:return g(p.getFloat32(q),4);case 27:return g(p.getFloat64(q),8)}if((e=m(t))<0&&(r<2||6<r))throw"Invalid length";switch(r){case 0:return e;case 1:return-1-e;case 2:if(e<0){for(var u=[],v=0;(e=n(r))>=0;)v+=e,u.push(h(e));var w=new Uint8Array(v),x=0;for(a=0;a<u.length;++a)w.set(u[a],x),x+=u[a].length;return w}return h(e);case 3:var y=[];if(e<0)for(;(e=n(r))>=0;)o(y,e);else o(y,e);return String.fromCharCode.apply(null,y);case 4:var z;if(e<0)for(z=[];!l();)z.push(s());else for(z=new Array(e),a=0;a<e;++a)z[a]=s();return z;case 5:var A={};for(a=0;a<e||e<0&&!l();++a)A[s()]=s();return A;case 6:return b(s(),e);case 7:switch(e){case 20:return!1;case 21:return!0;case 22:return null;case 23:return c;default:return f(e)}}}();if(q!==a.byteLength)throw"Remaining bytes";return r}};a.exports?a.exports=g:b.CBOR||(b.CBOR=g)}(ca)}(da);var ea=da.exports,fa={exports:{}};!function(a,b){!function(a){function b(){var a,b,c="";for(a=0;a<32;a++)b=16*Math.random()|0,8!==a&&12!==a&&16!==a&&20!==a||(c+="-"),c+=(12===a?4:16===a?3&b|8:b).toString(16);return c}function c(a,b){var c=e[b||"all"];return c&&c.test(a)||!1}var d="0.1.0",e={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=c,b.VERSION=d,a.uuid=b,a.isUUID=c}(b),null!==a&&(a.exports=b.uuid)}(fa,fa.exports);var ga,ha,ia,ja,ka,la=fa.exports,ma=function(){return la.uuid?la.uuid():la()},na=function(){function a(a){var b,c,d,e=a.setup;if(this._PNSDKSuffix={},this.instanceId="pn-".concat(ma()),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.setCipherKey(e.cipherKey),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(a,b){return"ps".concat(b+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!==(b=e.fileUploadPublishRetryLimit)&&void 0!==b?b:5,this.useRandomIVs=null===(c=e.useRandomIVs)||void 0===c||c,this.enableSubscribeBeta=null!==(d=e.enableSubscribeBeta)&&void 0!==d&&d,"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,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)}}return a.prototype.getAuthKey=function(){return this.authKey},a.prototype.setAuthKey=function(a){return this.authKey=a,this},a.prototype.setCipherKey=function(a){return this.cipherKey=a,this},a.prototype.getUUID=function(){return this.UUID},a.prototype.setUUID=function(a){if(!a||"string"!=typeof a||0===a.trim().length)throw new Error("Missing uuid parameter. Provide a valid string uuid");return this.UUID=a,this},a.prototype.getUserId=function(){return this.UUID},a.prototype.setUserId=function(a){if(!a||"string"!=typeof a||0===a.trim().length)throw new Error("Missing or invalid userId parameter. Provide a valid string userId");return this.UUID=a,this},a.prototype.getFilterExpression=function(){return this.filterExpression},a.prototype.setFilterExpression=function(a){return this.filterExpression=a,this},a.prototype.getPresenceTimeout=function(){return this._presenceTimeout},a.prototype.setPresenceTimeout=function(a){return a>=20?this._presenceTimeout=a:(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},a.prototype.setProxy=function(a){this.proxy=a},a.prototype.getHeartbeatInterval=function(){return this._heartbeatInterval},a.prototype.setHeartbeatInterval=function(a){return this._heartbeatInterval=a,this},a.prototype.getSubscribeTimeout=function(){return this._subscribeRequestTimeout},a.prototype.setSubscribeTimeout=function(a){return this._subscribeRequestTimeout=a,this},a.prototype.getTransactionTimeout=function(){return this._transactionalRequestTimeout},a.prototype.setTransactionTimeout=function(a){return this._transactionalRequestTimeout=a,this},a.prototype.isSendBeaconEnabled=function(){return this._useSendBeacon},a.prototype.setSendBeaconConfig=function(a){return this._useSendBeacon=a,this},a.prototype.getVersion=function(){return"7.3.0"},a.prototype._addPnsdkSuffix=function(a,b){this._PNSDKSuffix[a]=b},a.prototype._getPnsdkSuffix=function(a){var b=this;return Object.keys(this._PNSDKSuffix).reduce(function(c,d){return c+a+b._PNSDKSuffix[d]},"")},a}(),oa=oa||function(a,b){var c={},d=c.lib={},e=function(){},f=d.Base={extend:function(a){e.prototype=this;var b=new e;return a&&b.mixIn(a),b.hasOwnProperty("init")||(b.init=function(){b.$super.init.apply(this,arguments)}),b.init.prototype=b,b.$super=this,b},create:function(){var a=this.extend();return a.init.apply(a,arguments),a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},g=d.WordArray=f.extend({init:function(a,b){a=this.words=a||[],this.sigBytes=null!=b?b:4*a.length},toString:function(a){return(a||i).stringify(this)},concat:function(a){var b=this.words,c=a.words,d=this.sigBytes;if(a=a.sigBytes,this.clamp(),d%4)for(var e=0;e<a;e++)b[d+e>>>2]|=(c[e>>>2]>>>24-e%4*8&255)<<24-(d+e)%4*8;else if(65535<c.length)for(e=0;e<a;e+=4)b[d+e>>>2]=c[e>>>2];else b.push.apply(b,c);return this.sigBytes+=a,this},clamp:function(){var b=this.words,c=this.sigBytes;b[c>>>2]&=4294967295<<32-c%4*8,b.length=a.ceil(c/4)},clone:function(){var a=f.clone.call(this);return a.words=this.words.slice(0),a},random:function(b){for(var c=[],d=0;d<b;d+=4)c.push(4294967296*a.random()|0);return new g.init(c,b)}}),h=c.enc={},i=h.Hex={stringify:function(a){var b=a.words;a=a.sigBytes;for(var c=[],d=0;d<a;d++){var e=b[d>>>2]>>>24-d%4*8&255;c.push((e>>>4).toString(16)),c.push((15&e).toString(16))}return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d<b;d+=2)c[d>>>3]|=parseInt(a.substr(d,2),16)<<24-d%8*4;return new g.init(c,b/2)}},j=h.Latin1={stringify:function(a){var b=a.words;a=a.sigBytes;for(var c=[],d=0;d<a;d++)c.push(String.fromCharCode(b[d>>>2]>>>24-d%4*8&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d<b;d++)c[d>>>2]|=(255&a.charCodeAt(d))<<24-d%4*8;return new g.init(c,b)}},k=h.Utf8={stringify:function(a){try{return decodeURIComponent(escape(j.stringify(a)))}catch(a){throw Error("Malformed UTF-8 data")}},parse:function(a){return j.parse(unescape(encodeURIComponent(a)))}},l=d.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new g.init,this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=k.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,f=this.blockSize,h=e/(4*f);if(b=(h=b?a.ceil(h):a.max((0|h)-this._minBufferSize,0))*f,e=a.min(4*b,e),b){for(var i=0;i<b;i+=f)this._doProcessBlock(d,i);i=d.splice(0,b),c.sigBytes-=e}return new g.init(i,e)},clone:function(){var a=f.clone.call(this);return a._data=this._data.clone(),a},_minBufferSize:0});d.Hasher=l.extend({cfg:f.extend(),init:function(a){this.cfg=this.cfg.extend(a),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(a){return this._append(a),this._process(),this},finalize:function(a){return a&&this._append(a),this._doFinalize()},blockSize:16,_createHelper:function(a){return function(b,c){return new a.init(c).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return new m.HMAC.init(a,c).finalize(b)}}});var m=c.algo={};return c}(Math);!function(a){for(var b=oa,c=(e=b.lib).WordArray,d=e.Hasher,e=b.algo,f=[],g=[],h=function(a){return 4294967296*(a-(0|a))|0},i=2,j=0;64>j;){var k;a:{k=i;for(var l=a.sqrt(k),m=2;m<=l;m++)if(!(k%m)){k=!1;break a}k=!0}k&&(8>j&&(f[j]=h(a.pow(i,.5))),g[j]=h(a.pow(i,1/3)),j++),i++}var n=[];e=e.SHA256=d.extend({_doReset:function(){this._hash=new c.init(f.slice(0))},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],h=c[3],i=c[4],j=c[5],k=c[6],l=c[7],m=0;64>m;m++){if(16>m)n[m]=0|a[b+m];else{var o=n[m-15],p=n[m-2];n[m]=((o<<25|o>>>7)^(o<<14|o>>>18)^o>>>3)+n[m-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+n[m-16];
10
+ }o=l+((i<<26|i>>>6)^(i<<21|i>>>11)^(i<<7|i>>>25))+(i&j^~i&k)+g[m]+n[m],p=((d<<30|d>>>2)^(d<<19|d>>>13)^(d<<10|d>>>22))+(d&e^d&f^e&f),l=k,k=j,j=i,i=h+o|0,h=f,f=e,e=d,d=o+p|0}c[0]=c[0]+d|0,c[1]=c[1]+e|0,c[2]=c[2]+f|0,c[3]=c[3]+h|0,c[4]=c[4]+i|0,c[5]=c[5]+j|0,c[6]=c[6]+k|0,c[7]=c[7]+l|0},_doFinalize:function(){var b=this._data,c=b.words,d=8*this._nDataBytes,e=8*b.sigBytes;return c[e>>>5]|=128<<24-e%32,c[14+(e+64>>>9<<4)]=a.floor(d/4294967296),c[15+(e+64>>>9<<4)]=d,b.sigBytes=4*c.length,this._process(),this._hash},clone:function(){var a=d.clone.call(this);return a._hash=this._hash.clone(),a}}),b.SHA256=d._createHelper(e),b.HmacSHA256=d._createHmacHelper(e)}(Math),ha=(ga=oa).enc.Utf8,ga.algo.HMAC=ga.lib.Base.extend({init:function(a,b){a=this._hasher=new a.init,"string"==typeof b&&(b=ha.parse(b));var c=a.blockSize,d=4*c;b.sigBytes>d&&(b=a.finalize(b)),b.clamp();for(var e=this._oKey=b.clone(),f=this._iKey=b.clone(),g=e.words,h=f.words,i=0;i<c;i++)g[i]^=1549556828,h[i]^=909522486;e.sigBytes=f.sigBytes=d,this.reset()},reset:function(){var a=this._hasher;a.reset(),a.update(this._iKey)},update:function(a){return this._hasher.update(a),this},finalize:function(a){var b=this._hasher;return a=b.finalize(a),b.reset(),b.finalize(this._oKey.clone().concat(a))}}),ja=(ia=oa).lib.WordArray,ia.enc.Base64={stringify:function(a){var b=a.words,c=a.sigBytes,d=this._map;a.clamp(),a=[];for(var e=0;e<c;e+=3)for(var f=(b[e>>>2]>>>24-e%4*8&255)<<16|(b[e+1>>>2]>>>24-(e+1)%4*8&255)<<8|b[e+2>>>2]>>>24-(e+2)%4*8&255,g=0;4>g&&e+.75*g<c;g++)a.push(d.charAt(f>>>6*(3-g)&63));if(b=d.charAt(64))for(;a.length%4;)a.push(b);return a.join("")},parse:function(a){var b=a.length,c=this._map;(d=c.charAt(64))&&-1!=(d=a.indexOf(d))&&(b=d);for(var d=[],e=0,f=0;f<b;f++)if(f%4){var g=c.indexOf(a.charAt(f-1))<<f%4*2,h=c.indexOf(a.charAt(f))>>>6-f%4*2;d[e>>>2]|=(g|h)<<24-e%4*8,e++}return ja.create(d,e)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},function(a){function b(a,b,c,d,e,f,g){return((a=a+(b&c|~b&d)+e+g)<<f|a>>>32-f)+b}function c(a,b,c,d,e,f,g){return((a=a+(b&d|c&~d)+e+g)<<f|a>>>32-f)+b}function d(a,b,c,d,e,f,g){return((a=a+(b^c^d)+e+g)<<f|a>>>32-f)+b}function e(a,b,c,d,e,f,g){return((a=a+(c^(b|~d))+e+g)<<f|a>>>32-f)+b}for(var f=oa,g=(i=f.lib).WordArray,h=i.Hasher,i=f.algo,j=[],k=0;64>k;k++)j[k]=4294967296*a.abs(a.sin(k+1))|0;i=i.MD5=h.extend({_doReset:function(){this._hash=new g.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(a,f){for(var g=0;16>g;g++){var h=a[i=f+g];a[i]=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8)}g=this._hash.words;var i=a[f+0],k=(h=a[f+1],a[f+2]),l=a[f+3],m=a[f+4],n=a[f+5],o=a[f+6],p=a[f+7],q=a[f+8],r=a[f+9],s=a[f+10],t=a[f+11],u=a[f+12],v=a[f+13],w=a[f+14],x=a[f+15],y=b(y=g[0],B=g[1],A=g[2],z=g[3],i,7,j[0]),z=b(z,y,B,A,h,12,j[1]),A=b(A,z,y,B,k,17,j[2]),B=b(B,A,z,y,l,22,j[3]);y=b(y,B,A,z,m,7,j[4]),z=b(z,y,B,A,n,12,j[5]),A=b(A,z,y,B,o,17,j[6]),B=b(B,A,z,y,p,22,j[7]),y=b(y,B,A,z,q,7,j[8]),z=b(z,y,B,A,r,12,j[9]),A=b(A,z,y,B,s,17,j[10]),B=b(B,A,z,y,t,22,j[11]),y=b(y,B,A,z,u,7,j[12]),z=b(z,y,B,A,v,12,j[13]),A=b(A,z,y,B,w,17,j[14]),y=c(y,B=b(B,A,z,y,x,22,j[15]),A,z,h,5,j[16]),z=c(z,y,B,A,o,9,j[17]),A=c(A,z,y,B,t,14,j[18]),B=c(B,A,z,y,i,20,j[19]),y=c(y,B,A,z,n,5,j[20]),z=c(z,y,B,A,s,9,j[21]),A=c(A,z,y,B,x,14,j[22]),B=c(B,A,z,y,m,20,j[23]),y=c(y,B,A,z,r,5,j[24]),z=c(z,y,B,A,w,9,j[25]),A=c(A,z,y,B,l,14,j[26]),B=c(B,A,z,y,q,20,j[27]),y=c(y,B,A,z,v,5,j[28]),z=c(z,y,B,A,k,9,j[29]),A=c(A,z,y,B,p,14,j[30]),y=d(y,B=c(B,A,z,y,u,20,j[31]),A,z,n,4,j[32]),z=d(z,y,B,A,q,11,j[33]),A=d(A,z,y,B,t,16,j[34]),B=d(B,A,z,y,w,23,j[35]),y=d(y,B,A,z,h,4,j[36]),z=d(z,y,B,A,m,11,j[37]),A=d(A,z,y,B,p,16,j[38]),B=d(B,A,z,y,s,23,j[39]),y=d(y,B,A,z,v,4,j[40]),z=d(z,y,B,A,i,11,j[41]),A=d(A,z,y,B,l,16,j[42]),B=d(B,A,z,y,o,23,j[43]),y=d(y,B,A,z,r,4,j[44]),z=d(z,y,B,A,u,11,j[45]),A=d(A,z,y,B,x,16,j[46]),y=e(y,B=d(B,A,z,y,k,23,j[47]),A,z,i,6,j[48]),z=e(z,y,B,A,p,10,j[49]),A=e(A,z,y,B,w,15,j[50]),B=e(B,A,z,y,n,21,j[51]),y=e(y,B,A,z,u,6,j[52]),z=e(z,y,B,A,l,10,j[53]),A=e(A,z,y,B,s,15,j[54]),B=e(B,A,z,y,h,21,j[55]),y=e(y,B,A,z,q,6,j[56]),z=e(z,y,B,A,x,10,j[57]),A=e(A,z,y,B,o,15,j[58]),B=e(B,A,z,y,v,21,j[59]),y=e(y,B,A,z,m,6,j[60]),z=e(z,y,B,A,t,10,j[61]),A=e(A,z,y,B,k,15,j[62]),B=e(B,A,z,y,r,21,j[63]),g[0]=g[0]+y|0,g[1]=g[1]+B|0,g[2]=g[2]+A|0,g[3]=g[3]+z|0},_doFinalize:function(){var b=this._data,c=b.words,d=8*this._nDataBytes,e=8*b.sigBytes;c[e>>>5]|=128<<24-e%32;var f=a.floor(d/4294967296);for(c[15+(e+64>>>9<<4)]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8),c[14+(e+64>>>9<<4)]=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8),b.sigBytes=4*(c.length+1),this._process(),c=(b=this._hash).words,d=0;4>d;d++)e=c[d],c[d]=16711935&(e<<8|e>>>24)|4278255360&(e<<24|e>>>8);return b},clone:function(){var a=h.clone.call(this);return a._hash=this._hash.clone(),a}}),f.MD5=h._createHelper(i),f.HmacMD5=h._createHmacHelper(i)}(Math),function(){var a,b=oa,c=(a=b.lib).Base,d=a.WordArray,e=(a=b.algo).EvpKDF=c.extend({cfg:c.extend({keySize:4,hasher:a.MD5,iterations:1}),init:function(a){this.cfg=this.cfg.extend(a)},compute:function(a,b){for(var c=(h=this.cfg).hasher.create(),e=d.create(),f=e.words,g=h.keySize,h=h.iterations;f.length<g;){i&&c.update(i);var i=c.update(a).finalize(b);c.reset();for(var j=1;j<h;j++)i=c.finalize(i),c.reset();e.concat(i)}return e.sigBytes=4*g,e}});b.EvpKDF=function(a,b,c){return e.create(c).compute(a,b)}}(),oa.lib.Cipher||function(a){var b=(n=oa).lib,c=b.Base,d=b.WordArray,e=b.BufferedBlockAlgorithm,f=n.enc.Base64,g=n.algo.EvpKDF,h=b.Cipher=e.extend({cfg:c.extend(),createEncryptor:function(a,b){return this.create(this._ENC_XFORM_MODE,a,b)},createDecryptor:function(a,b){return this.create(this._DEC_XFORM_MODE,a,b)},init:function(a,b,c){this.cfg=this.cfg.extend(c),this._xformMode=a,this._key=b,this.reset()},reset:function(){e.reset.call(this),this._doReset()},process:function(a){return this._append(a),this._process()},finalize:function(a){return a&&this._append(a),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(a){return{encrypt:function(b,c,d){return("string"==typeof c?o:m).encrypt(a,b,c,d)},decrypt:function(b,c,d){return("string"==typeof c?o:m).decrypt(a,b,c,d)}}}});b.StreamCipher=h.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var i=n.mode={},j=function(a,b,c){var d=this._iv;d?this._iv=void 0:d=this._prevBlock;for(var e=0;e<c;e++)a[b+e]^=d[e]},k=(b.BlockCipherMode=c.extend({createEncryptor:function(a,b){return this.Encryptor.create(a,b)},createDecryptor:function(a,b){return this.Decryptor.create(a,b)},init:function(a,b){this._cipher=a,this._iv=b}})).extend();k.Encryptor=k.extend({processBlock:function(a,b){var c=this._cipher,d=c.blockSize;j.call(this,a,b,d),c.encryptBlock(a,b),this._prevBlock=a.slice(b,b+d)}}),k.Decryptor=k.extend({processBlock:function(a,b){var c=this._cipher,d=c.blockSize,e=a.slice(b,b+d);c.decryptBlock(a,b),j.call(this,a,b,d),this._prevBlock=e}}),i=i.CBC=k,k=(n.pad={}).Pkcs7={pad:function(a,b){for(var c,e=(c=(c=4*b)-a.sigBytes%c)<<24|c<<16|c<<8|c,f=[],g=0;g<c;g+=4)f.push(e);c=d.create(f,c),a.concat(c)},unpad:function(a){a.sigBytes-=255&a.words[a.sigBytes-1>>>2]}},b.BlockCipher=h.extend({cfg:h.cfg.extend({mode:i,padding:k}),reset:function(){h.reset.call(this);var a=(b=this.cfg).iv,b=b.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=b.createEncryptor;else c=b.createDecryptor,this._minBufferSize=1;this._mode=c.call(b,this,a&&a.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var l=b.CipherParams=c.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),m=(i=(n.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;return((a=a.salt)?d.create([1398893684,1701076831]).concat(a).concat(b):b).toString(f)},parse:function(a){var b=(a=f.parse(a)).words;if(1398893684==b[0]&&1701076831==b[1]){var c=d.create(b.slice(2,4));b.splice(0,4),a.sigBytes-=16}return l.create({ciphertext:a,salt:c})}},b.SerializableCipher=c.extend({cfg:c.extend({format:i}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=a.createEncryptor(c,d);return b=e.finalize(b),e=e.cfg,l.create({ciphertext:b,key:c,iv:e.iv,algorithm:a,mode:e.mode,padding:e.padding,blockSize:a.blockSize,formatter:d.format})},decrypt:function(a,b,c,d){return d=this.cfg.extend(d),b=this._parse(b,d.format),a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return"string"==typeof a?b.parse(a,this):a}})),n=(n.kdf={}).OpenSSL={execute:function(a,b,c,e){return e||(e=d.random(8)),a=g.create({keySize:b+c}).compute(a,e),c=d.create(a.words.slice(b),4*c),a.sigBytes=4*b,l.create({key:a,iv:c,salt:e})}},o=b.PasswordBasedCipher=m.extend({cfg:m.cfg.extend({kdf:n}),encrypt:function(a,b,c,d){return c=(d=this.cfg.extend(d)).kdf.execute(c,a.keySize,a.ivSize),d.iv=c.iv,(a=m.encrypt.call(this,a,b,c.key,d)).mixIn(c),a},decrypt:function(a,b,c,d){return d=this.cfg.extend(d),b=this._parse(b,d.format),c=d.kdf.execute(c,a.keySize,a.ivSize,b.salt),d.iv=c.iv,m.decrypt.call(this,a,b,c.key,d)}})}(),function(){for(var a=oa,b=a.lib.BlockCipher,c=a.algo,d=[],e=[],f=[],g=[],h=[],i=[],j=[],k=[],l=[],m=[],n=[],o=0;256>o;o++)n[o]=128>o?o<<1:o<<1^283;var p=0,q=0;for(o=0;256>o;o++){var r=(r=q^q<<1^q<<2^q<<3^q<<4)>>>8^255&r^99;d[p]=r,e[r]=p;var s=n[p],t=n[s],u=n[t],v=257*n[r]^16843008*r;f[p]=v<<24|v>>>8,g[p]=v<<16|v>>>16,h[p]=v<<8|v>>>24,i[p]=v,v=16843009*u^65537*t^257*s^16843008*p,j[r]=v<<24|v>>>8,k[r]=v<<16|v>>>16,l[r]=v<<8|v>>>24,m[r]=v,p?(p=s^n[n[n[u^s]]],q^=n[n[q]]):p=q=1}var w=[0,1,2,4,8,16,32,64,128,27,54];c=c.AES=b.extend({_doReset:function(){for(var a=(c=this._key).words,b=c.sigBytes/4,c=4*((this._nRounds=b+6)+1),e=this._keySchedule=[],f=0;f<c;f++)if(f<b)e[f]=a[f];else{var g=e[f-1];f%b?6<b&&4==f%b&&(g=d[g>>>24]<<24|d[g>>>16&255]<<16|d[g>>>8&255]<<8|d[255&g]):(g=d[(g=g<<8|g>>>24)>>>24]<<24|d[g>>>16&255]<<16|d[g>>>8&255]<<8|d[255&g],g^=w[f/b|0]<<24),e[f]=e[f-b]^g}for(a=this._invKeySchedule=[],b=0;b<c;b++)f=c-b,g=b%4?e[f]:e[f-4],a[b]=4>b||4>=f?g:j[d[g>>>24]]^k[d[g>>>16&255]]^l[d[g>>>8&255]]^m[d[255&g]]},encryptBlock:function(a,b){this._doCryptBlock(a,b,this._keySchedule,f,g,h,i,d)},decryptBlock:function(a,b){var c=a[b+1];a[b+1]=a[b+3],a[b+3]=c,this._doCryptBlock(a,b,this._invKeySchedule,j,k,l,m,e),c=a[b+1],a[b+1]=a[b+3],a[b+3]=c},_doCryptBlock:function(a,b,c,d,e,f,g,h){for(var i=this._nRounds,j=a[b]^c[0],k=a[b+1]^c[1],l=a[b+2]^c[2],m=a[b+3]^c[3],n=4,o=1;o<i;o++){var p=d[j>>>24]^e[k>>>16&255]^f[l>>>8&255]^g[255&m]^c[n++],q=d[k>>>24]^e[l>>>16&255]^f[m>>>8&255]^g[255&j]^c[n++],r=d[l>>>24]^e[m>>>16&255]^f[j>>>8&255]^g[255&k]^c[n++];m=d[m>>>24]^e[j>>>16&255]^f[k>>>8&255]^g[255&l]^c[n++],j=p,k=q,l=r}p=(h[j>>>24]<<24|h[k>>>16&255]<<16|h[l>>>8&255]<<8|h[255&m])^c[n++],q=(h[k>>>24]<<24|h[l>>>16&255]<<16|h[m>>>8&255]<<8|h[255&j])^c[n++],r=(h[l>>>24]<<24|h[m>>>16&255]<<16|h[j>>>8&255]<<8|h[255&k])^c[n++],m=(h[m>>>24]<<24|h[j>>>16&255]<<16|h[k>>>8&255]<<8|h[255&l])^c[n++],a[b]=p,a[b+1]=q,a[b+2]=r,a[b+3]=m},keySize:8}),a.AES=b._createHelper(c)}(),oa.mode.ECB=((ka=oa.lib.BlockCipherMode.extend()).Encryptor=ka.extend({processBlock:function(a,b){this._cipher.encryptBlock(a,b)}}),ka.Decryptor=ka.extend({processBlock:function(a,b){this._cipher.decryptBlock(a,b)}}),ka);var pa,qa,ra,sa=oa,ta=function(){function a(a){var b=a.config;this._config=b,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"}}return a.prototype.HMACSHA256=function(a){return sa.HmacSHA256(a,this._config.secretKey).toString(sa.enc.Base64)},a.prototype.SHA256=function(a){return sa.SHA256(a).toString(sa.enc.Hex)},a.prototype._parseOptions=function(a){var b=a||{};return b.hasOwnProperty("encryptKey")||(b.encryptKey=this._defaultOptions.encryptKey),b.hasOwnProperty("keyEncoding")||(b.keyEncoding=this._defaultOptions.keyEncoding),b.hasOwnProperty("keyLength")||(b.keyLength=this._defaultOptions.keyLength),b.hasOwnProperty("mode")||(b.mode=this._defaultOptions.mode),-1===this._allowedKeyEncodings.indexOf(b.keyEncoding.toLowerCase())&&(b.keyEncoding=this._defaultOptions.keyEncoding),-1===this._allowedKeyLengths.indexOf(parseInt(b.keyLength,10))&&(b.keyLength=this._defaultOptions.keyLength),-1===this._allowedModes.indexOf(b.mode.toLowerCase())&&(b.mode=this._defaultOptions.mode),b},a.prototype._decodeKey=function(a,b){return"base64"===b.keyEncoding?sa.enc.Base64.parse(a):"hex"===b.keyEncoding?sa.enc.Hex.parse(a):a},a.prototype._getPaddedKey=function(a,b){return a=this._decodeKey(a,b),b.encryptKey?sa.enc.Utf8.parse(this.SHA256(a).slice(0,32)):a},a.prototype._getMode=function(a){return"ecb"===a.mode?sa.mode.ECB:sa.mode.CBC},a.prototype._getIV=function(a){return"cbc"===a.mode?sa.enc.Utf8.parse(this._iv):null},a.prototype._getRandomIV=function(){return sa.lib.WordArray.random(16)},a.prototype.encrypt=function(a,b,c){return this._config.customEncrypt?this._config.customEncrypt(a):this.pnEncrypt(a,b,c)},a.prototype.decrypt=function(a,b,c){return this._config.customDecrypt?this._config.customDecrypt(a):this.pnDecrypt(a,b,c)},a.prototype.pnEncrypt=function(a,b,c){if(!b&&!this._config.cipherKey)return a;c=this._parseOptions(c);var d=this._getMode(c),e=this._getPaddedKey(b||this._config.cipherKey,c);if(this._config.useRandomIVs){var f=this._getRandomIV(),g=sa.AES.encrypt(a,e,{iv:f,mode:d}).ciphertext;return f.clone().concat(g.clone()).toString(sa.enc.Base64)}var h=this._getIV(c);return sa.AES.encrypt(a,e,{iv:h,mode:d}).ciphertext.toString(sa.enc.Base64)||a},a.prototype.pnDecrypt=function(a,b,c){if(!b&&!this._config.cipherKey)return a;c=this._parseOptions(c);var d=this._getMode(c),e=this._getPaddedKey(b||this._config.cipherKey,c);if(this._config.useRandomIVs){var f=k((i=new Uint8ClampedArray(j(a))).slice(0,16)),g=k(i.slice(16));try{var h=sa.AES.decrypt({ciphertext:g},e,{iv:f,mode:d}).toString(sa.enc.Utf8);return JSON.parse(h)}catch(a){return null}}else{f=this._getIV(c);try{var i=sa.enc.Base64.parse(a);return h=sa.AES.decrypt({ciphertext:i},e,{iv:f,mode:d}).toString(sa.enc.Utf8),JSON.parse(h)}catch(a){return null}}},a}(),ua=function(){function a(a){var b=a.timeEndpoint;this._timeEndpoint=b}return a.prototype.onReconnection=function(a){this._reconnectionCallback=a},a.prototype.startPolling=function(){this._timeTimer=setInterval(this._performTimeLoop.bind(this),3e3)},a.prototype.stopPolling=function(){clearInterval(this._timeTimer)},a.prototype._performTimeLoop=function(){var a=this;this._timeEndpoint(function(b){b.error||(clearInterval(a._timeTimer),a._reconnectionCallback())})},a}(),va=function(){function a(a){var b=a.config;this.hashHistory=[],this._config=b}return a.prototype.getKey=function(a){var b=function(a){var b=0;if(0===a.length)return b;for(var c=0;c<a.length;c+=1)b=(b<<5)-b+a.charCodeAt(c),b&=b;return b}(JSON.stringify(a.payload)).toString(),c=a.publishMetaData.publishTimetoken;return"".concat(c,"-").concat(b)},a.prototype.isDuplicate=function(a){return this.hashHistory.includes(this.getKey(a))},a.prototype.addEntry=function(a){this.hashHistory.length>=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(a))},a.prototype.clearHistory=function(){this.hashHistory=[]},a}(),wa={signPamFromParams:function(a){return m(a).map(function(b){return"".concat(b,"=").concat(l(a[b]))}).join("&")},endsWith:function(a,b){return-1!==a.indexOf(b,this.length-b.length)},createPromise:function(){var a,b;return{promise:new Promise(function(c,d){a=c,b=d}),reject:b,fulfill:a}},encodeString:l},xa={PNNetworkUpCategory:"PNNetworkUpCategory",PNNetworkDownCategory:"PNNetworkDownCategory",PNNetworkIssuesCategory:"PNNetworkIssuesCategory",PNTimeoutCategory:"PNTimeoutCategory",PNBadRequestCategory:"PNBadRequestCategory",PNAccessDeniedCategory:"PNAccessDeniedCategory",PNUnknownCategory:"PNUnknownCategory",PNReconnectedCategory:"PNReconnectedCategory",PNConnectedCategory:"PNConnectedCategory",PNRequestMessageCountExceededCategory:"PNRequestMessageCountExceededCategory"},ya=function(){function a(a){var b=a.subscribeEndpoint,c=a.leaveEndpoint,d=a.heartbeatEndpoint,e=a.setStateEndpoint,f=a.timeEndpoint,g=a.getFileUrl,h=a.config,i=a.crypto,j=a.listenerManager;this._listenerManager=j,this._config=h,this._leaveEndpoint=c,this._heartbeatEndpoint=d,this._setStateEndpoint=e,this._subscribeEndpoint=b,this._getFileUrl=g,this._crypto=i,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 ua({timeEndpoint:f}),this._dedupingManager=new va({config:h})}return a.prototype.adaptStateChange=function(a,b){var c=this,d=a.state,e=a.channels,f=void 0===e?[]:e,g=a.channelGroups,h=void 0===g?[]:g,i=a.withHeartbeat,j=void 0!==i&&i;if(f.forEach(function(a){a in c._channels&&(c._channels[a].state=d)}),h.forEach(function(a){a in c._channelGroups&&(c._channelGroups[a].state=d)}),j){var k={};return f.forEach(function(a){return k[a]=d}),h.forEach(function(a){return k[a]=d}),this._heartbeatEndpoint({channels:f,channelGroups:h,state:k},b)}return this._setStateEndpoint({state:d,channels:f,channelGroups:h},b)},a.prototype.adaptPresenceChange=function(a){var b=this,c=a.connected,d=a.channels,e=void 0===d?[]:d,f=a.channelGroups,g=void 0===f?[]:f;c?(e.forEach(function(a){b._heartbeatChannels[a]={state:{}}}),g.forEach(function(a){b._heartbeatChannelGroups[a]={state:{}}})):(e.forEach(function(a){a in b._heartbeatChannels&&delete b._heartbeatChannels[a]}),g.forEach(function(a){a in b._heartbeatChannelGroups&&delete b._heartbeatChannelGroups[a]}),!1===this._config.suppressLeaveEvents&&this._leaveEndpoint({channels:e,channelGroups:g},function(a){b._listenerManager.announceStatus(a)})),this.reconnect()},a.prototype.adaptSubscribeChange=function(a){var b=this,c=a.timetoken,d=a.channels,e=void 0===d?[]:d,f=a.channelGroups,g=void 0===f?[]:f,h=a.withPresence,i=void 0!==h&&h,j=a.withHeartbeats,k=void 0!==j&&j;this._config.subscribeKey&&""!==this._config.subscribeKey?(c&&(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=c),"0"!==this._currentTimetoken&&0!==this._currentTimetoken&&(this._storedTimetoken=this._currentTimetoken,this._currentTimetoken=0),e.forEach(function(a){b._channels[a]={state:{}},i&&(b._presenceChannels[a]={}),(k||b._config.getHeartbeatInterval())&&(b._heartbeatChannels[a]={}),b._pendingChannelSubscriptions.push(a)}),g.forEach(function(a){b._channelGroups[a]={state:{}},i&&(b._presenceChannelGroups[a]={}),(k||b._config.getHeartbeatInterval())&&(b._heartbeatChannelGroups[a]={}),b._pendingChannelGroupSubscriptions.push(a)}),this._subscriptionStatusAnnounced=!1,this.reconnect()):console&&console.log&&console.log("subscribe key missing; aborting subscribe")},a.prototype.adaptUnsubscribeChange=function(a,b){var c=this,d=a.channels,e=void 0===d?[]:d,f=a.channelGroups,g=void 0===f?[]:f,h=[],i=[];e.forEach(function(a){a in c._channels&&(delete c._channels[a],h.push(a),a in c._heartbeatChannels&&delete c._heartbeatChannels[a]),a in c._presenceChannels&&(delete c._presenceChannels[a],h.push(a))}),g.forEach(function(a){a in c._channelGroups&&(delete c._channelGroups[a],i.push(a),a in c._heartbeatChannelGroups&&delete c._heartbeatChannelGroups[a]),a in c._presenceChannelGroups&&(delete c._presenceChannelGroups[a],i.push(a))}),0===h.length&&0===i.length||(!1!==this._config.suppressLeaveEvents||b||this._leaveEndpoint({channels:h,channelGroups:i},function(a){a.affectedChannels=h,a.affectedChannelGroups=i,a.currentTimetoken=c._currentTimetoken,a.lastTimetoken=c._lastTimetoken,c._listenerManager.announceStatus(a)}),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())},a.prototype.unsubscribeAll=function(a){this.adaptUnsubscribeChange({channels:this.getSubscribedChannels(),channelGroups:this.getSubscribedChannelGroups()},a)},a.prototype.getHeartbeatChannels=function(){return Object.keys(this._heartbeatChannels)},a.prototype.getHeartbeatChannelGroups=function(){return Object.keys(this._heartbeatChannelGroups)},a.prototype.getSubscribedChannels=function(){return Object.keys(this._channels)},a.prototype.getSubscribedChannelGroups=function(){return Object.keys(this._channelGroups)},a.prototype.reconnect=function(){this._startSubscribeLoop(),this._registerHeartbeatTimer()},a.prototype.disconnect=function(){this._stopSubscribeLoop(),this._stopHeartbeatTimer(),this._reconnectionManager.stopPolling()},a.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()))},a.prototype._stopHeartbeatTimer=function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=null)},a.prototype._performHeartbeatLoop=function(){var a=this,b=this.getHeartbeatChannels(),c=this.getHeartbeatChannelGroups(),d={};0===b.length&&0===c.length||(this.getSubscribedChannels().forEach(function(b){var c=a._channels[b].state;Object.keys(c).length&&(d[b]=c)}),this.getSubscribedChannelGroups().forEach(function(b){var c=a._channelGroups[b].state;Object.keys(c).length&&(d[b]=c)}),this._heartbeatEndpoint({channels:b,channelGroups:c,state:d},function(b){b.error&&a._config.announceFailedHeartbeats&&a._listenerManager.announceStatus(b),b.error&&a._config.autoNetworkDetection&&a._isOnline&&(a._isOnline=!1,a.disconnect(),a._listenerManager.announceNetworkDown(),a.reconnect()),!b.error&&a._config.announceSuccessfulHeartbeats&&a._listenerManager.announceStatus(b)}.bind(this)))},a.prototype._startSubscribeLoop=function(){var a=this;this._stopSubscribeLoop();var b={},c=[],d=[];if(Object.keys(this._channels).forEach(function(d){var e=a._channels[d].state;Object.keys(e).length&&(b[d]=e),c.push(d)}),Object.keys(this._presenceChannels).forEach(function(a){c.push("".concat(a,"-pnpres"))}),Object.keys(this._channelGroups).forEach(function(c){var e=a._channelGroups[c].state;Object.keys(e).length&&(b[c]=e),d.push(c)}),Object.keys(this._presenceChannelGroups).forEach(function(a){d.push("".concat(a,"-pnpres"))}),0!==c.length||0!==d.length){var e={channels:c,channelGroups:d,state:b,timetoken:this._currentTimetoken,filterExpression:this._config.filterExpression,region:this._region};this._subscribeCall=this._subscribeEndpoint(e,this._processSubscribeResponse.bind(this))}},a.prototype._processSubscribeResponse=function(a,b){var d=this;if(a.error){if(a.errorData&&"Aborted"===a.errorData.message)return;a.category===xa.PNTimeoutCategory?this._startSubscribeLoop():a.category===xa.PNNetworkIssuesCategory?(this.disconnect(),a.error&&this._config.autoNetworkDetection&&this._isOnline&&(this._isOnline=!1,this._listenerManager.announceNetworkDown()),this._reconnectionManager.onReconnection(function(){d._config.autoNetworkDetection&&!d._isOnline&&(d._isOnline=!0,d._listenerManager.announceNetworkUp()),d.reconnect(),d._subscriptionStatusAnnounced=!0;var b={category:xa.PNReconnectedCategory,operation:a.operation,lastTimetoken:d._lastTimetoken,currentTimetoken:d._currentTimetoken};d._listenerManager.announceStatus(b)}),this._reconnectionManager.startPolling(),this._listenerManager.announceStatus(a)):a.category===xa.PNBadRequestCategory?(this._stopHeartbeatTimer(),this._listenerManager.announceStatus(a)):this._listenerManager.announceStatus(a)}else{if(this._storedTimetoken?(this._currentTimetoken=this._storedTimetoken,this._storedTimetoken=null):(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=b.metadata.timetoken),!this._subscriptionStatusAnnounced){var e={};e.category=xa.PNConnectedCategory,e.operation=a.operation,e.affectedChannels=this._pendingChannelSubscriptions,e.subscribedChannels=this.getSubscribedChannels(),e.affectedChannelGroups=this._pendingChannelGroupSubscriptions,e.lastTimetoken=this._lastTimetoken,e.currentTimetoken=this._currentTimetoken,this._subscriptionStatusAnnounced=!0,this._listenerManager.announceStatus(e),this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[]}var f=b.messages||[],g=this._config,h=g.requestMessageCountThreshold,i=g.dedupeOnSubscribe;if(h&&f.length>=h){var j={};j.category=xa.PNRequestMessageCountExceededCategory,j.operation=a.operation,this._listenerManager.announceStatus(j)}f.forEach(function(a){var b=a.channel,e=a.subscriptionMatch,f=a.publishMetaData;if(b===e&&(e=null),i){if(d._dedupingManager.isDuplicate(a))return;d._dedupingManager.addEntry(a)}if(wa.endsWith(a.channel,"-pnpres"))(o={channel:null,subscription:null}).actualChannel=null!=e?b:null,o.subscribedChannel=null!=e?e:b,b&&(o.channel=b.substring(0,b.lastIndexOf("-pnpres"))),e&&(o.subscription=e.substring(0,e.lastIndexOf("-pnpres"))),o.action=a.payload.action,o.state=a.payload.data,o.timetoken=f.publishTimetoken,o.occupancy=a.payload.occupancy,o.uuid=a.payload.uuid,o.timestamp=a.payload.timestamp,a.payload.join&&(o.join=a.payload.join),a.payload.leave&&(o.leave=a.payload.leave),a.payload.timeout&&(o.timeout=a.payload.timeout),d._listenerManager.announcePresence(o);else if(1===a.messageType)(o={channel:null,subscription:null}).channel=b,o.subscription=e,o.timetoken=f.publishTimetoken,o.publisher=a.issuingClientId,a.userMetadata&&(o.userMetadata=a.userMetadata),o.message=a.payload,d._listenerManager.announceSignal(o);else if(2===a.messageType){if((o={channel:null,subscription:null}).channel=b,o.subscription=e,o.timetoken=f.publishTimetoken,o.publisher=a.issuingClientId,a.userMetadata&&(o.userMetadata=a.userMetadata),o.message={event:a.payload.event,type:a.payload.type,data:a.payload.data},d._listenerManager.announceObjects(o),"uuid"===a.payload.type){var g=d._renameChannelField(o);d._listenerManager.announceUser(ba(ba({},g),{message:ba(ba({},g.message),{event:d._renameEvent(g.message.event),type:"user"})}))}else if("channel"===a.payload.type)g=d._renameChannelField(o),d._listenerManager.announceSpace(ba(ba({},g),{message:ba(ba({},g.message),{event:d._renameEvent(g.message.event),type:"space"})}));else if("membership"===a.payload.type){var h=(g=d._renameChannelField(o)).message.data,j=h.uuid,k=h.channel,l=c(h,["uuid","channel"]);l.user=j,l.space=k,d._listenerManager.announceMembership(ba(ba({},g),{message:ba(ba({},g.message),{event:d._renameEvent(g.message.event),data:l})}))}}else if(3===a.messageType)(o={}).channel=b,o.subscription=e,o.timetoken=f.publishTimetoken,o.publisher=a.issuingClientId,o.data={messageTimetoken:a.payload.data.messageTimetoken,actionTimetoken:a.payload.data.actionTimetoken,type:a.payload.data.type,uuid:a.issuingClientId,value:a.payload.data.value},o.event=a.payload.event,d._listenerManager.announceMessageAction(o);else if(4===a.messageType){(o={}).channel=b,o.subscription=e,o.timetoken=f.publishTimetoken,o.publisher=a.issuingClientId;var m=a.payload;if(d._config.cipherKey){var n=d._crypto.decrypt(a.payload);"object"==typeof n&&null!==n&&(m=n)}a.userMetadata&&(o.userMetadata=a.userMetadata),o.message=m.message,o.file={id:m.file.id,name:m.file.name,url:d._getFileUrl({id:m.file.id,name:m.file.name,channel:b})},d._listenerManager.announceFile(o)}else{var o;(o={channel:null,subscription:null}).actualChannel=null!=e?b:null,o.subscribedChannel=null!=e?e:b,o.channel=b,o.subscription=e,o.timetoken=f.publishTimetoken,o.publisher=a.issuingClientId,a.userMetadata&&(o.userMetadata=a.userMetadata),d._config.cipherKey?o.message=d._crypto.decrypt(a.payload):o.message=a.payload,d._listenerManager.announceMessage(o)}}),this._region=b.metadata.region,this._startSubscribeLoop()}},a.prototype._stopSubscribeLoop=function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)},a.prototype._renameEvent=function(a){return"set"===a?"updated":"removed"},a.prototype._renameChannelField=function(a){var b=a.channel,d=c(a,["channel"]);return d.spaceId=b,d},a}(),za={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"},Aa=function(){function a(a){this._maximumSamplesCount=100,this._trackedLatencies={},this._latencies={},this._maximumSamplesCount=a.maximumSamplesCount||this._maximumSamplesCount}return a.prototype.operationsLatencyForRequest=function(){var a=this,b={};return Object.keys(this._latencies).forEach(function(c){
11
+ var d=a._latencies[c],e=a._averageLatency(d);e>0&&(b["l_".concat(c)]=e)}),b},a.prototype.startLatencyMeasure=function(a,b){a!==za.PNSubscribeOperation&&b&&(this._trackedLatencies[b]=Date.now())},a.prototype.stopLatencyMeasure=function(a,b){if(a!==za.PNSubscribeOperation&&b){var c=this._endpointName(a),d=this._latencies[c],e=this._trackedLatencies[b];d||(this._latencies[c]=[],d=this._latencies[c]),d.push(Date.now()-e),d.length>this._maximumSamplesCount&&d.splice(0,d.length-this._maximumSamplesCount),delete this._trackedLatencies[b]}},a.prototype._averageLatency=function(a){return Math.floor(a.reduce(function(a,b){return a+b},0)/a.length)},a.prototype._endpointName=function(a){var b=null;switch(a){case za.PNPublishOperation:b="pub";break;case za.PNSignalOperation:b="sig";break;case za.PNHistoryOperation:case za.PNFetchMessagesOperation:case za.PNDeleteMessagesOperation:case za.PNMessageCounts:b="hist";break;case za.PNUnsubscribeOperation:case za.PNWhereNowOperation:case za.PNHereNowOperation:case za.PNHeartbeatOperation:case za.PNSetStateOperation:case za.PNGetStateOperation:b="pres";break;case za.PNAddChannelsToGroupOperation:case za.PNRemoveChannelsFromGroupOperation:case za.PNChannelGroupsOperation:case za.PNRemoveGroupOperation:case za.PNChannelsForGroupOperation:b="cg";break;case za.PNPushNotificationEnabledChannelsOperation:case za.PNRemoveAllPushNotificationsOperation:b="push";break;case za.PNCreateUserOperation:case za.PNUpdateUserOperation:case za.PNDeleteUserOperation:case za.PNGetUserOperation:case za.PNGetUsersOperation:case za.PNCreateSpaceOperation:case za.PNUpdateSpaceOperation:case za.PNDeleteSpaceOperation:case za.PNGetSpaceOperation:case za.PNGetSpacesOperation:case za.PNGetMembersOperation:case za.PNUpdateMembersOperation:case za.PNGetMembershipsOperation:case za.PNUpdateMembershipsOperation:b="obj";break;case za.PNAddMessageActionOperation:case za.PNRemoveMessageActionOperation:case za.PNGetMessageActionsOperation:b="msga";break;case za.PNAccessManagerGrant:case za.PNAccessManagerAudit:b="pam";break;case za.PNAccessManagerGrantToken:case za.PNAccessManagerRevokeToken:b="pamv3";break;default:b="time"}return b},a}(),Ba=function(){function a(a,b,c){this._payload=a,this._setDefaultPayloadStructure(),this.title=b,this.body=c}return Object.defineProperty(a.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"title",{set:function(a){this._title=a},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"subtitle",{set:function(a){this._subtitle=a},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"body",{set:function(a){this._body=a},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"badge",{set:function(a){this._badge=a},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"sound",{set:function(a){this._sound=a},enumerable:!1,configurable:!0}),a.prototype._setDefaultPayloadStructure=function(){},a.prototype.toObject=function(){return{}},a}(),Ca=function(b){function c(){return null!==b&&b.apply(this,arguments)||this}return a(c,b),Object.defineProperty(c.prototype,"configurations",{set:function(a){a&&a.length&&(this._configurations=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"notification",{get:function(){return this._payload.aps},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"title",{get:function(){return this._title},set:function(a){a&&a.length&&(this._payload.aps.alert.title=a,this._title=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"subtitle",{get:function(){return this._subtitle},set:function(a){a&&a.length&&(this._payload.aps.alert.subtitle=a,this._subtitle=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"body",{get:function(){return this._body},set:function(a){a&&a.length&&(this._payload.aps.alert.body=a,this._body=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"badge",{get:function(){return this._badge},set:function(a){null!=a&&(this._payload.aps.badge=a,this._badge=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"sound",{get:function(){return this._sound},set:function(a){a&&a.length&&(this._payload.aps.sound=a,this._sound=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"silent",{set:function(a){this._isSilent=a},enumerable:!1,configurable:!0}),c.prototype._setDefaultPayloadStructure=function(){this._payload.aps={alert:{}}},c.prototype.toObject=function(){var a=this,b=ba({},this._payload),c=b.aps,d=c.alert;if(this._isSilent&&(c["content-available"]=1),"apns2"===this._apnsPushType){if(!this._configurations||!this._configurations.length)throw new ReferenceError("APNS2 configuration is missing");var e=[];this._configurations.forEach(function(b){e.push(a._objectFromAPNS2Configuration(b))}),e.length&&(b.pn_push=e)}return d&&Object.keys(d).length||delete c.alert,this._isSilent&&(delete c.alert,delete c.badge,delete c.sound,d={}),this._isSilent||Object.keys(d).length?b:null},c.prototype._objectFromAPNS2Configuration=function(a){var b=this;if(!a.targets||!a.targets.length)throw new ReferenceError("At least one APNS2 target should be provided");var c=[];a.targets.forEach(function(a){c.push(b._objectFromAPNSTarget(a))});var d=a.collapseId,e=a.expirationDate,f={auth_method:"token",targets:c,version:"v2"};return d&&d.length&&(f.collapse_id=d),e&&(f.expiration=e.toISOString()),f},c.prototype._objectFromAPNSTarget=function(a){if(!a.topic||!a.topic.length)throw new TypeError("Target 'topic' undefined.");var b=a.topic,c=a.environment,d=void 0===c?"development":c,e=a.excludedDevices,f=void 0===e?[]:e,g={topic:b,environment:d};return f.length&&(g.excluded_devices=f),g},c}(Ba),Da=function(b){function c(){return null!==b&&b.apply(this,arguments)||this}return a(c,b),Object.defineProperty(c.prototype,"backContent",{get:function(){return this._backContent},set:function(a){a&&a.length&&(this._payload.back_content=a,this._backContent=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"backTitle",{get:function(){return this._backTitle},set:function(a){a&&a.length&&(this._payload.back_title=a,this._backTitle=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"count",{get:function(){return this._count},set:function(a){null!=a&&(this._payload.count=a,this._count=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"title",{get:function(){return this._title},set:function(a){a&&a.length&&(this._payload.title=a,this._title=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"type",{get:function(){return this._type},set:function(a){a&&a.length&&(this._payload.type=a,this._type=a)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"subtitle",{get:function(){return this.backTitle},set:function(a){this.backTitle=a},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"body",{get:function(){return this.backContent},set:function(a){this.backContent=a},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"badge",{get:function(){return this.count},set:function(a){this.count=a},enumerable:!1,configurable:!0}),c.prototype.toObject=function(){return Object.keys(this._payload).length?ba({},this._payload):null},c}(Ba),Ea=function(b){function d(){return null!==b&&b.apply(this,arguments)||this}return a(d,b),Object.defineProperty(d.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"title",{get:function(){return this._title},set:function(a){a&&a.length&&(this._payload.notification.title=a,this._title=a)},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"body",{get:function(){return this._body},set:function(a){a&&a.length&&(this._payload.notification.body=a,this._body=a)},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"sound",{get:function(){return this._sound},set:function(a){a&&a.length&&(this._payload.notification.sound=a,this._sound=a)},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"icon",{get:function(){return this._icon},set:function(a){a&&a.length&&(this._payload.notification.icon=a,this._icon=a)},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"tag",{get:function(){return this._tag},set:function(a){a&&a.length&&(this._payload.notification.tag=a,this._tag=a)},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"silent",{set:function(a){this._isSilent=a},enumerable:!1,configurable:!0}),d.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},d.prototype.toObject=function(){var a=ba({},this._payload.data),b=null,d={};if(Object.keys(this._payload).length>2){var e=this._payload;e.notification,e.data;var f=c(e,["notification","data"]);a=ba(ba({},a),f)}return this._isSilent?a.notification=this._payload.notification:b=this._payload.notification,Object.keys(a).length&&(d.data=a),b&&Object.keys(b).length&&(d.notification=b),Object.keys(d).length?d:null},d}(Ba),Fa=function(){function a(a,b){this._payload={apns:{},mpns:{},fcm:{}},this._title=a,this._body=b,this.apns=new Ca(this._payload.apns,a,b),this.mpns=new Da(this._payload.mpns,a,b),this.fcm=new Ea(this._payload.fcm,a,b)}return Object.defineProperty(a.prototype,"debugging",{set:function(a){this._debugging=a},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"title",{get:function(){return this._title},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"body",{get:function(){return this._body},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"subtitle",{get:function(){return this._subtitle},set:function(a){this._subtitle=a,this.apns.subtitle=a,this.mpns.subtitle=a,this.fcm.subtitle=a},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"badge",{get:function(){return this._badge},set:function(a){this._badge=a,this.apns.badge=a,this.mpns.badge=a,this.fcm.badge=a},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"sound",{get:function(){return this._sound},set:function(a){this._sound=a,this.apns.sound=a,this.mpns.sound=a,this.fcm.sound=a},enumerable:!1,configurable:!0}),a.prototype.buildPayload=function(a){var b={};if(a.includes("apns")||a.includes("apns2")){this.apns._apnsPushType=a.includes("apns")?"apns":"apns2";var c=this.apns.toObject();c&&Object.keys(c).length&&(b.pn_apns=c)}if(a.includes("mpns")){var d=this.mpns.toObject();d&&Object.keys(d).length&&(b.pn_mpns=d)}if(a.includes("fcm")){var e=this.fcm.toObject();e&&Object.keys(e).length&&(b.pn_gcm=e)}return Object.keys(b).length&&this._debugging&&(b.pn_debug=!0),b},a}(),Ga=function(){function a(){this._listeners=[]}return a.prototype.addListener=function(a){this._listeners.push(a)},a.prototype.removeListener=function(a){var b=[];this._listeners.forEach(function(c){c!==a&&b.push(c)}),this._listeners=b},a.prototype.removeAllListeners=function(){this._listeners=[]},a.prototype.announcePresence=function(a){this._listeners.forEach(function(b){b.presence&&b.presence(a)})},a.prototype.announceStatus=function(a){this._listeners.forEach(function(b){b.status&&b.status(a)})},a.prototype.announceMessage=function(a){this._listeners.forEach(function(b){b.message&&b.message(a)})},a.prototype.announceSignal=function(a){this._listeners.forEach(function(b){b.signal&&b.signal(a)})},a.prototype.announceMessageAction=function(a){this._listeners.forEach(function(b){b.messageAction&&b.messageAction(a)})},a.prototype.announceFile=function(a){this._listeners.forEach(function(b){b.file&&b.file(a)})},a.prototype.announceObjects=function(a){this._listeners.forEach(function(b){b.objects&&b.objects(a)})},a.prototype.announceUser=function(a){this._listeners.forEach(function(b){b.user&&b.user(a)})},a.prototype.announceSpace=function(a){this._listeners.forEach(function(b){b.space&&b.space(a)})},a.prototype.announceMembership=function(a){this._listeners.forEach(function(b){b.membership&&b.membership(a)})},a.prototype.announceNetworkUp=function(){var a={};a.category=xa.PNNetworkUpCategory,this.announceStatus(a)},a.prototype.announceNetworkDown=function(){var a={};a.category=xa.PNNetworkDownCategory,this.announceStatus(a)},a}(),Ha=function(){function a(a,b){this._config=a,this._cbor=b}return a.prototype.setToken=function(a){a&&a.length>0?this._token=a:this._token=void 0},a.prototype.getToken=function(){return this._token},a.prototype.extractPermissions=function(a){var b={read:!1,write:!1,manage:!1,"delete":!1,get:!1,update:!1,join:!1};return 128==(128&a)&&(b.join=!0),64==(64&a)&&(b.update=!0),32==(32&a)&&(b.get=!0),8==(8&a)&&(b["delete"]=!0),4==(4&a)&&(b.manage=!0),2==(2&a)&&(b.write=!0),1==(1&a)&&(b.read=!0),b},a.prototype.parseToken=function(a){var b=this,c=this._cbor.decodeToken(a);if(void 0!==c){var d=c.res.uuid?Object.keys(c.res.uuid):[],e=Object.keys(c.res.chan),f=Object.keys(c.res.grp),g=c.pat.uuid?Object.keys(c.pat.uuid):[],h=Object.keys(c.pat.chan),i=Object.keys(c.pat.grp),j={version:c.v,timestamp:c.t,ttl:c.ttl,authorized_uuid:c.uuid},k=d.length>0,l=e.length>0,m=f.length>0;(k||l||m)&&(j.resources={},k&&(j.resources.uuids={},d.forEach(function(a){j.resources.uuids[a]=b.extractPermissions(c.res.uuid[a])})),l&&(j.resources.channels={},e.forEach(function(a){j.resources.channels[a]=b.extractPermissions(c.res.chan[a])})),m&&(j.resources.groups={},f.forEach(function(a){j.resources.groups[a]=b.extractPermissions(c.res.grp[a])})));var n=g.length>0,o=h.length>0,p=i.length>0;return(n||o||p)&&(j.patterns={},n&&(j.patterns.uuids={},g.forEach(function(a){j.patterns.uuids[a]=b.extractPermissions(c.pat.uuid[a])})),o&&(j.patterns.channels={},h.forEach(function(a){j.patterns.channels[a]=b.extractPermissions(c.pat.chan[a])})),p&&(j.patterns.groups={},i.forEach(function(a){j.patterns.groups[a]=b.extractPermissions(c.pat.grp[a])}))),Object.keys(c.meta).length>0&&(j.meta=c.meta),j.signature=c.sig,j}},a}(),Ia=function(b){function c(a,c){var d=this.constructor,e=b.call(this,a)||this;return e.name=e.constructor.name,e.status=c,e.message=a,Object.setPrototypeOf(e,d.prototype),e}return a(c,b),c}(Error),Ja=Object.freeze({__proto__:null,getOperation:function(){return za.PNAddChannelsToGroupOperation},validateParams:function(a,b){var c=b.channels,d=b.channelGroup,e=a.config;return d?c&&0!==c.length?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing Channel Group"},getURL:function(a,b){var c=b.channelGroup,d=a.config;return"/v1/channel-registration/sub-key/".concat(d.subscribeKey,"/channel-group/").concat(wa.encodeString(c))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.channels;return{add:(void 0===c?[]:c).join(",")}},handleResponse:function(){return{}}}),Ka=Object.freeze({__proto__:null,getOperation:function(){return za.PNRemoveChannelsFromGroupOperation},validateParams:function(a,b){var c=b.channels,d=b.channelGroup,e=a.config;return d?c&&0!==c.length?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing Channel Group"},getURL:function(a,b){var c=b.channelGroup,d=a.config;return"/v1/channel-registration/sub-key/".concat(d.subscribeKey,"/channel-group/").concat(wa.encodeString(c))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.channels;return{remove:(void 0===c?[]:c).join(",")}},handleResponse:function(){return{}}}),La=Object.freeze({__proto__:null,getOperation:function(){return za.PNRemoveGroupOperation},validateParams:function(a,b){var c=b.channelGroup,d=a.config;return c?d.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channel Group"},getURL:function(a,b){var c=b.channelGroup,d=a.config;return"/v1/channel-registration/sub-key/".concat(d.subscribeKey,"/channel-group/").concat(wa.encodeString(c),"/remove")},isAuthSupported:function(){return!0},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},prepareParams:function(){return{}},handleResponse:function(){return{}}}),Ma=Object.freeze({__proto__:null,getOperation:function(){return za.PNChannelGroupsOperation},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a){var b=a.config;return"/v1/channel-registration/sub-key/".concat(b.subscribeKey,"/channel-group")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return{groups:b.payload.groups}}}),Na=Object.freeze({__proto__:null,getOperation:function(){return za.PNChannelsForGroupOperation},validateParams:function(a,b){var c=b.channelGroup,d=a.config;return c?d.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channel Group"},getURL:function(a,b){var c=b.channelGroup,d=a.config;return"/v1/channel-registration/sub-key/".concat(d.subscribeKey,"/channel-group/").concat(wa.encodeString(c))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return{channels:b.payload.channels}}}),Oa=Object.freeze({__proto__:null,getOperation:function(){return za.PNPushNotificationEnabledChannelsOperation},validateParams:function(a,b){var c=b.device,d=b.pushGateway,e=b.channels,f=b.topic,g=a.config;return c?d?"apns2"!==d||f?e&&0!==e.length?g.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(a,b){var c=b.device,d=b.pushGateway,e=a.config;return"apns2"===d?"/v2/push/sub-key/".concat(e.subscribeKey,"/devices-apns2/").concat(c):"/v1/push/sub-key/".concat(e.subscribeKey,"/devices/").concat(c)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.pushGateway,d=b.channels,e=void 0===d?[]:d,f=b.environment,g=void 0===f?"development":f,h=b.topic,i={type:c,add:e.join(",")};return"apns2"===c&&delete(i=ba(ba({},i),{environment:g,topic:h})).type,i},handleResponse:function(){return{}}}),Pa=Object.freeze({__proto__:null,getOperation:function(){return za.PNPushNotificationEnabledChannelsOperation},validateParams:function(a,b){var c=b.device,d=b.pushGateway,e=b.channels,f=b.topic,g=a.config;return c?d?"apns2"!==d||f?e&&0!==e.length?g.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(a,b){var c=b.device,d=b.pushGateway,e=a.config;return"apns2"===d?"/v2/push/sub-key/".concat(e.subscribeKey,"/devices-apns2/").concat(c):"/v1/push/sub-key/".concat(e.subscribeKey,"/devices/").concat(c)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.pushGateway,d=b.channels,e=void 0===d?[]:d,f=b.environment,g=void 0===f?"development":f,h=b.topic,i={type:c,remove:e.join(",")};return"apns2"===c&&delete(i=ba(ba({},i),{environment:g,topic:h})).type,i},handleResponse:function(){return{}}}),Qa=Object.freeze({__proto__:null,getOperation:function(){return za.PNPushNotificationEnabledChannelsOperation},validateParams:function(a,b){var c=b.device,d=b.pushGateway,e=b.topic,f=a.config;return c?d?"apns2"!==d||e?f.subscribeKey?void 0:"Missing Subscribe Key":"Missing APNS2 topic":"Missing GW Type (pushGateway: gcm, apns or apns2)":"Missing Device ID (device)"},getURL:function(a,b){var c=b.device,d=b.pushGateway,e=a.config;return"apns2"===d?"/v2/push/sub-key/".concat(e.subscribeKey,"/devices-apns2/").concat(c):"/v1/push/sub-key/".concat(e.subscribeKey,"/devices/").concat(c)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.pushGateway,d=b.environment,e=void 0===d?"development":d,f=b.topic,g={type:c};return"apns2"===c&&delete(g=ba(ba({},g),{environment:e,topic:f})).type,g},handleResponse:function(a,b){return{channels:b}}}),Ra=Object.freeze({__proto__:null,getOperation:function(){return za.PNRemoveAllPushNotificationsOperation},validateParams:function(a,b){var c=b.device,d=b.pushGateway,e=b.topic,f=a.config;return c?d?"apns2"!==d||e?f.subscribeKey?void 0:"Missing Subscribe Key":"Missing APNS2 topic":"Missing GW Type (pushGateway: gcm, apns or apns2)":"Missing Device ID (device)"},getURL:function(a,b){var c=b.device,d=b.pushGateway,e=a.config;return"apns2"===d?"/v2/push/sub-key/".concat(e.subscribeKey,"/devices-apns2/").concat(c,"/remove"):"/v1/push/sub-key/".concat(e.subscribeKey,"/devices/").concat(c,"/remove")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.pushGateway,d=b.environment,e=void 0===d?"development":d,f=b.topic,g={type:c};return"apns2"===c&&delete(g=ba(ba({},g),{environment:e,topic:f})).type,g},handleResponse:function(){return{}}}),Sa=Object.freeze({__proto__:null,getOperation:function(){return za.PNUnsubscribeOperation},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a,b){var c=a.config,d=b.channels,e=void 0===d?[]:d,f=e.length>0?e.join(","):",";return"/v2/presence/sub-key/".concat(c.subscribeKey,"/channel/").concat(wa.encodeString(f),"/leave")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.channelGroups,d=void 0===c?[]:c,e={};return d.length>0&&(e["channel-group"]=d.join(",")),e},handleResponse:function(){return{}}}),Ta=Object.freeze({__proto__:null,getOperation:function(){return za.PNWhereNowOperation},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a,b){var c=a.config,d=b.uuid,e=void 0===d?c.UUID:d;return"/v2/presence/sub-key/".concat(c.subscribeKey,"/uuid/").concat(wa.encodeString(e))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return b.payload?{channels:b.payload.channels}:{channels:[]}}}),Ua=Object.freeze({__proto__:null,getOperation:function(){return za.PNHeartbeatOperation},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a,b){var c=a.config,d=b.channels,e=void 0===d?[]:d,f=e.length>0?e.join(","):",";return"/v2/presence/sub-key/".concat(c.subscribeKey,"/channel/").concat(wa.encodeString(f),"/heartbeat")},isAuthSupported:function(){return!0},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},prepareParams:function(a,b){var c=b.channelGroups,d=void 0===c?[]:c,e=b.state,f=void 0===e?{}:e,g=a.config,h={};return d.length>0&&(h["channel-group"]=d.join(",")),h.state=JSON.stringify(f),h.heartbeat=g.getPresenceTimeout(),h},handleResponse:function(){return{}}}),Va=Object.freeze({__proto__:null,getOperation:function(){return za.PNGetStateOperation},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a,b){var c=a.config,d=b.uuid,e=void 0===d?c.UUID:d,f=b.channels,g=void 0===f?[]:f,h=g.length>0?g.join(","):",";return"/v2/presence/sub-key/".concat(c.subscribeKey,"/channel/").concat(wa.encodeString(h),"/uuid/").concat(e)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.channelGroups,d=void 0===c?[]:c,e={};return d.length>0&&(e["channel-group"]=d.join(",")),e},handleResponse:function(a,b,c){var d=c.channels,e=void 0===d?[]:d,f=c.channelGroups,g=void 0===f?[]:f,h={};return 1===e.length&&0===g.length?h[e[0]]=b.payload:h=b.payload,{channels:h}}}),Wa=Object.freeze({__proto__:null,getOperation:function(){return za.PNSetStateOperation},validateParams:function(a,b){var c=a.config,d=b.state,e=b.channels,f=void 0===e?[]:e,g=b.channelGroups,h=void 0===g?[]:g;return d?c.subscribeKey?0===f.length&&0===h.length?"Please provide a list of channels and/or channel-groups":void 0:"Missing Subscribe Key":"Missing State"},getURL:function(a,b){var c=a.config,d=b.channels,e=void 0===d?[]:d,f=e.length>0?e.join(","):",";return"/v2/presence/sub-key/".concat(c.subscribeKey,"/channel/").concat(wa.encodeString(f),"/uuid/").concat(wa.encodeString(c.UUID),"/data")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.state,d=b.channelGroups,e=void 0===d?[]:d,f={};return f.state=JSON.stringify(c),e.length>0&&(f["channel-group"]=e.join(",")),f},handleResponse:function(a,b){return{state:b.payload}}}),Xa=Object.freeze({__proto__:null,getOperation:function(){return za.PNHereNowOperation},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a,b){var c=a.config,d=b.channels,e=void 0===d?[]:d,f=b.channelGroups,g=void 0===f?[]:f,h="/v2/presence/sub-key/".concat(c.subscribeKey);if(e.length>0||g.length>0){var i=e.length>0?e.join(","):",";h+="/channel/".concat(wa.encodeString(i))}return h},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.channelGroups,d=void 0===c?[]:c,e=b.includeUUIDs,f=void 0===e||e,g=b.includeState,h=void 0!==g&&g,i=b.queryParameters,j=void 0===i?{}:i,k={};return f||(k.disable_uuids=1),h&&(k.state=1),d.length>0&&(k["channel-group"]=d.join(",")),k=ba(ba({},k),j)},handleResponse:function(a,b,c){var d=c.channels,e=void 0===d?[]:d,f=c.channelGroups,g=void 0===f?[]:f,h=c.includeUUIDs,i=void 0===h||h,j=c.includeState,k=void 0!==j&&j;return e.length>1||g.length>0||0===g.length&&0===e.length?function(){var a={};return a.totalChannels=b.payload.total_channels,a.totalOccupancy=b.payload.total_occupancy,a.channels={},Object.keys(b.payload.channels).forEach(function(c){var d=b.payload.channels[c],e=[];return a.channels[c]={occupants:e,name:c,occupancy:d.occupancy},i&&d.uuids.forEach(function(a){k?e.push({state:a.state,uuid:a.uuid}):e.push({state:null,uuid:a})}),a}),a}():function(){var a={},c=[];return a.totalChannels=1,a.totalOccupancy=b.occupancy,a.channels={},a.channels[e[0]]={occupants:c,name:e[0],occupancy:b.occupancy},i&&b.uuids&&b.uuids.forEach(function(a){k?c.push({state:a.state,uuid:a.uuid}):c.push({state:null,uuid:a})}),a}()},handleError:function(a,b,c){402!==c.statusCode||this.getURL(a,b).includes("channel")||(c.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.")}}),Ya=Object.freeze({__proto__:null,getOperation:function(){return za.PNAddMessageActionOperation},validateParams:function(a,b){var c=a.config,d=b.action,e=b.channel;return b.messageTimetoken?c.subscribeKey?e?d?d.value?d.type?d.type.length>15?"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(a,b){var c=a.config,d=b.channel,e=b.messageTimetoken;return"/v1/message-actions/".concat(c.subscribeKey,"/channel/").concat(wa.encodeString(d),"/message/").concat(e)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},getRequestHeaders:function(){return{"Content-Type":"application/json"}},isAuthSupported:function(){return!0},prepareParams:function(){return{}},postPayload:function(a,b){return b.action},handleResponse:function(a,b){return{data:b.data}}}),Za=Object.freeze({__proto__:null,getOperation:function(){return za.PNRemoveMessageActionOperation},validateParams:function(a,b){var c=a.config,d=b.channel,e=b.actionTimetoken;return b.messageTimetoken?e?c.subscribeKey?d?void 0:"Missing message channel":"Missing Subscribe Key":"Missing action timetoken":"Missing message timetoken"},useDelete:function(){return!0},getURL:function(a,b){var c=a.config,d=b.channel,e=b.actionTimetoken,f=b.messageTimetoken;return"/v1/message-actions/".concat(c.subscribeKey,"/channel/").concat(wa.encodeString(d),"/message/").concat(f,"/action/").concat(e)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return{data:b.data}}}),$a=Object.freeze({__proto__:null,getOperation:function(){return za.PNGetMessageActionsOperation},validateParams:function(a,b){var c=a.config,d=b.channel;return c.subscribeKey?d?void 0:"Missing message channel":"Missing Subscribe Key"},getURL:function(a,b){var c=a.config,d=b.channel;return"/v1/message-actions/".concat(c.subscribeKey,"/channel/").concat(wa.encodeString(d))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.limit,d=b.start,e=b.end,f={};return c&&(f.limit=c),d&&(f.start=d),e&&(f.end=e),f},handleResponse:function(a,b){var c={data:b.data,start:null,end:null};return c.data.length&&(c.end=c.data[c.data.length-1].actionTimetoken,c.start=c.data[0].actionTimetoken),c}}),_a={getOperation:function(){return za.PNListFilesOperation},validateParams:function(a,b){if(!(null==b?void 0:b.channel))return"channel can't be empty"},getURL:function(a,b){var c=a.config;return"/v1/files/".concat(c.subscribeKey,"/channels/").concat(wa.encodeString(b.channel),"/files")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c={};return b.limit&&(c.limit=b.limit),b.next&&(c.next=b.next),c},handleResponse:function(a,b){return{status:b.status,data:b.data,next:b.next,count:b.count}}},ab={getOperation:function(){return za.PNGenerateUploadUrlOperation},validateParams:function(a,b){return(null==b?void 0:b.channel)?(null==b?void 0:b.name)?void 0:"name can't be empty":"channel can't be empty"},usePost:function(){return!0},postURL:function(a,b){var c=a.config;return"/v1/files/".concat(c.subscribeKey,"/channels/").concat(wa.encodeString(b.channel),"/generate-upload-url")},postPayload:function(a,b){return{name:b.name}},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return{status:b.status,data:b.data,file_upload_request:b.file_upload_request}}},bb={getOperation:function(){return za.PNPublishFileOperation},validateParams:function(a,b){return(null==b?void 0:b.channel)?(null==b?void 0:b.fileId)?(null==b?void 0:b.fileName)?void 0:"file name can't be empty":"file id can't be empty":"channel can't be empty"},getURL:function(a,b){var c=a.config,d=c.publishKey,e=c.subscribeKey,f=function(a,b){var c=a.crypto,d=a.config,e=JSON.stringify(b);return d.cipherKey&&(e=c.encrypt(e),e=JSON.stringify(e)),e||""}(a,{message:b.message,file:{name:b.fileName,id:b.fileId}});return"/v1/files/publish-file/".concat(d,"/").concat(e,"/0/").concat(wa.encodeString(b.channel),"/0/").concat(wa.encodeString(f))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c={};return b.ttl&&(c.ttl=b.ttl),void 0!==b.storeInHistory&&(c.store=b.storeInHistory?"1":"0"),b.meta&&"object"==typeof b.meta&&(c.meta=JSON.stringify(b.meta)),c},handleResponse:function(a,b){return{timetoken:b[2]}}},cb=function(a){var b=function(a){var b=this,c=a.generateUploadUrl,e=a.publishFile,g=a.modules,h=g.PubNubFile,i=g.config,j=g.cryptography,k=g.networking;return function(a){var g=a.channel,l=a.file,m=a.message,o=a.cipherKey,p=a.meta,q=a.ttl,r=a.storeInHistory;
12
+ return d(b,void 0,void 0,function(){var a,b,d,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q;return f(this,function(f){switch(f.label){case 0:if(!g)throw new Ia("Validation failed, check status for details",n("channel can't be empty"));if(!l)throw new Ia("Validation failed, check status for details",n("file can't be empty"));return a=h.create(l),[4,c({channel:g,name:a.name})];case 1:return b=f.sent(),d=b.file_upload_request,s=d.url,t=d.form_fields,u=b.data,v=u.id,w=u.name,h.supportsEncryptFile&&(null!=o?o:i.cipherKey)?[4,j.encryptFile(null!=o?o:i.cipherKey,a,h)]:[3,3];case 2:a=f.sent(),f.label=3;case 3:x=t,a.mimeType&&(x=t.map(function(b){return"Content-Type"===b.key?{key:b.key,value:a.mimeType}:b})),f.label=4;case 4:return f.trys.push([4,18,,22]),h.supportsFileUri&&l.uri?(A=(z=k).POSTFILE,B=[s,x],[4,a.toFileUri()]):[3,7];case 5:return[4,A.apply(z,B.concat([f.sent()]))];case 6:return y=f.sent(),[3,17];case 7:return h.supportsFile?(D=(C=k).POSTFILE,E=[s,x],[4,a.toFile()]):[3,10];case 8:return[4,D.apply(C,E.concat([f.sent()]))];case 9:return y=f.sent(),[3,17];case 10:return h.supportsBuffer?(G=(F=k).POSTFILE,H=[s,x],[4,a.toBuffer()]):[3,13];case 11:return[4,G.apply(F,H.concat([f.sent()]))];case 12:return y=f.sent(),[3,17];case 13:return h.supportsBlob?(J=(I=k).POSTFILE,K=[s,x],[4,a.toBlob()]):[3,16];case 14:return[4,J.apply(I,K.concat([f.sent()]))];case 15:return y=f.sent(),[3,17];case 16:throw new Error("Unsupported environment");case 17:return[3,22];case 18:return(L=f.sent()).response?[4,(R=L.response,new Promise(function(a){var b="";R.on("data",function(a){b+=a.toString("utf8")}),R.on("end",function(){a(b)})}))]:[3,20];case 19:throw M=f.sent(),N=/<Message>(.*)<\/Message>/gi.exec(M),new Ia(N?"Upload to bucket failed: ".concat(N[1]):"Upload to bucket failed.",L);case 20:throw new Ia("Upload to bucket failed.",L);case 21:return[3,22];case 22:if(204!==y.status)throw new Ia("Upload to bucket was unsuccessful",y);O=i.fileUploadPublishRetryLimit,P=!1,Q={timetoken:"0"},f.label=23;case 23:return f.trys.push([23,25,,26]),[4,e({channel:g,message:m,fileId:v,fileName:w,meta:p,storeInHistory:r,ttl:q})];case 24:return Q=f.sent(),P=!0,[3,26];case 25:return f.sent(),O-=1,[3,26];case 26:if(!P&&O>0)return[3,23];f.label=27;case 27:if(P)return[2,{timetoken:Q.timetoken,id:v,name:w}];throw new Ia("Publish failed. You may want to execute that operation manually using pubnub.publishFile",{channel:g,id:v,name:w})}var R})})}}(a);return function(a,c){var d=b(a);return"function"==typeof c?(d.then(function(a){return c(null,a)})["catch"](function(a){return c(a,null)}),d):d}},db=function(a,b){var c=b.channel,d=b.id,e=b.name,f=a.config,g=a.networking,h=a.tokenManager;if(!c)throw new Ia("Validation failed, check status for details",n("channel can't be empty"));if(!d)throw new Ia("Validation failed, check status for details",n("file id can't be empty"));if(!e)throw new Ia("Validation failed, check status for details",n("file name can't be empty"));var i="/v1/files/".concat(f.subscribeKey,"/channels/").concat(wa.encodeString(c),"/files/").concat(d,"/").concat(e),j={};j.uuid=f.getUUID(),j.pnsdk=p(f);var k=h.getToken()||f.getAuthKey();k&&(j.auth=k),f.secretKey&&r(a,i,j,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var l=Object.keys(j).map(function(a){return"".concat(encodeURIComponent(a),"=").concat(encodeURIComponent(j[a]))}).join("&");return""!==l?"".concat(g.getStandardOrigin()).concat(i,"?").concat(l):"".concat(g.getStandardOrigin()).concat(i)},eb={getOperation:function(){return za.PNDownloadFileOperation},validateParams:function(a,b){return(null==b?void 0:b.channel)?(null==b?void 0:b.name)?(null==b?void 0:b.id)?void 0:"id can't be empty":"name can't be empty":"channel can't be empty"},useGetFile:function(){return!0},getFileURL:function(a,b){var c=a.config;return"/v1/files/".concat(c.subscribeKey,"/channels/").concat(wa.encodeString(b.channel),"/files/").concat(b.id,"/").concat(b.name)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},ignoreBody:function(){return!0},forceBuffered:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b,c){var e=a.PubNubFile,g=a.config,h=a.cryptography;return d(void 0,void 0,void 0,function(){var a,d,i,j;return f(this,function(f){switch(f.label){case 0:return a=b.response.body,e.supportsEncryptFile&&(null!==(d=c.cipherKey)&&void 0!==d?d:g.cipherKey)?[4,h.decrypt(null!==(i=c.cipherKey)&&void 0!==i?i:g.cipherKey,a)]:[3,2];case 1:a=f.sent(),f.label=2;case 2:return[2,e.create({data:a,name:null!==(j=b.response.name)&&void 0!==j?j:c.name,mimeType:b.response.type})]}})})}},fb={getOperation:function(){return za.PNListFilesOperation},validateParams:function(a,b){return(null==b?void 0:b.channel)?(null==b?void 0:b.id)?(null==b?void 0:b.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(a,b){var c=a.config;return"/v1/files/".concat(c.subscribeKey,"/channels/").concat(wa.encodeString(b.channel),"/files/").concat(b.id,"/").concat(b.name)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return{status:b.status}}},gb={getOperation:function(){return za.PNGetAllUUIDMetadataOperation},validateParams:function(){},getURL:function(a){var b=a.config;return"/v2/objects/".concat(b.subscribeKey,"/uuids")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f,g,i,j,k,l,m={include:["status","type"]};return(null==b?void 0:b.include)&&(null===(c=b.include)||void 0===c?void 0:c.customFields)&&m.include.push("custom"),m.include=m.include.join(","),(null===(d=null==b?void 0:b.include)||void 0===d?void 0:d.totalCount)&&(m.count=null===(e=b.include)||void 0===e?void 0:e.totalCount),(null===(f=null==b?void 0:b.page)||void 0===f?void 0:f.next)&&(m.start=null===(g=b.page)||void 0===g?void 0:g.next),(null===(i=null==b?void 0:b.page)||void 0===i?void 0:i.prev)&&(m.end=null===(j=b.page)||void 0===j?void 0:j.prev),(null==b?void 0:b.filter)&&(m.filter=b.filter),m.limit=null!==(k=null==b?void 0:b.limit)&&void 0!==k?k:100,(null==b?void 0:b.sort)&&(m.sort=Object.entries(null!==(l=b.sort)&&void 0!==l?l:{}).map(function(a){var b=h(a,2),c=b[0],d=b[1];return"asc"===d||"desc"===d?"".concat(c,":").concat(d):c})),m},handleResponse:function(a,b){return{status:b.status,data:b.data,totalCount:b.totalCount,next:b.next,prev:b.prev}}},hb={getOperation:function(){return za.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(a,b){var c,d=a.config;return"/v2/objects/".concat(d.subscribeKey,"/uuids/").concat(wa.encodeString(null!==(c=null==b?void 0:b.uuid)&&void 0!==c?c:d.getUUID()))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e=a.config,f={};return f.uuid=null!==(c=null==b?void 0:b.uuid)&&void 0!==c?c:e.getUUID(),f.include=["status","type","custom"],(null==b?void 0:b.include)&&!1===(null===(d=b.include)||void 0===d?void 0:d.customFields)&&f.include.pop(),f.include=f.include.join(","),f},handleResponse:function(a,b){return{status:b.status,data:b.data}}},ib={getOperation:function(){return za.PNSetUUIDMetadataOperation},validateParams:function(a,b){if(!(null==b?void 0:b.data))return"Data cannot be empty"},usePatch:function(){return!0},patchURL:function(a,b){var c,d=a.config;return"/v2/objects/".concat(d.subscribeKey,"/uuids/").concat(wa.encodeString(null!==(c=b.uuid)&&void 0!==c?c:d.getUUID()))},patchPayload:function(a,b){return b.data},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e=a.config,f={};return f.uuid=null!==(c=null==b?void 0:b.uuid)&&void 0!==c?c:e.getUUID(),f.include=["status","type","custom"],(null==b?void 0:b.include)&&!1===(null===(d=b.include)||void 0===d?void 0:d.customFields)&&f.include.pop(),f.include=f.include.join(","),f},handleResponse:function(a,b){return{status:b.status,data:b.data}}},jb={getOperation:function(){return za.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(a,b){var c,d=a.config;return"/v2/objects/".concat(d.subscribeKey,"/uuids/").concat(wa.encodeString(null!==(c=null==b?void 0:b.uuid)&&void 0!==c?c:d.getUUID()))},useDelete:function(){return!0},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d=a.config;return{uuid:null!==(c=null==b?void 0:b.uuid)&&void 0!==c?c:d.getUUID()}},handleResponse:function(a,b){return{status:b.status,data:b.data}}},kb={getOperation:function(){return za.PNGetAllChannelMetadataOperation},validateParams:function(){},getURL:function(a){var b=a.config;return"/v2/objects/".concat(b.subscribeKey,"/channels")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f,g,i,j,k,l,m={include:["status","type"]};return(null==b?void 0:b.include)&&(null===(c=b.include)||void 0===c?void 0:c.customFields)&&m.include.push("custom"),m.include=m.include.join(","),(null===(d=null==b?void 0:b.include)||void 0===d?void 0:d.totalCount)&&(m.count=null===(e=b.include)||void 0===e?void 0:e.totalCount),(null===(f=null==b?void 0:b.page)||void 0===f?void 0:f.next)&&(m.start=null===(g=b.page)||void 0===g?void 0:g.next),(null===(i=null==b?void 0:b.page)||void 0===i?void 0:i.prev)&&(m.end=null===(j=b.page)||void 0===j?void 0:j.prev),(null==b?void 0:b.filter)&&(m.filter=b.filter),m.limit=null!==(k=null==b?void 0:b.limit)&&void 0!==k?k:100,(null==b?void 0:b.sort)&&(m.sort=Object.entries(null!==(l=b.sort)&&void 0!==l?l:{}).map(function(a){var b=h(a,2),c=b[0],d=b[1];return"asc"===d||"desc"===d?"".concat(c,":").concat(d):c})),m},handleResponse:function(a,b){return{status:b.status,data:b.data,totalCount:b.totalCount,prev:b.prev,next:b.next}}},lb={getOperation:function(){return za.PNGetChannelMetadataOperation},validateParams:function(a,b){if(!(null==b?void 0:b.channel))return"Channel cannot be empty"},getURL:function(a,b){var c=a.config;return"/v2/objects/".concat(c.subscribeKey,"/channels/").concat(wa.encodeString(b.channel))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d={include:["status","type","custom"]};return(null==b?void 0:b.include)&&!1===(null===(c=b.include)||void 0===c?void 0:c.customFields)&&d.include.pop(),d.include=d.include.join(","),d},handleResponse:function(a,b){return{status:b.status,data:b.data}}},mb={getOperation:function(){return za.PNSetChannelMetadataOperation},validateParams:function(a,b){return(null==b?void 0:b.channel)?(null==b?void 0:b.data)?void 0:"Data cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(a,b){var c=a.config;return"/v2/objects/".concat(c.subscribeKey,"/channels/").concat(wa.encodeString(b.channel))},patchPayload:function(a,b){return b.data},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d={include:["status","type","custom"]};return(null==b?void 0:b.include)&&!1===(null===(c=b.include)||void 0===c?void 0:c.customFields)&&d.include.pop(),d.include=d.include.join(","),d},handleResponse:function(a,b){return{status:b.status,data:b.data}}},nb={getOperation:function(){return za.PNRemoveChannelMetadataOperation},validateParams:function(a,b){if(!(null==b?void 0:b.channel))return"Channel cannot be empty"},getURL:function(a,b){var c=a.config;return"/v2/objects/".concat(c.subscribeKey,"/channels/").concat(wa.encodeString(b.channel))},useDelete:function(){return!0},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return{status:b.status,data:b.data}}},ob={getOperation:function(){return za.PNGetMembersOperation},validateParams:function(a,b){if(!(null==b?void 0:b.channel))return"UUID cannot be empty"},getURL:function(a,b){var c=a.config;return"/v2/objects/".concat(c.subscribeKey,"/channels/").concat(wa.encodeString(b.channel),"/uuids")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f,g,i,j,k,l,m,n,o,p={include:["uuid.status","uuid.type","type"]};return(null==b?void 0:b.include)&&((null===(c=b.include)||void 0===c?void 0:c.customFields)&&p.include.push("custom"),(null===(d=b.include)||void 0===d?void 0:d.customUUIDFields)&&p.include.push("uuid.custom"),(null===(f=null===(e=b.include)||void 0===e?void 0:e.UUIDFields)||void 0===f||f)&&p.include.push("uuid")),p.include=p.include.join(","),(null===(g=null==b?void 0:b.include)||void 0===g?void 0:g.totalCount)&&(p.count=null===(i=b.include)||void 0===i?void 0:i.totalCount),(null===(j=null==b?void 0:b.page)||void 0===j?void 0:j.next)&&(p.start=null===(k=b.page)||void 0===k?void 0:k.next),(null===(l=null==b?void 0:b.page)||void 0===l?void 0:l.prev)&&(p.end=null===(m=b.page)||void 0===m?void 0:m.prev),(null==b?void 0:b.filter)&&(p.filter=b.filter),p.limit=null!==(n=null==b?void 0:b.limit)&&void 0!==n?n:100,(null==b?void 0:b.sort)&&(p.sort=Object.entries(null!==(o=b.sort)&&void 0!==o?o:{}).map(function(a){var b=h(a,2),c=b[0],d=b[1];return"asc"===d||"desc"===d?"".concat(c,":").concat(d):c})),p},handleResponse:function(a,b){return{status:b.status,data:b.data,totalCount:b.totalCount,prev:b.prev,next:b.next}}},pb={getOperation:function(){return za.PNSetMembersOperation},validateParams:function(a,b){return(null==b?void 0:b.channel)?(null==b?void 0:b.uuids)&&0!==(null==b?void 0:b.uuids.length)?void 0:"UUIDs cannot be empty":"Channel cannot be empty"},usePatch:function(){return!0},patchURL:function(a,b){var c=a.config;return"/v2/objects/".concat(c.subscribeKey,"/channels/").concat(wa.encodeString(b.channel),"/uuids")},patchPayload:function(a,b){var c;return(c={set:[],"delete":[]})[b.type]=b.uuids.map(function(a){return"string"==typeof a?{uuid:{id:a}}:{uuid:{id:a.id},custom:a.custom,status:a.status}}),c},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f,g,i,j,k,l,m={include:["uuid.status","uuid.type","type"]};return(null==b?void 0:b.include)&&((null===(c=b.include)||void 0===c?void 0:c.customFields)&&m.include.push("custom"),(null===(d=b.include)||void 0===d?void 0:d.customUUIDFields)&&m.include.push("uuid.custom"),(null===(e=b.include)||void 0===e?void 0:e.UUIDFields)&&m.include.push("uuid")),m.include=m.include.join(","),(null===(f=null==b?void 0:b.include)||void 0===f?void 0:f.totalCount)&&(m.count=!0),(null===(g=null==b?void 0:b.page)||void 0===g?void 0:g.next)&&(m.start=null===(i=b.page)||void 0===i?void 0:i.next),(null===(j=null==b?void 0:b.page)||void 0===j?void 0:j.prev)&&(m.end=null===(k=b.page)||void 0===k?void 0:k.prev),(null==b?void 0:b.filter)&&(m.filter=b.filter),null!=b.limit&&(m.limit=b.limit),(null==b?void 0:b.sort)&&(m.sort=Object.entries(null!==(l=b.sort)&&void 0!==l?l:{}).map(function(a){var b=h(a,2),c=b[0],d=b[1];return"asc"===d||"desc"===d?"".concat(c,":").concat(d):c})),m},handleResponse:function(a,b){return{status:b.status,data:b.data,totalCount:b.totalCount,prev:b.prev,next:b.next}}},qb={getOperation:function(){return za.PNGetMembershipsOperation},validateParams:function(){},getURL:function(a,b){var c,d=a.config;return"/v2/objects/".concat(d.subscribeKey,"/uuids/").concat(wa.encodeString(null!==(c=null==b?void 0:b.uuid)&&void 0!==c?c:d.getUUID()),"/channels")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f,g,i,j,k,l,m,n,o={include:["channel.status","channel.type","status"]};return(null==b?void 0:b.include)&&((null===(c=b.include)||void 0===c?void 0:c.customFields)&&o.include.push("custom"),(null===(d=b.include)||void 0===d?void 0:d.customChannelFields)&&o.include.push("channel.custom"),(null===(e=b.include)||void 0===e?void 0:e.channelFields)&&o.include.push("channel")),o.include=o.include.join(","),(null===(f=null==b?void 0:b.include)||void 0===f?void 0:f.totalCount)&&(o.count=null===(g=b.include)||void 0===g?void 0:g.totalCount),(null===(i=null==b?void 0:b.page)||void 0===i?void 0:i.next)&&(o.start=null===(j=b.page)||void 0===j?void 0:j.next),(null===(k=null==b?void 0:b.page)||void 0===k?void 0:k.prev)&&(o.end=null===(l=b.page)||void 0===l?void 0:l.prev),(null==b?void 0:b.filter)&&(o.filter=b.filter),o.limit=null!==(m=null==b?void 0:b.limit)&&void 0!==m?m:100,(null==b?void 0:b.sort)&&(o.sort=Object.entries(null!==(n=b.sort)&&void 0!==n?n:{}).map(function(a){var b=h(a,2),c=b[0],d=b[1];return"asc"===d||"desc"===d?"".concat(c,":").concat(d):c})),o},handleResponse:function(a,b){return{status:b.status,data:b.data,totalCount:b.totalCount,prev:b.prev,next:b.next}}},rb={getOperation:function(){return za.PNSetMembershipsOperation},validateParams:function(a,b){if(!(null==b?void 0:b.channels)||0===(null==b?void 0:b.channels.length))return"Channels cannot be empty"},usePatch:function(){return!0},patchURL:function(a,b){var c,d=a.config;return"/v2/objects/".concat(d.subscribeKey,"/uuids/").concat(wa.encodeString(null!==(c=b.uuid)&&void 0!==c?c:d.getUUID()),"/channels")},patchPayload:function(a,b){var c;return(c={set:[],"delete":[]})[b.type]=b.channels.map(function(a){return"string"==typeof a?{channel:{id:a}}:{channel:{id:a.id},custom:a.custom,status:a.status}}),c},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f,g,i,j,k,l,m={include:["channel.status","channel.type","status"]};return(null==b?void 0:b.include)&&((null===(c=b.include)||void 0===c?void 0:c.customFields)&&m.include.push("custom"),(null===(d=b.include)||void 0===d?void 0:d.customChannelFields)&&m.include.push("channel.custom"),(null===(e=b.include)||void 0===e?void 0:e.channelFields)&&m.include.push("channel")),m.include=m.include.join(","),(null===(f=null==b?void 0:b.include)||void 0===f?void 0:f.totalCount)&&(m.count=!0),(null===(g=null==b?void 0:b.page)||void 0===g?void 0:g.next)&&(m.start=null===(i=b.page)||void 0===i?void 0:i.next),(null===(j=null==b?void 0:b.page)||void 0===j?void 0:j.prev)&&(m.end=null===(k=b.page)||void 0===k?void 0:k.prev),(null==b?void 0:b.filter)&&(m.filter=b.filter),null!=b.limit&&(m.limit=b.limit),(null==b?void 0:b.sort)&&(m.sort=Object.entries(null!==(l=b.sort)&&void 0!==l?l:{}).map(function(a){var b=h(a,2),c=b[0],d=b[1];return"asc"===d||"desc"===d?"".concat(c,":").concat(d):c})),m},handleResponse:function(a,b){return{status:b.status,data:b.data,totalCount:b.totalCount,prev:b.prev,next:b.next}}},sb=Object.freeze({__proto__:null,getOperation:function(){return za.PNAccessManagerAudit},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a){var b=a.config;return"/v2/auth/audit/sub-key/".concat(b.subscribeKey)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(a,b){var c=b.channel,d=b.channelGroup,e=b.authKeys,f=void 0===e?[]:e,g={};return c&&(g.channel=c),d&&(g["channel-group"]=d),f.length>0&&(g.auth=f.join(",")),g},handleResponse:function(a,b){return b.payload}}),tb=Object.freeze({__proto__:null,getOperation:function(){return za.PNAccessManagerGrant},validateParams:function(a,b){var c=a.config;return c.subscribeKey?c.publishKey?c.secretKey?null==b.uuids||b.authKeys?null==b.uuids||null==b.channels&&null==b.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(a){var b=a.config;return"/v2/auth/grant/sub-key/".concat(b.subscribeKey)},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(a,b){var c=b.channels,d=void 0===c?[]:c,e=b.channelGroups,f=void 0===e?[]:e,g=b.uuids,h=void 0===g?[]:g,i=b.ttl,j=b.read,k=void 0!==j&&j,l=b.write,m=void 0!==l&&l,n=b.manage,o=void 0!==n&&n,p=b.get,q=void 0!==p&&p,r=b.join,s=void 0!==r&&r,t=b.update,u=void 0!==t&&t,v=b.authKeys,w=void 0===v?[]:v,x=b["delete"],y={};return y.r=k?"1":"0",y.w=m?"1":"0",y.m=o?"1":"0",y.d=x?"1":"0",y.g=q?"1":"0",y.j=s?"1":"0",y.u=u?"1":"0",d.length>0&&(y.channel=d.join(",")),f.length>0&&(y["channel-group"]=f.join(",")),w.length>0&&(y.auth=w.join(",")),h.length>0&&(y["target-uuid"]=h.join(",")),(i||0===i)&&(y.ttl=i),y},handleResponse:function(){return{}}}),ub=Object.freeze({__proto__:null,getOperation:function(){return za.PNAccessManagerGrantToken},extractPermissions:u,validateParams:function(a,b){var c,d,e,f,g,h,i=a.config;if(!i.subscribeKey)return"Missing Subscribe Key";if(!i.publishKey)return"Missing Publish Key";if(!i.secretKey)return"Missing Secret Key";if(!b.resources&&!b.patterns)return"Missing either Resources or Patterns.";var j=void 0!==(null==b?void 0:b.authorized_uuid),k=void 0!==(null===(c=null==b?void 0:b.resources)||void 0===c?void 0:c.uuids),l=void 0!==(null===(d=null==b?void 0:b.resources)||void 0===d?void 0:d.channels),m=void 0!==(null===(e=null==b?void 0:b.resources)||void 0===e?void 0:e.groups),n=void 0!==(null===(f=null==b?void 0:b.patterns)||void 0===f?void 0:f.uuids),o=void 0!==(null===(g=null==b?void 0:b.patterns)||void 0===g?void 0:g.channels),p=void 0!==(null===(h=null==b?void 0:b.patterns)||void 0===h?void 0:h.groups),q=j||k||n||l||o||m||p;return t(b)&&q?"Cannot mix `users`, `spaces` and `authorizedUserId` with `uuids`, `channels`, `groups` and `authorized_uuid`":(!b.resources||b.resources.uuids&&0!==Object.keys(b.resources.uuids).length||b.resources.channels&&0!==Object.keys(b.resources.channels).length||b.resources.groups&&0!==Object.keys(b.resources.groups).length||b.resources.users&&0!==Object.keys(b.resources.users).length||b.resources.spaces&&0!==Object.keys(b.resources.spaces).length)&&(!b.patterns||b.patterns.uuids&&0!==Object.keys(b.patterns.uuids).length||b.patterns.channels&&0!==Object.keys(b.patterns.channels).length||b.patterns.groups&&0!==Object.keys(b.patterns.groups).length||b.patterns.users&&0!==Object.keys(b.patterns.users).length||b.patterns.spaces&&0!==Object.keys(b.patterns.spaces).length)?void 0:"Missing values for either Resources or Patterns."},postURL:function(a){var b=a.config;return"/v3/pam/".concat(b.subscribeKey,"/grant")},usePost:function(){return!0},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(){return{}},postPayload:function(a,b){return v(0,b)},handleResponse:function(a,b){return b.data.token}}),vb={getOperation:function(){return za.PNAccessManagerRevokeToken},validateParams:function(a,b){return a.config.secretKey?b?void 0:"token can't be empty":"Missing Secret Key"},getURL:function(a,b){var c=a.config;return"/v3/pam/".concat(c.subscribeKey,"/grant/").concat(wa.encodeString(b))},useDelete:function(){return!0},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!1},prepareParams:function(a){return{uuid:a.config.getUUID()}},handleResponse:function(a,b){return{status:b.status,data:b.data}}},wb=Object.freeze({__proto__:null,getOperation:function(){return za.PNPublishOperation},validateParams:function(a,b){var c=a.config,d=b.message;return b.channel?d?c.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},usePost:function(a,b){var c=b.sendByPost;return void 0!==c&&c},getURL:function(a,b){var c=a.config,d=b.channel,e=w(a,b.message);return"/publish/".concat(c.publishKey,"/").concat(c.subscribeKey,"/0/").concat(wa.encodeString(d),"/0/").concat(wa.encodeString(e))},postURL:function(a,b){var c=a.config,d=b.channel;return"/publish/".concat(c.publishKey,"/").concat(c.subscribeKey,"/0/").concat(wa.encodeString(d),"/0")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(a,b){return w(a,b.message)},prepareParams:function(a,b){var c=b.meta,d=b.replicate,e=void 0===d||d,f=b.storeInHistory,g=b.ttl,h={};return null!=f&&(h.store=f?"1":"0"),g&&(h.ttl=g),!1===e&&(h.norep="true"),c&&"object"==typeof c&&(h.meta=JSON.stringify(c)),h},handleResponse:function(a,b){return{timetoken:b[2]}}}),xb=Object.freeze({__proto__:null,getOperation:function(){return za.PNSignalOperation},validateParams:function(a,b){var c=a.config,d=b.message;return b.channel?d?c.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},getURL:function(a,b){var c,d=a.config,e=b.channel,f=b.message,g=(c=f,JSON.stringify(c));return"/signal/".concat(d.publishKey,"/").concat(d.subscribeKey,"/0/").concat(wa.encodeString(e),"/0/").concat(wa.encodeString(g))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return{timetoken:b[2]}}}),yb=Object.freeze({__proto__:null,getOperation:function(){return za.PNHistoryOperation},validateParams:function(a,b){var c=b.channel,d=a.config;return c?d.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(a,b){var c=b.channel,d=a.config;return"/v2/history/sub-key/".concat(d.subscribeKey,"/channel/").concat(wa.encodeString(c))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.start,d=b.end,e=b.reverse,f=b.count,g=void 0===f?100:f,h=b.stringifiedTimeToken,i=void 0!==h&&h,j=b.includeMeta,k=void 0!==j&&j,l={include_token:"true"};return l.count=g,c&&(l.start=c),d&&(l.end=d),i&&(l.string_message_token="true"),null!=e&&(l.reverse=e.toString()),k&&(l.include_meta="true"),l},handleResponse:function(a,b){var c={messages:[],startTimeToken:b[1],endTimeToken:b[2]};return Array.isArray(b[0])&&b[0].forEach(function(b){var d={timetoken:b.timetoken,entry:x(a,b.message)};b.meta&&(d.meta=b.meta),c.messages.push(d)}),c}}),zb=Object.freeze({__proto__:null,getOperation:function(){return za.PNDeleteMessagesOperation},validateParams:function(a,b){var c=b.channel,d=a.config;return c?d.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},useDelete:function(){return!0},getURL:function(a,b){var c=b.channel,d=a.config;return"/v3/history/sub-key/".concat(d.subscribeKey,"/channel/").concat(wa.encodeString(c))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.start,d=b.end,e={};return c&&(e.start=c),d&&(e.end=d),e},handleResponse:function(a,b){return b.payload}}),Ab=Object.freeze({__proto__:null,getOperation:function(){return za.PNMessageCounts},validateParams:function(a,b){var c=b.channels,d=b.timetoken,e=b.channelTimetokens,f=a.config;return c?d&&e?"timetoken and channelTimetokens are incompatible together":e&&e.length>1&&c.length!==e.length?"Length of channelTimetokens and channels do not match":f.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"},getURL:function(a,b){var c=b.channels,d=a.config,e=c.join(",");return"/v3/history/sub-key/".concat(d.subscribeKey,"/message-counts/").concat(wa.encodeString(e))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.timetoken,d=b.channelTimetokens,e={};if(d&&1===d.length){var f=h(d,1)[0];e.timetoken=f}else d?e.channelsTimetoken=d.join(","):c&&(e.timetoken=c);return e},handleResponse:function(a,b){return{channels:b.channels}}}),Bb=Object.freeze({__proto__:null,getOperation:function(){return za.PNFetchMessagesOperation},validateParams:function(a,b){var c=b.channels,d=b.includeMessageActions,e=void 0!==d&&d,f=a.config;if(!c||0===c.length)return"Missing channels";if(!f.subscribeKey)return"Missing Subscribe Key";if(e&&c.length>1)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(a,b){var c=b.channels,d=void 0===c?[]:c,e=b.includeMessageActions,f=void 0!==e&&e,g=a.config,h=f?"history-with-actions":"history",i=d.length>0?d.join(","):",";return"/v3/".concat(h,"/sub-key/").concat(g.subscribeKey,"/channel/").concat(wa.encodeString(i))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=b.channels,d=b.start,e=b.end,f=b.includeMessageActions,g=b.count,h=b.stringifiedTimeToken,i=void 0!==h&&h,j=b.includeMeta,k=void 0!==j&&j,l=b.includeUuid,m=b.includeUUID,n=void 0===m||m,o=b.includeMessageType,p=void 0===o||o,q={};return q.max=g||(c.length>1||!0===f?25:100),d&&(q.start=d),e&&(q.end=e),i&&(q.string_message_token="true"),k&&(q.include_meta="true"),n&&!1!==l&&(q.include_uuid="true"),p&&(q.include_message_type="true"),q},handleResponse:function(a,b){var c={channels:{}};return Object.keys(b.channels||{}).forEach(function(d){c.channels[d]=[],(b.channels[d]||[]).forEach(function(b){var e={};e.channel=d,e.timetoken=b.timetoken,e.message=function(a,b){var c=a.config,d=a.crypto;if(!c.cipherKey)return b;try{return d.decrypt(b)}catch(a){return b}}(a,b.message),e.messageType=b.message_type,e.uuid=b.uuid,b.actions&&(e.actions=b.actions,e.data=b.actions),b.meta&&(e.meta=b.meta),c.channels[d].push(e)})}),b.more&&(c.more=b.more),c}}),Cb=Object.freeze({__proto__:null,getOperation:function(){return za.PNTimeOperation},getURL:function(){return"/time/0"},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},prepareParams:function(){return{}},isAuthSupported:function(){return!1},handleResponse:function(a,b){return{timetoken:b[0]}},validateParams:function(){}}),Db=Object.freeze({__proto__:null,getOperation:function(){return za.PNSubscribeOperation},validateParams:function(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"},getURL:function(a,b){var c=a.config,d=b.channels,e=void 0===d?[]:d,f=e.length>0?e.join(","):",";return"/v2/subscribe/".concat(c.subscribeKey,"/").concat(wa.encodeString(f),"/0")},getRequestTimeout:function(a){return a.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c=a.config,d=b.state,e=b.channelGroups,f=void 0===e?[]:e,g=b.timetoken,h=b.filterExpression,i=b.region,j={heartbeat:c.getPresenceTimeout()};return f.length>0&&(j["channel-group"]=f.join(",")),h&&h.length>0&&(j["filter-expr"]=h),Object.keys(d).length&&(j.state=JSON.stringify(d)),g&&(j.tt=g),i&&(j.tr=i),j},handleResponse:function(a,b){var c=[];b.m.forEach(function(a){var b={publishTimetoken:a.p.t,region:a.p.r},d={shard:parseInt(a.a,10),subscriptionMatch:a.b,channel:a.c,messageType:a.e,payload:a.d,flags:a.f,issuingClientId:a.i,subscribeKey:a.k,originationTimetoken:a.o,userMetadata:a.u,publishMetaData:b};c.push(d)});var d={timetoken:b.t.t,region:b.t.r};return{messages:c,metadata:d}}}),Eb={getOperation:function(){return za.PNHandshakeOperation},validateParams:function(a,b){if(!(null==b?void 0:b.channels)&&!(null==b?void 0:b.channelGroups))return"channels and channleGroups both should not be empty"},getURL:function(a,b){var c=a.config,d=b.channels?b.channels.join(","):",";return"/v2/subscribe/".concat(c.subscribeKey,"/").concat(wa.encodeString(d),"/0")},getRequestTimeout:function(a){return a.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c={};return b.channelGroups&&b.channelGroups.length>0&&(c["channel-group"]=b.channelGroups.join(",")),c.tt=0,c},handleResponse:function(a,b){
13
+ return{region:b.t.r,timetoken:b.t.t}}},Fb={getOperation:function(){return za.PNReceiveMessagesOperation},validateParams:function(a,b){return(null==b?void 0:b.channels)||(null==b?void 0:b.channelGroups)?(null==b?void 0:b.timetoken)?(null==b?void 0:b.region)?void 0:"region can not be empty":"timetoken can not be empty":"channels and channleGroups both should not be empty"},getURL:function(a,b){var c=a.config,d=b.channels?b.channels.join(","):",";return"/v2/subscribe/".concat(c.subscribeKey,"/").concat(wa.encodeString(d),"/0")},getRequestTimeout:function(a){return a.config.getSubscribeTimeout()},isAuthSupported:function(){return!0},getAbortSignal:function(a,b){return b.abortSignal},prepareParams:function(a,b){var c={};return b.channelGroups&&b.channelGroups.length>0&&(c["channel-group"]=b.channelGroups.join(",")),c.tt=b.timetoken,c.tr=b.region,c},handleResponse:function(a,b){var c=[];return b.m.forEach(function(a){var b={shard:parseInt(a.a,10),subscriptionMatch:a.b,channel:a.c,messageType:a.e,payload:a.d,flags:a.f,issuingClientId:a.i,subscribeKey:a.k,originationTimetoken:a.o,publishMetaData:{timetoken:a.p.t,region:a.p.r}};c.push(b)}),{messages:c,metadata:{region:b.t.r,timetoken:b.t.t}}}},Gb=function(){function a(a){void 0===a&&(a=!1),this.sync=a,this.listeners=new Set}return a.prototype.subscribe=function(a){var b=this;return this.listeners.add(a),function(){b.listeners["delete"](a)}},a.prototype.notify=function(a){var b=this,c=function(){b.listeners.forEach(function(b){b(a)})};this.sync?c():setTimeout(c,0)},a}(),Hb=function(){function a(a){this.label=a,this.transitionMap=new Map,this.enterEffects=[],this.exitEffects=[]}return a.prototype.transition=function(a,b){var c;if(this.transitionMap.has(b.type))return null===(c=this.transitionMap.get(b.type))||void 0===c?void 0:c(a,b)},a.prototype.on=function(a,b){return this.transitionMap.set(a,b),this},a.prototype["with"]=function(a,b){return[this,a,null!=b?b:[]]},a.prototype.onEnter=function(a){return this.enterEffects.push(a),this},a.prototype.onExit=function(a){return this.exitEffects.push(a),this},a}(),Ib=function(b){function c(){return null!==b&&b.apply(this,arguments)||this}return a(c,b),c.prototype.describe=function(a){return new Hb(a)},c.prototype.start=function(a,b){this.currentState=a,this.currentContext=b,this.notify({type:"engineStarted",state:a,context:b})},c.prototype.transition=function(a){var b,c,d,e,f,i;if(!this.currentState)throw new Error("Start the engine first");this.notify({type:"eventReceived",event:a});var j=this.currentState.transition(this.currentContext,a);if(j){var k=h(j,3),l=k[0],m=k[1],n=k[2];try{for(var o=g(this.currentState.exitEffects),p=o.next();!p.done;p=o.next()){var q=p.value;this.notify({type:"invocationDispatched",invocation:q(this.currentContext)})}}catch(a){b={error:a}}finally{try{p&&!p.done&&(c=o["return"])&&c.call(o)}finally{if(b)throw b.error}}var r=this.currentState;this.currentState=l;var s=this.currentContext;this.currentContext=m,this.notify({type:"transitionDone",fromState:r,fromContext:s,toState:l,toContext:m,event:a});try{for(var t=g(n),u=t.next();!u.done;u=t.next())q=u.value,this.notify({type:"invocationDispatched",invocation:q})}catch(a){d={error:a}}finally{try{u&&!u.done&&(e=t["return"])&&e.call(t)}finally{if(d)throw d.error}}try{for(var v=g(this.currentState.enterEffects),w=v.next();!w.done;w=v.next())q=w.value,this.notify({type:"invocationDispatched",invocation:q(this.currentContext)})}catch(a){f={error:a}}finally{try{w&&!w.done&&(i=v["return"])&&i.call(v)}finally{if(f)throw f.error}}}},c}(Gb),Jb=function(){function a(a){this.dependencies=a,this.instances=new Map,this.handlers=new Map}return a.prototype.on=function(a,b){this.handlers.set(a,b)},a.prototype.dispatch=function(a){if("CANCEL"!==a.type){var b=this.handlers.get(a.type);if(!b)throw new Error("Unhandled invocation '".concat(a.type,"'"));var c=b(a.payload,this.dependencies);a.managed&&this.instances.set(a.type,c),c.start()}else if(this.instances.has(a.payload)){var d=this.instances.get(a.payload);null==d||d.cancel(),this.instances["delete"](a.payload)}},a}(),Kb=function(b){function c(){var a=this.constructor,c=b.call(this,"The operation was aborted.")||this;return c.name="AbortError",Object.setPrototypeOf(c,a.prototype),c}return a(c,b),c}(Error),Lb=function(b){function c(){var a=null!==b&&b.apply(this,arguments)||this;return a._aborted=!1,a}return a(c,b),Object.defineProperty(c.prototype,"aborted",{get:function(){return this._aborted},enumerable:!1,configurable:!0}),c.prototype.throwIfAborted=function(){if(this._aborted)throw new Kb},c.prototype.abort=function(){this._aborted=!0,this.notify(new Kb)},c}(Gb),Mb=function(b){function c(a,c,d){var e=b.call(this,a,c)||this;return e.asyncFunction=d,e.abortSignal=new Lb,e}return a(c,b),c.prototype.start=function(){this.asyncFunction(this.payload,this.abortSignal,this.dependencies)},c.prototype.cancel=function(){this.abortSignal.abort()},c}(function(a,b){this.payload=a,this.dependencies=b}),Nb=function(a){return function(b,c){return new Mb(b,c,a)}},Ob=z("HANDSHAKE",function(a,b){return{channels:a,groups:b}}),Pb=z("RECEIVE_EVENTS",function(a,b,c){return{channels:a,groups:b,cursor:c}}),Qb=(qa=function(a){return a},ra=function(){for(var a=[],b=0;b<arguments.length;b++)a[b]=arguments[b];return{type:pa,payload:qa.apply(void 0,i([],h(a),!1)),managed:!1}},ra.type=pa="EMIT_EVENTS",ra),Rb=z("RECONNECT",function(a){return a}),Sb=z("HANDSHAKE_RECONNECT",function(a){return a}),Tb=y("SUBSCRIPTION_CHANGE",function(a,b){return{channels:a,groups:b}}),Ub=y("DISCONNECT",function(){return{}}),Vb=y("RECONNECT",function(){return{}});y("RESTORE",function(a,b,c,d){return{channels:a,groups:b,timetoken:c,region:d}});var Wb=y("HANDSHAKING_SUCCESS",function(a){return a}),Xb=y("HANDSHAKING_FAILURE",function(a){return a}),Yb=y("HANDSHAKING_RECONNECTING_SUCCESS",function(a){return{cursor:a}}),Zb=y("HANDSHAKING_RECONNECTING_FAILURE",function(a){return a}),$b=y("HANDSHAKING_RECONNECTING_GIVEUP",function(){return{}}),_b=y("HANDSHAKING_RECONNECTING_RETRY",function(){return{}}),ac=y("RECEIVING_SUCCESS",function(a,b){return{cursor:a,events:b}}),bc=y("RECEIVING_FAILURE",function(a){return a}),cc=y("RECONNECTING_SUCCESS",function(a,b){return{cursor:a,events:b}}),dc=y("RECONNECTING_FAILURE",function(a){return a}),ec=y("RECONNECTING_GIVEUP",function(){return{}}),fc=y("RECONNECTING_RETRY",function(){return{}}),gc=function(b){function c(a,c){var e=b.call(this,c)||this;return e.on(Ob.type,Nb(function(b,c,g){var h=g.handshake;return d(e,void 0,void 0,function(){var d,e;return f(this,function(f){switch(f.label){case 0:c.throwIfAborted(),f.label=1;case 1:return f.trys.push([1,3,,4]),[4,h({abortSignal:c,channels:b.channels,channelGroups:b.groups})];case 2:return d=f.sent(),a.transition(Wb(d)),[3,4];case 3:return(e=f.sent())instanceof Error&&"Aborted"===e.message?[2]:e instanceof Ia?[2,a.transition(Xb(e))]:[3,4];case 4:return[2]}})})})),e.on(Pb.type,Nb(function(b,c,g){var h=g.receiveEvents;return d(e,void 0,void 0,function(){var d,e;return f(this,function(f){switch(f.label){case 0:c.throwIfAborted(),f.label=1;case 1:return f.trys.push([1,3,,4]),[4,h({abortSignal:c,channels:b.channels,channelGroups:b.groups,timetoken:b.cursor.timetoken,region:b.cursor.region})];case 2:return d=f.sent(),a.transition(ac(d.metadata,d.messages)),[3,4];case 3:return(e=f.sent())instanceof Error&&"Aborted"===e.message?[2]:e instanceof Ia?[2,a.transition(bc(e))]:[3,4];case 4:return[2]}})})})),e.on(Qb.type,Nb(function(a,b,c){return c.receiveEvents,d(e,void 0,void 0,function(){return f(this,function(b){return a.length>0&&console.log(a),[2]})})})),e.on(Rb.type,Nb(function(b,c,g){var h=g.receiveEvents,i=g.shouldRetry,j=g.getRetryDelay,k=g.delay;return d(e,void 0,void 0,function(){var d,e;return f(this,function(f){switch(f.label){case 0:return i(b.reason,b.attempts)?(c.throwIfAborted(),[4,k(j(b.attempts))]):[2,a.transition(ec())];case 1:f.sent(),c.throwIfAborted(),f.label=2;case 2:return f.trys.push([2,4,,5]),[4,h({abortSignal:c,channels:b.channels,channelGroups:b.groups,timetoken:b.cursor.timetoken,region:b.cursor.region})];case 3:return d=f.sent(),[2,a.transition(cc(d.metadata,d.messages))];case 4:return(e=f.sent())instanceof Error&&"Aborted"===e.message?[2]:e instanceof Ia?[2,a.transition(dc(e))]:[3,5];case 5:return[2]}})})})),e.on(Sb.type,Nb(function(b,c,g){var h=g.handshake,i=g.shouldRetry,j=g.getRetryDelay,k=g.delay;return d(e,void 0,void 0,function(){var d,e;return f(this,function(f){switch(f.label){case 0:return i(b.reason,b.attempts)?(c.throwIfAborted(),[4,k(j(b.attempts))]):[2,a.transition($b())];case 1:f.sent(),c.throwIfAborted(),f.label=2;case 2:return f.trys.push([2,4,,5]),[4,h({abortSignal:c,channels:b.channels,channelGroups:b.groups})];case 3:return d=f.sent(),[2,a.transition(Yb(d.metadata))];case 4:return(e=f.sent())instanceof Error&&"Aborted"===e.message?[2]:e instanceof Ia?[2,a.transition(Zb(e))]:[3,5];case 5:return[2]}})})})),e}return a(c,b),c}(Jb),hc=new Hb("STOPPED");hc.on(Tb.type,function(a,b){return hc["with"]({channels:b.payload.channels,groups:b.payload.groups})}),hc.on(Vb.type,function(a){return oc["with"](ba({},a))});var ic=new Hb("HANDSHAKE_FAILURE");ic.on(_b.type,function(a){return nc["with"](ba(ba({},a),{attempts:0}))}),ic.on(Ub.type,function(a){return hc["with"]({channels:a.channels,groups:a.groups})});var jc=new Hb("STOPPED");jc.on(Tb.type,function(a,b){return jc["with"]({channels:b.payload.channels,groups:b.payload.groups,cursor:a.cursor})}),jc.on(Vb.type,function(a){return mc["with"](ba({},a))});var kc=new Hb("RECEIVE_FAILURE");kc.on(fc.type,function(a){return lc["with"](ba(ba({},a),{attempts:0}))}),kc.on(Ub.type,function(a){return jc["with"]({channels:a.channels,groups:a.groups,cursor:a.cursor})});var lc=new Hb("RECEIVE_RECONNECTING");lc.onEnter(function(a){return Rb(a)}),lc.onExit(function(){return Rb.cancel}),lc.on(cc.type,function(a,b){return mc["with"]({channels:a.channels,groups:a.groups,cursor:b.payload.cursor},[Qb(b.payload.events)])}),lc.on(dc.type,function(a,b){return lc["with"](ba(ba({},a),{attempts:a.attempts+1,reason:b.payload}))}),lc.on(ec.type,function(a){return kc["with"]({groups:a.groups,channels:a.channels,cursor:a.cursor,reason:a.reason})}),lc.on(Ub.type,function(a){return jc["with"]({channels:a.channels,groups:a.groups,cursor:a.cursor})});var mc=new Hb("RECEIVING");mc.onEnter(function(a){return Pb(a.channels,a.groups,a.cursor)}),mc.onExit(function(){return Pb.cancel}),mc.on(ac.type,function(a,b){return mc["with"](ba(ba({},a),{cursor:b.payload.cursor}),[Qb(b.payload.events)])}),mc.on(Tb.type,function(a,b){return 0===b.payload.channels.length&&0===b.payload.groups.length?pc["with"](void 0):mc["with"](ba(ba({},a),{channels:b.payload.channels,groups:b.payload.groups}))}),mc.on(bc.type,function(a,b){return lc["with"](ba(ba({},a),{attempts:0,reason:b.payload}))}),mc.on(Ub.type,function(a){return jc["with"]({channels:a.channels,groups:a.groups,cursor:a.cursor})});var nc=new Hb("HANDSHAKE_RECONNECTING");nc.onEnter(function(a){return Sb(a)}),nc.onExit(function(){return Rb.cancel}),nc.on(cc.type,function(a,b){return mc["with"]({channels:a.channels,groups:a.groups,cursor:b.payload.cursor},[Qb(b.payload.events)])}),nc.on(dc.type,function(a,b){return nc["with"](ba(ba({},a),{attempts:a.attempts+1,reason:b.payload}))}),nc.on(ec.type,function(a){return ic["with"]({groups:a.groups,channels:a.channels,reason:a.reason})}),nc.on(Ub.type,function(a){return hc["with"]({channels:a.channels,groups:a.groups})});var oc=new Hb("HANDSHAKING");oc.onEnter(function(a){return Ob(a.channels,a.groups)}),oc.onExit(function(){return Ob.cancel}),oc.on(Tb.type,function(a,b){return 0===b.payload.channels.length&&0===b.payload.groups.length?pc["with"](void 0):oc["with"]({channels:b.payload.channels,groups:b.payload.groups})}),oc.on(Wb.type,function(a,b){return mc["with"]({channels:a.channels,groups:a.groups,cursor:b.payload})}),oc.on(Xb.type,function(a,b){return nc["with"](ba(ba({},a),{attempts:0,reason:b.payload}))}),oc.on(Ub.type,function(a){return hc["with"]({channels:a.channels,groups:a.groups})});var pc=new Hb("UNSUBSCRIBED");pc.on(Tb.type,function(a,b){return oc["with"]({channels:b.payload.channels,groups:b.payload.groups})});var qc=function(){function a(a){var b=this;this.engine=new Ib,this.channels=[],this.groups=[],this.dispatcher=new gc(this.engine,a),this.engine.subscribe(function(a){"invocationDispatched"===a.type&&b.dispatcher.dispatch(a.invocation)}),this.engine.start(pc,void 0)}return Object.defineProperty(a.prototype,"_engine",{get:function(){return this.engine},enumerable:!1,configurable:!0}),a.prototype.subscribe=function(a){var b=a.channels,c=a.groups;this.channels=i(i([],h(this.channels),!1),h(null!=b?b:[]),!1),this.groups=i(i([],h(this.groups),!1),h(null!=c?c:[]),!1),this.engine.transition(Tb(this.channels,this.groups))},a.prototype.unsubscribe=function(a){var b=a.channels,c=a.groups;this.channels=this.channels.filter(function(a){var c;return null===(c=!(null==b?void 0:b.includes(a)))||void 0===c||c}),this.groups=this.groups.filter(function(a){var b;return null===(b=!(null==c?void 0:c.includes(a)))||void 0===b||b}),this.engine.transition(Tb(this.channels.slice(0),this.groups.slice(0)))},a.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.engine.transition(Tb(this.channels.slice(0),this.groups.slice(0)))},a.prototype.reconnect=function(){this.engine.transition(Vb())},a.prototype.disconnect=function(){this.engine.transition(Ub())},a}(),rc=function(){function a(a){var b=this,c=a.networking,d=a.cbor,e=new na({setup:a});this._config=e;var f=new ta({config:e}),g=a.cryptography;c.init(e);var j=new Ha(e,d);this._tokenManager=j;var k=new Aa({maximumSamplesCount:6e4});this._telemetryManager=k;var l={config:e,networking:c,crypto:f,cryptography:g,tokenManager:j,telemetryManager:k,PubNubFile:a.PubNubFile};this.File=a.PubNubFile,this.encryptFile=function(a,c){return g.encryptFile(a,c,b.File)},this.decryptFile=function(a,c){return g.decryptFile(a,c,b.File)};var m=s.bind(this,l,Cb),n=s.bind(this,l,Sa),o=s.bind(this,l,Ua),p=s.bind(this,l,Wa),q=s.bind(this,l,Db),r=new Ga;if(this._listenerManager=r,this.iAmHere=s.bind(this,l,Ua),this.iAmAway=s.bind(this,l,Sa),this.setPresenceState=s.bind(this,l,Wa),this.handshake=s.bind(this,l,Eb),this.receiveMessages=s.bind(this,l,Fb),!0===e.enableSubscribeBeta){var t=new qc({handshake:this.handshake,receiveEvents:this.receiveMessages});this.subscribe=t.subscribe.bind(t),this.unsubscribe=t.unsubscribe.bind(t),this.eventEngine=t}else{var u=new ya({timeEndpoint:m,leaveEndpoint:n,heartbeatEndpoint:o,setStateEndpoint:p,subscribeEndpoint:q,crypto:l.crypto,config:l.config,listenerManager:r,getFileUrl:function(a){return db(l,a)}});this.subscribe=u.adaptSubscribeChange.bind(u),this.unsubscribe=u.adaptUnsubscribeChange.bind(u),this.disconnect=u.disconnect.bind(u),this.reconnect=u.reconnect.bind(u),this.unsubscribeAll=u.unsubscribeAll.bind(u),this.getSubscribedChannels=u.getSubscribedChannels.bind(u),this.getSubscribedChannelGroups=u.getSubscribedChannelGroups.bind(u),this.setState=u.adaptStateChange.bind(u),this.presence=u.adaptPresenceChange.bind(u),this.destroy=function(a){u.unsubscribeAll(a),u.disconnect()}}this.addListener=r.addListener.bind(r),this.removeListener=r.removeListener.bind(r),this.removeAllListeners=r.removeAllListeners.bind(r),this.parseToken=j.parseToken.bind(j),this.setToken=j.setToken.bind(j),this.getToken=j.getToken.bind(j),this.channelGroups={listGroups:s.bind(this,l,Ma),listChannels:s.bind(this,l,Na),addChannels:s.bind(this,l,Ja),removeChannels:s.bind(this,l,Ka),deleteGroup:s.bind(this,l,La)},this.push={addChannels:s.bind(this,l,Oa),removeChannels:s.bind(this,l,Pa),deleteDevice:s.bind(this,l,Ra),listChannels:s.bind(this,l,Qa)},this.hereNow=s.bind(this,l,Xa),this.whereNow=s.bind(this,l,Ta),this.getState=s.bind(this,l,Va),this.grant=s.bind(this,l,tb),this.grantToken=s.bind(this,l,ub),this.audit=s.bind(this,l,sb),this.revokeToken=s.bind(this,l,vb),this.publish=s.bind(this,l,wb),this.fire=function(a,c){return a.replicate=!1,a.storeInHistory=!1,b.publish(a,c)},this.signal=s.bind(this,l,xb),this.history=s.bind(this,l,yb),this.deleteMessages=s.bind(this,l,zb),this.messageCounts=s.bind(this,l,Ab),this.fetchMessages=s.bind(this,l,Bb),this.addMessageAction=s.bind(this,l,Ya),this.removeMessageAction=s.bind(this,l,Za),this.getMessageActions=s.bind(this,l,$a),this.listFiles=s.bind(this,l,_a);var v=s.bind(this,l,ab);this.publishFile=s.bind(this,l,bb),this.sendFile=cb({generateUploadUrl:v,publishFile:this.publishFile,modules:l}),this.getFileUrl=function(a){return db(l,a)},this.downloadFile=s.bind(this,l,eb),this.deleteFile=s.bind(this,l,fb),this.objects={getAllUUIDMetadata:s.bind(this,l,gb),getUUIDMetadata:s.bind(this,l,hb),setUUIDMetadata:s.bind(this,l,ib),removeUUIDMetadata:s.bind(this,l,jb),getAllChannelMetadata:s.bind(this,l,kb),getChannelMetadata:s.bind(this,l,lb),setChannelMetadata:s.bind(this,l,mb),removeChannelMetadata:s.bind(this,l,nb),getChannelMembers:s.bind(this,l,ob),setChannelMembers:function(a){for(var c=[],d=1;d<arguments.length;d++)c[d-1]=arguments[d];return s.call.apply(s,i([b,l,pb,ba({type:"set"},a)],h(c),!1))},removeChannelMembers:function(a){for(var c=[],d=1;d<arguments.length;d++)c[d-1]=arguments[d];return s.call.apply(s,i([b,l,pb,ba({type:"delete"},a)],h(c),!1))},getMemberships:s.bind(this,l,qb),setMemberships:function(a){for(var c=[],d=1;d<arguments.length;d++)c[d-1]=arguments[d];return s.call.apply(s,i([b,l,rb,ba({type:"set"},a)],h(c),!1))},removeMemberships:function(a){for(var c=[],d=1;d<arguments.length;d++)c[d-1]=arguments[d];return s.call.apply(s,i([b,l,rb,ba({type:"delete"},a)],h(c),!1))}},this.createUser=function(a){return b.objects.setUUIDMetadata({uuid:a.userId,data:a.data,include:a.include})},this.updateUser=this.createUser,this.removeUser=function(a){return b.objects.removeUUIDMetadata({uuid:null==a?void 0:a.userId})},this.fetchUser=function(a){return b.objects.getUUIDMetadata({uuid:null==a?void 0:a.userId,include:null==a?void 0:a.include})},this.fetchUsers=this.objects.getAllUUIDMetadata,this.createSpace=function(a){return b.objects.setChannelMetadata({channel:a.spaceId,data:a.data,include:a.include})},this.updateSpace=this.createSpace,this.removeSpace=function(a){return b.objects.removeChannelMetadata({channel:a.spaceId})},this.fetchSpace=function(a){return b.objects.getChannelMetadata({channel:a.spaceId,include:a.include})},this.fetchSpaces=this.objects.getAllChannelMetadata,this.addMemberships=function(a){var c,d;return"string"==typeof a.spaceId?b.objects.setChannelMembers({channel:a.spaceId,uuids:null===(c=a.users)||void 0===c?void 0:c.map(function(a){return"string"==typeof a?a:{id:a.userId,custom:a.custom,status:a.status}}),limit:0}):b.objects.setMemberships({uuid:a.userId,channels:null===(d=a.spaces)||void 0===d?void 0:d.map(function(a){return"string"==typeof a?a:{id:a.spaceId,custom:a.custom,status:a.status}}),limit:0})},this.updateMemberships=this.addMemberships,this.removeMemberships=function(a){return"string"==typeof a.spaceId?b.objects.removeChannelMembers({channel:a.spaceId,uuids:a.userIds,limit:0}):b.objects.removeMemberships({uuid:a.userId,channels:a.spaceIds,limit:0})},this.fetchMemberships=function(a){return"string"==typeof a.spaceId?b.objects.getChannelMembers({channel:a.spaceId,filter:a.filter,limit:a.limit,page:a.page,include:{customFields:a.include.customFields,UUIDFields:a.include.userFields,customUUIDFields:a.include.customUserFields,totalCount:a.include.totalCount},sort:null!=a.sort?Object.fromEntries(Object.entries(a.sort).map(function(a){var b=h(a,2),c=b[0],d=b[1];return[c.replace("user","uuid"),d]})):null}).then(function(a){var b;return a.data=null===(b=a.data)||void 0===b?void 0:b.map(function(a){return{user:a.uuid,custom:a.custom,updated:a.updated,eTag:a.eTag}}),a}):b.objects.getMemberships({uuid:a.userId,filter:a.filter,limit:a.limit,page:a.page,include:{customFields:a.include.customFields,channelFields:a.include.spaceFields,customChannelFields:a.include.customSpaceFields,totalCount:a.include.totalCount},sort:null!=a.sort?Object.fromEntries(Object.entries(a.sort).map(function(a){var b=h(a,2),c=b[0],d=b[1];return[c.replace("space","channel"),d]})):null}).then(function(a){var b;return a.data=null===(b=a.data)||void 0===b?void 0:b.map(function(a){return{space:a.channel,custom:a.custom,updated:a.updated,eTag:a.eTag}}),a})},this.time=m,this.stop=this.destroy,this.encrypt=f.encrypt.bind(f),this.decrypt=f.decrypt.bind(f),this.getAuthKey=l.config.getAuthKey.bind(l.config),this.setAuthKey=l.config.setAuthKey.bind(l.config),this.setCipherKey=l.config.setCipherKey.bind(l.config),this.getUUID=l.config.getUUID.bind(l.config),this.setUUID=l.config.setUUID.bind(l.config),this.getFilterExpression=l.config.getFilterExpression.bind(l.config),this.setFilterExpression=l.config.setFilterExpression.bind(l.config),this.setHeartbeatInterval=l.config.setHeartbeatInterval.bind(l.config),c.hasModule("proxy")&&(this.setProxy=function(a){l.config.setProxy(a),b.reconnect()})}return a.prototype.getVersion=function(){return this._config.getVersion()},a.prototype._addPnsdkSuffix=function(a,b){this._config._addPnsdkSuffix(a,b)},a.prototype.networkDownDetected=function(){this._listenerManager.announceNetworkDown(),this._config.restore?this.disconnect():this.destroy(!0)},a.prototype.networkUpDetected=function(){this._listenerManager.announceNetworkUp(),this.reconnect()},a.notificationPayload=function(a,b){return new Fa(a,b)},a.generateUUID=function(){return ma()},a.OPERATIONS=za,a.CATEGORIES=xa,a}(),sc=function(){function a(a){var b=this;this._modules={},Object.keys(a).forEach(function(c){b._modules[c]=a[c].bind(b)})}return a.prototype.init=function(a){this._config=a,Array.isArray(this._config.origin)?this._currentSubDomain=Math.floor(Math.random()*this._config.origin.length):this._currentSubDomain=0,this._coreParams={},this.shiftStandardOrigin()},a.prototype.nextOrigin=function(){var a=this._config.secure?"https://":"http://";if("string"==typeof this._config.origin)return"".concat(a).concat(this._config.origin);this._currentSubDomain+=1,this._currentSubDomain>=this._config.origin.length&&(this._currentSubDomain=0);var b=this._config.origin[this._currentSubDomain];return"".concat(a).concat(b)},a.prototype.hasModule=function(a){return a in this._modules},a.prototype.shiftStandardOrigin=function(){return this._standardOrigin=this.nextOrigin(),this._standardOrigin},a.prototype.getStandardOrigin=function(){return this._standardOrigin},a.prototype.POSTFILE=function(a,b,c){return this._modules.postfile(a,b,c)},a.prototype.GETFILE=function(a,b,c){return this._modules.getfile(a,b,c)},a.prototype.POST=function(a,b,c,d){return this._modules.post(a,b,c,d)},a.prototype.PATCH=function(a,b,c,d){return this._modules.patch(a,b,c,d)},a.prototype.GET=function(a,b,c){return this._modules.get(a,b,c)},a.prototype.DELETE=function(a,b,c){return this._modules.del(a,b,c)},a.prototype._detectErrorCategory=function(a){if("ENOTFOUND"===a.code)return xa.PNNetworkIssuesCategory;if("ECONNREFUSED"===a.code)return xa.PNNetworkIssuesCategory;if("ECONNRESET"===a.code)return xa.PNNetworkIssuesCategory;if("EAI_AGAIN"===a.code)return xa.PNNetworkIssuesCategory;if(0===a.status||a.hasOwnProperty("status")&&void 0===a.status)return xa.PNNetworkIssuesCategory;if(a.timeout)return xa.PNTimeoutCategory;if("ETIMEDOUT"===a.code)return xa.PNNetworkIssuesCategory;if(a.response){if(a.response.badRequest)return xa.PNBadRequestCategory;if(a.response.forbidden)return xa.PNAccessDeniedCategory}return xa.PNUnknownCategory},a}(),tc=function(){function a(a,b){this._base64ToBinary=b,this._decode=a}return a.prototype.decodeToken=function(a){var b="";a.length%4==3?b="=":a.length%4==2&&(b="==");var c=a.replace(/-/gi,"+").replace(/_/gi,"/")+b,d=this._decode(this._base64ToBinary(c));if("object"==typeof d)return d},a}(),uc={exports:{}},vc={exports:{}};!function(a){function b(a){if(a)return function(a){for(var c in b.prototype)a[c]=b.prototype[c];return a}(a)}a.exports=b,b.prototype.on=b.prototype.addEventListener=function(a,b){return this._callbacks=this._callbacks||{},(this._callbacks["$"+a]=this._callbacks["$"+a]||[]).push(b),this},b.prototype.once=function(a,b){function c(){this.off(a,c),b.apply(this,arguments)}return c.fn=b,this.on(a,c),this},b.prototype.off=b.prototype.removeListener=b.prototype.removeAllListeners=b.prototype.removeEventListener=function(a,b){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var c,d=this._callbacks["$"+a];if(!d)return this;if(1==arguments.length)return delete this._callbacks["$"+a],this;for(var e=0;e<d.length;e++)if((c=d[e])===b||c.fn===b){d.splice(e,1);break}return 0===d.length&&delete this._callbacks["$"+a],this},b.prototype.emit=function(a){this._callbacks=this._callbacks||{};for(var b=new Array(arguments.length-1),c=this._callbacks["$"+a],d=1;d<arguments.length;d++)b[d-1]=arguments[d];if(c){d=0;for(var e=(c=c.slice(0)).length;d<e;++d)c[d].apply(this,b)}return this},b.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks["$"+a]||[]},b.prototype.hasListeners=function(a){return!!this.listeners(a).length}}(vc);var wc=C;C["default"]=C,C.stable=G,C.stableStringify=G;var xc="[...]",yc="[Circular]",zc=[],Ac=[],Bc=String.prototype.replace,Cc=/%20/g,Dc="RFC3986",Ec={"default":Dc,formatters:{RFC1738:function(a){return Bc.call(a,Cc,"+")},RFC3986:function(a){return String(a)}},RFC1738:"RFC1738",RFC3986:Dc},Fc=Ec,Gc=Object.prototype.hasOwnProperty,Hc=Array.isArray,Ic=function(){for(var a=[],b=0;b<256;++b)a.push("%"+((b<16?"0":"")+b.toString(16)).toUpperCase());return a}(),Jc=function(a,b){for(var c=b&&b.plainObjects?Object.create(null):{},d=0;d<a.length;++d)void 0!==a[d]&&(c[d]=a[d]);return c},Kc={arrayToObject:Jc,assign:function(a,b){return Object.keys(b).reduce(function(a,c){return a[c]=b[c],a},a)},combine:function(a,b){return[].concat(a,b)},compact:function(a){for(var b=[{obj:{o:a},prop:"o"}],c=[],d=0;d<b.length;++d)for(var e=b[d],f=e.obj[e.prop],g=Object.keys(f),h=0;h<g.length;++h){var i=g[h],j=f[i];"object"==typeof j&&null!==j&&-1===c.indexOf(j)&&(b.push({obj:f,prop:i}),c.push(j))}return function(a){for(;a.length>1;){var b=a.pop(),c=b.obj[b.prop];if(Hc(c)){for(var d=[],e=0;e<c.length;++e)void 0!==c[e]&&d.push(c[e]);b.obj[b.prop]=d}}}(b),a},decode:function(a,b,c){var d=a.replace(/\+/g," ");if("iso-8859-1"===c)return d.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(d)}catch(a){return d}},encode:function(a,b,c,d,e){if(0===a.length)return a;var f=a;if("symbol"==typeof a?f=Symbol.prototype.toString.call(a):"string"!=typeof a&&(f=String(a)),"iso-8859-1"===c)return escape(f).replace(/%u[0-9a-f]{4}/gi,function(a){return"%26%23"+parseInt(a.slice(2),16)+"%3B"});for(var g="",h=0;h<f.length;++h){var i=f.charCodeAt(h);45===i||46===i||95===i||126===i||i>=48&&i<=57||i>=65&&i<=90||i>=97&&i<=122||e===Fc.RFC1738&&(40===i||41===i)?g+=f.charAt(h):i<128?g+=Ic[i]:i<2048?g+=Ic[192|i>>6]+Ic[128|63&i]:i<55296||i>=57344?g+=Ic[224|i>>12]+Ic[128|i>>6&63]+Ic[128|63&i]:(h+=1,i=65536+((1023&i)<<10|1023&f.charCodeAt(h)),g+=Ic[240|i>>18]+Ic[128|i>>12&63]+Ic[128|i>>6&63]+Ic[128|63&i])}return g},isBuffer:function(a){return!(!a||"object"!=typeof a||!(a.constructor&&a.constructor.isBuffer&&a.constructor.isBuffer(a)))},isRegExp:function(a){return"[object RegExp]"===Object.prototype.toString.call(a)},maybeMap:function(a,b){if(Hc(a)){for(var c=[],d=0;d<a.length;d+=1)c.push(b(a[d]));return c}return b(a)},merge:function rd(a,b,c){if(!b)return a;if("object"!=typeof b){if(Hc(a))a.push(b);else{if(!a||"object"!=typeof a)return[a,b];(c&&(c.plainObjects||c.allowPrototypes)||!Gc.call(Object.prototype,b))&&(a[b]=!0)}return a}if(!a||"object"!=typeof a)return[a].concat(b);var d=a;return Hc(a)&&!Hc(b)&&(d=Jc(a,c)),Hc(a)&&Hc(b)?(b.forEach(function(b,d){if(Gc.call(a,d)){var e=a[d];e&&"object"==typeof e&&b&&"object"==typeof b?a[d]=rd(e,b,c):a.push(b)}else a[d]=b}),a):Object.keys(b).reduce(function(a,d){var e=b[d];return Gc.call(a,d)?a[d]=rd(a[d],e,c):a[d]=e,a},d)}},Lc=Kc,Mc=Ec,Nc=Object.prototype.hasOwnProperty,Oc={brackets:function(a){return a+"[]"},comma:"comma",indices:function(a,b){return a+"["+b+"]"},repeat:function(a){return a}},Pc=Array.isArray,Qc=String.prototype.split,Rc=Array.prototype.push,Sc=function(a,b){Rc.apply(a,Pc(b)?b:[b])},Tc=Date.prototype.toISOString,Uc=Mc["default"],Vc={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:Lc.encode,encodeValuesOnly:!1,format:Uc,formatter:Mc.formatters[Uc],indices:!1,serializeDate:function(a){return Tc.call(a)},skipNulls:!1,strictNullHandling:!1},Wc=function sd(a,b,c,d,e,f,g,h,i,j,k,l,m,n){var o,p=a;if("function"==typeof g?p=g(b,p):p instanceof Date?p=j(p):"comma"===c&&Pc(p)&&(p=Lc.maybeMap(p,function(a){return a instanceof Date?j(a):a})),null===p){if(d)return f&&!m?f(b,Vc.encoder,n,"key",k):b;p=""}if("string"==typeof(o=p)||"number"==typeof o||"boolean"==typeof o||"symbol"==typeof o||"bigint"==typeof o||Lc.isBuffer(p)){if(f){var q=m?b:f(b,Vc.encoder,n,"key",k);if("comma"===c&&m){for(var r=Qc.call(String(p),","),s="",t=0;t<r.length;++t)s+=(0===t?"":",")+l(f(r[t],Vc.encoder,n,"value",k));return[l(q)+"="+s]}return[l(q)+"="+l(f(p,Vc.encoder,n,"value",k))]}return[l(b)+"="+l(String(p))]}var u,v=[];if(void 0===p)return v;if("comma"===c&&Pc(p))u=[{value:p.length>0?p.join(",")||null:void 0}];else if(Pc(g))u=g;else{var w=Object.keys(p);u=h?w.sort(h):w}for(var x=0;x<u.length;++x){var y=u[x],z="object"==typeof y&&void 0!==y.value?y.value:p[y];if(!e||null!==z){var A=Pc(p)?"function"==typeof c?c(b,y):b:b+(i?"."+y:"["+y+"]");Sc(v,sd(z,A,c,d,e,f,g,h,i,j,k,l,m,n))}}return v},Xc=Kc,Yc=Object.prototype.hasOwnProperty,Zc=Array.isArray,$c={allowDots:!1,allowPrototypes:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:Xc.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},_c=function(a){return a.replace(/&#(\d+);/g,function(a,b){return String.fromCharCode(parseInt(b,10))})},ad=function(a,b){return a&&"string"==typeof a&&b.comma&&a.indexOf(",")>-1?a.split(","):a},bd=function(a,b,c,d){if(a){var e=c.allowDots?a.replace(/\.([^.[]+)/g,"[$1]"):a,f=/(\[[^[\]]*])/g,g=c.depth>0&&/(\[[^[\]]*])/.exec(e),h=g?e.slice(0,g.index):e,i=[];if(h){if(!c.plainObjects&&Yc.call(Object.prototype,h)&&!c.allowPrototypes)return;i.push(h)}for(var j=0;c.depth>0&&null!==(g=f.exec(e))&&j<c.depth;){if(j+=1,!c.plainObjects&&Yc.call(Object.prototype,g[1].slice(1,-1))&&!c.allowPrototypes)return;i.push(g[1])}return g&&i.push("["+e.slice(g.index)+"]"),function(a,b,c,d){for(var e=d?b:ad(b,c),f=a.length-1;f>=0;--f){var g,h=a[f];if("[]"===h&&c.parseArrays)g=[].concat(e);else{g=c.plainObjects?Object.create(null):{};var i="["===h.charAt(0)&&"]"===h.charAt(h.length-1)?h.slice(1,-1):h,j=parseInt(i,10);c.parseArrays||""!==i?!isNaN(j)&&h!==i&&String(j)===i&&j>=0&&c.parseArrays&&j<=c.arrayLimit?(g=[])[j]=e:"__proto__"!==i&&(g[i]=e):g={0:e}}e=g}return e}(i,b,c,d)}},cd={formats:Ec,parse:function(a,b){var c=function(a){if(!a)return $c;if(null!==a.decoder&&void 0!==a.decoder&&"function"!=typeof a.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==a.charset&&"utf-8"!==a.charset&&"iso-8859-1"!==a.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var b=void 0===a.charset?$c.charset:a.charset;return{allowDots:void 0===a.allowDots?$c.allowDots:!!a.allowDots,allowPrototypes:"boolean"==typeof a.allowPrototypes?a.allowPrototypes:$c.allowPrototypes,arrayLimit:"number"==typeof a.arrayLimit?a.arrayLimit:$c.arrayLimit,charset:b,charsetSentinel:"boolean"==typeof a.charsetSentinel?a.charsetSentinel:$c.charsetSentinel,comma:"boolean"==typeof a.comma?a.comma:$c.comma,decoder:"function"==typeof a.decoder?a.decoder:$c.decoder,delimiter:"string"==typeof a.delimiter||Xc.isRegExp(a.delimiter)?a.delimiter:$c.delimiter,depth:"number"==typeof a.depth||!1===a.depth?+a.depth:$c.depth,
14
+ ignoreQueryPrefix:!0===a.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof a.interpretNumericEntities?a.interpretNumericEntities:$c.interpretNumericEntities,parameterLimit:"number"==typeof a.parameterLimit?a.parameterLimit:$c.parameterLimit,parseArrays:!1!==a.parseArrays,plainObjects:"boolean"==typeof a.plainObjects?a.plainObjects:$c.plainObjects,strictNullHandling:"boolean"==typeof a.strictNullHandling?a.strictNullHandling:$c.strictNullHandling}}(b);if(""===a||null==a)return c.plainObjects?Object.create(null):{};for(var d="string"==typeof a?function(a,b){var c,d={},e=b.ignoreQueryPrefix?a.replace(/^\?/,""):a,f=b.parameterLimit===1/0?void 0:b.parameterLimit,g=e.split(b.delimiter,f),h=-1,i=b.charset;if(b.charsetSentinel)for(c=0;c<g.length;++c)0===g[c].indexOf("utf8=")&&("utf8=%E2%9C%93"===g[c]?i="utf-8":"utf8=%26%2310003%3B"===g[c]&&(i="iso-8859-1"),h=c,c=g.length);for(c=0;c<g.length;++c)if(c!==h){var j,k,l=g[c],m=l.indexOf("]="),n=-1===m?l.indexOf("="):m+1;-1===n?(j=b.decoder(l,$c.decoder,i,"key"),k=b.strictNullHandling?null:""):(j=b.decoder(l.slice(0,n),$c.decoder,i,"key"),k=Xc.maybeMap(ad(l.slice(n+1),b),function(a){return b.decoder(a,$c.decoder,i,"value")})),k&&b.interpretNumericEntities&&"iso-8859-1"===i&&(k=_c(k)),l.indexOf("[]=")>-1&&(k=Zc(k)?[k]:k),Yc.call(d,j)?d[j]=Xc.combine(d[j],k):d[j]=k}return d}(a,c):a,e=c.plainObjects?Object.create(null):{},f=Object.keys(d),g=0;g<f.length;++g){var h=f[g],i=bd(h,d[h],c,"string"==typeof a);e=Xc.merge(e,i,c)}return Xc.compact(e)},stringify:function(a,b){var c,d=a,e=function(a){if(!a)return Vc;if(null!==a.encoder&&void 0!==a.encoder&&"function"!=typeof a.encoder)throw new TypeError("Encoder has to be a function.");var b=a.charset||Vc.charset;if(void 0!==a.charset&&"utf-8"!==a.charset&&"iso-8859-1"!==a.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var c=Mc["default"];if(void 0!==a.format){if(!Nc.call(Mc.formatters,a.format))throw new TypeError("Unknown format option provided.");c=a.format}var d=Mc.formatters[c],e=Vc.filter;return("function"==typeof a.filter||Pc(a.filter))&&(e=a.filter),{addQueryPrefix:"boolean"==typeof a.addQueryPrefix?a.addQueryPrefix:Vc.addQueryPrefix,allowDots:void 0===a.allowDots?Vc.allowDots:!!a.allowDots,charset:b,charsetSentinel:"boolean"==typeof a.charsetSentinel?a.charsetSentinel:Vc.charsetSentinel,delimiter:void 0===a.delimiter?Vc.delimiter:a.delimiter,encode:"boolean"==typeof a.encode?a.encode:Vc.encode,encoder:"function"==typeof a.encoder?a.encoder:Vc.encoder,encodeValuesOnly:"boolean"==typeof a.encodeValuesOnly?a.encodeValuesOnly:Vc.encodeValuesOnly,filter:e,format:c,formatter:d,serializeDate:"function"==typeof a.serializeDate?a.serializeDate:Vc.serializeDate,skipNulls:"boolean"==typeof a.skipNulls?a.skipNulls:Vc.skipNulls,sort:"function"==typeof a.sort?a.sort:null,strictNullHandling:"boolean"==typeof a.strictNullHandling?a.strictNullHandling:Vc.strictNullHandling}}(b);"function"==typeof e.filter?d=(0,e.filter)("",d):Pc(e.filter)&&(c=e.filter);var f,g=[];if("object"!=typeof d||null===d)return"";f=b&&b.arrayFormat in Oc?b.arrayFormat:b&&"indices"in b?b.indices?"indices":"repeat":"indices";var h=Oc[f];c||(c=Object.keys(d)),e.sort&&c.sort(e.sort);for(var i=0;i<c.length;++i){var j=c[i];e.skipNulls&&null===d[j]||Sc(g,Wc(d[j],j,h,e.strictNullHandling,e.skipNulls,e.encode?e.encoder:null,e.filter,e.sort,e.allowDots,e.serializeDate,e.format,e.formatter,e.encodeValuesOnly,e.charset))}var k=g.join(e.delimiter),l=!0===e.addQueryPrefix?"?":"";return e.charsetSentinel&&(l+="iso-8859-1"===e.charset?"utf8=%26%2310003%3B&":"utf8=%E2%9C%93&"),k.length>0?l+k:""}},dd=function(a){return null!==a&&"object"===J(a)},ed=dd,fd=L;L.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},L.prototype.parse=function(a){return this._parser=a,this},L.prototype.responseType=function(a){return this._responseType=a,this},L.prototype.serialize=function(a){return this._serializer=a,this},L.prototype.timeout=function(a){if(!a||"object"!==K(a))return this._timeout=a,this._responseTimeout=0,this._uploadTimeout=0,this;for(var b in a)if(Object.prototype.hasOwnProperty.call(a,b))switch(b){case"deadline":this._timeout=a.deadline;break;case"response":this._responseTimeout=a.response;break;case"upload":this._uploadTimeout=a.upload;break;default:console.warn("Unknown timeout option",b)}return this},L.prototype.retry=function(a,b){return 0!==arguments.length&&!0!==a||(a=1),a<=0&&(a=0),this._maxRetries=a,this._retries=0,this._retryCallback=b,this};var gd=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),hd=new Set([408,413,429,500,502,503,504,521,522,524]);L.prototype._shouldRetry=function(a,b){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var c=this._retryCallback(a,b);if(!0===c)return!0;if(!1===c)return!1}catch(a){console.error(a)}if(b&&b.status&&hd.has(b.status))return!0;if(a){if(a.code&&gd.has(a.code))return!0;if(a.timeout&&"ECONNABORTED"===a.code)return!0;if(a.crossDomain)return!0}return!1},L.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()},L.prototype.then=function(a,b){var c=this;if(!this._fullfilledPromise){var d=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(a,b){d.on("abort",function(){if(!(c._maxRetries&&c._maxRetries>c._retries))if(c.timedout&&c.timedoutError)b(c.timedoutError);else{var a=new Error("Aborted");a.code="ABORTED",a.status=c.status,a.method=c.method,a.url=c.url,b(a)}}),d.end(function(c,d){c?b(c):a(d)})})}return this._fullfilledPromise.then(a,b)},L.prototype["catch"]=function(a){return this.then(void 0,a)},L.prototype.use=function(a){return a(this),this},L.prototype.ok=function(a){if("function"!=typeof a)throw new Error("Callback required");return this._okCallback=a,this},L.prototype._isResponseOK=function(a){return!!a&&(this._okCallback?this._okCallback(a):a.status>=200&&a.status<300)},L.prototype.get=function(a){return this._header[a.toLowerCase()]},L.prototype.getHeader=L.prototype.get,L.prototype.set=function(a,b){if(ed(a)){for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&this.set(c,a[c]);return this}return this._header[a.toLowerCase()]=b,this.header[a]=b,this},L.prototype.unset=function(a){return delete this._header[a.toLowerCase()],delete this.header[a],this},L.prototype.field=function(a,b){if(null==a)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(ed(a)){for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&this.field(c,a[c]);return this}if(Array.isArray(b)){for(var d in b)Object.prototype.hasOwnProperty.call(b,d)&&this.field(a,b[d]);return this}if(null==b)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof b&&(b=String(b)),this._getFormData().append(a,b),this},L.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},L.prototype._auth=function(a,b,c,d){switch(c.type){case"basic":this.set("Authorization","Basic ".concat(d("".concat(a,":").concat(b))));break;case"auto":this.username=a,this.password=b;break;case"bearer":this.set("Authorization","Bearer ".concat(a))}return this},L.prototype.withCredentials=function(a){return void 0===a&&(a=!0),this._withCredentials=a,this},L.prototype.redirects=function(a){return this._maxRedirects=a,this},L.prototype.maxResponseSize=function(a){if("number"!=typeof a)throw new TypeError("Invalid argument");return this._maxResponseSize=a,this},L.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},L.prototype.send=function(a){var b=ed(a),c=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(b&&!this._data)Array.isArray(a)?this._data=[]:this._isHost(a)||(this._data={});else if(a&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(b&&ed(this._data))for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&(this._data[d]=a[d]);else"string"==typeof a?(c||this.type("form"),(c=this._header["content-type"])&&(c=c.toLowerCase().trim()),this._data="application/x-www-form-urlencoded"===c?this._data?"".concat(this._data,"&").concat(a):a:(this._data||"")+a):this._data=a;return!b||this._isHost(a)||c||this.type("json"),this},L.prototype.sortQuery=function(a){return this._sort=void 0===a||a,this},L.prototype._finalizeQueryString=function(){var a=this._query.join("&");if(a&&(this.url+=(this.url.includes("?")?"&":"?")+a),this._query.length=0,this._sort){var b=this.url.indexOf("?");if(b>=0){var c=this.url.slice(b+1).split("&");"function"==typeof this._sort?c.sort(this._sort):c.sort(),this.url=this.url.slice(0,b)+"?"+c.join("&")}}},L.prototype._appendQueryString=function(){console.warn("Unsupported")},L.prototype._timeoutError=function(a,b,c){if(!this._aborted){var d=new Error("".concat(a+b,"ms exceeded"));d.timeout=b,d.code="ECONNABORTED",d.errno=c,this.timedout=!0,this.timedoutError=d,this.abort(),this.callback(d)}},L.prototype._setTimeouts=function(){var a=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){a._timeoutError("Timeout of ",a._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){a._timeoutError("Response timeout of ",a._responseTimeout,"ETIMEDOUT")},this._responseTimeout))};var id={};id.type=function(a){return a.split(/ *; */).shift()},id.params=function(a){var b,c={},d=M(a.split(/ *; */));try{for(d.s();!(b=d.n()).done;){var e=b.value.split(/ *= */),f=e.shift(),g=e.shift();f&&g&&(c[f]=g)}}catch(a){d.e(a)}finally{d.f()}return c},id.parseLinks=function(a){var b,c={},d=M(a.split(/ *, */));try{for(d.s();!(b=d.n()).done;){var e=b.value.split(/ *; */),f=e[0].slice(1,-1);c[e[1].split(/ *= */)[1].slice(1,-1)]=f}}catch(a){d.e(a)}finally{d.f()}return c},id.cleanHeader=function(a,b){return delete a["content-type"],delete a["content-length"],delete a["transfer-encoding"],delete a.host,b&&(delete a.authorization,delete a.cookie),a};var jd=id,kd=O;O.prototype.get=function(a){return this.header[a.toLowerCase()]},O.prototype._setHeaderProperties=function(a){var b=a["content-type"]||"";this.type=jd.type(b);var c=jd.params(b);for(var d in c)Object.prototype.hasOwnProperty.call(c,d)&&(this[d]=c[d]);this.links={};try{a.link&&(this.links=jd.parseLinks(a.link))}catch(a){}},O.prototype._setStatusProperties=function(a){var b=a/100|0;this.statusCode=a,this.status=this.statusCode,this.statusType=b,this.info=1===b,this.ok=2===b,this.redirect=3===b,this.clientError=4===b,this.serverError=5===b,this.error=(4===b||5===b)&&this.toError(),this.created=201===a,this.accepted=202===a,this.noContent=204===a,this.badRequest=400===a,this.unauthorized=401===a,this.notAcceptable=406===a,this.forbidden=403===a,this.notFound=404===a,this.unprocessableEntity=422===a},["use","on","once","set","query","type","accept","auth","withCredentials","sortQuery","retry","ok","redirects","timeout","buffer","serialize","parse","ca","key","pfx","cert","disableTLSCerts"].forEach(function(a){R.prototype[a]=function(){for(var b=arguments.length,c=new Array(b),d=0;d<b;d++)c[d]=arguments[d];return this._defaults.push({fn:a,args:c}),this}}),R.prototype._setDefaults=function(a){this._defaults.forEach(function(b){a[b.fn].apply(a,P(b.args))})};var ld=R;!function(a,b){function c(a){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a})(a)}function d(){}function e(a){if(!q(a))return a;var b=[];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&f(b,c,a[c]);return b.join("&")}function f(a,b,c){if(void 0!==c)if(null!==c)if(Array.isArray(c))c.forEach(function(c){f(a,b,c)});else if(q(c))for(var d in c)Object.prototype.hasOwnProperty.call(c,d)&&f(a,"".concat(b,"[").concat(d,"]"),c[d]);else a.push(encodeURI(b)+"="+encodeURIComponent(c));else a.push(encodeURI(b))}function g(a){for(var b,c,d={},e=a.split("&"),f=0,g=e.length;f<g;++f)-1===(c=(b=e[f]).indexOf("="))?d[decodeURIComponent(b)]="":d[decodeURIComponent(b.slice(0,c))]=decodeURIComponent(b.slice(c+1));return d}function h(a){return/[/+]json($|[^-\w])/i.test(a)}function i(a){this.req=a,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 b=this.xhr.status;1223===b&&(b=204),this._setStatusProperties(b),this.headers=function(a){for(var b,c,d,e,f=a.split(/\r?\n/),g={},h=0,i=f.length;h<i;++h)-1!==(b=(c=f[h]).indexOf(":"))&&(d=c.slice(0,b).toLowerCase(),e=u(c.slice(b+1)),g[d]=e);return g}(this.xhr.getAllResponseHeaders()),this.header=this.headers,this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this._setHeaderProperties(this.header),null===this.text&&a._responseType?this.body=this.xhr.response:this.body="HEAD"===this.req.method?null:this._parseBody(this.text?this.text:this.xhr.response)}function j(a,b){var c=this;this._query=this._query||[],this.method=a,this.url=b,this.header={},this._header={},this.on("end",function(){var a,b=null,d=null;try{d=new i(c)}catch(a){return(b=new Error("Parser is unable to parse the response")).parse=!0,b.original=a,c.xhr?(b.rawResponse=void 0===c.xhr.responseType?c.xhr.responseText:c.xhr.response,b.status=c.xhr.status?c.xhr.status:null,b.statusCode=b.status):(b.rawResponse=null,b.status=null),c.callback(b)}c.emit("response",d);try{c._isResponseOK(d)||(a=new Error(d.statusText||d.text||"Unsuccessful HTTP response"))}catch(b){a=b}a?(a.original=b,a.response=d,a.status=d.status,c.callback(a,d)):c.callback(null,d)})}function k(a,b,c){var d=t("DELETE",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d}var l;"undefined"!=typeof window?l=window:"undefined"==typeof self?(console.warn("Using browser-only version of superagent in non-browser environment"),l=void 0):l=self;var m=vc.exports,n=wc,o=cd,p=fd,q=dd,r=kd,s=ld;a.exports=function(a,c){return"function"==typeof c?new b.Request("GET",a).end(c):1===arguments.length?new b.Request("GET",a):new b.Request(a,c)};var t=b=a.exports;b.Request=j,t.getXHR=function(){if(l.XMLHttpRequest&&(!l.location||"file:"!==l.location.protocol||!l.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(a){}throw new Error("Browser-only version of superagent could not find XHR")};var u="".trim?function(a){return a.trim()}:function(a){return a.replace(/(^\s*|\s*$)/g,"")};t.serializeObject=e,t.parseString=g,t.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"},t.serialize={"application/x-www-form-urlencoded":o.stringify,"application/json":n},t.parse={"application/x-www-form-urlencoded":g,"application/json":JSON.parse},r(i.prototype),i.prototype._parseBody=function(a){var b=t.parse[this.type];return this.req._parser?this.req._parser(this,a):(!b&&h(this.type)&&(b=t.parse["application/json"]),b&&a&&(a.length>0||a instanceof Object)?b(a):null)},i.prototype.toError=function(){var a=this.req,b=a.method,c=a.url,d="cannot ".concat(b," ").concat(c," (").concat(this.status,")"),e=new Error(d);return e.status=this.status,e.method=b,e.url=c,e},t.Response=i,m(j.prototype),p(j.prototype),j.prototype.type=function(a){return this.set("Content-Type",t.types[a]||a),this},j.prototype.accept=function(a){return this.set("Accept",t.types[a]||a),this},j.prototype.auth=function(a,b,d){1===arguments.length&&(b=""),"object"===c(b)&&null!==b&&(d=b,b=""),d||(d={type:"function"==typeof btoa?"basic":"auto"});var e=function(a){if("function"==typeof btoa)return btoa(a);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(a,b,d,e)},j.prototype.query=function(a){return"string"!=typeof a&&(a=e(a)),a&&this._query.push(a),this},j.prototype.attach=function(a,b,c){if(b){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(a,b,c||b.name)}return this},j.prototype._getFormData=function(){return this._formData||(this._formData=new l.FormData),this._formData},j.prototype.callback=function(a,b){if(this._shouldRetry(a,b))return this._retry();var c=this._callback;this.clearTimeout(),a&&(this._maxRetries&&(a.retries=this._retries-1),this.emit("error",a)),c(a,b)},j.prototype.crossDomainError=function(){var a=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.");a.crossDomain=!0,a.status=this.status,a.method=this.method,a.url=this.url,this.callback(a)},j.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},j.prototype.ca=j.prototype.agent,j.prototype.buffer=j.prototype.ca,j.prototype.write=function(){throw new Error("Streaming is not supported in browser version of superagent")},j.prototype.pipe=j.prototype.write,j.prototype._isHost=function(a){return a&&"object"===c(a)&&!Array.isArray(a)&&"[object Object]"!==Object.prototype.toString.call(a)},j.prototype.end=function(a){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=a||d,this._finalizeQueryString(),this._end()},j.prototype._setUploadTimeout=function(){var a=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout(function(){a._timeoutError("Upload timeout of ",a._uploadTimeout,"ETIMEDOUT")},this._uploadTimeout))},j.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));var a=this;this.xhr=t.getXHR();var b=this.xhr,c=this._formData||this._data;this._setTimeouts(),b.onreadystatechange=function(){var a=b.readyState;if(a>=2&&d._responseTimeoutTimer&&clearTimeout(d._responseTimeoutTimer),4===a){var c;try{c=b.status}catch(d){c=0}if(!c){if(d.timedout||d._aborted)return;return d.crossDomainError()}d.emit("end")}};var d=function(b,c){c.total>0&&(c.percent=c.loaded/c.total*100,100===c.percent&&clearTimeout(a._uploadTimeoutTimer)),c.direction=b,a.emit("progress",c)};if(this.hasListeners("progress"))try{b.addEventListener("progress",d.bind(null,"download")),b.upload&&b.upload.addEventListener("progress",d.bind(null,"upload"))}catch(a){}b.upload&&this._setUploadTimeout();try{this.username&&this.password?b.open(this.method,this.url,!0,this.username,this.password):b.open(this.method,this.url,!0)}catch(a){return this.callback(a)}if(this._withCredentials&&(b.withCredentials=!0),!this._formData&&"GET"!==this.method&&"HEAD"!==this.method&&"string"!=typeof c&&!this._isHost(c)){var e=this._header["content-type"],f=this._serializer||t.serialize[e?e.split(";")[0]:""];!f&&h(e)&&(f=t.serialize["application/json"]),f&&(c=f(c))}for(var g in this.header)null!==this.header[g]&&Object.prototype.hasOwnProperty.call(this.header,g)&&b.setRequestHeader(g,this.header[g]);this._responseType&&(b.responseType=this._responseType),this.emit("request",this),b.send(void 0===c?null:c)},t.agent=function(){return new s},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(a){s.prototype[a.toLowerCase()]=function(b,c){var d=new t.Request(a,b);return this._setDefaults(d),c&&d.end(c),d}}),s.prototype.del=s.prototype["delete"],t.get=function(a,b,c){var d=t("GET",a);return"function"==typeof b&&(c=b,b=null),b&&d.query(b),c&&d.end(c),d},t.head=function(a,b,c){var d=t("HEAD",a);return"function"==typeof b&&(c=b,b=null),b&&d.query(b),c&&d.end(c),d},t.options=function(a,b,c){var d=t("OPTIONS",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},t.del=k,t["delete"]=k,t.patch=function(a,b,c){var d=t("PATCH",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},t.post=function(a,b,c){var d=t("POST",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},t.put=function(a,b,c){var d=t("PUT",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d}}(uc,uc.exports);var md,nd=uc.exports,od=function(){function a(){}return Object.defineProperty(a.prototype,"algo",{get:function(){return"aes-256-cbc"},enumerable:!1,configurable:!0}),a.prototype.encrypt=function(a,b){return d(this,void 0,void 0,function(){var c;return f(this,function(d){switch(d.label){case 0:return[4,this.getKey(a)];case 1:if(c=d.sent(),b instanceof ArrayBuffer)return[2,this.encryptArrayBuffer(c,b)];if("string"==typeof b)return[2,this.encryptString(c,b)];throw new Error("Cannot encrypt this file. In browsers file encryption supports only string or ArrayBuffer")}})})},a.prototype.decrypt=function(a,b){return d(this,void 0,void 0,function(){var c;return f(this,function(d){switch(d.label){case 0:return[4,this.getKey(a)];case 1:if(c=d.sent(),b instanceof ArrayBuffer)return[2,this.decryptArrayBuffer(c,b)];if("string"==typeof b)return[2,this.decryptString(c,b)];throw new Error("Cannot decrypt this file. In browsers file decryption supports only string or ArrayBuffer")}})})},a.prototype.encryptFile=function(a,b,c){return d(this,void 0,void 0,function(){var d,e,g;return f(this,function(f){switch(f.label){case 0:return[4,this.getKey(a)];case 1:return d=f.sent(),[4,b.toArrayBuffer()];case 2:return e=f.sent(),[4,this.encryptArrayBuffer(d,e)];case 3:return g=f.sent(),[2,c.create({name:b.name,mimeType:"application/octet-stream",data:g})]}})})},a.prototype.decryptFile=function(a,b,c){return d(this,void 0,void 0,function(){var d,e,g;return f(this,function(f){switch(f.label){case 0:return[4,this.getKey(a)];case 1:return d=f.sent(),[4,b.toArrayBuffer()];case 2:return e=f.sent(),[4,this.decryptArrayBuffer(d,e)];case 3:return g=f.sent(),[2,c.create({name:b.name,data:g})]}})})},a.prototype.getKey=function(a){return d(this,void 0,void 0,function(){var b,c,d;return f(this,function(f){switch(f.label){case 0:return b=e.from(a),[4,crypto.subtle.digest("SHA-256",b.buffer)];case 1:return c=f.sent(),d=e.from(e.from(c).toString("hex").slice(0,32),"utf8").buffer,[2,crypto.subtle.importKey("raw",d,"AES-CBC",!0,["encrypt","decrypt"])]}})})},a.prototype.encryptArrayBuffer=function(a,b){return d(this,void 0,void 0,function(){var c,d,e;return f(this,function(f){switch(f.label){case 0:return c=crypto.getRandomValues(new Uint8Array(16)),d=$,e=[c.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:c},a,b)];case 1:return[2,d.apply(void 0,e.concat([f.sent()]))]}})})},a.prototype.decryptArrayBuffer=function(a,b){return d(this,void 0,void 0,function(){var c;return f(this,function(d){return c=b.slice(0,16),[2,crypto.subtle.decrypt({name:"AES-CBC",iv:c},a,b.slice(16))]})})},a.prototype.encryptString=function(a,b){return d(this,void 0,void 0,function(){var c,d,g,h;return f(this,function(f){switch(f.label){case 0:return c=crypto.getRandomValues(new Uint8Array(16)),d=e.from(b).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:c},a,d)];case 1:return g=f.sent(),h=$(c.buffer,g),[2,e.from(h).toString("utf8")]}})})},a.prototype.decryptString=function(a,b){return d(this,void 0,void 0,function(){var c,d,g,h;return f(this,function(f){switch(f.label){case 0:return c=e.from(b),d=c.slice(0,16),g=c.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:d},a,g)];case 1:return h=f.sent(),[2,e.from(h).toString("utf8")]}})})},a.IV_LENGTH=16,a}(),pd=(md=function(){function a(a){if(a instanceof File)this.data=a,this.name=this.data.name,this.mimeType=this.data.type;else if(a.data){var b=a.data;this.data=new File([b],a.name,{type:a.mimeType}),this.name=a.name,a.mimeType&&(this.mimeType=a.mimeType)}if(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.")}return a.create=function(a){return new this(a)},a.prototype.toBuffer=function(){return d(this,void 0,void 0,function(){return f(this,function(a){throw new Error("This feature is only supported in Node.js environments.")})})},a.prototype.toStream=function(){return d(this,void 0,void 0,function(){return f(this,function(a){throw new Error("This feature is only supported in Node.js environments.")})})},a.prototype.toFileUri=function(){return d(this,void 0,void 0,function(){return f(this,function(a){throw new Error("This feature is only supported in react native environments.")})})},a.prototype.toBlob=function(){return d(this,void 0,void 0,function(){return f(this,function(a){return[2,this.data]})})},a.prototype.toArrayBuffer=function(){return d(this,void 0,void 0,function(){var a=this;return f(this,function(b){return[2,new Promise(function(b,c){var d=new FileReader;d.addEventListener("load",function(){if(d.result instanceof ArrayBuffer)return b(d.result)}),d.addEventListener("error",function(){c(d.error)}),d.readAsArrayBuffer(a.data)})]})})},a.prototype.toString=function(){return d(this,void 0,void 0,function(){var a=this;return f(this,function(b){return[2,new Promise(function(b,c){var d=new FileReader;d.addEventListener("load",function(){if("string"==typeof d.result)return b(d.result)}),d.addEventListener("error",function(){c(d.error)}),d.readAsBinaryString(a.data)})]})})},a.prototype.toFile=function(){return d(this,void 0,void 0,function(){return f(this,function(a){return[2,this.data]})})},a}(),md.supportsFile="undefined"!=typeof File,md.supportsBlob="undefined"!=typeof Blob,md.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,md.supportsBuffer=!1,md.supportsStream=!1,md.supportsString=!0,md.supportsEncryptFile=!0,md.supportsFileUri=!1,md),qd=function(b){function c(a){var c=this,d=a.listenToBrowserNetworkEvents,e=void 0===d||d;return a.sdkFamily="Web",a.networking=new sc({del:Z,get:W,post:X,patch:Y,sendBeacon:_,getfile:V,postfile:U}),a.cbor=new tc(function(a){return A(ea.decode(a))},j),a.PubNubFile=pd,a.cryptography=new od,c=b.call(this,a)||this,e&&(window.addEventListener("offline",function(){c.networkDownDetected()}),window.addEventListener("online",function(){c.networkUpDetected()})),c}return a(c,b),c}(rc);return qd})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},b("buffer").Buffer)},{buffer:38}],46:[function(b,c,d){(function(b){!function(b){"use strict";if("function"==typeof bootstrap)bootstrap("promise",b);else if("object"==typeof d&&"object"==typeof c)c.exports=b();else if("function"==typeof a&&a.amd)a(b);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=b}else{if("undefined"==typeof window&&"undefined"==typeof self)throw new Error("This environment was not anticipated by Q. Please file a bug.");var e="undefined"!=typeof window?window:self,f=e.Q;e.Q=b(),e.Q.noConflict=function(){return e.Q=f,this}}}(function(){"use strict";function a(a){return function(){return X.apply(a,arguments)}}function c(a){return a===Object(a)}function d(a){return"[object StopIteration]"===da(a)||a instanceof T}function e(a,b){if(Q&&b.stack&&"object"==typeof a&&null!==a&&a.stack&&a.stack.indexOf(ea)===-1){for(var c=[],d=b;d;d=d.source)d.stack&&c.unshift(d.stack);c.unshift(a.stack);var e=c.join("\n"+ea+"\n");a.stack=f(e)}}function f(a){for(var b=a.split("\n"),c=[],d=0;d<b.length;++d){var e=b[d];i(e)||g(e)||!e||c.push(e)}return c.join("\n")}function g(a){return a.indexOf("(module.js:")!==-1||a.indexOf("(node.js:")!==-1}function h(a){var b=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(a);if(b)return[b[1],Number(b[2])];var c=/at ([^ ]+):(\d+):(?:\d+)$/.exec(a);if(c)return[c[1],Number(c[2])];var d=/.*@(.+):(\d+)$/.exec(a);return d?[d[1],Number(d[2])]:void 0}function i(a){var b=h(a);if(!b)return!1;var c=b[0],d=b[1];return c===S&&d>=U&&d<=ja}function j(){if(Q)try{throw new Error}catch(a){var b=a.stack.split("\n"),c=b[0].indexOf("@")>0?b[1]:b[2],d=h(c);if(!d)return;return S=d[0],d[1]}}function k(a,b,c){return function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(b+" is deprecated, use "+c+" instead.",new Error("").stack),a.apply(a,arguments)}}function l(a){return a instanceof p?a:t(a)?C(a):B(a)}function m(){function a(a){b=a,f.source=a,Z(c,function(b,c){l.nextTick(function(){a.promiseDispatch.apply(a,c)})},void 0),c=void 0,d=void 0}var b,c=[],d=[],e=aa(m.prototype),f=aa(p.prototype);if(f.promiseDispatch=function(a,e,f){var g=Y(arguments);c?(c.push(g),"when"===e&&f[1]&&d.push(f[1])):l.nextTick(function(){b.promiseDispatch.apply(b,g)})},f.valueOf=function(){if(c)return f;var a=r(b);return s(a)&&(b=a),a},f.inspect=function(){return b?b.inspect():{state:"pending"}},l.longStackSupport&&Q)try{throw new Error}catch(g){f.stack=g.stack.substring(g.stack.indexOf("\n")+1)}return e.promise=f,e.resolve=function(c){b||a(l(c))},e.fulfill=function(c){b||a(B(c))},e.reject=function(c){b||a(A(c))},e.notify=function(a){b||Z(d,function(b,c){l.nextTick(function(){c(a)})},void 0)},e}function n(a){if("function"!=typeof a)throw new TypeError("resolver must be a function.");var b=m();try{a(b.resolve,b.reject,b.notify)}catch(c){b.reject(c)}return b.promise}function o(a){return n(function(b,c){for(var d=0,e=a.length;d<e;d++)l(a[d]).then(b,c)})}function p(a,b,c){void 0===b&&(b=function(a){return A(new Error("Promise does not support operation: "+a))}),void 0===c&&(c=function(){return{state:"unknown"}});var d=aa(p.prototype);if(d.promiseDispatch=function(c,e,f){var g;try{g=a[e]?a[e].apply(d,f):b.call(d,e,f)}catch(h){g=A(h)}c&&c(g)},d.inspect=c,c){var e=c();"rejected"===e.state&&(d.exception=e.reason),d.valueOf=function(){var a=c();return"pending"===a.state||"rejected"===a.state?d:a.value}}return d}function q(a,b,c,d){return l(a).then(b,c,d)}function r(a){if(s(a)){var b=a.inspect();if("fulfilled"===b.state)return b.value}return a}function s(a){return a instanceof p}function t(a){return c(a)&&"function"==typeof a.then}function u(a){return s(a)&&"pending"===a.inspect().state}function v(a){return!s(a)||"fulfilled"===a.inspect().state}function w(a){return s(a)&&"rejected"===a.inspect().state}function x(){fa.length=0,ga.length=0,ia||(ia=!0)}function y(a,c){ia&&("object"==typeof b&&"function"==typeof b.emit&&l.nextTick.runAfter(function(){$(ga,a)!==-1&&(b.emit("unhandledRejection",c,a),ha.push(a))}),ga.push(a),c&&"undefined"!=typeof c.stack?fa.push(c.stack):fa.push("(no stack) "+c))}function z(a){if(ia){var c=$(ga,a);c!==-1&&("object"==typeof b&&"function"==typeof b.emit&&l.nextTick.runAfter(function(){var d=$(ha,a);d!==-1&&(b.emit("rejectionHandled",fa[c],a),ha.splice(d,1))}),ga.splice(c,1),fa.splice(c,1))}}function A(a){var b=p({when:function(b){return b&&z(this),b?b(a):this}},function(){return this},function(){return{state:"rejected",reason:a}});return y(b,a),b}function B(a){return p({when:function(){return a},get:function(b){return a[b]},set:function(b,c){a[b]=c},"delete":function(b){delete a[b]},post:function(b,c){return null===b||void 0===b?a.apply(void 0,c):a[b].apply(a,c)},apply:function(b,c){return a.apply(b,c)},keys:function(){return ca(a)}},void 0,function(){return{state:"fulfilled",value:a}})}function C(a){var b=m();return l.nextTick(function(){
15
+ try{a.then(b.resolve,b.reject,b.notify)}catch(c){b.reject(c)}}),b.promise}function D(a){return p({isDef:function(){}},function(b,c){return J(a,b,c)},function(){return l(a).inspect()})}function E(a,b,c){return l(a).spread(b,c)}function F(a){return function(){function b(a,b){var g;if("undefined"==typeof StopIteration){try{g=c[a](b)}catch(h){return A(h)}return g.done?l(g.value):q(g.value,e,f)}try{g=c[a](b)}catch(h){return d(h)?l(h.value):A(h)}return q(g,e,f)}var c=a.apply(this,arguments),e=b.bind(b,"next"),f=b.bind(b,"throw");return e()}}function G(a){l.done(l.async(a)())}function H(a){throw new T(a)}function I(a){return function(){return E([this,K(arguments)],function(b,c){return a.apply(b,c)})}}function J(a,b,c){return l(a).dispatch(b,c)}function K(a){return q(a,function(a){var b=0,c=m();return Z(a,function(d,e,f){var g;s(e)&&"fulfilled"===(g=e.inspect()).state?a[f]=g.value:(++b,q(e,function(d){a[f]=d,0===--b&&c.resolve(a)},c.reject,function(a){c.notify({index:f,value:a})}))},void 0),0===b&&c.resolve(a),c.promise})}function L(a){if(0===a.length)return l.resolve();var b=l.defer(),c=0;return Z(a,function(d,e,f){function g(a){b.resolve(a)}function h(){c--,0===c&&b.reject(new Error("Can't get fulfillment value from any promise, all promises were rejected."))}function i(a){b.notify({index:f,value:a})}var j=a[f];c++,q(j,g,h,i)},void 0),b.promise}function M(a){return q(a,function(a){return a=_(a,l),q(K(_(a,function(a){return q(a,V,V)})),function(){return a})})}function N(a){return l(a).allSettled()}function O(a,b){return l(a).then(void 0,void 0,b)}function P(a,b){return l(a).nodeify(b)}var Q=!1;try{throw new Error}catch(R){Q=!!R.stack}var S,T,U=j(),V=function(){},W=function(){function a(){for(var a,b;d.next;)d=d.next,a=d.task,d.task=void 0,b=d.domain,b&&(d.domain=void 0,b.enter()),c(a,b);for(;i.length;)a=i.pop(),c(a);f=!1}function c(b,c){try{b()}catch(d){if(h)throw c&&c.exit(),setTimeout(a,0),c&&c.enter(),d;setTimeout(function(){throw d},0)}c&&c.exit()}var d={task:void 0,next:null},e=d,f=!1,g=void 0,h=!1,i=[];if(W=function(a){e=e.next={task:a,domain:h&&b.domain,next:null},f||(f=!0,g())},"object"==typeof b&&"[object process]"===b.toString()&&b.nextTick)h=!0,g=function(){b.nextTick(a)};else if("function"==typeof setImmediate)g="undefined"!=typeof window?setImmediate.bind(window,a):function(){setImmediate(a)};else if("undefined"!=typeof MessageChannel){var j=new MessageChannel;j.port1.onmessage=function(){g=k,j.port1.onmessage=a,a()};var k=function(){j.port2.postMessage(0)};g=function(){setTimeout(a,0),k()}}else g=function(){setTimeout(a,0)};return W.runAfter=function(a){i.push(a),f||(f=!0,g())},W}(),X=Function.call,Y=a(Array.prototype.slice),Z=a(Array.prototype.reduce||function(a,b){var c=0,d=this.length;if(1===arguments.length)for(;;){if(c in this){b=this[c++];break}if(++c>=d)throw new TypeError}for(;c<d;c++)c in this&&(b=a(b,this[c],c));return b}),$=a(Array.prototype.indexOf||function(a){for(var b=0;b<this.length;b++)if(this[b]===a)return b;return-1}),_=a(Array.prototype.map||function(a,b){var c=this,d=[];return Z(c,function(e,f,g){d.push(a.call(b,f,g,c))},void 0),d}),aa=Object.create||function(a){function b(){}return b.prototype=a,new b},ba=a(Object.prototype.hasOwnProperty),ca=Object.keys||function(a){var b=[];for(var c in a)ba(a,c)&&b.push(c);return b},da=a(Object.prototype.toString);T="undefined"!=typeof ReturnValue?ReturnValue:function(a){this.value=a};var ea="From previous event:";l.resolve=l,l.nextTick=W,l.longStackSupport=!1,"object"==typeof b&&b&&b.env&&b.env.Q_DEBUG&&(l.longStackSupport=!0),l.defer=m,m.prototype.makeNodeResolver=function(){var a=this;return function(b,c){b?a.reject(b):arguments.length>2?a.resolve(Y(arguments,1)):a.resolve(c)}},l.Promise=n,l.promise=n,n.race=o,n.all=K,n.reject=A,n.resolve=l,l.passByCopy=function(a){return a},p.prototype.passByCopy=function(){return this},l.join=function(a,b){return l(a).join(b)},p.prototype.join=function(a){return l([this,a]).spread(function(a,b){if(a===b)return a;throw new Error("Can't join: not the same: "+a+" "+b)})},l.race=o,p.prototype.race=function(){return this.then(l.race)},l.makePromise=p,p.prototype.toString=function(){return"[object Promise]"},p.prototype.then=function(a,b,c){function d(b){try{return"function"==typeof a?a(b):b}catch(c){return A(c)}}function f(a){if("function"==typeof b){e(a,h);try{return b(a)}catch(c){return A(c)}}return A(a)}function g(a){return"function"==typeof c?c(a):a}var h=this,i=m(),j=!1;return l.nextTick(function(){h.promiseDispatch(function(a){j||(j=!0,i.resolve(d(a)))},"when",[function(a){j||(j=!0,i.resolve(f(a)))}])}),h.promiseDispatch(void 0,"when",[void 0,function(a){var b,c=!1;try{b=g(a)}catch(d){if(c=!0,!l.onerror)throw d;l.onerror(d)}c||i.notify(b)}]),i.promise},l.tap=function(a,b){return l(a).tap(b)},p.prototype.tap=function(a){return a=l(a),this.then(function(b){return a.fcall(b).thenResolve(b)})},l.when=q,p.prototype.thenResolve=function(a){return this.then(function(){return a})},l.thenResolve=function(a,b){return l(a).thenResolve(b)},p.prototype.thenReject=function(a){return this.then(function(){throw a})},l.thenReject=function(a,b){return l(a).thenReject(b)},l.nearer=r,l.isPromise=s,l.isPromiseAlike=t,l.isPending=u,p.prototype.isPending=function(){return"pending"===this.inspect().state},l.isFulfilled=v,p.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},l.isRejected=w,p.prototype.isRejected=function(){return"rejected"===this.inspect().state};var fa=[],ga=[],ha=[],ia=!0;l.resetUnhandledRejections=x,l.getUnhandledReasons=function(){return fa.slice()},l.stopUnhandledRejectionTracking=function(){x(),ia=!1},x(),l.reject=A,l.fulfill=B,l.master=D,l.spread=E,p.prototype.spread=function(a,b){return this.all().then(function(b){return a.apply(void 0,b)},b)},l.async=F,l.spawn=G,l["return"]=H,l.promised=I,l.dispatch=J,p.prototype.dispatch=function(a,b){var c=this,d=m();return l.nextTick(function(){c.promiseDispatch(d.resolve,a,b)}),d.promise},l.get=function(a,b){return l(a).dispatch("get",[b])},p.prototype.get=function(a){return this.dispatch("get",[a])},l.set=function(a,b,c){return l(a).dispatch("set",[b,c])},p.prototype.set=function(a,b){return this.dispatch("set",[a,b])},l.del=l["delete"]=function(a,b){return l(a).dispatch("delete",[b])},p.prototype.del=p.prototype["delete"]=function(a){return this.dispatch("delete",[a])},l.mapply=l.post=function(a,b,c){return l(a).dispatch("post",[b,c])},p.prototype.mapply=p.prototype.post=function(a,b){return this.dispatch("post",[a,b])},l.send=l.mcall=l.invoke=function(a,b){return l(a).dispatch("post",[b,Y(arguments,2)])},p.prototype.send=p.prototype.mcall=p.prototype.invoke=function(a){return this.dispatch("post",[a,Y(arguments,1)])},l.fapply=function(a,b){return l(a).dispatch("apply",[void 0,b])},p.prototype.fapply=function(a){return this.dispatch("apply",[void 0,a])},l["try"]=l.fcall=function(a){return l(a).dispatch("apply",[void 0,Y(arguments,1)])},p.prototype.fcall=function(){return this.dispatch("apply",[void 0,Y(arguments)])},l.fbind=function(a){var b=l(a),c=Y(arguments,1);return function(){return b.dispatch("apply",[this,c.concat(Y(arguments))])}},p.prototype.fbind=function(){var a=this,b=Y(arguments);return function(){return a.dispatch("apply",[this,b.concat(Y(arguments))])}},l.keys=function(a){return l(a).dispatch("keys",[])},p.prototype.keys=function(){return this.dispatch("keys",[])},l.all=K,p.prototype.all=function(){return K(this)},l.any=L,p.prototype.any=function(){return L(this)},l.allResolved=k(M,"allResolved","allSettled"),p.prototype.allResolved=function(){return M(this)},l.allSettled=N,p.prototype.allSettled=function(){return this.then(function(a){return K(_(a,function(a){function b(){return a.inspect()}return a=l(a),a.then(b,b)}))})},l.fail=l["catch"]=function(a,b){return l(a).then(void 0,b)},p.prototype.fail=p.prototype["catch"]=function(a){return this.then(void 0,a)},l.progress=O,p.prototype.progress=function(a){return this.then(void 0,void 0,a)},l.fin=l["finally"]=function(a,b){return l(a)["finally"](b)},p.prototype.fin=p.prototype["finally"]=function(a){return a=l(a),this.then(function(b){return a.fcall().then(function(){return b})},function(b){return a.fcall().then(function(){throw b})})},l.done=function(a,b,c,d){return l(a).done(b,c,d)},p.prototype.done=function(a,c,d){var f=function(a){l.nextTick(function(){if(e(a,g),!l.onerror)throw a;l.onerror(a)})},g=a||c||d?this.then(a,c,d):this;"object"==typeof b&&b&&b.domain&&(f=b.domain.bind(f)),g.then(void 0,f)},l.timeout=function(a,b,c){return l(a).timeout(b,c)},p.prototype.timeout=function(a,b){var c=m(),d=setTimeout(function(){b&&"string"!=typeof b||(b=new Error(b||"Timed out after "+a+" ms"),b.code="ETIMEDOUT"),c.reject(b)},a);return this.then(function(a){clearTimeout(d),c.resolve(a)},function(a){clearTimeout(d),c.reject(a)},c.notify),c.promise},l.delay=function(a,b){return void 0===b&&(b=a,a=void 0),l(a).delay(b)},p.prototype.delay=function(a){return this.then(function(b){var c=m();return setTimeout(function(){c.resolve(b)},a),c.promise})},l.nfapply=function(a,b){return l(a).nfapply(b)},p.prototype.nfapply=function(a){var b=m(),c=Y(a);return c.push(b.makeNodeResolver()),this.fapply(c).fail(b.reject),b.promise},l.nfcall=function(a){var b=Y(arguments,1);return l(a).nfapply(b)},p.prototype.nfcall=function(){var a=Y(arguments),b=m();return a.push(b.makeNodeResolver()),this.fapply(a).fail(b.reject),b.promise},l.nfbind=l.denodeify=function(a){var b=Y(arguments,1);return function(){var c=b.concat(Y(arguments)),d=m();return c.push(d.makeNodeResolver()),l(a).fapply(c).fail(d.reject),d.promise}},p.prototype.nfbind=p.prototype.denodeify=function(){var a=Y(arguments);return a.unshift(this),l.denodeify.apply(void 0,a)},l.nbind=function(a,b){var c=Y(arguments,2);return function(){function d(){return a.apply(b,arguments)}var e=c.concat(Y(arguments)),f=m();return e.push(f.makeNodeResolver()),l(d).fapply(e).fail(f.reject),f.promise}},p.prototype.nbind=function(){var a=Y(arguments,0);return a.unshift(this),l.nbind.apply(void 0,a)},l.nmapply=l.npost=function(a,b,c){return l(a).npost(b,c)},p.prototype.nmapply=p.prototype.npost=function(a,b){var c=Y(b||[]),d=m();return c.push(d.makeNodeResolver()),this.dispatch("post",[a,c]).fail(d.reject),d.promise},l.nsend=l.nmcall=l.ninvoke=function(a,b){var c=Y(arguments,2),d=m();return c.push(d.makeNodeResolver()),l(a).dispatch("post",[b,c]).fail(d.reject),d.promise},p.prototype.nsend=p.prototype.nmcall=p.prototype.ninvoke=function(a){var b=Y(arguments,1),c=m();return b.push(c.makeNodeResolver()),this.dispatch("post",[a,b]).fail(c.reject),c.promise},l.nodeify=P,p.prototype.nodeify=function(a){return a?void this.then(function(b){l.nextTick(function(){a(null,b)})},function(b){l.nextTick(function(){a(b)})}):this},l.noConflict=function(){throw new Error("Q.noConflict only works when Q is used as a global")};var ja=j();return l})}).call(this,b("_process"))},{_process:44}],47:[function(a,b,c){b.exports=function(a,b,c){for(var d=0,e=a.length,f=3==arguments.length?c:a[d++];d<e;)f=b.call(null,f,a[d],++d,a);return f}},{}],48:[function(a,b,c){function d(a){var b;if(2===arguments.length&&"object"==typeof arguments[1])b=arguments[1];else{b=new Array(arguments.length-1);for(var c=1;c<arguments.length;++c)b[c-1]=arguments[c]}return b&&b.hasOwnProperty||(b={}),a.replace(e,function(c,d,e){var f;return"{"===a[e-1]&&"}"===a[e+c.length]?d:(f=b.hasOwnProperty(d)?b[d]:null,null===f||void 0===f?"":f)})}var e=/\{([0-9a-zA-Z_]+)\}/g;b.exports=d},{}],49:[function(a,b,c){function d(){}function e(a){if(!s(a))return a;var b=[];for(var c in a)null!=a[c]&&f(b,c,a[c]);return b.join("&")}function f(a,b,c){if(Array.isArray(c))return c.forEach(function(c){f(a,b,c)});if(s(c))for(var d in c)f(a,b+"["+d+"]",c[d]);else a.push(encodeURIComponent(b)+"="+encodeURIComponent(c))}function g(a){for(var b,c,d={},e=a.split("&"),f=0,g=e.length;f<g;++f)b=e[f],c=b.indexOf("="),c==-1?d[decodeURIComponent(b)]="":d[decodeURIComponent(b.slice(0,c))]=decodeURIComponent(b.slice(c+1));return d}function h(a){var b,c,d,e,f=a.split(/\r?\n/),g={};f.pop();for(var h=0,i=f.length;h<i;++h)c=f[h],b=c.indexOf(":"),d=c.slice(0,b).toLowerCase(),e=u(c.slice(b+1)),g[d]=e;return g}function i(a){return/[\/+]json\b/.test(a)}function j(a){return a.split(/ *; */).shift()}function k(a){return q(a.split(/ *; */),function(a,b){var c=b.split(/ *= */),d=c.shift(),e=c.shift();return d&&e&&(a[d]=e),a},{})}function l(a,b){b=b||{},this.req=a,this.xhr=this.req.xhr,this.text="HEAD"!=this.req.method&&(""===this.xhr.responseType||"text"===this.xhr.responseType)||"undefined"==typeof this.xhr.responseType?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText,this._setStatusProperties(this.xhr.status),this.header=this.headers=h(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this._setHeaderProperties(this.header),this.body="HEAD"!=this.req.method?this._parseBody(this.text?this.text:this.xhr.response):null}function m(a,b){var c=this;this._query=this._query||[],this.method=a,this.url=b,this.header={},this._header={},this.on("end",function(){var a=null,b=null;try{b=new l(c)}catch(d){return a=new Error("Parser is unable to parse the response"),a.parse=!0,a.original=d,a.rawResponse=c.xhr&&c.xhr.responseText?c.xhr.responseText:null,a.statusCode=c.xhr&&c.xhr.status?c.xhr.status:null,c.callback(a)}if(c.emit("response",b),a)return c.callback(a,b);try{if(b.status>=200&&b.status<300)return c.callback(a,b);var e=new Error(b.statusText||"Unsuccessful HTTP response");e.original=a,e.response=b,e.status=b.status,c.callback(e,b)}catch(d){c.callback(d)}})}function n(a,b){var c=t("DELETE",a);return b&&c.end(b),c}var o,p=a("emitter"),q=a("reduce"),r=a("./request-base"),s=a("./is-object");o="undefined"!=typeof window?window:"undefined"!=typeof self?self:this;var t=b.exports=a("./request").bind(null,m);t.getXHR=function(){if(!(!o.XMLHttpRequest||o.location&&"file:"==o.location.protocol&&o.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(a){}return!1};var u="".trim?function(a){return a.trim()}:function(a){return a.replace(/(^\s*|\s*$)/g,"")};t.serializeObject=e,t.parseString=g,t.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},t.serialize={"application/x-www-form-urlencoded":e,"application/json":JSON.stringify},t.parse={"application/x-www-form-urlencoded":g,"application/json":JSON.parse},l.prototype.get=function(a){return this.header[a.toLowerCase()]},l.prototype._setHeaderProperties=function(a){var b=this.header["content-type"]||"";this.type=j(b);var c=k(b);for(var d in c)this[d]=c[d]},l.prototype._parseBody=function(a){var b=t.parse[this.type];return!b&&i(this.type)&&(b=t.parse["application/json"]),b&&a&&(a.length||a instanceof Object)?b(a):null},l.prototype._setStatusProperties=function(a){1223===a&&(a=204);var b=a/100|0;this.status=this.statusCode=a,this.statusType=b,this.info=1==b,this.ok=2==b,this.clientError=4==b,this.serverError=5==b,this.error=(4==b||5==b)&&this.toError(),this.accepted=202==a,this.noContent=204==a,this.badRequest=400==a,this.unauthorized=401==a,this.notAcceptable=406==a,this.notFound=404==a,this.forbidden=403==a},l.prototype.toError=function(){var a=this.req,b=a.method,c=a.url,d="cannot "+b+" "+c+" ("+this.status+")",e=new Error(d);return e.status=this.status,e.method=b,e.url=c,e},t.Response=l,p(m.prototype);for(var v in r)m.prototype[v]=r[v];m.prototype.type=function(a){return this.set("Content-Type",t.types[a]||a),this},m.prototype.responseType=function(a){return this._responseType=a,this},m.prototype.accept=function(a){return this.set("Accept",t.types[a]||a),this},m.prototype.auth=function(a,b,c){switch(c||(c={type:"basic"}),c.type){case"basic":var d=btoa(a+":"+b);this.set("Authorization","Basic "+d);break;case"auto":this.username=a,this.password=b}return this},m.prototype.query=function(a){return"string"!=typeof a&&(a=e(a)),a&&this._query.push(a),this},m.prototype.attach=function(a,b,c){return this._getFormData().append(a,b,c||b.name),this},m.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},m.prototype.callback=function(a,b){var c=this._callback;this.clearTimeout(),c(a,b)},m.prototype.crossDomainError=function(){var a=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.");a.crossDomain=!0,a.status=this.status,a.method=this.method,a.url=this.url,this.callback(a)},m.prototype._timeoutError=function(){var a=this._timeout,b=new Error("timeout of "+a+"ms exceeded");b.timeout=a,this.callback(b)},m.prototype._appendQueryString=function(){var a=this._query.join("&");a&&(this.url+=~this.url.indexOf("?")?"&"+a:"?"+a)},m.prototype.end=function(a){var b=this,c=this.xhr=t.getXHR(),e=this._timeout,f=this._formData||this._data;this._callback=a||d,c.onreadystatechange=function(){if(4==c.readyState){var a;try{a=c.status}catch(d){a=0}if(0==a){if(b.timedout)return b._timeoutError();if(b._aborted)return;return b.crossDomainError()}b.emit("end")}};var g=function(a){a.total>0&&(a.percent=a.loaded/a.total*100),a.direction="download",b.emit("progress",a)};this.hasListeners("progress")&&(c.onprogress=g);try{c.upload&&this.hasListeners("progress")&&(c.upload.onprogress=g)}catch(h){}if(e&&!this._timer&&(this._timer=setTimeout(function(){b.timedout=!0,b.abort()},e)),this._appendQueryString(),this.username&&this.password?c.open(this.method,this.url,!0,this.username,this.password):c.open(this.method,this.url,!0),this._withCredentials&&(c.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof f&&!this._isHost(f)){var j=this._header["content-type"],k=this._serializer||t.serialize[j?j.split(";")[0]:""];!k&&i(j)&&(k=t.serialize["application/json"]),k&&(f=k(f))}for(var l in this.header)null!=this.header[l]&&c.setRequestHeader(l,this.header[l]);return this._responseType&&(c.responseType=this._responseType),this.emit("request",this),c.send("undefined"!=typeof f?f:null),this},t.Request=m,t.get=function(a,b,c){var d=t("GET",a);return"function"==typeof b&&(c=b,b=null),b&&d.query(b),c&&d.end(c),d},t.head=function(a,b,c){var d=t("HEAD",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},t.options=function(a,b,c){var d=t("OPTIONS",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},t.del=n,t["delete"]=n,t.patch=function(a,b,c){var d=t("PATCH",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},t.post=function(a,b,c){var d=t("POST",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},t.put=function(a,b,c){var d=t("PUT",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d}},{"./is-object":50,"./request":52,"./request-base":51,emitter:40,reduce:47}],50:[function(a,b,c){function d(a){return null!==a&&"object"==typeof a}b.exports=d},{}],51:[function(a,b,c){var d=a("./is-object");c.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},c.parse=function(a){return this._parser=a,this},c.serialize=function(a){return this._serializer=a,this},c.timeout=function(a){return this._timeout=a,this},c.then=function(a,b){if(!this._fullfilledPromise){var c=this;this._fullfilledPromise=new Promise(function(a,b){c.end(function(c,d){c?b(c):a(d)})})}return this._fullfilledPromise.then(a,b)},c.use=function(a){return a(this),this},c.get=function(a){return this._header[a.toLowerCase()]},c.getHeader=c.get,c.set=function(a,b){if(d(a)){for(var c in a)this.set(c,a[c]);return this}return this._header[a.toLowerCase()]=b,this.header[a]=b,this},c.unset=function(a){return delete this._header[a.toLowerCase()],delete this.header[a],this},c.field=function(a,b){return this._getFormData().append(a,b),this},c.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},c.withCredentials=function(){return this._withCredentials=!0,this},c.redirects=function(a){return this._maxRedirects=a,this},c.toJSON=function(){return{method:this.method,url:this.url,data:this._data}},c._isHost=function(a){var b={}.toString.call(a);switch(b){case"[object File]":case"[object Blob]":case"[object FormData]":return!0;default:return!1}},c.send=function(a){var b=d(a),c=this._header["content-type"];if(b&&d(this._data))for(var e in a)this._data[e]=a[e];else"string"==typeof a?(c||this.type("form"),c=this._header["content-type"],"application/x-www-form-urlencoded"==c?this._data=this._data?this._data+"&"+a:a:this._data=(this._data||"")+a):this._data=a;return!b||this._isHost(a)?this:(c||this.type("json"),this)}},{"./is-object":50}],52:[function(a,b,c){function d(a,b,c){return"function"==typeof c?new a("GET",b).end(c):2==arguments.length?new a("GET",b):new a(b,c)}b.exports=d},{}],53:[function(b,c,d){(function(a,b,c){"use strict";var d=function(a,b,c){c=e.extend({},e.options,c);var f,g,h=e.runValidations(a,b,c);for(f in h)for(g in h[f])if(e.isPromise(h[f][g]))throw new Error("Use validate.async if you want support for promises");return d.processValidationResults(h,c)},e=d;e.extend=function(a){return[].slice.call(arguments,1).forEach(function(b){for(var c in b)a[c]=b[c]}),a},e.extend(d,{version:{major:0,minor:9,patch:0,metadata:null,toString:function(){var a=e.format("%{major}.%{minor}.%{patch}",e.version);return e.isEmpty(e.version.metadata)||(a+="+"+e.version.metadata),a}},Promise:"undefined"!=typeof Promise?Promise:null,EMPTY_STRING_REGEXP:/^\s*$/,runValidations:function(a,b,c){var d,f,g,h,i,j,k,l=[];(e.isDomElement(a)||e.isJqueryElement(a))&&(a=e.collectFormValues(a));for(d in b){g=e.getDeepObjectValue(a,d),h=e.result(b[d],g,a,d,c,b);for(f in h){if(i=e.validators[f],!i)throw k=e.format("Unknown validator %{name}",{name:f}),new Error(k);j=h[f],j=e.result(j,g,a,d,c,b),j&&l.push({attribute:d,value:g,validator:f,globalOptions:c,attributes:a,options:j,error:i.call(i,g,j,d,a,c)})}}return l},processValidationResults:function(a,b){var c;switch(a=e.pruneEmptyErrors(a,b),a=e.expandMultipleErrors(a,b),a=e.convertErrorMessages(a,b),b.format||"grouped"){case"detailed":break;case"flat":a=e.flattenErrorsToArray(a);break;case"grouped":a=e.groupErrorsByAttribute(a);for(c in a)a[c]=e.flattenErrorsToArray(a[c]);break;default:throw new Error(e.format("Unknown format %{format}",b))}return e.isEmpty(a)?void 0:a},async:function(a,b,c){c=e.extend({},e.async.options,c);var d=c.wrapErrors||function(a){return a};c.cleanAttributes!==!1&&(a=e.cleanAttributes(a,b));var f=e.runValidations(a,b,c);return new e.Promise(function(g,h){e.waitForResults(f).then(function(){var i=e.processValidationResults(f,c);i?h(new d(i,c,a,b)):g(a)},function(a){h(a)})})},single:function(a,b,c){return c=e.extend({},e.single.options,c,{format:"flat",fullMessages:!1}),e({single:a},{single:b},c)},waitForResults:function(a){return a.reduce(function(a,b){return e.isPromise(b.error)?a.then(function(){return b.error.then(function(a){b.error=a||null},function(a){if(a instanceof Error)throw a;e.error("Rejecting promises with the result is deprecated. Please use the resolve callback instead."),b.error=a})}):a},new e.Promise(function(a){a()}))},result:function(a){var b=[].slice.call(arguments,1);return"function"==typeof a&&(a=a.apply(null,b)),a},isNumber:function(a){return"number"==typeof a&&!isNaN(a)},isFunction:function(a){return"function"==typeof a},isInteger:function(a){return e.isNumber(a)&&a%1===0},isObject:function(a){return a===Object(a)},isDate:function(a){return a instanceof Date},isDefined:function(a){return null!==a&&void 0!==a},isPromise:function(a){return!!a&&e.isFunction(a.then)},isJqueryElement:function(a){return a&&e.isString(a.jquery)},isDomElement:function(a){return!!a&&(!(!e.isFunction(a.querySelectorAll)||!e.isFunction(a.querySelector))&&(!(!e.isObject(document)||a!==document)||("object"==typeof HTMLElement?a instanceof HTMLElement:a&&"object"==typeof a&&null!==a&&1===a.nodeType&&"string"==typeof a.nodeName)))},isEmpty:function(a){var b;if(!e.isDefined(a))return!0;if(e.isFunction(a))return!1;if(e.isString(a))return e.EMPTY_STRING_REGEXP.test(a);if(e.isArray(a))return 0===a.length;if(e.isDate(a))return!1;if(e.isObject(a)){for(b in a)return!1;return!0}return!1},format:e.extend(function(a,b){return e.isString(a)?a.replace(e.format.FORMAT_REGEXP,function(a,c,d){return"%"===c?"%{"+d+"}":String(b[d])}):a},{FORMAT_REGEXP:/(%?)%\{([^\}]+)\}/g}),prettify:function(a){return e.isNumber(a)?100*a%1===0?""+a:parseFloat(Math.round(100*a)/100).toFixed(2):e.isArray(a)?a.map(function(a){return e.prettify(a)}).join(", "):e.isObject(a)?a.toString():(a=""+a,a.replace(/([^\s])\.([^\s])/g,"$1 $2").replace(/\\+/g,"").replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,function(a,b,c){return""+b+" "+c.toLowerCase()}).toLowerCase())},stringifyValue:function(a){return e.prettify(a)},isString:function(a){return"string"==typeof a},isArray:function(a){return"[object Array]"==={}.toString.call(a)},contains:function(a,b){return!!e.isDefined(a)&&(e.isArray(a)?a.indexOf(b)!==-1:b in a)},forEachKeyInKeypath:function(a,b,c){if(e.isString(b)){var d,f="",g=!1;for(d=0;d<b.length;++d)switch(b[d]){case".":g?(g=!1,f+="."):(a=c(a,f,!1),f="");break;case"\\":g?(g=!1,f+="\\"):g=!0;break;default:g=!1,f+=b[d]}return c(a,f,!0)}},getDeepObjectValue:function(a,b){if(e.isObject(a))return e.forEachKeyInKeypath(a,b,function(a,b){if(e.isObject(a))return a[b]})},collectFormValues:function(a,b){var c,d,f,g,h={};if(e.isJqueryElement(a)&&(a=a[0]),!a)return h;for(b=b||{},f=a.querySelectorAll("input[name], textarea[name]"),c=0;c<f.length;++c)d=f.item(c),e.isDefined(d.getAttribute("data-ignored"))||(g=e.sanitizeFormValue(d.value,b),"number"===d.type?g=g?+g:null:"checkbox"===d.type?d.attributes.value?d.checked||(g=h[d.name]||null):g=d.checked:"radio"===d.type&&(d.checked||(g=h[d.name]||null)),h[d.name]=g);for(f=a.querySelectorAll("select[name]"),c=0;c<f.length;++c)d=f.item(c),g=e.sanitizeFormValue(d.options[d.selectedIndex].value,b),h[d.name]=g;return h},sanitizeFormValue:function(a,b){return b.trim&&e.isString(a)&&(a=a.trim()),b.nullify!==!1&&""===a?null:a},capitalize:function(a){return e.isString(a)?a[0].toUpperCase()+a.slice(1):a},pruneEmptyErrors:function(a){return a.filter(function(a){return!e.isEmpty(a.error)})},expandMultipleErrors:function(a){var b=[];return a.forEach(function(a){e.isArray(a.error)?a.error.forEach(function(c){b.push(e.extend({},a,{error:c}))}):b.push(a)}),b},convertErrorMessages:function(a,b){b=b||{};var c=[];return a.forEach(function(a){var d=e.result(a.error,a.value,a.attribute,a.options,a.attributes,a.globalOptions);return e.isString(d)?("^"===d[0]?d=d.slice(1):b.fullMessages!==!1&&(d=e.capitalize(e.prettify(a.attribute))+" "+d),d=d.replace(/\\\^/g,"^"),d=e.format(d,{value:e.stringifyValue(a.value)}),void c.push(e.extend({},a,{error:d}))):void c.push(a)}),c},groupErrorsByAttribute:function(a){var b={};return a.forEach(function(a){var c=b[a.attribute];c?c.push(a):b[a.attribute]=[a]}),b},flattenErrorsToArray:function(a){return a.map(function(a){return a.error})},cleanAttributes:function(a,b){function c(a,b,c){return e.isObject(a[b])?a[b]:a[b]=!!c||{}}function d(a){var b,d={};for(b in a)a[b]&&e.forEachKeyInKeypath(d,b,c);return d}function f(a,b){if(!e.isObject(a))return a;var c,d,g=e.extend({},a);for(d in a)c=b[d],e.isObject(c)?g[d]=f(g[d],c):c||delete g[d];return g}return e.isObject(b)&&e.isObject(a)?(b=d(b),f(a,b)):{}},exposeModule:function(a,b,c,d,e){c?(d&&d.exports&&(c=d.exports=a),c.validate=a):(b.validate=a,a.isFunction(e)&&e.amd&&e([],function(){return a}))},warn:function(a){"undefined"!=typeof console&&console.warn&&console.warn("[validate.js] "+a)},error:function(a){"undefined"!=typeof console&&console.error&&console.error("[validate.js] "+a)}}),d.validators={presence:function(a,b){if(b=e.extend({},this.options,b),e.isEmpty(a))return b.message||this.message||"can't be blank"},length:function(a,b,c){if(!e.isEmpty(a)){b=e.extend({},this.options,b);var d,f=b.is,g=b.maximum,h=b.minimum,i=b.tokenizer||function(a){return a},j=[];a=i(a);var k=a.length;return e.isNumber(k)?(e.isNumber(f)&&k!==f&&(d=b.wrongLength||this.wrongLength||"is the wrong length (should be %{count} characters)",j.push(e.format(d,{count:f}))),e.isNumber(h)&&k<h&&(d=b.tooShort||this.tooShort||"is too short (minimum is %{count} characters)",j.push(e.format(d,{count:h}))),e.isNumber(g)&&k>g&&(d=b.tooLong||this.tooLong||"is too long (maximum is %{count} characters)",j.push(e.format(d,{count:g}))),j.length>0?b.message||j:void 0):(e.error(e.format("Attribute %{attr} has a non numeric value for `length`",{attr:c})),b.message||this.notValid||"has an incorrect length")}},numericality:function(a,b){if(!e.isEmpty(a)){b=e.extend({},this.options,b);var c,d,f=[],g={greaterThan:function(a,b){return a>b},greaterThanOrEqualTo:function(a,b){return a>=b},equalTo:function(a,b){return a===b},lessThan:function(a,b){return a<b},lessThanOrEqualTo:function(a,b){return a<=b}};if(b.noStrings!==!0&&e.isString(a)&&(a=+a),!e.isNumber(a))return b.message||b.notValid||this.notValid||"is not a number";if(b.onlyInteger&&!e.isInteger(a))return b.message||b.notInteger||this.notInteger||"must be an integer";for(c in g)if(d=b[c],e.isNumber(d)&&!g[c](a,d)){var h="not"+e.capitalize(c),i=b[h]||this[h]||"must be %{type} %{count}";f.push(e.format(i,{count:d,type:e.prettify(c)}))}return b.odd&&a%2!==1&&f.push(b.notOdd||this.notOdd||"must be odd"),b.even&&a%2!==0&&f.push(b.notEven||this.notEven||"must be even"),f.length?b.message||f:void 0}},datetime:e.extend(function(a,b){if(!e.isFunction(this.parse)||!e.isFunction(this.format))throw new Error("Both the parse and format functions needs to be set to use the datetime/date validator");if(!e.isEmpty(a)){b=e.extend({},this.options,b);var c,d=[],f=b.earliest?this.parse(b.earliest,b):NaN,g=b.latest?this.parse(b.latest,b):NaN;return a=this.parse(a,b),isNaN(a)||b.dateOnly&&a%864e5!==0?b.message||this.notValid||"must be a valid date":(!isNaN(f)&&a<f&&(c=this.tooEarly||"must be no earlier than %{date}",c=e.format(c,{date:this.format(f,b)}),d.push(c)),!isNaN(g)&&a>g&&(c=this.tooLate||"must be no later than %{date}",c=e.format(c,{date:this.format(g,b)}),d.push(c)),d.length?b.message||d:void 0)}},{parse:null,format:null}),date:function(a,b){return b=e.extend({},b,{dateOnly:!0}),e.validators.datetime.call(e.validators.datetime,a,b)},format:function(a,b){(e.isString(b)||b instanceof RegExp)&&(b={pattern:b}),b=e.extend({},this.options,b);var c,d=b.message||this.message||"is invalid",f=b.pattern;if(!e.isEmpty(a))return e.isString(a)?(e.isString(f)&&(f=new RegExp(b.pattern,b.flags)),c=f.exec(a),c&&c[0].length==a.length?void 0:d):d},inclusion:function(a,b){if(!e.isEmpty(a)&&(e.isArray(b)&&(b={within:b}),b=e.extend({},this.options,b),!e.contains(b.within,a))){var c=b.message||this.message||"^%{value} is not included in the list";return e.format(c,{value:a})}},exclusion:function(a,b){if(!e.isEmpty(a)&&(e.isArray(b)&&(b={within:b}),b=e.extend({},this.options,b),e.contains(b.within,a))){var c=b.message||this.message||"^%{value} is restricted";return e.format(c,{value:a})}},email:e.extend(function(a,b){b=e.extend({},this.options,b);var c=b.message||this.message||"is not a valid email";if(!e.isEmpty(a))return e.isString(a)&&this.PATTERN.exec(a)?void 0:c},{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(a,b,c,d){if(!e.isEmpty(a)){e.isString(b)&&(b={attribute:b}),b=e.extend({},this.options,b);var f=b.message||this.message||"is not equal to %{attribute}";if(e.isEmpty(b.attribute)||!e.isString(b.attribute))throw new Error("The attribute must be a non empty string");
16
+ var g=e.getDeepObjectValue(d,b.attribute),h=b.comparator||function(a,b){return a===b};return h(a,g,b,c,d)?void 0:e.format(f,{attribute:e.prettify(b.attribute)})}},url:function(a,b){if(!e.isEmpty(a)){b=e.extend({},this.options,b);var c=b.message||this.message||"is not a valid url",d=b.schemes||this.schemes||["http","https"],f=b.allowLocal||this.allowLocal||!1;if(!e.isString(a))return c;var g="^(?:(?:"+d.join("|")+"):\\/\\/)(?:\\S+(?::\\S*)?@)?";g+="(?:";var h="(?:(?:[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,})))";f?h="(?:localhost|"+h+")":g+="(?!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})",g+="(?:[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]))|"+h+"(?::\\d{2,5})?(?:\\/[^\\s]*)?$";var i=new RegExp(g,"i");return i.exec(a)?void 0:c}}},d.exposeModule(d,this,a,b,c)}).call(this,"undefined"!=typeof d?d:null,"undefined"!=typeof c?c:null,"undefined"!=typeof a?a:null)},{}]},{},[1])(1)});