@pageproof/sdk-pr 94.0.1532555891030 → 94.0.1532561852367
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.
- package/lib/api/Comments.js +1 -1
- package/lib/pageproof.js +1 -1
- package/package.json +1 -1
package/lib/api/Comments.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _Comment=require("../models/Comment");var _Comment2=_interopRequireDefault(_Comment);var _CommentState=require("../enum/CommentState");var _CommentState2=_interopRequireDefault(_CommentState);var _constants=require("../util/constants");var _sort=require("../util/sort");var _comment=require("../util/comment");var _creationToken=require("../util/creationToken");var _throttle=require("../util/throttle");var _throttle2=_interopRequireDefault(_throttle);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}function getCommentDataFromPages(pages){var comments=[];Object.keys(pages).forEach(function(pageNumber){pages[pageNumber].Comments.forEach(function(commentData){comments.push(commentData)})});return comments}var _sortPages=(0,_sort.sortObjectsByKey)("pageNumber");var _sortCreatedDateDESC=(0,_sort.sortObjectsByKey)("createdDate",true);var _sortCreatedDateASC=(0,_sort.sortObjectsByKey)("createdDate",false);var sortComments=(0,_sort.combineSort)(_sortPages,_sortCreatedDateDESC);var sortReplies=(0,_sort.combineSort)(_sortPages,_sortCreatedDateASC);function mapComments(commentsData){var comments=[];var replies=[];commentsData.forEach(function(commentData){var entity=(new _Comment2.default).fromComment(commentData);if(entity.parentCommentId){replies.push(entity)}else{comments.push(entity)}});comments.sort(sortComments);var commentIds=comments.map(function(c){return c.id});var sortByParentCommentIndex=(0,_sort.sortObjectsBy)(function(r){return commentIds.indexOf(r.parentCommentId)},true);replies.sort((0,_sort.combineSort)(sortReplies,sortByParentCommentIndex));return comments.concat(replies)}var Comments=function(_API){_inherits(Comments,_API);function Comments(){_classCallCheck(this,Comments);return _possibleConstructorReturn(this,_API.apply(this,arguments))}Comments.prototype._mark=function _mark(commentId,state,value){var _data;var field=void 0;switch(state){case _CommentState2.default.TODO:{field="change";break}case _CommentState2.default.DONE:{field="done";break}default:{throw new Error('Cannot mark comment state "'+state+'".')}}var data=(_data={commentId:commentId},_data[field]=value?1:0,_data);return this.client.request("comments.state.update",data).then(function(){return null})};Comments.prototype.mark=function mark(commentId,state){return this._mark(commentId,state,true)};Comments.prototype.unmark=function unmark(commentId,state){return this._mark(commentId,state,false)};Comments.prototype.load=function load(_options){var _this2=this;var options=typeof _options==="string"?{proofId:_options}:_options;var proofId=options.proofId,_options$pageNumber=options.pageNumber,pageNumber=_options$pageNumber===undefined?null:_options$pageNumber,_options$sinceDate=options.sinceDate,sinceDate=_options$sinceDate===undefined?null:_options$sinceDate,_options$async=options.async,async=_options$async===undefined?false:_options$async,_options$decrypt=options.decrypt,decrypt=_options$decrypt===undefined?true:_options$decrypt,onDecryptComment=options.onDecryptComment,onDecryptComments=options.onDecryptComments,_options$onDecryptCom=options.onDecryptCommentsThrottleMs,onDecryptCommentsThrottleMs=_options$onDecryptCom===undefined?1e3:_options$onDecryptCom,onDecryptError=options.onDecryptError;var sinceDateISO=sinceDate?sinceDate.toISOString().match(_constants.ISO_REGEX)[0]:_constants.DEFAULT_ISO_DATE;var payload={proofId:proofId,page:pageNumber,timestamp:sinceDateISO};return this.client.request(pageNumber!==null?"comments.load-page":"comments.load-all",payload).then(function(response){var comments=mapComments(response.data.Pages?getCommentDataFromPages(response.data.Pages):response.data);var wait=Promise.resolve();if(decrypt){var scheduled=[];var pendingBatch=[];var scheduleOnDecryptComments=onDecryptComments?(0,_throttle2.default)(function(){if(pendingBatch.length){onDecryptComments(pendingBatch);pendingBatch=[]}},onDecryptCommentsThrottleMs):function(){};var cached=Promise.all(comments.map(function(comment){return _this2.client.cache.auto(_constants.COMMENT_CACHE_PREFIX+comment.comment$,function(resolve){scheduled.push({comment:comment,resolve:resolve})}).then(function(rawComment){if(rawComment){comment.fromRawComment(rawComment)}return comment})}));wait=wait.then(function(){return cached});wait=wait.then(function(){var decrypted=scheduled.map(function(_ref){var comment=_ref.comment,resolve=_ref.resolve;return _this2.client.crypto().decryptComment(comment.comment$,comment.envelope,_this2.client.session.privateKeyPEM).then(function(rawComment){comment.fromRawComment(rawComment);resolve(rawComment);if(onDecryptComment){onDecryptComment(comment)}pendingBatch.push(comment);scheduleOnDecryptComments()}).catch(function(err){if(onDecryptError){onDecryptError(err,comment)}if(!async){return Promise.reject(err)}return undefined})});if(!async){return Promise.all(decrypted)}return null})}return wait.then(function(){return comments})})};Comments.prototype.create=function create(_ref2){var _this3=this;var raw=_ref2.raw,proofId=_ref2.proofId,_ref2$pageNumber=_ref2.pageNumber,pageNumber=_ref2$pageNumber===undefined?1:_ref2$pageNumber,pin=_ref2.pin,mediaTime=_ref2.mediaTime,mediaDuration=_ref2.mediaDuration,parentCommentId=_ref2.parentCommentId,metadata=_ref2.metadata,state=_ref2.state,retryCreationToken=_ref2.creationToken;var mentions=(0,_comment.getCommentMentions)(raw);var creationToken=retryCreationToken||(0,_creationToken.generateCreationToken)();return this.client.crypto().encryptComment(raw,[this.client.session.serverPublicKeyPEM,this.client.session.publicKeyPEM]).then(function(_ref3){var envelope=_ref3.envelope,comment$=_ref3.comment$;return{proofId:proofId,page:parentCommentId?undefined:pageNumber,envelope:envelope,encryptedComment:comment$,xy:JSON.stringify({x:pin&&typeof pin.x==="number"?pin.x:null,y:pin&&typeof pin.y==="number"?pin.y:null,x2:pin&&typeof pin.x2==="number"?pin.x2:null,y2:pin&&typeof pin.y2==="number"?pin.y2:null,time:typeof mediaTime==="number"?mediaTime:null,duration:typeof mediaDuration==="number"?mediaDuration:null}),parent:parentCommentId||
|
|
1
|
+
"use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _Comment=require("../models/Comment");var _Comment2=_interopRequireDefault(_Comment);var _CommentState=require("../enum/CommentState");var _CommentState2=_interopRequireDefault(_CommentState);var _constants=require("../util/constants");var _sort=require("../util/sort");var _comment=require("../util/comment");var _creationToken=require("../util/creationToken");var _throttle=require("../util/throttle");var _throttle2=_interopRequireDefault(_throttle);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}function getCommentDataFromPages(pages){var comments=[];Object.keys(pages).forEach(function(pageNumber){pages[pageNumber].Comments.forEach(function(commentData){comments.push(commentData)})});return comments}var _sortPages=(0,_sort.sortObjectsByKey)("pageNumber");var _sortCreatedDateDESC=(0,_sort.sortObjectsByKey)("createdDate",true);var _sortCreatedDateASC=(0,_sort.sortObjectsByKey)("createdDate",false);var sortComments=(0,_sort.combineSort)(_sortPages,_sortCreatedDateDESC);var sortReplies=(0,_sort.combineSort)(_sortPages,_sortCreatedDateASC);function mapComments(commentsData){var comments=[];var replies=[];commentsData.forEach(function(commentData){var entity=(new _Comment2.default).fromComment(commentData);if(entity.parentCommentId){replies.push(entity)}else{comments.push(entity)}});comments.sort(sortComments);var commentIds=comments.map(function(c){return c.id});var sortByParentCommentIndex=(0,_sort.sortObjectsBy)(function(r){return commentIds.indexOf(r.parentCommentId)},true);replies.sort((0,_sort.combineSort)(sortReplies,sortByParentCommentIndex));return comments.concat(replies)}var Comments=function(_API){_inherits(Comments,_API);function Comments(){_classCallCheck(this,Comments);return _possibleConstructorReturn(this,_API.apply(this,arguments))}Comments.prototype._mark=function _mark(commentId,state,value){var _data;var field=void 0;switch(state){case _CommentState2.default.TODO:{field="change";break}case _CommentState2.default.DONE:{field="done";break}default:{throw new Error('Cannot mark comment state "'+state+'".')}}var data=(_data={commentId:commentId},_data[field]=value?1:0,_data);return this.client.request("comments.state.update",data).then(function(){return null})};Comments.prototype.mark=function mark(commentId,state){return this._mark(commentId,state,true)};Comments.prototype.unmark=function unmark(commentId,state){return this._mark(commentId,state,false)};Comments.prototype.load=function load(_options){var _this2=this;var options=typeof _options==="string"?{proofId:_options}:_options;var proofId=options.proofId,_options$pageNumber=options.pageNumber,pageNumber=_options$pageNumber===undefined?null:_options$pageNumber,_options$sinceDate=options.sinceDate,sinceDate=_options$sinceDate===undefined?null:_options$sinceDate,_options$async=options.async,async=_options$async===undefined?false:_options$async,_options$decrypt=options.decrypt,decrypt=_options$decrypt===undefined?true:_options$decrypt,onDecryptComment=options.onDecryptComment,onDecryptComments=options.onDecryptComments,_options$onDecryptCom=options.onDecryptCommentsThrottleMs,onDecryptCommentsThrottleMs=_options$onDecryptCom===undefined?1e3:_options$onDecryptCom,onDecryptError=options.onDecryptError;var sinceDateISO=sinceDate?sinceDate.toISOString().match(_constants.ISO_REGEX)[0]:_constants.DEFAULT_ISO_DATE;var payload={proofId:proofId,page:pageNumber,timestamp:sinceDateISO};return this.client.request(pageNumber!==null?"comments.load-page":"comments.load-all",payload).then(function(response){var comments=mapComments(response.data.Pages?getCommentDataFromPages(response.data.Pages):response.data);var wait=Promise.resolve();if(decrypt){var scheduled=[];var pendingBatch=[];var scheduleOnDecryptComments=onDecryptComments?(0,_throttle2.default)(function(){if(pendingBatch.length){onDecryptComments(pendingBatch);pendingBatch=[]}},onDecryptCommentsThrottleMs):function(){};var cached=Promise.all(comments.map(function(comment){return _this2.client.cache.auto(_constants.COMMENT_CACHE_PREFIX+comment.comment$,function(resolve){scheduled.push({comment:comment,resolve:resolve})}).then(function(rawComment){if(rawComment){comment.fromRawComment(rawComment)}return comment})}));wait=wait.then(function(){return cached});wait=wait.then(function(){var decrypted=scheduled.map(function(_ref){var comment=_ref.comment,resolve=_ref.resolve;return _this2.client.crypto().decryptComment(comment.comment$,comment.envelope,_this2.client.session.privateKeyPEM).then(function(rawComment){comment.fromRawComment(rawComment);resolve(rawComment);if(onDecryptComment){onDecryptComment(comment)}pendingBatch.push(comment);scheduleOnDecryptComments()}).catch(function(err){if(onDecryptError){onDecryptError(err,comment)}if(!async){return Promise.reject(err)}return undefined})});if(!async){return Promise.all(decrypted)}return null})}return wait.then(function(){return comments})})};Comments.prototype.create=function create(_ref2){var _this3=this;var raw=_ref2.raw,proofId=_ref2.proofId,_ref2$pageNumber=_ref2.pageNumber,pageNumber=_ref2$pageNumber===undefined?1:_ref2$pageNumber,pin=_ref2.pin,mediaTime=_ref2.mediaTime,mediaDuration=_ref2.mediaDuration,parentCommentId=_ref2.parentCommentId,metadata=_ref2.metadata,state=_ref2.state,retryCreationToken=_ref2.creationToken;var mentions=(0,_comment.getCommentMentions)(raw);var creationToken=retryCreationToken||(0,_creationToken.generateCreationToken)();return this.client.crypto().encryptComment(raw,[this.client.session.serverPublicKeyPEM,this.client.session.publicKeyPEM]).then(function(_ref3){var envelope=_ref3.envelope,comment$=_ref3.comment$;return{proofId:proofId,page:parentCommentId?undefined:pageNumber,envelope:envelope,encryptedComment:comment$,xy:JSON.stringify({x:pin&&typeof pin.x==="number"?pin.x:null,y:pin&&typeof pin.y==="number"?pin.y:null,x2:pin&&typeof pin.x2==="number"?pin.x2:null,y2:pin&&typeof pin.y2==="number"?pin.y2:null,time:typeof mediaTime==="number"?mediaTime:null,duration:typeof mediaDuration==="number"?mediaDuration:null}),parent:parentCommentId||undefined,mentions:mentions.map(function(m){return m.id}).join(","),metadata:metadata?JSON.stringify(metadata):"{}",creationToken:creationToken,change:state===_CommentState2.default.TODO?"1":undefined,done:state===_CommentState2.default.DONE?"1":undefined}}).then(function(requestData){return _this3.client.request("comments.create",requestData).then(function(response){return(new _Comment2.default).fromComment(response.data).fromRawComment(raw)})}).catch(function(err){if(err){err.creationToken=creationToken}return Promise.reject(err)})};return Comments}(_API3.default);exports.default=Comments;
|
package/lib/pageproof.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.PageProof=t():e.PageProof=t()}(this,function(){return function(e){function t(n){if(o[n])return o[n].exports;var r=o[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var o={};return t.m=e,t.c=o,t.d=function(e,o,n){t.o(e,o)||Object.defineProperty(e,o,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(o,"a",o),o},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=30)}([function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=function e(t){n(this,e),this.client=t};t.default=r},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t,o){var n=[],r={};return Array.isArray(t)?(n=t,t.forEach(function(e){r[e]=e})):(0,y.default)(t)&&(n=Object.keys(t),r=t),n.forEach(function(t){var n=r[t],i=void 0;if("string"==typeof n)i=-1!==n.indexOf(".")?function(){for(var e=n.split("."),t=o,r=0;r<e.length;r++){var i=e[r];if(!(0,w.default)(t,i)){t=void 0;break}t=t[i]}return t}:function(){return o[n]};else{if("function"!=typeof n){if(null===n)return;throw new Error("Unknown transformer.")}i=n}var a=i.call(e,o);void 0!==a&&(e[t]=a)}),e}function i(e){return function(t){return Number(t[e])}}function a(e,t){return function(o){return t[o[e]]}}function s(e){return function(t){var o=t[e];if(o&&"0001-01-01T00:00:00"!==o)return"number"==typeof o?new Date(1e3*o):new Date(o+"Z")}}function u(e){return function(t){var o=String(t[e]);return"1"===o||"true"===o}}function f(e){return function(t){return w.default.call(t,e)}}function c(e,t){return function(o){return o[e]?o[e].map(t):[]}}function l(e,t){return function(o){return o[e]?JSON.parse(o[e]):Array.isArray(t)?[].concat(t):d({},t)}}function p(e){return function(t){return t[e]?t[e]:void 0}}t.__esModule=!0;var d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e};t.number=i,t.enumeration=a,t.date=s,t.truthy=u,t.exists=f,t.each=c,t.json=l,t.optional=p;var h=o(15),y=n(h),m=o(9),w=n(m);t.default=r},function(e,t,o){"use strict";t.__esModule=!0;t.TOKEN_HEADER="x-authorization-token",t.HMAC_HEADER="x-authorization-hmac",t.TIMESTAMP_HEADER="x-timestamp",t.DEVICE_ID_HEADER="x-device-id",t.SUBSCRIPTION_KEY_HEADER="ocp-apim-subscription-key",t.SDK_VERSION_HEADER="x-pageproof-javascript-sdk",t.RETRY_AFTER_HEADER="retry-after",t.BYTES_PER_BLOCK=2097152,t.MENTION_REGEX=/@{(U[a-zA-Z0-9]{15}|~everyone)}{(.*?)}/g,t.ISO_REGEX=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,t.DEFAULT_ISO_DATE="0001-01-01T00:00:00",t.DAY_IN_MS=864e5,t.COMMENT_CACHE_PREFIX="comment",t.THUMBNAIL_CACHE_PREFIX="thumbnail"},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=o(1),i=function(e){return e&&e.__esModule?e:{default:e}}(r),a={id:"UserId",name:"Name",email:"Email",hasActivated:"Activated",hasRegistered:"IsRegistered",hasAvatar:"HasAvatar",accountType:"AccountType",teamType:"TeamType",teamLogo:"Branding.LogoURL",registeredDate:(0,r.date)("Registered"),lastLoginDate:(0,r.date)("LastLogin"),lastUploadDate:(0,r.date)("LastUpload"),isAdmin:"IsDomainAdmin"},s=function(){function e(){n(this,e)}return e.prototype.fromJSON=function(e){return(0,i.default)(this,Object.keys(a),e),this},e.prototype.fromUser=function(e){return(0,i.default)(this,a,e),this},e}();t.default=s},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(){return this.dueDate&&this.dueDate.getTime()<Date.now()}t.__esModule=!0;var a=o(1),s=n(a),u=o(17),f=n(u),c=o(18),l=n(c),p=o(5),d=n(p),h=o(19),y={id:"ProofId",name:"Title",status:"Status",workflowId:"WorkflowId",version:"Version",dueDate:(0,a.date)("DueDate"),createdDate:(0,a.date)("CreatedDate"),approvedDate:(0,a.date)("ApprovedDate"),isLocked:"Locked",isArchived:"Closed",isOverdue:i,uploaderUserId:"UserId",ownerUserIds:"OwnerIds",editorUserId:"EditorId",editorUserIds:"EditorIds",lockerUserId:"ProofLockerId",messageToReviewers:"Description",messageToOwners:"OwnerMessage",messageToEditor:"EditorMessage",fileId:"FileId",fileExtension:"Extension",fileStatus:"FileStatus",fileMessage:"FileStatusMessage",pageCount:(0,a.number)("Pages"),commentCount:(0,a.number)("ParentComments"),canDownload:(0,a.truthy)("DownloadOriginal"),type:"Type",processStatus:"ProcessStatus",recipient:"Recipient"},m=function(){function e(){r(this,e)}return e.prototype.getState=function(){var e=f.default.ACTIVE;return this.fileStatus===d.default.UPLOADING?e=f.default.UPLOADING:this.hasFileError()?e=f.default.FILE_ERROR:this.isProcessing()?e=f.default.PROCESSING:this.status===l.default.ARCHIVED?e=f.default.ARCHIVED:this.hasWorkflow()?this.status===l.default.TODOS_REQUESTED?e=f.default.TODOS_REQUESTED:this.status===l.default.AWAITING_NEW_VERSION?e=f.default.AWAITING_NEW_VERSION:this.status===l.default.APPROVED?e=f.default.APPROVED:this.hasWorkflowStarted()?this.isOverdue&&(e=f.default.OVERDUE):e=f.default.NOT_STARTED:e=f.default.PROOFERS_NEEDED,e},e.prototype.hasWorkflowStarted=function(){return this.hasWorkflow()&&this.status!==l.default.NEW},e.prototype.isProcessing=function(){return this.fileStatus===d.default.UPLOADING||this.fileStatus===d.default.QUEUED||this.fileStatus===d.default.RIPPING},e.prototype.getProcessingProgress=function(){switch(this.fileStatus){case d.default.UPLOADING:return.1;case d.default.QUEUED:return.2;case d.default.RIPPING:return.6;default:return-1}},e.prototype.hasWorkflow=function(){return(0,h.isWorkflowId)(this.workflowId)},e.prototype.hasFile=function(){return(0,h.isFileId)(this.fileId)},e.prototype.hasFileError=function(){return this.fileStatus===d.default.ERROR||!this.fileStatus||!this.hasFile()},e.prototype.hasEditor=function(){return(0,h.isUserId)(this.editorUserId)},e.prototype.hasThumbnail=function(){return this.fileStatus===d.default.OK},e.prototype.canUserUploadNewVersion=function(e){return this.getState()===f.default.AWAITING_NEW_VERSION&&(this.editorUserId===e||this.isOwner(e))},e.prototype.isOwner=function(e){return-1!==this.ownerUserIds.indexOf(e)},e.prototype.calculateState=function(){this.state=this.getState()},e.prototype.fromProof=function(e){return(0,s.default)(this,y,e),this.calculateState(),this},e}();t.default=m},function(e,t,o){"use strict";t.__esModule=!0;var n={OK:"OK",UPLOADING:"Uploading",QUEUED:"Queued",RIPPING:"Ripping",ERROR:"Error"};t.default=n},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(1),a=n(i),s=o(3),u=n(s),f={userId:"UserId",token:"Token",sharedKey:"SharedKey",privateKeyPEM$:"PrivateKey",privateKeyPEM:null,publicKeyPEM:"PublicKey",serverPublicKeyPEM:"PublicServerKey"},c=function(){function e(){r(this,e)}return e.prototype.fromJSON=function(e){return(0,a.default)(this,Object.keys(f),e),this.user=(new u.default).fromJSON(e.user),this},e.prototype.fromSession=function(e){return(0,a.default)(this,f,e),this.user=(new u.default).fromUser(e),this},e}();t.default=c},function(e,t,o){"use strict";function n(){if("function"==typeof n.driver){return new(0,n.driver)}if("string"==typeof n.driver){var e=void 0;switch(n.driver){case"Blob":e=o(56).default;break;case"Buffer":e=o(57).default;break;case"String":e=o(58).default;break;default:throw new Error('Unknown Bluffer driver "'+n.driver+'".')}if(e)return new e;throw new Error('Bluffer driver "'+n.driver+'" not found.')}throw new Error('Bluffer.driver must be either "Blob", "Bluffer", or "String" or a custom constructor.')}t.__esModule=!0;var r=o(11)("bluffer");n.driver="String","undefined"!=typeof Blob?n.driver="Blob":(r("The current JavaScript environment does not support native Bluffer, falling back to using StringBluffer."),n.driver="String"),t.default=n},function(e,t,o){"use strict";t.__esModule=!0;var n={ERROR_CRITICAL:3,OK:200,ERROR_INVALID:201,ERROR_NO_ACCESS:100,ERROR_NO_ACCESS_WRITE:101,ERROR_RESTRICTED:102,ERROR_SQL_ERROR:105,ERROR_OUT_SYNC:106,ERROR_STORAGE_ERROR:110,ERROR_QUEUE_ERROR:111,ERROR_SQL_DEADLOCK_ERROR:121,ERROR_BAD_REQUEST:400,ERROR_UNAUTHORISED:401,ERROR_MEDIA_PERMISSION_NO_ACCESS:402,ERROR_NOT_FOUND:1e3,ERROR_CREATE:1001,ERROR_UPDATE:1002,ERROR_DELETE:1003,ERROR_EXISTS:1004,ERROR_USER_INVALID_LOGIN:1010,ERROR_USER_INVALID_PASSWORD:1011,ERROR_USER_IS_REGISTERED:1012,ERROR_USER_INVALID_EMAIL:1013,ERROR_USER_INVALID_LOGIN_COUNT:1014,ERROR_USER_DISABLED:1015,ERROR_BAD_REQUEST_DATE:201,ERROR_THROTTLED:429,ERROR_REUSED_CREATION_TOKEN:2011,ERROR_UPGRADE_REQUIRED:3e3,ERROR_VISIBLE_WORKFLOW_USERS_EXIST:3001,ERROR_GROUP_EXISTS:3002,ERROR_GROUP_PROOFS_EXIST:3003};t.default=n},function(e,t,o){"use strict";t.__esModule=!0,t.default=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=o(1),i=function(e){return e&&e.__esModule?e:{default:e}}(r),a={id:"FileId",name:"Name",blocks:"Chunks",downloadable:"Downloadable",assignedTo:"AssignedTo",assignedType:"AssignedType",status:"Status",message:"Message"},s={id:"Attachment",name:"AttachmentName",blocks:"AttachmentChunks",assignedTo:"CommentId",assignedType:function(){return"attachment"},status:"AttachmentStatus",message:function(){return""}},u=function(){function e(){n(this,e)}return e.prototype.fromFile=function(e){return(0,i.default)(this,a,e),this},e.prototype.fromCommentAttachment=function(e){return(0,i.default)(this,s,e),this},e}();t.default=u},function(e,t,o){"use strict";e.exports=function e(){return e}},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(1),a=n(i),s=o(13),u=n(s),f=o(26),c=n(f),l={id:"StepId",name:"Title",position:(0,i.number)("Position"),state:function(e){return e.Complete?c.default.COMPLETE:e.Visible?c.default.VISIBLE:c.default.NOT_VISIBLE},users:(0,i.each)("Users",function(e,t){var o=(new u.default).fromWorkflowUser(e);return o._calculateState(e,t),o})},p=function(){function e(){r(this,e)}return e.prototype.fromWorkflowStep=function(e){return(0,a.default)(this,l,e),this},e}();t.default=p},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(1),u=n(s),f=o(3),c=n(f),l=o(25),p=n(l),d={id:"UserId",name:"Name",email:"Email",role:"Role",permissions:function(e){return{inviter:e.IsInviter}}},h=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype._calculateState=function(e,t){e.SkippedInStep?this.state=p.default.SKIPPED:e.CompleteInStep?this.state=p.default.FINISHED:e.ViewedInStep?this.state=p.default.SEEN:t.Visible?this.state=p.default.VISIBLE:this.state=p.default.NOT_VISIBLE},t.prototype.fromWorkflowUser=function(e){return this._calculateState({},{}),(0,u.default)(this,d,e),this},t}(c.default);t.default=h},function(e,t,o){"use strict";t.__esModule=!0;var n={COMMENT:"comment",TODO:"todo",DONE:"done"};t.default=n},function(e,t,o){"use strict";t.__esModule=!0;var n=Object.prototype.toString;t.default=function(e){return"[object Object]"===n.call(e)}},function(e,t,o){"use strict";t.__esModule=!0;var n=void 0;n="94.0.1532555891030",t.default=n},function(e,t,o){"use strict";t.__esModule=!0;var n={UPLOADING:"uploading",FILE_ERROR:"file-error",PROCESSING:"processing",ARCHIVED:"archived",PROOFERS_NEEDED:"proofers-needed",TODOS_REQUESTED:"todos-requested",AWAITING_NEW_VERSION:"awaiting-new-version",APPROVED:"approved",NOT_STARTED:"not-started",OVERDUE:"overdue",ACTIVE:"active"};t.default=n},function(e,t,o){"use strict";t.__esModule=!0;var n={NEW:0,PROOFING:10,FINAL_APPROVING:30,TODOS_REQUESTED:50,AWAITING_NEW_VERSION:60,APPROVED:70,ARCHIVED:100};t.default=n},function(e,t,o){"use strict";var n={Proof:"P",Workflow:"W",File:"F",User:"U",Brief:"B"},r={};Object.keys(n).forEach(function(e){r["is"+e+"Id"]=function(t){return t&&16===t.length&&t[0]===n[e]}}),e.exports=r},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=o(1),i=function(e){return e&&e.__esModule?e:{default:e}}(r),a={id:"ProofId",version:"Version"},s=function(){function e(){n(this,e)}return e.prototype.fromProofVersion=function(e){return(0,i.default)(this,a,e),this},e}();t.default=s},function(e,t,o){"use strict";function n(e,t){return r(function(t){return t[e]},t)}function r(e,t){var o=t?1:-1,n=t?-1:1;return function(t,r){var i=e(t),a=e(r);return i<a?o:i>a?n:0}}function i(e,t){var o={};t.forEach(function(e,t){o[e]=t});var n="function"==typeof e?e:function(t){return t[e]};return function(e,t){var r=o[n(e)],i=o[n(t)];return r<i?-1:r>i?1:0}}function a(){for(var e=arguments.length,t=Array(e),o=0;o<e;o++)t[o]=arguments[o];var n=t.length;return function(e,o){for(var r=0;r<n;r++){var i=t[r](e,o);if(i)return i}return 0}}t.__esModule=!0,t.sortObjectsByKey=n,t.sortObjectsBy=r,t.sortObjectsByValues=i,t.combineSort=a},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(1),a=n(i),s=o(4),u=n(s),f={id:"GroupId",name:"Name",proofs:(0,i.each)("ProofInfo",function(e){return(new u.default).fromProof(e)})},c=function(){function e(){r(this,e)}return e.prototype.fromProofGroup=function(e){return(0,a.default)(this,f,e),this},e}();t.default=c},function(e,t,o){"use strict";t.__esModule=!0;var n={NONE:"none",GOOGLE_DRIVE:"drive",DROPBOX:"dropbox",ONEDRIVE:"onedrive",BOX:"box"};t.default=n},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(1),a=n(i),s=o(12),u=n(s),f={id:"WorkflowId",name:"Title",steps:(0,i.each)("WorkflowSteps",function(e){return(new u.default).fromWorkflowStep(e)})},c=function(){function e(){r(this,e)}return e.prototype.getStepByPosition=function(e){for(var t=this.steps.length,o=0;o<t;o+=1){var n=this.steps[o];if(n.position===e)return n}return null},e.prototype.getOrderedSteps=function(){return this.steps.sort(function(e,t){return e.position<t.position?-1:e.position>t.position?1:0})},e.prototype.getApproverStep=function(){return this.getStepByPosition(1e3)},e.prototype.fromWorkflow=function(e){return(0,a.default)(this,f,e),this},e}();t.default=c},function(e,t,o){"use strict";t.__esModule=!0;var n={NONE:null,NOT_VISIBLE:"not-visible",VISIBLE:"visible",SEEN:"seen",SKIPPED:"skipped",FINISHED:"finished"};t.default=n},function(e,t,o){"use strict";t.__esModule=!0;var n={NONE:null,NOT_VISIBLE:"not-visible",VISIBLE:"visible",COMPLETE:"complete"};t.default=n},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(1),a=n(i),s=o(3),u=n(s),f=o(28),c=n(f),l=o(10),p=n(l),d=o(14),h=n(d),y=o(29),m={__prepare:function(e){e._XY=c.default.parseValue(e.XY)},id:"CommentId",proofId:"ProofId",pin:function(e){return(new c.default).fromPin(e._XY)},user:function(e){return(new u.default).fromUser(e)},comment$:"EncryptedComment",envelope:"Envelope",attachments:function(e){return e.Attachment?[(new p.default).fromCommentAttachment(e)]:[]},agreeCount:function(e){return e.Agrees.length},pageNumber:(0,i.number)("Page"),mediaTime:function(e){return null==e._XY.time?void 0:e._XY.time},mediaDuration:function(e){return null==e._XY.duration?void 0:e._XY.duration},createdDate:(0,i.date)("Timestamp"),updatedDate:(0,i.date)("Updated"),parentCommentId:(0,i.optional)("Parent"),metadata:(0,i.json)("Metadata",{}),state:function(e){return+e.Done?h.default.DONE:+e.Change?h.default.TODO:h.default.COMMENT}},w=function(){function e(){r(this,e)}return e.prototype.fromComment=function(e){return(0,a.default)(this,m,e),this},e.prototype.fromRawComment=function(e){var t=(0,y.parseComment)(e);return this.raw=t.raw,this.text=t.text,this.html=t.html,this.tokens=t.tokens,this},e}();t.default=w},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},i=o(1),a=function(e){return e&&e.__esModule?e:{default:e}}(i),s={x:"x",y:"y",x2:(0,i.optional)("x2"),y2:(0,i.optional)("y2")},u=function(){function e(){n(this,e)}return e.prototype.fromPin=function(e){return(0,a.default)(this,s,e),this},e.parseValue=function(e){var t={x:null,y:null,x2:null,y2:null,time:null,duration:null};if("{"===e[0]){var o=JSON.parse(e);t=r({},t,o)}else if(-1!==e.indexOf(",")){var n=e.split(","),i=n[0],a=n[1];t.x=parseFloat(i),t.y=parseFloat(a)}return t},e}();t.default=u},function(e,t,o){"use strict";function n(e){return(0,c.default)(e)}function r(e){return e.replace(l.MENTION_REGEX,function(e,t,o){return o})}function i(e){var t=0;return e.replace(l.MENTION_REGEX,function(e,o,n,r){return'<span data-mention data-mention-index="'+t+++'" data-mention-user-id="'+o+'" data-mention-user-label="'+n.replace(/"/,'\\"')+'" data-mention-start-index="'+r+'" data-mention-end-index="'+(r+e.length)+'" data-mention-length="'+e.length+'">'+n+"</span>"})}function a(e){var t=[];return e.replace(l.MENTION_REGEX,function(e,o,n,r){t.push({id:o,label:n,index:r,length:e.length})}),t}function s(e){var t=a(e),o=[],n=0;t.forEach(function(t){var r=e.slice(n,t.index);n=t.index+t.length,r&&o.push({type:"text",value:r}),o.push({type:"mention",value:t})});var r=e.slice(n);return r&&o.push({type:"text",value:r}),o}function u(e){var t=n(e);return{raw:e,text:r(t),html:i(t),mentions:a(e),tokens:s(e)}}t.__esModule=!0,t.getCommentTokens=t.getCommentText=t.getCommentMentions=t.getCommentHTML=t.getCommentEscaped=t.parseComment=void 0;var f=o(68),c=function(e){return e&&e.__esModule?e:{default:e}}(f),l=o(2);t.parseComment=u,t.getCommentEscaped=n,t.getCommentHTML=i,t.getCommentMentions=a,t.getCommentText=r,t.getCommentTokens=s},function(e,t,o){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t.default=e,t}function r(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.version=t.Model=t.Enum=t.Bluffer=t.Client=void 0;var i=o(31),a=r(i),s=o(7),u=r(s),f=o(75),c=n(f),l=o(78),p=n(l),d=o(16),h=r(d);t.default=a.default,t.Client=a.default,t.Bluffer=u.default,t.Enum=c,t.Model=p,t.version=h.default},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(32),a=n(i),s=o(37),u=n(s),f=o(38),c=n(f),l=o(40),p=n(l),d=o(42),h=n(d),y=o(44),m=n(y),w=o(45),v=n(w),_=o(46),b=n(_),E=o(53),g=n(E),O=o(54),P=n(O),I=o(62),T=n(I),R=o(65),S=n(R),k=o(67),M=n(k),A=o(71),C=n(A),j=o(72),D=n(j),q=o(6),N=n(q),x=o(73),U=n(x),B=o(8),K=n(B),G=o(74),L=n(G),W=o(11)("PageProof"),F=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,e),this.options=t,this.events=new U.default,this.adapters=new a.default(this.options.adapters),this.cache=new u.default(this),this.accounts=new h.default(this),this.comments=new M.default(this),this.dashboard=new m.default(this),this.files=new P.default(this),this.profile=new C.default(this),this.proofs=new b.default(this),this.briefs=new g.default(this),this.users=new v.default(this),this.workflows=new S.default(this),this.sessions=new D.default(this),this._registerCoreHooks(),this._enhance()}return e.prototype._registerCoreHooks=function(){this.on("error.throttled",function(e){var t=e.data.response.data.timeout;return W("Sleeping "+t+"ms until rate limit resets"),(0,L.default)(t)})},e.prototype._enhance=function(){var e=this;this.adapters.getEnhancementAdapters().forEach(function(t){return t.onClientReady(e)})},e.prototype.setSession=function(e){return!e||e instanceof N.default?this.session=e||null:this.session=(new N.default).fromJSON(e),this.session},e.prototype.request=function(e,t,o){var n=this,r=new c.default(e,t),i=this.adapters.getRequestAdapter(),a=Promise.resolve();if(!r.endpoint.anonymous){if(!this.session)return Promise.reject(new Error("Cannot make call to endpoint ("+e+") when unauthorized."));a=this.adapters.getCryptoAdapter().generateAuthorizationHeaders(r.getMethod(),r.getPath(),this.session).then(function(e){return r.addHeaders(e)})}var s={request:r};return a.then(function(){var e=r.build();return n.events.emit("experimental.request.before",s,!0).then(function(){return e})}).then(function(e){return i.send(e,o)}).then(p.default.parse).then(function(r){if(s.response=r,n.events.emit("experimental.request.after",s),r.code===K.default.ERROR_THROTTLED){var i=n.events.emit("error.throttled",s);if(i.some(Boolean))return Promise.all(i).then(function(){return n.events.emit("experimental.request.retry",s),n.request(e,t,o)})}if(r.code===K.default.ERROR_UNAUTHORISED){var a=n.session?n.session.token:null;return n.events.emit("error.unauthorized",s,!0).then(function(){return n.session&&n.session.token!==a?n.request(e,t,o):r})}if(r.deprecated){var u="The "+e+" API has been deprecated. "+(r.deprecated||"");n.events.emit("error.deprecated",{name:e,message:u})}return r}).then(function(t){try{if(t.error){n.events.emit("error.response",s);var o=new Error(e+" request resulted in an "+t.code+" error.");return o.response=t,o.request=r,Promise.reject(o)}return n.events.emit("experimental.request.resolve",s),Promise.resolve(t)}finally{n.events.emit("experimental.request.finally",s)}})},e.prototype.admin=function(){return this.session?this.session.user.isAdmin?(this._admin||(this._admin=Promise.resolve(new T.default(this))),this._admin):Promise.reject(new Error("The current user must be an administrator of a team or enterprise account.")):Promise.reject(new Error("You must be logged in to use the Admin API."))},e.prototype.crypto=function(){return this.adapters.getCryptoAdapter()},e.prototype.on=function(e,t){return this.events.on(e,t)},e}();t.default=F},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(33),a=n(i),s=o(34),u=n(s),f=o(35),c=n(f),l=o(36),p=n(l),d=function(){function e(t){r(this,e),this.adapters=[].concat(t)}return e.prototype.getAdapterInstanceOf=function(e){return this.getAnyAdaptersInstanceOf(e)[0]||null},e.prototype.getAnyAdaptersInstanceOf=function(e){for(var t=[],o=e.__adapter__,n=0;n<this.adapters.length;n+=1){var r=this.adapters[n];Object.getPrototypeOf(Object.getPrototypeOf(r)).constructor.__adapter__===o&&t.push(r)}return t},e.prototype.getCryptoAdapter=function(){var e=this.getAdapterInstanceOf(a.default);if(!e)throw new Error("ICryptoAdapter not found. This adapter is required for the SDK to function correctly.");return e},e.prototype.getRequestAdapter=function(){var e=this.getAdapterInstanceOf(u.default);if(!e)throw new Error("IRequestAdapter not found. This adapter is required for the SDK to function correctly.");return e},e.prototype.getCacheAdapter=function(){return this.getAdapterInstanceOf(c.default)},e.prototype.getEnhancementAdapters=function(){return this.getAnyAdaptersInstanceOf(p.default)},e}();t.default=d},function(e,t,o){"use strict";function n(){}t.__esModule=!0,n.__adapter__="ICryptoAdapter",t.default=n},function(e,t,o){"use strict";function n(){}t.__esModule=!0,n.__adapter__="IRequestAdapter",t.default=n},function(e,t,o){"use strict";function n(){}t.__esModule=!0,n.__adapter__="ICacheAdapter",t.default=n},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t,o){var n=e[t];e[t]=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];var i=n.bind.apply(n,[this].concat(t));return o(i,this,t).apply(this,t)}}function i(e){function t(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],a=Object.getOwnPropertyNames(r).filter(function(t){return r[t].client===e}),s=Object.getPrototypeOf(r),u=Object.keys(s).filter(function(e){return"function"==typeof s[e]&&0!==e.indexOf("_")});(i.length||o)&&u.forEach(function(e){n.push({namespace:i.join("."),name:e,api:r})}),a.forEach(function(e){t(r[e],i.concat(e))})}var o=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=[];return t(e),n}t.__esModule=!0;var a,s,u=(s=a=function(){function e(){n(this,e)}return e.prototype.onClientReady=function(e){var t=this;i(e).forEach(function(e){r(e.api,e.name,function(o){var n={api:e.api,namespace:e.namespace,name:e.name,displayName:e.namespace+"."+e.name};return t.onMethodBefore(n),function(){var e=void 0;try{e=o()}catch(e){throw n.error=e,t.onMethodThrown(n),e}finally{n.value=e,t.onMethodAfter(n),e&&"function"==typeof e.then&&e.then(function(e){n.resolved=e,t.onMethodResolve(n)},function(e){n.rejected=e,t.onMethodReject(n)}).then(function(){t.onMethodFinally(n)})}return e}})}),e.on("experimental.request.before",function(e){return t.onRequestBefore(e.data)}),e.on("experimental.request.after",function(e){return t.onRequestAfter(e.data)}),e.on("error.response",function(e){return t.onRequestReject(e.data)}),e.on("error.throttled",function(e){return t.onRequestThrottled(e.data)}),e.on("experimental.request.retry",function(e){return t.onRequestRetry(e.data)}),e.on("error.unauthorized",function(e){return t.onRequestUnauthorized(e.data)}),e.on("error.deprecated",function(e){return t.onRequestDeprecated(e.data)}),e.on("experimental.request.resolve",function(e){return t.onRequestResolve(e.data)}),e.on("experimental.request.finally",function(e){return t.onRequestFinally(e.data)})},e.prototype.onMethodBefore=function(){},e.prototype.onMethodAfter=function(){},e.prototype.onMethodReject=function(){},e.prototype.onMethodResolve=function(){},e.prototype.onMethodFinally=function(){},e.prototype.onMethodThrown=function(){},e.prototype.onRequestBefore=function(){},e.prototype.onRequestAfter=function(){},e.prototype.onRequestReject=function(){},e.prototype.onRequestThrottled=function(){},e.prototype.onRequestRetry=function(){},e.prototype.onRequestUnauthorized=function(){},e.prototype.onRequestDeprecated=function(){},e.prototype.onRequestResolve=function(){},e.prototype.onRequestFinally=function(){},e}(),a.__adapter__="IEnhancementAdapter",s);t.default=u},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=function(){function e(t){n(this,e),this.client=t}return e.prototype.auto=function(e,t){var o=this.client.adapters.getCacheAdapter(),n=function(){};return o?(n=function(t){void 0!==t&&o.set(e,t)},o.get(e).catch(function(){return Promise.resolve(t(n)).then(function(e){return n(e),e})})):Promise.resolve(t(n))},e}();t.default=r},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},a=o(39),s=n(a),u=o(15),f=n(u),c=o(16),l=n(c),p=o(2),d=function(){function e(t,o){if(r(this,e),this.name=t,this.endpoint=s.default[t],!this.endpoint)throw new Error('Unknown request endpoint "'+t+'".');this.params={},this.addParams(o),this.headers={}}return e.prototype.addHeaders=function(e){return this.headers=i({},this.headers,e),this},e.prototype.addHeader=function(e,t){return this.headers[e]=t,this},e.prototype.addParams=function(e){return this.params=i({},this.params,e),this},e.prototype.addParam=function(e,t){this.params[e]=t},e.prototype.getPath=function(){var e=this,t=this.endpoint,o=t.path,n=t.chain,r=t.trailing,i=o;return n&&n.forEach(function(t){"/"!==i[i.length-1]&&(i+="/"),i+=e.params[t]}),r&&"/"!==i[i.length-1]&&(i+="/"),i},e.prototype.getQuery=function(){var e=this,t=this.endpoint.query;if(t){var o=t.map(function(t){return void 0!==e.params[t]?t+"="+encodeURIComponent(e.params[t]):null}).filter(Boolean).join("&");if(o)return"?"+o}return""},e.prototype.getHeaders=function(){var e,t=i({},this.headers,(e={},e[p.SDK_VERSION_HEADER]=l.default,e));if("POST"===this.endpoint.method)switch(this.endpoint.version){case 2:t["Content-Type"]="application/json";break;case 1:default:t["Content-Type"]="application/x-www-form-urlencoded"}return t},e.prototype.getBody=function(){var e=this,t=this.endpoint;if(t.body){if("string"==typeof t.body){var o=this.params[t.body];return o=(0,f.default)(o)?JSON.stringify(o):String(o)}var n=!0===t.body?Object.keys(this.params):t.body,r={};switch(n.forEach(function(t){var o=e.params[t];void 0!==o&&(r[t]=o)}),t.version){case 2:return JSON.stringify(r);case 1:default:return Object.keys(r).map(function(t){return t+"="+encodeURIComponent(e.params[t])}).join("&")}}return null},e.prototype.getMethod=function(){return(this.endpoint.method||"GET").toUpperCase()},e.prototype.isWithCredentials=function(){return!0===this.endpoint.credentials},e.prototype.build=function(){return{method:this.getMethod(),path:this.getPath(),query:this.getQuery(),body:this.getBody(),headers:this.getHeaders(),credentials:this.isWithCredentials()}},e}();t.default=d},function(e,t){e.exports={"accounts.register":{method:"POST",path:"/api/users/register",body:["email","password","privateKey","publicKey"],anonymous:!0},"accounts.login":{method:"POST",path:"/api/users/login",body:["email","password"],anonymous:!0},"accounts.generate-activation-code":{method:"GET",path:"/api/users/auth/generate",chain:["userId"],trailing:!0},"accounts.activate":{method:"POST",path:"/api/users/auth/activate",body:["userId","authCode"],trailing:!0},"accounts.logout":{method:"GET",path:"/api/users/logout"},"profile.upload-avatar":{method:"POST",path:"/api/media/file/avatar",body:["uploadedImage"]},"profile.change-password":{method:"POST",path:"/api/users/changepassword",body:["oldPassword","newPassword","newPrivateKey"],trailing:!0},"dashboard.inbox":{method:"GET",path:"/api/proofs/dashboard/proofin",trailing:!0},"dashboard.sent":{method:"GET",path:"/api/proofs/dashboard/proofout",trailing:!0},"dashboard.outbox":{method:"GET",path:"/api/proofs/dashboard/proofoutbox",trailing:!0},"dashboard.search":{method:"POST",path:"/api/proofs/search",body:["query","all","filterBy"]},"users.by-id":{method:"GET",path:"/api/users",chain:["userId"]},"users.by-email":{method:"POST",path:"/api/users/email",body:["email"],trailing:!0},"users.invite":{method:"POST",path:"/api/users/create",body:["email"]},"proofs.create":{method:"POST",path:"/api/proofs/create",body:["title","dueDate","description","groupId"]},"proofs.normalize-workflow":{method:"POST",path:"/api/proofs/permission/check",body:["proofId","workflowId"]},"proofs.set-workflow":{method:"POST",path:"/api/proofs/update",body:["proofId","workflowId"]},"proofs.set-tags":{method:"POST",path:"/api/tags/create",body:["relatedId","tag"]},"proofs.set-file":{method:"POST",path:"/api/proofs/update",body:["proofId","fileId"]},"proofs.distribute-file":{method:"GET",path:"/api/proofs/distribute",chain:["proofId"],trailing:!0},"proofs.archive":{method:"GET",path:"/api/proofs/close",chain:["proofId"],trailing:!0},"proofs.unarchive":{method:"GET",path:"/api/proofs/reopen",chain:["proofId"],trailing:!0},"proofs.delete":{method:"GET",path:"/api/proofs/delete",chain:["proofId"],trailing:!0},"proofs.start":{method:"POST",path:"/api/proofs/startworkflow",body:["proofId"],trailing:!0},"proofs.editors.add":{version:2,method:"POST",path:"/api/proofs/editor/add",body:["proofId","editors","editorMessage"]},"proofs.editors.remove":{version:2,method:"POST",path:"/api/proofs/editor/remove",body:["proofId","editors"]},"proofs.editors.replace":{version:2,method:"POST",path:"/api/proofs/editor/replace",body:["proofId","oldEditors","newEditors"]},"proofs.editors.set":{version:2,method:"POST",path:"/api/proofs/editor/set",body:["proofId","editors"]},"briefs.start":{method:"POST",path:"/api/briefs/start",body:["briefId"]},"proofs.return":{method:"GET",path:"/api/proofs/returnproof",chain:["proofId"]},"proofs.groups.create":{method:"POST",path:"/api/proofs/groups/create",body:["name"]},"proofs.groups.update":{method:"POST",path:"/api/proofs/groups/update",body:["groupId","name"]},"proofs.groups.load":{method:"GET",path:"/api/proofs/group",chain:["groupId"]},"proofs.groups.ready":{method:"POST",path:"/api/proofs/groups/ready",body:["groupId"]},"proofs.groups.owners.add":{version:2,method:"POST",path:"/api/v2/proofs/owners/groups/add",body:["groupId","owners"]},"proofs.groups.workflows.add-reviewers":{version:2,method:"POST",path:"/api/v2/workflows/groups/reviewers/add",body:["groupId","reviewers"]},"proofs.versions.attach":{method:"POST",path:"/api/proofs/versions/create",body:["proofId","versionId"]},"proofs.versions.list":{method:"GET",path:"/api/proofs/versions",chain:["proofId"],trailing:!0},"proofs.load":{method:"GET",path:"/api/proofs/",chain:["proofId"],trailing:!0},"proofs.lock":{method:"GET",path:"/api/proofs/lock/",chain:["proofId"],trailing:!0},"proofs.unlock":{method:"GET",path:"/api/proofs/unlock/",chain:["proofId"],trailing:!0},"proofs.request-unlock":{method:"GET",path:"/api/proofs/unlockemail/",chain:["proofId"],trailing:!0},"files.generate-token":{method:"GET",path:"/api/media/getfiletoken",query:["relatedId","fileType"]},"files.upload-block":{method:"POST",path:"/api/media/file",query:["block","part","token"],body:"data"},"files.upload-complete":{method:"POST",path:"/api/media/file",query:["block","blockCount","part","token","extn","pages","filename","storeoriginal"],body:"envelope"},"files.details":{method:"GET",path:"/api/media/file/details",chain:["fileId"]},"files.download-block":{method:"GET",path:"/api/media/getfilechunk",chain:["proofId","fileId","block"]},"files.thumbnail":{method:"GET",path:"/api/media/getimage/thumb",chain:["fileId"]},"files.import.generic":{method:"POST",path:"/api/media/filedrive",body:["extn","filename","url","envelope","storeOriginal"]},"files.import.drive":{method:"POST",path:"/api/media/filedrive",body:["extn","filename","url","envelope","storeOriginal","accessToken"]},"files.import.onedrive":{method:"POST",path:"/api/media/fileonedrive",body:["extn","filename","url","envelope","storeOriginal","accessToken"]},"files.import.box":{method:"POST",path:"/api/media/filebox",body:["extn","filename","url","envelope","storeOriginal","accessToken"]},"files.import.dropbox":{method:"POST",path:"/api/media/filedropbox",body:["extn","filename","url","envelope","storeOriginal","accessToken"]},"workflows.create":{version:2,method:"POST",path:"/api/v2/workflows/create",body:["title"]},"workflows.load":{version:2,method:"GET",path:"/api/v2/workflows/detail",chain:["workflowId"]},"workflows.steps.add":{version:2,method:"POST",path:"/api/v2/workflows/steps/add",body:["workflowId","title","position"]},"workflows.steps.move-before":{method:"POST",path:"/api/workflows/step/movebefore",body:["stepId","beforeStepId"]},"workflows.steps.move-after":{method:"POST",path:"/api/workflows/step/moveafter",body:["stepId","afterStepId"]},"workflows.steps.swap":{method:"POST",path:"/api/workflows/step/swap",body:["stepId","swapStepId"]},"workflows.users.set":{version:2,method:"POST",path:"/api/v2/workflows/users/set",body:["workflowId","stepId","position","users"]},"workflows.users.update":{version:2,method:"POST",path:"/api/v2/workflows/users/update",body:["workflowId","stepId","userId","role","permissions"]},"workflows.users.add":{version:2,method:"POST",path:"/api/v2/workflows/users/add",body:["workflowId","stepId","users"]},"workflows.delete":{method:"POST",path:"/api/workflows/delete",body:["workflowId"]},"workflows.duplicate":{method:"POST",path:"/api/workflows/duplicateonly",body:["workflowId"]},"workflows.owned":{method:"GET",path:"/api/workflows",trailing:!0},"workflows.shared":{method:"GET",path:"/api/workflows/share/user",trailing:!0},"comments.load-all":{method:"POST",path:"/api/proofs/recent",body:["proofId","timestamp"]},"comments.load-page":{method:"POST",path:"/api/proofs/comment/recent",body:["proofId","timestamp","page"]},"comments.state.update":{method:"POST",path:"/api/proofs/comment/updatestatus",body:["commentId","change","done"]},"comments.create":{method:"POST",path:"/api/proofs/comment/create",body:["proofId","page","envelope","encryptedComment","xy","parent","mentions","metadata","creationToken","change","done"]},"proofs-owners.add":{version:2,method:"POST",path:"/api/v2/proofs/owners/add",body:["proofId","users"]},"proofs-owners.remove":{version:2,method:"POST",path:"/api/v2/proofs/owners/remove",body:["proofId","users"]},"proofs.tag-delete":{method:"POST",path:"/api/tags/delete",body:["relatedId","tag"]},"proofs.remove-editor":{method:"GET",path:"/api/proofs/deleteeditor",chain:["proofId"],trailing:!0},"briefs.create":{method:"POST",path:"/api/briefs/create",body:["title","messageToRecipient","dueDate","tag"]},"briefs.update":{method:"POST",path:"/api/briefs/update",body:["briefId","title","messageToRecipient","dueDate","tag","recipient","editorId","editorMessage"]},"admin.team.users.enabled":{method:"GET",path:"/api/admin/getusers/active",trailing:!0},"admin.team.users.disabled":{method:"GET",path:"/api/admin/getusers/inactive",trailing:!0},"admin.team.users.set-enabled":{method:"POST",path:"/api/admin/setenabled",body:["email","enabled"]},"sessions.check":{method:"GET",path:"/api/sessions/check"},"sso.get-public-key":{method:"GET",path:"/sso/public_key",anonymous:!0},"sso.get-session":{version:2,method:"POST",path:"/sso/session",body:["nonce"],anonymous:!0,credentials:!0},"sso.get-login-options":{version:2,method:"POST",path:"/sso/login_options",body:["email"],anonymous:!0}}},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(8),a=n(i),s=o(41),u=o(2),f=o(9),c=n(f),l=function(){function e(){r(this,e),this.error=!1,this.code=-1,this.data=null,this.message=null,this.deprecated=null}return e.parse=function(t){var o=t.status,n=t.headers,r=void 0===n?{}:n,i=t.body,f=new e;if(o===s.TOO_MANY_REQUESTS_STATUS)return f.error=!0,f.message="PageProof Error #h"+s.TOO_MANY_REQUESTS_STATUS,f.code=a.default.ERROR_THROTTLED,f.data={timeout:1e3*(parseFloat(r[u.RETRY_AFTER_HEADER])||60)},f;if((0,c.default)(r,"deprecated")&&(f.deprecated=r.deprecated),o===s.OK_STATUS&&!i)return f.code=a.default.OK,f;try{var l=JSON.parse(i);"string"==typeof l||(l&&"ResponseCode"in l?(f.code=l.ResponseCode,f.code!==a.default.OK&&(f.error=!0)):l.Message&&1===Object.keys(l).length&&(f.error=!0,f.code=a.default.ERROR_CRITICAL)),f.error&&(f.message="PageProof Error #s"+f.code),f.data=l}catch(e){f.error=!0}return f},e}();t.default=l},function(e,t,o){"use strict";t.__esModule=!0;t.TOO_MANY_REQUESTS_STATUS=429,t.OK_STATUS=200},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(0),u=n(s),f=o(6),c=n(f),l=o(43),p=n(l),d=function(e){function t(o){r(this,t);var n=i(this,e.call(this,o));return n.sso=new p.default(o),n}return a(t,e),t.prototype.register=function(e,t){var o=this;return this.client.crypto().generatePasswordHash(t).then(function(e){return Promise.all([e,o.client.crypto().generateKeyPair()])}).then(function(e){var n=e[0],r=e[1];return Promise.all([n,r,o.client.crypto().encryptPrivateKey(r.privateKeyPEM,t)])}).then(function(t){var n=t[0],r=t[1],i=t[2];return Promise.all([r,o.client.request("accounts.register",{email:e,password:n,privateKey:i,publicKey:r.publicKeyPEM})])}).then(function(n){var r=n[0];return Promise.all([r,o.login(e,t,!1)])}).then(function(e){var t=e[0],n=e[1];return Promise.all([t,n,o.generateActivationCode()])}).then(function(e){var t=e[0],o=e[1];return o.privateKeyPEM=t.privateKeyPEM,o})},t.prototype.generateActivationCode=function(){return this.client.request("accounts.generate-activation-code",{userId:this.client.session.userId})},t.prototype.activate=function(e){var t=this;return this.client.request("accounts.activate",{userId:this.client.session.userId,authCode:e}).then(function(){t.client.session.user.hasActivated=!0})},t.prototype.login=function(e,t){var o=this,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return this.client.crypto().generatePasswordHash(t).then(function(t){return o.client.request("accounts.login",{email:e,password:t})}).then(function(t){var o=(new c.default).fromSession(t.data);return o.user.email=e,o}).then(function(e){return n?o.client.crypto().decryptPrivateKey(e.privateKeyPEM$,t).then(function(t){return e.privateKeyPEM=t,e}):e}).then(function(e){return o.client.setSession(e),e})},t.prototype.logout=function(){var e=this;return this.client.request("accounts.logout").catch(function(t){return e.client.setSession(null),Promise.reject(t)}).then(function(){e.client.setSession(null)})},t}(u.default);t.default=d},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(0),u=n(s),f=o(6),c=n(f),l=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.getSession=function(){var e=this;return this.client.request("sso.get-public-key").then(function(e){return e.data.ServerPublicKey}).then(function(t){return e.client.crypto().generateWrappedSymmetricKey(t)}).then(function(t){var o=t.key,n=t.key$;return Promise.all([o,e.client.request("sso.get-session",{nonce:n})])}).then(function(t){var o=t[0],n=t[1],r=(new c.default).fromSession(n.data);return Promise.all([r,e.client.crypto().decryptManagedPrivateKey(r.privateKeyPEM$,o)])}).then(function(e){var t=e[0],o=e[1];return t.privateKeyPEM=o,t})},t.prototype.getLoginOptions=function(e){return this.client.request("sso.get-login-options",{email:e}).then(function(e){return e.data})},t}(u.default);t.default=l},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){var t={};return Object.keys(d).forEach(function(o){t[o]=e[d[o]]}),t}function u(e){return(e||[]).map(function(e){return(new p.default).fromProof(e)})}t.__esModule=!0;var f=o(0),c=n(f),l=o(4),p=n(l),d={inbox:"ProofIn",sent:"ProofOut",outbox:"ProofOutBox"},h=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.inbox=function(){return this._loadSingleTabProofs("inbox")},t.prototype.sent=function(){return this._loadSingleTabProofs("sent")},t.prototype.outbox=function(){return this._loadSingleTabProofs("outbox")},t.prototype._loadSingleTabProofs=function(e){return this.client.request("dashboard."+e).then(function(e){return s(e.data)}).then(function(t){return t[e]}).then(u)},t.prototype.search=function(e){return this._loadSearchProofs({query:e})},t.prototype.everything=function(){return this._loadSearchProofs({all:1})},t.prototype.approved=function(){return this._loadSearchProofs({filterBy:70})},t.prototype.archived=function(){return this._loadSearchProofs({filterBy:100})},t.prototype._loadSearchProofs=function(e){return this.client.request("dashboard.search",e).then(function(e){return u(e.data.Proofs)})},t}(c.default);t.default=h},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){return e.data.length>0?(new p.default).fromUser(e.data[0]):(new p.default).fromUser(e.data)}function u(e){return e.data.length?(new p.default).fromUser(e.data[0]):null}t.__esModule=!0;var f=o(0),c=n(f),l=o(3),p=n(l),d=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.byEmail=function(e){return this.client.request("users.by-email",{email:e}).then(u)},t.prototype.byId=function(e){return this.client.request("users.by-id",{userId:e}).then(s)},t.prototype.invite=function(e){return this.client.request("users.invite",{email:e}).then(s)},t}(c.default);t.default=d},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(0),u=n(s),f=o(47),c=n(f),l=o(48),p=n(l),d=o(49),h=n(d),y=o(50),m=n(y),w=o(4),v=n(w),_=o(5),b=n(_),E=o(2),g=function(e){function t(o){r(this,t);var n=i(this,e.call(this,o));return n.owners=new c.default(o),n.editors=new p.default(o),n.versions=new h.default(o),n.groups=new m.default(o),n}return a(t,e),t.prototype.setWorkflow=function(e,t){var o=this;return this.client.request("proofs.normalize-workflow",{proofId:e,workflowId:t}).then(function(){return o.client.request("proofs.set-workflow",{proofId:e,workflowId:t})})},t.prototype.setTags=function(e,t){return this.client.request("proofs.set-tags",{relatedId:e,tag:t.join(",")})},t.prototype.deleteTag=function(e,t){return this.client.request("proofs.tag-delete",{relatedId:e,tag:t})},t.prototype.setFile=function(e,t){var o=this;return this.client.request("proofs.set-file",{proofId:e,fileId:t}).then(function(){return o.client.request("proofs.distribute-file",{proofId:e})})},t.prototype.create=function(e){var t=this,o=e.name,n=e.tags,r=void 0===n?[]:n,i=e.dueDate,a=void 0===i?new Date(Date.now()+3*E.DAY_IN_MS):i,s=e.messageToReviewers,u=e.workflow,f=e.file,c=e.group,l=e.start,p=void 0===l||l,d=p&&!c;return this.client.request("proofs.create",{title:o,dueDate:a.toISOString(),description:s,groupId:c?c.id:void 0}).then(function(e){var o=(new v.default).fromProof(e.data);return Promise.all([o,r.length&&t.setTags(o.id,r),u&&t.setWorkflow(o.id,u.id),f&&t.setFile(o.id,f.id)])}).then(function(e){var o=e[0];return Promise.resolve(d&&t.start(o.id)).then(function(){return o})}).then(function(e){return u&&(e.workflowId=u.id),f&&(e.fileId=f.id,e.fileStatus=b.default.UPLOADING),e.calculateState(),e})},t.prototype.archive=function(e){return this.client.request("proofs.archive",{proofId:e})},t.prototype.unarchive=function(e){return this.client.request("proofs.unarchive",{proofId:e})},t.prototype.delete=function(e){return this.client.request("proofs.delete",{proofId:e})},t.prototype.return=function(e){return this.client.request("proofs.return",{proofId:e})},t.prototype.start=function(e){return this.client.request("proofs.start",{proofId:e})},t.prototype.removeEditor=function(e){return this.client.request("proofs.remove-editor",{proofId:e})},t.prototype.load=function(e){return this.client.request("proofs.load",{proofId:e}).then(function(e){return(new v.default).fromProof(e.data)})},t.prototype.lock=function(e){return this.client.request("proofs.lock",{proofId:e})},t.prototype.unlock=function(e){return this.client.request("proofs.unlock",{proofId:e})},t.prototype.requestUnlock=function(e){return this.client.request("proofs.request-unlock",{proofId:e})},t}(u.default);t.default=g},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=o(0),s=function(e){return e&&e.__esModule?e:{default:e}}(a),u=function(e){function t(){return n(this,t),r(this,e.apply(this,arguments))}return i(t,e),t.prototype.add=function(e,t){return this.client.request("proofs-owners.add",{proofId:e,users:[].concat(t)})},t.prototype.remove=function(e,t){return this.client.request("proofs-owners.remove",{proofId:e,users:[].concat(t)})},t}(s.default);t.default=u},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=o(0),s=function(e){return e&&e.__esModule?e:{default:e}}(a),u=function(e){function t(){return n(this,t),r(this,e.apply(this,arguments))}return i(t,e),t.prototype.add=function(e,t,o){var n={proofId:e,editors:[].concat(t),editorMessage:null===o?"":o};return this.client.request("proofs.editors.add",n)},t.prototype.remove=function(e,t){return this.client.request("proofs.editors.remove",{proofId:e,editors:[].concat(t)})},t.prototype.replace=function(e,t,o){return this.client.request("proofs.editors.replace",{proofId:e,oldEditors:[].concat(t),newEditors:[].concat(o)})},t.prototype.set=function(e,t){return this.client.request("proofs.editors.set",{proofId:e,editors:[].concat(t)})},t}(s.default);t.default=u},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(0),u=n(s),f=o(20),c=n(f),l=o(21),p=(0,l.sortObjectsByKey)("version"),d=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.attach=function(e,t){return this.client.request("proofs.versions.attach",{proofId:e,versionId:t})},t.prototype.list=function(e){return this.client.request("proofs.versions.list",{proofId:e}).then(function(e){return e.data.map(function(e){return(new c.default).fromProofVersion(e)}).sort(p)})},t}(u.default);t.default=d},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){return(new l.default).fromProofGroup(e.data)}t.__esModule=!0;var u=o(0),f=n(u),c=o(22),l=n(c),p=o(51),d=n(p),h=o(52),y=n(h),m=function(e){function t(o){r(this,t);var n=i(this,e.call(this,o));return n.owners=new d.default(o),n.workflows=new y.default(o),n}return a(t,e),t.prototype.create=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.name;return this.client.request("proofs.groups.create",{name:t}).then(s)},t.prototype.load=function(e){return this.client.request("proofs.groups.load",{groupId:e}).then(s)},t.prototype.ready=function(e){return this.client.request("proofs.groups.ready",{groupId:e})},t.prototype.update=function(e,t){var o=t.name;return this.client.request("proofs.groups.update",{groupId:e,name:o}).then(s)},t}(f.default);t.default=m},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=o(0),s=function(e){return e&&e.__esModule?e:{default:e}}(a),u=function(e){function t(){return n(this,t),r(this,e.apply(this,arguments))}return i(t,e),t.prototype.add=function(e,t){return this.client.request("proofs.groups.owners.add",{groupId:e,owners:[].concat(t)})},t}(s.default);t.default=u},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=o(0),s=function(e){return e&&e.__esModule?e:{default:e}}(a),u=function(e){function t(){return n(this,t),r(this,e.apply(this,arguments))}return i(t,e),t.prototype.addReviewers=function(e,t){return this.client.request("proofs.groups.workflows.add-reviewers",{groupId:e,reviewers:[].concat(t)})},t}(s.default);t.default=u},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(0),u=n(s),f=o(4),c=n(f),l=o(5),p=n(l),d=o(2),h=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.setTags=function(e,t){return this.client.request("proofs.set-tags",{relatedId:e,tag:t.join(",")})},t.prototype.deleteTag=function(e,t){return this.client.request("proofs.tag-delete",{relatedId:e,tag:t})},t.prototype.setFile=function(e,t){var o=this;return this.client.request("proofs.set-file",{proofId:e,fileId:t}).then(function(){return o.client.request("proofs.distribute-file",{proofId:e})})},t.prototype.create=function(e){var t=this,o=e.name,n=e.file,r=e.tags,i=void 0===r?[]:r,a=e.dueDate,s=void 0===a?new Date(Date.now()+3*d.DAY_IN_MS):a;return this.client.request("briefs.create",{title:o,messageToRecipient:"",dueDate:s.toISOString(),tag:i.join(",")}).then(function(e){var o=(new c.default).fromProof(e.data.Brief);return Promise.all([o,n&&t.setFile(o.id,n.id)])}).then(function(e){var t=e[0];return n&&(t.fileId=n.id,t.fileStatus=p.default.UPLOADING),t.calculateState(),t})},t.prototype.update=function(e){var t=this,o=e.briefId,n=e.data,r=e.start,i=void 0!==r&&r;return this.client.request("briefs.update",{briefId:o,title:n.title,messageToRecipient:n.messageToRecipient,dueDate:n.dueDate?n.dueDate.toISOString():"",tag:n.tags?n.tags.join(","):"",recipient:n.recipient,editorId:n.editorId,editorMessage:n.editorMessage}).then(function(e){return(new c.default).fromProof(e.data.Brief)}).then(function(e){return Promise.resolve(i&&t.start(e.id)).then(function(){return e})})},t.prototype.delete=function(e){return this.client.request("proofs.delete",{proofId:e})},t.prototype.start=function(e){return this.client.request("briefs.start",{briefId:e})},t}(u.default);t.default=h},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){var t=e.lastIndexOf(".");return{name:(0,O.default)(e.substring(0,t)),extension:e.substring(t+1)}}t.__esModule=!0;var u=o(0),f=n(u),c=o(10),l=n(c),p=o(5),d=n(p),h=o(23),y=n(h),m=o(55),w=n(m),v=o(7),_=n(v),b=o(60),E=n(b),g=o(61),O=n(g),P=o(2),I=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.generateToken=function(e,t){return e&&!t?Promise.reject(Error('The "assignedType" option is required when specifying the "assignedTo" option.')):!e&&t?Promise.reject(Error('The "assignedTo" option is required when specifying the "assignedType" option.')):this.client.request("files.generate-token",{relatedId:e,fileType:t}).then(function(e){return e.data.Token})},t.prototype._waitFileProcessed=function(e){var t=this;return new Promise(function(o,n){var r=null,i=null;!function a(){t.details(e).then(function(t){switch(r=null,t.status){case d.default.OK:o(t);break;case d.default.ERROR:n(new Error("File "+e+" encountered a processing error: "+t.message));break;default:r=setTimeout(a,5e3)}r&&t.status!==d.default.RIPPING||clearTimeout(i)}).catch(n)}(),i=setTimeout(function(){clearTimeout(r),n(new Error("File did not finish processing within specified duration."))},3e4)})},t.prototype.import=function(e){var t=this,o=e.name,n=e.url,r=e.provider,i=void 0===r?y.default.NONE:r,a=e.auth,u=e.download,f=void 0!==u&&u,c=e.process,p=void 0!==c&&c;if(!Object.keys(y.default).some(function(e){return y.default[e]===i}))return Promise.reject(new Error('Unsupported provider "'+i+'"'));var d=i;i===y.default.NONE&&(d="generic");var h=s(o),m=h.name,w=h.extension;return this._generateKeyIVEnvelope().then(function(e){var o=e.envelope;return t.client.request("files.import."+d,{extn:w,filename:m,url:n,envelope:o,accessToken:a,storeOriginal:f})}).then(function(e){return e.data}).then(function(e){if(p)return t._waitFileProcessed(e);var o=new l.default;return o.id=e,o})},t.prototype._generateKeyIVEnvelope=function(){var e=this;return this.client.crypto().generateKeyIV().then(function(t){return Promise.all([t,e.client.crypto().envelopeSeal(t.keyIV,[e.client.session.serverPublicKeyPEM,e.client.session.publicKeyPEM])])}).then(function(e){return{keyIV:e[0],envelope:e[1]}})},t.prototype.upload=function(e){var t=this,o=e.name,n=e.contents,r=e.assignedTo,i=e.assignedType,a=e.download,s=void 0!==a&&a,u=e.async,f=void 0===u||u,c=e.onProgress,p=e.onError;return this.generateToken(r,i).then(function(e){return Promise.all([e,t._generateKeyIVEnvelope()])}).then(function(e){var r=e[0],i=e[1],a=i.keyIV,u=i.envelope,l=t._upload({name:o,contents:n,download:s,token:r,keyIV:a,envelope:u,onProgress:c,onError:p});return f&&(l=Promise.resolve()),l.then(function(){return r})}).then(function(e){var t=new l.default;return t.id=e,t})},t.prototype._upload=function(e){var t=this,o=e.name,n=e.contents,r=e.download,i=e.token,a=e.keyIV,u=e.envelope,f=e.onProgress;return new Promise(function(e){function c(){y().then(function(t){if(!_)if(null===t)_=!0,e(m.then(T));else{var o=I(t,v++);m=m.then(function(){return o}),o.then(c)}})}var l=4,p=s(o),d=p.name,h=p.extension,y=(0,w.default)(n),m=Promise.resolve(),v=0,_=!1,b=Math.ceil((0,E.default)(n)/P.BYTES_PER_BLOCK),g=new Array(b),O=function(){};f&&(O=function(e,t){g[e]=Math.max(t,g[e]||0),f(g.reduce(function(e,t){return e+(t||0)},0)/b*.99)});for(var I=function(e,o){return t.client.crypto().encryptFileBlock(a,e).then(function(e){return t.client.request("files.upload-block",{block:o,part:1,token:i,data:e},{onUploadProgress:O.bind(null,o)})})},T=function(){return t.client.request("files.upload-complete",{block:0,blockCount:v,part:0,token:i,extn:h,pages:1,filename:d,storeoriginal:r?1:0,envelope:u}).then(function(){return f&&f(100)})};l--;)c()})},t.prototype.download=function(e){var t=this,o="string"==typeof e?{fileId:e}:e,n=o.fileId;return this.details(n).then(function(e){if(!e.downloadable)throw new Error("File "+n+" is not downloadable.");if(e.status!==d.default.OK)throw new Error("File "+n+" cannot be download. The file may still be uploading, processing or has errored.");if(!e.blocks)throw new Error("File "+n+" is empty.");return t._downloadFile(e,o)})},t.prototype._downloadFile=function(e,t){var o=this;return new Promise(function(n){function r(){if(!y)if(h<u.length){var e=h++,t=d(e);f=f.then(function(){return t.then(function(t){return c(t,e,s)})}),t.then(r)}else y=!0,n(f.then(m))}var i=4,a=new _.default,s=e.blocks,u=new Array(s),f=Promise.resolve(),c=t.onData||function(e,t){u[t]=e},l=function(){};if(t.onProgress){var p=new Array(s);l=function(e,o){p[e]=Math.max(o,p[e]||0),t.onProgress(p.reduce(function(e,t){return e+(t||0)},0)/s*.99)}}for(var d=function(t){return o.client.request("files.download-block",{proofId:e.assignedTo,fileId:e.id,block:t+1},{onDownloadProgress:l.bind(null,t)}).then(function(e){return o.client.crypto().decryptFileBlock(e.data,o.client.session.privateKeyPEM).then(function(e){return a.createBase64(e)})})},h=0,y=!1,m=function(){return t.onProgress&&t.onProgress(100),t.onData?null:a.combine.apply(a,u)};i--;)r()})},t.prototype.details=function(e){return this.client.request("files.details",{fileId:e}).then(function(e){return(new l.default).fromFile(e.data)})},t.prototype.thumbnail=function(e){var t=this;return this.client.cache.auto(P.THUMBNAIL_CACHE_PREFIX+e,function(){return t._thumbnail(e)})},t.prototype._thumbnail=function(e){var t=this;return this.client.request("files.thumbnail",{fileId:e}).then(function(e){return t.client.crypto().decryptImage(e.data,t.client.session.privateKeyPEM)}).then(function(e){return(new _.default).createBase64(e)})},t.prototype.thumbnails=function(e,t){var o=this,n=t.async,r=void 0!==n&&n,i=t.onLoadThumbnails,a=[];return Promise.all(e.map(function(e){return o.client.cache.auto(P.THUMBNAIL_CACHE_PREFIX+e,function(t){a.push({fileId:e,resolve:t})}).then(function(t){var o;return t&&(o={},o[e]=t,o)})})).then(function(e){var t=Promise.all(a.map(function(e){var t=e.fileId,n=e.resolve;return o._thumbnail(t).then(function(e){if(n(e),r){var o;i((o={},o[t]=e,o))}return e})}));return r?e:t.then(function(t){return[].concat(e,t)})}).then(function(e){return Object.assign.apply(Object,[{}].concat(e))})},t}(f.default);t.default=I},function(e,t,o){"use strict";function n(e){var t=new a.default,o=0,n=Promise.resolve(),i=t.size(e);return function(){var a=o++*r.BYTES_PER_BLOCK,s=a+r.BYTES_PER_BLOCK;return n=n.then(function(){return a>i?null:t.slice(e,a,s).then(t.readBase64).then(function(e){return"data:;base64,"+e})})}}t.__esModule=!0;var r=o(2),i=o(7),a=function(e){return e&&e.__esModule?e:{default:e}}(i);t.default=n},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e){for(var t=new ArrayBuffer(e.length),o=new Uint8Array(t),n=0;n<e.length;n++)o[n]=e.charCodeAt(n);return t}t.__esModule=!0;var i=function(){function e(){n(this,e)}return e.prototype.create=function(e){return Promise.resolve(new Blob([r(e)]))},e.prototype.createBase64=function(e){return this.create(atob(e))},e.prototype.combine=function(){for(var e=arguments.length,t=Array(e),o=0;o<e;o++)t[o]=arguments[o];return Promise.resolve(new Blob(t))},e.prototype.slice=function(e,t,o){return Promise.resolve(e.slice(t,o))},e.prototype.read=function(e){return new Promise(function(t,o){var n=new FileReader;n.onload=function(){t(n.result)},n.onerror=function(){o(n.error)},n.readAsText(e)})},e.prototype.readBase64=function(e){return new Promise(function(t,o){var n=new FileReader;n.onload=function(){var e=n.result;t(e.substring(e.indexOf(",")+1))},n.onerror=function(){o(n.error)},n.readAsDataURL(e)})},e.prototype.size=function(e){return e.size},e}();t.default=i},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=function(){function e(){n(this,e)}return e.prototype.create=function(e){return Promise.resolve(Buffer.from(e))},e.prototype.createBase64=function(e){return Promise.resolve(Buffer.from(e,"base64"))},e.prototype.combine=function(){for(var e=arguments.length,t=Array(e),o=0;o<e;o++)t[o]=arguments[o];return Promise.resolve(Buffer.concat(t))},e.prototype.slice=function(e,t,o){return Promise.resolve(e.slice(t,o))},e.prototype.read=function(e){return Promise.resolve(e.toString())},e.prototype.readBase64=function(e){return Promise.resolve(e.toString("base64"))},e.prototype.size=function(e){return Buffer.byteLength(e)},e}();t.default=r},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e){for(var t=e.length,o=e.length-1;o>=0;o--){var n=e.charCodeAt(o);n>127&&n<=2047?t++:n>2047&&n<=65535&&(t+=2),n>=56320&&n<=57343&&o--}return t}t.__esModule=!0;var i=o(59),a=function(){function e(){n(this,e)}return e.prototype.create=function(e){return Promise.resolve(e)},e.prototype.createBase64=function(e){return Promise.resolve((0,i.atob)(e))},e.prototype.combine=function(){for(var e=arguments.length,t=Array(e),o=0;o<e;o++)t[o]=arguments[o];return Promise.resolve(t.join(""))},e.prototype.slice=function(e,t,o){return Promise.resolve(e.slice(t,o))},e.prototype.read=function(e){return Promise.resolve(e)},e.prototype.readBase64=function(e){return Promise.resolve((0,i.btoa)(e))},e.prototype.size=function(e){return r(e)},e}();t.default=a},function(e,t,o){!function(){function e(e){this.message=e}var o=t,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";e.prototype=new Error,e.prototype.name="InvalidCharacterError",o.btoa||(o.btoa=function(t){for(var o,r,i=String(t),a=0,s=n,u="";i.charAt(0|a)||(s="=",a%1);u+=s.charAt(63&o>>8-a%1*8)){if((r=i.charCodeAt(a+=.75))>255)throw new e("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");o=o<<8|r}return u}),o.atob||(o.atob=function(t){var o=String(t).replace(/[=]+$/,"");if(o.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,i,a=0,s=0,u="";i=o.charAt(s++);~i&&(r=a%4?64*r+i:i,a++%4)?u+=String.fromCharCode(255&r>>(-2*a&6)):0)i=n.indexOf(i);return u})}()},function(e,t,o){"use strict";function n(e){return"undefined"!=typeof Blob&&e instanceof Blob?e.size:0}t.__esModule=!0,t.default=n},function(e,t,o){"use strict";function n(e){return e.replace(/[-_()]/g,"").replace(/\s+/g," ").replace(/\s/g,"_")}t.__esModule=!0,t.default=n},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(0),u=n(s),f=o(63),c=n(f),l=function(e){function t(o){r(this,t);var n=i(this,e.call(this,o));return n.team=new c.default(o),n}return a(t,e),t}(u.default);t.default=l},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(0),u=n(s),f=o(64),c=n(f),l=function(e){function t(o){r(this,t);var n=i(this,e.call(this,o));return n.users=new c.default(o),n}return a(t,e),t}(u.default);t.default=l},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){return e.data.map(function(e){return(new l.default).fromUser(e)})}t.__esModule=!0;var u=o(0),f=n(u),c=o(3),l=n(c),p=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.enabled=function(){return this.client.request("admin.team.users.enabled").then(s)},t.prototype.disabled=function(){return this.client.request("admin.team.users.disabled").then(s)},t.prototype._setEnabled=function(e,t){return this.client.request("admin.team.users.set-enabled",{email:e,enabled:t})},t.prototype.enable=function(e){return this._setEnabled(e,!0)},t.prototype.disable=function(e){return this._setEnabled(e,!1)},t}(f.default);t.default=p},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){return e&&((0,w.isUserId)(e.id)||e.email)}function u(e){return(e||[]).map(function(e){return(new p.default).fromWorkflow(e)})}t.__esModule=!0;var f=o(0),c=n(f),l=o(24),p=n(l),d=o(12),h=n(d),y=o(13),m=n(y),w=o(19),v=o(66),_=n(v),b=function(e){function t(o){r(this,t);var n=i(this,e.call(this,o));return n.steps=new _.default(o),n}return a(t,e),t.prototype.create=function(e){var t=this,o=e.save,n=void 0!==o&&o,r=e.name,i=e.steps,a=void 0===i?[]:i,u=e.reviewers,f=e.approver;if(!s(f))return Promise.reject(Error("An approver is required to create a workflow."));if(n&&!r)return Promise.reject(Error("A workflow must have a name when saving it as a workflow template."));var c=a;u&&u.length&&c.splice(0,0,{users:u}),f&&c.push({position:1e3,users:[f]});for(var l=0,p=0;p<c.length;p++){var d=c[p];if(!d.users||!d.users.length)return Promise.reject(Error("Workflow steps must contain users."));(!d.position||d.position<l)&&(d.position=l+1),l=Math.max(l,d.position);for(var h=0;h<d.users.length;h++){if(!s(d.users[h]))return Promise.reject(Error("A user id or email address must be provided for a workflow user."))}}var y=void 0;return this._createWorkflow(r).then(function(e){return y=e.id,Promise.all([e,Promise.all(c.map(function(o){var n=e.getStepByPosition(o.position);return n?t._setWorkflowStepUsersMutate(e.id,n,o.users):t._addWorkflowStepAndUsers(e.id,o)}))])}).then(function(e){var t=e[0],o=e[1];return t.steps=o,t}).then(function(e){return n?t._duplicateWorkflow(y):e}).catch(function(e){return Promise.resolve(y&&t._deleteWorkflow(y)).then(function(){return Promise.reject(e)})})},t.prototype.load=function(e){return this.client.request("workflows.load",{workflowId:e}).then(function(e){return(new p.default).fromWorkflow(e.data)})},t.prototype.use=function(e){return this.duplicate(e)},t.prototype.duplicate=function(e){return this._duplicateWorkflow(e)},t.prototype.delete=function(e){return this._deleteWorkflow(e)},t.prototype.all=function(){return Promise.all([this.owned(),this.shared()]).then(function(e){return[].concat(e[0],e[1])})},t.prototype.owned=function(){return this.client.request("workflows.owned").then(function(e){return u(e.data)})},t.prototype.shared=function(){return this.client.request("workflows.shared").then(function(e){return u(e.data)})},t.prototype.setApprover=function(e,t){return this.client.request("workflows.users.set",{workflowId:e,position:1e3,users:[t]})},t.prototype._duplicateWorkflow=function(e){var t=this;return this.client.request("workflows.duplicate",{workflowId:e}).then(function(e){var o=e.data.WorkflowId;return t.load(o)})},t.prototype._deleteWorkflow=function(e){return this.client.request("workflows.delete",{workflowId:e})},t.prototype._createWorkflow=function(e){return this.client.request("workflows.create",{title:e}).then(function(e){return(new p.default).fromWorkflow(e.data)})},t.prototype._addWorkflowStepAndUsers=function(e,t){var o=this;return this.client.request("workflows.steps.add",{workflowId:e,title:t.name,position:t.position}).then(function(n){var r=(new h.default).fromWorkflowStep(n.data);return o._setWorkflowStepUsersMutate(e,r,t.users)})},t.prototype._setWorkflowStepUsersMutate=function(e,t,o){return this.client.request("workflows.users.set",{workflowId:e,stepId:t.id,users:o.map(function(e){return{email:e.email,userId:e.id,role:e.role,permissions:e.permissions&&{inviter:!!e.permissions.inviter}}})}).then(function(e){var o=e.data.map(function(e){return(new m.default).fromWorkflowUser(e)});return t.users=o,t})},t}(c.default);t.default=b},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=o(0),s=function(e){return e&&e.__esModule?e:{default:e}}(a),u=function(e){function t(){return n(this,t),r(this,e.apply(this,arguments))}return i(t,e),t.prototype.moveBefore=function(e,t){return this.client.request("workflows.steps.move-before",{stepId:e,beforeStepId:t})},t.prototype.moveAfter=function(e,t){return this.client.request("workflows.steps.move-after",{stepId:e,afterStepId:t})},t.prototype.swap=function(e,t){return this.client.request("workflows.steps.swap",{stepId:e,swapStepId:t})},t}(s.default);t.default=u},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){var t=[];return Object.keys(e).forEach(function(o){e[o].Comments.forEach(function(e){t.push(e)})}),t}function u(e){var t=[],o=[];e.forEach(function(e){var n=(new p.default).fromComment(e);n.parentCommentId?o.push(n):t.push(n)}),t.sort(P);var n=t.map(function(e){return e.id}),r=(0,m.sortObjectsBy)(function(e){return n.indexOf(e.parentCommentId)},!0);return o.sort((0,m.combineSort)(I,r)),t.concat(o)}t.__esModule=!0;var f=o(0),c=n(f),l=o(27),p=n(l),d=o(14),h=n(d),y=o(2),m=o(21),w=o(29),v=o(69),_=o(70),b=n(_),E=(0,m.sortObjectsByKey)("pageNumber"),g=(0,m.sortObjectsByKey)("createdDate",!0),O=(0,m.sortObjectsByKey)("createdDate",!1),P=(0,m.combineSort)(E,g),I=(0,m.combineSort)(E,O),T=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype._mark=function(e,t,o){var n,r=void 0;switch(t){case h.default.TODO:r="change";break;case h.default.DONE:r="done";break;default:throw new Error('Cannot mark comment state "'+t+'".')}var i=(n={commentId:e},n[r]=o?1:0,n);return this.client.request("comments.state.update",i).then(function(){return null})},t.prototype.mark=function(e,t){return this._mark(e,t,!0)},t.prototype.unmark=function(e,t){return this._mark(e,t,!1)},t.prototype.load=function(e){var t=this,o="string"==typeof e?{proofId:e}:e,n=o.proofId,r=o.pageNumber,i=void 0===r?null:r,a=o.sinceDate,f=void 0===a?null:a,c=o.async,l=void 0!==c&&c,p=o.decrypt,d=void 0===p||p,h=o.onDecryptComment,m=o.onDecryptComments,w=o.onDecryptCommentsThrottleMs,v=void 0===w?1e3:w,_=o.onDecryptError,E=f?f.toISOString().match(y.ISO_REGEX)[0]:y.DEFAULT_ISO_DATE,g={proofId:n,page:i,timestamp:E};return this.client.request(null!==i?"comments.load-page":"comments.load-all",g).then(function(e){var o=u(e.data.Pages?s(e.data.Pages):e.data),n=Promise.resolve();if(d){var r=[],i=[],a=m?(0,b.default)(function(){i.length&&(m(i),i=[])},v):function(){},f=Promise.all(o.map(function(e){return t.client.cache.auto(y.COMMENT_CACHE_PREFIX+e.comment$,function(t){r.push({comment:e,resolve:t})}).then(function(t){return t&&e.fromRawComment(t),e})}));n=n.then(function(){return f}),n=n.then(function(){var e=r.map(function(e){var o=e.comment,n=e.resolve;return t.client.crypto().decryptComment(o.comment$,o.envelope,t.client.session.privateKeyPEM).then(function(e){o.fromRawComment(e),n(e),h&&h(o),i.push(o),a()}).catch(function(e){if(_&&_(e,o),!l)return Promise.reject(e)})});return l?null:Promise.all(e)})}return n.then(function(){return o})})},t.prototype.create=function(e){var t=this,o=e.raw,n=e.proofId,r=e.pageNumber,i=void 0===r?1:r,a=e.pin,s=e.mediaTime,u=e.mediaDuration,f=e.parentCommentId,c=e.metadata,l=e.state,d=e.creationToken,y=(0,w.getCommentMentions)(o),m=d||(0,v.generateCreationToken)();return this.client.crypto().encryptComment(o,[this.client.session.serverPublicKeyPEM,this.client.session.publicKeyPEM]).then(function(e){var t=e.envelope,o=e.comment$;return{proofId:n,page:f?void 0:i,envelope:t,encryptedComment:o,xy:JSON.stringify({x:a&&"number"==typeof a.x?a.x:null,y:a&&"number"==typeof a.y?a.y:null,x2:a&&"number"==typeof a.x2?a.x2:null,y2:a&&"number"==typeof a.y2?a.y2:null,time:"number"==typeof s?s:null,duration:"number"==typeof u?u:null}),parent:f||null,mentions:y.map(function(e){return e.id}).join(","),metadata:c?JSON.stringify(c):"{}",creationToken:m,change:l===h.default.TODO?"1":void 0,done:l===h.default.DONE?"1":void 0}}).then(function(e){return t.client.request("comments.create",e).then(function(e){return(new p.default).fromComment(e.data).fromRawComment(o)})}).catch(function(e){return e&&(e.creationToken=m),Promise.reject(e)})},t}(c.default);t.default=T},function(e,t,o){"use strict";function n(e){var t=""+e,o=r.exec(t);if(!o)return t;var n,i="",a=0,s=0;for(a=o.index;a<t.length;a++){switch(t.charCodeAt(a)){case 34:n=""";break;case 38:n="&";break;case 39:n="'";break;case 60:n="<";break;case 62:n=">";break;default:continue}s!==a&&(i+=t.substring(s,a)),s=a+1,i+=n}return s!==a?i+t.substring(s,a):i}/*!
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.PageProof=t():e.PageProof=t()}(this,function(){return function(e){function t(n){if(o[n])return o[n].exports;var r=o[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var o={};return t.m=e,t.c=o,t.d=function(e,o,n){t.o(e,o)||Object.defineProperty(e,o,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(o,"a",o),o},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=30)}([function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=function e(t){n(this,e),this.client=t};t.default=r},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t,o){var n=[],r={};return Array.isArray(t)?(n=t,t.forEach(function(e){r[e]=e})):(0,y.default)(t)&&(n=Object.keys(t),r=t),n.forEach(function(t){var n=r[t],i=void 0;if("string"==typeof n)i=-1!==n.indexOf(".")?function(){for(var e=n.split("."),t=o,r=0;r<e.length;r++){var i=e[r];if(!(0,w.default)(t,i)){t=void 0;break}t=t[i]}return t}:function(){return o[n]};else{if("function"!=typeof n){if(null===n)return;throw new Error("Unknown transformer.")}i=n}var a=i.call(e,o);void 0!==a&&(e[t]=a)}),e}function i(e){return function(t){return Number(t[e])}}function a(e,t){return function(o){return t[o[e]]}}function s(e){return function(t){var o=t[e];if(o&&"0001-01-01T00:00:00"!==o)return"number"==typeof o?new Date(1e3*o):new Date(o+"Z")}}function u(e){return function(t){var o=String(t[e]);return"1"===o||"true"===o}}function f(e){return function(t){return w.default.call(t,e)}}function c(e,t){return function(o){return o[e]?o[e].map(t):[]}}function l(e,t){return function(o){return o[e]?JSON.parse(o[e]):Array.isArray(t)?[].concat(t):d({},t)}}function p(e){return function(t){return t[e]?t[e]:void 0}}t.__esModule=!0;var d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e};t.number=i,t.enumeration=a,t.date=s,t.truthy=u,t.exists=f,t.each=c,t.json=l,t.optional=p;var h=o(15),y=n(h),m=o(9),w=n(m);t.default=r},function(e,t,o){"use strict";t.__esModule=!0;t.TOKEN_HEADER="x-authorization-token",t.HMAC_HEADER="x-authorization-hmac",t.TIMESTAMP_HEADER="x-timestamp",t.DEVICE_ID_HEADER="x-device-id",t.SUBSCRIPTION_KEY_HEADER="ocp-apim-subscription-key",t.SDK_VERSION_HEADER="x-pageproof-javascript-sdk",t.RETRY_AFTER_HEADER="retry-after",t.BYTES_PER_BLOCK=2097152,t.MENTION_REGEX=/@{(U[a-zA-Z0-9]{15}|~everyone)}{(.*?)}/g,t.ISO_REGEX=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,t.DEFAULT_ISO_DATE="0001-01-01T00:00:00",t.DAY_IN_MS=864e5,t.COMMENT_CACHE_PREFIX="comment",t.THUMBNAIL_CACHE_PREFIX="thumbnail"},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=o(1),i=function(e){return e&&e.__esModule?e:{default:e}}(r),a={id:"UserId",name:"Name",email:"Email",hasActivated:"Activated",hasRegistered:"IsRegistered",hasAvatar:"HasAvatar",accountType:"AccountType",teamType:"TeamType",teamLogo:"Branding.LogoURL",registeredDate:(0,r.date)("Registered"),lastLoginDate:(0,r.date)("LastLogin"),lastUploadDate:(0,r.date)("LastUpload"),isAdmin:"IsDomainAdmin"},s=function(){function e(){n(this,e)}return e.prototype.fromJSON=function(e){return(0,i.default)(this,Object.keys(a),e),this},e.prototype.fromUser=function(e){return(0,i.default)(this,a,e),this},e}();t.default=s},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(){return this.dueDate&&this.dueDate.getTime()<Date.now()}t.__esModule=!0;var a=o(1),s=n(a),u=o(17),f=n(u),c=o(18),l=n(c),p=o(5),d=n(p),h=o(19),y={id:"ProofId",name:"Title",status:"Status",workflowId:"WorkflowId",version:"Version",dueDate:(0,a.date)("DueDate"),createdDate:(0,a.date)("CreatedDate"),approvedDate:(0,a.date)("ApprovedDate"),isLocked:"Locked",isArchived:"Closed",isOverdue:i,uploaderUserId:"UserId",ownerUserIds:"OwnerIds",editorUserId:"EditorId",editorUserIds:"EditorIds",lockerUserId:"ProofLockerId",messageToReviewers:"Description",messageToOwners:"OwnerMessage",messageToEditor:"EditorMessage",fileId:"FileId",fileExtension:"Extension",fileStatus:"FileStatus",fileMessage:"FileStatusMessage",pageCount:(0,a.number)("Pages"),commentCount:(0,a.number)("ParentComments"),canDownload:(0,a.truthy)("DownloadOriginal"),type:"Type",processStatus:"ProcessStatus",recipient:"Recipient"},m=function(){function e(){r(this,e)}return e.prototype.getState=function(){var e=f.default.ACTIVE;return this.fileStatus===d.default.UPLOADING?e=f.default.UPLOADING:this.hasFileError()?e=f.default.FILE_ERROR:this.isProcessing()?e=f.default.PROCESSING:this.status===l.default.ARCHIVED?e=f.default.ARCHIVED:this.hasWorkflow()?this.status===l.default.TODOS_REQUESTED?e=f.default.TODOS_REQUESTED:this.status===l.default.AWAITING_NEW_VERSION?e=f.default.AWAITING_NEW_VERSION:this.status===l.default.APPROVED?e=f.default.APPROVED:this.hasWorkflowStarted()?this.isOverdue&&(e=f.default.OVERDUE):e=f.default.NOT_STARTED:e=f.default.PROOFERS_NEEDED,e},e.prototype.hasWorkflowStarted=function(){return this.hasWorkflow()&&this.status!==l.default.NEW},e.prototype.isProcessing=function(){return this.fileStatus===d.default.UPLOADING||this.fileStatus===d.default.QUEUED||this.fileStatus===d.default.RIPPING},e.prototype.getProcessingProgress=function(){switch(this.fileStatus){case d.default.UPLOADING:return.1;case d.default.QUEUED:return.2;case d.default.RIPPING:return.6;default:return-1}},e.prototype.hasWorkflow=function(){return(0,h.isWorkflowId)(this.workflowId)},e.prototype.hasFile=function(){return(0,h.isFileId)(this.fileId)},e.prototype.hasFileError=function(){return this.fileStatus===d.default.ERROR||!this.fileStatus||!this.hasFile()},e.prototype.hasEditor=function(){return(0,h.isUserId)(this.editorUserId)},e.prototype.hasThumbnail=function(){return this.fileStatus===d.default.OK},e.prototype.canUserUploadNewVersion=function(e){return this.getState()===f.default.AWAITING_NEW_VERSION&&(this.editorUserId===e||this.isOwner(e))},e.prototype.isOwner=function(e){return-1!==this.ownerUserIds.indexOf(e)},e.prototype.calculateState=function(){this.state=this.getState()},e.prototype.fromProof=function(e){return(0,s.default)(this,y,e),this.calculateState(),this},e}();t.default=m},function(e,t,o){"use strict";t.__esModule=!0;var n={OK:"OK",UPLOADING:"Uploading",QUEUED:"Queued",RIPPING:"Ripping",ERROR:"Error"};t.default=n},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(1),a=n(i),s=o(3),u=n(s),f={userId:"UserId",token:"Token",sharedKey:"SharedKey",privateKeyPEM$:"PrivateKey",privateKeyPEM:null,publicKeyPEM:"PublicKey",serverPublicKeyPEM:"PublicServerKey"},c=function(){function e(){r(this,e)}return e.prototype.fromJSON=function(e){return(0,a.default)(this,Object.keys(f),e),this.user=(new u.default).fromJSON(e.user),this},e.prototype.fromSession=function(e){return(0,a.default)(this,f,e),this.user=(new u.default).fromUser(e),this},e}();t.default=c},function(e,t,o){"use strict";function n(){if("function"==typeof n.driver){return new(0,n.driver)}if("string"==typeof n.driver){var e=void 0;switch(n.driver){case"Blob":e=o(56).default;break;case"Buffer":e=o(57).default;break;case"String":e=o(58).default;break;default:throw new Error('Unknown Bluffer driver "'+n.driver+'".')}if(e)return new e;throw new Error('Bluffer driver "'+n.driver+'" not found.')}throw new Error('Bluffer.driver must be either "Blob", "Bluffer", or "String" or a custom constructor.')}t.__esModule=!0;var r=o(11)("bluffer");n.driver="String","undefined"!=typeof Blob?n.driver="Blob":(r("The current JavaScript environment does not support native Bluffer, falling back to using StringBluffer."),n.driver="String"),t.default=n},function(e,t,o){"use strict";t.__esModule=!0;var n={ERROR_CRITICAL:3,OK:200,ERROR_INVALID:201,ERROR_NO_ACCESS:100,ERROR_NO_ACCESS_WRITE:101,ERROR_RESTRICTED:102,ERROR_SQL_ERROR:105,ERROR_OUT_SYNC:106,ERROR_STORAGE_ERROR:110,ERROR_QUEUE_ERROR:111,ERROR_SQL_DEADLOCK_ERROR:121,ERROR_BAD_REQUEST:400,ERROR_UNAUTHORISED:401,ERROR_MEDIA_PERMISSION_NO_ACCESS:402,ERROR_NOT_FOUND:1e3,ERROR_CREATE:1001,ERROR_UPDATE:1002,ERROR_DELETE:1003,ERROR_EXISTS:1004,ERROR_USER_INVALID_LOGIN:1010,ERROR_USER_INVALID_PASSWORD:1011,ERROR_USER_IS_REGISTERED:1012,ERROR_USER_INVALID_EMAIL:1013,ERROR_USER_INVALID_LOGIN_COUNT:1014,ERROR_USER_DISABLED:1015,ERROR_BAD_REQUEST_DATE:201,ERROR_THROTTLED:429,ERROR_REUSED_CREATION_TOKEN:2011,ERROR_UPGRADE_REQUIRED:3e3,ERROR_VISIBLE_WORKFLOW_USERS_EXIST:3001,ERROR_GROUP_EXISTS:3002,ERROR_GROUP_PROOFS_EXIST:3003};t.default=n},function(e,t,o){"use strict";t.__esModule=!0,t.default=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=o(1),i=function(e){return e&&e.__esModule?e:{default:e}}(r),a={id:"FileId",name:"Name",blocks:"Chunks",downloadable:"Downloadable",assignedTo:"AssignedTo",assignedType:"AssignedType",status:"Status",message:"Message"},s={id:"Attachment",name:"AttachmentName",blocks:"AttachmentChunks",assignedTo:"CommentId",assignedType:function(){return"attachment"},status:"AttachmentStatus",message:function(){return""}},u=function(){function e(){n(this,e)}return e.prototype.fromFile=function(e){return(0,i.default)(this,a,e),this},e.prototype.fromCommentAttachment=function(e){return(0,i.default)(this,s,e),this},e}();t.default=u},function(e,t,o){"use strict";e.exports=function e(){return e}},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(1),a=n(i),s=o(13),u=n(s),f=o(26),c=n(f),l={id:"StepId",name:"Title",position:(0,i.number)("Position"),state:function(e){return e.Complete?c.default.COMPLETE:e.Visible?c.default.VISIBLE:c.default.NOT_VISIBLE},users:(0,i.each)("Users",function(e,t){var o=(new u.default).fromWorkflowUser(e);return o._calculateState(e,t),o})},p=function(){function e(){r(this,e)}return e.prototype.fromWorkflowStep=function(e){return(0,a.default)(this,l,e),this},e}();t.default=p},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(1),u=n(s),f=o(3),c=n(f),l=o(25),p=n(l),d={id:"UserId",name:"Name",email:"Email",role:"Role",permissions:function(e){return{inviter:e.IsInviter}}},h=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype._calculateState=function(e,t){e.SkippedInStep?this.state=p.default.SKIPPED:e.CompleteInStep?this.state=p.default.FINISHED:e.ViewedInStep?this.state=p.default.SEEN:t.Visible?this.state=p.default.VISIBLE:this.state=p.default.NOT_VISIBLE},t.prototype.fromWorkflowUser=function(e){return this._calculateState({},{}),(0,u.default)(this,d,e),this},t}(c.default);t.default=h},function(e,t,o){"use strict";t.__esModule=!0;var n={COMMENT:"comment",TODO:"todo",DONE:"done"};t.default=n},function(e,t,o){"use strict";t.__esModule=!0;var n=Object.prototype.toString;t.default=function(e){return"[object Object]"===n.call(e)}},function(e,t,o){"use strict";t.__esModule=!0;var n=void 0;n="94.0.1532561852367",t.default=n},function(e,t,o){"use strict";t.__esModule=!0;var n={UPLOADING:"uploading",FILE_ERROR:"file-error",PROCESSING:"processing",ARCHIVED:"archived",PROOFERS_NEEDED:"proofers-needed",TODOS_REQUESTED:"todos-requested",AWAITING_NEW_VERSION:"awaiting-new-version",APPROVED:"approved",NOT_STARTED:"not-started",OVERDUE:"overdue",ACTIVE:"active"};t.default=n},function(e,t,o){"use strict";t.__esModule=!0;var n={NEW:0,PROOFING:10,FINAL_APPROVING:30,TODOS_REQUESTED:50,AWAITING_NEW_VERSION:60,APPROVED:70,ARCHIVED:100};t.default=n},function(e,t,o){"use strict";var n={Proof:"P",Workflow:"W",File:"F",User:"U",Brief:"B"},r={};Object.keys(n).forEach(function(e){r["is"+e+"Id"]=function(t){return t&&16===t.length&&t[0]===n[e]}}),e.exports=r},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=o(1),i=function(e){return e&&e.__esModule?e:{default:e}}(r),a={id:"ProofId",version:"Version"},s=function(){function e(){n(this,e)}return e.prototype.fromProofVersion=function(e){return(0,i.default)(this,a,e),this},e}();t.default=s},function(e,t,o){"use strict";function n(e,t){return r(function(t){return t[e]},t)}function r(e,t){var o=t?1:-1,n=t?-1:1;return function(t,r){var i=e(t),a=e(r);return i<a?o:i>a?n:0}}function i(e,t){var o={};t.forEach(function(e,t){o[e]=t});var n="function"==typeof e?e:function(t){return t[e]};return function(e,t){var r=o[n(e)],i=o[n(t)];return r<i?-1:r>i?1:0}}function a(){for(var e=arguments.length,t=Array(e),o=0;o<e;o++)t[o]=arguments[o];var n=t.length;return function(e,o){for(var r=0;r<n;r++){var i=t[r](e,o);if(i)return i}return 0}}t.__esModule=!0,t.sortObjectsByKey=n,t.sortObjectsBy=r,t.sortObjectsByValues=i,t.combineSort=a},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(1),a=n(i),s=o(4),u=n(s),f={id:"GroupId",name:"Name",proofs:(0,i.each)("ProofInfo",function(e){return(new u.default).fromProof(e)})},c=function(){function e(){r(this,e)}return e.prototype.fromProofGroup=function(e){return(0,a.default)(this,f,e),this},e}();t.default=c},function(e,t,o){"use strict";t.__esModule=!0;var n={NONE:"none",GOOGLE_DRIVE:"drive",DROPBOX:"dropbox",ONEDRIVE:"onedrive",BOX:"box"};t.default=n},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(1),a=n(i),s=o(12),u=n(s),f={id:"WorkflowId",name:"Title",steps:(0,i.each)("WorkflowSteps",function(e){return(new u.default).fromWorkflowStep(e)})},c=function(){function e(){r(this,e)}return e.prototype.getStepByPosition=function(e){for(var t=this.steps.length,o=0;o<t;o+=1){var n=this.steps[o];if(n.position===e)return n}return null},e.prototype.getOrderedSteps=function(){return this.steps.sort(function(e,t){return e.position<t.position?-1:e.position>t.position?1:0})},e.prototype.getApproverStep=function(){return this.getStepByPosition(1e3)},e.prototype.fromWorkflow=function(e){return(0,a.default)(this,f,e),this},e}();t.default=c},function(e,t,o){"use strict";t.__esModule=!0;var n={NONE:null,NOT_VISIBLE:"not-visible",VISIBLE:"visible",SEEN:"seen",SKIPPED:"skipped",FINISHED:"finished"};t.default=n},function(e,t,o){"use strict";t.__esModule=!0;var n={NONE:null,NOT_VISIBLE:"not-visible",VISIBLE:"visible",COMPLETE:"complete"};t.default=n},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(1),a=n(i),s=o(3),u=n(s),f=o(28),c=n(f),l=o(10),p=n(l),d=o(14),h=n(d),y=o(29),m={__prepare:function(e){e._XY=c.default.parseValue(e.XY)},id:"CommentId",proofId:"ProofId",pin:function(e){return(new c.default).fromPin(e._XY)},user:function(e){return(new u.default).fromUser(e)},comment$:"EncryptedComment",envelope:"Envelope",attachments:function(e){return e.Attachment?[(new p.default).fromCommentAttachment(e)]:[]},agreeCount:function(e){return e.Agrees.length},pageNumber:(0,i.number)("Page"),mediaTime:function(e){return null==e._XY.time?void 0:e._XY.time},mediaDuration:function(e){return null==e._XY.duration?void 0:e._XY.duration},createdDate:(0,i.date)("Timestamp"),updatedDate:(0,i.date)("Updated"),parentCommentId:(0,i.optional)("Parent"),metadata:(0,i.json)("Metadata",{}),state:function(e){return+e.Done?h.default.DONE:+e.Change?h.default.TODO:h.default.COMMENT}},w=function(){function e(){r(this,e)}return e.prototype.fromComment=function(e){return(0,a.default)(this,m,e),this},e.prototype.fromRawComment=function(e){var t=(0,y.parseComment)(e);return this.raw=t.raw,this.text=t.text,this.html=t.html,this.tokens=t.tokens,this},e}();t.default=w},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},i=o(1),a=function(e){return e&&e.__esModule?e:{default:e}}(i),s={x:"x",y:"y",x2:(0,i.optional)("x2"),y2:(0,i.optional)("y2")},u=function(){function e(){n(this,e)}return e.prototype.fromPin=function(e){return(0,a.default)(this,s,e),this},e.parseValue=function(e){var t={x:null,y:null,x2:null,y2:null,time:null,duration:null};if("{"===e[0]){var o=JSON.parse(e);t=r({},t,o)}else if(-1!==e.indexOf(",")){var n=e.split(","),i=n[0],a=n[1];t.x=parseFloat(i),t.y=parseFloat(a)}return t},e}();t.default=u},function(e,t,o){"use strict";function n(e){return(0,c.default)(e)}function r(e){return e.replace(l.MENTION_REGEX,function(e,t,o){return o})}function i(e){var t=0;return e.replace(l.MENTION_REGEX,function(e,o,n,r){return'<span data-mention data-mention-index="'+t+++'" data-mention-user-id="'+o+'" data-mention-user-label="'+n.replace(/"/,'\\"')+'" data-mention-start-index="'+r+'" data-mention-end-index="'+(r+e.length)+'" data-mention-length="'+e.length+'">'+n+"</span>"})}function a(e){var t=[];return e.replace(l.MENTION_REGEX,function(e,o,n,r){t.push({id:o,label:n,index:r,length:e.length})}),t}function s(e){var t=a(e),o=[],n=0;t.forEach(function(t){var r=e.slice(n,t.index);n=t.index+t.length,r&&o.push({type:"text",value:r}),o.push({type:"mention",value:t})});var r=e.slice(n);return r&&o.push({type:"text",value:r}),o}function u(e){var t=n(e);return{raw:e,text:r(t),html:i(t),mentions:a(e),tokens:s(e)}}t.__esModule=!0,t.getCommentTokens=t.getCommentText=t.getCommentMentions=t.getCommentHTML=t.getCommentEscaped=t.parseComment=void 0;var f=o(68),c=function(e){return e&&e.__esModule?e:{default:e}}(f),l=o(2);t.parseComment=u,t.getCommentEscaped=n,t.getCommentHTML=i,t.getCommentMentions=a,t.getCommentText=r,t.getCommentTokens=s},function(e,t,o){"use strict";function n(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t.default=e,t}function r(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.version=t.Model=t.Enum=t.Bluffer=t.Client=void 0;var i=o(31),a=r(i),s=o(7),u=r(s),f=o(75),c=n(f),l=o(78),p=n(l),d=o(16),h=r(d);t.default=a.default,t.Client=a.default,t.Bluffer=u.default,t.Enum=c,t.Model=p,t.version=h.default},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(32),a=n(i),s=o(37),u=n(s),f=o(38),c=n(f),l=o(40),p=n(l),d=o(42),h=n(d),y=o(44),m=n(y),w=o(45),v=n(w),_=o(46),b=n(_),E=o(53),g=n(E),O=o(54),P=n(O),I=o(62),T=n(I),R=o(65),S=n(R),k=o(67),M=n(k),A=o(71),C=n(A),j=o(72),D=n(j),q=o(6),N=n(q),x=o(73),U=n(x),B=o(8),K=n(B),G=o(74),L=n(G),W=o(11)("PageProof"),F=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,e),this.options=t,this.events=new U.default,this.adapters=new a.default(this.options.adapters),this.cache=new u.default(this),this.accounts=new h.default(this),this.comments=new M.default(this),this.dashboard=new m.default(this),this.files=new P.default(this),this.profile=new C.default(this),this.proofs=new b.default(this),this.briefs=new g.default(this),this.users=new v.default(this),this.workflows=new S.default(this),this.sessions=new D.default(this),this._registerCoreHooks(),this._enhance()}return e.prototype._registerCoreHooks=function(){this.on("error.throttled",function(e){var t=e.data.response.data.timeout;return W("Sleeping "+t+"ms until rate limit resets"),(0,L.default)(t)})},e.prototype._enhance=function(){var e=this;this.adapters.getEnhancementAdapters().forEach(function(t){return t.onClientReady(e)})},e.prototype.setSession=function(e){return!e||e instanceof N.default?this.session=e||null:this.session=(new N.default).fromJSON(e),this.session},e.prototype.request=function(e,t,o){var n=this,r=new c.default(e,t),i=this.adapters.getRequestAdapter(),a=Promise.resolve();if(!r.endpoint.anonymous){if(!this.session)return Promise.reject(new Error("Cannot make call to endpoint ("+e+") when unauthorized."));a=this.adapters.getCryptoAdapter().generateAuthorizationHeaders(r.getMethod(),r.getPath(),this.session).then(function(e){return r.addHeaders(e)})}var s={request:r};return a.then(function(){var e=r.build();return n.events.emit("experimental.request.before",s,!0).then(function(){return e})}).then(function(e){return i.send(e,o)}).then(p.default.parse).then(function(r){if(s.response=r,n.events.emit("experimental.request.after",s),r.code===K.default.ERROR_THROTTLED){var i=n.events.emit("error.throttled",s);if(i.some(Boolean))return Promise.all(i).then(function(){return n.events.emit("experimental.request.retry",s),n.request(e,t,o)})}if(r.code===K.default.ERROR_UNAUTHORISED){var a=n.session?n.session.token:null;return n.events.emit("error.unauthorized",s,!0).then(function(){return n.session&&n.session.token!==a?n.request(e,t,o):r})}if(r.deprecated){var u="The "+e+" API has been deprecated. "+(r.deprecated||"");n.events.emit("error.deprecated",{name:e,message:u})}return r}).then(function(t){try{if(t.error){n.events.emit("error.response",s);var o=new Error(e+" request resulted in an "+t.code+" error.");return o.response=t,o.request=r,Promise.reject(o)}return n.events.emit("experimental.request.resolve",s),Promise.resolve(t)}finally{n.events.emit("experimental.request.finally",s)}})},e.prototype.admin=function(){return this.session?this.session.user.isAdmin?(this._admin||(this._admin=Promise.resolve(new T.default(this))),this._admin):Promise.reject(new Error("The current user must be an administrator of a team or enterprise account.")):Promise.reject(new Error("You must be logged in to use the Admin API."))},e.prototype.crypto=function(){return this.adapters.getCryptoAdapter()},e.prototype.on=function(e,t){return this.events.on(e,t)},e}();t.default=F},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(33),a=n(i),s=o(34),u=n(s),f=o(35),c=n(f),l=o(36),p=n(l),d=function(){function e(t){r(this,e),this.adapters=[].concat(t)}return e.prototype.getAdapterInstanceOf=function(e){return this.getAnyAdaptersInstanceOf(e)[0]||null},e.prototype.getAnyAdaptersInstanceOf=function(e){for(var t=[],o=e.__adapter__,n=0;n<this.adapters.length;n+=1){var r=this.adapters[n];Object.getPrototypeOf(Object.getPrototypeOf(r)).constructor.__adapter__===o&&t.push(r)}return t},e.prototype.getCryptoAdapter=function(){var e=this.getAdapterInstanceOf(a.default);if(!e)throw new Error("ICryptoAdapter not found. This adapter is required for the SDK to function correctly.");return e},e.prototype.getRequestAdapter=function(){var e=this.getAdapterInstanceOf(u.default);if(!e)throw new Error("IRequestAdapter not found. This adapter is required for the SDK to function correctly.");return e},e.prototype.getCacheAdapter=function(){return this.getAdapterInstanceOf(c.default)},e.prototype.getEnhancementAdapters=function(){return this.getAnyAdaptersInstanceOf(p.default)},e}();t.default=d},function(e,t,o){"use strict";function n(){}t.__esModule=!0,n.__adapter__="ICryptoAdapter",t.default=n},function(e,t,o){"use strict";function n(){}t.__esModule=!0,n.__adapter__="IRequestAdapter",t.default=n},function(e,t,o){"use strict";function n(){}t.__esModule=!0,n.__adapter__="ICacheAdapter",t.default=n},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t,o){var n=e[t];e[t]=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];var i=n.bind.apply(n,[this].concat(t));return o(i,this,t).apply(this,t)}}function i(e){function t(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],a=Object.getOwnPropertyNames(r).filter(function(t){return r[t].client===e}),s=Object.getPrototypeOf(r),u=Object.keys(s).filter(function(e){return"function"==typeof s[e]&&0!==e.indexOf("_")});(i.length||o)&&u.forEach(function(e){n.push({namespace:i.join("."),name:e,api:r})}),a.forEach(function(e){t(r[e],i.concat(e))})}var o=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=[];return t(e),n}t.__esModule=!0;var a,s,u=(s=a=function(){function e(){n(this,e)}return e.prototype.onClientReady=function(e){var t=this;i(e).forEach(function(e){r(e.api,e.name,function(o){var n={api:e.api,namespace:e.namespace,name:e.name,displayName:e.namespace+"."+e.name};return t.onMethodBefore(n),function(){var e=void 0;try{e=o()}catch(e){throw n.error=e,t.onMethodThrown(n),e}finally{n.value=e,t.onMethodAfter(n),e&&"function"==typeof e.then&&e.then(function(e){n.resolved=e,t.onMethodResolve(n)},function(e){n.rejected=e,t.onMethodReject(n)}).then(function(){t.onMethodFinally(n)})}return e}})}),e.on("experimental.request.before",function(e){return t.onRequestBefore(e.data)}),e.on("experimental.request.after",function(e){return t.onRequestAfter(e.data)}),e.on("error.response",function(e){return t.onRequestReject(e.data)}),e.on("error.throttled",function(e){return t.onRequestThrottled(e.data)}),e.on("experimental.request.retry",function(e){return t.onRequestRetry(e.data)}),e.on("error.unauthorized",function(e){return t.onRequestUnauthorized(e.data)}),e.on("error.deprecated",function(e){return t.onRequestDeprecated(e.data)}),e.on("experimental.request.resolve",function(e){return t.onRequestResolve(e.data)}),e.on("experimental.request.finally",function(e){return t.onRequestFinally(e.data)})},e.prototype.onMethodBefore=function(){},e.prototype.onMethodAfter=function(){},e.prototype.onMethodReject=function(){},e.prototype.onMethodResolve=function(){},e.prototype.onMethodFinally=function(){},e.prototype.onMethodThrown=function(){},e.prototype.onRequestBefore=function(){},e.prototype.onRequestAfter=function(){},e.prototype.onRequestReject=function(){},e.prototype.onRequestThrottled=function(){},e.prototype.onRequestRetry=function(){},e.prototype.onRequestUnauthorized=function(){},e.prototype.onRequestDeprecated=function(){},e.prototype.onRequestResolve=function(){},e.prototype.onRequestFinally=function(){},e}(),a.__adapter__="IEnhancementAdapter",s);t.default=u},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=function(){function e(t){n(this,e),this.client=t}return e.prototype.auto=function(e,t){var o=this.client.adapters.getCacheAdapter(),n=function(){};return o?(n=function(t){void 0!==t&&o.set(e,t)},o.get(e).catch(function(){return Promise.resolve(t(n)).then(function(e){return n(e),e})})):Promise.resolve(t(n))},e}();t.default=r},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},a=o(39),s=n(a),u=o(15),f=n(u),c=o(16),l=n(c),p=o(2),d=function(){function e(t,o){if(r(this,e),this.name=t,this.endpoint=s.default[t],!this.endpoint)throw new Error('Unknown request endpoint "'+t+'".');this.params={},this.addParams(o),this.headers={}}return e.prototype.addHeaders=function(e){return this.headers=i({},this.headers,e),this},e.prototype.addHeader=function(e,t){return this.headers[e]=t,this},e.prototype.addParams=function(e){return this.params=i({},this.params,e),this},e.prototype.addParam=function(e,t){this.params[e]=t},e.prototype.getPath=function(){var e=this,t=this.endpoint,o=t.path,n=t.chain,r=t.trailing,i=o;return n&&n.forEach(function(t){"/"!==i[i.length-1]&&(i+="/"),i+=e.params[t]}),r&&"/"!==i[i.length-1]&&(i+="/"),i},e.prototype.getQuery=function(){var e=this,t=this.endpoint.query;if(t){var o=t.map(function(t){return void 0!==e.params[t]?t+"="+encodeURIComponent(e.params[t]):null}).filter(Boolean).join("&");if(o)return"?"+o}return""},e.prototype.getHeaders=function(){var e,t=i({},this.headers,(e={},e[p.SDK_VERSION_HEADER]=l.default,e));if("POST"===this.endpoint.method)switch(this.endpoint.version){case 2:t["Content-Type"]="application/json";break;case 1:default:t["Content-Type"]="application/x-www-form-urlencoded"}return t},e.prototype.getBody=function(){var e=this,t=this.endpoint;if(t.body){if("string"==typeof t.body){var o=this.params[t.body];return o=(0,f.default)(o)?JSON.stringify(o):String(o)}var n=!0===t.body?Object.keys(this.params):t.body,r={};switch(n.forEach(function(t){var o=e.params[t];void 0!==o&&(r[t]=o)}),t.version){case 2:return JSON.stringify(r);case 1:default:return Object.keys(r).map(function(t){return t+"="+encodeURIComponent(e.params[t])}).join("&")}}return null},e.prototype.getMethod=function(){return(this.endpoint.method||"GET").toUpperCase()},e.prototype.isWithCredentials=function(){return!0===this.endpoint.credentials},e.prototype.build=function(){return{method:this.getMethod(),path:this.getPath(),query:this.getQuery(),body:this.getBody(),headers:this.getHeaders(),credentials:this.isWithCredentials()}},e}();t.default=d},function(e,t){e.exports={"accounts.register":{method:"POST",path:"/api/users/register",body:["email","password","privateKey","publicKey"],anonymous:!0},"accounts.login":{method:"POST",path:"/api/users/login",body:["email","password"],anonymous:!0},"accounts.generate-activation-code":{method:"GET",path:"/api/users/auth/generate",chain:["userId"],trailing:!0},"accounts.activate":{method:"POST",path:"/api/users/auth/activate",body:["userId","authCode"],trailing:!0},"accounts.logout":{method:"GET",path:"/api/users/logout"},"profile.upload-avatar":{method:"POST",path:"/api/media/file/avatar",body:["uploadedImage"]},"profile.change-password":{method:"POST",path:"/api/users/changepassword",body:["oldPassword","newPassword","newPrivateKey"],trailing:!0},"dashboard.inbox":{method:"GET",path:"/api/proofs/dashboard/proofin",trailing:!0},"dashboard.sent":{method:"GET",path:"/api/proofs/dashboard/proofout",trailing:!0},"dashboard.outbox":{method:"GET",path:"/api/proofs/dashboard/proofoutbox",trailing:!0},"dashboard.search":{method:"POST",path:"/api/proofs/search",body:["query","all","filterBy"]},"users.by-id":{method:"GET",path:"/api/users",chain:["userId"]},"users.by-email":{method:"POST",path:"/api/users/email",body:["email"],trailing:!0},"users.invite":{method:"POST",path:"/api/users/create",body:["email"]},"proofs.create":{method:"POST",path:"/api/proofs/create",body:["title","dueDate","description","groupId"]},"proofs.normalize-workflow":{method:"POST",path:"/api/proofs/permission/check",body:["proofId","workflowId"]},"proofs.set-workflow":{method:"POST",path:"/api/proofs/update",body:["proofId","workflowId"]},"proofs.set-tags":{method:"POST",path:"/api/tags/create",body:["relatedId","tag"]},"proofs.set-file":{method:"POST",path:"/api/proofs/update",body:["proofId","fileId"]},"proofs.distribute-file":{method:"GET",path:"/api/proofs/distribute",chain:["proofId"],trailing:!0},"proofs.archive":{method:"GET",path:"/api/proofs/close",chain:["proofId"],trailing:!0},"proofs.unarchive":{method:"GET",path:"/api/proofs/reopen",chain:["proofId"],trailing:!0},"proofs.delete":{method:"GET",path:"/api/proofs/delete",chain:["proofId"],trailing:!0},"proofs.start":{method:"POST",path:"/api/proofs/startworkflow",body:["proofId"],trailing:!0},"proofs.editors.add":{version:2,method:"POST",path:"/api/proofs/editor/add",body:["proofId","editors","editorMessage"]},"proofs.editors.remove":{version:2,method:"POST",path:"/api/proofs/editor/remove",body:["proofId","editors"]},"proofs.editors.replace":{version:2,method:"POST",path:"/api/proofs/editor/replace",body:["proofId","oldEditors","newEditors"]},"proofs.editors.set":{version:2,method:"POST",path:"/api/proofs/editor/set",body:["proofId","editors"]},"briefs.start":{method:"POST",path:"/api/briefs/start",body:["briefId"]},"proofs.return":{method:"GET",path:"/api/proofs/returnproof",chain:["proofId"]},"proofs.groups.create":{method:"POST",path:"/api/proofs/groups/create",body:["name"]},"proofs.groups.update":{method:"POST",path:"/api/proofs/groups/update",body:["groupId","name"]},"proofs.groups.load":{method:"GET",path:"/api/proofs/group",chain:["groupId"]},"proofs.groups.ready":{method:"POST",path:"/api/proofs/groups/ready",body:["groupId"]},"proofs.groups.owners.add":{version:2,method:"POST",path:"/api/v2/proofs/owners/groups/add",body:["groupId","owners"]},"proofs.groups.workflows.add-reviewers":{version:2,method:"POST",path:"/api/v2/workflows/groups/reviewers/add",body:["groupId","reviewers"]},"proofs.versions.attach":{method:"POST",path:"/api/proofs/versions/create",body:["proofId","versionId"]},"proofs.versions.list":{method:"GET",path:"/api/proofs/versions",chain:["proofId"],trailing:!0},"proofs.load":{method:"GET",path:"/api/proofs/",chain:["proofId"],trailing:!0},"proofs.lock":{method:"GET",path:"/api/proofs/lock/",chain:["proofId"],trailing:!0},"proofs.unlock":{method:"GET",path:"/api/proofs/unlock/",chain:["proofId"],trailing:!0},"proofs.request-unlock":{method:"GET",path:"/api/proofs/unlockemail/",chain:["proofId"],trailing:!0},"files.generate-token":{method:"GET",path:"/api/media/getfiletoken",query:["relatedId","fileType"]},"files.upload-block":{method:"POST",path:"/api/media/file",query:["block","part","token"],body:"data"},"files.upload-complete":{method:"POST",path:"/api/media/file",query:["block","blockCount","part","token","extn","pages","filename","storeoriginal"],body:"envelope"},"files.details":{method:"GET",path:"/api/media/file/details",chain:["fileId"]},"files.download-block":{method:"GET",path:"/api/media/getfilechunk",chain:["proofId","fileId","block"]},"files.thumbnail":{method:"GET",path:"/api/media/getimage/thumb",chain:["fileId"]},"files.import.generic":{method:"POST",path:"/api/media/filedrive",body:["extn","filename","url","envelope","storeOriginal"]},"files.import.drive":{method:"POST",path:"/api/media/filedrive",body:["extn","filename","url","envelope","storeOriginal","accessToken"]},"files.import.onedrive":{method:"POST",path:"/api/media/fileonedrive",body:["extn","filename","url","envelope","storeOriginal","accessToken"]},"files.import.box":{method:"POST",path:"/api/media/filebox",body:["extn","filename","url","envelope","storeOriginal","accessToken"]},"files.import.dropbox":{method:"POST",path:"/api/media/filedropbox",body:["extn","filename","url","envelope","storeOriginal","accessToken"]},"workflows.create":{version:2,method:"POST",path:"/api/v2/workflows/create",body:["title"]},"workflows.load":{version:2,method:"GET",path:"/api/v2/workflows/detail",chain:["workflowId"]},"workflows.steps.add":{version:2,method:"POST",path:"/api/v2/workflows/steps/add",body:["workflowId","title","position"]},"workflows.steps.move-before":{method:"POST",path:"/api/workflows/step/movebefore",body:["stepId","beforeStepId"]},"workflows.steps.move-after":{method:"POST",path:"/api/workflows/step/moveafter",body:["stepId","afterStepId"]},"workflows.steps.swap":{method:"POST",path:"/api/workflows/step/swap",body:["stepId","swapStepId"]},"workflows.users.set":{version:2,method:"POST",path:"/api/v2/workflows/users/set",body:["workflowId","stepId","position","users"]},"workflows.users.update":{version:2,method:"POST",path:"/api/v2/workflows/users/update",body:["workflowId","stepId","userId","role","permissions"]},"workflows.users.add":{version:2,method:"POST",path:"/api/v2/workflows/users/add",body:["workflowId","stepId","users"]},"workflows.delete":{method:"POST",path:"/api/workflows/delete",body:["workflowId"]},"workflows.duplicate":{method:"POST",path:"/api/workflows/duplicateonly",body:["workflowId"]},"workflows.owned":{method:"GET",path:"/api/workflows",trailing:!0},"workflows.shared":{method:"GET",path:"/api/workflows/share/user",trailing:!0},"comments.load-all":{method:"POST",path:"/api/proofs/recent",body:["proofId","timestamp"]},"comments.load-page":{method:"POST",path:"/api/proofs/comment/recent",body:["proofId","timestamp","page"]},"comments.state.update":{method:"POST",path:"/api/proofs/comment/updatestatus",body:["commentId","change","done"]},"comments.create":{method:"POST",path:"/api/proofs/comment/create",body:["proofId","page","envelope","encryptedComment","xy","parent","mentions","metadata","creationToken","change","done"]},"proofs-owners.add":{version:2,method:"POST",path:"/api/v2/proofs/owners/add",body:["proofId","users"]},"proofs-owners.remove":{version:2,method:"POST",path:"/api/v2/proofs/owners/remove",body:["proofId","users"]},"proofs.tag-delete":{method:"POST",path:"/api/tags/delete",body:["relatedId","tag"]},"proofs.remove-editor":{method:"GET",path:"/api/proofs/deleteeditor",chain:["proofId"],trailing:!0},"briefs.create":{method:"POST",path:"/api/briefs/create",body:["title","messageToRecipient","dueDate","tag"]},"briefs.update":{method:"POST",path:"/api/briefs/update",body:["briefId","title","messageToRecipient","dueDate","tag","recipient","editorId","editorMessage"]},"admin.team.users.enabled":{method:"GET",path:"/api/admin/getusers/active",trailing:!0},"admin.team.users.disabled":{method:"GET",path:"/api/admin/getusers/inactive",trailing:!0},"admin.team.users.set-enabled":{method:"POST",path:"/api/admin/setenabled",body:["email","enabled"]},"sessions.check":{method:"GET",path:"/api/sessions/check"},"sso.get-public-key":{method:"GET",path:"/sso/public_key",anonymous:!0},"sso.get-session":{version:2,method:"POST",path:"/sso/session",body:["nonce"],anonymous:!0,credentials:!0},"sso.get-login-options":{version:2,method:"POST",path:"/sso/login_options",body:["email"],anonymous:!0}}},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var i=o(8),a=n(i),s=o(41),u=o(2),f=o(9),c=n(f),l=function(){function e(){r(this,e),this.error=!1,this.code=-1,this.data=null,this.message=null,this.deprecated=null}return e.parse=function(t){var o=t.status,n=t.headers,r=void 0===n?{}:n,i=t.body,f=new e;if(o===s.TOO_MANY_REQUESTS_STATUS)return f.error=!0,f.message="PageProof Error #h"+s.TOO_MANY_REQUESTS_STATUS,f.code=a.default.ERROR_THROTTLED,f.data={timeout:1e3*(parseFloat(r[u.RETRY_AFTER_HEADER])||60)},f;if((0,c.default)(r,"deprecated")&&(f.deprecated=r.deprecated),o===s.OK_STATUS&&!i)return f.code=a.default.OK,f;try{var l=JSON.parse(i);"string"==typeof l||(l&&"ResponseCode"in l?(f.code=l.ResponseCode,f.code!==a.default.OK&&(f.error=!0)):l.Message&&1===Object.keys(l).length&&(f.error=!0,f.code=a.default.ERROR_CRITICAL)),f.error&&(f.message="PageProof Error #s"+f.code),f.data=l}catch(e){f.error=!0}return f},e}();t.default=l},function(e,t,o){"use strict";t.__esModule=!0;t.TOO_MANY_REQUESTS_STATUS=429,t.OK_STATUS=200},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(0),u=n(s),f=o(6),c=n(f),l=o(43),p=n(l),d=function(e){function t(o){r(this,t);var n=i(this,e.call(this,o));return n.sso=new p.default(o),n}return a(t,e),t.prototype.register=function(e,t){var o=this;return this.client.crypto().generatePasswordHash(t).then(function(e){return Promise.all([e,o.client.crypto().generateKeyPair()])}).then(function(e){var n=e[0],r=e[1];return Promise.all([n,r,o.client.crypto().encryptPrivateKey(r.privateKeyPEM,t)])}).then(function(t){var n=t[0],r=t[1],i=t[2];return Promise.all([r,o.client.request("accounts.register",{email:e,password:n,privateKey:i,publicKey:r.publicKeyPEM})])}).then(function(n){var r=n[0];return Promise.all([r,o.login(e,t,!1)])}).then(function(e){var t=e[0],n=e[1];return Promise.all([t,n,o.generateActivationCode()])}).then(function(e){var t=e[0],o=e[1];return o.privateKeyPEM=t.privateKeyPEM,o})},t.prototype.generateActivationCode=function(){return this.client.request("accounts.generate-activation-code",{userId:this.client.session.userId})},t.prototype.activate=function(e){var t=this;return this.client.request("accounts.activate",{userId:this.client.session.userId,authCode:e}).then(function(){t.client.session.user.hasActivated=!0})},t.prototype.login=function(e,t){var o=this,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return this.client.crypto().generatePasswordHash(t).then(function(t){return o.client.request("accounts.login",{email:e,password:t})}).then(function(t){var o=(new c.default).fromSession(t.data);return o.user.email=e,o}).then(function(e){return n?o.client.crypto().decryptPrivateKey(e.privateKeyPEM$,t).then(function(t){return e.privateKeyPEM=t,e}):e}).then(function(e){return o.client.setSession(e),e})},t.prototype.logout=function(){var e=this;return this.client.request("accounts.logout").catch(function(t){return e.client.setSession(null),Promise.reject(t)}).then(function(){e.client.setSession(null)})},t}(u.default);t.default=d},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(0),u=n(s),f=o(6),c=n(f),l=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.getSession=function(){var e=this;return this.client.request("sso.get-public-key").then(function(e){return e.data.ServerPublicKey}).then(function(t){return e.client.crypto().generateWrappedSymmetricKey(t)}).then(function(t){var o=t.key,n=t.key$;return Promise.all([o,e.client.request("sso.get-session",{nonce:n})])}).then(function(t){var o=t[0],n=t[1],r=(new c.default).fromSession(n.data);return Promise.all([r,e.client.crypto().decryptManagedPrivateKey(r.privateKeyPEM$,o)])}).then(function(e){var t=e[0],o=e[1];return t.privateKeyPEM=o,t})},t.prototype.getLoginOptions=function(e){return this.client.request("sso.get-login-options",{email:e}).then(function(e){return e.data})},t}(u.default);t.default=l},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){var t={};return Object.keys(d).forEach(function(o){t[o]=e[d[o]]}),t}function u(e){return(e||[]).map(function(e){return(new p.default).fromProof(e)})}t.__esModule=!0;var f=o(0),c=n(f),l=o(4),p=n(l),d={inbox:"ProofIn",sent:"ProofOut",outbox:"ProofOutBox"},h=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.inbox=function(){return this._loadSingleTabProofs("inbox")},t.prototype.sent=function(){return this._loadSingleTabProofs("sent")},t.prototype.outbox=function(){return this._loadSingleTabProofs("outbox")},t.prototype._loadSingleTabProofs=function(e){return this.client.request("dashboard."+e).then(function(e){return s(e.data)}).then(function(t){return t[e]}).then(u)},t.prototype.search=function(e){return this._loadSearchProofs({query:e})},t.prototype.everything=function(){return this._loadSearchProofs({all:1})},t.prototype.approved=function(){return this._loadSearchProofs({filterBy:70})},t.prototype.archived=function(){return this._loadSearchProofs({filterBy:100})},t.prototype._loadSearchProofs=function(e){return this.client.request("dashboard.search",e).then(function(e){return u(e.data.Proofs)})},t}(c.default);t.default=h},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){return e.data.length>0?(new p.default).fromUser(e.data[0]):(new p.default).fromUser(e.data)}function u(e){return e.data.length?(new p.default).fromUser(e.data[0]):null}t.__esModule=!0;var f=o(0),c=n(f),l=o(3),p=n(l),d=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.byEmail=function(e){return this.client.request("users.by-email",{email:e}).then(u)},t.prototype.byId=function(e){return this.client.request("users.by-id",{userId:e}).then(s)},t.prototype.invite=function(e){return this.client.request("users.invite",{email:e}).then(s)},t}(c.default);t.default=d},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(0),u=n(s),f=o(47),c=n(f),l=o(48),p=n(l),d=o(49),h=n(d),y=o(50),m=n(y),w=o(4),v=n(w),_=o(5),b=n(_),E=o(2),g=function(e){function t(o){r(this,t);var n=i(this,e.call(this,o));return n.owners=new c.default(o),n.editors=new p.default(o),n.versions=new h.default(o),n.groups=new m.default(o),n}return a(t,e),t.prototype.setWorkflow=function(e,t){var o=this;return this.client.request("proofs.normalize-workflow",{proofId:e,workflowId:t}).then(function(){return o.client.request("proofs.set-workflow",{proofId:e,workflowId:t})})},t.prototype.setTags=function(e,t){return this.client.request("proofs.set-tags",{relatedId:e,tag:t.join(",")})},t.prototype.deleteTag=function(e,t){return this.client.request("proofs.tag-delete",{relatedId:e,tag:t})},t.prototype.setFile=function(e,t){var o=this;return this.client.request("proofs.set-file",{proofId:e,fileId:t}).then(function(){return o.client.request("proofs.distribute-file",{proofId:e})})},t.prototype.create=function(e){var t=this,o=e.name,n=e.tags,r=void 0===n?[]:n,i=e.dueDate,a=void 0===i?new Date(Date.now()+3*E.DAY_IN_MS):i,s=e.messageToReviewers,u=e.workflow,f=e.file,c=e.group,l=e.start,p=void 0===l||l,d=p&&!c;return this.client.request("proofs.create",{title:o,dueDate:a.toISOString(),description:s,groupId:c?c.id:void 0}).then(function(e){var o=(new v.default).fromProof(e.data);return Promise.all([o,r.length&&t.setTags(o.id,r),u&&t.setWorkflow(o.id,u.id),f&&t.setFile(o.id,f.id)])}).then(function(e){var o=e[0];return Promise.resolve(d&&t.start(o.id)).then(function(){return o})}).then(function(e){return u&&(e.workflowId=u.id),f&&(e.fileId=f.id,e.fileStatus=b.default.UPLOADING),e.calculateState(),e})},t.prototype.archive=function(e){return this.client.request("proofs.archive",{proofId:e})},t.prototype.unarchive=function(e){return this.client.request("proofs.unarchive",{proofId:e})},t.prototype.delete=function(e){return this.client.request("proofs.delete",{proofId:e})},t.prototype.return=function(e){return this.client.request("proofs.return",{proofId:e})},t.prototype.start=function(e){return this.client.request("proofs.start",{proofId:e})},t.prototype.removeEditor=function(e){return this.client.request("proofs.remove-editor",{proofId:e})},t.prototype.load=function(e){return this.client.request("proofs.load",{proofId:e}).then(function(e){return(new v.default).fromProof(e.data)})},t.prototype.lock=function(e){return this.client.request("proofs.lock",{proofId:e})},t.prototype.unlock=function(e){return this.client.request("proofs.unlock",{proofId:e})},t.prototype.requestUnlock=function(e){return this.client.request("proofs.request-unlock",{proofId:e})},t}(u.default);t.default=g},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=o(0),s=function(e){return e&&e.__esModule?e:{default:e}}(a),u=function(e){function t(){return n(this,t),r(this,e.apply(this,arguments))}return i(t,e),t.prototype.add=function(e,t){return this.client.request("proofs-owners.add",{proofId:e,users:[].concat(t)})},t.prototype.remove=function(e,t){return this.client.request("proofs-owners.remove",{proofId:e,users:[].concat(t)})},t}(s.default);t.default=u},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=o(0),s=function(e){return e&&e.__esModule?e:{default:e}}(a),u=function(e){function t(){return n(this,t),r(this,e.apply(this,arguments))}return i(t,e),t.prototype.add=function(e,t,o){var n={proofId:e,editors:[].concat(t),editorMessage:null===o?"":o};return this.client.request("proofs.editors.add",n)},t.prototype.remove=function(e,t){return this.client.request("proofs.editors.remove",{proofId:e,editors:[].concat(t)})},t.prototype.replace=function(e,t,o){return this.client.request("proofs.editors.replace",{proofId:e,oldEditors:[].concat(t),newEditors:[].concat(o)})},t.prototype.set=function(e,t){return this.client.request("proofs.editors.set",{proofId:e,editors:[].concat(t)})},t}(s.default);t.default=u},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(0),u=n(s),f=o(20),c=n(f),l=o(21),p=(0,l.sortObjectsByKey)("version"),d=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.attach=function(e,t){return this.client.request("proofs.versions.attach",{proofId:e,versionId:t})},t.prototype.list=function(e){return this.client.request("proofs.versions.list",{proofId:e}).then(function(e){return e.data.map(function(e){return(new c.default).fromProofVersion(e)}).sort(p)})},t}(u.default);t.default=d},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){return(new l.default).fromProofGroup(e.data)}t.__esModule=!0;var u=o(0),f=n(u),c=o(22),l=n(c),p=o(51),d=n(p),h=o(52),y=n(h),m=function(e){function t(o){r(this,t);var n=i(this,e.call(this,o));return n.owners=new d.default(o),n.workflows=new y.default(o),n}return a(t,e),t.prototype.create=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.name;return this.client.request("proofs.groups.create",{name:t}).then(s)},t.prototype.load=function(e){return this.client.request("proofs.groups.load",{groupId:e}).then(s)},t.prototype.ready=function(e){return this.client.request("proofs.groups.ready",{groupId:e})},t.prototype.update=function(e,t){var o=t.name;return this.client.request("proofs.groups.update",{groupId:e,name:o}).then(s)},t}(f.default);t.default=m},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=o(0),s=function(e){return e&&e.__esModule?e:{default:e}}(a),u=function(e){function t(){return n(this,t),r(this,e.apply(this,arguments))}return i(t,e),t.prototype.add=function(e,t){return this.client.request("proofs.groups.owners.add",{groupId:e,owners:[].concat(t)})},t}(s.default);t.default=u},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=o(0),s=function(e){return e&&e.__esModule?e:{default:e}}(a),u=function(e){function t(){return n(this,t),r(this,e.apply(this,arguments))}return i(t,e),t.prototype.addReviewers=function(e,t){return this.client.request("proofs.groups.workflows.add-reviewers",{groupId:e,reviewers:[].concat(t)})},t}(s.default);t.default=u},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(0),u=n(s),f=o(4),c=n(f),l=o(5),p=n(l),d=o(2),h=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.setTags=function(e,t){return this.client.request("proofs.set-tags",{relatedId:e,tag:t.join(",")})},t.prototype.deleteTag=function(e,t){return this.client.request("proofs.tag-delete",{relatedId:e,tag:t})},t.prototype.setFile=function(e,t){var o=this;return this.client.request("proofs.set-file",{proofId:e,fileId:t}).then(function(){return o.client.request("proofs.distribute-file",{proofId:e})})},t.prototype.create=function(e){var t=this,o=e.name,n=e.file,r=e.tags,i=void 0===r?[]:r,a=e.dueDate,s=void 0===a?new Date(Date.now()+3*d.DAY_IN_MS):a;return this.client.request("briefs.create",{title:o,messageToRecipient:"",dueDate:s.toISOString(),tag:i.join(",")}).then(function(e){var o=(new c.default).fromProof(e.data.Brief);return Promise.all([o,n&&t.setFile(o.id,n.id)])}).then(function(e){var t=e[0];return n&&(t.fileId=n.id,t.fileStatus=p.default.UPLOADING),t.calculateState(),t})},t.prototype.update=function(e){var t=this,o=e.briefId,n=e.data,r=e.start,i=void 0!==r&&r;return this.client.request("briefs.update",{briefId:o,title:n.title,messageToRecipient:n.messageToRecipient,dueDate:n.dueDate?n.dueDate.toISOString():"",tag:n.tags?n.tags.join(","):"",recipient:n.recipient,editorId:n.editorId,editorMessage:n.editorMessage}).then(function(e){return(new c.default).fromProof(e.data.Brief)}).then(function(e){return Promise.resolve(i&&t.start(e.id)).then(function(){return e})})},t.prototype.delete=function(e){return this.client.request("proofs.delete",{proofId:e})},t.prototype.start=function(e){return this.client.request("briefs.start",{briefId:e})},t}(u.default);t.default=h},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){var t=e.lastIndexOf(".");return{name:(0,O.default)(e.substring(0,t)),extension:e.substring(t+1)}}t.__esModule=!0;var u=o(0),f=n(u),c=o(10),l=n(c),p=o(5),d=n(p),h=o(23),y=n(h),m=o(55),w=n(m),v=o(7),_=n(v),b=o(60),E=n(b),g=o(61),O=n(g),P=o(2),I=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.generateToken=function(e,t){return e&&!t?Promise.reject(Error('The "assignedType" option is required when specifying the "assignedTo" option.')):!e&&t?Promise.reject(Error('The "assignedTo" option is required when specifying the "assignedType" option.')):this.client.request("files.generate-token",{relatedId:e,fileType:t}).then(function(e){return e.data.Token})},t.prototype._waitFileProcessed=function(e){var t=this;return new Promise(function(o,n){var r=null,i=null;!function a(){t.details(e).then(function(t){switch(r=null,t.status){case d.default.OK:o(t);break;case d.default.ERROR:n(new Error("File "+e+" encountered a processing error: "+t.message));break;default:r=setTimeout(a,5e3)}r&&t.status!==d.default.RIPPING||clearTimeout(i)}).catch(n)}(),i=setTimeout(function(){clearTimeout(r),n(new Error("File did not finish processing within specified duration."))},3e4)})},t.prototype.import=function(e){var t=this,o=e.name,n=e.url,r=e.provider,i=void 0===r?y.default.NONE:r,a=e.auth,u=e.download,f=void 0!==u&&u,c=e.process,p=void 0!==c&&c;if(!Object.keys(y.default).some(function(e){return y.default[e]===i}))return Promise.reject(new Error('Unsupported provider "'+i+'"'));var d=i;i===y.default.NONE&&(d="generic");var h=s(o),m=h.name,w=h.extension;return this._generateKeyIVEnvelope().then(function(e){var o=e.envelope;return t.client.request("files.import."+d,{extn:w,filename:m,url:n,envelope:o,accessToken:a,storeOriginal:f})}).then(function(e){return e.data}).then(function(e){if(p)return t._waitFileProcessed(e);var o=new l.default;return o.id=e,o})},t.prototype._generateKeyIVEnvelope=function(){var e=this;return this.client.crypto().generateKeyIV().then(function(t){return Promise.all([t,e.client.crypto().envelopeSeal(t.keyIV,[e.client.session.serverPublicKeyPEM,e.client.session.publicKeyPEM])])}).then(function(e){return{keyIV:e[0],envelope:e[1]}})},t.prototype.upload=function(e){var t=this,o=e.name,n=e.contents,r=e.assignedTo,i=e.assignedType,a=e.download,s=void 0!==a&&a,u=e.async,f=void 0===u||u,c=e.onProgress,p=e.onError;return this.generateToken(r,i).then(function(e){return Promise.all([e,t._generateKeyIVEnvelope()])}).then(function(e){var r=e[0],i=e[1],a=i.keyIV,u=i.envelope,l=t._upload({name:o,contents:n,download:s,token:r,keyIV:a,envelope:u,onProgress:c,onError:p});return f&&(l=Promise.resolve()),l.then(function(){return r})}).then(function(e){var t=new l.default;return t.id=e,t})},t.prototype._upload=function(e){var t=this,o=e.name,n=e.contents,r=e.download,i=e.token,a=e.keyIV,u=e.envelope,f=e.onProgress;return new Promise(function(e){function c(){y().then(function(t){if(!_)if(null===t)_=!0,e(m.then(T));else{var o=I(t,v++);m=m.then(function(){return o}),o.then(c)}})}var l=4,p=s(o),d=p.name,h=p.extension,y=(0,w.default)(n),m=Promise.resolve(),v=0,_=!1,b=Math.ceil((0,E.default)(n)/P.BYTES_PER_BLOCK),g=new Array(b),O=function(){};f&&(O=function(e,t){g[e]=Math.max(t,g[e]||0),f(g.reduce(function(e,t){return e+(t||0)},0)/b*.99)});for(var I=function(e,o){return t.client.crypto().encryptFileBlock(a,e).then(function(e){return t.client.request("files.upload-block",{block:o,part:1,token:i,data:e},{onUploadProgress:O.bind(null,o)})})},T=function(){return t.client.request("files.upload-complete",{block:0,blockCount:v,part:0,token:i,extn:h,pages:1,filename:d,storeoriginal:r?1:0,envelope:u}).then(function(){return f&&f(100)})};l--;)c()})},t.prototype.download=function(e){var t=this,o="string"==typeof e?{fileId:e}:e,n=o.fileId;return this.details(n).then(function(e){if(!e.downloadable)throw new Error("File "+n+" is not downloadable.");if(e.status!==d.default.OK)throw new Error("File "+n+" cannot be download. The file may still be uploading, processing or has errored.");if(!e.blocks)throw new Error("File "+n+" is empty.");return t._downloadFile(e,o)})},t.prototype._downloadFile=function(e,t){var o=this;return new Promise(function(n){function r(){if(!y)if(h<u.length){var e=h++,t=d(e);f=f.then(function(){return t.then(function(t){return c(t,e,s)})}),t.then(r)}else y=!0,n(f.then(m))}var i=4,a=new _.default,s=e.blocks,u=new Array(s),f=Promise.resolve(),c=t.onData||function(e,t){u[t]=e},l=function(){};if(t.onProgress){var p=new Array(s);l=function(e,o){p[e]=Math.max(o,p[e]||0),t.onProgress(p.reduce(function(e,t){return e+(t||0)},0)/s*.99)}}for(var d=function(t){return o.client.request("files.download-block",{proofId:e.assignedTo,fileId:e.id,block:t+1},{onDownloadProgress:l.bind(null,t)}).then(function(e){return o.client.crypto().decryptFileBlock(e.data,o.client.session.privateKeyPEM).then(function(e){return a.createBase64(e)})})},h=0,y=!1,m=function(){return t.onProgress&&t.onProgress(100),t.onData?null:a.combine.apply(a,u)};i--;)r()})},t.prototype.details=function(e){return this.client.request("files.details",{fileId:e}).then(function(e){return(new l.default).fromFile(e.data)})},t.prototype.thumbnail=function(e){var t=this;return this.client.cache.auto(P.THUMBNAIL_CACHE_PREFIX+e,function(){return t._thumbnail(e)})},t.prototype._thumbnail=function(e){var t=this;return this.client.request("files.thumbnail",{fileId:e}).then(function(e){return t.client.crypto().decryptImage(e.data,t.client.session.privateKeyPEM)}).then(function(e){return(new _.default).createBase64(e)})},t.prototype.thumbnails=function(e,t){var o=this,n=t.async,r=void 0!==n&&n,i=t.onLoadThumbnails,a=[];return Promise.all(e.map(function(e){return o.client.cache.auto(P.THUMBNAIL_CACHE_PREFIX+e,function(t){a.push({fileId:e,resolve:t})}).then(function(t){var o;return t&&(o={},o[e]=t,o)})})).then(function(e){var t=Promise.all(a.map(function(e){var t=e.fileId,n=e.resolve;return o._thumbnail(t).then(function(e){if(n(e),r){var o;i((o={},o[t]=e,o))}return e})}));return r?e:t.then(function(t){return[].concat(e,t)})}).then(function(e){return Object.assign.apply(Object,[{}].concat(e))})},t}(f.default);t.default=I},function(e,t,o){"use strict";function n(e){var t=new a.default,o=0,n=Promise.resolve(),i=t.size(e);return function(){var a=o++*r.BYTES_PER_BLOCK,s=a+r.BYTES_PER_BLOCK;return n=n.then(function(){return a>i?null:t.slice(e,a,s).then(t.readBase64).then(function(e){return"data:;base64,"+e})})}}t.__esModule=!0;var r=o(2),i=o(7),a=function(e){return e&&e.__esModule?e:{default:e}}(i);t.default=n},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e){for(var t=new ArrayBuffer(e.length),o=new Uint8Array(t),n=0;n<e.length;n++)o[n]=e.charCodeAt(n);return t}t.__esModule=!0;var i=function(){function e(){n(this,e)}return e.prototype.create=function(e){return Promise.resolve(new Blob([r(e)]))},e.prototype.createBase64=function(e){return this.create(atob(e))},e.prototype.combine=function(){for(var e=arguments.length,t=Array(e),o=0;o<e;o++)t[o]=arguments[o];return Promise.resolve(new Blob(t))},e.prototype.slice=function(e,t,o){return Promise.resolve(e.slice(t,o))},e.prototype.read=function(e){return new Promise(function(t,o){var n=new FileReader;n.onload=function(){t(n.result)},n.onerror=function(){o(n.error)},n.readAsText(e)})},e.prototype.readBase64=function(e){return new Promise(function(t,o){var n=new FileReader;n.onload=function(){var e=n.result;t(e.substring(e.indexOf(",")+1))},n.onerror=function(){o(n.error)},n.readAsDataURL(e)})},e.prototype.size=function(e){return e.size},e}();t.default=i},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var r=function(){function e(){n(this,e)}return e.prototype.create=function(e){return Promise.resolve(Buffer.from(e))},e.prototype.createBase64=function(e){return Promise.resolve(Buffer.from(e,"base64"))},e.prototype.combine=function(){for(var e=arguments.length,t=Array(e),o=0;o<e;o++)t[o]=arguments[o];return Promise.resolve(Buffer.concat(t))},e.prototype.slice=function(e,t,o){return Promise.resolve(e.slice(t,o))},e.prototype.read=function(e){return Promise.resolve(e.toString())},e.prototype.readBase64=function(e){return Promise.resolve(e.toString("base64"))},e.prototype.size=function(e){return Buffer.byteLength(e)},e}();t.default=r},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e){for(var t=e.length,o=e.length-1;o>=0;o--){var n=e.charCodeAt(o);n>127&&n<=2047?t++:n>2047&&n<=65535&&(t+=2),n>=56320&&n<=57343&&o--}return t}t.__esModule=!0;var i=o(59),a=function(){function e(){n(this,e)}return e.prototype.create=function(e){return Promise.resolve(e)},e.prototype.createBase64=function(e){return Promise.resolve((0,i.atob)(e))},e.prototype.combine=function(){for(var e=arguments.length,t=Array(e),o=0;o<e;o++)t[o]=arguments[o];return Promise.resolve(t.join(""))},e.prototype.slice=function(e,t,o){return Promise.resolve(e.slice(t,o))},e.prototype.read=function(e){return Promise.resolve(e)},e.prototype.readBase64=function(e){return Promise.resolve((0,i.btoa)(e))},e.prototype.size=function(e){return r(e)},e}();t.default=a},function(e,t,o){!function(){function e(e){this.message=e}var o=t,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";e.prototype=new Error,e.prototype.name="InvalidCharacterError",o.btoa||(o.btoa=function(t){for(var o,r,i=String(t),a=0,s=n,u="";i.charAt(0|a)||(s="=",a%1);u+=s.charAt(63&o>>8-a%1*8)){if((r=i.charCodeAt(a+=.75))>255)throw new e("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");o=o<<8|r}return u}),o.atob||(o.atob=function(t){var o=String(t).replace(/[=]+$/,"");if(o.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,i,a=0,s=0,u="";i=o.charAt(s++);~i&&(r=a%4?64*r+i:i,a++%4)?u+=String.fromCharCode(255&r>>(-2*a&6)):0)i=n.indexOf(i);return u})}()},function(e,t,o){"use strict";function n(e){return"undefined"!=typeof Blob&&e instanceof Blob?e.size:0}t.__esModule=!0,t.default=n},function(e,t,o){"use strict";function n(e){return e.replace(/[-_()]/g,"").replace(/\s+/g," ").replace(/\s/g,"_")}t.__esModule=!0,t.default=n},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(0),u=n(s),f=o(63),c=n(f),l=function(e){function t(o){r(this,t);var n=i(this,e.call(this,o));return n.team=new c.default(o),n}return a(t,e),t}(u.default);t.default=l},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var s=o(0),u=n(s),f=o(64),c=n(f),l=function(e){function t(o){r(this,t);var n=i(this,e.call(this,o));return n.users=new c.default(o),n}return a(t,e),t}(u.default);t.default=l},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){return e.data.map(function(e){return(new l.default).fromUser(e)})}t.__esModule=!0;var u=o(0),f=n(u),c=o(3),l=n(c),p=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype.enabled=function(){return this.client.request("admin.team.users.enabled").then(s)},t.prototype.disabled=function(){return this.client.request("admin.team.users.disabled").then(s)},t.prototype._setEnabled=function(e,t){return this.client.request("admin.team.users.set-enabled",{email:e,enabled:t})},t.prototype.enable=function(e){return this._setEnabled(e,!0)},t.prototype.disable=function(e){return this._setEnabled(e,!1)},t}(f.default);t.default=p},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){return e&&((0,w.isUserId)(e.id)||e.email)}function u(e){return(e||[]).map(function(e){return(new p.default).fromWorkflow(e)})}t.__esModule=!0;var f=o(0),c=n(f),l=o(24),p=n(l),d=o(12),h=n(d),y=o(13),m=n(y),w=o(19),v=o(66),_=n(v),b=function(e){function t(o){r(this,t);var n=i(this,e.call(this,o));return n.steps=new _.default(o),n}return a(t,e),t.prototype.create=function(e){var t=this,o=e.save,n=void 0!==o&&o,r=e.name,i=e.steps,a=void 0===i?[]:i,u=e.reviewers,f=e.approver;if(!s(f))return Promise.reject(Error("An approver is required to create a workflow."));if(n&&!r)return Promise.reject(Error("A workflow must have a name when saving it as a workflow template."));var c=a;u&&u.length&&c.splice(0,0,{users:u}),f&&c.push({position:1e3,users:[f]});for(var l=0,p=0;p<c.length;p++){var d=c[p];if(!d.users||!d.users.length)return Promise.reject(Error("Workflow steps must contain users."));(!d.position||d.position<l)&&(d.position=l+1),l=Math.max(l,d.position);for(var h=0;h<d.users.length;h++){if(!s(d.users[h]))return Promise.reject(Error("A user id or email address must be provided for a workflow user."))}}var y=void 0;return this._createWorkflow(r).then(function(e){return y=e.id,Promise.all([e,Promise.all(c.map(function(o){var n=e.getStepByPosition(o.position);return n?t._setWorkflowStepUsersMutate(e.id,n,o.users):t._addWorkflowStepAndUsers(e.id,o)}))])}).then(function(e){var t=e[0],o=e[1];return t.steps=o,t}).then(function(e){return n?t._duplicateWorkflow(y):e}).catch(function(e){return Promise.resolve(y&&t._deleteWorkflow(y)).then(function(){return Promise.reject(e)})})},t.prototype.load=function(e){return this.client.request("workflows.load",{workflowId:e}).then(function(e){return(new p.default).fromWorkflow(e.data)})},t.prototype.use=function(e){return this.duplicate(e)},t.prototype.duplicate=function(e){return this._duplicateWorkflow(e)},t.prototype.delete=function(e){return this._deleteWorkflow(e)},t.prototype.all=function(){return Promise.all([this.owned(),this.shared()]).then(function(e){return[].concat(e[0],e[1])})},t.prototype.owned=function(){return this.client.request("workflows.owned").then(function(e){return u(e.data)})},t.prototype.shared=function(){return this.client.request("workflows.shared").then(function(e){return u(e.data)})},t.prototype.setApprover=function(e,t){return this.client.request("workflows.users.set",{workflowId:e,position:1e3,users:[t]})},t.prototype._duplicateWorkflow=function(e){var t=this;return this.client.request("workflows.duplicate",{workflowId:e}).then(function(e){var o=e.data.WorkflowId;return t.load(o)})},t.prototype._deleteWorkflow=function(e){return this.client.request("workflows.delete",{workflowId:e})},t.prototype._createWorkflow=function(e){return this.client.request("workflows.create",{title:e}).then(function(e){return(new p.default).fromWorkflow(e.data)})},t.prototype._addWorkflowStepAndUsers=function(e,t){var o=this;return this.client.request("workflows.steps.add",{workflowId:e,title:t.name,position:t.position}).then(function(n){var r=(new h.default).fromWorkflowStep(n.data);return o._setWorkflowStepUsersMutate(e,r,t.users)})},t.prototype._setWorkflowStepUsersMutate=function(e,t,o){return this.client.request("workflows.users.set",{workflowId:e,stepId:t.id,users:o.map(function(e){return{email:e.email,userId:e.id,role:e.role,permissions:e.permissions&&{inviter:!!e.permissions.inviter}}})}).then(function(e){var o=e.data.map(function(e){return(new m.default).fromWorkflowUser(e)});return t.users=o,t})},t}(c.default);t.default=b},function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var a=o(0),s=function(e){return e&&e.__esModule?e:{default:e}}(a),u=function(e){function t(){return n(this,t),r(this,e.apply(this,arguments))}return i(t,e),t.prototype.moveBefore=function(e,t){return this.client.request("workflows.steps.move-before",{stepId:e,beforeStepId:t})},t.prototype.moveAfter=function(e,t){return this.client.request("workflows.steps.move-after",{stepId:e,afterStepId:t})},t.prototype.swap=function(e,t){return this.client.request("workflows.steps.swap",{stepId:e,swapStepId:t})},t}(s.default);t.default=u},function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function s(e){var t=[];return Object.keys(e).forEach(function(o){e[o].Comments.forEach(function(e){t.push(e)})}),t}function u(e){var t=[],o=[];e.forEach(function(e){var n=(new p.default).fromComment(e);n.parentCommentId?o.push(n):t.push(n)}),t.sort(P);var n=t.map(function(e){return e.id}),r=(0,m.sortObjectsBy)(function(e){return n.indexOf(e.parentCommentId)},!0);return o.sort((0,m.combineSort)(I,r)),t.concat(o)}t.__esModule=!0;var f=o(0),c=n(f),l=o(27),p=n(l),d=o(14),h=n(d),y=o(2),m=o(21),w=o(29),v=o(69),_=o(70),b=n(_),E=(0,m.sortObjectsByKey)("pageNumber"),g=(0,m.sortObjectsByKey)("createdDate",!0),O=(0,m.sortObjectsByKey)("createdDate",!1),P=(0,m.combineSort)(E,g),I=(0,m.combineSort)(E,O),T=function(e){function t(){return r(this,t),i(this,e.apply(this,arguments))}return a(t,e),t.prototype._mark=function(e,t,o){var n,r=void 0;switch(t){case h.default.TODO:r="change";break;case h.default.DONE:r="done";break;default:throw new Error('Cannot mark comment state "'+t+'".')}var i=(n={commentId:e},n[r]=o?1:0,n);return this.client.request("comments.state.update",i).then(function(){return null})},t.prototype.mark=function(e,t){return this._mark(e,t,!0)},t.prototype.unmark=function(e,t){return this._mark(e,t,!1)},t.prototype.load=function(e){var t=this,o="string"==typeof e?{proofId:e}:e,n=o.proofId,r=o.pageNumber,i=void 0===r?null:r,a=o.sinceDate,f=void 0===a?null:a,c=o.async,l=void 0!==c&&c,p=o.decrypt,d=void 0===p||p,h=o.onDecryptComment,m=o.onDecryptComments,w=o.onDecryptCommentsThrottleMs,v=void 0===w?1e3:w,_=o.onDecryptError,E=f?f.toISOString().match(y.ISO_REGEX)[0]:y.DEFAULT_ISO_DATE,g={proofId:n,page:i,timestamp:E};return this.client.request(null!==i?"comments.load-page":"comments.load-all",g).then(function(e){var o=u(e.data.Pages?s(e.data.Pages):e.data),n=Promise.resolve();if(d){var r=[],i=[],a=m?(0,b.default)(function(){i.length&&(m(i),i=[])},v):function(){},f=Promise.all(o.map(function(e){return t.client.cache.auto(y.COMMENT_CACHE_PREFIX+e.comment$,function(t){r.push({comment:e,resolve:t})}).then(function(t){return t&&e.fromRawComment(t),e})}));n=n.then(function(){return f}),n=n.then(function(){var e=r.map(function(e){var o=e.comment,n=e.resolve;return t.client.crypto().decryptComment(o.comment$,o.envelope,t.client.session.privateKeyPEM).then(function(e){o.fromRawComment(e),n(e),h&&h(o),i.push(o),a()}).catch(function(e){if(_&&_(e,o),!l)return Promise.reject(e)})});return l?null:Promise.all(e)})}return n.then(function(){return o})})},t.prototype.create=function(e){var t=this,o=e.raw,n=e.proofId,r=e.pageNumber,i=void 0===r?1:r,a=e.pin,s=e.mediaTime,u=e.mediaDuration,f=e.parentCommentId,c=e.metadata,l=e.state,d=e.creationToken,y=(0,w.getCommentMentions)(o),m=d||(0,v.generateCreationToken)();return this.client.crypto().encryptComment(o,[this.client.session.serverPublicKeyPEM,this.client.session.publicKeyPEM]).then(function(e){var t=e.envelope,o=e.comment$;return{proofId:n,page:f?void 0:i,envelope:t,encryptedComment:o,xy:JSON.stringify({x:a&&"number"==typeof a.x?a.x:null,y:a&&"number"==typeof a.y?a.y:null,x2:a&&"number"==typeof a.x2?a.x2:null,y2:a&&"number"==typeof a.y2?a.y2:null,time:"number"==typeof s?s:null,duration:"number"==typeof u?u:null}),parent:f||void 0,mentions:y.map(function(e){return e.id}).join(","),metadata:c?JSON.stringify(c):"{}",creationToken:m,change:l===h.default.TODO?"1":void 0,done:l===h.default.DONE?"1":void 0}}).then(function(e){return t.client.request("comments.create",e).then(function(e){return(new p.default).fromComment(e.data).fromRawComment(o)})}).catch(function(e){return e&&(e.creationToken=m),Promise.reject(e)})},t}(c.default);t.default=T},function(e,t,o){"use strict";function n(e){var t=""+e,o=r.exec(t);if(!o)return t;var n,i="",a=0,s=0;for(a=o.index;a<t.length;a++){switch(t.charCodeAt(a)){case 34:n=""";break;case 38:n="&";break;case 39:n="'";break;case 60:n="<";break;case 62:n=">";break;default:continue}s!==a&&(i+=t.substring(s,a)),s=a+1,i+=n}return s!==a?i+t.substring(s,a):i}/*!
|
|
2
2
|
* escape-html
|
|
3
3
|
* Copyright(c) 2012-2013 TJ Holowaychuk
|
|
4
4
|
* Copyright(c) 2015 Andreas Lubbe
|