comprodls-sdk 2.31.2 → 2.32.0

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,18 +1,21 @@
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(u.DEFAULT_HOSTS=u.REALM_HOSTS[b.toUpperCase()][a.toUpperCase()],!u.DEFAULT_HOSTS)throw"Invalid Environment"}catch(d){var e,f=u.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=u,this.environment=a,c.orgid&&c.token){var e=A.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/activity"),j=a("./services/analytics"),k=a("./services/collab"),l=a("./services/product"),m=a("./services/xapi"),n=a("./services/attempts"),o=a("./services/push"),p=a("./services/pushX"),q=a("./services/pub"),r=a("./services/sisevents"),s=a("./services/lrs"),t=a("./services/spaces"),u=a("./config"),v=a("./open_access"),w=a("./services/superuser"),x=a("./services/invitations"),y=a("./services/workflows"),z=a("./services/integrations"),A=a("./token/validations"),B=a("./services/drive"),C=a("./services/taxonomy"),D=a("./services/rules");c.init=d,e.prototype.authWithCredentials=f.authWithCredentials,e.prototype.authWithToken=f.authWithToken,e.prototype.authWithExtUser=f.authWithExtUser,e.prototype.getClassEnrolmentsStat=v.getClassEnrolmentsStat,e.prototype.getSingleInvitation=v.getSingleInvitation,e.prototype.request=g.api.genericAPICaller,e.prototype.Auth=h,e.prototype.Activity=i,e.prototype.Analytics=j,e.prototype.Collab=k,e.prototype.Product=l,e.prototype.Xapi=m,e.prototype.Attempts=n,e.prototype.Push=o,e.prototype.Pub=q,e.prototype.SISEvents=r,e.prototype.LRS=s,e.prototype.PushX=p,e.prototype.Spaces=t,e.prototype.Superuser=w,e.prototype.Invitations=x,e.prototype.Workflows=y,e.prototype.Integrations=z,e.prototype.Drive=B,e.prototype.Taxonomy=C,e.prototype.Rules=D},{"./config":2,"./helpers":3,"./open_access":10,"./services/activity":13,"./services/analytics":14,"./services/attempts":15,"./services/auth":16,"./services/collab":17,"./services/drive":18,"./services/integrations":19,"./services/invitations":20,"./services/lrs":21,"./services/product":22,"./services/pub":23,"./services/push":26,"./services/pushX":24,"./services/rules":27,"./services/sisevents":28,"./services/spaces":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",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",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",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",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",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",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",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",getAllJobs:"/accounts/{accountId}/ext-users/{extUserId}/jobs",getJob:"/accounts/{accountId}/ext-users/{extUserId}/jobs/{jobId}",getAllClassesAPI:"/org/{orgId}/classes",getParticularClassAPI:"/org/{orgId}/classes/{classId}",getParticularShadowClassAPI:"/org/{orgId}/shadow/classes/{extClassId}",classProductAssociation:"/org/{orgId}/classes/{classId}/associate-product/{productcode}",multiClassProductAssociations:"/org/{orgId}/classes/{classId}/associate-product/multi",enrollUsertoClass:"/org/{orgId}/classes/{classId}/enroll-user/{userId}",enrollSelftoClass:"/org/{orgId}/classes/{classId}/enroll-self",enrollMultiUserstoClass:"/org/{orgId}/classes/{classId}/enroll-user/multi",createClass:"/org/{orgId}/classes",createMultipleClasses:"/org/{orgId}/classes/multi",specificClass:"/org/{orgId}/classes/{classId}",cloneClass:"/org/{orgId}/classes/{classId}/clone",ClassAppdata:"/org/{orgId}/classes/{classid}/appdata",generateClassCode:"/org/{orgId}/classes/{classId}/class-code/generate",getUserSpaces:"/accounts/{accountid}/ext-users/{extuserid}/spaces",validateSpaceCode:"/accounts/{accountid}/space-code/validate",validateClassCode:"/accounts/{accountid}/class-code/validate",joinInstituteSpace:"/accounts/{accountid}/join-institute-space",provisionSpacesToStudent:"/accounts/{accountId}/student/provision-spaces",provisionSpacesToTeacher:"/accounts/{accountId}/teacher/provision-spaces",shadowProvision:"/org/{orgId}/shadow-provision",provisionBulkSpaces:"/org/{orgId}/provision-spaces/bulk",entitleUserToProduct:"/accounts/{accountId}/entitle-user",microEntitleUserToProduct:"/accounts/{accountId}/entitle-user/micro",bulkMicroEntitleProductToUser:"/accounts/{accountId}/entitle-user/micro/bulk",enrollUserInClass:"/accounts/{accountId}/enroll-with-classcode",getExtProductAPI:"/accounts/{accountId}/products/{extProductId}",getSpaceDetails:"/accounts/{accountId}/spaces/{spacekey}",updateUserInformation:"/accounts/{accountId}/update-user-information",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"},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",getAllAssignedPathsOfClass:"/{orgId}/class/assigned-paths",getMyAssignedPathsOfClass:"/{orgId}/user/class/assigned-paths",getAssignedPathAnalytics:"/{orgId}/class/assigned-paths/aggregations",getTimeseriesAnalytics:"/progress/timeseries"},c.SISEVENTS_API_URLS={postSingleSISEvent:"/{orgId}/events",postMultiSISEvent:"/{orgId}/events/multi"},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",resetUserProductProgress:"/accounts/{accountId}/progress/user/product/reset"},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"},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"},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",updateSchedule:"/accounts/{accountId}/context/{context}/schedule/{scheduleId}"},c.DRIVE_API_URLS={getAParticularDocument:"/accounts/{accountid}/users/{extuserid}/documents/{documentid}",getAllDocumentsInAFolder:"/accounts/{accountid}/users/{extuserid}/documents"},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:90,"string-template":131,superagent:133}],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=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":141}],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:90,superagent:133}],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:68,q:90,superagent:133}],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(){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);
2
- 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:68,q:90,superagent:133}],13:[function(a,b,c){b.exports=a("./activity")},{"./activity":11}],14:[function(a,b,c){function d(){return{archiveUserAnalytics:i.bind(this),getArchivedUserAnalytics:y.bind(this),getOrgAnalyticsStat:e.bind(this),getClassAnalytics:x.bind(this),getClassProductRecentPendingSubmissions:p.bind(this),getClassRecordUserAggregations:w.bind(this),getClassRecord:q.bind(this),getClassRecordItemAggregations:r.bind(this),getShowcaseRecordOfAClass:s.bind(this),getGroupRecord:t.bind(this),getClassGroupsRecentPendingSubmissions:u.bind(this),getGroupsWithEvaluatedOnce:v.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),getQuestionProgressByLearningObjective:z.bind(this),getAllAssignedPathsOfClass:A.bind(this),getMyAssignedPathsOfClass:C.bind(this),getAssignedPathAnalytics:B.bind(this),getMyParticularAssignedPathOfClass:D.bind(this),getTimeseriesAnalytics:E.bind(this)}}function e(a){var b=this,c=F.defer(),d={};if(a&&a.type)if(d=I.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=I.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=G.get(f).query(g);h=I.api.setupAPIToken(h,b.token),b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h.end(function(a,b){a?(a=new J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d)}else d.message=d.description="type not found in request options",d=new J(I.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function f(a){var b=this,c=F.defer(),d={};if(a&&a.type&&a.userid&&a.productcode)if(d=I.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=I.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=G.get(f).query(g);h=I.api.setupAPIToken(h,b.token),b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h.end(function(a,b){a?(a=new J(I.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 J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function g(a){var b=this,c=F.defer(),d={};if(a&&a.userprogressid)if(d=I.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getAnalyticProductById;e=I.api.constructAPIUrl(e,{orgId:b.orgId,userProgressId:a.userprogressid});var f=G.get(e);f=I.api.setupAPIToken(f,b.token),b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function h(a){var b=this,c=F.defer(),d={};if(a&&a.ext_user_id&&a.productcode&&a.itemcode&&(a.submission_order||a.ext_link_id)&&a.part)if(d=I.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getExternalDataForUserAnalyticItem;e=I.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=G.get(e).query(f);g=I.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function i(a){var b=this,c={},d=F.defer();if(a&&a.userid&&a.productid)if(c=I.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=I.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=G.post(f).query(e).set("Content-Type","application/json");g=I.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function j(a){var b=this,c={},d=F.defer();if(c=I.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=I.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=G.get(f).query(e);g=I.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.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 k(a){var b=this,c=F.defer(),d={};if(a&&a.classid&&a.productcode&&a.userid)if(d=I.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getUserClassRecentSubmissions;e=I.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=G.get(e).query(f);g=I.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function l(a){var b=this,c={},d=F.defer();if(a&&a.classid&&a.productcode)if(c=I.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getStudentsWithEvaluatedOnce;e=I.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode},g=G.get(e).query(f);g=I.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(c=new J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function m(a){var b=this,c=F.defer(),d={};if(a&&a.userid&&a.productcode)if(d=I.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.appState;e=I.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=G.get(e).query(f);g=I.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function n(a){var b=this,c=F.defer(),d={};if(a&&a.userid&&a.productcode&&a.appdata)if(d=I.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.appState;e=I.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=G.put(e).query(f).set("Content-Type","application/json").set("Accept","application/json").send(a.appdata);g=I.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function o(a){var b=this,c=F.defer(),d={};if(a&&a.userid&&a.productcode)if(d=I.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.appState;e=I.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=G["delete"](e).query(f);g=I.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function p(a){var b=this,c=F.defer(),d={};if(a&&a.classid&&a.productcode)if(d=I.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassProductRecentPendingSubmissions;e=I.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=G.get(e).query(f);g=I.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function q(a){var b=this,c=F.defer(),d={};if(a&&a.classid&&a.productcode)if(d=I.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassRecord;e=I.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode,includeContext:a.includeContext},g=G.get(e).query(f);g=I.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function r(a){var b=this,c=F.defer(),d={};if(a&&a.classid&&a.productcode)if(d=I.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassRecordItemAggregations;e=I.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode,"item-code":a["item-code"]},g=G.get(e).query(f);g=I.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function s(a){var b=this,c=F.defer(),d={};if(a&&a.classid)if(d=I.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getShowcaseRecordOfAClass;e=I.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=G.get(e).query(f);g=I.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function t(a){var b=this,c=F.defer(),d={};if(a&&a.classid&&a.productcode&&a.groupid)if(d=I.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getGroupRecord;e=I.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=G.get(e).query(f);g=I.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function u(a){var b=this,c=F.defer(),d={};if(a&&a.classid&&a.productcode)if(d=I.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassGroupsRecentPendingSubmissions;e=I.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=G.get(e).query(f);g=I.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function v(a){var b=this,c={},d=F.defer();if(a&&a.classid&&a.productcode)if(c=I.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getGroupsWithEvaluatedOnce;e=I.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode},g=G.get(e).query(f);g=I.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(c=new J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function w(a){var b=this,c={},d=F.defer();if(a&&a.classid&&a.productcode)if(c=I.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassRecordUserAggregations;e=I.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode,userid:a.userid},g=G.get(e).query(f);g=I.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(c=new J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function x(a){var b=this,c=F.defer(),d={};if(a&&a.type&&a.analyticsDataType&&a.classid)if(d=I.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=I.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=G.get(f).query(g);h=I.api.setupAPIToken(h,b.token),b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h.end(function(a,b){a?(a=new J(I.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 J(I.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 J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function y(a){var b=this,c=F.defer(),d={};if(a&&a.useranalyticid)if(d=I.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getArchivedUserAnalytics;e=I.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=G.get(e).query(f);g=I.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function z(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 A(a){var b=this,c=F.defer(),d=I.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=I.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid},g=G.get(e).query(f);g=I.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function B(a){var b=this,c=F.defer(),d=I.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.assignedPathId&&a.productcode){var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getAssignedPathAnalytics;e=I.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,assignedpathid:a.assignedPathId,productcode:a.productcode},g=G.get(e).query(f);g=I.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new J(I.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - classid or assignedPathId or productcode not found in request options.",d=new J(I.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function C(a){var b=this,c=F.defer(),d=I.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=I.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);var g=G.get(e).query(f);g=I.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function D(a){var b=this,c=F.defer(),d=I.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.userid&&a.assignedPathId){var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getMyAssignedPathsOfClass;e=I.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);var g=G.get(e).query(f);g=I.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new J(I.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - classid, userid, assignedPathId not found in request options.",d=new J(I.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function E(a){var b,c=this,d=F.defer();if(a&&a.query){var e=c.config.DEFAULT_HOSTS.ANALYTICS+c.config.ANALYTICS_API_URLS.getTimeseriesAnalytics,f={query:a.query};a.cursor&&(f.cursor=a.cursor);var g=G.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.agent(K).end(function(a,c){a?(b=new J(I.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 J(I.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}var F=a("q"),G=a("superagent"),H=a("agentkeepalive"),I=a("../../helpers"),J=I.errors.DLSError;b.exports=d;var K=new H({timeout:6e4,freeSocketTimeout:3e4})},{"../../helpers":3,agentkeepalive:37,q:90,superagent:133}],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)}}function e(a){var b,c=this,d=k.defer();if(a&&a.userid&&a.activityid){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.userAttempts;e=m.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=l.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new n(m.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 n(m.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function f(a){var b,c=this,d=k.defer();if(a&&a.userid&&a.activityid&&a.body){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.userAttempts;e=m.api.constructAPIUrl(e,{orgId:c.orgId,userId:a.userid,activityId:a.activityid});var f=l.post(e).send(a.body);c.traceid&&f.set("X-Amzn-Trace-Id",c.traceid),f.end(function(a,b){a?(a=new n(m.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 n(m.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function g(a){var b,c=this,d=k.defer();if(a&&a.userid&&a.activityid){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.getUserAttemptStatsForActivity;e=m.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=l.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new n(m.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 n(m.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function h(a){var b,c=this,d=k.defer();if(a&&a.userid&&a.activityid&&a.attemptid){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.getUserAttemptForActivity;e=m.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=l.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new n(m.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 n(m.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function i(a){var b,c=this,d=k.defer();if(a&&a.userid&&a.activityid){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.getUserFirstAttemptForActivity;e=m.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=l.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new n(m.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 n(m.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function j(a){var b,c=this,d=k.defer();if(a&&a.userid&&a.activityid){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.getUserLastAttemptForActivity;e=m.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=l.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 n(m.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 n(m.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}var k=a("q"),l=a("superagent"),m=a("../../helpers"),n=m.errors.DLSError;b.exports=d},{"../../helpers":3,q:90,superagent:133}],16:[function(a,b,c){function d(){return{pisImport:k.bind(this),getAllUsers:g.bind(this),getUserProfile:e.bind(this),deleteUserProfile:f.bind(this),updateUserRole:h.bind(this),getUserClasses:i.bind(this),getClassUsers:j.bind(this),enrollUsertoClass:z.bind(this),enrollSelftoClass:A.bind(this),enrollMultiUserstoClass:B.bind(this),unEnrollMultiUserstoClass:C.bind(this),unEnrollUsertoClass:D.bind(this),getOrgSettings:l.bind(this),updateOrgSettings:m.bind(this),generateClassCode:n.bind(this),getAllJobs:o.bind(this),getJob:p.bind(this),createClass:F.bind(this),updateClass:G.bind(this),createMultipleClasses:H.bind(this),deleteClass:I.bind(this),cloneClass:$.bind(this),getAllClasses:q.bind(this),getParticularClass:r.bind(this),getParticularShadowClass:s.bind(this),createClassProductAssociation:t.bind(this),removeClassProductAssociation:u.bind(this),createMultiClassProductAssociations:v.bind(this),addItemsToShowcaseOfAClass:Y.bind(this),deleteItemsFromShowcaseOfAClass:Z.bind(this),getClassAppdata:w.bind(this),putClassAppdata:x.bind(this),deleteClassAppdata:y.bind(this),encodeURLParameter:E.bind(this),createAssignedPath:J.bind(this),deleteAssignedPath:K.bind(this),updateAssignedPath:L.bind(this),createGroup:M.bind(this),getAllGroupsByPath:N.bind(this),getAGroup:O.bind(this),updateGroup:P.bind(this),deleteGroup:Q.bind(this),getAllMembersOfAGroup:R.bind(this),getAllGroupMembersByPath:S.bind(this),createMultiUserGroupMembership:T.bind(this),deleteMultiUserGroupMembership:U.bind(this),getMyAllMemberships:X.bind(this),archiveGroup:V.bind(this),unarchiveGroup:W.bind(this)}}function e(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(f,{orgId:b.orgId,userId:e});var g={},h=aa.get(f).query(g);b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h=ca.api.setupAPIToken(h,b.token),h.end(function(a,b){if(a)a=new ea(ca.errors.ERROR_TYPES.API_ERROR,a),c.reject(a);else{var d=da.convertUserResponse({data:b.body});c.resolve(d)}})}return c.promise}function f(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(f,{orgId:b.orgId,userId:e});var g=aa["delete"](f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function g(a){var b=this,c=_.defer(),d=ca.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();
3
- });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=ca.api.constructAPIUrl(p,{index:"users"});var q={query:JSON.stringify(o)},r=aa.get(p).query(q);b.traceid&&r.set("X-Amzn-Trace-Id",b.traceid),r=ca.api.setupAPIToken(r,b.token),r.end(function(d,e){if(d){var f={type:ca.errors.ERROR_TYPES.API_ERROR,err:d},g=da.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=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,userId:a.userid});var f={ext_data:a.ext_data,target_role:a.target_role},g=aa.put(e).set("Content-Type","application/json").set("Accept","application/json").send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,h),c.reject(h)}return c.promise}function i(a){var b=this,c=_.defer(),d=ca.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=ca.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=aa.get(f).query(g);b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h=ca.api.setupAPIToken(h,b.token),h.end(function(a,b){a?(a=new ea(ca.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}return c.promise}function j(a){var b=this,c=_.defer(),d=ca.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=ca.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=aa.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.agent(fa).end(function(a,b){a?(a=new ea(ca.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):(b.body.entities=da.convertEnrollmetsResponse({data:b.body.entities}),c.resolve(b.body))})}else d={},d.message=d.description="Required parameter classid is not defined.",d=new ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function k(a){var b=this,c=_.defer(),d=ca.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=ca.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=aa.post(e).query(g).set("Content-Type","multipart/form-data").attach("upfile",f);b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h=ca.api.setupAPIToken(h,b.token),h.end(function(a,b){a?(a=new ea(ca.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}return c.promise}function l(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId});var f={};a&&a.field&&(e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getSettingsField,e=ca.api.constructAPIUrl(e,{orgId:b.orgId,field:a.field}));var g=aa.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new ea(ca.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}return c.promise}function m(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId});var f=aa.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=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new ea(ca.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}return c.promise}function n(a){var b,c=this,d=_.defer();if(a&&a.classid)if(b=ca.validations.isAuthenticated(c.orgId,c.token))d.reject(b);else{var e=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.generateClassCode;e=ca.api.constructAPIUrl(e,{orgId:c.orgId,classId:a.classid});var f=aa.post(e);c.traceid&&f.set("X-Amzn-Trace-Id",c.traceid),f=ca.api.setupAPIToken(f,c.token),f.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function o(a){var b=this,c=_.defer();if(a&&a.accountId&&a.extUserId){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getAllJobs;d=ca.api.constructAPIUrl(d,{accountId:a.accountId,extUserId:a.extUserId});var e={};a.jobType&&(e.jobType=a.jobType);var f=aa.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(g=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function p(a){var b=this,c=_.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=ca.api.constructAPIUrl(d,{accountId:a.accountId,extUserId:a.extUserId,jobId:a.jobId});var e={jobType:a.jobType},f=aa.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(g=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function q(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(m,{index:"classes"});var n={query:JSON.stringify(l)},o=aa.get(m).query(n);b.traceid&&o.set("X-Amzn-Trace-Id",b.traceid),o=ca.api.setupAPIToken(o,b.token),o.end(function(b,d){if(b){var e={type:ca.errors.ERROR_TYPES.API_ERROR,err:b},f=da.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,studentCount:j.studentCount,teacherCount:j.teacherCount};j.tagid_1&&(k.tagid_1=j.tagid_1,k.tagname_1=j.tagname_1,k.taglookup_1=j.taglookup_1),j.tagid_2&&(k.tagid_2=j.tagid_2,k.tagname_2=j.tagname_2,k.taglookup_2=j.taglookup_2),j.tagid_3&&(k.tagid_3=j.tagid_3,k.tagname_3=j.tagname_3,k.taglookup_3=j.taglookup_3),g.entities.push(k)}c.resolve(g)}})}return c.promise}function r(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId});var f=aa.get(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.agent(fa).end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function s(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,extClassId:a.ext_classid});var f=aa.get(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function t(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId,productcode:a.productcode});var f=aa.post(e).set("Content-Type","application/json").set("Accept","application/json");b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function u(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId,productcode:a.productcode});var f={},g=aa["delete"](e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function v(a){var b=_.defer(),c=this,d=ca.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=ca.api.constructAPIUrl(g,{orgId:c.orgId,classId:a.classId});var i=aa.post(g).set("Content-Type","application/json").set("Accept","application/json").send(h);c.traceid&&i.set("X-Amzn-Trace-Id",c.traceid),i=ca.api.setupAPIToken(i,c.token),i.end(function(a,c){a?(d=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),b.reject(d);return b.promise}function w(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classid:a.classid});var f=aa.get(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function x(a){var b=this,c=_.defer(),d=ca.validations.isAuthenticated(b.orgId,b.token);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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classid:a.classid});var f=aa.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=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function y(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classid:a.classid});var f=aa["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function z(a){var b=this,c={},d=_.defer();if(a&&a.classid&&a.userid)if(c=ca.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.enrollUsertoClass;e=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid,userId:a.userid});var f={},g=aa.post(e).set("Content-Type","application/json").set("Accept","application/json").query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function A(a){var b=this,c={},d=_.defer();if(a&&a.classid)if(c=ca.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.enrollSelftoClass;e=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f={classrole:a.classrole},g=aa.post(e).set("Content-Type","application/json").set("Accept","application/json").send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function B(a){var b=this,c={},d=_.defer();if(a&&a.classid&&a.users)if(c=ca.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.enrollMultiUserstoClass;e=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f={users:a.users},g=aa.post(e).set("Content-Type","application/json").set("Accept","application/json").send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function C(a){var b=this,c={},d=_.defer();if(a&&a.classid&&a.users)if(c=ca.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.enrollMultiUserstoClass;e=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f={users:a.users},g=aa["delete"](e).set("Content-Type","application/json").set("Accept","application/json").send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function D(a){var b=this,c={},d=_.defer();if(a&&a.classid&&a.userid)if(c=ca.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.enrollUsertoClass;e=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid,userId:a.userid});var f={},g=aa["delete"](e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function E(a){var b={};for(var c in a)b[a[c]]=encodeURIComponent(a[c]);return b}function F(a){var b=this,c=_.defer(),d=ca.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=ca.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);var g=aa.post(e).send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){if(a)a=new ea(ca.errors.ERROR_TYPES.API_ERROR,a),c.reject(a);else{var d=da.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function G(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f=aa.put(e).send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function H(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId});var f=aa.post(e).send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function I(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f=aa["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=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function J(a){var b=this,c=_.defer(),d=ca.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.data&&a.data.title&&a.data.duedate&&a.data.items&&a.data.items.length>0){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.createAssignedPath;e=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f=aa.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=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new ea(ca.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 duedate or items not found in request options.",d=new ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function K(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid,assignedPathId:a.assignedpathid});var f=aa["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function L(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid,assignedPathId:a.assignedpathid});var f=aa.put(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),a.data&&f.send(a.data),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function M(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId});var f=aa.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function N(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId});var f={path:a.path};a.cursor&&(f.cursor=a.cursor);var g=aa.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(d=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function O(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,groupId:a.groupId});var f=aa.get(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function P(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,groupId:a.groupId});var f=aa.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=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function Q(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,groupId:a.groupId});var f=aa["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function R(a){var b=this,c=_.defer(),d={},e=ca.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=ca.api.constructAPIUrl(f,{orgId:b.orgId,groupId:a.groupId}),a.cursor&&(d.cursor=a.cursor);var g=aa.get(f).set("Content-Type","application/json").set("Accept","application/json").send(d);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(e=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function S(a){var b=this,c=_.defer(),d={},e=ca.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=ca.api.constructAPIUrl(f,{orgId:b.orgId}),d.path=a.path,a.cursor&&(d.cursor=a.cursor);var g=aa.get(f).set("Content-Type","application/json").set("Accept","application/json").query(d);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(e=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function T(a){var b=this,c=_.defer(),d={},e=ca.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=ca.api.constructAPIUrl(f,{orgId:b.orgId,groupId:a.groupId}),d=a.body;var g=aa.post(f).set("Content-Type","application/json").set("Accept","application/json").send(d);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(e=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function U(a){var b=this,c=_.defer(),d={},e=ca.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=ca.api.constructAPIUrl(f,{orgId:b.orgId,groupId:a.groupId}),d=a.body;var g=aa["delete"](f).set("Content-Type","application/json").set("Accept","application/json").send(d);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(e=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function V(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,groupId:a.groupId});var f=aa.put(e).set("Content-Type","application/json").set("Accept","application/json").send({});b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function W(a){var b=this,c=_.defer(),d=ca.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;
4
- e=ca.api.constructAPIUrl(e,{orgId:b.orgId,groupId:a.groupId});var f=aa.put(e).set("Content-Type","application/json").set("Accept","application/json").send({});b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function X(a){var b=this,c=_.defer(),d={},e=ca.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=ca.api.constructAPIUrl(f,{orgId:b.orgId,userId:a.userId}),d.path=a.path,a.cursor&&(d.cursor=a.cursor);var g=aa.get(f).set("Content-Type","application/json").set("Accept","application/json").query(d);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(e=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function Y(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId});var f=aa.post(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.send(a.body),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function Z(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId});var f=aa["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.send(a.body),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function $(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f=aa.post(e).send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}var _=a("q"),aa=a("superagent"),ba=a("agentkeepalive"),ca=a("../../helpers"),da=a("../../helpers/lib/api/converter"),ea=ca.errors.DLSError;b.exports=d;var fa=new ba({timeout:6e4,freeSocketTimeout:3e4})},{"../../helpers":3,"../../helpers/lib/api/converter":4,agentkeepalive:37,q:90,superagent:133}],17:[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:90,superagent:133}],18:[function(a,b,c){function d(){return{getAParticularDocument:e.bind(this),getAllDocumentsInAFolder:f.bind(this)}}function e(a){var b=this,c=g.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=i.api.constructAPIUrl(d,e);var f={folderid:a.folderid},k=h.get(d).query(f);b.traceid&&k.set("X-Amzn-Trace-Id",b.traceid),k.end(function(a,b){a?(a=new j(i.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else{var l={};l.message=l.description="Mandatory params - accountid or extuserid or documentid or folderid not found in request options.",l=new j(i.errors.ERROR_TYPES.SDK_ERROR,l),c.reject(l)}return c.promise}function f(a){var b=this,c=g.defer();if(a&&a.accountid&&a.extuserid&&a.folderid){var d=b.config.DEFAULT_HOSTS.DRIVE+b.config.DRIVE_API_URLS.getAllDocumentsInAFolder;d=i.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=h.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new j(i.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else{var k={};k.message=k.description="Mandatory params - accountid or extuserid or folderid not found in request options.",k=new j(i.errors.ERROR_TYPES.SDK_ERROR,k),c.reject(k)}return c.promise}var g=a("q"),h=a("superagent"),i=a("../../helpers"),j=i.errors.DLSError;b.exports=d},{"../../helpers":3,q:90,superagent:133}],19:[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)}}function e(){var a,b=this,c=n.defer(),d=b.config.DEFAULT_HOSTS.INTEGRATION+b.config.INTEGRATIONS_API_URLS.getGetStreamCredentials;d=p.api.constructAPIUrl(d,{accountId:b.accountId});var e=o.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 r(p.errors.ERROR_TYPES.API_ERROR,b),c.reject(a)):c.resolve(d)}),c.promise}function f(a){var b,c=this,d=n.defer();if(a&&a.index&&a.query){var e=c.config.DEFAULT_HOSTS.INTEGRATION+c.config.INTEGRATIONS_API_URLS.queryDataFromSearch;e=p.api.constructAPIUrl(e,{index:a.index});var f={query:a.query},g=o.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){if(a){var c={type:p.errors.ERROR_TYPES.API_ERROR,err:a},e=q.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 r(p.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function g(a){var b,c=this,d=n.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=p.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=o.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new r(p.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 r(p.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function h(a){var b,c=this,d=n.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=p.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=o.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new r(p.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 r(p.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function i(a){var b,c=this,d=n.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=p.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=o.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new r(p.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 r(p.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function j(a){var b,c=n.defer(),d=this;if(a&&a.events){var e=d.config.DEFAULT_HOSTS.INTEGRATION+d.config.INTEGRATIONS_API_URLS.customEvents;e=p.api.constructAPIUrl(e,{accountId:d.accountId});var f=o.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 r(p.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 r(p.errors.ERROR_TYPES.SDK_ERROR,b),c.reject(b);return c.promise}function k(a){var b,c=n.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=p.api.constructAPIUrl(e,{accountId:a.accountid,context:a.context});var f=o.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 r(p.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 r(p.errors.ERROR_TYPES.SDK_ERROR,b),c.reject(b);return c.promise}function l(a){var b,c=n.defer(),d=this;if(a&&a.context&&a.accountid){var e=d.config.DEFAULT_HOSTS.INTEGRATION+d.config.INTEGRATIONS_API_URLS.schedules;e=p.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=o.get(e).query(f);d.traceid&&g.set("X-Amzn-Trace-Id",d.traceid),g.end(function(a,d){a?(b=new r(p.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 r(p.errors.ERROR_TYPES.SDK_ERROR,b),c.reject(b);return c.promise}function m(a){var b,c=n.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.updateSchedule;e=p.api.constructAPIUrl(e,{accountId:a.accountid,context:a.context,scheduleId:a.scheduleid});var f=o.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 r(p.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 r(p.errors.ERROR_TYPES.SDK_ERROR,b),c.reject(b);return c.promise}var n=a("q"),o=a("superagent"),p=a("../../helpers"),q=a("../../helpers/lib/api/converter"),r=p.errors.DLSError;b.exports=d},{"../../helpers":3,"../../helpers/lib/api/converter":4,q:90,superagent:133}],20:[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:90,superagent:133}],21:[function(a,b,c){function d(){var a={};try{this.lrs=new g.LRS({endpoint:this.config.DEFAULT_HOSTS.XAPI+"/"+this.orgId+"/tapi",auth:this.token.access_token,allowFail:!1}),this.tincan=new g({recordStores:[this.lrs]})}catch(b){return b.description="Error while initializing lrs.",b.message=b.description,a=new j(i.errors.ERROR_TYPES.SDK_ERROR,b),b}return{getStatement:e.bind(this),createStatement:f.bind(this)}}function e(a){var b=this,c=h.defer(),d={},e=!1;return a&&(d={limit:a.limit||10,since:a.since||null,until:a.until||null},a.actor&&(d.agent=new g.Agent(a.actor)),a.verb&&(d.verb=new g.Verb(a.verb)),a.moreUrl&&(e=!0),a.registration&&(d.registration=a.registration)),e?b.lrs.moreStatements({url:a.moreUrl,callback:function(a,b){if(null!==a){var d=new j(i.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else{var e=[];for(var f in b.statements)e.push(JSON.parse(b.statements[f].originalJSON));b.statements=e,c.resolve(b)}}}):b.lrs.queryStatements({params:d,callback:function(a,b){if(null!==a){var d=new j(i.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else{var e=[];for(var f in b.statements)e.push(JSON.parse(b.statements[f].originalJSON));b.statements=e,c.resolve(b)}}}),c.promise}function f(a){var b,c=this,d=h.defer(),e={},f=[];if(Array.isArray(a))for(var k in a)a[k].actor&&a[k].verb&&a[k].object&&a[k].registration?(e={verb:new g.Verb(a[k].verb),actor:new g.Agent(a[k].actor),object:new g.Activity(a[k].object),context:{registration:a[k].registration}},a[k].timestamp&&(e.timestamp=a[k].timestamp),a[k].result&&(e.result=a[k].result),f.push(e)):(b={},b.message=b.description="Mandatory parameter options not found in request options",b=new j(i.errors.ERROR_TYPES.SDK_ERROR,b));else b={},b.message=b.description="Mandatory parameter options not found in request options",b=new j(i.errors.ERROR_TYPES.SDK_ERROR,b);return b?d.reject(b):c.tincan.sendStatements(f,function(a){for(var c in a)if(null!==a[c].err){var e={message:a[c].xhr.statusText,description:JSON.parse(a[c].xhr.response),status:a[c].xhr.status};if(e){b=new j(i.errors.ERROR_TYPES.API_ERROR,e),d.reject(b);break}}b||d.resolve()}),d.promise}var g=a("tincanjs"),h=a("q"),i=a("../../helpers"),j=i.errors.DLSError;b.exports=d},{"../../helpers":3,q:90,tincanjs:135}],22:[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);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:90,superagent:133}],23:[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;
5
- }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);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:90,superagent:133}],24:[function(a,b,c){function d(){var a=m();return{connect:e.bind(this,a),cleanup:f.bind(this,a),grantByUserOrgId:g.bind(this),grantByAccountId:h.bind(this),grantByAccountIdOnExtUserId:i.bind(this)}}function e(a,b){var c=!1;if(c&&!b.userid){var d={};throw d.message=d.description="Mandatory parameter userid not found in request options.",d=new n(l.errors.ERROR_TYPES.PUSHX_ERROR,d)}return a.setup({userid:b.userid,pubnub:{publishKey:b.publishKey,subscribeKey:b.subscribeKey,authKey:b.authKey,ssl:!0}})}function f(a){a.cleanup()}function g(a){var b=this,c=j.defer(),d=l.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else{var e=b.config.DEFAULT_HOSTS.PUSHX+b.config.PUSHX_API_URLS.grantByUserOrgId;e=l.api.constructAPIUrl(e,{orgId:b.orgId});var f=k.post(e).set("Content-Type","application/json").set("Accept","application/json"),g={};a.authKey&&(g.authKey=a.authKey),f.send(g),f=l.api.setupAPIToken(f,b.token),b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new n(l.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}return c.promise}function h(a){var b=this,c={},d=j.defer();if(a.accountId&&a.refId){var e=b.config.DEFAULT_HOSTS.PUSHX+b.config.PUSHX_API_URLS.grantByAccountId;e=l.api.constructAPIUrl(e,{accountId:a.accountId});var f=k.post(e).set("Content-Type","application/json").set("Accept","application/json");b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid);var g={refId:a.refId};a.authKey&&(g.authKey=a.authKey),f.send(g),f.end(function(a,b){a?(a=new n(l.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else c.message=c.description="Required parameter ['accountId', 'refId'] not found in request options",c=new n(l.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function i(a){var b=this,c={},d=j.defer();if(a.accountId&&a.extUserId){var e=b.config.DEFAULT_HOSTS.PUSHX+b.config.PUSHX_API_URLS.grantByAccountId;e=l.api.constructAPIUrl(e,{accountId:a.accountId});var f=k.post(e).set("Content-Type","application/json").set("Accept","application/json");b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid);var g={extUserId:a.extUserId};a.authKey&&(g.authKey=a.authKey),f.send(g),f.end(function(a,b){a?(a=new n(l.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else c.message=c.description="Required parameter ['accountId', 'extUserId'] not found in request options",c=new n(l.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}var j=a("q"),k=a("superagent"),l=a("../../helpers"),m=a("./pubnubClientWrapper"),n=l.errors.DLSError;b.exports=d},{"../../helpers":3,"./pubnubClientWrapper":25,q:90,superagent:133}],25:[function(a,b,c){var d=a("pubnub"),e=a("events").EventEmitter,f=a("../../helpers"),g=f.errors.PUSHXError,h="$";b.exports=function(){"use strict";var a,b,c=new e,i=[],j={},k=!1,l=function(){return{on:function(a,b){var d,e=[];a.orgid||a.userid||a.accountid||a.productid||a.classid?(a.accountid?e.push("a-"+a.accountid):(a.orgid&&e.push("o-"+a.orgid),a.userid&&e.push("u-"+a.userid),a.productid&&e.push("p-"+a.productid),a.classid&&e.push("c-"+a.classid)),d=e.join(h)+h+a.channel,i.includes(d)||(i.push(d),j[d]={status:"pending"},c.on(d,b),p(d))):"pushx_status"!==a.channel||k||(c.on(a.channel,b),k=!0)},getMySubscriptionStatus:o}},m=function(a){var b=a.subscribedChannel,d=a.message;c.emit(b,d)},n=function(a){var b,d,e=[];switch(a.category){case"PNConnectedCategory":if("PNSubscribeOperation"===a.operation){e=a.subscribedChannels;for(var h in e)j[e[h]]&&(j[e[h]].status="subscribed");d={category:"PUSHX",type:"CHANNEL_SUBSCRIPTION",status:"SUCCESS",message:"Success: Subscribed successfully.",httpcode:200,data:{payload:{channels:a.subscribedChannels},message:"Success: Subscribed successfully."}},c.emit("pushx_status",d)}break;case"PNAccessDeniedCategory":if("PNSubscribeOperation"===a.operation){var i={payload:JSON.parse(a.errorData.response.text).payload,message:"Forbidden: Subscription failed.",errorDetails:{operation:a.operation,category:a.category,statusCode:a.statusCode}};e=i.payload.channels;for(var k in e)j[e[k]]&&(j[e[k]].status="error",j[e[k]].error=b);b=new g(f.errors.ERROR_CATEGORY.PUSHX,i),c.emit("pushx_status",b)}break;case"PNBadRequestCategory":case"PNNetworkDownCategory":case"PNNetworkUpCategory":b={message:"PushX Error",status:a.statusCode,pushXError:a},b=new g(f.errors.ERROR_CATEGORY.PUSHX,b),c.emit("pushx_status",b)}},o=function(){return JSON.parse(JSON.stringify(j))},p=function(b){a.subscribe({channels:[b]})},q=function(c){function e(){b=c,a.addListener({message:function(a){m(a)},status:function(a){n(a)}})}var f=c.pubnub;return f.uuid=c.userid,a||!f?new Error("Already Initialized"):(a=new d(f),e(),l())},r=function(){a&&(a.unsubscribeAll(),a.stop(),i=[],k=!1,j={}),a=void 0};return{setup:q,cleanup:r}}},{"../../helpers":3,events:67,pubnub:88}],26:[function(a,b,c){function d(){return{connect:e.bind(this)}}function e(a,b){var c,d=this,e=h.defer(),j={CONNECT:"push_connect",CONNECT_ERROR:"push_error",USER_NEW:"presence",USER_CHANGED:"presenceupdate",COLLAB_EVENT:"collab",ACTIVITY_EVENT:"activity",JOB_EVENT:"job",SYSTEM_EVENT:"systemevents",ERROR:"error",ACTIVEROOM:"activeroom"};if(b&&a)a=a.toLowerCase(),c=d.config.DEFAULT_HOSTS.PUSH+"/"+a+"?orgid="+a+"&userid="+b;else{var k=i.validations.isAuthenticated(d.orgId,d.token);k?e.reject(k):c=d.config.DEFAULT_HOSTS.PUSH+"/"+d.orgId.toLowerCase()+"?orgid="+d.orgId.toLowerCase()+"&token="+d.token.access_token}if(c){var l=g.connect(c),m=new f;m.on(j.ACTIVEROOM,function(a){l.emit(j.ACTIVEROOM,a)}),e.resolve(m),l.on("connect",function(){var a={};m.emit(j.CONNECT,a)}),l.on("connect_error",function(a){var b={};b.error={},b.error.message="connect_error",b.error.description="Connection Error to PUSH API, URL: "+c+", "+JSON.stringify(a),m.emit(j.CONNECT_ERROR,b)}),l.on("connect_timeout",function(a){var b={};b.error={},b.error.message="connect_timeout",b.error.description="Timeout error to PUSH API, URL: "+c+", "+JSON.stringify(a),m.emit(j.CONNECT_ERROR,b)}),l.on("presence",function(a){var b=a;m.emit(j.USER_NEW,b)}),l.on("presenceupdate",function(a){var b=a;m.emit(j.USER_CHANGED,b)}),l.on("collab",function(a){var b=a;m.emit(j.COLLAB_EVENT,b)}),l.on("activity",function(a){var b=a;m.emit(j.ACTIVITY_EVENT,b)}),l.on("job",function(a){var b=a;m.emit(j.JOB_EVENT,b)}),l.on("systemevents",function(a){var b=a;m.emit(j.SYSTEM_EVENT,b)}),l.on("error",function(a){var b;try{b=JSON.parse(a)}catch(c){b=new Error(a)}l.disconnect(),m.emit(j.ERROR,b)})}return e.promise}var f=a("events").EventEmitter,g=a("socket.io-client"),h=a("q"),i=a("../../helpers");i.errors.DLSError;b.exports=d},{"../../helpers":3,events:67,q:90,"socket.io-client":109}],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 o(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 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.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 o(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 o(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={mergeGlobalRules:a.mergeGlobalRules},f=m.get(d).set("Content-Type","application/json").set("Accept","application/json").query(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 o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory params - orgId or context or ruleType or userId not 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=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 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 ruleType or ruleId or body.rule_display 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.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 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 ruleType or body 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.ruleType&&a.ruleId&&a.body){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.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 ruleType or ruleId or body 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.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 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 ruleType or ruleId 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:90,superagent:133}],28:[function(a,b,c){function d(){return{postSISEvent:e.bind(this)}}function e(a){var b,c=this,d=g.defer(),e={};if(h.isArray(a.entities))if(e=i.validations.isAuthenticated(c.orgId,c.token))d.reject(e);else{b=c.config.DEFAULT_HOSTS.SISEVENTS+c.config.SISEVENTS_API_URLS.postMultiSISEvent,b=i.api.constructAPIUrl(b,{orgId:c.orgId});var k=a,l=f.post(b).send(k);l=i.api.setupAPIToken(l,c.token),c.traceid&&l.set("X-Amzn-Trace-Id",c.traceid),l.end(function(a,b){a?(a=new j(i.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else e.message=e.description="Mandatory parameter entities not present in options",e=new j(i.errors.ERROR_TYPES.SDK_ERROR,e),d.reject(e);return d.promise}var f=a("superagent"),g=a("q"),h=a("underscore"),i=a("../../helpers"),j=i.errors.DLSError;b.exports=d},{"../../helpers":3,q:90,superagent:133,underscore:137}],29:[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),getInvitationsByEmail:x.bind(this),updateInstituteTitle:y.bind(this)}}function e(a){var b=this,c=z.defer();if(a&&a.extuserid){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getUserSpaces;d=B.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=A.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(g=new C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function f(a){var b=this,c=z.defer();if(a&&a.spaceCodeBody&&a.spaceCodeBody.space_code){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.validateSpaceCode;d=B.api.constructAPIUrl(d,{accountid:b.accountId});var e=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function g(a){var b=this,c=z.defer();if(a&&a.classCodeBody&&a.classCodeBody.class_code){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.validateClassCode;d=B.api.constructAPIUrl(d,{accountid:b.accountId});var e={};a.details&&(e.details=a.details);var f=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function h(a){var b=this,c=z.defer(),d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.generateSpaceCode;d=B.api.constructAPIUrl(d,{accountid:b.accountId});var e={};a.ignore_words&&(e.ignore_words=a.ignore_words);var f=A.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 C(B.errors.ERROR_TYPES.API_ERROR,a),c.reject(err)):c.resolve(b)}),c.promise}function i(a){var b=this,c=z.defer();if(a&&a.ext_user_id&&a.spacecode){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.changeSpaceCode;d=B.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=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function j(a){var b=this,c=z.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=B.api.constructAPIUrl(d,{accountid:b.accountId});var e=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function k(a){var b=this,c=z.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=B.api.constructAPIUrl(e,{accountId:b.accountId});var f=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function l(a){var b=this,c=z.defer();if(a&&a.ext_user_id&&a.ext_role){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.provisionSpacesToTeacher;d=B.api.constructAPIUrl(d,{accountId:b.accountId});var e=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function m(a){var b=this,c=z.defer(),d=B.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=B.api.constructAPIUrl(e,{orgId:b.orgId});var f=A.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=B.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function n(a){var b=this,c=z.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=B.api.constructAPIUrl(e,{orgId:b.orgId});var f=A.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?(a=new C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function o(a){var b=this,c=z.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=B.api.constructAPIUrl(d,{accountId:b.accountId});var e=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function p(a){var b=this,c=z.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=B.api.constructAPIUrl(d,{accountId:b.accountId});var e=A["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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function q(a){var b=this,c=z.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=B.api.constructAPIUrl(f,{accountId:b.accountId});var g=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function r(a){var b=this,c=z.defer();if(a&&a["micro-entitlements"]){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.bulkMicroEntitleProductToUser;d=B.api.constructAPIUrl(d,{accountId:b.accountId});var e=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function s(a){var b=this,c=z.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=B.api.constructAPIUrl(e,{accountId:b.accountId});var f=A["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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function t(a){var b=this,c=z.defer();if(a&&a.ext_product_id){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getExtProductAPI;d=B.api.constructAPIUrl(d,{accountId:b.accountId,extProductId:a.ext_product_id});var e=A.get(d);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(f=new C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function u(a){var b=this,c=z.defer();if(a&&a.spacekey){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getSpaceDetails;d=B.api.constructAPIUrl(d,{accountId:b.accountId,spacekey:a.spacekey});var e={orgid:b.orgId},f=A.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=B.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(g=new C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function v(a){var b=this,c=z.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=B.api.constructAPIUrl(d,{accountId:b.accountId});var e=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function w(a){var b=this,c=z.defer(),d={};if(a&&a.ext_user_id){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.updateUserInformation;e=B.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=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function x(a){var b=this,c=z.defer(),d={};if(a&&a.email){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getInvitationsByEmail;e=B.api.constructAPIUrl(e,{accountid:b.accountId});var f={email:a.email};a.status&&(f.status=a.status);var g=A.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function y(a){var b=this,c=z.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=B.api.constructAPIUrl(e,{accountId:b.accountId,instituteSpaceCode:a.space_code});var f=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}var z=a("q"),A=a("superagent"),B=a("../../helpers"),C=B.errors.DLSError;b.exports=d},{"../../helpers":3,q:90,superagent:133}],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){
6
- 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:90,superagent:133}],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:90,superagent:133}],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){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:90,superagent:133}],33:[function(a,b,c){function d(a){return this.accountId=a,{postStatement:e.bind(this),postExternalStatements:f.bind(this),resetUserProductProgress:g.bind(this)}}function e(a){var b,c=this,d=h.defer(),e={};if(e=j.validations.isAuthenticated(c.orgId,c.token))d.reject(e);else{b=c.config.DEFAULT_HOSTS.XAPI+c.config.XAPI_API_URLS.postMultiStatements,b=j.api.constructAPIUrl(b,{orgId:c.orgId});var f=a,g=i.post(b).send(f);g=j.api.setupAPIToken(g,c.token),c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new k(j.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}return d.promise}function f(a){var b=this,c=h.defer(),d=b.config.DEFAULT_HOSTS.XAPI+b.config.XAPI_API_URLS.postExternalMultiStatements;d=j.api.constructAPIUrl(d,{orgId:b.orgId});var e=i.post(d).send(a);return b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.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 g(a){var b=this,c=h.defer(),d={};if(a&&a.userid&&a.productcode&&a.actorid){var e=b.config.DEFAULT_HOSTS.XAPI+b.config.XAPI_API_URLS.resetUserProductProgress;e=j.api.constructAPIUrl(e,{accountId:b.accountId});var f=i["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 k(j.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description="userid, productcode or actorid not found in request options.",d=new k(j.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}var h=a("q"),i=a("superagent"),j=a("../../helpers"),k=j.errors.DLSError;b.exports=d},{"../../helpers":3,q:90,superagent:133}],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:90,superagent:133}],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(a,b,c){function d(a,e){if(d.count<=0)throw new Error("after called too many times");--d.count,a?(f=!0,b(a),b=c):0!==d.count||f||b(null,e)}var f=!1;return c=c||e,d.count=a,0===a?b():d}function e(){}b.exports=d},{}],37:[function(a,b,c){function d(){}b.exports=d,b.exports.HttpsAgent=d},{}],38:[function(a,b,c){b.exports=function(a,b,c){var d=a.byteLength;if(b=b||0,c=c||d,a.slice)return a.slice(b,c);if(b<0&&(b+=d),c<0&&(c+=d),c>d&&(c=d),b>=d||b>=c||0===d)return new ArrayBuffer(0);for(var e=new Uint8Array(a),f=new Uint8Array(c-b),g=b,h=0;g<c;g++,h++)f[h]=e[g];return f.buffer}},{}],39:[function(a,b,c){function d(a){a=a||{},this.ms=a.min||100,this.max=a.max||1e4,this.factor=a.factor||2,this.jitter=a.jitter>0&&a.jitter<=1?a.jitter:0,this.attempts=0}b.exports=d,d.prototype.duration=function(){var a=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var b=Math.random(),c=Math.floor(b*this.jitter*a);a=0==(1&Math.floor(10*b))?a-c:a+c}return 0|Math.min(a,this.max)},d.prototype.reset=function(){this.attempts=0},d.prototype.setMin=function(a){this.ms=a},d.prototype.setMax=function(a){this.max=a},d.prototype.setJitter=function(a){this.jitter=a}},{}],40:[function(a,b,c){!function(a){"use strict";c.encode=function(b){var c,d=new Uint8Array(b),e=d.length,f="";for(c=0;c<e;c+=3)f+=a[d[c]>>2],f+=a[(3&d[c])<<4|d[c+1]>>4],f+=a[(15&d[c+1])<<2|d[c+2]>>6],f+=a[63&d[c+2]];return e%3===2?f=f.substring(0,f.length-1)+"=":e%3===1&&(f=f.substring(0,f.length-2)+"=="),f},c.decode=function(b){var c,d,e,f,g,h=.75*b.length,i=b.length,j=0;"="===b[b.length-1]&&(h--,"="===b[b.length-2]&&h--);var k=new ArrayBuffer(h),l=new Uint8Array(k);for(c=0;c<i;c+=4)d=a.indexOf(b[c]),e=a.indexOf(b[c+1]),f=a.indexOf(b[c+2]),g=a.indexOf(b[c+3]),l[j++]=d<<2|e>>4,l[j++]=(15&e)<<4|f>>2,l[j++]=(3&f)<<6|63&g;return k}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")},{}],41:[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)},{}],42:[function(a,b,c){(function(a){function c(a){for(var b=0;b<a.length;b++){var c=a[b];if(c.buffer instanceof ArrayBuffer){var d=c.buffer;if(c.byteLength!==d.byteLength){var e=new Uint8Array(c.byteLength);e.set(new Uint8Array(d,c.byteOffset,c.byteLength)),d=e.buffer}a[b]=d}}}function d(a,b){b=b||{};var d=new f;c(a);for(var e=0;e<a.length;e++)d.append(a[e]);return b.type?d.getBlob(b.type):d.getBlob()}function e(a,b){return c(a),new Blob(a,b||{})}var f=a.BlobBuilder||a.WebKitBlobBuilder||a.MSBlobBuilder||a.MozBlobBuilder,g=function(){try{var a=new Blob(["hi"]);return 2===a.size}catch(b){return!1}}(),h=g&&function(){try{var a=new Blob([new Uint8Array([1,2])]);return 2===a.size}catch(b){return!1}}(),i=f&&f.prototype.append&&f.prototype.getBlob;b.exports=function(){return g?h?a.Blob:e:i?d:void 0}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],43:[function(a,b,c){},{}],44:[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;
7
- },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":41,ieee754:74,isarray:77}],45:[function(a,b,c){b.exports={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Time-out",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Large",414:"Request-URI Too Large",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Time-out",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},{}],46:[function(a,b,c){var d=[].slice;b.exports=function(a,b){if("string"==typeof b&&(b=a[b]),"function"!=typeof b)throw new Error("bind() requires a function");var c=d.call(arguments,2);return function(){return b.apply(a,c.concat(d.call(arguments)))}}},{}],47:[function(a,b,c){b.exports=function(a,b){var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}},{}],48:[function(a,b,c){function d(a){return Array.isArray?Array.isArray(a):"[object Array]"===r(a)}function e(a){return"boolean"==typeof a}function f(a){return null===a}function g(a){return null==a}function h(a){return"number"==typeof a}function i(a){return"string"==typeof a}function j(a){return"symbol"==typeof a}function k(a){return void 0===a}function l(a){return"[object RegExp]"===r(a)}function m(a){return"object"==typeof a&&null!==a}function n(a){return"[object Date]"===r(a)}function o(a){return"[object Error]"===r(a)||a instanceof Error}function p(a){return"function"==typeof a}function q(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function r(a){return Object.prototype.toString.call(a)}c.isArray=d,c.isBoolean=e,c.isNull=f,c.isNullOrUndefined=g,c.isNumber=h,c.isString=i,c.isSymbol=j,c.isUndefined=k,c.isRegExp=l,c.isObject=m,c.isDate=n,c.isError=o,c.isFunction=p,c.isPrimitive=q,c.isBuffer=a("buffer").Buffer.isBuffer},{buffer:44}],49:[function(a,b,c){b.exports=a("./lib/")},{"./lib/":50}],50:[function(a,b,c){b.exports=a("./socket"),b.exports.parser=a("engine.io-parser")},{"./socket":51,"engine.io-parser":63}],51:[function(a,b,c){(function(c){function d(a,b){if(!(this instanceof d))return new d(a,b);b=b||{},a&&"object"==typeof a&&(b=a,a=null),a?(a=k(a),b.hostname=a.host,b.secure="https"==a.protocol||"wss"==a.protocol,b.port=a.port,a.query&&(b.query=a.query)):b.host&&(b.hostname=k(b.host).host),this.secure=null!=b.secure?b.secure:c.location&&"https:"==location.protocol,b.hostname&&!b.port&&(b.port=this.secure?"443":"80"),this.agent=b.agent||!1,this.hostname=b.hostname||(c.location?location.hostname:"localhost"),this.port=b.port||(c.location&&location.port?location.port:this.secure?443:80),this.query=b.query||{},"string"==typeof this.query&&(this.query=m.decode(this.query)),this.upgrade=!1!==b.upgrade,this.path=(b.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!b.forceJSONP,this.jsonp=!1!==b.jsonp,this.forceBase64=!!b.forceBase64,this.enablesXDR=!!b.enablesXDR,this.timestampParam=b.timestampParam||"t",this.timestampRequests=b.timestampRequests,this.transports=b.transports||["polling","websocket"],this.readyState="",this.writeBuffer=[],this.policyPort=b.policyPort||843,this.rememberUpgrade=b.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=b.onlyBinaryUpgrades,this.perMessageDeflate=!1!==b.perMessageDeflate&&(b.perMessageDeflate||{}),!0===this.perMessageDeflate&&(this.perMessageDeflate={}),this.perMessageDeflate&&null==this.perMessageDeflate.threshold&&(this.perMessageDeflate.threshold=1024),this.pfx=b.pfx||null,this.key=b.key||null,this.passphrase=b.passphrase||null,this.cert=b.cert||null,this.ca=b.ca||null,this.ciphers=b.ciphers||null,this.rejectUnauthorized=void 0===b.rejectUnauthorized?null:b.rejectUnauthorized;var e="object"==typeof c&&c;e.global===e&&b.extraHeaders&&Object.keys(b.extraHeaders).length>0&&(this.extraHeaders=b.extraHeaders),this.open()}function e(a){var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}var f=a("./transports"),g=a("component-emitter"),h=a("debug")("engine.io-client:socket"),i=a("indexof"),j=a("engine.io-parser"),k=a("parseuri"),l=a("parsejson"),m=a("parseqs");b.exports=d,d.priorWebsocketSuccess=!1,g(d.prototype),d.protocol=j.protocol,d.Socket=d,d.Transport=a("./transport"),d.transports=a("./transports"),d.parser=a("engine.io-parser"),d.prototype.createTransport=function(a){h('creating transport "%s"',a);var b=e(this.query);b.EIO=j.protocol,b.transport=a,this.id&&(b.sid=this.id);var c=new f[a]({agent:this.agent,hostname:this.hostname,port:this.port,secure:this.secure,path:this.path,query:b,forceJSONP:this.forceJSONP,jsonp:this.jsonp,forceBase64:this.forceBase64,enablesXDR:this.enablesXDR,timestampRequests:this.timestampRequests,timestampParam:this.timestampParam,policyPort:this.policyPort,socket:this,pfx:this.pfx,key:this.key,passphrase:this.passphrase,cert:this.cert,ca:this.ca,ciphers:this.ciphers,rejectUnauthorized:this.rejectUnauthorized,perMessageDeflate:this.perMessageDeflate,extraHeaders:this.extraHeaders});return c},d.prototype.open=function(){var a;if(this.rememberUpgrade&&d.priorWebsocketSuccess&&this.transports.indexOf("websocket")!=-1)a="websocket";else{if(0===this.transports.length){var b=this;return void setTimeout(function(){b.emit("error","No transports available")},0)}a=this.transports[0]}this.readyState="opening";try{a=this.createTransport(a)}catch(c){return this.transports.shift(),void this.open()}a.open(),this.setTransport(a)},d.prototype.setTransport=function(a){h("setting transport %s",a.name);var b=this;this.transport&&(h("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=a,a.on("drain",function(){b.onDrain()}).on("packet",function(a){b.onPacket(a)}).on("error",function(a){b.onError(a)}).on("close",function(){b.onClose("transport close")})},d.prototype.probe=function(a){function b(){if(m.onlyBinaryUpgrades){var b=!this.supportsBinary&&m.transport.supportsBinary;l=l||b}l||(h('probe transport "%s" opened',a),k.send([{type:"ping",data:"probe"}]),k.once("packet",function(b){if(!l)if("pong"==b.type&&"probe"==b.data){if(h('probe transport "%s" pong',a),m.upgrading=!0,m.emit("upgrading",k),!k)return;d.priorWebsocketSuccess="websocket"==k.name,h('pausing current transport "%s"',m.transport.name),m.transport.pause(function(){l||"closed"!=m.readyState&&(h("changing transport and sending upgrade packet"),j(),m.setTransport(k),k.send([{type:"upgrade"}]),m.emit("upgrade",k),k=null,m.upgrading=!1,m.flush())})}else{h('probe transport "%s" failed',a);var c=new Error("probe error");c.transport=k.name,m.emit("upgradeError",c)}}))}function c(){l||(l=!0,j(),k.close(),k=null)}function e(b){var d=new Error("probe error: "+b);d.transport=k.name,c(),h('probe transport "%s" failed because of error: %s',a,b),m.emit("upgradeError",d)}function f(){e("transport closed")}function g(){e("socket closed")}function i(a){k&&a.name!=k.name&&(h('"%s" works - aborting "%s"',a.name,k.name),c())}function j(){k.removeListener("open",b),k.removeListener("error",e),k.removeListener("close",f),m.removeListener("close",g),m.removeListener("upgrading",i)}h('probing transport "%s"',a);var k=this.createTransport(a,{probe:1}),l=!1,m=this;d.priorWebsocketSuccess=!1,k.once("open",b),k.once("error",e),k.once("close",f),this.once("close",g),this.once("upgrading",i),k.open()},d.prototype.onOpen=function(){if(h("socket open"),this.readyState="open",d.priorWebsocketSuccess="websocket"==this.transport.name,this.emit("open"),this.flush(),"open"==this.readyState&&this.upgrade&&this.transport.pause){h("starting upgrade probes");for(var a=0,b=this.upgrades.length;a<b;a++)this.probe(this.upgrades[a])}},d.prototype.onPacket=function(a){if("opening"==this.readyState||"open"==this.readyState)switch(h('socket receive: type "%s", data "%s"',a.type,a.data),this.emit("packet",a),this.emit("heartbeat"),a.type){case"open":this.onHandshake(l(a.data));break;case"pong":this.setPing(),this.emit("pong");break;case"error":var b=new Error("server error");b.code=a.data,this.onError(b);break;case"message":this.emit("data",a.data),this.emit("message",a.data)}else h('packet received with socket readyState "%s"',this.readyState)},d.prototype.onHandshake=function(a){this.emit("handshake",a),this.id=a.sid,this.transport.query.sid=a.sid,this.upgrades=this.filterUpgrades(a.upgrades),this.pingInterval=a.pingInterval,this.pingTimeout=a.pingTimeout,this.onOpen(),"closed"!=this.readyState&&(this.setPing(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat))},d.prototype.onHeartbeat=function(a){clearTimeout(this.pingTimeoutTimer);var b=this;b.pingTimeoutTimer=setTimeout(function(){"closed"!=b.readyState&&b.onClose("ping timeout")},a||b.pingInterval+b.pingTimeout)},d.prototype.setPing=function(){var a=this;clearTimeout(a.pingIntervalTimer),a.pingIntervalTimer=setTimeout(function(){h("writing ping packet - expecting pong within %sms",a.pingTimeout),a.ping(),a.onHeartbeat(a.pingTimeout)},a.pingInterval)},d.prototype.ping=function(){var a=this;this.sendPacket("ping",function(){a.emit("ping")})},d.prototype.onDrain=function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit("drain"):this.flush()},d.prototype.flush=function(){"closed"!=this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(h("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},d.prototype.write=d.prototype.send=function(a,b,c){return this.sendPacket("message",a,b,c),this},d.prototype.sendPacket=function(a,b,c,d){if("function"==typeof b&&(d=b,b=void 0),"function"==typeof c&&(d=c,c=null),"closing"!=this.readyState&&"closed"!=this.readyState){c=c||{},c.compress=!1!==c.compress;var e={type:a,data:b,options:c};this.emit("packetCreate",e),this.writeBuffer.push(e),d&&this.once("flush",d),this.flush()}},d.prototype.close=function(){function a(){d.onClose("forced close"),h("socket closing - telling transport to close"),d.transport.close()}function b(){d.removeListener("upgrade",b),d.removeListener("upgradeError",b),a()}function c(){d.once("upgrade",b),d.once("upgradeError",b)}if("opening"==this.readyState||"open"==this.readyState){this.readyState="closing";var d=this;this.writeBuffer.length?this.once("drain",function(){this.upgrading?c():a()}):this.upgrading?c():a()}return this},d.prototype.onError=function(a){h("socket error %j",a),d.priorWebsocketSuccess=!1,this.emit("error",a),this.onClose("transport error",a)},d.prototype.onClose=function(a,b){if("opening"==this.readyState||"open"==this.readyState||"closing"==this.readyState){h('socket close with reason: "%s"',a);var c=this;clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),this.readyState="closed",this.id=null,this.emit("close",a,b),c.writeBuffer=[],c.prevBufferLen=0}},d.prototype.filterUpgrades=function(a){for(var b=[],c=0,d=a.length;c<d;c++)~i(this.transports,a[c])&&b.push(a[c]);return b}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./transport":52,"./transports":53,"component-emitter":59,debug:60,"engine.io-parser":63,indexof:75,parsejson:83,parseqs:84,parseuri:85}],52:[function(a,b,c){function d(a){this.path=a.path,this.hostname=a.hostname,this.port=a.port,this.secure=a.secure,this.query=a.query,this.timestampParam=a.timestampParam,this.timestampRequests=a.timestampRequests,this.readyState="",this.agent=a.agent||!1,this.socket=a.socket,this.enablesXDR=a.enablesXDR,this.pfx=a.pfx,this.key=a.key,this.passphrase=a.passphrase,this.cert=a.cert,this.ca=a.ca,this.ciphers=a.ciphers,this.rejectUnauthorized=a.rejectUnauthorized,this.extraHeaders=a.extraHeaders}var e=a("engine.io-parser"),f=a("component-emitter");b.exports=d,f(d.prototype),d.prototype.onError=function(a,b){var c=new Error(a);return c.type="TransportError",c.description=b,this.emit("error",c),this},d.prototype.open=function(){return"closed"!=this.readyState&&""!=this.readyState||(this.readyState="opening",this.doOpen()),this},d.prototype.close=function(){return"opening"!=this.readyState&&"open"!=this.readyState||(this.doClose(),this.onClose()),this},d.prototype.send=function(a){if("open"!=this.readyState)throw new Error("Transport not open");this.write(a)},d.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},d.prototype.onData=function(a){var b=e.decodePacket(a,this.socket.binaryType);this.onPacket(b)},d.prototype.onPacket=function(a){this.emit("packet",a)},d.prototype.onClose=function(){this.readyState="closed",this.emit("close")}},{"component-emitter":59,"engine.io-parser":63}],53:[function(a,b,c){(function(b){function d(a){var c,d=!1,h=!1,i=!1!==a.jsonp;if(b.location){var j="https:"==location.protocol,k=location.port;k||(k=j?443:80),d=a.hostname!=location.hostname||k!=a.port,h=a.secure!=j}if(a.xdomain=d,a.xscheme=h,c=new e(a),"open"in c&&!a.forceJSONP)return new f(a);if(!i)throw new Error("JSONP disabled");return new g(a)}var e=a("xmlhttprequest-ssl"),f=a("./polling-xhr"),g=a("./polling-jsonp"),h=a("./websocket");c.polling=d,c.websocket=h}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./polling-jsonp":54,"./polling-xhr":55,"./websocket":57,"xmlhttprequest-ssl":58}],54:[function(a,b,c){(function(c){function d(){}function e(a){f.call(this,a),this.query=this.query||{},h||(c.___eio||(c.___eio=[]),h=c.___eio),this.index=h.length;var b=this;h.push(function(a){b.onData(a)}),this.query.j=this.index,c.document&&c.addEventListener&&c.addEventListener("beforeunload",function(){b.script&&(b.script.onerror=d)},!1)}var f=a("./polling"),g=a("component-inherit");b.exports=e;var h,i=/\n/g,j=/\\n/g;g(e,f),e.prototype.supportsBinary=!1,e.prototype.doClose=function(){this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),f.prototype.doClose.call(this)},e.prototype.doPoll=function(){var a=this,b=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),b.async=!0,b.src=this.uri(),b.onerror=function(b){a.onError("jsonp poll error",b)};var c=document.getElementsByTagName("script")[0];c?c.parentNode.insertBefore(b,c):(document.head||document.body).appendChild(b),this.script=b;var d="undefined"!=typeof navigator&&/gecko/i.test(navigator.userAgent);d&&setTimeout(function(){var a=document.createElement("iframe");document.body.appendChild(a),document.body.removeChild(a)},100)},e.prototype.doWrite=function(a,b){function c(){d(),b()}function d(){if(e.iframe)try{e.form.removeChild(e.iframe)}catch(a){e.onError("jsonp polling iframe removal error",a)}try{var b='<iframe src="javascript:0" name="'+e.iframeId+'">';f=document.createElement(b)}catch(a){f=document.createElement("iframe"),f.name=e.iframeId,f.src="javascript:0"}f.id=e.iframeId,e.form.appendChild(f),e.iframe=f}var e=this;if(!this.form){var f,g=document.createElement("form"),h=document.createElement("textarea"),k=this.iframeId="eio_iframe_"+this.index;g.className="socketio",g.style.position="absolute",g.style.top="-1000px",g.style.left="-1000px",g.target=k,g.method="POST",g.setAttribute("accept-charset","utf-8"),h.name="d",g.appendChild(h),document.body.appendChild(g),this.form=g,this.area=h}this.form.action=this.uri(),d(),a=a.replace(j,"\\\n"),this.area.value=a.replace(i,"\\n");try{this.form.submit()}catch(l){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"==e.iframe.readyState&&c()}:this.iframe.onload=c}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./polling":56,"component-inherit":47}],55:[function(a,b,c){(function(c){function d(){}function e(a){if(i.call(this,a),c.location){var b="https:"==location.protocol,d=location.port;d||(d=b?443:80),this.xd=a.hostname!=c.location.hostname||d!=a.port,this.xs=a.secure!=b}else this.extraHeaders=a.extraHeaders}function f(a){this.method=a.method||"GET",this.uri=a.uri,this.xd=!!a.xd,this.xs=!!a.xs,this.async=!1!==a.async,this.data=void 0!=a.data?a.data:null,this.agent=a.agent,this.isBinary=a.isBinary,this.supportsBinary=a.supportsBinary,this.enablesXDR=a.enablesXDR,this.pfx=a.pfx,this.key=a.key,this.passphrase=a.passphrase,this.cert=a.cert,this.ca=a.ca,this.ciphers=a.ciphers,this.rejectUnauthorized=a.rejectUnauthorized,this.extraHeaders=a.extraHeaders,this.create()}function g(){for(var a in f.requests)f.requests.hasOwnProperty(a)&&f.requests[a].abort()}var h=a("xmlhttprequest-ssl"),i=a("./polling"),j=a("component-emitter"),k=a("component-inherit"),l=a("debug")("engine.io-client:polling-xhr");b.exports=e,b.exports.Request=f,k(e,i),e.prototype.supportsBinary=!0,e.prototype.request=function(a){return a=a||{},a.uri=this.uri(),a.xd=this.xd,a.xs=this.xs,a.agent=this.agent||!1,a.supportsBinary=this.supportsBinary,a.enablesXDR=this.enablesXDR,a.pfx=this.pfx,a.key=this.key,a.passphrase=this.passphrase,a.cert=this.cert,a.ca=this.ca,a.ciphers=this.ciphers,a.rejectUnauthorized=this.rejectUnauthorized,a.extraHeaders=this.extraHeaders,new f(a)},e.prototype.doWrite=function(a,b){var c="string"!=typeof a&&void 0!==a,d=this.request({method:"POST",data:a,isBinary:c}),e=this;d.on("success",b),d.on("error",function(a){e.onError("xhr post error",a)}),this.sendXhr=d},e.prototype.doPoll=function(){l("xhr poll");var a=this.request(),b=this;a.on("data",function(a){b.onData(a)}),a.on("error",function(a){b.onError("xhr poll error",a)}),this.pollXhr=a},j(f.prototype),f.prototype.create=function(){var a={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};a.pfx=this.pfx,a.key=this.key,a.passphrase=this.passphrase,a.cert=this.cert,a.ca=this.ca,a.ciphers=this.ciphers,a.rejectUnauthorized=this.rejectUnauthorized;var b=this.xhr=new h(a),d=this;try{l("xhr open %s: %s",this.method,this.uri),b.open(this.method,this.uri,this.async);try{if(this.extraHeaders){b.setDisableHeaderCheck(!0);for(var e in this.extraHeaders)this.extraHeaders.hasOwnProperty(e)&&b.setRequestHeader(e,this.extraHeaders[e])}}catch(g){}if(this.supportsBinary&&(b.responseType="arraybuffer"),"POST"==this.method)try{this.isBinary?b.setRequestHeader("Content-type","application/octet-stream"):b.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(g){}"withCredentials"in b&&(b.withCredentials=!0),this.hasXDR()?(b.onload=function(){d.onLoad()},b.onerror=function(){d.onError(b.responseText)}):b.onreadystatechange=function(){4==b.readyState&&(200==b.status||1223==b.status?d.onLoad():setTimeout(function(){d.onError(b.status)},0))},l("xhr data %s",this.data),b.send(this.data)}catch(g){return void setTimeout(function(){d.onError(g)},0)}c.document&&(this.index=f.requestsCount++,f.requests[this.index]=this)},f.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},f.prototype.onData=function(a){this.emit("data",a),this.onSuccess()},f.prototype.onError=function(a){this.emit("error",a),this.cleanup(!0)},f.prototype.cleanup=function(a){if("undefined"!=typeof this.xhr&&null!==this.xhr){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=d:this.xhr.onreadystatechange=d,a)try{this.xhr.abort()}catch(b){}c.document&&delete f.requests[this.index],this.xhr=null}},f.prototype.onLoad=function(){var a;try{var b;try{b=this.xhr.getResponseHeader("Content-Type").split(";")[0]}catch(c){}if("application/octet-stream"===b)a=this.xhr.response;else if(this.supportsBinary)try{a=String.fromCharCode.apply(null,new Uint8Array(this.xhr.response))}catch(c){for(var d=new Uint8Array(this.xhr.response),e=[],f=0,g=d.length;f<g;f++)e.push(d[f]);a=String.fromCharCode.apply(null,e)}else a=this.xhr.responseText}catch(c){this.onError(c)}null!=a&&this.onData(a)},f.prototype.hasXDR=function(){return"undefined"!=typeof c.XDomainRequest&&!this.xs&&this.enablesXDR},f.prototype.abort=function(){this.cleanup()},c.document&&(f.requestsCount=0,f.requests={},c.attachEvent?c.attachEvent("onunload",g):c.addEventListener&&c.addEventListener("beforeunload",g,!1))}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./polling":56,"component-emitter":59,"component-inherit":47,debug:60,"xmlhttprequest-ssl":58}],56:[function(a,b,c){function d(a){var b=a&&a.forceBase64;k&&!b||(this.supportsBinary=!1),e.call(this,a)}var e=a("../transport"),f=a("parseqs"),g=a("engine.io-parser"),h=a("component-inherit"),i=a("yeast"),j=a("debug")("engine.io-client:polling");b.exports=d;var k=function(){var b=a("xmlhttprequest-ssl"),c=new b({xdomain:!1});return null!=c.responseType}();h(d,e),d.prototype.name="polling",d.prototype.doOpen=function(){this.poll()},d.prototype.pause=function(a){function b(){j("paused"),c.readyState="paused",a()}var c=this;if(this.readyState="pausing",this.polling||!this.writable){var d=0;this.polling&&(j("we are currently polling - waiting to pause"),d++,this.once("pollComplete",function(){j("pre-pause polling complete"),--d||b()})),this.writable||(j("we are currently writing - waiting to pause"),d++,this.once("drain",function(){j("pre-pause writing complete"),--d||b()}))}else b()},d.prototype.poll=function(){j("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},d.prototype.onData=function(a){var b=this;j("polling got data %s",a);var c=function(a,c,d){return"opening"==b.readyState&&b.onOpen(),"close"==a.type?(b.onClose(),!1):void b.onPacket(a)};g.decodePayload(a,this.socket.binaryType,c),"closed"!=this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"==this.readyState?this.poll():j('ignoring poll - transport state "%s"',this.readyState))},d.prototype.doClose=function(){function a(){j("writing close packet"),b.write([{type:"close"}])}var b=this;"open"==this.readyState?(j("transport open - closing"),a()):(j("transport not open - deferring close"),this.once("open",a))},d.prototype.write=function(a){var b=this;this.writable=!1;var c=function(){b.writable=!0,b.emit("drain")},b=this;g.encodePayload(a,this.supportsBinary,function(a){b.doWrite(a,c)})},d.prototype.uri=function(){var a=this.query||{},b=this.secure?"https":"http",c="";!1!==this.timestampRequests&&(a[this.timestampParam]=i()),this.supportsBinary||a.sid||(a.b64=1),a=f.encode(a),this.port&&("https"==b&&443!=this.port||"http"==b&&80!=this.port)&&(c=":"+this.port),a.length&&(a="?"+a);var d=this.hostname.indexOf(":")!==-1;return b+"://"+(d?"["+this.hostname+"]":this.hostname)+c+this.path+a}},{"../transport":52,"component-inherit":47,debug:60,"engine.io-parser":63,parseqs:84,"xmlhttprequest-ssl":58,yeast:144}],57:[function(a,b,c){(function(c){function d(a){var b=a&&a.forceBase64;b&&(this.supportsBinary=!1),this.perMessageDeflate=a.perMessageDeflate,e.call(this,a)}var e=a("../transport"),f=a("engine.io-parser"),g=a("parseqs"),h=a("component-inherit"),i=a("yeast"),j=a("debug")("engine.io-client:websocket"),k=c.WebSocket||c.MozWebSocket,l=k;if(!l&&"undefined"==typeof window)try{l=a("ws")}catch(m){}b.exports=d,h(d,e),d.prototype.name="websocket",d.prototype.supportsBinary=!0,d.prototype.doOpen=function(){if(this.check()){var a=this.uri(),b=void 0,c={agent:this.agent,perMessageDeflate:this.perMessageDeflate};c.pfx=this.pfx,c.key=this.key,c.passphrase=this.passphrase,c.cert=this.cert,c.ca=this.ca,c.ciphers=this.ciphers,
8
- c.rejectUnauthorized=this.rejectUnauthorized,this.extraHeaders&&(c.headers=this.extraHeaders),this.ws=k?new l(a):new l(a,b,c),void 0===this.ws.binaryType&&(this.supportsBinary=!1),this.ws.supports&&this.ws.supports.binary?(this.supportsBinary=!0,this.ws.binaryType="buffer"):this.ws.binaryType="arraybuffer",this.addEventListeners()}},d.prototype.addEventListeners=function(){var a=this;this.ws.onopen=function(){a.onOpen()},this.ws.onclose=function(){a.onClose()},this.ws.onmessage=function(b){a.onData(b.data)},this.ws.onerror=function(b){a.onError("websocket error",b)}},"undefined"!=typeof navigator&&/iPad|iPhone|iPod/i.test(navigator.userAgent)&&(d.prototype.onData=function(a){var b=this;setTimeout(function(){e.prototype.onData.call(b,a)},0)}),d.prototype.write=function(a){function b(){d.emit("flush"),setTimeout(function(){d.writable=!0,d.emit("drain")},0)}var d=this;this.writable=!1;for(var e=a.length,g=0,h=e;g<h;g++)!function(a){f.encodePacket(a,d.supportsBinary,function(f){if(!k){var g={};if(a.options&&(g.compress=a.options.compress),d.perMessageDeflate){var h="string"==typeof f?c.Buffer.byteLength(f):f.length;h<d.perMessageDeflate.threshold&&(g.compress=!1)}}try{k?d.ws.send(f):d.ws.send(f,g)}catch(i){j("websocket closed before onclose event")}--e||b()})}(a[g])},d.prototype.onClose=function(){e.prototype.onClose.call(this)},d.prototype.doClose=function(){"undefined"!=typeof this.ws&&this.ws.close()},d.prototype.uri=function(){var a=this.query||{},b=this.secure?"wss":"ws",c="";this.port&&("wss"==b&&443!=this.port||"ws"==b&&80!=this.port)&&(c=":"+this.port),this.timestampRequests&&(a[this.timestampParam]=i()),this.supportsBinary||(a.b64=1),a=g.encode(a),a.length&&(a="?"+a);var d=this.hostname.indexOf(":")!==-1;return b+"://"+(d?"["+this.hostname+"]":this.hostname)+c+this.path+a},d.prototype.check=function(){return!(!l||"__initialize"in l&&this.name===d.prototype.name)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../transport":52,"component-inherit":47,debug:60,"engine.io-parser":63,parseqs:84,ws:43,yeast:144}],58:[function(a,b,c){var d=a("has-cors");b.exports=function(a){var b=a.xdomain,c=a.xscheme,e=a.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!b||d))return new XMLHttpRequest}catch(f){}try{if("undefined"!=typeof XDomainRequest&&!c&&e)return new XDomainRequest}catch(f){}if(!b)try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(f){}}},{"has-cors":72}],59:[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}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(){d.off(a,c),b.apply(this,arguments)}var d=this;return this._callbacks=this._callbacks||{},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 this},d.prototype.emit=function(a){this._callbacks=this._callbacks||{};var b=[].slice.call(arguments,1),c=this._callbacks[a];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}},{}],60:[function(a,b,c){function d(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}function e(){var a=arguments,b=this.useColors;if(a[0]=(b?"%c":"")+this.namespace+(b?" %c":" ")+a[0]+(b?"%c ":" ")+"+"+c.humanize(this.diff),!b)return a;var d="color: "+this.color;a=[a[0],d,"color: inherit"].concat(Array.prototype.slice.call(a,1));var e=0,f=0;return a[0].replace(/%[a-z%]/g,function(a){"%%"!==a&&(e++,"%c"===a&&(f=e))}),a.splice(f,0,d),a}function f(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function g(a){try{null==a?c.storage.removeItem("debug"):c.storage.debug=a}catch(b){}}function h(){var a;try{a=c.storage.debug}catch(b){}return a}function i(){try{return window.localStorage}catch(a){}}c=b.exports=a("./debug"),c.log=f,c.formatArgs=e,c.save=g,c.load=h,c.useColors=d,c.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:i(),c.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],c.formatters.j=function(a){return JSON.stringify(a)},c.enable(h())},{"./debug":61}],61:[function(a,b,c){function d(){return c.colors[k++%c.colors.length]}function e(a){function b(){}function e(){var a=e,b=+new Date,f=b-(j||b);a.diff=f,a.prev=j,a.curr=b,j=b,null==a.useColors&&(a.useColors=c.useColors()),null==a.color&&a.useColors&&(a.color=d());var g=Array.prototype.slice.call(arguments);g[0]=c.coerce(g[0]),"string"!=typeof g[0]&&(g=["%o"].concat(g));var h=0;g[0]=g[0].replace(/%([a-z%])/g,function(b,d){if("%%"===b)return b;h++;var e=c.formatters[d];if("function"==typeof e){var f=g[h];b=e.call(a,f),g.splice(h,1),h--}return b}),"function"==typeof c.formatArgs&&(g=c.formatArgs.apply(a,g));var i=e.log||c.log||console.log.bind(console);i.apply(a,g)}b.enabled=!1,e.enabled=!0;var f=c.enabled(a)?e:b;return f.namespace=a,f}function f(a){c.save(a);for(var b=(a||"").split(/[\s,]+/),d=b.length,e=0;e<d;e++)b[e]&&(a=b[e].replace(/\*/g,".*?"),"-"===a[0]?c.skips.push(new RegExp("^"+a.substr(1)+"$")):c.names.push(new RegExp("^"+a+"$")))}function g(){c.enable("")}function h(a){var b,d;for(b=0,d=c.skips.length;b<d;b++)if(c.skips[b].test(a))return!1;for(b=0,d=c.names.length;b<d;b++)if(c.names[b].test(a))return!0;return!1}function i(a){return a instanceof Error?a.stack||a.message:a}c=b.exports=e,c.coerce=i,c.disable=g,c.enable=f,c.enabled=h,c.humanize=a("ms"),c.names=[],c.skips=[],c.formatters={};var j,k=0},{ms:62}],62:[function(a,b,c){function d(a){if(a=""+a,!(a.length>1e4)){var b=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(a);if(b){var c=parseFloat(b[1]),d=(b[2]||"ms").toLowerCase();switch(d){case"years":case"year":case"yrs":case"yr":case"y":return c*l;case"days":case"day":case"d":return c*k;case"hours":case"hour":case"hrs":case"hr":case"h":return c*j;case"minutes":case"minute":case"mins":case"min":case"m":return c*i;case"seconds":case"second":case"secs":case"sec":case"s":return c*h;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c}}}}function e(a){return a>=k?Math.round(a/k)+"d":a>=j?Math.round(a/j)+"h":a>=i?Math.round(a/i)+"m":a>=h?Math.round(a/h)+"s":a+"ms"}function f(a){return g(a,k,"day")||g(a,j,"hour")||g(a,i,"minute")||g(a,h,"second")||a+" ms"}function g(a,b,c){if(!(a<b))return a<1.5*b?Math.floor(a/b)+" "+c:Math.ceil(a/b)+" "+c+"s"}var h=1e3,i=60*h,j=60*i,k=24*j,l=365.25*k;b.exports=function(a,b){return b=b||{},"string"==typeof a?d(a):b["long"]?f(a):e(a)}},{}],63:[function(a,b,c){(function(b){function d(a,b){var d="b"+c.packets[a.type]+a.data.data;return b(d)}function e(a,b,d){if(!b)return c.encodeBase64Packet(a,d);var e=a.data,f=new Uint8Array(e),g=new Uint8Array(1+e.byteLength);g[0]=r[a.type];for(var h=0;h<f.length;h++)g[h+1]=f[h];return d(g.buffer)}function f(a,b,d){if(!b)return c.encodeBase64Packet(a,d);var e=new FileReader;return e.onload=function(){a.data=e.result,c.encodePacket(a,b,!0,d)},e.readAsArrayBuffer(a.data)}function g(a,b,d){if(!b)return c.encodeBase64Packet(a,d);if(q)return f(a,b,d);var e=new Uint8Array(1);e[0]=r[a.type];var g=new u([e.buffer,a.data]);return d(g)}function h(a,b,c){for(var d=new Array(a.length),e=m(a.length,c),f=function(a,c,e){b(c,function(b,c){d[a]=c,e(b,d)})},g=0;g<a.length;g++)f(g,a[g],e)}var i=a("./keys"),j=a("has-binary"),k=a("arraybuffer.slice"),l=a("base64-arraybuffer"),m=a("after"),n=a("utf8"),o=navigator.userAgent.match(/Android/i),p=/PhantomJS/i.test(navigator.userAgent),q=o||p;c.protocol=3;var r=c.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},s=i(r),t={type:"error",data:"parser error"},u=a("blob");c.encodePacket=function(a,c,f,h){"function"==typeof c&&(h=c,c=!1),"function"==typeof f&&(h=f,f=null);var i=void 0===a.data?void 0:a.data.buffer||a.data;if(b.ArrayBuffer&&i instanceof ArrayBuffer)return e(a,c,h);if(u&&i instanceof b.Blob)return g(a,c,h);if(i&&i.base64)return d(a,h);var j=r[a.type];return void 0!==a.data&&(j+=f?n.encode(String(a.data)):String(a.data)),h(""+j)},c.encodeBase64Packet=function(a,d){var e="b"+c.packets[a.type];if(u&&a.data instanceof b.Blob){var f=new FileReader;return f.onload=function(){var a=f.result.split(",")[1];d(e+a)},f.readAsDataURL(a.data)}var g;try{g=String.fromCharCode.apply(null,new Uint8Array(a.data))}catch(h){for(var i=new Uint8Array(a.data),j=new Array(i.length),k=0;k<i.length;k++)j[k]=i[k];g=String.fromCharCode.apply(null,j)}return e+=b.btoa(g),d(e)},c.decodePacket=function(a,b,d){if("string"==typeof a||void 0===a){if("b"==a.charAt(0))return c.decodeBase64Packet(a.substr(1),b);if(d)try{a=n.decode(a)}catch(e){return t}var f=a.charAt(0);return Number(f)==f&&s[f]?a.length>1?{type:s[f],data:a.substring(1)}:{type:s[f]}:t}var g=new Uint8Array(a),f=g[0],h=k(a,1);return u&&"blob"===b&&(h=new u([h])),{type:s[f],data:h}},c.decodeBase64Packet=function(a,c){var d=s[a.charAt(0)];if(!b.ArrayBuffer)return{type:d,data:{base64:!0,data:a.substr(1)}};var e=l.decode(a.substr(1));return"blob"===c&&u&&(e=new u([e])),{type:d,data:e}},c.encodePayload=function(a,b,d){function e(a){return a.length+":"+a}function f(a,d){c.encodePacket(a,!!g&&b,!0,function(a){d(null,e(a))})}"function"==typeof b&&(d=b,b=null);var g=j(a);return b&&g?u&&!q?c.encodePayloadAsBlob(a,d):c.encodePayloadAsArrayBuffer(a,d):a.length?void h(a,f,function(a,b){return d(b.join(""))}):d("0:")},c.decodePayload=function(a,b,d){if("string"!=typeof a)return c.decodePayloadAsBinary(a,b,d);"function"==typeof b&&(d=b,b=null);var e;if(""==a)return d(t,0,1);for(var f,g,h="",i=0,j=a.length;i<j;i++){var k=a.charAt(i);if(":"!=k)h+=k;else{if(""==h||h!=(f=Number(h)))return d(t,0,1);if(g=a.substr(i+1,f),h!=g.length)return d(t,0,1);if(g.length){if(e=c.decodePacket(g,b,!0),t.type==e.type&&t.data==e.data)return d(t,0,1);var l=d(e,i+f,j);if(!1===l)return}i+=f,h=""}}return""!=h?d(t,0,1):void 0},c.encodePayloadAsArrayBuffer=function(a,b){function d(a,b){c.encodePacket(a,!0,!0,function(a){return b(null,a)})}return a.length?void h(a,d,function(a,c){var d=c.reduce(function(a,b){var c;return c="string"==typeof b?b.length:b.byteLength,a+c.toString().length+c+2},0),e=new Uint8Array(d),f=0;return c.forEach(function(a){var b="string"==typeof a,c=a;if(b){for(var d=new Uint8Array(a.length),g=0;g<a.length;g++)d[g]=a.charCodeAt(g);c=d.buffer}b?e[f++]=0:e[f++]=1;for(var h=c.byteLength.toString(),g=0;g<h.length;g++)e[f++]=parseInt(h[g]);e[f++]=255;for(var d=new Uint8Array(c),g=0;g<d.length;g++)e[f++]=d[g]}),b(e.buffer)}):b(new ArrayBuffer(0))},c.encodePayloadAsBlob=function(a,b){function d(a,b){c.encodePacket(a,!0,!0,function(a){var c=new Uint8Array(1);if(c[0]=1,"string"==typeof a){for(var d=new Uint8Array(a.length),e=0;e<a.length;e++)d[e]=a.charCodeAt(e);a=d.buffer,c[0]=0}for(var f=a instanceof ArrayBuffer?a.byteLength:a.size,g=f.toString(),h=new Uint8Array(g.length+1),e=0;e<g.length;e++)h[e]=parseInt(g[e]);if(h[g.length]=255,u){var i=new u([c.buffer,h.buffer,a]);b(null,i)}})}h(a,d,function(a,c){return b(new u(c))})},c.decodePayloadAsBinary=function(a,b,d){"function"==typeof b&&(d=b,b=null);for(var e=a,f=[],g=!1;e.byteLength>0;){for(var h=new Uint8Array(e),i=0===h[0],j="",l=1;255!=h[l];l++){if(j.length>310){g=!0;break}j+=h[l]}if(g)return d(t,0,1);e=k(e,2+j.length),j=parseInt(j);var m=k(e,0,j);if(i)try{m=String.fromCharCode.apply(null,new Uint8Array(m))}catch(n){var o=new Uint8Array(m);m="";for(var l=0;l<o.length;l++)m+=String.fromCharCode(o[l])}f.push(m),e=k(e,j)}var p=f.length;f.forEach(function(a,e){d(c.decodePacket(a,b,!0),e,p)})}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./keys":64,after:36,"arraybuffer.slice":38,"base64-arraybuffer":40,blob:42,"has-binary":65,utf8:139}],64:[function(a,b,c){b.exports=Object.keys||function(a){var b=[],c=Object.prototype.hasOwnProperty;for(var d in a)c.call(a,d)&&b.push(d);return b}},{}],65:[function(a,b,c){(function(c){function d(a){function b(a){if(!a)return!1;if(c.Buffer&&c.Buffer.isBuffer(a)||c.ArrayBuffer&&a instanceof ArrayBuffer||c.Blob&&a instanceof Blob||c.File&&a instanceof File)return!0;if(e(a)){for(var d=0;d<a.length;d++)if(b(a[d]))return!0}else if(a&&"object"==typeof a){a.toJSON&&(a=a.toJSON());for(var f in a)if(Object.prototype.hasOwnProperty.call(a,f)&&b(a[f]))return!0}return!1}return b(a)}var e=a("isarray");b.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{isarray:66}],66:[function(a,b,c){b.exports=Array.isArray||function(a){return"[object Array]"==Object.prototype.toString.call(a)}},{}],67:[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}},{}],68:[function(a,b,c){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){"use strict";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(){"use strict";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}},{}],69:[function(a,b,c){var d=Object.prototype.hasOwnProperty,e=Object.prototype.toString;b.exports=function(a,b,c){if("[object Function]"!==e.call(b))throw new TypeError("iterator must be a function");var f=a.length;if(f===+f)for(var g=0;g<f;g++)b.call(c,a[g],g,a);else for(var h in a)d.call(a,h)&&b.call(c,a[h],h,a)}},{}],70:[function(a,b,c){(function(c){function d(a){function b(a){if(!a)return!1;if(c.Buffer&&c.Buffer.isBuffer&&c.Buffer.isBuffer(a)||c.ArrayBuffer&&a instanceof ArrayBuffer||c.Blob&&a instanceof Blob||c.File&&a instanceof File)return!0;if(e(a)){for(var d=0;d<a.length;d++)if(b(a[d]))return!0}else if(a&&"object"==typeof a){a.toJSON&&"function"==typeof a.toJSON&&(a=a.toJSON());for(var f in a)if(Object.prototype.hasOwnProperty.call(a,f)&&b(a[f]))return!0}return!1}return b(a)}var e=a("isarray");b.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{isarray:71}],71:[function(a,b,c){arguments[4][66][0].apply(c,arguments)},{dup:66}],72:[function(a,b,c){try{b.exports="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(d){b.exports=!1}},{}],73:[function(a,b,c){var d=a("http"),e=b.exports;for(var f in d)d.hasOwnProperty(f)&&(e[f]=d[f]);e.request=function(a,b){return a||(a={}),a.scheme="https",a.protocol="https:",d.request.call(this,a,b)}},{http:127}],74:[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}},{}],75:[function(a,b,c){var d=[].indexOf;b.exports=function(a,b){if(d)return a.indexOf(b);for(var c=0;c<a.length;++c)if(a[c]===b)return c;return-1}},{}],76:[function(a,b,c){"function"==typeof Object.create?b.exports=function(a,b){b&&(a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}))}:b.exports=function(a,b){if(b){a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}}},{}],77:[function(a,b,c){var d={}.toString;b.exports=Array.isArray||function(a){return"[object Array]"==d.call(a)}},{}],78:[function(b,c,d){(function(b){(function(){function e(a,b){function c(a){if(c[a]!==q)return c[a];var e;if("bug-string-char-index"==a)e="a"!="a"[0];else if("json"==a)e=c("json-stringify")&&c("json-parse");else{var g,h='{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';if("json-stringify"==a){var i=b.stringify,k="function"==typeof i&&t;if(k){(g=function(){return 1}).toJSON=g;try{k="0"===i(0)&&"0"===i(new d)&&'""'==i(new f)&&i(s)===q&&i(q)===q&&i()===q&&"1"===i(g)&&"[1]"==i([g])&&"[null]"==i([q])&&"null"==i(null)&&"[null,null,null]"==i([q,s,null])&&i({a:[g,!0,!1,null,"\0\b\n\f\r\t"]})==h&&"1"===i(null,g)&&"[\n 1,\n 2\n]"==i([1,2],null,1)&&'"-271821-04-20T00:00:00.000Z"'==i(new j((-864e13)))&&'"+275760-09-13T00:00:00.000Z"'==i(new j(864e13))&&'"-000001-01-01T00:00:00.000Z"'==i(new j((-621987552e5)))&&'"1969-12-31T23:59:59.999Z"'==i(new j((-1)))}catch(l){k=!1}}e=k}if("json-parse"==a){var m=b.parse;if("function"==typeof m)try{if(0===m("0")&&!m(!1)){g=m(h);var n=5==g.a.length&&1===g.a[0];if(n){try{n=!m('"\t"')}catch(l){}if(n)try{n=1!==m("01")}catch(l){}if(n)try{n=1!==m("1.")}catch(l){}}}}catch(l){n=!1}e=n}}return c[a]=!!e}a||(a=i.Object()),b||(b=i.Object());var d=a.Number||i.Number,f=a.String||i.String,h=a.Object||i.Object,j=a.Date||i.Date,k=a.SyntaxError||i.SyntaxError,l=a.TypeError||i.TypeError,m=a.Math||i.Math,n=a.JSON||i.JSON;"object"==typeof n&&n&&(b.stringify=n.stringify,b.parse=n.parse);var o,p,q,r=h.prototype,s=r.toString,t=new j((-0xc782b5b800cec));try{t=t.getUTCFullYear()==-109252&&0===t.getUTCMonth()&&1===t.getUTCDate()&&10==t.getUTCHours()&&37==t.getUTCMinutes()&&6==t.getUTCSeconds()&&708==t.getUTCMilliseconds()}catch(u){}if(!c("json")){var v="[object Function]",w="[object Date]",x="[object Number]",y="[object String]",z="[object Array]",A="[object Boolean]",B=c("bug-string-char-index");if(!t)var C=m.floor,D=[0,31,59,90,120,151,181,212,243,273,304,334],E=function(a,b){return D[b]+365*(a-1970)+C((a-1969+(b=+(b>1)))/4)-C((a-1901+b)/100)+C((a-1601+b)/400)};if((o=r.hasOwnProperty)||(o=function(a){var b,c={};return(c.__proto__=null,c.__proto__={toString:1},c).toString!=s?o=function(a){var b=this.__proto__,c=a in(this.__proto__=null,this);return this.__proto__=b,c}:(b=c.constructor,o=function(a){var c=(this.constructor||b).prototype;return a in this&&!(a in c&&this[a]===c[a])}),c=null,o.call(this,a)}),p=function(a,b){var c,d,e,f=0;(c=function(){this.valueOf=0}).prototype.valueOf=0,d=new c;for(e in d)o.call(d,e)&&f++;return c=d=null,f?p=2==f?function(a,b){var c,d={},e=s.call(a)==v;for(c in a)e&&"prototype"==c||o.call(d,c)||!(d[c]=1)||!o.call(a,c)||b(c)}:function(a,b){var c,d,e=s.call(a)==v;for(c in a)e&&"prototype"==c||!o.call(a,c)||(d="constructor"===c)||b(c);(d||o.call(a,c="constructor"))&&b(c)}:(d=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"],p=function(a,b){var c,e,f=s.call(a)==v,h=!f&&"function"!=typeof a.constructor&&g[typeof a.hasOwnProperty]&&a.hasOwnProperty||o;for(c in a)f&&"prototype"==c||!h.call(a,c)||b(c);for(e=d.length;c=d[--e];h.call(a,c)&&b(c));}),p(a,b)},!c("json-stringify")){var F={92:"\\\\",34:'\\"',8:"\\b",12:"\\f",10:"\\n",13:"\\r",9:"\\t"},G="000000",H=function(a,b){return(G+(b||0)).slice(-a)},I="\\u00",J=function(a){for(var b='"',c=0,d=a.length,e=!B||d>10,f=e&&(B?a.split(""):a);c<d;c++){var g=a.charCodeAt(c);switch(g){case 8:case 9:case 10:case 12:case 13:case 34:case 92:b+=F[g];break;default:if(g<32){b+=I+H(2,g.toString(16));break}b+=e?f[c]:a.charAt(c)}}return b+'"'},K=function(a,b,c,d,e,f,g){var h,i,j,k,m,n,r,t,u,v,B,D,F,G,I,L;try{h=b[a]}catch(M){}if("object"==typeof h&&h)if(i=s.call(h),i!=w||o.call(h,"toJSON"))"function"==typeof h.toJSON&&(i!=x&&i!=y&&i!=z||o.call(h,"toJSON"))&&(h=h.toJSON(a));else if(h>-1/0&&h<1/0){if(E){for(m=C(h/864e5),j=C(m/365.2425)+1970-1;E(j+1,0)<=m;j++);for(k=C((m-E(j,0))/30.42);E(j,k+1)<=m;k++);m=1+m-E(j,k),n=(h%864e5+864e5)%864e5,r=C(n/36e5)%24,t=C(n/6e4)%60,u=C(n/1e3)%60,v=n%1e3}else j=h.getUTCFullYear(),k=h.getUTCMonth(),m=h.getUTCDate(),r=h.getUTCHours(),t=h.getUTCMinutes(),u=h.getUTCSeconds(),v=h.getUTCMilliseconds();h=(j<=0||j>=1e4?(j<0?"-":"+")+H(6,j<0?-j:j):H(4,j))+"-"+H(2,k+1)+"-"+H(2,m)+"T"+H(2,r)+":"+H(2,t)+":"+H(2,u)+"."+H(3,v)+"Z"}else h=null;if(c&&(h=c.call(b,a,h)),null===h)return"null";if(i=s.call(h),i==A)return""+h;if(i==x)return h>-1/0&&h<1/0?""+h:"null";if(i==y)return J(""+h);if("object"==typeof h){for(G=g.length;G--;)if(g[G]===h)throw l();if(g.push(h),B=[],I=f,f+=e,i==z){for(F=0,G=h.length;F<G;F++)D=K(F,h,c,d,e,f,g),B.push(D===q?"null":D);L=B.length?e?"[\n"+f+B.join(",\n"+f)+"\n"+I+"]":"["+B.join(",")+"]":"[]"}else p(d||h,function(a){var b=K(a,h,c,d,e,f,g);b!==q&&B.push(J(a)+":"+(e?" ":"")+b)}),L=B.length?e?"{\n"+f+B.join(",\n"+f)+"\n"+I+"}":"{"+B.join(",")+"}":"{}";return g.pop(),L}};b.stringify=function(a,b,c){var d,e,f,h;if(g[typeof b]&&b)if((h=s.call(b))==v)e=b;else if(h==z){f={};for(var i,j=0,k=b.length;j<k;i=b[j++],h=s.call(i),(h==y||h==x)&&(f[i]=1));}if(c)if((h=s.call(c))==x){if((c-=c%1)>0)for(d="",c>10&&(c=10);d.length<c;d+=" ");}else h==y&&(d=c.length<=10?c:c.slice(0,10));return K("",(i={},i[""]=a,i),e,f,d,"",[])}}if(!c("json-parse")){var L,M,N=f.fromCharCode,O={92:"\\",34:'"',47:"/",98:"\b",116:"\t",110:"\n",102:"\f",114:"\r"},P=function(){throw L=M=null,k()},Q=function(){for(var a,b,c,d,e,f=M,g=f.length;L<g;)switch(e=f.charCodeAt(L)){case 9:case 10:case 13:case 32:L++;break;case 123:case 125:case 91:case 93:case 58:case 44:return a=B?f.charAt(L):f[L],L++,a;case 34:for(a="@",L++;L<g;)if(e=f.charCodeAt(L),e<32)P();else if(92==e)switch(e=f.charCodeAt(++L)){case 92:case 34:case 47:case 98:case 116:case 110:case 102:case 114:a+=O[e],L++;break;case 117:for(b=++L,c=L+4;L<c;L++)e=f.charCodeAt(L),e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70||P();a+=N("0x"+f.slice(b,L));break;default:P()}else{if(34==e)break;for(e=f.charCodeAt(L),b=L;e>=32&&92!=e&&34!=e;)e=f.charCodeAt(++L);a+=f.slice(b,L)}if(34==f.charCodeAt(L))return L++,a;P();default:if(b=L,45==e&&(d=!0,e=f.charCodeAt(++L)),e>=48&&e<=57){for(48==e&&(e=f.charCodeAt(L+1),e>=48&&e<=57)&&P(),d=!1;L<g&&(e=f.charCodeAt(L),e>=48&&e<=57);L++);if(46==f.charCodeAt(L)){for(c=++L;c<g&&(e=f.charCodeAt(c),e>=48&&e<=57);c++);c==L&&P(),L=c}if(e=f.charCodeAt(L),101==e||69==e){for(e=f.charCodeAt(++L),43!=e&&45!=e||L++,c=L;c<g&&(e=f.charCodeAt(c),e>=48&&e<=57);c++);c==L&&P(),L=c}return+f.slice(b,L)}if(d&&P(),"true"==f.slice(L,L+4))return L+=4,!0;if("false"==f.slice(L,L+5))return L+=5,!1;if("null"==f.slice(L,L+4))return L+=4,null;P()}return"$"},R=function(a){var b,c;if("$"==a&&P(),"string"==typeof a){if("@"==(B?a.charAt(0):a[0]))return a.slice(1);if("["==a){for(b=[];a=Q(),"]"!=a;c||(c=!0))c&&(","==a?(a=Q(),"]"==a&&P()):P()),","==a&&P(),b.push(R(a));return b}if("{"==a){for(b={};a=Q(),"}"!=a;c||(c=!0))c&&(","==a?(a=Q(),"}"==a&&P()):P()),","!=a&&"string"==typeof a&&"@"==(B?a.charAt(0):a[0])&&":"==Q()||P(),b[a.slice(1)]=R(Q());return b}P()}return a},S=function(a,b,c){var d=T(a,b,c);d===q?delete a[b]:a[b]=d},T=function(a,b,c){var d,e=a[b];if("object"==typeof e&&e)if(s.call(e)==z)for(d=e.length;d--;)S(e,d,c);else p(e,function(a){S(e,a,c)});return c.call(a,b,e)};b.parse=function(a,b){var c,d;return L=0,M=""+a,c=R(Q()),"$"!=Q()&&P(),L=M=null,b&&s.call(b)==v?T((d={},d[""]=c,d),"",b):c}}}return b.runInContext=e,b}var f="function"==typeof a&&a.amd,g={"function":!0,object:!0},h=g[typeof d]&&d&&!d.nodeType&&d,i=g[typeof window]&&window||this,j=h&&g[typeof c]&&c&&!c.nodeType&&"object"==typeof b&&b;if(!j||j.global!==j&&j.window!==j&&j.self!==j||(i=j),h&&!f)e(i,h);else{var k=i.JSON,l=i.JSON3,m=!1,n=e(i,i.JSON3={noConflict:function(){return m||(m=!0,i.JSON=k,i.JSON3=l,k=l=null),n}});i.JSON={parse:n.parse,stringify:n.stringify}}f&&a(function(){return n})}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],79:[function(a,b,c){"use strict";var d;if(!Object.keys){var e=Object.prototype.hasOwnProperty,f=Object.prototype.toString,g=a("./isArguments"),h=Object.prototype.propertyIsEnumerable,i=!h.call({toString:null},"toString"),j=h.call(function(){},"prototype"),k=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(a){var b=a.constructor;return b&&b.prototype===a},m={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},n=function(){if("undefined"==typeof window)return!1;for(var a in window)try{if(!m["$"+a]&&e.call(window,a)&&null!==window[a]&&"object"==typeof window[a])try{l(window[a])}catch(b){return!0}}catch(b){return!0}return!1}(),o=function(a){if("undefined"==typeof window||!n)return l(a);try{return l(a)}catch(b){return!1}};d=function(a){var b=null!==a&&"object"==typeof a,c="[object Function]"===f.call(a),d=g(a),h=b&&"[object String]"===f.call(a),l=[];if(!b&&!c&&!d)throw new TypeError("Object.keys called on a non-object");var m=j&&c;if(h&&a.length>0&&!e.call(a,0))for(var n=0;n<a.length;++n)l.push(String(n));if(d&&a.length>0)for(var p=0;p<a.length;++p)l.push(String(p));else for(var q in a)m&&"prototype"===q||!e.call(a,q)||l.push(String(q));if(i)for(var r=o(a),s=0;s<k.length;++s)r&&"constructor"===k[s]||!e.call(a,k[s])||l.push(k[s]);return l}}b.exports=d},{"./isArguments":81}],80:[function(a,b,c){"use strict";var d=Array.prototype.slice,e=a("./isArguments"),f=Object.keys,g=f?function(a){return f(a)}:a("./implementation"),h=Object.keys;g.shim=function(){if(Object.keys){var a=function(){var a=Object.keys(arguments);return a&&a.length===arguments.length}(1,2);a||(Object.keys=function(a){return h(e(a)?d.call(a):a)})}else Object.keys=g;return Object.keys||g},b.exports=g},{"./implementation":79,"./isArguments":81}],81:[function(a,b,c){"use strict";var d=Object.prototype.toString;b.exports=function(a){var b=d.call(a),c="[object Arguments]"===b;return c||(c="[object Array]"!==b&&null!==a&&"object"==typeof a&&"number"==typeof a.length&&a.length>=0&&"[object Function]"===d.call(a.callee)),c}},{}],82:[function(a,b,c){c.endianness=function(){return"LE"},c.hostname=function(){return"undefined"!=typeof location?location.hostname:""},c.loadavg=function(){return[]},c.uptime=function(){return 0},c.freemem=function(){return Number.MAX_VALUE},c.totalmem=function(){return Number.MAX_VALUE},c.cpus=function(){return[]},c.type=function(){return"Browser"},c.release=function(){return"undefined"!=typeof navigator?navigator.appVersion:""},c.networkInterfaces=c.getNetworkInterfaces=function(){return{}},c.arch=function(){return"javascript"},c.platform=function(){return"browser"},c.tmpdir=c.tmpDir=function(){return"/tmp"},c.EOL="\n"},{}],83:[function(a,b,c){(function(a){var c=/^[\],:{}\s]*$/,d=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,e=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,f=/(?:^|:|,)(?:\s*\[)+/g,g=/^\s+/,h=/\s+$/;
9
- b.exports=function(b){return"string"==typeof b&&b?(b=b.replace(g,"").replace(h,""),a.JSON&&JSON.parse?JSON.parse(b):c.test(b.replace(d,"@").replace(e,"]").replace(f,""))?new Function("return "+b)():void 0):null}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],84:[function(a,b,c){c.encode=function(a){var b="";for(var c in a)a.hasOwnProperty(c)&&(b.length&&(b+="&"),b+=encodeURIComponent(c)+"="+encodeURIComponent(a[c]));return b},c.decode=function(a){for(var b={},c=a.split("&"),d=0,e=c.length;d<e;d++){var f=c[d].split("=");b[decodeURIComponent(f[0])]=decodeURIComponent(f[1])}return b}},{}],85:[function(a,b,c){var d=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,e=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];b.exports=function(a){var b=a,c=a.indexOf("["),f=a.indexOf("]");c!=-1&&f!=-1&&(a=a.substring(0,c)+a.substring(c,f).replace(/:/g,";")+a.substring(f,a.length));for(var g=d.exec(a||""),h={},i=14;i--;)h[e[i]]=g[i]||"";return c!=-1&&f!=-1&&(h.source=b,h.host=h.host.substring(1,h.host.length-1).replace(/;/g,":"),h.authority=h.authority.replace("[","").replace("]","").replace(/;/g,":"),h.ipv6uri=!0),h}},{}],86:[function(a,b,c){(function(a){"use strict";function c(b,c,d,e){if("function"!=typeof b)throw new TypeError('"callback" argument must be a function');var f,g,h=arguments.length;switch(h){case 0:case 1:return a.nextTick(b);case 2:return a.nextTick(function(){b.call(null,c)});case 3:return a.nextTick(function(){b.call(null,c,d)});case 4:return a.nextTick(function(){b.call(null,c,d,e)});default:for(f=new Array(h-1),g=0;g<f.length;)f[g++]=arguments[g];return a.nextTick(function(){b.apply(null,f)})}}"undefined"==typeof a||!a.version||0===a.version.indexOf("v0.")||0===a.version.indexOf("v1.")&&0!==a.version.indexOf("v1.8.")?b.exports={nextTick:c}:b.exports=a}).call(this,a("_process"))},{_process:87}],87:[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,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}},{}],88:[function(b,c,d){!function(b,e){"object"==typeof d&&"object"==typeof c?c.exports=e():"function"==typeof a&&a.amd?a([],e):"object"==typeof d?d.PubNub=e():b.PubNub=e()}(this,function(){return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={exports:{},id:d,loaded:!1};return a[d].call(e.exports,e,e.exports,b),e.loaded=!0,e.exports}var c={};return b.m=a,b.c=c,b.p="",b(0)}([function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function f(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function g(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function h(a){return!(!navigator||!navigator.sendBeacon)&&void navigator.sendBeacon(a)}Object.defineProperty(b,"__esModule",{value:!0});var i=c(1),j=d(i),k=c(40),l=d(k),m=c(41),n=d(m),o=c(42),p=(c(5),function(a){function b(a){e(this,b);var c=a.listenToBrowserNetworkEvents,d=void 0===c||c;a.db=n["default"],a.sdkFamily="Web",a.networking=new l["default"]({del:o.del,get:o.get,post:o.post,sendBeacon:h});var g=f(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a));return d&&(window.addEventListener("offline",function(){g.networkDownDetected()}),window.addEventListener("online",function(){g.networkUpDetected()})),g}return g(b,a),b}(j["default"]));b["default"]=p,a.exports=b["default"]},function(a,b,c){"use strict";function d(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[c]=a[c]);return b["default"]=a,b}function e(a){return a&&a.__esModule?a:{"default":a}}function f(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(b,"__esModule",{value:!0});var g=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),h=c(2),i=e(h),j=c(6),k=e(j),l=c(8),m=e(l),n=c(9),o=e(n),p=c(16),q=e(p),r=c(17),s=d(r),t=c(18),u=d(t),v=c(19),w=d(v),x=c(20),y=d(x),z=c(21),A=d(z),B=c(22),C=d(B),D=c(23),E=d(D),F=c(24),G=d(F),H=c(25),I=d(H),J=c(26),K=d(J),L=c(27),M=d(L),N=c(28),O=d(N),P=c(29),Q=d(P),R=c(30),S=d(R),T=c(31),U=d(T),V=c(32),W=d(V),X=c(33),Y=d(X),Z=c(34),$=d(Z),_=c(35),aa=d(_),ba=c(36),ca=d(ba),da=c(37),ea=d(da),fa=c(38),ga=d(fa),ha=c(12),ia=d(ha),ja=c(39),ka=d(ja),la=c(13),ma=e(la),na=c(10),oa=e(na),pa=(c(5),c(3)),qa=e(pa),ra=function(){function a(b){var c=this;f(this,a);var d=b.db,e=b.networking,g=this._config=new i["default"]({setup:b,db:d}),h=new k["default"]({config:g});e.init(g);var j={config:g,networking:e,crypto:h},l=q["default"].bind(this,j,ia),n=q["default"].bind(this,j,K),p=q["default"].bind(this,j,O),r=q["default"].bind(this,j,S),t=q["default"].bind(this,j,ka),v=this._listenerManager=new o["default"],x=new m["default"]({timeEndpoint:l,leaveEndpoint:n,heartbeatEndpoint:p,setStateEndpoint:r,subscribeEndpoint:t,crypto:j.crypto,config:j.config,listenerManager:v});this.addListener=v.addListener.bind(v),this.removeListener=v.removeListener.bind(v),this.removeAllListeners=v.removeAllListeners.bind(v),this.channelGroups={listGroups:q["default"].bind(this,j,y),listChannels:q["default"].bind(this,j,A),addChannels:q["default"].bind(this,j,s),removeChannels:q["default"].bind(this,j,u),deleteGroup:q["default"].bind(this,j,w)},this.push={addChannels:q["default"].bind(this,j,C),removeChannels:q["default"].bind(this,j,E),deleteDevice:q["default"].bind(this,j,I),listChannels:q["default"].bind(this,j,G)},this.hereNow=q["default"].bind(this,j,U),this.whereNow=q["default"].bind(this,j,M),this.getState=q["default"].bind(this,j,Q),this.setState=x.adaptStateChange.bind(x),this.grant=q["default"].bind(this,j,Y),this.audit=q["default"].bind(this,j,W),this.publish=q["default"].bind(this,j,$),this.fire=function(a,b){return a.replicate=!1,a.storeInHistory=!1,c.publish(a,b)},this.history=q["default"].bind(this,j,aa),this.deleteMessages=q["default"].bind(this,j,ca),this.messageCounts=q["default"].bind(this,j,ea),this.fetchMessages=q["default"].bind(this,j,ga),this.time=l,this.subscribe=x.adaptSubscribeChange.bind(x),this.presence=x.adaptPresenceChange.bind(x),this.unsubscribe=x.adaptUnsubscribeChange.bind(x),this.disconnect=x.disconnect.bind(x),this.reconnect=x.reconnect.bind(x),this.destroy=function(a){x.unsubscribeAll(a),x.disconnect()},this.stop=this.destroy,this.unsubscribeAll=x.unsubscribeAll.bind(x),this.getSubscribedChannels=x.getSubscribedChannels.bind(x),this.getSubscribedChannelGroups=x.getSubscribedChannelGroups.bind(x),this.encrypt=h.encrypt.bind(h),this.decrypt=h.decrypt.bind(h),this.getAuthKey=j.config.getAuthKey.bind(j.config),this.setAuthKey=j.config.setAuthKey.bind(j.config),this.setCipherKey=j.config.setCipherKey.bind(j.config),this.getUUID=j.config.getUUID.bind(j.config),this.setUUID=j.config.setUUID.bind(j.config),this.getFilterExpression=j.config.getFilterExpression.bind(j.config),this.setFilterExpression=j.config.setFilterExpression.bind(j.config),this.setHeartbeatInterval=j.config.setHeartbeatInterval.bind(j.config),e.hasModule("proxy")&&(this.setProxy=function(a){j.config.setProxy(a),c.reconnect()})}return g(a,[{key:"getVersion",value:function(){return this._config.getVersion()}},{key:"networkDownDetected",value:function(){this._listenerManager.announceNetworkDown(),this._config.restore?this.disconnect():this.destroy(!0)}},{key:"networkUpDetected",value:function(){this._listenerManager.announceNetworkUp(),this.reconnect()}}],[{key:"generateUUID",value:function(){return qa["default"].createUUID()}}]),a}();ra.OPERATIONS=ma["default"],ra.CATEGORIES=oa["default"],b["default"]=ra,a.exports=b["default"]},function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(b,"__esModule",{value:!0});var e=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),f=c(3),g=function(a){return a&&a.__esModule?a:{"default":a}}(f),h=(c(5),function(){function a(b){var c=b.setup,e=b.db;d(this,a),this._db=e,this.instanceId="pn-"+g["default"].createUUID(),this.secretKey=c.secretKey||c.secret_key,this.subscribeKey=c.subscribeKey||c.subscribe_key,this.publishKey=c.publishKey||c.publish_key,this.sdkName=c.sdkName,this.sdkFamily=c.sdkFamily,this.partnerId=c.partnerId,this.setAuthKey(c.authKey),this.setCipherKey(c.cipherKey),this.setFilterExpression(c.filterExpression),this.origin=c.origin||"ps.pndsn.com",this.secure=c.ssl||!1,this.restore=c.restore||!1,this.proxy=c.proxy,this.keepAlive=c.keepAlive,this.keepAliveSettings=c.keepAliveSettings,this.autoNetworkDetection=c.autoNetworkDetection||!1,this.dedupeOnSubscribe=c.dedupeOnSubscribe||!1,this.maximumCacheSize=c.maximumCacheSize||100,this.customEncrypt=c.customEncrypt,this.customDecrypt=c.customDecrypt,"undefined"!=typeof location&&"https:"===location.protocol&&(this.secure=!0),this.logVerbosity=c.logVerbosity||!1,this.suppressLeaveEvents=c.suppressLeaveEvents||!1,this.announceFailedHeartbeats=c.announceFailedHeartbeats||!0,this.announceSuccessfulHeartbeats=c.announceSuccessfulHeartbeats||!1,this.useInstanceId=c.useInstanceId||!1,this.useRequestId=c.useRequestId||!1,this.requestMessageCountThreshold=c.requestMessageCountThreshold,this.setTransactionTimeout(c.transactionalRequestTimeout||15e3),this.setSubscribeTimeout(c.subscribeRequestTimeout||31e4),this.setSendBeaconConfig(c.useSendBeacon||!0),this.setPresenceTimeout(c.presenceTimeout||300),null!=c.heartbeatInterval&&this.setHeartbeatInterval(c.heartbeatInterval),this.setUUID(this._decideUUID(c.uuid))}return e(a,[{key:"getAuthKey",value:function(){return this.authKey}},{key:"setAuthKey",value:function(a){return this.authKey=a,this}},{key:"setCipherKey",value:function(a){return this.cipherKey=a,this}},{key:"getUUID",value:function(){return this.UUID}},{key:"setUUID",value:function(a){return this._db&&this._db.set&&this._db.set(this.subscribeKey+"uuid",a),this.UUID=a,this}},{key:"getFilterExpression",value:function(){return this.filterExpression}},{key:"setFilterExpression",value:function(a){return this.filterExpression=a,this}},{key:"getPresenceTimeout",value:function(){return this._presenceTimeout}},{key:"setPresenceTimeout",value:function(a){return this._presenceTimeout=a,this.setHeartbeatInterval(this._presenceTimeout/2-1),this}},{key:"setProxy",value:function(a){this.proxy=a}},{key:"getHeartbeatInterval",value:function(){return this._heartbeatInterval}},{key:"setHeartbeatInterval",value:function(a){return this._heartbeatInterval=a,this}},{key:"getSubscribeTimeout",value:function(){return this._subscribeRequestTimeout}},{key:"setSubscribeTimeout",value:function(a){return this._subscribeRequestTimeout=a,this}},{key:"getTransactionTimeout",value:function(){return this._transactionalRequestTimeout}},{key:"setTransactionTimeout",value:function(a){return this._transactionalRequestTimeout=a,this}},{key:"isSendBeaconEnabled",value:function(){return this._useSendBeacon}},{key:"setSendBeaconConfig",value:function(a){return this._useSendBeacon=a,this}},{key:"getVersion",value:function(){return"4.24.2"}},{key:"_decideUUID",value:function(a){return a||(this._db&&this._db.get&&this._db.get(this.subscribeKey+"uuid")?this._db.get(this.subscribeKey+"uuid"):"pn-"+g["default"].createUUID())}}]),a}());b["default"]=h,a.exports=b["default"]},function(a,b,c){"use strict";Object.defineProperty(b,"__esModule",{value:!0});var d=c(4),e=function(a){return a&&a.__esModule?a:{"default":a}}(d);b["default"]={createUUID:function(){return e["default"].uuid?e["default"].uuid():(0,e["default"])()}},a.exports=b["default"]},function(a,b,c){var d,e,f;!function(c,g){e=[b],d=g,void 0!==(f="function"==typeof d?d.apply(b,e):d)&&(a.exports=f)}(0,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=d[b||"all"];return c&&c.test(a)||!1}var d={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="0.1.0",a.uuid=b,a.isUUID=c})},function(a,b){"use strict";a.exports={}},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(b,"__esModule",{value:!0});var f=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),g=c(2),h=(d(g),c(7)),i=d(h),j=function(){function a(b){var c=b.config;e(this,a),this._config=c,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 f(a,[{key:"HMACSHA256",value:function(a){return i["default"].HmacSHA256(a,this._config.secretKey).toString(i["default"].enc.Base64)}},{key:"SHA256",value:function(a){return i["default"].SHA256(a).toString(i["default"].enc.Hex)}},{key:"_parseOptions",value: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}},{key:"_decodeKey",value:function(a,b){return"base64"===b.keyEncoding?i["default"].enc.Base64.parse(a):"hex"===b.keyEncoding?i["default"].enc.Hex.parse(a):a}},{key:"_getPaddedKey",value:function(a,b){return a=this._decodeKey(a,b),b.encryptKey?i["default"].enc.Utf8.parse(this.SHA256(a).slice(0,32)):a}},{key:"_getMode",value:function(a){return"ecb"===a.mode?i["default"].mode.ECB:i["default"].mode.CBC}},{key:"_getIV",value:function(a){return"cbc"===a.mode?i["default"].enc.Utf8.parse(this._iv):null}},{key:"encrypt",value:function(a,b,c){return this._config.customEncrypt?this._config.customEncrypt(a):this.pnEncrypt(a,b,c)}},{key:"decrypt",value:function(a,b,c){return this._config.customDecrypt?this._config.customDecrypt(a):this.pnDecrypt(a,b,c)}},{key:"pnEncrypt",value:function(a,b,c){if(!b&&!this._config.cipherKey)return a;c=this._parseOptions(c);var d=this._getIV(c),e=this._getMode(c),f=this._getPaddedKey(b||this._config.cipherKey,c);return i["default"].AES.encrypt(a,f,{iv:d,mode:e}).ciphertext.toString(i["default"].enc.Base64)||a}},{key:"pnDecrypt",value:function(a,b,c){if(!b&&!this._config.cipherKey)return a;c=this._parseOptions(c);var d=this._getIV(c),e=this._getMode(c),f=this._getPaddedKey(b||this._config.cipherKey,c);try{var g=i["default"].enc.Base64.parse(a),h=i["default"].AES.decrypt({ciphertext:g},f,{iv:d,mode:e}).toString(i["default"].enc.Utf8);return JSON.parse(h)}catch(a){return null}}}]),a}();b["default"]=j,a.exports=b["default"]},function(a,b){"use strict";var c=c||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=void 0!=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),h=b?a.ceil(h):a.max((0|h)-this._minBufferSize,0);if(b=h*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=c,d=b.lib,e=d.WordArray,f=d.Hasher,d=b.algo,g=[],h=[],i=function(a){return 4294967296*(a-(0|a))|0},j=2,k=0;64>k;){var l;a:{l=j;for(var m=a.sqrt(l),n=2;n<=m;n++)if(!(l%n)){l=!1;break a}l=!0}l&&(8>k&&(g[k]=i(a.pow(j,.5))),h[k]=i(a.pow(j,1/3)),k++),j++}var o=[],d=d.SHA256=f.extend({_doReset:function(){this._hash=new e.init(g.slice(0))},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],g=c[3],i=c[4],j=c[5],k=c[6],l=c[7],m=0;64>m;m++){if(16>m)o[m]=0|a[b+m];else{var n=o[m-15],p=o[m-2];o[m]=((n<<25|n>>>7)^(n<<14|n>>>18)^n>>>3)+o[m-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+o[m-16]}n=l+((i<<26|i>>>6)^(i<<21|i>>>11)^(i<<7|i>>>25))+(i&j^~i&k)+h[m]+o[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=g+n|0,g=f,f=e,e=d,d=n+p|0}c[0]=c[0]+d|0,c[1]=c[1]+e|0,c[2]=c[2]+f|0,c[3]=c[3]+g|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=f.clone.call(this);return a._hash=this._hash.clone(),a}});b.SHA256=f._createHelper(d),b.HmacSHA256=f._createHmacHelper(d)}(Math),function(){var a=c,b=a.enc.Utf8;a.algo.HMAC=a.lib.Base.extend({init:function(a,c){a=this._hasher=new a.init,"string"==typeof c&&(c=b.parse(c));var d=a.blockSize,e=4*d;c.sigBytes>e&&(c=a.finalize(c)),c.clamp();for(var f=this._oKey=c.clone(),g=this._iKey=c.clone(),h=f.words,i=g.words,j=0;j<d;j++)h[j]^=1549556828,i[j]^=909522486;f.sigBytes=g.sigBytes=e,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))}})}(),function(){var a=c,b=a.lib.WordArray;a.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 c=a.length,d=this._map,e=d.charAt(64);e&&-1!=(e=a.indexOf(e))&&(c=e);for(var e=[],f=0,g=0;g<c;g++)if(g%4){var h=d.indexOf(a.charAt(g-1))<<g%4*2,i=d.indexOf(a.charAt(g))>>>6-g%4*2;e[f>>>2]|=(h|i)<<24-f%4*8,f++}return b.create(e,f)},_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 d(a,b,c,d,e,f,g){return((a=a+(b&d|c&~d)+e+g)<<f|a>>>32-f)+b}function e(a,b,c,d,e,f,g){return((a=a+(b^c^d)+e+g)<<f|a>>>32-f)+b}function f(a,b,c,d,e,f,g){return((a=a+(c^(b|~d))+e+g)<<f|a>>>32-f)+b}for(var g=c,h=g.lib,i=h.WordArray,j=h.Hasher,h=g.algo,k=[],l=0;64>l;l++)k[l]=4294967296*a.abs(a.sin(l+1))|0;h=h.MD5=j.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(a,c){for(var g=0;16>g;g++){var h=c+g,i=a[h];a[h]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var g=this._hash.words,h=a[c+0],i=a[c+1],j=a[c+2],l=a[c+3],m=a[c+4],n=a[c+5],o=a[c+6],p=a[c+7],q=a[c+8],r=a[c+9],s=a[c+10],t=a[c+11],u=a[c+12],v=a[c+13],w=a[c+14],x=a[c+15],y=g[0],z=g[1],A=g[2],B=g[3],y=b(y,z,A,B,h,7,k[0]),B=b(B,y,z,A,i,12,k[1]),A=b(A,B,y,z,j,17,k[2]),z=b(z,A,B,y,l,22,k[3]),y=b(y,z,A,B,m,7,k[4]),B=b(B,y,z,A,n,12,k[5]),A=b(A,B,y,z,o,17,k[6]),z=b(z,A,B,y,p,22,k[7]),y=b(y,z,A,B,q,7,k[8]),B=b(B,y,z,A,r,12,k[9]),A=b(A,B,y,z,s,17,k[10]),z=b(z,A,B,y,t,22,k[11]),y=b(y,z,A,B,u,7,k[12]),B=b(B,y,z,A,v,12,k[13]),A=b(A,B,y,z,w,17,k[14]),z=b(z,A,B,y,x,22,k[15]),y=d(y,z,A,B,i,5,k[16]),B=d(B,y,z,A,o,9,k[17]),A=d(A,B,y,z,t,14,k[18]),z=d(z,A,B,y,h,20,k[19]),y=d(y,z,A,B,n,5,k[20]),B=d(B,y,z,A,s,9,k[21]),A=d(A,B,y,z,x,14,k[22]),z=d(z,A,B,y,m,20,k[23]),y=d(y,z,A,B,r,5,k[24]),B=d(B,y,z,A,w,9,k[25]),A=d(A,B,y,z,l,14,k[26]),z=d(z,A,B,y,q,20,k[27]),y=d(y,z,A,B,v,5,k[28]),B=d(B,y,z,A,j,9,k[29]),A=d(A,B,y,z,p,14,k[30]),z=d(z,A,B,y,u,20,k[31]),y=e(y,z,A,B,n,4,k[32]),B=e(B,y,z,A,q,11,k[33]),A=e(A,B,y,z,t,16,k[34]),z=e(z,A,B,y,w,23,k[35]),y=e(y,z,A,B,i,4,k[36]),B=e(B,y,z,A,m,11,k[37]),A=e(A,B,y,z,p,16,k[38]),z=e(z,A,B,y,s,23,k[39]),y=e(y,z,A,B,v,4,k[40]),B=e(B,y,z,A,h,11,k[41]),A=e(A,B,y,z,l,16,k[42]),z=e(z,A,B,y,o,23,k[43]),y=e(y,z,A,B,r,4,k[44]),B=e(B,y,z,A,u,11,k[45]),A=e(A,B,y,z,x,16,k[46]),z=e(z,A,B,y,j,23,k[47]),y=f(y,z,A,B,h,6,k[48]),B=f(B,y,z,A,p,10,k[49]),A=f(A,B,y,z,w,15,k[50]),z=f(z,A,B,y,n,21,k[51]),y=f(y,z,A,B,u,6,k[52]),B=f(B,y,z,A,l,10,k[53]),A=f(A,B,y,z,s,15,k[54]),z=f(z,A,B,y,i,21,k[55]),y=f(y,z,A,B,q,6,k[56]),B=f(B,y,z,A,x,10,k[57]),A=f(A,B,y,z,o,15,k[58]),z=f(z,A,B,y,v,21,k[59]),y=f(y,z,A,B,m,6,k[60]),B=f(B,y,z,A,t,10,k[61]),A=f(A,B,y,z,j,15,k[62]),z=f(z,A,B,y,r,21,k[63]);g[0]=g[0]+y|0,g[1]=g[1]+z|0,g[2]=g[2]+A|0,g[3]=g[3]+B|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(),b=this._hash,c=b.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=j.clone.call(this);return a._hash=this._hash.clone(),a}}),g.MD5=j._createHelper(h),g.HmacMD5=j._createHmacHelper(h)}(Math),function(){var a=c,b=a.lib,d=b.Base,e=b.WordArray,b=a.algo,f=b.EvpKDF=d.extend({cfg:d.extend({keySize:4,hasher:b.MD5,iterations:1}),init:function(a){this.cfg=this.cfg.extend(a)},compute:function(a,b){for(var c=this.cfg,d=c.hasher.create(),f=e.create(),g=f.words,h=c.keySize,c=c.iterations;g.length<h;){i&&d.update(i);var i=d.update(a).finalize(b);d.reset();for(var j=1;j<c;j++)i=d.finalize(i),d.reset();f.concat(i)}return f.sigBytes=4*h,f}});a.EvpKDF=function(a,b,c){return f.create(c).compute(a,b)}}(),c.lib.Cipher||function(a){var b=c,d=b.lib,e=d.Base,f=d.WordArray,g=d.BufferedBlockAlgorithm,h=b.enc.Base64,i=b.algo.EvpKDF,j=d.Cipher=g.extend({cfg:e.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(){g.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?p:o).encrypt(a,b,c,d)},decrypt:function(b,c,d){return("string"==typeof c?p:o).decrypt(a,b,c,d)}}}});d.StreamCipher=j.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var k=b.mode={},l=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]},m=(d.BlockCipherMode=e.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();m.Encryptor=m.extend({processBlock:function(a,b){var c=this._cipher,d=c.blockSize;l.call(this,a,b,d),c.encryptBlock(a,b),this._prevBlock=a.slice(b,b+d)}}),m.Decryptor=m.extend({processBlock:function(a,b){var c=this._cipher,d=c.blockSize,e=a.slice(b,b+d);c.decryptBlock(a,b),l.call(this,a,b,d),this._prevBlock=e}}),k=k.CBC=m,m=(b.pad={}).Pkcs7={pad:function(a,b){for(var c=4*b,c=c-a.sigBytes%c,d=c<<24|c<<16|c<<8|c,e=[],g=0;g<c;g+=4)e.push(d);c=f.create(e,c),a.concat(c)},unpad:function(a){a.sigBytes-=255&a.words[a.sigBytes-1>>>2]}},d.BlockCipher=j.extend({cfg:j.cfg.extend({mode:k,padding:m}),reset:function(){j.reset.call(this);var a=this.cfg,b=a.iv,a=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=a.createEncryptor;else c=a.createDecryptor,this._minBufferSize=1;this._mode=c.call(a,this,b&&b.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 n=d.CipherParams=e.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),k=(b.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;return a=a.salt,(a?f.create([1398893684,1701076831]).concat(a).concat(b):b).toString(h)},parse:function(a){a=h.parse(a);var b=a.words;if(1398893684==b[0]&&1701076831==b[1]){var c=f.create(b.slice(2,4));b.splice(0,4),a.sigBytes-=16}return n.create({ciphertext:a,salt:c})}},o=d.SerializableCipher=e.extend({cfg:e.extend({format:k}),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,n.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}}),b=(b.kdf={}).OpenSSL={execute:function(a,b,c,d){return d||(d=f.random(8)),a=i.create({keySize:b+c}).compute(a,d),c=f.create(a.words.slice(b),4*c),a.sigBytes=4*b,n.create({key:a,iv:c,salt:d})}},p=d.PasswordBasedCipher=o.extend({cfg:o.cfg.extend({kdf:b}),encrypt:function(a,b,c,d){return d=this.cfg.extend(d),c=d.kdf.execute(c,a.keySize,a.ivSize),d.iv=c.iv,a=o.encrypt.call(this,a,b,c.key,d),a.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,o.decrypt.call(this,a,b,c.key,d)}})}(),function(){for(var a=c,b=a.lib.BlockCipher,d=a.algo,e=[],f=[],g=[],h=[],i=[],j=[],k=[],l=[],m=[],n=[],o=[],p=0;256>p;p++)o[p]=128>p?p<<1:p<<1^283;for(var q=0,r=0,p=0;256>p;p++){var s=r^r<<1^r<<2^r<<3^r<<4,s=s>>>8^255&s^99;e[q]=s,f[s]=q;var t=o[q],u=o[t],v=o[u],w=257*o[s]^16843008*s;g[q]=w<<24|w>>>8,h[q]=w<<16|w>>>16,i[q]=w<<8|w>>>24,j[q]=w,w=16843009*v^65537*u^257*t^16843008*q,k[s]=w<<24|w>>>8,l[s]=w<<16|w>>>16,m[s]=w<<8|w>>>24,n[s]=w,q?(q=t^o[o[o[v^t]]],r^=o[o[r]]):q=r=1}var x=[0,1,2,4,8,16,32,64,128,27,54],d=d.AES=b.extend({_doReset:function(){for(var a=this._key,b=a.words,c=a.sigBytes/4,a=4*((this._nRounds=c+6)+1),d=this._keySchedule=[],f=0;f<a;f++)if(f<c)d[f]=b[f];else{var g=d[f-1];f%c?6<c&&4==f%c&&(g=e[g>>>24]<<24|e[g>>>16&255]<<16|e[g>>>8&255]<<8|e[255&g]):(g=g<<8|g>>>24,g=e[g>>>24]<<24|e[g>>>16&255]<<16|e[g>>>8&255]<<8|e[255&g],g^=x[f/c|0]<<24),d[f]=d[f-c]^g}for(b=this._invKeySchedule=[],c=0;c<a;c++)f=a-c,
10
- g=c%4?d[f]:d[f-4],b[c]=4>c||4>=f?g:k[e[g>>>24]]^l[e[g>>>16&255]]^m[e[g>>>8&255]]^n[e[255&g]]},encryptBlock:function(a,b){this._doCryptBlock(a,b,this._keySchedule,g,h,i,j,e)},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,k,l,m,n,f),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(d)}(),c.mode.ECB=function(){var a=c.lib.BlockCipherMode.extend();return a.Encryptor=a.extend({processBlock:function(a,b){this._cipher.encryptBlock(a,b)}}),a.Decryptor=a.extend({processBlock:function(a,b){this._cipher.decryptBlock(a,b)}}),a}(),a.exports=c},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(b,"__esModule",{value:!0});var f=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),g=c(6),h=(d(g),c(2)),i=(d(h),c(9)),j=(d(i),c(11)),k=d(j),l=c(14),m=d(l),n=c(15),o=d(n),p=(c(5),c(10)),q=d(p),r=function(){function a(b){var c=b.subscribeEndpoint,d=b.leaveEndpoint,f=b.heartbeatEndpoint,g=b.setStateEndpoint,h=b.timeEndpoint,i=b.config,j=b.crypto,l=b.listenerManager;e(this,a),this._listenerManager=l,this._config=i,this._leaveEndpoint=d,this._heartbeatEndpoint=f,this._setStateEndpoint=g,this._subscribeEndpoint=c,this._crypto=j,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 k["default"]({timeEndpoint:h}),this._dedupingManager=new m["default"]({config:i})}return f(a,[{key:"adaptStateChange",value: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;return 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)}),this._setStateEndpoint({state:d,channels:f,channelGroups:h},b)}},{key:"adaptPresenceChange",value: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()}},{key:"adaptSubscribeChange",value: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;return 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._heartbeatChannels[a]={}),b._pendingChannelSubscriptions.push(a)}),g.forEach(function(a){b._channelGroups[a]={state:{}},i&&(b._presenceChannelGroups[a]={}),k&&(b._heartbeatChannelGroups[a]={}),b._pendingChannelGroupSubscriptions.push(a)}),this._subscriptionStatusAnnounced=!1,this.reconnect(),void 0):void(console&&console.log&&console.log("subscribe key missing; aborting subscribe"))}},{key:"adaptUnsubscribeChange",value: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._channelGroups[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())}},{key:"unsubscribeAll",value:function(a){this.adaptUnsubscribeChange({channels:this.getSubscribedChannels(),channelGroups:this.getSubscribedChannelGroups()},a)}},{key:"getHeartbeatChannels",value:function(){return Object.keys(this._heartbeatChannels)}},{key:"getHeartbeatChannelGroups",value:function(){return Object.keys(this._heartbeatChannelGroups)}},{key:"getSubscribedChannels",value:function(){return Object.keys(this._channels)}},{key:"getSubscribedChannelGroups",value:function(){return Object.keys(this._channelGroups)}},{key:"reconnect",value:function(){this._startSubscribeLoop(),this._registerHeartbeatTimer()}},{key:"disconnect",value:function(){this._stopSubscribeLoop(),this._stopHeartbeatTimer(),this._reconnectionManager.stopPolling()}},{key:"_registerHeartbeatTimer",value:function(){this._stopHeartbeatTimer(),0!==this._config.getHeartbeatInterval()&&(this._performHeartbeatLoop(),this._heartbeatTimer=setInterval(this._performHeartbeatLoop.bind(this),1e3*this._config.getHeartbeatInterval()))}},{key:"_stopHeartbeatTimer",value:function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=null)}},{key:"_performHeartbeatLoop",value:function(){var a=this,b=this.getHeartbeatChannels(),c=this.getHeartbeatChannelGroups(),d={};if(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)});var e=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)};this._heartbeatEndpoint({channels:b,channelGroups:c,state:d},e.bind(this))}}},{key:"_startSubscribeLoop",value: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(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(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))}}},{key:"_processSubscribeResponse",value:function(a,b){var c=this;if(a.error)return void(a.category===q["default"].PNTimeoutCategory?this._startSubscribeLoop():a.category===q["default"].PNNetworkIssuesCategory?(this.disconnect(),a.error&&this._config.autoNetworkDetection&&this._isOnline&&(this._isOnline=!1,this._listenerManager.announceNetworkDown()),this._reconnectionManager.onReconnection(function(){c._config.autoNetworkDetection&&!c._isOnline&&(c._isOnline=!0,c._listenerManager.announceNetworkUp()),c.reconnect(),c._subscriptionStatusAnnounced=!0;var b={category:q["default"].PNReconnectedCategory,operation:a.operation,lastTimetoken:c._lastTimetoken,currentTimetoken:c._currentTimetoken};c._listenerManager.announceStatus(b)}),this._reconnectionManager.startPolling(),this._listenerManager.announceStatus(a)):a.category===q["default"].PNBadRequestCategory?(this._stopHeartbeatTimer(),this._listenerManager.announceStatus(a)):this._listenerManager.announceStatus(a));if(this._storedTimetoken?(this._currentTimetoken=this._storedTimetoken,this._storedTimetoken=null):(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=b.metadata.timetoken),!this._subscriptionStatusAnnounced){var d={};d.category=q["default"].PNConnectedCategory,d.operation=a.operation,d.affectedChannels=this._pendingChannelSubscriptions,d.subscribedChannels=this.getSubscribedChannels(),d.affectedChannelGroups=this._pendingChannelGroupSubscriptions,d.lastTimetoken=this._lastTimetoken,d.currentTimetoken=this._currentTimetoken,this._subscriptionStatusAnnounced=!0,this._listenerManager.announceStatus(d),this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[]}var e=b.messages||[],f=this._config,g=f.requestMessageCountThreshold,h=f.dedupeOnSubscribe;if(g&&e.length>=g){var i={};i.category=q["default"].PNRequestMessageCountExceededCategory,i.operation=a.operation,this._listenerManager.announceStatus(i)}e.forEach(function(a){var b=a.channel,d=a.subscriptionMatch,e=a.publishMetaData;if(b===d&&(d=null),h){if(c._dedupingManager.isDuplicate(a))return;c._dedupingManager.addEntry(a)}if(o["default"].endsWith(a.channel,"-pnpres")){var f={};f.channel=null,f.subscription=null,f.actualChannel=null!=d?b:null,f.subscribedChannel=null!=d?d:b,b&&(f.channel=b.substring(0,b.lastIndexOf("-pnpres"))),d&&(f.subscription=d.substring(0,d.lastIndexOf("-pnpres"))),f.action=a.payload.action,f.state=a.payload.data,f.timetoken=e.publishTimetoken,f.occupancy=a.payload.occupancy,f.uuid=a.payload.uuid,f.timestamp=a.payload.timestamp,a.payload.join&&(f.join=a.payload.join),a.payload.leave&&(f.leave=a.payload.leave),a.payload.timeout&&(f.timeout=a.payload.timeout),c._listenerManager.announcePresence(f)}else{var g={};g.channel=null,g.subscription=null,g.actualChannel=null!=d?b:null,g.subscribedChannel=null!=d?d:b,g.channel=b,g.subscription=d,g.timetoken=e.publishTimetoken,g.publisher=a.issuingClientId,a.userMetadata&&(g.userMetadata=a.userMetadata),c._config.cipherKey?g.message=c._crypto.decrypt(a.payload):g.message=a.payload,c._listenerManager.announceMessage(g)}}),this._region=b.metadata.region,this._startSubscribeLoop()}},{key:"_stopSubscribeLoop",value:function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)}}]),a}();b["default"]=r,a.exports=b["default"]},function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(b,"__esModule",{value:!0});var e=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),f=(c(5),c(10)),g=function(a){return a&&a.__esModule?a:{"default":a}}(f),h=function(){function a(){d(this,a),this._listeners=[]}return e(a,[{key:"addListener",value:function(a){this._listeners.push(a)}},{key:"removeListener",value:function(a){var b=[];this._listeners.forEach(function(c){c!==a&&b.push(c)}),this._listeners=b}},{key:"removeAllListeners",value:function(){this._listeners=[]}},{key:"announcePresence",value:function(a){this._listeners.forEach(function(b){b.presence&&b.presence(a)})}},{key:"announceStatus",value:function(a){this._listeners.forEach(function(b){b.status&&b.status(a)})}},{key:"announceMessage",value:function(a){this._listeners.forEach(function(b){b.message&&b.message(a)})}},{key:"announceNetworkUp",value:function(){var a={};a.category=g["default"].PNNetworkUpCategory,this.announceStatus(a)}},{key:"announceNetworkDown",value:function(){var a={};a.category=g["default"].PNNetworkDownCategory,this.announceStatus(a)}}]),a}();b["default"]=h,a.exports=b["default"]},function(a,b){"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b["default"]={PNNetworkUpCategory:"PNNetworkUpCategory",PNNetworkDownCategory:"PNNetworkDownCategory",PNNetworkIssuesCategory:"PNNetworkIssuesCategory",PNTimeoutCategory:"PNTimeoutCategory",PNBadRequestCategory:"PNBadRequestCategory",PNAccessDeniedCategory:"PNAccessDeniedCategory",PNUnknownCategory:"PNUnknownCategory",PNReconnectedCategory:"PNReconnectedCategory",PNConnectedCategory:"PNConnectedCategory",PNRequestMessageCountExceededCategory:"PNRequestMessageCountExceededCategory"},a.exports=b["default"]},function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(b,"__esModule",{value:!0});var e=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),f=c(12),g=(function(a){a&&a.__esModule}(f),c(5),function(){function a(b){var c=b.timeEndpoint;d(this,a),this._timeEndpoint=c}return e(a,[{key:"onReconnection",value:function(a){this._reconnectionCallback=a}},{key:"startPolling",value:function(){this._timeTimer=setInterval(this._performTimeLoop.bind(this),3e3)}},{key:"stopPolling",value:function(){clearInterval(this._timeTimer)}},{key:"_performTimeLoop",value:function(){var a=this;this._timeEndpoint(function(b){b.error||(clearInterval(a._timeTimer),a._reconnectionCallback())})}}]),a}());b["default"]=g,a.exports=b["default"]},function(a,b,c){"use strict";function d(){return l["default"].PNTimeOperation}function e(){return"/time/0"}function f(a){return a.config.getTransactionTimeout()}function g(){return{}}function h(){return!1}function i(a,b){return{timetoken:b[0]}}function j(){}Object.defineProperty(b,"__esModule",{value:!0}),b.getOperation=d,b.getURL=e,b.getRequestTimeout=f,b.prepareParams=g,b.isAuthSupported=h,b.handleResponse=i,b.validateParams=j;var k=(c(5),c(13)),l=function(a){return a&&a.__esModule?a:{"default":a}}(k)},function(a,b){"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b["default"]={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNMessageCounts:"PNMessageCountsOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",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",PNAccessManagerAudit:"PNAccessManagerAudit"},a.exports=b["default"]},function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(b,"__esModule",{value:!0});var e=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),f=c(2),g=(function(a){a&&a.__esModule}(f),c(5),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}),h=function(){function a(b){var c=b.config;d(this,a),this.hashHistory=[],this._config=c}return e(a,[{key:"getKey",value:function(a){var b=g(JSON.stringify(a.payload)).toString();return a.publishMetaData.publishTimetoken+"-"+b}},{key:"isDuplicate",value:function(a){return this.hashHistory.includes(this.getKey(a))}},{key:"addEntry",value:function(a){this.hashHistory.length>=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(a))}},{key:"clearHistory",value:function(){this.hashHistory=[]}}]),a}();b["default"]=h,a.exports=b["default"]},function(a,b){"use strict";function c(a){var b=[];return Object.keys(a).forEach(function(a){return b.push(a)}),b}function d(a){return encodeURIComponent(a).replace(/[!~*'()]/g,function(a){return"%"+a.charCodeAt(0).toString(16).toUpperCase()})}function e(a){return c(a).sort()}function f(a){return e(a).map(function(b){return b+"="+d(a[b])}).join("&")}function g(a,b){return-1!==a.indexOf(b,this.length-b.length)}function h(){var a=void 0,b=void 0;return{promise:new Promise(function(c,d){a=c,b=d}),reject:b,fulfill:a}}a.exports={signPamFromParams:f,endsWith:g,createPromise:h,encodeString:d}},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function f(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b}function g(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function h(a,b){return a.type=b,a.error=!0,a}function i(a){return h({message:a},"validationError")}function j(a,b,c){return a.usePost&&a.usePost(b,c)?a.postURL(b,c):a.getURL(b,c)}function k(a){if(a.sdkName)return a.sdkName;var b="PubNub-JS-"+a.sdkFamily;return a.partnerId&&(b+="-"+a.partnerId),b+="/"+a.getVersion()}function l(a,b,c){var d=a.config,e=a.crypto;c.timestamp=Math.floor((new Date).getTime()/1e3);var f=d.subscribeKey+"\n"+d.publishKey+"\n"+b+"\n";f+=p["default"].signPamFromParams(c);var g=e.HMACSHA256(f);g=g.replace(/\+/g,"-"),g=g.replace(/\//g,"_"),c.signature=g}Object.defineProperty(b,"__esModule",{value:!0}),b["default"]=function(a,b){var c=a.networking,d=a.config,e=null,f=null,g={};b.getOperation()===s["default"].PNTimeOperation||b.getOperation()===s["default"].PNChannelGroupsOperation?e=arguments.length<=2?void 0:arguments[2]:(g=arguments.length<=2?void 0:arguments[2],e=arguments.length<=3?void 0:arguments[3]),"undefined"==typeof Promise||e||(f=p["default"].createPromise());var h=b.validateParams(a,g);if(!h){var m=b.prepareParams(a,g),o=j(b,a,g),q=void 0,r={url:o,operation:b.getOperation(),timeout:b.getRequestTimeout(a)};m.uuid=d.UUID,m.pnsdk=k(d),d.useInstanceId&&(m.instanceid=d.instanceId),d.useRequestId&&(m.requestid=n["default"].createUUID()),b.isAuthSupported()&&d.getAuthKey()&&(m.auth=d.getAuthKey()),d.secretKey&&l(a,o,m);var u=function(c,d){if(c.error)return void(e?e(c):f&&f.reject(new t("PubNub call failed, check status for details",c)));var h=b.handleResponse(a,d,g);e?e(c,h):f&&f.fulfill(h)};if(b.usePost&&b.usePost(a,g)){var v=b.postPayload(a,g);q=c.POST(m,v,r,u)}else q=b.useDelete&&b.useDelete()?c.DELETE(m,r,u):c.GET(m,r,u);return b.getOperation()===s["default"].PNSubscribeOperation?q:f?f.promise:void 0}return e?e(i(h)):f?(f.reject(new t("Validation failed, check status for details",i(h))),f.promise):void 0};var m=c(3),n=d(m),o=(c(5),c(15)),p=d(o),q=c(2),r=(d(q),c(13)),s=d(r),t=function(a){function b(a,c){e(this,b);var d=f(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,a));return d.name=d.constructor.name,d.status=c,d.message=a,d}return g(b,a),b}(Error);a.exports=b["default"]},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(){return m["default"].PNAddChannelsToGroupOperation}function f(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"}function g(a,b){var c=b.channelGroup;return"/v1/channel-registration/sub-key/"+a.config.subscribeKey+"/channel-group/"+o["default"].encodeString(c)}function h(a){return a.config.getTransactionTimeout()}function i(){return!0}function j(a,b){var c=b.channels;return{add:(void 0===c?[]:c).join(",")}}function k(){return{}}Object.defineProperty(b,"__esModule",{value:!0}),b.getOperation=e,b.validateParams=f,b.getURL=g,b.getRequestTimeout=h,b.isAuthSupported=i,b.prepareParams=j,b.handleResponse=k;var l=(c(5),c(13)),m=d(l),n=c(15),o=d(n)},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(){return m["default"].PNRemoveChannelsFromGroupOperation}function f(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"}function g(a,b){var c=b.channelGroup;return"/v1/channel-registration/sub-key/"+a.config.subscribeKey+"/channel-group/"+o["default"].encodeString(c)}function h(a){return a.config.getTransactionTimeout()}function i(){return!0}function j(a,b){var c=b.channels;return{remove:(void 0===c?[]:c).join(",")}}function k(){return{}}Object.defineProperty(b,"__esModule",{value:!0}),b.getOperation=e,b.validateParams=f,b.getURL=g,b.getRequestTimeout=h,b.isAuthSupported=i,b.prepareParams=j,b.handleResponse=k;var l=(c(5),c(13)),m=d(l),n=c(15),o=d(n)},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(){return m["default"].PNRemoveGroupOperation}function f(a,b){var c=b.channelGroup,d=a.config;return c?d.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channel Group"}function g(a,b){var c=b.channelGroup;return"/v1/channel-registration/sub-key/"+a.config.subscribeKey+"/channel-group/"+o["default"].encodeString(c)+"/remove"}function h(){return!0}function i(a){return a.config.getTransactionTimeout()}function j(){return{}}function k(){return{}}Object.defineProperty(b,"__esModule",{value:!0}),b.getOperation=e,b.validateParams=f,b.getURL=g,b.isAuthSupported=h,b.getRequestTimeout=i,b.prepareParams=j,b.handleResponse=k;var l=(c(5),c(13)),m=d(l),n=c(15),o=d(n)},function(a,b,c){"use strict";function d(){return l["default"].PNChannelGroupsOperation}function e(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"}function f(a){return"/v1/channel-registration/sub-key/"+a.config.subscribeKey+"/channel-group"}function g(a){return a.config.getTransactionTimeout()}function h(){return!0}function i(){return{}}function j(a,b){return{groups:b.payload.groups}}Object.defineProperty(b,"__esModule",{value:!0}),b.getOperation=d,b.validateParams=e,b.getURL=f,b.getRequestTimeout=g,b.isAuthSupported=h,b.prepareParams=i,b.handleResponse=j;var k=(c(5),c(13)),l=function(a){return a&&a.__esModule?a:{"default":a}}(k)},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(){return m["default"].PNChannelsForGroupOperation}function f(a,b){var c=b.channelGroup,d=a.config;return c?d.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channel Group"}function g(a,b){var c=b.channelGroup;return"/v1/channel-registration/sub-key/"+a.config.subscribeKey+"/channel-group/"+o["default"].encodeString(c)}function h(a){return a.config.getTransactionTimeout()}function i(){return!0}function j(){return{}}function k(a,b){return{channels:b.payload.channels}}Object.defineProperty(b,"__esModule",{value:!0}),b.getOperation=e,b.validateParams=f,b.getURL=g,b.getRequestTimeout=h,b.isAuthSupported=i,b.prepareParams=j,b.handleResponse=k;var l=(c(5),c(13)),m=d(l),n=c(15),o=d(n)},function(a,b,c){"use strict";function d(){return l["default"].PNPushNotificationEnabledChannelsOperation}function e(a,b){var c=b.device,d=b.pushGateway,e=b.channels,f=a.config;return c?d?e&&0!==e.length?f.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing GW Type (pushGateway: gcm or apns)":"Missing Device ID (device)"}function f(a,b){var c=b.device;return"/v1/push/sub-key/"+a.config.subscribeKey+"/devices/"+c}function g(a){return a.config.getTransactionTimeout()}function h(){return!0}function i(a,b){var c=b.pushGateway,d=b.channels;return{type:c,add:(void 0===d?[]:d).join(",")}}function j(){return{}}Object.defineProperty(b,"__esModule",{value:!0}),b.getOperation=d,b.validateParams=e,b.getURL=f,b.getRequestTimeout=g,b.isAuthSupported=h,b.prepareParams=i,b.handleResponse=j;var k=(c(5),c(13)),l=function(a){return a&&a.__esModule?a:{"default":a}}(k)},function(a,b,c){"use strict";function d(){return l["default"].PNPushNotificationEnabledChannelsOperation}function e(a,b){var c=b.device,d=b.pushGateway,e=b.channels,f=a.config;return c?d?e&&0!==e.length?f.subscribeKey?void 0:"Missing Subscribe Key":"Missing Channels":"Missing GW Type (pushGateway: gcm or apns)":"Missing Device ID (device)"}function f(a,b){var c=b.device;return"/v1/push/sub-key/"+a.config.subscribeKey+"/devices/"+c}function g(a){return a.config.getTransactionTimeout()}function h(){return!0}function i(a,b){var c=b.pushGateway,d=b.channels;return{type:c,remove:(void 0===d?[]:d).join(",")}}function j(){return{}}Object.defineProperty(b,"__esModule",{value:!0}),b.getOperation=d,b.validateParams=e,b.getURL=f,b.getRequestTimeout=g,b.isAuthSupported=h,b.prepareParams=i,b.handleResponse=j;var k=(c(5),c(13)),l=function(a){return a&&a.__esModule?a:{"default":a}}(k)},function(a,b,c){"use strict";function d(){return l["default"].PNPushNotificationEnabledChannelsOperation}function e(a,b){var c=b.device,d=b.pushGateway,e=a.config;return c?d?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing GW Type (pushGateway: gcm or apns)":"Missing Device ID (device)"}function f(a,b){var c=b.device;return"/v1/push/sub-key/"+a.config.subscribeKey+"/devices/"+c}function g(a){return a.config.getTransactionTimeout()}function h(){return!0}function i(a,b){return{type:b.pushGateway}}function j(a,b){return{channels:b}}Object.defineProperty(b,"__esModule",{value:!0}),b.getOperation=d,b.validateParams=e,b.getURL=f,b.getRequestTimeout=g,b.isAuthSupported=h,b.prepareParams=i,b.handleResponse=j;var k=(c(5),c(13)),l=function(a){return a&&a.__esModule?a:{"default":a}}(k)},function(a,b,c){"use strict";function d(){return l["default"].PNRemoveAllPushNotificationsOperation}function e(a,b){var c=b.device,d=b.pushGateway,e=a.config;return c?d?e.subscribeKey?void 0:"Missing Subscribe Key":"Missing GW Type (pushGateway: gcm or apns)":"Missing Device ID (device)"}function f(a,b){var c=b.device;return"/v1/push/sub-key/"+a.config.subscribeKey+"/devices/"+c+"/remove"}function g(a){return a.config.getTransactionTimeout()}function h(){return!0}function i(a,b){return{type:b.pushGateway}}function j(){return{}}Object.defineProperty(b,"__esModule",{value:!0}),b.getOperation=d,b.validateParams=e,b.getURL=f,b.getRequestTimeout=g,b.isAuthSupported=h,b.prepareParams=i,b.handleResponse=j;var k=(c(5),c(13)),l=function(a){return a&&a.__esModule?a:{"default":a}}(k)},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(){return m["default"].PNUnsubscribeOperation}function f(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"}function g(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/"+c.subscribeKey+"/channel/"+o["default"].encodeString(f)+"/leave"}function h(a){return a.config.getTransactionTimeout()}function i(){return!0}function j(a,b){var c=b.channelGroups,d=void 0===c?[]:c,e={};return d.length>0&&(e["channel-group"]=d.join(",")),e}function k(){return{}}Object.defineProperty(b,"__esModule",{value:!0}),b.getOperation=e,b.validateParams=f,b.getURL=g,b.getRequestTimeout=h,b.isAuthSupported=i,b.prepareParams=j,b.handleResponse=k;var l=(c(5),c(13)),m=d(l),n=c(15),o=d(n)},function(a,b,c){"use strict";function d(){return l["default"].PNWhereNowOperation}function e(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"}function f(a,b){var c=a.config,d=b.uuid,e=void 0===d?c.UUID:d;return"/v2/presence/sub-key/"+c.subscribeKey+"/uuid/"+e}function g(a){return a.config.getTransactionTimeout()}function h(){return!0}function i(){return{}}function j(a,b){return b.payload?{channels:b.payload.channels}:{channels:[]}}Object.defineProperty(b,"__esModule",{value:!0}),b.getOperation=d,b.validateParams=e,b.getURL=f,b.getRequestTimeout=g,b.isAuthSupported=h,b.prepareParams=i,b.handleResponse=j;var k=(c(5),c(13)),l=function(a){return a&&a.__esModule?a:{"default":a}}(k)},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(){return m["default"].PNHeartbeatOperation}function f(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"}function g(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/"+c.subscribeKey+"/channel/"+o["default"].encodeString(f)+"/heartbeat"}function h(){return!0}function i(a){return a.config.getTransactionTimeout()}function j(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}function k(){return{}}Object.defineProperty(b,"__esModule",{value:!0}),b.getOperation=e,b.validateParams=f,b.getURL=g,b.isAuthSupported=h,b.getRequestTimeout=i,b.prepareParams=j,b.handleResponse=k;var l=(c(5),c(13)),m=d(l),n=c(15),o=d(n)},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(){return m["default"].PNGetStateOperation}function f(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"}function g(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/"+c.subscribeKey+"/channel/"+o["default"].encodeString(h)+"/uuid/"+e}function h(a){return a.config.getTransactionTimeout()}function i(){return!0}function j(a,b){var c=b.channelGroups,d=void 0===c?[]:c,e={};return d.length>0&&(e["channel-group"]=d.join(",")),e}function k(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}}Object.defineProperty(b,"__esModule",{value:!0}),b.getOperation=e,b.validateParams=f,b.getURL=g,b.getRequestTimeout=h,b.isAuthSupported=i,b.prepareParams=j,b.handleResponse=k;var l=(c(5),c(13)),m=d(l),n=c(15),o=d(n)},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(){return m["default"].PNSetStateOperation}function f(a,b){
11
- 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"}function g(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/"+c.subscribeKey+"/channel/"+o["default"].encodeString(f)+"/uuid/"+c.UUID+"/data"}function h(a){return a.config.getTransactionTimeout()}function i(){return!0}function j(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}function k(a,b){return{state:b.payload}}Object.defineProperty(b,"__esModule",{value:!0}),b.getOperation=e,b.validateParams=f,b.getURL=g,b.getRequestTimeout=h,b.isAuthSupported=i,b.prepareParams=j,b.handleResponse=k;var l=(c(5),c(13)),m=d(l),n=c(15),o=d(n)},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(){return m["default"].PNHereNowOperation}function f(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"}function g(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/"+c.subscribeKey;if(e.length>0||g.length>0){var i=e.length>0?e.join(","):",";h+="/channel/"+o["default"].encodeString(i)}return h}function h(a){return a.config.getTransactionTimeout()}function i(){return!0}function j(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={};return f||(i.disable_uuids=1),h&&(i.state=1),d.length>0&&(i["channel-group"]=d.join(",")),i}function k(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}()}Object.defineProperty(b,"__esModule",{value:!0}),b.getOperation=e,b.validateParams=f,b.getURL=g,b.getRequestTimeout=h,b.isAuthSupported=i,b.prepareParams=j,b.handleResponse=k;var l=(c(5),c(13)),m=d(l),n=c(15),o=d(n)},function(a,b,c){"use strict";function d(){return l["default"].PNAccessManagerAudit}function e(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"}function f(a){return"/v2/auth/audit/sub-key/"+a.config.subscribeKey}function g(a){return a.config.getTransactionTimeout()}function h(){return!1}function i(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}function j(a,b){return b.payload}Object.defineProperty(b,"__esModule",{value:!0}),b.getOperation=d,b.validateParams=e,b.getURL=f,b.getRequestTimeout=g,b.isAuthSupported=h,b.prepareParams=i,b.handleResponse=j;var k=(c(5),c(13)),l=function(a){return a&&a.__esModule?a:{"default":a}}(k)},function(a,b,c){"use strict";function d(){return l["default"].PNAccessManagerGrant}function e(a){var b=a.config;return b.subscribeKey?b.publishKey?b.secretKey?void 0:"Missing Secret Key":"Missing Publish Key":"Missing Subscribe Key"}function f(a){return"/v2/auth/grant/sub-key/"+a.config.subscribeKey}function g(a){return a.config.getTransactionTimeout()}function h(){return!1}function i(a,b){var c=b.channels,d=void 0===c?[]:c,e=b.channelGroups,f=void 0===e?[]:e,g=b.ttl,h=b.read,i=void 0!==h&&h,j=b.write,k=void 0!==j&&j,l=b.manage,m=void 0!==l&&l,n=b.authKeys,o=void 0===n?[]:n,p={};return p.r=i?"1":"0",p.w=k?"1":"0",p.m=m?"1":"0",d.length>0&&(p.channel=d.join(",")),f.length>0&&(p["channel-group"]=f.join(",")),o.length>0&&(p.auth=o.join(",")),(g||0===g)&&(p.ttl=g),p}function j(){return{}}Object.defineProperty(b,"__esModule",{value:!0}),b.getOperation=d,b.validateParams=e,b.getURL=f,b.getRequestTimeout=g,b.isAuthSupported=h,b.prepareParams=i,b.handleResponse=j;var k=(c(5),c(13)),l=function(a){return a&&a.__esModule?a:{"default":a}}(k)},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(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 f(){return r["default"].PNPublishOperation}function g(a,b){var c=a.config,d=b.message;return b.channel?d?c.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"}function h(a,b){var c=b.sendByPost;return void 0!==c&&c}function i(a,b){var c=a.config,d=b.channel,f=b.message,g=e(a,f);return"/publish/"+c.publishKey+"/"+c.subscribeKey+"/0/"+t["default"].encodeString(d)+"/0/"+t["default"].encodeString(g)}function j(a,b){var c=a.config,d=b.channel;return"/publish/"+c.publishKey+"/"+c.subscribeKey+"/0/"+t["default"].encodeString(d)+"/0"}function k(a){return a.config.getTransactionTimeout()}function l(){return!0}function m(a,b){return e(a,b.message)}function n(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"===(void 0===c?"undefined":p(c))&&(h.meta=JSON.stringify(c)),h}function o(a,b){return{timetoken:b[2]}}Object.defineProperty(b,"__esModule",{value:!0});var p="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};b.getOperation=f,b.validateParams=g,b.usePost=h,b.getURL=i,b.postURL=j,b.getRequestTimeout=k,b.isAuthSupported=l,b.postPayload=m,b.prepareParams=n,b.handleResponse=o;var q=(c(5),c(13)),r=d(q),s=c(15),t=d(s)},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b){var c=a.config,d=a.crypto;if(!c.cipherKey)return b;try{return d.decrypt(b)}catch(a){return b}}function f(){return n["default"].PNHistoryOperation}function g(a,b){var c=b.channel,d=a.config;return c?d.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"}function h(a,b){var c=b.channel;return"/v2/history/sub-key/"+a.config.subscribeKey+"/channel/"+p["default"].encodeString(c)}function i(a){return a.config.getTransactionTimeout()}function j(){return!0}function k(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={include_token:"true"};return j.count=g,c&&(j.start=c),d&&(j.end=d),i&&(j.string_message_token="true"),null!=e&&(j.reverse=e.toString()),j}function l(a,b){var c={messages:[],startTimeToken:b[1],endTimeToken:b[2]};return b[0].forEach(function(b){var d={timetoken:b.timetoken,entry:e(a,b.message)};c.messages.push(d)}),c}Object.defineProperty(b,"__esModule",{value:!0}),b.getOperation=f,b.validateParams=g,b.getURL=h,b.getRequestTimeout=i,b.isAuthSupported=j,b.prepareParams=k,b.handleResponse=l;var m=(c(5),c(13)),n=d(m),o=c(15),p=d(o)},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(){return n["default"].PNDeleteMessagesOperation}function f(a,b){var c=b.channel,d=a.config;return c?d.subscribeKey?void 0:"Missing Subscribe Key":"Missing channel"}function g(){return!0}function h(a,b){var c=b.channel;return"/v3/history/sub-key/"+a.config.subscribeKey+"/channel/"+p["default"].encodeString(c)}function i(a){return a.config.getTransactionTimeout()}function j(){return!0}function k(a,b){var c=b.start,d=b.end,e={};return c&&(e.start=c),d&&(e.end=d),e}function l(a,b){return b.payload}Object.defineProperty(b,"__esModule",{value:!0}),b.getOperation=e,b.validateParams=f,b.useDelete=g,b.getURL=h,b.getRequestTimeout=i,b.isAuthSupported=j,b.prepareParams=k,b.handleResponse=l;var m=(c(5),c(13)),n=d(m),o=c(15),p=d(o)},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(){return n["default"].PNMessageCounts}function f(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":d&&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"}function g(a,b){var c=b.channels,d=a.config,e=c.join(",");return"/v3/history/sub-key/"+d.subscribeKey+"/message-counts/"+p["default"].encodeString(e)}function h(a){return a.config.getTransactionTimeout()}function i(){return!0}function j(a,b){var c=b.timetoken,d=b.channelTimetokens,e={};if(d&&1===d.length){var f=l(d,1),g=f[0];e.timetoken=g}else d?e.channelsTimetoken=d.join(","):c&&(e.timetoken=c);return e}function k(a,b){return{channels:b.channels}}Object.defineProperty(b,"__esModule",{value:!0});var l=function(){function a(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!b||c.length!==b);d=!0);}catch(a){e=!0,f=a}finally{try{!d&&h["return"]&&h["return"]()}finally{if(e)throw f}}return c}return function(b,c){if(Array.isArray(b))return b;if(Symbol.iterator in Object(b))return a(b,c);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();b.getOperation=e,b.validateParams=f,b.getURL=g,b.getRequestTimeout=h,b.isAuthSupported=i,b.prepareParams=j,b.handleResponse=k;var m=c(13),n=d(m),o=c(15),p=d(o)},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b){var c=a.config,d=a.crypto;if(!c.cipherKey)return b;try{return d.decrypt(b)}catch(a){return b}}function f(){return n["default"].PNFetchMessagesOperation}function g(a,b){var c=b.channels,d=a.config;return c&&0!==c.length?d.subscribeKey?void 0:"Missing Subscribe Key":"Missing channels"}function h(a,b){var c=b.channels,d=void 0===c?[]:c,e=a.config,f=d.length>0?d.join(","):",";return"/v3/history/sub-key/"+e.subscribeKey+"/channel/"+p["default"].encodeString(f)}function i(a){return a.config.getTransactionTimeout()}function j(){return!0}function k(a,b){var c=b.start,d=b.end,e=b.count,f=b.stringifiedTimeToken,g=void 0!==f&&f,h={};return e&&(h.max=e),c&&(h.start=c),d&&(h.end=d),g&&(h.string_message_token="true"),h}function l(a,b){var c={channels:{}};return Object.keys(b.channels||{}).forEach(function(d){c.channels[d]=[],(b.channels[d]||[]).forEach(function(b){var f={};f.channel=d,f.subscription=null,f.timetoken=b.timetoken,f.message=e(a,b.message),c.channels[d].push(f)})}),c}Object.defineProperty(b,"__esModule",{value:!0}),b.getOperation=f,b.validateParams=g,b.getURL=h,b.getRequestTimeout=i,b.isAuthSupported=j,b.prepareParams=k,b.handleResponse=l;var m=(c(5),c(13)),n=d(m),o=c(15),p=d(o)},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(){return m["default"].PNSubscribeOperation}function f(a){if(!a.config.subscribeKey)return"Missing Subscribe Key"}function g(a,b){var c=a.config,d=b.channels,e=void 0===d?[]:d,f=e.length>0?e.join(","):",";return"/v2/subscribe/"+c.subscribeKey+"/"+o["default"].encodeString(f)+"/0"}function h(a){return a.config.getSubscribeTimeout()}function i(){return!0}function j(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}function k(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,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}}Object.defineProperty(b,"__esModule",{value:!0}),b.getOperation=e,b.validateParams=f,b.getURL=g,b.getRequestTimeout=h,b.isAuthSupported=i,b.prepareParams=j,b.handleResponse=k;var l=(c(5),c(13)),m=d(l),n=c(15),o=d(n)},function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(b,"__esModule",{value:!0});var f=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),g=c(2),h=(d(g),c(10)),i=d(h),j=(c(5),function(){function a(b){var c=this;e(this,a),this._modules={},Object.keys(b).forEach(function(a){c._modules[a]=b[a].bind(c)})}return f(a,[{key:"init",value:function(a){this._config=a,this._maxSubDomain=20,this._currentSubDomain=Math.floor(Math.random()*this._maxSubDomain),this._providedFQDN=(this._config.secure?"https://":"http://")+this._config.origin,this._coreParams={},this.shiftStandardOrigin()}},{key:"nextOrigin",value:function(){if(-1===this._providedFQDN.indexOf("ps."))return this._providedFQDN;var a=void 0;return this._currentSubDomain=this._currentSubDomain+1,this._currentSubDomain>=this._maxSubDomain&&(this._currentSubDomain=1),a=this._currentSubDomain.toString(),this._providedFQDN.replace("ps.","ps"+a+".")}},{key:"hasModule",value:function(a){return a in this._modules}},{key:"shiftStandardOrigin",value:function(){var a=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._standardOrigin=this.nextOrigin(a),this._standardOrigin}},{key:"getStandardOrigin",value:function(){return this._standardOrigin}},{key:"POST",value:function(a,b,c,d){return this._modules.post(a,b,c,d)}},{key:"GET",value:function(a,b,c){return this._modules.get(a,b,c)}},{key:"DELETE",value:function(a,b,c){return this._modules.del(a,b,c)}},{key:"_detectErrorCategory",value:function(a){if("ENOTFOUND"===a.code)return i["default"].PNNetworkIssuesCategory;if("ECONNREFUSED"===a.code)return i["default"].PNNetworkIssuesCategory;if("ECONNRESET"===a.code)return i["default"].PNNetworkIssuesCategory;if("EAI_AGAIN"===a.code)return i["default"].PNNetworkIssuesCategory;if(0===a.status||a.hasOwnProperty("status")&&void 0===a.status)return i["default"].PNNetworkIssuesCategory;if(a.timeout)return i["default"].PNTimeoutCategory;if("ETIMEDOUT"===a.code)return i["default"].PNNetworkIssuesCategory;if(a.response){if(a.response.badRequest)return i["default"].PNBadRequestCategory;if(a.response.forbidden)return i["default"].PNAccessDeniedCategory}return i["default"].PNUnknownCategory}}]),a}());b["default"]=j,a.exports=b["default"]},function(a,b){"use strict";Object.defineProperty(b,"__esModule",{value:!0}),b["default"]={get:function(a){try{return localStorage.getItem(a)}catch(a){return null}},set:function(a,b){try{return localStorage.setItem(a,b)}catch(a){return null}}},a.exports=b["default"]},function(a,b,c){"use strict";function d(a){var b=(new Date).getTime(),c=(new Date).toISOString(),d=function(){return console&&console.log?console:window&&window.console&&window.console.log?window.console:console}();d.log("<<<<<"),d.log("["+c+"]","\n",a.url,"\n",a.qs),d.log("-----"),a.on("response",function(c){var e=(new Date).getTime(),f=e-b,g=(new Date).toISOString();d.log(">>>>>>"),d.log("["+g+" / "+f+"]","\n",a.url,"\n",a.qs,"\n",c.text),d.log("-----")})}function e(a,b,c){var e=this;return this._config.logVerbosity&&(a=a.use(d)),this._config.proxy&&this._modules.proxy&&(a=this._modules.proxy.call(this,a)),this._config.keepAlive&&this._modules.keepAlive&&(a=this._modules.keepAlive(a)),a.timeout(b.timeout).end(function(a,b){var d=void 0,f={};if(f.error=null!==a,f.operation=g.operation,b&&b.status&&(f.statusCode=b.status),a){if(a.response&&a.response.text&&!e._config.logVerbosity)try{f.errorData=JSON.parse(a.response.text)}catch(g){f.errorData=a}else f.errorData=a;return f.category=e._detectErrorCategory(a),c(f,null)}try{d=JSON.parse(b.text)}catch(a){return f.errorData=b,f.error=!0,c(f,null)}return d.error&&1===d.error&&d.status&&d.message&&d.service?(f.errorData=d,f.statusCode=d.status,f.error=!0,f.category=e._detectErrorCategory(f),c(f,null)):c(f,d)})}function f(a,b,c){var d=j["default"].get(this.getStandardOrigin()+b.url).query(a);return e.call(this,d,b,c)}function g(a,b,c,d){var f=j["default"].post(this.getStandardOrigin()+c.url).query(a).send(b);return e.call(this,f,c,d)}function h(a,b,c){var d=j["default"]["delete"](this.getStandardOrigin()+b.url).query(a);return e.call(this,d,b,c)}Object.defineProperty(b,"__esModule",{value:!0}),b.get=f,b.post=g,b.del=h;var i=c(43),j=function(a){return a&&a.__esModule?a:{"default":a}}(i);c(5)},function(a,b,c){function d(){}function e(a){if(!p(a))return a;var b=[];for(var c in a)f(b,c,a[c]);return b.join("&")}function f(a,b,c){if(null!=c)if(Array.isArray(c))c.forEach(function(c){f(a,b,c)});else if(p(c))for(var d in c)f(a,b+"["+d+"]",c[d]);else a.push(encodeURIComponent(b)+"="+encodeURIComponent(c));else null===c&&a.push(encodeURIComponent(b))}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("="),-1==c?d[decodeURIComponent(b)]="":d[decodeURIComponent(b.slice(0,c))]=decodeURIComponent(b.slice(c+1));return d}function h(a){for(var b,c,d,e,f=a.split(/\r?\n/),g={},h=0,i=f.length;h<i;++h)c=f[h],-1!==(b=c.indexOf(":"))&&(d=c.slice(0,b).toLowerCase(),e=t(c.slice(b+1)),g[d]=e);return g}function i(a){return/[\/+]json($|[^-\w])/.test(a)}function j(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.header=this.headers=h(this.xhr.getAllResponseHeaders()),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?this._parseBody(this.text?this.text:this.xhr.response):null}function k(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 j(c)}catch(b){return a=new Error("Parser is unable to parse the response"),a.parse=!0,a.original=b,c.xhr?(a.rawResponse=void 0===c.xhr.responseType?c.xhr.responseText:c.xhr.response,a.status=c.xhr.status?c.xhr.status:null,a.statusCode=a.status):(a.rawResponse=null,a.status=null),c.callback(a)}c.emit("response",b);var d;try{c._isResponseOK(b)||(d=new Error(b.statusText||"Unsuccessful HTTP response"))}catch(a){d=a}d?(d.original=a,d.response=b,d.status=b.status,c.callback(d,b)):c.callback(null,b)})}function l(a,b,c){var d=s("DELETE",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d}var m;"undefined"!=typeof window?m=window:"undefined"!=typeof self?m=self:(console.warn("Using browser-only version of superagent in non-browser environment"),m=this);var n=c(44),o=c(45),p=c(46),q=c(47),r=c(49),s=b=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)};b.Request=k,s.getXHR=function(){if(!(!m.XMLHttpRequest||m.location&&"file:"==m.location.protocol&&m.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 Error("Browser-only version of superagent could not find XHR")};var t="".trim?function(a){return a.trim()}:function(a){return a.replace(/(^\s*|\s*$)/g,"")};s.serializeObject=e,s.parseString=g,s.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"},s.serialize={"application/x-www-form-urlencoded":e,"application/json":JSON.stringify},s.parse={"application/x-www-form-urlencoded":g,"application/json":JSON.parse},q(j.prototype),j.prototype._parseBody=function(a){var b=s.parse[this.type];return this.req._parser?this.req._parser(this,a):(!b&&i(this.type)&&(b=s.parse["application/json"]),b&&a&&(a.length||a instanceof Object)?b(a):null)},j.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},s.Response=j,n(k.prototype),o(k.prototype),k.prototype.type=function(a){return this.set("Content-Type",s.types[a]||a),this},k.prototype.accept=function(a){return this.set("Accept",s.types[a]||a),this},k.prototype.auth=function(a,b,c){1===arguments.length&&(b=""),"object"==typeof b&&null!==b&&(c=b,b=""),c||(c={type:"function"==typeof btoa?"basic":"auto"});var d=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,c,d)},k.prototype.query=function(a){return"string"!=typeof a&&(a=e(a)),a&&this._query.push(a),this},k.prototype.attach=function(a,b,c){if(b){if(this._data)throw Error("superagent can't mix .send() and .attach()");this._getFormData().append(a,b,c||b.name)}return this},k.prototype._getFormData=function(){return this._formData||(this._formData=new m.FormData),this._formData},k.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)},k.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)},k.prototype.buffer=k.prototype.ca=k.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},k.prototype.pipe=k.prototype.write=function(){throw Error("Streaming is not supported in browser version of superagent")},k.prototype._isHost=function(a){return a&&"object"==typeof a&&!Array.isArray(a)&&"[object Object]"!==Object.prototype.toString.call(a)},k.prototype.end=function(a){return 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()},k.prototype._end=function(){var a=this,b=this.xhr=s.getXHR(),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),c.direction=b,a.emit("progress",c)};if(this.hasListeners("progress"))try{b.onprogress=d.bind(null,"download"),b.upload&&(b.upload.onprogress=d.bind(null,"upload"))}catch(a){}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||s.serialize[e?e.split(";")[0]:""];!f&&i(e)&&(f=s.serialize["application/json"]),f&&(c=f(c))}for(var g in this.header)null!=this.header[g]&&this.header.hasOwnProperty(g)&&b.setRequestHeader(g,this.header[g]);return this._responseType&&(b.responseType=this._responseType),this.emit("request",this),b.send(void 0!==c?c:null),this},s.agent=function(){return new r},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(a){r.prototype[a.toLowerCase()]=function(b,c){var d=new s.Request(a,b);return this._setDefaults(d),c&&d.end(c),d}}),r.prototype.del=r.prototype["delete"],s.get=function(a,b,c){var d=s("GET",a);return"function"==typeof b&&(c=b,b=null),b&&d.query(b),c&&d.end(c),d},s.head=function(a,b,c){var d=s("HEAD",a);return"function"==typeof b&&(c=b,b=null),b&&d.query(b),c&&d.end(c),d},s.options=function(a,b,c){var d=s("OPTIONS",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},s.del=l,s["delete"]=l,s.patch=function(a,b,c){var d=s("PATCH",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},s.post=function(a,b,c){var d=s("POST",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},s.put=function(a,b,c){var d=s("PUT",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d}},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}a.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])===b||d.fn===b){c.splice(e,1);break}return this},d.prototype.emit=function(a){this._callbacks=this._callbacks||{};var b=[].slice.call(arguments,1),c=this._callbacks["$"+a];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}},function(a,b,c){"use strict";function d(a){if(a)return e(a)}function e(a){for(var b in d.prototype)a[b]=d.prototype[b];return a}var f=c(46);a.exports=d,d.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this},d.prototype.parse=function(a){return this._parser=a,this},d.prototype.responseType=function(a){return this._responseType=a,this},d.prototype.serialize=function(a){return this._serializer=a,this},d.prototype.timeout=function(a){if(!a||"object"!=typeof a)return this._timeout=a,this._responseTimeout=0,this;for(var b in a)switch(b){case"deadline":this._timeout=a.deadline;break;case"response":this._responseTimeout=a.response;break;default:console.warn("Unknown timeout option",b)}return this},d.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 g=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];d.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&&b.status>=500&&501!=b.status)return!0;if(a){if(a.code&&~g.indexOf(a.code))return!0;if(a.timeout&&"ECONNABORTED"==a.code)return!0;if(a.crossDomain)return!0}return!1},d.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},d.prototype.then=function(a,b){if(!this._fullfilledPromise){var c=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){c.end(function(c,d){c?b(c):a(d)})})}return this._fullfilledPromise.then(a,b)},d.prototype["catch"]=function(a){return this.then(void 0,a)},d.prototype.use=function(a){return a(this),this},d.prototype.ok=function(a){if("function"!=typeof a)throw Error("Callback required");return this._okCallback=a,this},d.prototype._isResponseOK=function(a){return!!a&&(this._okCallback?this._okCallback(a):a.status>=200&&a.status<300)},d.prototype.get=function(a){return this._header[a.toLowerCase()]},d.prototype.getHeader=d.prototype.get,d.prototype.set=function(a,b){if(f(a)){for(var c in a)this.set(c,a[c]);return this}return this._header[a.toLowerCase()]=b,this.header[a]=b,this},d.prototype.unset=function(a){return delete this._header[a.toLowerCase()],delete this.header[a],this},d.prototype.field=function(a,b){if(null===a||void 0===a)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()"),f(a)){for(var c in a)this.field(c,a[c]);return this}if(Array.isArray(b)){for(var d in b)this.field(a,b[d]);return this}if(null===b||void 0===b)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof b&&(b=""+b),this._getFormData().append(a,b),this},d.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},d.prototype._auth=function(a,b,c,d){switch(c.type){case"basic":this.set("Authorization","Basic "+d(a+":"+b));break;case"auto":this.username=a,this.password=b;break;case"bearer":this.set("Authorization","Bearer "+a)}return this},d.prototype.withCredentials=function(a){return void 0==a&&(a=!0),this._withCredentials=a,this},d.prototype.redirects=function(a){return this._maxRedirects=a,this},d.prototype.maxResponseSize=function(a){if("number"!=typeof a)throw TypeError("Invalid argument");return this._maxResponseSize=a,this},d.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},d.prototype.send=function(a){var b=f(a),c=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()"),b&&!this._data)Array.isArray(a)?this._data=[]:this._isHost(a)||(this._data={});else if(a&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(b&&f(this._data))for(var d in a)this._data[d]=a[d];else"string"==typeof a?(c||this.type("form"),c=this._header["content-type"],this._data="application/x-www-form-urlencoded"==c?this._data?this._data+"&"+a:a:(this._data||"")+a):this._data=a;return!b||this._isHost(a)?this:(c||this.type("json"),this)},d.prototype.sortQuery=function(a){return this._sort=void 0===a||a,this},d.prototype._finalizeQueryString=function(){var a=this._query.join("&");if(a&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+a),this._query.length=0,this._sort){var b=this.url.indexOf("?");if(b>=0){var c=this.url.substring(b+1).split("&");"function"==typeof this._sort?c.sort(this._sort):c.sort(),this.url=this.url.substring(0,b)+"?"+c.join("&")}}},d.prototype._appendQueryString=function(){console.trace("Unsupported")},d.prototype._timeoutError=function(a,b,c){if(!this._aborted){var d=new Error(a+b+"ms exceeded");d.timeout=b,d.code="ECONNABORTED",d.errno=c,this.timedout=!0,this.abort(),this.callback(d)}},d.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));
12
- }},function(a,b){"use strict";function c(a){return null!==a&&"object"==typeof a}a.exports=c},function(a,b,c){"use strict";function d(a){if(a)return e(a)}function e(a){for(var b in d.prototype)a[b]=d.prototype[b];return a}var f=c(48);a.exports=d,d.prototype.get=function(a){return this.header[a.toLowerCase()]},d.prototype._setHeaderProperties=function(a){var b=a["content-type"]||"";this.type=f.type(b);var c=f.params(b);for(var d in c)this[d]=c[d];this.links={};try{a.link&&(this.links=f.parseLinks(a.link))}catch(a){}},d.prototype._setStatusProperties=function(a){var b=a/100|0;this.status=this.statusCode=a,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}},function(a,b){"use strict";b.type=function(a){return a.split(/ *; */).shift()},b.params=function(a){return a.split(/ *; */).reduce(function(a,b){var c=b.split(/ *= */),d=c.shift(),e=c.shift();return d&&e&&(a[d]=e),a},{})},b.parseLinks=function(a){return a.split(/ *, */).reduce(function(a,b){var c=b.split(/ *; */),d=c[0].slice(1,-1);return a[c[1].split(/ *= */)[1].slice(1,-1)]=d,a},{})},b.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}},function(a,b){function c(){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(a){c.prototype[a]=function(){return this._defaults.push({fn:a,arguments:arguments}),this}}),c.prototype._setDefaults=function(a){this._defaults.forEach(function(b){a[b.fn].apply(a,b.arguments)})},a.exports=c}])})},{}],89:[function(b,c,d){(function(b){!function(e){function f(a){throw new RangeError(I[a])}function g(a,b){for(var c=a.length,d=[];c--;)d[c]=b(a[c]);return d}function h(a,b){var c=a.split("@"),d="";c.length>1&&(d=c[0]+"@",a=c[1]),a=a.replace(H,".");var e=a.split("."),f=g(e,b).join(".");return d+f}function i(a){for(var b,c,d=[],e=0,f=a.length;e<f;)b=a.charCodeAt(e++),b>=55296&&b<=56319&&e<f?(c=a.charCodeAt(e++),56320==(64512&c)?d.push(((1023&b)<<10)+(1023&c)+65536):(d.push(b),e--)):d.push(b);return d}function j(a){return g(a,function(a){var b="";return a>65535&&(a-=65536,b+=L(a>>>10&1023|55296),a=56320|1023&a),b+=L(a)}).join("")}function k(a){return a-48<10?a-22:a-65<26?a-65:a-97<26?a-97:x}function l(a,b){return a+22+75*(a<26)-((0!=b)<<5)}function m(a,b,c){var d=0;for(a=c?K(a/B):a>>1,a+=K(a/b);a>J*z>>1;d+=x)a=K(a/J);return K(d+(J+1)*a/(a+A))}function n(a){var b,c,d,e,g,h,i,l,n,o,p=[],q=a.length,r=0,s=D,t=C;for(c=a.lastIndexOf(E),c<0&&(c=0),d=0;d<c;++d)a.charCodeAt(d)>=128&&f("not-basic"),p.push(a.charCodeAt(d));for(e=c>0?c+1:0;e<q;){for(g=r,h=1,i=x;e>=q&&f("invalid-input"),l=k(a.charCodeAt(e++)),(l>=x||l>K((w-r)/h))&&f("overflow"),r+=l*h,n=i<=t?y:i>=t+z?z:i-t,!(l<n);i+=x)o=x-n,h>K(w/o)&&f("overflow"),h*=o;b=p.length+1,t=m(r-g,b,0==g),K(r/b)>w-s&&f("overflow"),s+=K(r/b),r%=b,p.splice(r++,0,s)}return j(p)}function o(a){var b,c,d,e,g,h,j,k,n,o,p,q,r,s,t,u=[];for(a=i(a),q=a.length,b=D,c=0,g=C,h=0;h<q;++h)p=a[h],p<128&&u.push(L(p));for(d=e=u.length,e&&u.push(E);d<q;){for(j=w,h=0;h<q;++h)p=a[h],p>=b&&p<j&&(j=p);for(r=d+1,j-b>K((w-c)/r)&&f("overflow"),c+=(j-b)*r,b=j,h=0;h<q;++h)if(p=a[h],p<b&&++c>w&&f("overflow"),p==b){for(k=c,n=x;o=n<=g?y:n>=g+z?z:n-g,!(k<o);n+=x)t=k-o,s=x-o,u.push(L(l(o+t%s,0))),k=K(t/s);u.push(L(l(k,0))),g=m(c,r,d==e),c=0,++d}++c,++b}return u.join("")}function p(a){return h(a,function(a){return F.test(a)?n(a.slice(4).toLowerCase()):a})}function q(a){return h(a,function(a){return G.test(a)?"xn--"+o(a):a})}var r="object"==typeof d&&d&&!d.nodeType&&d,s="object"==typeof c&&c&&!c.nodeType&&c,t="object"==typeof b&&b;t.global!==t&&t.window!==t&&t.self!==t||(e=t);var u,v,w=2147483647,x=36,y=1,z=26,A=38,B=700,C=72,D=128,E="-",F=/^xn--/,G=/[^\x20-\x7E]/,H=/[\x2E\u3002\uFF0E\uFF61]/g,I={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},J=x-y,K=Math.floor,L=String.fromCharCode;if(u={version:"1.4.1",ucs2:{decode:i,encode:j},decode:n,encode:o,toASCII:q,toUnicode:p},"function"==typeof a&&"object"==typeof a.amd&&a.amd)a("punycode",function(){return u});else if(r&&s)if(c.exports==r)s.exports=u;else for(v in u)u.hasOwnProperty(v)&&(r[v]=u[v]);else e.punycode=u}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],90:[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(){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:87}],91:[function(a,b,c){"use strict";function d(a,b){return Object.prototype.hasOwnProperty.call(a,b)}b.exports=function(a,b,c,f){b=b||"&",c=c||"=";var g={};if("string"!=typeof a||0===a.length)return g;var h=/\+/g;a=a.split(b);var i=1e3;f&&"number"==typeof f.maxKeys&&(i=f.maxKeys);var j=a.length;i>0&&j>i&&(j=i);for(var k=0;k<j;++k){var l,m,n,o,p=a[k].replace(h,"%20"),q=p.indexOf(c);q>=0?(l=p.substr(0,q),m=p.substr(q+1)):(l=p,m=""),n=decodeURIComponent(l),o=decodeURIComponent(m),d(g,n)?e(g[n])?g[n].push(o):g[n]=[g[n],o]:g[n]=o}return g};var e=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)}},{}],92:[function(a,b,c){"use strict";function d(a,b){if(a.map)return a.map(b);for(var c=[],d=0;d<a.length;d++)c.push(b(a[d],d));return c}var e=function(a){switch(typeof a){case"string":return a;case"boolean":return a?"true":"false";case"number":return isFinite(a)?a:"";default:return""}};b.exports=function(a,b,c,h){return b=b||"&",c=c||"=",null===a&&(a=void 0),"object"==typeof a?d(g(a),function(g){var h=encodeURIComponent(e(g))+c;return f(a[g])?d(a[g],function(a){return h+encodeURIComponent(e(a))}).join(b):h+encodeURIComponent(e(a[g]))}).join(b):h?encodeURIComponent(e(h))+c+encodeURIComponent(e(a)):""};var f=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},g=Object.keys||function(a){var b=[];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&b.push(c);return b}},{}],93:[function(a,b,c){"use strict";c.decode=c.parse=a("./decode"),c.encode=c.stringify=a("./encode")},{"./decode":91,"./encode":92}],94:[function(a,b,c){b.exports=a("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":95}],95:[function(a,b,c){"use strict";function d(a){return this instanceof d?(j.call(this,a),k.call(this,a),a&&a.readable===!1&&(this.readable=!1),a&&a.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,a&&a.allowHalfOpen===!1&&(this.allowHalfOpen=!1),void this.once("end",e)):new d(a)}function e(){this.allowHalfOpen||this._writableState.ended||g.nextTick(f,this)}function f(a){a.end()}var g=a("process-nextick-args"),h=Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b};b.exports=d;var i=Object.create(a("core-util-is"));i.inherits=a("inherits");var j=a("./_stream_readable"),k=a("./_stream_writable");i.inherits(d,j);for(var l=h(k.prototype),m=0;m<l.length;m++){var n=l[m];d.prototype[n]||(d.prototype[n]=k.prototype[n])}Object.defineProperty(d.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(d.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(a){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=a,this._writableState.destroyed=a)}}),d.prototype._destroy=function(a,b){this.push(null),this.end(),g.nextTick(b,a)}},{"./_stream_readable":97,"./_stream_writable":99,"core-util-is":48,inherits:76,"process-nextick-args":86}],96:[function(a,b,c){"use strict";function d(a){return this instanceof d?void e.call(this,a):new d(a)}b.exports=d;var e=a("./_stream_transform"),f=Object.create(a("core-util-is"));f.inherits=a("inherits"),f.inherits(d,e),d.prototype._transform=function(a,b,c){c(null,a)}},{"./_stream_transform":98,"core-util-is":48,inherits:76}],97:[function(a,b,c){(function(c,d){"use strict";function e(a){return L.from(a)}function f(a){return L.isBuffer(a)||a instanceof M}function g(a,b,c){return"function"==typeof a.prependListener?a.prependListener(b,c):void(a._events&&a._events[b]?I(a._events[b])?a._events[b].unshift(c):a._events[b]=[c,a._events[b]]:a.on(b,c))}function h(b,c){H=H||a("./_stream_duplex"),b=b||{};var d=c instanceof H;this.objectMode=!!b.objectMode,d&&(this.objectMode=this.objectMode||!!b.readableObjectMode);var e=b.highWaterMark,f=b.readableHighWaterMark,g=this.objectMode?16:16384;e||0===e?this.highWaterMark=e:d&&(f||0===f)?this.highWaterMark=f:this.highWaterMark=g,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new R,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=b.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,b.encoding&&(Q||(Q=a("string_decoder/").StringDecoder),this.decoder=new Q(b.encoding),this.encoding=b.encoding)}function i(b){return H=H||a("./_stream_duplex"),this instanceof i?(this._readableState=new h(b,this),this.readable=!0,b&&("function"==typeof b.read&&(this._read=b.read),"function"==typeof b.destroy&&(this._destroy=b.destroy)),void K.call(this)):new i(b)}function j(a,b,c,d,f){var g=a._readableState;if(null===b)g.reading=!1,p(a,g);else{var h;f||(h=l(g,b)),h?a.emit("error",h):g.objectMode||b&&b.length>0?("string"==typeof b||g.objectMode||Object.getPrototypeOf(b)===L.prototype||(b=e(b)),d?g.endEmitted?a.emit("error",new Error("stream.unshift() after end event")):k(a,g,b,!0):g.ended?a.emit("error",new Error("stream.push() after EOF")):(g.reading=!1,g.decoder&&!c?(b=g.decoder.write(b),g.objectMode||0!==b.length?k(a,g,b,!1):s(a,g)):k(a,g,b,!1))):d||(g.reading=!1)}return m(g)}function k(a,b,c,d){b.flowing&&0===b.length&&!b.sync?(a.emit("data",c),a.read(0)):(b.length+=b.objectMode?1:c.length,d?b.buffer.unshift(c):b.buffer.push(c),b.needReadable&&q(a)),s(a,b)}function l(a,b){var c;return f(b)||"string"==typeof b||void 0===b||a.objectMode||(c=new TypeError("Invalid non-string/buffer chunk")),c}function m(a){return!a.ended&&(a.needReadable||a.length<a.highWaterMark||0===a.length)}function n(a){return a>=U?a=U:(a--,a|=a>>>1,a|=a>>>2,a|=a>>>4,a|=a>>>8,a|=a>>>16,a++),a}function o(a,b){return a<=0||0===b.length&&b.ended?0:b.objectMode?1:a!==a?b.flowing&&b.length?b.buffer.head.data.length:b.length:(a>b.highWaterMark&&(b.highWaterMark=n(a)),a<=b.length?a:b.ended?b.length:(b.needReadable=!0,0))}function p(a,b){if(!b.ended){if(b.decoder){var c=b.decoder.end();c&&c.length&&(b.buffer.push(c),b.length+=b.objectMode?1:c.length)}b.ended=!0,q(a)}}function q(a){var b=a._readableState;b.needReadable=!1,b.emittedReadable||(P("emitReadable",b.flowing),b.emittedReadable=!0,b.sync?G.nextTick(r,a):r(a))}function r(a){P("emit readable"),a.emit("readable"),y(a)}function s(a,b){b.readingMore||(b.readingMore=!0,G.nextTick(t,a,b))}function t(a,b){for(var c=b.length;!b.reading&&!b.flowing&&!b.ended&&b.length<b.highWaterMark&&(P("maybeReadMore read 0"),a.read(0),c!==b.length);)c=b.length;b.readingMore=!1}function u(a){return function(){var b=a._readableState;P("pipeOnDrain",b.awaitDrain),b.awaitDrain&&b.awaitDrain--,0===b.awaitDrain&&J(a,"data")&&(b.flowing=!0,y(a))}}function v(a){P("readable nexttick read 0"),a.read(0)}function w(a,b){b.resumeScheduled||(b.resumeScheduled=!0,G.nextTick(x,a,b))}function x(a,b){b.reading||(P("resume read 0"),a.read(0)),b.resumeScheduled=!1,b.awaitDrain=0,a.emit("resume"),y(a),b.flowing&&!b.reading&&a.read(0)}function y(a){var b=a._readableState;for(P("flow",b.flowing);b.flowing&&null!==a.read(););}function z(a,b){if(0===b.length)return null;var c;return b.objectMode?c=b.buffer.shift():!a||a>=b.length?(c=b.decoder?b.buffer.join(""):1===b.buffer.length?b.buffer.head.data:b.buffer.concat(b.length),b.buffer.clear()):c=A(a,b.buffer,b.decoder),c}function A(a,b,c){var d;return a<b.head.data.length?(d=b.head.data.slice(0,a),b.head.data=b.head.data.slice(a)):d=a===b.head.data.length?b.shift():c?B(a,b):C(a,b),d}function B(a,b){var c=b.head,d=1,e=c.data;for(a-=e.length;c=c.next;){var f=c.data,g=a>f.length?f.length:a;if(e+=g===f.length?f:f.slice(0,a),a-=g,0===a){g===f.length?(++d,c.next?b.head=c.next:b.head=b.tail=null):(b.head=c,c.data=f.slice(g));break}++d}return b.length-=d,e}function C(a,b){var c=L.allocUnsafe(a),d=b.head,e=1;for(d.data.copy(c),a-=d.data.length;d=d.next;){var f=d.data,g=a>f.length?f.length:a;if(f.copy(c,c.length-a,0,g),a-=g,0===a){g===f.length?(++e,d.next?b.head=d.next:b.head=b.tail=null):(b.head=d,d.data=f.slice(g));break}++e}return b.length-=e,c}function D(a){var b=a._readableState;if(b.length>0)throw new Error('"endReadable()" called on non-empty stream');b.endEmitted||(b.ended=!0,G.nextTick(E,b,a))}function E(a,b){a.endEmitted||0!==a.length||(a.endEmitted=!0,b.readable=!1,b.emit("end"))}function F(a,b){for(var c=0,d=a.length;c<d;c++)if(a[c]===b)return c;return-1}var G=a("process-nextick-args");b.exports=i;var H,I=a("isarray");i.ReadableState=h;var J=(a("events").EventEmitter,function(a,b){return a.listeners(b).length}),K=a("./internal/streams/stream"),L=a("safe-buffer").Buffer,M=d.Uint8Array||function(){},N=Object.create(a("core-util-is"));N.inherits=a("inherits");var O=a("util"),P=void 0;P=O&&O.debuglog?O.debuglog("stream"):function(){};var Q,R=a("./internal/streams/BufferList"),S=a("./internal/streams/destroy");N.inherits(i,K);var T=["error","close","destroy","pause","resume"];Object.defineProperty(i.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(a){this._readableState&&(this._readableState.destroyed=a)}}),i.prototype.destroy=S.destroy,i.prototype._undestroy=S.undestroy,i.prototype._destroy=function(a,b){this.push(null),b(a)},i.prototype.push=function(a,b){var c,d=this._readableState;return d.objectMode?c=!0:"string"==typeof a&&(b=b||d.defaultEncoding,b!==d.encoding&&(a=L.from(a,b),b=""),c=!0),j(this,a,b,!1,c)},i.prototype.unshift=function(a){return j(this,a,null,!0,!1)},i.prototype.isPaused=function(){return this._readableState.flowing===!1},i.prototype.setEncoding=function(b){return Q||(Q=a("string_decoder/").StringDecoder),this._readableState.decoder=new Q(b),this._readableState.encoding=b,this};var U=8388608;i.prototype.read=function(a){P("read",a),a=parseInt(a,10);var b=this._readableState,c=a;if(0!==a&&(b.emittedReadable=!1),0===a&&b.needReadable&&(b.length>=b.highWaterMark||b.ended))return P("read: emitReadable",b.length,b.ended),0===b.length&&b.ended?D(this):q(this),null;if(a=o(a,b),0===a&&b.ended)return 0===b.length&&D(this),null;var d=b.needReadable;P("need readable",d),(0===b.length||b.length-a<b.highWaterMark)&&(d=!0,P("length less than watermark",d)),b.ended||b.reading?(d=!1,P("reading or ended",d)):d&&(P("do read"),b.reading=!0,b.sync=!0,0===b.length&&(b.needReadable=!0),this._read(b.highWaterMark),b.sync=!1,b.reading||(a=o(c,b)));var e;return e=a>0?z(a,b):null,null===e?(b.needReadable=!0,a=0):b.length-=a,0===b.length&&(b.ended||(b.needReadable=!0),c!==a&&b.ended&&D(this)),null!==e&&this.emit("data",e),e},i.prototype._read=function(a){this.emit("error",new Error("_read() is not implemented"))},i.prototype.pipe=function(a,b){function d(a,b){P("onunpipe"),a===m&&b&&b.hasUnpiped===!1&&(b.hasUnpiped=!0,f())}function e(){P("onend"),a.end()}function f(){P("cleanup"),a.removeListener("close",j),a.removeListener("finish",k),a.removeListener("drain",q),a.removeListener("error",i),a.removeListener("unpipe",d),m.removeListener("end",e),m.removeListener("end",l),m.removeListener("data",h),r=!0,!n.awaitDrain||a._writableState&&!a._writableState.needDrain||q()}function h(b){P("ondata"),s=!1;var c=a.write(b);!1!==c||s||((1===n.pipesCount&&n.pipes===a||n.pipesCount>1&&F(n.pipes,a)!==-1)&&!r&&(P("false write response, pause",m._readableState.awaitDrain),
13
- m._readableState.awaitDrain++,s=!0),m.pause())}function i(b){P("onerror",b),l(),a.removeListener("error",i),0===J(a,"error")&&a.emit("error",b)}function j(){a.removeListener("finish",k),l()}function k(){P("onfinish"),a.removeListener("close",j),l()}function l(){P("unpipe"),m.unpipe(a)}var m=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=a;break;case 1:n.pipes=[n.pipes,a];break;default:n.pipes.push(a)}n.pipesCount+=1,P("pipe count=%d opts=%j",n.pipesCount,b);var o=(!b||b.end!==!1)&&a!==c.stdout&&a!==c.stderr,p=o?e:l;n.endEmitted?G.nextTick(p):m.once("end",p),a.on("unpipe",d);var q=u(m);a.on("drain",q);var r=!1,s=!1;return m.on("data",h),g(a,"error",i),a.once("close",j),a.once("finish",k),a.emit("pipe",m),n.flowing||(P("pipe resume"),m.resume()),a},i.prototype.unpipe=function(a){var b=this._readableState,c={hasUnpiped:!1};if(0===b.pipesCount)return this;if(1===b.pipesCount)return a&&a!==b.pipes?this:(a||(a=b.pipes),b.pipes=null,b.pipesCount=0,b.flowing=!1,a&&a.emit("unpipe",this,c),this);if(!a){var d=b.pipes,e=b.pipesCount;b.pipes=null,b.pipesCount=0,b.flowing=!1;for(var f=0;f<e;f++)d[f].emit("unpipe",this,c);return this}var g=F(b.pipes,a);return g===-1?this:(b.pipes.splice(g,1),b.pipesCount-=1,1===b.pipesCount&&(b.pipes=b.pipes[0]),a.emit("unpipe",this,c),this)},i.prototype.on=function(a,b){var c=K.prototype.on.call(this,a,b);if("data"===a)this._readableState.flowing!==!1&&this.resume();else if("readable"===a){var d=this._readableState;d.endEmitted||d.readableListening||(d.readableListening=d.needReadable=!0,d.emittedReadable=!1,d.reading?d.length&&q(this):G.nextTick(v,this))}return c},i.prototype.addListener=i.prototype.on,i.prototype.resume=function(){var a=this._readableState;return a.flowing||(P("resume"),a.flowing=!0,w(this,a)),this},i.prototype.pause=function(){return P("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(P("pause"),this._readableState.flowing=!1,this.emit("pause")),this},i.prototype.wrap=function(a){var b=this,c=this._readableState,d=!1;a.on("end",function(){if(P("wrapped end"),c.decoder&&!c.ended){var a=c.decoder.end();a&&a.length&&b.push(a)}b.push(null)}),a.on("data",function(e){if(P("wrapped data"),c.decoder&&(e=c.decoder.write(e)),(!c.objectMode||null!==e&&void 0!==e)&&(c.objectMode||e&&e.length)){var f=b.push(e);f||(d=!0,a.pause())}});for(var e in a)void 0===this[e]&&"function"==typeof a[e]&&(this[e]=function(b){return function(){return a[b].apply(a,arguments)}}(e));for(var f=0;f<T.length;f++)a.on(T[f],this.emit.bind(this,T[f]));return this._read=function(b){P("wrapped _read",b),d&&(d=!1,a.resume())},this},Object.defineProperty(i.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),i._fromList=z}).call(this,a("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_stream_duplex":95,"./internal/streams/BufferList":100,"./internal/streams/destroy":101,"./internal/streams/stream":102,_process:87,"core-util-is":48,events:67,inherits:76,isarray:77,"process-nextick-args":86,"safe-buffer":108,"string_decoder/":132,util:43}],98:[function(a,b,c){"use strict";function d(a,b){var c=this._transformState;c.transforming=!1;var d=c.writecb;if(!d)return this.emit("error",new Error("write callback called multiple times"));c.writechunk=null,c.writecb=null,null!=b&&this.push(b),d(a);var e=this._readableState;e.reading=!1,(e.needReadable||e.length<e.highWaterMark)&&this._read(e.highWaterMark)}function e(a){return this instanceof e?(h.call(this,a),this._transformState={afterTransform:d.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,a&&("function"==typeof a.transform&&(this._transform=a.transform),"function"==typeof a.flush&&(this._flush=a.flush)),void this.on("prefinish",f)):new e(a)}function f(){var a=this;"function"==typeof this._flush?this._flush(function(b,c){g(a,b,c)}):g(this,null,null)}function g(a,b,c){if(b)return a.emit("error",b);if(null!=c&&a.push(c),a._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(a._transformState.transforming)throw new Error("Calling transform done when still transforming");return a.push(null)}b.exports=e;var h=a("./_stream_duplex"),i=Object.create(a("core-util-is"));i.inherits=a("inherits"),i.inherits(e,h),e.prototype.push=function(a,b){return this._transformState.needTransform=!1,h.prototype.push.call(this,a,b)},e.prototype._transform=function(a,b,c){throw new Error("_transform() is not implemented")},e.prototype._write=function(a,b,c){var d=this._transformState;if(d.writecb=c,d.writechunk=a,d.writeencoding=b,!d.transforming){var e=this._readableState;(d.needTransform||e.needReadable||e.length<e.highWaterMark)&&this._read(e.highWaterMark)}},e.prototype._read=function(a){var b=this._transformState;null!==b.writechunk&&b.writecb&&!b.transforming?(b.transforming=!0,this._transform(b.writechunk,b.writeencoding,b.afterTransform)):b.needTransform=!0},e.prototype._destroy=function(a,b){var c=this;h.prototype._destroy.call(this,a,function(a){b(a),c.emit("close")})}},{"./_stream_duplex":95,"core-util-is":48,inherits:76}],99:[function(a,b,c){(function(c,d){"use strict";function e(a){var b=this;this.next=null,this.entry=null,this.finish=function(){A(b,a)}}function f(a){return H.from(a)}function g(a){return H.isBuffer(a)||a instanceof I}function h(){}function i(b,c){C=C||a("./_stream_duplex"),b=b||{};var d=c instanceof C;this.objectMode=!!b.objectMode,d&&(this.objectMode=this.objectMode||!!b.writableObjectMode);var f=b.highWaterMark,g=b.writableHighWaterMark,h=this.objectMode?16:16384;f||0===f?this.highWaterMark=f:d&&(g||0===g)?this.highWaterMark=g:this.highWaterMark=h,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var i=b.decodeStrings===!1;this.decodeStrings=!i,this.defaultEncoding=b.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(a){r(c,a)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new e(this)}function j(b){return C=C||a("./_stream_duplex"),K.call(j,this)||this instanceof C?(this._writableState=new i(b,this),this.writable=!0,b&&("function"==typeof b.write&&(this._write=b.write),"function"==typeof b.writev&&(this._writev=b.writev),"function"==typeof b.destroy&&(this._destroy=b.destroy),"function"==typeof b["final"]&&(this._final=b["final"])),void G.call(this)):new j(b)}function k(a,b){var c=new Error("write after end");a.emit("error",c),B.nextTick(b,c)}function l(a,b,c,d){var e=!0,f=!1;return null===c?f=new TypeError("May not write null values to stream"):"string"==typeof c||void 0===c||b.objectMode||(f=new TypeError("Invalid non-string/buffer chunk")),f&&(a.emit("error",f),B.nextTick(d,f),e=!1),e}function m(a,b,c){return a.objectMode||a.decodeStrings===!1||"string"!=typeof b||(b=H.from(b,c)),b}function n(a,b,c,d,e,f){if(!c){var g=m(b,d,e);d!==g&&(c=!0,e="buffer",d=g)}var h=b.objectMode?1:d.length;b.length+=h;var i=b.length<b.highWaterMark;if(i||(b.needDrain=!0),b.writing||b.corked){var j=b.lastBufferedRequest;b.lastBufferedRequest={chunk:d,encoding:e,isBuf:c,callback:f,next:null},j?j.next=b.lastBufferedRequest:b.bufferedRequest=b.lastBufferedRequest,b.bufferedRequestCount+=1}else o(a,b,!1,h,d,e,f);return i}function o(a,b,c,d,e,f,g){b.writelen=d,b.writecb=g,b.writing=!0,b.sync=!0,c?a._writev(e,b.onwrite):a._write(e,f,b.onwrite),b.sync=!1}function p(a,b,c,d,e){--b.pendingcb,c?(B.nextTick(e,d),B.nextTick(y,a,b),a._writableState.errorEmitted=!0,a.emit("error",d)):(e(d),a._writableState.errorEmitted=!0,a.emit("error",d),y(a,b))}function q(a){a.writing=!1,a.writecb=null,a.length-=a.writelen,a.writelen=0}function r(a,b){var c=a._writableState,d=c.sync,e=c.writecb;if(q(c),b)p(a,c,d,b,e);else{var f=v(c);f||c.corked||c.bufferProcessing||!c.bufferedRequest||u(a,c),d?D(s,a,c,f,e):s(a,c,f,e)}}function s(a,b,c,d){c||t(a,b),b.pendingcb--,d(),y(a,b)}function t(a,b){0===b.length&&b.needDrain&&(b.needDrain=!1,a.emit("drain"))}function u(a,b){b.bufferProcessing=!0;var c=b.bufferedRequest;if(a._writev&&c&&c.next){var d=b.bufferedRequestCount,f=new Array(d),g=b.corkedRequestsFree;g.entry=c;for(var h=0,i=!0;c;)f[h]=c,c.isBuf||(i=!1),c=c.next,h+=1;f.allBuffers=i,o(a,b,!0,b.length,f,"",g.finish),b.pendingcb++,b.lastBufferedRequest=null,g.next?(b.corkedRequestsFree=g.next,g.next=null):b.corkedRequestsFree=new e(b),b.bufferedRequestCount=0}else{for(;c;){var j=c.chunk,k=c.encoding,l=c.callback,m=b.objectMode?1:j.length;if(o(a,b,!1,m,j,k,l),c=c.next,b.bufferedRequestCount--,b.writing)break}null===c&&(b.lastBufferedRequest=null)}b.bufferedRequest=c,b.bufferProcessing=!1}function v(a){return a.ending&&0===a.length&&null===a.bufferedRequest&&!a.finished&&!a.writing}function w(a,b){a._final(function(c){b.pendingcb--,c&&a.emit("error",c),b.prefinished=!0,a.emit("prefinish"),y(a,b)})}function x(a,b){b.prefinished||b.finalCalled||("function"==typeof a._final?(b.pendingcb++,b.finalCalled=!0,B.nextTick(w,a,b)):(b.prefinished=!0,a.emit("prefinish")))}function y(a,b){var c=v(b);return c&&(x(a,b),0===b.pendingcb&&(b.finished=!0,a.emit("finish"))),c}function z(a,b,c){b.ending=!0,y(a,b),c&&(b.finished?B.nextTick(c):a.once("finish",c)),b.ended=!0,a.writable=!1}function A(a,b,c){var d=a.entry;for(a.entry=null;d;){var e=d.callback;b.pendingcb--,e(c),d=d.next}b.corkedRequestsFree?b.corkedRequestsFree.next=a:b.corkedRequestsFree=a}var B=a("process-nextick-args");b.exports=j;var C,D=!c.browser&&["v0.10","v0.9."].indexOf(c.version.slice(0,5))>-1?setImmediate:B.nextTick;j.WritableState=i;var E=Object.create(a("core-util-is"));E.inherits=a("inherits");var F={deprecate:a("util-deprecate")},G=a("./internal/streams/stream"),H=a("safe-buffer").Buffer,I=d.Uint8Array||function(){},J=a("./internal/streams/destroy");E.inherits(j,G),i.prototype.getBuffer=function(){for(var a=this.bufferedRequest,b=[];a;)b.push(a),a=a.next;return b},function(){try{Object.defineProperty(i.prototype,"buffer",{get:F.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(a){}}();var K;"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(K=Function.prototype[Symbol.hasInstance],Object.defineProperty(j,Symbol.hasInstance,{value:function(a){return!!K.call(this,a)||this===j&&(a&&a._writableState instanceof i)}})):K=function(a){return a instanceof this},j.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},j.prototype.write=function(a,b,c){var d=this._writableState,e=!1,i=!d.objectMode&&g(a);return i&&!H.isBuffer(a)&&(a=f(a)),"function"==typeof b&&(c=b,b=null),i?b="buffer":b||(b=d.defaultEncoding),"function"!=typeof c&&(c=h),d.ended?k(this,c):(i||l(this,d,a,c))&&(d.pendingcb++,e=n(this,d,i,a,b,c)),e},j.prototype.cork=function(){var a=this._writableState;a.corked++},j.prototype.uncork=function(){var a=this._writableState;a.corked&&(a.corked--,a.writing||a.corked||a.finished||a.bufferProcessing||!a.bufferedRequest||u(this,a))},j.prototype.setDefaultEncoding=function(a){if("string"==typeof a&&(a=a.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((a+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+a);return this._writableState.defaultEncoding=a,this},Object.defineProperty(j.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),j.prototype._write=function(a,b,c){c(new Error("_write() is not implemented"))},j.prototype._writev=null,j.prototype.end=function(a,b,c){var d=this._writableState;"function"==typeof a?(c=a,a=null,b=null):"function"==typeof b&&(c=b,b=null),null!==a&&void 0!==a&&this.write(a,b),d.corked&&(d.corked=1,this.uncork()),d.ending||d.finished||z(this,d,c)},Object.defineProperty(j.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(a){this._writableState&&(this._writableState.destroyed=a)}}),j.prototype.destroy=J.destroy,j.prototype._undestroy=J.undestroy,j.prototype._destroy=function(a,b){this.end(),b(a)}}).call(this,a("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_stream_duplex":95,"./internal/streams/destroy":101,"./internal/streams/stream":102,_process:87,"core-util-is":48,inherits:76,"process-nextick-args":86,"safe-buffer":108,"util-deprecate":140}],100:[function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function e(a,b,c){a.copy(b,c)}var f=a("safe-buffer").Buffer,g=a("util");b.exports=function(){function a(){d(this,a),this.head=null,this.tail=null,this.length=0}return a.prototype.push=function(a){var b={data:a,next:null};this.length>0?this.tail.next=b:this.head=b,this.tail=b,++this.length},a.prototype.unshift=function(a){var b={data:a,next:this.head};0===this.length&&(this.tail=b),this.head=b,++this.length},a.prototype.shift=function(){if(0!==this.length){var a=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,a}},a.prototype.clear=function(){this.head=this.tail=null,this.length=0},a.prototype.join=function(a){if(0===this.length)return"";for(var b=this.head,c=""+b.data;b=b.next;)c+=a+b.data;return c},a.prototype.concat=function(a){if(0===this.length)return f.alloc(0);if(1===this.length)return this.head.data;for(var b=f.allocUnsafe(a>>>0),c=this.head,d=0;c;)e(c.data,b,d),d+=c.data.length,c=c.next;return b},a}(),g&&g.inspect&&g.inspect.custom&&(b.exports.prototype[g.inspect.custom]=function(){var a=g.inspect({length:this.length});return this.constructor.name+" "+a})},{"safe-buffer":108,util:43}],101:[function(a,b,c){"use strict";function d(a,b){var c=this,d=this._readableState&&this._readableState.destroyed,e=this._writableState&&this._writableState.destroyed;return d||e?(b?b(a):!a||this._writableState&&this._writableState.errorEmitted||g.nextTick(f,this,a),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(a||null,function(a){!b&&a?(g.nextTick(f,c,a),c._writableState&&(c._writableState.errorEmitted=!0)):b&&b(a)}),this)}function e(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function f(a,b){a.emit("error",b)}var g=a("process-nextick-args");b.exports={destroy:d,undestroy:e}},{"process-nextick-args":86}],102:[function(a,b,c){b.exports=a("events").EventEmitter},{events:67}],103:[function(a,b,c){b.exports=a("./readable").PassThrough},{"./readable":104}],104:[function(a,b,c){c=b.exports=a("./lib/_stream_readable.js"),c.Stream=c,c.Readable=c,c.Writable=a("./lib/_stream_writable.js"),c.Duplex=a("./lib/_stream_duplex.js"),c.Transform=a("./lib/_stream_transform.js"),c.PassThrough=a("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":95,"./lib/_stream_passthrough.js":96,"./lib/_stream_readable.js":97,"./lib/_stream_transform.js":98,"./lib/_stream_writable.js":99}],105:[function(a,b,c){b.exports=a("./readable").Transform},{"./readable":104}],106:[function(a,b,c){b.exports=a("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":99}],107:[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}},{}],108:[function(a,b,c){function d(a,b){for(var c in a)b[c]=a[c]}function e(a,b,c){return g(a,b,c)}var f=a("buffer"),g=f.Buffer;g.from&&g.alloc&&g.allocUnsafe&&g.allocUnsafeSlow?b.exports=f:(d(f,c),c.Buffer=e),d(g,e),e.from=function(a,b,c){if("number"==typeof a)throw new TypeError("Argument must not be a number");return g(a,b,c)},e.alloc=function(a,b,c){if("number"!=typeof a)throw new TypeError("Argument must be a number");var d=g(a);return void 0!==b?"string"==typeof c?d.fill(b,c):d.fill(b):d.fill(0),d},e.allocUnsafe=function(a){if("number"!=typeof a)throw new TypeError("Argument must be a number");return g(a)},e.allocUnsafeSlow=function(a){if("number"!=typeof a)throw new TypeError("Argument must be a number");return f.SlowBuffer(a)}},{buffer:44}],109:[function(a,b,c){function d(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d=e(a),f=d.source,j=d.id,k=d.path,l=i[j]&&k in i[j].nsps,m=b.forceNew||b["force new connection"]||!1===b.multiplex||l;return m?(h("ignoring socket cache for %s",f),c=g(f,b)):(i[j]||(h("new io instance for %s",f),i[j]=g(f,b)),c=i[j]),c.socket(d.path)}var e=a("./url"),f=a("socket.io-parser"),g=a("./manager"),h=a("debug")("socket.io-client");b.exports=c=d;var i=c.managers={};c.protocol=f.protocol,c.connect=d,c.Manager=a("./manager"),c.Socket=a("./socket")},{"./manager":110,"./socket":112,"./url":113,debug:115,"socket.io-parser":119}],110:[function(a,b,c){function d(a,b){return this instanceof d?(a&&"object"==typeof a&&(b=a,a=void 0),b=b||{},b.path=b.path||"/socket.io",this.nsps={},this.subs=[],this.opts=b,this.reconnection(b.reconnection!==!1),this.reconnectionAttempts(b.reconnectionAttempts||1/0),this.reconnectionDelay(b.reconnectionDelay||1e3),this.reconnectionDelayMax(b.reconnectionDelayMax||5e3),this.randomizationFactor(b.randomizationFactor||.5),this.backoff=new m({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==b.timeout?2e4:b.timeout),this.readyState="closed",this.uri=a,this.connecting=[],this.lastPing=null,this.encoding=!1,this.packetBuffer=[],this.encoder=new h.Encoder,this.decoder=new h.Decoder,this.autoConnect=b.autoConnect!==!1,void(this.autoConnect&&this.open())):new d(a,b)}var e=a("engine.io-client"),f=a("./socket"),g=a("component-emitter"),h=a("socket.io-parser"),i=a("./on"),j=a("component-bind"),k=a("debug")("socket.io-client:manager"),l=a("indexof"),m=a("backo2"),n=Object.prototype.hasOwnProperty;b.exports=d,d.prototype.emitAll=function(){this.emit.apply(this,arguments);for(var a in this.nsps)n.call(this.nsps,a)&&this.nsps[a].emit.apply(this.nsps[a],arguments)},d.prototype.updateSocketIds=function(){for(var a in this.nsps)n.call(this.nsps,a)&&(this.nsps[a].id=this.engine.id)},g(d.prototype),d.prototype.reconnection=function(a){return arguments.length?(this._reconnection=!!a,this):this._reconnection},d.prototype.reconnectionAttempts=function(a){return arguments.length?(this._reconnectionAttempts=a,this):this._reconnectionAttempts},d.prototype.reconnectionDelay=function(a){return arguments.length?(this._reconnectionDelay=a,this.backoff&&this.backoff.setMin(a),this):this._reconnectionDelay},d.prototype.randomizationFactor=function(a){return arguments.length?(this._randomizationFactor=a,this.backoff&&this.backoff.setJitter(a),this):this._randomizationFactor},d.prototype.reconnectionDelayMax=function(a){return arguments.length?(this._reconnectionDelayMax=a,this.backoff&&this.backoff.setMax(a),this):this._reconnectionDelayMax},d.prototype.timeout=function(a){return arguments.length?(this._timeout=a,this):this._timeout},d.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()},d.prototype.open=d.prototype.connect=function(a){if(k("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;k("opening %s",this.uri),this.engine=e(this.uri,this.opts);var b=this.engine,c=this;this.readyState="opening",this.skipReconnect=!1;var d=i(b,"open",function(){c.onopen(),a&&a()}),f=i(b,"error",function(b){if(k("connect_error"),c.cleanup(),c.readyState="closed",c.emitAll("connect_error",b),a){var d=new Error("Connection error");d.data=b,a(d)}else c.maybeReconnectOnOpen()});if(!1!==this._timeout){var g=this._timeout;k("connect attempt will timeout after %d",g);var h=setTimeout(function(){k("connect attempt timed out after %d",g),d.destroy(),b.close(),b.emit("error","timeout"),c.emitAll("connect_timeout",g)},g);this.subs.push({destroy:function(){clearTimeout(h)}})}return this.subs.push(d),this.subs.push(f),this},d.prototype.onopen=function(){k("open"),this.cleanup(),this.readyState="open",this.emit("open");var a=this.engine;this.subs.push(i(a,"data",j(this,"ondata"))),this.subs.push(i(a,"ping",j(this,"onping"))),this.subs.push(i(a,"pong",j(this,"onpong"))),this.subs.push(i(a,"error",j(this,"onerror"))),this.subs.push(i(a,"close",j(this,"onclose"))),this.subs.push(i(this.decoder,"decoded",j(this,"ondecoded")))},d.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},d.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},d.prototype.ondata=function(a){this.decoder.add(a)},d.prototype.ondecoded=function(a){this.emit("packet",a)},d.prototype.onerror=function(a){k("error",a),this.emitAll("error",a)},d.prototype.socket=function(a){function b(){~l(d.connecting,c)||d.connecting.push(c)}var c=this.nsps[a];if(!c){c=new f(this,a),this.nsps[a]=c;var d=this;c.on("connecting",b),c.on("connect",function(){c.id=d.engine.id}),this.autoConnect&&b()}return c},d.prototype.destroy=function(a){var b=l(this.connecting,a);~b&&this.connecting.splice(b,1),this.connecting.length||this.close()},d.prototype.packet=function(a){k("writing packet %j",a);var b=this;b.encoding?b.packetBuffer.push(a):(b.encoding=!0,this.encoder.encode(a,function(c){for(var d=0;d<c.length;d++)b.engine.write(c[d],a.options);b.encoding=!1,b.processPacketQueue()}))},d.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var a=this.packetBuffer.shift();this.packet(a)}},d.prototype.cleanup=function(){k("cleanup");for(var a;a=this.subs.shift();)a.destroy();this.packetBuffer=[],this.encoding=!1,this.lastPing=null,this.decoder.destroy()},d.prototype.close=d.prototype.disconnect=function(){k("disconnect"),this.skipReconnect=!0,this.reconnecting=!1,"opening"==this.readyState&&this.cleanup(),this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},d.prototype.onclose=function(a){k("onclose"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",a),this._reconnection&&!this.skipReconnect&&this.reconnect()},d.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var a=this;if(this.backoff.attempts>=this._reconnectionAttempts)k("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var b=this.backoff.duration();k("will wait %dms before reconnect attempt",b),this.reconnecting=!0;var c=setTimeout(function(){a.skipReconnect||(k("attempting reconnect"),a.emitAll("reconnect_attempt",a.backoff.attempts),a.emitAll("reconnecting",a.backoff.attempts),a.skipReconnect||a.open(function(b){b?(k("reconnect attempt error"),a.reconnecting=!1,a.reconnect(),a.emitAll("reconnect_error",b.data)):(k("reconnect success"),a.onreconnect())}))},b);this.subs.push({destroy:function(){clearTimeout(c)}})}},d.prototype.onreconnect=function(){var a=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",a)}},{"./on":111,"./socket":112,backo2:39,"component-bind":46,"component-emitter":114,debug:115,"engine.io-client":49,indexof:75,"socket.io-parser":119}],111:[function(a,b,c){function d(a,b,c){return a.on(b,c),{destroy:function(){a.removeListener(b,c)}}}b.exports=d},{}],112:[function(a,b,c){function d(a,b){this.io=a,this.nsp=b,this.json=this,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,this.io.autoConnect&&this.open()}var e=a("socket.io-parser"),f=a("component-emitter"),g=a("to-array"),h=a("./on"),i=a("component-bind"),j=a("debug")("socket.io-client:socket"),k=a("has-binary");b.exports=c=d;var l={connect:1,connect_error:1,connect_timeout:1,connecting:1,disconnect:1,error:1,reconnect:1,reconnect_attempt:1,reconnect_failed:1,reconnect_error:1,reconnecting:1,ping:1,pong:1},m=f.prototype.emit;f(d.prototype),d.prototype.subEvents=function(){if(!this.subs){var a=this.io;this.subs=[h(a,"open",i(this,"onopen")),h(a,"packet",i(this,"onpacket")),h(a,"close",i(this,"onclose"))]}},d.prototype.open=d.prototype.connect=function(){return this.connected?this:(this.subEvents(),this.io.open(),"open"==this.io.readyState&&this.onopen(),this.emit("connecting"),this)},d.prototype.send=function(){var a=g(arguments);return a.unshift("message"),this.emit.apply(this,a),this},d.prototype.emit=function(a){if(l.hasOwnProperty(a))return m.apply(this,arguments),this;var b=g(arguments),c=e.EVENT;k(b)&&(c=e.BINARY_EVENT);var d={type:c,data:b};return d.options={},d.options.compress=!this.flags||!1!==this.flags.compress,"function"==typeof b[b.length-1]&&(j("emitting packet with ack id %d",this.ids),this.acks[this.ids]=b.pop(),d.id=this.ids++),this.connected?this.packet(d):this.sendBuffer.push(d),delete this.flags,this},d.prototype.packet=function(a){a.nsp=this.nsp,this.io.packet(a)},d.prototype.onopen=function(){j("transport is open - connecting"),"/"!=this.nsp&&this.packet({type:e.CONNECT})},d.prototype.onclose=function(a){j("close (%s)",a),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",a)},d.prototype.onpacket=function(a){if(a.nsp==this.nsp)switch(a.type){case e.CONNECT:this.onconnect();break;case e.EVENT:this.onevent(a);break;case e.BINARY_EVENT:this.onevent(a);break;case e.ACK:this.onack(a);break;case e.BINARY_ACK:this.onack(a);break;case e.DISCONNECT:this.ondisconnect();break;case e.ERROR:this.emit("error",a.data)}},d.prototype.onevent=function(a){var b=a.data||[];j("emitting event %j",b),null!=a.id&&(j("attaching ack callback to event"),b.push(this.ack(a.id))),this.connected?m.apply(this,b):this.receiveBuffer.push(b)},d.prototype.ack=function(a){var b=this,c=!1;return function(){if(!c){c=!0;var d=g(arguments);j("sending ack %j",d);var f=k(d)?e.BINARY_ACK:e.ACK;b.packet({type:f,id:a,data:d})}}},d.prototype.onack=function(a){var b=this.acks[a.id];"function"==typeof b?(j("calling ack %s with %j",a.id,a.data),b.apply(this,a.data),delete this.acks[a.id]):j("bad ack %s",a.id)},d.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},d.prototype.emitBuffered=function(){var a;for(a=0;a<this.receiveBuffer.length;a++)m.apply(this,this.receiveBuffer[a]);for(this.receiveBuffer=[],a=0;a<this.sendBuffer.length;a++)this.packet(this.sendBuffer[a]);this.sendBuffer=[]},d.prototype.ondisconnect=function(){j("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},d.prototype.destroy=function(){if(this.subs){for(var a=0;a<this.subs.length;a++)this.subs[a].destroy();this.subs=null}this.io.destroy(this)},d.prototype.close=d.prototype.disconnect=function(){return this.connected&&(j("performing disconnect (%s)",this.nsp),this.packet({type:e.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this},d.prototype.compress=function(a){return this.flags=this.flags||{},this.flags.compress=a,this}},{"./on":111,"component-bind":46,"component-emitter":114,debug:115,"has-binary":70,"socket.io-parser":119,"to-array":136}],113:[function(a,b,c){(function(c){function d(a,b){var d=a,b=b||c.location;null==a&&(a=b.protocol+"//"+b.host),"string"==typeof a&&("/"==a.charAt(0)&&(a="/"==a.charAt(1)?b.protocol+a:b.host+a),/^(https?|wss?):\/\//.test(a)||(f("protocol-less url %s",a),a="undefined"!=typeof b?b.protocol+"//"+a:"https://"+a),f("parse %s",a),d=e(a)),d.port||(/^(http|ws)$/.test(d.protocol)?d.port="80":/^(http|ws)s$/.test(d.protocol)&&(d.port="443")),d.path=d.path||"/";var g=d.host.indexOf(":")!==-1,h=g?"["+d.host+"]":d.host;return d.id=d.protocol+"://"+h+":"+d.port,d.href=d.protocol+"://"+h+(b&&b.port==d.port?"":":"+d.port),d}var e=a("parseuri"),f=a("debug")("socket.io-client:url");b.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{debug:115,parseuri:85}],114:[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}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 this},d.prototype.emit=function(a){this._callbacks=this._callbacks||{};var b=[].slice.call(arguments,1),c=this._callbacks["$"+a];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}},{}],115:[function(a,b,c){arguments[4][60][0].apply(c,arguments)},{"./debug":116,dup:60}],116:[function(a,b,c){arguments[4][61][0].apply(c,arguments)},{dup:61,ms:117}],117:[function(a,b,c){arguments[4][62][0].apply(c,arguments)},{dup:62}],118:[function(a,b,c){(function(b){var d=a("isarray"),e=a("./is-buffer");c.deconstructPacket=function(a){function b(a){if(!a)return a;if(e(a)){var f={_placeholder:!0,num:c.length};return c.push(a),f}if(d(a)){for(var g=new Array(a.length),h=0;h<a.length;h++)g[h]=b(a[h]);return g}if("object"==typeof a&&!(a instanceof Date)){var g={};for(var i in a)g[i]=b(a[i]);return g}return a}var c=[],f=a.data,g=a;return g.data=b(f),g.attachments=c.length,{packet:g,buffers:c}},c.reconstructPacket=function(a,b){function c(a){if(a&&a._placeholder){var e=b[a.num];return e}if(d(a)){for(var f=0;f<a.length;f++)a[f]=c(a[f]);return a}if(a&&"object"==typeof a){for(var g in a)a[g]=c(a[g]);return a}return a}return a.data=c(a.data),a.attachments=void 0,a},c.removeBlobs=function(a,c){function f(a,i,j){if(!a)return a;if(b.Blob&&a instanceof Blob||b.File&&a instanceof File){g++;var k=new FileReader;k.onload=function(){j?j[i]=this.result:h=this.result,--g||c(h)},k.readAsArrayBuffer(a)}else if(d(a))for(var l=0;l<a.length;l++)f(a[l],l,a);else if(a&&"object"==typeof a&&!e(a))for(var m in a)f(a[m],m,a)}var g=0,h=a;f(h),g||c(h)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./is-buffer":120,isarray:124}],119:[function(a,b,c){function d(){}function e(a){var b="",d=!1;return b+=a.type,c.BINARY_EVENT!=a.type&&c.BINARY_ACK!=a.type||(b+=a.attachments,b+="-"),a.nsp&&"/"!=a.nsp&&(d=!0,b+=a.nsp),null!=a.id&&(d&&(b+=",",d=!1),b+=a.id),null!=a.data&&(d&&(b+=","),b+=l.stringify(a.data)),k("encoded %j as %s",a,b),b}function f(a,b){function c(a){var c=n.deconstructPacket(a),d=e(c.packet),f=c.buffers;f.unshift(d),b(f)}n.removeBlobs(a,c)}function g(){this.reconstructor=null}function h(a){var b={},d=0;if(b.type=Number(a.charAt(0)),null==c.types[b.type])return j();if(c.BINARY_EVENT==b.type||c.BINARY_ACK==b.type){for(var e="";"-"!=a.charAt(++d)&&(e+=a.charAt(d),d!=a.length););if(e!=Number(e)||"-"!=a.charAt(d))throw new Error("Illegal attachments");b.attachments=Number(e)}if("/"==a.charAt(d+1))for(b.nsp="";++d;){var f=a.charAt(d);if(","==f)break;if(b.nsp+=f,d==a.length)break;
14
- }else b.nsp="/";var g=a.charAt(d+1);if(""!==g&&Number(g)==g){for(b.id="";++d;){var f=a.charAt(d);if(null==f||Number(f)!=f){--d;break}if(b.id+=a.charAt(d),d==a.length)break}b.id=Number(b.id)}if(a.charAt(++d))try{b.data=l.parse(a.substr(d))}catch(h){return j()}return k("decoded %s as %j",a,b),b}function i(a){this.reconPack=a,this.buffers=[]}function j(a){return{type:c.ERROR,data:"parser error"}}var k=a("debug")("socket.io-parser"),l=a("json3"),m=(a("isarray"),a("component-emitter")),n=a("./binary"),o=a("./is-buffer");c.protocol=4,c.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],c.CONNECT=0,c.DISCONNECT=1,c.EVENT=2,c.ACK=3,c.ERROR=4,c.BINARY_EVENT=5,c.BINARY_ACK=6,c.Encoder=d,c.Decoder=g,d.prototype.encode=function(a,b){if(k("encoding packet %j",a),c.BINARY_EVENT==a.type||c.BINARY_ACK==a.type)f(a,b);else{var d=e(a);b([d])}},m(g.prototype),g.prototype.add=function(a){var b;if("string"==typeof a)b=h(a),c.BINARY_EVENT==b.type||c.BINARY_ACK==b.type?(this.reconstructor=new i(b),0===this.reconstructor.reconPack.attachments&&this.emit("decoded",b)):this.emit("decoded",b);else{if(!o(a)&&!a.base64)throw new Error("Unknown type: "+a);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");b=this.reconstructor.takeBinaryData(a),b&&(this.reconstructor=null,this.emit("decoded",b))}},g.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},i.prototype.takeBinaryData=function(a){if(this.buffers.push(a),this.buffers.length==this.reconPack.attachments){var b=n.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),b}return null},i.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}},{"./binary":118,"./is-buffer":120,"component-emitter":121,debug:122,isarray:124,json3:78}],120:[function(a,b,c){(function(a){function c(b){return a.Buffer&&a.Buffer.isBuffer(b)||a.ArrayBuffer&&b instanceof ArrayBuffer}b.exports=c}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],121:[function(a,b,c){arguments[4][59][0].apply(c,arguments)},{dup:59}],122:[function(a,b,c){arguments[4][60][0].apply(c,arguments)},{"./debug":123,dup:60}],123:[function(a,b,c){arguments[4][61][0].apply(c,arguments)},{dup:61,ms:125}],124:[function(a,b,c){arguments[4][66][0].apply(c,arguments)},{dup:66}],125:[function(a,b,c){arguments[4][62][0].apply(c,arguments)},{dup:62}],126:[function(a,b,c){function d(){e.call(this)}b.exports=d;var e=a("events").EventEmitter,f=a("inherits");f(d,e),d.Readable=a("readable-stream/readable.js"),d.Writable=a("readable-stream/writable.js"),d.Duplex=a("readable-stream/duplex.js"),d.Transform=a("readable-stream/transform.js"),d.PassThrough=a("readable-stream/passthrough.js"),d.Stream=d,d.prototype.pipe=function(a,b){function c(b){a.writable&&!1===a.write(b)&&j.pause&&j.pause()}function d(){j.readable&&j.resume&&j.resume()}function f(){k||(k=!0,a.end())}function g(){k||(k=!0,"function"==typeof a.destroy&&a.destroy())}function h(a){if(i(),0===e.listenerCount(this,"error"))throw a}function i(){j.removeListener("data",c),a.removeListener("drain",d),j.removeListener("end",f),j.removeListener("close",g),j.removeListener("error",h),a.removeListener("error",h),j.removeListener("end",i),j.removeListener("close",i),a.removeListener("close",i)}var j=this;j.on("data",c),a.on("drain",d),a._isStdio||b&&b.end===!1||(j.on("end",f),j.on("close",g));var k=!1;return j.on("error",h),a.on("error",h),j.on("end",i),j.on("close",i),a.on("close",i),a.emit("pipe",j),a}},{events:67,inherits:76,"readable-stream/duplex.js":94,"readable-stream/passthrough.js":103,"readable-stream/readable.js":104,"readable-stream/transform.js":105,"readable-stream/writable.js":106}],127:[function(a,b,c){var d=a("./lib/request"),e=a("xtend"),f=a("builtin-status-codes"),g=a("url"),h=c;h.request=function(a,b){a="string"==typeof a?g.parse(a):e(a);var c=a.protocol||"",f=a.hostname||a.host,h=a.port,i=a.path||"/";f&&f.indexOf(":")!==-1&&(f="["+f+"]"),a.url=(f?c+"//"+f:"")+(h?":"+h:"")+i,a.method=(a.method||"GET").toUpperCase(),a.headers=a.headers||{};var j=new d(a);return b&&j.on("response",b),j},h.get=function(a,b){var c=h.request(a,b);return c.end(),c},h.Agent=function(){},h.Agent.defaultMaxSockets=4,h.STATUS_CODES=f,h.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]},{"./lib/request":129,"builtin-status-codes":45,url:138,xtend:143}],128:[function(a,b,c){(function(a){function b(a){try{return f.responseType=a,f.responseType===a}catch(b){}return!1}function d(a){return"function"==typeof a}c.fetch=d(a.fetch)&&d(a.ReadableByteStream),c.blobConstructor=!1;try{new Blob([new ArrayBuffer(1)]),c.blobConstructor=!0}catch(e){}var f=new a.XMLHttpRequest;f.open("GET",a.location.host?"/":"https://example.com");var g="undefined"!=typeof a.ArrayBuffer,h=g&&d(a.ArrayBuffer.prototype.slice);c.arraybuffer=g&&b("arraybuffer"),c.msstream=!c.fetch&&h&&b("ms-stream"),c.mozchunkedarraybuffer=!c.fetch&&g&&b("moz-chunked-arraybuffer"),c.overrideMimeType=d(f.overrideMimeType),c.vbArray=d(a.VBArray),f=null}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],129:[function(a,b,c){(function(c,d,e){function f(a){return h.fetch?"fetch":h.mozchunkedarraybuffer?"moz-chunked-arraybuffer":h.msstream?"ms-stream":h.arraybuffer&&a?"arraybuffer":h.vbArray&&a?"text:vbarray":"text"}function g(a){try{return null!==a.status}catch(b){return!1}}var h=a("./capability"),i=a("foreach"),j=a("indexof"),k=a("inherits"),l=a("object-keys"),m=a("./response"),n=a("stream"),o=m.IncomingMessage,p=m.readyStates,q=b.exports=function(a){var b=this;n.Writable.call(b),b._opts=a,b._body=[],b._headers={},a.auth&&b.setHeader("Authorization","Basic "+new e(a.auth).toString("base64")),i(l(a.headers),function(c){b.setHeader(c,a.headers[c])});var c;if("prefer-streaming"===a.mode)c=!1;else if("allow-wrong-content-type"===a.mode)c=!h.overrideMimeType;else{if(a.mode&&"default"!==a.mode&&"prefer-fast"!==a.mode)throw new Error("Invalid value for opts.mode");c=!0}b._mode=f(c),b.on("finish",function(){b._onFinish()})};k(q,n.Writable),q.prototype.setHeader=function(a,b){var c=this,d=a.toLowerCase();j(r,d)===-1&&(c._headers[d]={name:a,value:b})},q.prototype.getHeader=function(a){var b=this;return b._headers[a.toLowerCase()].value},q.prototype.removeHeader=function(a){var b=this;delete b._headers[a.toLowerCase()]},q.prototype._onFinish=function(){var a=this;if(!a._destroyed){var b,f=a._opts,g=a._headers;if("POST"!==f.method&&"PUT"!==f.method||(b=h.blobConstructor?new d.Blob(a._body.map(function(a){return a.toArrayBuffer()}),{type:(g["content-type"]||{}).value||""}):e.concat(a._body).toString()),"fetch"===a._mode){var j=l(g).map(function(a){return[g[a].name,g[a].value]});d.fetch(a._opts.url,{method:a._opts.method,headers:j,body:b,mode:"cors",credentials:f.withCredentials?"include":"same-origin"}).then(function(b){a._fetchResponse=b,a._connect()}).then(void 0,function(b){a.emit("error",b)})}else{var k=a._xhr=new d.XMLHttpRequest;try{k.open(a._opts.method,a._opts.url,!0)}catch(m){return void c.nextTick(function(){a.emit("error",m)})}"responseType"in k&&(k.responseType=a._mode.split(":")[0]),"withCredentials"in k&&(k.withCredentials=!!f.withCredentials),"text"===a._mode&&"overrideMimeType"in k&&k.overrideMimeType("text/plain; charset=x-user-defined"),i(l(g),function(a){k.setRequestHeader(g[a].name,g[a].value)}),a._response=null,k.onreadystatechange=function(){switch(k.readyState){case p.LOADING:case p.DONE:a._onXHRProgress()}},"moz-chunked-arraybuffer"===a._mode&&(k.onprogress=function(){a._onXHRProgress()}),k.onerror=function(){a._destroyed||a.emit("error",new Error("XHR error"))};try{k.send(b)}catch(m){return void c.nextTick(function(){a.emit("error",m)})}}}},q.prototype._onXHRProgress=function(){var a=this;g(a._xhr)&&!a._destroyed&&(a._response||a._connect(),a._response._onXHRProgress())},q.prototype._connect=function(){var a=this;a._destroyed||(a._response=new o(a._xhr,a._fetchResponse,a._mode),a.emit("response",a._response))},q.prototype._write=function(a,b,c){var d=this;d._body.push(a),c()},q.prototype.abort=q.prototype.destroy=function(){var a=this;a._destroyed=!0,a._response&&(a._response._destroyed=!0),a._xhr&&a._xhr.abort()},q.prototype.end=function(a,b,c){var d=this;"function"==typeof a&&(c=a,a=void 0),n.Writable.prototype.end.call(d,a,b,c)},q.prototype.flushHeaders=function(){},q.prototype.setTimeout=function(){},q.prototype.setNoDelay=function(){},q.prototype.setSocketKeepAlive=function(){};var r=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"]}).call(this,a("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer)},{"./capability":128,"./response":130,_process:87,buffer:44,foreach:69,indexof:75,inherits:76,"object-keys":80,stream:126}],130:[function(a,b,c){(function(b,d,e){var f=a("./capability"),g=a("foreach"),h=a("inherits"),i=a("stream"),j=c.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},k=c.IncomingMessage=function(a,c,d){function h(){n.read().then(function(a){if(!j._destroyed){if(a.done)return void j.push(null);j.push(new e(a.value)),h()}})}var j=this;if(i.Readable.call(j),j._mode=d,j.headers={},j.rawHeaders=[],j.trailers={},j.rawTrailers=[],j.on("end",function(){b.nextTick(function(){j.emit("close")})}),"fetch"===d){j._fetchResponse=c,j.statusCode=c.status,j.statusMessage=c.statusText;for(var k,l,m=c.headers[Symbol.iterator]();k=(l=m.next()).value,!l.done;)j.headers[k[0].toLowerCase()]=k[1],j.rawHeaders.push(k[0],k[1]);var n=c.body.getReader();h()}else{j._xhr=a,j._pos=0,j.statusCode=a.status,j.statusMessage=a.statusText;var o=a.getAllResponseHeaders().split(/\r?\n/);if(g(o,function(a){var b=a.match(/^([^:]+):\s*(.*)/);if(b){var c=b[1].toLowerCase();void 0!==j.headers[c]?j.headers[c]+=", "+b[2]:j.headers[c]=b[2],j.rawHeaders.push(b[1],b[2])}}),j._charset="x-user-defined",!f.overrideMimeType){var p=j.rawHeaders["mime-type"];if(p){var q=p.match(/;\s*charset=([^;])(;|$)/);q&&(j._charset=q[1].toLowerCase())}j._charset||(j._charset="utf-8")}}};h(k,i.Readable),k.prototype._read=function(){},k.prototype._onXHRProgress=function(){var a=this,b=a._xhr,c=null;switch(a._mode){case"text:vbarray":if(b.readyState!==j.DONE)break;try{c=new d.VBArray(b.responseBody).toArray()}catch(f){}if(null!==c){a.push(new e(c));break}case"text":try{c=b.responseText}catch(f){a._mode="text:vbarray";break}if(c.length>a._pos){var g=c.substr(a._pos);if("x-user-defined"===a._charset){for(var h=new e(g.length),i=0;i<g.length;i++)h[i]=255&g.charCodeAt(i);a.push(h)}else a.push(g,a._charset);a._pos=c.length}break;case"arraybuffer":if(b.readyState!==j.DONE)break;c=b.response,a.push(new e(new Uint8Array(c)));break;case"moz-chunked-arraybuffer":if(c=b.response,b.readyState!==j.LOADING||!c)break;a.push(new e(new Uint8Array(c)));break;case"ms-stream":if(c=b.response,b.readyState!==j.LOADING)break;var k=new d.MSStreamReader;k.onprogress=function(){k.result.byteLength>a._pos&&(a.push(new e(new Uint8Array(k.result.slice(a._pos)))),a._pos=k.result.byteLength)},k.onload=function(){a.push(null)},k.readAsArrayBuffer(c)}a._xhr.readyState===j.DONE&&"ms-stream"!==a._mode&&a.push(null)}}).call(this,a("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer)},{"./capability":128,_process:87,buffer:44,foreach:69,inherits:76,stream:126}],131:[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},{}],132:[function(a,b,c){"use strict";function d(a){if(!a)return"utf8";for(var b;;)switch(a){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return a;default:if(b)return;a=(""+a).toLowerCase(),b=!0}}function e(a){var b=d(a);if("string"!=typeof b&&(s.isEncoding===t||!t(a)))throw new Error("Unknown encoding: "+a);return b||a}function f(a){this.encoding=e(a);var b;switch(this.encoding){case"utf16le":this.text=m,this.end=n,b=4;break;case"utf8":this.fillLast=j,b=4;break;case"base64":this.text=o,this.end=p,b=3;break;default:return this.write=q,void(this.end=r)}this.lastNeed=0,this.lastTotal=0,this.lastChar=s.allocUnsafe(b)}function g(a){return a<=127?0:a>>5===6?2:a>>4===14?3:a>>3===30?4:a>>6===2?-1:-2}function h(a,b,c){var d=b.length-1;if(d<c)return 0;var e=g(b[d]);return e>=0?(e>0&&(a.lastNeed=e-1),e):--d<c||e===-2?0:(e=g(b[d]),e>=0?(e>0&&(a.lastNeed=e-2),e):--d<c||e===-2?0:(e=g(b[d]),e>=0?(e>0&&(2===e?e=0:a.lastNeed=e-3),e):0))}function i(a,b,c){if(128!==(192&b[0]))return a.lastNeed=0,"�";if(a.lastNeed>1&&b.length>1){if(128!==(192&b[1]))return a.lastNeed=1,"�";if(a.lastNeed>2&&b.length>2&&128!==(192&b[2]))return a.lastNeed=2,"�"}}function j(a){var b=this.lastTotal-this.lastNeed,c=i(this,a,b);return void 0!==c?c:this.lastNeed<=a.length?(a.copy(this.lastChar,b,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(a.copy(this.lastChar,b,0,a.length),void(this.lastNeed-=a.length))}function k(a,b){var c=h(this,a,b);if(!this.lastNeed)return a.toString("utf8",b);this.lastTotal=c;var d=a.length-(c-this.lastNeed);return a.copy(this.lastChar,0,d),a.toString("utf8",b,d)}function l(a){var b=a&&a.length?this.write(a):"";return this.lastNeed?b+"�":b}function m(a,b){if((a.length-b)%2===0){var c=a.toString("utf16le",b);if(c){var d=c.charCodeAt(c.length-1);if(d>=55296&&d<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=a[a.length-2],this.lastChar[1]=a[a.length-1],c.slice(0,-1)}return c}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=a[a.length-1],a.toString("utf16le",b,a.length-1)}function n(a){var b=a&&a.length?this.write(a):"";if(this.lastNeed){var c=this.lastTotal-this.lastNeed;return b+this.lastChar.toString("utf16le",0,c)}return b}function o(a,b){var c=(a.length-b)%3;return 0===c?a.toString("base64",b):(this.lastNeed=3-c,this.lastTotal=3,1===c?this.lastChar[0]=a[a.length-1]:(this.lastChar[0]=a[a.length-2],this.lastChar[1]=a[a.length-1]),a.toString("base64",b,a.length-c))}function p(a){var b=a&&a.length?this.write(a):"";return this.lastNeed?b+this.lastChar.toString("base64",0,3-this.lastNeed):b}function q(a){return a.toString(this.encoding)}function r(a){return a&&a.length?this.write(a):""}var s=a("safe-buffer").Buffer,t=s.isEncoding||function(a){switch(a=""+a,a&&a.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};c.StringDecoder=f,f.prototype.write=function(a){if(0===a.length)return"";var b,c;if(this.lastNeed){if(b=this.fillLast(a),void 0===b)return"";c=this.lastNeed,this.lastNeed=0}else c=0;return c<a.length?b?b+this.text(a,c):this.text(a,c):b||""},f.prototype.end=l,f.prototype.text=k,f.prototype.fillLast=function(a){return this.lastNeed<=a.length?(a.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(a.copy(this.lastChar,this.lastTotal-this.lastNeed,0,a.length),void(this.lastNeed-=a.length))}},{"safe-buffer":108}],133:[function(a,b,c){function d(){}function e(a){var b={}.toString.call(a);switch(b){case"[object File]":case"[object Blob]":case"[object FormData]":return!0;default:return!1}}function f(a){return a===Object(a)}function g(a){if(!f(a))return a;var b=[];for(var c in a)null!=a[c]&&h(b,c,a[c]);return b.join("&")}function h(a,b,c){return Array.isArray(c)?c.forEach(function(c){h(a,b,c)}):void a.push(encodeURIComponent(b)+"="+encodeURIComponent(c))}function i(a){for(var b,c,d={},e=a.split("&"),f=0,g=e.length;f<g;++f)c=e[f],b=c.split("="),d[decodeURIComponent(b[0])]=decodeURIComponent(b[1]);return d}function j(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 k(a){return/[\/+]json\b/.test(a)}function l(a){return a.split(/ *; */).shift()}function m(a){return t(a.split(/ *; */),function(a,b){var c=b.split(/ *= */),d=c.shift(),e=c.shift();return d&&e&&(a[d]=e),a},{})}function n(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=j(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 o(a,b){var c=this;s.call(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 n(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,c.callback(a)}if(c.emit("response",b),a)return c.callback(a,b);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)})}function p(a,b){return"function"==typeof b?new o("GET",a).end(b):1==arguments.length?new o("GET",a):new o(a,b)}function q(a,b){var c=p("DELETE",a);return b&&c.end(b),c}var r,s=a("emitter"),t=a("reduce");r="undefined"!=typeof window?window:"undefined"!=typeof self?self:this,p.getXHR=function(){if(!(!r.XMLHttpRequest||r.location&&"file:"==r.location.protocol&&r.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,"")};p.serializeObject=g,p.parseString=i,p.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"},p.serialize={"application/x-www-form-urlencoded":g,"application/json":JSON.stringify},p.parse={"application/x-www-form-urlencoded":i,"application/json":JSON.parse},n.prototype.get=function(a){return this.header[a.toLowerCase()]},n.prototype.setHeaderProperties=function(a){var b=this.header["content-type"]||"";this.type=l(b);var c=m(b);for(var d in c)this[d]=c[d]},n.prototype.parseBody=function(a){var b=p.parse[this.type];return b&&a&&(a.length||a instanceof Object)?b(a):null},n.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},n.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},p.Response=n,s(o.prototype),o.prototype.use=function(a){return a(this),this},o.prototype.timeout=function(a){return this._timeout=a,this},o.prototype.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},o.prototype.abort=function(){if(!this.aborted)return this.aborted=!0,this.xhr.abort(),this.clearTimeout(),this.emit("abort"),this},o.prototype.set=function(a,b){if(f(a)){for(var c in a)this.set(c,a[c]);return this}return this._header[a.toLowerCase()]=b,this.header[a]=b,this},o.prototype.unset=function(a){return delete this._header[a.toLowerCase()],delete this.header[a],this},o.prototype.getHeader=function(a){return this._header[a.toLowerCase()]},o.prototype.type=function(a){return this.set("Content-Type",p.types[a]||a),this},o.prototype.parse=function(a){return this._parser=a,this},o.prototype.accept=function(a){return this.set("Accept",p.types[a]||a),this},o.prototype.auth=function(a,b){var c=btoa(a+":"+b);return this.set("Authorization","Basic "+c),this},o.prototype.query=function(a){return"string"!=typeof a&&(a=g(a)),a&&this._query.push(a),this},o.prototype.field=function(a,b){return this._formData||(this._formData=new r.FormData),this._formData.append(a,b),this},o.prototype.attach=function(a,b,c){return this._formData||(this._formData=new r.FormData),this._formData.append(a,b,c||b.name),this},o.prototype.send=function(a){var b=f(a),c=this.getHeader("Content-Type");if(b&&f(this._data))for(var d in a)this._data[d]=a[d];else"string"==typeof a?(c||this.type("form"),c=this.getHeader("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||e(a)?this:(c||this.type("json"),this)},o.prototype.callback=function(a,b){var c=this._callback;this.clearTimeout(),c(a,b)},o.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)},o.prototype.timeoutError=function(){var a=this._timeout,b=new Error("timeout of "+a+"ms exceeded");b.timeout=a,this.callback(b)},o.prototype.withCredentials=function(){return this._withCredentials=!0,this},o.prototype.end=function(a){var b=this,c=this.xhr=p.getXHR(),f=this._query.join("&"),g=this._timeout,h=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 i=function(a){a.total>0&&(a.percent=a.loaded/a.total*100),a.direction="download",b.emit("progress",a)};this.hasListeners("progress")&&(c.onprogress=i);try{c.upload&&this.hasListeners("progress")&&(c.upload.onprogress=i)}catch(j){}if(g&&!this._timer&&(this._timer=setTimeout(function(){b.timedout=!0,b.abort()},g)),f&&(f=p.serializeObject(f),this.url+=~this.url.indexOf("?")?"&"+f:"?"+f),c.open(this.method,this.url,!0),this._withCredentials&&(c.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof h&&!e(h)){var l=this.getHeader("Content-Type"),m=this._parser||p.serialize[l?l.split(";")[0]:""];!m&&k(l)&&(m=p.serialize["application/json"]),m&&(h=m(h))}for(var n in this.header)null!=this.header[n]&&c.setRequestHeader(n,this.header[n]);return this.emit("request",this),c.send("undefined"!=typeof h?h:null),this},o.prototype.then=function(a,b){return this.end(function(c,d){c?b(c):a(d)})},p.Request=o,p.get=function(a,b,c){var d=p("GET",a);return"function"==typeof b&&(c=b,b=null),b&&d.query(b),c&&d.end(c),d},p.head=function(a,b,c){var d=p("HEAD",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},p.del=q,p["delete"]=q,p.patch=function(a,b,c){var d=p("PATCH",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},p.post=function(a,b,c){var d=p("POST",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},p.put=function(a,b,c){var d=p("PUT",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},b.exports=p},{emitter:134,reduce:107}],134:[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 this},d.prototype.emit=function(a){this._callbacks=this._callbacks||{};var b=[].slice.call(arguments,1),c=this._callbacks["$"+a];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}},{}],135:[function(a,b,c){(function(c){"0.50.0";var d=d||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,c){a=this.words=a||[],this.sigBytes=c!=b?c: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-8*(e%4)&255)<<24-8*((d+e)%4);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-8*(c%4),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-8*(d%4)&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-4*(d%8);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-8*(d%4)&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-8*(d%4);return new g.init(c,b)}},k=h.Utf8={stringify:function(a){try{return decodeURIComponent(escape(j.stringify(a)))}catch(b){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),h=b?a.ceil(h):a.max((0|h)-this._minBufferSize,0);if(b=h*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(){var a=d,b=a.lib,c=b.WordArray,e=b.Hasher,f=[],b=a.algo.SHA1=e.extend({_doReset:function(){this._hash=new c.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],g=c[2],h=c[3],i=c[4],j=0;80>j;j++){if(16>j)f[j]=0|a[b+j];else{var k=f[j-3]^f[j-8]^f[j-14]^f[j-16];f[j]=k<<1|k>>>31}k=(d<<5|d>>>27)+i+f[j],k=20>j?k+((e&g|~e&h)+1518500249):40>j?k+((e^g^h)+1859775393):60>j?k+((e&g|e&h|g&h)-1894007588):k+((e^g^h)-899497514),i=h,h=g,g=e<<30|e>>>2,e=d,d=k}c[0]=c[0]+d|0,c[1]=c[1]+e|0,c[2]=c[2]+g|0,c[3]=c[3]+h|0,c[4]=c[4]+i|0},_doFinalize:function(){var a=this._data,b=a.words,c=8*this._nDataBytes,d=8*a.sigBytes;return b[d>>>5]|=128<<24-d%32,b[(d+64>>>9<<4)+14]=Math.floor(c/4294967296),b[(d+64>>>9<<4)+15]=c,a.sigBytes=4*b.length,this._process(),this._hash},clone:function(){var a=e.clone.call(this);return a._hash=this._hash.clone(),a}});a.SHA1=e._createHelper(b),a.HmacSHA1=e._createHmacHelper(b)}();var d=d||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,c){a=this.words=a||[],this.sigBytes=c!=b?c: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-8*(e%4)&255)<<24-8*((d+e)%4);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-8*(c%4),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-8*(d%4)&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-4*(d%8);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-8*(d%4)&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-8*(d%4);return new g.init(c,b)}},k=h.Utf8={stringify:function(a){try{return decodeURIComponent(escape(j.stringify(a)))}catch(b){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),
15
- this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,f=this.blockSize,h=e/(4*f),h=b?a.ceil(h):a.max((0|h)-this._minBufferSize,0);if(b=h*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=d,c=b.lib,e=c.WordArray,f=c.Hasher,c=b.algo,g=[],h=[],i=function(a){return 4294967296*(a-(0|a))|0},j=2,k=0;64>k;){var l;a:{l=j;for(var m=a.sqrt(l),n=2;n<=m;n++)if(!(l%n)){l=!1;break a}l=!0}l&&(8>k&&(g[k]=i(a.pow(j,.5))),h[k]=i(a.pow(j,1/3)),k++),j++}var o=[],c=c.SHA256=f.extend({_doReset:function(){this._hash=new e.init(g.slice(0))},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],g=c[3],i=c[4],j=c[5],k=c[6],l=c[7],m=0;64>m;m++){if(16>m)o[m]=0|a[b+m];else{var n=o[m-15],p=o[m-2];o[m]=((n<<25|n>>>7)^(n<<14|n>>>18)^n>>>3)+o[m-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+o[m-16]}n=l+((i<<26|i>>>6)^(i<<21|i>>>11)^(i<<7|i>>>25))+(i&j^~i&k)+h[m]+o[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=g+n|0,g=f,f=e,e=d,d=n+p|0}c[0]=c[0]+d|0,c[1]=c[1]+e|0,c[2]=c[2]+f|0,c[3]=c[3]+g|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[(e+64>>>9<<4)+14]=a.floor(d/4294967296),c[(e+64>>>9<<4)+15]=d,b.sigBytes=4*c.length,this._process(),this._hash},clone:function(){var a=f.clone.call(this);return a._hash=this._hash.clone(),a}});b.SHA256=f._createHelper(c),b.HmacSHA256=f._createHmacHelper(c)}(Math),function(){var a=d,b=a.lib,c=b.WordArray,e=a.enc;e.Base64={stringify:function(a){var b=a.words,c=a.sigBytes,d=this._map;a.clamp();for(var e=[],f=0;f<c;f+=3)for(var g=b[f>>>2]>>>24-f%4*8&255,h=b[f+1>>>2]>>>24-(f+1)%4*8&255,i=b[f+2>>>2]>>>24-(f+2)%4*8&255,j=g<<16|h<<8|i,k=0;k<4&&f+.75*k<c;k++)e.push(d.charAt(j>>>6*(3-k)&63));var l=d.charAt(64);if(l)for(;e.length%4;)e.push(l);return e.join("")},parse:function(a){var b=a.length,d=this._map,e=d.charAt(64);if(e){var f=a.indexOf(e);f!=-1&&(b=f)}for(var g=[],h=0,i=0;i<b;i++)if(i%4){var j=d.indexOf(a.charAt(i-1))<<i%4*2,k=d.indexOf(a.charAt(i))>>>6-i%4*2;g[h>>>2]|=(j|k)<<24-h%4*8,h++}return c.create(g,h)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(){if("function"==typeof ArrayBuffer){var a=d,b=a.lib,c=b.WordArray,e=c.init,f=c.init=function(a){if(a instanceof ArrayBuffer&&(a=new Uint8Array(a)),(a instanceof Int8Array||a instanceof Uint8ClampedArray||a instanceof Int16Array||a instanceof Uint16Array||a instanceof Int32Array||a instanceof Uint32Array||a instanceof Float32Array||a instanceof Float64Array)&&(a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength)),a instanceof Uint8Array){for(var b=a.byteLength,c=[],d=0;d<b;d++)c[d>>>2]|=a[d]<<24-d%4*8;e.call(this,c,b)}else e.apply(this,arguments)};f.prototype=c}}();var e;!function(){"use strict";var a={statementId:!0,voidedStatementId:!0,verb:!0,object:!0,registration:!0,context:!0,actor:!0,since:!0,until:!0,limit:!0,authoritative:!0,sparse:!0,instructor:!0,ascending:!0,continueToken:!0,agent:!0,activityId:!0,stateId:!0,profileId:!0,activity_platform:!0,grouping:!0,"Accept-Language":!0};e=function(a){this.log("constructor"),this.recordStores=[],this.actor=null,this.activity=null,this.registration=null,this.context=null,this.init(a)},e.prototype={LOG_SRC:"TinCan",log:function(a,b){e.DEBUG&&"undefined"!=typeof console&&console.log&&(b=b||this.LOG_SRC||"TinCan",console.log("TinCan."+b+": "+a))},init:function(a){this.log("init");var b;if(a=a||{},a.hasOwnProperty("url")&&""!==a.url&&this._initFromQueryString(a.url),a.hasOwnProperty("recordStores")&&void 0!==a.recordStores)for(b=0;b<a.recordStores.length;b+=1)this.addRecordStore(a.recordStores[b]);a.hasOwnProperty("activity")&&(a.activity instanceof e.Activity?this.activity=a.activity:this.activity=new e.Activity(a.activity)),a.hasOwnProperty("actor")&&(a.actor instanceof e.Agent?this.actor=a.actor:this.actor=new e.Agent(a.actor)),a.hasOwnProperty("context")&&(a.context instanceof e.Context?this.context=a.context:this.context=new e.Context(a.context)),a.hasOwnProperty("registration")&&(this.registration=a.registration)},_initFromQueryString:function(b){this.log("_initFromQueryString");var c,d,f,g=e.Utils.parseURL(b).params,h=["endpoint","auth"],i={},j=null;if(g.hasOwnProperty("actor")){this.log("_initFromQueryString - found actor: "+g.actor);try{this.actor=e.Agent.fromJSON(g.actor),delete g.actor}catch(k){this.log("_initFromQueryString - failed to set actor: "+k)}}if(g.hasOwnProperty("activity_id")&&(this.activity=new e.Activity({id:g.activity_id}),delete g.activity_id),(g.hasOwnProperty("activity_platform")||g.hasOwnProperty("registration")||g.hasOwnProperty("grouping"))&&(f={},g.hasOwnProperty("activity_platform")&&(f.platform=g.activity_platform,delete g.activity_platform),g.hasOwnProperty("registration")&&(f.registration=this.registration=g.registration,delete g.registration),g.hasOwnProperty("grouping")&&(f.contextActivities={},f.contextActivities.grouping=g.grouping,delete g.grouping),this.context=new e.Context(f)),g.hasOwnProperty("endpoint")){for(c=0;c<h.length;c+=1)d=h[c],g.hasOwnProperty(d)&&(i[d]=g[d],delete g[d]);for(c in g)g.hasOwnProperty(c)&&(a.hasOwnProperty(c)?delete g[c]:(j=j||{},j[c]=g[c]));null!==j&&(i.extended=j),i.allowFail=!1,this.addRecordStore(i)}},addRecordStore:function(a){this.log("addRecordStore");var b;b=a instanceof e.LRS?a:new e.LRS(a),this.recordStores.push(b)},prepareStatement:function(a){return this.log("prepareStatement"),a instanceof e.Statement||(a=new e.Statement(a)),null===a.actor&&null!==this.actor&&(a.actor=this.actor),null===a.target&&null!==this.activity&&(a.target=this.activity),null!==this.context&&(null===a.context?a.context=this.context:(null===a.context.registration&&(a.context.registration=this.context.registration),null===a.context.platform&&(a.context.platform=this.context.platform),null!==this.context.contextActivities&&(null===a.context.contextActivities?a.context.contextActivities=this.context.contextActivities:(null!==this.context.contextActivities.grouping&&null===a.context.contextActivities.grouping&&(a.context.contextActivities.grouping=this.context.contextActivities.grouping),null!==this.context.contextActivities.parent&&null===a.context.contextActivities.parent&&(a.context.contextActivities.parent=this.context.contextActivities.parent),null!==this.context.contextActivities.other&&null===a.context.contextActivities.other&&(a.context.contextActivities.other=this.context.contextActivities.other))))),a},sendStatement:function(a,b){this.log("sendStatement");var c,d,e,f=this,g=this.prepareStatement(a),h=this.recordStores.length,i=[],j=[];if(h>0)for("function"==typeof b&&(e=function(a,c){var d;f.log("sendStatement - callbackWrapper: "+h),h>1?(h-=1,j.push({err:a,xhr:c})):1===h?(j.push({err:a,xhr:c}),d=[j,g],b.apply(this,d)):f.log("sendStatement - unexpected record store count: "+h)}),d=0;d<h;d+=1)c=this.recordStores[d],i.push(c.saveStatement(g,{callback:e}));else this.log("[warning] sendStatement: No LRSs added yet (statement not sent)"),"function"==typeof b&&b.apply(this,[null,g]);return{statement:g,results:i}},getStatement:function(a,b,c){this.log("getStatement");var d;return c=c||{},c.params=c.params||{},this.recordStores.length>0?(d=this.recordStores[0],d.retrieveStatement(a,{callback:b,params:c.params})):void this.log("[warning] getStatement: No LRSs added yet (statement not retrieved)")},voidStatement:function(a,b,c){this.log("voidStatement");var d,f,g,h,i,j=this,k=this.recordStores.length,l=[],m=[];if(a instanceof e.Statement&&(a=a.id),"undefined"!=typeof c.actor?f=c.actor:null!==this.actor&&(f=this.actor),g=new e.Statement({actor:f,verb:{id:"http://adlnet.gov/expapi/verbs/voided"},target:{objectType:"StatementRef",id:a}}),k>0)for("function"==typeof b&&(i=function(a,c){var d;j.log("voidStatement - callbackWrapper: "+k),k>1?(k-=1,m.push({err:a,xhr:c})):1===k?(m.push({err:a,xhr:c}),d=[m,g],b.apply(this,d)):j.log("voidStatement - unexpected record store count: "+k)}),h=0;h<k;h+=1)d=this.recordStores[h],l.push(d.saveStatement(g,{callback:i}));else this.log("[warning] voidStatement: No LRSs added yet (statement not sent)"),"function"==typeof b&&b.apply(this,[null,g]);return{statement:g,results:l}},getVoidedStatement:function(a,b){this.log("getVoidedStatement");var c;return this.recordStores.length>0?(c=this.recordStores[0],c.retrieveVoidedStatement(a,{callback:b})):void this.log("[warning] getVoidedStatement: No LRSs added yet (statement not retrieved)")},sendStatements:function(a,b){this.log("sendStatements");var c,d,e,f=this,g=[],h=this.recordStores.length,i=[],j=[];if(0===a.length)"function"==typeof b&&b.apply(this,[null,g]);else{for(d=0;d<a.length;d+=1)g.push(this.prepareStatement(a[d]));if(h>0)for("function"==typeof b&&(e=function(a,c){var d;f.log("sendStatements - callbackWrapper: "+h),h>1?(h-=1,j.push({err:a,xhr:c})):1===h?(j.push({err:a,xhr:c}),d=[j,g],b.apply(this,d)):f.log("sendStatements - unexpected record store count: "+h)}),d=0;d<h;d+=1)c=this.recordStores[d],i.push(c.saveStatements(g,{callback:e}));else this.log("[warning] sendStatements: No LRSs added yet (statements not sent)"),"function"==typeof b&&b.apply(this,[null,g])}return{statements:g,results:i}},getStatements:function(a){this.log("getStatements");var b,c,d={};return this.recordStores.length>0?(b=this.recordStores[0],a=a||{},c=a.params||{},a.sendActor&&null!==this.actor&&("0.9"===b.version||"0.95"===b.version?c.actor=this.actor:c.agent=this.actor),a.sendActivity&&null!==this.activity&&("0.9"===b.version||"0.95"===b.version?c.target=this.activity:c.activity=this.activity),"undefined"==typeof c.registration&&null!==this.registration&&(c.registration=this.registration),d={params:c},"undefined"!=typeof a.callback&&(d.callback=a.callback),b.queryStatements(d)):void this.log("[warning] getStatements: No LRSs added yet (statements not read)")},getState:function(a,b){this.log("getState");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor,activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.registration?c.registration=b.registration:null!==this.registration&&(c.registration=this.registration),"undefined"!=typeof b.callback&&(c.callback=b.callback),d.retrieveState(a,c)):void this.log("[warning] getState: No LRSs added yet (state not retrieved)")},setState:function(a,b,c){this.log("setState");var d,f;return this.recordStores.length>0?(f=this.recordStores[0],c=c||{},d={agent:"undefined"!=typeof c.agent?c.agent:this.actor,activity:"undefined"!=typeof c.activity?c.activity:this.activity},"undefined"!=typeof c.registration?d.registration=c.registration:null!==this.registration&&(d.registration=this.registration),"undefined"!=typeof c.lastSHA1&&(d.lastSHA1=c.lastSHA1),"undefined"!=typeof c.contentType&&(d.contentType=c.contentType,"undefined"!=typeof c.overwriteJSON&&!c.overwriteJSON&&e.Utils.isApplicationJSON(c.contentType)&&(d.method="POST")),"undefined"!=typeof c.callback&&(d.callback=c.callback),f.saveState(a,b,d)):void this.log("[warning] setState: No LRSs added yet (state not saved)")},deleteState:function(a,b){this.log("deleteState");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor,activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.registration?c.registration=b.registration:null!==this.registration&&(c.registration=this.registration),"undefined"!=typeof b.callback&&(c.callback=b.callback),d.dropState(a,c)):void this.log("[warning] deleteState: No LRSs added yet (state not deleted)")},getActivityProfile:function(a,b){this.log("getActivityProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.retrieveActivityProfile(a,c)):void this.log("[warning] getActivityProfile: No LRSs added yet (activity profile not retrieved)")},setActivityProfile:function(a,b,c){this.log("setActivityProfile");var d,f;return this.recordStores.length>0?(f=this.recordStores[0],c=c||{},d={activity:"undefined"!=typeof c.activity?c.activity:this.activity},"undefined"!=typeof c.callback&&(d.callback=c.callback),"undefined"!=typeof c.lastSHA1&&(d.lastSHA1=c.lastSHA1),"undefined"!=typeof c.contentType&&(d.contentType=c.contentType,"undefined"!=typeof c.overwriteJSON&&!c.overwriteJSON&&e.Utils.isApplicationJSON(c.contentType)&&(d.method="POST")),f.saveActivityProfile(a,b,d)):void this.log("[warning] setActivityProfile: No LRSs added yet (activity profile not saved)")},deleteActivityProfile:function(a,b){this.log("deleteActivityProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.dropActivityProfile(a,c)):void this.log("[warning] deleteActivityProfile: No LRSs added yet (activity profile not deleted)")},getAgentProfile:function(a,b){this.log("getAgentProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.retrieveAgentProfile(a,c)):void this.log("[warning] getAgentProfile: No LRSs added yet (agent profile not retrieved)")},setAgentProfile:function(a,b,c){this.log("setAgentProfile");var d,f;return this.recordStores.length>0?(f=this.recordStores[0],c=c||{},d={agent:"undefined"!=typeof c.agent?c.agent:this.actor},"undefined"!=typeof c.callback&&(d.callback=c.callback),"undefined"!=typeof c.lastSHA1&&(d.lastSHA1=c.lastSHA1),"undefined"!=typeof c.contentType&&(d.contentType=c.contentType,"undefined"!=typeof c.overwriteJSON&&!c.overwriteJSON&&e.Utils.isApplicationJSON(c.contentType)&&(d.method="POST")),f.saveAgentProfile(a,b,d)):void this.log("[warning] setAgentProfile: No LRSs added yet (agent profile not saved)")},deleteAgentProfile:function(a,b){this.log("deleteAgentProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.dropAgentProfile(a,c)):void this.log("[warning] deleteAgentProfile: No LRSs added yet (agent profile not deleted)")}},e.DEBUG=!1,e.enableDebug=function(){e.DEBUG=!0},e.disableDebug=function(){e.DEBUG=!1},e.versions=function(){return["1.0.2","1.0.1","1.0.0","0.95","0.9"]},"object"==typeof b&&(b.exports=e)}(),function(){"use strict";e.Utils={defaultEncoding:"utf8",getUUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16)})},getISODateString:function(a){function b(a,b){var c,d;for("undefined"!=typeof a&&null!==a||(a=0),"undefined"!=typeof b&&null!==b||(b=2),c=Math.pow(10,b-1),d=a.toString();a<c&&c>1;)d="0"+d,c/=10;return d}return a.getUTCFullYear()+"-"+b(a.getUTCMonth()+1)+"-"+b(a.getUTCDate())+"T"+b(a.getUTCHours())+":"+b(a.getUTCMinutes())+":"+b(a.getUTCSeconds())+"."+b(a.getUTCMilliseconds(),3)+"Z"},convertISO8601DurationToMilliseconds:function(a){var b,c,d,e,f=a.indexOf("-")>=0,g=a.indexOf("T"),h=a.indexOf("H"),i=a.indexOf("M"),j=a.indexOf("S");if(g===-1||i!==-1&&i<g||a.indexOf("D")!==-1||a.indexOf("Y")!==-1)throw new Error("ISO 8601 timestamps including years, months and/or days are not currently supported");return h===-1?(h=g,b=0):b=parseInt(a.slice(g+1,h),10),i===-1?(i=g,c=0):c=parseInt(a.slice(h+1,i),10),d=parseFloat(a.slice(i+1,j)),e=parseInt(1e3*(60*(60*b+c)+d),10),isNaN(e)&&(e=0),f&&(e*=-1),e},convertMillisecondsToISO8601Duration:function(a){var b,c,d,e,f=parseInt(a,10),g="",h="";return e=Math.round(f/10),e<0&&(g="-",e*=-1),b=parseInt(e/36e4,10),c=parseInt(e%36e4/6e3,10),d=e%36e4%6e3/100,h=g+"PT",b>0&&(h+=b+"H"),c>0&&(h+=c+"M"),h+=d+"S"},getSHA1String:function(a){return d.SHA1(a).toString(d.enc.Hex)},getSHA256String:function(a){return"[object ArrayBuffer]"===Object.prototype.toString.call(a)&&(a=d.lib.WordArray.create(a)),d.SHA256(a).toString(d.enc.Hex)},getBase64String:function(a){return d.enc.Base64.stringify(d.enc.Latin1.parse(a))},getLangDictionaryValue:function(a,b){var c,d=this[a];if("undefined"!=typeof b&&"undefined"!=typeof d[b])return d[b];if("undefined"!=typeof d.und)return d.und;if("undefined"!=typeof d["en-US"])return d["en-US"];for(c in d)if(d.hasOwnProperty(c))return d[c];return""},parseURL:function(a,b){var c,d,e,f,g="/"===a.charAt(0),h=["(/[^?#]*)","(\\?[^#]*|)","(#.*|)$"],i=/\+/g,j=/([^&=]+)=?([^&]*)/g,k=function(a){return decodeURIComponent(a.replace(i," "))};if(b=b||{},g){if("undefined"==typeof b.allowRelative||!b.allowRelative)throw new Error("Refusing to parse relative URL without 'allowRelative' option")}else h.unshift("^(https?:)//","(([^:/?#]*)(?::([0-9]+))?)"),a.indexOf("/",8)===-1&&(a+="/");if(c=new RegExp(h.join("")),d=a.match(c),null===d)throw new Error("Unable to parse URL regular expression did not match: '"+a+"'");if(g?(e={protocol:null,host:null,hostname:null,port:null,path:null,pathname:d[1],search:d[2],hash:d[3],params:{}},e.path=e.pathname):(e={protocol:d[1],host:d[2],hostname:d[3],port:d[4],pathname:d[5],search:d[6],hash:d[7],params:{}},e.path=e.protocol+"//"+e.host+e.pathname),""!==e.search)for(;f=j.exec(e.search.substring(1));)e.params[k(f[1])]=k(f[2]);return e},getServerRoot:function(a){var b=a.split("/");return b[0]+"//"+b[2]},getContentTypeFromHeader:function(a){return String(a).split(";")[0]},isApplicationJSON:function(a){return 0===e.Utils.getContentTypeFromHeader(a).toLowerCase().indexOf("application/json")},stringToArrayBuffer:function(){e.prototype.log("stringToArrayBuffer not overloaded - no environment loaded?")},stringFromArrayBuffer:function(){e.prototype.log("stringFromArrayBuffer not overloaded - no environment loaded?")}}}(),function(){"use strict";var a=e.LRS=function(a){this.log("constructor"),this.endpoint=null,this.version=null,this.auth=null,this.allowFail=!0,this.extended=null,this.init(a)};a.prototype={LOG_SRC:"LRS",log:e.prototype.log,init:function(a){this.log("init");var b,c=e.versions(),d=!1;if(a=a||{},a.hasOwnProperty("alertOnRequestFailure")&&this.log("'alertOnRequestFailure' is deprecated (alerts have been removed) no need to set it now"),!a.hasOwnProperty("endpoint")||null===a.endpoint||""===a.endpoint)throw this.log("[error] LRS invalid: no endpoint"),{code:3,mesg:"LRS invalid: no endpoint"};if(this.endpoint=String(a.endpoint),"/"!==this.endpoint.slice(-1)&&(this.log("adding trailing slash to endpoint"),this.endpoint+="/"),a.hasOwnProperty("allowFail")&&(this.allowFail=a.allowFail),a.hasOwnProperty("auth")?this.auth=a.auth:a.hasOwnProperty("username")&&a.hasOwnProperty("password")&&(this.auth="Basic "+e.Utils.getBase64String(a.username+":"+a.password)),a.hasOwnProperty("extended")&&(this.extended=a.extended),this._initByEnvironment(a),"undefined"!=typeof a.version){for(this.log("version: "+a.version),b=0;b<c.length;b+=1)if(c[b]===a.version){d=!0;break}if(!d)throw this.log("[error] LRS invalid: version not supported ("+a.version+")"),{code:5,mesg:"LRS invalid: version not supported ("+a.version+")"};this.version=a.version}else this.version=c[0]},_getBoundary:function(){return e.Utils.getUUID().replace(/-/g,"")},_initByEnvironment:function(){this.log("_initByEnvironment not overloaded - no environment loaded?")},_makeRequest:function(){this.log("_makeRequest not overloaded - no environment loaded?")},_getMultipartRequestData:function(){this.log("_getMultipartRequestData not overloaded - no environment loaded?")},_IEModeConversion:function(){this.log("_IEModeConversion not overloaded - browser environment not loaded.")},_processGetStatementResult:function(a,b){var c,d,f,g,h={};if(!b.attachments)return e.Statement.fromJSON(a.responseText);for(c=a.getResponseHeader("Content-Type").split("boundary=")[1],d=this._parseMultipart(c,a.response),f=JSON.parse(d[0].body),g=1;g<d.length;g+=1)h[d[g].headers["X-Experience-API-Hash"]]=d[g].body;return this._assignAttachmentContent([f],h),new e.Statement(f)},sendRequest:function(a){this.log("sendRequest");var b,c=this.endpoint+a.url,d={};if(0===a.url.indexOf("http")&&(c=a.url),null!==this.extended){a.params=a.params||{};for(b in this.extended)this.extended.hasOwnProperty(b)&&(a.params.hasOwnProperty(b)||null!==this.extended[b]&&(a.params[b]=this.extended[b]))}d.Authorization=this.auth,"0.9"!==this.version&&(d["X-Experience-API-Version"]=this.version);for(b in a.headers)a.headers.hasOwnProperty(b)&&(d[b]=a.headers[b]);return this._makeRequest(c,d,a)},about:function(a){this.log("about");var b,c,d;if(a=a||{},b={url:"about",method:"GET",params:{}},"undefined"!=typeof a.callback&&(d=function(b,c){var d=c;null===b&&(d=e.About.fromJSON(c.responseText)),a.callback(b,d)},b.callback=d),c=this.sendRequest(b),!d)return null===c.err&&(c.xhr=e.About.fromJSON(c.xhr.responseText)),c},saveStatement:function(a,b){this.log("saveStatement");var c,d,e,f={url:"statements",headers:{}},g=[];b=b||{};try{c=a.asVersion(this.version)}catch(h){return this.allowFail?(this.log("[warning] statement could not be serialized in version ("+this.version+"): "+h),"undefined"!=typeof b.callback?void b.callback(null,null):{err:null,xhr:null}):(this.log("[error] statement could not be serialized in version ("+this.version+"): "+h),"undefined"!=typeof b.callback?void b.callback(h,null):{err:h,xhr:null})}if(c.hasOwnProperty("attachments")&&a.hasAttachmentWithContent()){for(d=this._getBoundary(),f.headers["Content-Type"]="multipart/mixed; boundary="+d,e=0;e<a.attachments.length;e+=1)null!==a.attachments[e].content&&g.push(a.attachments[e]);try{f.data=this._getMultipartRequestData(d,c,g)}catch(h){return this.allowFail?(this.log("[warning] multipart request data could not be created (attachments probably not supported): "+h),"undefined"!=typeof b.callback?void b.callback(null,null):{err:null,xhr:null}):(this.log("[error] multipart request data could not be created (attachments probably not supported): "+h),"undefined"!=typeof b.callback?void b.callback(h,null):{err:h,xhr:null})}}else f.headers["Content-Type"]="application/json",f.data=JSON.stringify(c);return null!==a.id?(f.method="PUT",f.params={statementId:a.id}):f.method="POST","undefined"!=typeof b.callback&&(f.callback=b.callback),this.sendRequest(f)},retrieveStatement:function(a,b){this.log("retrieveStatement");var c,d,e,f=this;return b=b||{},b.params=b.params||{},c={url:"statements",method:"GET",params:{statementId:a}},b.params.attachments&&(c.params.attachments=!0,c.expectMultipart=!0),"undefined"!=typeof b.callback&&(e=function(a,c){var d=c;null===a&&(d=f._processGetStatementResult(c,b.params)),b.callback(a,d)},c.callback=e),d=this.sendRequest(c),e||(d.statement=null,null===d.err&&(d.statement=f._processGetStatementResult(d.xhr,b.params))),d},retrieveVoidedStatement:function(a,b){this.log("retrieveVoidedStatement");var c,d,e,f=this;return b=b||{},b.params=b.params||{},c={url:"statements",method:"GET",params:{}},"0.9"===this.version||"0.95"===this.version?c.params.statementId=a:(c.params.voidedStatementId=a,b.params.attachments&&(c.params.attachments=!0,c.expectMultipart=!0)),"undefined"!=typeof b.callback&&(e=function(a,c){var d=c;null===a&&(d=f._processGetStatementResult(c,b.params)),b.callback(a,d)},c.callback=e),d=this.sendRequest(c),e||(d.statement=null,null===d.err&&(d.statement=f._processGetStatementResult(d.xhr,b.params))),d},saveStatements:function(a,b){this.log("saveStatements");var c,d,e,f,g={url:"statements",method:"POST",headers:{}},h=[],i=[];if(b=b||{},0===a.length)return"undefined"!=typeof b.callback?void b.callback(new Error("no statements"),null):{err:new Error("no statements"),xhr:null};for(e=0;e<a.length;e+=1){try{c=a[e].asVersion(this.version)}catch(j){return this.allowFail?(this.log("[warning] statement could not be serialized in version ("+this.version+"): "+j),"undefined"!=typeof b.callback?void b.callback(null,null):{err:null,xhr:null}):(this.log("[error] statement could not be serialized in version ("+this.version+"): "+j),"undefined"!=typeof b.callback?void b.callback(j,null):{err:j,xhr:null})}if(a[e].hasAttachmentWithContent())for(f=0;f<a[e].attachments.length;f+=1)null!==a[e].attachments[f].content&&i.push(a[e].attachments[f]);h.push(c)}if(0!==i.length){d=this._getBoundary(),g.headers["Content-Type"]="multipart/mixed; boundary="+d;try{g.data=this._getMultipartRequestData(d,h,i)}catch(j){return this.allowFail?(this.log("[warning] multipart request data could not be created (attachments probably not supported): "+j),"undefined"!=typeof b.callback?void b.callback(null,null):{err:null,xhr:null}):(this.log("[error] multipart request data could not be created (attachments probably not supported): "+j),"undefined"!=typeof b.callback?void b.callback(j,null):{err:j,xhr:null})}}else g.headers["Content-Type"]="application/json",g.data=JSON.stringify(h);return"undefined"!=typeof b.callback&&(g.callback=b.callback),this.sendRequest(g)},queryStatements:function(a){this.log("queryStatements");var b,c,d,f=this;a=a||{},a.params=a.params||{};try{b=this._queryStatementsRequestCfg(a),a.params.attachments&&(b.expectMultipart=!0)}catch(g){return this.log("[error] Query statements failed - "+g),"undefined"!=typeof a.callback&&a.callback(g,{}),{err:g,statementsResult:null}}return"undefined"!=typeof a.callback&&(d=function(b,c){var d,g,h,i,j=c,k={};if(null===b)if(a.params.attachments){for(g=c.getResponseHeader("Content-Type").split("boundary=")[1],d=f._parseMultipart(g,c.response),h=JSON.parse(d[0].body),i=1;i<d.length;i+=1)k[d[i].headers["X-Experience-API-Hash"]]=d[i].body;for(f._assignAttachmentContent(h.statements,k),j=new e.StatementsResult({statements:h.statements}),i=0;i<j.statements.length;i+=1)j.statements[i]instanceof e.Statement||(j.statements[i]=new e.Statement(j.statements[i]))}else j=e.StatementsResult.fromJSON(c.responseText);a.callback(b,j)},b.callback=d),c=this.sendRequest(b),c.config=b,d||(c.statementsResult=null,null===c.err&&(c.statementsResult=e.StatementsResult.fromJSON(c.xhr.responseText))),c},_queryStatementsRequestCfg:function(a){this.log("_queryStatementsRequestCfg");var b,c,d={},e={url:"statements",method:"GET",params:d},f=["agent","actor","object","instructor"],g=["verb","activity"],h=["registration","context","since","until","limit","authoritative","sparse","ascending","related_activities","related_agents","format","attachments"],i={verb:!0,registration:!0,since:!0,until:!0,limit:!0,ascending:!0},j={.9:{supported:{actor:!0,instructor:!0,target:!0,object:!0,context:!0,authoritative:!0,sparse:!0}},"1.0.0":{supported:{agent:!0,activity:!0,related_activities:!0,related_agents:!0,format:!0,attachments:!0}}};j[.95]=j[.9],j["1.0.1"]=j["1.0.0"],j["1.0.2"]=j["1.0.0"],a.params.hasOwnProperty("target")&&(a.params.object=a.params.target);for(c in a.params)if(a.params.hasOwnProperty(c)&&"undefined"==typeof i[c]&&"undefined"==typeof j[this.version].supported[c])throw"Unrecognized query parameter configured: "+c;for(b=0;b<f.length;b+=1)"undefined"!=typeof a.params[f[b]]&&(d[f[b]]=JSON.stringify(a.params[f[b]].asVersion(this.version)));for(b=0;b<g.length;b+=1)"undefined"!=typeof a.params[g[b]]&&("undefined"==typeof a.params[g[b]].id?d[g[b]]=a.params[g[b]]:d[g[b]]=a.params[g[b]].id);for(b=0;b<h.length;b+=1)"undefined"!=typeof a.params[h[b]]&&null!==a.params[h[b]]&&(d[h[b]]=a.params[h[b]]);return e},_assignAttachmentContent:function(a,b){var c,d;for(c=0;c<a.length;c+=1)if(a[c].hasOwnProperty("attachments")&&null!==a[c].attachments)for(d=0;d<a[c].attachments.length;d+=1)b.hasOwnProperty(a[c].attachments[d].sha2)&&(a[c].attachments[d].content=b[a[c].attachments[d].sha2])},_parseMultipart:function(a,b){var c,d,f,g,h,i,j,k,l,m,n,o="--"+a,p=[],q=2;for(c=new Uint8Array(b),d=this.__uint8ToString(c),f=d.indexOf(o+"--"),g=d.indexOf(o);g!==-1;)h=d.indexOf(o,g+o.length),i=g+o.length+q,j=d.indexOf("\r\n\r\n",g),k=j+q+q,l=h-2,m=this._parseHeaders(this.__uint8ToString(new Uint8Array(b.slice(i,j)))),n=b.slice(k,l),0===p.length&&(n=e.Utils.stringFromArrayBuffer(n)),p.push({headers:m,body:n}),g=h===f?-1:h;return p},__uint8ToString:function(a){var b,c="",d=a.byteLength;for(b=0;b<d;b+=1)c+=String.fromCharCode(a[b]);return c},_parseHeaders:function(a){var b,c,d,e,f={};for(b=a.split("\n"),e=0;e<b.length;e+=1)d=b[e].split(":",2),null!==d[1]?(f[d[0]]=d[1].replace(/^\s+|\s+$/g,""),c=d[0]):"\t"===d[0].substring(0,1)&&(f[d[0]]=d[1].replace(/^\s+|\s+$/g,""));return f},moreStatements:function(a){this.log("moreStatements: "+a.url);var b,c,d,f,g;return a=a||{},f=e.Utils.parseURL(a.url,{allowRelative:!0}),g=e.Utils.getServerRoot(this.endpoint),0===f.path.indexOf("/statements")&&(f.path=this.endpoint.replace(g,"")+f.path,this.log("converting non-standard more URL to "+f.path)),0!==f.path.indexOf("/")&&(f.path="/"+f.path),b={method:"GET",url:g+f.path,params:f.params},"undefined"!=typeof a.callback&&(d=function(b,c){var d=c;null===b&&(d=e.StatementsResult.fromJSON(c.responseText)),a.callback(b,d)},b.callback=d),c=this.sendRequest(b),c.config=b,d||(c.statementsResult=null,null===c.err&&(c.statementsResult=e.StatementsResult.fromJSON(c.xhr.responseText))),c},retrieveState:function(a,b){this.log("retrieveState");var c,d,f,g={},h={},i=this;if(f=b.requestHeaders||{},g={stateId:a,activityId:b.activity.id},"0.9"===this.version?g.actor=JSON.stringify(b.agent.asVersion(this.version)):g.agent=JSON.stringify(b.agent.asVersion(this.version)),"undefined"!=typeof b.registration&&null!==b.registration&&("0.9"===this.version?g.registrationId=b.registration:g.registration=b.registration),h={url:"activities/state",method:"GET",params:g,ignore404:!0,headers:f},"undefined"!=typeof b.callback&&(d=function(c,d){var f=d;if(null===c)if(404===d.status)f=null;else if(f=new e.State({id:a,contents:d.responseText}),"undefined"!=typeof d.getResponseHeader&&null!==d.getResponseHeader("ETag")&&""!==d.getResponseHeader("ETag")?f.etag=d.getResponseHeader("ETag"):f.etag='"'+e.Utils.getSHA1String(d.responseText)+'"',"undefined"!=typeof d.contentType?f.contentType=d.contentType:"undefined"!=typeof d.getResponseHeader&&null!==d.getResponseHeader("Content-Type")&&""!==d.getResponseHeader("Content-Type")&&(f.contentType=d.getResponseHeader("Content-Type")),e.Utils.isApplicationJSON(f.contentType))try{f.contents=JSON.parse(f.contents)}catch(g){i.log("retrieveState - failed to deserialize JSON: "+g)}b.callback(c,f)},h.callback=d),c=this.sendRequest(h),!d&&(c.state=null,null===c.err&&404!==c.xhr.status&&(c.state=new e.State({id:a,contents:c.xhr.responseText}),"undefined"!=typeof c.xhr.getResponseHeader&&null!==c.xhr.getResponseHeader("ETag")&&""!==c.xhr.getResponseHeader("ETag")?c.state.etag=c.xhr.getResponseHeader("ETag"):c.state.etag='"'+e.Utils.getSHA1String(c.xhr.responseText)+'"',"undefined"!=typeof c.xhr.contentType?c.state.contentType=c.xhr.contentType:"undefined"!=typeof c.xhr.getResponseHeader&&null!==c.xhr.getResponseHeader("Content-Type")&&""!==c.xhr.getResponseHeader("Content-Type")&&(c.state.contentType=c.xhr.getResponseHeader("Content-Type")),e.Utils.isApplicationJSON(c.state.contentType))))try{c.state.contents=JSON.parse(c.state.contents)}catch(j){this.log("retrieveState - failed to deserialize JSON: "+j);
16
- }return c},retrieveStateIds:function(a){this.log("retrieveStateIds");var b,c,d,e,f={};if(a=a||{},c=a.requestHeaders||{},f.activityId=a.activity.id,"0.9"===this.version?f.actor=JSON.stringify(a.agent.asVersion(this.version)):f.agent=JSON.stringify(a.agent.asVersion(this.version)),"undefined"!=typeof a.registration&&null!==a.registration&&("0.9"===this.version?f.registrationId=a.registration:f.registration=a.registration),b={url:"activities/state",method:"GET",params:f,headers:c,ignore404:!0},"undefined"!=typeof a.callback&&(e=function(b,c){var d=c;if(null!==b)return void a.callback(b,d);if(404===c.status)d=[];else try{d=JSON.parse(c.responseText)}catch(e){b="Response JSON parse error: "+e}a.callback(b,d)},b.callback=e),"undefined"!=typeof a.since&&(b.params.since=a.since),d=this.sendRequest(b),!e){if(d.profileIds=null,null!==d.err)return d;if(404===d.xhr.status)d.profileIds=[];else try{d.profileIds=JSON.parse(d.xhr.responseText)}catch(g){d.err="retrieveStateIds - JSON parse error: "+g}}return d},saveState:function(a,b,c){this.log("saveState");var d,f,g;return g=c.requestHeaders||{},"undefined"==typeof c.contentType&&(c.contentType="application/octet-stream"),g["Content-Type"]=c.contentType,"object"==typeof b&&e.Utils.isApplicationJSON(c.contentType)&&(b=JSON.stringify(b)),"undefined"!=typeof c.method&&"POST"===c.method||(c.method="PUT"),d={stateId:a,activityId:c.activity.id},"0.9"===this.version?d.actor=JSON.stringify(c.agent.asVersion(this.version)):d.agent=JSON.stringify(c.agent.asVersion(this.version)),"undefined"!=typeof c.registration&&null!==c.registration&&("0.9"===this.version?d.registrationId=c.registration:d.registration=c.registration),f={url:"activities/state",method:c.method,params:d,data:b,headers:g},"undefined"!=typeof c.callback&&(f.callback=c.callback),"undefined"!=typeof c.lastSHA1&&null!==c.lastSHA1&&(f.headers["If-Match"]=c.lastSHA1),this.sendRequest(f)},dropState:function(a,b){this.log("dropState");var c,d,e;return e=b.requestHeaders||{},c={activityId:b.activity.id},"0.9"===this.version?c.actor=JSON.stringify(b.agent.asVersion(this.version)):c.agent=JSON.stringify(b.agent.asVersion(this.version)),null!==a&&(c.stateId=a),"undefined"!=typeof b.registration&&null!==b.registration&&("0.9"===this.version?c.registrationId=b.registration:c.registration=b.registration),d={url:"activities/state",method:"DELETE",params:c,headers:e},"undefined"!=typeof b.callback&&(d.callback=b.callback),this.sendRequest(d)},retrieveActivity:function(a,b){this.log("retrieveActivity");var c,d,f,g={};return f=b.requestHeaders||{},g={url:"activities",method:"GET",params:{activityId:a},ignore404:!0,headers:f},"undefined"!=typeof b.callback&&(d=function(c,d){var f=d;null===c&&(f=404===d.status?new e.Activity({id:a}):e.Activity.fromJSON(d.responseText)),b.callback(c,f)},g.callback=d),c=this.sendRequest(g),d||(c.activity=null,null===c.err&&(404===c.xhr.status?c.activity=new e.Activity({id:a}):c.activity=e.Activity.fromJSON(c.xhr.responseText))),c},retrieveActivityProfile:function(a,b){this.log("retrieveActivityProfile");var c,d,f,g={},h=this;if(f=b.requestHeaders||{},g={url:"activities/profile",method:"GET",params:{profileId:a,activityId:b.activity.id},ignore404:!0,headers:f},"undefined"!=typeof b.callback&&(d=function(c,d){var f=d;if(null===c)if(404===d.status)f=null;else if(f=new e.ActivityProfile({id:a,activity:b.activity,contents:d.responseText}),"undefined"!=typeof d.getResponseHeader&&null!==d.getResponseHeader("ETag")&&""!==d.getResponseHeader("ETag")?f.etag=d.getResponseHeader("ETag"):f.etag='"'+e.Utils.getSHA1String(d.responseText)+'"',"undefined"!=typeof d.contentType?f.contentType=d.contentType:"undefined"!=typeof d.getResponseHeader&&null!==d.getResponseHeader("Content-Type")&&""!==d.getResponseHeader("Content-Type")&&(f.contentType=d.getResponseHeader("Content-Type")),e.Utils.isApplicationJSON(f.contentType))try{f.contents=JSON.parse(f.contents)}catch(g){h.log("retrieveActivityProfile - failed to deserialize JSON: "+g)}b.callback(c,f)},g.callback=d),c=this.sendRequest(g),!d&&(c.profile=null,null===c.err&&404!==c.xhr.status&&(c.profile=new e.ActivityProfile({id:a,activity:b.activity,contents:c.xhr.responseText}),"undefined"!=typeof c.xhr.getResponseHeader&&null!==c.xhr.getResponseHeader("ETag")&&""!==c.xhr.getResponseHeader("ETag")?c.profile.etag=c.xhr.getResponseHeader("ETag"):c.profile.etag='"'+e.Utils.getSHA1String(c.xhr.responseText)+'"',"undefined"!=typeof c.xhr.contentType?c.profile.contentType=c.xhr.contentType:"undefined"!=typeof c.xhr.getResponseHeader&&null!==c.xhr.getResponseHeader("Content-Type")&&""!==c.xhr.getResponseHeader("Content-Type")&&(c.profile.contentType=c.xhr.getResponseHeader("Content-Type")),e.Utils.isApplicationJSON(c.profile.contentType))))try{c.profile.contents=JSON.parse(c.profile.contents)}catch(i){this.log("retrieveActivityProfile - failed to deserialize JSON: "+i)}return c},retrieveActivityProfileIds:function(a){this.log("retrieveActivityProfileIds");var b,c,d,e;if(a=a||{},c=a.requestHeaders||{},b={url:"activities/profile",method:"GET",params:{activityId:a.activity.id},headers:c,ignore404:!0},"undefined"!=typeof a.callback&&(e=function(b,c){var d=c;if(null!==b)return void a.callback(b,d);if(404===c.status)d=[];else try{d=JSON.parse(c.responseText)}catch(e){b="Response JSON parse error: "+e}a.callback(b,d)},b.callback=e),"undefined"!=typeof a.since&&(b.params.since=a.since),d=this.sendRequest(b),!e){if(d.profileIds=null,null!==d.err)return d;if(404===d.xhr.status)d.profileIds=[];else try{d.profileIds=JSON.parse(d.xhr.responseText)}catch(f){d.err="retrieveActivityProfileIds - JSON parse error: "+f}}return d},saveActivityProfile:function(a,b,c){this.log("saveActivityProfile");var d,f;return f=c.requestHeaders||{},"undefined"==typeof c.contentType&&(c.contentType="application/octet-stream"),f["Content-Type"]=c.contentType,"undefined"!=typeof c.method&&"POST"===c.method||(c.method="PUT"),"object"==typeof b&&e.Utils.isApplicationJSON(c.contentType)&&(b=JSON.stringify(b)),d={url:"activities/profile",method:c.method,params:{profileId:a,activityId:c.activity.id},data:b,headers:f},"undefined"!=typeof c.callback&&(d.callback=c.callback),"undefined"!=typeof c.lastSHA1&&null!==c.lastSHA1?d.headers["If-Match"]=c.lastSHA1:d.headers["If-None-Match"]="*",this.sendRequest(d)},dropActivityProfile:function(a,b){this.log("dropActivityProfile");var c,d,e;return e=b.requestHeaders||{},c={profileId:a,activityId:b.activity.id},d={url:"activities/profile",method:"DELETE",params:c,headers:e},"undefined"!=typeof b.callback&&(d.callback=b.callback),this.sendRequest(d)},retrieveAgentProfile:function(a,b){this.log("retrieveAgentProfile");var c,d,f,g={},h=this;if(f=b.requestHeaders||{},g={method:"GET",params:{profileId:a},ignore404:!0,headers:f},"0.9"===this.version?(g.url="actors/profile",g.params.actor=JSON.stringify(b.agent.asVersion(this.version))):(g.url="agents/profile",g.params.agent=JSON.stringify(b.agent.asVersion(this.version))),"undefined"!=typeof b.callback&&(d=function(c,d){var f=d;if(null===c)if(404===d.status)f=null;else if(f=new e.AgentProfile({id:a,agent:b.agent,contents:d.responseText}),"undefined"!=typeof d.getResponseHeader&&null!==d.getResponseHeader("ETag")&&""!==d.getResponseHeader("ETag")?f.etag=d.getResponseHeader("ETag"):f.etag='"'+e.Utils.getSHA1String(d.responseText)+'"',"undefined"!=typeof d.contentType?f.contentType=d.contentType:"undefined"!=typeof d.getResponseHeader&&null!==d.getResponseHeader("Content-Type")&&""!==d.getResponseHeader("Content-Type")&&(f.contentType=d.getResponseHeader("Content-Type")),e.Utils.isApplicationJSON(f.contentType))try{f.contents=JSON.parse(f.contents)}catch(g){h.log("retrieveAgentProfile - failed to deserialize JSON: "+g)}b.callback(c,f)},g.callback=d),c=this.sendRequest(g),!d&&(c.profile=null,null===c.err&&404!==c.xhr.status&&(c.profile=new e.AgentProfile({id:a,agent:b.agent,contents:c.xhr.responseText}),"undefined"!=typeof c.xhr.getResponseHeader&&null!==c.xhr.getResponseHeader("ETag")&&""!==c.xhr.getResponseHeader("ETag")?c.profile.etag=c.xhr.getResponseHeader("ETag"):c.profile.etag='"'+e.Utils.getSHA1String(c.xhr.responseText)+'"',"undefined"!=typeof c.xhr.contentType?c.profile.contentType=c.xhr.contentType:"undefined"!=typeof c.xhr.getResponseHeader&&null!==c.xhr.getResponseHeader("Content-Type")&&""!==c.xhr.getResponseHeader("Content-Type")&&(c.profile.contentType=c.xhr.getResponseHeader("Content-Type")),e.Utils.isApplicationJSON(c.profile.contentType))))try{c.profile.contents=JSON.parse(c.profile.contents)}catch(i){this.log("retrieveAgentProfile - failed to deserialize JSON: "+i)}return c},retrieveAgentProfileIds:function(a){this.log("retrieveAgentProfileIds");var b,c,d,e,f={};if(a=a||{},c=a.requestHeaders||{},b={method:"GET",params:f,headers:c,ignore404:!0},"0.9"===this.version?(b.url="actors/profile",f.actor=JSON.stringify(a.agent.asVersion(this.version))):(b.url="agents/profile",f.agent=JSON.stringify(a.agent.asVersion(this.version))),"undefined"!=typeof a.callback&&(e=function(b,c){var d=c;if(null!==b)return void a.callback(b,d);if(404===c.status)d=[];else try{d=JSON.parse(c.responseText)}catch(e){b="Response JSON parse error: "+e}a.callback(b,d)},b.callback=e),"undefined"!=typeof a.since&&(b.params.since=a.since),d=this.sendRequest(b),!e){if(d.profileIds=null,null!==d.err)return d;if(404===d.xhr.status)d.profileIds=[];else try{d.profileIds=JSON.parse(d.xhr.responseText)}catch(g){d.err="retrieveAgentProfileIds - JSON parse error: "+g}}return d},saveAgentProfile:function(a,b,c){this.log("saveAgentProfile");var d,f;return f=c.requestHeaders||{},"undefined"==typeof c.contentType&&(c.contentType="application/octet-stream"),f["Content-Type"]=c.contentType,"undefined"!=typeof c.method&&"POST"===c.method||(c.method="PUT"),"object"==typeof b&&e.Utils.isApplicationJSON(c.contentType)&&(b=JSON.stringify(b)),d={method:c.method,params:{profileId:a},data:b,headers:f},"0.9"===this.version?(d.url="actors/profile",d.params.actor=JSON.stringify(c.agent.asVersion(this.version))):(d.url="agents/profile",d.params.agent=JSON.stringify(c.agent.asVersion(this.version))),"undefined"!=typeof c.callback&&(d.callback=c.callback),"undefined"!=typeof c.lastSHA1&&null!==c.lastSHA1?d.headers["If-Match"]=c.lastSHA1:d.headers["If-None-Match"]="*",this.sendRequest(d)},dropAgentProfile:function(a,b){this.log("dropAgentProfile");var c,d,e;return e=b.requestHeaders||{},c={profileId:a},d={method:"DELETE",params:c,headers:e},"0.9"===this.version?(d.url="actors/profile",c.actor=JSON.stringify(b.agent.asVersion(this.version))):(d.url="agents/profile",c.agent=JSON.stringify(b.agent.asVersion(this.version))),"undefined"!=typeof b.callback&&(d.callback=b.callback),this.sendRequest(d)}},a.syncEnabled=null}(),function(){"use strict";var a=e.AgentAccount=function(a){this.log("constructor"),this.homePage=null,this.name=null,this.init(a)};a.prototype={LOG_SRC:"AgentAccount",log:e.prototype.log,init:function(a){this.log("init");var b,c=["name","homePage"];for(a=a||{},"undefined"!=typeof a.accountServiceHomePage&&(a.homePage=a.accountServiceHomePage),"undefined"!=typeof a.accountName&&(a.name=a.accountName),b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]])},toString:function(){this.log("toString");var a="";return null!==this.name||null!==this.homePage?(a+=null!==this.name?this.name:"-",a+=":",a+=null!==this.homePage?this.homePage:"-"):a="AgentAccount: unidentified",a},asVersion:function(a){this.log("asVersion: "+a);var b={};return a=a||e.versions()[0],"0.9"===a?(b.accountName=this.name,b.accountServiceHomePage=this.homePage):(b.name=this.name,b.homePage=this.homePage),b}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.Agent=function(a){this.log("constructor"),this.name=null,this.mbox=null,this.mbox_sha1sum=null,this.openid=null,this.account=null,this.degraded=!1,this.init(a)};a.prototype={objectType:"Agent",LOG_SRC:"Agent",log:e.prototype.log,init:function(a){this.log("init");var b,c,d=["name","mbox","mbox_sha1sum","openid"];for(a=a||{},"undefined"!=typeof a.lastName||"undefined"!=typeof a.firstName?(a.name="","undefined"!=typeof a.firstName&&a.firstName.length>0&&(a.name=a.firstName[0],a.firstName.length>1&&(this.degraded=!0)),""!==a.name&&(a.name+=" "),"undefined"!=typeof a.lastName&&a.lastName.length>0&&(a.name+=a.lastName[0],a.lastName.length>1&&(this.degraded=!0))):"undefined"==typeof a.familyName&&"undefined"==typeof a.givenName||(a.name="","undefined"!=typeof a.givenName&&a.givenName.length>0&&(a.name=a.givenName[0],a.givenName.length>1&&(this.degraded=!0)),""!==a.name&&(a.name+=" "),"undefined"!=typeof a.familyName&&a.familyName.length>0&&(a.name+=a.familyName[0],a.familyName.length>1&&(this.degraded=!0))),"object"==typeof a.name&&null!==a.name&&(a.name.length>1&&(this.degraded=!0),a.name=a.name[0]),"object"==typeof a.mbox&&null!==a.mbox&&(a.mbox.length>1&&(this.degraded=!0),a.mbox=a.mbox[0]),"object"==typeof a.mbox_sha1sum&&null!==a.mbox_sha1sum&&(a.mbox_sha1sum.length>1&&(this.degraded=!0),a.mbox_sha1sum=a.mbox_sha1sum[0]),"object"==typeof a.openid&&null!==a.openid&&(a.openid.length>1&&(this.degraded=!0),a.openid=a.openid[0]),"object"==typeof a.account&&null!==a.account&&"undefined"==typeof a.account.homePage&&"undefined"==typeof a.account.name&&(0===a.account.length?delete a.account:(a.account.length>1&&(this.degraded=!0),a.account=a.account[0])),a.hasOwnProperty("account")&&(a.account instanceof e.AgentAccount?this.account=a.account:this.account=new e.AgentAccount(a.account)),b=0;b<d.length;b+=1)a.hasOwnProperty(d[b])&&null!==a[d[b]]&&(c=a[d[b]],"mbox"===d[b]&&c.indexOf("mailto:")===-1&&(c="mailto:"+c),this[d[b]]=c)},toString:function(){return this.log("toString"),null!==this.name?this.name:null!==this.mbox?this.mbox.replace("mailto:",""):null!==this.mbox_sha1sum?this.mbox_sha1sum:null!==this.openid?this.openid:null!==this.account?this.account.toString():this.objectType+": unidentified"},asVersion:function(a){this.log("asVersion: "+a);var b={objectType:this.objectType};return a=a||e.versions()[0],"0.9"===a?(null!==this.mbox?b.mbox=[this.mbox]:null!==this.mbox_sha1sum?b.mbox_sha1sum=[this.mbox_sha1sum]:null!==this.openid?b.openid=[this.openid]:null!==this.account&&(b.account=[this.account.asVersion(a)]),null!==this.name&&(b.name=[this.name])):(null!==this.mbox?b.mbox=this.mbox:null!==this.mbox_sha1sum?b.mbox_sha1sum=this.mbox_sha1sum:null!==this.openid?b.openid=this.openid:null!==this.account&&(b.account=this.account.asVersion(a)),null!==this.name&&(b.name=this.name)),b}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.Group=function(a){this.log("constructor"),this.name=null,this.mbox=null,this.mbox_sha1sum=null,this.openid=null,this.account=null,this.member=[],this.init(a)};a.prototype={objectType:"Group",LOG_SRC:"Group",log:e.prototype.log,init:function(a){this.log("init");var b;if(a=a||{},e.Agent.prototype.init.call(this,a),"undefined"!=typeof a.member)for(b=0;b<a.member.length;b+=1)a.member[b]instanceof e.Agent?this.member.push(a.member[b]):this.member.push(new e.Agent(a.member[b]))},toString:function(a){this.log("toString");var b=e.Agent.prototype.toString.call(this,a);return b!==this.objectType+": unidentified"&&(b=this.objectType+": "+b),b},asVersion:function(a){this.log("asVersion: "+a);var b,c;if(a=a||e.versions()[0],b=e.Agent.prototype.asVersion.call(this,a),this.member.length>0)for(b.member=[],c=0;c<this.member.length;c+=1)b.member.push(this.member[c].asVersion(a));return b}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a={"http://adlnet.gov/expapi/verbs/experienced":"experienced","http://adlnet.gov/expapi/verbs/attended":"attended","http://adlnet.gov/expapi/verbs/attempted":"attempted","http://adlnet.gov/expapi/verbs/completed":"completed","http://adlnet.gov/expapi/verbs/passed":"passed","http://adlnet.gov/expapi/verbs/failed":"failed","http://adlnet.gov/expapi/verbs/answered":"answered","http://adlnet.gov/expapi/verbs/interacted":"interacted","http://adlnet.gov/expapi/verbs/imported":"imported","http://adlnet.gov/expapi/verbs/created":"created","http://adlnet.gov/expapi/verbs/shared":"shared","http://adlnet.gov/expapi/verbs/voided":"voided"},b=e.Verb=function(a){this.log("constructor"),this.id=null,this.display=null,this.init(a)};b.prototype={LOG_SRC:"Verb",log:e.prototype.log,init:function(b){this.log("init");var c,d,e=["id","display"];if("string"==typeof b){this.id=b,this.display={und:this.id};for(d in a)if(a.hasOwnProperty(d)&&a[d]===b){this.id=d;break}}else{for(b=b||{},c=0;c<e.length;c+=1)b.hasOwnProperty(e[c])&&null!==b[e[c]]&&(this[e[c]]=b[e[c]]);null===this.display&&"undefined"!=typeof a[this.id]&&(this.display={und:a[this.id]})}},toString:function(a){return this.log("toString"),null!==this.display?this.getLangDictionaryValue("display",a):this.id},asVersion:function(b){this.log("asVersion");var c;return b=b||e.versions()[0],"0.9"===b?c=a[this.id]:(c={id:this.id},null!==this.display&&(c.display=this.display)),c},getLangDictionaryValue:e.Utils.getLangDictionaryValue},b.fromJSON=function(a){b.prototype.log("fromJSON");var c=JSON.parse(a);return new b(c)}}(),function(){"use strict";var a=e.Result=function(a){this.log("constructor"),this.score=null,this.success=null,this.completion=null,this.duration=null,this.response=null,this.extensions=null,this.init(a)};a.prototype={LOG_SRC:"Result",log:e.prototype.log,init:function(a){this.log("init");var b,c=["completion","duration","extensions","response","success"];for(a=a||{},a.hasOwnProperty("score")&&null!==a.score&&(a.score instanceof e.Score?this.score=a.score:this.score=new e.Score(a.score)),b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]]);"Completed"===this.completion&&(this.completion=!0)},asVersion:function(a){this.log("asVersion");var b,c={},d=["success","duration","response","extensions"],f=["score"];for(a=a||e.versions()[0],b=0;b<d.length;b+=1)null!==this[d[b]]&&(c[d[b]]=this[d[b]]);for(b=0;b<f.length;b+=1)null!==this[f[b]]&&(c[f[b]]=this[f[b]].asVersion(a));return null!==this.completion&&("0.9"===a?this.completion&&(c.completion="Completed"):c.completion=this.completion),c}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.Score=function(a){this.log("constructor"),this.scaled=null,this.raw=null,this.min=null,this.max=null,this.init(a)};a.prototype={LOG_SRC:"Score",log:e.prototype.log,init:function(a){this.log("init");var b,c=["scaled","raw","min","max"];for(a=a||{},b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]])},asVersion:function(a){this.log("asVersion");var b,c={},d=["scaled","raw","min","max"];for(a=a||e.versions()[0],b=0;b<d.length;b+=1)null!==this[d[b]]&&(c[d[b]]=this[d[b]]);return c}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.InteractionComponent=function(a){this.log("constructor"),this.id=null,this.description=null,this.init(a)};a.prototype={LOG_SRC:"InteractionComponent",log:e.prototype.log,init:function(a){this.log("init");var b,c=["id","description"];for(a=a||{},b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]])},asVersion:function(a){this.log("asVersion");var b,c,d={id:this.id},f=["description"];for(a=a||e.versions()[0],b=0;b<f.length;b+=1)c=f[b],null!==this[c]&&(d[c]=this[c]);return d},getLangDictionaryValue:e.Utils.getLangDictionaryValue},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a={"http://adlnet.gov/expapi/activities/course":"course","http://adlnet.gov/expapi/activities/module":"module","http://adlnet.gov/expapi/activities/meeting":"meeting","http://adlnet.gov/expapi/activities/media":"media","http://adlnet.gov/expapi/activities/performance":"performance","http://adlnet.gov/expapi/activities/simulation":"simulation","http://adlnet.gov/expapi/activities/assessment":"assessment","http://adlnet.gov/expapi/activities/interaction":"interaction","http://adlnet.gov/expapi/activities/cmi.interaction":"cmi.interaction","http://adlnet.gov/expapi/activities/question":"question","http://adlnet.gov/expapi/activities/objective":"objective","http://adlnet.gov/expapi/activities/link":"link"},b=e.ActivityDefinition=function(a){this.log("constructor"),this.name=null,this.description=null,this.type=null,this.moreInfo=null,this.extensions=null,this.interactionType=null,this.correctResponsesPattern=null,this.choices=null,this.scale=null,this.source=null,this.target=null,this.steps=null,this.init(a)};b.prototype={LOG_SRC:"ActivityDefinition",log:e.prototype.log,init:function(b){this.log("init");var c,d,f,g=["name","description","moreInfo","extensions","correctResponsesPattern"],h=[];if(b=b||{},b.hasOwnProperty("type")&&null!==b.type){for(f in a)a.hasOwnProperty(f)&&a[f]===b.type&&(b.type=a[f]);this.type=b.type}if(b.hasOwnProperty("interactionType")&&null!==b.interactionType&&(this.interactionType=b.interactionType,"choice"===b.interactionType||"sequencing"===b.interactionType?h.push("choices"):"likert"===b.interactionType?h.push("scale"):"matching"===b.interactionType?(h.push("source"),h.push("target")):"performance"===b.interactionType&&h.push("steps"),h.length>0))for(c=0;c<h.length;c+=1)if(f=h[c],b.hasOwnProperty(f)&&null!==b[f])for(this[f]=[],d=0;d<b[f].length;d+=1)b[f][d]instanceof e.InteractionComponent?this[f].push(b[f][d]):this[f].push(new e.InteractionComponent(b[f][d]));for(c=0;c<g.length;c+=1)b.hasOwnProperty(g[c])&&null!==b[g[c]]&&(this[g[c]]=b[g[c]])},toString:function(a){return this.log("toString"),null!==this.name?this.getLangDictionaryValue("name",a):null!==this.description?this.getLangDictionaryValue("description",a):""},asVersion:function(b){this.log("asVersion");var c,d,f,g={},h=["name","description","interactionType","correctResponsesPattern","extensions"],i=["choices","scale","source","target","steps"];for(b=b||e.versions()[0],null!==this.type&&("0.9"===b?g.type=a[this.type]:g.type=this.type),c=0;c<h.length;c+=1)f=h[c],null!==this[f]&&(g[f]=this[f]);for(c=0;c<i.length;c+=1)if(f=i[c],null!==this[f])for(g[f]=[],d=0;d<this[f].length;d+=1)g[f].push(this[f][d].asVersion(b));return 0!==b.indexOf("0.9")&&null!==this.moreInfo&&(g.moreInfo=this.moreInfo),g},getLangDictionaryValue:e.Utils.getLangDictionaryValue},b.fromJSON=function(a){b.prototype.log("fromJSON");var c=JSON.parse(a);return new b(c)}}(),function(){"use strict";var a=e.Activity=function(a){this.log("constructor"),this.objectType="Activity",this.id=null,this.definition=null,this.init(a)};a.prototype={LOG_SRC:"Activity",log:e.prototype.log,init:function(a){this.log("init");var b,c=["id"];for(a=a||{},a.hasOwnProperty("definition")&&(a.definition instanceof e.ActivityDefinition?this.definition=a.definition:this.definition=new e.ActivityDefinition(a.definition)),b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]])},toString:function(a){this.log("toString");var b="";return null!==this.definition&&(b=this.definition.toString(a),""!==b)?b:null!==this.id?this.id:"Activity: unidentified"},asVersion:function(a){this.log("asVersion");var b={id:this.id,objectType:this.objectType};return a=a||e.versions()[0],null!==this.definition&&(b.definition=this.definition.asVersion(a)),b}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.ContextActivities=function(a){this.log("constructor"),this.category=null,this.parent=null,this.grouping=null,this.other=null,this.init(a)};a.prototype={LOG_SRC:"ContextActivities",log:e.prototype.log,init:function(a){this.log("init");var b,c,d,e,f=["category","parent","grouping","other"];for(a=a||{},b=0;b<f.length;b+=1)if(d=f[b],a.hasOwnProperty(d)&&null!==a[d])if("[object Array]"===Object.prototype.toString.call(a[d]))for(c=0;c<a[d].length;c+=1)this.add(d,a[d][c]);else e=a[d],this.add(d,e)},add:function(a,b){if("category"===a||"parent"===a||"grouping"===a||"other"===a)return null===this[a]&&(this[a]=[]),b instanceof e.Activity||(b="string"==typeof b?{id:b}:b,b=new e.Activity(b)),this[a].push(b),this[a].length-1},asVersion:function(a){this.log("asVersion");var b,c,d={},f=["parent","grouping","other"];for(a=a||e.versions()[0],b=0;b<f.length;b+=1)if(null!==this[f[b]]&&this[f[b]].length>0)if("0.9"===a||"0.95"===a)this[f[b]].length>1&&this.log("[warning] version does not support multiple values in: "+f[b]),d[f[b]]=this[f[b]][0].asVersion(a);else for(d[f[b]]=[],c=0;c<this[f[b]].length;c+=1)d[f[b]].push(this[f[b]][c].asVersion(a));if(null!==this.category&&this.category.length>0){if("0.9"===a||"0.95"===a)throw this.log("[error] version does not support the 'category' property: "+a),new Error(a+" does not support the 'category' property");for(d.category=[],b=0;b<this.category.length;b+=1)d.category.push(this.category[b].asVersion(a))}return d}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.Context=function(a){this.log("constructor"),this.registration=null,this.instructor=null,this.team=null,this.contextActivities=null,this.revision=null,this.platform=null,this.language=null,this.statement=null,this.extensions=null,this.init(a)};a.prototype={LOG_SRC:"Context",log:e.prototype.log,init:function(a){this.log("init");var b,c,d,f=["registration","revision","platform","language","extensions"],g=["instructor","team"];for(a=a||{},b=0;b<f.length;b+=1)c=f[b],a.hasOwnProperty(c)&&null!==a[c]&&(this[c]=a[c]);for(b=0;b<g.length;b+=1)c=g[b],a.hasOwnProperty(c)&&null!==a[c]&&(d=a[c],"undefined"!=typeof d.objectType&&"Person"!==d.objectType||(d.objectType="Agent"),"Agent"!==d.objectType||d instanceof e.Agent?"Group"!==d.objectType||d instanceof e.Group||(d=new e.Group(d)):d=new e.Agent(d),this[c]=d);a.hasOwnProperty("contextActivities")&&null!==a.contextActivities&&(a.contextActivities instanceof e.ContextActivities?this.contextActivities=a.contextActivities:this.contextActivities=new e.ContextActivities(a.contextActivities)),a.hasOwnProperty("statement")&&null!==a.statement&&(a.statement instanceof e.StatementRef?this.statement=a.statement:a.statement instanceof e.SubStatement?this.statement=a.statement:"StatementRef"===a.statement.objectType?this.statement=new e.StatementRef(a.statement):"SubStatement"===a.statement.objectType?this.statement=new e.SubStatement(a.statement):this.log("Unable to parse statement.context.statement property."))},asVersion:function(a){this.log("asVersion");var b,c={},d=["registration","revision","platform","language","extensions"],f=["instructor","team","contextActivities","statement"];if(a=a||e.versions()[0],this.statement instanceof e.SubStatement&&"0.9"!==a&&"0.95"!==a)throw this.log("[error] version does not support SubStatements in the 'statement' property: "+a),new Error(a+" does not support SubStatements in the 'statement' property");for(b=0;b<d.length;b+=1)null!==this[d[b]]&&(c[d[b]]=this[d[b]]);for(b=0;b<f.length;b+=1)null!==this[f[b]]&&(c[f[b]]=this[f[b]].asVersion(a));return c}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.StatementRef=function(a){this.log("constructor"),this.id=null,this.init(a)};a.prototype={objectType:"StatementRef",LOG_SRC:"StatementRef",log:e.prototype.log,init:function(a){this.log("init");var b,c=["id"];for(a=a||{},b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]])},toString:function(){return this.log("toString"),this.id},asVersion:function(a){this.log("asVersion");var b={objectType:this.objectType,id:this.id};return"0.9"===a&&(b.objectType="Statement"),b}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.SubStatement=function(a){this.log("constructor"),this.actor=null,this.verb=null,this.target=null,this.result=null,this.context=null,this.timestamp=null,this.init(a)};a.prototype={objectType:"SubStatement",LOG_SRC:"SubStatement",log:e.prototype.log,init:function(a){this.log("init");var b,c=["timestamp"];for(a=a||{},a.hasOwnProperty("object")&&(a.target=a.object),a.hasOwnProperty("actor")&&("undefined"!=typeof a.actor.objectType&&"Person"!==a.actor.objectType||(a.actor.objectType="Agent"),"Agent"===a.actor.objectType?a.actor instanceof e.Agent?this.actor=a.actor:this.actor=new e.Agent(a.actor):"Group"===a.actor.objectType&&(a.actor instanceof e.Group?this.actor=a.actor:this.actor=new e.Group(a.actor))),a.hasOwnProperty("verb")&&(a.verb instanceof e.Verb?this.verb=a.verb:this.verb=new e.Verb(a.verb)),a.hasOwnProperty("target")&&(a.target instanceof e.Activity||a.target instanceof e.Agent||a.target instanceof e.Group||a.target instanceof e.SubStatement||a.target instanceof e.StatementRef?this.target=a.target:("undefined"==typeof a.target.objectType&&(a.target.objectType="Activity"),"Activity"===a.target.objectType?this.target=new e.Activity(a.target):"Agent"===a.target.objectType?this.target=new e.Agent(a.target):"Group"===a.target.objectType?this.target=new e.Group(a.target):"SubStatement"===a.target.objectType?this.target=new e.SubStatement(a.target):"StatementRef"===a.target.objectType?this.target=new e.StatementRef(a.target):this.log("Unrecognized target type: "+a.target.objectType))),a.hasOwnProperty("result")&&(a.result instanceof e.Result?this.result=a.result:this.result=new e.Result(a.result)),a.hasOwnProperty("context")&&(a.context instanceof e.Context?this.context=a.context:this.context=new e.Context(a.context)),b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]])},toString:function(a){return this.log("toString"),(null!==this.actor?this.actor.toString(a):"")+" "+(null!==this.verb?this.verb.toString(a):"")+" "+(null!==this.target?this.target.toString(a):"")},asVersion:function(a){this.log("asVersion");var b,c,d=["timestamp"],f=["actor","verb","result","context"];for(b={objectType:this.objectType},a=a||e.versions()[0],c=0;c<d.length;c+=1)null!==this[d[c]]&&(b[d[c]]=this[d[c]]);for(c=0;c<f.length;c+=1)null!==this[f[c]]&&(b[f[c]]=this[f[c]].asVersion(a));return null!==this.target&&(b.object=this.target.asVersion(a)),"0.9"===a&&(b.objectType="Statement"),b}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.Statement=function(a,b){this.log("constructor"),b="number"==typeof b?{storeOriginal:b}:b||{},"undefined"==typeof b.storeOriginal&&(b.storeOriginal=null),"undefined"==typeof b.doStamp&&(b.doStamp=!0),this.id=null,this.actor=null,this.verb=null,this.target=null,this.result=null,this.context=null,this.timestamp=null,this.stored=null,this.authority=null,this.attachments=null,this.version=null,this.degraded=!1,this.voided=null,this.inProgress=null,this.originalJSON=null,this.init(a,b)};a.prototype={LOG_SRC:"Statement",log:e.prototype.log,init:function(a,b){this.log("init");var c,d=["id","stored","timestamp","version","inProgress","voided"];if(a=a||{},b.storeOriginal&&(this.originalJSON=JSON.stringify(a,null,b.storeOriginal)),a.hasOwnProperty("object")&&(a.target=a.object),a.hasOwnProperty("actor")&&("undefined"!=typeof a.actor.objectType&&"Person"!==a.actor.objectType||(a.actor.objectType="Agent"),"Agent"===a.actor.objectType?a.actor instanceof e.Agent?this.actor=a.actor:this.actor=new e.Agent(a.actor):"Group"===a.actor.objectType&&(a.actor instanceof e.Group?this.actor=a.actor:this.actor=new e.Group(a.actor))),a.hasOwnProperty("authority")&&("undefined"!=typeof a.authority.objectType&&"Person"!==a.authority.objectType||(a.authority.objectType="Agent"),"Agent"===a.authority.objectType?a.authority instanceof e.Agent?this.authority=a.authority:this.authority=new e.Agent(a.authority):"Group"===a.authority.objectType&&(a.actor instanceof e.Group?this.authority=a.authority:this.authority=new e.Group(a.authority))),
17
- a.hasOwnProperty("verb")&&(a.verb instanceof e.Verb?this.verb=a.verb:this.verb=new e.Verb(a.verb)),a.hasOwnProperty("target")&&(a.target instanceof e.Activity||a.target instanceof e.Agent||a.target instanceof e.Group||a.target instanceof e.SubStatement||a.target instanceof e.StatementRef?this.target=a.target:("undefined"==typeof a.target.objectType&&(a.target.objectType="Activity"),"Activity"===a.target.objectType?this.target=new e.Activity(a.target):"Agent"===a.target.objectType?this.target=new e.Agent(a.target):"Group"===a.target.objectType?this.target=new e.Group(a.target):"SubStatement"===a.target.objectType?this.target=new e.SubStatement(a.target):"StatementRef"===a.target.objectType?this.target=new e.StatementRef(a.target):this.log("Unrecognized target type: "+a.target.objectType))),a.hasOwnProperty("result")&&(a.result instanceof e.Result?this.result=a.result:this.result=new e.Result(a.result)),a.hasOwnProperty("context")&&(a.context instanceof e.Context?this.context=a.context:this.context=new e.Context(a.context)),a.hasOwnProperty("attachments")&&null!==a.attachments)for(this.attachments=[],c=0;c<a.attachments.length;c+=1)a.attachments[c]instanceof e.Attachment?this.attachments.push(a.attachments[c]):this.attachments.push(new e.Attachment(a.attachments[c]));for(c=0;c<d.length;c+=1)a.hasOwnProperty(d[c])&&null!==a[d[c]]&&(this[d[c]]=a[d[c]]);b.doStamp&&this.stamp()},toString:function(a){return this.log("toString"),(null!==this.actor?this.actor.toString(a):"")+" "+(null!==this.verb?this.verb.toString(a):"")+" "+(null!==this.target?this.target.toString(a):"")},asVersion:function(a){this.log("asVersion");var b,c={},d=["id","timestamp"],f=["actor","verb","result","context","authority"];for(a=a||e.versions()[0],b=0;b<d.length;b+=1)null!==this[d[b]]&&(c[d[b]]=this[d[b]]);for(b=0;b<f.length;b+=1)null!==this[f[b]]&&(c[f[b]]=this[f[b]].asVersion(a));if(null!==this.target&&(c.object=this.target.asVersion(a)),"0.9"!==a&&"0.95"!==a||null!==this.voided&&(c.voided=this.voided),"0.9"===a&&null!==this.inProgress&&(c.inProgress=this.inProgress),null!==this.attachments&&"0.9"!==a&&"0.95"!==a)for(c.attachments=[],b=0;b<this.attachments.length;b+=1)this.attachments[b]instanceof e.Attachment?c.attachments.push(this.attachments[b].asVersion(a)):c.attachments.push(new e.Attachment(this.attachments[b]).asVersion(a));return c},stamp:function(){this.log("stamp"),null===this.id&&(this.id=e.Utils.getUUID()),null===this.timestamp&&(this.timestamp=e.Utils.getISODateString(new Date))},hasAttachmentWithContent:function(){this.log("hasAttachmentWithContent");var a;if(null===this.attachments)return!1;for(a=0;a<this.attachments.length;a+=1)if(null!==this.attachments[a].content)return!0;return!1}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.StatementsResult=function(a){this.log("constructor"),this.statements=null,this.more=null,this.init(a)};a.prototype={LOG_SRC:"StatementsResult",log:e.prototype.log,init:function(a){this.log("init"),a=a||{},a.hasOwnProperty("statements")&&(this.statements=a.statements),a.hasOwnProperty("more")&&(this.more=a.more)}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c,d,f,g=[];try{c=JSON.parse(b)}catch(h){a.prototype.log("fromJSON - JSON.parse error: "+h)}if(c){for(f=0;f<c.statements.length;f+=1){try{d=new e.Statement(c.statements[f],4)}catch(i){a.prototype.log("fromJSON - statement instantiation failed: "+i+" ("+JSON.stringify(c.statements[f])+")"),d=new e.Statement({id:c.statements[f].id},4)}g.push(d)}c.statements=g}return new a(c)}}(),function(){"use strict";var a=e.State=function(a){this.log("constructor"),this.id=null,this.updated=null,this.contents=null,this.etag=null,this.contentType=null,this.init(a)};a.prototype={LOG_SRC:"State",log:e.prototype.log,init:function(a){this.log("init");var b,c=["id","contents","etag","contentType"];for(a=a||{},b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]]);this.updated=!1}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.ActivityProfile=function(a){this.log("constructor"),this.id=null,this.activity=null,this.updated=null,this.contents=null,this.etag=null,this.contentType=null,this.init(a)};a.prototype={LOG_SRC:"ActivityProfile",log:e.prototype.log,init:function(a){this.log("init");var b,c=["id","contents","etag","contentType"];for(a=a||{},a.hasOwnProperty("activity")&&(a.activity instanceof e.Activity?this.activity=a.activity:this.activity=new e.Activity(a.activity)),b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]]);this.updated=!1}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.AgentProfile=function(a){this.log("constructor"),this.id=null,this.agent=null,this.updated=null,this.contents=null,this.etag=null,this.contentType=null,this.init(a)};a.prototype={LOG_SRC:"AgentProfile",log:e.prototype.log,init:function(a){this.log("init");var b,c=["id","contents","etag","contentType"];for(a=a||{},a.hasOwnProperty("agent")&&(a.agent instanceof e.Agent?this.agent=a.agent:this.agent=new e.Agent(a.agent)),b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]]);this.updated=!1}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.About=function(a){this.log("constructor"),this.version=null,this.init(a)};a.prototype={LOG_SRC:"About",log:e.prototype.log,init:function(a){this.log("init");var b,c=["version"];for(a=a||{},b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]])}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.Attachment=function(a){this.log("constructor"),this.usageType=null,this.display=null,this.contentType=null,this.length=null,this.sha2=null,this.description=null,this.fileUrl=null,this.content=null,this.init(a)};a.prototype={LOG_SRC:"Attachment",log:e.prototype.log,init:function(a){this.log("init");var b,c=["contentType","length","sha2","usageType","display","description","fileUrl"];for(a=a||{},b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]]);a.hasOwnProperty("content")&&null!==a.content&&("string"==typeof a.content?this.setContentFromString(a.content):this.setContent(a.content))},asVersion:function(a){this.log("asVersion");var b;return a=a||e.versions()[0],"0.9"===a||"0.95"===a?b=null:(b={contentType:this.contentType,display:this.display,length:this.length,sha2:this.sha2,usageType:this.usageType},null!==this.fileUrl&&(b.fileUrl=this.fileUrl),null!==this.description&&(b.description=this.description)),b},getLangDictionaryValue:e.Utils.getLangDictionaryValue,setContent:function(a){this.content=a,this.length=a.byteLength,this.sha2=e.Utils.getSHA256String(a)},setContentFromString:function(a){var b=a;b=e.Utils.stringToArrayBuffer(a),this.setContent(b)},getContentAsString:function(){return e.Utils.stringFromArrayBuffer(this.content)}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)},a._defaultEncoding="utf-8"}(),function(){"use strict";var b,d,f,g="Environment.Node",h=e.prototype.log,i=a("querystring"),j=a("xhr2");b=function(a,b){h("requestComplete - xhr.status: "+a.status,g),h("requestComplete - xhr.responseText: "+a.responseText,g);var c,d=a.status,e=b.ignore404&&404===d;return d>=200&&d<400||e?b.callback?void b.callback(null,a):c={err:null,xhr:a}:(c={err:d,xhr:a},0===d?h("[warning] There was a problem communicating with the Learning Record Store. Aborted, offline, or invalid CORS endpoint ("+d+")",g):h("[warning] There was a problem communicating with the Learning Record Store. ("+d+" | "+a.responseText+")",g),b.callback&&b.callback(d,a),c)},e.LRS.prototype._initByEnvironment=function(){},e.LRS.prototype._makeRequest=function(a,c,d){h("_makeRequest using http/https",g);var e,f,k=a,l="undefined"!=typeof d.callback;"undefined"!=typeof d.params&&Object.keys(d.params).length>0&&(k+="?"+i.stringify(d.params)),e=new j,e.open(d.method,k,l),d.expectMultipart&&(e.responseType="arraybuffer");for(f in c)c.hasOwnProperty(f)&&e.setRequestHeader(f,c[f]);return"undefined"!=typeof d.data&&(d.data+=""),l&&(e.onreadystatechange=function(){h("xhr.onreadystatechange - xhr.readyState: "+e.readyState,g),4===e.readyState&&b(e,d)}),e.send(d.data),l?e:b(e,d)},e.LRS.syncEnabled=!1,e.LRS.prototype._getMultipartRequestData=function(a,b,e){var g,h=[];for(h.push(d(a,b)),g=0;g<e.length;g+=1)null!==e[g].content&&h.push(f(a,e[g].content,e[g].sha2,e[g].contentType));return"undefined"==typeof c.from?h.push(new c("\r\n--"+a+"--\r\n")):h.push(c.from("\r\n--"+a+"--\r\n")),c.concat(h)},d=function(a,b){var d=["--"+a,"Content-Type: application/json","",JSON.stringify(b)].join("\r\n");return d+="\r\n","undefined"==typeof c.from?new c(d):c.from(d)},f=function(a,b,d,e){var f=[],g=["--"+a,"Content-Type: "+e,"Content-Transfer-Encoding: binary","X-Experience-API-Hash: "+d].join("\r\n");return g+="\r\n\r\n","undefined"==typeof c.from?(f.push(new c(g)),f.push(new c(b))):(f.push(c.from(g)),f.push(c.from(b))),c.concat(f)},e.Utils.stringToArrayBuffer=function(a,b){var d,f,g,h;if(b||(b=e.Utils.defaultEncoding),"undefined"==typeof c.from){for(d=new c(a,b),f=new ArrayBuffer(d.length),g=new Uint8Array(f),h=0;h<d.length;h+=1)g[h]=d[h];return f}return d=c.from(a,b),f=d.buffer,f.slice(d.byteOffset,d.byteOffset+d.byteLength)},e.Utils.stringFromArrayBuffer=function(a,b){var d,f,g;if(b||(b=e.Utils.defaultEncoding),"undefined"==typeof c.from)for(d=new c(a.byteLength),f=new Uint8Array(a),g=0;g<d.length;g+=1)d[g]=f[g];else d=c.from(a);return d.toString(b)}}()}).call(this,a("buffer").Buffer)},{buffer:44,querystring:93,xhr2:142}],136:[function(a,b,c){function d(a,b){var c=[];b=b||0;for(var d=b||0;d<a.length;d++)c[d-b]=a[d];return c}b.exports=d},{}],137:[function(b,c,d){(function(){function b(a){function b(b,c,d,e,f,g){for(;f>=0&&f<g;f+=a){var h=e?e[f]:f;d=c(d,b[h],h,b)}return d}return function(c,d,e,f){d=w(d,f,4);var g=!D(c)&&v.keys(c),h=(g||c).length,i=a>0?0:h-1;return arguments.length<3&&(e=c[g?g[i]:i],i+=a),b(c,d,e,g,i,h)}}function e(a){return function(b,c,d){c=x(c,d);for(var e=C(b),f=a>0?0:e-1;f>=0&&f<e;f+=a)if(c(b[f],f,b))return f;return-1}}function f(a,b,c){return function(d,e,f){var g=0,h=C(d);if("number"==typeof f)a>0?g=f>=0?f:Math.max(f+h,g):h=f>=0?Math.min(f+1,h):f+h+1;else if(c&&f&&h)return f=c(d,e),d[f]===e?f:-1;if(e!==e)return f=b(n.call(d,g,h),v.isNaN),f>=0?f+g:-1;for(f=a>0?g:h-1;f>=0&&f<h;f+=a)if(d[f]===e)return f;return-1}}function g(a,b){var c=I.length,d=a.constructor,e=v.isFunction(d)&&d.prototype||k,f="constructor";for(v.has(a,f)&&!v.contains(b,f)&&b.push(f);c--;)f=I[c],f in a&&a[f]!==e[f]&&!v.contains(b,f)&&b.push(f)}var h=this,i=h._,j=Array.prototype,k=Object.prototype,l=Function.prototype,m=j.push,n=j.slice,o=k.toString,p=k.hasOwnProperty,q=Array.isArray,r=Object.keys,s=l.bind,t=Object.create,u=function(){},v=function(a){return a instanceof v?a:this instanceof v?void(this._wrapped=a):new v(a)};"undefined"!=typeof d?("undefined"!=typeof c&&c.exports&&(d=c.exports=v),d._=v):h._=v,v.VERSION="1.8.3";var w=function(a,b,c){if(void 0===b)return a;switch(null==c?3:c){case 1:return function(c){return a.call(b,c)};case 2:return function(c,d){return a.call(b,c,d)};case 3:return function(c,d,e){return a.call(b,c,d,e)};case 4:return function(c,d,e,f){return a.call(b,c,d,e,f)}}return function(){return a.apply(b,arguments)}},x=function(a,b,c){return null==a?v.identity:v.isFunction(a)?w(a,b,c):v.isObject(a)?v.matcher(a):v.property(a)};v.iteratee=function(a,b){return x(a,b,1/0)};var y=function(a,b){return function(c){var d=arguments.length;if(d<2||null==c)return c;for(var e=1;e<d;e++)for(var f=arguments[e],g=a(f),h=g.length,i=0;i<h;i++){var j=g[i];b&&void 0!==c[j]||(c[j]=f[j])}return c}},z=function(a){if(!v.isObject(a))return{};if(t)return t(a);u.prototype=a;var b=new u;return u.prototype=null,b},A=function(a){return function(b){return null==b?void 0:b[a]}},B=Math.pow(2,53)-1,C=A("length"),D=function(a){var b=C(a);return"number"==typeof b&&b>=0&&b<=B};v.each=v.forEach=function(a,b,c){b=w(b,c);var d,e;if(D(a))for(d=0,e=a.length;d<e;d++)b(a[d],d,a);else{var f=v.keys(a);for(d=0,e=f.length;d<e;d++)b(a[f[d]],f[d],a)}return a},v.map=v.collect=function(a,b,c){b=x(b,c);for(var d=!D(a)&&v.keys(a),e=(d||a).length,f=Array(e),g=0;g<e;g++){var h=d?d[g]:g;f[g]=b(a[h],h,a)}return f},v.reduce=v.foldl=v.inject=b(1),v.reduceRight=v.foldr=b(-1),v.find=v.detect=function(a,b,c){var d;if(d=D(a)?v.findIndex(a,b,c):v.findKey(a,b,c),void 0!==d&&d!==-1)return a[d]},v.filter=v.select=function(a,b,c){var d=[];return b=x(b,c),v.each(a,function(a,c,e){b(a,c,e)&&d.push(a)}),d},v.reject=function(a,b,c){return v.filter(a,v.negate(x(b)),c)},v.every=v.all=function(a,b,c){b=x(b,c);for(var d=!D(a)&&v.keys(a),e=(d||a).length,f=0;f<e;f++){var g=d?d[f]:f;if(!b(a[g],g,a))return!1}return!0},v.some=v.any=function(a,b,c){b=x(b,c);for(var d=!D(a)&&v.keys(a),e=(d||a).length,f=0;f<e;f++){var g=d?d[f]:f;if(b(a[g],g,a))return!0}return!1},v.contains=v.includes=v.include=function(a,b,c,d){return D(a)||(a=v.values(a)),("number"!=typeof c||d)&&(c=0),v.indexOf(a,b,c)>=0},v.invoke=function(a,b){var c=n.call(arguments,2),d=v.isFunction(b);return v.map(a,function(a){var e=d?b:a[b];return null==e?e:e.apply(a,c)})},v.pluck=function(a,b){return v.map(a,v.property(b))},v.where=function(a,b){return v.filter(a,v.matcher(b))},v.findWhere=function(a,b){return v.find(a,v.matcher(b))},v.max=function(a,b,c){var d,e,f=-(1/0),g=-(1/0);if(null==b&&null!=a){a=D(a)?a:v.values(a);for(var h=0,i=a.length;h<i;h++)d=a[h],d>f&&(f=d)}else b=x(b,c),v.each(a,function(a,c,d){e=b(a,c,d),(e>g||e===-(1/0)&&f===-(1/0))&&(f=a,g=e)});return f},v.min=function(a,b,c){var d,e,f=1/0,g=1/0;if(null==b&&null!=a){a=D(a)?a:v.values(a);for(var h=0,i=a.length;h<i;h++)d=a[h],d<f&&(f=d)}else b=x(b,c),v.each(a,function(a,c,d){e=b(a,c,d),(e<g||e===1/0&&f===1/0)&&(f=a,g=e)});return f},v.shuffle=function(a){for(var b,c=D(a)?a:v.values(a),d=c.length,e=Array(d),f=0;f<d;f++)b=v.random(0,f),b!==f&&(e[f]=e[b]),e[b]=c[f];return e},v.sample=function(a,b,c){return null==b||c?(D(a)||(a=v.values(a)),a[v.random(a.length-1)]):v.shuffle(a).slice(0,Math.max(0,b))},v.sortBy=function(a,b,c){return b=x(b,c),v.pluck(v.map(a,function(a,c,d){return{value:a,index:c,criteria:b(a,c,d)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;if(c!==d){if(c>d||void 0===c)return 1;if(c<d||void 0===d)return-1}return a.index-b.index}),"value")};var E=function(a){return function(b,c,d){var e={};return c=x(c,d),v.each(b,function(d,f){var g=c(d,f,b);a(e,d,g)}),e}};v.groupBy=E(function(a,b,c){v.has(a,c)?a[c].push(b):a[c]=[b]}),v.indexBy=E(function(a,b,c){a[c]=b}),v.countBy=E(function(a,b,c){v.has(a,c)?a[c]++:a[c]=1}),v.toArray=function(a){return a?v.isArray(a)?n.call(a):D(a)?v.map(a,v.identity):v.values(a):[]},v.size=function(a){return null==a?0:D(a)?a.length:v.keys(a).length},v.partition=function(a,b,c){b=x(b,c);var d=[],e=[];return v.each(a,function(a,c,f){(b(a,c,f)?d:e).push(a)}),[d,e]},v.first=v.head=v.take=function(a,b,c){if(null!=a)return null==b||c?a[0]:v.initial(a,a.length-b)},v.initial=function(a,b,c){return n.call(a,0,Math.max(0,a.length-(null==b||c?1:b)))},v.last=function(a,b,c){if(null!=a)return null==b||c?a[a.length-1]:v.rest(a,Math.max(0,a.length-b))},v.rest=v.tail=v.drop=function(a,b,c){return n.call(a,null==b||c?1:b)},v.compact=function(a){return v.filter(a,v.identity)};var F=function(a,b,c,d){for(var e=[],f=0,g=d||0,h=C(a);g<h;g++){var i=a[g];if(D(i)&&(v.isArray(i)||v.isArguments(i))){b||(i=F(i,b,c));var j=0,k=i.length;for(e.length+=k;j<k;)e[f++]=i[j++]}else c||(e[f++]=i)}return e};v.flatten=function(a,b){return F(a,b,!1)},v.without=function(a){return v.difference(a,n.call(arguments,1))},v.uniq=v.unique=function(a,b,c,d){v.isBoolean(b)||(d=c,c=b,b=!1),null!=c&&(c=x(c,d));for(var e=[],f=[],g=0,h=C(a);g<h;g++){var i=a[g],j=c?c(i,g,a):i;b?(g&&f===j||e.push(i),f=j):c?v.contains(f,j)||(f.push(j),e.push(i)):v.contains(e,i)||e.push(i)}return e},v.union=function(){return v.uniq(F(arguments,!0,!0))},v.intersection=function(a){for(var b=[],c=arguments.length,d=0,e=C(a);d<e;d++){var f=a[d];if(!v.contains(b,f)){for(var g=1;g<c&&v.contains(arguments[g],f);g++);g===c&&b.push(f)}}return b},v.difference=function(a){var b=F(arguments,!0,!0,1);return v.filter(a,function(a){return!v.contains(b,a)})},v.zip=function(){return v.unzip(arguments)},v.unzip=function(a){for(var b=a&&v.max(a,C).length||0,c=Array(b),d=0;d<b;d++)c[d]=v.pluck(a,d);return c},v.object=function(a,b){for(var c={},d=0,e=C(a);d<e;d++)b?c[a[d]]=b[d]:c[a[d][0]]=a[d][1];return c},v.findIndex=e(1),v.findLastIndex=e(-1),v.sortedIndex=function(a,b,c,d){c=x(c,d,1);for(var e=c(b),f=0,g=C(a);f<g;){var h=Math.floor((f+g)/2);c(a[h])<e?f=h+1:g=h}return f},v.indexOf=f(1,v.findIndex,v.sortedIndex),v.lastIndexOf=f(-1,v.findLastIndex),v.range=function(a,b,c){null==b&&(b=a||0,a=0),c=c||1;for(var d=Math.max(Math.ceil((b-a)/c),0),e=Array(d),f=0;f<d;f++,a+=c)e[f]=a;return e};var G=function(a,b,c,d,e){if(!(d instanceof b))return a.apply(c,e);var f=z(a.prototype),g=a.apply(f,e);return v.isObject(g)?g:f};v.bind=function(a,b){if(s&&a.bind===s)return s.apply(a,n.call(arguments,1));if(!v.isFunction(a))throw new TypeError("Bind must be called on a function");var c=n.call(arguments,2),d=function(){return G(a,d,b,this,c.concat(n.call(arguments)))};return d},v.partial=function(a){var b=n.call(arguments,1),c=function(){for(var d=0,e=b.length,f=Array(e),g=0;g<e;g++)f[g]=b[g]===v?arguments[d++]:b[g];for(;d<arguments.length;)f.push(arguments[d++]);return G(a,c,this,this,f)};return c},v.bindAll=function(a){var b,c,d=arguments.length;if(d<=1)throw new Error("bindAll must be passed function names");for(b=1;b<d;b++)c=arguments[b],a[c]=v.bind(a[c],a);return a},v.memoize=function(a,b){var c=function(d){var e=c.cache,f=""+(b?b.apply(this,arguments):d);return v.has(e,f)||(e[f]=a.apply(this,arguments)),e[f]};return c.cache={},c},v.delay=function(a,b){var c=n.call(arguments,2);return setTimeout(function(){return a.apply(null,c)},b)},v.defer=v.partial(v.delay,v,1),v.throttle=function(a,b,c){var d,e,f,g=null,h=0;c||(c={});var i=function(){h=c.leading===!1?0:v.now(),g=null,f=a.apply(d,e),g||(d=e=null)};return function(){var j=v.now();h||c.leading!==!1||(h=j);var k=b-(j-h);return d=this,e=arguments,k<=0||k>b?(g&&(clearTimeout(g),g=null),h=j,f=a.apply(d,e),g||(d=e=null)):g||c.trailing===!1||(g=setTimeout(i,k)),f}},v.debounce=function(a,b,c){var d,e,f,g,h,i=function(){var j=v.now()-g;j<b&&j>=0?d=setTimeout(i,b-j):(d=null,c||(h=a.apply(f,e),d||(f=e=null)))};return function(){f=this,e=arguments,g=v.now();var j=c&&!d;return d||(d=setTimeout(i,b)),j&&(h=a.apply(f,e),f=e=null),h}},v.wrap=function(a,b){return v.partial(b,a)},v.negate=function(a){return function(){return!a.apply(this,arguments)}},v.compose=function(){var a=arguments,b=a.length-1;return function(){for(var c=b,d=a[b].apply(this,arguments);c--;)d=a[c].call(this,d);return d}},v.after=function(a,b){return function(){if(--a<1)return b.apply(this,arguments)}},v.before=function(a,b){var c;return function(){return--a>0&&(c=b.apply(this,arguments)),a<=1&&(b=null),c}},v.once=v.partial(v.before,2);var H=!{toString:null}.propertyIsEnumerable("toString"),I=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];v.keys=function(a){if(!v.isObject(a))return[];if(r)return r(a);var b=[];for(var c in a)v.has(a,c)&&b.push(c);return H&&g(a,b),b},v.allKeys=function(a){if(!v.isObject(a))return[];var b=[];for(var c in a)b.push(c);return H&&g(a,b),b},v.values=function(a){for(var b=v.keys(a),c=b.length,d=Array(c),e=0;e<c;e++)d[e]=a[b[e]];return d},v.mapObject=function(a,b,c){b=x(b,c);for(var d,e=v.keys(a),f=e.length,g={},h=0;h<f;h++)d=e[h],g[d]=b(a[d],d,a);return g},v.pairs=function(a){for(var b=v.keys(a),c=b.length,d=Array(c),e=0;e<c;e++)d[e]=[b[e],a[b[e]]];return d},v.invert=function(a){for(var b={},c=v.keys(a),d=0,e=c.length;d<e;d++)b[a[c[d]]]=c[d];return b},v.functions=v.methods=function(a){var b=[];for(var c in a)v.isFunction(a[c])&&b.push(c);return b.sort()},v.extend=y(v.allKeys),v.extendOwn=v.assign=y(v.keys),v.findKey=function(a,b,c){b=x(b,c);for(var d,e=v.keys(a),f=0,g=e.length;f<g;f++)if(d=e[f],b(a[d],d,a))return d},v.pick=function(a,b,c){var d,e,f={},g=a;if(null==g)return f;v.isFunction(b)?(e=v.allKeys(g),d=w(b,c)):(e=F(arguments,!1,!1,1),d=function(a,b,c){return b in c},g=Object(g));for(var h=0,i=e.length;h<i;h++){var j=e[h],k=g[j];d(k,j,g)&&(f[j]=k)}return f},v.omit=function(a,b,c){if(v.isFunction(b))b=v.negate(b);else{var d=v.map(F(arguments,!1,!1,1),String);b=function(a,b){return!v.contains(d,b)}}return v.pick(a,b,c)},v.defaults=y(v.allKeys,!0),v.create=function(a,b){var c=z(a);return b&&v.extendOwn(c,b),c},v.clone=function(a){return v.isObject(a)?v.isArray(a)?a.slice():v.extend({},a):a},v.tap=function(a,b){return b(a),a},v.isMatch=function(a,b){var c=v.keys(b),d=c.length;if(null==a)return!d;for(var e=Object(a),f=0;f<d;f++){var g=c[f];if(b[g]!==e[g]||!(g in e))return!1}return!0};var J=function(a,b,c,d){if(a===b)return 0!==a||1/a===1/b;if(null==a||null==b)return a===b;a instanceof v&&(a=a._wrapped),b instanceof v&&(b=b._wrapped);var e=o.call(a);if(e!==o.call(b))return!1;switch(e){case"[object RegExp]":case"[object String]":return""+a==""+b;case"[object Number]":return+a!==+a?+b!==+b:0===+a?1/+a===1/b:+a===+b;case"[object Date]":case"[object Boolean]":return+a===+b}var f="[object Array]"===e;if(!f){if("object"!=typeof a||"object"!=typeof b)return!1;var g=a.constructor,h=b.constructor;if(g!==h&&!(v.isFunction(g)&&g instanceof g&&v.isFunction(h)&&h instanceof h)&&"constructor"in a&&"constructor"in b)return!1}c=c||[],d=d||[];for(var i=c.length;i--;)if(c[i]===a)return d[i]===b;if(c.push(a),d.push(b),f){if(i=a.length,i!==b.length)return!1;for(;i--;)if(!J(a[i],b[i],c,d))return!1}else{var j,k=v.keys(a);if(i=k.length,v.keys(b).length!==i)return!1;for(;i--;)if(j=k[i],!v.has(b,j)||!J(a[j],b[j],c,d))return!1}return c.pop(),d.pop(),!0};v.isEqual=function(a,b){return J(a,b)},v.isEmpty=function(a){return null==a||(D(a)&&(v.isArray(a)||v.isString(a)||v.isArguments(a))?0===a.length:0===v.keys(a).length)},v.isElement=function(a){return!(!a||1!==a.nodeType)},v.isArray=q||function(a){return"[object Array]"===o.call(a)},v.isObject=function(a){var b=typeof a;return"function"===b||"object"===b&&!!a},v.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(a){v["is"+a]=function(b){return o.call(b)==="[object "+a+"]"}}),v.isArguments(arguments)||(v.isArguments=function(a){return v.has(a,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(v.isFunction=function(a){return"function"==typeof a||!1}),v.isFinite=function(a){return isFinite(a)&&!isNaN(parseFloat(a))},v.isNaN=function(a){return v.isNumber(a)&&a!==+a},v.isBoolean=function(a){return a===!0||a===!1||"[object Boolean]"===o.call(a)},v.isNull=function(a){return null===a},v.isUndefined=function(a){return void 0===a},v.has=function(a,b){return null!=a&&p.call(a,b)},v.noConflict=function(){return h._=i,this},v.identity=function(a){return a},v.constant=function(a){return function(){return a}},v.noop=function(){},v.property=A,v.propertyOf=function(a){return null==a?function(){}:function(b){return a[b]}},v.matcher=v.matches=function(a){return a=v.extendOwn({},a),function(b){return v.isMatch(b,a)}},v.times=function(a,b,c){var d=Array(Math.max(0,a));b=w(b,c,1);for(var e=0;e<a;e++)d[e]=b(e);return d},v.random=function(a,b){return null==b&&(b=a,a=0),a+Math.floor(Math.random()*(b-a+1))},v.now=Date.now||function(){return(new Date).getTime()};var K={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},L=v.invert(K),M=function(a){var b=function(b){return a[b]},c="(?:"+v.keys(a).join("|")+")",d=RegExp(c),e=RegExp(c,"g");return function(a){return a=null==a?"":""+a,d.test(a)?a.replace(e,b):a}};v.escape=M(K),v.unescape=M(L),v.result=function(a,b,c){var d=null==a?void 0:a[b];return void 0===d&&(d=c),v.isFunction(d)?d.call(a):d};var N=0;v.uniqueId=function(a){var b=++N+"";return a?a+b:b},v.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var O=/(.)^/,P={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},Q=/\\|'|\r|\n|\u2028|\u2029/g,R=function(a){return"\\"+P[a]};v.template=function(a,b,c){!b&&c&&(b=c),b=v.defaults({},b,v.templateSettings);var d=RegExp([(b.escape||O).source,(b.interpolate||O).source,(b.evaluate||O).source].join("|")+"|$","g"),e=0,f="__p+='";a.replace(d,function(b,c,d,g,h){return f+=a.slice(e,h).replace(Q,R),e=h+b.length,c?f+="'+\n((__t=("+c+"))==null?'':_.escape(__t))+\n'":d?f+="'+\n((__t=("+d+"))==null?'':__t)+\n'":g&&(f+="';\n"+g+"\n__p+='"),b}),f+="';\n",b.variable||(f="with(obj||{}){\n"+f+"}\n"),f="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+f+"return __p;\n";try{var g=new Function(b.variable||"obj","_",f)}catch(h){throw h.source=f,h}var i=function(a){return g.call(this,a,v)},j=b.variable||"obj";return i.source="function("+j+"){\n"+f+"}",i},v.chain=function(a){var b=v(a);return b._chain=!0,b};var S=function(a,b){return a._chain?v(b).chain():b};v.mixin=function(a){v.each(v.functions(a),function(b){var c=v[b]=a[b];v.prototype[b]=function(){var a=[this._wrapped];return m.apply(a,arguments),S(this,c.apply(v,a))}})},v.mixin(v),v.each(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=j[a];v.prototype[a]=function(){var c=this._wrapped;return b.apply(c,arguments),"shift"!==a&&"splice"!==a||0!==c.length||delete c[0],S(this,c)}}),v.each(["concat","join","slice"],function(a){var b=j[a];v.prototype[a]=function(){return S(this,b.apply(this._wrapped,arguments))}}),v.prototype.value=function(){return this._wrapped},v.prototype.valueOf=v.prototype.toJSON=v.prototype.value,v.prototype.toString=function(){return""+this._wrapped},"function"==typeof a&&a.amd&&a("underscore",[],function(){return v})}).call(this)},{}],138:[function(a,b,c){function d(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function e(a,b,c){if(a&&j(a)&&a instanceof d)return a;var e=new d;return e.parse(a,b,c),e}function f(a){return i(a)&&(a=e(a)),a instanceof d?a.format():d.prototype.format.call(a)}function g(a,b){return e(a,!1,!0).resolve(b)}function h(a,b){return a?e(a,!1,!0).resolveObject(b):b}function i(a){return"string"==typeof a}function j(a){return"object"==typeof a&&null!==a}function k(a){return null===a}function l(a){return null==a}var m=a("punycode");c.parse=e,c.resolve=g,c.resolveObject=h,c.format=f,c.Url=d;var n=/^([a-z0-9.+-]+:)/i,o=/:[0-9]*$/,p=["<",">",'"',"`"," ","\r","\n","\t"],q=["{","}","|","\\","^","`"].concat(p),r=["'"].concat(q),s=["%","/","?",";","#"].concat(r),t=["/","?","#"],u=255,v=/^[a-z0-9A-Z_-]{0,63}$/,w=/^([a-z0-9A-Z_-]{0,63})(.*)$/,x={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},z={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},A=a("querystring");d.prototype.parse=function(a,b,c){if(!i(a))throw new TypeError("Parameter 'url' must be a string, not "+typeof a);var d=a;d=d.trim();var e=n.exec(d);if(e){e=e[0];var f=e.toLowerCase();this.protocol=f,d=d.substr(e.length)}if(c||e||d.match(/^\/\/[^@\/]+@[^@\/]+/)){var g="//"===d.substr(0,2);!g||e&&y[e]||(d=d.substr(2),this.slashes=!0)}if(!y[e]&&(g||e&&!z[e])){for(var h=-1,j=0;j<t.length;j++){var k=d.indexOf(t[j]);k!==-1&&(h===-1||k<h)&&(h=k)}var l,o;o=h===-1?d.lastIndexOf("@"):d.lastIndexOf("@",h),o!==-1&&(l=d.slice(0,o),d=d.slice(o+1),this.auth=decodeURIComponent(l)),h=-1;for(var j=0;j<s.length;j++){var k=d.indexOf(s[j]);k!==-1&&(h===-1||k<h)&&(h=k)}h===-1&&(h=d.length),this.host=d.slice(0,h),d=d.slice(h),this.parseHost(),this.hostname=this.hostname||"";var p="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!p)for(var q=this.hostname.split(/\./),j=0,B=q.length;j<B;j++){var C=q[j];if(C&&!C.match(v)){for(var D="",E=0,F=C.length;E<F;E++)D+=C.charCodeAt(E)>127?"x":C[E];if(!D.match(v)){var G=q.slice(0,j),H=q.slice(j+1),I=C.match(w);I&&(G.push(I[1]),H.unshift(I[2])),H.length&&(d="/"+H.join(".")+d),this.hostname=G.join(".");break}}}if(this.hostname.length>u?this.hostname="":this.hostname=this.hostname.toLowerCase(),!p){for(var J=this.hostname.split("."),K=[],j=0;j<J.length;++j){var L=J[j];K.push(L.match(/[^A-Za-z0-9_-]/)?"xn--"+m.encode(L):L)}this.hostname=K.join(".")}var M=this.port?":"+this.port:"",N=this.hostname||"";this.host=N+M,this.href+=this.host,p&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==d[0]&&(d="/"+d))}if(!x[f])for(var j=0,B=r.length;j<B;j++){var O=r[j],P=encodeURIComponent(O);P===O&&(P=escape(O)),d=d.split(O).join(P)}var Q=d.indexOf("#");Q!==-1&&(this.hash=d.substr(Q),d=d.slice(0,Q));var R=d.indexOf("?");if(R!==-1?(this.search=d.substr(R),this.query=d.substr(R+1),b&&(this.query=A.parse(this.query)),d=d.slice(0,R)):b&&(this.search="",this.query={}),d&&(this.pathname=d),z[f]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var M=this.pathname||"",L=this.search||"";this.path=M+L}return this.href=this.format(),this},d.prototype.format=function(){var a=this.auth||"";a&&(a=encodeURIComponent(a),a=a.replace(/%3A/i,":"),a+="@");var b=this.protocol||"",c=this.pathname||"",d=this.hash||"",e=!1,f="";this.host?e=a+this.host:this.hostname&&(e=a+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(e+=":"+this.port)),this.query&&j(this.query)&&Object.keys(this.query).length&&(f=A.stringify(this.query));var g=this.search||f&&"?"+f||"";return b&&":"!==b.substr(-1)&&(b+=":"),this.slashes||(!b||z[b])&&e!==!1?(e="//"+(e||""),c&&"/"!==c.charAt(0)&&(c="/"+c)):e||(e=""),d&&"#"!==d.charAt(0)&&(d="#"+d),g&&"?"!==g.charAt(0)&&(g="?"+g),c=c.replace(/[?#]/g,function(a){return encodeURIComponent(a)}),g=g.replace("#","%23"),b+e+c+g+d},d.prototype.resolve=function(a){return this.resolveObject(e(a,!1,!0)).format()},d.prototype.resolveObject=function(a){if(i(a)){var b=new d;b.parse(a,!1,!0),a=b}var c=new d;if(Object.keys(this).forEach(function(a){c[a]=this[a]},this),c.hash=a.hash,""===a.href)return c.href=c.format(),c;if(a.slashes&&!a.protocol)return Object.keys(a).forEach(function(b){"protocol"!==b&&(c[b]=a[b])}),z[c.protocol]&&c.hostname&&!c.pathname&&(c.path=c.pathname="/"),c.href=c.format(),c;if(a.protocol&&a.protocol!==c.protocol){if(!z[a.protocol])return Object.keys(a).forEach(function(b){c[b]=a[b]}),c.href=c.format(),c;if(c.protocol=a.protocol,a.host||y[a.protocol])c.pathname=a.pathname;else{for(var e=(a.pathname||"").split("/");e.length&&!(a.host=e.shift()););a.host||(a.host=""),a.hostname||(a.hostname=""),""!==e[0]&&e.unshift(""),e.length<2&&e.unshift(""),c.pathname=e.join("/")}if(c.search=a.search,c.query=a.query,c.host=a.host||"",c.auth=a.auth,c.hostname=a.hostname||a.host,c.port=a.port,c.pathname||c.search){var f=c.pathname||"",g=c.search||"";c.path=f+g}return c.slashes=c.slashes||a.slashes,c.href=c.format(),c}var h=c.pathname&&"/"===c.pathname.charAt(0),j=a.host||a.pathname&&"/"===a.pathname.charAt(0),m=j||h||c.host&&a.pathname,n=m,o=c.pathname&&c.pathname.split("/")||[],e=a.pathname&&a.pathname.split("/")||[],p=c.protocol&&!z[c.protocol];if(p&&(c.hostname="",c.port=null,c.host&&(""===o[0]?o[0]=c.host:o.unshift(c.host)),c.host="",a.protocol&&(a.hostname=null,a.port=null,a.host&&(""===e[0]?e[0]=a.host:e.unshift(a.host)),a.host=null),m=m&&(""===e[0]||""===o[0])),j)c.host=a.host||""===a.host?a.host:c.host,c.hostname=a.hostname||""===a.hostname?a.hostname:c.hostname,c.search=a.search,c.query=a.query,o=e;else if(e.length)o||(o=[]),o.pop(),o=o.concat(e),c.search=a.search,c.query=a.query;else if(!l(a.search)){if(p){c.hostname=c.host=o.shift();
18
- var q=!!(c.host&&c.host.indexOf("@")>0)&&c.host.split("@");q&&(c.auth=q.shift(),c.host=c.hostname=q.shift())}return c.search=a.search,c.query=a.query,k(c.pathname)&&k(c.search)||(c.path=(c.pathname?c.pathname:"")+(c.search?c.search:"")),c.href=c.format(),c}if(!o.length)return c.pathname=null,c.search?c.path="/"+c.search:c.path=null,c.href=c.format(),c;for(var r=o.slice(-1)[0],s=(c.host||a.host)&&("."===r||".."===r)||""===r,t=0,u=o.length;u>=0;u--)r=o[u],"."==r?o.splice(u,1):".."===r?(o.splice(u,1),t++):t&&(o.splice(u,1),t--);if(!m&&!n)for(;t--;t)o.unshift("..");!m||""===o[0]||o[0]&&"/"===o[0].charAt(0)||o.unshift(""),s&&"/"!==o.join("/").substr(-1)&&o.push("");var v=""===o[0]||o[0]&&"/"===o[0].charAt(0);if(p){c.hostname=c.host=v?"":o.length?o.shift():"";var q=!!(c.host&&c.host.indexOf("@")>0)&&c.host.split("@");q&&(c.auth=q.shift(),c.host=c.hostname=q.shift())}return m=m||c.host&&o.length,m&&!v&&o.unshift(""),o.length?c.pathname=o.join("/"):(c.pathname=null,c.path=null),k(c.pathname)&&k(c.search)||(c.path=(c.pathname?c.pathname:"")+(c.search?c.search:"")),c.auth=a.auth||c.auth,c.slashes=c.slashes||a.slashes,c.href=c.format(),c},d.prototype.parseHost=function(){var a=this.host,b=o.exec(a);b&&(b=b[0],":"!==b&&(this.port=b.substr(1)),a=a.substr(0,a.length-b.length)),a&&(this.hostname=a)}},{punycode:89,querystring:93}],139:[function(b,c,d){(function(b){!function(e){function f(a){for(var b,c,d=[],e=0,f=a.length;e<f;)b=a.charCodeAt(e++),b>=55296&&b<=56319&&e<f?(c=a.charCodeAt(e++),56320==(64512&c)?d.push(((1023&b)<<10)+(1023&c)+65536):(d.push(b),e--)):d.push(b);return d}function g(a){for(var b,c=a.length,d=-1,e="";++d<c;)b=a[d],b>65535&&(b-=65536,e+=u(b>>>10&1023|55296),b=56320|1023&b),e+=u(b);return e}function h(a){if(a>=55296&&a<=57343)throw Error("Lone surrogate U+"+a.toString(16).toUpperCase()+" is not a scalar value")}function i(a,b){return u(a>>b&63|128)}function j(a){if(0==(4294967168&a))return u(a);var b="";return 0==(4294965248&a)?b=u(a>>6&31|192):0==(4294901760&a)?(h(a),b=u(a>>12&15|224),b+=i(a,6)):0==(4292870144&a)&&(b=u(a>>18&7|240),b+=i(a,12),b+=i(a,6)),b+=u(63&a|128)}function k(a){for(var b,c=f(a),d=c.length,e=-1,g="";++e<d;)b=c[e],g+=j(b);return g}function l(){if(t>=s)throw Error("Invalid byte index");var a=255&r[t];if(t++,128==(192&a))return 63&a;throw Error("Invalid continuation byte")}function m(){var a,b,c,d,e;if(t>s)throw Error("Invalid byte index");if(t==s)return!1;if(a=255&r[t],t++,0==(128&a))return a;if(192==(224&a)){var b=l();if(e=(31&a)<<6|b,e>=128)return e;throw Error("Invalid continuation byte")}if(224==(240&a)){if(b=l(),c=l(),e=(15&a)<<12|b<<6|c,e>=2048)return h(e),e;throw Error("Invalid continuation byte")}if(240==(248&a)&&(b=l(),c=l(),d=l(),e=(15&a)<<18|b<<12|c<<6|d,e>=65536&&e<=1114111))return e;throw Error("Invalid UTF-8 detected")}function n(a){r=f(a),s=r.length,t=0;for(var b,c=[];(b=m())!==!1;)c.push(b);return g(c)}var o="object"==typeof d&&d,p="object"==typeof c&&c&&c.exports==o&&c,q="object"==typeof b&&b;q.global!==q&&q.window!==q||(e=q);var r,s,t,u=String.fromCharCode,v={version:"2.0.0",encode:k,decode:n};if("function"==typeof a&&"object"==typeof a.amd&&a.amd)a(function(){return v});else if(o&&!o.nodeType)if(p)p.exports=v;else{var w={},x=w.hasOwnProperty;for(var y in v)x.call(v,y)&&(o[y]=v[y])}else e.utf8=v}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],140:[function(a,b,c){(function(a){function c(a,b){function c(){if(!e){if(d("throwDeprecation"))throw new Error(b);d("traceDeprecation")?console.trace(b):console.warn(b),e=!0}return a.apply(this,arguments)}if(d("noDeprecation"))return a;var e=!1;return c}function d(b){try{if(!a.localStorage)return!1}catch(c){return!1}var d=a.localStorage[b];return null!=d&&"true"===String(d).toLowerCase()}b.exports=c}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],141:[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");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)},{}],142:[function(a,b,c){(function(c,d){(function(){var e,f,g,h,i,j,k,l,m,n,o,p,q={}.hasOwnProperty,r=function(a,b){function c(){this.constructor=a}for(var d in b)q.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};i=function(){function a(){this.onloadstart=null,this.onprogress=null,this.onabort=null,this.onerror=null,this.onload=null,this.ontimeout=null,this.onloadend=null,this._listeners={}}return a.prototype.onloadstart=null,a.prototype.onprogress=null,a.prototype.onabort=null,a.prototype.onerror=null,a.prototype.onload=null,a.prototype.ontimeout=null,a.prototype.onloadend=null,a.prototype.addEventListener=function(a,b){var c;a=a.toLowerCase(),(c=this._listeners)[a]||(c[a]=[]),this._listeners[a].push(b)},a.prototype.removeEventListener=function(a,b){var c;a=a.toLowerCase(),this._listeners[a]&&(c=this._listeners[a].indexOf(b),c!==-1&&this._listeners.splice(c,1))},a.prototype.dispatchEvent=function(a){var b,c,d,e,f;if(b=a.type,d=this._listeners[b])for(e=0,f=d.length;e<f;e++)(c=d[e])(a);(c=this["on"+b])&&c(a)},a}(),l=a("http"),m=a("https"),n=a("os"),o=a("url"),h=function(a){function b(a){b.__super__.constructor.call(this),this.onreadystatechange=null,this._anonymous=a&&a.anon,this.readyState=b.UNSENT,this.response=null,this.responseText="",this.responseType="",this.status=0,this.statusText="",this.timeout=0,this.upload=new k(this),this._method=null,this._url=null,this._sync=!1,this._headers=null,this._loweredHeaders=null,this._mimeOverride=null,this._request=null,this._response=null,this._responseParts=null,this._responseHeaders=null,this._aborting=null,this._error=null,this._loadedBytes=0,this._totalBytes=0,this._lengthComputable=!1}return r(b,a),b.prototype.onreadystatechange=null,b.prototype.readyState=null,b.prototype.response=null,b.prototype.responseText=null,b.prototype.responseType=null,b.prototype.status=null,b.prototype.timeout=null,b.prototype.upload=null,b.prototype.open=function(a,c,d,e,f){var h;if(a=a.toUpperCase(),a in this._restrictedMethods)throw new g("HTTP method "+a+" is not allowed in XHR");switch(h=this._parseUrl(c),void 0===d&&(d=!0),this.readyState){case b.UNSENT:case b.OPENED:case b.DONE:break;case b.HEADERS_RECEIVED:case b.LOADING:}this._method=a,this._url=h,this._sync=!d,this._headers={},this._loweredHeaders={},this._mimeOverride=null,this._setReadyState(b.OPENED),this._request=null,this._response=null,this.status=0,this.statusText="",this._responseParts=[],this._responseHeaders=null,this._loadedBytes=0,this._totalBytes=0,this._lengthComputable=!1},b.prototype.setRequestHeader=function(a,c){var d;if(this.readyState!==b.OPENED)throw new e("XHR readyState must be OPENED");return d=a.toLowerCase(),this._restrictedHeaders[d]||/^sec\-/.test(d)||/^proxy-/.test(d)?void console.warn('Refused to set unsafe header "'+a+'"'):(c=c.toString(),void(d in this._loweredHeaders?(a=this._loweredHeaders[d],this._headers[a]=this._headers[a]+", "+c):(this._loweredHeaders[d]=a,this._headers[a]=c)))},b.prototype.send=function(a){if(this.readyState!==b.OPENED)throw new e("XHR readyState must be OPENED");if(this._request)throw new e("send() already called");switch(this._url.protocol){case"file:":this._sendFile(a);break;case"http:":case"https:":this._sendHttp(a);break;default:throw new f("Unsupported protocol "+this._url.protocol)}},b.prototype.abort=function(){this._request&&(this._request.abort(),this._setError(),this._dispatchProgress("abort"),this._dispatchProgress("loadend"))},b.prototype.getResponseHeader=function(a){var b;return this._responseHeaders?(b=a.toLowerCase(),b in this._responseHeaders?this._responseHeaders[b]:null):null},b.prototype.getAllResponseHeaders=function(){var a,b,c;return this._responseHeaders?(a=function(){var a,d;a=this._responseHeaders,d=[];for(b in a)c=a[b],d.push(""+b+": "+c);return d}.call(this),a.join("\r\n")):""},b.prototype.overrideMimeType=function(a){if(this.readyState===b.LOADING||this.readyState===b.DONE)throw new e("overrideMimeType() not allowed in LOADING or DONE");this._mimeOverride=a.toLowerCase()},b.prototype.nodejsSet=function(a){"httpAgent"in a&&(this.nodejsHttpAgent=a.httpAgent),"httpsAgent"in a&&(this.nodejsHttpsAgent=a.httpsAgent)},b.nodejsSet=function(a){b.prototype.nodejsSet(a)},b.prototype.UNSENT=0,b.UNSENT=0,b.prototype.OPENED=1,b.OPENED=1,b.prototype.HEADERS_RECEIVED=2,b.HEADERS_RECEIVED=2,b.prototype.LOADING=3,b.LOADING=3,b.prototype.DONE=4,b.DONE=4,b.prototype.nodejsHttpAgent=l.globalAgent,b.prototype.nodejsHttpsAgent=m.globalAgent,b.prototype._restrictedMethods={CONNECT:!0,TRACE:!0,TRACK:!0},b.prototype._restrictedHeaders={"accept-charset":!0,"accept-encoding":!0,"access-control-request-headers":!0,"access-control-request-method":!0,connection:!0,"content-length":!0,cookie:!0,cookie2:!0,date:!0,dnt:!0,expect:!0,host:!0,"keep-alive":!0,origin:!0,referer:!0,te:!0,trailer:!0,"transfer-encoding":!0,upgrade:!0,"user-agent":!0,via:!0},b.prototype._privateHeaders={"set-cookie":!0,"set-cookie2":!0},b.prototype._userAgent="Mozilla/5.0 ("+n.type()+" "+n.arch()+") "+("node.js/"+c.versions.node+" v8/"+c.versions.v8),b.prototype._setReadyState=function(a){var b;this.readyState=a,b=new j("readystatechange",this),this.dispatchEvent(b)},b.prototype._sendFile=function(){if("GET"!==this._url.method)throw new f("The file protocol only supports GET");throw new Error("Protocol file: not implemented")},b.prototype._sendHttp=function(a){if(this._sync)throw new Error("Synchronous XHR processing not implemented");null==a||"GET"!==this._method&&"HEAD"!==this._method?a||(a=""):(console.warn("Discarding entity body for "+this._method+" requests"),a=null),this.upload._setData(a),this._finalizeHeaders(),this._sendHxxpRequest()},b.prototype._sendHxxpRequest=function(){var a,b,c,d=this;"http:"===this._url.protocol?(b=l,a=this.nodejsHttpAgent):(b=m,a=this.nodejsHttpsAgent),c=b.request({hostname:this._url.hostname,port:this._url.port,path:this._url.path,auth:this._url.auth,method:this._method,headers:this._headers,agent:a}),this._request=c,this.timeout&&c.setTimeout(this.timeout,function(){return d._onHttpTimeout(c)}),c.on("response",function(a){return d._onHttpResponse(c,a)}),c.on("error",function(a){return d._onHttpRequestError(c,a)}),this.upload._startUpload(c),this._request===c&&this._dispatchProgress("loadstart")},b.prototype._finalizeHeaders=function(){this._headers.Connection="keep-alive",this._headers.Host=this._url.host,this._anonymous&&(this._headers.Referer="about:blank"),this._headers["User-Agent"]=this._userAgent,this.upload._finalizeHeaders(this._headers,this._loweredHeaders)},b.prototype._onHttpResponse=function(a,c){var d,e=this;if(this._request===a){switch(c.statusCode){case 301:case 302:case 303:case 307:case 308:return this._url=this._parseUrl(c.headers.location),this._method="GET","content-type"in this._loweredHeaders&&(delete this._headers[this._loweredHeaders["content-type"]],delete this._loweredHeaders["content-type"]),"Content-Type"in this._headers&&delete this._headers["Content-Type"],delete this._headers["Content-Length"],this.upload._reset(),this._finalizeHeaders(),void this._sendHxxpRequest()}return this._response=c,this._response.on("data",function(a){return e._onHttpResponseData(c,a)}),this._response.on("end",function(){return e._onHttpResponseEnd(c)}),this._response.on("close",function(){return e._onHttpResponseClose(c)}),this.status=this._response.statusCode,this.statusText=l.STATUS_CODES[this.status],this._parseResponseHeaders(c),(d=this._responseHeaders["content-length"])?(this._totalBytes=parseInt(d),this._lengthComputable=!0):this._lengthComputable=!1,this._setReadyState(b.HEADERS_RECEIVED)}},b.prototype._onHttpResponseData=function(a,c){if(this._response===a)return this._responseParts.push(c),this._loadedBytes+=c.length,this.readyState!==b.LOADING&&this._setReadyState(b.LOADING),this._dispatchProgress("progress")},b.prototype._onHttpResponseEnd=function(a){if(this._response===a)return this._parseResponse(),this._request=null,this._response=null,this._setReadyState(b.DONE),this._dispatchProgress("load"),this._dispatchProgress("loadend")},b.prototype._onHttpResponseClose=function(a){var c;if(this._response===a)return c=this._request,this._setError(),c.abort(),this._setReadyState(b.DONE),this._dispatchProgress("error"),this._dispatchProgress("loadend")},b.prototype._onHttpTimeout=function(a){if(this._request===a)return this._setError(),a.abort(),this._setReadyState(b.DONE),this._dispatchProgress("timeout"),this._dispatchProgress("loadend")},b.prototype._onHttpRequestError=function(a,c){if(this._request===a)return this._setError(),a.abort(),this._setReadyState(b.DONE),this._dispatchProgress("error"),this._dispatchProgress("loadend")},b.prototype._dispatchProgress=function(a){var b;b=new j(a,this),b.lengthComputable=this._lengthComputable,b.loaded=this._loadedBytes,b.total=this._totalBytes,this.dispatchEvent(b)},b.prototype._setError=function(){this._request=null,this._response=null,this._responseHeaders=null,this._responseParts=null},b.prototype._parseUrl=function(a){var b,c,d,e;return e=o.parse(a,!1,!0),e.hash=null,e.auth&&("undefined"!=typeof d&&null!==d||"undefined"!=typeof c&&null!==c)&&(b=e.auth.indexOf(":"),b===-1?d||(d=e.auth):(d||(d=e.substring(0,b)),c||(c=e.substring(b+1)))),(d||c)&&(e.auth=""+d+":"+c),e},b.prototype._parseResponseHeaders=function(a){var b,c,d,e;this._responseHeaders={},e=a.headers;for(c in e)d=e[c],b=c.toLowerCase(),this._privateHeaders[b]||(null!==this._mimeOverride&&"content-type"===b&&(d=this._mimeOverride),this._responseHeaders[b]=d);null===this._mimeOverride||"content-type"in this._responseHeaders||(this._responseHeaders["content-type"]=this._mimeOverride)},b.prototype._parseResponse=function(){var a,b,c,e,f,g,h;switch(b=d.concat?d.concat(this._responseParts):this._concatBuffers(this._responseParts),this._responseParts=null,this.responseType){case"text":this._parseTextResponse(b);break;case"json":this.responseText=null;try{this.response=JSON.parse(b.toString("utf-8"))}catch(i){e=i,this.response=null}break;case"buffer":this.responseText=null,this.response=b;break;case"arraybuffer":for(this.responseText=null,a=new ArrayBuffer(b.length),f=new Uint8Array(a),c=g=0,h=b.length;0<=h?g<h:g>h;c=0<=h?++g:--g)f[c]=b[c];this.response=a;break;default:this._parseTextResponse(b)}},b.prototype._parseTextResponse=function(a){var b;try{this.responseText=a.toString(this._parseResponseEncoding())}catch(c){b=c,this.responseText=a.toString("binary")}this.response=this.responseText},b.prototype._parseResponseEncoding=function(){var a,b,c;return b=null,(a=this._responseHeaders["content-type"])&&(c=/\;\s*charset\=(.*)$/.exec(a))?c[1]:"utf-8"},b.prototype._concatBuffers=function(a){var b,c,e,f,g,h,i;if(0===a.length)return new d(0);if(1===a.length)return a[0];for(c=0,f=0,h=a.length;f<h;f++)b=a[f],c+=b.length;for(e=new d(c),c=0,g=0,i=a.length;g<i;g++)b=a[g],b.copy(e,c),c+=b.length;return e},b}(i),b.exports=h,h.XMLHttpRequest=h,g=function(a){function b(){b.__super__.constructor.apply(this,arguments)}return r(b,a),b}(Error),h.SecurityError=g,e=function(a){function b(){b.__super__.constructor.apply(this,arguments)}return r(b,a),b}(Error),e=function(a){function b(){return p=b.__super__.constructor.apply(this,arguments)}return r(b,a),b}(Error),h.InvalidStateError=e,f=function(a){function b(){b.__super__.constructor.apply(this,arguments)}return r(b,a),b}(Error),h.NetworkError=f,j=function(){function a(a,b){this.type=a,this.target=b,this.currentTarget=this.target,this.lengthComputable=!1,this.loaded=0,this.total=0}return a.prototype.bubbles=!1,a.prototype.cancelable=!1,a.prototype.target=null,a.prototype.loaded=null,a.prototype.lengthComputable=null,a.prototype.total=null,a}(),h.XMLHttpRequestProgressEvent=j,k=function(a){function b(a){b.__super__.constructor.call(this),this._request=a,this._reset()}return r(b,a),b.prototype._reset=function(){this._contentType=null,this._body=null},b.prototype._setData=function(a){var b,c,e,f,g,h,i,j;if("undefined"!=typeof a&&null!==a)if("string"==typeof a)0!==a.length&&(this._contentType="text/plain;charset=UTF-8"),this._body=new d(a,"utf8");else if(d.isBuffer(a))this._body=a;else if(a instanceof ArrayBuffer){for(b=new d(a.byteLength),f=new Uint8Array(a),c=g=0,i=a.byteLength;0<=i?g<i:g>i;c=0<=i?++g:--g)b[c]=f[c];this._body=b}else{if(!(a.buffer&&a.buffer instanceof ArrayBuffer))throw new Error("Unsupported send() data "+a);for(b=new d(a.byteLength),e=a.byteOffset,f=new Uint8Array(a.buffer),c=h=0,j=a.byteLength;0<=j?h<j:h>j;c=0<=j?++h:--h)b[c]=f[c+e];this._body=b}},b.prototype._finalizeHeaders=function(a,b){this._contentType&&("content-type"in b||(a["Content-Type"]=this._contentType)),this._body&&(a["Content-Length"]=this._body.length.toString())},b.prototype._startUpload=function(a){this._body&&a.write(this._body),a.end()},b}(i),h.XMLHttpRequestUpload=k}).call(this)}).call(this,a("_process"),a("buffer").Buffer)},{_process:87,buffer:44,http:127,https:73,os:82,url:138}],143:[function(a,b,c){function d(){for(var a={},b=0;b<arguments.length;b++){var c=arguments[b];for(var d in c)e.call(c,d)&&(a[d]=c[d])}return a}b.exports=d;var e=Object.prototype.hasOwnProperty},{}],144:[function(a,b,c){"use strict";function d(a){var b="";do b=h[a%i]+b,a=Math.floor(a/i);while(a>0);return b}function e(a){var b=0;for(l=0;l<a.length;l++)b=b*i+j[a.charAt(l)];return b}function f(){var a=d(+new Date);return a!==g?(k=0,g=a):a+"."+d(k++)}for(var g,h="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),i=64,j={},k=0,l=0;l<i;l++)j[h[l]]=l;f.encode=d,f.decode=e,b.exports=f},{}]},{},[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(u.DEFAULT_HOSTS=u.REALM_HOSTS[b.toUpperCase()][a.toUpperCase()],!u.DEFAULT_HOSTS)throw"Invalid Environment"}catch(d){var e,f=u.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=u,this.environment=a,c.orgid&&c.token){var e=A.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/activity"),j=a("./services/analytics"),k=a("./services/collab"),l=a("./services/product"),m=a("./services/xapi"),n=a("./services/attempts"),o=a("./services/push"),p=a("./services/pushX"),q=a("./services/pub"),r=a("./services/sisevents"),s=a("./services/lrs"),t=a("./services/spaces"),u=a("./config"),v=a("./open_access"),w=a("./services/superuser"),x=a("./services/invitations"),y=a("./services/workflows"),z=a("./services/integrations"),A=a("./token/validations"),B=a("./services/drive"),C=a("./services/taxonomy"),D=a("./services/rules"),E=a("./services/datasyncmanager");c.init=d,e.prototype.authWithCredentials=f.authWithCredentials,e.prototype.authWithToken=f.authWithToken,e.prototype.authWithExtUser=f.authWithExtUser,e.prototype.getClassEnrolmentsStat=v.getClassEnrolmentsStat,e.prototype.getSingleInvitation=v.getSingleInvitation,e.prototype.request=g.api.genericAPICaller,e.prototype.Auth=h,e.prototype.Activity=i,e.prototype.Analytics=j,e.prototype.Collab=k,e.prototype.Product=l,e.prototype.Xapi=m,e.prototype.Attempts=n,e.prototype.Push=o,e.prototype.Pub=q,e.prototype.SISEvents=r,e.prototype.LRS=s,e.prototype.PushX=p,e.prototype.Spaces=t,e.prototype.Superuser=w,e.prototype.Invitations=x,e.prototype.Workflows=y,e.prototype.Integrations=z,e.prototype.Drive=B,e.prototype.Taxonomy=C,e.prototype.Rules=D,e.prototype.Datasyncmanager=E},{"./config":2,"./helpers":3,"./open_access":10,"./services/activity":13,"./services/analytics":14,"./services/attempts":15,"./services/auth":16,"./services/collab":17,"./services/datasyncmanager":18,"./services/drive":19,"./services/integrations":20,"./services/invitations":21,"./services/lrs":22,"./services/product":23,"./services/pub":24,"./services/push":27,"./services/pushX":25,"./services/rules":28,"./services/sisevents":29,"./services/spaces":30,"./services/superuser":31,"./services/taxonomy":32,"./services/workflows":33,"./services/xapi":34,"./token":35,"./token/validations":36}],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",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",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",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",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",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",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",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",getAllJobs:"/accounts/{accountId}/ext-users/{extUserId}/jobs",getJob:"/accounts/{accountId}/ext-users/{extUserId}/jobs/{jobId}",getAllClassesAPI:"/org/{orgId}/classes",getParticularClassAPI:"/org/{orgId}/classes/{classId}",getParticularShadowClassAPI:"/org/{orgId}/shadow/classes/{extClassId}",classProductAssociation:"/org/{orgId}/classes/{classId}/associate-product/{productcode}",multiClassProductAssociations:"/org/{orgId}/classes/{classId}/associate-product/multi",enrollUsertoClass:"/org/{orgId}/classes/{classId}/enroll-user/{userId}",enrollSelftoClass:"/org/{orgId}/classes/{classId}/enroll-self",enrollMultiUserstoClass:"/org/{orgId}/classes/{classId}/enroll-user/multi",createClass:"/org/{orgId}/classes",createMultipleClasses:"/org/{orgId}/classes/multi",specificClass:"/org/{orgId}/classes/{classId}",cloneClass:"/org/{orgId}/classes/{classId}/clone",ClassAppdata:"/org/{orgId}/classes/{classid}/appdata",generateClassCode:"/org/{orgId}/classes/{classId}/class-code/generate",getUserSpaces:"/accounts/{accountid}/ext-users/{extuserid}/spaces",validateSpaceCode:"/accounts/{accountid}/space-code/validate",validateClassCode:"/accounts/{accountid}/class-code/validate",joinInstituteSpace:"/accounts/{accountid}/join-institute-space",provisionSpacesToStudent:"/accounts/{accountId}/student/provision-spaces",provisionSpacesToTeacher:"/accounts/{accountId}/teacher/provision-spaces",shadowProvision:"/org/{orgId}/shadow-provision",provisionBulkSpaces:"/org/{orgId}/provision-spaces/bulk",entitleUserToProduct:"/accounts/{accountId}/entitle-user",microEntitleUserToProduct:"/accounts/{accountId}/entitle-user/micro",bulkMicroEntitleProductToUser:"/accounts/{accountId}/entitle-user/micro/bulk",enrollUserInClass:"/accounts/{accountId}/enroll-with-classcode",getExtProductAPI:"/accounts/{accountId}/products/{extProductId}",getSpaceDetails:"/accounts/{accountId}/spaces/{spacekey}",updateUserInformation:"/accounts/{accountId}/update-user-information",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"},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",getAllAssignedPathsOfClass:"/{orgId}/class/assigned-paths",getMyAssignedPathsOfClass:"/{orgId}/user/class/assigned-paths",getAssignedPathAnalytics:"/{orgId}/class/assigned-paths/aggregations",timeseriesAnalytics:"/progress/timeseries"},c.SISEVENTS_API_URLS={postSingleSISEvent:"/{orgId}/events",postMultiSISEvent:"/{orgId}/events/multi"},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",resetUserProductProgress:"/accounts/{accountId}/progress/user/product/reset"},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"},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"},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",updateSchedule:"/accounts/{accountId}/context/{context}/schedule/{scheduleId}"},c.DRIVE_API_URLS={getAParticularDocument:"/accounts/{accountid}/users/{extuserid}/documents/{documentid}",getAllDocumentsInAFolder:"/accounts/{accountid}/users/{extuserid}/documents"},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:90,"string-template":132,superagent:133}],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=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":141}],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:90,superagent:133}],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:69,q:90,superagent:133}],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(){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),
2
+ 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:69,q:90,superagent:133}],13:[function(a,b,c){b.exports=a("./activity")},{"./activity":11}],14:[function(a,b,c){function d(){return{archiveUserAnalytics:i.bind(this),getArchivedUserAnalytics:y.bind(this),getOrgAnalyticsStat:e.bind(this),getClassAnalytics:x.bind(this),getClassProductRecentPendingSubmissions:p.bind(this),getClassRecordUserAggregations:w.bind(this),getClassRecord:q.bind(this),getClassRecordItemAggregations:r.bind(this),getShowcaseRecordOfAClass:s.bind(this),getGroupRecord:t.bind(this),getClassGroupsRecentPendingSubmissions:u.bind(this),getGroupsWithEvaluatedOnce:v.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),getQuestionProgressByLearningObjective:z.bind(this),getAllAssignedPathsOfClass:A.bind(this),getMyAssignedPathsOfClass:C.bind(this),getAssignedPathAnalytics:B.bind(this),getMyParticularAssignedPathOfClass:D.bind(this),getTimeseriesAnalytics:E.bind(this),postProgressTimeseries:F.bind(this)}}function e(a){var b=this,c=G.defer(),d={};if(a&&a.type)if(d=J.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=J.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=H.get(f).query(g);h=J.api.setupAPIToken(h,b.token),b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h.end(function(a,b){a?(a=new K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d)}else d.message=d.description="type not found in request options",d=new K(J.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function f(a){var b=this,c=G.defer(),d={};if(a&&a.type&&a.userid&&a.productcode)if(d=J.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=J.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=H.get(f).query(g);h=J.api.setupAPIToken(h,b.token),b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h.end(function(a,b){a?(a=new K(J.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 K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function g(a){var b=this,c=G.defer(),d={};if(a&&a.userprogressid)if(d=J.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getAnalyticProductById;e=J.api.constructAPIUrl(e,{orgId:b.orgId,userProgressId:a.userprogressid});var f=H.get(e);f=J.api.setupAPIToken(f,b.token),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)})}else d.message=d.description="Required parameter 'userprogressid' not found in request options",d=new K(J.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function h(a){var b=this,c=G.defer(),d={};if(a&&a.ext_user_id&&a.productcode&&a.itemcode&&(a.submission_order||a.ext_link_id)&&a.part)if(d=J.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getExternalDataForUserAnalyticItem;e=J.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=H.get(e).query(f);g=J.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function i(a){var b=this,c={},d=G.defer();if(a&&a.userid&&a.productid)if(c=J.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=J.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=H.post(f).query(e).set("Content-Type","application/json");g=J.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function j(a){var b=this,c={},d=G.defer();if(c=J.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=J.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=H.get(f).query(e);g=J.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new K(J.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}return d.promise}function k(a){var b=this,c=G.defer(),d={};if(a&&a.classid&&a.productcode&&a.userid)if(d=J.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getUserClassRecentSubmissions;e=J.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=H.get(e).query(f);g=J.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function l(a){var b=this,c={},d=G.defer();if(a&&a.classid&&a.productcode)if(c=J.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getStudentsWithEvaluatedOnce;e=J.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode},g=H.get(e).query(f);g=J.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(c=new K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function m(a){var b=this,c=G.defer(),d={};if(a&&a.userid&&a.productcode)if(d=J.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.appState;e=J.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=H.get(e).query(f);g=J.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function n(a){var b=this,c=G.defer(),d={};if(a&&a.userid&&a.productcode&&a.appdata)if(d=J.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.appState;e=J.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=H.put(e).query(f).set("Content-Type","application/json").set("Accept","application/json").send(a.appdata);g=J.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function o(a){var b=this,c=G.defer(),d={};if(a&&a.userid&&a.productcode)if(d=J.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.appState;e=J.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=H["delete"](e).query(f);g=J.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function p(a){var b=this,c=G.defer(),d={};if(a&&a.classid&&a.productcode)if(d=J.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassProductRecentPendingSubmissions;e=J.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=H.get(e).query(f);g=J.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function q(a){var b=this,c=G.defer(),d={};if(a&&a.classid&&a.productcode)if(d=J.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassRecord;e=J.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode,includeContext:a.includeContext},g=H.get(e).query(f);g=J.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function r(a){var b=this,c=G.defer(),d={};if(a&&a.classid&&a.productcode)if(d=J.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassRecordItemAggregations;e=J.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode,"item-code":a["item-code"]},g=H.get(e).query(f);g=J.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function s(a){var b=this,c=G.defer(),d={};if(a&&a.classid)if(d=J.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getShowcaseRecordOfAClass;e=J.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=H.get(e).query(f);g=J.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function t(a){var b=this,c=G.defer(),d={};if(a&&a.classid&&a.productcode&&a.groupid)if(d=J.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getGroupRecord;e=J.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=H.get(e).query(f);g=J.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function u(a){var b=this,c=G.defer(),d={};if(a&&a.classid&&a.productcode)if(d=J.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassGroupsRecentPendingSubmissions;e=J.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=H.get(e).query(f);g=J.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function v(a){var b=this,c={},d=G.defer();if(a&&a.classid&&a.productcode)if(c=J.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getGroupsWithEvaluatedOnce;e=J.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode},g=H.get(e).query(f);g=J.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(c=new K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function w(a){var b=this,c={},d=G.defer();if(a&&a.classid&&a.productcode)if(c=J.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getClassRecordUserAggregations;e=J.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,productcode:a.productcode,userid:a.userid},g=H.get(e).query(f);g=J.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(c=new K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function x(a){var b=this,c=G.defer(),d={};if(a&&a.type&&a.analyticsDataType&&a.classid)if(d=J.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=J.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=H.get(f).query(g);h=J.api.setupAPIToken(h,b.token),b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h.end(function(a,b){a?(a=new K(J.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 K(J.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 K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function y(a){var b=this,c=G.defer(),d={};if(a&&a.useranalyticid)if(d=J.validations.isAuthenticated(b.orgId,b.token))c.reject(d);else{var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getArchivedUserAnalytics;e=J.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=H.get(e).query(f);g=J.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(a=new K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function z(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 A(a){var b=this,c=G.defer(),d=J.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=J.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid},g=H.get(e).query(f);g=J.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function B(a){var b=this,c=G.defer(),d=J.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.assignedPathId&&a.productcode){var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getAssignedPathAnalytics;e=J.api.constructAPIUrl(e,{orgId:b.orgId});var f={classid:a.classid,assignedpathid:a.assignedPathId,productcode:a.productcode},g=H.get(e).query(f);g=J.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new K(J.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - classid or assignedPathId or productcode not found in request options.",d=new K(J.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function C(a){var b=this,c=G.defer(),d=J.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=J.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);var g=H.get(e).query(f);g=J.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function D(a){var b=this,c=G.defer(),d=J.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.userid&&a.assignedPathId){var e=b.config.DEFAULT_HOSTS.ANALYTICS+b.config.ANALYTICS_API_URLS.getMyAssignedPathsOfClass;e=J.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);var g=H.get(e).query(f);g=J.api.setupAPIToken(g,b.token),b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new K(J.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d={},d.message=d.description="Mandatory params - classid, userid, assignedPathId not found in request options.",d=new K(J.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function E(a){var b,c=this,d=G.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=H.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.agent(L).end(function(a,c){a?(b=new K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function F(a){var b,c=this,d=G.defer();if(a&&a.body&&a.body.query){var e=c.config.DEFAULT_HOSTS.ANALYTICS+c.config.ANALYTICS_API_URLS.timeseriesAnalytics,f=H.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(L).end(function(a,c){a?(b=new K(J.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 K(J.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.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:38,q:90,superagent:133}],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)}}function e(a){var b,c=this,d=k.defer();if(a&&a.userid&&a.activityid){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.userAttempts;e=m.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=l.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new n(m.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 n(m.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function f(a){var b,c=this,d=k.defer();if(a&&a.userid&&a.activityid&&a.body){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.userAttempts;e=m.api.constructAPIUrl(e,{orgId:c.orgId,userId:a.userid,activityId:a.activityid});var f=l.post(e).send(a.body);c.traceid&&f.set("X-Amzn-Trace-Id",c.traceid),f.end(function(a,b){a?(a=new n(m.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 n(m.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function g(a){var b,c=this,d=k.defer();if(a&&a.userid&&a.activityid){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.getUserAttemptStatsForActivity;e=m.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=l.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new n(m.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 n(m.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function h(a){var b,c=this,d=k.defer();if(a&&a.userid&&a.activityid&&a.attemptid){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.getUserAttemptForActivity;e=m.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=l.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new n(m.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 n(m.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function i(a){var b,c=this,d=k.defer();if(a&&a.userid&&a.activityid){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.getUserFirstAttemptForActivity;e=m.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=l.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new n(m.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 n(m.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function j(a){var b,c=this,d=k.defer();if(a&&a.userid&&a.activityid){var e=c.config.DEFAULT_HOSTS.ATTEMPTS+c.config.ATTEMPTS_API_URLS.getUserLastAttemptForActivity;e=m.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=l.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 n(m.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 n(m.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}var k=a("q"),l=a("superagent"),m=a("../../helpers"),n=m.errors.DLSError;b.exports=d},{"../../helpers":3,q:90,superagent:133}],16:[function(a,b,c){function d(){return{pisImport:k.bind(this),getAllUsers:g.bind(this),getUserProfile:e.bind(this),deleteUserProfile:f.bind(this),updateUserRole:h.bind(this),getUserClasses:i.bind(this),getClassUsers:j.bind(this),enrollUsertoClass:z.bind(this),enrollSelftoClass:A.bind(this),enrollMultiUserstoClass:B.bind(this),unEnrollMultiUserstoClass:C.bind(this),unEnrollUsertoClass:D.bind(this),getOrgSettings:l.bind(this),updateOrgSettings:m.bind(this),generateClassCode:n.bind(this),getAllJobs:o.bind(this),getJob:p.bind(this),createClass:F.bind(this),updateClass:G.bind(this),createMultipleClasses:H.bind(this),deleteClass:I.bind(this),cloneClass:$.bind(this),getAllClasses:q.bind(this),getParticularClass:r.bind(this),getParticularShadowClass:s.bind(this),createClassProductAssociation:t.bind(this),removeClassProductAssociation:u.bind(this),createMultiClassProductAssociations:v.bind(this),addItemsToShowcaseOfAClass:Y.bind(this),deleteItemsFromShowcaseOfAClass:Z.bind(this),getClassAppdata:w.bind(this),putClassAppdata:x.bind(this),deleteClassAppdata:y.bind(this),encodeURLParameter:E.bind(this),createAssignedPath:J.bind(this),deleteAssignedPath:K.bind(this),updateAssignedPath:L.bind(this),createGroup:M.bind(this),getAllGroupsByPath:N.bind(this),getAGroup:O.bind(this),updateGroup:P.bind(this),deleteGroup:Q.bind(this),getAllMembersOfAGroup:R.bind(this),getAllGroupMembersByPath:S.bind(this),createMultiUserGroupMembership:T.bind(this),deleteMultiUserGroupMembership:U.bind(this),getMyAllMemberships:X.bind(this),archiveGroup:V.bind(this),unarchiveGroup:W.bind(this)}}function e(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(f,{orgId:b.orgId,userId:e});var g={},h=aa.get(f).query(g);b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h=ca.api.setupAPIToken(h,b.token),h.end(function(a,b){if(a)a=new ea(ca.errors.ERROR_TYPES.API_ERROR,a),c.reject(a);else{var d=da.convertUserResponse({data:b.body});c.resolve(d)}})}return c.promise}function f(a){var b=this,c=_.defer(),d=ca.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;
3
+ f=ca.api.constructAPIUrl(f,{orgId:b.orgId,userId:e});var g=aa["delete"](f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function g(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(p,{index:"users"});var q={query:JSON.stringify(o)},r=aa.get(p).query(q);b.traceid&&r.set("X-Amzn-Trace-Id",b.traceid),r=ca.api.setupAPIToken(r,b.token),r.end(function(d,e){if(d){var f={type:ca.errors.ERROR_TYPES.API_ERROR,err:d},g=da.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=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,userId:a.userid});var f={ext_data:a.ext_data,target_role:a.target_role},g=aa.put(e).set("Content-Type","application/json").set("Accept","application/json").send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,h),c.reject(h)}return c.promise}function i(a){var b=this,c=_.defer(),d=ca.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=ca.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=aa.get(f).query(g);b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h=ca.api.setupAPIToken(h,b.token),h.end(function(a,b){a?(a=new ea(ca.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}return c.promise}function j(a){var b=this,c=_.defer(),d=ca.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=ca.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=aa.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.agent(fa).end(function(a,b){a?(a=new ea(ca.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):(b.body.entities=da.convertEnrollmetsResponse({data:b.body.entities}),c.resolve(b.body))})}else d={},d.message=d.description="Required parameter classid is not defined.",d=new ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function k(a){var b=this,c=_.defer(),d=ca.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=ca.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=aa.post(e).query(g).set("Content-Type","multipart/form-data").attach("upfile",f);b.traceid&&h.set("X-Amzn-Trace-Id",b.traceid),h=ca.api.setupAPIToken(h,b.token),h.end(function(a,b){a?(a=new ea(ca.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}return c.promise}function l(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId});var f={};a&&a.field&&(e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getSettingsField,e=ca.api.constructAPIUrl(e,{orgId:b.orgId,field:a.field}));var g=aa.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new ea(ca.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}return c.promise}function m(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId});var f=aa.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=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new ea(ca.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}return c.promise}function n(a){var b,c=this,d=_.defer();if(a&&a.classid)if(b=ca.validations.isAuthenticated(c.orgId,c.token))d.reject(b);else{var e=c.config.DEFAULT_HOSTS.AUTH+c.config.AUTH_API_URLS.generateClassCode;e=ca.api.constructAPIUrl(e,{orgId:c.orgId,classId:a.classid});var f=aa.post(e);c.traceid&&f.set("X-Amzn-Trace-Id",c.traceid),f=ca.api.setupAPIToken(f,c.token),f.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function o(a){var b=this,c=_.defer();if(a&&a.accountId&&a.extUserId){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getAllJobs;d=ca.api.constructAPIUrl(d,{accountId:a.accountId,extUserId:a.extUserId});var e={};a.jobType&&(e.jobType=a.jobType);var f=aa.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(g=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function p(a){var b=this,c=_.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=ca.api.constructAPIUrl(d,{accountId:a.accountId,extUserId:a.extUserId,jobId:a.jobId});var e={jobType:a.jobType},f=aa.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(g=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function q(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(m,{index:"classes"});var n={query:JSON.stringify(l)},o=aa.get(m).query(n);b.traceid&&o.set("X-Amzn-Trace-Id",b.traceid),o=ca.api.setupAPIToken(o,b.token),o.end(function(b,d){if(b){var e={type:ca.errors.ERROR_TYPES.API_ERROR,err:b},f=da.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,studentCount:j.studentCount,teacherCount:j.teacherCount};j.tagid_1&&(k.tagid_1=j.tagid_1,k.tagname_1=j.tagname_1,k.taglookup_1=j.taglookup_1),j.tagid_2&&(k.tagid_2=j.tagid_2,k.tagname_2=j.tagname_2,k.taglookup_2=j.taglookup_2),j.tagid_3&&(k.tagid_3=j.tagid_3,k.tagname_3=j.tagname_3,k.taglookup_3=j.taglookup_3),g.entities.push(k)}c.resolve(g)}})}return c.promise}function r(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId});var f=aa.get(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.agent(fa).end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function s(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,extClassId:a.ext_classid});var f=aa.get(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function t(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId,productcode:a.productcode});var f=aa.post(e).set("Content-Type","application/json").set("Accept","application/json");b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function u(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId,productcode:a.productcode});var f={},g=aa["delete"](e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function v(a){var b=_.defer(),c=this,d=ca.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=ca.api.constructAPIUrl(g,{orgId:c.orgId,classId:a.classId});var i=aa.post(g).set("Content-Type","application/json").set("Accept","application/json").send(h);c.traceid&&i.set("X-Amzn-Trace-Id",c.traceid),i=ca.api.setupAPIToken(i,c.token),i.end(function(a,c){a?(d=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),b.reject(d);return b.promise}function w(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classid:a.classid});var f=aa.get(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function x(a){var b=this,c=_.defer(),d=ca.validations.isAuthenticated(b.orgId,b.token);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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classid:a.classid});var f=aa.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=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function y(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classid:a.classid});var f=aa["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function z(a){var b=this,c={},d=_.defer();if(a&&a.classid&&a.userid)if(c=ca.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.enrollUsertoClass;e=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid,userId:a.userid});var f={},g=aa.post(e).set("Content-Type","application/json").set("Accept","application/json").query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function A(a){var b=this,c={},d=_.defer();if(a&&a.classid)if(c=ca.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.enrollSelftoClass;e=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f={classrole:a.classrole},g=aa.post(e).set("Content-Type","application/json").set("Accept","application/json").send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function B(a){var b=this,c={},d=_.defer();if(a&&a.classid&&a.users)if(c=ca.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.enrollMultiUserstoClass;e=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f={users:a.users},g=aa.post(e).set("Content-Type","application/json").set("Accept","application/json").send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function C(a){var b=this,c={},d=_.defer();if(a&&a.classid&&a.users)if(c=ca.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.enrollMultiUserstoClass;e=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f={users:a.users},g=aa["delete"](e).set("Content-Type","application/json").set("Accept","application/json").send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function D(a){var b=this,c={},d=_.defer();if(a&&a.classid&&a.userid)if(c=ca.validations.isAuthenticated(b.orgId,b.token))d.reject(c);else{var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.enrollUsertoClass;e=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid,userId:a.userid});var f={},g=aa["delete"](e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function E(a){var b={};for(var c in a)b[a[c]]=encodeURIComponent(a[c]);return b}function F(a){var b=this,c=_.defer(),d=ca.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=ca.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);var g=aa.post(e).send(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){if(a)a=new ea(ca.errors.ERROR_TYPES.API_ERROR,a),c.reject(a);else{var d=da.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function G(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f=aa.put(e).send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function H(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId});var f=aa.post(e).send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function I(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f=aa["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=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function J(a){var b=this,c=_.defer(),d=ca.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else if(a&&a.classid&&a.data&&a.data.title&&a.data.duedate&&a.data.items&&a.data.items.length>0){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.createAssignedPath;e=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f=aa.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=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new ea(ca.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 duedate or items not found in request options.",d=new ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function K(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid,assignedPathId:a.assignedpathid});var f=aa["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function L(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid,assignedPathId:a.assignedpathid});var f=aa.put(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),a.data&&f.send(a.data),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function M(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId});var f=aa.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function N(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId});var f={path:a.path};a.cursor&&(f.cursor=a.cursor);var g=aa.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(d=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function O(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,groupId:a.groupId});var f=aa.get(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function P(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,groupId:a.groupId});var f=aa.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=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function Q(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,groupId:a.groupId});var f=aa["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function R(a){var b=this,c=_.defer(),d={},e=ca.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=ca.api.constructAPIUrl(f,{orgId:b.orgId,groupId:a.groupId}),a.cursor&&(d.cursor=a.cursor);var g=aa.get(f).set("Content-Type","application/json").set("Accept","application/json").send(d);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(e=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function S(a){var b=this,c=_.defer(),d={},e=ca.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=ca.api.constructAPIUrl(f,{orgId:b.orgId}),d.path=a.path,a.cursor&&(d.cursor=a.cursor);var g=aa.get(f).set("Content-Type","application/json").set("Accept","application/json").query(d);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(e=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function T(a){var b=this,c=_.defer(),d={},e=ca.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=ca.api.constructAPIUrl(f,{orgId:b.orgId,groupId:a.groupId}),d=a.body;var g=aa.post(f).set("Content-Type","application/json").set("Accept","application/json").send(d);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(e=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function U(a){var b=this,c=_.defer(),d={},e=ca.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=ca.api.constructAPIUrl(f,{orgId:b.orgId,groupId:a.groupId}),d=a.body;var g=aa["delete"](f).set("Content-Type","application/json").set("Accept","application/json").send(d);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(e=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);
4
+ return c.promise}function V(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,groupId:a.groupId});var f=aa.put(e).set("Content-Type","application/json").set("Accept","application/json").send({});b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function W(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,groupId:a.groupId});var f=aa.put(e).set("Content-Type","application/json").set("Accept","application/json").send({});b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function X(a){var b=this,c=_.defer(),d={},e=ca.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=ca.api.constructAPIUrl(f,{orgId:b.orgId,userId:a.userId}),d.path=a.path,a.cursor&&(d.cursor=a.cursor);var g=aa.get(f).set("Content-Type","application/json").set("Accept","application/json").query(d);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g=ca.api.setupAPIToken(g,b.token),g.end(function(a,b){a?(e=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function Y(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId});var f=aa.post(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.send(a.body),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function Z(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classId});var f=aa["delete"](e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.send(a.body),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function $(a){var b=this,c=_.defer(),d=ca.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=ca.api.constructAPIUrl(e,{orgId:b.orgId,classId:a.classid});var f=aa.post(e).send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=ca.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(a=new ea(ca.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 ea(ca.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}var _=a("q"),aa=a("superagent"),ba=a("agentkeepalive"),ca=a("../../helpers"),da=a("../../helpers/lib/api/converter"),ea=ca.errors.DLSError;b.exports=d;var fa=new ba({timeout:6e4,freeSocketTimeout:3e4})},{"../../helpers":3,"../../helpers/lib/api/converter":4,agentkeepalive:38,q:90,superagent:133}],17:[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:90,superagent:133}],18:[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:38,q:90,superagent:133}],19:[function(a,b,c){function d(){return{getAParticularDocument:e.bind(this),getAllDocumentsInAFolder:f.bind(this)}}function e(a){var b=this,c=g.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=i.api.constructAPIUrl(d,e);var f={folderid:a.folderid},k=h.get(d).query(f);b.traceid&&k.set("X-Amzn-Trace-Id",b.traceid),k.end(function(a,b){a?(a=new j(i.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else{var l={};l.message=l.description="Mandatory params - accountid or extuserid or documentid or folderid not found in request options.",l=new j(i.errors.ERROR_TYPES.SDK_ERROR,l),c.reject(l)}return c.promise}function f(a){var b=this,c=g.defer();if(a&&a.accountid&&a.extuserid&&a.folderid){var d=b.config.DEFAULT_HOSTS.DRIVE+b.config.DRIVE_API_URLS.getAllDocumentsInAFolder;d=i.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=h.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new j(i.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else{var k={};k.message=k.description="Mandatory params - accountid or extuserid or folderid not found in request options.",k=new j(i.errors.ERROR_TYPES.SDK_ERROR,k),c.reject(k)}return c.promise}var g=a("q"),h=a("superagent"),i=a("../../helpers"),j=i.errors.DLSError;b.exports=d},{"../../helpers":3,q:90,superagent:133}],20:[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)}}function e(){var a,b=this,c=n.defer(),d=b.config.DEFAULT_HOSTS.INTEGRATION+b.config.INTEGRATIONS_API_URLS.getGetStreamCredentials;d=p.api.constructAPIUrl(d,{accountId:b.accountId});var e=o.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 r(p.errors.ERROR_TYPES.API_ERROR,b),c.reject(a)):c.resolve(d)}),c.promise}function f(a){var b,c=this,d=n.defer();if(a&&a.index&&a.query){var e=c.config.DEFAULT_HOSTS.INTEGRATION+c.config.INTEGRATIONS_API_URLS.queryDataFromSearch;e=p.api.constructAPIUrl(e,{index:a.index});var f={query:a.query},g=o.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){if(a){var c={type:p.errors.ERROR_TYPES.API_ERROR,err:a},e=q.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 r(p.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function g(a){var b,c=this,d=n.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=p.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=o.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new r(p.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 r(p.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function h(a){var b,c=this,d=n.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=p.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=o.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new r(p.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 r(p.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function i(a){var b,c=this,d=n.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=p.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=o.get(e).query(f);c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new r(p.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 r(p.errors.ERROR_TYPES.SDK_ERROR,b),d.reject(b);return d.promise}function j(a){var b,c=n.defer(),d=this;if(a&&a.events){var e=d.config.DEFAULT_HOSTS.INTEGRATION+d.config.INTEGRATIONS_API_URLS.customEvents;e=p.api.constructAPIUrl(e,{accountId:d.accountId});var f=o.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 r(p.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 r(p.errors.ERROR_TYPES.SDK_ERROR,b),c.reject(b);return c.promise}function k(a){var b,c=n.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=p.api.constructAPIUrl(e,{accountId:a.accountid,context:a.context});var f=o.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 r(p.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 r(p.errors.ERROR_TYPES.SDK_ERROR,b),c.reject(b);return c.promise}function l(a){var b,c=n.defer(),d=this;if(a&&a.context&&a.accountid){var e=d.config.DEFAULT_HOSTS.INTEGRATION+d.config.INTEGRATIONS_API_URLS.schedules;e=p.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=o.get(e).query(f);d.traceid&&g.set("X-Amzn-Trace-Id",d.traceid),g.end(function(a,d){a?(b=new r(p.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 r(p.errors.ERROR_TYPES.SDK_ERROR,b),c.reject(b);return c.promise}function m(a){var b,c=n.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.updateSchedule;e=p.api.constructAPIUrl(e,{accountId:a.accountid,context:a.context,scheduleId:a.scheduleid});var f=o.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 r(p.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 r(p.errors.ERROR_TYPES.SDK_ERROR,b),c.reject(b);return c.promise}var n=a("q"),o=a("superagent"),p=a("../../helpers"),q=a("../../helpers/lib/api/converter"),r=p.errors.DLSError;b.exports=d},{"../../helpers":3,"../../helpers/lib/api/converter":4,q:90,superagent:133}],21:[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:90,superagent:133}],22:[function(a,b,c){function d(){var a={};try{this.lrs=new g.LRS({endpoint:this.config.DEFAULT_HOSTS.XAPI+"/"+this.orgId+"/tapi",auth:this.token.access_token,allowFail:!1}),this.tincan=new g({recordStores:[this.lrs]})}catch(b){return b.description="Error while initializing lrs.",b.message=b.description,a=new j(i.errors.ERROR_TYPES.SDK_ERROR,b),b}return{getStatement:e.bind(this),createStatement:f.bind(this)}}function e(a){var b=this,c=h.defer(),d={},e=!1;return a&&(d={limit:a.limit||10,since:a.since||null,until:a.until||null},a.actor&&(d.agent=new g.Agent(a.actor)),a.verb&&(d.verb=new g.Verb(a.verb)),a.moreUrl&&(e=!0),a.registration&&(d.registration=a.registration)),e?b.lrs.moreStatements({url:a.moreUrl,callback:function(a,b){if(null!==a){var d=new j(i.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else{var e=[];for(var f in b.statements)e.push(JSON.parse(b.statements[f].originalJSON));b.statements=e,c.resolve(b)}}}):b.lrs.queryStatements({params:d,callback:function(a,b){if(null!==a){var d=new j(i.errors.ERROR_TYPES.API_ERROR,a);c.reject(d)}else{var e=[];for(var f in b.statements)e.push(JSON.parse(b.statements[f].originalJSON));b.statements=e,c.resolve(b)}}}),c.promise}function f(a){var b,c=this,d=h.defer(),e={},f=[];if(Array.isArray(a))for(var k in a)a[k].actor&&a[k].verb&&a[k].object&&a[k].registration?(e={verb:new g.Verb(a[k].verb),actor:new g.Agent(a[k].actor),object:new g.Activity(a[k].object),context:{registration:a[k].registration}},a[k].timestamp&&(e.timestamp=a[k].timestamp),a[k].result&&(e.result=a[k].result),f.push(e)):(b={},b.message=b.description="Mandatory parameter options not found in request options",b=new j(i.errors.ERROR_TYPES.SDK_ERROR,b));else b={},b.message=b.description="Mandatory parameter options not found in request options",b=new j(i.errors.ERROR_TYPES.SDK_ERROR,b);return b?d.reject(b):c.tincan.sendStatements(f,function(a){for(var c in a)if(null!==a[c].err){var e={message:a[c].xhr.statusText,description:JSON.parse(a[c].xhr.response),status:a[c].xhr.status};if(e){b=new j(i.errors.ERROR_TYPES.API_ERROR,e),d.reject(b);break}}b||d.resolve()}),d.promise}var g=a("tincanjs"),h=a("q"),i=a("../../helpers"),j=i.errors.DLSError;b.exports=d},{"../../helpers":3,q:90,tincanjs:135}],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);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);
5
+ 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:90,superagent:133}],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);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:90,superagent:133}],25:[function(a,b,c){function d(){var a=m();return{connect:e.bind(this,a),cleanup:f.bind(this,a),grantByUserOrgId:g.bind(this),grantByAccountId:h.bind(this),grantByAccountIdOnExtUserId:i.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 n(l.errors.ERROR_TYPES.PUSHX_ERROR,d)}return a.setup({userid:b.userid,pubnub:{publishKey:b.publishKey,subscribeKey:b.subscribeKey,authKey:b.authKey,ssl:!0}})}function f(a){a.cleanup()}function g(a){var b=this,c=j.defer(),d=l.validations.isAuthenticated(b.orgId,b.token);if(d)c.reject(d);else{var e=b.config.DEFAULT_HOSTS.PUSHX+b.config.PUSHX_API_URLS.grantByUserOrgId;e=l.api.constructAPIUrl(e,{orgId:b.orgId});var f=k.post(e).set("Content-Type","application/json").set("Accept","application/json"),g={};a.authKey&&(g.authKey=a.authKey),f.send(g),f=l.api.setupAPIToken(f,b.token),b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(a=new n(l.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}return c.promise}function h(a){var b=this,c={},d=j.defer();if(a.accountId&&a.refId){var e=b.config.DEFAULT_HOSTS.PUSHX+b.config.PUSHX_API_URLS.grantByAccountId;e=l.api.constructAPIUrl(e,{accountId:a.accountId});var f=k.post(e).set("Content-Type","application/json").set("Accept","application/json");b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid);var g={refId:a.refId};a.authKey&&(g.authKey=a.authKey),f.send(g),f.end(function(a,b){a?(a=new n(l.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else c.message=c.description="Required parameter ['accountId', 'refId'] not found in request options",c=new n(l.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}function i(a){var b=this,c={},d=j.defer();if(a.accountId&&a.extUserId){var e=b.config.DEFAULT_HOSTS.PUSHX+b.config.PUSHX_API_URLS.grantByAccountId;e=l.api.constructAPIUrl(e,{accountId:a.accountId});var f=k.post(e).set("Content-Type","application/json").set("Accept","application/json");b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid);var g={extUserId:a.extUserId};a.authKey&&(g.authKey=a.authKey),f.send(g),f.end(function(a,b){a?(a=new n(l.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else c.message=c.description="Required parameter ['accountId', 'extUserId'] not found in request options",c=new n(l.errors.ERROR_TYPES.SDK_ERROR,c),d.reject(c);return d.promise}var j=a("q"),k=a("superagent"),l=a("../../helpers"),m=a("./pubnubClientWrapper"),n=l.errors.DLSError;b.exports=d},{"../../helpers":3,"./pubnubClientWrapper":26,q:90,superagent:133}],26:[function(a,b,c){var d=a("pubnub"),e=a("events").EventEmitter,f=a("../../helpers"),g=f.errors.PUSHXError,h="$";b.exports=function(){"use strict";var a,b,c=new e,i=[],j={},k=!1,l=function(){return{on:function(a,b){var d,e=[];a.orgid||a.userid||a.accountid||a.productid||a.classid?(a.accountid?e.push("a-"+a.accountid):(a.orgid&&e.push("o-"+a.orgid),a.userid&&e.push("u-"+a.userid),a.productid&&e.push("p-"+a.productid),a.classid&&e.push("c-"+a.classid)),d=e.join(h)+h+a.channel,i.includes(d)||(i.push(d),j[d]={status:"pending"},c.on(d,b),p(d))):"pushx_status"!==a.channel||k||(c.on(a.channel,b),k=!0)},getMySubscriptionStatus:o}},m=function(a){var b=a.subscribedChannel,d=a.message;c.emit(b,d)},n=function(a){var b,d,e=[];switch(a.category){case"PNConnectedCategory":if("PNSubscribeOperation"===a.operation){e=a.subscribedChannels;for(var h in e)j[e[h]]&&(j[e[h]].status="subscribed");d={category:"PUSHX",type:"CHANNEL_SUBSCRIPTION",status:"SUCCESS",message:"Success: Subscribed successfully.",httpcode:200,data:{payload:{channels:a.subscribedChannels},message:"Success: Subscribed successfully."}},c.emit("pushx_status",d)}break;case"PNAccessDeniedCategory":if("PNSubscribeOperation"===a.operation){var i={payload:JSON.parse(a.errorData.response.text).payload,message:"Forbidden: Subscription failed.",errorDetails:{operation:a.operation,category:a.category,statusCode:a.statusCode}};e=i.payload.channels;for(var k in e)j[e[k]]&&(j[e[k]].status="error",j[e[k]].error=b);b=new g(f.errors.ERROR_CATEGORY.PUSHX,i),c.emit("pushx_status",b)}break;case"PNBadRequestCategory":case"PNNetworkDownCategory":case"PNNetworkUpCategory":b={message:"PushX Error",status:a.statusCode,pushXError:a},b=new g(f.errors.ERROR_CATEGORY.PUSHX,b),c.emit("pushx_status",b)}},o=function(){return JSON.parse(JSON.stringify(j))},p=function(b){a.subscribe({channels:[b]})},q=function(c){function e(){b=c,a.addListener({message:function(a){m(a)},status:function(a){n(a)}})}var f=c.pubnub;return f.uuid=c.userid,a||!f?new Error("Already Initialized"):(a=new d(f),e(),l())},r=function(){a&&(a.unsubscribeAll(),a.stop(),i=[],k=!1,j={}),a=void 0};return{setup:q,cleanup:r}}},{"../../helpers":3,events:68,pubnub:88}],27:[function(a,b,c){function d(){return{connect:e.bind(this)}}function e(a,b){var c,d=this,e=h.defer(),j={CONNECT:"push_connect",CONNECT_ERROR:"push_error",USER_NEW:"presence",USER_CHANGED:"presenceupdate",COLLAB_EVENT:"collab",ACTIVITY_EVENT:"activity",JOB_EVENT:"job",SYSTEM_EVENT:"systemevents",ERROR:"error",ACTIVEROOM:"activeroom"};if(b&&a)a=a.toLowerCase(),c=d.config.DEFAULT_HOSTS.PUSH+"/"+a+"?orgid="+a+"&userid="+b;else{var k=i.validations.isAuthenticated(d.orgId,d.token);k?e.reject(k):c=d.config.DEFAULT_HOSTS.PUSH+"/"+d.orgId.toLowerCase()+"?orgid="+d.orgId.toLowerCase()+"&token="+d.token.access_token}if(c){var l=g.connect(c),m=new f;m.on(j.ACTIVEROOM,function(a){l.emit(j.ACTIVEROOM,a)}),e.resolve(m),l.on("connect",function(){var a={};m.emit(j.CONNECT,a)}),l.on("connect_error",function(a){var b={};b.error={},b.error.message="connect_error",b.error.description="Connection Error to PUSH API, URL: "+c+", "+JSON.stringify(a),m.emit(j.CONNECT_ERROR,b)}),l.on("connect_timeout",function(a){var b={};b.error={},b.error.message="connect_timeout",b.error.description="Timeout error to PUSH API, URL: "+c+", "+JSON.stringify(a),m.emit(j.CONNECT_ERROR,b)}),l.on("presence",function(a){var b=a;m.emit(j.USER_NEW,b)}),l.on("presenceupdate",function(a){var b=a;m.emit(j.USER_CHANGED,b)}),l.on("collab",function(a){var b=a;m.emit(j.COLLAB_EVENT,b)}),l.on("activity",function(a){var b=a;m.emit(j.ACTIVITY_EVENT,b)}),l.on("job",function(a){var b=a;m.emit(j.JOB_EVENT,b)}),l.on("systemevents",function(a){var b=a;m.emit(j.SYSTEM_EVENT,b)}),l.on("error",function(a){var b;try{b=JSON.parse(a)}catch(c){b=new Error(a)}l.disconnect(),m.emit(j.ERROR,b)})}return e.promise}var f=a("events").EventEmitter,g=a("socket.io-client"),h=a("q"),i=a("../../helpers");i.errors.DLSError;b.exports=d},{"../../helpers":3,events:68,q:90,"socket.io-client":95}],28:[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 o(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 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.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 o(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 o(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={mergeGlobalRules:a.mergeGlobalRules},f=m.get(d).set("Content-Type","application/json").set("Accept","application/json").query(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 o(n.errors.ERROR_TYPES.API_ERROR,a),c.reject(a)):c.resolve(b.body)})}else{var g={};g.message=g.description="Mandatory params - orgId or context or ruleType or userId not 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=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 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 ruleType or ruleId or body.rule_display 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.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 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 ruleType or body 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.ruleType&&a.ruleId&&a.body){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.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 ruleType or ruleId or body 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.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 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 ruleType or ruleId 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:90,superagent:133}],29:[function(a,b,c){function d(){return{postSISEvent:e.bind(this)}}function e(a){var b,c=this,d=g.defer(),e={};if(h.isArray(a.entities))if(e=i.validations.isAuthenticated(c.orgId,c.token))d.reject(e);else{b=c.config.DEFAULT_HOSTS.SISEVENTS+c.config.SISEVENTS_API_URLS.postMultiSISEvent,b=i.api.constructAPIUrl(b,{orgId:c.orgId});var k=a,l=f.post(b).send(k);l=i.api.setupAPIToken(l,c.token),c.traceid&&l.set("X-Amzn-Trace-Id",c.traceid),l.end(function(a,b){a?(a=new j(i.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}else e.message=e.description="Mandatory parameter entities not present in options",e=new j(i.errors.ERROR_TYPES.SDK_ERROR,e),d.reject(e);return d.promise}var f=a("superagent"),g=a("q"),h=a("underscore"),i=a("../../helpers"),j=i.errors.DLSError;b.exports=d},{"../../helpers":3,q:90,superagent:133,underscore:137}],30:[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),getInvitationsByEmail:x.bind(this),updateInstituteTitle:y.bind(this)}}function e(a){var b=this,c=z.defer();if(a&&a.extuserid){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getUserSpaces;d=B.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=A.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f.end(function(a,b){a?(g=new C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function f(a){var b=this,c=z.defer();if(a&&a.spaceCodeBody&&a.spaceCodeBody.space_code){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.validateSpaceCode;d=B.api.constructAPIUrl(d,{accountid:b.accountId});var e=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function g(a){var b=this,c=z.defer();if(a&&a.classCodeBody&&a.classCodeBody.class_code){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.validateClassCode;d=B.api.constructAPIUrl(d,{accountid:b.accountId});var e={};a.details&&(e.details=a.details);var f=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function h(a){var b=this,c=z.defer(),d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.generateSpaceCode;d=B.api.constructAPIUrl(d,{accountid:b.accountId});var e={};a.ignore_words&&(e.ignore_words=a.ignore_words);var f=A.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 C(B.errors.ERROR_TYPES.API_ERROR,a),c.reject(err)):c.resolve(b)}),c.promise}function i(a){var b=this,c=z.defer();if(a&&a.ext_user_id&&a.spacecode){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.changeSpaceCode;d=B.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=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function j(a){var b=this,c=z.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=B.api.constructAPIUrl(d,{accountid:b.accountId});var e=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function k(a){var b=this,c=z.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=B.api.constructAPIUrl(e,{accountId:b.accountId});var f=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function l(a){var b=this,c=z.defer();if(a&&a.ext_user_id&&a.ext_role){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.provisionSpacesToTeacher;d=B.api.constructAPIUrl(d,{accountId:b.accountId});var e=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function m(a){var b=this,c=z.defer(),d=B.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=B.api.constructAPIUrl(e,{orgId:b.orgId});var f=A.post(e).set("Content-Type","application/json").set("Accept","application/json").send(a);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=B.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(d=new C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function n(a){var b=this,c=z.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=B.api.constructAPIUrl(e,{orgId:b.orgId});var f=A.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?(a=new C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function o(a){var b=this,c=z.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=B.api.constructAPIUrl(d,{accountId:b.accountId});var e=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function p(a){var b=this,c=z.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=B.api.constructAPIUrl(d,{accountId:b.accountId});var e=A["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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function q(a){var b=this,c=z.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=B.api.constructAPIUrl(f,{accountId:b.accountId});var g=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,e),c.reject(e);return c.promise}function r(a){var b=this,c=z.defer();if(a&&a["micro-entitlements"]){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.bulkMicroEntitleProductToUser;d=B.api.constructAPIUrl(d,{accountId:b.accountId});var e=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function s(a){var b=this,c=z.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=B.api.constructAPIUrl(e,{accountId:b.accountId});var f=A["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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function t(a){var b=this,c=z.defer();if(a&&a.ext_product_id){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getExtProductAPI;d=B.api.constructAPIUrl(d,{accountId:b.accountId,
6
+ extProductId:a.ext_product_id});var e=A.get(d);b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.end(function(a,b){a?(f=new C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function u(a){var b=this,c=z.defer();if(a&&a.spacekey){var d=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getSpaceDetails;d=B.api.constructAPIUrl(d,{accountId:b.accountId,spacekey:a.spacekey});var e={orgid:b.orgId},f=A.get(d).query(e);b.traceid&&f.set("X-Amzn-Trace-Id",b.traceid),f=B.api.setupAPIToken(f,b.token),f.end(function(a,b){a?(g=new C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,g),c.reject(g)}return c.promise}function v(a){var b=this,c=z.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=B.api.constructAPIUrl(d,{accountId:b.accountId});var e=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,f),c.reject(f)}return c.promise}function w(a){var b=this,c=z.defer(),d={};if(a&&a.ext_user_id){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.updateUserInformation;e=B.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=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function x(a){var b=this,c=z.defer(),d={};if(a&&a.email){var e=b.config.DEFAULT_HOSTS.AUTH+b.config.AUTH_API_URLS.getInvitationsByEmail;e=B.api.constructAPIUrl(e,{accountid:b.accountId});var f={email:a.email};a.status&&(f.status=a.status);var g=A.get(e).query(f);b.traceid&&g.set("X-Amzn-Trace-Id",b.traceid),g.end(function(a,b){a?(d=new C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}function y(a){var b=this,c=z.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=B.api.constructAPIUrl(e,{accountId:b.accountId,instituteSpaceCode:a.space_code});var f=A.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 C(B.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 C(B.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}var z=a("q"),A=a("superagent"),B=a("../../helpers"),C=B.errors.DLSError;b.exports=d},{"../../helpers":3,q:90,superagent:133}],31:[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:90,superagent:133}],32:[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:90,superagent:133}],33:[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){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:90,superagent:133}],34:[function(a,b,c){function d(a){return this.accountId=a,{postStatement:e.bind(this),postExternalStatements:f.bind(this),resetUserProductProgress:g.bind(this)}}function e(a){var b,c=this,d=h.defer(),e={};if(e=j.validations.isAuthenticated(c.orgId,c.token))d.reject(e);else{b=c.config.DEFAULT_HOSTS.XAPI+c.config.XAPI_API_URLS.postMultiStatements,b=j.api.constructAPIUrl(b,{orgId:c.orgId});var f=a,g=i.post(b).send(f);g=j.api.setupAPIToken(g,c.token),c.traceid&&g.set("X-Amzn-Trace-Id",c.traceid),g.end(function(a,b){a?(a=new k(j.errors.ERROR_TYPES.API_ERROR,a),d.reject(a)):d.resolve(b.body)})}return d.promise}function f(a){var b=this,c=h.defer(),d=b.config.DEFAULT_HOSTS.XAPI+b.config.XAPI_API_URLS.postExternalMultiStatements;d=j.api.constructAPIUrl(d,{orgId:b.orgId});var e=i.post(d).send(a);return b.traceid&&e.set("X-Amzn-Trace-Id",b.traceid),e.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 g(a){var b=this,c=h.defer(),d={};if(a&&a.userid&&a.productcode&&a.actorid){var e=b.config.DEFAULT_HOSTS.XAPI+b.config.XAPI_API_URLS.resetUserProductProgress;e=j.api.constructAPIUrl(e,{accountId:b.accountId});var f=i["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 k(j.errors.ERROR_TYPES.API_ERROR,a),c.reject(d)):c.resolve(b.body)})}else d.message=d.description="userid, productcode or actorid not found in request options.",d=new k(j.errors.ERROR_TYPES.SDK_ERROR,d),c.reject(d);return c.promise}var h=a("q"),i=a("superagent"),j=a("../../helpers"),k=j.errors.DLSError;b.exports=d},{"../../helpers":3,q:90,superagent:133}],35:[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":36,q:90,superagent:133}],36:[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}],37:[function(a,b,c){function d(a,b,c){function d(a,e){if(d.count<=0)throw new Error("after called too many times");--d.count,a?(f=!0,b(a),b=c):0!==d.count||f||b(null,e)}var f=!1;return c=c||e,d.count=a,0===a?b():d}function e(){}b.exports=d},{}],38:[function(a,b,c){function d(){}b.exports=d,b.exports.HttpsAgent=d},{}],39:[function(a,b,c){b.exports=function(a,b,c){var d=a.byteLength;if(b=b||0,c=c||d,a.slice)return a.slice(b,c);if(b<0&&(b+=d),c<0&&(c+=d),c>d&&(c=d),b>=d||b>=c||0===d)return new ArrayBuffer(0);for(var e=new Uint8Array(a),f=new Uint8Array(c-b),g=b,h=0;g<c;g++,h++)f[h]=e[g];return f.buffer}},{}],40:[function(a,b,c){function d(a){a=a||{},this.ms=a.min||100,this.max=a.max||1e4,this.factor=a.factor||2,this.jitter=a.jitter>0&&a.jitter<=1?a.jitter:0,this.attempts=0}b.exports=d,d.prototype.duration=function(){var a=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var b=Math.random(),c=Math.floor(b*this.jitter*a);a=0==(1&Math.floor(10*b))?a-c:a+c}return 0|Math.min(a,this.max)},d.prototype.reset=function(){this.attempts=0},d.prototype.setMin=function(a){this.ms=a},d.prototype.setMax=function(a){this.max=a},d.prototype.setJitter=function(a){this.jitter=a}},{}],41:[function(a,b,c){!function(a){"use strict";c.encode=function(b){var c,d=new Uint8Array(b),e=d.length,f="";for(c=0;c<e;c+=3)f+=a[d[c]>>2],f+=a[(3&d[c])<<4|d[c+1]>>4],f+=a[(15&d[c+1])<<2|d[c+2]>>6],f+=a[63&d[c+2]];return e%3===2?f=f.substring(0,f.length-1)+"=":e%3===1&&(f=f.substring(0,f.length-2)+"=="),f},c.decode=function(b){var c,d,e,f,g,h=.75*b.length,i=b.length,j=0;"="===b[b.length-1]&&(h--,"="===b[b.length-2]&&h--);var k=new ArrayBuffer(h),l=new Uint8Array(k);for(c=0;c<i;c+=4)d=a.indexOf(b[c]),e=a.indexOf(b[c+1]),f=a.indexOf(b[c+2]),g=a.indexOf(b[c+3]),l[j++]=d<<2|e>>4,l[j++]=(15&e)<<4|f>>2,l[j++]=(3&f)<<6|63&g;return k}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")},{}],42:[function(a,b,c){(function(a){function c(a){for(var b=0;b<a.length;b++){var c=a[b];if(c.buffer instanceof ArrayBuffer){var d=c.buffer;if(c.byteLength!==d.byteLength){var e=new Uint8Array(c.byteLength);e.set(new Uint8Array(d,c.byteOffset,c.byteLength)),d=e.buffer}a[b]=d}}}function d(a,b){b=b||{};var d=new f;c(a);for(var e=0;e<a.length;e++)d.append(a[e]);return b.type?d.getBlob(b.type):d.getBlob()}function e(a,b){return c(a),new Blob(a,b||{})}var f=a.BlobBuilder||a.WebKitBlobBuilder||a.MSBlobBuilder||a.MozBlobBuilder,g=function(){try{var a=new Blob(["hi"]);return 2===a.size}catch(b){return!1}}(),h=g&&function(){try{var a=new Blob([new Uint8Array([1,2])]);return 2===a.size}catch(b){return!1}}(),i=f&&f.prototype.append&&f.prototype.getBlob;b.exports=function(){return g?h?a.Blob:e:i?d:void 0}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],43:[function(a,b,c){},{}],44:[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)},{}],45:[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;
7
+ }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":44,ieee754:74,isarray:46}],46:[function(a,b,c){var d={}.toString;b.exports=Array.isArray||function(a){return"[object Array]"==d.call(a)}},{}],47:[function(a,b,c){b.exports={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Time-out",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Large",414:"Request-URI Too Large",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Time-out",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},{}],48:[function(a,b,c){var d=[].slice;b.exports=function(a,b){if("string"==typeof b&&(b=a[b]),"function"!=typeof b)throw new Error("bind() requires a function");var c=d.call(arguments,2);return function(){return b.apply(a,c.concat(d.call(arguments)))}}},{}],49:[function(a,b,c){b.exports=function(a,b){var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}},{}],50:[function(a,b,c){function d(a){return Array.isArray?Array.isArray(a):"[object Array]"===r(a)}function e(a){return"boolean"==typeof a}function f(a){return null===a}function g(a){return null==a}function h(a){return"number"==typeof a}function i(a){return"string"==typeof a}function j(a){return"symbol"==typeof a}function k(a){return void 0===a}function l(a){return"[object RegExp]"===r(a)}function m(a){return"object"==typeof a&&null!==a}function n(a){return"[object Date]"===r(a)}function o(a){return"[object Error]"===r(a)||a instanceof Error}function p(a){return"function"==typeof a}function q(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function r(a){return Object.prototype.toString.call(a)}c.isArray=d,c.isBoolean=e,c.isNull=f,c.isNullOrUndefined=g,c.isNumber=h,c.isString=i,c.isSymbol=j,c.isUndefined=k,c.isRegExp=l,c.isObject=m,c.isDate=n,c.isError=o,c.isFunction=p,c.isPrimitive=q,c.isBuffer=a("buffer").Buffer.isBuffer},{buffer:45}],51:[function(a,b,c){b.exports=a("./lib/")},{"./lib/":52}],52:[function(a,b,c){b.exports=a("./socket"),b.exports.parser=a("engine.io-parser")},{"./socket":53,"engine.io-parser":65}],53:[function(a,b,c){(function(c){function d(a,b){if(!(this instanceof d))return new d(a,b);b=b||{},a&&"object"==typeof a&&(b=a,a=null),a?(a=k(a),b.hostname=a.host,b.secure="https"==a.protocol||"wss"==a.protocol,b.port=a.port,a.query&&(b.query=a.query)):b.host&&(b.hostname=k(b.host).host),this.secure=null!=b.secure?b.secure:c.location&&"https:"==location.protocol,b.hostname&&!b.port&&(b.port=this.secure?"443":"80"),this.agent=b.agent||!1,this.hostname=b.hostname||(c.location?location.hostname:"localhost"),this.port=b.port||(c.location&&location.port?location.port:this.secure?443:80),this.query=b.query||{},"string"==typeof this.query&&(this.query=m.decode(this.query)),this.upgrade=!1!==b.upgrade,this.path=(b.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!b.forceJSONP,this.jsonp=!1!==b.jsonp,this.forceBase64=!!b.forceBase64,this.enablesXDR=!!b.enablesXDR,this.timestampParam=b.timestampParam||"t",this.timestampRequests=b.timestampRequests,this.transports=b.transports||["polling","websocket"],this.readyState="",this.writeBuffer=[],this.policyPort=b.policyPort||843,this.rememberUpgrade=b.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=b.onlyBinaryUpgrades,this.perMessageDeflate=!1!==b.perMessageDeflate&&(b.perMessageDeflate||{}),!0===this.perMessageDeflate&&(this.perMessageDeflate={}),this.perMessageDeflate&&null==this.perMessageDeflate.threshold&&(this.perMessageDeflate.threshold=1024),this.pfx=b.pfx||null,this.key=b.key||null,this.passphrase=b.passphrase||null,this.cert=b.cert||null,this.ca=b.ca||null,this.ciphers=b.ciphers||null,this.rejectUnauthorized=void 0===b.rejectUnauthorized?null:b.rejectUnauthorized;var e="object"==typeof c&&c;e.global===e&&b.extraHeaders&&Object.keys(b.extraHeaders).length>0&&(this.extraHeaders=b.extraHeaders),this.open()}function e(a){var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}var f=a("./transports"),g=a("component-emitter"),h=a("debug")("engine.io-client:socket"),i=a("indexof"),j=a("engine.io-parser"),k=a("parseuri"),l=a("parsejson"),m=a("parseqs");b.exports=d,d.priorWebsocketSuccess=!1,g(d.prototype),d.protocol=j.protocol,d.Socket=d,d.Transport=a("./transport"),d.transports=a("./transports"),d.parser=a("engine.io-parser"),d.prototype.createTransport=function(a){h('creating transport "%s"',a);var b=e(this.query);b.EIO=j.protocol,b.transport=a,this.id&&(b.sid=this.id);var c=new f[a]({agent:this.agent,hostname:this.hostname,port:this.port,secure:this.secure,path:this.path,query:b,forceJSONP:this.forceJSONP,jsonp:this.jsonp,forceBase64:this.forceBase64,enablesXDR:this.enablesXDR,timestampRequests:this.timestampRequests,timestampParam:this.timestampParam,policyPort:this.policyPort,socket:this,pfx:this.pfx,key:this.key,passphrase:this.passphrase,cert:this.cert,ca:this.ca,ciphers:this.ciphers,rejectUnauthorized:this.rejectUnauthorized,perMessageDeflate:this.perMessageDeflate,extraHeaders:this.extraHeaders});return c},d.prototype.open=function(){var a;if(this.rememberUpgrade&&d.priorWebsocketSuccess&&this.transports.indexOf("websocket")!=-1)a="websocket";else{if(0===this.transports.length){var b=this;return void setTimeout(function(){b.emit("error","No transports available")},0)}a=this.transports[0]}this.readyState="opening";try{a=this.createTransport(a)}catch(c){return this.transports.shift(),void this.open()}a.open(),this.setTransport(a)},d.prototype.setTransport=function(a){h("setting transport %s",a.name);var b=this;this.transport&&(h("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=a,a.on("drain",function(){b.onDrain()}).on("packet",function(a){b.onPacket(a)}).on("error",function(a){b.onError(a)}).on("close",function(){b.onClose("transport close")})},d.prototype.probe=function(a){function b(){if(m.onlyBinaryUpgrades){var b=!this.supportsBinary&&m.transport.supportsBinary;l=l||b}l||(h('probe transport "%s" opened',a),k.send([{type:"ping",data:"probe"}]),k.once("packet",function(b){if(!l)if("pong"==b.type&&"probe"==b.data){if(h('probe transport "%s" pong',a),m.upgrading=!0,m.emit("upgrading",k),!k)return;d.priorWebsocketSuccess="websocket"==k.name,h('pausing current transport "%s"',m.transport.name),m.transport.pause(function(){l||"closed"!=m.readyState&&(h("changing transport and sending upgrade packet"),j(),m.setTransport(k),k.send([{type:"upgrade"}]),m.emit("upgrade",k),k=null,m.upgrading=!1,m.flush())})}else{h('probe transport "%s" failed',a);var c=new Error("probe error");c.transport=k.name,m.emit("upgradeError",c)}}))}function c(){l||(l=!0,j(),k.close(),k=null)}function e(b){var d=new Error("probe error: "+b);d.transport=k.name,c(),h('probe transport "%s" failed because of error: %s',a,b),m.emit("upgradeError",d)}function f(){e("transport closed")}function g(){e("socket closed")}function i(a){k&&a.name!=k.name&&(h('"%s" works - aborting "%s"',a.name,k.name),c())}function j(){k.removeListener("open",b),k.removeListener("error",e),k.removeListener("close",f),m.removeListener("close",g),m.removeListener("upgrading",i)}h('probing transport "%s"',a);var k=this.createTransport(a,{probe:1}),l=!1,m=this;d.priorWebsocketSuccess=!1,k.once("open",b),k.once("error",e),k.once("close",f),this.once("close",g),this.once("upgrading",i),k.open()},d.prototype.onOpen=function(){if(h("socket open"),this.readyState="open",d.priorWebsocketSuccess="websocket"==this.transport.name,this.emit("open"),this.flush(),"open"==this.readyState&&this.upgrade&&this.transport.pause){h("starting upgrade probes");for(var a=0,b=this.upgrades.length;a<b;a++)this.probe(this.upgrades[a])}},d.prototype.onPacket=function(a){if("opening"==this.readyState||"open"==this.readyState)switch(h('socket receive: type "%s", data "%s"',a.type,a.data),this.emit("packet",a),this.emit("heartbeat"),a.type){case"open":this.onHandshake(l(a.data));break;case"pong":this.setPing(),this.emit("pong");break;case"error":var b=new Error("server error");b.code=a.data,this.onError(b);break;case"message":this.emit("data",a.data),this.emit("message",a.data)}else h('packet received with socket readyState "%s"',this.readyState)},d.prototype.onHandshake=function(a){this.emit("handshake",a),this.id=a.sid,this.transport.query.sid=a.sid,this.upgrades=this.filterUpgrades(a.upgrades),this.pingInterval=a.pingInterval,this.pingTimeout=a.pingTimeout,this.onOpen(),"closed"!=this.readyState&&(this.setPing(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat))},d.prototype.onHeartbeat=function(a){clearTimeout(this.pingTimeoutTimer);var b=this;b.pingTimeoutTimer=setTimeout(function(){"closed"!=b.readyState&&b.onClose("ping timeout")},a||b.pingInterval+b.pingTimeout)},d.prototype.setPing=function(){var a=this;clearTimeout(a.pingIntervalTimer),a.pingIntervalTimer=setTimeout(function(){h("writing ping packet - expecting pong within %sms",a.pingTimeout),a.ping(),a.onHeartbeat(a.pingTimeout)},a.pingInterval)},d.prototype.ping=function(){var a=this;this.sendPacket("ping",function(){a.emit("ping")})},d.prototype.onDrain=function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit("drain"):this.flush()},d.prototype.flush=function(){"closed"!=this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(h("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},d.prototype.write=d.prototype.send=function(a,b,c){return this.sendPacket("message",a,b,c),this},d.prototype.sendPacket=function(a,b,c,d){if("function"==typeof b&&(d=b,b=void 0),"function"==typeof c&&(d=c,c=null),"closing"!=this.readyState&&"closed"!=this.readyState){c=c||{},c.compress=!1!==c.compress;var e={type:a,data:b,options:c};this.emit("packetCreate",e),this.writeBuffer.push(e),d&&this.once("flush",d),this.flush()}},d.prototype.close=function(){function a(){d.onClose("forced close"),h("socket closing - telling transport to close"),d.transport.close()}function b(){d.removeListener("upgrade",b),d.removeListener("upgradeError",b),a()}function c(){d.once("upgrade",b),d.once("upgradeError",b)}if("opening"==this.readyState||"open"==this.readyState){this.readyState="closing";var d=this;this.writeBuffer.length?this.once("drain",function(){this.upgrading?c():a()}):this.upgrading?c():a()}return this},d.prototype.onError=function(a){h("socket error %j",a),d.priorWebsocketSuccess=!1,this.emit("error",a),this.onClose("transport error",a)},d.prototype.onClose=function(a,b){if("opening"==this.readyState||"open"==this.readyState||"closing"==this.readyState){h('socket close with reason: "%s"',a);var c=this;clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),this.readyState="closed",this.id=null,this.emit("close",a,b),c.writeBuffer=[],c.prevBufferLen=0}},d.prototype.filterUpgrades=function(a){for(var b=[],c=0,d=a.length;c<d;c++)~i(this.transports,a[c])&&b.push(a[c]);return b}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./transport":54,"./transports":55,"component-emitter":61,debug:62,"engine.io-parser":65,indexof:75,parsejson:83,parseqs:84,parseuri:85}],54:[function(a,b,c){function d(a){this.path=a.path,this.hostname=a.hostname,this.port=a.port,this.secure=a.secure,this.query=a.query,this.timestampParam=a.timestampParam,this.timestampRequests=a.timestampRequests,this.readyState="",this.agent=a.agent||!1,this.socket=a.socket,this.enablesXDR=a.enablesXDR,this.pfx=a.pfx,this.key=a.key,this.passphrase=a.passphrase,this.cert=a.cert,this.ca=a.ca,this.ciphers=a.ciphers,this.rejectUnauthorized=a.rejectUnauthorized,this.extraHeaders=a.extraHeaders}var e=a("engine.io-parser"),f=a("component-emitter");b.exports=d,f(d.prototype),d.prototype.onError=function(a,b){var c=new Error(a);return c.type="TransportError",c.description=b,this.emit("error",c),this},d.prototype.open=function(){return"closed"!=this.readyState&&""!=this.readyState||(this.readyState="opening",this.doOpen()),this},d.prototype.close=function(){return"opening"!=this.readyState&&"open"!=this.readyState||(this.doClose(),this.onClose()),this},d.prototype.send=function(a){if("open"!=this.readyState)throw new Error("Transport not open");this.write(a)},d.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},d.prototype.onData=function(a){var b=e.decodePacket(a,this.socket.binaryType);this.onPacket(b)},d.prototype.onPacket=function(a){this.emit("packet",a)},d.prototype.onClose=function(){this.readyState="closed",this.emit("close")}},{"component-emitter":61,"engine.io-parser":65}],55:[function(a,b,c){(function(b){function d(a){var c,d=!1,h=!1,i=!1!==a.jsonp;if(b.location){var j="https:"==location.protocol,k=location.port;k||(k=j?443:80),d=a.hostname!=location.hostname||k!=a.port,h=a.secure!=j}if(a.xdomain=d,a.xscheme=h,c=new e(a),"open"in c&&!a.forceJSONP)return new f(a);if(!i)throw new Error("JSONP disabled");return new g(a)}var e=a("xmlhttprequest-ssl"),f=a("./polling-xhr"),g=a("./polling-jsonp"),h=a("./websocket");c.polling=d,c.websocket=h}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./polling-jsonp":56,"./polling-xhr":57,"./websocket":59,"xmlhttprequest-ssl":60}],56:[function(a,b,c){(function(c){function d(){}function e(a){f.call(this,a),this.query=this.query||{},h||(c.___eio||(c.___eio=[]),h=c.___eio),this.index=h.length;var b=this;h.push(function(a){b.onData(a)}),this.query.j=this.index,c.document&&c.addEventListener&&c.addEventListener("beforeunload",function(){b.script&&(b.script.onerror=d)},!1)}var f=a("./polling"),g=a("component-inherit");b.exports=e;var h,i=/\n/g,j=/\\n/g;g(e,f),e.prototype.supportsBinary=!1,e.prototype.doClose=function(){this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),f.prototype.doClose.call(this)},e.prototype.doPoll=function(){var a=this,b=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),b.async=!0,b.src=this.uri(),b.onerror=function(b){a.onError("jsonp poll error",b)};var c=document.getElementsByTagName("script")[0];c?c.parentNode.insertBefore(b,c):(document.head||document.body).appendChild(b),this.script=b;var d="undefined"!=typeof navigator&&/gecko/i.test(navigator.userAgent);d&&setTimeout(function(){var a=document.createElement("iframe");document.body.appendChild(a),document.body.removeChild(a)},100)},e.prototype.doWrite=function(a,b){function c(){d(),b()}function d(){if(e.iframe)try{e.form.removeChild(e.iframe)}catch(a){e.onError("jsonp polling iframe removal error",a)}try{var b='<iframe src="javascript:0" name="'+e.iframeId+'">';f=document.createElement(b)}catch(a){f=document.createElement("iframe"),f.name=e.iframeId,f.src="javascript:0"}f.id=e.iframeId,e.form.appendChild(f),e.iframe=f}var e=this;if(!this.form){var f,g=document.createElement("form"),h=document.createElement("textarea"),k=this.iframeId="eio_iframe_"+this.index;g.className="socketio",g.style.position="absolute",g.style.top="-1000px",g.style.left="-1000px",g.target=k,g.method="POST",g.setAttribute("accept-charset","utf-8"),h.name="d",g.appendChild(h),document.body.appendChild(g),this.form=g,this.area=h}this.form.action=this.uri(),d(),a=a.replace(j,"\\\n"),this.area.value=a.replace(i,"\\n");try{this.form.submit()}catch(l){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"==e.iframe.readyState&&c()}:this.iframe.onload=c}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./polling":58,"component-inherit":49}],57:[function(a,b,c){(function(c){function d(){}function e(a){if(i.call(this,a),c.location){var b="https:"==location.protocol,d=location.port;d||(d=b?443:80),this.xd=a.hostname!=c.location.hostname||d!=a.port,this.xs=a.secure!=b}else this.extraHeaders=a.extraHeaders}function f(a){this.method=a.method||"GET",this.uri=a.uri,this.xd=!!a.xd,this.xs=!!a.xs,this.async=!1!==a.async,this.data=void 0!=a.data?a.data:null,this.agent=a.agent,this.isBinary=a.isBinary,this.supportsBinary=a.supportsBinary,this.enablesXDR=a.enablesXDR,this.pfx=a.pfx,this.key=a.key,this.passphrase=a.passphrase,this.cert=a.cert,this.ca=a.ca,this.ciphers=a.ciphers,this.rejectUnauthorized=a.rejectUnauthorized,this.extraHeaders=a.extraHeaders,this.create()}function g(){for(var a in f.requests)f.requests.hasOwnProperty(a)&&f.requests[a].abort()}var h=a("xmlhttprequest-ssl"),i=a("./polling"),j=a("component-emitter"),k=a("component-inherit"),l=a("debug")("engine.io-client:polling-xhr");b.exports=e,b.exports.Request=f,k(e,i),e.prototype.supportsBinary=!0,e.prototype.request=function(a){return a=a||{},a.uri=this.uri(),a.xd=this.xd,a.xs=this.xs,a.agent=this.agent||!1,a.supportsBinary=this.supportsBinary,a.enablesXDR=this.enablesXDR,a.pfx=this.pfx,a.key=this.key,a.passphrase=this.passphrase,a.cert=this.cert,a.ca=this.ca,a.ciphers=this.ciphers,a.rejectUnauthorized=this.rejectUnauthorized,a.extraHeaders=this.extraHeaders,new f(a)},e.prototype.doWrite=function(a,b){var c="string"!=typeof a&&void 0!==a,d=this.request({method:"POST",data:a,isBinary:c}),e=this;d.on("success",b),d.on("error",function(a){e.onError("xhr post error",a)}),this.sendXhr=d},e.prototype.doPoll=function(){l("xhr poll");var a=this.request(),b=this;a.on("data",function(a){b.onData(a)}),a.on("error",function(a){b.onError("xhr poll error",a)}),this.pollXhr=a},j(f.prototype),f.prototype.create=function(){var a={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};a.pfx=this.pfx,a.key=this.key,a.passphrase=this.passphrase,a.cert=this.cert,a.ca=this.ca,a.ciphers=this.ciphers,a.rejectUnauthorized=this.rejectUnauthorized;var b=this.xhr=new h(a),d=this;try{l("xhr open %s: %s",this.method,this.uri),b.open(this.method,this.uri,this.async);try{if(this.extraHeaders){b.setDisableHeaderCheck(!0);for(var e in this.extraHeaders)this.extraHeaders.hasOwnProperty(e)&&b.setRequestHeader(e,this.extraHeaders[e])}}catch(g){}if(this.supportsBinary&&(b.responseType="arraybuffer"),"POST"==this.method)try{this.isBinary?b.setRequestHeader("Content-type","application/octet-stream"):b.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(g){}"withCredentials"in b&&(b.withCredentials=!0),this.hasXDR()?(b.onload=function(){d.onLoad()},b.onerror=function(){d.onError(b.responseText)}):b.onreadystatechange=function(){4==b.readyState&&(200==b.status||1223==b.status?d.onLoad():setTimeout(function(){d.onError(b.status)},0))},l("xhr data %s",this.data),b.send(this.data)}catch(g){return void setTimeout(function(){d.onError(g)},0)}c.document&&(this.index=f.requestsCount++,f.requests[this.index]=this);
8
+ },f.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},f.prototype.onData=function(a){this.emit("data",a),this.onSuccess()},f.prototype.onError=function(a){this.emit("error",a),this.cleanup(!0)},f.prototype.cleanup=function(a){if("undefined"!=typeof this.xhr&&null!==this.xhr){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=d:this.xhr.onreadystatechange=d,a)try{this.xhr.abort()}catch(b){}c.document&&delete f.requests[this.index],this.xhr=null}},f.prototype.onLoad=function(){var a;try{var b;try{b=this.xhr.getResponseHeader("Content-Type").split(";")[0]}catch(c){}if("application/octet-stream"===b)a=this.xhr.response;else if(this.supportsBinary)try{a=String.fromCharCode.apply(null,new Uint8Array(this.xhr.response))}catch(c){for(var d=new Uint8Array(this.xhr.response),e=[],f=0,g=d.length;f<g;f++)e.push(d[f]);a=String.fromCharCode.apply(null,e)}else a=this.xhr.responseText}catch(c){this.onError(c)}null!=a&&this.onData(a)},f.prototype.hasXDR=function(){return"undefined"!=typeof c.XDomainRequest&&!this.xs&&this.enablesXDR},f.prototype.abort=function(){this.cleanup()},c.document&&(f.requestsCount=0,f.requests={},c.attachEvent?c.attachEvent("onunload",g):c.addEventListener&&c.addEventListener("beforeunload",g,!1))}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./polling":58,"component-emitter":61,"component-inherit":49,debug:62,"xmlhttprequest-ssl":60}],58:[function(a,b,c){function d(a){var b=a&&a.forceBase64;k&&!b||(this.supportsBinary=!1),e.call(this,a)}var e=a("../transport"),f=a("parseqs"),g=a("engine.io-parser"),h=a("component-inherit"),i=a("yeast"),j=a("debug")("engine.io-client:polling");b.exports=d;var k=function(){var b=a("xmlhttprequest-ssl"),c=new b({xdomain:!1});return null!=c.responseType}();h(d,e),d.prototype.name="polling",d.prototype.doOpen=function(){this.poll()},d.prototype.pause=function(a){function b(){j("paused"),c.readyState="paused",a()}var c=this;if(this.readyState="pausing",this.polling||!this.writable){var d=0;this.polling&&(j("we are currently polling - waiting to pause"),d++,this.once("pollComplete",function(){j("pre-pause polling complete"),--d||b()})),this.writable||(j("we are currently writing - waiting to pause"),d++,this.once("drain",function(){j("pre-pause writing complete"),--d||b()}))}else b()},d.prototype.poll=function(){j("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},d.prototype.onData=function(a){var b=this;j("polling got data %s",a);var c=function(a,c,d){return"opening"==b.readyState&&b.onOpen(),"close"==a.type?(b.onClose(),!1):void b.onPacket(a)};g.decodePayload(a,this.socket.binaryType,c),"closed"!=this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"==this.readyState?this.poll():j('ignoring poll - transport state "%s"',this.readyState))},d.prototype.doClose=function(){function a(){j("writing close packet"),b.write([{type:"close"}])}var b=this;"open"==this.readyState?(j("transport open - closing"),a()):(j("transport not open - deferring close"),this.once("open",a))},d.prototype.write=function(a){var b=this;this.writable=!1;var c=function(){b.writable=!0,b.emit("drain")},b=this;g.encodePayload(a,this.supportsBinary,function(a){b.doWrite(a,c)})},d.prototype.uri=function(){var a=this.query||{},b=this.secure?"https":"http",c="";!1!==this.timestampRequests&&(a[this.timestampParam]=i()),this.supportsBinary||a.sid||(a.b64=1),a=f.encode(a),this.port&&("https"==b&&443!=this.port||"http"==b&&80!=this.port)&&(c=":"+this.port),a.length&&(a="?"+a);var d=this.hostname.indexOf(":")!==-1;return b+"://"+(d?"["+this.hostname+"]":this.hostname)+c+this.path+a}},{"../transport":54,"component-inherit":49,debug:62,"engine.io-parser":65,parseqs:84,"xmlhttprequest-ssl":60,yeast:144}],59:[function(a,b,c){(function(c){function d(a){var b=a&&a.forceBase64;b&&(this.supportsBinary=!1),this.perMessageDeflate=a.perMessageDeflate,e.call(this,a)}var e=a("../transport"),f=a("engine.io-parser"),g=a("parseqs"),h=a("component-inherit"),i=a("yeast"),j=a("debug")("engine.io-client:websocket"),k=c.WebSocket||c.MozWebSocket,l=k;if(!l&&"undefined"==typeof window)try{l=a("ws")}catch(m){}b.exports=d,h(d,e),d.prototype.name="websocket",d.prototype.supportsBinary=!0,d.prototype.doOpen=function(){if(this.check()){var a=this.uri(),b=void 0,c={agent:this.agent,perMessageDeflate:this.perMessageDeflate};c.pfx=this.pfx,c.key=this.key,c.passphrase=this.passphrase,c.cert=this.cert,c.ca=this.ca,c.ciphers=this.ciphers,c.rejectUnauthorized=this.rejectUnauthorized,this.extraHeaders&&(c.headers=this.extraHeaders),this.ws=k?new l(a):new l(a,b,c),void 0===this.ws.binaryType&&(this.supportsBinary=!1),this.ws.supports&&this.ws.supports.binary?(this.supportsBinary=!0,this.ws.binaryType="buffer"):this.ws.binaryType="arraybuffer",this.addEventListeners()}},d.prototype.addEventListeners=function(){var a=this;this.ws.onopen=function(){a.onOpen()},this.ws.onclose=function(){a.onClose()},this.ws.onmessage=function(b){a.onData(b.data)},this.ws.onerror=function(b){a.onError("websocket error",b)}},"undefined"!=typeof navigator&&/iPad|iPhone|iPod/i.test(navigator.userAgent)&&(d.prototype.onData=function(a){var b=this;setTimeout(function(){e.prototype.onData.call(b,a)},0)}),d.prototype.write=function(a){function b(){d.emit("flush"),setTimeout(function(){d.writable=!0,d.emit("drain")},0)}var d=this;this.writable=!1;for(var e=a.length,g=0,h=e;g<h;g++)!function(a){f.encodePacket(a,d.supportsBinary,function(f){if(!k){var g={};if(a.options&&(g.compress=a.options.compress),d.perMessageDeflate){var h="string"==typeof f?c.Buffer.byteLength(f):f.length;h<d.perMessageDeflate.threshold&&(g.compress=!1)}}try{k?d.ws.send(f):d.ws.send(f,g)}catch(i){j("websocket closed before onclose event")}--e||b()})}(a[g])},d.prototype.onClose=function(){e.prototype.onClose.call(this)},d.prototype.doClose=function(){"undefined"!=typeof this.ws&&this.ws.close()},d.prototype.uri=function(){var a=this.query||{},b=this.secure?"wss":"ws",c="";this.port&&("wss"==b&&443!=this.port||"ws"==b&&80!=this.port)&&(c=":"+this.port),this.timestampRequests&&(a[this.timestampParam]=i()),this.supportsBinary||(a.b64=1),a=g.encode(a),a.length&&(a="?"+a);var d=this.hostname.indexOf(":")!==-1;return b+"://"+(d?"["+this.hostname+"]":this.hostname)+c+this.path+a},d.prototype.check=function(){return!(!l||"__initialize"in l&&this.name===d.prototype.name)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../transport":54,"component-inherit":49,debug:62,"engine.io-parser":65,parseqs:84,ws:43,yeast:144}],60:[function(a,b,c){var d=a("has-cors");b.exports=function(a){var b=a.xdomain,c=a.xscheme,e=a.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!b||d))return new XMLHttpRequest}catch(f){}try{if("undefined"!=typeof XDomainRequest&&!c&&e)return new XDomainRequest}catch(f){}if(!b)try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(f){}}},{"has-cors":72}],61:[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}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(){d.off(a,c),b.apply(this,arguments)}var d=this;return this._callbacks=this._callbacks||{},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 this},d.prototype.emit=function(a){this._callbacks=this._callbacks||{};var b=[].slice.call(arguments,1),c=this._callbacks[a];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}},{}],62:[function(a,b,c){function d(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}function e(){var a=arguments,b=this.useColors;if(a[0]=(b?"%c":"")+this.namespace+(b?" %c":" ")+a[0]+(b?"%c ":" ")+"+"+c.humanize(this.diff),!b)return a;var d="color: "+this.color;a=[a[0],d,"color: inherit"].concat(Array.prototype.slice.call(a,1));var e=0,f=0;return a[0].replace(/%[a-z%]/g,function(a){"%%"!==a&&(e++,"%c"===a&&(f=e))}),a.splice(f,0,d),a}function f(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function g(a){try{null==a?c.storage.removeItem("debug"):c.storage.debug=a}catch(b){}}function h(){var a;try{a=c.storage.debug}catch(b){}return a}function i(){try{return window.localStorage}catch(a){}}c=b.exports=a("./debug"),c.log=f,c.formatArgs=e,c.save=g,c.load=h,c.useColors=d,c.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:i(),c.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],c.formatters.j=function(a){return JSON.stringify(a)},c.enable(h())},{"./debug":63}],63:[function(a,b,c){function d(){return c.colors[k++%c.colors.length]}function e(a){function b(){}function e(){var a=e,b=+new Date,f=b-(j||b);a.diff=f,a.prev=j,a.curr=b,j=b,null==a.useColors&&(a.useColors=c.useColors()),null==a.color&&a.useColors&&(a.color=d());var g=Array.prototype.slice.call(arguments);g[0]=c.coerce(g[0]),"string"!=typeof g[0]&&(g=["%o"].concat(g));var h=0;g[0]=g[0].replace(/%([a-z%])/g,function(b,d){if("%%"===b)return b;h++;var e=c.formatters[d];if("function"==typeof e){var f=g[h];b=e.call(a,f),g.splice(h,1),h--}return b}),"function"==typeof c.formatArgs&&(g=c.formatArgs.apply(a,g));var i=e.log||c.log||console.log.bind(console);i.apply(a,g)}b.enabled=!1,e.enabled=!0;var f=c.enabled(a)?e:b;return f.namespace=a,f}function f(a){c.save(a);for(var b=(a||"").split(/[\s,]+/),d=b.length,e=0;e<d;e++)b[e]&&(a=b[e].replace(/\*/g,".*?"),"-"===a[0]?c.skips.push(new RegExp("^"+a.substr(1)+"$")):c.names.push(new RegExp("^"+a+"$")))}function g(){c.enable("")}function h(a){var b,d;for(b=0,d=c.skips.length;b<d;b++)if(c.skips[b].test(a))return!1;for(b=0,d=c.names.length;b<d;b++)if(c.names[b].test(a))return!0;return!1}function i(a){return a instanceof Error?a.stack||a.message:a}c=b.exports=e,c.coerce=i,c.disable=g,c.enable=f,c.enabled=h,c.humanize=a("ms"),c.names=[],c.skips=[],c.formatters={};var j,k=0},{ms:64}],64:[function(a,b,c){function d(a){if(a=""+a,!(a.length>1e4)){var b=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(a);if(b){var c=parseFloat(b[1]),d=(b[2]||"ms").toLowerCase();switch(d){case"years":case"year":case"yrs":case"yr":case"y":return c*l;case"days":case"day":case"d":return c*k;case"hours":case"hour":case"hrs":case"hr":case"h":return c*j;case"minutes":case"minute":case"mins":case"min":case"m":return c*i;case"seconds":case"second":case"secs":case"sec":case"s":return c*h;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c}}}}function e(a){return a>=k?Math.round(a/k)+"d":a>=j?Math.round(a/j)+"h":a>=i?Math.round(a/i)+"m":a>=h?Math.round(a/h)+"s":a+"ms"}function f(a){return g(a,k,"day")||g(a,j,"hour")||g(a,i,"minute")||g(a,h,"second")||a+" ms"}function g(a,b,c){if(!(a<b))return a<1.5*b?Math.floor(a/b)+" "+c:Math.ceil(a/b)+" "+c+"s"}var h=1e3,i=60*h,j=60*i,k=24*j,l=365.25*k;b.exports=function(a,b){return b=b||{},"string"==typeof a?d(a):b["long"]?f(a):e(a)}},{}],65:[function(a,b,c){(function(b){function d(a,b){var d="b"+c.packets[a.type]+a.data.data;return b(d)}function e(a,b,d){if(!b)return c.encodeBase64Packet(a,d);var e=a.data,f=new Uint8Array(e),g=new Uint8Array(1+e.byteLength);g[0]=r[a.type];for(var h=0;h<f.length;h++)g[h+1]=f[h];return d(g.buffer)}function f(a,b,d){if(!b)return c.encodeBase64Packet(a,d);var e=new FileReader;return e.onload=function(){a.data=e.result,c.encodePacket(a,b,!0,d)},e.readAsArrayBuffer(a.data)}function g(a,b,d){if(!b)return c.encodeBase64Packet(a,d);if(q)return f(a,b,d);var e=new Uint8Array(1);e[0]=r[a.type];var g=new u([e.buffer,a.data]);return d(g)}function h(a,b,c){for(var d=new Array(a.length),e=m(a.length,c),f=function(a,c,e){b(c,function(b,c){d[a]=c,e(b,d)})},g=0;g<a.length;g++)f(g,a[g],e)}var i=a("./keys"),j=a("has-binary"),k=a("arraybuffer.slice"),l=a("base64-arraybuffer"),m=a("after"),n=a("utf8"),o=navigator.userAgent.match(/Android/i),p=/PhantomJS/i.test(navigator.userAgent),q=o||p;c.protocol=3;var r=c.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},s=i(r),t={type:"error",data:"parser error"},u=a("blob");c.encodePacket=function(a,c,f,h){"function"==typeof c&&(h=c,c=!1),"function"==typeof f&&(h=f,f=null);var i=void 0===a.data?void 0:a.data.buffer||a.data;if(b.ArrayBuffer&&i instanceof ArrayBuffer)return e(a,c,h);if(u&&i instanceof b.Blob)return g(a,c,h);if(i&&i.base64)return d(a,h);var j=r[a.type];return void 0!==a.data&&(j+=f?n.encode(String(a.data)):String(a.data)),h(""+j)},c.encodeBase64Packet=function(a,d){var e="b"+c.packets[a.type];if(u&&a.data instanceof b.Blob){var f=new FileReader;return f.onload=function(){var a=f.result.split(",")[1];d(e+a)},f.readAsDataURL(a.data)}var g;try{g=String.fromCharCode.apply(null,new Uint8Array(a.data))}catch(h){for(var i=new Uint8Array(a.data),j=new Array(i.length),k=0;k<i.length;k++)j[k]=i[k];g=String.fromCharCode.apply(null,j)}return e+=b.btoa(g),d(e)},c.decodePacket=function(a,b,d){if("string"==typeof a||void 0===a){if("b"==a.charAt(0))return c.decodeBase64Packet(a.substr(1),b);if(d)try{a=n.decode(a)}catch(e){return t}var f=a.charAt(0);return Number(f)==f&&s[f]?a.length>1?{type:s[f],data:a.substring(1)}:{type:s[f]}:t}var g=new Uint8Array(a),f=g[0],h=k(a,1);return u&&"blob"===b&&(h=new u([h])),{type:s[f],data:h}},c.decodeBase64Packet=function(a,c){var d=s[a.charAt(0)];if(!b.ArrayBuffer)return{type:d,data:{base64:!0,data:a.substr(1)}};var e=l.decode(a.substr(1));return"blob"===c&&u&&(e=new u([e])),{type:d,data:e}},c.encodePayload=function(a,b,d){function e(a){return a.length+":"+a}function f(a,d){c.encodePacket(a,!!g&&b,!0,function(a){d(null,e(a))})}"function"==typeof b&&(d=b,b=null);var g=j(a);return b&&g?u&&!q?c.encodePayloadAsBlob(a,d):c.encodePayloadAsArrayBuffer(a,d):a.length?void h(a,f,function(a,b){return d(b.join(""))}):d("0:")},c.decodePayload=function(a,b,d){if("string"!=typeof a)return c.decodePayloadAsBinary(a,b,d);"function"==typeof b&&(d=b,b=null);var e;if(""==a)return d(t,0,1);for(var f,g,h="",i=0,j=a.length;i<j;i++){var k=a.charAt(i);if(":"!=k)h+=k;else{if(""==h||h!=(f=Number(h)))return d(t,0,1);if(g=a.substr(i+1,f),h!=g.length)return d(t,0,1);if(g.length){if(e=c.decodePacket(g,b,!0),t.type==e.type&&t.data==e.data)return d(t,0,1);var l=d(e,i+f,j);if(!1===l)return}i+=f,h=""}}return""!=h?d(t,0,1):void 0},c.encodePayloadAsArrayBuffer=function(a,b){function d(a,b){c.encodePacket(a,!0,!0,function(a){return b(null,a)})}return a.length?void h(a,d,function(a,c){var d=c.reduce(function(a,b){var c;return c="string"==typeof b?b.length:b.byteLength,a+c.toString().length+c+2},0),e=new Uint8Array(d),f=0;return c.forEach(function(a){var b="string"==typeof a,c=a;if(b){for(var d=new Uint8Array(a.length),g=0;g<a.length;g++)d[g]=a.charCodeAt(g);c=d.buffer}b?e[f++]=0:e[f++]=1;for(var h=c.byteLength.toString(),g=0;g<h.length;g++)e[f++]=parseInt(h[g]);e[f++]=255;for(var d=new Uint8Array(c),g=0;g<d.length;g++)e[f++]=d[g]}),b(e.buffer)}):b(new ArrayBuffer(0))},c.encodePayloadAsBlob=function(a,b){function d(a,b){c.encodePacket(a,!0,!0,function(a){var c=new Uint8Array(1);if(c[0]=1,"string"==typeof a){for(var d=new Uint8Array(a.length),e=0;e<a.length;e++)d[e]=a.charCodeAt(e);a=d.buffer,c[0]=0}for(var f=a instanceof ArrayBuffer?a.byteLength:a.size,g=f.toString(),h=new Uint8Array(g.length+1),e=0;e<g.length;e++)h[e]=parseInt(g[e]);if(h[g.length]=255,u){var i=new u([c.buffer,h.buffer,a]);b(null,i)}})}h(a,d,function(a,c){return b(new u(c))})},c.decodePayloadAsBinary=function(a,b,d){"function"==typeof b&&(d=b,b=null);for(var e=a,f=[],g=!1;e.byteLength>0;){for(var h=new Uint8Array(e),i=0===h[0],j="",l=1;255!=h[l];l++){if(j.length>310){g=!0;break}j+=h[l]}if(g)return d(t,0,1);e=k(e,2+j.length),j=parseInt(j);var m=k(e,0,j);if(i)try{m=String.fromCharCode.apply(null,new Uint8Array(m))}catch(n){var o=new Uint8Array(m);m="";for(var l=0;l<o.length;l++)m+=String.fromCharCode(o[l])}f.push(m),e=k(e,j)}var p=f.length;f.forEach(function(a,e){d(c.decodePacket(a,b,!0),e,p)})}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./keys":66,after:37,"arraybuffer.slice":39,"base64-arraybuffer":41,blob:42,"has-binary":67,utf8:139}],66:[function(a,b,c){b.exports=Object.keys||function(a){var b=[],c=Object.prototype.hasOwnProperty;for(var d in a)c.call(a,d)&&b.push(d);return b}},{}],67:[function(a,b,c){(function(c){function d(a){function b(a){if(!a)return!1;if(c.Buffer&&c.Buffer.isBuffer(a)||c.ArrayBuffer&&a instanceof ArrayBuffer||c.Blob&&a instanceof Blob||c.File&&a instanceof File)return!0;if(e(a)){for(var d=0;d<a.length;d++)if(b(a[d]))return!0}else if(a&&"object"==typeof a){a.toJSON&&(a=a.toJSON());for(var f in a)if(Object.prototype.hasOwnProperty.call(a,f)&&b(a[f]))return!0}return!1}return b(a)}var e=a("isarray");b.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{isarray:77}],68:[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}},{}],69:[function(a,b,c){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){"use strict";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(){"use strict";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}},{}],70:[function(a,b,c){var d=Object.prototype.hasOwnProperty,e=Object.prototype.toString;b.exports=function(a,b,c){if("[object Function]"!==e.call(b))throw new TypeError("iterator must be a function");var f=a.length;if(f===+f)for(var g=0;g<f;g++)b.call(c,a[g],g,a);else for(var h in a)d.call(a,h)&&b.call(c,a[h],h,a)}},{}],71:[function(a,b,c){(function(c){function d(a){function b(a){if(!a)return!1;if(c.Buffer&&c.Buffer.isBuffer&&c.Buffer.isBuffer(a)||c.ArrayBuffer&&a instanceof ArrayBuffer||c.Blob&&a instanceof Blob||c.File&&a instanceof File)return!0;if(e(a)){for(var d=0;d<a.length;d++)if(b(a[d]))return!0}else if(a&&"object"==typeof a){a.toJSON&&"function"==typeof a.toJSON&&(a=a.toJSON());for(var f in a)if(Object.prototype.hasOwnProperty.call(a,f)&&b(a[f]))return!0}return!1}return b(a)}var e=a("isarray");b.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{isarray:77}],72:[function(a,b,c){try{b.exports="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(d){b.exports=!1}},{}],73:[function(a,b,c){var d=a("http"),e=b.exports;for(var f in d)d.hasOwnProperty(f)&&(e[f]=d[f]);e.request=function(a,b){return a||(a={}),a.scheme="https",a.protocol="https:",d.request.call(this,a,b)}},{http:128}],74:[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}},{}],75:[function(a,b,c){var d=[].indexOf;b.exports=function(a,b){if(d)return a.indexOf(b);for(var c=0;c<a.length;++c)if(a[c]===b)return c;return-1}},{}],76:[function(a,b,c){"function"==typeof Object.create?b.exports=function(a,b){b&&(a.super_=b,a.prototype=Object.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}))}:b.exports=function(a,b){if(b){a.super_=b;var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a}}},{}],77:[function(a,b,c){b.exports=Array.isArray||function(a){return"[object Array]"==Object.prototype.toString.call(a)}},{}],78:[function(b,c,d){(function(b){(function(){function e(a,b){function c(a){if(c[a]!==q)return c[a];var e;if("bug-string-char-index"==a)e="a"!="a"[0];else if("json"==a)e=c("json-stringify")&&c("json-parse");else{var g,h='{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';if("json-stringify"==a){var i=b.stringify,k="function"==typeof i&&t;if(k){(g=function(){return 1}).toJSON=g;try{k="0"===i(0)&&"0"===i(new d)&&'""'==i(new f)&&i(s)===q&&i(q)===q&&i()===q&&"1"===i(g)&&"[1]"==i([g])&&"[null]"==i([q])&&"null"==i(null)&&"[null,null,null]"==i([q,s,null])&&i({a:[g,!0,!1,null,"\0\b\n\f\r\t"]})==h&&"1"===i(null,g)&&"[\n 1,\n 2\n]"==i([1,2],null,1)&&'"-271821-04-20T00:00:00.000Z"'==i(new j((-864e13)))&&'"+275760-09-13T00:00:00.000Z"'==i(new j(864e13))&&'"-000001-01-01T00:00:00.000Z"'==i(new j((-621987552e5)))&&'"1969-12-31T23:59:59.999Z"'==i(new j((-1)))}catch(l){k=!1}}e=k}if("json-parse"==a){var m=b.parse;if("function"==typeof m)try{if(0===m("0")&&!m(!1)){g=m(h);var n=5==g.a.length&&1===g.a[0];if(n){try{n=!m('"\t"')}catch(l){}if(n)try{n=1!==m("01")}catch(l){}if(n)try{n=1!==m("1.")}catch(l){}}}}catch(l){n=!1}e=n}}return c[a]=!!e}a||(a=i.Object()),b||(b=i.Object());var d=a.Number||i.Number,f=a.String||i.String,h=a.Object||i.Object,j=a.Date||i.Date,k=a.SyntaxError||i.SyntaxError,l=a.TypeError||i.TypeError,m=a.Math||i.Math,n=a.JSON||i.JSON;"object"==typeof n&&n&&(b.stringify=n.stringify,b.parse=n.parse);var o,p,q,r=h.prototype,s=r.toString,t=new j((-0xc782b5b800cec));try{t=t.getUTCFullYear()==-109252&&0===t.getUTCMonth()&&1===t.getUTCDate()&&10==t.getUTCHours()&&37==t.getUTCMinutes()&&6==t.getUTCSeconds()&&708==t.getUTCMilliseconds()}catch(u){}if(!c("json")){var v="[object Function]",w="[object Date]",x="[object Number]",y="[object String]",z="[object Array]",A="[object Boolean]",B=c("bug-string-char-index");if(!t)var C=m.floor,D=[0,31,59,90,120,151,181,212,243,273,304,334],E=function(a,b){return D[b]+365*(a-1970)+C((a-1969+(b=+(b>1)))/4)-C((a-1901+b)/100)+C((a-1601+b)/400)};if((o=r.hasOwnProperty)||(o=function(a){var b,c={};return(c.__proto__=null,c.__proto__={toString:1},c).toString!=s?o=function(a){var b=this.__proto__,c=a in(this.__proto__=null,this);return this.__proto__=b,c}:(b=c.constructor,o=function(a){var c=(this.constructor||b).prototype;return a in this&&!(a in c&&this[a]===c[a])}),c=null,o.call(this,a)}),p=function(a,b){var c,d,e,f=0;(c=function(){this.valueOf=0}).prototype.valueOf=0,d=new c;for(e in d)o.call(d,e)&&f++;return c=d=null,f?p=2==f?function(a,b){var c,d={},e=s.call(a)==v;for(c in a)e&&"prototype"==c||o.call(d,c)||!(d[c]=1)||!o.call(a,c)||b(c)}:function(a,b){var c,d,e=s.call(a)==v;for(c in a)e&&"prototype"==c||!o.call(a,c)||(d="constructor"===c)||b(c);(d||o.call(a,c="constructor"))&&b(c)}:(d=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"],p=function(a,b){var c,e,f=s.call(a)==v,h=!f&&"function"!=typeof a.constructor&&g[typeof a.hasOwnProperty]&&a.hasOwnProperty||o;for(c in a)f&&"prototype"==c||!h.call(a,c)||b(c);for(e=d.length;c=d[--e];h.call(a,c)&&b(c));}),p(a,b)},!c("json-stringify")){var F={92:"\\\\",34:'\\"',8:"\\b",12:"\\f",10:"\\n",13:"\\r",9:"\\t"},G="000000",H=function(a,b){return(G+(b||0)).slice(-a)},I="\\u00",J=function(a){for(var b='"',c=0,d=a.length,e=!B||d>10,f=e&&(B?a.split(""):a);c<d;c++){var g=a.charCodeAt(c);switch(g){case 8:case 9:case 10:case 12:case 13:case 34:case 92:b+=F[g];break;default:if(g<32){b+=I+H(2,g.toString(16));break}b+=e?f[c]:a.charAt(c)}}return b+'"'},K=function(a,b,c,d,e,f,g){var h,i,j,k,m,n,r,t,u,v,B,D,F,G,I,L;try{h=b[a]}catch(M){}if("object"==typeof h&&h)if(i=s.call(h),i!=w||o.call(h,"toJSON"))"function"==typeof h.toJSON&&(i!=x&&i!=y&&i!=z||o.call(h,"toJSON"))&&(h=h.toJSON(a));else if(h>-1/0&&h<1/0){if(E){for(m=C(h/864e5),j=C(m/365.2425)+1970-1;E(j+1,0)<=m;j++);for(k=C((m-E(j,0))/30.42);E(j,k+1)<=m;k++);m=1+m-E(j,k),n=(h%864e5+864e5)%864e5,r=C(n/36e5)%24,t=C(n/6e4)%60,u=C(n/1e3)%60,v=n%1e3}else j=h.getUTCFullYear(),k=h.getUTCMonth(),m=h.getUTCDate(),r=h.getUTCHours(),t=h.getUTCMinutes(),u=h.getUTCSeconds(),v=h.getUTCMilliseconds();h=(j<=0||j>=1e4?(j<0?"-":"+")+H(6,j<0?-j:j):H(4,j))+"-"+H(2,k+1)+"-"+H(2,m)+"T"+H(2,r)+":"+H(2,t)+":"+H(2,u)+"."+H(3,v)+"Z"}else h=null;if(c&&(h=c.call(b,a,h)),null===h)return"null";if(i=s.call(h),i==A)return""+h;if(i==x)return h>-1/0&&h<1/0?""+h:"null";if(i==y)return J(""+h);if("object"==typeof h){for(G=g.length;G--;)if(g[G]===h)throw l();if(g.push(h),B=[],I=f,f+=e,i==z){for(F=0,G=h.length;F<G;F++)D=K(F,h,c,d,e,f,g),B.push(D===q?"null":D);L=B.length?e?"[\n"+f+B.join(",\n"+f)+"\n"+I+"]":"["+B.join(",")+"]":"[]"}else p(d||h,function(a){var b=K(a,h,c,d,e,f,g);b!==q&&B.push(J(a)+":"+(e?" ":"")+b)}),L=B.length?e?"{\n"+f+B.join(",\n"+f)+"\n"+I+"}":"{"+B.join(",")+"}":"{}";return g.pop(),L}};b.stringify=function(a,b,c){var d,e,f,h;if(g[typeof b]&&b)if((h=s.call(b))==v)e=b;else if(h==z){f={};for(var i,j=0,k=b.length;j<k;i=b[j++],h=s.call(i),(h==y||h==x)&&(f[i]=1));}if(c)if((h=s.call(c))==x){if((c-=c%1)>0)for(d="",c>10&&(c=10);d.length<c;d+=" ");}else h==y&&(d=c.length<=10?c:c.slice(0,10));return K("",(i={},i[""]=a,i),e,f,d,"",[])}}if(!c("json-parse")){var L,M,N=f.fromCharCode,O={92:"\\",34:'"',47:"/",98:"\b",116:"\t",110:"\n",102:"\f",114:"\r"},P=function(){throw L=M=null,k()},Q=function(){for(var a,b,c,d,e,f=M,g=f.length;L<g;)switch(e=f.charCodeAt(L)){case 9:case 10:case 13:case 32:L++;break;case 123:case 125:case 91:case 93:case 58:case 44:return a=B?f.charAt(L):f[L],L++,a;case 34:for(a="@",L++;L<g;)if(e=f.charCodeAt(L),e<32)P();else if(92==e)switch(e=f.charCodeAt(++L)){case 92:case 34:case 47:case 98:case 116:case 110:case 102:case 114:a+=O[e],L++;break;case 117:for(b=++L,c=L+4;L<c;L++)e=f.charCodeAt(L),e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70||P();a+=N("0x"+f.slice(b,L));break;default:P()}else{if(34==e)break;for(e=f.charCodeAt(L),b=L;e>=32&&92!=e&&34!=e;)e=f.charCodeAt(++L);a+=f.slice(b,L)}if(34==f.charCodeAt(L))return L++,a;P();default:if(b=L,45==e&&(d=!0,e=f.charCodeAt(++L)),e>=48&&e<=57){for(48==e&&(e=f.charCodeAt(L+1),e>=48&&e<=57)&&P(),d=!1;L<g&&(e=f.charCodeAt(L),e>=48&&e<=57);L++);if(46==f.charCodeAt(L)){for(c=++L;c<g&&(e=f.charCodeAt(c),e>=48&&e<=57);c++);c==L&&P(),L=c}if(e=f.charCodeAt(L),101==e||69==e){for(e=f.charCodeAt(++L),43!=e&&45!=e||L++,c=L;c<g&&(e=f.charCodeAt(c),e>=48&&e<=57);c++);c==L&&P(),L=c}return+f.slice(b,L)}if(d&&P(),"true"==f.slice(L,L+4))return L+=4,!0;if("false"==f.slice(L,L+5))return L+=5,!1;if("null"==f.slice(L,L+4))return L+=4,null;P()}return"$"},R=function(a){var b,c;if("$"==a&&P(),"string"==typeof a){if("@"==(B?a.charAt(0):a[0]))return a.slice(1);
9
+ if("["==a){for(b=[];a=Q(),"]"!=a;c||(c=!0))c&&(","==a?(a=Q(),"]"==a&&P()):P()),","==a&&P(),b.push(R(a));return b}if("{"==a){for(b={};a=Q(),"}"!=a;c||(c=!0))c&&(","==a?(a=Q(),"}"==a&&P()):P()),","!=a&&"string"==typeof a&&"@"==(B?a.charAt(0):a[0])&&":"==Q()||P(),b[a.slice(1)]=R(Q());return b}P()}return a},S=function(a,b,c){var d=T(a,b,c);d===q?delete a[b]:a[b]=d},T=function(a,b,c){var d,e=a[b];if("object"==typeof e&&e)if(s.call(e)==z)for(d=e.length;d--;)S(e,d,c);else p(e,function(a){S(e,a,c)});return c.call(a,b,e)};b.parse=function(a,b){var c,d;return L=0,M=""+a,c=R(Q()),"$"!=Q()&&P(),L=M=null,b&&s.call(b)==v?T((d={},d[""]=c,d),"",b):c}}}return b.runInContext=e,b}var f="function"==typeof a&&a.amd,g={"function":!0,object:!0},h=g[typeof d]&&d&&!d.nodeType&&d,i=g[typeof window]&&window||this,j=h&&g[typeof c]&&c&&!c.nodeType&&"object"==typeof b&&b;if(!j||j.global!==j&&j.window!==j&&j.self!==j||(i=j),h&&!f)e(i,h);else{var k=i.JSON,l=i.JSON3,m=!1,n=e(i,i.JSON3={noConflict:function(){return m||(m=!0,i.JSON=k,i.JSON3=l,k=l=null),n}});i.JSON={parse:n.parse,stringify:n.stringify}}f&&a(function(){return n})}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],79:[function(a,b,c){"use strict";var d;if(!Object.keys){var e=Object.prototype.hasOwnProperty,f=Object.prototype.toString,g=a("./isArguments"),h=Object.prototype.propertyIsEnumerable,i=!h.call({toString:null},"toString"),j=h.call(function(){},"prototype"),k=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(a){var b=a.constructor;return b&&b.prototype===a},m={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},n=function(){if("undefined"==typeof window)return!1;for(var a in window)try{if(!m["$"+a]&&e.call(window,a)&&null!==window[a]&&"object"==typeof window[a])try{l(window[a])}catch(b){return!0}}catch(b){return!0}return!1}(),o=function(a){if("undefined"==typeof window||!n)return l(a);try{return l(a)}catch(b){return!1}};d=function(a){var b=null!==a&&"object"==typeof a,c="[object Function]"===f.call(a),d=g(a),h=b&&"[object String]"===f.call(a),l=[];if(!b&&!c&&!d)throw new TypeError("Object.keys called on a non-object");var m=j&&c;if(h&&a.length>0&&!e.call(a,0))for(var n=0;n<a.length;++n)l.push(String(n));if(d&&a.length>0)for(var p=0;p<a.length;++p)l.push(String(p));else for(var q in a)m&&"prototype"===q||!e.call(a,q)||l.push(String(q));if(i)for(var r=o(a),s=0;s<k.length;++s)r&&"constructor"===k[s]||!e.call(a,k[s])||l.push(k[s]);return l}}b.exports=d},{"./isArguments":81}],80:[function(a,b,c){"use strict";var d=Array.prototype.slice,e=a("./isArguments"),f=Object.keys,g=f?function(a){return f(a)}:a("./implementation"),h=Object.keys;g.shim=function(){if(Object.keys){var a=function(){var a=Object.keys(arguments);return a&&a.length===arguments.length}(1,2);a||(Object.keys=function(a){return h(e(a)?d.call(a):a)})}else Object.keys=g;return Object.keys||g},b.exports=g},{"./implementation":79,"./isArguments":81}],81:[function(a,b,c){"use strict";var d=Object.prototype.toString;b.exports=function(a){var b=d.call(a),c="[object Arguments]"===b;return c||(c="[object Array]"!==b&&null!==a&&"object"==typeof a&&"number"==typeof a.length&&a.length>=0&&"[object Function]"===d.call(a.callee)),c}},{}],82:[function(a,b,c){c.endianness=function(){return"LE"},c.hostname=function(){return"undefined"!=typeof location?location.hostname:""},c.loadavg=function(){return[]},c.uptime=function(){return 0},c.freemem=function(){return Number.MAX_VALUE},c.totalmem=function(){return Number.MAX_VALUE},c.cpus=function(){return[]},c.type=function(){return"Browser"},c.release=function(){return"undefined"!=typeof navigator?navigator.appVersion:""},c.networkInterfaces=c.getNetworkInterfaces=function(){return{}},c.arch=function(){return"javascript"},c.platform=function(){return"browser"},c.tmpdir=c.tmpDir=function(){return"/tmp"},c.EOL="\n"},{}],83:[function(a,b,c){(function(a){var c=/^[\],:{}\s]*$/,d=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,e=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,f=/(?:^|:|,)(?:\s*\[)+/g,g=/^\s+/,h=/\s+$/;b.exports=function(b){return"string"==typeof b&&b?(b=b.replace(g,"").replace(h,""),a.JSON&&JSON.parse?JSON.parse(b):c.test(b.replace(d,"@").replace(e,"]").replace(f,""))?new Function("return "+b)():void 0):null}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],84:[function(a,b,c){c.encode=function(a){var b="";for(var c in a)a.hasOwnProperty(c)&&(b.length&&(b+="&"),b+=encodeURIComponent(c)+"="+encodeURIComponent(a[c]));return b},c.decode=function(a){for(var b={},c=a.split("&"),d=0,e=c.length;d<e;d++){var f=c[d].split("=");b[decodeURIComponent(f[0])]=decodeURIComponent(f[1])}return b}},{}],85:[function(a,b,c){var d=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,e=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];b.exports=function(a){var b=a,c=a.indexOf("["),f=a.indexOf("]");c!=-1&&f!=-1&&(a=a.substring(0,c)+a.substring(c,f).replace(/:/g,";")+a.substring(f,a.length));for(var g=d.exec(a||""),h={},i=14;i--;)h[e[i]]=g[i]||"";return c!=-1&&f!=-1&&(h.source=b,h.host=h.host.substring(1,h.host.length-1).replace(/;/g,":"),h.authority=h.authority.replace("[","").replace("]","").replace(/;/g,":"),h.ipv6uri=!0),h}},{}],86:[function(a,b,c){(function(a){"use strict";function c(b,c,d,e){if("function"!=typeof b)throw new TypeError('"callback" argument must be a function');var f,g,h=arguments.length;switch(h){case 0:case 1:return a.nextTick(b);case 2:return a.nextTick(function(){b.call(null,c)});case 3:return a.nextTick(function(){b.call(null,c,d)});case 4:return a.nextTick(function(){b.call(null,c,d,e)});default:for(f=new Array(h-1),g=0;g<f.length;)f[g++]=arguments[g];return a.nextTick(function(){b.apply(null,f)})}}"undefined"==typeof a||!a.version||0===a.version.indexOf("v0.")||0===a.version.indexOf("v1.")&&0!==a.version.indexOf("v1.8.")?b.exports={nextTick:c}:b.exports=a}).call(this,a("_process"))},{_process:87}],87:[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,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}},{}],88:[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");Z(a,b),a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)}function c(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 d(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 f(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 g(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 h(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 i(a){var b,c=[];for(b=0;b<a.length;b+=1)c[b/4|0]|=a[b]<<24-8*b;return pa.lib.WordArray.create(c,a.length)}function j(a){return encodeURIComponent(a).replace(/[!~*'()]/g,function(a){return"%".concat(a.charCodeAt(0).toString(16).toUpperCase())})}function k(a){return function(a){var b=[];return Object.keys(a).forEach(function(a){return b.push(a)}),b}(a).sort()}function l(a){return(b={message:a}).type="validationError",b.error=!0,b;var b}function m(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 n(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 o(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 p(a,b,c,d,e){var f=a.config,g=a.crypto,h=o(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(ta.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 q(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=ja(),j=null,k=null,q={};b.getOperation()===wa.PNTimeOperation||b.getOperation()===wa.PNChannelGroupsOperation?j=c[0]:(q=c[0],j=c[1]),"undefined"==typeof Promise||j||(k=ta.createPromise());var r=b.validateParams(a,q);if(r)return j?j(l(r)):k?(k.reject(new Fa("Validation failed, check status for details",l(r))),k.promise):void 0;var s,t=b.prepareParams(a,q),u=m(b,a,q),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,q):null,abortSignal:"function"==typeof b.getAbortSignal?b.getAbortSignal(a,q):null};t.uuid=f.UUID,t.pnsdk=n(f);var w=g.operationsLatencyForRequest();if(Object.keys(w).length&&(t=$($({},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&&p(a,u,t,q,b);var y=function(c,d){if(c.error)return b.handleError&&b.handleError(a,q,c),void(j?j(c):k&&k.reject(new Fa("PubNub call failed, check status for details",c)));g.stopLatencyMeasure(b.getOperation(),i);var e=b.handleResponse(a,d,q);"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()===wa.PNSubscribeOperation&&(c={statusCode:400,error:!0,operation:b.getOperation(),errorData:a,category:ua.PNUnknownCategory}),j(c,null)}else k&&k.reject(new Fa("PubNub call failed, check status for details",a))})};if(g.startLatencyMeasure(b.getOperation(),i),"POST"===o(a,b,q)){var z=b.postPayload(a,q);s=e.POST(t,z,v,y)}else"PATCH"===o(a,b,q)?(z=b.patchPayload(a,q),s=e.PATCH(t,z,v,y)):s="DELETE"===o(a,b,q)?e.DELETE(t,v,y):"GETFILE"===o(a,b,q)?e.GETFILE(t,v,y):e.GET(t,v,y);return b.getOperation()===wa.PNSubscribeOperation?s:k?k.promise:void 0}function r(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 s(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 t(a,b){var c=a.config,d=a.crypto;if(!c.cipherKey)return b;try{return d.decrypt(b)}catch(a){return b}}function u(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,h([],g(c),!1))}};return c.type=a,c}function v(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,h([],g(c),!1)),managed:!0}};return c.type=a,c.cancel={type:"CANCEL",payload:a,managed:!1},c}function w(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function x(a,b,c,d){var e;void 0===d&&(d=w()),z(a,"",0,[],void 0,0,d);try{e=0===xc.length?JSON.stringify(a,b,c):JSON.stringify(a,D(b),c)}catch(a){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==wc.length;){var f=wc.pop();4===f.length?Object.defineProperty(f[0],f[1],f[3]):f[0][f[1]]=f[2]}}return e}function y(a,b,c,d){var e=Object.getOwnPropertyDescriptor(d,c);void 0!==e.get?e.configurable?(Object.defineProperty(d,c,{value:a}),wc.push([d,c,b,e])):xc.push([b,c,a]):(d[c]=a,wc.push([d,c,b]))}function z(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 y(vc,a,b,e);if(void 0!==g.depthLimit&&f>g.depthLimit)return void y(uc,a,b,e);if(void 0!==g.edgesLimit&&c+1>g.edgesLimit)return void y(uc,a,b,e);if(d.push(a),Array.isArray(a))for(h=0;h<a.length;h++)z(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];z(a[j],j,h,d,a,f,g)}}d.pop()}}function A(a,b){return a<b?-1:a>b?1:0}function B(a,b,c,d){void 0===d&&(d=w());var e,f=C(a,"",0,[],void 0,0,d)||a;try{e=0===xc.length?JSON.stringify(f,b,c):JSON.stringify(f,D(b),c)}catch(a){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==wc.length;){var g=wc.pop();4===g.length?Object.defineProperty(g[0],g[1],g[3]):g[0][g[1]]=g[2]}}return e}function C(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 y(vc,a,b,e);try{if("function"==typeof a.toJSON)return}catch(a){return}if(void 0!==g.depthLimit&&f>g.depthLimit)return void y(uc,a,b,e);if(void 0!==g.edgesLimit&&c+1>g.edgesLimit)return void y(uc,a,b,e);if(d.push(a),Array.isArray(a))for(h=0;h<a.length;h++)C(a[h],h,h,d,a,f,g);else{var i={},j=Object.keys(a).sort(A);for(h=0;h<j.length;h++){var k=j[h];C(a[k],k,h,d,a,f,g),i[k]=a[k]}if(void 0===e)return i;wc.push([e,b,a]),e[b]=i}d.pop()}}function D(a){return a=void 0!==a?a:function(a,b){return b},function(b,c){if(xc.length>0)for(var d=0;d<xc.length;d++){var e=xc[d];if(e[1]===b&&e[0]===c){c=e[2],xc.splice(d,1);break}}return a.call(this,b,c)}}function E(a){return(E="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 F(a){return(F="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 G(a){if(a)return function(a){for(var b in G.prototype)Object.prototype.hasOwnProperty.call(G.prototype,b)&&(a[b]=G.prototype[b]);return a}(a)}function H(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 I(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)?I(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 I(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 J(a){if(a)return function(a){for(var b in J.prototype)Object.prototype.hasOwnProperty.call(J.prototype,b)&&(a[b]=J.prototype[b]);return a}(a)}function K(a){return function(a){if(Array.isArray(a))return L(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 L(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)?L(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 L(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 M(){this._defaults=[]}function N(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 O(a,b,c){var d=this;this._config.logVerbosity&&(a=a.use(N)),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:ua.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 P(a,b,e){return c(this,void 0,void 0,function(){var c;return d(this,function(d){switch(d.label){case 0:return c=kd.post(a),b.forEach(function(a){var b=a.key,d=a.value;c=c.field(b,d)}),c.attach("file",e,{contentType:"application/octet-stream"}),[4,c];case 1:return[2,d.sent()]}})})}function Q(a,b,c){var d=kd.get(this.getStandardOrigin()+b.url).set(b.headers).query(a);return O.call(this,d,b,c)}function R(a,b,c){var d=kd.get(this.getStandardOrigin()+b.url).set(b.headers).query(a);return O.call(this,d,b,c)}function S(a,b,c,d){var e=kd.post(this.getStandardOrigin()+c.url).query(a).set(c.headers).send(b);return O.call(this,e,c,d)}function T(a,b,c,d){var e=kd.patch(this.getStandardOrigin()+c.url).query(a).set(c.headers).send(b);return O.call(this,e,c,d)}function U(a,b,c){var d=kd["delete"](this.getStandardOrigin()+b.url).set(b.headers).query(a);return O.call(this,d,b,c)}function V(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 W(a){return!(!navigator||!navigator.sendBeacon)&&void navigator.sendBeacon(a)}function X(a){for(var b=pa.enc.Base64.parse(a).words,c=new ArrayBuffer(4*b.length),d=new Uint8Array(c),e=0,f=0,g=0;g<b.length;g+=1){var h=b[g];d[f=4*g]=(4278190080&h)>>24,d[f+1]=(16711680&h)>>16,d[f+2]=(65280&h)>>8,d[f+3]=255&h}for(var i=f+3;i>=f;i-=1)0===d[i]&&e<3&&(e+=1);return e>0?d.buffer.slice(0,d.byteLength-e):d.buffer}function Y(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)?Y(g):g}),c}var Z=function(a,b){return(Z=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)},$=function(){return $=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},$.apply(this,arguments)},_="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof b?b:"undefined"!=typeof self?self:{},aa={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)}(_)}(aa);var ba=aa.exports,ca={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)}(ca,ca.exports);var da,ea,fa,ga,ha,ia=ca.exports,ja=function(){return ia.uuid?ia.uuid():ia()},ka=function(){function a(a){var b,c,d,e=a.setup;if(this._PNSDKSuffix={},this.instanceId="pn-".concat(ja()),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.");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),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.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;
10
+ },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.0.1"},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}(),la=la||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=la,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]}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),ea=(da=la).enc.Utf8,da.algo.HMAC=da.lib.Base.extend({init:function(a,b){a=this._hasher=new a.init,"string"==typeof b&&(b=ea.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))}}),ga=(fa=la).lib.WordArray,fa.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 ga.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=la,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=la,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)}}(),la.lib.Cipher||function(a){var b=(n=la).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=la,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)}(),la.mode.ECB=((ha=la.lib.BlockCipherMode.extend()).Encryptor=ha.extend({processBlock:function(a,b){this._cipher.encryptBlock(a,b)}}),ha.Decryptor=ha.extend({processBlock:function(a,b){this._cipher.decryptBlock(a,b)}}),ha);var ma,na,oa,pa=la,qa=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 pa.HmacSHA256(a,this._config.secretKey).toString(pa.enc.Base64)},a.prototype.SHA256=function(a){return pa.SHA256(a).toString(pa.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?pa.enc.Base64.parse(a):"hex"===b.keyEncoding?pa.enc.Hex.parse(a):a},a.prototype._getPaddedKey=function(a,b){return a=this._decodeKey(a,b),b.encryptKey?pa.enc.Utf8.parse(this.SHA256(a).slice(0,32)):a},a.prototype._getMode=function(a){return"ecb"===a.mode?pa.mode.ECB:pa.mode.CBC},a.prototype._getIV=function(a){return"cbc"===a.mode?pa.enc.Utf8.parse(this._iv):null},a.prototype._getRandomIV=function(){return pa.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=pa.AES.encrypt(a,e,{iv:f,mode:d}).ciphertext;return f.clone().concat(g.clone()).toString(pa.enc.Base64)}var h=this._getIV(c);return pa.AES.encrypt(a,e,{iv:h,mode:d}).ciphertext.toString(pa.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),f=this._getPaddedKey(b||this._config.cipherKey,c);if(this._config.useRandomIVs){var g=i((k=e.from(a,"base64")).slice(0,16)),h=i(k.slice(16));try{var j=pa.AES.decrypt({ciphertext:h},f,{iv:g,mode:d}).toString(pa.enc.Utf8);return JSON.parse(j)}catch(a){return null}}else{g=this._getIV(c);try{var k=pa.enc.Base64.parse(a);return j=pa.AES.decrypt({ciphertext:k},f,{iv:g,mode:d}).toString(pa.enc.Utf8),JSON.parse(j)}catch(a){return null}}},a}(),ra=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}(),sa=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}(),ta={signPamFromParams:function(a){return k(a).map(function(b){return"".concat(b,"=").concat(j(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:j},ua={PNNetworkUpCategory:"PNNetworkUpCategory",PNNetworkDownCategory:"PNNetworkDownCategory",PNNetworkIssuesCategory:"PNNetworkIssuesCategory",PNTimeoutCategory:"PNTimeoutCategory",PNBadRequestCategory:"PNBadRequestCategory",PNAccessDeniedCategory:"PNAccessDeniedCategory",PNUnknownCategory:"PNUnknownCategory",PNReconnectedCategory:"PNReconnectedCategory",PNConnectedCategory:"PNConnectedCategory",PNRequestMessageCountExceededCategory:"PNRequestMessageCountExceededCategory"},va=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 ra({timeEndpoint:f}),this._dedupingManager=new sa({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;return 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)}),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 c=this;if(a.error){if(a.errorData&&"Aborted"===a.errorData.message)return;a.category===ua.PNTimeoutCategory?this._startSubscribeLoop():a.category===ua.PNNetworkIssuesCategory?(this.disconnect(),a.error&&this._config.autoNetworkDetection&&this._isOnline&&(this._isOnline=!1,this._listenerManager.announceNetworkDown()),this._reconnectionManager.onReconnection(function(){c._config.autoNetworkDetection&&!c._isOnline&&(c._isOnline=!0,c._listenerManager.announceNetworkUp()),c.reconnect(),c._subscriptionStatusAnnounced=!0;var b={category:ua.PNReconnectedCategory,operation:a.operation,lastTimetoken:c._lastTimetoken,currentTimetoken:c._currentTimetoken};c._listenerManager.announceStatus(b)}),this._reconnectionManager.startPolling(),this._listenerManager.announceStatus(a)):a.category===ua.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 d={};d.category=ua.PNConnectedCategory,d.operation=a.operation,d.affectedChannels=this._pendingChannelSubscriptions,d.subscribedChannels=this.getSubscribedChannels(),d.affectedChannelGroups=this._pendingChannelGroupSubscriptions,d.lastTimetoken=this._lastTimetoken,d.currentTimetoken=this._currentTimetoken,this._subscriptionStatusAnnounced=!0,this._listenerManager.announceStatus(d),this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[]}var e=b.messages||[],f=this._config,g=f.requestMessageCountThreshold,h=f.dedupeOnSubscribe;if(g&&e.length>=g){var i={};i.category=ua.PNRequestMessageCountExceededCategory,i.operation=a.operation,this._listenerManager.announceStatus(i)}e.forEach(function(a){var b=a.channel,d=a.subscriptionMatch,e=a.publishMetaData;if(b===d&&(d=null),h){if(c._dedupingManager.isDuplicate(a))return;c._dedupingManager.addEntry(a)}if(ta.endsWith(a.channel,"-pnpres"))(i={channel:null,subscription:null}).actualChannel=null!=d?b:null,i.subscribedChannel=null!=d?d:b,b&&(i.channel=b.substring(0,b.lastIndexOf("-pnpres"))),d&&(i.subscription=d.substring(0,d.lastIndexOf("-pnpres"))),i.action=a.payload.action,i.state=a.payload.data,i.timetoken=e.publishTimetoken,i.occupancy=a.payload.occupancy,i.uuid=a.payload.uuid,i.timestamp=a.payload.timestamp,a.payload.join&&(i.join=a.payload.join),a.payload.leave&&(i.leave=a.payload.leave),a.payload.timeout&&(i.timeout=a.payload.timeout),c._listenerManager.announcePresence(i);else if(1===a.messageType)(i={channel:null,subscription:null}).channel=b,i.subscription=d,i.timetoken=e.publishTimetoken,i.publisher=a.issuingClientId,a.userMetadata&&(i.userMetadata=a.userMetadata),i.message=a.payload,c._listenerManager.announceSignal(i);else if(2===a.messageType)(i={channel:null,subscription:null}).channel=b,i.subscription=d,i.timetoken=e.publishTimetoken,i.publisher=a.issuingClientId,a.userMetadata&&(i.userMetadata=a.userMetadata),i.message={event:a.payload.event,type:a.payload.type,data:a.payload.data},c._listenerManager.announceObjects(i),"user"===a.payload.type?c._listenerManager.announceUser(i):"space"===a.payload.type?c._listenerManager.announceSpace(i):"membership"===a.payload.type&&c._listenerManager.announceMembership(i);else if(3===a.messageType)(i={}).channel=b,i.subscription=d,i.timetoken=e.publishTimetoken,i.publisher=a.issuingClientId,i.data={messageTimetoken:a.payload.data.messageTimetoken,actionTimetoken:a.payload.data.actionTimetoken,type:a.payload.data.type,uuid:a.issuingClientId,value:a.payload.data.value},i.event=a.payload.event,c._listenerManager.announceMessageAction(i);else if(4===a.messageType){(i={}).channel=b,i.subscription=d,i.timetoken=e.publishTimetoken,i.publisher=a.issuingClientId;var f=a.payload;if(c._config.cipherKey){var g=c._crypto.decrypt(a.payload);"object"==typeof g&&null!==g&&(f=g)}a.userMetadata&&(i.userMetadata=a.userMetadata),i.message=f.message,i.file={id:f.file.id,name:f.file.name,url:c._getFileUrl({id:f.file.id,name:f.file.name,channel:b})},c._listenerManager.announceFile(i)}else{var i;(i={channel:null,subscription:null}).actualChannel=null!=d?b:null,i.subscribedChannel=null!=d?d:b,
11
+ i.channel=b,i.subscription=d,i.timetoken=e.publishTimetoken,i.publisher=a.issuingClientId,a.userMetadata&&(i.userMetadata=a.userMetadata),c._config.cipherKey?i.message=c._crypto.decrypt(a.payload):i.message=a.payload,c._listenerManager.announceMessage(i)}}),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}(),wa={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"},xa=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){var d=a._latencies[c],e=a._averageLatency(d);e>0&&(b["l_".concat(c)]=e)}),b},a.prototype.startLatencyMeasure=function(a,b){a!==wa.PNSubscribeOperation&&b&&(this._trackedLatencies[b]=Date.now())},a.prototype.stopLatencyMeasure=function(a,b){if(a!==wa.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 wa.PNPublishOperation:b="pub";break;case wa.PNSignalOperation:b="sig";break;case wa.PNHistoryOperation:case wa.PNFetchMessagesOperation:case wa.PNDeleteMessagesOperation:case wa.PNMessageCounts:b="hist";break;case wa.PNUnsubscribeOperation:case wa.PNWhereNowOperation:case wa.PNHereNowOperation:case wa.PNHeartbeatOperation:case wa.PNSetStateOperation:case wa.PNGetStateOperation:b="pres";break;case wa.PNAddChannelsToGroupOperation:case wa.PNRemoveChannelsFromGroupOperation:case wa.PNChannelGroupsOperation:case wa.PNRemoveGroupOperation:case wa.PNChannelsForGroupOperation:b="cg";break;case wa.PNPushNotificationEnabledChannelsOperation:case wa.PNRemoveAllPushNotificationsOperation:b="push";break;case wa.PNCreateUserOperation:case wa.PNUpdateUserOperation:case wa.PNDeleteUserOperation:case wa.PNGetUserOperation:case wa.PNGetUsersOperation:case wa.PNCreateSpaceOperation:case wa.PNUpdateSpaceOperation:case wa.PNDeleteSpaceOperation:case wa.PNGetSpaceOperation:case wa.PNGetSpacesOperation:case wa.PNGetMembersOperation:case wa.PNUpdateMembersOperation:case wa.PNGetMembershipsOperation:case wa.PNUpdateMembershipsOperation:b="obj";break;case wa.PNAddMessageActionOperation:case wa.PNRemoveMessageActionOperation:case wa.PNGetMessageActionsOperation:b="msga";break;case wa.PNAccessManagerGrant:case wa.PNAccessManagerAudit:b="pam";break;case wa.PNAccessManagerGrantToken:case wa.PNAccessManagerRevokeToken:b="pamv3";break;default:b="time"}return b},a}(),ya=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}(),za=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=$({},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}(ya),Aa=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?$({},this._payload):null},c}(ya),Ba=function(b){function c(){return null!==b&&b.apply(this,arguments)||this}return a(c,b),Object.defineProperty(c.prototype,"notification",{get:function(){return this._payload.notification},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"data",{get:function(){return this._payload.data},enumerable:!1,configurable:!0}),Object.defineProperty(c.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(c.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(c.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(c.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(c.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(c.prototype,"silent",{set:function(a){this._isSilent=a},enumerable:!1,configurable:!0}),c.prototype._setDefaultPayloadStructure=function(){this._payload.notification={},this._payload.data={}},c.prototype.toObject=function(){var a=$({},this._payload.data),b=null,c={};if(Object.keys(this._payload).length>2){var d=this._payload;d.notification,d.data;var e=function(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}(d,["notification","data"]);a=$($({},a),e)}return this._isSilent?a.notification=this._payload.notification:b=this._payload.notification,Object.keys(a).length&&(c.data=a),b&&Object.keys(b).length&&(c.notification=b),Object.keys(c).length?c:null},c}(ya),Ca=function(){function a(a,b){this._payload={apns:{},mpns:{},fcm:{}},this._title=a,this._body=b,this.apns=new za(this._payload.apns,a,b),this.mpns=new Aa(this._payload.mpns,a,b),this.fcm=new Ba(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}(),Da=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=ua.PNNetworkUpCategory,this.announceStatus(a)},a.prototype.announceNetworkDown=function(){var a={};a.category=ua.PNNetworkDownCategory,this.announceStatus(a)},a}(),Ea=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}(),Fa=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),Ga=Object.freeze({__proto__:null,getOperation:function(){return wa.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(ta.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{}}}),Ha=Object.freeze({__proto__:null,getOperation:function(){return wa.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(ta.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{}}}),Ia=Object.freeze({__proto__:null,getOperation:function(){return wa.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(ta.encodeString(c),"/remove")},isAuthSupported:function(){return!0},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},prepareParams:function(){return{}},handleResponse:function(){return{}}}),Ja=Object.freeze({__proto__:null,getOperation:function(){return wa.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}}}),Ka=Object.freeze({__proto__:null,getOperation:function(){return wa.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(ta.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}}}),La=Object.freeze({__proto__:null,getOperation:function(){return wa.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=$($({},i),{environment:g,topic:h})).type,i},handleResponse:function(){return{}}}),Ma=Object.freeze({__proto__:null,getOperation:function(){return wa.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=$($({},i),{environment:g,topic:h})).type,i},handleResponse:function(){return{}}}),Na=Object.freeze({__proto__:null,getOperation:function(){return wa.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=$($({},g),{environment:e,topic:f})).type,g},handleResponse:function(a,b){return{channels:b}}}),Oa=Object.freeze({__proto__:null,getOperation:function(){return wa.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=$($({},g),{environment:e,topic:f})).type,g},handleResponse:function(){return{}}}),Pa=Object.freeze({__proto__:null,getOperation:function(){return wa.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(ta.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{}}}),Qa=Object.freeze({__proto__:null,getOperation:function(){return wa.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(ta.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:[]}}}),Ra=Object.freeze({__proto__:null,getOperation:function(){return wa.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(ta.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{}}}),Sa=Object.freeze({__proto__:null,getOperation:function(){return wa.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(ta.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}}}),Ta=Object.freeze({__proto__:null,getOperation:function(){return wa.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(ta.encodeString(f),"/uuid/").concat(ta.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}}}),Ua=Object.freeze({__proto__:null,getOperation:function(){return wa.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(ta.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=$($({},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.")}}),Va=Object.freeze({__proto__:null,getOperation:function(){return wa.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(ta.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(){
12
+ return{}},postPayload:function(a,b){return b.action},handleResponse:function(a,b){return{data:b.data}}}),Wa=Object.freeze({__proto__:null,getOperation:function(){return wa.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(ta.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}}}),Xa=Object.freeze({__proto__:null,getOperation:function(){return wa.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(ta.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}}),Ya={getOperation:function(){return wa.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(ta.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}}},Za={getOperation:function(){return wa.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(ta.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}}},$a={getOperation:function(){return wa.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(ta.encodeString(b.channel),"/0/").concat(ta.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]}}},_a=function(a){var b=function(a){var b=this,e=a.generateUploadUrl,f=a.publishFile,g=a.modules,h=g.PubNubFile,i=g.config,j=g.cryptography,k=g.networking;return function(a){var g=a.channel,m=a.file,n=a.message,o=a.cipherKey,p=a.meta,q=a.ttl,r=a.storeInHistory;return c(b,void 0,void 0,function(){var a,b,c,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 d(this,function(d){switch(d.label){case 0:if(!g)throw new Fa("Validation failed, check status for details",l("channel can't be empty"));if(!m)throw new Fa("Validation failed, check status for details",l("file can't be empty"));return a=h.create(m),[4,e({channel:g,name:a.name})];case 1:return b=d.sent(),c=b.file_upload_request,s=c.url,t=c.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=d.sent(),d.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})),d.label=4;case 4:return d.trys.push([4,18,,20]),h.supportsFileUri&&m.uri?(A=(z=k).POSTFILE,B=[s,x],[4,a.toFileUri()]):[3,7];case 5:return[4,A.apply(z,B.concat([d.sent()]))];case 6:return y=d.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([d.sent()]))];case 9:return y=d.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([d.sent()]))];case 12:return y=d.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([d.sent()]))];case 15:return y=d.sent(),[3,17];case 16:throw new Error("Unsupported environment");case 17:return[3,20];case 18:return L=d.sent(),[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)})}))];case 19:throw M=d.sent(),N=/<Message>(.*)<\/Message>/gi.exec(M),new Fa(N?"Upload to bucket failed: ".concat(N[1]):"Upload to bucket failed.",L);case 20:if(204!==y.status)throw new Fa("Upload to bucket was unsuccessful",y);O=i.fileUploadPublishRetryLimit,P=!1,Q={timetoken:"0"},d.label=21;case 21:return d.trys.push([21,23,,24]),[4,f({channel:g,message:n,fileId:v,fileName:w,meta:p,storeInHistory:r,ttl:q})];case 22:return Q=d.sent(),P=!0,[3,24];case 23:return d.sent(),O-=1,[3,24];case 24:if(!P&&O>0)return[3,21];d.label=25;case 25:if(P)return[2,{timetoken:Q.timetoken,id:v,name:w}];throw new Fa("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}},ab=function(a,b){var c=b.channel,d=b.id,e=b.name,f=a.config,g=a.networking;if(!c)throw new Fa("Validation failed, check status for details",l("channel can't be empty"));if(!d)throw new Fa("Validation failed, check status for details",l("file id can't be empty"));if(!e)throw new Fa("Validation failed, check status for details",l("file name can't be empty"));var h="/v1/files/".concat(f.subscribeKey,"/channels/").concat(ta.encodeString(c),"/files/").concat(d,"/").concat(e),i={};i.uuid=f.getUUID(),i.pnsdk=n(f),f.getAuthKey()&&(i.auth=f.getAuthKey()),f.secretKey&&p(a,h,i,{},{getOperation:function(){return"PubNubGetFileUrlOperation"}});var j=Object.keys(i).map(function(a){return"".concat(encodeURIComponent(a),"=").concat(encodeURIComponent(i[a]))}).join("&");return""!==j?"".concat(g.getStandardOrigin()).concat(h,"?").concat(j):"".concat(g.getStandardOrigin()).concat(h)},bb={getOperation:function(){return wa.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(ta.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,e){var f=a.PubNubFile,g=a.config,h=a.cryptography;return c(void 0,void 0,void 0,function(){var a,c,i,j;return d(this,function(d){switch(d.label){case 0:return a=b.response.body,f.supportsEncryptFile&&(null!==(c=e.cipherKey)&&void 0!==c?c:g.cipherKey)?[4,h.decrypt(null!==(i=e.cipherKey)&&void 0!==i?i:g.cipherKey,a)]:[3,2];case 1:a=d.sent(),d.label=2;case 2:return[2,f.create({data:a,name:null!==(j=b.response.name)&&void 0!==j?j:e.name,mimeType:b.response.type})]}})})}},cb={getOperation:function(){return wa.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(ta.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}}},db={getOperation:function(){return wa.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,h,i,j,k,l,m={};return(null===(c=null==b?void 0:b.include)||void 0===c?void 0:c.customFields)&&(m.include="custom"),(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===(h=b.page)||void 0===h?void 0:h.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=g(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}}},eb={getOperation:function(){return wa.PNGetUUIDMetadataOperation},validateParams:function(){},getURL:function(a,b){var c,d=a.config;return"/v2/objects/".concat(d.subscribeKey,"/uuids/").concat(ta.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,f=a.config;return{uuid:null!==(c=null==b?void 0:b.uuid)&&void 0!==c?c:f.getUUID(),include:(null===(e=null===(d=null==b?void 0:b.include)||void 0===d?void 0:d.customFields)||void 0===e||e)&&"custom"}},handleResponse:function(a,b){return{status:b.status,data:b.data}}},fb={getOperation:function(){return wa.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(ta.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,f=a.config;return{uuid:null!==(c=null==b?void 0:b.uuid)&&void 0!==c?c:f.getUUID(),include:(null===(e=null===(d=null==b?void 0:b.include)||void 0===d?void 0:d.customFields)||void 0===e||e)&&"custom"}},handleResponse:function(a,b){return{status:b.status,data:b.data}}},gb={getOperation:function(){return wa.PNRemoveUUIDMetadataOperation},validateParams:function(){},getURL:function(a,b){var c,d=a.config;return"/v2/objects/".concat(d.subscribeKey,"/uuids/").concat(ta.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}}},hb={getOperation:function(){return wa.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,h,i,j,k,l,m={};return(null===(c=null==b?void 0:b.include)||void 0===c?void 0:c.customFields)&&(m.include="custom"),(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===(h=b.page)||void 0===h?void 0:h.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=g(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}}},ib={getOperation:function(){return wa.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(ta.encodeString(b.channel))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d;return{include:(null===(d=null===(c=null==b?void 0:b.include)||void 0===c?void 0:c.customFields)||void 0===d||d)&&"custom"}},handleResponse:function(a,b){return{status:b.status,data:b.data}}},jb={getOperation:function(){return wa.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(ta.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;return{include:(null===(d=null===(c=null==b?void 0:b.include)||void 0===c?void 0:c.customFields)||void 0===d||d)&&"custom"}},handleResponse:function(a,b){return{status:b.status,data:b.data}}},kb={getOperation:function(){return wa.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(ta.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}}},lb={getOperation:function(){return wa.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(ta.encodeString(b.channel),"/uuids")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f,h,i,j,k,l,m,n,o,p={};return(null==b?void 0:b.include)&&(p.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===(h=null==b?void 0:b.include)||void 0===h?void 0:h.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=g(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}}},mb={getOperation:function(){return wa.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(ta.encodeString(b.channel),"/uuids")},patchPayload:function(a,b){var c;return(c={set:[],remove:[]})[b.type]=b.uuids.map(function(a){return"string"==typeof a?{uuid:{id:a}}:{uuid:{id:a.id},custom:a.custom}}),c},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f,h,i,j,k,l,m={};return(null==b?void 0:b.include)&&(m.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===(h=null==b?void 0:b.page)||void 0===h?void 0:h.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?void 0: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=g(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}}},nb={getOperation:function(){return wa.PNGetMembershipsOperation},validateParams:function(){},getURL:function(a,b){var c,d=a.config;return"/v2/objects/".concat(d.subscribeKey,"/uuids/").concat(ta.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,h,i,j,k,l,m,n,o={};return(null==b?void 0:b.include)&&(o.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===(h=b.include)||void 0===h?void 0:h.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=g(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}}},ob={getOperation:function(){return wa.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(ta.encodeString(null!==(c=b.uuid)&&void 0!==c?c:d.getUUID()),"/channels")},patchPayload:function(a,b){var c;return(c={set:[],remove:[]})[b.type]=b.channels.map(function(a){return"string"==typeof a?{channel:{id:a}}:{channel:{id:a.id},custom:a.custom}}),c},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(a,b){var c,d,e,f,h,i,j,k,l,m={};return(null==b?void 0:b.include)&&(m.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===(h=null==b?void 0:b.page)||void 0===h?void 0:h.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?void 0: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=g(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}}},pb=Object.freeze({__proto__:null,getOperation:function(){return wa.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}}),qb=Object.freeze({__proto__:null,getOperation:function(){return wa.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{}}}),rb=Object.freeze({__proto__:null,getOperation:function(){return wa.PNAccessManagerGrantToken},extractPermissions:r,validateParams:function(a,b){var c=a.config;return c.subscribeKey?c.publishKey?c.secretKey?b.resources||b.patterns?(!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.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)?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(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 function(a,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]=r(i[a])}),j&&Object.keys(j).forEach(function(a){h.permissions.resources.channels[a]=r(j[a])}),k&&Object.keys(k).forEach(function(a){h.permissions.resources.groups[a]=r(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]=r(l[a])}),m&&Object.keys(m).forEach(function(a){h.permissions.patterns.channels[a]=r(m[a])}),n&&Object.keys(n).forEach(function(a){h.permissions.patterns.groups[a]=r(n[a])})}return(c||0===c)&&(h.ttl=c),f&&(h.permissions.meta=f),g&&(h.permissions.uuid="".concat(g)),h}(0,b)},handleResponse:function(a,b){return b.data.token}}),sb={getOperation:function(){return wa.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(ta.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}}},tb=Object.freeze({__proto__:null,getOperation:function(){return wa.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=s(a,b.message);return"/publish/".concat(c.publishKey,"/").concat(c.subscribeKey,"/0/").concat(ta.encodeString(d),"/0/").concat(ta.encodeString(e))},postURL:function(a,b){var c=a.config,d=b.channel;return"/publish/".concat(c.publishKey,"/").concat(c.subscribeKey,"/0/").concat(ta.encodeString(d),"/0")},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},postPayload:function(a,b){return s(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]}}}),ub=Object.freeze({__proto__:null,getOperation:function(){return wa.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(ta.encodeString(e),"/0/").concat(ta.encodeString(g))},getRequestTimeout:function(a){return a.config.getTransactionTimeout()},isAuthSupported:function(){return!0},prepareParams:function(){return{}},handleResponse:function(a,b){return{timetoken:b[2]}}}),vb=Object.freeze({__proto__:null,getOperation:function(){return wa.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(ta.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:t(a,b.message)};b.meta&&(d.meta=b.meta),c.messages.push(d)}),c}}),wb=Object.freeze({__proto__:null,getOperation:function(){return wa.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(ta.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}}),xb=Object.freeze({__proto__:null,getOperation:function(){return wa.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":d&&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(ta.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=g(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}}}),yb=Object.freeze({__proto__:null,getOperation:function(){return wa.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){
13
+ 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(ta.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}}),zb=Object.freeze({__proto__:null,getOperation:function(){return wa.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(){}}),Ab=Object.freeze({__proto__:null,getOperation:function(){return wa.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(ta.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}}}),Bb={getOperation:function(){return wa.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(ta.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){return{region:b.t.r,timetoken:b.t.t}}},Cb={getOperation:function(){return wa.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(ta.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}}}},Db=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}(),Eb=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}(),Fb=function(b){function c(){return null!==b&&b.apply(this,arguments)||this}return a(c,b),c.prototype.describe=function(a){return new Eb(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,h,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=g(j,3),l=k[0],m=k[1],n=k[2];try{for(var o=f(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=f(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=f(this.currentState.enterEffects),w=v.next();!w.done;w=v.next())q=w.value,this.notify({type:"invocationDispatched",invocation:q(this.currentContext)})}catch(a){h={error:a}}finally{try{w&&!w.done&&(i=v["return"])&&i.call(v)}finally{if(h)throw h.error}}}},c}(Db),Gb=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}(),Hb=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),Ib=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 Hb},c.prototype.abort=function(){this._aborted=!0,this.notify(new Hb)},c}(Db),Jb=function(b){function c(a,c,d){var e=b.call(this,a,c)||this;return e.asyncFunction=d,e.abortSignal=new Ib,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}),Kb=function(a){return function(b,c){return new Jb(b,c,a)}},Lb=v("HANDSHAKE",function(a,b){return{channels:a,groups:b}}),Mb=v("RECEIVE_EVENTS",function(a,b,c){return{channels:a,groups:b,cursor:c}}),Nb=(na=function(a){return a},oa=function(){for(var a=[],b=0;b<arguments.length;b++)a[b]=arguments[b];return{type:ma,payload:na.apply(void 0,h([],g(a),!1)),managed:!1}},oa.type=ma="EMIT_EVENTS",oa),Ob=v("RECONNECT",function(a){return a}),Pb=v("HANDSHAKE_RECONNECT",function(a){return a}),Qb=u("SUBSCRIPTION_CHANGE",function(a,b){return{channels:a,groups:b}}),Rb=u("DISCONNECT",function(){return{}}),Sb=u("RECONNECT",function(){return{}});u("RESTORE",function(a,b,c,d){return{channels:a,groups:b,timetoken:c,region:d}});var Tb=u("HANDSHAKING_SUCCESS",function(a){return a}),Ub=u("HANDSHAKING_FAILURE",function(a){return a}),Vb=u("HANDSHAKING_RECONNECTING_SUCCESS",function(a){return{cursor:a}}),Wb=u("HANDSHAKING_RECONNECTING_FAILURE",function(a){return a}),Xb=u("HANDSHAKING_RECONNECTING_GIVEUP",function(){return{}}),Yb=u("HANDSHAKING_RECONNECTING_RETRY",function(){return{}}),Zb=u("RECEIVING_SUCCESS",function(a,b){return{cursor:a,events:b}}),$b=u("RECEIVING_FAILURE",function(a){return a}),_b=u("RECONNECTING_SUCCESS",function(a,b){return{cursor:a,events:b}}),ac=u("RECONNECTING_FAILURE",function(a){return a}),bc=u("RECONNECTING_GIVEUP",function(){return{}}),cc=u("RECONNECTING_RETRY",function(){return{}}),dc=function(b){function e(a,e){var f=b.call(this,e)||this;return f.on(Lb.type,Kb(function(b,e,g){var h=g.handshake;return c(f,void 0,void 0,function(){var c,f;return d(this,function(d){switch(d.label){case 0:e.throwIfAborted(),d.label=1;case 1:return d.trys.push([1,3,,4]),[4,h({abortSignal:e,channels:b.channels,channelGroups:b.groups})];case 2:return c=d.sent(),a.transition(Tb(c)),[3,4];case 3:return(f=d.sent())instanceof Error&&"Aborted"===f.message?[2]:f instanceof Fa?[2,a.transition(Ub(f))]:[3,4];case 4:return[2]}})})})),f.on(Mb.type,Kb(function(b,e,g){var h=g.receiveEvents;return c(f,void 0,void 0,function(){var c,f;return d(this,function(d){switch(d.label){case 0:e.throwIfAborted(),d.label=1;case 1:return d.trys.push([1,3,,4]),[4,h({abortSignal:e,channels:b.channels,channelGroups:b.groups,timetoken:b.cursor.timetoken,region:b.cursor.region})];case 2:return c=d.sent(),a.transition(Zb(c.metadata,c.messages)),[3,4];case 3:return(f=d.sent())instanceof Error&&"Aborted"===f.message?[2]:f instanceof Fa?[2,a.transition($b(f))]:[3,4];case 4:return[2]}})})})),f.on(Nb.type,Kb(function(a,b,e){return e.receiveEvents,c(f,void 0,void 0,function(){return d(this,function(b){return a.length>0&&console.log(a),[2]})})})),f.on(Ob.type,Kb(function(b,e,g){var h=g.receiveEvents,i=g.shouldRetry,j=g.getRetryDelay,k=g.delay;return c(f,void 0,void 0,function(){var c,f;return d(this,function(d){switch(d.label){case 0:return i(b.reason,b.attempts)?(e.throwIfAborted(),[4,k(j(b.attempts))]):[2,a.transition(bc())];case 1:d.sent(),e.throwIfAborted(),d.label=2;case 2:return d.trys.push([2,4,,5]),[4,h({abortSignal:e,channels:b.channels,channelGroups:b.groups,timetoken:b.cursor.timetoken,region:b.cursor.region})];case 3:return c=d.sent(),[2,a.transition(_b(c.metadata,c.messages))];case 4:return(f=d.sent())instanceof Error&&"Aborted"===f.message?[2]:f instanceof Fa?[2,a.transition(ac(f))]:[3,5];case 5:return[2]}})})})),f.on(Pb.type,Kb(function(b,e,g){var h=g.handshake,i=g.shouldRetry,j=g.getRetryDelay,k=g.delay;return c(f,void 0,void 0,function(){var c,f;return d(this,function(d){switch(d.label){case 0:return i(b.reason,b.attempts)?(e.throwIfAborted(),[4,k(j(b.attempts))]):[2,a.transition(Xb())];case 1:d.sent(),e.throwIfAborted(),d.label=2;case 2:return d.trys.push([2,4,,5]),[4,h({abortSignal:e,channels:b.channels,channelGroups:b.groups})];case 3:return c=d.sent(),[2,a.transition(Vb(c.metadata))];case 4:return(f=d.sent())instanceof Error&&"Aborted"===f.message?[2]:f instanceof Fa?[2,a.transition(Wb(f))]:[3,5];case 5:return[2]}})})})),f}return a(e,b),e}(Gb),ec=new Eb("STOPPED");ec.on(Qb.type,function(a,b){return ec["with"]({channels:b.payload.channels,groups:b.payload.groups})}),ec.on(Sb.type,function(a){return lc["with"]($({},a))});var fc=new Eb("HANDSHAKE_FAILURE");fc.on(Yb.type,function(a){return kc["with"]($($({},a),{attempts:0}))}),fc.on(Rb.type,function(a){return ec["with"]({channels:a.channels,groups:a.groups})});var gc=new Eb("STOPPED");gc.on(Qb.type,function(a,b){return gc["with"]({channels:b.payload.channels,groups:b.payload.groups,cursor:a.cursor})}),gc.on(Sb.type,function(a){return jc["with"]($({},a))});var hc=new Eb("RECEIVE_FAILURE");hc.on(cc.type,function(a){return ic["with"]($($({},a),{attempts:0}))}),hc.on(Rb.type,function(a){return gc["with"]({channels:a.channels,groups:a.groups,cursor:a.cursor})});var ic=new Eb("RECEIVE_RECONNECTING");ic.onEnter(function(a){return Ob(a)}),ic.onExit(function(){return Ob.cancel}),ic.on(_b.type,function(a,b){return jc["with"]({channels:a.channels,groups:a.groups,cursor:b.payload.cursor},[Nb(b.payload.events)])}),ic.on(ac.type,function(a,b){return ic["with"]($($({},a),{attempts:a.attempts+1,reason:b.payload}))}),ic.on(bc.type,function(a){return hc["with"]({groups:a.groups,channels:a.channels,cursor:a.cursor,reason:a.reason})}),ic.on(Rb.type,function(a){return gc["with"]({channels:a.channels,groups:a.groups,cursor:a.cursor})});var jc=new Eb("RECEIVING");jc.onEnter(function(a){return Mb(a.channels,a.groups,a.cursor)}),jc.onExit(function(){return Mb.cancel}),jc.on(Zb.type,function(a,b){return jc["with"]($($({},a),{cursor:b.payload.cursor}),[Nb(b.payload.events)])}),jc.on(Qb.type,function(a,b){return 0===b.payload.channels.length&&0===b.payload.groups.length?mc["with"](void 0):jc["with"]($($({},a),{channels:b.payload.channels,groups:b.payload.groups}))}),jc.on($b.type,function(a,b){return ic["with"]($($({},a),{attempts:0,reason:b.payload}))}),jc.on(Rb.type,function(a){return gc["with"]({channels:a.channels,groups:a.groups,cursor:a.cursor})});var kc=new Eb("HANDSHAKE_RECONNECTING");kc.onEnter(function(a){return Pb(a)}),kc.onExit(function(){return Ob.cancel}),kc.on(_b.type,function(a,b){return jc["with"]({channels:a.channels,groups:a.groups,cursor:b.payload.cursor},[Nb(b.payload.events)])}),kc.on(ac.type,function(a,b){return kc["with"]($($({},a),{attempts:a.attempts+1,reason:b.payload}))}),kc.on(bc.type,function(a){return fc["with"]({groups:a.groups,channels:a.channels,reason:a.reason})}),kc.on(Rb.type,function(a){return ec["with"]({channels:a.channels,groups:a.groups})});var lc=new Eb("HANDSHAKING");lc.onEnter(function(a){return Lb(a.channels,a.groups)}),lc.onExit(function(){return Lb.cancel}),lc.on(Qb.type,function(a,b){return 0===b.payload.channels.length&&0===b.payload.groups.length?mc["with"](void 0):lc["with"]({channels:b.payload.channels,groups:b.payload.groups})}),lc.on(Tb.type,function(a,b){return jc["with"]({channels:a.channels,groups:a.groups,cursor:b.payload})}),lc.on(Ub.type,function(a,b){return kc["with"]($($({},a),{attempts:0,reason:b.payload}))}),lc.on(Rb.type,function(a){return ec["with"]({channels:a.channels,groups:a.groups})});var mc=new Eb("UNSUBSCRIBED");mc.on(Qb.type,function(a,b){return lc["with"]({channels:b.payload.channels,groups:b.payload.groups})});var nc=function(){function a(a){var b=this;this.engine=new Fb,this.channels=[],this.groups=[],this.dispatcher=new dc(this.engine,a),this.engine.subscribe(function(a){"invocationDispatched"===a.type&&b.dispatcher.dispatch(a.invocation)}),this.engine.start(mc,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=h(h([],g(this.channels),!1),g(null!=b?b:[]),!1),this.groups=h(h([],g(this.groups),!1),g(null!=c?c:[]),!1),this.engine.transition(Qb(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(Qb(this.channels.slice(0),this.groups.slice(0)))},a.prototype.unsubscribeAll=function(){this.channels=[],this.groups=[],this.engine.transition(Qb(this.channels.slice(0),this.groups.slice(0)))},a.prototype.reconnect=function(){this.engine.transition(Sb())},a.prototype.disconnect=function(){this.engine.transition(Rb())},a}(),oc=function(){function a(a){var b=this,c=a.networking,d=a.cbor,e=new ka({setup:a});this._config=e;var f=new qa({config:e}),i=a.cryptography;c.init(e);var j=new Ea(e,d);this._tokenManager=j;var k=new xa({maximumSamplesCount:6e4});this._telemetryManager=k;var l={config:e,networking:c,crypto:f,cryptography:i,tokenManager:j,telemetryManager:k,PubNubFile:a.PubNubFile};this.File=a.PubNubFile,this.encryptFile=function(a,c){return i.encryptFile(a,c,b.File)},this.decryptFile=function(a,c){return i.decryptFile(a,c,b.File)};var m=q.bind(this,l,zb),n=q.bind(this,l,Pa),o=q.bind(this,l,Ra),p=q.bind(this,l,Ta),r=q.bind(this,l,Ab),s=new Da;if(this._listenerManager=s,this.iAmHere=q.bind(this,l,Ra),this.iAmAway=q.bind(this,l,Pa),this.setPresenceState=q.bind(this,l,Ta),this.handshake=q.bind(this,l,Bb),this.receiveMessages=q.bind(this,l,Cb),!0===e.enableSubscribeBeta){var t=new nc({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 va({timeEndpoint:m,leaveEndpoint:n,heartbeatEndpoint:o,setStateEndpoint:p,subscribeEndpoint:r,crypto:l.crypto,config:l.config,listenerManager:s,getFileUrl:function(a){return ab(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=s.addListener.bind(s),this.removeListener=s.removeListener.bind(s),this.removeAllListeners=s.removeAllListeners.bind(s),this.parseToken=j.parseToken.bind(j),this.setToken=j.setToken.bind(j),this.getToken=j.getToken.bind(j),this.channelGroups={listGroups:q.bind(this,l,Ja),listChannels:q.bind(this,l,Ka),addChannels:q.bind(this,l,Ga),removeChannels:q.bind(this,l,Ha),deleteGroup:q.bind(this,l,Ia)},this.push={addChannels:q.bind(this,l,La),removeChannels:q.bind(this,l,Ma),deleteDevice:q.bind(this,l,Oa),listChannels:q.bind(this,l,Na)},this.hereNow=q.bind(this,l,Ua),this.whereNow=q.bind(this,l,Qa),this.getState=q.bind(this,l,Sa),this.grant=q.bind(this,l,qb),this.grantToken=q.bind(this,l,rb),this.audit=q.bind(this,l,pb),this.revokeToken=q.bind(this,l,sb),this.publish=q.bind(this,l,tb),this.fire=function(a,c){return a.replicate=!1,a.storeInHistory=!1,b.publish(a,c)},this.signal=q.bind(this,l,ub),this.history=q.bind(this,l,vb),this.deleteMessages=q.bind(this,l,wb),this.messageCounts=q.bind(this,l,xb),this.fetchMessages=q.bind(this,l,yb),this.addMessageAction=q.bind(this,l,Va),this.removeMessageAction=q.bind(this,l,Wa),this.getMessageActions=q.bind(this,l,Xa),this.listFiles=q.bind(this,l,Ya);var v=q.bind(this,l,Za);this.publishFile=q.bind(this,l,$a),this.sendFile=_a({generateUploadUrl:v,publishFile:this.publishFile,modules:l}),this.getFileUrl=function(a){return ab(l,a)},this.downloadFile=q.bind(this,l,bb),this.deleteFile=q.bind(this,l,cb),this.objects={getAllUUIDMetadata:q.bind(this,l,db),getUUIDMetadata:q.bind(this,l,eb),setUUIDMetadata:q.bind(this,l,fb),removeUUIDMetadata:q.bind(this,l,gb),getAllChannelMetadata:q.bind(this,l,hb),getChannelMetadata:q.bind(this,l,ib),setChannelMetadata:q.bind(this,l,jb),removeChannelMetadata:q.bind(this,l,kb),getChannelMembers:q.bind(this,l,lb),setChannelMembers:function(a){for(var c=[],d=1;d<arguments.length;d++)c[d-1]=arguments[d];return q.call.apply(q,h([b,l,mb,$({type:"set"},a)],g(c),!1))},removeChannelMembers:function(a){for(var c=[],d=1;d<arguments.length;d++)c[d-1]=arguments[d];return q.call.apply(q,h([b,l,mb,$({type:"delete"},a)],g(c),!1))},getMemberships:q.bind(this,l,nb),setMemberships:function(a){for(var c=[],d=1;d<arguments.length;d++)c[d-1]=arguments[d];return q.call.apply(q,h([b,l,ob,$({type:"set"},a)],g(c),!1))},removeMemberships:function(a){for(var c=[],d=1;d<arguments.length;d++)c[d-1]=arguments[d];return q.call.apply(q,h([b,l,ob,$({type:"delete"},a)],g(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.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 Ca(a,b)},a.generateUUID=function(){return ja()},a.OPERATIONS=wa,a.CATEGORIES=ua,a}(),pc=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 ua.PNNetworkIssuesCategory;if("ECONNREFUSED"===a.code)return ua.PNNetworkIssuesCategory;if("ECONNRESET"===a.code)return ua.PNNetworkIssuesCategory;if("EAI_AGAIN"===a.code)return ua.PNNetworkIssuesCategory;if(0===a.status||a.hasOwnProperty("status")&&void 0===a.status)return ua.PNNetworkIssuesCategory;if(a.timeout)return ua.PNTimeoutCategory;if("ETIMEDOUT"===a.code)return ua.PNNetworkIssuesCategory;if(a.response){if(a.response.badRequest)return ua.PNBadRequestCategory;if(a.response.forbidden)return ua.PNAccessDeniedCategory}return ua.PNUnknownCategory},a}(),qc=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}(),rc={exports:{}},sc={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}}(sc);var tc=x;x["default"]=x,x.stable=B,x.stableStringify=B;var uc="[...]",vc="[Circular]",wc=[],xc=[],yc=String.prototype.replace,zc=/%20/g,Ac="RFC3986",Bc={"default":Ac,formatters:{RFC1738:function(a){return yc.call(a,zc,"+")},RFC3986:function(a){return String(a)}},RFC1738:"RFC1738",RFC3986:Ac},Cc=Bc,Dc=Object.prototype.hasOwnProperty,Ec=Array.isArray,Fc=function(){for(var a=[],b=0;b<256;++b)a.push("%"+((b<16?"0":"")+b.toString(16)).toUpperCase());return a}(),Gc=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},Hc={arrayToObject:Gc,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(Ec(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===Cc.RFC1738&&(40===i||41===i)?g+=f.charAt(h):i<128?g+=Fc[i]:i<2048?g+=Fc[192|i>>6]+Fc[128|63&i]:i<55296||i>=57344?g+=Fc[224|i>>12]+Fc[128|i>>6&63]+Fc[128|63&i]:(h+=1,i=65536+((1023&i)<<10|1023&f.charCodeAt(h)),g+=Fc[240|i>>18]+Fc[128|i>>12&63]+Fc[128|i>>6&63]+Fc[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(Ec(a)){for(var c=[],d=0;d<a.length;d+=1)c.push(b(a[d]));return c}return b(a)},merge:function od(a,b,c){if(!b)return a;if("object"!=typeof b){if(Ec(a))a.push(b);else{if(!a||"object"!=typeof a)return[a,b];(c&&(c.plainObjects||c.allowPrototypes)||!Dc.call(Object.prototype,b))&&(a[b]=!0)}return a}if(!a||"object"!=typeof a)return[a].concat(b);var d=a;return Ec(a)&&!Ec(b)&&(d=Gc(a,c)),Ec(a)&&Ec(b)?(b.forEach(function(b,d){if(Dc.call(a,d)){var e=a[d];e&&"object"==typeof e&&b&&"object"==typeof b?a[d]=od(e,b,c):a.push(b)}else a[d]=b}),a):Object.keys(b).reduce(function(a,d){var e=b[d];return Dc.call(a,d)?a[d]=od(a[d],e,c):a[d]=e,a},d)}},Ic=Hc,Jc=Bc,Kc=Object.prototype.hasOwnProperty,Lc={brackets:function(a){return a+"[]"},comma:"comma",indices:function(a,b){return a+"["+b+"]"},repeat:function(a){return a}},Mc=Array.isArray,Nc=String.prototype.split,Oc=Array.prototype.push,Pc=function(a,b){Oc.apply(a,Mc(b)?b:[b])},Qc=Date.prototype.toISOString,Rc=Jc["default"],Sc={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:Ic.encode,encodeValuesOnly:!1,format:Rc,formatter:Jc.formatters[Rc],indices:!1,serializeDate:function(a){return Qc.call(a)},skipNulls:!1,strictNullHandling:!1},Tc=function pd(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&&Mc(p)&&(p=Ic.maybeMap(p,function(a){return a instanceof Date?j(a):a})),null===p){if(d)return f&&!m?f(b,Sc.encoder,n,"key",k):b;p=""}if("string"==typeof(o=p)||"number"==typeof o||"boolean"==typeof o||"symbol"==typeof o||"bigint"==typeof o||Ic.isBuffer(p)){if(f){var q=m?b:f(b,Sc.encoder,n,"key",k);if("comma"===c&&m){for(var r=Nc.call(String(p),","),s="",t=0;t<r.length;++t)s+=(0===t?"":",")+l(f(r[t],Sc.encoder,n,"value",k));return[l(q)+"="+s]}return[l(q)+"="+l(f(p,Sc.encoder,n,"value",k))]}return[l(b)+"="+l(String(p))]}var u,v=[];if(void 0===p)return v;if("comma"===c&&Mc(p))u=[{value:p.length>0?p.join(",")||null:void 0}];else if(Mc(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=Mc(p)?"function"==typeof c?c(b,y):b:b+(i?"."+y:"["+y+"]");Pc(v,pd(z,A,c,d,e,f,g,h,i,j,k,l,m,n))}}return v},Uc=Hc,Vc=Object.prototype.hasOwnProperty,Wc=Array.isArray,Xc={allowDots:!1,allowPrototypes:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:Uc.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},Yc=function(a){return a.replace(/&#(\d+);/g,function(a,b){return String.fromCharCode(parseInt(b,10))})},Zc=function(a,b){return a&&"string"==typeof a&&b.comma&&a.indexOf(",")>-1?a.split(","):a},$c=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&&Vc.call(Object.prototype,h)&&!c.allowPrototypes)return;i.push(h);
14
+ }for(var j=0;c.depth>0&&null!==(g=f.exec(e))&&j<c.depth;){if(j+=1,!c.plainObjects&&Vc.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:Zc(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)}},_c={formats:Bc,parse:function(a,b){var c=function(a){if(!a)return Xc;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?Xc.charset:a.charset;return{allowDots:void 0===a.allowDots?Xc.allowDots:!!a.allowDots,allowPrototypes:"boolean"==typeof a.allowPrototypes?a.allowPrototypes:Xc.allowPrototypes,arrayLimit:"number"==typeof a.arrayLimit?a.arrayLimit:Xc.arrayLimit,charset:b,charsetSentinel:"boolean"==typeof a.charsetSentinel?a.charsetSentinel:Xc.charsetSentinel,comma:"boolean"==typeof a.comma?a.comma:Xc.comma,decoder:"function"==typeof a.decoder?a.decoder:Xc.decoder,delimiter:"string"==typeof a.delimiter||Uc.isRegExp(a.delimiter)?a.delimiter:Xc.delimiter,depth:"number"==typeof a.depth||!1===a.depth?+a.depth:Xc.depth,ignoreQueryPrefix:!0===a.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof a.interpretNumericEntities?a.interpretNumericEntities:Xc.interpretNumericEntities,parameterLimit:"number"==typeof a.parameterLimit?a.parameterLimit:Xc.parameterLimit,parseArrays:!1!==a.parseArrays,plainObjects:"boolean"==typeof a.plainObjects?a.plainObjects:Xc.plainObjects,strictNullHandling:"boolean"==typeof a.strictNullHandling?a.strictNullHandling:Xc.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,Xc.decoder,i,"key"),k=b.strictNullHandling?null:""):(j=b.decoder(l.slice(0,n),Xc.decoder,i,"key"),k=Uc.maybeMap(Zc(l.slice(n+1),b),function(a){return b.decoder(a,Xc.decoder,i,"value")})),k&&b.interpretNumericEntities&&"iso-8859-1"===i&&(k=Yc(k)),l.indexOf("[]=")>-1&&(k=Wc(k)?[k]:k),Vc.call(d,j)?d[j]=Uc.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=$c(h,d[h],c,"string"==typeof a);e=Uc.merge(e,i,c)}return Uc.compact(e)},stringify:function(a,b){var c,d=a,e=function(a){if(!a)return Sc;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||Sc.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=Jc["default"];if(void 0!==a.format){if(!Kc.call(Jc.formatters,a.format))throw new TypeError("Unknown format option provided.");c=a.format}var d=Jc.formatters[c],e=Sc.filter;return("function"==typeof a.filter||Mc(a.filter))&&(e=a.filter),{addQueryPrefix:"boolean"==typeof a.addQueryPrefix?a.addQueryPrefix:Sc.addQueryPrefix,allowDots:void 0===a.allowDots?Sc.allowDots:!!a.allowDots,charset:b,charsetSentinel:"boolean"==typeof a.charsetSentinel?a.charsetSentinel:Sc.charsetSentinel,delimiter:void 0===a.delimiter?Sc.delimiter:a.delimiter,encode:"boolean"==typeof a.encode?a.encode:Sc.encode,encoder:"function"==typeof a.encoder?a.encoder:Sc.encoder,encodeValuesOnly:"boolean"==typeof a.encodeValuesOnly?a.encodeValuesOnly:Sc.encodeValuesOnly,filter:e,format:c,formatter:d,serializeDate:"function"==typeof a.serializeDate?a.serializeDate:Sc.serializeDate,skipNulls:"boolean"==typeof a.skipNulls?a.skipNulls:Sc.skipNulls,sort:"function"==typeof a.sort?a.sort:null,strictNullHandling:"boolean"==typeof a.strictNullHandling?a.strictNullHandling:Sc.strictNullHandling}}(b);"function"==typeof e.filter?d=(0,e.filter)("",d):Mc(e.filter)&&(c=e.filter);var f,g=[];if("object"!=typeof d||null===d)return"";f=b&&b.arrayFormat in Lc?b.arrayFormat:b&&"indices"in b?b.indices?"indices":"repeat":"indices";var h=Lc[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]||Pc(g,Tc(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:""}},ad=function(a){return null!==a&&"object"===E(a)},bd=ad,cd=G;G.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),clearTimeout(this._uploadTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,delete this._uploadTimeoutTimer,this},G.prototype.parse=function(a){return this._parser=a,this},G.prototype.responseType=function(a){return this._responseType=a,this},G.prototype.serialize=function(a){return this._serializer=a,this},G.prototype.timeout=function(a){if(!a||"object"!==F(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},G.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 dd=new Set(["ETIMEDOUT","ECONNRESET","EADDRINUSE","ECONNREFUSED","EPIPE","ENOTFOUND","ENETUNREACH","EAI_AGAIN"]),ed=new Set([408,413,429,500,502,503,504,521,522,524]);G.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&&ed.has(b.status))return!0;if(a){if(a.code&&dd.has(a.code))return!0;if(a.timeout&&"ECONNABORTED"===a.code)return!0;if(a.crossDomain)return!0}return!1},G.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()},G.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)},G.prototype["catch"]=function(a){return this.then(void 0,a)},G.prototype.use=function(a){return a(this),this},G.prototype.ok=function(a){if("function"!=typeof a)throw new Error("Callback required");return this._okCallback=a,this},G.prototype._isResponseOK=function(a){return!!a&&(this._okCallback?this._okCallback(a):a.status>=200&&a.status<300)},G.prototype.get=function(a){return this._header[a.toLowerCase()]},G.prototype.getHeader=G.prototype.get,G.prototype.set=function(a,b){if(bd(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},G.prototype.unset=function(a){return delete this._header[a.toLowerCase()],delete this.header[a],this},G.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(bd(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},G.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},G.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},G.prototype.withCredentials=function(a){return void 0===a&&(a=!0),this._withCredentials=a,this},G.prototype.redirects=function(a){return this._maxRedirects=a,this},G.prototype.maxResponseSize=function(a){if("number"!=typeof a)throw new TypeError("Invalid argument");return this._maxResponseSize=a,this},G.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},G.prototype.send=function(a){var b=bd(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&&bd(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},G.prototype.sortQuery=function(a){return this._sort=void 0===a||a,this},G.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("&")}}},G.prototype._appendQueryString=function(){console.warn("Unsupported")},G.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)}},G.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 fd={};fd.type=function(a){return a.split(/ *; */).shift()},fd.params=function(a){var b,c={},d=H(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},fd.parseLinks=function(a){var b,c={},d=H(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},fd.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 gd=fd,hd=J;J.prototype.get=function(a){return this.header[a.toLowerCase()]},J.prototype._setHeaderProperties=function(a){var b=a["content-type"]||"";this.type=gd.type(b);var c=gd.params(b);for(var d in c)Object.prototype.hasOwnProperty.call(c,d)&&(this[d]=c[d]);this.links={};try{a.link&&(this.links=gd.parseLinks(a.link))}catch(a){}},J.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){M.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}}),M.prototype._setDefaults=function(a){this._defaults.forEach(function(b){a[b.fn].apply(a,K(b.args))})};var id=M;!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=sc.exports,n=tc,o=_c,p=cd,q=ad,r=hd,s=id;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}}(rc,rc.exports);var jd,kd=rc.exports,ld=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 c(this,void 0,void 0,function(){var c;return d(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 c(this,void 0,void 0,function(){var c;return d(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,e){return c(this,void 0,void 0,function(){var c,f,g;return d(this,function(d){switch(d.label){case 0:return[4,this.getKey(a)];case 1:return c=d.sent(),[4,b.toArrayBuffer()];case 2:return f=d.sent(),[4,this.encryptArrayBuffer(c,f)];case 3:return g=d.sent(),[2,e.create({name:b.name,mimeType:"application/octet-stream",data:g})]}})})},a.prototype.decryptFile=function(a,b,e){return c(this,void 0,void 0,function(){var c,f,g;return d(this,function(d){switch(d.label){case 0:return[4,this.getKey(a)];case 1:return c=d.sent(),[4,b.toArrayBuffer()];case 2:return f=d.sent(),[4,this.decryptArrayBuffer(c,f)];case 3:return g=d.sent(),[2,e.create({name:b.name,data:g})]}})})},a.prototype.getKey=function(a){return c(this,void 0,void 0,function(){var b,c,f;return d(this,function(d){switch(d.label){case 0:return b=e.from(a),[4,crypto.subtle.digest("SHA-256",b.buffer)];case 1:return c=d.sent(),f=e.from(e.from(c).toString("hex").slice(0,32),"utf8").buffer,[2,crypto.subtle.importKey("raw",f,"AES-CBC",!0,["encrypt","decrypt"])]}})})},a.prototype.encryptArrayBuffer=function(a,b){return c(this,void 0,void 0,function(){var c,e,f;return d(this,function(d){switch(d.label){case 0:return c=crypto.getRandomValues(new Uint8Array(16)),e=V,f=[c.buffer],[4,crypto.subtle.encrypt({name:"AES-CBC",iv:c},a,b)];case 1:return[2,e.apply(void 0,f.concat([d.sent()]))]}})})},a.prototype.decryptArrayBuffer=function(a,b){return c(this,void 0,void 0,function(){var c;return d(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 c(this,void 0,void 0,function(){var c,f,g,h;return d(this,function(d){switch(d.label){case 0:return c=crypto.getRandomValues(new Uint8Array(16)),f=e.from(b).buffer,[4,crypto.subtle.encrypt({name:"AES-CBC",iv:c},a,f)];case 1:return g=d.sent(),h=V(c.buffer,g),[2,e.from(h).toString("utf8")]}})})},a.prototype.decryptString=function(a,b){return c(this,void 0,void 0,function(){var c,f,g,h;return d(this,function(d){switch(d.label){case 0:return c=e.from(b),f=c.slice(0,16),g=c.slice(16),[4,crypto.subtle.decrypt({name:"AES-CBC",iv:f},a,g)];case 1:return h=d.sent(),[2,e.from(h).toString("utf8")]}})})},a.IV_LENGTH=16,a}(),md=(jd=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 c(this,void 0,void 0,function(){return d(this,function(a){throw new Error("This feature is only supported in Node.js environments.")})})},a.prototype.toStream=function(){return c(this,void 0,void 0,function(){return d(this,function(a){throw new Error("This feature is only supported in Node.js environments.")})})},a.prototype.toFileUri=function(){return c(this,void 0,void 0,function(){return d(this,function(a){throw new Error("This feature is only supported in react native environments.")})})},a.prototype.toBlob=function(){return c(this,void 0,void 0,function(){return d(this,function(a){return[2,this.data]})})},a.prototype.toArrayBuffer=function(){return c(this,void 0,void 0,function(){var a=this;return d(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 c(this,void 0,void 0,function(){var a=this;return d(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 c(this,void 0,void 0,function(){return d(this,function(a){return[2,this.data]})})},a}(),jd.supportsFile="undefined"!=typeof File,jd.supportsBlob="undefined"!=typeof Blob,jd.supportsArrayBuffer="undefined"!=typeof ArrayBuffer,jd.supportsBuffer=!1,jd.supportsStream=!1,jd.supportsString=!0,jd.supportsEncryptFile=!0,jd.supportsFileUri=!1,jd),nd=function(b){function c(a){var c=this,d=a.listenToBrowserNetworkEvents,e=void 0===d||d;return a.sdkFamily="Web",a.networking=new pc({del:U,get:R,post:S,patch:T,sendBeacon:W,getfile:Q,postfile:P}),a.cbor=new qc(function(a){return Y(ba.decode(a))},X),a.PubNubFile=md,a.cryptography=new ld,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}(oc);return nd})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},b("buffer").Buffer)},{buffer:45}],89:[function(b,c,d){(function(b){!function(e){function f(a){throw new RangeError(I[a])}function g(a,b){for(var c=a.length,d=[];c--;)d[c]=b(a[c]);return d}function h(a,b){var c=a.split("@"),d="";c.length>1&&(d=c[0]+"@",a=c[1]),a=a.replace(H,".");var e=a.split("."),f=g(e,b).join(".");return d+f}function i(a){for(var b,c,d=[],e=0,f=a.length;e<f;)b=a.charCodeAt(e++),b>=55296&&b<=56319&&e<f?(c=a.charCodeAt(e++),56320==(64512&c)?d.push(((1023&b)<<10)+(1023&c)+65536):(d.push(b),e--)):d.push(b);return d}function j(a){return g(a,function(a){var b="";return a>65535&&(a-=65536,b+=L(a>>>10&1023|55296),a=56320|1023&a),b+=L(a)}).join("")}function k(a){return a-48<10?a-22:a-65<26?a-65:a-97<26?a-97:x}function l(a,b){return a+22+75*(a<26)-((0!=b)<<5)}function m(a,b,c){var d=0;for(a=c?K(a/B):a>>1,a+=K(a/b);a>J*z>>1;d+=x)a=K(a/J);return K(d+(J+1)*a/(a+A))}function n(a){var b,c,d,e,g,h,i,l,n,o,p=[],q=a.length,r=0,s=D,t=C;for(c=a.lastIndexOf(E),c<0&&(c=0),d=0;d<c;++d)a.charCodeAt(d)>=128&&f("not-basic"),p.push(a.charCodeAt(d));for(e=c>0?c+1:0;e<q;){for(g=r,h=1,i=x;e>=q&&f("invalid-input"),l=k(a.charCodeAt(e++)),(l>=x||l>K((w-r)/h))&&f("overflow"),r+=l*h,n=i<=t?y:i>=t+z?z:i-t,!(l<n);i+=x)o=x-n,h>K(w/o)&&f("overflow"),h*=o;b=p.length+1,t=m(r-g,b,0==g),K(r/b)>w-s&&f("overflow"),s+=K(r/b),r%=b,p.splice(r++,0,s)}return j(p)}function o(a){var b,c,d,e,g,h,j,k,n,o,p,q,r,s,t,u=[];for(a=i(a),q=a.length,b=D,c=0,g=C,h=0;h<q;++h)p=a[h],p<128&&u.push(L(p));for(d=e=u.length,e&&u.push(E);d<q;){for(j=w,h=0;h<q;++h)p=a[h],p>=b&&p<j&&(j=p);for(r=d+1,j-b>K((w-c)/r)&&f("overflow"),c+=(j-b)*r,b=j,h=0;h<q;++h)if(p=a[h],p<b&&++c>w&&f("overflow"),p==b){for(k=c,n=x;o=n<=g?y:n>=g+z?z:n-g,!(k<o);n+=x)t=k-o,s=x-o,u.push(L(l(o+t%s,0))),k=K(t/s);u.push(L(l(k,0))),g=m(c,r,d==e),c=0,++d}++c,++b}return u.join("")}function p(a){return h(a,function(a){return F.test(a)?n(a.slice(4).toLowerCase()):a})}function q(a){return h(a,function(a){return G.test(a)?"xn--"+o(a):a})}var r="object"==typeof d&&d&&!d.nodeType&&d,s="object"==typeof c&&c&&!c.nodeType&&c,t="object"==typeof b&&b;t.global!==t&&t.window!==t&&t.self!==t||(e=t);var u,v,w=2147483647,x=36,y=1,z=26,A=38,B=700,C=72,D=128,E="-",F=/^xn--/,G=/[^\x20-\x7E]/,H=/[\x2E\u3002\uFF0E\uFF61]/g,I={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},J=x-y,K=Math.floor,L=String.fromCharCode;if(u={version:"1.4.1",ucs2:{decode:i,encode:j},decode:n,encode:o,toASCII:q,toUnicode:p},"function"==typeof a&&"object"==typeof a.amd&&a.amd)a("punycode",function(){return u});else if(r&&s)if(c.exports==r)s.exports=u;else for(v in u)u.hasOwnProperty(v)&&(r[v]=u[v]);else e.punycode=u}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],90:[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.");
15
+ 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(){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:87}],91:[function(a,b,c){"use strict";function d(a,b){return Object.prototype.hasOwnProperty.call(a,b)}b.exports=function(a,b,c,f){b=b||"&",c=c||"=";var g={};if("string"!=typeof a||0===a.length)return g;var h=/\+/g;a=a.split(b);var i=1e3;f&&"number"==typeof f.maxKeys&&(i=f.maxKeys);var j=a.length;i>0&&j>i&&(j=i);for(var k=0;k<j;++k){var l,m,n,o,p=a[k].replace(h,"%20"),q=p.indexOf(c);q>=0?(l=p.substr(0,q),m=p.substr(q+1)):(l=p,m=""),n=decodeURIComponent(l),o=decodeURIComponent(m),d(g,n)?e(g[n])?g[n].push(o):g[n]=[g[n],o]:g[n]=o}return g};var e=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)}},{}],92:[function(a,b,c){"use strict";function d(a,b){if(a.map)return a.map(b);for(var c=[],d=0;d<a.length;d++)c.push(b(a[d],d));return c}var e=function(a){switch(typeof a){case"string":return a;case"boolean":return a?"true":"false";case"number":return isFinite(a)?a:"";default:return""}};b.exports=function(a,b,c,h){return b=b||"&",c=c||"=",null===a&&(a=void 0),"object"==typeof a?d(g(a),function(g){var h=encodeURIComponent(e(g))+c;return f(a[g])?d(a[g],function(a){return h+encodeURIComponent(e(a))}).join(b):h+encodeURIComponent(e(a[g]))}).join(b):h?encodeURIComponent(e(h))+c+encodeURIComponent(e(a)):""};var f=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},g=Object.keys||function(a){var b=[];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&b.push(c);return b}},{}],93:[function(a,b,c){"use strict";c.decode=c.parse=a("./decode"),c.encode=c.stringify=a("./encode")},{"./decode":91,"./encode":92}],94:[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}},{}],95:[function(a,b,c){function d(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d=e(a),f=d.source,j=d.id,k=d.path,l=i[j]&&k in i[j].nsps,m=b.forceNew||b["force new connection"]||!1===b.multiplex||l;return m?(h("ignoring socket cache for %s",f),c=g(f,b)):(i[j]||(h("new io instance for %s",f),i[j]=g(f,b)),c=i[j]),c.socket(d.path)}var e=a("./url"),f=a("socket.io-parser"),g=a("./manager"),h=a("debug")("socket.io-client");b.exports=c=d;var i=c.managers={};c.protocol=f.protocol,c.connect=d,c.Manager=a("./manager"),c.Socket=a("./socket")},{"./manager":96,"./socket":98,"./url":99,debug:101,"socket.io-parser":105}],96:[function(a,b,c){function d(a,b){return this instanceof d?(a&&"object"==typeof a&&(b=a,a=void 0),b=b||{},b.path=b.path||"/socket.io",this.nsps={},this.subs=[],this.opts=b,this.reconnection(b.reconnection!==!1),this.reconnectionAttempts(b.reconnectionAttempts||1/0),this.reconnectionDelay(b.reconnectionDelay||1e3),this.reconnectionDelayMax(b.reconnectionDelayMax||5e3),this.randomizationFactor(b.randomizationFactor||.5),this.backoff=new m({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==b.timeout?2e4:b.timeout),this.readyState="closed",this.uri=a,this.connecting=[],this.lastPing=null,this.encoding=!1,this.packetBuffer=[],this.encoder=new h.Encoder,this.decoder=new h.Decoder,this.autoConnect=b.autoConnect!==!1,void(this.autoConnect&&this.open())):new d(a,b)}var e=a("engine.io-client"),f=a("./socket"),g=a("component-emitter"),h=a("socket.io-parser"),i=a("./on"),j=a("component-bind"),k=a("debug")("socket.io-client:manager"),l=a("indexof"),m=a("backo2"),n=Object.prototype.hasOwnProperty;b.exports=d,d.prototype.emitAll=function(){this.emit.apply(this,arguments);for(var a in this.nsps)n.call(this.nsps,a)&&this.nsps[a].emit.apply(this.nsps[a],arguments)},d.prototype.updateSocketIds=function(){for(var a in this.nsps)n.call(this.nsps,a)&&(this.nsps[a].id=this.engine.id)},g(d.prototype),d.prototype.reconnection=function(a){return arguments.length?(this._reconnection=!!a,this):this._reconnection},d.prototype.reconnectionAttempts=function(a){return arguments.length?(this._reconnectionAttempts=a,this):this._reconnectionAttempts},d.prototype.reconnectionDelay=function(a){return arguments.length?(this._reconnectionDelay=a,this.backoff&&this.backoff.setMin(a),this):this._reconnectionDelay},d.prototype.randomizationFactor=function(a){return arguments.length?(this._randomizationFactor=a,this.backoff&&this.backoff.setJitter(a),this):this._randomizationFactor},d.prototype.reconnectionDelayMax=function(a){return arguments.length?(this._reconnectionDelayMax=a,this.backoff&&this.backoff.setMax(a),this):this._reconnectionDelayMax},d.prototype.timeout=function(a){return arguments.length?(this._timeout=a,this):this._timeout},d.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()},d.prototype.open=d.prototype.connect=function(a){if(k("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;k("opening %s",this.uri),this.engine=e(this.uri,this.opts);var b=this.engine,c=this;this.readyState="opening",this.skipReconnect=!1;var d=i(b,"open",function(){c.onopen(),a&&a()}),f=i(b,"error",function(b){if(k("connect_error"),c.cleanup(),c.readyState="closed",c.emitAll("connect_error",b),a){var d=new Error("Connection error");d.data=b,a(d)}else c.maybeReconnectOnOpen()});if(!1!==this._timeout){var g=this._timeout;k("connect attempt will timeout after %d",g);var h=setTimeout(function(){k("connect attempt timed out after %d",g),d.destroy(),b.close(),b.emit("error","timeout"),c.emitAll("connect_timeout",g)},g);this.subs.push({destroy:function(){clearTimeout(h)}})}return this.subs.push(d),this.subs.push(f),this},d.prototype.onopen=function(){k("open"),this.cleanup(),this.readyState="open",this.emit("open");var a=this.engine;this.subs.push(i(a,"data",j(this,"ondata"))),this.subs.push(i(a,"ping",j(this,"onping"))),this.subs.push(i(a,"pong",j(this,"onpong"))),this.subs.push(i(a,"error",j(this,"onerror"))),this.subs.push(i(a,"close",j(this,"onclose"))),this.subs.push(i(this.decoder,"decoded",j(this,"ondecoded")))},d.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},d.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},d.prototype.ondata=function(a){this.decoder.add(a)},d.prototype.ondecoded=function(a){this.emit("packet",a)},d.prototype.onerror=function(a){k("error",a),this.emitAll("error",a)},d.prototype.socket=function(a){function b(){~l(d.connecting,c)||d.connecting.push(c)}var c=this.nsps[a];if(!c){c=new f(this,a),this.nsps[a]=c;var d=this;c.on("connecting",b),c.on("connect",function(){c.id=d.engine.id}),this.autoConnect&&b()}return c},d.prototype.destroy=function(a){var b=l(this.connecting,a);~b&&this.connecting.splice(b,1),this.connecting.length||this.close()},d.prototype.packet=function(a){k("writing packet %j",a);var b=this;b.encoding?b.packetBuffer.push(a):(b.encoding=!0,this.encoder.encode(a,function(c){for(var d=0;d<c.length;d++)b.engine.write(c[d],a.options);b.encoding=!1,b.processPacketQueue()}))},d.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var a=this.packetBuffer.shift();this.packet(a)}},d.prototype.cleanup=function(){k("cleanup");for(var a;a=this.subs.shift();)a.destroy();this.packetBuffer=[],this.encoding=!1,this.lastPing=null,this.decoder.destroy()},d.prototype.close=d.prototype.disconnect=function(){k("disconnect"),this.skipReconnect=!0,this.reconnecting=!1,"opening"==this.readyState&&this.cleanup(),this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},d.prototype.onclose=function(a){k("onclose"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",a),this._reconnection&&!this.skipReconnect&&this.reconnect()},d.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var a=this;if(this.backoff.attempts>=this._reconnectionAttempts)k("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var b=this.backoff.duration();k("will wait %dms before reconnect attempt",b),this.reconnecting=!0;var c=setTimeout(function(){a.skipReconnect||(k("attempting reconnect"),a.emitAll("reconnect_attempt",a.backoff.attempts),a.emitAll("reconnecting",a.backoff.attempts),a.skipReconnect||a.open(function(b){b?(k("reconnect attempt error"),a.reconnecting=!1,a.reconnect(),a.emitAll("reconnect_error",b.data)):(k("reconnect success"),a.onreconnect())}))},b);this.subs.push({destroy:function(){clearTimeout(c)}})}},d.prototype.onreconnect=function(){var a=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",a)}},{"./on":97,"./socket":98,backo2:40,"component-bind":48,"component-emitter":100,debug:101,"engine.io-client":51,indexof:75,"socket.io-parser":105}],97:[function(a,b,c){function d(a,b,c){return a.on(b,c),{destroy:function(){a.removeListener(b,c)}}}b.exports=d},{}],98:[function(a,b,c){function d(a,b){this.io=a,this.nsp=b,this.json=this,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,this.io.autoConnect&&this.open()}var e=a("socket.io-parser"),f=a("component-emitter"),g=a("to-array"),h=a("./on"),i=a("component-bind"),j=a("debug")("socket.io-client:socket"),k=a("has-binary");b.exports=c=d;var l={connect:1,connect_error:1,connect_timeout:1,connecting:1,disconnect:1,error:1,reconnect:1,reconnect_attempt:1,reconnect_failed:1,reconnect_error:1,reconnecting:1,ping:1,pong:1},m=f.prototype.emit;f(d.prototype),d.prototype.subEvents=function(){if(!this.subs){var a=this.io;this.subs=[h(a,"open",i(this,"onopen")),h(a,"packet",i(this,"onpacket")),h(a,"close",i(this,"onclose"))]}},d.prototype.open=d.prototype.connect=function(){return this.connected?this:(this.subEvents(),this.io.open(),"open"==this.io.readyState&&this.onopen(),this.emit("connecting"),this)},d.prototype.send=function(){var a=g(arguments);return a.unshift("message"),this.emit.apply(this,a),this},d.prototype.emit=function(a){if(l.hasOwnProperty(a))return m.apply(this,arguments),this;var b=g(arguments),c=e.EVENT;k(b)&&(c=e.BINARY_EVENT);var d={type:c,data:b};return d.options={},d.options.compress=!this.flags||!1!==this.flags.compress,"function"==typeof b[b.length-1]&&(j("emitting packet with ack id %d",this.ids),this.acks[this.ids]=b.pop(),d.id=this.ids++),this.connected?this.packet(d):this.sendBuffer.push(d),delete this.flags,this},d.prototype.packet=function(a){a.nsp=this.nsp,this.io.packet(a)},d.prototype.onopen=function(){j("transport is open - connecting"),"/"!=this.nsp&&this.packet({type:e.CONNECT})},d.prototype.onclose=function(a){j("close (%s)",a),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",a)},d.prototype.onpacket=function(a){if(a.nsp==this.nsp)switch(a.type){case e.CONNECT:this.onconnect();break;case e.EVENT:this.onevent(a);break;case e.BINARY_EVENT:this.onevent(a);break;case e.ACK:this.onack(a);break;case e.BINARY_ACK:this.onack(a);break;case e.DISCONNECT:this.ondisconnect();break;case e.ERROR:this.emit("error",a.data)}},d.prototype.onevent=function(a){var b=a.data||[];j("emitting event %j",b),null!=a.id&&(j("attaching ack callback to event"),b.push(this.ack(a.id))),this.connected?m.apply(this,b):this.receiveBuffer.push(b)},d.prototype.ack=function(a){var b=this,c=!1;return function(){if(!c){c=!0;var d=g(arguments);j("sending ack %j",d);var f=k(d)?e.BINARY_ACK:e.ACK;b.packet({type:f,id:a,data:d})}}},d.prototype.onack=function(a){var b=this.acks[a.id];"function"==typeof b?(j("calling ack %s with %j",a.id,a.data),b.apply(this,a.data),delete this.acks[a.id]):j("bad ack %s",a.id)},d.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},d.prototype.emitBuffered=function(){var a;for(a=0;a<this.receiveBuffer.length;a++)m.apply(this,this.receiveBuffer[a]);for(this.receiveBuffer=[],a=0;a<this.sendBuffer.length;a++)this.packet(this.sendBuffer[a]);this.sendBuffer=[]},d.prototype.ondisconnect=function(){j("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},d.prototype.destroy=function(){if(this.subs){for(var a=0;a<this.subs.length;a++)this.subs[a].destroy();this.subs=null}this.io.destroy(this)},d.prototype.close=d.prototype.disconnect=function(){return this.connected&&(j("performing disconnect (%s)",this.nsp),this.packet({type:e.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this},d.prototype.compress=function(a){return this.flags=this.flags||{},this.flags.compress=a,this}},{"./on":97,"component-bind":48,"component-emitter":100,debug:101,"has-binary":71,"socket.io-parser":105,"to-array":136}],99:[function(a,b,c){(function(c){function d(a,b){var d=a,b=b||c.location;null==a&&(a=b.protocol+"//"+b.host),"string"==typeof a&&("/"==a.charAt(0)&&(a="/"==a.charAt(1)?b.protocol+a:b.host+a),/^(https?|wss?):\/\//.test(a)||(f("protocol-less url %s",a),a="undefined"!=typeof b?b.protocol+"//"+a:"https://"+a),f("parse %s",a),d=e(a)),d.port||(/^(http|ws)$/.test(d.protocol)?d.port="80":/^(http|ws)s$/.test(d.protocol)&&(d.port="443")),d.path=d.path||"/";var g=d.host.indexOf(":")!==-1,h=g?"["+d.host+"]":d.host;return d.id=d.protocol+"://"+h+":"+d.port,d.href=d.protocol+"://"+h+(b&&b.port==d.port?"":":"+d.port),d}var e=a("parseuri"),f=a("debug")("socket.io-client:url");b.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{debug:101,parseuri:85}],100:[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}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 this},d.prototype.emit=function(a){this._callbacks=this._callbacks||{};var b=[].slice.call(arguments,1),c=this._callbacks["$"+a];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}},{}],101:[function(a,b,c){arguments[4][62][0].apply(c,arguments)},{"./debug":102,dup:62}],102:[function(a,b,c){arguments[4][63][0].apply(c,arguments)},{dup:63,ms:103}],103:[function(a,b,c){arguments[4][64][0].apply(c,arguments)},{dup:64}],104:[function(a,b,c){(function(b){var d=a("isarray"),e=a("./is-buffer");c.deconstructPacket=function(a){function b(a){if(!a)return a;if(e(a)){var f={_placeholder:!0,num:c.length};return c.push(a),f}if(d(a)){for(var g=new Array(a.length),h=0;h<a.length;h++)g[h]=b(a[h]);return g}if("object"==typeof a&&!(a instanceof Date)){var g={};for(var i in a)g[i]=b(a[i]);return g}return a}var c=[],f=a.data,g=a;return g.data=b(f),g.attachments=c.length,{packet:g,buffers:c}},c.reconstructPacket=function(a,b){function c(a){if(a&&a._placeholder){var e=b[a.num];return e}if(d(a)){for(var f=0;f<a.length;f++)a[f]=c(a[f]);return a}if(a&&"object"==typeof a){for(var g in a)a[g]=c(a[g]);return a}return a}return a.data=c(a.data),a.attachments=void 0,a},c.removeBlobs=function(a,c){function f(a,i,j){if(!a)return a;if(b.Blob&&a instanceof Blob||b.File&&a instanceof File){g++;var k=new FileReader;k.onload=function(){j?j[i]=this.result:h=this.result,--g||c(h)},k.readAsArrayBuffer(a)}else if(d(a))for(var l=0;l<a.length;l++)f(a[l],l,a);else if(a&&"object"==typeof a&&!e(a))for(var m in a)f(a[m],m,a)}var g=0,h=a;f(h),g||c(h)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./is-buffer":106,isarray:77}],105:[function(a,b,c){function d(){}function e(a){var b="",d=!1;return b+=a.type,c.BINARY_EVENT!=a.type&&c.BINARY_ACK!=a.type||(b+=a.attachments,b+="-"),a.nsp&&"/"!=a.nsp&&(d=!0,b+=a.nsp),null!=a.id&&(d&&(b+=",",d=!1),b+=a.id),null!=a.data&&(d&&(b+=","),b+=l.stringify(a.data)),k("encoded %j as %s",a,b),b}function f(a,b){function c(a){var c=n.deconstructPacket(a),d=e(c.packet),f=c.buffers;f.unshift(d),b(f)}n.removeBlobs(a,c)}function g(){this.reconstructor=null}function h(a){var b={},d=0;if(b.type=Number(a.charAt(0)),null==c.types[b.type])return j();if(c.BINARY_EVENT==b.type||c.BINARY_ACK==b.type){
16
+ for(var e="";"-"!=a.charAt(++d)&&(e+=a.charAt(d),d!=a.length););if(e!=Number(e)||"-"!=a.charAt(d))throw new Error("Illegal attachments");b.attachments=Number(e)}if("/"==a.charAt(d+1))for(b.nsp="";++d;){var f=a.charAt(d);if(","==f)break;if(b.nsp+=f,d==a.length)break}else b.nsp="/";var g=a.charAt(d+1);if(""!==g&&Number(g)==g){for(b.id="";++d;){var f=a.charAt(d);if(null==f||Number(f)!=f){--d;break}if(b.id+=a.charAt(d),d==a.length)break}b.id=Number(b.id)}if(a.charAt(++d))try{b.data=l.parse(a.substr(d))}catch(h){return j()}return k("decoded %s as %j",a,b),b}function i(a){this.reconPack=a,this.buffers=[]}function j(a){return{type:c.ERROR,data:"parser error"}}var k=a("debug")("socket.io-parser"),l=a("json3"),m=(a("isarray"),a("component-emitter")),n=a("./binary"),o=a("./is-buffer");c.protocol=4,c.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],c.CONNECT=0,c.DISCONNECT=1,c.EVENT=2,c.ACK=3,c.ERROR=4,c.BINARY_EVENT=5,c.BINARY_ACK=6,c.Encoder=d,c.Decoder=g,d.prototype.encode=function(a,b){if(k("encoding packet %j",a),c.BINARY_EVENT==a.type||c.BINARY_ACK==a.type)f(a,b);else{var d=e(a);b([d])}},m(g.prototype),g.prototype.add=function(a){var b;if("string"==typeof a)b=h(a),c.BINARY_EVENT==b.type||c.BINARY_ACK==b.type?(this.reconstructor=new i(b),0===this.reconstructor.reconPack.attachments&&this.emit("decoded",b)):this.emit("decoded",b);else{if(!o(a)&&!a.base64)throw new Error("Unknown type: "+a);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");b=this.reconstructor.takeBinaryData(a),b&&(this.reconstructor=null,this.emit("decoded",b))}},g.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},i.prototype.takeBinaryData=function(a){if(this.buffers.push(a),this.buffers.length==this.reconPack.attachments){var b=n.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),b}return null},i.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}},{"./binary":104,"./is-buffer":106,"component-emitter":107,debug:108,isarray:77,json3:78}],106:[function(a,b,c){(function(a){function c(b){return a.Buffer&&a.Buffer.isBuffer(b)||a.ArrayBuffer&&b instanceof ArrayBuffer}b.exports=c}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],107:[function(a,b,c){arguments[4][61][0].apply(c,arguments)},{dup:61}],108:[function(a,b,c){arguments[4][62][0].apply(c,arguments)},{"./debug":109,dup:62}],109:[function(a,b,c){arguments[4][63][0].apply(c,arguments)},{dup:63,ms:110}],110:[function(a,b,c){arguments[4][64][0].apply(c,arguments)},{dup:64}],111:[function(a,b,c){function d(){e.call(this)}b.exports=d;var e=a("events").EventEmitter,f=a("inherits");f(d,e),d.Readable=a("readable-stream/readable.js"),d.Writable=a("readable-stream/writable.js"),d.Duplex=a("readable-stream/duplex.js"),d.Transform=a("readable-stream/transform.js"),d.PassThrough=a("readable-stream/passthrough.js"),d.Stream=d,d.prototype.pipe=function(a,b){function c(b){a.writable&&!1===a.write(b)&&j.pause&&j.pause()}function d(){j.readable&&j.resume&&j.resume()}function f(){k||(k=!0,a.end())}function g(){k||(k=!0,"function"==typeof a.destroy&&a.destroy())}function h(a){if(i(),0===e.listenerCount(this,"error"))throw a}function i(){j.removeListener("data",c),a.removeListener("drain",d),j.removeListener("end",f),j.removeListener("close",g),j.removeListener("error",h),a.removeListener("error",h),j.removeListener("end",i),j.removeListener("close",i),a.removeListener("close",i)}var j=this;j.on("data",c),a.on("drain",d),a._isStdio||b&&b.end===!1||(j.on("end",f),j.on("close",g));var k=!1;return j.on("error",h),a.on("error",h),j.on("end",i),j.on("close",i),a.on("close",i),a.emit("pipe",j),a}},{events:68,inherits:76,"readable-stream/duplex.js":113,"readable-stream/passthrough.js":122,"readable-stream/readable.js":123,"readable-stream/transform.js":124,"readable-stream/writable.js":125}],112:[function(a,b,c){arguments[4][46][0].apply(c,arguments)},{dup:46}],113:[function(a,b,c){b.exports=a("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":114}],114:[function(a,b,c){"use strict";function d(a){return this instanceof d?(j.call(this,a),k.call(this,a),a&&a.readable===!1&&(this.readable=!1),a&&a.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,a&&a.allowHalfOpen===!1&&(this.allowHalfOpen=!1),void this.once("end",e)):new d(a)}function e(){this.allowHalfOpen||this._writableState.ended||g.nextTick(f,this)}function f(a){a.end()}var g=a("process-nextick-args"),h=Object.keys||function(a){var b=[];for(var c in a)b.push(c);return b};b.exports=d;var i=Object.create(a("core-util-is"));i.inherits=a("inherits");var j=a("./_stream_readable"),k=a("./_stream_writable");i.inherits(d,j);for(var l=h(k.prototype),m=0;m<l.length;m++){var n=l[m];d.prototype[n]||(d.prototype[n]=k.prototype[n])}Object.defineProperty(d.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(d.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(a){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=a,this._writableState.destroyed=a)}}),d.prototype._destroy=function(a,b){this.push(null),this.end(),g.nextTick(b,a)}},{"./_stream_readable":116,"./_stream_writable":118,"core-util-is":50,inherits:76,"process-nextick-args":86}],115:[function(a,b,c){"use strict";function d(a){return this instanceof d?void e.call(this,a):new d(a)}b.exports=d;var e=a("./_stream_transform"),f=Object.create(a("core-util-is"));f.inherits=a("inherits"),f.inherits(d,e),d.prototype._transform=function(a,b,c){c(null,a)}},{"./_stream_transform":117,"core-util-is":50,inherits:76}],116:[function(a,b,c){(function(c,d){"use strict";function e(a){return L.from(a)}function f(a){return L.isBuffer(a)||a instanceof M}function g(a,b,c){return"function"==typeof a.prependListener?a.prependListener(b,c):void(a._events&&a._events[b]?I(a._events[b])?a._events[b].unshift(c):a._events[b]=[c,a._events[b]]:a.on(b,c))}function h(b,c){H=H||a("./_stream_duplex"),b=b||{};var d=c instanceof H;this.objectMode=!!b.objectMode,d&&(this.objectMode=this.objectMode||!!b.readableObjectMode);var e=b.highWaterMark,f=b.readableHighWaterMark,g=this.objectMode?16:16384;e||0===e?this.highWaterMark=e:d&&(f||0===f)?this.highWaterMark=f:this.highWaterMark=g,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new R,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=b.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,b.encoding&&(Q||(Q=a("string_decoder/").StringDecoder),this.decoder=new Q(b.encoding),this.encoding=b.encoding)}function i(b){return H=H||a("./_stream_duplex"),this instanceof i?(this._readableState=new h(b,this),this.readable=!0,b&&("function"==typeof b.read&&(this._read=b.read),"function"==typeof b.destroy&&(this._destroy=b.destroy)),void K.call(this)):new i(b)}function j(a,b,c,d,f){var g=a._readableState;if(null===b)g.reading=!1,p(a,g);else{var h;f||(h=l(g,b)),h?a.emit("error",h):g.objectMode||b&&b.length>0?("string"==typeof b||g.objectMode||Object.getPrototypeOf(b)===L.prototype||(b=e(b)),d?g.endEmitted?a.emit("error",new Error("stream.unshift() after end event")):k(a,g,b,!0):g.ended?a.emit("error",new Error("stream.push() after EOF")):(g.reading=!1,g.decoder&&!c?(b=g.decoder.write(b),g.objectMode||0!==b.length?k(a,g,b,!1):s(a,g)):k(a,g,b,!1))):d||(g.reading=!1)}return m(g)}function k(a,b,c,d){b.flowing&&0===b.length&&!b.sync?(a.emit("data",c),a.read(0)):(b.length+=b.objectMode?1:c.length,d?b.buffer.unshift(c):b.buffer.push(c),b.needReadable&&q(a)),s(a,b)}function l(a,b){var c;return f(b)||"string"==typeof b||void 0===b||a.objectMode||(c=new TypeError("Invalid non-string/buffer chunk")),c}function m(a){return!a.ended&&(a.needReadable||a.length<a.highWaterMark||0===a.length)}function n(a){return a>=U?a=U:(a--,a|=a>>>1,a|=a>>>2,a|=a>>>4,a|=a>>>8,a|=a>>>16,a++),a}function o(a,b){return a<=0||0===b.length&&b.ended?0:b.objectMode?1:a!==a?b.flowing&&b.length?b.buffer.head.data.length:b.length:(a>b.highWaterMark&&(b.highWaterMark=n(a)),a<=b.length?a:b.ended?b.length:(b.needReadable=!0,0))}function p(a,b){if(!b.ended){if(b.decoder){var c=b.decoder.end();c&&c.length&&(b.buffer.push(c),b.length+=b.objectMode?1:c.length)}b.ended=!0,q(a)}}function q(a){var b=a._readableState;b.needReadable=!1,b.emittedReadable||(P("emitReadable",b.flowing),b.emittedReadable=!0,b.sync?G.nextTick(r,a):r(a))}function r(a){P("emit readable"),a.emit("readable"),y(a)}function s(a,b){b.readingMore||(b.readingMore=!0,G.nextTick(t,a,b))}function t(a,b){for(var c=b.length;!b.reading&&!b.flowing&&!b.ended&&b.length<b.highWaterMark&&(P("maybeReadMore read 0"),a.read(0),c!==b.length);)c=b.length;b.readingMore=!1}function u(a){return function(){var b=a._readableState;P("pipeOnDrain",b.awaitDrain),b.awaitDrain&&b.awaitDrain--,0===b.awaitDrain&&J(a,"data")&&(b.flowing=!0,y(a))}}function v(a){P("readable nexttick read 0"),a.read(0)}function w(a,b){b.resumeScheduled||(b.resumeScheduled=!0,G.nextTick(x,a,b))}function x(a,b){b.reading||(P("resume read 0"),a.read(0)),b.resumeScheduled=!1,b.awaitDrain=0,a.emit("resume"),y(a),b.flowing&&!b.reading&&a.read(0)}function y(a){var b=a._readableState;for(P("flow",b.flowing);b.flowing&&null!==a.read(););}function z(a,b){if(0===b.length)return null;var c;return b.objectMode?c=b.buffer.shift():!a||a>=b.length?(c=b.decoder?b.buffer.join(""):1===b.buffer.length?b.buffer.head.data:b.buffer.concat(b.length),b.buffer.clear()):c=A(a,b.buffer,b.decoder),c}function A(a,b,c){var d;return a<b.head.data.length?(d=b.head.data.slice(0,a),b.head.data=b.head.data.slice(a)):d=a===b.head.data.length?b.shift():c?B(a,b):C(a,b),d}function B(a,b){var c=b.head,d=1,e=c.data;for(a-=e.length;c=c.next;){var f=c.data,g=a>f.length?f.length:a;if(e+=g===f.length?f:f.slice(0,a),a-=g,0===a){g===f.length?(++d,c.next?b.head=c.next:b.head=b.tail=null):(b.head=c,c.data=f.slice(g));break}++d}return b.length-=d,e}function C(a,b){var c=L.allocUnsafe(a),d=b.head,e=1;for(d.data.copy(c),a-=d.data.length;d=d.next;){var f=d.data,g=a>f.length?f.length:a;if(f.copy(c,c.length-a,0,g),a-=g,0===a){g===f.length?(++e,d.next?b.head=d.next:b.head=b.tail=null):(b.head=d,d.data=f.slice(g));break}++e}return b.length-=e,c}function D(a){var b=a._readableState;if(b.length>0)throw new Error('"endReadable()" called on non-empty stream');b.endEmitted||(b.ended=!0,G.nextTick(E,b,a))}function E(a,b){a.endEmitted||0!==a.length||(a.endEmitted=!0,b.readable=!1,b.emit("end"))}function F(a,b){for(var c=0,d=a.length;c<d;c++)if(a[c]===b)return c;return-1}var G=a("process-nextick-args");b.exports=i;var H,I=a("isarray");i.ReadableState=h;var J=(a("events").EventEmitter,function(a,b){return a.listeners(b).length}),K=a("./internal/streams/stream"),L=a("safe-buffer").Buffer,M=d.Uint8Array||function(){},N=Object.create(a("core-util-is"));N.inherits=a("inherits");var O=a("util"),P=void 0;P=O&&O.debuglog?O.debuglog("stream"):function(){};var Q,R=a("./internal/streams/BufferList"),S=a("./internal/streams/destroy");N.inherits(i,K);var T=["error","close","destroy","pause","resume"];Object.defineProperty(i.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(a){this._readableState&&(this._readableState.destroyed=a)}}),i.prototype.destroy=S.destroy,i.prototype._undestroy=S.undestroy,i.prototype._destroy=function(a,b){this.push(null),b(a)},i.prototype.push=function(a,b){var c,d=this._readableState;return d.objectMode?c=!0:"string"==typeof a&&(b=b||d.defaultEncoding,b!==d.encoding&&(a=L.from(a,b),b=""),c=!0),j(this,a,b,!1,c)},i.prototype.unshift=function(a){return j(this,a,null,!0,!1)},i.prototype.isPaused=function(){return this._readableState.flowing===!1},i.prototype.setEncoding=function(b){return Q||(Q=a("string_decoder/").StringDecoder),this._readableState.decoder=new Q(b),this._readableState.encoding=b,this};var U=8388608;i.prototype.read=function(a){P("read",a),a=parseInt(a,10);var b=this._readableState,c=a;if(0!==a&&(b.emittedReadable=!1),0===a&&b.needReadable&&(b.length>=b.highWaterMark||b.ended))return P("read: emitReadable",b.length,b.ended),0===b.length&&b.ended?D(this):q(this),null;if(a=o(a,b),0===a&&b.ended)return 0===b.length&&D(this),null;var d=b.needReadable;P("need readable",d),(0===b.length||b.length-a<b.highWaterMark)&&(d=!0,P("length less than watermark",d)),b.ended||b.reading?(d=!1,P("reading or ended",d)):d&&(P("do read"),b.reading=!0,b.sync=!0,0===b.length&&(b.needReadable=!0),this._read(b.highWaterMark),b.sync=!1,b.reading||(a=o(c,b)));var e;return e=a>0?z(a,b):null,null===e?(b.needReadable=!0,a=0):b.length-=a,0===b.length&&(b.ended||(b.needReadable=!0),c!==a&&b.ended&&D(this)),null!==e&&this.emit("data",e),e},i.prototype._read=function(a){this.emit("error",new Error("_read() is not implemented"))},i.prototype.pipe=function(a,b){function d(a,b){P("onunpipe"),a===m&&b&&b.hasUnpiped===!1&&(b.hasUnpiped=!0,f())}function e(){P("onend"),a.end()}function f(){P("cleanup"),a.removeListener("close",j),a.removeListener("finish",k),a.removeListener("drain",q),a.removeListener("error",i),a.removeListener("unpipe",d),m.removeListener("end",e),m.removeListener("end",l),m.removeListener("data",h),r=!0,!n.awaitDrain||a._writableState&&!a._writableState.needDrain||q()}function h(b){P("ondata"),s=!1;var c=a.write(b);!1!==c||s||((1===n.pipesCount&&n.pipes===a||n.pipesCount>1&&F(n.pipes,a)!==-1)&&!r&&(P("false write response, pause",m._readableState.awaitDrain),m._readableState.awaitDrain++,s=!0),m.pause())}function i(b){P("onerror",b),l(),a.removeListener("error",i),0===J(a,"error")&&a.emit("error",b)}function j(){a.removeListener("finish",k),l()}function k(){P("onfinish"),a.removeListener("close",j),l()}function l(){P("unpipe"),m.unpipe(a)}var m=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=a;break;case 1:n.pipes=[n.pipes,a];break;default:n.pipes.push(a)}n.pipesCount+=1,P("pipe count=%d opts=%j",n.pipesCount,b);var o=(!b||b.end!==!1)&&a!==c.stdout&&a!==c.stderr,p=o?e:l;n.endEmitted?G.nextTick(p):m.once("end",p),a.on("unpipe",d);var q=u(m);a.on("drain",q);var r=!1,s=!1;return m.on("data",h),g(a,"error",i),a.once("close",j),a.once("finish",k),a.emit("pipe",m),n.flowing||(P("pipe resume"),m.resume()),a},i.prototype.unpipe=function(a){var b=this._readableState,c={hasUnpiped:!1};if(0===b.pipesCount)return this;if(1===b.pipesCount)return a&&a!==b.pipes?this:(a||(a=b.pipes),b.pipes=null,b.pipesCount=0,b.flowing=!1,a&&a.emit("unpipe",this,c),this);if(!a){var d=b.pipes,e=b.pipesCount;b.pipes=null,b.pipesCount=0,b.flowing=!1;for(var f=0;f<e;f++)d[f].emit("unpipe",this,c);return this}var g=F(b.pipes,a);return g===-1?this:(b.pipes.splice(g,1),b.pipesCount-=1,1===b.pipesCount&&(b.pipes=b.pipes[0]),a.emit("unpipe",this,c),this)},i.prototype.on=function(a,b){var c=K.prototype.on.call(this,a,b);if("data"===a)this._readableState.flowing!==!1&&this.resume();else if("readable"===a){var d=this._readableState;d.endEmitted||d.readableListening||(d.readableListening=d.needReadable=!0,d.emittedReadable=!1,d.reading?d.length&&q(this):G.nextTick(v,this))}return c},i.prototype.addListener=i.prototype.on,i.prototype.resume=function(){var a=this._readableState;return a.flowing||(P("resume"),a.flowing=!0,w(this,a)),this},i.prototype.pause=function(){return P("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(P("pause"),this._readableState.flowing=!1,this.emit("pause")),this},i.prototype.wrap=function(a){var b=this,c=this._readableState,d=!1;a.on("end",function(){if(P("wrapped end"),c.decoder&&!c.ended){var a=c.decoder.end();a&&a.length&&b.push(a)}b.push(null)}),a.on("data",function(e){if(P("wrapped data"),c.decoder&&(e=c.decoder.write(e)),(!c.objectMode||null!==e&&void 0!==e)&&(c.objectMode||e&&e.length)){var f=b.push(e);f||(d=!0,a.pause())}});for(var e in a)void 0===this[e]&&"function"==typeof a[e]&&(this[e]=function(b){return function(){return a[b].apply(a,arguments)}}(e));for(var f=0;f<T.length;f++)a.on(T[f],this.emit.bind(this,T[f]));return this._read=function(b){P("wrapped _read",b),d&&(d=!1,a.resume())},this},Object.defineProperty(i.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),i._fromList=z}).call(this,a("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_stream_duplex":114,"./internal/streams/BufferList":119,"./internal/streams/destroy":120,"./internal/streams/stream":121,_process:87,"core-util-is":50,events:68,inherits:76,isarray:112,"process-nextick-args":86,"safe-buffer":126,"string_decoder/":127,util:43}],117:[function(a,b,c){"use strict";function d(a,b){var c=this._transformState;c.transforming=!1;var d=c.writecb;if(!d)return this.emit("error",new Error("write callback called multiple times"));c.writechunk=null,c.writecb=null,null!=b&&this.push(b),d(a);var e=this._readableState;e.reading=!1,(e.needReadable||e.length<e.highWaterMark)&&this._read(e.highWaterMark)}function e(a){return this instanceof e?(h.call(this,a),this._transformState={afterTransform:d.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,a&&("function"==typeof a.transform&&(this._transform=a.transform),"function"==typeof a.flush&&(this._flush=a.flush)),void this.on("prefinish",f)):new e(a)}function f(){var a=this;"function"==typeof this._flush?this._flush(function(b,c){g(a,b,c)}):g(this,null,null)}function g(a,b,c){if(b)return a.emit("error",b);if(null!=c&&a.push(c),a._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(a._transformState.transforming)throw new Error("Calling transform done when still transforming");return a.push(null)}b.exports=e;var h=a("./_stream_duplex"),i=Object.create(a("core-util-is"));i.inherits=a("inherits"),i.inherits(e,h),e.prototype.push=function(a,b){return this._transformState.needTransform=!1,h.prototype.push.call(this,a,b)},e.prototype._transform=function(a,b,c){throw new Error("_transform() is not implemented")},e.prototype._write=function(a,b,c){var d=this._transformState;if(d.writecb=c,d.writechunk=a,d.writeencoding=b,!d.transforming){var e=this._readableState;(d.needTransform||e.needReadable||e.length<e.highWaterMark)&&this._read(e.highWaterMark)}},e.prototype._read=function(a){var b=this._transformState;null!==b.writechunk&&b.writecb&&!b.transforming?(b.transforming=!0,this._transform(b.writechunk,b.writeencoding,b.afterTransform)):b.needTransform=!0},e.prototype._destroy=function(a,b){var c=this;h.prototype._destroy.call(this,a,function(a){b(a),c.emit("close")})}},{"./_stream_duplex":114,"core-util-is":50,inherits:76}],118:[function(a,b,c){(function(c,d){"use strict";function e(a){var b=this;this.next=null,this.entry=null,this.finish=function(){A(b,a)}}function f(a){return H.from(a)}function g(a){return H.isBuffer(a)||a instanceof I}function h(){}function i(b,c){C=C||a("./_stream_duplex"),b=b||{};var d=c instanceof C;this.objectMode=!!b.objectMode,d&&(this.objectMode=this.objectMode||!!b.writableObjectMode);var f=b.highWaterMark,g=b.writableHighWaterMark,h=this.objectMode?16:16384;f||0===f?this.highWaterMark=f:d&&(g||0===g)?this.highWaterMark=g:this.highWaterMark=h,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var i=b.decodeStrings===!1;this.decodeStrings=!i,this.defaultEncoding=b.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(a){r(c,a)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new e(this)}function j(b){return C=C||a("./_stream_duplex"),K.call(j,this)||this instanceof C?(this._writableState=new i(b,this),this.writable=!0,b&&("function"==typeof b.write&&(this._write=b.write),"function"==typeof b.writev&&(this._writev=b.writev),"function"==typeof b.destroy&&(this._destroy=b.destroy),"function"==typeof b["final"]&&(this._final=b["final"])),void G.call(this)):new j(b)}function k(a,b){var c=new Error("write after end");a.emit("error",c),B.nextTick(b,c)}function l(a,b,c,d){var e=!0,f=!1;return null===c?f=new TypeError("May not write null values to stream"):"string"==typeof c||void 0===c||b.objectMode||(f=new TypeError("Invalid non-string/buffer chunk")),f&&(a.emit("error",f),B.nextTick(d,f),e=!1),e}function m(a,b,c){return a.objectMode||a.decodeStrings===!1||"string"!=typeof b||(b=H.from(b,c)),b}function n(a,b,c,d,e,f){if(!c){var g=m(b,d,e);d!==g&&(c=!0,e="buffer",d=g)}var h=b.objectMode?1:d.length;b.length+=h;var i=b.length<b.highWaterMark;if(i||(b.needDrain=!0),b.writing||b.corked){var j=b.lastBufferedRequest;b.lastBufferedRequest={chunk:d,encoding:e,isBuf:c,callback:f,next:null},j?j.next=b.lastBufferedRequest:b.bufferedRequest=b.lastBufferedRequest,b.bufferedRequestCount+=1}else o(a,b,!1,h,d,e,f);return i}function o(a,b,c,d,e,f,g){b.writelen=d,b.writecb=g,b.writing=!0,b.sync=!0,c?a._writev(e,b.onwrite):a._write(e,f,b.onwrite),b.sync=!1}function p(a,b,c,d,e){--b.pendingcb,c?(B.nextTick(e,d),B.nextTick(y,a,b),a._writableState.errorEmitted=!0,a.emit("error",d)):(e(d),a._writableState.errorEmitted=!0,a.emit("error",d),y(a,b))}function q(a){a.writing=!1,a.writecb=null,a.length-=a.writelen,a.writelen=0}function r(a,b){var c=a._writableState,d=c.sync,e=c.writecb;if(q(c),b)p(a,c,d,b,e);else{var f=v(c);f||c.corked||c.bufferProcessing||!c.bufferedRequest||u(a,c),d?D(s,a,c,f,e):s(a,c,f,e)}}function s(a,b,c,d){c||t(a,b),b.pendingcb--,d(),y(a,b)}function t(a,b){0===b.length&&b.needDrain&&(b.needDrain=!1,a.emit("drain"))}function u(a,b){b.bufferProcessing=!0;var c=b.bufferedRequest;if(a._writev&&c&&c.next){var d=b.bufferedRequestCount,f=new Array(d),g=b.corkedRequestsFree;g.entry=c;for(var h=0,i=!0;c;)f[h]=c,c.isBuf||(i=!1),c=c.next,h+=1;f.allBuffers=i,o(a,b,!0,b.length,f,"",g.finish),b.pendingcb++,b.lastBufferedRequest=null,g.next?(b.corkedRequestsFree=g.next,g.next=null):b.corkedRequestsFree=new e(b),b.bufferedRequestCount=0}else{for(;c;){var j=c.chunk,k=c.encoding,l=c.callback,m=b.objectMode?1:j.length;if(o(a,b,!1,m,j,k,l),c=c.next,b.bufferedRequestCount--,b.writing)break}null===c&&(b.lastBufferedRequest=null)}b.bufferedRequest=c,b.bufferProcessing=!1}function v(a){return a.ending&&0===a.length&&null===a.bufferedRequest&&!a.finished&&!a.writing}function w(a,b){a._final(function(c){b.pendingcb--,c&&a.emit("error",c),b.prefinished=!0,a.emit("prefinish"),y(a,b)})}function x(a,b){b.prefinished||b.finalCalled||("function"==typeof a._final?(b.pendingcb++,b.finalCalled=!0,B.nextTick(w,a,b)):(b.prefinished=!0,a.emit("prefinish")))}function y(a,b){var c=v(b);return c&&(x(a,b),0===b.pendingcb&&(b.finished=!0,a.emit("finish"))),c}function z(a,b,c){b.ending=!0,y(a,b),c&&(b.finished?B.nextTick(c):a.once("finish",c)),b.ended=!0,a.writable=!1}function A(a,b,c){var d=a.entry;for(a.entry=null;d;){var e=d.callback;b.pendingcb--,e(c),d=d.next}b.corkedRequestsFree?b.corkedRequestsFree.next=a:b.corkedRequestsFree=a}var B=a("process-nextick-args");b.exports=j;var C,D=!c.browser&&["v0.10","v0.9."].indexOf(c.version.slice(0,5))>-1?setImmediate:B.nextTick;j.WritableState=i;var E=Object.create(a("core-util-is"));E.inherits=a("inherits");var F={deprecate:a("util-deprecate")},G=a("./internal/streams/stream"),H=a("safe-buffer").Buffer,I=d.Uint8Array||function(){},J=a("./internal/streams/destroy");E.inherits(j,G),i.prototype.getBuffer=function(){for(var a=this.bufferedRequest,b=[];a;)b.push(a),a=a.next;return b},function(){try{Object.defineProperty(i.prototype,"buffer",{get:F.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(a){}}();var K;"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(K=Function.prototype[Symbol.hasInstance],Object.defineProperty(j,Symbol.hasInstance,{value:function(a){return!!K.call(this,a)||this===j&&(a&&a._writableState instanceof i)}})):K=function(a){return a instanceof this},j.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},j.prototype.write=function(a,b,c){var d=this._writableState,e=!1,i=!d.objectMode&&g(a);return i&&!H.isBuffer(a)&&(a=f(a)),"function"==typeof b&&(c=b,b=null),i?b="buffer":b||(b=d.defaultEncoding),"function"!=typeof c&&(c=h),d.ended?k(this,c):(i||l(this,d,a,c))&&(d.pendingcb++,e=n(this,d,i,a,b,c)),e},j.prototype.cork=function(){var a=this._writableState;a.corked++},j.prototype.uncork=function(){var a=this._writableState;a.corked&&(a.corked--,a.writing||a.corked||a.finished||a.bufferProcessing||!a.bufferedRequest||u(this,a))},j.prototype.setDefaultEncoding=function(a){if("string"==typeof a&&(a=a.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((a+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+a);return this._writableState.defaultEncoding=a,this},Object.defineProperty(j.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),j.prototype._write=function(a,b,c){c(new Error("_write() is not implemented"))},j.prototype._writev=null,j.prototype.end=function(a,b,c){var d=this._writableState;"function"==typeof a?(c=a,a=null,b=null):"function"==typeof b&&(c=b,b=null),null!==a&&void 0!==a&&this.write(a,b),d.corked&&(d.corked=1,this.uncork()),d.ending||d.finished||z(this,d,c)},Object.defineProperty(j.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(a){this._writableState&&(this._writableState.destroyed=a)}}),j.prototype.destroy=J.destroy,j.prototype._undestroy=J.undestroy,j.prototype._destroy=function(a,b){this.end(),b(a)}}).call(this,a("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_stream_duplex":114,"./internal/streams/destroy":120,"./internal/streams/stream":121,_process:87,"core-util-is":50,inherits:76,"process-nextick-args":86,"safe-buffer":126,"util-deprecate":140}],119:[function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function e(a,b,c){a.copy(b,c)}var f=a("safe-buffer").Buffer,g=a("util");b.exports=function(){function a(){d(this,a),this.head=null,this.tail=null,this.length=0}return a.prototype.push=function(a){var b={data:a,next:null};this.length>0?this.tail.next=b:this.head=b,this.tail=b,++this.length},a.prototype.unshift=function(a){var b={data:a,next:this.head};0===this.length&&(this.tail=b),this.head=b,++this.length},a.prototype.shift=function(){if(0!==this.length){var a=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,a}},a.prototype.clear=function(){this.head=this.tail=null,this.length=0},a.prototype.join=function(a){if(0===this.length)return"";for(var b=this.head,c=""+b.data;b=b.next;)c+=a+b.data;return c},a.prototype.concat=function(a){if(0===this.length)return f.alloc(0);if(1===this.length)return this.head.data;for(var b=f.allocUnsafe(a>>>0),c=this.head,d=0;c;)e(c.data,b,d),d+=c.data.length,c=c.next;return b},a}(),g&&g.inspect&&g.inspect.custom&&(b.exports.prototype[g.inspect.custom]=function(){var a=g.inspect({length:this.length});return this.constructor.name+" "+a})},{"safe-buffer":126,util:43}],120:[function(a,b,c){"use strict";function d(a,b){var c=this,d=this._readableState&&this._readableState.destroyed,e=this._writableState&&this._writableState.destroyed;return d||e?(b?b(a):!a||this._writableState&&this._writableState.errorEmitted||g.nextTick(f,this,a),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(a||null,function(a){!b&&a?(g.nextTick(f,c,a),c._writableState&&(c._writableState.errorEmitted=!0)):b&&b(a)}),this)}function e(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function f(a,b){a.emit("error",b)}var g=a("process-nextick-args");b.exports={destroy:d,undestroy:e}},{"process-nextick-args":86}],121:[function(a,b,c){b.exports=a("events").EventEmitter},{events:68}],122:[function(a,b,c){b.exports=a("./readable").PassThrough},{"./readable":123}],123:[function(a,b,c){c=b.exports=a("./lib/_stream_readable.js"),c.Stream=c,c.Readable=c,c.Writable=a("./lib/_stream_writable.js"),c.Duplex=a("./lib/_stream_duplex.js"),c.Transform=a("./lib/_stream_transform.js"),c.PassThrough=a("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":114,"./lib/_stream_passthrough.js":115,"./lib/_stream_readable.js":116,"./lib/_stream_transform.js":117,"./lib/_stream_writable.js":118}],124:[function(a,b,c){b.exports=a("./readable").Transform},{"./readable":123}],125:[function(a,b,c){b.exports=a("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":118}],126:[function(a,b,c){function d(a,b){for(var c in a)b[c]=a[c]}function e(a,b,c){return g(a,b,c)}var f=a("buffer"),g=f.Buffer;g.from&&g.alloc&&g.allocUnsafe&&g.allocUnsafeSlow?b.exports=f:(d(f,c),c.Buffer=e),d(g,e),e.from=function(a,b,c){if("number"==typeof a)throw new TypeError("Argument must not be a number");return g(a,b,c)},e.alloc=function(a,b,c){if("number"!=typeof a)throw new TypeError("Argument must be a number");var d=g(a);return void 0!==b?"string"==typeof c?d.fill(b,c):d.fill(b):d.fill(0),d},e.allocUnsafe=function(a){if("number"!=typeof a)throw new TypeError("Argument must be a number");return g(a)},e.allocUnsafeSlow=function(a){if("number"!=typeof a)throw new TypeError("Argument must be a number");return f.SlowBuffer(a)}},{buffer:45}],127:[function(a,b,c){"use strict";function d(a){if(!a)return"utf8";for(var b;;)switch(a){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return a;default:if(b)return;a=(""+a).toLowerCase(),b=!0}}function e(a){var b=d(a);if("string"!=typeof b&&(s.isEncoding===t||!t(a)))throw new Error("Unknown encoding: "+a);return b||a}function f(a){this.encoding=e(a);var b;switch(this.encoding){case"utf16le":this.text=m,this.end=n,b=4;break;case"utf8":this.fillLast=j,b=4;break;case"base64":this.text=o,this.end=p,b=3;break;default:return this.write=q,void(this.end=r)}this.lastNeed=0,this.lastTotal=0,this.lastChar=s.allocUnsafe(b)}function g(a){return a<=127?0:a>>5===6?2:a>>4===14?3:a>>3===30?4:a>>6===2?-1:-2}function h(a,b,c){var d=b.length-1;if(d<c)return 0;var e=g(b[d]);return e>=0?(e>0&&(a.lastNeed=e-1),e):--d<c||e===-2?0:(e=g(b[d]),e>=0?(e>0&&(a.lastNeed=e-2),e):--d<c||e===-2?0:(e=g(b[d]),e>=0?(e>0&&(2===e?e=0:a.lastNeed=e-3),e):0))}function i(a,b,c){if(128!==(192&b[0]))return a.lastNeed=0,"�";if(a.lastNeed>1&&b.length>1){if(128!==(192&b[1]))return a.lastNeed=1,"�";if(a.lastNeed>2&&b.length>2&&128!==(192&b[2]))return a.lastNeed=2,"�"}}function j(a){var b=this.lastTotal-this.lastNeed,c=i(this,a,b);return void 0!==c?c:this.lastNeed<=a.length?(a.copy(this.lastChar,b,0,this.lastNeed),
17
+ this.lastChar.toString(this.encoding,0,this.lastTotal)):(a.copy(this.lastChar,b,0,a.length),void(this.lastNeed-=a.length))}function k(a,b){var c=h(this,a,b);if(!this.lastNeed)return a.toString("utf8",b);this.lastTotal=c;var d=a.length-(c-this.lastNeed);return a.copy(this.lastChar,0,d),a.toString("utf8",b,d)}function l(a){var b=a&&a.length?this.write(a):"";return this.lastNeed?b+"�":b}function m(a,b){if((a.length-b)%2===0){var c=a.toString("utf16le",b);if(c){var d=c.charCodeAt(c.length-1);if(d>=55296&&d<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=a[a.length-2],this.lastChar[1]=a[a.length-1],c.slice(0,-1)}return c}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=a[a.length-1],a.toString("utf16le",b,a.length-1)}function n(a){var b=a&&a.length?this.write(a):"";if(this.lastNeed){var c=this.lastTotal-this.lastNeed;return b+this.lastChar.toString("utf16le",0,c)}return b}function o(a,b){var c=(a.length-b)%3;return 0===c?a.toString("base64",b):(this.lastNeed=3-c,this.lastTotal=3,1===c?this.lastChar[0]=a[a.length-1]:(this.lastChar[0]=a[a.length-2],this.lastChar[1]=a[a.length-1]),a.toString("base64",b,a.length-c))}function p(a){var b=a&&a.length?this.write(a):"";return this.lastNeed?b+this.lastChar.toString("base64",0,3-this.lastNeed):b}function q(a){return a.toString(this.encoding)}function r(a){return a&&a.length?this.write(a):""}var s=a("safe-buffer").Buffer,t=s.isEncoding||function(a){switch(a=""+a,a&&a.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};c.StringDecoder=f,f.prototype.write=function(a){if(0===a.length)return"";var b,c;if(this.lastNeed){if(b=this.fillLast(a),void 0===b)return"";c=this.lastNeed,this.lastNeed=0}else c=0;return c<a.length?b?b+this.text(a,c):this.text(a,c):b||""},f.prototype.end=l,f.prototype.text=k,f.prototype.fillLast=function(a){return this.lastNeed<=a.length?(a.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(a.copy(this.lastChar,this.lastTotal-this.lastNeed,0,a.length),void(this.lastNeed-=a.length))}},{"safe-buffer":126}],128:[function(a,b,c){var d=a("./lib/request"),e=a("xtend"),f=a("builtin-status-codes"),g=a("url"),h=c;h.request=function(a,b){a="string"==typeof a?g.parse(a):e(a);var c=a.protocol||"",f=a.hostname||a.host,h=a.port,i=a.path||"/";f&&f.indexOf(":")!==-1&&(f="["+f+"]"),a.url=(f?c+"//"+f:"")+(h?":"+h:"")+i,a.method=(a.method||"GET").toUpperCase(),a.headers=a.headers||{};var j=new d(a);return b&&j.on("response",b),j},h.get=function(a,b){var c=h.request(a,b);return c.end(),c},h.Agent=function(){},h.Agent.defaultMaxSockets=4,h.STATUS_CODES=f,h.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]},{"./lib/request":130,"builtin-status-codes":47,url:138,xtend:143}],129:[function(a,b,c){(function(a){function b(a){try{return f.responseType=a,f.responseType===a}catch(b){}return!1}function d(a){return"function"==typeof a}c.fetch=d(a.fetch)&&d(a.ReadableByteStream),c.blobConstructor=!1;try{new Blob([new ArrayBuffer(1)]),c.blobConstructor=!0}catch(e){}var f=new a.XMLHttpRequest;f.open("GET",a.location.host?"/":"https://example.com");var g="undefined"!=typeof a.ArrayBuffer,h=g&&d(a.ArrayBuffer.prototype.slice);c.arraybuffer=g&&b("arraybuffer"),c.msstream=!c.fetch&&h&&b("ms-stream"),c.mozchunkedarraybuffer=!c.fetch&&g&&b("moz-chunked-arraybuffer"),c.overrideMimeType=d(f.overrideMimeType),c.vbArray=d(a.VBArray),f=null}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],130:[function(a,b,c){(function(c,d,e){function f(a){return h.fetch?"fetch":h.mozchunkedarraybuffer?"moz-chunked-arraybuffer":h.msstream?"ms-stream":h.arraybuffer&&a?"arraybuffer":h.vbArray&&a?"text:vbarray":"text"}function g(a){try{return null!==a.status}catch(b){return!1}}var h=a("./capability"),i=a("foreach"),j=a("indexof"),k=a("inherits"),l=a("object-keys"),m=a("./response"),n=a("stream"),o=m.IncomingMessage,p=m.readyStates,q=b.exports=function(a){var b=this;n.Writable.call(b),b._opts=a,b._body=[],b._headers={},a.auth&&b.setHeader("Authorization","Basic "+new e(a.auth).toString("base64")),i(l(a.headers),function(c){b.setHeader(c,a.headers[c])});var c;if("prefer-streaming"===a.mode)c=!1;else if("allow-wrong-content-type"===a.mode)c=!h.overrideMimeType;else{if(a.mode&&"default"!==a.mode&&"prefer-fast"!==a.mode)throw new Error("Invalid value for opts.mode");c=!0}b._mode=f(c),b.on("finish",function(){b._onFinish()})};k(q,n.Writable),q.prototype.setHeader=function(a,b){var c=this,d=a.toLowerCase();j(r,d)===-1&&(c._headers[d]={name:a,value:b})},q.prototype.getHeader=function(a){var b=this;return b._headers[a.toLowerCase()].value},q.prototype.removeHeader=function(a){var b=this;delete b._headers[a.toLowerCase()]},q.prototype._onFinish=function(){var a=this;if(!a._destroyed){var b,f=a._opts,g=a._headers;if("POST"!==f.method&&"PUT"!==f.method||(b=h.blobConstructor?new d.Blob(a._body.map(function(a){return a.toArrayBuffer()}),{type:(g["content-type"]||{}).value||""}):e.concat(a._body).toString()),"fetch"===a._mode){var j=l(g).map(function(a){return[g[a].name,g[a].value]});d.fetch(a._opts.url,{method:a._opts.method,headers:j,body:b,mode:"cors",credentials:f.withCredentials?"include":"same-origin"}).then(function(b){a._fetchResponse=b,a._connect()}).then(void 0,function(b){a.emit("error",b)})}else{var k=a._xhr=new d.XMLHttpRequest;try{k.open(a._opts.method,a._opts.url,!0)}catch(m){return void c.nextTick(function(){a.emit("error",m)})}"responseType"in k&&(k.responseType=a._mode.split(":")[0]),"withCredentials"in k&&(k.withCredentials=!!f.withCredentials),"text"===a._mode&&"overrideMimeType"in k&&k.overrideMimeType("text/plain; charset=x-user-defined"),i(l(g),function(a){k.setRequestHeader(g[a].name,g[a].value)}),a._response=null,k.onreadystatechange=function(){switch(k.readyState){case p.LOADING:case p.DONE:a._onXHRProgress()}},"moz-chunked-arraybuffer"===a._mode&&(k.onprogress=function(){a._onXHRProgress()}),k.onerror=function(){a._destroyed||a.emit("error",new Error("XHR error"))};try{k.send(b)}catch(m){return void c.nextTick(function(){a.emit("error",m)})}}}},q.prototype._onXHRProgress=function(){var a=this;g(a._xhr)&&!a._destroyed&&(a._response||a._connect(),a._response._onXHRProgress())},q.prototype._connect=function(){var a=this;a._destroyed||(a._response=new o(a._xhr,a._fetchResponse,a._mode),a.emit("response",a._response))},q.prototype._write=function(a,b,c){var d=this;d._body.push(a),c()},q.prototype.abort=q.prototype.destroy=function(){var a=this;a._destroyed=!0,a._response&&(a._response._destroyed=!0),a._xhr&&a._xhr.abort()},q.prototype.end=function(a,b,c){var d=this;"function"==typeof a&&(c=a,a=void 0),n.Writable.prototype.end.call(d,a,b,c)},q.prototype.flushHeaders=function(){},q.prototype.setTimeout=function(){},q.prototype.setNoDelay=function(){},q.prototype.setSocketKeepAlive=function(){};var r=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"]}).call(this,a("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer)},{"./capability":129,"./response":131,_process:87,buffer:45,foreach:70,indexof:75,inherits:76,"object-keys":80,stream:111}],131:[function(a,b,c){(function(b,d,e){var f=a("./capability"),g=a("foreach"),h=a("inherits"),i=a("stream"),j=c.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},k=c.IncomingMessage=function(a,c,d){function h(){n.read().then(function(a){if(!j._destroyed){if(a.done)return void j.push(null);j.push(new e(a.value)),h()}})}var j=this;if(i.Readable.call(j),j._mode=d,j.headers={},j.rawHeaders=[],j.trailers={},j.rawTrailers=[],j.on("end",function(){b.nextTick(function(){j.emit("close")})}),"fetch"===d){j._fetchResponse=c,j.statusCode=c.status,j.statusMessage=c.statusText;for(var k,l,m=c.headers[Symbol.iterator]();k=(l=m.next()).value,!l.done;)j.headers[k[0].toLowerCase()]=k[1],j.rawHeaders.push(k[0],k[1]);var n=c.body.getReader();h()}else{j._xhr=a,j._pos=0,j.statusCode=a.status,j.statusMessage=a.statusText;var o=a.getAllResponseHeaders().split(/\r?\n/);if(g(o,function(a){var b=a.match(/^([^:]+):\s*(.*)/);if(b){var c=b[1].toLowerCase();void 0!==j.headers[c]?j.headers[c]+=", "+b[2]:j.headers[c]=b[2],j.rawHeaders.push(b[1],b[2])}}),j._charset="x-user-defined",!f.overrideMimeType){var p=j.rawHeaders["mime-type"];if(p){var q=p.match(/;\s*charset=([^;])(;|$)/);q&&(j._charset=q[1].toLowerCase())}j._charset||(j._charset="utf-8")}}};h(k,i.Readable),k.prototype._read=function(){},k.prototype._onXHRProgress=function(){var a=this,b=a._xhr,c=null;switch(a._mode){case"text:vbarray":if(b.readyState!==j.DONE)break;try{c=new d.VBArray(b.responseBody).toArray()}catch(f){}if(null!==c){a.push(new e(c));break}case"text":try{c=b.responseText}catch(f){a._mode="text:vbarray";break}if(c.length>a._pos){var g=c.substr(a._pos);if("x-user-defined"===a._charset){for(var h=new e(g.length),i=0;i<g.length;i++)h[i]=255&g.charCodeAt(i);a.push(h)}else a.push(g,a._charset);a._pos=c.length}break;case"arraybuffer":if(b.readyState!==j.DONE)break;c=b.response,a.push(new e(new Uint8Array(c)));break;case"moz-chunked-arraybuffer":if(c=b.response,b.readyState!==j.LOADING||!c)break;a.push(new e(new Uint8Array(c)));break;case"ms-stream":if(c=b.response,b.readyState!==j.LOADING)break;var k=new d.MSStreamReader;k.onprogress=function(){k.result.byteLength>a._pos&&(a.push(new e(new Uint8Array(k.result.slice(a._pos)))),a._pos=k.result.byteLength)},k.onload=function(){a.push(null)},k.readAsArrayBuffer(c)}a._xhr.readyState===j.DONE&&"ms-stream"!==a._mode&&a.push(null)}}).call(this,a("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a("buffer").Buffer)},{"./capability":129,_process:87,buffer:45,foreach:70,inherits:76,stream:111}],132:[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},{}],133:[function(a,b,c){function d(){}function e(a){var b={}.toString.call(a);switch(b){case"[object File]":case"[object Blob]":case"[object FormData]":return!0;default:return!1}}function f(a){return a===Object(a)}function g(a){if(!f(a))return a;var b=[];for(var c in a)null!=a[c]&&h(b,c,a[c]);return b.join("&")}function h(a,b,c){return Array.isArray(c)?c.forEach(function(c){h(a,b,c)}):void a.push(encodeURIComponent(b)+"="+encodeURIComponent(c))}function i(a){for(var b,c,d={},e=a.split("&"),f=0,g=e.length;f<g;++f)c=e[f],b=c.split("="),d[decodeURIComponent(b[0])]=decodeURIComponent(b[1]);return d}function j(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 k(a){return/[\/+]json\b/.test(a)}function l(a){return a.split(/ *; */).shift()}function m(a){return t(a.split(/ *; */),function(a,b){var c=b.split(/ *= */),d=c.shift(),e=c.shift();return d&&e&&(a[d]=e),a},{})}function n(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=j(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 o(a,b){var c=this;s.call(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 n(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,c.callback(a)}if(c.emit("response",b),a)return c.callback(a,b);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)})}function p(a,b){return"function"==typeof b?new o("GET",a).end(b):1==arguments.length?new o("GET",a):new o(a,b)}function q(a,b){var c=p("DELETE",a);return b&&c.end(b),c}var r,s=a("emitter"),t=a("reduce");r="undefined"!=typeof window?window:"undefined"!=typeof self?self:this,p.getXHR=function(){if(!(!r.XMLHttpRequest||r.location&&"file:"==r.location.protocol&&r.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,"")};p.serializeObject=g,p.parseString=i,p.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"},p.serialize={"application/x-www-form-urlencoded":g,"application/json":JSON.stringify},p.parse={"application/x-www-form-urlencoded":i,"application/json":JSON.parse},n.prototype.get=function(a){return this.header[a.toLowerCase()]},n.prototype.setHeaderProperties=function(a){var b=this.header["content-type"]||"";this.type=l(b);var c=m(b);for(var d in c)this[d]=c[d]},n.prototype.parseBody=function(a){var b=p.parse[this.type];return b&&a&&(a.length||a instanceof Object)?b(a):null},n.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},n.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},p.Response=n,s(o.prototype),o.prototype.use=function(a){return a(this),this},o.prototype.timeout=function(a){return this._timeout=a,this},o.prototype.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},o.prototype.abort=function(){if(!this.aborted)return this.aborted=!0,this.xhr.abort(),this.clearTimeout(),this.emit("abort"),this},o.prototype.set=function(a,b){if(f(a)){for(var c in a)this.set(c,a[c]);return this}return this._header[a.toLowerCase()]=b,this.header[a]=b,this},o.prototype.unset=function(a){return delete this._header[a.toLowerCase()],delete this.header[a],this},o.prototype.getHeader=function(a){return this._header[a.toLowerCase()]},o.prototype.type=function(a){return this.set("Content-Type",p.types[a]||a),this},o.prototype.parse=function(a){return this._parser=a,this},o.prototype.accept=function(a){return this.set("Accept",p.types[a]||a),this},o.prototype.auth=function(a,b){var c=btoa(a+":"+b);return this.set("Authorization","Basic "+c),this},o.prototype.query=function(a){return"string"!=typeof a&&(a=g(a)),a&&this._query.push(a),this},o.prototype.field=function(a,b){return this._formData||(this._formData=new r.FormData),this._formData.append(a,b),this},o.prototype.attach=function(a,b,c){return this._formData||(this._formData=new r.FormData),this._formData.append(a,b,c||b.name),this},o.prototype.send=function(a){var b=f(a),c=this.getHeader("Content-Type");if(b&&f(this._data))for(var d in a)this._data[d]=a[d];else"string"==typeof a?(c||this.type("form"),c=this.getHeader("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||e(a)?this:(c||this.type("json"),this)},o.prototype.callback=function(a,b){var c=this._callback;this.clearTimeout(),c(a,b)},o.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)},o.prototype.timeoutError=function(){var a=this._timeout,b=new Error("timeout of "+a+"ms exceeded");b.timeout=a,this.callback(b)},o.prototype.withCredentials=function(){return this._withCredentials=!0,this},o.prototype.end=function(a){var b=this,c=this.xhr=p.getXHR(),f=this._query.join("&"),g=this._timeout,h=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 i=function(a){a.total>0&&(a.percent=a.loaded/a.total*100),a.direction="download",b.emit("progress",a)};this.hasListeners("progress")&&(c.onprogress=i);try{c.upload&&this.hasListeners("progress")&&(c.upload.onprogress=i)}catch(j){}if(g&&!this._timer&&(this._timer=setTimeout(function(){b.timedout=!0,b.abort()},g)),f&&(f=p.serializeObject(f),this.url+=~this.url.indexOf("?")?"&"+f:"?"+f),c.open(this.method,this.url,!0),this._withCredentials&&(c.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof h&&!e(h)){var l=this.getHeader("Content-Type"),m=this._parser||p.serialize[l?l.split(";")[0]:""];!m&&k(l)&&(m=p.serialize["application/json"]),m&&(h=m(h))}for(var n in this.header)null!=this.header[n]&&c.setRequestHeader(n,this.header[n]);return this.emit("request",this),c.send("undefined"!=typeof h?h:null),this},o.prototype.then=function(a,b){return this.end(function(c,d){c?b(c):a(d)})},p.Request=o,p.get=function(a,b,c){var d=p("GET",a);return"function"==typeof b&&(c=b,b=null),b&&d.query(b),c&&d.end(c),d},p.head=function(a,b,c){var d=p("HEAD",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},p.del=q,p["delete"]=q,p.patch=function(a,b,c){var d=p("PATCH",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},p.post=function(a,b,c){var d=p("POST",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},p.put=function(a,b,c){var d=p("PUT",a);return"function"==typeof b&&(c=b,b=null),b&&d.send(b),c&&d.end(c),d},b.exports=p},{emitter:134,reduce:94}],134:[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 this},d.prototype.emit=function(a){this._callbacks=this._callbacks||{};var b=[].slice.call(arguments,1),c=this._callbacks["$"+a];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}},{}],135:[function(a,b,c){(function(c){"0.50.0";var d=d||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,c){a=this.words=a||[],this.sigBytes=c!=b?c: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-8*(e%4)&255)<<24-8*((d+e)%4);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-8*(c%4),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-8*(d%4)&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-4*(d%8);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-8*(d%4)&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-8*(d%4);return new g.init(c,b)}},k=h.Utf8={stringify:function(a){try{return decodeURIComponent(escape(j.stringify(a)))}catch(b){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),h=b?a.ceil(h):a.max((0|h)-this._minBufferSize,0);if(b=h*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(){var a=d,b=a.lib,c=b.WordArray,e=b.Hasher,f=[],b=a.algo.SHA1=e.extend({_doReset:function(){this._hash=new c.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],g=c[2],h=c[3],i=c[4],j=0;80>j;j++){if(16>j)f[j]=0|a[b+j];else{var k=f[j-3]^f[j-8]^f[j-14]^f[j-16];f[j]=k<<1|k>>>31}k=(d<<5|d>>>27)+i+f[j],k=20>j?k+((e&g|~e&h)+1518500249):40>j?k+((e^g^h)+1859775393):60>j?k+((e&g|e&h|g&h)-1894007588):k+((e^g^h)-899497514),i=h,h=g,g=e<<30|e>>>2,e=d,d=k}c[0]=c[0]+d|0,c[1]=c[1]+e|0,c[2]=c[2]+g|0,c[3]=c[3]+h|0,c[4]=c[4]+i|0},_doFinalize:function(){var a=this._data,b=a.words,c=8*this._nDataBytes,d=8*a.sigBytes;return b[d>>>5]|=128<<24-d%32,b[(d+64>>>9<<4)+14]=Math.floor(c/4294967296),b[(d+64>>>9<<4)+15]=c,a.sigBytes=4*b.length,this._process(),this._hash},clone:function(){var a=e.clone.call(this);return a._hash=this._hash.clone(),a}});a.SHA1=e._createHelper(b),a.HmacSHA1=e._createHmacHelper(b)}();var d=d||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,c){a=this.words=a||[],this.sigBytes=c!=b?c: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-8*(e%4)&255)<<24-8*((d+e)%4);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-8*(c%4),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-8*(d%4)&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-4*(d%8);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-8*(d%4)&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-8*(d%4);return new g.init(c,b)}},k=h.Utf8={stringify:function(a){try{return decodeURIComponent(escape(j.stringify(a)))}catch(b){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),h=b?a.ceil(h):a.max((0|h)-this._minBufferSize,0);if(b=h*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=d,c=b.lib,e=c.WordArray,f=c.Hasher,c=b.algo,g=[],h=[],i=function(a){return 4294967296*(a-(0|a))|0},j=2,k=0;64>k;){var l;a:{l=j;for(var m=a.sqrt(l),n=2;n<=m;n++)if(!(l%n)){l=!1;break a}l=!0}l&&(8>k&&(g[k]=i(a.pow(j,.5))),h[k]=i(a.pow(j,1/3)),k++),j++}var o=[],c=c.SHA256=f.extend({_doReset:function(){this._hash=new e.init(g.slice(0))},_doProcessBlock:function(a,b){for(var c=this._hash.words,d=c[0],e=c[1],f=c[2],g=c[3],i=c[4],j=c[5],k=c[6],l=c[7],m=0;64>m;m++){if(16>m)o[m]=0|a[b+m];else{var n=o[m-15],p=o[m-2];o[m]=((n<<25|n>>>7)^(n<<14|n>>>18)^n>>>3)+o[m-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+o[m-16]}n=l+((i<<26|i>>>6)^(i<<21|i>>>11)^(i<<7|i>>>25))+(i&j^~i&k)+h[m]+o[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=g+n|0,g=f,f=e,e=d,d=n+p|0}c[0]=c[0]+d|0,c[1]=c[1]+e|0,c[2]=c[2]+f|0,c[3]=c[3]+g|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[(e+64>>>9<<4)+14]=a.floor(d/4294967296),c[(e+64>>>9<<4)+15]=d,b.sigBytes=4*c.length,this._process(),this._hash},clone:function(){var a=f.clone.call(this);return a._hash=this._hash.clone(),a}});b.SHA256=f._createHelper(c),b.HmacSHA256=f._createHmacHelper(c)}(Math),function(){var a=d,b=a.lib,c=b.WordArray,e=a.enc;e.Base64={stringify:function(a){var b=a.words,c=a.sigBytes,d=this._map;a.clamp();for(var e=[],f=0;f<c;f+=3)for(var g=b[f>>>2]>>>24-f%4*8&255,h=b[f+1>>>2]>>>24-(f+1)%4*8&255,i=b[f+2>>>2]>>>24-(f+2)%4*8&255,j=g<<16|h<<8|i,k=0;k<4&&f+.75*k<c;k++)e.push(d.charAt(j>>>6*(3-k)&63));var l=d.charAt(64);if(l)for(;e.length%4;)e.push(l);return e.join("")},parse:function(a){var b=a.length,d=this._map,e=d.charAt(64);if(e){var f=a.indexOf(e);f!=-1&&(b=f)}for(var g=[],h=0,i=0;i<b;i++)if(i%4){var j=d.indexOf(a.charAt(i-1))<<i%4*2,k=d.indexOf(a.charAt(i))>>>6-i%4*2;g[h>>>2]|=(j|k)<<24-h%4*8,h++}return c.create(g,h)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(){if("function"==typeof ArrayBuffer){var a=d,b=a.lib,c=b.WordArray,e=c.init,f=c.init=function(a){if(a instanceof ArrayBuffer&&(a=new Uint8Array(a)),(a instanceof Int8Array||a instanceof Uint8ClampedArray||a instanceof Int16Array||a instanceof Uint16Array||a instanceof Int32Array||a instanceof Uint32Array||a instanceof Float32Array||a instanceof Float64Array)&&(a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength)),a instanceof Uint8Array){for(var b=a.byteLength,c=[],d=0;d<b;d++)c[d>>>2]|=a[d]<<24-d%4*8;e.call(this,c,b)}else e.apply(this,arguments)};f.prototype=c}}();var e;!function(){"use strict";var a={statementId:!0,voidedStatementId:!0,verb:!0,object:!0,registration:!0,context:!0,actor:!0,since:!0,until:!0,limit:!0,authoritative:!0,sparse:!0,instructor:!0,ascending:!0,continueToken:!0,agent:!0,activityId:!0,stateId:!0,profileId:!0,activity_platform:!0,grouping:!0,"Accept-Language":!0};e=function(a){this.log("constructor"),this.recordStores=[],this.actor=null,this.activity=null,this.registration=null,this.context=null,this.init(a)},e.prototype={LOG_SRC:"TinCan",log:function(a,b){e.DEBUG&&"undefined"!=typeof console&&console.log&&(b=b||this.LOG_SRC||"TinCan",console.log("TinCan."+b+": "+a))},init:function(a){this.log("init");var b;if(a=a||{},a.hasOwnProperty("url")&&""!==a.url&&this._initFromQueryString(a.url),a.hasOwnProperty("recordStores")&&void 0!==a.recordStores)for(b=0;b<a.recordStores.length;b+=1)this.addRecordStore(a.recordStores[b]);a.hasOwnProperty("activity")&&(a.activity instanceof e.Activity?this.activity=a.activity:this.activity=new e.Activity(a.activity)),a.hasOwnProperty("actor")&&(a.actor instanceof e.Agent?this.actor=a.actor:this.actor=new e.Agent(a.actor)),a.hasOwnProperty("context")&&(a.context instanceof e.Context?this.context=a.context:this.context=new e.Context(a.context)),a.hasOwnProperty("registration")&&(this.registration=a.registration)},_initFromQueryString:function(b){this.log("_initFromQueryString");var c,d,f,g=e.Utils.parseURL(b).params,h=["endpoint","auth"],i={},j=null;if(g.hasOwnProperty("actor")){this.log("_initFromQueryString - found actor: "+g.actor);try{this.actor=e.Agent.fromJSON(g.actor),delete g.actor}catch(k){this.log("_initFromQueryString - failed to set actor: "+k)}}if(g.hasOwnProperty("activity_id")&&(this.activity=new e.Activity({
18
+ id:g.activity_id}),delete g.activity_id),(g.hasOwnProperty("activity_platform")||g.hasOwnProperty("registration")||g.hasOwnProperty("grouping"))&&(f={},g.hasOwnProperty("activity_platform")&&(f.platform=g.activity_platform,delete g.activity_platform),g.hasOwnProperty("registration")&&(f.registration=this.registration=g.registration,delete g.registration),g.hasOwnProperty("grouping")&&(f.contextActivities={},f.contextActivities.grouping=g.grouping,delete g.grouping),this.context=new e.Context(f)),g.hasOwnProperty("endpoint")){for(c=0;c<h.length;c+=1)d=h[c],g.hasOwnProperty(d)&&(i[d]=g[d],delete g[d]);for(c in g)g.hasOwnProperty(c)&&(a.hasOwnProperty(c)?delete g[c]:(j=j||{},j[c]=g[c]));null!==j&&(i.extended=j),i.allowFail=!1,this.addRecordStore(i)}},addRecordStore:function(a){this.log("addRecordStore");var b;b=a instanceof e.LRS?a:new e.LRS(a),this.recordStores.push(b)},prepareStatement:function(a){return this.log("prepareStatement"),a instanceof e.Statement||(a=new e.Statement(a)),null===a.actor&&null!==this.actor&&(a.actor=this.actor),null===a.target&&null!==this.activity&&(a.target=this.activity),null!==this.context&&(null===a.context?a.context=this.context:(null===a.context.registration&&(a.context.registration=this.context.registration),null===a.context.platform&&(a.context.platform=this.context.platform),null!==this.context.contextActivities&&(null===a.context.contextActivities?a.context.contextActivities=this.context.contextActivities:(null!==this.context.contextActivities.grouping&&null===a.context.contextActivities.grouping&&(a.context.contextActivities.grouping=this.context.contextActivities.grouping),null!==this.context.contextActivities.parent&&null===a.context.contextActivities.parent&&(a.context.contextActivities.parent=this.context.contextActivities.parent),null!==this.context.contextActivities.other&&null===a.context.contextActivities.other&&(a.context.contextActivities.other=this.context.contextActivities.other))))),a},sendStatement:function(a,b){this.log("sendStatement");var c,d,e,f=this,g=this.prepareStatement(a),h=this.recordStores.length,i=[],j=[];if(h>0)for("function"==typeof b&&(e=function(a,c){var d;f.log("sendStatement - callbackWrapper: "+h),h>1?(h-=1,j.push({err:a,xhr:c})):1===h?(j.push({err:a,xhr:c}),d=[j,g],b.apply(this,d)):f.log("sendStatement - unexpected record store count: "+h)}),d=0;d<h;d+=1)c=this.recordStores[d],i.push(c.saveStatement(g,{callback:e}));else this.log("[warning] sendStatement: No LRSs added yet (statement not sent)"),"function"==typeof b&&b.apply(this,[null,g]);return{statement:g,results:i}},getStatement:function(a,b,c){this.log("getStatement");var d;return c=c||{},c.params=c.params||{},this.recordStores.length>0?(d=this.recordStores[0],d.retrieveStatement(a,{callback:b,params:c.params})):void this.log("[warning] getStatement: No LRSs added yet (statement not retrieved)")},voidStatement:function(a,b,c){this.log("voidStatement");var d,f,g,h,i,j=this,k=this.recordStores.length,l=[],m=[];if(a instanceof e.Statement&&(a=a.id),"undefined"!=typeof c.actor?f=c.actor:null!==this.actor&&(f=this.actor),g=new e.Statement({actor:f,verb:{id:"http://adlnet.gov/expapi/verbs/voided"},target:{objectType:"StatementRef",id:a}}),k>0)for("function"==typeof b&&(i=function(a,c){var d;j.log("voidStatement - callbackWrapper: "+k),k>1?(k-=1,m.push({err:a,xhr:c})):1===k?(m.push({err:a,xhr:c}),d=[m,g],b.apply(this,d)):j.log("voidStatement - unexpected record store count: "+k)}),h=0;h<k;h+=1)d=this.recordStores[h],l.push(d.saveStatement(g,{callback:i}));else this.log("[warning] voidStatement: No LRSs added yet (statement not sent)"),"function"==typeof b&&b.apply(this,[null,g]);return{statement:g,results:l}},getVoidedStatement:function(a,b){this.log("getVoidedStatement");var c;return this.recordStores.length>0?(c=this.recordStores[0],c.retrieveVoidedStatement(a,{callback:b})):void this.log("[warning] getVoidedStatement: No LRSs added yet (statement not retrieved)")},sendStatements:function(a,b){this.log("sendStatements");var c,d,e,f=this,g=[],h=this.recordStores.length,i=[],j=[];if(0===a.length)"function"==typeof b&&b.apply(this,[null,g]);else{for(d=0;d<a.length;d+=1)g.push(this.prepareStatement(a[d]));if(h>0)for("function"==typeof b&&(e=function(a,c){var d;f.log("sendStatements - callbackWrapper: "+h),h>1?(h-=1,j.push({err:a,xhr:c})):1===h?(j.push({err:a,xhr:c}),d=[j,g],b.apply(this,d)):f.log("sendStatements - unexpected record store count: "+h)}),d=0;d<h;d+=1)c=this.recordStores[d],i.push(c.saveStatements(g,{callback:e}));else this.log("[warning] sendStatements: No LRSs added yet (statements not sent)"),"function"==typeof b&&b.apply(this,[null,g])}return{statements:g,results:i}},getStatements:function(a){this.log("getStatements");var b,c,d={};return this.recordStores.length>0?(b=this.recordStores[0],a=a||{},c=a.params||{},a.sendActor&&null!==this.actor&&("0.9"===b.version||"0.95"===b.version?c.actor=this.actor:c.agent=this.actor),a.sendActivity&&null!==this.activity&&("0.9"===b.version||"0.95"===b.version?c.target=this.activity:c.activity=this.activity),"undefined"==typeof c.registration&&null!==this.registration&&(c.registration=this.registration),d={params:c},"undefined"!=typeof a.callback&&(d.callback=a.callback),b.queryStatements(d)):void this.log("[warning] getStatements: No LRSs added yet (statements not read)")},getState:function(a,b){this.log("getState");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor,activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.registration?c.registration=b.registration:null!==this.registration&&(c.registration=this.registration),"undefined"!=typeof b.callback&&(c.callback=b.callback),d.retrieveState(a,c)):void this.log("[warning] getState: No LRSs added yet (state not retrieved)")},setState:function(a,b,c){this.log("setState");var d,f;return this.recordStores.length>0?(f=this.recordStores[0],c=c||{},d={agent:"undefined"!=typeof c.agent?c.agent:this.actor,activity:"undefined"!=typeof c.activity?c.activity:this.activity},"undefined"!=typeof c.registration?d.registration=c.registration:null!==this.registration&&(d.registration=this.registration),"undefined"!=typeof c.lastSHA1&&(d.lastSHA1=c.lastSHA1),"undefined"!=typeof c.contentType&&(d.contentType=c.contentType,"undefined"!=typeof c.overwriteJSON&&!c.overwriteJSON&&e.Utils.isApplicationJSON(c.contentType)&&(d.method="POST")),"undefined"!=typeof c.callback&&(d.callback=c.callback),f.saveState(a,b,d)):void this.log("[warning] setState: No LRSs added yet (state not saved)")},deleteState:function(a,b){this.log("deleteState");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor,activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.registration?c.registration=b.registration:null!==this.registration&&(c.registration=this.registration),"undefined"!=typeof b.callback&&(c.callback=b.callback),d.dropState(a,c)):void this.log("[warning] deleteState: No LRSs added yet (state not deleted)")},getActivityProfile:function(a,b){this.log("getActivityProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.retrieveActivityProfile(a,c)):void this.log("[warning] getActivityProfile: No LRSs added yet (activity profile not retrieved)")},setActivityProfile:function(a,b,c){this.log("setActivityProfile");var d,f;return this.recordStores.length>0?(f=this.recordStores[0],c=c||{},d={activity:"undefined"!=typeof c.activity?c.activity:this.activity},"undefined"!=typeof c.callback&&(d.callback=c.callback),"undefined"!=typeof c.lastSHA1&&(d.lastSHA1=c.lastSHA1),"undefined"!=typeof c.contentType&&(d.contentType=c.contentType,"undefined"!=typeof c.overwriteJSON&&!c.overwriteJSON&&e.Utils.isApplicationJSON(c.contentType)&&(d.method="POST")),f.saveActivityProfile(a,b,d)):void this.log("[warning] setActivityProfile: No LRSs added yet (activity profile not saved)")},deleteActivityProfile:function(a,b){this.log("deleteActivityProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.dropActivityProfile(a,c)):void this.log("[warning] deleteActivityProfile: No LRSs added yet (activity profile not deleted)")},getAgentProfile:function(a,b){this.log("getAgentProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.retrieveAgentProfile(a,c)):void this.log("[warning] getAgentProfile: No LRSs added yet (agent profile not retrieved)")},setAgentProfile:function(a,b,c){this.log("setAgentProfile");var d,f;return this.recordStores.length>0?(f=this.recordStores[0],c=c||{},d={agent:"undefined"!=typeof c.agent?c.agent:this.actor},"undefined"!=typeof c.callback&&(d.callback=c.callback),"undefined"!=typeof c.lastSHA1&&(d.lastSHA1=c.lastSHA1),"undefined"!=typeof c.contentType&&(d.contentType=c.contentType,"undefined"!=typeof c.overwriteJSON&&!c.overwriteJSON&&e.Utils.isApplicationJSON(c.contentType)&&(d.method="POST")),f.saveAgentProfile(a,b,d)):void this.log("[warning] setAgentProfile: No LRSs added yet (agent profile not saved)")},deleteAgentProfile:function(a,b){this.log("deleteAgentProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.dropAgentProfile(a,c)):void this.log("[warning] deleteAgentProfile: No LRSs added yet (agent profile not deleted)")}},e.DEBUG=!1,e.enableDebug=function(){e.DEBUG=!0},e.disableDebug=function(){e.DEBUG=!1},e.versions=function(){return["1.0.2","1.0.1","1.0.0","0.95","0.9"]},"object"==typeof b&&(b.exports=e)}(),function(){"use strict";e.Utils={defaultEncoding:"utf8",getUUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16)})},getISODateString:function(a){function b(a,b){var c,d;for("undefined"!=typeof a&&null!==a||(a=0),"undefined"!=typeof b&&null!==b||(b=2),c=Math.pow(10,b-1),d=a.toString();a<c&&c>1;)d="0"+d,c/=10;return d}return a.getUTCFullYear()+"-"+b(a.getUTCMonth()+1)+"-"+b(a.getUTCDate())+"T"+b(a.getUTCHours())+":"+b(a.getUTCMinutes())+":"+b(a.getUTCSeconds())+"."+b(a.getUTCMilliseconds(),3)+"Z"},convertISO8601DurationToMilliseconds:function(a){var b,c,d,e,f=a.indexOf("-")>=0,g=a.indexOf("T"),h=a.indexOf("H"),i=a.indexOf("M"),j=a.indexOf("S");if(g===-1||i!==-1&&i<g||a.indexOf("D")!==-1||a.indexOf("Y")!==-1)throw new Error("ISO 8601 timestamps including years, months and/or days are not currently supported");return h===-1?(h=g,b=0):b=parseInt(a.slice(g+1,h),10),i===-1?(i=g,c=0):c=parseInt(a.slice(h+1,i),10),d=parseFloat(a.slice(i+1,j)),e=parseInt(1e3*(60*(60*b+c)+d),10),isNaN(e)&&(e=0),f&&(e*=-1),e},convertMillisecondsToISO8601Duration:function(a){var b,c,d,e,f=parseInt(a,10),g="",h="";return e=Math.round(f/10),e<0&&(g="-",e*=-1),b=parseInt(e/36e4,10),c=parseInt(e%36e4/6e3,10),d=e%36e4%6e3/100,h=g+"PT",b>0&&(h+=b+"H"),c>0&&(h+=c+"M"),h+=d+"S"},getSHA1String:function(a){return d.SHA1(a).toString(d.enc.Hex)},getSHA256String:function(a){return"[object ArrayBuffer]"===Object.prototype.toString.call(a)&&(a=d.lib.WordArray.create(a)),d.SHA256(a).toString(d.enc.Hex)},getBase64String:function(a){return d.enc.Base64.stringify(d.enc.Latin1.parse(a))},getLangDictionaryValue:function(a,b){var c,d=this[a];if("undefined"!=typeof b&&"undefined"!=typeof d[b])return d[b];if("undefined"!=typeof d.und)return d.und;if("undefined"!=typeof d["en-US"])return d["en-US"];for(c in d)if(d.hasOwnProperty(c))return d[c];return""},parseURL:function(a,b){var c,d,e,f,g="/"===a.charAt(0),h=["(/[^?#]*)","(\\?[^#]*|)","(#.*|)$"],i=/\+/g,j=/([^&=]+)=?([^&]*)/g,k=function(a){return decodeURIComponent(a.replace(i," "))};if(b=b||{},g){if("undefined"==typeof b.allowRelative||!b.allowRelative)throw new Error("Refusing to parse relative URL without 'allowRelative' option")}else h.unshift("^(https?:)//","(([^:/?#]*)(?::([0-9]+))?)"),a.indexOf("/",8)===-1&&(a+="/");if(c=new RegExp(h.join("")),d=a.match(c),null===d)throw new Error("Unable to parse URL regular expression did not match: '"+a+"'");if(g?(e={protocol:null,host:null,hostname:null,port:null,path:null,pathname:d[1],search:d[2],hash:d[3],params:{}},e.path=e.pathname):(e={protocol:d[1],host:d[2],hostname:d[3],port:d[4],pathname:d[5],search:d[6],hash:d[7],params:{}},e.path=e.protocol+"//"+e.host+e.pathname),""!==e.search)for(;f=j.exec(e.search.substring(1));)e.params[k(f[1])]=k(f[2]);return e},getServerRoot:function(a){var b=a.split("/");return b[0]+"//"+b[2]},getContentTypeFromHeader:function(a){return String(a).split(";")[0]},isApplicationJSON:function(a){return 0===e.Utils.getContentTypeFromHeader(a).toLowerCase().indexOf("application/json")},stringToArrayBuffer:function(){e.prototype.log("stringToArrayBuffer not overloaded - no environment loaded?")},stringFromArrayBuffer:function(){e.prototype.log("stringFromArrayBuffer not overloaded - no environment loaded?")}}}(),function(){"use strict";var a=e.LRS=function(a){this.log("constructor"),this.endpoint=null,this.version=null,this.auth=null,this.allowFail=!0,this.extended=null,this.init(a)};a.prototype={LOG_SRC:"LRS",log:e.prototype.log,init:function(a){this.log("init");var b,c=e.versions(),d=!1;if(a=a||{},a.hasOwnProperty("alertOnRequestFailure")&&this.log("'alertOnRequestFailure' is deprecated (alerts have been removed) no need to set it now"),!a.hasOwnProperty("endpoint")||null===a.endpoint||""===a.endpoint)throw this.log("[error] LRS invalid: no endpoint"),{code:3,mesg:"LRS invalid: no endpoint"};if(this.endpoint=String(a.endpoint),"/"!==this.endpoint.slice(-1)&&(this.log("adding trailing slash to endpoint"),this.endpoint+="/"),a.hasOwnProperty("allowFail")&&(this.allowFail=a.allowFail),a.hasOwnProperty("auth")?this.auth=a.auth:a.hasOwnProperty("username")&&a.hasOwnProperty("password")&&(this.auth="Basic "+e.Utils.getBase64String(a.username+":"+a.password)),a.hasOwnProperty("extended")&&(this.extended=a.extended),this._initByEnvironment(a),"undefined"!=typeof a.version){for(this.log("version: "+a.version),b=0;b<c.length;b+=1)if(c[b]===a.version){d=!0;break}if(!d)throw this.log("[error] LRS invalid: version not supported ("+a.version+")"),{code:5,mesg:"LRS invalid: version not supported ("+a.version+")"};this.version=a.version}else this.version=c[0]},_getBoundary:function(){return e.Utils.getUUID().replace(/-/g,"")},_initByEnvironment:function(){this.log("_initByEnvironment not overloaded - no environment loaded?")},_makeRequest:function(){this.log("_makeRequest not overloaded - no environment loaded?")},_getMultipartRequestData:function(){this.log("_getMultipartRequestData not overloaded - no environment loaded?")},_IEModeConversion:function(){this.log("_IEModeConversion not overloaded - browser environment not loaded.")},_processGetStatementResult:function(a,b){var c,d,f,g,h={};if(!b.attachments)return e.Statement.fromJSON(a.responseText);for(c=a.getResponseHeader("Content-Type").split("boundary=")[1],d=this._parseMultipart(c,a.response),f=JSON.parse(d[0].body),g=1;g<d.length;g+=1)h[d[g].headers["X-Experience-API-Hash"]]=d[g].body;return this._assignAttachmentContent([f],h),new e.Statement(f)},sendRequest:function(a){this.log("sendRequest");var b,c=this.endpoint+a.url,d={};if(0===a.url.indexOf("http")&&(c=a.url),null!==this.extended){a.params=a.params||{};for(b in this.extended)this.extended.hasOwnProperty(b)&&(a.params.hasOwnProperty(b)||null!==this.extended[b]&&(a.params[b]=this.extended[b]))}d.Authorization=this.auth,"0.9"!==this.version&&(d["X-Experience-API-Version"]=this.version);for(b in a.headers)a.headers.hasOwnProperty(b)&&(d[b]=a.headers[b]);return this._makeRequest(c,d,a)},about:function(a){this.log("about");var b,c,d;if(a=a||{},b={url:"about",method:"GET",params:{}},"undefined"!=typeof a.callback&&(d=function(b,c){var d=c;null===b&&(d=e.About.fromJSON(c.responseText)),a.callback(b,d)},b.callback=d),c=this.sendRequest(b),!d)return null===c.err&&(c.xhr=e.About.fromJSON(c.xhr.responseText)),c},saveStatement:function(a,b){this.log("saveStatement");var c,d,e,f={url:"statements",headers:{}},g=[];b=b||{};try{c=a.asVersion(this.version)}catch(h){return this.allowFail?(this.log("[warning] statement could not be serialized in version ("+this.version+"): "+h),"undefined"!=typeof b.callback?void b.callback(null,null):{err:null,xhr:null}):(this.log("[error] statement could not be serialized in version ("+this.version+"): "+h),"undefined"!=typeof b.callback?void b.callback(h,null):{err:h,xhr:null})}if(c.hasOwnProperty("attachments")&&a.hasAttachmentWithContent()){for(d=this._getBoundary(),f.headers["Content-Type"]="multipart/mixed; boundary="+d,e=0;e<a.attachments.length;e+=1)null!==a.attachments[e].content&&g.push(a.attachments[e]);try{f.data=this._getMultipartRequestData(d,c,g)}catch(h){return this.allowFail?(this.log("[warning] multipart request data could not be created (attachments probably not supported): "+h),"undefined"!=typeof b.callback?void b.callback(null,null):{err:null,xhr:null}):(this.log("[error] multipart request data could not be created (attachments probably not supported): "+h),"undefined"!=typeof b.callback?void b.callback(h,null):{err:h,xhr:null})}}else f.headers["Content-Type"]="application/json",f.data=JSON.stringify(c);return null!==a.id?(f.method="PUT",f.params={statementId:a.id}):f.method="POST","undefined"!=typeof b.callback&&(f.callback=b.callback),this.sendRequest(f)},retrieveStatement:function(a,b){this.log("retrieveStatement");var c,d,e,f=this;return b=b||{},b.params=b.params||{},c={url:"statements",method:"GET",params:{statementId:a}},b.params.attachments&&(c.params.attachments=!0,c.expectMultipart=!0),"undefined"!=typeof b.callback&&(e=function(a,c){var d=c;null===a&&(d=f._processGetStatementResult(c,b.params)),b.callback(a,d)},c.callback=e),d=this.sendRequest(c),e||(d.statement=null,null===d.err&&(d.statement=f._processGetStatementResult(d.xhr,b.params))),d},retrieveVoidedStatement:function(a,b){this.log("retrieveVoidedStatement");var c,d,e,f=this;return b=b||{},b.params=b.params||{},c={url:"statements",method:"GET",params:{}},"0.9"===this.version||"0.95"===this.version?c.params.statementId=a:(c.params.voidedStatementId=a,b.params.attachments&&(c.params.attachments=!0,c.expectMultipart=!0)),"undefined"!=typeof b.callback&&(e=function(a,c){var d=c;null===a&&(d=f._processGetStatementResult(c,b.params)),b.callback(a,d)},c.callback=e),d=this.sendRequest(c),e||(d.statement=null,null===d.err&&(d.statement=f._processGetStatementResult(d.xhr,b.params))),d},saveStatements:function(a,b){this.log("saveStatements");var c,d,e,f,g={url:"statements",method:"POST",headers:{}},h=[],i=[];if(b=b||{},0===a.length)return"undefined"!=typeof b.callback?void b.callback(new Error("no statements"),null):{err:new Error("no statements"),xhr:null};for(e=0;e<a.length;e+=1){try{c=a[e].asVersion(this.version)}catch(j){return this.allowFail?(this.log("[warning] statement could not be serialized in version ("+this.version+"): "+j),"undefined"!=typeof b.callback?void b.callback(null,null):{err:null,xhr:null}):(this.log("[error] statement could not be serialized in version ("+this.version+"): "+j),"undefined"!=typeof b.callback?void b.callback(j,null):{err:j,xhr:null})}if(a[e].hasAttachmentWithContent())for(f=0;f<a[e].attachments.length;f+=1)null!==a[e].attachments[f].content&&i.push(a[e].attachments[f]);h.push(c)}if(0!==i.length){d=this._getBoundary(),g.headers["Content-Type"]="multipart/mixed; boundary="+d;try{g.data=this._getMultipartRequestData(d,h,i)}catch(j){return this.allowFail?(this.log("[warning] multipart request data could not be created (attachments probably not supported): "+j),"undefined"!=typeof b.callback?void b.callback(null,null):{err:null,xhr:null}):(this.log("[error] multipart request data could not be created (attachments probably not supported): "+j),"undefined"!=typeof b.callback?void b.callback(j,null):{err:j,xhr:null})}}else g.headers["Content-Type"]="application/json",g.data=JSON.stringify(h);return"undefined"!=typeof b.callback&&(g.callback=b.callback),this.sendRequest(g)},queryStatements:function(a){this.log("queryStatements");var b,c,d,f=this;a=a||{},a.params=a.params||{};try{b=this._queryStatementsRequestCfg(a),a.params.attachments&&(b.expectMultipart=!0)}catch(g){return this.log("[error] Query statements failed - "+g),"undefined"!=typeof a.callback&&a.callback(g,{}),{err:g,statementsResult:null}}return"undefined"!=typeof a.callback&&(d=function(b,c){var d,g,h,i,j=c,k={};if(null===b)if(a.params.attachments){for(g=c.getResponseHeader("Content-Type").split("boundary=")[1],d=f._parseMultipart(g,c.response),h=JSON.parse(d[0].body),i=1;i<d.length;i+=1)k[d[i].headers["X-Experience-API-Hash"]]=d[i].body;for(f._assignAttachmentContent(h.statements,k),j=new e.StatementsResult({statements:h.statements}),i=0;i<j.statements.length;i+=1)j.statements[i]instanceof e.Statement||(j.statements[i]=new e.Statement(j.statements[i]))}else j=e.StatementsResult.fromJSON(c.responseText);a.callback(b,j)},b.callback=d),c=this.sendRequest(b),c.config=b,d||(c.statementsResult=null,null===c.err&&(c.statementsResult=e.StatementsResult.fromJSON(c.xhr.responseText))),c},_queryStatementsRequestCfg:function(a){this.log("_queryStatementsRequestCfg");var b,c,d={},e={url:"statements",method:"GET",params:d},f=["agent","actor","object","instructor"],g=["verb","activity"],h=["registration","context","since","until","limit","authoritative","sparse","ascending","related_activities","related_agents","format","attachments"],i={verb:!0,registration:!0,since:!0,until:!0,limit:!0,ascending:!0},j={.9:{supported:{actor:!0,instructor:!0,target:!0,object:!0,context:!0,authoritative:!0,sparse:!0}},"1.0.0":{supported:{agent:!0,activity:!0,related_activities:!0,related_agents:!0,format:!0,attachments:!0}}};j[.95]=j[.9],j["1.0.1"]=j["1.0.0"],j["1.0.2"]=j["1.0.0"],a.params.hasOwnProperty("target")&&(a.params.object=a.params.target);for(c in a.params)if(a.params.hasOwnProperty(c)&&"undefined"==typeof i[c]&&"undefined"==typeof j[this.version].supported[c])throw"Unrecognized query parameter configured: "+c;for(b=0;b<f.length;b+=1)"undefined"!=typeof a.params[f[b]]&&(d[f[b]]=JSON.stringify(a.params[f[b]].asVersion(this.version)));for(b=0;b<g.length;b+=1)"undefined"!=typeof a.params[g[b]]&&("undefined"==typeof a.params[g[b]].id?d[g[b]]=a.params[g[b]]:d[g[b]]=a.params[g[b]].id);for(b=0;b<h.length;b+=1)"undefined"!=typeof a.params[h[b]]&&null!==a.params[h[b]]&&(d[h[b]]=a.params[h[b]]);return e},_assignAttachmentContent:function(a,b){var c,d;for(c=0;c<a.length;c+=1)if(a[c].hasOwnProperty("attachments")&&null!==a[c].attachments)for(d=0;d<a[c].attachments.length;d+=1)b.hasOwnProperty(a[c].attachments[d].sha2)&&(a[c].attachments[d].content=b[a[c].attachments[d].sha2])},_parseMultipart:function(a,b){var c,d,f,g,h,i,j,k,l,m,n,o="--"+a,p=[],q=2;for(c=new Uint8Array(b),d=this.__uint8ToString(c),f=d.indexOf(o+"--"),g=d.indexOf(o);g!==-1;)h=d.indexOf(o,g+o.length),i=g+o.length+q,j=d.indexOf("\r\n\r\n",g),k=j+q+q,l=h-2,m=this._parseHeaders(this.__uint8ToString(new Uint8Array(b.slice(i,j)))),n=b.slice(k,l),0===p.length&&(n=e.Utils.stringFromArrayBuffer(n)),p.push({headers:m,body:n}),g=h===f?-1:h;return p},__uint8ToString:function(a){var b,c="",d=a.byteLength;for(b=0;b<d;b+=1)c+=String.fromCharCode(a[b]);return c},_parseHeaders:function(a){var b,c,d,e,f={};for(b=a.split("\n"),e=0;e<b.length;e+=1)d=b[e].split(":",2),null!==d[1]?(f[d[0]]=d[1].replace(/^\s+|\s+$/g,""),c=d[0]):"\t"===d[0].substring(0,1)&&(f[d[0]]=d[1].replace(/^\s+|\s+$/g,""));return f},moreStatements:function(a){this.log("moreStatements: "+a.url);var b,c,d,f,g;return a=a||{},f=e.Utils.parseURL(a.url,{allowRelative:!0}),g=e.Utils.getServerRoot(this.endpoint),0===f.path.indexOf("/statements")&&(f.path=this.endpoint.replace(g,"")+f.path,this.log("converting non-standard more URL to "+f.path)),0!==f.path.indexOf("/")&&(f.path="/"+f.path),b={method:"GET",url:g+f.path,params:f.params},"undefined"!=typeof a.callback&&(d=function(b,c){var d=c;null===b&&(d=e.StatementsResult.fromJSON(c.responseText)),a.callback(b,d)},b.callback=d),c=this.sendRequest(b),c.config=b,d||(c.statementsResult=null,null===c.err&&(c.statementsResult=e.StatementsResult.fromJSON(c.xhr.responseText))),c},retrieveState:function(a,b){this.log("retrieveState");var c,d,f,g={},h={},i=this;if(f=b.requestHeaders||{},g={stateId:a,activityId:b.activity.id},"0.9"===this.version?g.actor=JSON.stringify(b.agent.asVersion(this.version)):g.agent=JSON.stringify(b.agent.asVersion(this.version)),"undefined"!=typeof b.registration&&null!==b.registration&&("0.9"===this.version?g.registrationId=b.registration:g.registration=b.registration),h={url:"activities/state",method:"GET",params:g,ignore404:!0,headers:f},"undefined"!=typeof b.callback&&(d=function(c,d){var f=d;if(null===c)if(404===d.status)f=null;else if(f=new e.State({id:a,contents:d.responseText}),"undefined"!=typeof d.getResponseHeader&&null!==d.getResponseHeader("ETag")&&""!==d.getResponseHeader("ETag")?f.etag=d.getResponseHeader("ETag"):f.etag='"'+e.Utils.getSHA1String(d.responseText)+'"',"undefined"!=typeof d.contentType?f.contentType=d.contentType:"undefined"!=typeof d.getResponseHeader&&null!==d.getResponseHeader("Content-Type")&&""!==d.getResponseHeader("Content-Type")&&(f.contentType=d.getResponseHeader("Content-Type")),e.Utils.isApplicationJSON(f.contentType))try{f.contents=JSON.parse(f.contents)}catch(g){i.log("retrieveState - failed to deserialize JSON: "+g)}b.callback(c,f)},h.callback=d),c=this.sendRequest(h),!d&&(c.state=null,null===c.err&&404!==c.xhr.status&&(c.state=new e.State({id:a,contents:c.xhr.responseText}),"undefined"!=typeof c.xhr.getResponseHeader&&null!==c.xhr.getResponseHeader("ETag")&&""!==c.xhr.getResponseHeader("ETag")?c.state.etag=c.xhr.getResponseHeader("ETag"):c.state.etag='"'+e.Utils.getSHA1String(c.xhr.responseText)+'"',"undefined"!=typeof c.xhr.contentType?c.state.contentType=c.xhr.contentType:"undefined"!=typeof c.xhr.getResponseHeader&&null!==c.xhr.getResponseHeader("Content-Type")&&""!==c.xhr.getResponseHeader("Content-Type")&&(c.state.contentType=c.xhr.getResponseHeader("Content-Type")),e.Utils.isApplicationJSON(c.state.contentType))))try{c.state.contents=JSON.parse(c.state.contents)}catch(j){this.log("retrieveState - failed to deserialize JSON: "+j)}return c},retrieveStateIds:function(a){this.log("retrieveStateIds");var b,c,d,e,f={};if(a=a||{},c=a.requestHeaders||{},f.activityId=a.activity.id,"0.9"===this.version?f.actor=JSON.stringify(a.agent.asVersion(this.version)):f.agent=JSON.stringify(a.agent.asVersion(this.version)),"undefined"!=typeof a.registration&&null!==a.registration&&("0.9"===this.version?f.registrationId=a.registration:f.registration=a.registration),b={url:"activities/state",method:"GET",params:f,headers:c,ignore404:!0},"undefined"!=typeof a.callback&&(e=function(b,c){var d=c;if(null!==b)return void a.callback(b,d);if(404===c.status)d=[];else try{d=JSON.parse(c.responseText)}catch(e){b="Response JSON parse error: "+e}a.callback(b,d)},b.callback=e),"undefined"!=typeof a.since&&(b.params.since=a.since),d=this.sendRequest(b),!e){if(d.profileIds=null,null!==d.err)return d;if(404===d.xhr.status)d.profileIds=[];else try{d.profileIds=JSON.parse(d.xhr.responseText)}catch(g){d.err="retrieveStateIds - JSON parse error: "+g}}return d},saveState:function(a,b,c){this.log("saveState");var d,f,g;return g=c.requestHeaders||{},"undefined"==typeof c.contentType&&(c.contentType="application/octet-stream"),g["Content-Type"]=c.contentType,"object"==typeof b&&e.Utils.isApplicationJSON(c.contentType)&&(b=JSON.stringify(b)),"undefined"!=typeof c.method&&"POST"===c.method||(c.method="PUT"),d={stateId:a,activityId:c.activity.id},"0.9"===this.version?d.actor=JSON.stringify(c.agent.asVersion(this.version)):d.agent=JSON.stringify(c.agent.asVersion(this.version)),"undefined"!=typeof c.registration&&null!==c.registration&&("0.9"===this.version?d.registrationId=c.registration:d.registration=c.registration),f={url:"activities/state",method:c.method,params:d,data:b,headers:g},"undefined"!=typeof c.callback&&(f.callback=c.callback),"undefined"!=typeof c.lastSHA1&&null!==c.lastSHA1&&(f.headers["If-Match"]=c.lastSHA1),this.sendRequest(f)},dropState:function(a,b){this.log("dropState");var c,d,e;return e=b.requestHeaders||{},c={activityId:b.activity.id},"0.9"===this.version?c.actor=JSON.stringify(b.agent.asVersion(this.version)):c.agent=JSON.stringify(b.agent.asVersion(this.version)),null!==a&&(c.stateId=a),"undefined"!=typeof b.registration&&null!==b.registration&&("0.9"===this.version?c.registrationId=b.registration:c.registration=b.registration),d={url:"activities/state",method:"DELETE",params:c,headers:e},"undefined"!=typeof b.callback&&(d.callback=b.callback),this.sendRequest(d)},retrieveActivity:function(a,b){this.log("retrieveActivity");var c,d,f,g={};return f=b.requestHeaders||{},g={url:"activities",method:"GET",params:{activityId:a},ignore404:!0,headers:f},"undefined"!=typeof b.callback&&(d=function(c,d){var f=d;null===c&&(f=404===d.status?new e.Activity({id:a}):e.Activity.fromJSON(d.responseText)),b.callback(c,f)},g.callback=d),c=this.sendRequest(g),d||(c.activity=null,null===c.err&&(404===c.xhr.status?c.activity=new e.Activity({id:a}):c.activity=e.Activity.fromJSON(c.xhr.responseText))),c},retrieveActivityProfile:function(a,b){this.log("retrieveActivityProfile");var c,d,f,g={},h=this;if(f=b.requestHeaders||{},g={url:"activities/profile",method:"GET",params:{profileId:a,activityId:b.activity.id},ignore404:!0,headers:f},"undefined"!=typeof b.callback&&(d=function(c,d){var f=d;if(null===c)if(404===d.status)f=null;else if(f=new e.ActivityProfile({id:a,activity:b.activity,contents:d.responseText}),"undefined"!=typeof d.getResponseHeader&&null!==d.getResponseHeader("ETag")&&""!==d.getResponseHeader("ETag")?f.etag=d.getResponseHeader("ETag"):f.etag='"'+e.Utils.getSHA1String(d.responseText)+'"',"undefined"!=typeof d.contentType?f.contentType=d.contentType:"undefined"!=typeof d.getResponseHeader&&null!==d.getResponseHeader("Content-Type")&&""!==d.getResponseHeader("Content-Type")&&(f.contentType=d.getResponseHeader("Content-Type")),e.Utils.isApplicationJSON(f.contentType))try{f.contents=JSON.parse(f.contents)}catch(g){h.log("retrieveActivityProfile - failed to deserialize JSON: "+g)}b.callback(c,f)},g.callback=d),c=this.sendRequest(g),!d&&(c.profile=null,null===c.err&&404!==c.xhr.status&&(c.profile=new e.ActivityProfile({id:a,activity:b.activity,contents:c.xhr.responseText}),"undefined"!=typeof c.xhr.getResponseHeader&&null!==c.xhr.getResponseHeader("ETag")&&""!==c.xhr.getResponseHeader("ETag")?c.profile.etag=c.xhr.getResponseHeader("ETag"):c.profile.etag='"'+e.Utils.getSHA1String(c.xhr.responseText)+'"',"undefined"!=typeof c.xhr.contentType?c.profile.contentType=c.xhr.contentType:"undefined"!=typeof c.xhr.getResponseHeader&&null!==c.xhr.getResponseHeader("Content-Type")&&""!==c.xhr.getResponseHeader("Content-Type")&&(c.profile.contentType=c.xhr.getResponseHeader("Content-Type")),e.Utils.isApplicationJSON(c.profile.contentType))))try{c.profile.contents=JSON.parse(c.profile.contents)}catch(i){this.log("retrieveActivityProfile - failed to deserialize JSON: "+i)}return c},retrieveActivityProfileIds:function(a){this.log("retrieveActivityProfileIds");var b,c,d,e;if(a=a||{},c=a.requestHeaders||{},b={url:"activities/profile",method:"GET",params:{activityId:a.activity.id},headers:c,ignore404:!0},"undefined"!=typeof a.callback&&(e=function(b,c){var d=c;if(null!==b)return void a.callback(b,d);if(404===c.status)d=[];else try{
19
+ d=JSON.parse(c.responseText)}catch(e){b="Response JSON parse error: "+e}a.callback(b,d)},b.callback=e),"undefined"!=typeof a.since&&(b.params.since=a.since),d=this.sendRequest(b),!e){if(d.profileIds=null,null!==d.err)return d;if(404===d.xhr.status)d.profileIds=[];else try{d.profileIds=JSON.parse(d.xhr.responseText)}catch(f){d.err="retrieveActivityProfileIds - JSON parse error: "+f}}return d},saveActivityProfile:function(a,b,c){this.log("saveActivityProfile");var d,f;return f=c.requestHeaders||{},"undefined"==typeof c.contentType&&(c.contentType="application/octet-stream"),f["Content-Type"]=c.contentType,"undefined"!=typeof c.method&&"POST"===c.method||(c.method="PUT"),"object"==typeof b&&e.Utils.isApplicationJSON(c.contentType)&&(b=JSON.stringify(b)),d={url:"activities/profile",method:c.method,params:{profileId:a,activityId:c.activity.id},data:b,headers:f},"undefined"!=typeof c.callback&&(d.callback=c.callback),"undefined"!=typeof c.lastSHA1&&null!==c.lastSHA1?d.headers["If-Match"]=c.lastSHA1:d.headers["If-None-Match"]="*",this.sendRequest(d)},dropActivityProfile:function(a,b){this.log("dropActivityProfile");var c,d,e;return e=b.requestHeaders||{},c={profileId:a,activityId:b.activity.id},d={url:"activities/profile",method:"DELETE",params:c,headers:e},"undefined"!=typeof b.callback&&(d.callback=b.callback),this.sendRequest(d)},retrieveAgentProfile:function(a,b){this.log("retrieveAgentProfile");var c,d,f,g={},h=this;if(f=b.requestHeaders||{},g={method:"GET",params:{profileId:a},ignore404:!0,headers:f},"0.9"===this.version?(g.url="actors/profile",g.params.actor=JSON.stringify(b.agent.asVersion(this.version))):(g.url="agents/profile",g.params.agent=JSON.stringify(b.agent.asVersion(this.version))),"undefined"!=typeof b.callback&&(d=function(c,d){var f=d;if(null===c)if(404===d.status)f=null;else if(f=new e.AgentProfile({id:a,agent:b.agent,contents:d.responseText}),"undefined"!=typeof d.getResponseHeader&&null!==d.getResponseHeader("ETag")&&""!==d.getResponseHeader("ETag")?f.etag=d.getResponseHeader("ETag"):f.etag='"'+e.Utils.getSHA1String(d.responseText)+'"',"undefined"!=typeof d.contentType?f.contentType=d.contentType:"undefined"!=typeof d.getResponseHeader&&null!==d.getResponseHeader("Content-Type")&&""!==d.getResponseHeader("Content-Type")&&(f.contentType=d.getResponseHeader("Content-Type")),e.Utils.isApplicationJSON(f.contentType))try{f.contents=JSON.parse(f.contents)}catch(g){h.log("retrieveAgentProfile - failed to deserialize JSON: "+g)}b.callback(c,f)},g.callback=d),c=this.sendRequest(g),!d&&(c.profile=null,null===c.err&&404!==c.xhr.status&&(c.profile=new e.AgentProfile({id:a,agent:b.agent,contents:c.xhr.responseText}),"undefined"!=typeof c.xhr.getResponseHeader&&null!==c.xhr.getResponseHeader("ETag")&&""!==c.xhr.getResponseHeader("ETag")?c.profile.etag=c.xhr.getResponseHeader("ETag"):c.profile.etag='"'+e.Utils.getSHA1String(c.xhr.responseText)+'"',"undefined"!=typeof c.xhr.contentType?c.profile.contentType=c.xhr.contentType:"undefined"!=typeof c.xhr.getResponseHeader&&null!==c.xhr.getResponseHeader("Content-Type")&&""!==c.xhr.getResponseHeader("Content-Type")&&(c.profile.contentType=c.xhr.getResponseHeader("Content-Type")),e.Utils.isApplicationJSON(c.profile.contentType))))try{c.profile.contents=JSON.parse(c.profile.contents)}catch(i){this.log("retrieveAgentProfile - failed to deserialize JSON: "+i)}return c},retrieveAgentProfileIds:function(a){this.log("retrieveAgentProfileIds");var b,c,d,e,f={};if(a=a||{},c=a.requestHeaders||{},b={method:"GET",params:f,headers:c,ignore404:!0},"0.9"===this.version?(b.url="actors/profile",f.actor=JSON.stringify(a.agent.asVersion(this.version))):(b.url="agents/profile",f.agent=JSON.stringify(a.agent.asVersion(this.version))),"undefined"!=typeof a.callback&&(e=function(b,c){var d=c;if(null!==b)return void a.callback(b,d);if(404===c.status)d=[];else try{d=JSON.parse(c.responseText)}catch(e){b="Response JSON parse error: "+e}a.callback(b,d)},b.callback=e),"undefined"!=typeof a.since&&(b.params.since=a.since),d=this.sendRequest(b),!e){if(d.profileIds=null,null!==d.err)return d;if(404===d.xhr.status)d.profileIds=[];else try{d.profileIds=JSON.parse(d.xhr.responseText)}catch(g){d.err="retrieveAgentProfileIds - JSON parse error: "+g}}return d},saveAgentProfile:function(a,b,c){this.log("saveAgentProfile");var d,f;return f=c.requestHeaders||{},"undefined"==typeof c.contentType&&(c.contentType="application/octet-stream"),f["Content-Type"]=c.contentType,"undefined"!=typeof c.method&&"POST"===c.method||(c.method="PUT"),"object"==typeof b&&e.Utils.isApplicationJSON(c.contentType)&&(b=JSON.stringify(b)),d={method:c.method,params:{profileId:a},data:b,headers:f},"0.9"===this.version?(d.url="actors/profile",d.params.actor=JSON.stringify(c.agent.asVersion(this.version))):(d.url="agents/profile",d.params.agent=JSON.stringify(c.agent.asVersion(this.version))),"undefined"!=typeof c.callback&&(d.callback=c.callback),"undefined"!=typeof c.lastSHA1&&null!==c.lastSHA1?d.headers["If-Match"]=c.lastSHA1:d.headers["If-None-Match"]="*",this.sendRequest(d)},dropAgentProfile:function(a,b){this.log("dropAgentProfile");var c,d,e;return e=b.requestHeaders||{},c={profileId:a},d={method:"DELETE",params:c,headers:e},"0.9"===this.version?(d.url="actors/profile",c.actor=JSON.stringify(b.agent.asVersion(this.version))):(d.url="agents/profile",c.agent=JSON.stringify(b.agent.asVersion(this.version))),"undefined"!=typeof b.callback&&(d.callback=b.callback),this.sendRequest(d)}},a.syncEnabled=null}(),function(){"use strict";var a=e.AgentAccount=function(a){this.log("constructor"),this.homePage=null,this.name=null,this.init(a)};a.prototype={LOG_SRC:"AgentAccount",log:e.prototype.log,init:function(a){this.log("init");var b,c=["name","homePage"];for(a=a||{},"undefined"!=typeof a.accountServiceHomePage&&(a.homePage=a.accountServiceHomePage),"undefined"!=typeof a.accountName&&(a.name=a.accountName),b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]])},toString:function(){this.log("toString");var a="";return null!==this.name||null!==this.homePage?(a+=null!==this.name?this.name:"-",a+=":",a+=null!==this.homePage?this.homePage:"-"):a="AgentAccount: unidentified",a},asVersion:function(a){this.log("asVersion: "+a);var b={};return a=a||e.versions()[0],"0.9"===a?(b.accountName=this.name,b.accountServiceHomePage=this.homePage):(b.name=this.name,b.homePage=this.homePage),b}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.Agent=function(a){this.log("constructor"),this.name=null,this.mbox=null,this.mbox_sha1sum=null,this.openid=null,this.account=null,this.degraded=!1,this.init(a)};a.prototype={objectType:"Agent",LOG_SRC:"Agent",log:e.prototype.log,init:function(a){this.log("init");var b,c,d=["name","mbox","mbox_sha1sum","openid"];for(a=a||{},"undefined"!=typeof a.lastName||"undefined"!=typeof a.firstName?(a.name="","undefined"!=typeof a.firstName&&a.firstName.length>0&&(a.name=a.firstName[0],a.firstName.length>1&&(this.degraded=!0)),""!==a.name&&(a.name+=" "),"undefined"!=typeof a.lastName&&a.lastName.length>0&&(a.name+=a.lastName[0],a.lastName.length>1&&(this.degraded=!0))):"undefined"==typeof a.familyName&&"undefined"==typeof a.givenName||(a.name="","undefined"!=typeof a.givenName&&a.givenName.length>0&&(a.name=a.givenName[0],a.givenName.length>1&&(this.degraded=!0)),""!==a.name&&(a.name+=" "),"undefined"!=typeof a.familyName&&a.familyName.length>0&&(a.name+=a.familyName[0],a.familyName.length>1&&(this.degraded=!0))),"object"==typeof a.name&&null!==a.name&&(a.name.length>1&&(this.degraded=!0),a.name=a.name[0]),"object"==typeof a.mbox&&null!==a.mbox&&(a.mbox.length>1&&(this.degraded=!0),a.mbox=a.mbox[0]),"object"==typeof a.mbox_sha1sum&&null!==a.mbox_sha1sum&&(a.mbox_sha1sum.length>1&&(this.degraded=!0),a.mbox_sha1sum=a.mbox_sha1sum[0]),"object"==typeof a.openid&&null!==a.openid&&(a.openid.length>1&&(this.degraded=!0),a.openid=a.openid[0]),"object"==typeof a.account&&null!==a.account&&"undefined"==typeof a.account.homePage&&"undefined"==typeof a.account.name&&(0===a.account.length?delete a.account:(a.account.length>1&&(this.degraded=!0),a.account=a.account[0])),a.hasOwnProperty("account")&&(a.account instanceof e.AgentAccount?this.account=a.account:this.account=new e.AgentAccount(a.account)),b=0;b<d.length;b+=1)a.hasOwnProperty(d[b])&&null!==a[d[b]]&&(c=a[d[b]],"mbox"===d[b]&&c.indexOf("mailto:")===-1&&(c="mailto:"+c),this[d[b]]=c)},toString:function(){return this.log("toString"),null!==this.name?this.name:null!==this.mbox?this.mbox.replace("mailto:",""):null!==this.mbox_sha1sum?this.mbox_sha1sum:null!==this.openid?this.openid:null!==this.account?this.account.toString():this.objectType+": unidentified"},asVersion:function(a){this.log("asVersion: "+a);var b={objectType:this.objectType};return a=a||e.versions()[0],"0.9"===a?(null!==this.mbox?b.mbox=[this.mbox]:null!==this.mbox_sha1sum?b.mbox_sha1sum=[this.mbox_sha1sum]:null!==this.openid?b.openid=[this.openid]:null!==this.account&&(b.account=[this.account.asVersion(a)]),null!==this.name&&(b.name=[this.name])):(null!==this.mbox?b.mbox=this.mbox:null!==this.mbox_sha1sum?b.mbox_sha1sum=this.mbox_sha1sum:null!==this.openid?b.openid=this.openid:null!==this.account&&(b.account=this.account.asVersion(a)),null!==this.name&&(b.name=this.name)),b}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.Group=function(a){this.log("constructor"),this.name=null,this.mbox=null,this.mbox_sha1sum=null,this.openid=null,this.account=null,this.member=[],this.init(a)};a.prototype={objectType:"Group",LOG_SRC:"Group",log:e.prototype.log,init:function(a){this.log("init");var b;if(a=a||{},e.Agent.prototype.init.call(this,a),"undefined"!=typeof a.member)for(b=0;b<a.member.length;b+=1)a.member[b]instanceof e.Agent?this.member.push(a.member[b]):this.member.push(new e.Agent(a.member[b]))},toString:function(a){this.log("toString");var b=e.Agent.prototype.toString.call(this,a);return b!==this.objectType+": unidentified"&&(b=this.objectType+": "+b),b},asVersion:function(a){this.log("asVersion: "+a);var b,c;if(a=a||e.versions()[0],b=e.Agent.prototype.asVersion.call(this,a),this.member.length>0)for(b.member=[],c=0;c<this.member.length;c+=1)b.member.push(this.member[c].asVersion(a));return b}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a={"http://adlnet.gov/expapi/verbs/experienced":"experienced","http://adlnet.gov/expapi/verbs/attended":"attended","http://adlnet.gov/expapi/verbs/attempted":"attempted","http://adlnet.gov/expapi/verbs/completed":"completed","http://adlnet.gov/expapi/verbs/passed":"passed","http://adlnet.gov/expapi/verbs/failed":"failed","http://adlnet.gov/expapi/verbs/answered":"answered","http://adlnet.gov/expapi/verbs/interacted":"interacted","http://adlnet.gov/expapi/verbs/imported":"imported","http://adlnet.gov/expapi/verbs/created":"created","http://adlnet.gov/expapi/verbs/shared":"shared","http://adlnet.gov/expapi/verbs/voided":"voided"},b=e.Verb=function(a){this.log("constructor"),this.id=null,this.display=null,this.init(a)};b.prototype={LOG_SRC:"Verb",log:e.prototype.log,init:function(b){this.log("init");var c,d,e=["id","display"];if("string"==typeof b){this.id=b,this.display={und:this.id};for(d in a)if(a.hasOwnProperty(d)&&a[d]===b){this.id=d;break}}else{for(b=b||{},c=0;c<e.length;c+=1)b.hasOwnProperty(e[c])&&null!==b[e[c]]&&(this[e[c]]=b[e[c]]);null===this.display&&"undefined"!=typeof a[this.id]&&(this.display={und:a[this.id]})}},toString:function(a){return this.log("toString"),null!==this.display?this.getLangDictionaryValue("display",a):this.id},asVersion:function(b){this.log("asVersion");var c;return b=b||e.versions()[0],"0.9"===b?c=a[this.id]:(c={id:this.id},null!==this.display&&(c.display=this.display)),c},getLangDictionaryValue:e.Utils.getLangDictionaryValue},b.fromJSON=function(a){b.prototype.log("fromJSON");var c=JSON.parse(a);return new b(c)}}(),function(){"use strict";var a=e.Result=function(a){this.log("constructor"),this.score=null,this.success=null,this.completion=null,this.duration=null,this.response=null,this.extensions=null,this.init(a)};a.prototype={LOG_SRC:"Result",log:e.prototype.log,init:function(a){this.log("init");var b,c=["completion","duration","extensions","response","success"];for(a=a||{},a.hasOwnProperty("score")&&null!==a.score&&(a.score instanceof e.Score?this.score=a.score:this.score=new e.Score(a.score)),b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]]);"Completed"===this.completion&&(this.completion=!0)},asVersion:function(a){this.log("asVersion");var b,c={},d=["success","duration","response","extensions"],f=["score"];for(a=a||e.versions()[0],b=0;b<d.length;b+=1)null!==this[d[b]]&&(c[d[b]]=this[d[b]]);for(b=0;b<f.length;b+=1)null!==this[f[b]]&&(c[f[b]]=this[f[b]].asVersion(a));return null!==this.completion&&("0.9"===a?this.completion&&(c.completion="Completed"):c.completion=this.completion),c}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.Score=function(a){this.log("constructor"),this.scaled=null,this.raw=null,this.min=null,this.max=null,this.init(a)};a.prototype={LOG_SRC:"Score",log:e.prototype.log,init:function(a){this.log("init");var b,c=["scaled","raw","min","max"];for(a=a||{},b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]])},asVersion:function(a){this.log("asVersion");var b,c={},d=["scaled","raw","min","max"];for(a=a||e.versions()[0],b=0;b<d.length;b+=1)null!==this[d[b]]&&(c[d[b]]=this[d[b]]);return c}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.InteractionComponent=function(a){this.log("constructor"),this.id=null,this.description=null,this.init(a)};a.prototype={LOG_SRC:"InteractionComponent",log:e.prototype.log,init:function(a){this.log("init");var b,c=["id","description"];for(a=a||{},b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]])},asVersion:function(a){this.log("asVersion");var b,c,d={id:this.id},f=["description"];for(a=a||e.versions()[0],b=0;b<f.length;b+=1)c=f[b],null!==this[c]&&(d[c]=this[c]);return d},getLangDictionaryValue:e.Utils.getLangDictionaryValue},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a={"http://adlnet.gov/expapi/activities/course":"course","http://adlnet.gov/expapi/activities/module":"module","http://adlnet.gov/expapi/activities/meeting":"meeting","http://adlnet.gov/expapi/activities/media":"media","http://adlnet.gov/expapi/activities/performance":"performance","http://adlnet.gov/expapi/activities/simulation":"simulation","http://adlnet.gov/expapi/activities/assessment":"assessment","http://adlnet.gov/expapi/activities/interaction":"interaction","http://adlnet.gov/expapi/activities/cmi.interaction":"cmi.interaction","http://adlnet.gov/expapi/activities/question":"question","http://adlnet.gov/expapi/activities/objective":"objective","http://adlnet.gov/expapi/activities/link":"link"},b=e.ActivityDefinition=function(a){this.log("constructor"),this.name=null,this.description=null,this.type=null,this.moreInfo=null,this.extensions=null,this.interactionType=null,this.correctResponsesPattern=null,this.choices=null,this.scale=null,this.source=null,this.target=null,this.steps=null,this.init(a)};b.prototype={LOG_SRC:"ActivityDefinition",log:e.prototype.log,init:function(b){this.log("init");var c,d,f,g=["name","description","moreInfo","extensions","correctResponsesPattern"],h=[];if(b=b||{},b.hasOwnProperty("type")&&null!==b.type){for(f in a)a.hasOwnProperty(f)&&a[f]===b.type&&(b.type=a[f]);this.type=b.type}if(b.hasOwnProperty("interactionType")&&null!==b.interactionType&&(this.interactionType=b.interactionType,"choice"===b.interactionType||"sequencing"===b.interactionType?h.push("choices"):"likert"===b.interactionType?h.push("scale"):"matching"===b.interactionType?(h.push("source"),h.push("target")):"performance"===b.interactionType&&h.push("steps"),h.length>0))for(c=0;c<h.length;c+=1)if(f=h[c],b.hasOwnProperty(f)&&null!==b[f])for(this[f]=[],d=0;d<b[f].length;d+=1)b[f][d]instanceof e.InteractionComponent?this[f].push(b[f][d]):this[f].push(new e.InteractionComponent(b[f][d]));for(c=0;c<g.length;c+=1)b.hasOwnProperty(g[c])&&null!==b[g[c]]&&(this[g[c]]=b[g[c]])},toString:function(a){return this.log("toString"),null!==this.name?this.getLangDictionaryValue("name",a):null!==this.description?this.getLangDictionaryValue("description",a):""},asVersion:function(b){this.log("asVersion");var c,d,f,g={},h=["name","description","interactionType","correctResponsesPattern","extensions"],i=["choices","scale","source","target","steps"];for(b=b||e.versions()[0],null!==this.type&&("0.9"===b?g.type=a[this.type]:g.type=this.type),c=0;c<h.length;c+=1)f=h[c],null!==this[f]&&(g[f]=this[f]);for(c=0;c<i.length;c+=1)if(f=i[c],null!==this[f])for(g[f]=[],d=0;d<this[f].length;d+=1)g[f].push(this[f][d].asVersion(b));return 0!==b.indexOf("0.9")&&null!==this.moreInfo&&(g.moreInfo=this.moreInfo),g},getLangDictionaryValue:e.Utils.getLangDictionaryValue},b.fromJSON=function(a){b.prototype.log("fromJSON");var c=JSON.parse(a);return new b(c)}}(),function(){"use strict";var a=e.Activity=function(a){this.log("constructor"),this.objectType="Activity",this.id=null,this.definition=null,this.init(a)};a.prototype={LOG_SRC:"Activity",log:e.prototype.log,init:function(a){this.log("init");var b,c=["id"];for(a=a||{},a.hasOwnProperty("definition")&&(a.definition instanceof e.ActivityDefinition?this.definition=a.definition:this.definition=new e.ActivityDefinition(a.definition)),b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]])},toString:function(a){this.log("toString");var b="";return null!==this.definition&&(b=this.definition.toString(a),""!==b)?b:null!==this.id?this.id:"Activity: unidentified"},asVersion:function(a){this.log("asVersion");var b={id:this.id,objectType:this.objectType};return a=a||e.versions()[0],null!==this.definition&&(b.definition=this.definition.asVersion(a)),b}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.ContextActivities=function(a){this.log("constructor"),this.category=null,this.parent=null,this.grouping=null,this.other=null,this.init(a)};a.prototype={LOG_SRC:"ContextActivities",log:e.prototype.log,init:function(a){this.log("init");var b,c,d,e,f=["category","parent","grouping","other"];for(a=a||{},b=0;b<f.length;b+=1)if(d=f[b],a.hasOwnProperty(d)&&null!==a[d])if("[object Array]"===Object.prototype.toString.call(a[d]))for(c=0;c<a[d].length;c+=1)this.add(d,a[d][c]);else e=a[d],this.add(d,e)},add:function(a,b){if("category"===a||"parent"===a||"grouping"===a||"other"===a)return null===this[a]&&(this[a]=[]),b instanceof e.Activity||(b="string"==typeof b?{id:b}:b,b=new e.Activity(b)),this[a].push(b),this[a].length-1},asVersion:function(a){this.log("asVersion");var b,c,d={},f=["parent","grouping","other"];for(a=a||e.versions()[0],b=0;b<f.length;b+=1)if(null!==this[f[b]]&&this[f[b]].length>0)if("0.9"===a||"0.95"===a)this[f[b]].length>1&&this.log("[warning] version does not support multiple values in: "+f[b]),d[f[b]]=this[f[b]][0].asVersion(a);else for(d[f[b]]=[],c=0;c<this[f[b]].length;c+=1)d[f[b]].push(this[f[b]][c].asVersion(a));if(null!==this.category&&this.category.length>0){if("0.9"===a||"0.95"===a)throw this.log("[error] version does not support the 'category' property: "+a),new Error(a+" does not support the 'category' property");for(d.category=[],b=0;b<this.category.length;b+=1)d.category.push(this.category[b].asVersion(a))}return d}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.Context=function(a){this.log("constructor"),this.registration=null,this.instructor=null,this.team=null,this.contextActivities=null,this.revision=null,this.platform=null,this.language=null,this.statement=null,this.extensions=null,this.init(a)};a.prototype={LOG_SRC:"Context",log:e.prototype.log,init:function(a){this.log("init");var b,c,d,f=["registration","revision","platform","language","extensions"],g=["instructor","team"];for(a=a||{},b=0;b<f.length;b+=1)c=f[b],a.hasOwnProperty(c)&&null!==a[c]&&(this[c]=a[c]);for(b=0;b<g.length;b+=1)c=g[b],a.hasOwnProperty(c)&&null!==a[c]&&(d=a[c],"undefined"!=typeof d.objectType&&"Person"!==d.objectType||(d.objectType="Agent"),"Agent"!==d.objectType||d instanceof e.Agent?"Group"!==d.objectType||d instanceof e.Group||(d=new e.Group(d)):d=new e.Agent(d),this[c]=d);a.hasOwnProperty("contextActivities")&&null!==a.contextActivities&&(a.contextActivities instanceof e.ContextActivities?this.contextActivities=a.contextActivities:this.contextActivities=new e.ContextActivities(a.contextActivities)),a.hasOwnProperty("statement")&&null!==a.statement&&(a.statement instanceof e.StatementRef?this.statement=a.statement:a.statement instanceof e.SubStatement?this.statement=a.statement:"StatementRef"===a.statement.objectType?this.statement=new e.StatementRef(a.statement):"SubStatement"===a.statement.objectType?this.statement=new e.SubStatement(a.statement):this.log("Unable to parse statement.context.statement property."))},asVersion:function(a){this.log("asVersion");var b,c={},d=["registration","revision","platform","language","extensions"],f=["instructor","team","contextActivities","statement"];if(a=a||e.versions()[0],this.statement instanceof e.SubStatement&&"0.9"!==a&&"0.95"!==a)throw this.log("[error] version does not support SubStatements in the 'statement' property: "+a),new Error(a+" does not support SubStatements in the 'statement' property");for(b=0;b<d.length;b+=1)null!==this[d[b]]&&(c[d[b]]=this[d[b]]);for(b=0;b<f.length;b+=1)null!==this[f[b]]&&(c[f[b]]=this[f[b]].asVersion(a));return c}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.StatementRef=function(a){this.log("constructor"),this.id=null,this.init(a)};a.prototype={objectType:"StatementRef",LOG_SRC:"StatementRef",log:e.prototype.log,init:function(a){this.log("init");var b,c=["id"];for(a=a||{},b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]])},toString:function(){return this.log("toString"),this.id},asVersion:function(a){this.log("asVersion");var b={objectType:this.objectType,id:this.id};return"0.9"===a&&(b.objectType="Statement"),b}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.SubStatement=function(a){this.log("constructor"),this.actor=null,this.verb=null,this.target=null,this.result=null,this.context=null,this.timestamp=null,this.init(a)};a.prototype={objectType:"SubStatement",LOG_SRC:"SubStatement",log:e.prototype.log,init:function(a){this.log("init");var b,c=["timestamp"];for(a=a||{},a.hasOwnProperty("object")&&(a.target=a.object),a.hasOwnProperty("actor")&&("undefined"!=typeof a.actor.objectType&&"Person"!==a.actor.objectType||(a.actor.objectType="Agent"),"Agent"===a.actor.objectType?a.actor instanceof e.Agent?this.actor=a.actor:this.actor=new e.Agent(a.actor):"Group"===a.actor.objectType&&(a.actor instanceof e.Group?this.actor=a.actor:this.actor=new e.Group(a.actor))),a.hasOwnProperty("verb")&&(a.verb instanceof e.Verb?this.verb=a.verb:this.verb=new e.Verb(a.verb)),a.hasOwnProperty("target")&&(a.target instanceof e.Activity||a.target instanceof e.Agent||a.target instanceof e.Group||a.target instanceof e.SubStatement||a.target instanceof e.StatementRef?this.target=a.target:("undefined"==typeof a.target.objectType&&(a.target.objectType="Activity"),"Activity"===a.target.objectType?this.target=new e.Activity(a.target):"Agent"===a.target.objectType?this.target=new e.Agent(a.target):"Group"===a.target.objectType?this.target=new e.Group(a.target):"SubStatement"===a.target.objectType?this.target=new e.SubStatement(a.target):"StatementRef"===a.target.objectType?this.target=new e.StatementRef(a.target):this.log("Unrecognized target type: "+a.target.objectType))),a.hasOwnProperty("result")&&(a.result instanceof e.Result?this.result=a.result:this.result=new e.Result(a.result)),a.hasOwnProperty("context")&&(a.context instanceof e.Context?this.context=a.context:this.context=new e.Context(a.context)),b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]])},toString:function(a){return this.log("toString"),(null!==this.actor?this.actor.toString(a):"")+" "+(null!==this.verb?this.verb.toString(a):"")+" "+(null!==this.target?this.target.toString(a):"")},asVersion:function(a){this.log("asVersion");var b,c,d=["timestamp"],f=["actor","verb","result","context"];for(b={objectType:this.objectType},a=a||e.versions()[0],c=0;c<d.length;c+=1)null!==this[d[c]]&&(b[d[c]]=this[d[c]]);for(c=0;c<f.length;c+=1)null!==this[f[c]]&&(b[f[c]]=this[f[c]].asVersion(a));return null!==this.target&&(b.object=this.target.asVersion(a)),"0.9"===a&&(b.objectType="Statement"),b}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.Statement=function(a,b){this.log("constructor"),b="number"==typeof b?{storeOriginal:b}:b||{},"undefined"==typeof b.storeOriginal&&(b.storeOriginal=null),"undefined"==typeof b.doStamp&&(b.doStamp=!0),this.id=null,this.actor=null,this.verb=null,this.target=null,this.result=null,this.context=null,this.timestamp=null,this.stored=null,this.authority=null,this.attachments=null,this.version=null,this.degraded=!1,this.voided=null,this.inProgress=null,this.originalJSON=null,this.init(a,b)};a.prototype={LOG_SRC:"Statement",log:e.prototype.log,init:function(a,b){this.log("init");var c,d=["id","stored","timestamp","version","inProgress","voided"];if(a=a||{},b.storeOriginal&&(this.originalJSON=JSON.stringify(a,null,b.storeOriginal)),a.hasOwnProperty("object")&&(a.target=a.object),a.hasOwnProperty("actor")&&("undefined"!=typeof a.actor.objectType&&"Person"!==a.actor.objectType||(a.actor.objectType="Agent"),"Agent"===a.actor.objectType?a.actor instanceof e.Agent?this.actor=a.actor:this.actor=new e.Agent(a.actor):"Group"===a.actor.objectType&&(a.actor instanceof e.Group?this.actor=a.actor:this.actor=new e.Group(a.actor))),a.hasOwnProperty("authority")&&("undefined"!=typeof a.authority.objectType&&"Person"!==a.authority.objectType||(a.authority.objectType="Agent"),"Agent"===a.authority.objectType?a.authority instanceof e.Agent?this.authority=a.authority:this.authority=new e.Agent(a.authority):"Group"===a.authority.objectType&&(a.actor instanceof e.Group?this.authority=a.authority:this.authority=new e.Group(a.authority))),a.hasOwnProperty("verb")&&(a.verb instanceof e.Verb?this.verb=a.verb:this.verb=new e.Verb(a.verb)),a.hasOwnProperty("target")&&(a.target instanceof e.Activity||a.target instanceof e.Agent||a.target instanceof e.Group||a.target instanceof e.SubStatement||a.target instanceof e.StatementRef?this.target=a.target:("undefined"==typeof a.target.objectType&&(a.target.objectType="Activity"),"Activity"===a.target.objectType?this.target=new e.Activity(a.target):"Agent"===a.target.objectType?this.target=new e.Agent(a.target):"Group"===a.target.objectType?this.target=new e.Group(a.target):"SubStatement"===a.target.objectType?this.target=new e.SubStatement(a.target):"StatementRef"===a.target.objectType?this.target=new e.StatementRef(a.target):this.log("Unrecognized target type: "+a.target.objectType))),a.hasOwnProperty("result")&&(a.result instanceof e.Result?this.result=a.result:this.result=new e.Result(a.result)),a.hasOwnProperty("context")&&(a.context instanceof e.Context?this.context=a.context:this.context=new e.Context(a.context)),a.hasOwnProperty("attachments")&&null!==a.attachments)for(this.attachments=[],c=0;c<a.attachments.length;c+=1)a.attachments[c]instanceof e.Attachment?this.attachments.push(a.attachments[c]):this.attachments.push(new e.Attachment(a.attachments[c]));for(c=0;c<d.length;c+=1)a.hasOwnProperty(d[c])&&null!==a[d[c]]&&(this[d[c]]=a[d[c]]);b.doStamp&&this.stamp()},toString:function(a){return this.log("toString"),(null!==this.actor?this.actor.toString(a):"")+" "+(null!==this.verb?this.verb.toString(a):"")+" "+(null!==this.target?this.target.toString(a):"")},asVersion:function(a){this.log("asVersion");var b,c={},d=["id","timestamp"],f=["actor","verb","result","context","authority"];for(a=a||e.versions()[0],b=0;b<d.length;b+=1)null!==this[d[b]]&&(c[d[b]]=this[d[b]]);for(b=0;b<f.length;b+=1)null!==this[f[b]]&&(c[f[b]]=this[f[b]].asVersion(a));if(null!==this.target&&(c.object=this.target.asVersion(a)),"0.9"!==a&&"0.95"!==a||null!==this.voided&&(c.voided=this.voided),"0.9"===a&&null!==this.inProgress&&(c.inProgress=this.inProgress),null!==this.attachments&&"0.9"!==a&&"0.95"!==a)for(c.attachments=[],b=0;b<this.attachments.length;b+=1)this.attachments[b]instanceof e.Attachment?c.attachments.push(this.attachments[b].asVersion(a)):c.attachments.push(new e.Attachment(this.attachments[b]).asVersion(a));return c},stamp:function(){this.log("stamp"),null===this.id&&(this.id=e.Utils.getUUID()),null===this.timestamp&&(this.timestamp=e.Utils.getISODateString(new Date))},hasAttachmentWithContent:function(){this.log("hasAttachmentWithContent");var a;if(null===this.attachments)return!1;for(a=0;a<this.attachments.length;a+=1)if(null!==this.attachments[a].content)return!0;return!1}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.StatementsResult=function(a){this.log("constructor"),this.statements=null,this.more=null,this.init(a)};a.prototype={LOG_SRC:"StatementsResult",log:e.prototype.log,init:function(a){this.log("init"),a=a||{},a.hasOwnProperty("statements")&&(this.statements=a.statements),a.hasOwnProperty("more")&&(this.more=a.more)}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c,d,f,g=[];try{c=JSON.parse(b)}catch(h){a.prototype.log("fromJSON - JSON.parse error: "+h)}if(c){for(f=0;f<c.statements.length;f+=1){try{d=new e.Statement(c.statements[f],4)}catch(i){a.prototype.log("fromJSON - statement instantiation failed: "+i+" ("+JSON.stringify(c.statements[f])+")"),d=new e.Statement({id:c.statements[f].id},4)}g.push(d)}c.statements=g}return new a(c)}}(),function(){"use strict";var a=e.State=function(a){this.log("constructor"),this.id=null,this.updated=null,this.contents=null,this.etag=null,this.contentType=null,this.init(a)};a.prototype={LOG_SRC:"State",log:e.prototype.log,init:function(a){this.log("init");var b,c=["id","contents","etag","contentType"];for(a=a||{},b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]]);this.updated=!1}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.ActivityProfile=function(a){this.log("constructor"),this.id=null,this.activity=null,this.updated=null,this.contents=null,this.etag=null,this.contentType=null,this.init(a)};a.prototype={LOG_SRC:"ActivityProfile",log:e.prototype.log,init:function(a){this.log("init");var b,c=["id","contents","etag","contentType"];for(a=a||{},a.hasOwnProperty("activity")&&(a.activity instanceof e.Activity?this.activity=a.activity:this.activity=new e.Activity(a.activity)),b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]]);this.updated=!1}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.AgentProfile=function(a){this.log("constructor"),this.id=null,this.agent=null,this.updated=null,this.contents=null,this.etag=null,this.contentType=null,this.init(a)};a.prototype={LOG_SRC:"AgentProfile",log:e.prototype.log,init:function(a){this.log("init");var b,c=["id","contents","etag","contentType"];for(a=a||{},a.hasOwnProperty("agent")&&(a.agent instanceof e.Agent?this.agent=a.agent:this.agent=new e.Agent(a.agent)),
20
+ b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]]);this.updated=!1}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.About=function(a){this.log("constructor"),this.version=null,this.init(a)};a.prototype={LOG_SRC:"About",log:e.prototype.log,init:function(a){this.log("init");var b,c=["version"];for(a=a||{},b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]])}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)}}(),function(){"use strict";var a=e.Attachment=function(a){this.log("constructor"),this.usageType=null,this.display=null,this.contentType=null,this.length=null,this.sha2=null,this.description=null,this.fileUrl=null,this.content=null,this.init(a)};a.prototype={LOG_SRC:"Attachment",log:e.prototype.log,init:function(a){this.log("init");var b,c=["contentType","length","sha2","usageType","display","description","fileUrl"];for(a=a||{},b=0;b<c.length;b+=1)a.hasOwnProperty(c[b])&&null!==a[c[b]]&&(this[c[b]]=a[c[b]]);a.hasOwnProperty("content")&&null!==a.content&&("string"==typeof a.content?this.setContentFromString(a.content):this.setContent(a.content))},asVersion:function(a){this.log("asVersion");var b;return a=a||e.versions()[0],"0.9"===a||"0.95"===a?b=null:(b={contentType:this.contentType,display:this.display,length:this.length,sha2:this.sha2,usageType:this.usageType},null!==this.fileUrl&&(b.fileUrl=this.fileUrl),null!==this.description&&(b.description=this.description)),b},getLangDictionaryValue:e.Utils.getLangDictionaryValue,setContent:function(a){this.content=a,this.length=a.byteLength,this.sha2=e.Utils.getSHA256String(a)},setContentFromString:function(a){var b=a;b=e.Utils.stringToArrayBuffer(a),this.setContent(b)},getContentAsString:function(){return e.Utils.stringFromArrayBuffer(this.content)}},a.fromJSON=function(b){a.prototype.log("fromJSON");var c=JSON.parse(b);return new a(c)},a._defaultEncoding="utf-8"}(),function(){"use strict";var b,d,f,g="Environment.Node",h=e.prototype.log,i=a("querystring"),j=a("xhr2");b=function(a,b){h("requestComplete - xhr.status: "+a.status,g),h("requestComplete - xhr.responseText: "+a.responseText,g);var c,d=a.status,e=b.ignore404&&404===d;return d>=200&&d<400||e?b.callback?void b.callback(null,a):c={err:null,xhr:a}:(c={err:d,xhr:a},0===d?h("[warning] There was a problem communicating with the Learning Record Store. Aborted, offline, or invalid CORS endpoint ("+d+")",g):h("[warning] There was a problem communicating with the Learning Record Store. ("+d+" | "+a.responseText+")",g),b.callback&&b.callback(d,a),c)},e.LRS.prototype._initByEnvironment=function(){},e.LRS.prototype._makeRequest=function(a,c,d){h("_makeRequest using http/https",g);var e,f,k=a,l="undefined"!=typeof d.callback;"undefined"!=typeof d.params&&Object.keys(d.params).length>0&&(k+="?"+i.stringify(d.params)),e=new j,e.open(d.method,k,l),d.expectMultipart&&(e.responseType="arraybuffer");for(f in c)c.hasOwnProperty(f)&&e.setRequestHeader(f,c[f]);return"undefined"!=typeof d.data&&(d.data+=""),l&&(e.onreadystatechange=function(){h("xhr.onreadystatechange - xhr.readyState: "+e.readyState,g),4===e.readyState&&b(e,d)}),e.send(d.data),l?e:b(e,d)},e.LRS.syncEnabled=!1,e.LRS.prototype._getMultipartRequestData=function(a,b,e){var g,h=[];for(h.push(d(a,b)),g=0;g<e.length;g+=1)null!==e[g].content&&h.push(f(a,e[g].content,e[g].sha2,e[g].contentType));return"undefined"==typeof c.from?h.push(new c("\r\n--"+a+"--\r\n")):h.push(c.from("\r\n--"+a+"--\r\n")),c.concat(h)},d=function(a,b){var d=["--"+a,"Content-Type: application/json","",JSON.stringify(b)].join("\r\n");return d+="\r\n","undefined"==typeof c.from?new c(d):c.from(d)},f=function(a,b,d,e){var f=[],g=["--"+a,"Content-Type: "+e,"Content-Transfer-Encoding: binary","X-Experience-API-Hash: "+d].join("\r\n");return g+="\r\n\r\n","undefined"==typeof c.from?(f.push(new c(g)),f.push(new c(b))):(f.push(c.from(g)),f.push(c.from(b))),c.concat(f)},e.Utils.stringToArrayBuffer=function(a,b){var d,f,g,h;if(b||(b=e.Utils.defaultEncoding),"undefined"==typeof c.from){for(d=new c(a,b),f=new ArrayBuffer(d.length),g=new Uint8Array(f),h=0;h<d.length;h+=1)g[h]=d[h];return f}return d=c.from(a,b),f=d.buffer,f.slice(d.byteOffset,d.byteOffset+d.byteLength)},e.Utils.stringFromArrayBuffer=function(a,b){var d,f,g;if(b||(b=e.Utils.defaultEncoding),"undefined"==typeof c.from)for(d=new c(a.byteLength),f=new Uint8Array(a),g=0;g<d.length;g+=1)d[g]=f[g];else d=c.from(a);return d.toString(b)}}()}).call(this,a("buffer").Buffer)},{buffer:45,querystring:93,xhr2:142}],136:[function(a,b,c){function d(a,b){var c=[];b=b||0;for(var d=b||0;d<a.length;d++)c[d-b]=a[d];return c}b.exports=d},{}],137:[function(b,c,d){(function(){function b(a){function b(b,c,d,e,f,g){for(;f>=0&&f<g;f+=a){var h=e?e[f]:f;d=c(d,b[h],h,b)}return d}return function(c,d,e,f){d=w(d,f,4);var g=!D(c)&&v.keys(c),h=(g||c).length,i=a>0?0:h-1;return arguments.length<3&&(e=c[g?g[i]:i],i+=a),b(c,d,e,g,i,h)}}function e(a){return function(b,c,d){c=x(c,d);for(var e=C(b),f=a>0?0:e-1;f>=0&&f<e;f+=a)if(c(b[f],f,b))return f;return-1}}function f(a,b,c){return function(d,e,f){var g=0,h=C(d);if("number"==typeof f)a>0?g=f>=0?f:Math.max(f+h,g):h=f>=0?Math.min(f+1,h):f+h+1;else if(c&&f&&h)return f=c(d,e),d[f]===e?f:-1;if(e!==e)return f=b(n.call(d,g,h),v.isNaN),f>=0?f+g:-1;for(f=a>0?g:h-1;f>=0&&f<h;f+=a)if(d[f]===e)return f;return-1}}function g(a,b){var c=I.length,d=a.constructor,e=v.isFunction(d)&&d.prototype||k,f="constructor";for(v.has(a,f)&&!v.contains(b,f)&&b.push(f);c--;)f=I[c],f in a&&a[f]!==e[f]&&!v.contains(b,f)&&b.push(f)}var h=this,i=h._,j=Array.prototype,k=Object.prototype,l=Function.prototype,m=j.push,n=j.slice,o=k.toString,p=k.hasOwnProperty,q=Array.isArray,r=Object.keys,s=l.bind,t=Object.create,u=function(){},v=function(a){return a instanceof v?a:this instanceof v?void(this._wrapped=a):new v(a)};"undefined"!=typeof d?("undefined"!=typeof c&&c.exports&&(d=c.exports=v),d._=v):h._=v,v.VERSION="1.8.3";var w=function(a,b,c){if(void 0===b)return a;switch(null==c?3:c){case 1:return function(c){return a.call(b,c)};case 2:return function(c,d){return a.call(b,c,d)};case 3:return function(c,d,e){return a.call(b,c,d,e)};case 4:return function(c,d,e,f){return a.call(b,c,d,e,f)}}return function(){return a.apply(b,arguments)}},x=function(a,b,c){return null==a?v.identity:v.isFunction(a)?w(a,b,c):v.isObject(a)?v.matcher(a):v.property(a)};v.iteratee=function(a,b){return x(a,b,1/0)};var y=function(a,b){return function(c){var d=arguments.length;if(d<2||null==c)return c;for(var e=1;e<d;e++)for(var f=arguments[e],g=a(f),h=g.length,i=0;i<h;i++){var j=g[i];b&&void 0!==c[j]||(c[j]=f[j])}return c}},z=function(a){if(!v.isObject(a))return{};if(t)return t(a);u.prototype=a;var b=new u;return u.prototype=null,b},A=function(a){return function(b){return null==b?void 0:b[a]}},B=Math.pow(2,53)-1,C=A("length"),D=function(a){var b=C(a);return"number"==typeof b&&b>=0&&b<=B};v.each=v.forEach=function(a,b,c){b=w(b,c);var d,e;if(D(a))for(d=0,e=a.length;d<e;d++)b(a[d],d,a);else{var f=v.keys(a);for(d=0,e=f.length;d<e;d++)b(a[f[d]],f[d],a)}return a},v.map=v.collect=function(a,b,c){b=x(b,c);for(var d=!D(a)&&v.keys(a),e=(d||a).length,f=Array(e),g=0;g<e;g++){var h=d?d[g]:g;f[g]=b(a[h],h,a)}return f},v.reduce=v.foldl=v.inject=b(1),v.reduceRight=v.foldr=b(-1),v.find=v.detect=function(a,b,c){var d;if(d=D(a)?v.findIndex(a,b,c):v.findKey(a,b,c),void 0!==d&&d!==-1)return a[d]},v.filter=v.select=function(a,b,c){var d=[];return b=x(b,c),v.each(a,function(a,c,e){b(a,c,e)&&d.push(a)}),d},v.reject=function(a,b,c){return v.filter(a,v.negate(x(b)),c)},v.every=v.all=function(a,b,c){b=x(b,c);for(var d=!D(a)&&v.keys(a),e=(d||a).length,f=0;f<e;f++){var g=d?d[f]:f;if(!b(a[g],g,a))return!1}return!0},v.some=v.any=function(a,b,c){b=x(b,c);for(var d=!D(a)&&v.keys(a),e=(d||a).length,f=0;f<e;f++){var g=d?d[f]:f;if(b(a[g],g,a))return!0}return!1},v.contains=v.includes=v.include=function(a,b,c,d){return D(a)||(a=v.values(a)),("number"!=typeof c||d)&&(c=0),v.indexOf(a,b,c)>=0},v.invoke=function(a,b){var c=n.call(arguments,2),d=v.isFunction(b);return v.map(a,function(a){var e=d?b:a[b];return null==e?e:e.apply(a,c)})},v.pluck=function(a,b){return v.map(a,v.property(b))},v.where=function(a,b){return v.filter(a,v.matcher(b))},v.findWhere=function(a,b){return v.find(a,v.matcher(b))},v.max=function(a,b,c){var d,e,f=-(1/0),g=-(1/0);if(null==b&&null!=a){a=D(a)?a:v.values(a);for(var h=0,i=a.length;h<i;h++)d=a[h],d>f&&(f=d)}else b=x(b,c),v.each(a,function(a,c,d){e=b(a,c,d),(e>g||e===-(1/0)&&f===-(1/0))&&(f=a,g=e)});return f},v.min=function(a,b,c){var d,e,f=1/0,g=1/0;if(null==b&&null!=a){a=D(a)?a:v.values(a);for(var h=0,i=a.length;h<i;h++)d=a[h],d<f&&(f=d)}else b=x(b,c),v.each(a,function(a,c,d){e=b(a,c,d),(e<g||e===1/0&&f===1/0)&&(f=a,g=e)});return f},v.shuffle=function(a){for(var b,c=D(a)?a:v.values(a),d=c.length,e=Array(d),f=0;f<d;f++)b=v.random(0,f),b!==f&&(e[f]=e[b]),e[b]=c[f];return e},v.sample=function(a,b,c){return null==b||c?(D(a)||(a=v.values(a)),a[v.random(a.length-1)]):v.shuffle(a).slice(0,Math.max(0,b))},v.sortBy=function(a,b,c){return b=x(b,c),v.pluck(v.map(a,function(a,c,d){return{value:a,index:c,criteria:b(a,c,d)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;if(c!==d){if(c>d||void 0===c)return 1;if(c<d||void 0===d)return-1}return a.index-b.index}),"value")};var E=function(a){return function(b,c,d){var e={};return c=x(c,d),v.each(b,function(d,f){var g=c(d,f,b);a(e,d,g)}),e}};v.groupBy=E(function(a,b,c){v.has(a,c)?a[c].push(b):a[c]=[b]}),v.indexBy=E(function(a,b,c){a[c]=b}),v.countBy=E(function(a,b,c){v.has(a,c)?a[c]++:a[c]=1}),v.toArray=function(a){return a?v.isArray(a)?n.call(a):D(a)?v.map(a,v.identity):v.values(a):[]},v.size=function(a){return null==a?0:D(a)?a.length:v.keys(a).length},v.partition=function(a,b,c){b=x(b,c);var d=[],e=[];return v.each(a,function(a,c,f){(b(a,c,f)?d:e).push(a)}),[d,e]},v.first=v.head=v.take=function(a,b,c){if(null!=a)return null==b||c?a[0]:v.initial(a,a.length-b)},v.initial=function(a,b,c){return n.call(a,0,Math.max(0,a.length-(null==b||c?1:b)))},v.last=function(a,b,c){if(null!=a)return null==b||c?a[a.length-1]:v.rest(a,Math.max(0,a.length-b))},v.rest=v.tail=v.drop=function(a,b,c){return n.call(a,null==b||c?1:b)},v.compact=function(a){return v.filter(a,v.identity)};var F=function(a,b,c,d){for(var e=[],f=0,g=d||0,h=C(a);g<h;g++){var i=a[g];if(D(i)&&(v.isArray(i)||v.isArguments(i))){b||(i=F(i,b,c));var j=0,k=i.length;for(e.length+=k;j<k;)e[f++]=i[j++]}else c||(e[f++]=i)}return e};v.flatten=function(a,b){return F(a,b,!1)},v.without=function(a){return v.difference(a,n.call(arguments,1))},v.uniq=v.unique=function(a,b,c,d){v.isBoolean(b)||(d=c,c=b,b=!1),null!=c&&(c=x(c,d));for(var e=[],f=[],g=0,h=C(a);g<h;g++){var i=a[g],j=c?c(i,g,a):i;b?(g&&f===j||e.push(i),f=j):c?v.contains(f,j)||(f.push(j),e.push(i)):v.contains(e,i)||e.push(i)}return e},v.union=function(){return v.uniq(F(arguments,!0,!0))},v.intersection=function(a){for(var b=[],c=arguments.length,d=0,e=C(a);d<e;d++){var f=a[d];if(!v.contains(b,f)){for(var g=1;g<c&&v.contains(arguments[g],f);g++);g===c&&b.push(f)}}return b},v.difference=function(a){var b=F(arguments,!0,!0,1);return v.filter(a,function(a){return!v.contains(b,a)})},v.zip=function(){return v.unzip(arguments)},v.unzip=function(a){for(var b=a&&v.max(a,C).length||0,c=Array(b),d=0;d<b;d++)c[d]=v.pluck(a,d);return c},v.object=function(a,b){for(var c={},d=0,e=C(a);d<e;d++)b?c[a[d]]=b[d]:c[a[d][0]]=a[d][1];return c},v.findIndex=e(1),v.findLastIndex=e(-1),v.sortedIndex=function(a,b,c,d){c=x(c,d,1);for(var e=c(b),f=0,g=C(a);f<g;){var h=Math.floor((f+g)/2);c(a[h])<e?f=h+1:g=h}return f},v.indexOf=f(1,v.findIndex,v.sortedIndex),v.lastIndexOf=f(-1,v.findLastIndex),v.range=function(a,b,c){null==b&&(b=a||0,a=0),c=c||1;for(var d=Math.max(Math.ceil((b-a)/c),0),e=Array(d),f=0;f<d;f++,a+=c)e[f]=a;return e};var G=function(a,b,c,d,e){if(!(d instanceof b))return a.apply(c,e);var f=z(a.prototype),g=a.apply(f,e);return v.isObject(g)?g:f};v.bind=function(a,b){if(s&&a.bind===s)return s.apply(a,n.call(arguments,1));if(!v.isFunction(a))throw new TypeError("Bind must be called on a function");var c=n.call(arguments,2),d=function(){return G(a,d,b,this,c.concat(n.call(arguments)))};return d},v.partial=function(a){var b=n.call(arguments,1),c=function(){for(var d=0,e=b.length,f=Array(e),g=0;g<e;g++)f[g]=b[g]===v?arguments[d++]:b[g];for(;d<arguments.length;)f.push(arguments[d++]);return G(a,c,this,this,f)};return c},v.bindAll=function(a){var b,c,d=arguments.length;if(d<=1)throw new Error("bindAll must be passed function names");for(b=1;b<d;b++)c=arguments[b],a[c]=v.bind(a[c],a);return a},v.memoize=function(a,b){var c=function(d){var e=c.cache,f=""+(b?b.apply(this,arguments):d);return v.has(e,f)||(e[f]=a.apply(this,arguments)),e[f]};return c.cache={},c},v.delay=function(a,b){var c=n.call(arguments,2);return setTimeout(function(){return a.apply(null,c)},b)},v.defer=v.partial(v.delay,v,1),v.throttle=function(a,b,c){var d,e,f,g=null,h=0;c||(c={});var i=function(){h=c.leading===!1?0:v.now(),g=null,f=a.apply(d,e),g||(d=e=null)};return function(){var j=v.now();h||c.leading!==!1||(h=j);var k=b-(j-h);return d=this,e=arguments,k<=0||k>b?(g&&(clearTimeout(g),g=null),h=j,f=a.apply(d,e),g||(d=e=null)):g||c.trailing===!1||(g=setTimeout(i,k)),f}},v.debounce=function(a,b,c){var d,e,f,g,h,i=function(){var j=v.now()-g;j<b&&j>=0?d=setTimeout(i,b-j):(d=null,c||(h=a.apply(f,e),d||(f=e=null)))};return function(){f=this,e=arguments,g=v.now();var j=c&&!d;return d||(d=setTimeout(i,b)),j&&(h=a.apply(f,e),f=e=null),h}},v.wrap=function(a,b){return v.partial(b,a)},v.negate=function(a){return function(){return!a.apply(this,arguments)}},v.compose=function(){var a=arguments,b=a.length-1;return function(){for(var c=b,d=a[b].apply(this,arguments);c--;)d=a[c].call(this,d);return d}},v.after=function(a,b){return function(){if(--a<1)return b.apply(this,arguments)}},v.before=function(a,b){var c;return function(){return--a>0&&(c=b.apply(this,arguments)),a<=1&&(b=null),c}},v.once=v.partial(v.before,2);var H=!{toString:null}.propertyIsEnumerable("toString"),I=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];v.keys=function(a){if(!v.isObject(a))return[];if(r)return r(a);var b=[];for(var c in a)v.has(a,c)&&b.push(c);return H&&g(a,b),b},v.allKeys=function(a){if(!v.isObject(a))return[];var b=[];for(var c in a)b.push(c);return H&&g(a,b),b},v.values=function(a){for(var b=v.keys(a),c=b.length,d=Array(c),e=0;e<c;e++)d[e]=a[b[e]];return d},v.mapObject=function(a,b,c){b=x(b,c);for(var d,e=v.keys(a),f=e.length,g={},h=0;h<f;h++)d=e[h],g[d]=b(a[d],d,a);return g},v.pairs=function(a){for(var b=v.keys(a),c=b.length,d=Array(c),e=0;e<c;e++)d[e]=[b[e],a[b[e]]];return d},v.invert=function(a){for(var b={},c=v.keys(a),d=0,e=c.length;d<e;d++)b[a[c[d]]]=c[d];return b},v.functions=v.methods=function(a){var b=[];for(var c in a)v.isFunction(a[c])&&b.push(c);return b.sort()},v.extend=y(v.allKeys),v.extendOwn=v.assign=y(v.keys),v.findKey=function(a,b,c){b=x(b,c);for(var d,e=v.keys(a),f=0,g=e.length;f<g;f++)if(d=e[f],b(a[d],d,a))return d},v.pick=function(a,b,c){var d,e,f={},g=a;if(null==g)return f;v.isFunction(b)?(e=v.allKeys(g),d=w(b,c)):(e=F(arguments,!1,!1,1),d=function(a,b,c){return b in c},g=Object(g));for(var h=0,i=e.length;h<i;h++){var j=e[h],k=g[j];d(k,j,g)&&(f[j]=k)}return f},v.omit=function(a,b,c){if(v.isFunction(b))b=v.negate(b);else{var d=v.map(F(arguments,!1,!1,1),String);b=function(a,b){return!v.contains(d,b)}}return v.pick(a,b,c)},v.defaults=y(v.allKeys,!0),v.create=function(a,b){var c=z(a);return b&&v.extendOwn(c,b),c},v.clone=function(a){return v.isObject(a)?v.isArray(a)?a.slice():v.extend({},a):a},v.tap=function(a,b){return b(a),a},v.isMatch=function(a,b){var c=v.keys(b),d=c.length;if(null==a)return!d;for(var e=Object(a),f=0;f<d;f++){var g=c[f];if(b[g]!==e[g]||!(g in e))return!1}return!0};var J=function(a,b,c,d){if(a===b)return 0!==a||1/a===1/b;if(null==a||null==b)return a===b;a instanceof v&&(a=a._wrapped),b instanceof v&&(b=b._wrapped);var e=o.call(a);if(e!==o.call(b))return!1;switch(e){case"[object RegExp]":case"[object String]":return""+a==""+b;case"[object Number]":return+a!==+a?+b!==+b:0===+a?1/+a===1/b:+a===+b;case"[object Date]":case"[object Boolean]":return+a===+b}var f="[object Array]"===e;if(!f){if("object"!=typeof a||"object"!=typeof b)return!1;var g=a.constructor,h=b.constructor;if(g!==h&&!(v.isFunction(g)&&g instanceof g&&v.isFunction(h)&&h instanceof h)&&"constructor"in a&&"constructor"in b)return!1}c=c||[],d=d||[];for(var i=c.length;i--;)if(c[i]===a)return d[i]===b;if(c.push(a),d.push(b),f){if(i=a.length,i!==b.length)return!1;for(;i--;)if(!J(a[i],b[i],c,d))return!1}else{var j,k=v.keys(a);if(i=k.length,v.keys(b).length!==i)return!1;for(;i--;)if(j=k[i],!v.has(b,j)||!J(a[j],b[j],c,d))return!1}return c.pop(),d.pop(),!0};v.isEqual=function(a,b){return J(a,b)},v.isEmpty=function(a){return null==a||(D(a)&&(v.isArray(a)||v.isString(a)||v.isArguments(a))?0===a.length:0===v.keys(a).length)},v.isElement=function(a){return!(!a||1!==a.nodeType)},v.isArray=q||function(a){return"[object Array]"===o.call(a)},v.isObject=function(a){var b=typeof a;return"function"===b||"object"===b&&!!a},v.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(a){v["is"+a]=function(b){return o.call(b)==="[object "+a+"]"}}),v.isArguments(arguments)||(v.isArguments=function(a){return v.has(a,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(v.isFunction=function(a){return"function"==typeof a||!1}),v.isFinite=function(a){return isFinite(a)&&!isNaN(parseFloat(a))},v.isNaN=function(a){return v.isNumber(a)&&a!==+a},v.isBoolean=function(a){return a===!0||a===!1||"[object Boolean]"===o.call(a)},v.isNull=function(a){return null===a},v.isUndefined=function(a){return void 0===a},v.has=function(a,b){return null!=a&&p.call(a,b)},v.noConflict=function(){return h._=i,this},v.identity=function(a){return a},v.constant=function(a){return function(){return a}},v.noop=function(){},v.property=A,v.propertyOf=function(a){return null==a?function(){}:function(b){return a[b]}},v.matcher=v.matches=function(a){return a=v.extendOwn({},a),function(b){return v.isMatch(b,a)}},v.times=function(a,b,c){var d=Array(Math.max(0,a));b=w(b,c,1);for(var e=0;e<a;e++)d[e]=b(e);return d},v.random=function(a,b){return null==b&&(b=a,a=0),a+Math.floor(Math.random()*(b-a+1))},v.now=Date.now||function(){return(new Date).getTime()};var K={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},L=v.invert(K),M=function(a){var b=function(b){return a[b]},c="(?:"+v.keys(a).join("|")+")",d=RegExp(c),e=RegExp(c,"g");return function(a){return a=null==a?"":""+a,d.test(a)?a.replace(e,b):a}};v.escape=M(K),v.unescape=M(L),v.result=function(a,b,c){var d=null==a?void 0:a[b];return void 0===d&&(d=c),v.isFunction(d)?d.call(a):d};var N=0;v.uniqueId=function(a){var b=++N+"";return a?a+b:b},v.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var O=/(.)^/,P={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},Q=/\\|'|\r|\n|\u2028|\u2029/g,R=function(a){return"\\"+P[a]};v.template=function(a,b,c){!b&&c&&(b=c),b=v.defaults({},b,v.templateSettings);var d=RegExp([(b.escape||O).source,(b.interpolate||O).source,(b.evaluate||O).source].join("|")+"|$","g"),e=0,f="__p+='";a.replace(d,function(b,c,d,g,h){return f+=a.slice(e,h).replace(Q,R),e=h+b.length,c?f+="'+\n((__t=("+c+"))==null?'':_.escape(__t))+\n'":d?f+="'+\n((__t=("+d+"))==null?'':__t)+\n'":g&&(f+="';\n"+g+"\n__p+='"),b}),f+="';\n",b.variable||(f="with(obj||{}){\n"+f+"}\n"),f="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+f+"return __p;\n";try{var g=new Function(b.variable||"obj","_",f)}catch(h){throw h.source=f,h}var i=function(a){return g.call(this,a,v)},j=b.variable||"obj";return i.source="function("+j+"){\n"+f+"}",i},v.chain=function(a){var b=v(a);return b._chain=!0,b};var S=function(a,b){return a._chain?v(b).chain():b};v.mixin=function(a){v.each(v.functions(a),function(b){var c=v[b]=a[b];v.prototype[b]=function(){var a=[this._wrapped];return m.apply(a,arguments),S(this,c.apply(v,a))}})},v.mixin(v),v.each(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=j[a];v.prototype[a]=function(){var c=this._wrapped;return b.apply(c,arguments),"shift"!==a&&"splice"!==a||0!==c.length||delete c[0],S(this,c)}}),v.each(["concat","join","slice"],function(a){var b=j[a];v.prototype[a]=function(){return S(this,b.apply(this._wrapped,arguments))}}),v.prototype.value=function(){return this._wrapped},v.prototype.valueOf=v.prototype.toJSON=v.prototype.value,v.prototype.toString=function(){return""+this._wrapped},"function"==typeof a&&a.amd&&a("underscore",[],function(){return v})}).call(this)},{}],138:[function(a,b,c){function d(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function e(a,b,c){if(a&&j(a)&&a instanceof d)return a;var e=new d;return e.parse(a,b,c),e}function f(a){return i(a)&&(a=e(a)),a instanceof d?a.format():d.prototype.format.call(a)}function g(a,b){return e(a,!1,!0).resolve(b)}function h(a,b){return a?e(a,!1,!0).resolveObject(b):b}function i(a){return"string"==typeof a}function j(a){return"object"==typeof a&&null!==a}function k(a){return null===a}function l(a){return null==a}var m=a("punycode");c.parse=e,c.resolve=g,c.resolveObject=h,c.format=f,c.Url=d;var n=/^([a-z0-9.+-]+:)/i,o=/:[0-9]*$/,p=["<",">",'"',"`"," ","\r","\n","\t"],q=["{","}","|","\\","^","`"].concat(p),r=["'"].concat(q),s=["%","/","?",";","#"].concat(r),t=["/","?","#"],u=255,v=/^[a-z0-9A-Z_-]{0,63}$/,w=/^([a-z0-9A-Z_-]{0,63})(.*)$/,x={javascript:!0,"javascript:":!0},y={javascript:!0,"javascript:":!0},z={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},A=a("querystring");d.prototype.parse=function(a,b,c){if(!i(a))throw new TypeError("Parameter 'url' must be a string, not "+typeof a);var d=a;d=d.trim();var e=n.exec(d);if(e){e=e[0];var f=e.toLowerCase();this.protocol=f,d=d.substr(e.length)}if(c||e||d.match(/^\/\/[^@\/]+@[^@\/]+/)){var g="//"===d.substr(0,2);!g||e&&y[e]||(d=d.substr(2),this.slashes=!0)}if(!y[e]&&(g||e&&!z[e])){for(var h=-1,j=0;j<t.length;j++){var k=d.indexOf(t[j]);k!==-1&&(h===-1||k<h)&&(h=k)}var l,o;o=h===-1?d.lastIndexOf("@"):d.lastIndexOf("@",h),o!==-1&&(l=d.slice(0,o),d=d.slice(o+1),this.auth=decodeURIComponent(l)),h=-1;for(var j=0;j<s.length;j++){var k=d.indexOf(s[j]);k!==-1&&(h===-1||k<h)&&(h=k)}h===-1&&(h=d.length),this.host=d.slice(0,h),d=d.slice(h),this.parseHost(),this.hostname=this.hostname||"";var p="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!p)for(var q=this.hostname.split(/\./),j=0,B=q.length;j<B;j++){var C=q[j];if(C&&!C.match(v)){for(var D="",E=0,F=C.length;E<F;E++)D+=C.charCodeAt(E)>127?"x":C[E];if(!D.match(v)){var G=q.slice(0,j),H=q.slice(j+1),I=C.match(w);I&&(G.push(I[1]),H.unshift(I[2])),H.length&&(d="/"+H.join(".")+d),this.hostname=G.join(".");break}}}if(this.hostname.length>u?this.hostname="":this.hostname=this.hostname.toLowerCase(),!p){for(var J=this.hostname.split("."),K=[],j=0;j<J.length;++j){var L=J[j];K.push(L.match(/[^A-Za-z0-9_-]/)?"xn--"+m.encode(L):L)}this.hostname=K.join(".")}var M=this.port?":"+this.port:"",N=this.hostname||"";this.host=N+M,this.href+=this.host,p&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==d[0]&&(d="/"+d))}if(!x[f])for(var j=0,B=r.length;j<B;j++){var O=r[j],P=encodeURIComponent(O);P===O&&(P=escape(O)),d=d.split(O).join(P)}var Q=d.indexOf("#");Q!==-1&&(this.hash=d.substr(Q),d=d.slice(0,Q));var R=d.indexOf("?");if(R!==-1?(this.search=d.substr(R),this.query=d.substr(R+1),b&&(this.query=A.parse(this.query)),d=d.slice(0,R)):b&&(this.search="",this.query={}),d&&(this.pathname=d),z[f]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var M=this.pathname||"",L=this.search||"";this.path=M+L}return this.href=this.format(),this},d.prototype.format=function(){var a=this.auth||"";a&&(a=encodeURIComponent(a),a=a.replace(/%3A/i,":"),a+="@");var b=this.protocol||"",c=this.pathname||"",d=this.hash||"",e=!1,f="";this.host?e=a+this.host:this.hostname&&(e=a+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(e+=":"+this.port)),this.query&&j(this.query)&&Object.keys(this.query).length&&(f=A.stringify(this.query));var g=this.search||f&&"?"+f||"";return b&&":"!==b.substr(-1)&&(b+=":"),this.slashes||(!b||z[b])&&e!==!1?(e="//"+(e||""),c&&"/"!==c.charAt(0)&&(c="/"+c)):e||(e=""),d&&"#"!==d.charAt(0)&&(d="#"+d),g&&"?"!==g.charAt(0)&&(g="?"+g),c=c.replace(/[?#]/g,function(a){return encodeURIComponent(a)}),g=g.replace("#","%23"),b+e+c+g+d},d.prototype.resolve=function(a){return this.resolveObject(e(a,!1,!0)).format()},d.prototype.resolveObject=function(a){if(i(a)){var b=new d;b.parse(a,!1,!0),a=b}var c=new d;if(Object.keys(this).forEach(function(a){c[a]=this[a]},this),c.hash=a.hash,""===a.href)return c.href=c.format(),c;if(a.slashes&&!a.protocol)return Object.keys(a).forEach(function(b){"protocol"!==b&&(c[b]=a[b])}),z[c.protocol]&&c.hostname&&!c.pathname&&(c.path=c.pathname="/"),c.href=c.format(),c;if(a.protocol&&a.protocol!==c.protocol){if(!z[a.protocol])return Object.keys(a).forEach(function(b){c[b]=a[b]}),c.href=c.format(),c;if(c.protocol=a.protocol,a.host||y[a.protocol])c.pathname=a.pathname;else{for(var e=(a.pathname||"").split("/");e.length&&!(a.host=e.shift()););a.host||(a.host=""),a.hostname||(a.hostname=""),""!==e[0]&&e.unshift(""),e.length<2&&e.unshift(""),c.pathname=e.join("/")}if(c.search=a.search,c.query=a.query,c.host=a.host||"",c.auth=a.auth,c.hostname=a.hostname||a.host,c.port=a.port,c.pathname||c.search){var f=c.pathname||"",g=c.search||"";c.path=f+g}return c.slashes=c.slashes||a.slashes,c.href=c.format(),c}var h=c.pathname&&"/"===c.pathname.charAt(0),j=a.host||a.pathname&&"/"===a.pathname.charAt(0),m=j||h||c.host&&a.pathname,n=m,o=c.pathname&&c.pathname.split("/")||[],e=a.pathname&&a.pathname.split("/")||[],p=c.protocol&&!z[c.protocol];if(p&&(c.hostname="",c.port=null,c.host&&(""===o[0]?o[0]=c.host:o.unshift(c.host)),c.host="",a.protocol&&(a.hostname=null,a.port=null,a.host&&(""===e[0]?e[0]=a.host:e.unshift(a.host)),a.host=null),m=m&&(""===e[0]||""===o[0])),j)c.host=a.host||""===a.host?a.host:c.host,c.hostname=a.hostname||""===a.hostname?a.hostname:c.hostname,c.search=a.search,c.query=a.query,o=e;else if(e.length)o||(o=[]),o.pop(),o=o.concat(e),c.search=a.search,c.query=a.query;else if(!l(a.search)){if(p){c.hostname=c.host=o.shift();var q=!!(c.host&&c.host.indexOf("@")>0)&&c.host.split("@");q&&(c.auth=q.shift(),c.host=c.hostname=q.shift())}return c.search=a.search,c.query=a.query,k(c.pathname)&&k(c.search)||(c.path=(c.pathname?c.pathname:"")+(c.search?c.search:"")),c.href=c.format(),c}if(!o.length)return c.pathname=null,c.search?c.path="/"+c.search:c.path=null,c.href=c.format(),c;for(var r=o.slice(-1)[0],s=(c.host||a.host)&&("."===r||".."===r)||""===r,t=0,u=o.length;u>=0;u--)r=o[u],"."==r?o.splice(u,1):".."===r?(o.splice(u,1),t++):t&&(o.splice(u,1),t--);if(!m&&!n)for(;t--;t)o.unshift("..");!m||""===o[0]||o[0]&&"/"===o[0].charAt(0)||o.unshift(""),s&&"/"!==o.join("/").substr(-1)&&o.push("");var v=""===o[0]||o[0]&&"/"===o[0].charAt(0);if(p){c.hostname=c.host=v?"":o.length?o.shift():"";var q=!!(c.host&&c.host.indexOf("@")>0)&&c.host.split("@");q&&(c.auth=q.shift(),c.host=c.hostname=q.shift())}return m=m||c.host&&o.length,m&&!v&&o.unshift(""),o.length?c.pathname=o.join("/"):(c.pathname=null,c.path=null),k(c.pathname)&&k(c.search)||(c.path=(c.pathname?c.pathname:"")+(c.search?c.search:"")),c.auth=a.auth||c.auth,c.slashes=c.slashes||a.slashes,c.href=c.format(),c},d.prototype.parseHost=function(){var a=this.host,b=o.exec(a);b&&(b=b[0],":"!==b&&(this.port=b.substr(1)),a=a.substr(0,a.length-b.length)),a&&(this.hostname=a)}},{punycode:89,querystring:93}],139:[function(b,c,d){(function(b){!function(e){function f(a){for(var b,c,d=[],e=0,f=a.length;e<f;)b=a.charCodeAt(e++),b>=55296&&b<=56319&&e<f?(c=a.charCodeAt(e++),56320==(64512&c)?d.push(((1023&b)<<10)+(1023&c)+65536):(d.push(b),e--)):d.push(b);return d}function g(a){for(var b,c=a.length,d=-1,e="";++d<c;)b=a[d],b>65535&&(b-=65536,e+=u(b>>>10&1023|55296),b=56320|1023&b),e+=u(b);return e}function h(a){if(a>=55296&&a<=57343)throw Error("Lone surrogate U+"+a.toString(16).toUpperCase()+" is not a scalar value")}function i(a,b){return u(a>>b&63|128)}function j(a){if(0==(4294967168&a))return u(a);var b="";return 0==(4294965248&a)?b=u(a>>6&31|192):0==(4294901760&a)?(h(a),b=u(a>>12&15|224),b+=i(a,6)):0==(4292870144&a)&&(b=u(a>>18&7|240),b+=i(a,12),b+=i(a,6)),b+=u(63&a|128)}function k(a){for(var b,c=f(a),d=c.length,e=-1,g="";++e<d;)b=c[e],g+=j(b);return g}function l(){if(t>=s)throw Error("Invalid byte index");var a=255&r[t];if(t++,128==(192&a))return 63&a;throw Error("Invalid continuation byte")}function m(){var a,b,c,d,e;if(t>s)throw Error("Invalid byte index");if(t==s)return!1;if(a=255&r[t],t++,0==(128&a))return a;if(192==(224&a)){var b=l();if(e=(31&a)<<6|b,e>=128)return e;throw Error("Invalid continuation byte")}if(224==(240&a)){if(b=l(),c=l(),e=(15&a)<<12|b<<6|c,e>=2048)return h(e),e;throw Error("Invalid continuation byte")}if(240==(248&a)&&(b=l(),c=l(),d=l(),e=(15&a)<<18|b<<12|c<<6|d,e>=65536&&e<=1114111))return e;throw Error("Invalid UTF-8 detected")}function n(a){r=f(a),s=r.length,t=0;for(var b,c=[];(b=m())!==!1;)c.push(b);return g(c)}var o="object"==typeof d&&d,p="object"==typeof c&&c&&c.exports==o&&c,q="object"==typeof b&&b;q.global!==q&&q.window!==q||(e=q);var r,s,t,u=String.fromCharCode,v={version:"2.0.0",encode:k,decode:n};if("function"==typeof a&&"object"==typeof a.amd&&a.amd)a(function(){return v});else if(o&&!o.nodeType)if(p)p.exports=v;else{var w={},x=w.hasOwnProperty;for(var y in v)x.call(v,y)&&(o[y]=v[y])}else e.utf8=v}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],140:[function(a,b,c){(function(a){function c(a,b){function c(){if(!e){if(d("throwDeprecation"))throw new Error(b);d("traceDeprecation")?console.trace(b):console.warn(b),e=!0}return a.apply(this,arguments)}if(d("noDeprecation"))return a;var e=!1;return c}function d(b){try{if(!a.localStorage)return!1}catch(c){return!1}var d=a.localStorage[b];return null!=d&&"true"===String(d).toLowerCase()}b.exports=c}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],141:[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),
21
+ 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");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)},{}],142:[function(a,b,c){(function(c,d){(function(){var e,f,g,h,i,j,k,l,m,n,o,p,q={}.hasOwnProperty,r=function(a,b){function c(){this.constructor=a}for(var d in b)q.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};i=function(){function a(){this.onloadstart=null,this.onprogress=null,this.onabort=null,this.onerror=null,this.onload=null,this.ontimeout=null,this.onloadend=null,this._listeners={}}return a.prototype.onloadstart=null,a.prototype.onprogress=null,a.prototype.onabort=null,a.prototype.onerror=null,a.prototype.onload=null,a.prototype.ontimeout=null,a.prototype.onloadend=null,a.prototype.addEventListener=function(a,b){var c;a=a.toLowerCase(),(c=this._listeners)[a]||(c[a]=[]),this._listeners[a].push(b)},a.prototype.removeEventListener=function(a,b){var c;a=a.toLowerCase(),this._listeners[a]&&(c=this._listeners[a].indexOf(b),c!==-1&&this._listeners.splice(c,1))},a.prototype.dispatchEvent=function(a){var b,c,d,e,f;if(b=a.type,d=this._listeners[b])for(e=0,f=d.length;e<f;e++)(c=d[e])(a);(c=this["on"+b])&&c(a)},a}(),l=a("http"),m=a("https"),n=a("os"),o=a("url"),h=function(a){function b(a){b.__super__.constructor.call(this),this.onreadystatechange=null,this._anonymous=a&&a.anon,this.readyState=b.UNSENT,this.response=null,this.responseText="",this.responseType="",this.status=0,this.statusText="",this.timeout=0,this.upload=new k(this),this._method=null,this._url=null,this._sync=!1,this._headers=null,this._loweredHeaders=null,this._mimeOverride=null,this._request=null,this._response=null,this._responseParts=null,this._responseHeaders=null,this._aborting=null,this._error=null,this._loadedBytes=0,this._totalBytes=0,this._lengthComputable=!1}return r(b,a),b.prototype.onreadystatechange=null,b.prototype.readyState=null,b.prototype.response=null,b.prototype.responseText=null,b.prototype.responseType=null,b.prototype.status=null,b.prototype.timeout=null,b.prototype.upload=null,b.prototype.open=function(a,c,d,e,f){var h;if(a=a.toUpperCase(),a in this._restrictedMethods)throw new g("HTTP method "+a+" is not allowed in XHR");switch(h=this._parseUrl(c),void 0===d&&(d=!0),this.readyState){case b.UNSENT:case b.OPENED:case b.DONE:break;case b.HEADERS_RECEIVED:case b.LOADING:}this._method=a,this._url=h,this._sync=!d,this._headers={},this._loweredHeaders={},this._mimeOverride=null,this._setReadyState(b.OPENED),this._request=null,this._response=null,this.status=0,this.statusText="",this._responseParts=[],this._responseHeaders=null,this._loadedBytes=0,this._totalBytes=0,this._lengthComputable=!1},b.prototype.setRequestHeader=function(a,c){var d;if(this.readyState!==b.OPENED)throw new e("XHR readyState must be OPENED");return d=a.toLowerCase(),this._restrictedHeaders[d]||/^sec\-/.test(d)||/^proxy-/.test(d)?void console.warn('Refused to set unsafe header "'+a+'"'):(c=c.toString(),void(d in this._loweredHeaders?(a=this._loweredHeaders[d],this._headers[a]=this._headers[a]+", "+c):(this._loweredHeaders[d]=a,this._headers[a]=c)))},b.prototype.send=function(a){if(this.readyState!==b.OPENED)throw new e("XHR readyState must be OPENED");if(this._request)throw new e("send() already called");switch(this._url.protocol){case"file:":this._sendFile(a);break;case"http:":case"https:":this._sendHttp(a);break;default:throw new f("Unsupported protocol "+this._url.protocol)}},b.prototype.abort=function(){this._request&&(this._request.abort(),this._setError(),this._dispatchProgress("abort"),this._dispatchProgress("loadend"))},b.prototype.getResponseHeader=function(a){var b;return this._responseHeaders?(b=a.toLowerCase(),b in this._responseHeaders?this._responseHeaders[b]:null):null},b.prototype.getAllResponseHeaders=function(){var a,b,c;return this._responseHeaders?(a=function(){var a,d;a=this._responseHeaders,d=[];for(b in a)c=a[b],d.push(""+b+": "+c);return d}.call(this),a.join("\r\n")):""},b.prototype.overrideMimeType=function(a){if(this.readyState===b.LOADING||this.readyState===b.DONE)throw new e("overrideMimeType() not allowed in LOADING or DONE");this._mimeOverride=a.toLowerCase()},b.prototype.nodejsSet=function(a){"httpAgent"in a&&(this.nodejsHttpAgent=a.httpAgent),"httpsAgent"in a&&(this.nodejsHttpsAgent=a.httpsAgent)},b.nodejsSet=function(a){b.prototype.nodejsSet(a)},b.prototype.UNSENT=0,b.UNSENT=0,b.prototype.OPENED=1,b.OPENED=1,b.prototype.HEADERS_RECEIVED=2,b.HEADERS_RECEIVED=2,b.prototype.LOADING=3,b.LOADING=3,b.prototype.DONE=4,b.DONE=4,b.prototype.nodejsHttpAgent=l.globalAgent,b.prototype.nodejsHttpsAgent=m.globalAgent,b.prototype._restrictedMethods={CONNECT:!0,TRACE:!0,TRACK:!0},b.prototype._restrictedHeaders={"accept-charset":!0,"accept-encoding":!0,"access-control-request-headers":!0,"access-control-request-method":!0,connection:!0,"content-length":!0,cookie:!0,cookie2:!0,date:!0,dnt:!0,expect:!0,host:!0,"keep-alive":!0,origin:!0,referer:!0,te:!0,trailer:!0,"transfer-encoding":!0,upgrade:!0,"user-agent":!0,via:!0},b.prototype._privateHeaders={"set-cookie":!0,"set-cookie2":!0},b.prototype._userAgent="Mozilla/5.0 ("+n.type()+" "+n.arch()+") "+("node.js/"+c.versions.node+" v8/"+c.versions.v8),b.prototype._setReadyState=function(a){var b;this.readyState=a,b=new j("readystatechange",this),this.dispatchEvent(b)},b.prototype._sendFile=function(){if("GET"!==this._url.method)throw new f("The file protocol only supports GET");throw new Error("Protocol file: not implemented")},b.prototype._sendHttp=function(a){if(this._sync)throw new Error("Synchronous XHR processing not implemented");null==a||"GET"!==this._method&&"HEAD"!==this._method?a||(a=""):(console.warn("Discarding entity body for "+this._method+" requests"),a=null),this.upload._setData(a),this._finalizeHeaders(),this._sendHxxpRequest()},b.prototype._sendHxxpRequest=function(){var a,b,c,d=this;"http:"===this._url.protocol?(b=l,a=this.nodejsHttpAgent):(b=m,a=this.nodejsHttpsAgent),c=b.request({hostname:this._url.hostname,port:this._url.port,path:this._url.path,auth:this._url.auth,method:this._method,headers:this._headers,agent:a}),this._request=c,this.timeout&&c.setTimeout(this.timeout,function(){return d._onHttpTimeout(c)}),c.on("response",function(a){return d._onHttpResponse(c,a)}),c.on("error",function(a){return d._onHttpRequestError(c,a)}),this.upload._startUpload(c),this._request===c&&this._dispatchProgress("loadstart")},b.prototype._finalizeHeaders=function(){this._headers.Connection="keep-alive",this._headers.Host=this._url.host,this._anonymous&&(this._headers.Referer="about:blank"),this._headers["User-Agent"]=this._userAgent,this.upload._finalizeHeaders(this._headers,this._loweredHeaders)},b.prototype._onHttpResponse=function(a,c){var d,e=this;if(this._request===a){switch(c.statusCode){case 301:case 302:case 303:case 307:case 308:return this._url=this._parseUrl(c.headers.location),this._method="GET","content-type"in this._loweredHeaders&&(delete this._headers[this._loweredHeaders["content-type"]],delete this._loweredHeaders["content-type"]),"Content-Type"in this._headers&&delete this._headers["Content-Type"],delete this._headers["Content-Length"],this.upload._reset(),this._finalizeHeaders(),void this._sendHxxpRequest()}return this._response=c,this._response.on("data",function(a){return e._onHttpResponseData(c,a)}),this._response.on("end",function(){return e._onHttpResponseEnd(c)}),this._response.on("close",function(){return e._onHttpResponseClose(c)}),this.status=this._response.statusCode,this.statusText=l.STATUS_CODES[this.status],this._parseResponseHeaders(c),(d=this._responseHeaders["content-length"])?(this._totalBytes=parseInt(d),this._lengthComputable=!0):this._lengthComputable=!1,this._setReadyState(b.HEADERS_RECEIVED)}},b.prototype._onHttpResponseData=function(a,c){if(this._response===a)return this._responseParts.push(c),this._loadedBytes+=c.length,this.readyState!==b.LOADING&&this._setReadyState(b.LOADING),this._dispatchProgress("progress")},b.prototype._onHttpResponseEnd=function(a){if(this._response===a)return this._parseResponse(),this._request=null,this._response=null,this._setReadyState(b.DONE),this._dispatchProgress("load"),this._dispatchProgress("loadend")},b.prototype._onHttpResponseClose=function(a){var c;if(this._response===a)return c=this._request,this._setError(),c.abort(),this._setReadyState(b.DONE),this._dispatchProgress("error"),this._dispatchProgress("loadend")},b.prototype._onHttpTimeout=function(a){if(this._request===a)return this._setError(),a.abort(),this._setReadyState(b.DONE),this._dispatchProgress("timeout"),this._dispatchProgress("loadend")},b.prototype._onHttpRequestError=function(a,c){if(this._request===a)return this._setError(),a.abort(),this._setReadyState(b.DONE),this._dispatchProgress("error"),this._dispatchProgress("loadend")},b.prototype._dispatchProgress=function(a){var b;b=new j(a,this),b.lengthComputable=this._lengthComputable,b.loaded=this._loadedBytes,b.total=this._totalBytes,this.dispatchEvent(b)},b.prototype._setError=function(){this._request=null,this._response=null,this._responseHeaders=null,this._responseParts=null},b.prototype._parseUrl=function(a){var b,c,d,e;return e=o.parse(a,!1,!0),e.hash=null,e.auth&&("undefined"!=typeof d&&null!==d||"undefined"!=typeof c&&null!==c)&&(b=e.auth.indexOf(":"),b===-1?d||(d=e.auth):(d||(d=e.substring(0,b)),c||(c=e.substring(b+1)))),(d||c)&&(e.auth=""+d+":"+c),e},b.prototype._parseResponseHeaders=function(a){var b,c,d,e;this._responseHeaders={},e=a.headers;for(c in e)d=e[c],b=c.toLowerCase(),this._privateHeaders[b]||(null!==this._mimeOverride&&"content-type"===b&&(d=this._mimeOverride),this._responseHeaders[b]=d);null===this._mimeOverride||"content-type"in this._responseHeaders||(this._responseHeaders["content-type"]=this._mimeOverride)},b.prototype._parseResponse=function(){var a,b,c,e,f,g,h;switch(b=d.concat?d.concat(this._responseParts):this._concatBuffers(this._responseParts),this._responseParts=null,this.responseType){case"text":this._parseTextResponse(b);break;case"json":this.responseText=null;try{this.response=JSON.parse(b.toString("utf-8"))}catch(i){e=i,this.response=null}break;case"buffer":this.responseText=null,this.response=b;break;case"arraybuffer":for(this.responseText=null,a=new ArrayBuffer(b.length),f=new Uint8Array(a),c=g=0,h=b.length;0<=h?g<h:g>h;c=0<=h?++g:--g)f[c]=b[c];this.response=a;break;default:this._parseTextResponse(b)}},b.prototype._parseTextResponse=function(a){var b;try{this.responseText=a.toString(this._parseResponseEncoding())}catch(c){b=c,this.responseText=a.toString("binary")}this.response=this.responseText},b.prototype._parseResponseEncoding=function(){var a,b,c;return b=null,(a=this._responseHeaders["content-type"])&&(c=/\;\s*charset\=(.*)$/.exec(a))?c[1]:"utf-8"},b.prototype._concatBuffers=function(a){var b,c,e,f,g,h,i;if(0===a.length)return new d(0);if(1===a.length)return a[0];for(c=0,f=0,h=a.length;f<h;f++)b=a[f],c+=b.length;for(e=new d(c),c=0,g=0,i=a.length;g<i;g++)b=a[g],b.copy(e,c),c+=b.length;return e},b}(i),b.exports=h,h.XMLHttpRequest=h,g=function(a){function b(){b.__super__.constructor.apply(this,arguments)}return r(b,a),b}(Error),h.SecurityError=g,e=function(a){function b(){b.__super__.constructor.apply(this,arguments)}return r(b,a),b}(Error),e=function(a){function b(){return p=b.__super__.constructor.apply(this,arguments)}return r(b,a),b}(Error),h.InvalidStateError=e,f=function(a){function b(){b.__super__.constructor.apply(this,arguments)}return r(b,a),b}(Error),h.NetworkError=f,j=function(){function a(a,b){this.type=a,this.target=b,this.currentTarget=this.target,this.lengthComputable=!1,this.loaded=0,this.total=0}return a.prototype.bubbles=!1,a.prototype.cancelable=!1,a.prototype.target=null,a.prototype.loaded=null,a.prototype.lengthComputable=null,a.prototype.total=null,a}(),h.XMLHttpRequestProgressEvent=j,k=function(a){function b(a){b.__super__.constructor.call(this),this._request=a,this._reset()}return r(b,a),b.prototype._reset=function(){this._contentType=null,this._body=null},b.prototype._setData=function(a){var b,c,e,f,g,h,i,j;if("undefined"!=typeof a&&null!==a)if("string"==typeof a)0!==a.length&&(this._contentType="text/plain;charset=UTF-8"),this._body=new d(a,"utf8");else if(d.isBuffer(a))this._body=a;else if(a instanceof ArrayBuffer){for(b=new d(a.byteLength),f=new Uint8Array(a),c=g=0,i=a.byteLength;0<=i?g<i:g>i;c=0<=i?++g:--g)b[c]=f[c];this._body=b}else{if(!(a.buffer&&a.buffer instanceof ArrayBuffer))throw new Error("Unsupported send() data "+a);for(b=new d(a.byteLength),e=a.byteOffset,f=new Uint8Array(a.buffer),c=h=0,j=a.byteLength;0<=j?h<j:h>j;c=0<=j?++h:--h)b[c]=f[c+e];this._body=b}},b.prototype._finalizeHeaders=function(a,b){this._contentType&&("content-type"in b||(a["Content-Type"]=this._contentType)),this._body&&(a["Content-Length"]=this._body.length.toString())},b.prototype._startUpload=function(a){this._body&&a.write(this._body),a.end()},b}(i),h.XMLHttpRequestUpload=k}).call(this)}).call(this,a("_process"),a("buffer").Buffer)},{_process:87,buffer:45,http:128,https:73,os:82,url:138}],143:[function(a,b,c){function d(){for(var a={},b=0;b<arguments.length;b++){var c=arguments[b];for(var d in c)e.call(c,d)&&(a[d]=c[d])}return a}b.exports=d;var e=Object.prototype.hasOwnProperty},{}],144:[function(a,b,c){"use strict";function d(a){var b="";do b=h[a%i]+b,a=Math.floor(a/i);while(a>0);return b}function e(a){var b=0;for(l=0;l<a.length;l++)b=b*i+j[a.charAt(l)];return b}function f(){var a=d(+new Date);return a!==g?(k=0,g=a):a+"."+d(k++)}for(var g,h="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),i=64,j={},k=0,l=0;l<i;l++)j[h[l]]=l;f.encode=d,f.decode=e,b.exports=f},{}]},{},[1])(1)});