(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[5],{

/***/ "twrL":
/***/ (function(module, exports, __webpack_require__) {

/* WEBPACK VAR INJECTION */(function(Buffer) {/************************************************************************!
*
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2015-2021 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/!function(e,t){ true?module.exports=t():undefined;}(this,function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports;}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i});},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0});},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(i,o,function(t){return e[t];}.bind(null,o));return i;},n.n=function(e){var t=e&&e.__esModule?function(){return e.default;}:function(){return e;};return n.d(t,"a",t),t;},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t);},n.p="",n(n.s=46);}([function(e,t,n){var i=n(8);function o(e,t,n){if(Error.call(this),Error.captureStackTrace)Error.captureStackTrace(this,o);else{var i=new Error();i.name=this.name,this.stack=i.stack;}this.code=e,this.message="["+e+"] "+t,this.underlyingError=n;}o.prototype=Object.create(Error.prototype),o.prototype.name="AdobeDCXError",o.INVALID_JSON="INVALID_JSON",o.READ_ONLY="READ_ONLY",o.INVALID_PARAMS="",o.INVALID_DATA="INVALID_DATA",o.DUPLICATE_VALUE="DUPLICATE_VALUE",o.NO_LOCAL_STORAGE="NO_LOCAL_STORAGE",o.INVALID_STATE="INVALID_STATE",o.DELETED_COMPOSITE="DELETED_COMPOSITE",o.UNEXPECTED_RESPONSE="UNEXPECTED_RESPONSE",o.ACCESS_DENIED="ACCESS_DENIED",o.NOT_FOUND="NOT_FOUND",o.NETWORK_ERROR="NETWORK_ERROR",o.COMPONENT_DOWNLOAD_ERROR="COMPONENT_DOWNLOAD_ERROR",o.COMPONENT_UPLOAD_ERROR="COMPONENT_UPLOAD_ERROR",o.COMPONENT_MODIFIED_ERROR="COMPONENT_MODIFIED_ERROR",o.UPDATE_CONFLICT="UPDATE_CONFLICT",o.NO_COMPOSITE="NO_COMPOSITE",o.ALREADY_EXISTS="ALREADY_EXISTS",o.SERVICE_IS_INACTIVE="SERVICE_IS_INACTIVE",o.EXCEEDS_QUOTA="EXCEEDS_QUOTA",o.NOT_IMPLEMENTED="NOT_IMPLEMENTED",o.RETRYABLE_SERVER_ERROR="RETRYABLE_SERVER_ERROR",o.TIMED_OUT="TIMED_OUT",o.UNEXPECTED="UNEXPECTED",o.TERMINATED_INPUTSTREAM="TERMINATED_INPUTSTREAM",o.WRONG_ENDPOINT="WRONG_ENDPOINT",o.OUT_OF_SPACE="ENOSPC";var r={};r[o.SERVICE_IS_INACTIVE]=1,r[o.NOT_IMPLEMENTED]=1,r[o.EXCEEDS_QUOTA]=1,r[o.RETRYABLE_SERVER_ERROR]=1,r[o.TIMED_OUT]=1,r[o.TERMINATED_INPUTSTREAM]=1,r[o.WRONG_ENDPOINT]=1,r[o.OUT_OF_SPACE]=1,o.wrapError=function(e,t,n,a){if(!n||!r[n.code]){if(a){var s=a.statusCode;if(s>=500&&s<600)501===s?(e=o.NOT_IMPLEMENTED,t="Unimplemented request"):507===s?(e=o.EXCEEDS_QUOTA,t="Quota exceeded"):(e=o.RETRYABLE_SERVER_ERROR,t="Server error");else if(429===s)e=o.RETRYABLE_SERVER_ERROR,t="Too many requests";else if(403===s){var c,l=a.responseText||a.response;try{c=JSON.parse(l);}catch(e){}if(c){var u=c.message&&c.message.includes("code=403.1"),_=c.type&&c.type===i.QUOTA_EXCEEDED;(u||_)&&(e=o.EXCEEDS_QUOTA,t="Quota exceeded");}}}n=new o(e,t,n);}return a&&(n.response=a),n;},o.networkError=function(e,t,n){return o.wrapError(o.NETWORK_ERROR,e,t,n);},o.unexpectedResponse=function(e,t,n){return o.wrapError(o.UNEXPECTED_RESPONSE,e,t,n);},e.exports=o;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}var o,r,a=n(21);o=n(22);var s={},c={"application/vnd.adobe.library+dcx":".cclibc"};s._setLogCallback=function(e){r=e;},s.merge=function(e){var t,n;for(t=1;t<arguments.length;++t){var o=arguments[t];if("object"===i(o))for(n in o)o.hasOwnProperty(n)&&(e[n]=o[n]);}return e;},s.parentDirectory=function(e){var t=e.split("/");return t.pop(),t.join("/");},s.filePathComponents=function(e){var t=e.split("/"),n=t.pop(),i=n.split("."),o=i.length>1?i.pop():null;return{directory:t.join("/"),fileName:n,baseName:i.join("."),extension:o};},s.appendPathElements=function(){var e,t=[],n=arguments.length;for(e=0;e<n;e++){var i=arguments[e];"string"==typeof i&&""!==i&&(0===e&&1!==i.length||"/"===i.charAt(0)&&(i=i.slice(1)),e!==n-1&&"/"===i.charAt(i.length-1)&&(i=i.slice(0,i.length-1)),t.push(i));}return t.join("/");};var l=/^[^\u0000-\u001F\u0022\u002A\u003A\u003C\u003E\u003F\u005C\u007F]*[^\u0000-\u001F\u0022\u002A\u002E\u003A\u003C\u003E\u003F\u005C\u007F]{1}$/;s.isValidPath=function(e,t){try{if(e.length>65535)return!1;var n=(t?e.slice(1):e).split("/");if(!n||0===n.length)return!1;var i,o=n.length;for(i=0;i<o;i++){if(n[i].length>255||!l.test(n[i]))return!1;}if(t&&n.length>0){var r=n[0];if("manifest"===r||"mimetype"===r)return!1;}return!0;}catch(e){return!1;}},s.isValidAbsolutePath=function(e){return s.isValidPath(e,!0);};var u=s.noOp=function(){};s.consumeStream=function(e,t,n){e.on("data",n||u),e.on("end",t||u);},s.flatCopy=function(e){var t,n={},i=Object.keys(e),o=i.length;for(t=0;t<o;t++){var r=i[t];n[r]=e[r];}return n;},s.deepCopy=function(e){return JSON.parse(JSON.stringify(e));},s.objectsEqual=function(e,t,n){var o,r,a={},c=Object.keys(e),l=c.length;for(r=0;r<l;r++){if(o=c[r],!n||!n[o]){var u=e[o],_=t[o],h=i(u);if(h!==i(_))return!1;if("object"===h){if(!s.objectsEqual(u,_,n))return!1;}else if(u!==_)return!1;}a[o]=!0;}for(l=(c=Object.keys(t)).length,r=0;r<l;r++)if(!a[o=c[r]])return!1;return!0;};var _=new RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?");s.parseURI=function(e){var t=e.match(_);return{scheme:t[2],authority:t[4],path:t[5],query:t[7],fragment:t[9]};},s.endPointOf=function(e){var t,n=s.parseURI(e),i=n.scheme,o=n.authority,r="https"===i?443:"http"===i?80:-1;return i&&o&&(t=(i+"://"+o).toLowerCase(),r>=0&&o.indexOf(":")<0&&(t=t+":"+r)),t;},s.ensureRelativeHrefStartsWithSlash=function(e){if(e){var t=s.parseURI(e),n=t.scheme,i=t.authority;n||i||"/"!==e.charAt(0)&&(e="/"+e);}return e;};var h=/^([^:]+):(.*)$/,p=/^\s+|\s+$/g;s.parseHeaders=function(e){var t,n,i,o={},r=e.split(/\r?\n/);for(t=0;t<r.length;++t){var a=r[t];if(a.length>0){var s=a.charCodeAt(0);if(!n||9!==s&&32!==s){var c=h.exec(a);c&&c.length>1&&(n=c[1].toLowerCase(),i=(i=c[2]||"").replace(p,""),o[n]?o[n]=o[n]+","+i:o[n]=i);}else o[n]=o[n]+" "+a.replace(p,"");}}return o;},s.timeStamp=function(e){var t=new Date().getTime();return e&&(t-=t%1e3),t;},s.generateUuid=o,s.log=function(e){if("function"==typeof r)try{r(e);}catch(e){}},s.validateLinks=function(e){return void 0===e||Object(e)===e&&!Object.keys(e).some(function(t){var n=e[t];return"_expiry"===t?"number"!=typeof n:Array.isArray(n)?n.some(function(e){return"string"!=typeof e.href;}):"string"!=typeof n.href;});},s.getTemplateFromLinks=function(e,t){var n=e&&e[t];if(n&&(!Array.isArray(n)||0!==n.length))return Array.isArray(n)&&(n=n[0]),n.href;s.log("Requested link is not available: ".concat(t));},s.getUrlFromLinks=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=s.getTemplateFromLinks(e,t);if(i){var o=new a(i);return o&&o.fill(n);}},s.getExtension=function(e){return c[e]||"";},s.platformRepoNameRules={maxLength:255,reservedNameRegex:/^CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9]$/i,reservedCharRegex:/[\\/:*?"|><]/g},s.platformRepoNameValidators={isValidLength:function(e){return e.length<=s.platformRepoNameRules.maxLength;},isNotReserved:function(e){return!s.platformRepoNameRules.reservedNameRegex.test(e);},hasValidCharacters:function(e){return!s.platformRepoNameRules.reservedCharRegex.test(e);}},e.exports=s;},function(e,t){var n=["INVALID_PARAMETER","READ_ONLY","NOT_IMPLEMENTED","NOT_SUPPORTED","REQUIRES_FILESYSTEM","DELETED_LOCALLY"];function i(e,t,o,r){if(-1!==n.indexOf(e))if(Error.call(this),Error.captureStackTrace)Error.captureStackTrace(this,i);else{var a=new Error();a.name=this.name,this.stack=a.stack;}this.code=e,this._message=t,this.message="["+e+"] "+t,this.libraryId=o,this.underlyingError=r;}i.prototype=Object.create(Error.prototype),i.prototype.name="AdobeLibraryError",i.INVALID_PARAMETER="INVALID_PARAMETER",i.READ_ONLY="READ_ONLY",i.NOT_IMPLEMENTED="NOT_IMPLEMENTED",i.NOT_SUPPORTED="NOT_SUPPORTED",i.REQUIRES_FILESYSTEM="REQUIRES_FILESYSTEM",i.DELETED_LOCALLY="DELETED_LOCALLY",i.NOT_ALLOWED="NOT_ALLOWED",i.FILE_TOO_LARGE="FILE_TOO_LARGE",i.EXCEEDS_MAX_LIBRARY_SIZE="EXCEEDS_MAX_LIBRARY_SIZE",i.CORRUPTED_LIBRARY="CORRUPTED_LIBRARY",i.THUMBNAIL_NOT_AVAILABLE="THUMBNAIL_NOT_AVAILABLE",i.STALE_THUMBNAIL="STALE_THUMBNAIL",i.RENDITION_NOT_AVAILABLE="RENDITION_NOT_AVAILABLE",i.FS_ERROR="FS_ERROR",i.OUT_OF_SPACE="OUT_OF_SPACE",i.LOGGED_OUT="LOGGED_OUT",i.EXCEEDS_QUOTA="EXCEEDS_QUOTA",i.RETRYABLE_SERVER_ERROR="RETRYABLE_SERVER_ERROR",i.TRANSFER_ERROR="TRANSFER_ERROR",i.TRANSFER_ABORTED="TRANSFER_ABORTED",i.NETWORK_ERROR="NETWORK_ERROR",i.ACCESS_DENIED="ACCESS_DENIED",i.URL_VALIDATION_FAILED="URL_VALIDATION_FAILED",i.NO_COMPATIBLE_APP_FOUND="NO_COMPATIBLE_APP_FOUND",i.APP_LAUNCH_FAILED="APP_LAUNCH_FAILED",i.OPERATION_CANCELLED="OPERATION_CANCELLED",i.INVALID_DATA="INVALID_DATA",i.CLIENT_CONNECTION_ERROR="CLIENT_CONNECTION_ERROR",i.NOT_FOUND="NOT_FOUND",Object.freeze(i),Object.seal(i.prototype),e.exports=i;},function(e,t,n){var i=n(0),o=n(2),r={getErrorStatusCode:function(e){if(e){var t=e.code===i.UNEXPECTED_RESPONSE&&e.response&&e.response.statusCode;return t||(e.underlyingError?r.getErrorStatusCode(e.underlyingError):void 0);}}},a=[i.COMPONENT_UPLOAD_ERROR,i.COMPONENT_DOWNLOAD_ERROR];r.getSyncError=function(e,t,n){if(e){if(e.code===o.TRANSFER_ABORTED)return e;var s,c=r.getErrorStatusCode(e);return e.code===i.SERVICE_IS_INACTIVE?s=new o(o.LOGGED_OUT,"no access token: call updateAccessToken() and try again",t,e):e.code===i.NETWORK_ERROR?s=new o(o.NETWORK_ERROR,"error connecting to server",t,e):e.code===i.EXCEEDS_QUOTA?s=new o(o.EXCEEDS_QUOTA,"push failed due to insufficient remaining quota",t,e):e.code===i.OUT_OF_SPACE?s=new o(o.OUT_OF_SPACE,"not enough disk space",t,e):e.code===i.NOT_IMPLEMENTED?s=new o(o.NOT_IMPLEMENTED,"tried to call an API not implemented on the server",t,e):e.code===i.RETRYABLE_SERVER_ERROR?s=new o(o.RETRYABLE_SERVER_ERROR,"intermittent server failure - can retry later",t,e):e.code===i.INVALID_DATA||e.code===i.INVALID_JSON?s=new o(o.CORRUPTED_LIBRARY,"unable to read manifest",t,e):c&&n&&n[c]?s=new o(n[c],"server returned "+c+"response",t,e):a.includes(e.code)&&e.failedComponents&&e.failedComponents.forEach(function(i){var o=r.getSyncError(i.error,t,n);(!s||r.getErrorPriority(s)<r.getErrorPriority(o))&&((s=o).failedComponents=e.failedComponents);}),s||(s=new o(o.TRANSFER_ERROR,"something went wrong during a push/pull operation",t,e)),s;}},r.getCommitError=function(e,t,n){if(e){var r=n?" - "+n:"";return e.code===i.INVALID_DATA||e.code===i.INVALID_JSON?new o(o.CORRUPTED_LIBRARY,"unable to read manifest"+r,t,e):e.code===i.OUT_OF_SPACE?new o(o.OUT_OF_SPACE,"not enough disk space"+r,t,e):new o(o.FS_ERROR,"filesystem error"+r,t,e);}},r.getFileSystemError=function(e,t,n){if(e)return"ENOSPC"===e.code?new o(o.OUT_OF_SPACE,t,n,e):new o(o.FS_ERROR,t,n,e);},r.getSnapshotError=function(e,t,n){if(e)return e.code===i.INVALID_DATA||e.code===i.INVALID_PARAMS?new o(o.INVALID_DATA,n,t,e):r.getFileSystemError(e,n,t);},r.getErrorPriority=function(e){var t=[o.OPERATION_CANCELLED,o.EXCEEDS_MAX_LIBRARY_SIZE,o.THUMBNAIL_NOT_AVAILABLE,o.RENDITION_NOT_AVAILABLE,o.URL_VALIDATION_FAILED,o.CORRUPTED_LIBRARY,o.TRANSFER_ABORTED,o.TRANSFER_ERROR,o.NETWORK_ERROR,o.EXCEEDS_QUOTA,o.RETRYABLE_SERVER_ERROR,o.LOGGED_OUT,o.FILE_TOO_LARGE,o.INVALID_DATA,o.FS_ERROR,o.OUT_OF_SPACE,o.ACCESS_DENIED,o.NOT_ALLOWED,o.DELETED_LOCALLY,o.REQUIRES_FILESYSTEM,o.NOT_SUPPORTED,o.NOT_IMPLEMENTED,o.INVALID_PARAMETER,o.READ_ONLY],n=e&&e.code&&t.indexOf(e.code);return void 0!==n?n:-1;},r.errorToString=function(e){var t="";return e&&(e.message&&(t+=e.message),e.libraryId&&(t+=" library: "+e.libraryId),e.underlyingError?t+="\n<- "+r.errorToString(e.underlyingError):e.response&&e.response.statusCode&&(t+=": "+e.response.statusCode),e.failedComponents&&(t+="\n<- Failed Components:",e.failedComponents.forEach(function(e){var n=e.component&&e.component.id,i=e.error,o=i&&i.message,r=i&&i.response&&i.response.statusCode;t+="\n    ["+n+"] "+o+(r?": "+r:"");}))),t;},r.isErrorCode=function(e){return!!e&&o.hasOwnProperty(e)&&o[e]===e;},Object.seal(r),e.exports=r;},function(e,t){var n={constructStringFromTemplate:function(e,t){var n=e;return Object.keys(t).forEach(function(e){n=n.replace("{{"+e+"}}",t[e]);}),n;},parseLocalisationFile:function(e){for(var t={},n=e.split(/\n/),i=0;i<n.length;i++)if(n[i]=n[i].replace(/^\s\s*/,"").replace(/\s\s*$/,""),n[i].length>0&&"#"!==n[i].match("^#")){for(var o=n[i].split("="),r=o[0].replace(/^\s\s*/,"").replace(/\s\s*$/,""),a=1===o.length?"":o[1];a.match(/\\$/)&&"\\"===a.match(/\\$/).toString();)a=a.substring(0,a.length-1),a+=n[++i].replace(/\s\s*$/,"");for(var s=2;s<o.length;s++)a+="="+o[s];a=a.replace(/^\s\s*/,"").replace(/\s\s*$/,""),t[r]=a;}return t;},compareVersions:function(e,t){if(e=(e||"0").toString().replace(/(\.0)*$/,"").replace(/[^.0-9]+/gim,"."),t=(t||"0").toString().replace(/(\.0)*$/,"").replace(/[^.0-9]+/gim,"."),(isNaN(parseInt(e,10))||parseInt(e,10)>250)&&(e="0"),(isNaN(parseInt(t,10))||parseInt(t,10)>250)&&(t="0"),e===t)return 0;for(var n,i=e.split("."),o=t.split("."),r=0;r<i.length&&r<o.length;r++){if(n=parseInt(i[r],10)-parseInt(o[r],10),isNaN(n))return isNaN(parseInt(i[r],10))?1:-1;if(n>0)return-1;if(n<0)return 1;}return(n=i.length-o.length)>0?-1:n<0?1:0;},promisify:function(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return new Promise(function(t,i){e.apply(void 0,n.concat([function(e,n){return e?i(e):t(n);}]));});};},debouncePromise:function(e,t){var n;return function(){for(var i=arguments.length,o=new Array(i),r=0;r<i;r++)o[r]=arguments[r];return new Promise(function(i,r){n&&clearTimeout(n),n=setTimeout(function(){t.apply(null,o).then(i,r),n=void 0;},e);});};}},i={KCCC:"ACCC",KCCCADS:"ADCS",PHSP:"PHXS",SPRK:"SPKR",SPRKPR:"SPKR",SPRKDV:"SPKR"};n.normalizeProductCode=function(e){return i[e]||e;};var o=function(e,t,n){return e=(e=e<t?t:e)>n?n:e;},r=function(e,t){return String.fromCharCode(Math.round((e.charCodeAt(0)+t.charCodeAt(0))/2));},a=/^[a-z]*[b-z][a-z]*$/;n.isValidOrderString=function(e){return"string"==typeof e&&a.test(e);},n.getOrderStringBetween=function(e,t){if(e=o(e||"a","a","{"),(t=o(t||"{","a","{"))===e)return e;if(t<e){var i=e;e=t,t=i;}for(var a=0;a<e.length;a++){var s=e[a],c=t[a];if(!c||s<c){var l=r(s,c);return l===c?e.substring(0,a+1)+n.getOrderStringBetween(e.substring(a+1),"{"):e.substring(0,a)+l;}}return e+n.getOrderStringBetween("a",t.substring(e.length));},n.getMultipleOrderStringsBetween=function(e,t,i){if(0===e)return[];var o=n.getOrderStringBetween(t,i),r=Math.floor(e/2),a=e-r-1,s=n.getMultipleOrderStringsBetween(r,t,o),c=n.getMultipleOrderStringsBetween(a,o,i);return s.concat([o]).concat(c);},n.isObject=function(e){return e===Object(e)&&!Array.isArray(e)&&"function"!=typeof e;},Object.seal(n),e.exports=n;},function(e,t,n){var i,o=n(1);var r={};var a={canUseFileSystem:!1,_setFS:function(e){i=e,a.canUseFileSystem=!!e;},ensureDirectoryExists:function(e,t){var n=function(e){e&&"EEXIST"===e.code?t():t(e);},r=function(r){if(r)t();else{var s=o.parentDirectory(e);s?a.ensureDirectoryExists(s,function(o){o?t(o):i.mkdir(e,n);}):i.mkdir(e,n);}};e?i.exists(e,r):r(!0);},getTempFilePathAt:function(e,t){!function n(){var i=e+o.generateUuid();a.exists(i,function(e){e?n():t(i);});}();},exists:function(e,t){i.exists(e,t);},deleteFile:function(e,t){i.unlink(e,function(e){e&&"ENOENT"!==e.code?t(e):t();});},readFile:function(e,t,n){i.readFile(e,t,n);},writeFile:function(e,t,n,r){var s=o.parentDirectory(e);a.ensureDirectoryExists(s,function(o){o?r(o):i.writeFile(e,t,n,r);});},writeFileAtomically:function(e,t,n,r){var s=o.parentDirectory(e);a.ensureDirectoryExists(s,function(o){o?r(o):a.getTempFilePathAt(s+"/",function(o){i.writeFile(o,t,n,function(t){t?r(t):i.rename(o,e,r);});});});},createWriteStream:function(e,t){return i.createWriteStream(e,t);},createReadStream:function(e,t){return i.createReadStream(e,t);},move:function(e,t,n,r){var s=o.parentDirectory(t);a.ensureDirectoryExists(s,function(o){if(o)r(o);else if(n){var a=new Date().getTime()/1e3;i.utimes(e,a,a,function(n){n?r(n):i.rename(e,t,r);});}else i.rename(e,t,r);});},info:function(e,t){i.stat(e,t);},directoryListing:function(e,t){var n,o,r=[],a=function(a){i.stat(e+"/"+a,function(e,i){if(!e)try{r.push({name:a,info:i}),n--;}catch(t){e=t;}e?o||(o=e,t(e)):0===n&&t(void 0,r);});};i.readdir(e,function(e,i){if(!e)try{var o,r=i.length;for(n=r,o=0;o<r;o++)a(i[o]);}catch(t){e=t;}e?t(e):0===n&&t(void 0,[]);});},deleteDirectory:function(e,t){var n,o,r=function(){try{i.rmdir(e,t);}catch(e){t(e);}},s=function(e){e&&!n&&(n=e),--o<1&&(n?t(n):r());},c=function(t){var n=e+"/"+t;i.unlink(n,function(e){try{e?a.deleteDirectory(n,function(e){s(e);}):s();}catch(e){s(e);}});};i.readdir(e,function(e,n){if(!e)try{var i,a=n.length;if(a<1)r();else for(o=a,i=0;i<a;i++)c(n[i]);}catch(t){e=t;}e&&t(e);});}};a.copyFile=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10;return r[t]=r[t]||{operationsInFlight:0,queue:[]},function(){for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];var s=o.pop(),c=function(){r[t].operationsInFlight+=1;e.apply(void 0,o.concat([function(){r[t].operationsInFlight-=1,r[t].queue.length>0&&r[t].queue.shift()(),s.apply(void 0,arguments);}]));};if(r[t].operationsInFlight>=n)return r[t].queue.push(c);c();};}(function(e,t,n){var r=o.parentDirectory(t);a.ensureDirectoryExists(r,function(r){r?n(r):function(e,t,n){var r=t+o.generateUuid();i.copyFile(e,r,function(e){e?n(e):i.rename(r,t,n);});}(e,t,n);});}),a.getMD5Hash=function(e,t){var n=(void 0).createHash("md5").setEncoding("base64");try{var o=i.createReadStream(e);o.pipe(n).on("finish",function(){return t(null,n.read());}),o.on("error",function(e){return t(e);});}catch(e){t(e);}},e.exports=a;},function(e,t,n){var i=n(11),o=n(1),r=n(0),a=n(16),s=n(2),c=n(4),l={},u={};l.isCompatibleType=function(e,t){return e===t||e===u[t];},l.validateLibraryId=function(e,t){if(t){if(e&&e.length>=30&&e.match(/^[0-9A-Z-]+$/i))return!0;}else if(e&&e.match(/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i))return!0;return!1;},l.areManifestsEqual=function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;var n=JSON.parse(e),i=JSON.parse(t);delete n["manifest-format-version"],delete i["manifest-format-version"];try{if(JSON.stringify(n)===JSON.stringify(i))return!0;}catch(e){}return!1;},l.getManifestForComparison=function(e,t){return t&&"\n"===t[1]?e._dcxBranch.prettifiedLocalData:e._dcxBranch.localData;},l.getDCXKey=function(e,t){if(!e||!("string"==typeof e||e instanceof String)||""===e)throw new s(s.INVALID_PARAMETER,"Invalid namespace");if(!t||!("string"==typeof t||t instanceof String)||""===t)throw new s(s.INVALID_PARAMETER,"Invalid key");return e+"#"+t;},l.getCustomDCXData=function(e){var t=e.getCustomKeys(),n=[];return t.forEach(function(t){var i=t.split("#"),o=i.length>=2;o&&i.forEach(function(e){""===e&&(o=!1);});var r=0===t.indexOf(a.DL_PREFIX);o&&!r&&n.push({namespace:i.shift(),key:i.join("#"),value:e.getValue(t)});}),n;},l.copyCustomDCXData=function(e,t){l.getCustomDCXData(e).forEach(function(e){t.setValue(l.getDCXKey(e.namespace,e.key),e.value);}),[a.REPRESENTATION_ORDER_KEY,a.IS_PREFERRED_THUMBNAIL_KEY,a.SHA_KEY].forEach(function(n){var i=e.getValue(n);i&&t.setValue(n,i);});},l.checkDeletedState=function(e,t){if(e.isDeletedLocally){if(t)return t(new s(s.DELETED_LOCALLY,"deleted/orphan object")),!0;throw new s(s.DELETED_LOCALLY,"deleted/orphan object");}return!1;},l.checkEncoding=function(e,t,n){if(-1===t.indexOf(e)){var i=t.join(", ");return n(new s(s.INVALID_PARAMETER,"Unsupported encoding. Supported encodings are: "+i)),!1;}return!0;},l.sortRepresentations=function(e){if(!(e.length<2))for(var t=!0;t;){t=!1;for(var n=1;n<e.length;n++){var i=e[n-1],o=e[n];o._getOrder()<i._getOrder()&&(e[n-1]=o,e[n]=i,t=!0);}}},l.removeMissingComponents=function(e,t,n){if(t&&n){var i=0;return n.forEach(function(n){var o=n.component,r=n.error;o&&r&&r.response&&404===r.response.statusCode&&e._services.log("Missing component: "+o.id+" from library "+t.compositeId),o&&r&&"[UNEXPECTED_RESPONSE] Incorrect content length"===r.message&&(i++,e._services.log("Skipped length-mismatch component: "+o.id+" from library "+t.compositeId));}),e._services.log("Fixed 0 of "+n.length+" components that failed to download"),e._analytics.reportRemoveMissingComponents(t.compositeId,n,0),n.length===0+i?t:void 0;}};var _=function(e,t){var n=function(e){return e.getRepresentationById(t);},i=e.elements.find(n)||e.removedElements.find(n);return i&&n(i);},h={"model/vnd.adobe.dn+dcx":"model/vnd.adobe.dn+dcxucf","application/vnd.adobe.element.agc+dcx":"application/vnd.adobe.element.agc+json"};l.fixLocalComponents=function(e,t){if(e&&t){var n=0,i=[];t.forEach(function(t){var o=t.component,a=t.error;if(o&&a&&a.code===r.INVALID_STATE){var s=_(e,o.id);s?i.push(s):e._dcxBranch.removeComponent(o),n++,e._services.log("Removed missing local component: ".concat(o.id," from library ").concat(e.id));}else if(o&&a&&h[o.type]){var c=_(e,o.id),l=h[o.type];c&&(c._getDCXElement().type=l,n++,e._services.log("Fixed mime type of local component: ".concat(o.id," from library ").concat(e.id," (").concat(l,")")));}}),n>0&&(e._beginOperation(),i.forEach(function(e){e.element.removeRepresentation(e);}),e._endOperation()),e._services.log("Fixed "+n+" of "+t.length+" components that failed to upload");}},l.recoverReadOnlyEdits=function(e,t,n){var i=[];e.elements.forEach(function(e){var n=t&&t.getChildWithId(e.id);(n&&n.getValue(a.MODIFIED_KEY))!==e.modified&&i.push(e);});var o=[];if(i.length>0){var r,s=e._localisation.translate("LIBS_RECOVERED_LIBRARY",{name:e.name});e.collection._privateCollection.libraries.some(function(t){if(t.name===s&&t.isWritable&&t.elements.length<e._config.MAX_ELEMENTS)return r=t,!0;}),r||(r=e.collection._privateCollection.createLibrary(s));var l=c.promisify(e.copyElement.bind(e));i.forEach(function(e){return o.push(l(e,r));}),e._services.log("Recovering "+i.length+" elements from read-only library");}Promise.all(o).then(function(){return n(null);},function(e){return n(e);});},l.ensureBranchDataValid=function(e){var t=[a.ELEMENTS_NAME,a.REMOVED_ELEMENTS_NAME,a.DOCUMENTATION_ELEMENTS_NAME],n=!1,i=function(e,t,n,i,o){e[t]||(e[t]={}),e[t][n]||(e[t][n]=[]),e[t][n].push({node:i,updateOrder:o});},o=function(e,t,n){var i=e.getValue(a.GROUPS_KEY);i[n].order=t,e.setValue(a.GROUPS_KEY,i);},r=function(e,t){e.setValue(a.ORDER_KEY,t);},s={};e.getChildrenOf().forEach(function(c){var l=t.includes(c.name),u=c.name===a.GROUPS_NAME;l?(function(i){if(-1!==t.indexOf(i.name)){var o=i.name===a.REMOVED_ELEMENTS_NAME;e.getChildrenOf(i).forEach(function(t){var i=t.getValue(a.REMOVED_KEY);!o&&i?(t.removeValue(a.REMOVED_KEY),n=!0):o&&!i&&(t.setValue(a.REMOVED_KEY,Date.now()),n=!0);var r=function(e){var t=e.getValue(a.CSDK_IS_FULL_SIZE_KEY);void 0!==t&&(e.removeValue(a.CSDK_IS_FULL_SIZE_KEY),void 0===e.getValue(a.IS_FULL_SIZE_KEY)&&e.setValue(a.IS_FULL_SIZE_KEY,t),n=!0);};e.getChildrenOf(t).forEach(r),e.getComponentsOf(t).forEach(r);});}}(c),function(t,n){a.ELEMENTS_NAME===n.name&&e.getChildrenOf(n).forEach(function(e){var n=e.getValue(a.GROUPS_KEY);if(n)for(var r in n)i(t,r,n[r].order,e,o);});}(s,c)):u&&function(t,n){e.getChildrenOf(n).forEach(function(e){var n=e.getValue(a.CLASSIFIER_KEY),o=e.getValue(a.ORDER_KEY),s=e.getValue(a.PARENT_KEY);i(t,"".concat(n,"#").concat(s),o,e,r);});}(s,c);});var l=function(e){var t=!1;return Object.keys(e).forEach(function(n){Object.keys(e[n]).sort().forEach(function(i,o,r){var a=e[n][i];if(a.length>1){t=!0;var s=r[o-1],l=r[o+1],u=c.getMultipleOrderStringsBetween(a.length,s,l);a.forEach(function(e,t){e.updateOrder(e.node,u[t],n);});}});}),t;}(s);return n||l;};var p=o.platformRepoNameRules,d=p.maxLength-o.getExtension(a.COMPOSITE_TYPE).length;l.sanitizeLibraryName=function(e){if((e=e.trim().replace(p.reservedCharRegex,"_")).length>d){var t=e.charCodeAt(d-1),n=t>=55296&&t<=57343;e=e.slice(0,n?d-1:d);}return p.reservedNameRegex.test(e)&&(e+=" "),e;},l.collaborationStateToDCX=function(e){return"incoming"===e?i.COLLABORATION.SHARED_WITH_USER:"outgoing"===e?i.COLLABORATION.SHARED_BY_USER:i.COLLABORATION.PRIVATE;},l.collaborationStateFromDCX=function(e){return e===i.COLLABORATION.SHARED_WITH_USER?"incoming":e===i.COLLABORATION.SHARED_BY_USER?"outgoing":void 0;},l.getCompositeRenditionMap=function(e){var t=e.getComponentsOf(),n={};return t&&t.forEach(function(e){if("rendition"===e.relationship){var t=e.getValue(a.RENDITION_TYPE_KEY);t&&(n[t]=e);}}),n;},l.recoverFromElmo=function(e,t,n){var i=e._services.fs,o=e._services.getPathSeparator(),r={},a=t.every(function(t){r[t]=!0;var n=e._getCompositeDir(t)+o+"manifest";try{var a=JSON.parse(i.readFileSync(n,"utf8")).children.find(function(e){return"elements"===e.name;});if(!a.children||0===a.children.length)return!0;}catch(e){}}),s=e._syncManager,c=function(t){if(t)return s.links.test(e._getNewCompositeHref(t),n),void e._services.log("Failed to recover from ELMO: "+t);e._services.log("Successfully recovered from ELMO"),n();};if(!a)return c("has_data");var l=function(){e._services.fileUtils.recursiveDeleteDirectory(e._getBaseDir(),function(e){c(e&&"local_delete");});};s.getServerComposites(e,function(t,n){if(t)return c("sg_fetch");n.every(function(e){return r[e.name];})&&n.length>=e._config.ELMO_LOCAL_LIBRARY_LIMIT?s.deleteAllServerComposites(e,function(e){if(e)return c("sg_delete");l();}):n.length<e._config.ELMO_SERVER_RECOVERED_LIMIT?l():c("out_of_sync");});},Object.seal(l),e.exports=l;},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var o=n(2),r=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._restrictedTypes=t,this._logCallback=n,this._listeners={};}var t,n,r;return t=e,(n=[{key:"_log",value:function(e){this._logCallback&&this._logCallback(e);}},{key:"_checkType",value:function(e){if(this._restrictedTypes&&!this._restrictedTypes.includes(e)){var t="".concat(e," is not allowed. Should be one of: [").concat(this._restrictedTypes.join(", "),"]");throw new o(o.INVALID_PARAMETER,t);}}},{key:"add",value:function(e,t){this._checkType(e),this._listeners[e]=this._listeners[e]||[],this._listeners[e].push(t);}},{key:"remove",value:function(e,t){this._checkType(e);var n=this._listeners[e],i=n?n.indexOf(t):-1;-1!==i&&n.splice(i,1);}},{key:"removeAll",value:function(e){e?(this._checkType(e),delete this._listeners[e]):this._listeners={};}},{key:"notify",value:function(e,t){var n=this;this._checkType(e);var i=this._listeners[e];i&&i.slice().forEach(function(e){try{e.apply(void 0,t||[]);}catch(e){n._log("Error in listener callback: "+(e?e.toString():"")),e&&e.stack&&n._log(e.stack);}});}},{key:"hasListeners",value:function(e){return this._checkType(e),(this._listeners[e]||[]).length>0;}},{key:"forEach",value:function(e){var t=this._listeners;Object.keys(t).forEach(function(n){t[n].forEach(function(t){return e(n,t);});});}}])&&i(t.prototype,n),r&&i(t,r),e;}();e.exports=r;},function(e,t){e.exports={PRIMARY:"http://ns.adobe.com/adobecloud/rel/primary",ID:"http://ns.adobe.com/adobecloud/rel/id",PATH:"http://ns.adobe.com/adobecloud/rel/path",RENDITION:"http://ns.adobe.com/adobecloud/rel/rendition",MANIFEST:"http://ns.adobe.com/adobecloud/rel/manifest",COMPONENT:"http://ns.adobe.com/adobecloud/rel/component",PAGE:"http://ns.adobe.com/adobecloud/rel/page",DISCARD:"http://ns.adobe.com/adobecloud/rel/discard",DIRECTORY:"http://ns.adobe.com/adobecloud/rel/directory",AC_EFFECTIVE:"http://ns.adobe.com/adobecloud/rel/ac/effective",AC_POLICY:"http://ns.adobe.com/adobecloud/rel/ac/policy",CREATE:"http://ns.adobe.com/adobecloud/rel/create",METADATA:"http://ns.adobe.com/adobecloud/rel/metadata/repository",REPOSITORY:"http://ns.adobe.com/adobecloud/rel/repository",RESOLVE_ID:"http://ns.adobe.com/adobecloud/rel/resolve/id",RESOLVE_PATH:"http://ns.adobe.com/adobecloud/rel/resolve/path",OPS:"http://ns.adobe.com/adobecloud/rel/ops",BLOCK_INITIALIZE:"http://ns.adobe.com/adobecloud/rel/block/init",BLOCK_TRANSFER:"http://ns.adobe.com/adobecloud/rel/block/transfer",BLOCK_FINALIZE:"http://ns.adobe.com/adobecloud/rel/block/finalize",APP_METADATA:"http://ns.adobe.com/adobecloud/rel/metadata/application",EMBEDDED_METADATA:"http://ns.adobe.com/adobecloud/rel/metadata/embedded",ANNOTATIONS:"http://ns.adobe.com/adobecloud/rel/annotations",DOWNLOAD:"http://ns.adobe.com/adobecloud/rel/download",QUOTA_EXCEEDED:"http://ns.adobe.com/adobecloud/problem/quotaexceeded",DESCRIBED_BY:"describedBy"};},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._isLocked=!1,this._queue=[];}var t,i,o;return t=e,(i=[{key:"execute",value:function(e){var t=this,n=function(e){return t.release(),e;};return this.obtain().then(e).then(function(e){return n(e);},function(e){return n(Promise.reject(e));});}},{key:"_obtain",value:function(e){this._isLocked?this._queue.push(e):(this._isLocked=!0,e(null));}},{key:"obtain",value:function(e){var t=this;return e?this._obtain(e):new Promise(function(e,n){return t._obtain(function(t){return t?n(t):e();});});}},{key:"release",value:function(){if(this._queue.length>0){var e=this._queue.shift();setTimeout(function(){return e(null);});}else this._isLocked=!1;}},{key:"abortPendingOperations",value:function(e){var t=this._queue;this._queue=[],t.forEach(function(t){return t(e);});}},{key:"isLocked",value:function(){return this._isLocked;}},{key:"hasPendingRequest",value:function(){return this._queue.length>0;}}])&&n(t.prototype,i),o&&n(t,o),e;}();e.exports=i;},function(e,t){var n={},i={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomsvc+xml":["atomsvc"],"application/ccxml+xml":["ccxml"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/font-tdpfr":["pfr"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/hyperstudio":["stk"],"application/illustrator":["ai"],"application/illustrator-text":["ai"],"application/illustrator.template":["ait"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/java-archive":["jar"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js"],"application/json":["json"],"application/jsonml+json":["jsonml"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/photoshop":["psd"],"application/photoshop.large":["psb"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/prs.cww":["cww"],"application/pskc+xml":["pskcxml"],"application/rdf+xml":["rdf"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.ae.graphic+zip":["aegraphic","mogrt"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.animate-xfl+zip":["fla","xfl"],"application/vnd.adobe.animate-oam+zip":["oam"],"application/vnd.adobe.animate-sym+zip":["sym"],"application/vnd.adobe.animate-swf+zip":["swa"],"application/vnd.adobe.characterstyle+json":["style"],"application/vnd.adobe.characterstyle+snippet":["idms"],"application/vnd.adobe.charts+zip":["zip"],"application/vnd.adobe.ch.puppet+zip":["puppet"],"application/vnd.adobe.color+json":["ase"],"application/vnd.adobe.colortheme+json":["ase"],"application/vnd.adobe.cube+txt":["cube"],"application/vnd.adobe.element.agc+json":["agc"],"application/vnd.adobe.exr.light+zip":["exr"],"application/vnd.adobe.fbx.3d+zip":["fbx"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.ibl.light+zip":["ibl","zip"],"application/vnd.adobe.illustrator.template":["ait"],"application/vnd.adobe.indesign-idms":["idms"],"application/vnd.adobe.indesign-idms-text":["idms"],"application/vnd.adobe.indesign.template":["indt"],"application/vnd.adobe.layerstyle":["asl"],"application/vnd.adobe.look+xml":["look"],"application/vnd.adobe.graphic+json":["json"],"application/vnd.adobe.mdl.material+zip":["mdl","zip"],"application/vnd.adobe.muse-collection":["muse"],"application/vnd.adobe.obj.3d+zip":["obj","zip"],"application/vnd.adobe.paragraphstyle+json":["style"],"application/vnd.adobe.paragraphstyle+snippet":["idms"],"application/vnd.adobe.photoshop.template":["psdt"],"application/vnd.adobe.ppro.graphic+zip":["prgraphic","mogrt"],"application/vnd.adobe.ribbon.brush+zip":["brush"],"application/vnd.adobe.sbsar+zip":["sbsar"],"application/vnd.adobe.scatter.brush+zip":["brush"],"application/vnd.adobe.vector.brush+zip":["brush"],"application/vnd.adobe.text+json":["text-json"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["xfdf"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],"application/vnd.crick.clicker.template":["clkt"],"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/voicexml+xml":["vxml"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["dmg"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-otf":["otf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-ttf":["ttf","ttc"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/font-woff":["woff"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["iso"],"application/x-java-jnlp-file":["jnlp"],"application/x-latex":["latex"],"application/x-lzh-compressed":["lzh","lha"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdownload":["exe","dll","com","bat","msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["wmf","wmz","emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-nzb":["nzb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["rar"],"application/x-research-info-systems":["ris"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["obj"],"application/x-ustar":["ustar"],"application/x-wais-source":["src"],"application/x-x509-ca-cert":["der","crt"],"application/x-xfig":["fig"],"application/x-xliff+xml":["xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"application/xaml+xml":["xaml"],"application/xcap-diff+xml":["xdf"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xml":["xml","xsl"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/adpcm":["adp"],"audio/aif":["aif"],"audio/basic":["au","snd"],"audio/m4a":["m4a"],"audio/midi":["mid","midi","kar","rmi"],"audio/mp4":["mp4a"],"audio/mpeg":["mpga","mp2","mp2a","m2a"],"audio/mpeg3":["mp3","m3a"],"audio/ogg":["oga","ogg","spx"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/wav":["wav"],"audio/webm":["weba"],"audio/x-aac":["aac"],"audio/x-aiff":["aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-wav":["wav"],"audio/xm":["xm"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/dng":["dng"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heif":["heif"],"image/ief":["ief"],"image/jpeg":["jpeg","jpg","jpe"],"image/jpg":["jpg"],"image/ktx":["ktx"],"image/png":["png"],"image/prs.btif":["btif"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/tiff":["tiff","tif"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.adobe.photoshop.template":["psdt"],"image/vnd.adobe.pattern+png":["png"],"image/vnd.adobe.shape+svg":["shape"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.dvb.subtitle":["sub"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/webp":["webp"],"image/x-3ds":["3ds"],"image/x-adobe-dng":["dng"],"image/x-adobe-photoshop-brush":["abr"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["ico"],"image/x-mrsid-image":["sid"],"image/x-pcx":["pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/rfc822":["eml","mime"],"model/gltf-binary":["glb"],"model/gltf+json":["gltf"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/vnd.usdz+zip":["usdz"],"model/vnd.adobe.dn+dcx":["dn"],"model/vnd.adobe.dn+dcxucf":["dn"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.vtu":["vtu"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["x3db","x3dbz"],"model/x3d+vrml":["x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"text/cache-manifest":["appcache"],"text/calendar":["ics","ifb"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in"],"text/prs.lines.tag":["dsc"],"text/richtext":["rtx"],"text/sgml":["sgml","sgm"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-fortran":["f","for","f77","f90"],"text/x-java-source":["java"],"text/x-opml":["opml"],"text/x-pascal":["p","pas"],"text/x-nfo":["nfo"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"video/3gpp":["3gp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/jpeg":["jpgv"],"video/jpm":["jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["mov","qt"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/webm":["webm"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx","wmv"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-quicktime":["mov"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"],"3d/vnd.adobe.dn+dcxucf":["dn"]},o={};Object.keys(i).forEach(function(e){i[e].forEach(function(t){o[t]=o[t]||[],o[t].push(e);});}),n.getExtensions=function(e){return e?i[e.toLowerCase()]||(t=e.toLowerCase(),(n=t.match(/application\/x-adobe-libraries-(.+)/))?[n[1]]:[]):[];var t,n;},n.getMimeTypes=function(e){return e?o[e.toLowerCase()]||function(e){return["application/x-adobe-libraries-"+e];}(e.toLowerCase()):[];},Object.seal(n),e.exports=n;},function(e,t,n){var i=n(12),o=n(58),r=n(63),a=n(66),s=n(27),c=n(30),l=n(1),u=n(0),_=n(5),h=n(31),p=n(14),d=n(24);function f(e,t){e&&_._setFS(e),this._compositeOptions=l.merge({},t),t&&t.logCallback&&l._setLogCallback(t.logCallback);}f.COLLABORATION={PRIVATE:i.COLLABORATION.PRIVATE,SHARED_BY_USER:i.COLLABORATION.SHARED_BY_USER,SHARED_WITH_USER:i.COLLABORATION.SHARED_WITH_USER},f.AdobeDCXError=u,f.FileContent=p,f.StreamProvider=d,f.prototype.newEmptyComposite=function(e,t,n,o){var r=new i(e,t,null,o,null,this._compositeOptions);return n&&(r.path=n),r;},f.prototype.newCompositeFromLocalStorage=function(e,t){try{if("string"!=typeof e)throw new u(u.INVALID_PARAMS,"");var n=new i(null,null,e,null,null,this._compositeOptions);n.loadCurrentFromLocalStorage(function(e){t(e,e?void 0:n);}),n.deleteTempFiles();}catch(e){t(e);}},f.prototype.newCompositeWithHref=function(e,t,n,o,r){var a=new i(n,r,null,o,e,this._compositeOptions);return t&&(a.path=t),a;},f.prototype.newCompositeWithAssetId=function(e,t,n,o,r,a,s){var l=new i(n,r,null,o,null,this._compositeOptions);return l.assetId=e,t&&(l.path=t),c.updateCompositeMetadata(l,a,function(e){return e?s(e):s(null,l);});},f.prototype.newCompositeAsCopyOf=function(e,t,n,o,r,a){return i.newCompositeAsCopyOf(e,t,n,o,r,a,this._compositeOptions);},f.prototype.copyCompositeAndAssetsFrom=function(e,t,n,o,r,a,s){i.copyCompositeAndAssetsFrom(e,t,n,o,r,a,this._compositeOptions,s);},f.prototype.createHTTPService=function(e){return new o(e);},f.prototype.createStorageSession=function(e,t,n,i){return new r(e,t,n,i);},f.prototype.createCommunitySession=function(e,t,n){return new a(e,t,n);},f.prototype.createPlatformSession=function(e,t,n,i){return new s(e,t,n,i);},f.prototype.compositeXfer=c,f.prototype.snapshot=h,e.exports=f;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}var o=n(0),r=n(13),a=n(23),s=n(56),c=n(15).STATES,l=n(5),u=n(1),_={PRIVATE:void 0,SHARED_BY_USER:"sharedByUser",SHARED_WITH_USER:"sharedWithUser"};function h(e,t,n,i,o,a){o=u.ensureRelativeHrefStartsWithSlash(o),this._options=a||{},n?this._setPath(n):o?(this._href=o,this._options.links&&(this._links=this._options.links),this._options.assetId&&(this._assetId=this._options.assetId),e&&(this._name=e),t&&(this._type=t),i&&(this._id=i)):t&&(this._current=new r(),e&&(this._current._data.name=e),this._current._data.type=t,i&&(this._current.compositeId=i)),this._autoRemoveUnusedLocalFiles=!0,this._options.xhrBaseBranchSupport&&(this._baseBranchData=void 0,this._pushedBranchData=void 0,this._pulledBranchData=void 0),this._collaborationType=_.PRIVATE;}function p(e,t,n){return{get:function(){return this._current?this._current[t]:this[e];},set:function(r){if(!n.includes(i(r)))throw new o(o.INVALID_PARAMS,"Expected types: ".concat(n.join(", ")));this._current&&(this._current[t]=r),this[e]=r;}};}h.newCompositeAsCopyOf=function(e,t,n,i,a,s,c){var l=e._core;if(l||e.current&&(l=e.current._core),!l)throw new o(o.INVALID_PARAMS,"compositeBranchOrElement must be a branch, an element or a composite with a current branch.");var _=new h(void 0,void 0,void 0,void 0,void 0,c);return i&&(_.path=i),_._current=r._newBranchAsCopyOfCore(l,this._localStorage),_.id=a||u.generateUuid(),t&&(_.name=t),n&&(_.type=n),s&&(_.href=s),c&&c.links&&(_.links=c.links),c&&c.assetId&&(_.assetId=c.assetId),_;},h.copyCompositeAndAssetsFrom=function(e,t,n,i,a,c,l,p){var d=e._core;if(d||e.current&&(d=e.current._core),!d)throw new o(o.INVALID_PARAMS,"compositeBranchOrElement must be a branch, an element or a composite with a current branch.");var f=new h(void 0,void 0,void 0,void 0,void 0,l);i&&(f.path=i),r._newBranchAsCopyOfCoreWithAssets(d,f.path&&new s(f.path,l.preserveFileExtensions),function(e,i){if(e)return p(e);f._current=i,f.collaborationType=_.PRIVATE,a!==f.id&&(f.id=a||u.generateUuid()),t&&(f.name=t),n&&(f.type=n),c&&(f.href=c),p(null,f);});},h.COLLABORATION=_,Object.defineProperties(h.prototype,{id:p("_id","compositeId",["string"]),name:p("_name","name",["string"]),type:p("_type","type",["string"]),href:{get:function(){return this._current?this._current.compositeHref:this._href;},set:function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string.");e=u.ensureRelativeHrefStartsWithSlash(e),this._current&&(this._current.compositeHref=e),this._href=e;}},links:p("_links","compositeLinks",["object"]),assetId:p("_assetId","compositeAssetId",["string"]),repoMetadata:p("_repoMetadata","compositeRepoMetadata",["object"]),isWritable:p("_isWritable","compositeIsWritable",["boolean"]),parentAssetId:p("_parentAssetId","compositeParentAssetId",["string"]),isParentWritable:p("_isParentWritable","compositeIsParentWritable",["boolean"]),isRenamePending:p("_isRenamePending","compositeIsRenamePending",["boolean"]),storageAssignee:p("_storageAssignee","compositeStorageAssignee",["object"]),collaborationType:{get:function(){return this._current?this._current._collaborationType:this._collaborationType;},set:function(e){if(e!==_.PRIVATE&&e!==_.SHARED_BY_USER&&e!==_.SHARED_WITH_USER)throw new o(o.INVALID_PARAMS,"Invalid value: ."+e);this._current&&(this._current._collaborationType=e),this._collaborationType=e;}},clientDataString:{get:function(){return this._current?this._current._clientDataString:this._clientDataString;},set:function(e){if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Invalid clientDataString: must be a string or undefined.");var t=this._options.maxClientDataLength||1024;if(e&&e.length>t)throw new o(o.INVALID_PARAMS,"Invalid clientDataString: cannot be greater than 1KB");this._current&&(this._current._clientDataString=e),this._clientDataString=e;}},path:{get:function(){return this._path;},set:function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string.");this._setPath(e);}},isBound:{get:function(){return this._current&&this._current.isBound||!this._current&&this._href;},set:function(){throw new o(o.READ_ONLY,"Cannot set the property isBound. Use resetIdentity or resetBinding instead.");}},hasLocalStorage:{get:function(){return this._localStorage;},set:function(){throw new o(o.READ_ONLY,"Cannot set the property hasLocalStorage.");}},autoRemoveUnusedLocalFiles:{get:function(){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");return this._autoRemoveUnusedLocalFiles;},set:function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._autoRemoveUnusedLocalFiles=e;}},clientDataStoragePath:{get:function(){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");return this._localStorage.clientDataPath();},set:function(){throw new o(o.READ_ONLY,'Property "clientDataStoragePath" is read-only.');}},current:{get:function(){return this._current;},set:function(){throw new o(o.READ_ONLY,'Property "current" is read-only.');}},isDiscarded:{get:function(){return this.repoMetadata&&"DISCARDED"===this.repoMetadata["repo:state"];}}}),h.prototype.loadCurrentFromLocalStorage=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");var t=this;this._loadBranch(this._localStorage.currentManifestPath(),!1,function(n,i){if(!n&&i)try{t._current=i,t._currentBranchCommittedAtDate=u.timeStamp(!0);}catch(e){n=e;}e(n,n?void 0:i);});},h.prototype.commitChanges=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");if(!this._current)return e(new o(o.INVALID_STATE,"Current branch is not in memory."));var t=this;l.writeFileAtomically(this._localStorage.currentManifestPath(),this._current.localData,"utf8",function(n){if(!n)try{t._currentBranchCommittedAtDate=u.timeStamp(!0),t._current._isDirty=!1;}catch(e){n=e;}e(n);});},h.prototype.tempAssetPath=function(){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");return this._localStorage.tempPathForComponent();},h.prototype.deleteTempFiles=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._localStorage.deleteTempFiles(function(t){e&&e(t);});},h.prototype.removeUnusedLocalFiles=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._localStorage.removeUnusedLocalFiles(this._currentBranchCommittedAtDate,e);},h.prototype.removeLocalFilesForComponentsWithIDs=function(e,t){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");if(!e)throw new o(o.INVALID_PARAMS,"Param componentIds must not be nil.");var n=this,i=this._current;n._loadBranch(n._localStorage.currentManifestPath(),!0,function(r,a){r&&"ENOENT"!==r.code?t([r]):n.loadBaseBranch(function(r,s){if(r&&"ENOENT"!==r.code)t([r]);else{var u,_,h=[],p={};for(u=0;u<e.length;++u){var d=e[u],f=i.getComponentWithId(d),m=a?a.getComponentWithId(d):void 0,v=s?s.getComponentWithId(d):void 0;if(!(f&&"/META-INF/metadata.xml"===f.absolutePath||m&&"/META-INF/metadata.xml"===m.absolutePath||v&&"/META-INF/metadata.xml"===v.absolutePath))if(f&&f.state===c.modified||m&&m.state===c.modified){var y=new o(o.COMPONENT_MODIFIED_ERROR,"Cannot remove the file of a modified component.");y.componentId=d,h.push(y);}else f&&(_=i.assetOfComponent(f))&&(void 0===p[_]&&(p[_]=d),n._localStorage.removeComponentAsset(f,i._local()),i._setDirty(!0)),m&&(_=a.assetOfComponent(m))&&void 0===p[_]&&(p[_]=d),v&&(_=s.assetOfComponent(v))&&void 0===p[_]&&(p[_]=d);}var g=Object.keys(p),E=g.length;if(E>0){var O=function(e){l.deleteFile(e,function(n){n&&(n.componentId=p[e],h.push(n)),0===--E&&t(h.length>0?h:void 0);});};for(u=0;u<g.length;++u)O(g[u]);}else t(h.length>0?h:void 0);}});});},h.prototype.removeLocalStorage=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");if(!this._path)return e(new o(o.INVALID_STATE,"No path set."));l.deleteDirectory(this._path,e);},h.prototype.loadBaseBranch=function(e){if(!this._localStorage&&!this._baseBranchData)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");if(this._localStorage)this._loadBranch(this._localStorage.currentBaseManifestPath(),!0,e);else{var t,n;try{n=new r(void 0,!0).parse(this._baseBranchData);}catch(e){t=e;}e(t,n);}},h.prototype.loadPulledBranch=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._loadBranch(this._localStorage.pulledManifestPath(),!1,e);},h.prototype.loadPushedBranch=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._loadBranch(this._localStorage.pushedManifestPath(),!1,e);},h.prototype.resolvePullWithBranch=function(e,t){if(!e)throw new o(o.INVALID_PARAMS,"Need a branch.");if(e===this._current)throw new o(o.INVALID_PARAMS,"Cannot resolve current.");if(this._localStorage&&!t)throw new o(o.INVALID_PARAMS,"Need a callback function.");var n=this,i=function(){e.readOnly=!1,e._collaborationType=n.collaborationType,e._clientDataString=n.clientDataString,n._current=e;};if(this._localStorage)n._localStorage.resolvePulledBranch(e,function(e){if(!e)try{i(),n._autoRemoveUnusedLocalFiles&&n._localStorage.removeUnusedLocalFiles(n._currentBranchCommittedAtDate,function(){});}catch(t){e=t;}t(e,e?void 0:n._current);});else{if(this._options.xhrBaseBranchSupport&&(this._baseBranchData=this._pulledBranchData,this._pulledBranchData=void 0),i(),!t)return this._current;t(void 0,this._current);}},h.prototype.acceptPush=function(e){if(this._localStorage&&!e)throw new o(o.INVALID_PARAMS,"Need a callback function.");var t,n,i=this,r=function(o){if(!o)if(t)try{i._localStorage?(t.applyToBranch(n),i._localStorage.acceptPushedBranch(n,function(n){if(!n)try{t.applyToBranch(i._current,!0),i._autoRemoveUnusedLocalFiles&&i._localStorage.removeUnusedLocalFiles(i._currentBranchCommittedAtDate,function(){});}catch(e){n=e;}e(n);})):(t.applyToBranch(i._current,!0),i._options.xhrBaseBranchSupport&&(i._baseBranchData=i._pushedBranchData,i._pushedBranchData=void 0),i._pushJournal=void 0,e&&e());}catch(e){o=e;}else e&&e();if(o){if(!e)throw o;e(o);}};if(!this._localStorage)return t=this._pushJournal,r();var s,c=2;a.readJournal(i._localStorage.pushJournalPath(),i,!1,function(e,n){c--,s?r():(e?"ENOENT"!==e.code&&(s=new o(o.INVALID_STATE,"Failed to load push journal.",e)):t=n,c||r());}),this._loadBranch(this._localStorage.currentManifestPath(),!1,function(e,t){c--,s?r():(e?s=new o(o.INVALID_STATE,"Failed to load current manifest.",e):n=t,c||r());});},h.prototype.discardPulledBranch=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");var t=this;this._localStorage.discardPulledBranch(function(n){if(!n){try{t._autoRemoveUnusedLocalFiles&&t._localStorage.removeUnusedLocalFiles(t._currentBranchCommittedAtDate,function(){});}catch(e){n=e;}e(n);}n&&e(n);});},h.prototype.discardPushedBranch=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");var t=this;this._localStorage.discardPushedBranch(function(n){if(!n){try{t._autoRemoveUnusedLocalFiles&&t._localStorage.removeUnusedLocalFiles(t._currentBranchCommittedAtDate,function(){});}catch(e){n=e;}e(n);}n&&e(n);});},h.prototype.resetBinding=function(e){delete this._href,this._current&&this._current._resetBinding(),this._localStorage?this._discardEveryBranchButCurrent(e):(this._baseBranchData=void 0,this._pushedBranchData=void 0,this._pulledBranchData=void 0,e&&e());},h.prototype.resetIdentity=function(e){delete this._href,this._current?(this._current._resetIdentity(),this._id=this._current.compositeId):this._id=u.generateUuid(),this._localStorage?this._discardEveryBranchButCurrent(e):(this._baseBranchData=void 0,this._pushedBranchData=void 0,this._pulledBranchData=void 0,e&&e());},h.prototype.setLocalData=function(e,t){if(!this._current)throw new o(o.INVALID_STATE,"No current branch set.");this._current.setLocalData(e,t);},h.prototype.getLocalData=function(e){if(!this._current)throw new o(o.INVALID_STATE,"No current branch set.");return this._current.getLocalData(e);},h.prototype._loadBranch=function(e,t,n){if("function"!=typeof n)throw new o(o.INVALID_PARAMS,'Param "callback" must be a function.');var i=this;l.exists(e,function(o){o?l.readFile(e,"utf8",function(o,a){var s;if(!o)try{(s=new r(void 0,t,e).parse(a))._localStorage=i._localStorage;}catch(e){o=e;}n(o,s);}):n();});},h.prototype._discardEveryBranchButCurrent=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");var t,n=this,i=3,r=function(o){o&&!t&&(t=o),0===--i&&(!t&&n._autoRemoveUnusedLocalFiles&&n._localStorage.removeUnusedLocalFiles(n._currentBranchCommittedAtDate,function(){}),e(t));};this._localStorage.discardPushedBranch(r),this._localStorage.discardPulledBranch(r),this._localStorage.discardBaseBranch(r);},h.prototype._setPath=function(e){this._localStorage?this._localStorage.compositePath=e:l.canUseFileSystem&&(this._localStorage=new s(e,this._options.preserveFileExtensions),this._current&&(this._current._localStorage=this._localStorage)),this._path=e;},e.exports=h;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n;}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e);}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance");}();}var r=n(20),a=n(55),s=n(0),c=n(1);function l(e,t,n){e?e=this._setData(e,t):(e={"manifest-format-version":6,id:c.generateUuid()},this.originalManifestFormatVersion=6,this._core=new r(e,this,t),this._data=e);this._pendingElements=[],this.manifestPath=n;}function u(e,t){return{get:function(){return this._data.local?this._data.local[e]:void 0;},set:function(n){var o=this._core;if(o._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");if(!t.includes(i(n)))throw new s(s.INVALID_PARAMS,"Expected types: ".concat(t.join(", ")));o._local()[e]=n,o._setDirty(!0,!0);}};}function _(e){var t=e["manifest-format-version"];if(t<6){if(t<4)throw new s(s.INVALID_DATA,"Encountered manifest format version "+e["manifest-format-version"]+". Format version conversion not yet implemented for that version.");t<5&&function e(t){var n,i,o=t.components;if(o)for(i=o.length,n=0;n<i;n++){delete o[n].localStorageAssetId;}var r=t.children;if(r)for(i=r.length,n=0;n<i;n++)e(r[n]);}(e),t<6&&function e(t,n){n&&t.path&&delete t.path;var o,r=t.components;if("object"===i(r))for(o=0;o<r.length;o++){var a=r[o];"number"==typeof a.version&&(a.version=a.version.toString());}var s=t.children;if("object"===i(s))for(o=0;o<s.length;o++){e(s[o]);}}(e,!0);}}l._newBranchAsCopyOfCore=function(e,t){var n=new l(JSON.parse(JSON.stringify(e._data))),i=n._core;return n._localStorage=t,n._resetIdentity(function(n){var o=e.getComponentWithId(n.id);if(!o)throw new s(s.INVALID_STATE,"Could not find original component.");if("modified"===o.state||!o.etag)throw new s(s.INVALID_STATE,"Cannot create a new composite from a branch that contains modified or unbound components.");var r=e._getHrefOfComponent(o);if(!r)throw new s(s.INVALID_STATE,"Cannot determine the href of component id "+o.id);i._setSourceHrefOfComponent(r,n),t&&t.removeComponentAsset(n,i._local());}),n;},l._newBranchAsCopyOfCoreWithAssets=function(e,t,n){var i=JSON.parse(JSON.stringify(e._data));i.children=[],i.components=[];var r=new l(i);r._localStorage=t,r._resetBinding();var a=e.getChildrenOf().map(function(e){return new Promise(function(t,n){r.copyChild(e,r.rootNode,void 0,void 0,void 0,function(e){return e?n(e):t();});});}),s=e.getComponentsOf().map(function(e){return new Promise(function(t,n){r.copyComponent(e,r.rootNode,void 0,void 0,function(e){return e?n(e):t();});});});Promise.all([].concat(o(a),o(s))).then(function(){r._reset(!0),n(null,r);},n);},Object.defineProperties(l.prototype,{compositeId:{get:function(){return this._core.rootNode.id;},set:function(e){var t=this._core;if(t._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");if("string"!=typeof e||""===e)throw new s(s.INVALID_PARAMS,"Expecting a non-empty string.");if(t._allNodes[e])throw new s(s.DUPLICATE_VALUE,"There is already a node with the same id.");delete t._allNodes[this._data.id],this._data.id=e,t._allNodes[e]=this._core.rootNode,t._setDirty();}},rootNode:{get:function(){return this._core.rootNode;},set:function(e){this._core.rootNode=e;}},name:{get:function(){return this._core.rootNode.name;},set:function(e){var t=this._core;if(t._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new s(s.INVALID_PARAMS,"Expecting a string or undefined.");t.rootNode.name=e;}},type:{get:function(){return this._core.rootNode.type;},set:function(e){var t=this._core;if(t._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");if("string"!=typeof e||""===e)throw new s(s.INVALID_PARAMS,"Expecting a non-empty string.");t.rootNode.type=e;}},compositeHref:{get:function(){return this._data.local?this._data.local.compositeHref:void 0;},set:function(e){var t=this._core;if(t._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new s(s.INVALID_PARAMS,"Expecting a string or undefined.");t._local().compositeHref=c.ensureRelativeHrefStartsWithSlash(e),t._setDirty(!0,!0);}},compositeLinks:{get:function(){return this._data.local?this._data.local.links:void 0;},set:function(e){var t=this._core;if(t._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");if(!c.validateLinks(e))throw new s(s.INVALID_PARAMS,"Expecting an object or undefined.");t._local().links=e,t._setDirty(!0,!0);}},compositeAssetId:u("assetId",["string","undefined"]),compositeRepoMetadata:u("repoMetadata",["object","undefined"]),compositeIsWritable:u("isWritable",["boolean","undefined"]),compositeParentAssetId:u("parentAssetId",["string","undefined"]),compositeIsParentWritable:u("isParentWritable",["boolean","undefined"]),compositeIsRenamePending:u("isRenamePending",["boolean","undefined"]),compositeStorageAssignee:u("storageAssignee",["object","undefined"]),_collaborationType:{get:function(){return this._data.local?this._data.local.collaborationType:void 0;},set:function(e){var t=this._core;if(t._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");e?t._local().collaborationType=e:delete t._local().collaborationType,t._setDirty(!0);}},_clientDataString:{get:function(){return this._data.local?this._data.local.clientDataString:void 0;},set:function(e){var t=this._core;if(t._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");e?t._local().clientDataString=e:delete t._local().clientDataString,t._setDirty(!0);}},manifestEtag:{get:function(){return this._data.local?this._data.local.manifestEtag:void 0;},set:function(e){var t=this._core;if(t._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new s(s.INVALID_PARAMS,"Expecting a string or undefined.");t._local().manifestEtag=e,t._setDirty(!0);}},compositeState:{get:function(){return this._data.state||"unmodified";},set:function(e){var t=this._core;if(t._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new s(s.INVALID_PARAMS,"Expecting a string.");if("unmodified"!==e&&"modified"!==e&&"pendingDelete"!==e&&"committedDelete"!==e&&"pendingDiscard"!==e)throw new s(s.INVALID_PARAMS,'State must be "modified", "unmodified", "pendingDiscard", "pendingDelete", or "committedDelete".');this._data.state=e,t._setDirty(!0);}},isBound:{get:function(){return this.manifestEtag&&this.compositeHref;},set:function(){throw new s(s.READ_ONLY,"Cannot set the property isBound. Use resetIdentity instead.");}},_localStorage:{get:function(){return this._core._localStorage;},set:function(e){this._core._localStorage=e;}},hasLocalStorage:{get:function(){return this._core.hasLocalStorage;},set:function(e){this._core.hasLocalStorage=e;}},_isDirty:{get:function(){return this._core._isDirty;},set:function(e){this._core._isDirty=e;}},isDirty:{get:function(){return this._core.isDirty;},set:function(e){this._core.isDirty=e;}},localData:{get:function(){return this._core._stringify(!1);},set:function(){throw new s(s.READ_ONLY,"Cannot set the property localData.");}},prettifiedLocalData:{get:function(){return this._core._stringify(!1,!0);},set:function(){throw new s(s.READ_ONLY,"Cannot set the property localData.");}},remoteData:{get:function(){return this._core._stringify(!0);},set:function(){throw new s(s.READ_ONLY,"Cannot set the property remoteData.");}},pendingElements:{get:function(){return this._pendingElements;},set:function(){throw new s(s.READ_ONLY,"Cannot set the property pendingElements.");}},changeCount:{get:function(){return this._core.changeCount;},set:function(e){this._core.changeCount=e;}},readOnly:{get:function(){return this._core._readOnly;},set:function(e){this._core._readOnly=e;}}}),l.prototype.parse=function(e){if("string"!=typeof e)throw new s(s.INVALID_PARAMS,'Param "data" must be a string');var t=null;try{t=JSON.parse(e);}catch(e){throw new s(s.INVALID_JSON,"Manifest could not be parsed. Underlying error: "+e.message);}return this._setData(t,this._core._readOnly);},l.prototype.getElementWithId=function(e){return this._createElement(this._core.getChildWithId(e));},l.prototype.getElementWithAbsolutePath=function(e){return this._createElement(this._core.getChildWithAbsolutePath(e));},l.prototype.addElement=function(e,t,n,i,o,r){if("string"!=typeof e)throw new s(s.INVALID_PARAMS,"Element must have a name of type string");if("string"!=typeof t)throw new s(s.INVALID_PARAMS,"Element must have a type of type string");if("string"!=typeof n)throw new s(s.INVALID_PARAMS,"Element must have a path of type string");var a=this._core.addChild(e,i,o,r);try{a.path=n;}catch(e){throw this._core.removeChild(a),e;}return a._data.type=t,this._createElement(a);},l.prototype.updateElement=function(e){var t=this.getChildWithId(e.rootNode.id);if(!t)throw new s(s.INVALID_PARAMS,"Element does not exist in branch.");var n=this._core.replaceChild(e.rootNode,t.path);return this._deleteElement(e),n;},l.prototype.abandonElement=function(e){this._deleteElement(e);},l.prototype.getChildWithId=function(e){return this._core.getChildWithId(e);},l.prototype.getChildWithAbsolutePath=function(e){return this._core.getChildWithAbsolutePath(e);},l.prototype.getChildrenOf=function(e){return this._core.getChildrenOf(e);},l.prototype.addChild=function(e,t,n,i){return this._core.addChild(e,t,n,i);},l.prototype.removeChild=function(e){return this._core.removeChild(e);},l.prototype.moveChild=function(e,t,n){return this._core.moveChild(e,t,n);},l.prototype.copyChild=function(e,t,n,i,o,r){return this._core.copyChild(e,t,n,i,o,r);},l.prototype.replaceChild=function(e,t,n,i){return this._core.replaceChild(e,t,n,i);},l.prototype.allComponents=function(){return this._core.allComponents();},l.prototype.getComponentWithId=function(e){return this._core.getComponentWithId(e);},l.prototype.getComponentWithAbsolutePath=function(e){return this._core.getComponentWithAbsolutePath(e);},l.prototype.getComponentsOf=function(e){return this._core.getComponentsOf(e);},l.prototype.addComponent=function(e,t,n,i,o,r,a,s,c,l){return this._core.addComponent(e,t,n,i,o,r,a,s,c,l);},l.prototype.addComponentWithUploadResults=function(e,t,n,i,o){return this._core.addComponentWithUploadResults(e,t,n,i,o);},l.prototype.updateComponent=function(e,t,n,i){return this._core.updateComponent(e,t,n,i);},l.prototype.updateComponentWithUploadResults=function(e,t){return this._core.updateComponentWithUploadResults(e,t);},l.prototype.removeComponent=function(e){return this._core.removeComponent(e);},l.prototype.moveComponent=function(e,t){return this._core.moveComponent(e,t);},l.prototype.copyComponent=function(e,t,n,i,o){return this._core.copyComponent(e,t,n,i,o);},l.prototype.replaceComponent=function(e,t,n,i){return this._core.replaceComponent(e,t,n,i);},l.prototype.assetOfComponent=function(e,t){return this._core.assetOfComponent(e,t);},l.prototype.copy=function(){var e=new l(JSON.parse(JSON.stringify(this._data)));return e._localStorage=this._localStorage,e;},l.prototype.setLocalData=function(e,t){if("string"!=typeof e)throw new s(s.INVALID_DATA,"Local data key must be a string.");if(this._local().customData=this._local().customData||{},Object(t)===t)try{JSON.stringify(t);}catch(e){throw new s(s.INVALID_DATA,"Local data value must be serializable.",e);}this._local().customData[e]=t,this._setDirty(!0);},l.prototype.getLocalData=function(e){if("string"!=typeof e)throw new s(s.INVALID_DATA,"Local data key must be a string.");return this._local().customData&&this._local().customData[e];},l.prototype._createElement=function(e){var t;if(e){var n=JSON.parse(JSON.stringify(e._data));n["manifest-format-version"]=this._data["manifest-format-version"],delete n.path,(t=new a(n,this,this._core._readOnly))&&this._localStorage&&(t._localStorage=this._localStorage,t._updateLocalDataFromBranch(this),this._localStorage.registerInMemoryBranchOrElement(t));}return t&&this._pendingElements.push(t),t;},l.prototype._deleteElement=function(e){var t=this._pendingElements.indexOf(e);if(t<0)throw new s(s.INVALID_PARAMS,"Unknown element.");this._pendingElements.splice(t,1),this._localStorage&&this._localStorage.unregisterInMemoryBranchOrElement(e);},l.prototype._updateLocalDataFromBranch=function(e){if(this._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");if(!this._localStorage)throw new s(s.NO_LOCAL_STORAGE,"No local storage.");if(!e._localStorage)throw new s(s.NO_LOCAL_STORAGE,"No local storage for source.");if(this._localStorage.compositePath!==e._localStorage.compositePath)throw new s(s.INVALID_PARAMS,"Branches must have same storage path.");this._core._localStorage.copyLocalStorageData(e,e._core._local(),this,this._core._local()),this._core._copySourceHrefsFrom(e._core);},l.prototype._verify=function(e){return"string"!=typeof e.id?new s(s.INVALID_DATA,"Manifest is missing an id of type string"):"string"!=typeof e.name?new s(s.INVALID_DATA,"Manifest is missing a name of type string"):"string"!=typeof e.type?new s(s.INVALID_DATA,"Manifest is missing a type of type string"):"number"!=typeof e["manifest-format-version"]?new s(s.INVALID_DATA,"Manifest is missing a manifest-format-version of type number"):null;},l.prototype._setData=function(e,t){this.originalManifestFormatVersion=e["manifest-format-version"],_(e),e.local&&(e.local.version=2);var n=this._verify(e);if(null===n)return e["manifest-format-version"]=6,this._core=new r(e,this,t),this._data=e,this;throw n;},l.prototype._reset=function(e,t){if(this._readOnly)throw new s(s.READ_ONLY,"This object is read-only.");this._data.local&&(delete this._data.local.manifestEtag,delete this._data.local.compositeHref,delete this._data.local.links,delete this._data.local.assetId,delete this._data.local.repoMetadata,delete this._data.local.isWritable,delete this._data.local.parentAssetId,delete this._data.local.isParentWritable,delete this._data.local.isRenamePending,delete this._data.local.storageAssignee,delete this._data.local.customData),e||(this._data.id=c.generateUuid()),this._data.state="modified",this._core._recursiveReset(this._data,t),this._core._setDirty();},l.prototype._resetBinding=function(e){this._reset(!0,e);},l.prototype._resetIdentity=function(e){this._reset(!1,e);},l.prototype._local=function(){return this._core._local();},l.prototype._setDirty=function(e){this._core._setDirty(e);},l.prototype._setPathOfNode=function(e,t){this._core._setPathOfNode(e,t);},l.prototype._verifyIntegrity=function(e,t,n){return this._core._verifyIntegrity(e,t,n);},e.exports=l;},function(e,t){e.exports=function e(t,n,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this.filename=t,this.size=n,this.range=i;};},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}var o=n(0),r=n(1);function a(e,t){e?this._setData(e):this._data={},this._readOnly=t;}var s={unmodified:"unmodified",modified:"modified",pendingDiscard:"pendingDiscard",pendingDelete:"pendingDelete",committedDelete:"committedDelete"};a.STATES=s,a._UploadResults=function(e){this.compositeId=e,this.records={};},a._UploadRecord=function(e,t,n,i,o,r){this.id=e,this.etag=t,this.version=n,this.md5=i,this.length=o,this.type=r;},Object.defineProperties(a.prototype,{id:{get:function(){return this._data.id;},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(this._owner)throw new o(o.READ_ONLY,"Cannot change the id of a component that is part of a branch or element.");if("string"!=typeof e||""===e)throw new o(o.INVALID_PARAMS,"Expecting a non-empty string.");this._data.id=e,this._setDirty();}},name:{get:function(){return this._data.name;},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.name=e,this._setDirty();}},type:{get:function(){return this._data.type;},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e||""===e)throw new o(o.INVALID_PARAMS,"Expecting a non-empty string.");this._data.type=e,this._setDirty();}},path:{get:function(){return this._data.path;},set:function(e){if(this._data.path!==e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!r.isValidPath(e))throw new o(o.INVALID_PARAMS,"Expecting a valid path.");this._owner?this._owner._core._setPathOfComponent(this,e):(this._data.path=e,this._parentPath=""),this._setDirty();}}},parentPath:{get:function(){return this._parentPath;},set:function(){throw new o(o.READ_ONLY,"parentPath is read-only.");}},absolutePath:{get:function(){return this._data.path&&this._owner?r.appendPathElements(this._parentPath,this._data.path):void 0;},set:function(){throw new o(o.READ_ONLY,"absolutePath is read-only.");}},relationship:{get:function(){return this._data.rel;},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.rel=e,this._setDirty();}},state:{get:function(){return this._data.state;},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string.");if(!s.hasOwnProperty(e))throw new o(o.INVALID_PARAMS,'State must be "modified", "unmodified", "pendingDiscard", "pendingDelete", or "committedDelete".');this._data.state=e,this._setDirty();}},etag:{get:function(){return this._data.etag;},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.etag=e,this._setDirty();}},md5:{get:function(){return this._data.md5;},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.md5=e,this._setDirty();}},version:{get:function(){return this._data.version;},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(void 0!==e&&"string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.version=e,this._setDirty();}},length:{get:function(){return this._data.length;},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("number"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a number or undefined.");this._data.length=e,this._setDirty();}},width:{get:function(){return this._data.width;},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("number"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a number or undefined.");this._data.width=e,this._setDirty();}},height:{get:function(){return this._data.height;},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("number"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a number or undefined.");this._data.height=e,this._setDirty();}}});var c={name:!0,id:!0,state:!0,path:!0,rel:!0,type:!0,etag:!0,length:!0,version:!0,md5:!0,width:!0,height:!0};a.prototype.getCustomKeys=function(){var e,t=[],n=Object.keys(this._data),i=n.length;for(e=0;e<i;e++){var o=n[e];c[o]||t.push(o);}return t;},a.prototype.getValue=function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "key" must be a string');return this._data[e];},a.prototype.setValue=function(e,t){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "key" must be a string');this._data[e]=t,this._setDirty();},a.prototype.removeValue=function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "key" must be a string');delete this._data[e],this._setDirty();},a.prototype.getLink=function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "relationship" must be a string');return this._data._links?this._data._links[e]:void 0;},a.prototype.setLink=function(e,t){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("object"!==i(e))throw new o(o.INVALID_PARAMS,'Param "link" must be an object.');if("string"!=typeof t)throw new o(o.INVALID_PARAMS,'Param "relationship" must be a string');var n=this._data._links;n||(n=this._data._links={}),n[t]=e,this._setDirty();},a.prototype.removeLink=function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "relationship" must be a string');var t=this._data._links;t&&(delete t[e],Object.keys(t).length<1&&delete this._data._links,this._setDirty());},a.prototype.isEqualTo=function(e,t){return r.objectsEqual(this._data,e._data,t);},a.prototype._setData=function(e){var t=this._verify(e);if(null===t)return this._data=e,this;throw t;},a.prototype._setDirty=function(){this._owner&&this._owner._setDirty();},a.prototype._verify=function(e){return"string"!=typeof e.id?new o(o.INVALID_DATA,"Component is missing an id of type string"):null;},e.exports=a;},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var o=n(2),r=n(1),a=n(7),s=n(4),c=["ROOT_DIR","POLL_INTERVAL","RENDITION_SIZES","FULL_RENDITION_CONFIG","EXTERNAL_LINK_PREFETCH","LOCALE","STORAGE_API_KEY","USER_AGENT_HEADER","SYNC_POLICY","ELEMENT_TYPE_FILTERS","AUTO_START_POLLING","SHARED_LOCAL_STORAGE","ALLOWED_DOMAINS","CLIENT_DESCRIPTION","DEVICE_ID","DEVICE_DESCRIPTION","APP_DESCRIPTION","DEFAULT_RENDITION_404_BACKOFF","LOCAL_SETTINGS","PLATFORM_FOLDER_REFRESH_INTERVAL"],l="library#",u="bookmarks.json",_={VERSION:1,DL_NAMESPACE:"library",DL_PREFIX:l,VERSION_KEY:"library#version",RELATIONSHIP_KEY:"library#rel",WIDTH_KEY:"library#width",HEIGHT_KEY:"library#height",LENGTH_KEY:"library#length",IS_FULL_SIZE_KEY:"library#isFullSize",CSDK_IS_FULL_SIZE_KEY:"library#isfullSize",IS_PREFERRED_THUMBNAIL_KEY:"library#isPreferredThumbnail",MODIFIED_KEY:"library#modified",CREATED_KEY:"library#created",REMOVED_KEY:"library#removed",MODIFIED_DATA_KEY:"library#modifiedData",CREATED_DATA_KEY:"library#createdData",REMOVED_DATA_KEY:"library#removedData",DESCRIPTION_KEY:"library#description",DESCRIPTION_DATA_KEY:"library#descriptionData",GROUPS_KEY:"library#groups",ORDER_KEY:"library#order",PARENT_KEY:"library#parentId",CLASSIFIER_KEY:"library#classifier",SOURCE_REF_KEY:"library#sourceRef",SOURCE_MODIFIED_KEY:"library#sourceModified",LINK_TYPE_KEY:"library#linktype",LINK_URL_KEY:"library#linkurl",LINK_LOCAL_PATH_KEY:"library#linklocalpath",REPRESENTATION_ORDER_KEY:"library#representationOrder",RENDITION_TYPE_KEY:"library#renditiontype",SHA_KEY:"library#sha256",DOCUMENT_ID_KEY:"library#documentId",DOCUMENT_TYPE_KEY:"library#documentType",DEPENDENCIES_KEY:"library#dependencies",LOCALIZED_NAME_KEY:"library#localizedName",AUTO_NAMED_KEY:"library#autoName",ANIMATION_ELEMENT_TYPE:"application/vnd.adobe.element.animation+dcx",BRUSH_ELEMENT_TYPE:"application/vnd.adobe.element.brush+dcx",COLOR_ELEMENT_TYPE:"application/vnd.adobe.element.color+dcx",IMAGE_ELEMENT_TYPE:"application/vnd.adobe.element.image+dcx",LAYER_STYLE_ELEMENT_TYPE:"application/vnd.adobe.element.layerstyle+dcx",COLOR_THEME_ELEMENT_TYPE:"application/vnd.adobe.element.colortheme+dcx",CHARACTER_STYLE_ELEMENT_TYPE:"application/vnd.adobe.element.characterstyle+dcx",PARAGRAPH_STYLE_ELEMENT_TYPE:"application/vnd.adobe.element.paragraphstyle+dcx",TEXT_ELEMENT_TYPE:"application/vnd.adobe.element.text+dcx",REPRESENTATION_CONTENT_VALUES:{"application/vnd.adobe.color+json":{namespace:"color",key:"data"},"application/vnd.adobe.text+json":{namespace:"text",key:"data",contentFromData:!0}},DEFAULT_GROUP_CLASSIFIER:"$default",DOCUMENTATON_GROUP_CLASSIFIER:"$documentation",COMPOSITE_TYPE:"application/vnd.adobe.library+dcx",LINK_REPRESENTATION_TYPE:"application/vnd.adobe.library.link+dcx",GROUP_TYPE:"application/vnd.adobe.library.group+dcx",ELEMENTS_NAME:"elements",REMOVED_ELEMENTS_NAME:"removed_elements",DOCUMENTATION_ELEMENTS_NAME:"documentation_elements",GROUPS_NAME:"groups",DATA_COLLABORATION_ROLE:"collaborationRole",BOOKMARKS_FILENAME:u,BOOKMARKS_FILE_VERSION:2,BOOKMARKS_PATH:"/bookmarks",BOOKMARKS_MONITOR_PATHS:[u,"collab-bookmarks.json"].map(function(e){return"/sync/adobe-libraries/".concat(e);}),BOOKMARKS_TYPES:{public:{allowed:["url"],required:["url"]},collab:{allowed:["urn","role"],required:{on_pushed_new:[],default:["urn"]}}},PLATFORM_DATA_FILENAME:"platform-data.json",PLATFORM_DATA_VERSION:1,PLATFORM_DATA_TTL:2592e6,PLATFORM_FOLDER_REFRESH_INTERVAL:6e4,OPERATIONS_POLL_INTERVAL:1,STOCK_NAMESPACE:"adobestock",STOCK_DATA_KEY:"trackingdata",STOCK_STATE_PURCHASED:"purchased",TOOLKIT_NAMESPACE:"toolkit",TOOLKIT_ID_KEY:"id",RELATIONSHIP_CHILD:"child",PUBLIC_USER_ID:"public",COLLABORATED_CLOUD_ID:"collaborated",DEFAULT_CLOUD_ID:"creative_cloud",DEFAULT_CORESYNC_CLOUD_ID:"00000000-0000-0000-0000-000000000000",STORAGE_ASSETS_PATH:"/assets/",LIBRARY_SYNC_GROUP:"adobe-libraries",CP_CLOUD_ID:"community-platform",CP_STORAGE_ASSETS_PATH:"/content/2/",VULCAN_PREFIX:"vulcan.SuiteMessage.",VULCAN_STARTUP_MESSAGE:"cclibraries.service.Initialized",VULCAN_SHUTDOWN_REQUEST:"cclibraries.service.TerminateServiceRequest",VULCAN_QUERY_REQUEST:"cclibraries.service.QueryRequest",VULCAN_QUERY_RESPONSE:"cclibraries.service.QueryResponse",VULCAN_LIBRARY_CHANGED_LOCAL_TYPE:"cclibraries.service.LibraryChangedLocal",VULCAN_LIBRARY_CHANGED_REMOTE_TYPE:"cclibraries.service.LibraryChangedRemote",VULCAN_LIBRARY_DELETED_TYPE:"cclibraries.service.LibraryDeleted",VULCAN_COLLECTIONS_LOADED_TYPE:"cclibraries.service.LibrariesLoaded",VULCAN_COLLECTIONS_UNLOADED_TYPE:"cclibraries.service.LibrariesUnloaded",VULCAN_PROXY_QUERY_REQUEST:"cclibraries.service.QueryProxySettingsRequest",VULCAN_PROXY_QUERY_RESPONSE:"cclibraries.service.QueryProxySettingsResponse",VULCAN_PROXY_CHANGE_MESSAGE:"cclibraries.service.ProxySettingsChanged",VULCAN_APP_READY_MESSAGE:"cclibraries.accessor.AppReady",VULCAN_APP_SEND_ACTION_MESSAGE:"cclibraries.accessor.EditElementRequest",VULCAN_APP_ACTION_ACCEPTED_MESSAGE:"cclibraries.accessor.EditAcceptedMessage"},h=function(){function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._listenerManager=new a(["change"]),this.MAX_ELEMENTS=1e4,this.MAX_REMOVED_ELEMENTS=2e3,this.MAX_DOCUMENTATION_ELEMENTS=2e3,this.MAX_COMPONENT_SIZE=1073741824,this.VALID_RELATIONS=["rendition","primary","alternate"],this.VALID_LIBRARY_RENDITION_TYPES=["banner","cover"],this.VALID_SYNC_POLICIES=["manifestAndAssets","manifestOnly"],this.ELEMENT_TYPE_FILTERS=[],this.VECTOR_RENDITION_ELEMENT_TYPES=["application/illustrator"],Object.keys(_).forEach(function(e){return t[e]=_[e];}),this.FS_RETRY_INTERVAL=100,this.FS_MAX_RETRIES=10,this.MAX_DCX_CONCURRENT_COPIES=10,this.REMOVE_OPERATION_TIMEOUT=100,this.EXPORT_VERSION=1,this.EXPORT_EXTENSION=".cclibs",this.ANALYTICS_ENABLED=!1,this.ANALYTICS_ELEMENT_UPDATE_THRESHOLD=500,this.STORAGE_API_KEY="",this.USER_AGENT_HEADER=void 0,this.SYNCING_ENABLED=!0,this.VULCAN_QUERY_TIMEOUT=8e3,this.DEFAULT_MAX_SYNC_INTERVAL=1e4,this.RETRY_FAIL_MAX_SYNC_INTERVAL=6e4,this.MAX_SYNC_INTERVAL=this.DEFAULT_MAX_SYNC_INTERVAL,this.POLL_INTERVAL=1,this.AUTO_START_POLLING=!1,this.RENDITION_SIZES={},this.FULL_RENDITION_CONFIG={},this.BACKOFF_INTERVALS=[1,1,2,3,5,8,13,21,34,55],this.ERROR_RETRY_INTERVALS=[30,60,120],this.NETWORK_TIMEOUT=6e5,this.IMAGE_SERVICE_NETWORK_TIMEOUT=18e4,this.RETRY_RANDOM_SECONDS=30,this.RENDITION_MAX_RETRIES=2,this.DEFAULT_RENDITION_RETRY_INTERVAL=1e3,this.RENDITION_RETRY_INTERVAL=this.DEFAULT_RENDITION_RETRY_INTERVAL,this.DEFAULT_RENDITION_404_BACKOFF=3e5,this.RENDITION_404_BACKOFF=this.DEFAULT_RENDITION_404_BACKOFF,this.LOCAL_RENDITION_MAX_RETRIES=5,this.LOCAL_RENDITION_RETRY_INTERVAL=200,this.MAX_UPDATE_CONFLICTS=5,this.MAX_REDIRECT_FOLLOW=5,this.MAX_HEAD_REDIRECT_FOLLOW=0,this.MAX_RECOVERED_LIBRARIES=10,this.ELMO_LOCAL_LIBRARY_LIMIT=2e4,this.ELMO_SERVER_RECOVERED_LIMIT=100,this.ADOBE_AUTHENTICATED_DOMAINS=["stock.adobe.com","stock.stage.adobe.com","adobe.io","adobestock.com","fotolia.net"],this.ALLOWED_DOMAINS=["cclibraries-defaults-cdn.adobe.com","cclibraries-defaults-cdn.stage.adobe.com","stageastockcdn.net","ftcdn.net"],this.DISALLOWED_DOMAINS={"cc-api-storage-stage.adobe.io":["stock.adobe.com"],"platform-cs-stage.adobe.io":["stock.adobe.com"],"cc-api-storage.adobe.io":["stock.stage.adobe.com"],"platform-cs.adobe.io":["stock.stage.adobe.com"]},this.SHA_CACHE={},this.DEFAULT_CONTENT_LOCATIONS=[],this.SYNC_POLICY="manifestAndAssets",this.REMOVED_ELEMENTS_CACHE_TIMEOUT=6e5,this.RENDITION_CACHE_FILE="cache.json",this.RENDITION_CACHE_PLACEHOLDER="<placeholder>",this.SHARED_LOCAL_STORAGE_TEAM_LIBRARIES_BETA_VERSION=21,this.SHARED_LOCAL_STORAGE=!0,this.SHARED_LOCAL_STORAGE_VERSION=23,this.SHARED_LOCAL_STORAGE_MIN_CLIENT_VERSION=6,this.SHARED_LOCAL_STORAGE_MAX_CLIENT_VERSION=23,this.LOCAL_SETTINGS={},this.ELEMENT_ACTIONS=["edit","openStock","editInSource"],this.LIBRARY_ACTIONS=["editInSource"],this.DOCUMENT_LIBRARY_ACTION_PRODUCT_MAP={types:{"application/vnd.adobe.xd.cloudproject+dcx":["SPKR"]},products:{SPKR:{minVersion:"34",appCode:"SPKR",appName:"XD",action:"editInSource"}}},this.ELEMENT_ACTION_PRODUCT_MAP={types:{"application/vnd.adobe.element.image+dcx":{"application/illustrator":["ILST_EDIT","ILST_PLACE","IDSN_PLACE"],"image/svg+xml":["ILST_EDIT","ILST_PLACE"],"application/vnd.adobe.indesign-idms":["IDSN_EDIT","IDSN_PLACE"],"image/vnd.adobe.photoshop":["PHXS_EDIT","PHXS_PLACE","IDSN_PLACE"],"application/photoshop":["PHXS_EDIT","PHXS_PLACE","IDSN_PLACE"],"application/photoshop.large":["PHXS_EDIT","PHXS_PLACE","IDSN_PLACE"],"image/png":["PHXS_EDIT","PHXS_PLACE","ILST_PLACE","IDSN_PLACE","PPRO_PLACE","AEFT_PLACE"],"image/jpeg":["PHXS_EDIT","PHXS_PLACE","ILST_PLACE","IDSN_PLACE","PPRO_PLACE","AEFT_PLACE"],"image/jpg":["PHXS_EDIT","PHXS_PLACE","IDSN_PLACE","ILST_PLACE","PPRO_PLACE","AEFT_PLACE"],"image/gif":["PHXS_EDIT","PHXS_PLACE","ILST_PLACE","IDSN_PLACE","PPRO_PLACE","AEFT_PLACE"],"image/bmp":["PHXS_EDIT","PHXS_PLACE","ILST_PLACE","IDSN_PLACE","PPRO_PLACE","AEFT_PLACE"],"image/x-portable-bitmap":["PHXS_EDIT","PHXS_PLACE"],"image/x-pict":["PHXS_EDIT","PHXS_PLACE"],"image/x-pcx":["PHXS_EDIT","PHXS_PLACE"],"image/x-portable-graymap":["PHXS_EDIT","PHXS_PLACE"],"image/x-portable-anymap":["PHXS_EDIT","PHXS_PLACE"],"image/x-portable-pixmap":["PHXS_EDIT","PHXS_PLACE"],"image/x-tga":["PHXS_EDIT","PHXS_PLACE"],"image/tiff":["PHXS_EDIT","PHXS_PLACE"],"image/vnd.wap.wbmp":["PHXS_EDIT","PHXS_PLACE"]},"application/vnd.adobe.element.text+dcx":{"application/illustrator-text":["ILST_EDIT_TEXT"],"application/vnd.adobe.indesign-idms-text":["IDSN_EDIT_TEXT"]},"application/vnd.adobe.element.template+dcx":{"image/vnd.adobe.photoshop.template":["PHXS_PLACE"],"application/illustrator.template":["ILST_PLACE"],"application/vnd.adobe.indesign.template":["IDSN_PLACE"]},"application/vnd.adobe.element.3d+dcx":{"application/vnd.adobe.obj.3d+zip":["ESHR_PLACE"]},"application/vnd.adobe.element.material+dcx":{"application/vnd.adobe.mdl.material+zip":["ESHR_PLACE"]},"application/vnd.adobe.element.light+dcx":{"application/vnd.adobe.ibl.light+zip":["ESHR_PLACE"]},"application/vnd.adobe.element.animation+dcx":{"application/vnd.adobe.animate-xfl+zip":["FLPR_EDIT"],"application/vnd.adobe.animate-sym+zip":["FLPR_EDIT"]}},products:{ILST_EDIT:{minVersion:"19.2",appCode:"ILST",appName:"Illustrator",action:"edit"},ILST_EDIT_TEXT:{minVersion:"22",appCode:"ILST",appName:"Illustrator",action:"edit"},IDSN_EDIT:{minVersion:"11.2",appCode:"IDSN",appName:"InDesign",action:"edit"},IDSN_EDIT_TEXT:{minVersion:"13",appCode:"IDSN",appName:"InDesign",action:"edit"},PHXS_EDIT:{minVersion:"16.1.2",appCode:"PHXS",appName:"Photoshop",action:"edit"},FLPR_EDIT:{minVersion:"16.1",appCode:"FLPR",appName:"Flash",action:"edit"},PHXS_PLACE:{minVersion:"17.0.0",appCode:"PHXS",appName:"Photoshop",action:"openStock"},ILST_PLACE:{minVersion:"20.0.0",appCode:"ILST",appName:"Illustrator",action:"openStock"},IDSN_PLACE:{minVersion:"11.4.0",appCode:"IDSN",appName:"InDesign",action:"openStock"},PPRO_PLACE:{minVersion:"10.3.0",appCode:"PPRO",appName:"Premiere Pro",action:"openStock"},AEFT_PLACE:{minVersion:"13.8.0",appCode:"AEFT",appName:"After Effects",action:"openStock"},ESHR_PLACE:{minVersion:"0.1",appCode:"ESHR",appName:"Project Felix",action:"openStock"}},installedApps:[]},this.TLS_DISCOVERY_PORT_RANGE=[45623,45625],this.TLS_DELAY_ON_DECLINE=500,this.TLS_DELAY_ON_READY=250;}var t,n,l;return t=e,(n=[{key:"getLocalSettings",value:function(){return this.LOCAL_SETTINGS;}},{key:"addChangeListener",value:function(e){this._listenerManager.add("change",e);}},{key:"removeChangeListener",value:function(e){this._listenerManager.remove("change",e);}},{key:"_validateLocalSetting",value:function(e,t){if("string"!=typeof e)throw new o(o.INVALID_PARAMETER,"Key must be a string");try{JSON.stringify(t);}catch(e){throw new o(o.INVALID_PARAMETER,"Value must be serializable to JSON",null,e);}}},{key:"_validateLocalSettings",value:function(e){var t=this;if(!s.isObject(e))throw new o(o.INVALID_PARAMETER,"Configuration data must be of type object");Object.keys(e).forEach(function(n){return t._validateLocalSetting(n,e[n]);});}},{key:"setLocalSetting",value:function(e,t){var n={};n[e]=t,this._validateLocalSetting(e,t),this.setLocalSettings(n);}},{key:"setLocalSettings",value:function(e){this._validateLocalSettings(e),Object.assign(this.LOCAL_SETTINGS,e),this._listenerManager.notify("change");}},{key:"setParameter",value:function(e,t){if(-1===c.indexOf(e))throw new o(o.INVALID_PARAMETER,"Parameter not configurable");if("SYNC_POLICY"===e&&-1===this.VALID_SYNC_POLICIES.indexOf(t))throw new o(o.INVALID_PARAMETER,"Invalid value for SYNC_POLICY");"POLL_INTERVAL"===e&&(t=Math.max(1,t)),this[e]=t,this._listenerManager.notify("change");}},{key:"getBackoffTicks",value:function(e){var t=this.BACKOFF_INTERVALS;return t[Math.max(0,Math.min(e,t.length-1))]-1;}},{key:"getRetryAfterHeader",value:function(e){if(e){var t=e["retry-after"]||e["Retry-After"];if(t)try{var n=parseInt(t,10);if(n)return Math.max(0,n);var i=Date.parse(t);if(i){var o=Date.now();return Math.max(0,i-o)/1e3+Math.floor(Math.random()*this.RETRY_RANDOM_SECONDS);}}catch(e){}}return 0;}},{key:"getLocationHeader",value:function(e){if(e){var t=e.location||e.Location;if(t)return t;}}},{key:"getContentTypeHeader",value:function(e){if(e){var t=e["content-type"]||e["Content-Type"];if(t){var n=t.indexOf(";");return n>0&&(t=t.substring(0,n)),t;}}}},{key:"getContentLengthHeader",value:function(e){if(e){var t=e["content-length"]||e["Content-Length"];return Number(t)||void 0;}}},{key:"isUnrecoverableClientError",value:function(e,t){return!!e&&e>=400&&e<500&&(401!==e||!!t)&&407!==e&&408!==e&&429!==e;}},{key:"isRedirect",value:function(e){return 301===e||302===e||303===e||307===e;}},{key:"_checkDomain",value:function(e,t){return t.some(function(t){if(e===t)return!0;var n=e.indexOf("."+t);return-1!==n&&n===e.length-t.length-1;});}},{key:"isAdobeDomain",value:function(e){return"string"==typeof e&&this._checkDomain(e,this.ADOBE_AUTHENTICATED_DOMAINS);}},{key:"validateURL",value:function(e,t){if(!e)return new o(o.URL_VALIDATION_FAILED,"URL not specified");var n=r.parseURI(e);if("https"!==n.scheme)return new o(o.URL_VALIDATION_FAILED,"URL must be https://");if(!this.isAdobeDomain(n.authority)&&!this._checkDomain(n.authority,this.ALLOWED_DOMAINS))return new o(o.URL_VALIDATION_FAILED,"URL domain not in allowedlist");var i=t&&t._syncManager._storageHost,a=i&&this.DISALLOWED_DOMAINS[i];return this._checkDomain(n.authority,a||[])?new o(o.URL_VALIDATION_FAILED,"URL domain does not match IMS environment (stage-production mismatch)"):null;}},{key:"formatElementActionMapForClient",value:function(e){return e<9?{types:this.ELEMENT_ACTION_PRODUCT_MAP.types["application/vnd.adobe.element.image+dcx"],products:this.ELEMENT_ACTION_PRODUCT_MAP.products,installedApps:this.ELEMENT_ACTION_PRODUCT_MAP.installedApps}:this.ELEMENT_ACTION_PRODUCT_MAP;}},{key:"updateElementActionMap",value:function(e,t){if(e<9){var n=t.types;t.types=this.ELEMENT_ACTION_PRODUCT_MAP.types,t.types["application/vnd.adobe.element.image+dcx"]=n;}this.ELEMENT_ACTION_PRODUCT_MAP=t;}},{key:"isNewBookmarkFormatSupported",value:function(e){return e>=18;}},{key:"shouldPrefetchFullRendition",value:function(e){var t=(this.FULL_RENDITION_CONFIG||{})[e.type];if(!t)return!1;var n=!1;return Object.keys(t).forEach(function(i){var o=t[i];if("IF_NO_MATCHING_REPRESENTATION"===o.condition&&o.types){var r=e.representations.every(function(e){return!o.types.includes(e.type);});n=n||r;}}),n;}},{key:"shouldPrefetchExternalLink",value:function(e){if(!e.isExternalLink)return!1;var t=(this.EXTERNAL_LINK_PREFETCH||{})[e.element.type];return void 0===t||t;}},{key:"addToRenditionSizeConfig",value:function(e){var t=this.RENDITION_SIZES,n=JSON.parse(JSON.stringify(t["*"]||[])),i=e["*"]||[];Object.keys(t).forEach(function(n){if(!e[n]){var o=t[n];i.forEach(function(e){-1===o.indexOf(e)&&o.push(e);}),t[n]=o;}}),Object.keys(e).forEach(function(i){var o=t[i]||JSON.parse(JSON.stringify(n));e[i].forEach(function(e){-1===o.indexOf(e)&&o.push(e);}),t[i]=o;}),this.setParameter("RENDITION_SIZES",t);}},{key:"addToFullRenditionConfig",value:function(e){var t=this.FULL_RENDITION_CONFIG;Object.keys(e).forEach(function(n){var i=t[n]||{};e[n].forEach(function(e){e.id&&(i[e.id]=e);}),t[n]=i;}),this.setParameter("FULL_RENDITION_CONFIG",t);}}])&&i(t.prototype,n),l&&i(t,l),e;}();Object.keys(_).forEach(function(e){return h[e]=_[e];}),e.exports=h;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function r(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function a(e,t,n){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=s(e)););return e;}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(n):o.value;}})(e,t,n||e);}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e);})(e);}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e;})(e,t);}var l=n(0),u=n(35),_=n(69),h=n(70),p=n(2),d=n(74),f=n(9),m=n(18),v=n(6),y=n(3),g=n(10),E=n(75),O=n(4).promisify,S=function(e){function t(e,n,o){var a,c,l;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,t),c=this,l=s(t).call(this),(a=!l||"object"!==i(l)&&"function"!=typeof l?r(c):l)._collection=e,a._dcxComposite=n,a._dcxBranch=n.current,a._publicId=o,a._renditionCache=new E(r(a)),a._autoGCMode={},a._transactionCount=0,a._commitInProgress=!1,a._pendingCommit=!1,a._onCommitCallbacks=[],a._dcxLock=new f(),a._networkLock=new f(),a._syncState=void 0,a._deletedLocally=!1,a._deletedFromServer=!1,a._waitForSyncToFinishCallbacks=[],a._errors=[],a._pushFailedDueToQuota=!1,a._numUpdateConflicts=0,a._numActiveCopyNodeOperations=0,a._pendingCopyNodeOperations=[],a._dcxTopLevelNodes={},a._dcxBranch.getChildrenOf().forEach(function(e){return a._dcxTopLevelNodes[e.name]=e;}),a._getTopLevelNode(a._config.ELEMENTS_NAME),a._dcxCompositeRenditionMap=v.getCompositeRenditionMap(a._dcxBranch),a._elements=a._createItemSet(a._config.ELEMENTS_NAME,function(e){return new h(r(a),e);}),a._documentationElements=a._createItemSet(a._config.DOCUMENTATION_ELEMENTS_NAME,function(e){return new h(r(a),e,!0);}),a._removedElements=a._createItemSet(a._config.REMOVED_ELEMENTS_NAME,function(e){return new h(r(a),e);}),a._groups=a._createItemSet(a._config.GROUPS_NAME,function(e){return new _(r(a),e);}),a._services.hasFileSystem()||(a._dcxBaseBranch=a._dcxBranch.copy()),a.addChangeListener(a._updateStorageUsed.bind(r(a))),a._updateStorageUsed(),a;}var n,u,S;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t);}(t,e),n=t,(u=[{key:"_setName",value:function(e){e=v.sanitizeLibraryName(e),a(s(t.prototype),"_setName",this).call(this,e),this._dcxComposite.isRenamePending=!0;}},{key:"_getTopLevelNode",value:function(e){var t=this._dcxTopLevelNodes[e];return t||(t=this._dcxTopLevelNodes[e]=this._dcxBranch.addChild(e)),t;}},{key:"_createItemSet",value:function(e,t){var n=new m(),i=this._dcxTopLevelNodes[e];return i&&this._dcxBranch.getChildrenOf(i).forEach(function(e){return n.add(t(e));}),n;}},{key:"_markDeletedLocally",value:function(e){this._elements.forEach(function(t){return t._markDeletedLocally(e);}),this._groups.forEach(function(t){return t._markDeletedLocally(e);}),a(s(t.prototype),"_markDeletedLocally",this).call(this,e);}},{key:"_removeAllListeners",value:function(){this._elements.forEach(function(e){return e._removeAllListeners();}),this._groups.forEach(function(e){return e._removeAllListeners();}),a(s(t.prototype),"_removeAllListeners",this).call(this);}},{key:"_toJSON",value:function(){return{id:this.id,name:this.name,elements:this._elements.map(function(e){return e._toJSON();}),renditionCache:this._renditionCache.serializeCache(),groups:this._groups.map(function(e){return e._toJSON();})};}},{key:"_getRenditionCache",value:function(){var e={},t=function(t){e[t.id]=JSON.parse(JSON.stringify(t._renditionCache));};return this._elements.forEach(t),this._removedElements.forEach(t),e;}},{key:"_doCommitCallbacks",value:function(e){var t=this,n=this._onCommitCallbacks;this._onCommitCallbacks=[],n.forEach(function(n){n.waitForSuccess&&!e?t._onCommitCallbacks.push(n):t._waitForCommit(n.callback);});}},{key:"_doCommit",value:function(e){var t=this,n=function(n){t._doCommitCallbacks(n),function(){if(e&&!t._config.SHARED_LOCAL_STORAGE){if(t._deletedLocally)return;t._collection._clearSyncErrors(),t._push(),t._collection._resetPollBackoff();}}();};this._services.hasFileSystem()?this._commitInProgress?this._pendingCommit=!0:(this._commitInProgress=!0,this._storageInterface.commitManifest(this,function(i,o){!function(e,n){e&&(e=y.getCommitError(e,t.id,n)),t._collection._reportCommitError(e);}(i,"Failed to write composite to disk"),t._commitInProgress=!1,t._pendingCommit?(t._pendingCommit=!1,0===t._transactionCount&&t._doCommit(e)):n(o);})):n();}},{key:"_waitForCommit",value:function(e,t){this._commitInProgress||this._transactionCount>0?this._onCommitCallbacks.push({callback:e,waitForSuccess:t}):this._renditionCache._waitForCommit(e);}},{key:"_notifyChange",value:function(){this._listenerManager.notify("change"),this._collection._notifyChange();}},{key:"_commit",value:function(e,t){0===this._transactionCount&&(t||(this._updateModifiedTime(),this._notifyChange()),this._doCommit(!e));}},{key:"_commitMetadata",value:function(){this._commit();}},{key:"_unblockCommits",value:function(){this._commitInProgress||0!==this._transactionCount||(this._services.log("Unblocking queued commits"),this._doCommitCallbacks(!0));}},{key:"_wrapOperation",value:function(e,t){var n;this._beginOperation();try{n=e.call(t);}catch(e){throw this._transactionCount--,e;}return this._endOperation(),n;}},{key:"_beginOperation",value:function(){this._transactionCount++;}},{key:"_endOperation",value:function(){this._transactionCount--,this._commit();}},{key:"_updateModifiedTime",value:function(){var e=Date.now();this._dcxNode.setValue(this._config.MODIFIED_KEY,e);}},{key:"_updateCreatedTime",value:function(){var e=Date.now();this._dcxNode.setValue(this._config.CREATED_KEY,e),this._dcxNode.setValue(this._config.MODIFIED_KEY,e);}},{key:"_getMissingLocalComponents",value:function(){return this._elements.reduce(function(e,t){return e.concat(t._getMissingLocalComponents());},[]);}},{key:"_gcLocalData",value:function(e){var t=this,n=[],i={},o=[];if(this._removedElements.forEach(function(e){e._shouldGCLocalData()&&(n.push(e),e._forEachRepresentation(function(e){var t=e._dcxComponent,n=e._getCurrentComponentPath();t&&n&&t.etag&&"modified"!==t.state?(i[n]=i[n]||[],i[n].push(t.id)):n&&o.push(n);}));}),0!==n.length){o.forEach(function(e){delete i[e];}),this._elements.forEach(function(e){e._forEachRepresentation(function(e){var t=e._getCurrentComponentPath();t&&delete i[t];});});var r=[];Object.keys(i).forEach(function(e){r.push.apply(r,i[e]);}),n.forEach(function(e){return t._renditionCache.clearCache(e);}),this._services.log("Removing local files for components: [ "+r.join(", ")+" ]"),this._dcxComposite.removeLocalFilesForComponentsWithIDs(r,e);}else e(null);}},{key:"_checkRenditionType",value:function(e,t){if(!e||-1===this._config.VALID_LIBRARY_RENDITION_TYPES.indexOf(e)){if(t)return t(new p(p.INVALID_PARAMETER,"composite rendition type not supported: "+e)),!1;throw new p(p.INVALID_PARAMETER,"composite rendition type not supported: "+e);}return!0;}},{key:"_setRenditionFromPath",value:function(e,t,n,i){var o=this;if(!v.checkDeletedState(this,i)){var r=this._dcxCompositeRenditionMap[e],a=t&&this._services.getFileNameFromPath(t),s=this._services.fileUtils.getFileExtension(a),c=this._services.uuid()+"."+s;this._services.fileUtils.checkFileSize(t,function(s){s?i(s):o._storageInterface.notifyStartWrite(o,[],function(){o._dcxBranch.addComponent(a,n,"rendition",c,t,!0,void 0,o._dcxNode,void 0,function(t,n){t?i(t):v.checkDeletedState(o,i)||(n.setValue(o._config.MODIFIED_KEY,Date.now()),n.setValue(o._config.RENDITION_TYPE_KEY,e),r&&o._dcxBranch.removeComponent(r),o._dcxCompositeRenditionMap=v.getCompositeRenditionMap(o._dcxBranch),o._commit(),i(null));});});});}}},{key:"_setRendition",value:function(e,t,n,i,o){var r,a=this,s=this._services.fs,c=function(t){t?o(y.getCommitError(t,a.id,"error writing library rendition")):v.checkDeletedState(a,o)||a._setRenditionFromPath(e,r,i,o);},l=this.collection._getTempDir();this._services.fileUtils.ensurePathExists(l,function(e){if(e)o(y.getCommitError(e,a.id,"error creating temp directory"));else if(!v.checkDeletedState(a,o)){var u=g.getExtensions(i)[0],_=a._services.uuid()+"."+u;r=l+a._services.getPathSeparator()+_,"buffer"===n?s.writeFile(r,t,c):s.writeFile(r,t,n,c);}});}},{key:"_setRenditionInBrowser",value:function(e,t,n,i){var o=this,r=this._dcxCompositeRenditionMap[e],a=this._collection._syncManager,s=this._services.uuid();a.uploadNewComponentForLibrary(t,s,n,"rendition",this,function(t,n){t?i(t):v.checkDeletedState(o,i)||(n.setValue(o._config.MODIFIED_KEY,Date.now()),n.setValue(o._config.RENDITION_TYPE_KEY,e),r&&o._dcxBranch.removeComponent(r),o._dcxCompositeRenditionMap=v.getCompositeRenditionMap(o._dcxBranch),o._commit(),i(null));});}},{key:"_doCreateGroup",value:function(e,t,n){var i=this._getTopLevelNode(this._config.GROUPS_NAME),o=this._dcxBranch.addChild(e,void 0,void 0,i);o.type=this._config.GROUP_TYPE,o.setValue(this._config.CLASSIFIER_KEY,n),o.setValue(this._config.ORDER_KEY,t);var r=new _(this,o);return r._updateCreatedTime(),this._groups.add(r),r;}},{key:"_doRemoveGroup",value:function(e,t){this._groups.delete(e),this._elements.filter(function(t){return void 0!==t.getOrderInGroup(e);}).forEach(function(n){n._doSetOrderInGroup(e,void 0,!0),t&&t(n);}),this._dcxBranch.removeChild(e._dcxNode),e._markDeletedLocally(!0);}},{key:"_getNumberOfElementsInGroup",value:function(e){if(e){var t=0,n=function(n){return void 0!==n.getOrderInGroup(e)&&t++;};return this._elements.forEach(n),this._documentationElements.forEach(n),t;}}},{key:"_doCopyGroup",value:function(e,t,n,i,o){var r=e.library!==t&&t._groups.every(function(t){return t.id!==e.id;})?e.id:this._services.uuid();this._doCopyDCXGroup(e,t,n,i,r,o);}},{key:"_doCopyDCXGroup",value:function(e,t,n,i,o,r){var a=this;t._beginOperation(),i&&this._beginOperation();var s=function(e){t._endOperation(),i&&a.endOperation(),r(e);};this._storageInterface.notifyStartWrite(t,[this],function(){var c=t._getTopLevelNode(a._config.GROUPS_NAME);t._dcxBranch.copyChild(e._dcxNode,c,void 0,o,o,function(o,c){if(!v.checkDeletedState(a,r))if(o)s(o);else{var l=new _(t,c);t._groups.add(l);var u=function(){v.checkDeletedState(a,r)||(t._endOperation(),i&&(a._doRemoveGroup(e),a.endOperation()),r(null,l));};if(n){var h=e.elements,p=O(a._doCopyElement.bind(a));Promise.all(h.map(function(e){return p(e,t,i);})).then(function(t){h.forEach(function(n,i){var o=n.getOrderInGroup(e),r=t[i];r._doSetOrderInGroup(l,o,!0),a._analytics.reportCopyElement(r,n);}),u();}).catch(s);}else u();}});});}},{key:"_doCreateElement",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=this._dcxBranch.addChild(e,void 0,void 0,this._getTopLevelNode(this._config.ELEMENTS_NAME));i.path=i.id,i.type=t;var o=new h(this,i,n);o._updateCreatedTime();var r=n?this._documentationElements:this._elements;return r.add(o),o;}},{key:"_doRemoveElement",value:function(e,t){this._elements.delete(e),this._documentationElements.delete(e),this._removedElements.delete(e),t&&this._dcxBranch.removeChild(e._dcxNode),e._markDeletedLocally(!0);}},{key:"_ensureRemovedElementsSpace",value:function(){for(;this._removedElements.size>=this._config.MAX_REMOVED_ELEMENTS;){var e=this._removedElements.reduce(function(e,t){return e&&e.removed<=t.removed?e:t;});this._doRemoveElement(e,!0);}}},{key:"_doMarkElementRemoved",value:function(e,t){this._elements.has(e)&&(this._ensureRemovedElementsSpace(),this._elements.delete(e),this._removedElements.add(e),t&&(e._dcxNode=this._dcxBranch.moveChild(e._dcxNode,void 0,this._getTopLevelNode(this._config.REMOVED_ELEMENTS_NAME)),e._updateTimestampOnRemove()));}},{key:"_doRestoreElement",value:function(e,t){this._removedElements.has(e)&&(this._removedElements.delete(e),this._elements.add(e),t&&(e._dcxNode=this._dcxBranch.moveChild(e._dcxNode,void 0,this._getTopLevelNode(this._config.ELEMENTS_NAME)),e._updateTimestampOnRestore(),e._stripObsoleteGroupsData()));}},{key:"_doCopyDCXNode",value:function(e,t,n,i,o){var r=this;if(this._numActiveCopyNodeOperations<this._config.MAX_DCX_CONCURRENT_COPIES)return this._numActiveCopyNodeOperations++,void e.copyChild(t,n,void 0,i,i,function(e,t){r._numActiveCopyNodeOperations--,o(e,t),r._pendingCopyNodeOperations.length>0&&r._pendingCopyNodeOperations.shift()();});this._pendingCopyNodeOperations.push(function(){return r._doCopyDCXNode(e,t,n,i,o);});}},{key:"_doCopyDCXElement",value:function(e,t,n,i,o){var r=this;t._beginOperation(),this._storageInterface.notifyStartWrite(t,[this],function(){var a=t._getTopLevelNode(e.isDocumentationElement?r._config.DOCUMENTATION_ELEMENTS_NAME:r._config.ELEMENTS_NAME);r._doCopyDCXNode(t._dcxBranch,e._dcxNode,a,i,function(i,a){if(!v.checkDeletedState(r,o)){if(i)return t._endOperation(),void o(i);var s=new h(t,a,e.isDocumentationElement);(e.isDocumentationElement?t._documentationElements:t._elements).add(s),s._stripObsoleteGroupsData();var c=function(){v.checkDeletedState(r,o)||(t._endOperation(),n&&r._wrapOperation(function(){return r._doRemoveElement(e,!0);}),o(null,s));};r._services.hasFileSystem()?t._renditionCache.copyCache(e,s).then(c,c):c();}});});}},{key:"_doCopyElement",value:function(e,t,n,i){if(e.isDocumentationElement&&t._documentationElements.size>=this._config.MAX_DOCUMENTATION_ELEMENTS)i(new p(p.EXCEEDS_MAX_LIBRARY_SIZE,"Library cannot have more than ".concat(this._config.MAX_DOCUMENTATION_ELEMENTS," documentation elements"),this.id));else if(t._elements.size>=this._config.MAX_ELEMENTS)i(new p(p.EXCEEDS_MAX_LIBRARY_SIZE,"Library cannot have more than ".concat(this._config.MAX_ELEMENTS," elements"),this.id));else{var o=e.id;!t._elements.getItemById(o)&&!t._removedElements.getItemById(o)&&!t._documentationElements.getItemById(o)||(o=this._services.uuid()),this._doCopyDCXElement(e,t,n,o,i);}}},{key:"jasmineToString",value:function(){return this.toString();}},{key:"toString",value:function(){return JSON.stringify(this._toJSON());}},{key:"_setSyncState",value:function(e){this._syncState!==e&&(this._syncState=e,this._collection._updateSyncState(),this._checkSyncFinishedAndNotify());}},{key:"_isSyncing",value:function(){return void 0!==this._syncState;}},{key:"_checkSyncFinishedAndNotify",value:function(){if(!this._isSyncing()){var e=this._waitForSyncToFinishCallbacks;this._waitForSyncToFinishCallbacks=[],e.forEach(function(e){return e();});}}},{key:"_waitForSyncToFinish",value:function(e){this._waitForSyncToFinishCallbacks.push(e),this._checkSyncFinishedAndNotify();}},{key:"_getClientData",value:function(){var e={};if(this._dcxComposite.clientDataString)try{e=JSON.parse(this._dcxComposite.clientDataString);}catch(e){}return e;}},{key:"_getClientDataValue",value:function(e){return this._getClientData()[e];}},{key:"_setClientDataValue",value:function(e,t){var n=this._getClientData();n[e]=t,this._dcxComposite.clientDataString=JSON.stringify(n);}},{key:"_setCollaboration",value:function(e){var t=e&&e.collaboration&&e.collaboration.toLowerCase();if(this.collaboration!==t){var n=v.collaborationStateToDCX(t);this._dcxComposite.collaborationType=n,this._commit(!0,!0),this._notifyChange(),this._revertLocalChangesIfNecessary();}}},{key:"_setAssetId",value:function(e){e&&this._dcxComposite.assetId!==e&&(this._dcxComposite.assetId=e,this._commit(!0,!0));}},{key:"_isDeletedError",value:function(e){var t=e&&(e.code===l.NO_COMPOSITE||e.code===l.DELETED_COMPOSITE),n=e&&e.code===l.UNEXPECTED_RESPONSE&&e.response&&401===e.response.statusCode;return t||this.collection.isPublic&&n;}},{key:"_isAlreadyExistsError",value:function(e){var t=e&&e.code===l.ALREADY_EXISTS,n=e&&e.code===l.UNEXPECTED_RESPONSE&&e.response&&409===e.response.statusCode;return t||n;}},{key:"_isReadOnlyError",value:function(e){if(!this._collection.isCollaborated)return!1;var t=!1;return!e||e.code!==l.COMPONENT_UPLOAD_ERROR&&e.code!==l.UNEXPECTED_RESPONSE||(e.code===l.UNEXPECTED_RESPONSE&&e.response&&403===e.response.statusCode&&(t=!0),e.code===l.COMPONENT_UPLOAD_ERROR&&Array.isArray(e.failedComponents)&&e.failedComponents.length>0&&(t=!0,e.failedComponents.forEach(function(e){e.error&&e.error.code===l.UNEXPECTED_RESPONSE&&e.error.response&&403===e.error.response.statusCode||(t=!1);}))),t;}},{key:"_simpleFieldMerge",value:function(e,t,n,i,o){var r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:[],a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:function(e){return e;},s=t.getValue(e),c=n&&n.getValue(e),l=i&&i.getValue(e),u=a(l);if(u!==a(s))o.setValue(e,s),r.forEach(function(e){return o.setValue(e,t.getValue(e));});else if(u!==a(c))return o!==n&&(o.setValue(e,c),r.forEach(function(e){return o.setValue(e,n.getValue(e));})),!0;return!1;}},{key:"_mergeAndSwitchToBranch",value:function(e,t,n){var i=this,o=void 0!==t,r=e.localData,a=function(t,a){if(!v.checkDeletedState(i,n))if(t)n(y.getCommitError(t,i.id));else{i._services.log("Starting merge "+(o?"(local)":"(remote)"));var s={},c=function(e){return s[e]=(s[e]||0)+1;};a.name!==i.name&&(e.name=i.name);var l=i._config.MODIFIED_KEY,u=a.rootNode.getValue(l)||0,p=e.rootNode.getValue(l)||0,d=i.modified;if(d!==u){var f=p===u?d:Math.max(d,p)+1;e.rootNode.setValue(l,f);}i._simpleFieldMerge(i._config.DOCUMENT_ID_KEY,i._dcxNode,e.rootNode,a.rootNode,e.rootNode),i._simpleFieldMerge(i._config.DOCUMENT_TYPE_KEY,i._dcxNode,e.rootNode,a.rootNode,e.rootNode);var m=function(e){var t={};return v.getCustomDCXData(e.rootNode).forEach(function(e){t[e.namespace+"#"+e.key]=e.value;}),t;},g={},E=m(i._dcxBranch),O=m(a),S=m(e);Object.keys(E).forEach(function(t){g[t]=!0,JSON.stringify(E[t])!==JSON.stringify(O[t])&&e.rootNode.setValue(t,E[t]);}),Object.keys(S).forEach(function(t){g[t]||O[t]&&!E[t]&&e.rootNode.removeValue(t);});var A=v.getCompositeRenditionMap(e),T=v.getCompositeRenditionMap(a);Object.keys(i._dcxCompositeRenditionMap).forEach(function(t){var n=i._dcxCompositeRenditionMap[t],o=T[t],r=A[t];o&&n.id===o.id||(r?(n.getValue(i._config.MODIFIED_KEY)||0)>(r.getValue(i._config.MODIFIED_KEY)||0)&&(e.removeComponent(r),e.copyComponent(n,e.rootNode)):e.copyComponent(n,e.rootNode));}),Object.keys(T).forEach(function(t){var n=i._dcxCompositeRenditionMap[t],o=T[t],r=A[t];!n&&r&&r.id===o.id&&e.removeComponent(r);});var b={};e.getChildrenOf().forEach(function(e){return b[e.name]=e;});var L=function(t){return b[t]||(b[t]=e.addChild(t)),b[t];};L(i._config.ELEMENTS_NAME);var I=[],P={},R=[],C=function(e,t,n,o){return[i._simpleFieldMerge("name",t,n,o,e._dcxNode,[i._config.LOCALIZED_NAME_KEY]),i._simpleFieldMerge(i._config.ORDER_KEY,t,n,o,e._dcxNode),i._simpleFieldMerge(i._config.PARENT_KEY,t,n,o,e._dcxNode)].some(function(e){return e;});};i._groups.forEach(function(t){var n=t.id,o=t._dcxNode,r=t.modified,s=e.getChildWithId(n),l=s&&s.getValue(i._config.MODIFIED_KEY),u=a&&a.getChildWithId(n),_=u&&u.getValue(i._config.MODIFIED_KEY);if(!_&&!l||_&&!l&&r!==_){c("g1: group created locally");var h=e.copyChild(o,L(i._config.GROUPS_NAME),void 0,void 0,void 0);t._setDCXNode(h);}else _&&!l&&r===_?(c("g2: group deleted on server"),R.push(t)):_===r&&_===l?(c("g3: no changes to group modified time"),t._setDCXNode(s),C(t,o,s,u)&&I.push(t)):_===r&&_!==l?(c("g4: updated group on server"),t._setDCXNode(s),I.push(t),C(t,o,s,u)):_!==r&&_===l?(c("g5: updated group locally"),t._setDCXNode(e.replaceChild(o,void 0,void 0)),C(t,o,s,u)&&I.push(t)):_!==r&&_!==l?(c("g6: updated group locally and on server (conflict)"),t._setDCXNode(e.replaceChild(o,void 0,void 0)),C(t,o,s,u)&&I.push(t)):i._services.log("ERROR: unexpected group merge case: base="+_+", current="+r+", pulled="+l);P[n]=!0;}),R.forEach(function(e){return i._doRemoveGroup(e);});var N=[],D=[],w=[],k=[],x=[],M=function(t){var n=t.id,r=t._dcxNode,s=t.modified,l=t.removed,u=e.getChildWithId(n),_=u&&u.getValue(i._config.MODIFIED_KEY),p=u&&u.getValue(i._config.REMOVED_KEY),d=a&&a.getChildWithId(n),f=d&&d.getValue(i._config.MODIFIED_KEY),m=d&&d.getValue(i._config.REMOVED_KEY);i._dcxBranch=e;var v=function(){return t.isDocumentationElement?L(i._config.DOCUMENTATION_ELEMENTS_NAME):L(l?i._config.REMOVED_ELEMENTS_NAME:i._config.ELEMENTS_NAME);},y=function(){return!l&&t.removed?(w.push(t),!0):!(!l||t.removed||(k.push(t),0));},g=function(){var e=[i._simpleFieldMerge("name",r,u,d,t._dcxNode,[i._config.AUTO_NAMED_KEY,i._config.LOCALIZED_NAME_KEY]),i._simpleFieldMerge("tags",r,u,d,t._dcxNode),i._simpleFieldMerge(i._config.SOURCE_REF_KEY,r,u,d,t._dcxNode),i._simpleFieldMerge(i._config.DEPENDENCIES_KEY,r,u,d,t._dcxNode,[],function(e){return JSON.stringify(e);})].some(function(e){return e;}),n=r.getValue(i._config.DESCRIPTION_DATA_KEY)||{time:0},o=u&&u.getValue(i._config.DESCRIPTION_DATA_KEY)||{time:0},a=d&&d.getValue(i._config.DESCRIPTION_DATA_KEY)||{time:0};if(n.time!==a.time){var s=r.getValue(i._config.DESCRIPTION_KEY);t._dcxNode.setValue(i._config.DESCRIPTION_KEY,s),t._dcxNode.setValue(i._config.DESCRIPTION_DATA_KEY,n);}else o.time!==a.time&&(e=!0);var c=r.getValue(i._config.GROUPS_KEY)||{},l=u&&u.getValue(i._config.GROUPS_KEY)||{},_=d&&d.getValue(i._config.GROUPS_KEY)||{},h={};return Object.keys(c).forEach(function(t){var n=c[t],i=l[t],o=_[t];o&&n.order===o.order?i||(e=!0):h[t]=n;}),Object.keys(l).forEach(function(t){var n=c[t],i=l[t],o=_[t];o&&!n||h[t]||(h[t]=i,o&&i.order===o.order||(e=!0));}),(Object.keys(h).length>0||Object.keys(l).length>0)&&JSON.stringify(l)!==JSON.stringify(h)&&t._dcxNode.setValue(i._config.GROUPS_KEY,h),e;};if(!f&&!_||f&&!_&&s!==f){c("e1: created element locally");var E=e.copyChild(r,v(),void 0,void 0,void 0);t._setDCXNode(E,!0);}else if(f&&!_&&s===f)c("e2: deleted element on server"),D.push(t);else if(f===s&&f===_){c("e3: no changes to element modified time"),t._setDCXNode(u,!0),m!==l&&(m===p?l&&!p?(c("e3a: removed element locally"),t._dcxNode=e.moveChild(t._dcxNode,void 0,L(i._config.REMOVED_ELEMENTS_NAME)),t._updateTimestampOnRemove(l)):p&&!l&&(c("e3b: restored element locally"),t._dcxNode=e.moveChild(t._dcxNode,void 0,L(i._config.ELEMENTS_NAME)),t._updateTimestampOnRestore()):l||(c("e3c: remove/restore element conflict - local restore wins"),t._dcxNode=e.moveChild(t._dcxNode,void 0,L(i._config.ELEMENTS_NAME)),t._updateTimestampOnRestore()));var O=y(),S=g();(O||S)&&I.push(t),t._ensureRemovedDataValid(o&&!i._config.SHARED_LOCAL_STORAGE);}else if(f===s&&f!==_)c("e4: updated element on server"),t._setDCXNode(u,o),I.push(t),y(),g(),t._ensureModifiedDataValid(o&&!i._config.SHARED_LOCAL_STORAGE);else if(f!==s&&f===_){c("e5: updated element locally");var A=e.replaceChild(r,void 0,void 0);t._setDCXNode(A,!0),(l&&!p||p&&!l)&&(t._dcxNode=e.moveChild(t._dcxNode,void 0,v())),g()&&I.push(t);}else if(f!==s&&f!==_){c("e6: updated element locally and on server (conflict)"),t._setDCXNode(u),I.push(t),y(),t._ensureModifiedDataValid(o&&!i._config.SHARED_LOCAL_STORAGE);var T=i._services.uuid(),b=e.copyChild(r,v(),void 0,T,T),R=new h(i,b,t.isDocumentationElement);N.push(R),P[R.id]=!0,i._services.hasFileSystem()&&x.push(function(e){return i._renditionCache.copyCache(t,R).then(e,e);}),i._analytics.reportCollisionElement(t);}else i._services.log("ERROR: unexpected element merge case: base="+f+", current="+s+", pulled="+_);i._dcxBranch=i._dcxComposite.current,P[n]=!0;};i._elements.forEach(M),i._documentationElements.forEach(M),i._removedElements.forEach(M);var H=function(e){(e.isDocumentationElement?i._documentationElements:e.removed?i._removedElements:i._elements).add(e);};N.forEach(H),D.forEach(function(e){return i._doRemoveElement(e,!1);}),w.forEach(function(e){return i._doMarkElementRemoved(e,!1);}),k.forEach(function(e){return i._doRestoreElement(e,!1);}),i._dcxBranch=e,i._dcxTopLevelNodes=b,i._dcxCompositeRenditionMap=v.getCompositeRenditionMap(e),Object.keys(i._dcxTopLevelNodes).forEach(function(t){var n=i._dcxTopLevelNodes[t];n&&i._dcxBranch.getChildrenOf(n).forEach(function(n){return function(t,n){if(!P[t.id]){var r=t.getValue(i._config.MODIFIED_KEY),s=a&&a.getChildWithId(t.id),l=s&&s.getValue(i._config.MODIFIED_KEY);if(l&&r&&l===r)c(n===i._config.GROUPS_NAME?"g7: deleted group locally":"e7: deleted element locally"),e.removeChild(t);else if(c(n===i._config.GROUPS_NAME?"g8: created group on server":"e8: created element on server"),n===i._config.GROUPS_NAME){var u=new _(i,t);i._groups.add(u);}else{var p=new h(i,t,n===i._config.DOCUMENTATION_ELEMENTS_NAME);H(p),p._ensureCreatedDataValid(o&&!i._config.SHARED_LOCAL_STORAGE);}}}(n,t);});}),Object.keys(s).sort().forEach(function(e){var t=s[e];i._services.log("Merge Case ".concat(e," (").concat(t,")"));}),v.ensureBranchDataValid(e),i._transactionCount++,Promise.all(x.map(function(e){return new Promise(function(t){return e(t);});})).then(function(){v.checkDeletedState(i,n)||(i._transactionCount--,i._storageInterface.resolvePullWithBranch(i,e,r,o,function(t){v.checkDeletedState(i,n)||(t?n(y.getCommitError(t,i.id)):(i._services.hasFileSystem()||(i._dcxBaseBranch=e.copy()),i._config.SHARED_LOCAL_STORAGE||o||i._prefetchRenditions(),n(null),I.forEach(function(e){return e._listenerManager.notify("change");}),i._notifyChange()));}));});}};this._waitForCommit(function(){v.checkDeletedState(i,n)||(t?a(null,t):"unmodified"===i._dcxBranch.compositeState?a(null,i._dcxBranch):i._loadBaseBranch(a));});}},{key:"_updateMetadata",value:function(e){var t=this,n=function(n){v.checkDeletedState(t,e)||(n&&t._collection._reportSyncError(n),t._networkLock.release(),e(n));};this._networkLock.obtain(function(i){i?e(null):v.checkDeletedState(t,e)||t._collection._syncManager.updateCompositeMetadata(t.id,t._dcxComposite,function(i,o){return i?t._isDeletedError(i)?void(t._services.hasFileSystem()&&"modified"===t._dcxBranch.compositeState&&t._collection.isPrivate?(t._doRebindToServer(!1,e),t._networkLock.release()):(t._deletedFromServer=!0,t._notifyChange(),n())):n(new p(p.NETWORK_ERROR,"Unable to update library metadata",t.id,i)):(o&&t._notifyChange(),n());});});}},{key:"_pull",value:function(e){var t=this;if(this._dcxComposite.href&&this._dcxBranch.isBound){if(this._deletedFromServer)e(null,!1);else{var n=function(n,i){v.checkDeletedState(t,e)||(n&&t._collection._reportSyncError(n),t._setSyncState(),t._networkLock.release(),e(n,i));};this._networkLock.obtain(function(i){i?e(null):v.checkDeletedState(t,e)||(t._setSyncState("downloading"),t._collection._syncManager.pullLibrary(t,function(i,o){v.checkDeletedState(t,e)||(t._isDeletedError(i)?t._services.hasFileSystem()&&"modified"===t._dcxBranch.compositeState&&t._collection.isPrivate?(t._doRebindToServer(!1,e),t._networkLock.release()):(t._deletedFromServer=!0,t._notifyChange(),n(null,!0)):i?n(y.getSyncError(i,t.id)):o?t._mergeAndSwitchToBranch(o,void 0,function(i){v.checkDeletedState(t,e)||n(i,!0);}):n(null,!1));}));});}}else e(null,!1);}},{key:"_pushWithParameters",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},i=!this._dcxComposite.isBound,o=function(e,o){n(null,o),t.collection._onLibraryPush&&t.collection._onLibraryPush(t,i&&o);};if(this._config.SYNCING_ENABLED){if(this._collection._retryTimeoutId)o(null,!1);else if(this._dcxBranch.isBound&&"modified"!==this._dcxBranch.compositeState)o(null,!1);else if(this._deletedFromServer)o(null,!1);else if(this.isWritable){if(this._pushPending)o(null,!1);else{var r=function(e,i){v.checkDeletedState(t,o)||(t._pushFailedDueToQuota=!1,e&&(t._collection._reportSyncError(e),e.code===p.EXCEEDS_QUOTA&&(t._pushFailedDueToQuota=!0)),t._setSyncState(),t._collection._syncManager.pullMissingComponents(t,function(){v.checkDeletedState(t,n)||(t._networkLock.release(),t._prefetchRenditions(),o(null,i));}));};this._pushPending=!0,this._networkLock.obtain(function(n){n?o(null,!1):t._waitForCommit(function(){var n;v.checkDeletedState(t,o)||(t._pushPending=!1,t._services.hasFileSystem()||(n=t._dcxBranch.copy()),t._setSyncState("uploading"),t._collection._syncManager.pushLibrary(t,e,function(e){if(!v.checkDeletedState(t,o))if(t._isDeletedError(e))t._services.hasFileSystem()&&"modified"===t._dcxBranch.compositeState&&t._collection.isPrivate?(t._doRebindToServer(!1,o),t._networkLock.release()):(t._deletedFromServer=!0,t._notifyChange(),r(null,!0));else{if(t._isAlreadyExistsError(e)){var i=t._localisation.translate("LIBS_RECOVERED_LIBRARY",{name:""}),a=t._collection._recoveredLibraryCount>t._config.MAX_RECOVERED_LIBRARIES;if(t._getRawName().endsWith(i)||a){var s=a?"count exceeded":"already recovered";return t._services.log("Failed to recover library ".concat(s,": ").concat(t.id)),void r(y.getSyncError(e,t.id));}return t._setName(t._localisation.translate("LIBS_RECOVERED_LIBRARY",{name:t._getRawName()})),t._services.log("Recovering library due to 409 error: ".concat(t.id)),t._collection._recoveredLibraryCount++,t._doRebindToServer(!0,o),void t._networkLock.release();}if(t._isReadOnlyError(e))return t._services.log("Push failed due to read only. Reverting: "+t.id),t._dcxComposite.isWritable=!1,void t._revertLocalChangesIfNecessary(function(e){return r(e,!1);});if(e&&e.code===p.TRANSFER_ABORTED)r(null,!0);else{if(e&&e.code===l.UPDATE_CONFLICT){if(t._services.log("Push failed due to conflict: "+t.id),t._numUpdateConflicts++,t._numUpdateConflicts<=t._config.MAX_UPDATE_CONFLICTS)return t._sync(!1,o),void t._networkLock.release();t._analytics.reportUnexpectedState(t,"updateConflict"),t._services.log("Reached maximum number of update-conflict retries: "+t.id);}t._numUpdateConflicts=0,e&&e.code===l.COMPONENT_UPLOAD_ERROR&&(t._services.log("Push failed due to component upload failure: "+t.id),v.fixLocalComponents(t,e.failedComponents)),e?r(y.getSyncError(e,t.id)):t._storageInterface.acceptPush(t,function(e){v.checkDeletedState(t,o)||(e?r(y.getCommitError(e,t.id),!0):(t._services.hasFileSystem()||(t._dcxBaseBranch=n),r(null,!0)));});}}}));});});}}else o(null,!1);}else o(null,!1);}},{key:"_loadBaseBranch",value:function(e){var t=this;this._services.hasFileSystem()?this._dcxComposite.loadBaseBranch(function(n,i){t._waitForCommit(function(){return e(n,i);});}):e(null,this._dcxBaseBranch);}},{key:"_revertLocalChangesIfNecessary",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};this.isWritable||"modified"!==this._dcxBranch.compositeState?t(null):this._loadBaseBranch(function(n,i){e._transactionCount++,v.recoverReadOnlyEdits(e,i,function(n){n&&e._services.log("Error recovering library changes: "+n),e._transactionCount--;var o=i.copy(),r=e.collaboration,a=e._dcxComposite.isWritable;e._mergeAndSwitchToBranch(o,e._dcxBranch,function(n){if(n)e._services.log("Error Reverting: "+e.id),t(n);else{var i=v.collaborationStateToDCX(r);e._dcxComposite.collaborationType=i,e._dcxComposite.isWritable=a,e._commit(!0,!0),e._waitForCommit(function(){e._notifyChange(),t(null);});}});});});}},{key:"_push",value:function(e){this._pushWithParameters(!1,e);}},{key:"_abortPushOrPull",value:function(){this._networkLock.abortPendingOperations(new p(p.TRANSFER_ABORTED)),this._collection._syncManager.abortPushOrPull(this.id);}},{key:"_deleteFromServer",value:function(e,t){var n=this;if(this._deletingFromServerInProgress||this._abortPushOrPull(),this._dcxComposite.href){if(this._deletedFromServer)t(null);else{this._deletingFromServerInProgress=!0;var i=function(e){n._deletingFromServerInProgress=!1,n._setSyncState(),n._networkLock.release(),t(e);};this._networkLock.obtain(function(o){o?t(null):n._deletedFromDisk?i(null):(n._setSyncState("uploading"),n._collection._prepareCompositeForDelete(n._dcxComposite),n._commit(!0,!0),n._waitForCommit(function(){n._deletedFromDisk?i(null):n._collection._syncManager.pushDeletedLibrary(n,n.collaboration,e,function(t){t?n._isDeletedError(t)?(n._deletedFromServer=!0,t=null):(e||t.code!==l.UPDATE_CONFLICT)&&(t=y.getSyncError(t,n.id),n._collection._reportSyncError(t)):n._deletedFromServer=!0,i(t);});}));});}}else t(null);}},{key:"_doRebindToServer",value:function(e,t){var n=this;this._deletedFromServer=!1;var i=e||"incoming"===this.collaboration?"resetIdentity":"resetBinding",o=this.id;this._dcxComposite[i](function(e){v.checkDeletedState(n,t)||(e?t(e):(n._transactionCount++,n.id!==o&&(n._collection._libraryIdMap[n.id]=n,delete n._collection._libraryIdMap[o]),n._services.fileUtils.moveLibrary(n,o,function(e){v.checkDeletedState(n,t)||(n._transactionCount--,e?t(e):(n._collection._prepareCompositeForPush(n._dcxComposite),n._setCollaboration(),n._commit(!1,!0),n._pushWithParameters(!0,t)));})));});}},{key:"_sync",value:function(e,t){var n=this,i=function(e,i){t&&n._waitForSyncToFinish(function(){return t(e,i);});};if(!this._config.SHARED_LOCAL_STORAGE&&this._config.SYNCING_ENABLED){if(this._collection._retryTimeoutId)i(null,!1);else{this._collection._clearSyncErrors(this.id);var o=function(e,t){v.checkDeletedState(n,i)||(e?i(e,t):n._push(function(e,o){v.checkDeletedState(n,i)||i(e,t||o);}));};e?o(null,!1):this._pull(o);}}else i(null,!1);}},{key:"_getCompositeDir",value:function(){return this._collection._getCompositeDir(this.id);}},{key:"_getRenditionCacheDir",value:function(){return this._collection._getRenditionCacheDir(this.id);}},{key:"_setAutoGC",value:function(e,t){!1===t?this._autoGCMode[e]=!1:delete this._autoGCMode[e],this._dcxComposite.autoRemoveUnusedLocalFiles=0===Object.keys(this._autoGCMode);}},{key:"_prefetchRenditions",value:function(){return this._services.hasFileSystem()?Promise.all(this._elements.map(function(e){return e._prefetchRenditions();})):Promise.resolve();}},{key:"_getActions",value:function(e){if(!this.documentType)return[];var t=this._config.DOCUMENT_LIBRARY_ACTION_PRODUCT_MAP,n=t.types[this.documentType]||[];return this._constructActions(e,n,t,d);}},{key:"getGroups",value:function(e){return e=e||this._config.DEFAULT_GROUP_CLASSIFIER,this._groups.filter(function(t){return e instanceof RegExp?e.test(t.classifierName):e===t.classifierName;});}},{key:"getGroupById",value:function(e){return this._groups.getItemById(e);}},{key:"createGroup",value:function(e,t,n){if(n=n||this._config.DEFAULT_GROUP_CLASSIFIER,v.checkDeletedState(this),!this.isWritable)throw new p(p.NOT_ALLOWED,"you do not have write access to this library",this.id);var i=this._doCreateGroup(e,t,n);return this._commit(),this._analytics.reportCreateGroup(i),i;}},{key:"removeGroup",value:function(e,t,n){var i=this;if(v.checkDeletedState(this),!this.isWritable)throw new p(p.NOT_ALLOWED,"you do not have write access to this library",this.id);if(!e)throw new p(p.INVALID_PARAMETER,"No group specified",this.id);if(!this._groups.has(e))throw new p(p.INVALID_PARAMETER,"group not in this library",this.id);var o=0;this._doRemoveGroup(e,function(e){t?(i.removeElement(e,n),o++):e._listenerManager.notify("change");}),this._commit(),this._analytics.reportDeleteGroup(e,t,o);}},{key:"moveGroup",value:function(e,t,n,i){var o=this;if(!v.checkDeletedState(this,i))if(this.isWritable){if(e){if(this._groups.has(e)){if(t){if(this!==t){if(t.isWritable){var r=n?this._getNumberOfElementsInGroup(e):void 0;return this._doCopyGroup(e,t,n,!0,function(t,a){t?i(t):(o._analytics.reportMoveGroup(a,e,n,r),i(null,a));});}i(new p(p.NOT_ALLOWED,"you do not have write access to the destination library",t.id));}else i(new p(p.INVALID_PARAMETER,"Move must have a different destination library",this.id));}else i(new p(p.INVALID_PARAMETER,"No destination library specified",this.id));}else i(new p(p.INVALID_PARAMETER,"Group not in this library",this.id));}else i(new p(p.INVALID_PARAMETER,"No group specified",this.id));}else i(new p(p.NOT_ALLOWED,"you do not have write access to this library",this.id));}},{key:"copyGroup",value:function(e,t,n,i){var o=this;if(!v.checkDeletedState(this,i))if(e){if(this._groups.has(e)){if(t){if(t.isWritable){var r=n?this._getNumberOfElementsInGroup(e):void 0;return this._doCopyGroup(e,t,n,!1,function(t,a){t?i(t):(o._analytics.reportCopyGroup(a,e,n,r),i(null,a));});}i(new p(p.NOT_ALLOWED,"you do not have write access to the destination library",t.id));}else i(new p(p.INVALID_PARAMETER,"No destination library specified",this.id));}else i(new p(p.INVALID_PARAMETER,"Group not in this library",this.id));}else i(new p(p.INVALID_PARAMETER,"No group specified",this.id));}},{key:"createElement",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(v.checkDeletedState(this),!this.isWritable)throw new p(p.NOT_ALLOWED,"you do not have write access to this library",this.id);var o=((i=i&&t===this._config.COLOR_ELEMENT_TYPE)?2:1)*this._config.MAX_ELEMENTS;if(this._elements.size>=o)throw new p(p.EXCEEDS_MAX_LIBRARY_SIZE,"Library cannot have more than "+this._config.MAX_ELEMENTS+" elements",this.id);return this._wrapOperation(function(){var i=n._doCreateElement(e,t);return n._analytics.reportCreateElement(i),i.beginOperation(),i;});}},{key:"createDocumentationElement",value:function(e,t){var n=this;if(v.checkDeletedState(this),!this.isWritable)throw new p(p.NOT_ALLOWED,"you do not have write access to this library",this.id);if(this._elements.size>=this._config.MAX_DOCUMENTATION_ELEMENTS)throw new p(p.EXCEEDS_MAX_LIBRARY_SIZE,"Library cannot have more than "+this._config.MAX_DOCUMENTATION_ELEMENTS+" documentation elements",this.id);return this._wrapOperation(function(){var i=n._doCreateElement(e,t,!0);return n._analytics.reportCreateElement(i),i.beginOperation(),i;});}},{key:"removeElement",value:function(e,t){var n=this;if(v.checkDeletedState(this),!this.isWritable)throw new p(p.NOT_ALLOWED,"you do not have write access to this library",this.id);if(!e)throw new p(p.INVALID_PARAMETER,"No element specified",this.id);if(e.isDocumentationElement&&(t=!0),!this._elements.has(e)&&!this._documentationElements.has(e)){if(!this._removedElements.has(e))throw new p(p.INVALID_PARAMETER,"Element not in this library",this.id);if(!t)throw new p(p.INVALID_PARAMETER,"Element already removed",this.id);}return this._wrapOperation(function(){for(;e._transactionCount>0;)e.endOperation();t?n._doRemoveElement(e,!0):n._doMarkElementRemoved(e,!0),n._analytics.reportDeleteElement(e,t);});}},{key:"restoreElement",value:function(e){var t=this;if(v.checkDeletedState(this),!this.isWritable)throw new p(p.NOT_ALLOWED,"you do not have write access to this library",this.id);if(!e)throw new p(p.INVALID_PARAMETER,"No element specified",this.id);if(!this._removedElements.has(e)){if(!this._elements.has(e))throw new p(p.INVALID_PARAMETER,"Element not in this library",this.id);throw new p(p.INVALID_PARAMETER,"Element already restored",this.id);}if(this._elements.size>=this._config.MAX_ELEMENTS)throw new p(p.EXCEEDS_MAX_LIBRARY_SIZE,"Library cannot have more than "+this._config.MAX_ELEMENTS+" elements",this.id);return this._wrapOperation(function(){t._doRestoreElement(e,!0),t._analytics.reportRestoreElement(e);});}},{key:"copyElement",value:function(e,t,n){var i=this;if(!v.checkDeletedState(this,n))if(e){if(this._elements.has(e)||this._removedElements.has(e)||this._documentationElements.has(e)){if(t){if(t.isWritable)return this._doCopyElement(e,t,!1,function(t,o){t?n(t):(i._analytics.reportCopyElement(o,e),n(null,o));});n(new p(p.NOT_ALLOWED,"you do not have write access to the destination library",t.id));}else n(new p(p.INVALID_PARAMETER,"No destination library specified",this.id));}else n(new p(p.INVALID_PARAMETER,"Element not in this library",this.id));}else n(new p(p.INVALID_PARAMETER,"No element specified",this.id));}},{key:"moveElement",value:function(e,t,n){var i=this;if(!v.checkDeletedState(this,n))if(this.isWritable){if(e){if(this._elements.has(e)||this._removedElements.has(e)||this._documentationElements.has(e)){if(t){if(this!==t){if(t.isWritable)return this._doCopyElement(e,t,!0,function(t,o){t?n(t):(i._analytics.reportMoveElement(o,e),n(null,o));});n(new p(p.NOT_ALLOWED,"you do not have write access to the destination library",t.id));}else n(new p(p.INVALID_PARAMETER,"Move must have a different destination library",this.id));}else n(new p(p.INVALID_PARAMETER,"No destination library specified",this.id));}else n(new p(p.INVALID_PARAMETER,"Element not in this library",this.id));}else n(new p(p.INVALID_PARAMETER,"No element specified",this.id));}else n(new p(p.NOT_ALLOWED,"you do not have write access to this library",this.id));}},{key:"getValues",value:function(){return v.getCustomDCXData(this._dcxNode);}},{key:"setValue",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(v.checkDeletedState(this),!this.isWritable)throw new p(p.NOT_ALLOWED,"you do not have write access to this library",this.id);if(e===this._config.DL_NAMESPACE)throw new p(p.INVALID_PARAMETER,"Reserved namespace",this.id);var o,r=v.getDCXKey(e,t);try{o=JSON.parse(JSON.stringify(n));}catch(e){throw new p(p.INVALID_PARAMETER,"Value cannot be serialized to JSON",this.id);}this._dcxNode.setValue(r,o),this._commit(!1,i);}},{key:"getValue",value:function(e,t){if(e===this._config.DL_NAMESPACE)throw new p(p.INVALID_PARAMETER,"Reserved namespace",this.id);var n=v.getDCXKey(e,t);return this._dcxNode.getValue(n);}},{key:"removeValue",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(v.checkDeletedState(this),!this.isWritable)throw new p(p.NOT_ALLOWED,"you do not have write access to this library",this.id);if(e===this._config.DL_NAMESPACE)throw new p(p.INVALID_PARAMETER,"Reserved namespace",this.id);var i=v.getDCXKey(e,t);this._dcxNode.removeValue(i),this._commit(!1,n);}},{key:"linkToDocument",value:function(e,t){var n=this;if(v.checkDeletedState(this),!this.isWritable)throw new p(p.NOT_ALLOWED,"you do not have write access to this library",this.id);if(!e&&!t)return this._wrapOperation(function(){n._dcxNode.removeValue(n._config.DOCUMENT_ID_KEY),n._dcxNode.removeValue(n._config.DOCUMENT_TYPE_KEY);});if("string"!=typeof e||"string"!=typeof t)throw new p(p.INVALID_PARAMETER,"document id and type must be strings",this.id);this._wrapOperation(function(){n._dcxNode.setValue(n._config.DOCUMENT_ID_KEY,e),n._dcxNode.setValue(n._config.DOCUMENT_TYPE_KEY,t);});}},{key:"getActions",value:function(e){if(!this._config.SHARED_LOCAL_STORAGE)throw new p(p.NOT_SUPPORTED,"getActions() not supported without shared local storage");if(e&&-1===this._config.LIBRARY_ACTIONS.indexOf(e))throw new p(p.INVALID_PARAMETER,"Unknown id supplied. Potential ids are",this._config.LIBRARY_ACTIONS.join(", "));return this._getActions(e);}},{key:"getRenditionPath",value:function(e,t){var n=this;if(this._services.hasFileSystem()){if(!v.checkDeletedState(this,t)&&this._checkRenditionType(e,t)){var i=this._dcxCompositeRenditionMap[e];if(!i)return t(null);var o=this._dcxBranch.assetOfComponent(i);if(o)return t(null,o);this._networkLock.obtain(function(e){e?t(e):v.checkDeletedState(n,t)?n._networkLock.release():(n._setSyncState("downloading"),n._collection._syncManager.downloadComponent(n._dcxBranch,i,function(e){n._networkLock.release(),n._setSyncState(),e?t(y.getSyncError(e,n.id)):v.checkDeletedState(n,t)||(n._commit(!0,!0),t(null,n._dcxBranch.assetOfComponent(i)));}));});}}else t(new p(p.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this.id));}},{key:"getRenditionURL",value:function(e){v.checkDeletedState(this),this._checkRenditionType(e);var t=this._dcxCompositeRenditionMap[e];if(t)return this._collection._syncManager.getContentURL(t);}},{key:"getAuthenticatedRenditionURL",value:function(e,t){if(!v.checkDeletedState(this,t)&&this._checkRenditionType(e,t)){var n=this.getRenditionURL(e);if(!n)return t(null);this._collection._syncManager.appendAccessTokenToURL(n,t);}}},{key:"setRendition",value:function(e,t,n,i,o){if(!v.checkDeletedState(this,o)&&this._checkRenditionType(e,o))if(t){if(this.isWritable){if(this._services.hasFileSystem()){if(!v.checkEncoding(n,["utf8","ascii","base64","buffer"],o))return;this._setRendition(e,t,n,i,o);}else{if(void 0!==n)return void o(new p(p.INVALID_PARAMETER,"Encoding parameter not supported in-browser"));this._setRenditionInBrowser(e,t,i,o);}}else o(new p(p.NOT_ALLOWED,"you do not have write access to this library",this.id));}else o(new p(p.INVALID_PARAMETER,"content must exist",this.id));}},{key:"setRenditionFromPath",value:function(e,t,n,i){v.checkDeletedState(this,i)||this._checkRenditionType(e,i)&&("string"==typeof t?this._services.hasFileSystem()?this.isWritable?this._setRenditionFromPath(e,t,n,i):i(new p(p.NOT_ALLOWED,"you do not have write access to this library",this.id)):i(new p(p.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this.id)):i(new p(p.INVALID_PARAMETER,"path must be a string",this.id)));}},{key:"removeRendition",value:function(e){var t=this;if(v.checkDeletedState(this),this._checkRenditionType(e),!this.isWritable)throw new p(p.NOT_ALLOWED,"you do not have write access to this library",this.id);var n=this._dcxCompositeRenditionMap[e];if(n)return this._wrapOperation(function(){t._dcxBranch.removeComponent(n),t._dcxCompositeRenditionMap=v.getCompositeRenditionMap(t._dcxBranch);});}},{key:"beginOperation",value:function(){if(v.checkDeletedState(this),!this.isWritable)throw new p(p.NOT_ALLOWED,"you do not have write access to this library",this.id);this._beginOperation();}},{key:"endOperation",value:function(){if(v.checkDeletedState(this),!this.isWritable)throw new p(p.NOT_ALLOWED,"you do not have write access to this library",this.id);this._endOperation();}},{key:"sync",value:function(e){v.checkDeletedState(this,e)||this._sync(!1,e);}},{key:"rebindToServer",value:function(e){this._services.hasFileSystem()?v.checkDeletedState(this,e)||(this.isWritable?this._deletedFromServer?this._doRebindToServer(!1,e):e(null):e(new p(p.NOT_ALLOWED,"you do not have write access to this library",this.id))):e(new p(p.REQUIRES_FILESYSTEM,"rebindToServer requires a filesystem",this.id));}},{key:"getElementById",value:function(e,t){var n=this._elements.getItemById(e);return n||t?n:this._removedElements.getItemById(e);}},{key:"getElementsAndDependencies",value:function(e){var t=this,n={};return e.forEach(function(e){return function e(i){var o=t._elements.getItemById(i);o&&!n[i]&&(n[i]=o,(o._dcxNode.getValue(t._config.DEPENDENCIES_KEY)||[]).forEach(e));}(e.id);}),Object.keys(n).map(function(e){return n[e];});}},{key:"_updateStorageUsed",value:function(){var e=this._dcxComposite._current;if(e){var t=e._core._recursivelyGetAllComponentsOfChild(e.rootNode);this._storageUsed=t.reduce(function(e,t){return e+t.length;},0)+e.remoteData.length;}}},{key:"_services",get:function(){return this._collection._services;}},{key:"_config",get:function(){return this._collection._config;}},{key:"_analytics",get:function(){return this._collection._analytics;}},{key:"_storageInterface",get:function(){return this._collection._storageInterface;}},{key:"_localisation",get:function(){return this._collection._localisation;}},{key:"_dcxNode",get:function(){return this._dcxBranch.rootNode;}},{key:"id",get:function(){return this._publicId||this._dcxComposite.id;}},{key:"assetId",get:function(){return this._dcxComposite.assetId;}},{key:"localEtag",get:function(){return'"0x'.concat((1e4+this._dcxBranch.changeCount).toString(16),'"');}},{key:"collection",get:function(){return this._collection;}},{key:"isWritable",get:function(){return void 0===this._dcxComposite.isWritable?!this._publicId:this._dcxComposite.isWritable;}},{key:"isParentWritable",get:function(){return this._dcxComposite.isParentWritable;}},{key:"owner",get:function(){return this._dcxComposite.storageAssignee&&this._dcxComposite.storageAssignee.id;}},{key:"ownerType",get:function(){return this._dcxComposite.storageAssignee&&this._dcxComposite.storageAssignee.type;}},{key:"parentDirectoryId",get:function(){return this._dcxComposite.parentAssetId;}},{key:"isPushedToServer",get:function(){return this._dcxComposite.isBound;}},{key:"elements",get:function(){return this._elements.toArray();}},{key:"documentationElements",get:function(){return this._documentationElements.toArray();}},{key:"removedElements",get:function(){return this._removedElements.toArray();}},{key:"isDeletedFromServer",get:function(){return this._deletedFromServer;}},{key:"isDeletedLocally",get:function(){return this._deletedLocally;}},{key:"isQuotaExceeded",get:function(){return this._pushFailedDueToQuota;}},{key:"toolkitId",get:function(){return this.getValue(this._config.TOOLKIT_NAMESPACE,this._config.TOOLKIT_ID_KEY);}},{key:"documentId",get:function(){return this._dcxNode.getValue(this._config.DOCUMENT_ID_KEY);}},{key:"documentType",get:function(){return this._dcxNode.getValue(this._config.DOCUMENT_TYPE_KEY);}},{key:"collaboration",get:function(){var e=this._dcxComposite.collaborationType;return v.collaborationStateFromDCX(e);}},{key:"syncState",get:function(){return this._syncState;}},{key:"syncProgress",get:function(){var e=this._collection._syncProgressMap[this.id];return e&&e.progress;}},{key:"storageUsed",get:function(){return this._storageUsed||0;}}])&&o(n.prototype,u),S&&o(n,S),t;}(u);e.exports=S;},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._items=[],this._itemMap=new Map();}var t,i,o;return t=e,(i=[{key:"toArray",value:function(){return this._items;}},{key:"add",value:function(e,t){this.has(e)||(void 0!==t?this._items.splice(t,0,e):this._items.push(e),this._itemMap.set(e.id,e));}},{key:"delete",value:function(e){if(this._itemMap.get(e.id)){var t=this._items.indexOf(e);this._items.splice(t,1),this._itemMap.delete(e.id);}}},{key:"has",value:function(e){return void 0!==this._itemMap.get(e.id);}},{key:"getItemById",value:function(e){return this._itemMap.get(e);}},{key:"forEach",value:function(e){this._items.forEach(e);}},{key:"map",value:function(e){return this._items.map(e);}},{key:"reduce",value:function(e,t){return this._items.reduce(e,t);}},{key:"filter",value:function(e){return this._items.filter(e);}},{key:"find",value:function(e){return this._items.find(e);}},{key:"every",value:function(e){return this._items.every(e);}},{key:"some",value:function(e){return this._items.some(e);}},{key:"size",get:function(){return this._items.length;}}])&&n(t.prototype,i),o&&n(t,o),e;}();e.exports=i;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable;})),n.push.apply(n,i);}return n;}function r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach(function(t){a(e,t,n[t]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t));});}return e;}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e;}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}function c(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}(e):t;}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e);})(e);}function u(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function _(e,t,n){return t&&u(e.prototype,t),n&&u(e,n),e;}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e;})(e,t);}var p=n(84),d=n(85),f=n(41),m=n(2),v=["public","collab"],y=function(e){function t(e){var n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return s(this,t),(n=c(this,l(t).call(this,e._config.BOOKMARKS_FILENAME,e)))._disableSyncing=i.DISABLE_SYNCING,n._bookmarks=[],n._bookmarkData=[],n._queuedOperations=[],n;}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&h(e,t);}(t,e),_(t,null,[{key:"waitForPushNew",value:function(e){return{condition:"on_pushed_new",libraryId:e};}},{key:"waitForDelete",value:function(e){return{condition:"on_deleted",libraryId:e};}}]),_(t,[{key:"_toJSON",value:function(){return{version:this._config.BOOKMARKS_FILE_VERSION,bookmark_data:this._bookmarkData,queued_operations:this._queuedOperations,bookmarks:this._bookmarks.filter(function(e){return"public"===e.type;}).map(function(e){return{id:e.id,url:e.url};}),etag:'"0"'};}},{key:"_fromJSON",value:function(e){if(!e||e.version&&e.version!==this._config.BOOKMARKS_FILE_VERSION)return this._services.log("Unsupported bookmarks.json file - ignoring"),void(this._bookmarkData=[]);e.version||(this._services.log("Legacy bookmarks.json file - migrating"),e.bookmark_data=e.bookmarks.map(function(e){return r({type:"public"},e);})),this._bookmarkData=e.bookmark_data,this._queuedOperations=e.queued_operations||[],this._ensureBookmarks();}},{key:"_serialize",value:function(e){return this._config.isNewBookmarkFormatSupported(e)?this._toJSON():this._bookmarks.filter(function(e){return"public"===e.type;}).map(function(e){return{_id:e.id,_url:e.url};});}},{key:"_deserialize",value:function(e){this._fromJSON(e);}},{key:"_checkAndApplyCondition",value:function(e){var t=e.condition&&e.condition.condition,n=e.condition&&e.condition.libraryId,i=this._collection._apiRoot.getLoadedCollections().reduce(function(e,t){return e||!t.isPrivate&&t._getLocalLibraryById(n);},null);return"on_pushed_new"===t&&i&&i._dcxBranch&&i._dcxBranch.compositeAssetId?(e.data.urn=i._dcxBranch.compositeAssetId,delete e.condition,!0):"on_deleted"===t&&!i&&(delete e.condition,!0);}},{key:"_isConditionStale",value:function(e){var t=e.condition&&e.condition.condition,n=e.condition&&e.condition.libraryId,i=n&&this._collection._apiRoot.getLibraryById(n);return"on_pushed_new"===t&&!i||"on_deleted"===t&&i;}},{key:"_checkAndApplyConditions",value:function(){var e=this,t=this._queuedOperations.filter(function(t){return!e._isConditionStale(t);}),n=t.reduce(function(t,n){return e._checkAndApplyCondition(n)||t;},!1)||t.length!==this._queuedOperations.length;return this._queuedOperations=t,n;}},{key:"_pushOperation",value:function(e){if("remove"===e.operation){var t=this._queuedOperations.findIndex(function(t){return"create"===t.operation&&t.data&&t.data.id===e.id;});if(t>=(this._isPushing?1:0))return void this._queuedOperations.splice(t,1);}this._queuedOperations.push(e);}},{key:"_ensureBookmarks",value:function(){var e=this,t={};this._bookmarks.forEach(function(e){return t[e.id]=e;});var n={},i=[];this._queuedOperations.forEach(function(e){"remove"===e.operation?n[e.id]=!0:"create"===e.operation&&("team"===e.data.type&&(e.data.type="collab"),i.push(e.data));}),this._bookmarks=[];var o=function(i){if(v.includes(i.type)&&!n[i.id]){var o=t[i.id],r=function(t){o&&o._onRemove&&(t._onRemove=o._onRemove),e._bookmarks.push(t);};t[i.id]&&delete t[i.id],"public"===i.type?r(new p(i.id,i.url)):"collab"===i.type&&r(new d(i.id,i.urn,i.role));}};this._bookmarkData.forEach(o),i.forEach(o),Object.keys(t).forEach(function(e){var n=t[e];n._onRemove&&n._onRemove();}),this._services.log("Notifying bookmarks change: ".concat(this._bookmarks.join(", "))),this._listenerManager.notify("change");}},{key:"_saveAndPushChanges",value:function(){var e=this;return this._ensureBookmarks(),this._lock.execute(function(){return e._save().then(function(){return!e._disableSyncing&&e._push();});});}},{key:"_sync",value:function(){var e=this;return this._disableSyncing?Promise.reject(new m(m.NOT_ALLOWED,"Syncing is disabled on this instance of the bookmark manager")):this._push().then(function(){return e._pull();});}},{key:"_pull",value:function(){var e=this;return this._syncManager.getBookmarks().then(function(t){return e._bookmarkData=t&&t.bookmarks||[],e._ensureBookmarks(),e._save();}).catch(function(t){return e._collection._reportSyncError(t);});}},{key:"_push",value:function(){var e=this;if(this._checkAndApplyConditions())return this._ensureBookmarks(),this._save().then(function(){return e._push();});var t=this._nextOperationToPush;if(!t)return Promise.resolve();this._isPushing=!0;var n=function(){var n=e._queuedOperations.indexOf(t);return-1!==n&&e._queuedOperations.splice(n,1),e._ensureBookmarks(),e._isPushing=!1,e._save().then(function(){return e._push();});},i=function(n){if(n.code!==m.RETRYABLE_SERVER_ERROR){var i=e._queuedOperations.indexOf(t);return-1!==i&&e._queuedOperations.splice(i,1),e._ensureBookmarks(),e._isPushing=!1,e._collection._reportSyncError(n),e._save().then(function(){return e._push();});}e._isPushing=!1,e._collection._reportSyncError(n);};return"create"===t.operation?this._syncManager.createBookmarks({bookmarks:[t.data]}).then(function(){return e._bookmarkData.push(t.data),n();},i):"remove"===t.operation?this._syncManager.removeBookmark(t.id).then(function(){var i=e._bookmarkData.findIndex(function(e){return e.id===t.id;});if(-1!==i){var o=e._bookmarkData[i];if(e._bookmarkData.splice(i,1),t.removeCollaboration&&o.urn)return e._syncManager.removeCollaborators("urn/".concat(o.urn),[e._syncManager._userId]).finally(n);}return n();},i):(this._services.log("Unknown bookmark operation ".concat(t.operation)),n());}},{key:"sync",value:function(){var e=this;return this._lock.execute(function(){return e._sync();});}},{key:"getBookmarks",value:function(){return this._bookmarks;}},{key:"findBookmark",value:function(e){return this.getBookmarks().find(function(t){return t.isReferenceTo(e);});}},{key:"createBookmark",value:function(e,t,n,i){var o=this,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:function(){},s=function(e){var t=o._bookmarks.find(function(t){return t.id===e;});a(null,t);};if(this._config.SHARED_LOCAL_STORAGE)this._storageInterface.createBookmark(this._collection,e,t,n,i,function(e,n){!e&&n?(o._deserialize(n),s(t)):a(e);});else{var c=this._bookmarks.find(function(e){return e.id===t;});c?a(null,c):(this._services.log("Creating bookmark: "+e+" data: "+JSON.stringify(n)),this._pushOperation({operation:"create",condition:i,data:r({id:t,type:e},n)}),this._saveAndPushChanges(),s(t));}}},{key:"removeBookmark",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){};this._config.SHARED_LOCAL_STORAGE?this._storageInterface.removeBookmark(this._collection,e,n,i):(this._services.log("Removing bookmark: ".concat(JSON.stringify(e.toJSON()))),this._bookmarks.find(function(t){var n=t.id;return e.id===n;})&&(this._pushOperation({operation:"remove",removeCollaboration:n,condition:t,id:e.id}),this._saveAndPushChanges()),i(null));}},{key:"_nextOperationToPush",get:function(){var e=[];return this._queuedOperations.find(function(t){if(!(t.condition||t.id&&e.includes(t.id)))return t;"create"===t.operation&&t.data&&e.push(t.data.id);});}}]),t;}(f);e.exports=y;},function(e,t,n){var i=n(0),o=n(8),r=n(51),a=n(15),s=n(5),c=n(1);function l(e,t,n){this._readOnly=n,this._owner=t,this._setData(e),this._localStorage=void 0;}function u(e,t,n,o,r,a,s,l){var u=t._owner._core,_=e._owner._core,h=n&&e.id===t.id,p=_._getSourceHrefOfComponent(e),d=u.getComponentWithId(t.id),f=!(d&&d.etag||"unmodified"!==e.state),m=!h&&!p,v=m;if(r&&!d&&(p||m)&&e.id===t.id&&(t._data.id=c.generateUuid(),t.state="modified",t.etag=void 0,t.version=void 0,t.md5=void 0,t.length=void 0),a&&a._copyComponentMapping(e.id,l,t.id,s)&&(v=!1,h||(t.state="modified")),m){if(f){if(p=_._getHrefOfComponent(e),u._setSourceHrefOfComponent(p,t,s),!p&&v)throw new i(i.INVALID_STATE,"Failed to determine the source href of a component that does not have a local file.");}else if(v)throw new i(i.INVALID_STATE,"Could not use server-to-server copy for component "+e.id);}else u._setSourceHrefOfComponent(p,t,s);p&&(t.state="modified");}Object.defineProperties(l.prototype,{rootNode:{get:function(){return this.getChildWithAbsolutePath(r.ROOT_PATH);},set:function(){throw new i(i.READ_ONLY,'Property "rootNode" is read-only.');}},hasLocalStorage:{get:function(){return this._localStorage;},set:function(){throw new i(i.READ_ONLY,"Cannot set the property hasLocalStorage.");}},isDirty:{get:function(){return this._isDirty;},set:function(){throw new i(i.READ_ONLY,"Cannot set the property isDirty.");}},changeCount:{get:function(){return this._data.local&&this._data.local.change||0;},set:function(){throw new i(i.READ_ONLY,"Cannot set the property changeCount.");}}}),l.prototype.getChildWithId=function(e){return this._allNodes[e];},l.prototype.getChildWithAbsolutePath=function(e){var t=this._absolutePaths[e.toLowerCase()];return t&&t instanceof r?t:void 0;},l.prototype.getChildrenOf=function(e){if(!(e=e?this._allNodes[e.id]:this.rootNode))throw new i(i.INVALID_PARAMS,"Unknown node");var t,n=[],o=e._data.children;if(Array.isArray(o))for(t=0;t<o.length;t++){var r=o[t],a=this._allNodes[r.id];if(!a)throw new i(i.INVALID_DATA,"Node not in cache");n[n.length]=a;}return n;},l.prototype.addChild=function(e,t,n,o){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(t=t||c.generateUuid(),this._allNodes[t])throw new i(i.DUPLICATE_VALUE,"Node already exists in branch.");if(n&&("number"!=typeof n||n%1!=0))throw new i(i.INVALID_PARAMS,'Param "index" must be an integer.');var a=o?this._allNodes[o.id]:this.rootNode;if(!a)throw new i(i.INVALID_PARAMS,"Unknown parent node.");var s=new r();s.id=t,e&&(s.name=e),s._parentPath=a.absolutePath||a._parentPath;var l=a._data.children;return l?(n>=0&&n<=l.length||(n=l.length),n===l.length?l[n]=s._data:l.splice(n,0,s._data)):a._data.children=[s._data],this._allNodes[s.id]=s,s._owner=this._owner,this._setDirty(),s;},l.prototype.removeChild=function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(!e)throw new i(i.INVALID_PARAMS,'Expecting param "node".');if(e.isRoot)throw new i(i.INVALID_PARAMS,"Cannot remove the root node.");var t=e.id;if(!t)throw new i(i.INVALID_PARAMS,'Param "node" must have an id.');var n=this._nodeDataOfParentOfNode(e);if(!n)throw new i(i.INVALID_PARAMS,"Node not found in this branch.");return n.parentNodeData.children.splice(n.index,1),0===n.parentNodeData.children.length&&delete n.parentNodeData.children,e=this._allNodes[t],this._removeNodeFromCachesRecursively(e._data),this._setDirty(),e;},l.prototype.moveChild=function(e,t,n){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(!e)throw new i(i.INVALID_PARAMS,'Expecting param "node".');if(e.isRoot)throw new i(i.INVALID_PARAMS,"Cannot move the root node.");if(t&&("number"!=typeof t||t%1!=0))throw new i(i.INVALID_PARAMS,'Param "index" must be an integer.');var o=e.id;if(!o)throw new i(i.INVALID_PARAMS,'Param "node" must have an id.');var r=this._nodeDataOfParentOfNode(e);if(e=this._allNodes[o],!r)throw new i(i.INVALID_PARAMS,"Node not found in this branch.");var a=n?this._allNodes[n.id]:this.rootNode;if(!a)throw new i(i.INVALID_PARAMS,"Unknown parent node.");if(this._nodeIdIsDescendantOf(a.id,e._data))throw new i(i.INVALID_PARAMS,"Must not create a cycle.");var s=r.parentNodeData.children.splice(r.index,1)[0];try{var c=a._data.children;c?(t>=0&&t<=c.length||(t=c.length),t===c.length?c[t]=s:c.splice(t,0,s)):a._data.children=[s];}catch(e){throw r.parentNodeData.children.splice(r.index,0,s),e;}return 0===r.parentNodeData.children.length&&delete r.parentNodeData.children,this._setDirty(),this._allNodes[o];},l.prototype.copyChild=function(e,t,n,i,o,r){return this._copyChild(e,t,n,i,o,!1,r);},l.prototype.replaceChild=function(e,t,n,i){return this._copyChild(e,void 0,void 0,t,n||e.id,!0,i);},l.prototype.allComponents=function(){var e,t=[];for(e in this._allComponents)this._allComponents.hasOwnProperty(e)&&t.push(this._allComponents[e]);return t;},l.prototype.getComponentWithId=function(e){return this._allComponents[e];},l.prototype.getComponentWithAbsolutePath=function(e){var t=this._absolutePaths[e.toLowerCase()];return t&&t instanceof a?t:void 0;},l.prototype.getComponentsOf=function(e){if(!(e=e?this._allNodes[e.id]:this.rootNode))throw new i(i.INVALID_PARAMS,"Unknown node");var t,n=[],o=e._data.components;if(Array.isArray(o))for(t=0;t<o.length;t++){var r=o[t],a=this._allComponents[r.id];if(!a)throw new i(i.INVALID_DATA,"Component not in cache");n[n.length]=a;}return n;},l.prototype.addComponent=function(e,t,n,o,r,s,l,u,_,h){var p=this._localStorage;if(!p)throw new i(i.NO_LOCAL_STORAGE,"No local storage. Use AdobeDCXCompositeXfer.uploadNewComponent() followed by addComponentWithUploadResults()");if("function"!=typeof h&&r)throw new i(i.INVALID_PARAMS,'Param "callback" must be a function.');if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(_&&"string"!=typeof _)throw new i(i.INVALID_PARAMS,'Param "id" must be of type string.');if(!r&&!l)throw new i(i.INVALID_PARAMS,"Must provide either source or sourceHref.");try{if(l){var d=this._getBranchOf(this).compositeHref;if(d){var f=c.endPointOf(d),m=c.endPointOf(l);if(f&&m&&f!==m)throw new i(i.WRONG_ENDPOINT,"Given source href has an invalid endpoint: "+m);}}var v=this._local();_=_||c.generateUuid();var y=new a();y.id=_,y.name=e,y.type=t,y.relationship=n,y.path=o,y.state="modified";var g=this,E=function(e){if(!e)try{if(_&&g._allComponents[_])throw new i(i.DUPLICATE_VALUE,'The "id" of a component must be unique.');var t=u?g._allNodes[u.id]:g.rootNode;if(!t)throw new i(i.INVALID_PARAMS,"Unknown parent node.");var n=g._normalizedAbsolutePathForItem(y,t);if(g._absolutePaths[n])throw new i(i.DUPLICATE_VALUE,"Duplicate absolute path: "+n);if(!c.isValidAbsolutePath(n))throw new i(i.INVALID_PARAMS,"Invalid absolute path: "+n);y._parentPath=t.absolutePath||t._parentPath;var o=t._data.components;o?o.push(y._data):t._data.components=[y._data],y._owner=g._owner,l&&g._setSourceHrefOfComponent(l,y),g._allComponents[y.id]=y,g._absolutePaths[n]=y,g._setDirty();}catch(t){p.removeComponentAsset(y,v),l&&g._setSourceHrefOfComponent(void 0,y),y=void 0,e=t;}if(h)return h(e,y);if(e)throw e;return y;};if(!r)return E();p.ingestComponentAsset(y,r,s,v,E);}catch(e){if(h)return h(e);throw e;}},l.prototype.addComponentWithUploadResults=function(e,t,n,o,r){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(r.compositeId!==this._owner.compositeId)throw new i(i.INVALID_PARAMS,"Param uploadResults does not appear valid to be for this composite.");var s=Object.keys(r.records);if(1!==s.length)throw new i(i.INVALID_PARAMS,"Param uploadResults must contain records of exactly one component upload.");if(this._localStorage)throw new i(i.INVALID_PARAMS,"This method is for in-browser use only. Use addComponent() instead.");var c=r.records[s[0]],l=c.id;if(this._allComponents[l])throw new i(i.DUPLICATE_VALUE,"Duplicate component id: "+l);var u=o?this._allNodes[o.id]:this.rootNode;if(!u)throw new i(i.INVALID_PARAMS,"Unknown parent node.");var _=new a();_.id=l,_.name=e,_.type=c.type,_.relationship=t,_.path=n,_.state="unmodified",_.etag=c.etag,_.length=c.length,_.version=c.version,_.md5=c.md5;var h=this._normalizedAbsolutePathForItem(_,u);if(this._absolutePaths[h])throw new i(i.DUPLICATE_VALUE,"Duplicate absolute path: "+h);_._parentPath=u.absolutePath||u._parentPath;var p=u._data.components;return p?p.push(_._data):u._data.components=[_._data],_._owner=this._owner,this._allComponents[l]=_,this._absolutePaths[h]=_,this._setDirty(),_;},l.prototype.updateComponent=function(e,t,n,o){var r=this._localStorage;if(!r)throw new i(i.NO_LOCAL_STORAGE,"No local storage. Use AdobeDCXCompositeXfer.uploadComponent() to upload a new component asset and then call updateComponentWithUploadResults()");if("function"!=typeof o)throw new i(i.INVALID_PARAMS,'Param "callback" must be a function.');if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(!(e=this._allComponents[e.id]))throw new i(i.INVALID_PARAMS,"Unknown component.");try{var a=this;r.ingestComponentAsset(e,t,n,this._local(),function(t){if(!t)try{"modified"!==e.state?e.state="modified":a._setDirty(),a._setSourceHrefOfComponent(void 0,e);}catch(n){t=n,e=void 0;}o(t,e);});}catch(e){o(e);}},l.prototype.updateComponentWithUploadResults=function(e,t){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(!(e=this._allComponents[e.id]))throw new i(i.INVALID_PARAMS,"Unknown component.");if(this._localStorage)throw new i(i.INVALID_PARAMS,"This method is for in-browser use only. Use updateComponent() instead.");if(t.compositeId!==this._owner.compositeId)throw new i(i.INVALID_PARAMS,"Param uploadResults does not appear valid to be for this composite.");var n=t.records[e.id];if(!n)throw new i(i.INVALID_PARAMS,"Param uploadResults does not contain an upload record for the given component.");return e.etag=n.etag,e.version=n.version,e.md5=n.md5,e.length=n.length,e;},l.prototype.removeComponent=function(e){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(!e)throw new i(i.INVALID_PARAMS,'Expecting param "component".');var t=e.id;if(!t)throw new i(i.INVALID_PARAMS,'Param "component" must have an id.');var n=this._nodeDataOfParentOfComponent(e);if(!n)throw new i(i.INVALID_PARAMS,"Component not found in this branch.");return n.parentNodeData.components.splice(n.index,1),0===n.parentNodeData.components.length&&delete n.parentNodeData.components,e=this._allComponents[t],delete this._allComponents[t],delete this._absolutePaths[this._normalizedAbsolutePathForItem(e)],this._localStorage&&(this._localStorage.removeComponentAsset(e,this._local()),this._setSourceHrefOfComponent(void 0,e)),e._owner=void 0,e._parentPath="",this._setDirty(),e;},l.prototype.moveComponent=function(e,t){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(!e)throw new i(i.INVALID_PARAMS,'Expecting param "component".');var n=e.id;if(!n)throw new i(i.INVALID_PARAMS,'Param "component" must have an id.');var o=this._nodeDataOfParentOfComponent(e);if(!o)throw new i(i.INVALID_PARAMS,"Component not found in this branch.");var r=t?this._allNodes[t.id]:this.rootNode;if(!r)throw new i(i.INVALID_PARAMS,"Unknown parent node.");var a=this._normalizedAbsolutePathForItem(e,r);if(this._absolutePaths[a])throw new i(i.DUPLICATE_VALUE,"Duplicate absolute path: "+a);var s=o.parentNodeData.components.splice(o.index,1)[0],c=r._data.components;return c?c.push(s):r._data.components=[s],0===o.parentNodeData.components.length&&delete o.parentNodeData.components,e=this._allComponents[n],delete this._absolutePaths[this._normalizedAbsolutePathForItem(e)],e._parentPath=r.absolutePath||r._parentPath,this._absolutePaths[a]=e,this._setDirty(),e;},l.prototype.copyComponent=function(e,t,n,i,o){return this._copyComponent(e,t,n,i,!1,o);},l.prototype.replaceComponent=function(e,t,n,i){return this._copyComponent(e,void 0,t,n||e.id,!0,i);},l.prototype.assetOfComponent=function(e,t){try{if(!this._localStorage)throw new i(i.NO_LOCAL_STORAGE,"No local storage.");if(!e)throw new i(i.INVALID_PARAMS,'Expecting param "component".');if(!e.id)throw new i(i.INVALID_PARAMS,'Param "component" must have an id.');var n=this._localStorage.componentAssetPath(e,this._local());if(!t)return n;s.exists(n,function(e){t(void 0,e?n:null);});}catch(e){if(!t)throw e;t(e);}},l.prototype._getHrefOfComponent=function(e){var t,n=this._getBranchOf(e);if(n.compositeLinks)return c.getUrlFromLinks(n.compositeLinks,o.COMPONENT,{component_id:e.id});var i=n.compositeHref;return i&&void 0!==e.version&&(t=c.appendPathElements(i,e.id),t+=";version="+e.version),t;},l.prototype._setSourceHrefOfComponent=function(e,t,n){var i=t.id,o=this._componentSourceHrefLookup(!0,n);e?o[i]=e:o[i]&&delete o[i];},l.prototype._getSourceHrefOfComponent=function(e,t){var n=e.id,i=this._componentSourceHrefLookup(!1,t);if(i)return i[n];},l.prototype._copySourceHrefsFrom=function(e){var t=e._componentSourceHrefLookup(!1),n=this.allComponents(),i=n.length;if(i&&t){var o,r=this._componentSourceHrefLookup(!0);for(o=0;o<i;o++){var a=n[o].id;r[a]=t[a];}}},l.prototype._getBranchOf=function(e){return e._owner?this._getBranchOf(e._owner):e;},l.prototype._isSameComposite=function(e){var t=this._getBranchOf(this),n=this._getBranchOf(e);return t._data.id===n._data.id&&!(!(t.compositeRepoMetadata?!n.compositeRepoMetadata&&!n.isBound:n.compositeRepoMetadata&&!t.isBound)&&t.compositeHref!==n.compositeHref)&&this._localStorage===e._localStorage;},l.prototype._stringify=function(e,t){if(e){var n=this._data.local,i=null;try{delete this._data.local,i=JSON.stringify(this._data,void 0,t?2:void 0);}catch(e){throw e;}finally{n&&(this._data.local=n);}return i;}return JSON.stringify(this._data,void 0,t?2:void 0);},l.prototype._setData=function(e){var t=new r(e,this._readOnly,!0);t._owner=this._owner,t._parentPath="";var n={},o={},s={};o[t.id]=t,s[r.ROOT_PATH]=t;var l=this;return function e(t,n,o,s,u){var _,h,p,d=t.components;if(Array.isArray(d))for(_=0;_<d.length;_++){var f=d[_],m=new a(f,l._readOnly);if(n[m.id])throw new i(i.INVALID_DATA,"Duplicate component id: "+m.id);if(m._owner=l._owner,m._parentPath=u,s[p=l._normalizedAbsolutePathForItem(m)])throw new i(i.INVALID_DATA,"Duplicate absolute path: "+p);if(!c.isValidAbsolutePath(p))throw new i(i.INVALID_DATA,"Invalid absolute component path: "+p);n[m.id]=m,s[p]=m;}var v=t.children;if(Array.isArray(v))for(_=0;_<v.length;_++){var y=v[_],g=new r(y,l._readOnly);if(o[g.id])throw new i(i.INVALID_DATA,"Duplicate node id: "+g.id);if(h=g.path,g._owner=l._owner,g._parentPath=u,h){if(s[p=l._normalizedAbsolutePathForItem(g)])throw new i(i.INVALID_DATA,"Duplicate absolute path: "+p);if(!c.isValidAbsolutePath(p))throw new i(i.INVALID_DATA,"Invalid node absolute path: "+p);s[p]=g;}o[g.id]=g,e(y,n,o,s,g.path?c.appendPathElements(u,g.path):u);}}(e,n,o,s,r.ROOT_PATH),this._data=e,this._allComponents=n,this._allNodes=o,this._absolutePaths=s,this._isDirty=!1,this;},l.prototype._removeNodeFromCachesRecursively=function(e){var t,n=e.components;if(Array.isArray(n))for(t=0;t<n.length;t++){var i=n[t].id,o=this._allComponents[i];delete this._allComponents[i],delete this._absolutePaths[this._normalizedAbsolutePathForItem(o)],o._owner=void 0,this._localStorage&&(this._localStorage.removeComponentAsset(o,this._local()),this._setSourceHrefOfComponent(void 0,o));}var r=e.children;if(Array.isArray(r))for(t=0;t<r.length;t++)this._removeNodeFromCachesRecursively(r[t]);var a=e.id,s=this._allNodes[a];delete this._allNodes[a],s.path&&delete this._absolutePaths[this._normalizedAbsolutePathForItem(s)],s._owner=void 0;},l.prototype._local=function(){return this._data.local||(this._data.local={version:2}),this._data.local;},l.prototype._componentSourceHrefLookup=function(e,t){if(e&&this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(t||(t=e?this._local():this._data.local)){var n=t["componentS2SCopy#srcHref"];return!n&&e&&(n=t["componentS2SCopy#srcHref"]={}),n;}},l.prototype._recursiveReset=function(e,t){var n,i=e.components;if(i)for(n=i.length-1;n>=0;n--){var o=i[n];"committedDelete"===o.state?(delete i[n],delete this._allComponents[o.id],delete o._owner,this._localStorage&&this._localStorage.removeComponentAsset(o,this._local()),this._setSourceHrefOfComponent(void 0,o,this._local())):(delete o.etag,delete o.version,delete o.length,delete o.md5,o.state="modified",t&&t(o));}var r=e.children;if(r)for(n=0;n<r.length;n++)this._recursiveReset(r[n],t);},l.prototype._nodeIdIsDescendantOf=function(e,t){var n,i=t.children;if(i)for(n=0;n<i.length;n++){var o=i[n];if(o.id===e||this._nodeIdIsDescendantOf(e,o))return!0;}return!1;},l.prototype._recursivelyGetAllComponentsOfChild=function(e,t){t=t||[];var n,i,o=e._data||e,r=o.components;if(r)for(i=r.length,n=0;n<i;n++)t[t.length]=this._allComponents[r[n].id];var a=o.children;if(a)for(i=a.length,n=0;n<i;n++)t=this._recursivelyGetAllComponentsOfChild(a[n],t);return t;},l.prototype._nodeDataOfParentOfNode=function(e,t){t=t||this._data;var n,i=e._data.id,o=t.children;if(o)for(n=0;n<o.length;n++){var r=o[n];if(r.id===i)return{parentNodeData:t,index:n};var a=this._nodeDataOfParentOfNode(e,r);if(a)return a;}return null;},l.prototype._nodeDataOfParentOfComponent=function(e,t){t=t||this._data;var n,i=e._data.id,o=t.components;if(o)for(n=0;n<o.length;n++){if(o[n].id===i)return{parentNodeData:t,index:n};}var r=t.children;if(r)for(n=0;n<r.length;n++){var a=r[n],s=this._nodeDataOfParentOfComponent(e,a);if(s)return s;}return null;},l.prototype._determineAbsolutePathChangesRecursively=function(e,t,n){var i,o=e.components;if(o)for(i=0;i<o.length;i++){var r=o[i],a=this._allComponents[r.id];n.push({item:a,parentPath:t,absPath:c.appendPathElements(t,r.path)});}var s=e.children;if(s)for(i=0;i<s.length;i++){var l=s[i],u=this._allNodes[l.id],_=l.path,h=_?c.appendPathElements(t,_):t;n.push({item:u,parentPath:t,absPath:_?h:void 0}),this._determineAbsolutePathChangesRecursively(l,h,n);}},l.prototype._setPathOfNode=function(e,t){var n=t?c.appendPathElements(e.parentPath,t):e.parentPath,o=[{item:e,absPath:t?n:void 0}];this._determineAbsolutePathChangesRecursively(e._data,n,o);for(var r=0;r<o.length;r++){var a=o[r],s=o[r].item;if(a.absPath){var l=a.absPath.toLowerCase(),u=this._absolutePaths[l];if(u){if(s.absolutePath&&u===this._normalizedAbsolutePathForItem(s))return;throw new i(i.DUPLICATE_VALUE,"Duplicate absolute path: "+l);}if(!c.isValidAbsolutePath(l))throw new i(i.INVALID_PARAMS,"Invalid absolute path: "+l);}}for(var _=0;_<o.length;_++){var h=o[_],p=h.item;if(p._data.path&&delete this._absolutePaths[this._normalizedAbsolutePathForItem(p)],h.absPath){var d=h.absPath.toLowerCase();this._absolutePaths[d]=h.item;}h.parentPath&&(p._parentPath=h.parentPath);}e._data.path=t;},l.prototype._setPathOfComponent=function(e,t){if(!this._allComponents[e.id])throw new i(i.INVALID_PARAMS,"Unknown component.");var n=c.appendPathElements(e.parentPath,t).toLowerCase();if(this._absolutePaths[n])throw new i(i.DUPLICATE_VALUE,"Duplicate absolute path for component: "+n);if(!c.isValidAbsolutePath(n))throw new i(i.INVALID_PARAMS,"Invalid absolute path: "+n);delete this._absolutePaths[this._normalizedAbsolutePathForItem(e)],this._absolutePaths[n]=e,e._data.path=t;},l.prototype._setDirty=function(e,t){e||"pendingDiscard"!==this._data.state&&"pendingDelete"!==this._data.state&&"committedDelete"!==this._data.state||console.error("Modifying deleted composite"),this._isDirty=!0,t||(this._local().change=this.changeCount+1),e||"unmodified"!==this._data.state&&this._data.state||(this._data.state="modified");},l.prototype._normalizedAbsolutePathForItem=function(e,t){return(t?c.appendPathElements(t.absolutePath||t._parentPath,e.path):e.absolutePath).toLowerCase();},l.prototype._hasSameEndpoint=function(e){var t=this._getBranchOf(this).compositeHref,n=this._getBranchOf(e).compositeHref;if(t&&n){var i=c.endPointOf(t),o=c.endPointOf(n);if(i&&o&&i!==o)return!1;}return!0;},l.prototype._copyComponent=function(e,t,n,o,r,a){if(!e)throw new i(i.INVALID_PARAMS,'Expecting param "component".');if(a&&"function"!=typeof a)throw new i(i.INVALID_PARAMS,"Param callback must be a function.");var s=this,c=e._owner._core,l=this._isSameComposite(c),_=l||this._hasSameEndpoint(e),h=c._local(),p=this._localStorage,d=c._localStorage,f=p&&d;if(f&&!a&&!l)throw new i(i.INVALID_PARAMS,"Must pass a callback when copying between two different composites.");if(!f&&!_)throw new i(i.NO_LOCAL_STORAGE,"Cannot copy between two different endpoints without local storage.");var m=function(e,t,n){u(e,t,l,0,!o,f?p:void 0,n,h);},v=f?d.componentAssetPath(e,h):void 0;if(!a)return this._copyComponentModel(e,t,r,n,o,m);if(l||!v)try{a(void 0,this._copyComponentModel(e,t,r,n,o,m));}catch(e){a(e);}else{var y={};p.ingestComponentAsset(e,v,!0,y,function(i){if(i)a(i);else try{h=y,a(void 0,s._copyComponentModel(e,t,r,n,o,m));}catch(e){a(e);}});}},l.prototype._copyComponentModel=function(e,t,n,o,r,s){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if(!e)throw new i(i.INVALID_PARAMS,'Expecting param "component".');var l=e._owner,u=new a(JSON.parse(JSON.stringify(e._data)));o?(u.path=o,u.id=r||c.generateUuid()):r&&(u.id=r),u._owner=this._owner,e.id===u.id&&this._isSameComposite(l._core)||(u.state="modified",u.etag=void 0,u.version=void 0,u.md5=void 0,u.length=void 0);var _,h,p=this._allComponents[u.id];if(p&&!n)throw new i(i.DUPLICATE_VALUE,"Component already exists.");if(n&&!p)throw new i(i.INVALID_PARAMS,"Could not find existing component.");if(n){var d=this._nodeDataOfParentOfComponent(p);if(!d)throw new i(i.INVALID_PARAMS,"Parent node of existing component not found in this branch.");var f=d.parentNodeData.id;if(!(h=this._allNodes[f]))throw new i(i.INVALID_STATE,"Unknown parent node.");_=d.index;}else if(!(h=t?this._allNodes[t.id]:this.rootNode))throw new i(i.INVALID_PARAMS,"Unknown parent node.");u._parentPath=h.absolutePath||h._parentPath;var m=this._normalizedAbsolutePathForItem(u),v=this._absolutePaths[m];if(v&&v!==p)throw new i(i.DUPLICATE_VALUE,"Duplicate absolute path: "+m);if(!c.isValidAbsolutePath(m))throw new i(i.INVALID_PARAMS,"Component path must be a valid path for a component.");var y=this._local();s&&s(e,u,y=c.deepCopy(y));var g=h._data.components;return n?g[_]=u._data:g?g.push(u._data):h._data.components=[u._data],this._data.local=y,this._allComponents[u.id]=u,this._absolutePaths[m]=u,this._setDirty(),u;},l.prototype._copyChild=function(e,t,n,o,r,a,s){if(!e)throw new i(i.INVALID_PARAMS,'Expecting param "node".');var c=this,l=e._owner._core,_=this._isSameComposite(l),h=_||this._hasSameEndpoint(e),p=l._local(),d=this._localStorage,f=l._localStorage,m=d&&f,v=l._recursivelyGetAllComponentsOfChild(e);if(v.length>0){if(m&&!s&&!_)throw new i(i.INVALID_PARAMS,"Must pass a callback when copying between two different composites.");if(!m&&!h)throw new i(i.NO_LOCAL_STORAGE,"Cannot copy components between two different endpoints without local storage.");}var y=function(e,t,n){u(e,t,_,0,!0,m?d:void 0,n,p);};if(!s)return this._copyChildModel(e,t,n,a,o,r,y);var g=function(){s(void 0,c._copyChildModel(e,t,n,a,o,r,y));};if(0===v.length||_||!m)try{g();}catch(e){s(e);}else{var E,O,S={},A=v.length,T=0,b=function(e){if(e&&!O&&(O=e),0===--T)if(O)s(O);else try{p=S,g();}catch(e){s(e);}};for(E=0;E<A;E++){var L=v[E],I=f.componentAssetPath(L,p);I&&(T++,d.ingestComponentAsset(L,I,!0,S,b));}if(0===T)try{g();}catch(e){s(e);}}},l.prototype._copyChildModel=function(e,t,n,o,s,l,u){if(this._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");var _=e._owner,h=new r(JSON.parse(JSON.stringify(e._data)));s?(h.path=s,h.id=l||c.generateUuid()):l&&(h.id=l),h._owner=this._owner,e.isRoot&&(delete h._data.local,delete h._data["manifest-format-version"]);var p,d=this._allNodes[h.id];if(d&&!o)throw new i(i.DUPLICATE_VALUE,"Child node already exists.");if(o&&!d)throw new i(i.INVALID_PARAMS,"Could not find existing node to replace.");if(o){var f=this._nodeDataOfParentOfNode(d);if(!f)throw new i(i.INVALID_PARAMS,"Parent of existing node not found in this branch.");var m=f.parentNodeData.id;if(!(p=this._allNodes[m]))throw new i(i.INVALID_STATE,"Unknown parent node.");n=f.index;}else if(!(p=t?this._allNodes[t.id]:this.rootNode))throw new i(i.INVALID_PARAMS,"Unknown parent node.");if(h._parentPath=p.absolutePath||p._parentPath,h.path){var v=this._normalizedAbsolutePathForItem(h),y=this._absolutePaths[v];if(y&&y!==d)throw new i(i.DUPLICATE_VALUE,"Duplicate absolute path: "+v);if(!c.isValidAbsolutePath(v))throw new i(i.INVALID_PARAMS,"Node path must be a valid path for a node.");}var g=c.flatCopy(this._allNodes),E=c.flatCopy(this._allComponents),O=c.flatCopy(this._absolutePaths),S=c.deepCopy(this._local());d&&function e(t,n,i,o,r,a){var s,c;delete i[t.id],t.path&&delete r[n._normalizedAbsolutePathForItem(t)];var l=t._data.children;if(l)for(c=l.length,s=0;s<c;s++)e(i[l[s].id],n,i,o,r,a);var u=t._data.components;if(u)for(c=u.length,s=0;s<c;s++){var _=o[u[s].id];delete o[_.id],delete r[n._normalizedAbsolutePathForItem(_)],n._localStorage&&(n._localStorage.removeComponentAsset(_,a),n._setSourceHrefOfComponent(void 0,_,a));}}(d,this,g,E,O,S);if(function e(t,n,o,s,l,_,h,p){if(s[t.id])throw new i(i.DUPLICATE_VALUE,"Duplicate node id: "+t.id);var d;if(s[t.id]=t,t.path){if(_[d=n._core._normalizedAbsolutePathForItem(t)])throw new i(i.DUPLICATE_VALUE,"Duplicate absolute path: "+d);_[d]=t;}var f,m,v=t._data.children;if(v)for(m=v.length,f=0;f<m;f++){var y=new r(v[f]);s[y.id]&&(y.id=c.generateUuid()),y._owner=n,y._parentPath=t.absolutePath||t._parentPath,e(y,n,o,s,l,_,h,p);}var g=t._data.components;if(g)for(m=g.length,f=0;f<m;f++){var E=new a(g[f]),O=E.id;if(l[O]&&(E.id=c.generateUuid(),E.state="modified",E.etag=void 0,E.version=void 0,E.md5=void 0,E.length=void 0),E._owner=n,E._parentPath=t.absolutePath||t._parentPath,u&&u(o.getComponentWithId(O),E,h),l[E.id])throw new i(i.DUPLICATE_VALUE,"Duplicate component id: "+E.id);if(l[E.id]=E,_[d=n._core._normalizedAbsolutePathForItem(E)])throw new i(i.DUPLICATE_VALUE,"Duplicate absolute path: "+d);_[d]=E;}}(h,this._owner,_,g,E,O,S,_._local()),o)p._data.children[n]=h._data;else{var A=p._data.children;A?(n>=0&&n<=A.length||(n=A.length),n===A.length?A[n]=h._data:A.splice(n,0,h._data)):p._data.children=[h._data];}return this._allNodes=g,this._allComponents=E,this._absolutePaths=O,this._data.local=S,this._setDirty(),h;},l.prototype._verifyIntegrity=function(e,t,n){var o,a=this,s=[],l=!1,u=function(e){return s.push(new i(i.INVALID_STATE,e)),t&&(l||(t("Branch for composite "+a.rootNode.id+" has the following errors:"),l=!0),t("   "+e)),!1;},_=function(e,t){return!!e||u(t);},h=[],p=function(e){(h.indexOf(e)<0||u("Item "+e.id+" encountered more than once"))&&h.push(e);},d=c.flatCopy(this._allComponents),f=c.flatCopy(this._allNodes),m=c.flatCopy(this._absolutePaths),v=Object.keys(m),y=v.length;for(o=0;o<y;o++){var g=v[o];_("/"===g.charAt(0),"Absolute path "+g+" does not start with a slash.");}var E=m[r.ROOT_PATH];_(E,"Cannot find root node via path")&&(_(E.id===this._data.id,"Root node has correct id"),_(E.path===r.ROOT_PATH,"Root node has correct path"),_(""===E._parentPath,"Root node has correct parent path"),_(E._owner===this._owner,"Root node has correct owner"),_(E._data===this._data,"Root node has correct data"),_(f[E.id]===E,"Cannot find root node via id")&&delete f[E.id],delete m[r.ROOT_PATH]),function e(t,n){var i,o,r=t.children;if(r)for(i=0;i<r.length;i++){var s=r[i],l=f[s.id];(l||u("Node "+s.id+" is not in cache."))&&(p(l),_(l._data===s,"Node "+l.id+" _data property incorrect."),delete f[l.id],l.path&&l._owner&&(o=a._normalizedAbsolutePathForItem(l),(m[o]||u("Absolute path of node "+l.id+" ("+o+") is not in cache."))&&delete m[o]),_(l._parentPath===n,"Parent path of node "+l.id+" should be "+n+" but is "+l._parentPath),_(l._owner===a._owner,"Node "+l.id+" _owner property is not correct.")),e(s,s.path?c.appendPathElements(n,s.path):n);}var h=t.components;if(h)for(i=0;i<h.length;i++){var v=h[i],y=d[v.id];(y||u("Component "+v.id+" is not in cache."))&&(p(y),_(y._data===v,"Component "+y.id+" _data property incorrect."),delete d[y.id],y._owner&&(o=a._normalizedAbsolutePathForItem(y),(m[o]||u("Absolute path "+o+" is not in cache."))&&delete m[o]),_(y._parentPath===n,"Parent path of component "+y.id+" should be "+n+" but is "+y._parentPath),_(y._owner===a._owner,"Component "+y.id+" _owner property is not correct."));}}(this._data,r.ROOT_PATH);var O=Object.keys(d);for(o=0;o<O.length;o++)u("Component "+O[o]+" is in cache but could not be found.");for(O=Object.keys(f),o=0;o<O.length;o++)u("Node "+O[o]+" is in cache but could not be found.");for(O=Object.keys(m),o=0;o<O.length;o++)u("Absolute path "+O[o]+" is in cache but could not be found.");if(this._localStorage){var S=this._localStorage.componentIds(this._local());for(o=0;o<S.length;o++)_(this._allComponents[S[o]],"Component "+S[o]+" is in local storage mapping but could not be found in the manifest.");if(e)for(S=Object.keys(this._allComponents),o=0;o<S.length;o++){var A=S[o],T=this._allComponents[A],b=this._localStorage.componentAssetPath(T,this._local());_(b,"Component "+A+" does not have an entry in local storage mapping.")&&n&&_(n.existsSync(b),"Asset "+b+" does not exist.");}var L=this._componentSourceHrefLookup();if(L)for(y=(S=Object.keys(L)).length,o=0;o<y;o++){var I=this._allComponents[S[o]];I?_("modified"===I.state,"Component "+S[o]+" is in local source href mapping but has a state of "+I.state):_(!1,"Component "+S[o]+" is in local source href mapping but could not be found in the manifest.");}}return s.length?s:null;},e.exports=l;},function(e,t,n){var i,o,r;function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}o=[],void 0===(r="function"==typeof(i=function(){var e={"+":!0,"#":!0,".":!0,"/":!0,";":!0,"?":!0,"&":!0},t={"*":!0};function n(e){return encodeURI(e).replace(/%25[0-9][0-9]/g,function(e){return"%"+e.substring(3);});}function i(e){return e=e.replace(/%../g,""),encodeURIComponent(e)===e;}function o(o){var r="";e[o.charAt(0)]&&(r=o.charAt(0),o=o.substring(1));var s="",c="",l=!0,u=!1,_=!1;"+"==r?l=!1:"."==r?(c=".",s="."):"/"==r?(c="/",s="/"):"#"==r?(c="#",l=!1):";"==r?(c=";",s=";",u=!0,_=!0):"?"==r?(c="?",s="&",u=!0):"&"==r&&(c="&",s="&",u=!0);for(var h=[],p=o.split(","),d=[],f={},m=0;m<p.length;m++){var v=p[m],y=null;if(-1!=v.indexOf(":")){var g=v.split(":");v=g[0],y=parseInt(g[1]);}for(var E={};t[v.charAt(v.length-1)];)E[v.charAt(v.length-1)]=!0,v=v.substring(0,v.length-1);var O={truncate:y,name:v,suffices:E};d.push(O),f[v]=O,h.push(v);}return{varNames:h,prefix:c,substitution:function(e){for(var t="",i=0,o=0;o<d.length;o++){var r=d[o],h=e(r.name);if(null==h||Array.isArray(h)&&0==h.length||"object"==a(h)&&0==Object.keys(h).length)i++;else if(t+=o==i?c:s||",",Array.isArray(h)){u&&(t+=r.name+"=");for(var p=0;p<h.length;p++)p>0&&(t+=r.suffices["*"]&&s||",",r.suffices["*"]&&u&&(t+=r.name+"=")),t+=l?encodeURIComponent(h[p]).replace(/!/g,"%21"):n(h[p]);}else if("object"==a(h)){u&&!r.suffices["*"]&&(t+=r.name+"=");var f=!0;for(var m in h)f||(t+=r.suffices["*"]&&s||","),f=!1,t+=l?encodeURIComponent(m).replace(/!/g,"%21"):n(m),t+=r.suffices["*"]?"=":",",t+=l?encodeURIComponent(h[m]).replace(/!/g,"%21"):n(h[m]);}else u&&(t+=r.name,_&&""==h||(t+="=")),null!=r.truncate&&(h=h.substring(0,r.truncate)),t+=l?encodeURIComponent(h).replace(/!/g,"%21"):n(h);}return t;},unSubstitution:function(e,t,n){if(c&&(e=e.substring(c.length)),1==d.length&&d[0].suffices["*"]){for(var o=(A=d[0]).name,r=A.suffices["*"]?e.split(s||","):[e],a=l&&-1!=e.indexOf("="),_=1;_<r.length;_++)e=r[_],a&&-1==e.indexOf("=")&&(r[_-1]+=(s||",")+e,r.splice(_,1),_--);for(_=0;_<r.length;_++)e=r[_],l&&-1!=e.indexOf("=")&&(a=!0),1==(y=e.split(",")).length?r[_]=y[0]:r[_]=y;if(u||a){for(var h=t[o]||{},p=0;p<r.length;p++){var m=e;if(!u||m){if("string"==typeof r[p]){var v=(e=r[p]).split("=",1)[0];if(e=e.substring(v.length+1),l){if(n&&!i(e))return;e=decodeURIComponent(e);}m=e;}else{if(v=(e=r[p][0]).split("=",1)[0],e=e.substring(v.length+1),l){if(n&&!i(e))return;e=decodeURIComponent(e);}r[p][0]=e,m=r[p];}if(l){if(n&&!i(v))return;v=decodeURIComponent(v);}void 0!==h[v]?Array.isArray(h[v])?h[v].push(m):h[v]=[h[v],m]:h[v]=m;}}1==Object.keys(h).length&&void 0!==h[o]?t[o]=h[o]:t[o]=h;}else{if(l)for(p=0;p<r.length;p++){var y=r[p];if(Array.isArray(y))for(var g=0;g<y.length;g++){if(n&&!i(y[g]))return;y[g]=decodeURIComponent(y[g]);}else{if(n&&!i(y))return;r[p]=decodeURIComponent(y);}}void 0!==t[o]?Array.isArray(t[o])?t[o]=t[o].concat(r):t[o]=[t[o]].concat(r):1!=r.length||A.suffices["*"]?t[o]=r:t[o]=r[0];}}else{r=1==d.length?[e]:e.split(s||",");var E={};for(_=0;_<r.length;_++){for(var O=0;O<d.length-1&&O<_&&!d[O].suffices["*"];O++);if(O!=_){for(var S=d.length-1;S>0&&d.length-S<r.length-_&&!d[S].suffices["*"];S--);d.length-S!=r.length-_?E[_]=O:E[_]=S;}else E[_]=_;}for(_=0;_<r.length;_++)if((e=r[_])||!u){if(y=e.split(","),a=!1,u){o=(e=y[0]).split("=",1)[0],e=e.substring(o.length+1),y[0]=e;var A=f[o]||d[0];}else o=(A=d[E[_]]).name;for(p=0;p<y.length;p++)if(l){if(n&&!i(y[p]))return;y[p]=decodeURIComponent(y[p]);}(u||A.suffices["*"])&&void 0!==t[o]?Array.isArray(t[o])?t[o]=t[o].concat(y):t[o]=[t[o]].concat(y):1!=y.length||A.suffices["*"]?t[o]=y:t[o]=y[0];}}return 1;}};}function r(e){if(!(this instanceof r))return new r(e);for(var t=e.split("{"),n=[t.shift()],i=[],a=[],s=[],c=[];t.length>0;){var l=t.shift(),u=l.split("}")[0],_=l.substring(u.length+1),h=o(u);a.push(h.substitution),s.push(h.unSubstitution),i.push(h.prefix),n.push(_),c=c.concat(h.varNames);}this.fill=function(e){if(e&&"function"!=typeof e){var t=e;e=function(e){return t[e];};}for(var i=n[0],o=0;o<a.length;o++)i+=(0,a[o])(e),i+=n[o+1];return i;},this.fromUri=function(e,t){t=t||{};for(var o={},r=0;r<n.length;r++){var a=n[r];if(e.substring(0,a.length)!==a)return;if(e=e.substring(a.length),r>=n.length-1){if(""==e)break;return;}var c=i[r];if(!c||e.substring(0,c.length)===c){for(var l=n[r+1],u=r;;){if(u==n.length-2){var _=e.substring(e.length-l.length);if(_!==l)return;var h=e.substring(0,e.length-l.length);e=_;}else if(l){var p=e.indexOf(l);h=e.substring(0,p),e=e.substring(p);}else if(i[u+1])-1===(p=e.indexOf(i[u+1]))&&(p=e.length),h=e.substring(0,p),e=e.substring(p);else{if(n.length>u+2){u++,l=n[u+1];continue;}h=e,e="";}break;}if(!s[r](h,o,t.strict))return;}}return o;},this.varNames=c,this.template=e;}return r.prototype={toString:function(){return this.template;},fillFromObject:function(e){return this.fill(e);},test:function(e,t){return!!this.fromUri(e,t);}},r;})?i.apply(t,o):i)||(e.exports=r);},function(e,t,n){var i=n(52),o=n(54);e.exports=function(e,t,n){var r=t&&n||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null);var a=(e=e||{}).random||(e.rng||i)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,t)for(var s=0;s<16;++s)t[r+s]=a[s];return t||o(a);};},function(e,t,n){var i=n(0),o=n(5);function r(e,t,n){n?this._setData(n,e.href):this._data={"push-journal-format-version":3,"composite-href":e.href,"uploaded-components":{}},this._filePath=t,this._waitingCallbacks=[],this._commitInProgress=!1,this._needAnotherCommit=!1;}r.readJournal=function(e,t,n,i){o.readFile(e,"utf8",function(o,a){var s;if(o&&o.code&&n&&(o=void 0),!o)try{a=JSON.parse(a),s=new r(t,e,a);}catch(i){n?s=new r(t,e):o=i;}i(o,o?void 0:s);});},Object.defineProperties(r.prototype,{compositeHref:{get:function(){return this._data["composite-href"];},set:function(e){e?this._data["composite-href"]=e:delete this._data["composite-href"];}},manifestEtag:{get:function(){return this._data.etag;},set:function(e){e?this._data.etag=e:delete this._data.etag;}},currentBranchEtag:{get:function(){return this._data["current-branch-etag"];},set:function(e){e?this._data["current-branch-etag"]=e:delete this._data["current-branch-etag"];}},compositeAssetId:{get:function(){return this._data["composite-asset-id"];},set:function(e){e?this._data["composite-asset-id"]=e:delete this._data["composite-asset-id"];}},compositeRepoMetadata:{get:function(){return this._data["composite-repo-metadata"];},set:function(e){e?this._data["composite-repo-metadata"]=e:delete this._data["composite-repo-metadata"];}},compositeLinks:{get:function(){return this._data["composite-links"];},set:function(e){e?this._data["composite-links"]=e:delete this._data["composite-links"];}},changeCount:{get:function(){return this._data.change;},set:function(e){e?this._data.change=e:delete this._data.change;}},compositeHasBeenCreated:{get:function(){return!!this._data["composite-created"];},set:function(e){e?this._data["composite-created"]=!0:delete this._data["composite-created"];}},compositeHasBeenDeleted:{get:function(){return!!this._data["composite-deleted"];},set:function(e){e?this._data["composite-deleted"]=!0:delete this._data["composite-deleted"];}},isEmpty:{get:function(){return 0===Object.keys(this._data["uploaded-components"]).length&&!this.compositeHasBeenDeleted&&!this.manifestEtag;},set:function(){throw new i(i.READ_ONLY,"This property is read-only.");}},isComplete:{get:function(){return!!(this._data.etag&&this._data.change||this._data["composite-deleted"]);},set:function(){throw new i(i.READ_ONLY,"This property is read-only.");}}}),r.prototype.recordUploadedComponent=function(e,t,n,i,o,r,a){var s={etag:t,length:o,version:n,md5:i};r&&(s["storage-name"]=r),a&&(s["source-href"]=a),s.timestamp=new Date().toISOString(),this._data["uploaded-components"][e]=s;},r.prototype.idsOfAllUploadedComponents=function(){return Object.keys(this._data["uploaded-components"]);};r.prototype.getRecordForUploadedComponent=function(e){var t=this._data["uploaded-components"][e];if(t&&!this.isComplete){var n=t.timestamp;if(!n)return this.removeRecordForUploadedComponent(e);if(n=new Date(n),isNaN(n.getTime()))return this.removeRecordForUploadedComponent(e);if(Date.now()-n.getTime()>=6048e5)return this.removeRecordForUploadedComponent(e);}return t;},r.prototype.removeRecordForUploadedComponent=function(e){delete this._data["uploaded-components"][e];},r.prototype.applyToBranch=function(e,t){var n=this;if(!this.isComplete)throw new i(i.INVALID_STATE,"Journal is not complete.");var o=e.isDirty;if(this.compositeHasBeenDeleted)e._data.state="committedDelete",e.manifestEtag=this.manifestEtag;else{var r,a="unmodified"!==e.compositeState&&this.changeCount!==e.changeCount,s=this.idsOfAllUploadedComponents(),c=s.length;for(r=0;r<c;r++){var l=s[r],u=e.getComponentWithId(l);if(u){var _=this.getRecordForUploadedComponent(u.id);u._data.etag=_.etag,u._data.length=_.length,u._data.version=_.version,u._data.md5=_.md5,_["source-href"]?e._core._getSourceHrefOfComponent(u)===_["source-href"]&&(u._data.state="unmodified",e._core._setSourceHrefOfComponent(void 0,u)):e.hasLocalStorage&&e._localStorage.componentAssetName(u,e._local())===_["storage-name"]?(u._data.state="unmodified",e._core._setSourceHrefOfComponent(void 0,u)):e.hasLocalStorage||(u._data.state="unmodified");}}e.manifestEtag=this.manifestEtag,["compositeHref","compositeAssetId","compositeLinks","compositeRepoMetadata"].forEach(function(t){n[t]!==e[t]&&(e[t]=n[t]);}),a||(e._data.state="unmodified");}t&&(e._isDirty=o);},r.prototype.commitChanges=function(e){if(this._filePath){var t=this;t._commitInProgress?(this._needAnotherCommit=!0,e&&this._waitingCallbacks.push(e)):function e(n){t._needAnotherCommit=!1,t._commitInProgress=!0,t._waitingCallbacks=[],o.writeFileAtomically(t._filePath,JSON.stringify(t._data),"utf8",function(i){var o,r=n.length;for(o=0;o<r;o++)try{n[o](i);}catch(e){}t._needAnotherCommit?e(t._waitingCallbacks):t._commitInProgress=!1;});}(e?[e]:[]);}else e&&e();},r.prototype._setData=function(e,t){if(e["push-journal-format-version"]<=2){var n=e["uploaded-components"];if(n){var i,o=Object.keys(n),r=o.length;for(i=0;i<r;i++){var a=n[o[i]];"number"==typeof a.version&&(a.version=String(a.version));}}e["push-journal-format-version"]=3;}var s=this._verify(e,t);if(null===s)return this._data=e,this;throw s;},r.prototype._verify=function(e,t){return 3!==e["push-journal-format-version"]?new i(i.INVALID_DATA,"Wrong push journal format version."):e["composite-href"]!==t?new i(i.INVALID_DATA,"Composite and journal hrefs mismatch."):e["uploaded-components"]?null:new i(i.INVALID_DATA,"Missing component list.");},e.exports=r;},function(e,t){e.exports=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e);};},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function a(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}(e):t;}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e);})(e);}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e;})(e,t);}var l=n(26),u=n(0),_=u.networkError,h=u.unexpectedResponse,p=n(5),d=function(e){function t(){return o(this,t),a(this,s(t).apply(this,arguments));}var n,i,l;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t);}(t,e),n=t,(i=[{key:"uploadAssetAtComponentHref",value:function(e,t,n,i,o,r,a,s){var c=this,l={};t&&(l["Content-Type"]=t);var p=function(t,n){t?delete l["If-Match"]:l["If-Match"]="*";var i=c._service.invoke("PUT",e,l,a,void 0,function(e,t){if(e)return n(_("Error uploading component",e,t));var i=t.statusCode;if(200===i||201===i||204===i){var o,r=t.responseText||t.response;if(!r||0===r.length)return n(void 0,t);try{o=JSON.parse(r);}catch(i){return(e=new u(u.INVALID_DATA,"Invalid JSON returned by server",i)).response=t,n(e,t,o);}n(void 0,t,o);}else e=h("Unexpected response uploading component",e,t),n(e);});return i.token=r,i;};return p(i,function(t,n,o){if(t){if(!(n=t.response))return s(t);var r=n.statusCode;i||404!==r?!i||409!==r&&412!==r?s(t):c._checkForComponentAlreadyUploaded(e,a,function(e,t){e?s(null,e,{md5:t}):p(!1,s);}):p(!0,s);}else s(void 0,n,o);});}},{key:"updateManifestAtHref",value:function(e,t,n,i,o){var r={"Content-Type":"application/vnd.adobe.dcx-manifest+json"};return i?r["If-Match"]="*":n&&(r["If-Match"]=n),this._service.invoke("PUT",e,r,t,void 0,function(e,t){if(e)return o(_("Error updating manifest",e,t));var r=t.statusCode;!t.headers.etag||200!==r&&201!==r&&204!==r?412===r||n&&!i&&409===r?((e=new u(u.UPDATE_CONFLICT,"Manifest has been changed")).response=t,o(e)):o(h("Unexpected response updating manifest",e,t)):o(void 0,t);});}},{key:"_checkForComponentAlreadyUploaded",value:function(e,t,n){var i=this;if(!(p.canUseFileSystem&&e&&t&&t.filename))return n();p.getMD5Hash(t.filename,function(t,o){if(t)return n();i.headRequest(e,function(e,t){if(e)return n();var i=t&&t.statusCode,r=t&&t.headers["content-md5"];200!==i||r!==o?n():n(t,r);});});}}])&&r(n.prototype,i),l&&r(n,l),t;}(l);e.exports=d;},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var o=n(0),r=o.networkError,a=o.unexpectedResponse,s=n(1),c=s.merge,l=s.appendPathElements,u=function(){function e(t,n,i){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._service=t,this._server=n,this._allowedEndpointRegex=i,n&&(this._endPoint=s.endPointOf(n)),this.SYNC_ASYNC_DEFAULT_DELAY=5,this.ASYNC_DEFAULT_DELAY=1,this.DEFAULT_POLL_DELAY=10,this._maxRedirects=5,this._authenticationAllowedList=[],!this._endPoint)throw new o(o.INVALID_PARAMS,"Could not determine endpoint from: "+n);this.authenticationAllowedList=["adobe.com","adobe.io","fotolia.net"];}var t,n,u;return t=e,(n=[{key:"isValidHref",value:function(e){var t=s.endPointOf(e);return!t||this._isEndpointAllowed(t);}},{key:"isDomainOnAllowedList",value:function(e){var t=s.parseURI(e).authority;if(!t||0===t.length)return!0;for(var n=t.length,i=this._authenticationAllowedList.length,o=0;o<i;o++){var r=this._authenticationAllowedList[o],a=r.length;if((n>a?t.slice(-a):t)===r)return!0;}return!1;}},{key:"getAsset",value:function(e,t,n){var i,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},u=arguments.length>4?arguments[4]:void 0;if("function"==typeof l&&(u=l,l={}),l.isDirectDownload||(e=this._resolveUrl(e)),!e)return u(new o(o.WRONG_ENDPOINT,"Wrong endpoint: "+e));var _={};"string"==typeof t?_["If-None-Match"]=t:c(_,t);var h,p=this,d=0;function f(e,t){if(e)return u(r("Error downloading an asset",e,t));var n=t.statusCode;if(200===n)u(void 0,t);else if(304===n)u(void 0,t);else if(301===n||302===n||303===n||307===n){if(!p._service.handlesRedirects&&p.maxRedirects){if(d<p.maxRedirects){var i=t.headers.location;i?h(i):u(a("Missing location header in redirect response",e,t));}else u(a("Too many redirects",e,t));}else u(a("Unexpected response getting an asset",e,t));}else u(a("Unexpected response getting an asset",e,t));}return(i=(h=function(t){var o={responseType:n};return l.isDirectDownload&&(_.Authorization=null,_["x-api-key"]=null,_["X-Request-Id"]=null),t&&(d++,o.reuseRequestDesc=i,p.isDomainOnAllowedList(t)||(_.Authorization=null)),p._service.invoke("GET",t||e,_,void 0,o,f);})()).progress=s.noOp,i;}},{key:"getAssetAsType",value:function(e,t,n,i){return this.getAsset(e,n,t,function(e,t){if(e)return i(e);if(200===t.statusCode){var n=t.response||t.responseText;i(void 0,n,t.headers.etag,t);}else 304===t.statusCode?i(void 0,null,t.headers.etag,t):i(a("Unexpected response getting asset",e,t));});}},{key:"headRequest",value:function(e,t){return this._service.invoke("HEAD",e,{},void 0,void 0,function(e,n){if(e)return t(e);t(e,n);});}},{key:"abortAll",value:function(){this._service.abortAll();}},{key:"_resolveUrl",value:function(e){if(void 0!==e){var t=s.endPointOf(e);if(t){if(!this._isEndpointAllowed(t))return;return e;}return l(this._server,e);}}},{key:"_isEndpointAllowed",value:function(e){return this._allowedEndpointRegex&&this._allowedEndpointRegex.test(e)||e===this._endPoint;}},{key:"_makeRelativeUrl",value:function(e){var t=s.endPointOf(e);if(t){if(t!==this._endPoint)return;var n=s.parseURI(e);(n.scheme||n.authority)&&(e=n.path,n.query&&(e+="?"+n.query),n.fragment&&(e+="#"+n.fragment));}return e;}},{key:"_parseAsyncResponse",value:function(e){var t=e.responseText||e.response;if(!t)throw new o(o.INVALID_DATA,"No body data.");var n={},i=t.indexOf("\n");if(-1===i)throw new o(o.INVALID_DATA,"Could not find status line.");var r=t.slice(0,13===t.charCodeAt(i-1)?i-1:i).split(" ");if(n.statusCode=parseInt(r[1],10),!n.statusCode)throw new o(o.INVALID_DATA,"Could not find status code.");r.length>2&&(n.statusText=r[2]);var a=t.search(/\r?\n\r?\n/);-1===a&&(a=t.length);var c=t.slice(i+1,a);n.headers=s.parseHeaders(c);var l="\r"===t.charAt(a)?a+4:a+2;return n.response=t.slice(l),n;}},{key:"_pollForAsyncResponse",value:function(e,t,n){var i=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this._parseAsyncResponse,c=arguments.length>4?arguments[4]:void 0,l=Date.now()+1e3*t,u={responseType:"text",reuseRequestDesc:n,noSoonerThen:l};s.log("asynchronous request - polling"),n=this._service.invoke("GET",e,void 0,void 0,u,function(t,l){if(t)return c(r("Error polling for an asynchronous response",t,l));var u=l.statusCode;if(202===u){s.log("asynchronous request - not yet ready");var _=l.headers["retry-after"];_&&(_=parseInt(_,10)),i._pollForAsyncResponse(e,_||i.DEFAULT_POLL_DELAY,n,o,c);}else if(200===u){s.log("asynchronous request - success");try{l=o(l);}catch(e){return c(a("Error parsing response body.",e,l));}200===(u=l.statusCode)||201===u||204===u?c(void 0,l):c(a("Unexpected response polling for an asynchronous response",t,l));}else s.log("asynchronous request - error"),c(a("Unexpected response polling for an asynchronous response",t,l));});}},{key:"_handle202Response",value:function(e,t,n,i,o){var r,s=e.responseText||e.response;try{r=JSON.parse(s);}catch(t){return o(a("Error parsing 202 response body.",t,e));}var c=r.href;if(!c)return o(a("202 response missing an href.",void 0,e));var l=e.headers["retry-after"];l=l?parseInt(l,10):n,this._pollForAsyncResponse(this._resolveUrl(c),l,t,i,o);}},{key:"_doHeadRequest",value:function(e,t){return this.headRequest(e,function(e,n){return e?t(new o(o.NETWORK_ERROR,"HEAD request failed",e)):[200,202,204].includes(n.statusCode)?void t(null,n):t(o.wrapError(o.UNEXPECTED_RESPONSE,"HEAD request yielded unexpected response",void 0,n));});}},{key:"_getCopyDelegate",value:function(e,t,n){var i=this;if(!this.isValidHref(e))return n(new o(o.WRONG_ENDPOINT,"Source href is not compatible with this service: ".concat(e)));n(null,function(n,o,r,a,s,c){return i.copyAssetToComponentId(n,o,t,r,a,s,e,c);});}},{key:"maxRedirects",get:function(){return this._maxRedirects;},set:function(e){if("number"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a number.");this._maxRedirects=Math.floor(e);}},{key:"authenticationAllowedList",get:function(){return this._authenticationAllowedList;},set:function(e){if(!Array.isArray(e))throw new o(o.INVALID_PARAMS,"Expecting an array.");this._authenticationAllowedList=e;}}])&&i(t.prototype,n),u&&i(t,u),e;}();e.exports=u;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable;})),n.push.apply(n,i);}return n;}function r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach(function(t){c(e,t,n[t]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t));});}return e;}function a(e,t){if(null==e)return{};var n,i,o=function(e,t){if(null==e)return{};var n,i,o={},r=Object.keys(e);for(i=0;i<r.length;i++)n=r[i],t.indexOf(n)>=0||(o[n]=e[n]);return o;}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(i=0;i<r.length;i++)n=r[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n]);}return o;}function s(e,t){return function(e){if(Array.isArray(e))return e;}(e)||function(e,t){if(!(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)))return;var n=[],i=!0,o=!1,r=void 0;try{for(var a,s=e[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);i=!0);}catch(e){o=!0,r=e;}finally{try{i||null==s.return||s.return();}finally{if(o)throw r;}}return n;}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}();}function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e;}function l(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function u(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}(e):t;}function _(e,t,n){return(_="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=h(e)););return e;}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(n):o.value;}})(e,t,n||e);}function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e);})(e);}function p(e,t){return(p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e;})(e,t);}var d=n(25),f=n(0),m=n(8),v=n(1),y=n(14),g=n(64),E=n(29),O=f.networkError,S=f.unexpectedResponse,A=n(65),T=n(21),b=/^(https:\/\/cc-api-storage(?:-stage)?\.adobe\.io(?::443)?\/.+)\/([^;/]+)/,L=/\/[^/]+$/,I=function(e){function t(e,n,i,o){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,t),(r=u(this,h(t).call(this,e,n,i))).setRootDocument(o),r;}var n,i,o;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&p(e,t);}(t,e),n=t,(i=[{key:"getRootDocument",value:function(e){var t=this;return this._getAllPages(this._server,void 0,function(n){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=i.result,r=i.etag,a=i.headers;if(n)return e(n);t.setRootDocument(o),e(null,o,r,a);});}},{key:"setRootDocument",value:function(e){this._rootDocument=e,this._rootLinks=e&&e._links;}},{key:"getAssets",value:function(e){var t;try{t=this._getUrlFromRootDocument("Assets.json",m.PAGE);}catch(t){return e(t);}return this._getAllPages(t,void 0,function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.result,o=n.etag,r=n.headers;return t?e(t):e(null,i,o,r);});}},{key:"getRepositories",value:function(e){var t;try{t=this._getUrlFromRootDocument("Repositories.json",m.PAGE);}catch(t){return e(t);}return this._getAllPages(t,void 0,function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.result,o=n.etag,r=n.headers;return t?e(t):e(null,i,o,r);});}},{key:"getEffectiveACFromLinks",value:function(e,t){var n=v.getUrlFromLinks(e,m.AC_EFFECTIVE);return this._getResponse(n,void 0,function(e,n){if(e)return t(e);var i=n&&n.result,o=i&&i[m.PRIMARY]||i["*"]||[];t(null,o);});}},{key:"getRepoMetadataFromLinks",value:function(e,t){var n=v.getUrlFromLinks(e,m.METADATA);return this._getResponse(n,void 0,function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.result;return e?t(e):t(null,i);});}},{key:"getCachedLinks",value:function(e,t){return e.assetId?e.links&&e.links._expiry>Date.now()?t(void 0,e.links):this.getLinksFromUrn(e.assetId,t):t(new f(f.INVALID_DATA,"Composite is not bound."));}},{key:"getLinksFromUrn",value:function(e,t){var n=this,i=new E();return i.push(this._getRootLinks(function(o,r){if(o)return t(o);var a=v.getUrlFromLinks(r,m.RESOLVE_ID,{id:e});i.push(n.getLinksFromUrl(a,t));})),i;}},{key:"getLinksFromPath",value:function(e,t,n){var i=this,o=new E();return o.push(this._getRootLinks(function(r,a){if(r)return n(r);var s=v.getUrlFromLinks(a,m.RESOLVE_PATH,{repositoryId:e,path:t});o.push(i.getLinksFromUrl(s,n));})),o;}},{key:"getLinksFromUrl",value:function(e,t){return this._getLinks(e,function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.links,o=n.response;return e?t(e):t(null,i,o);});}},{key:"getCollection",value:function(e,t,n){var i={};return t&&(i["If-None-Match"]=t),this._getAllPages(e,i,function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.result,o=t.etag,r=t.headers;return e?n(e):n(null,i,o,r);});}},{key:"getComponent",value:function(e,t,n){var i=this,o=e._owner;if(!o||!o.compositeLinks)throw new f(f.INVALID_STATE,"Component must be part of a branch of a bound composite.");var r=new E(),a=v.getUrlFromLinks(o.compositeLinks,m.DOWNLOAD,{resource:m.COMPONENT,revision:e.version||0,component_id:e.id});return r.push(this._service.invoke("GET",a,{},void 0,{responseType:"json"},function(e,o){if(e)return n(e);var a;try{a=JSON.parse(o.response).href;}catch(e){}if(!a)return n(new f(f.INVALID_DATA,"No href returned in api:download response."));r.push(i.getAsset(a,void 0,t,{isDirectDownload:!0},n));})),r;}},{key:"getRenditionOfComponent",value:function(e,t,n,i,o){var r;try{r=this.getComponentRenditionHref(e,e.version,n);}catch(e){return o(e);}this.getAsset(r,{accept:t},i,o);}},{key:"getCompositeManifest",value:function(e,t,n){if(e.isDiscarded)return n(new f(f.NO_COMPOSITE,"Composite has been discarded. ID: ".concat(e.id)));var i=this.getCompositeManifestHref(e);return this.getAssetAsType(i,"text",t,n);}},{key:"createCompositeDirectory",value:function(e,t,n){var i=this;if(t)return n(new f(f.INVALID_PARAMS));this._createComposite(e).then(function(t){var o=t.response,r=i._getLinksFromResponse(o),a=JSON.parse(o.response),s=a["repo:createdBy"],c=a["storage:assignee"];(c&&"org"===c.type?i._setDenyFromLinks(r,s):Promise.resolve()).then(function(){e.links=r,e.href=v.getUrlFromLinks(r,m.PRIMARY),e.assetId=o.headers["x-resource-id"],e.repoMetadata=a,e.storageAssignee=c,e.isWritable=!0,e.isParentWritable=!0,n(void 0,o);},n);},n);}},{key:"deleteCompositeDirectory",value:function(e,t){t(new f(f.INVALID_STATE,"Composites can only be discarded on platform."));}},{key:"discardComposite",value:function(e,t){var n=this,i=c({},"If-Match","*");return this._service.invoke("POST",v.getUrlFromLinks(e.links,m.DISCARD),i,void 0,{responseType:"text"},function(i,o){var r=function(){t(O("Error disposing composite directory",i,o));};return i||![200,201,204,403,404].includes(o.statusCode)?r():403===o.statusCode?n._getLinks(v.getUrlFromLinks(e.links,m.PRIMARY),function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.links;if(e){var a=e&&e.response&&e.response.statusCode;return[403,404].includes(a)?t():r();}if(v.getUrlFromLinks(i,m.DISCARD))return r();t(void 0,o);}):void t(void 0,o);});}},{key:"renameCompositeIfNecessary",value:function(e,t){var n=this,i=function(){v.log("Error: Tried to rename a composite without parent permissions. ".concat(e.assetId));var i=n._getCompositeNameFromRepoName(e);e.isRenamePending=!1,i&&i!==e.name&&(e.name=i),t();};return!e.isRenamePending||this._doesRepoNameMatchPath(e)?t():e.isParentWritable?void this.getRepoMetadataFromLinks(e.links,function(o,r){if(o)return t(o);if(!r["storage:assignee"]||"org"!==r["storage:assignee"].type)return t();var a=r["repo:path"],s=a.replace(L,""),c=r["repo:repositoryId"];if(s===a||!c)return t(new f(f.UNEXPECTED_RESPONSE,"Could not get metadata: ".concat(e.id)));n._moveComposite(e,s,c).then(function(n){var i=n.name,o=n.path;r["repo:name"]=i,r["repo:path"]=o,e.repoMetadata=r,e.isRenamePending=!1,t();},function(e){return[f.NOT_FOUND,f.ACCESS_DENIED].includes(e.code)?i():t(e);});}):i();}},{key:"updateCompositeMetadata",value:function(e,t){var n=e.links&&e.links._expiry;return this._getCompositeMetadata(e,function(i){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=o.links,a=o.isWritable,s=o.parentAssetId,c=o.isParentWritable,l=o.storageAssignee,u=o.repoName,_=o.repoMetadata;if(i)return t(i);var h=!1;r._expiry!==n&&(h=!0);var p=u.replace(/\.cclibc$/,""),d=e.storageAssignee&&"org"===e.storageAssignee.type;!e.isRenamePending&&d&&e.name!==p&&(e.name=p,h=!0);var f=v.getUrlFromLinks(r,m.PRIMARY);f!==e.href&&(e.href=f,h=!0),JSON.stringify(e.repoMetadata)!==JSON.stringify(_)&&(e.repoMetadata=_,h=!0),e.isWritable!==a&&(e.isWritable=a,h=!0),JSON.stringify(e.storageAssignee)!==JSON.stringify(l)&&(e.storageAssignee=l,h=!0),s&&(e.parentAssetId!==s&&(e.parentAssetId=s,h=!0),e.isParentWritable!==c&&(e.isParentWritable=c,h=!0)),t(null,h);});}},{key:"_getCompositeMetadata",value:function(e,t){var n=this,i=new E();return i.push(this.getCachedLinks(e,function(o,r){if(o)return t(o);var a,c,l;e.links=r,a=new Promise(function(t,o){i.push(n.getEffectiveACFromLinks(e.links,function(e,n){return e?o(e):t(n);}));}),c=new Promise(function(t,o){i.push(n.getRepoMetadataFromLinks(e.links,function(e,n){return e?o(e):t(n);}));}),l=new Promise(function(t,o){i.push(n._getCachedParentInfo(e.links,function(e,n){return e?o(e):t(n);}));}),Promise.all([a,l,c]).then(function(n){var i=s(n,3),o=i[0],r=i[1],a=i[2],c=o.includes("write"),l=r&&r.assetId,u=r&&r.permissions.includes("write"),_=a["storage:assignee"],h=a["repo:name"];t(null,{links:e.links,isWritable:c,parentAssetId:l,isParentWritable:u,storageAssignee:_,repoName:h,repoMetadata:a});},t);})),i;}},{key:"_getCachedParentInfo",value:function(e,t){var n=this,i=v.getUrlFromLinks(e,m.DIRECTORY),o=this._parentInfoCache&&this._parentInfoCache[i];return(!o||o.expiry<Date.now())&&(o=new g(this,function(t){return n._getParentInfo(e,t);}),this._parentInfoCache=this._parentInfoCache||{},this._parentInfoCache[i]=o),o.push(t);}},{key:"_getParentInfo",value:function(e,t){var n=this,i=new E(),o=v.getUrlFromLinks(e,m.DIRECTORY);return i.push(this.getLinksFromUrl(o,function(e,o,r){if(e)return e.response&&404===e.response.statusCode?t(null,{permissions:[],assetId:void 0}):t(e);var a=r.headers["x-resource-id"];i.push(n.getEffectiveACFromLinks(o,function(e,n){if(e)return t(e);t(null,{permissions:n,assetId:a});}));})),i;}},{key:"uploadComponent",value:function(e,t,n,i,o,r){if(!e._owner||!e._owner.compositeLinks)throw new f(f.INVALID_STATE,"Component must be part of a branch of a bound composite.");var a=e._owner.compositeLinks,s=a[m.CREATE]&&a[m.CREATE]["repo:maxsingletransfersize"]||9437184;if(o instanceof y&&o.size>=s)return this._blockUploadComponent(e,t,n,i,o,r);var c=v.getUrlFromLinks(e._owner.compositeLinks,m.COMPONENT,{component_id:e.id});return this.uploadAssetAtComponentHref(c,e.type,e._owner.compositeHref,t,n,i,o,r);}},{key:"_blockUploadComponent",value:function(e,t,n,i,o,r){var a=this,s=new E(),c=v.getUrlFromLinks(e._owner.compositeLinks,m.BLOCK_INITIALIZE),l=JSON.stringify({component_id:e.id,"repo:size":o.size,"repo:blocksize":6e6,"repo:reltype":m.COMPONENT,"repo:if-match":t?null:"*","dc:format":e.type});return this._postRequest(c,{"Content-Type":"application/vnd.adobecloud.bulk-transfer+json"},l,s).then(function(t){for(var n=a._processJsonResponse(t).result,i=n["repo:blocksize"],r=n._links[m.BLOCK_TRANSFER],c=v.getUrlFromLinks(n._links,m.BLOCK_FINALIZE),l=[],u=0,_=0;_<o.size;u++,_+=i){var h=r[u].href,p=Math.min(o.size,_+i)-1;l.push(a._uploadBlock(h,o.filename,e.type,_,p,s));}return Promise.all(l).then(function(){return a._postRequest(c,{"Content-Type":"application/vnd.adobecloud.bulk-transfer+json"},JSON.stringify(n),s);});}).then(function(){return a._doHeadRequest(v.getUrlFromLinks(e._owner.compositeLinks,m.COMPONENT,{component_id:e.id,revision:e.version}),function(e,t){return r(e,t,{});});}),s;}},{key:"_uploadBlock",value:function(e,t,n,i,o,r){var a=this,s={Authorization:null,"X-Request-Id":null,"Content-Length":o-i+1,"Content-Type":n},c=new y(t,void 0,{start:i,end:o});return new Promise(function(t,n){var i={method:"PUT",href:e,headers:s,callback:function(i,o){i?n(i):[200,201,204].includes(o.statusCode)?t():n(S("Unexpected status code from: ".concat(e),void 0,o));},body:c,options:{responseType:"json"}};a._service._doRequest(i),r&&r.push(i,!0);});}},{key:"copyAssetToComponentId",value:function(e,t,n,i,o,r,a,s){var c=this._invokeOperation("copy",{href:a,"if-match":"*"},{href:"".concat(n,"?component_id=").concat(e),"if-match":"*"},s);return c.token=r,c;}},{key:"updateManifest",value:function(e,t,n,i){var o=v.getUrlFromLinks(e.compositeLinks,m.MANIFEST);return this.updateManifestAtHref(o,t,e.manifestEtag,n,i);}},{key:"updateManifestAtHref",value:function(e,t,n,i,o){var r={"Content-Type":"application/vnd.adobe.dcx-manifest+json"};return i?r["If-Match"]="*":n&&(r["If-Match"]=n),this._service.invoke("PUT",e,r,t,void 0,function(e,t){if(e)return o(O("Error updating manifest",e,t));var r=t.statusCode;!t.headers.etag||200!==r&&201!==r&&204!==r?412===r||n&&!i&&409===r?((e=new f(f.UPDATE_CONFLICT,"Manifest has been changed")).response=t,o(e)):o(S("Unexpected response updating manifest",e,t)):o(void 0,t);});}},{key:"getHrefForComposite",value:function(e){return e.href;}},{key:"getCompositeManifestHref",value:function(e){return v.getUrlFromLinks(e.links,m.MANIFEST);}},{key:"getBranchManifestHref",value:function(e){return v.getUrlFromLinks(e.compositeLinks,m.MANIFEST);}},{key:"getComponentHref",value:function(e,t){var n=e._owner;if(!n||!n.compositeLinks)throw new f(f.INVALID_STATE,"Component must be part of a branch of a bound composite.");return v.getUrlFromLinks(n.compositeLinks,m.COMPONENT,{revision:t,component_id:e.id});}},{key:"getComponentRenditionHref",value:function(e,t,n){var i=e._owner;if(!i||!i.compositeLinks)throw new f(f.INVALID_STATE,"Component must be part of a branch of a bound composite.");return v.getUrlFromLinks(i.compositeLinks,m.RENDITION,{fragment:"id=".concat(e.id),size:n});}},{key:"_invokeOperation",value:function(e,t,n,i){var o=this,r=v.getUrlFromLinks(this._rootLinks,m.OPS),a={op:e,target:n,source:t};v.log("[invoke operation]: ".concat(JSON.stringify(a,void 0,2)));var s=function(e,t){var n;if(e)return i(e);try{n=JSON.parse(t.responseText||t.response);}catch(n){return(e=new f(f.INVALID_DATA,"Invalid JSON returned by server",n)).response=t,i(e);}if(n.error)return(e=new f(f.UNEXPECTED_RESPONSE,"Error in operation result: "+JSON.stringify(n.error,void 0,2))).response=t,i(e);i(void 0,t,n&&n.asset);},c=this._service.invoke("POST",r,{"Content-Type":"application/json"},JSON.stringify([a]),{responseType:"text"},function(t,n){if(t)return s(O("Error invoking operation "+e,t,n));var i=n.statusCode;200===i||201===i||204===i?s(void 0,n):202===i?o._handle202Response(n,c,o.SYNC_ASYNC_DEFAULT_DELAY,function(e){return e;},function(e,t){s(e,t);}):s(S("Unexpected response for operation "+e,t,n),n);});return c;}},{key:"_getLinks",value:function(e,t){var n=this;return this._doHeadRequest(e,function(e,i){if(e)return t(e);t(null,{links:n._getLinksFromResponse(i),response:i});});}},{key:"_getLinksFromResponse",value:function(e){var t=e&&e.headers.link;if(!t)throw new f(f.UNEXPECTED_RESPONSE,"HEAD request did not return link header");var n=A.parse(t);return n&&n.refs.reduce(function(e,t){var n=t.rel,i=t.uri,o=a(t,["rel","uri"]);return n&&(e[n]=e[n]||[],e[n].push(r({href:i},o))),e;},{_expiry:Date.now()+2592e6});}},{key:"_getRootLinks",value:function(e){var t=this;return this._rootLinks?(e(null,this._rootLinks),new E()):this.getRootDocument(function(n){return n?e(n):e(null,t._rootLinks);});}},{key:"_getAllPages",value:function(e,t,n){var i,o=new E();return o.push(this._getPagedResponse(e,t,function(e,t){return e?n(e):function e(t){return t&&t.result&&t.result.children?(i?i.result.children=i.result.children.concat(t.result.children):i=t,t.next?void o.push(t.next(function(t,i){return t?n(t):e(i);})):n(null,i)):n(null,i);}(t);})),o;}},{key:"_getPagedResponse",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;return this._getResponse(e,n,function(e,n){if(e)return i(e);var o,a=n.result,s=n.etag,c=n.headers;if(a&&a._page&&a._page.next&&a._links&&a._links[m.PAGE]){var l=new T(a._links[m.PAGE].href);o=function(e){return t._getPagedResponse(l.fill(r({},a._page,{start:a._page.next,resource:m.PRIMARY})),c,e);};}i(null,{result:a,etag:s,headers:c,next:o});});}},{key:"_processJsonResponse",value:function(e){var t;try{var n=e.responseText||e.response;t=JSON.parse(n);}catch(t){var i=new f(f.INVALID_DATA,"Invalid JSON returned by server",t);throw i.response=e,i;}return{result:t,etag:e.headers.etag,headers:e.headers,response:e};}},{key:"_getResponse",value:function(e,t,n){var i=this;return this._service.invoke("GET",e,t,void 0,{responseType:"text"},function(t,o){if(t)return n(O("Error reading from: ".concat(e),t,o));200===o.statusCode?n(null,i._processJsonResponse(o)):304===o.statusCode?n(null,{etag:o.headers.etag,headers:o.headers}):n(S("Unexpected status code from: ".concat(e),void 0,o));});}},{key:"_postRequest",value:function(e,t,n,i){var o=this;return new Promise(function(r,a){var s=function(t,n){return a(O("Error reading from: ".concat(e),t,n));},c=o._service.invoke("POST",e,t,n,{responseType:"text"},function(t,n){if(t)return s(t,n);200===n.statusCode||201===n.statusCode||204===n.statusCode?r(n):202===n.statusCode?o._handle202Response(n,c,o.SYNC_ASYNC_DEFAULT_DELAY,void 0,function(e,t){e?s(e,t):r(t);}):a(S("Unexpected status code from: ".concat(e),void 0,n));});i&&i.push(c);});}},{key:"_createComposite",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return new Promise(function(i,o){var r={"Content-Type":e.type},a=new T(e.href),s=t._getCompositeName(e,n),c=s.baseName,l=s.repoName,u=a.fill({path:l,respondWith:m.METADATA});t._service.invoke("POST",u,r,void 0,void 0,function(r,a){return r||![200,201,204,409].includes(a.statusCode)?o(O("Error creating composite directory",r,a)):409===a.statusCode?i(t._createComposite(e,n+1)):(e.name=c,i({href:u,response:a}));});});}},{key:"_setDenyFromLinks",value:function(e,t){var n=this,i=v.getUrlFromLinks(e,m.AC_POLICY),o={"Content-Type":"application/vnd.adobecloud.accesscontrolpolicy+json"},r={"repo:acl":[{"repo:principal":{"xdm:provider":{"@id":"https://ims-na1.adobelogin.com/"},"@type":"https://ns.adobe.com/adobecloudplatform/ims/user","@id":t},"repo:modifier":"grant","repo:privileges":["read","write","delete"],"repo:relations":[m.DESCRIBED_BY,m.AC_POLICY,m.ANNOTATIONS,m.APP_METADATA,m.EMBEDDED_METADATA,m.METADATA,m.PRIMARY,m.RENDITION]},{"repo:principal":"all","repo:modifier":"deny","repo:privileges":["read","write","delete"]}]};return new Promise(function(e,t){n._service.invoke("PUT",i,o,JSON.stringify(r),{responseType:"text"},function(n,i){return n?t(n):e(i);});});}},{key:"_getCompositeName",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=e.name;v.platformRepoNameValidators.isNotReserved(n)||(n="".concat(n," "));var i="".concat(n).concat(t?" ".concat(t):"").replace(v.platformRepoNameRules.reservedCharRegex,"_");return{baseName:i,repoName:"".concat(i).concat(v.getExtension(e.type))};}},{key:"_getCompositeNameFromRepoName",value:function(e){var t=new RegExp("^([^. ]+)(?: [0-9]+)?".concat(v.getExtension(e.type).replace(".","\\."),"$")),n=e.repoMetadata&&e.repoMetadata["repo:name"];return s(t.exec(n)||[],2)[1];}},{key:"_doesRepoNameMatchPath",value:function(e){return this._getCompositeNameFromRepoName(e)===e.name;}},{key:"_getStorageLinkTemplate",value:function(e){var t=this;this._storageLinkCache=this._storageLinkCache||{},this._storageLinkCache[e]=this._storageLinkCache[e]||{};var n,i=this._storageLinkCache[e];if(Date.now()<i.expiresAt){var o=new T(i.template);if(o)return Promise.resolve(o);}return i.fetchingPromise||(i.fetchingPromise=(n=e,new Promise(function(e,i){return t._doHeadRequest(n,function(t,n){return t?i(t):e(n);});})).then(function(n){var i=n&&n.headers&&n.headers["x-resource-urn"];return i?new Promise(function(n,o){return t.getLinksFromUrn(i,function(i,r){if(i)return o(i);try{var a=v.getTemplateFromLinks(r,m.COMPONENT);t._storageLinkCache[e]={template:a,expiresAt:Date.now()+36e5},n(new T(a));}catch(i){o(i);}});}):Promise.reject(new f(f.INVALID_DATA,"Request for composite did not return a URN: ".concat(e)));}),i.fetchingPromise.catch(function(){return delete t._storageLinkCache[e].fetchingPromise;})),i.fetchingPromise;}},{key:"_getCopyDelegate",value:function(e,n,i){var o=this;_(h(t.prototype),"_getCopyDelegate",this).call(this,e,n,function(t,r){if(!t)return i(null,r);var a=s(b.exec(e)||[],3),c=a[1],l=a[2];if(!c||!l)return i(new f(f.INVALID_PARAMS,"Href is not for a component: ".concat(e)));o._getStorageLinkTemplate(c).then(function(e){var t=e.fill({component_id:l});i(null,function(e,i,r,a,s,c){return o.copyAssetToComponentId(e,i,n,r,a,s,t,c);});},i);});}},{key:"_handle202Response",value:function(e,t,n,i,o){var r=e&&e.headers&&e.headers.location;if(!r)return o(S("202 response missing an href.",void 0,e));this._pollForAsyncResponse(this._resolveUrl(r),n,t,i,o);}},{key:"_getUrlFromRootDocument",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:m.PRIMARY;try{var n=this._rootDocument.children.find(function(t){return t["repo:name"]===e;}),i=new T(n._links[t].href);return i.fill({});}catch(t){throw new f(f.INVALID_DATA,"".concat(e," does not exist in document root"),t);}}},{key:"_encodeURIComponent",value:function(e){return encodeURIComponent(e).replace(/!/g,"%21");}},{key:"_moveComposite",value:function(e,t,n){var i=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return new Promise(function(r,a){var s=i._getCompositeName(e,o).repoName,c="".concat(t,"/").concat(s);i._invokeOperation("move",{href:e.href,"if-match":"*"},{path:c,"repo:repositoryId":n,"if-match":"*"},function(l){if(l){var u=i._getOperationStatusCode(l);return 409===u?r(i._moveComposite(e,t,n,o+1)):a(403===u?new f(f.ACCESS_DENIED,"Unable to complete ops request due to access violation.",l):404===u?new f(f.NOT_FOUND,"Unable to complete ops request. Source or target not found.",l):l);}r({name:s,path:c});});});}},{key:"_getOperationStatusCode",value:function(e){var t;if(e.response&&200===e.response.statusCode&&e.response.response)try{var n=JSON.parse(e.response.response);t=n.error&&n.error.status;}catch(e){v.log("Error parsing JSON ops response: ".concat(e));}return t||e.response&&e.response.statusCode;}}])&&l(n.prototype,i),o&&l(n,o),t;}(d);e.exports=I;},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var o=n(1),r=function(){function e(t,n,i){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._abortListeners=[],this._session=t,this._callback=n,this._cleanup=i,this._componentsPending=0,this.bytesTransfered=0,this.bytesTotal=0,this.onProgress=o.noOp,this._reportProgress=function(e){if(e>0){r.bytesTransfered+=e;var t=r.onProgress;t&&t(r.bytesTransfered,r.bytesTotal);}};}var t,n,r;return t=e,(n=[{key:"_callCallback",value:function(e,t){var n=this._callback;n&&(this._callback=void 0,n(e,t));}},{key:"_xferComplete",value:function(e,t){var n=this._cleanup;n?(this._cleanup=void 0,n(e,t)):this._callCallback(e,t);}},{key:"abort",value:function(e){this._aborted||(this._aborted=!0,e||(this._callback=void 0,e=new Error("Aborted")),this._xferComplete(e),this._session._service.abortAllWithToken(this),this._abortListeners.forEach(function(t){return t(e);}));}},{key:"addAbortListener",value:function(e){this._abortListeners.push(e);}},{key:"removeAbortListener",value:function(e){var t=this._abortListeners.indexOf(e);-1!==t&&this._abortListeners.splice(t,1);}}])&&i(t.prototype,n),r&&i(t,r),e;}();e.exports=r;},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._requests=[],this._bytesTransferred=0;}var t,i,o;return t=e,(i=[{key:"_onProgress",value:function(e){this._bytesTransferred+=e,this._progress&&this._progress(e);}},{key:"push",value:function(e,t){e&&(this._requests.push(e),e.token=this._token,t&&(e.progress=this._onProgress.bind(this)));}},{key:"token",set:function(e){this._token=e,this._requests.forEach(function(t){return t.token=e;});}},{key:"progress",set:function(e){this._progress=e;}},{key:"bytesSent",get:function(){return this._bytesTransferred;}}])&&n(t.prototype,i),o&&n(t,o),e;}();e.exports=i;},function(e,t,n){var i,o,r=n(12),a=n(15),s=n(13),c=n(0),l=n(23),u=n(1),_=n(5),h=n(14),p=n(28),d=n(29),f=a.STATES;function m(e,t,n){return c.wrapError(c.UNEXPECTED_RESPONSE,e,t,n);}var v={};function y(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t["repo:etag"]||e.headers.etag,i=t["repo:version"]||e.headers["x-latest-version"]||e.headers.version||e.headers.revision,o=t.md5||e.headers["content-md5"],r=t["repo:size"]||t.size||parseInt(e.headers["content-length"]);return{etag:n,version:i,md5:o,length:r};}v.pullComposite=function(e,t,n){if(!e.hasLocalStorage)throw new c(c.INVALID_PARAMS,"No local storage. Use AdobeDCXCompositeXfer.pullCompositeManifestOnly() to pull down the composite without local storage.");return this._pullComposite(e,t,"all",n);},v.pullMinimumComposite=function(e,t,n){if(!e.hasLocalStorage)throw new c(c.INVALID_PARAMS,"No local storage. Use AdobeDCXCompositeXfer.pullCompositeManifestOnly() to pull down the composite without local storage.");return this._pullComposite(e,t,"min",n);},v.pullCompositeManifestOnly=function(e,t,n){return this._pullComposite(e,t,"none",n);},v.downloadComponents=function(e,t,n,i){var o=function e(t){return t._owner?e(t._owner):t;}(t),r=new p(n,i);r._referenceBranch=o;var a=function(){return v._pullComponents(r,o,e||t.allComponents());};return o.hasLocalStorage?o._localStorage.loadPullJournal().then(function(e){r._journal=e,a();}):a(),r;},v.pushComposite=function(e,t,n,i){var o,r=e._localStorage;(o=new p(n,i,function(t,n){if(o._owner&&e.hasLocalStorage&&r.unregisterInMemoryBranchOrElement(o._owner),!e.hasLocalStorage){var i=o._journal;e._pushJournal=i.isEmpty?void 0:i;}o._callCallback(t,n);}))._composite=e,o._overwriteExisting=t;var a=!e.isBound;if(o._compositeIsNew=a,e.hasLocalStorage)e._loadBranch(r.currentManifestPath(),!1,function(t,n){if(t)return o._xferComplete(t);o._owner=n,e._localStorage.registerInMemoryBranchOrElement(n),l.readJournal(r.pushJournalPath(),e,!0,function(t,n){if(t)return o._xferComplete(t);o._journal=n,v._pushComposite(e,o);});});else{if(!e.href)return o._xferComplete(new c(c.INVALID_STATE,"New composite has no href"));o._owner=e.current.copy(),o._journal=e._pushJournal||new l(e),v._pushComposite(e,o);}return o;},v.uploadNewComponent=function(e,t,n,o,a,s){if(n._localStorage)throw new c(c.INVALID_PARAMS,"For in-browser use only. Use composite.current.addComponent() to add a new component asset");return i(o||u.generateUuid(),t,!0,n.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,n.id,n.href,a,s);},v.uploadComponent=function(e,t,n,o,a){if(n._localStorage)throw new c(c.INVALID_PARAMS,"For in-browser use only. Use composite.current.updateComponent() to update a component asset");return i(e.id,e.type,!1,n.collaborationType===r.COLLABORATION.SHARED_WITH_USER,t,n.id,n.href,o,a);},v.copyAssetForNewComponent=function(e,t,n,i,a,s){if(n._localStorage)throw new c(c.INVALID_PARAMS,"For in-browser use only. Use composite.current.addComponent() to add a new component asset");return o(i||u.generateUuid(),t,!0,n.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,n.id,n.href,a,s);},v.getURLForComponent=function(e,t){if(e._owner._localStorage)throw new c(c.INVALID_PARAMS,"For in-browser use only.");return t.getComponentHref(e,e.version);},v.updateCompositeMetadata=function(e,t,n){var i=new p(t,n);if(!t.updateCompositeMetadata)return n();var o=t.updateCompositeMetadata(e,function(t,n){return t?t.code===c.UNEXPECTED_RESPONSE&&t.response&&404===t.response.statusCode?i._callCallback(new c(c.NO_COMPOSITE,"Composite not found.",t)):i._callCallback(t):n&&e._current?e.commitChanges(function(e){return i._xferComplete(e,n);}):void i._xferComplete();});return o&&(o.token=i,o.progress=i._reportProgress),i;},v._pullComposite=function(e,t,n,i){if("string"!=typeof e.href)throw new c(c.INVALID_STATE,"Composite must have an href");var o;var r=function(i,r){if(i)return o._xferComplete(i);var a;r?(a=r.manifestEtag,o._referenceBranch=r):e.current&&(a=e.current.manifestEtag,o._referenceBranch=e.current);var l=t.getCompositeManifest(e,a,function(t,i,a){if(t)return t.response&&404===t.response.statusCode?o._xferComplete(new c(c.NO_COMPOSITE,"Composite missing or deleted",t.underlyingError||t)):o._xferComplete(t);if(null===i&&!r)return o._xferComplete(void 0,null);var l;if(null!==i)try{if((l=new s().parse(i))._localStorage=e._localStorage,l.compositeHref=e.href,l.compositeLinks=e.links,l.compositeRepoMetadata=e.repoMetadata,l.compositeAssetId=e.assetId,l.compositeIsWritable=e.isWritable,l.compositeParentAssetId=e.parentAssetId,l.compositeIsParentWritable=e.isParentWritable,l.compositeIsRenamePending=e.isRenamePending,l.compositeStorageAssignee=e.storageAssignee,l._collaborationType=e.collaborationType,l._clientDataString=e.clientDataString,l.manifestEtag=a,l.compositeState===f.committedDelete||l.compositeState===f.pendingDelete)return void o._session.deleteCompositeDirectory(e,function(e){return e?o._xferComplete(new c(c.DELETED_COMPOSITE,"Error deleting composite directory",e)):o._xferComplete(new c(c.DELETED_COMPOSITE,"Composite is deleted"));});o._referenceBranch&&l.hasLocalStorage&&l._updateLocalDataFromBranch(o._referenceBranch);}catch(e){return o._xferComplete(new c(c.INVALID_JSON,"Corrupted manifest",e));}else l=r;var u,_,h=l.allComponents();for(u=0;u<h.length;++u)(_=h[u]).state===f.pendingDelete||_.state===f.committedDelete?l.removeComponent(_):_.state=f.unmodified;h=void 0,"all"===n?h=l.allComponents():"min"===n&&(_=l.getComponentWithAbsolutePath("/META-INF/metadata.xml"))&&(h=[_]),h?v._pullComponents(o,l,h):o._xferComplete(void 0,l);});l&&(l.token=o,l.progress=o._reportProgress);};return(o=new p(t,i,function(t,n){if(t){var i=t.pulledBranch;i?(i.compositeState=f.unmodified,i.hasLocalStorage?_.writeFileAtomically(e._localStorage.pulledManifestPath(),t.pulledBranch.localData,"utf8",function(){o._callCallback(t);}):o._callCallback(t)):o._callCallback(t);}else{if(null===n)return o._callCallback(void 0,null);if(n.compositeState=f.unmodified,n.readOnly=!0,n.hasLocalStorage){var r=e._localStorage.pulledManifestPath();_.writeFileAtomically(r,n.localData,"utf8",function(e){if(e)return o._callCallback(e);n.manifestPath=r,n._isDirty=!1,o._callCallback(void 0,n);});}else e._options.xhrBaseBranchSupport&&(e._pulledBranchData=n.localData),o._callCallback(void 0,n);}}))._composite=e,e.hasLocalStorage?e._localStorage.loadPullJournal().then(function(t){o._journal=t,e.loadPulledBranch(r);}):r(),o;},v._pullComponents=function(e,t,n){if(!t.hasLocalStorage)throw new c(c.INVALID_PARAMS,"No local storage.");var i,o=e._session;function r(i,o){if(e._componentsPending-=1,i?(e.failedComponents=e.failedComponents||[],e.failedComponents.push({component:o,error:i})):e._journal&&e._journal.saveComponentPath(o),0===e._componentsPending&&!e._aborted){var r=e.failedComponents;if(r){i=new c(c.COMPONENT_DOWNLOAD_ERROR,"Failed to download all components");var a,s=r.length;for(a=0;a<s;a++){var l=r[a].error;if(l.code===c.OUT_OF_SPACE){i=new c(l.code,l.message);break;}}i.pulledBranch=t,i.failedComponents=r;}t.readOnly&&t.manifestPath&&(!r||n.length>r.length)?_.writeFileAtomically(t.manifestPath,t.localData,"utf8",function(n){i=i||n,e._xferComplete(i,i?void 0:t);}):e._xferComplete(i,i?void 0:t);}}function a(t){if(!e._aborted){var n=e._journal;if(n&&n.restoreComponentPath(t))r(null,t);else{e.bytesTotal+=t.length||0;var i=t._owner._localStorage.tempPathForComponent(t),a=u.parentDirectory(i);_.ensureDirectoryExists(a,function(n){if(n)return e.abort(n);var a=v._pullComponent(t,i,o,r);a.progress=e._reportProgress,a.token=e;});}}}function s(e){t.assetOfComponent(e,function(t,n){"string"!=typeof n?a(e):r(void 0,e);});}for(e._componentsPending=n.length,i=0;i<n.length;++i){var l,h=n[i];if(e._referenceBranch){var p=e._referenceBranch.getComponentWithId(h.id);p&&(l=p.etag);}h.etag!==l?a(h):s(h);}0===e._componentsPending&&e._xferComplete(void 0,t);},v._pullComponent=function(e,t,n,i){var o=e._owner;if(!e._owner.hasLocalStorage)throw new c(c.INVALID_PARAMS,"No local storage. Use AdobeDCXCompositeXfer.pullCompositeManifestOnly() to pull down the composite without local storage.");var r=new d(),a=0;return r.push(function s(){return n.getComponent(e,new h(t),function(n,l){if(n)n.code===c.NETWORK_ERROR&&a<1?(a++,r.push(s(),!0)):i(n,e);else if(200===l.statusCode){var u=Number(l.headers["content-length"]);e.length&&!isNaN(u)&&u!==e.length?i(new c(c.UNEXPECTED_RESPONSE,"Incorrect content length: expected ".concat(e.length,", but received ").concat(l.headers["content-length"]),n,l),e):o._localStorage.ingestComponentAsset(e,t,!1,o._local(),function(t){i(t,e,l.headers.etag);});}else 304===l.statusCode?i(void 0,e,l.headers.etag):i(m("Unexpected response getting a component",n,l),e);});}(),!0),r;},v._pushComposite=function(e,t){var n=this;if(!e.href)return t._xferComplete(new c(c.INVALID_STATE,"New composite has no href"));var i=t._owner,o=t._journal,a=t._compositeIsNew,s=t._overwriteExisting,l=t._session,u=i.changeCount,h=i.remoteData.length+50;if(t.bytesTotal=h,i.compositeState===f.committedDelete||e.isDiscarded)return t._xferComplete(new c(c.DELETED_COMPOSITE,"Attempt to push a deleted composite"));if(!a&&i.compositeState===f.unmodified)return t._xferComplete();if(i.compositeState===f.pendingDiscard)return a&&!s?t._xferComplete(new c(c.DELETED_COMPOSITE,"Attempt to delete unbound composite")):l.discardComposite(e,function(e){t._xferComplete(e);});if(i.compositeState===f.pendingDelete)return a&&!s?t._xferComplete(new c(c.DELETED_COMPOSITE,"Attempt to delete unbound composite")):e.collaborationType===r.COLLABORATION.SHARED_WITH_USER?t._xferComplete(new c(c.INVALID_STATE,"Attempt to delete composite that is shared with this user.")):v._deleteComposite(t,s,function(e,n){t._xferComplete(e,n);});function p(n){if(a)return t._xferComplete(n);var i=l.getCompositeManifestHref(e);l.headRequest(i,function(e,i){return e?t._xferComplete(e):404===i.statusCode?(n=new c(c.NO_COMPOSITE,"Composite does not exist; may have been deleted"),t._xferComplete(n)):t._xferComplete(n);});}!function(e,t,n){if(e.isBound&&t.renameCompositeIfNecessary)return t.renameCompositeIfNecessary(e,n);n();}(e,l,function(r){if(r)return t._xferComplete(r);!function(e,t,n,i,o){function r(e){e||(t.compositeHasBeenCreated=!0);var n,i=t._compositeCreationCallbacks,o=i.length;for(n=0;n<o;n++)try{i[n](e);}catch(e){}t._compositeCreationCallbacks=void 0;}e.isBound||t.compositeHasBeenCreated?o():t._compositeCreationCallbacks?t._compositeCreationCallbacks.push(o):(t._compositeCreationCallbacks=[o],i.createCompositeDirectory(e,n,function(t,o){if(t){if(t.code!==c.ALREADY_EXISTS)return r(m("Unexpected response creating a composite directory",t,o));if(n)r();else{var a=i.getCompositeManifestHref(e);i.headRequest(a,function(e,t){return e?r(e):404!==t.statusCode?r(e=new c(c.ALREADY_EXISTS,"Composite already exists and overwriteExisting not specified")):void r();});}}else r();}));}(e,o,s,l,function(r){if(r)return t._xferComplete(r);n._applyCompositeChangesToBranchAndJournal(e,i,o,function(n){if(n)return t._xferComplete(n);v._pushComponents(t,i,function(){var r=t.failedComponents;if(r){n=new c(c.COMPONENT_UPLOAD_ERROR,"One or more components failed to upload.");var a,d=r.length;for(a=0;a<d;a++){var m=r[a].error;if(m.code===c.EXCEEDS_QUOTA){n=new c(m.code,m.message);break;}}return n.failedComponents=r,p(n);}if(i.compositeState===f.modified){i.compositeState=f.unmodified,o.manifestEtag&&o.currentBranchEtag===i.manifestEtag&&(i.manifestEtag=o.manifestEtag);var v=i.remoteData;t.bytesTotal+=v.length,t.bytesTotal-=h;var y=l.updateManifest(i,v,s,function(n,r){if(n)return p(n);var a=r.headers.etag;o.manifestEtag=a,o.currentBranchEtag=i.manifestEtag,o.changeCount=u,o.commitChanges(function(n){if(n)return t._xferComplete(n);o.applyToBranch(i),i.compositeState=f.unmodified,e.hasLocalStorage?_.writeFileAtomically(e._localStorage.pushedManifestPath(),i.localData,"utf8",function(e){if(e)return t._xferComplete(e);i._isDirty=!1,t._xferComplete(null,i);}):(e._options.xhrBaseBranchSupport&&(e._pushedBranchData=i.localData),t._xferComplete(null,i));});});y&&(y.progress=t._reportProgress,y.token=t);}else t._xferComplete(null,i);});});});});},v._applyCompositeChangesToBranchAndJournal=function(e,t,n,i){e.links&&(t.compositeLinks=e.links,n.compositeLinks=e.links),e.assetId&&(t.compositeAssetId=e.assetId,n.compositeAssetId=e.assetId),e.repoMetadata&&(t.compositeRepoMetadata=e.repoMetadata,n.compositeRepoMetadata=e.repoMetadata),e.href!==t.compositeHref&&(t.compositeHref=e.href,n.compositeHref=e.href),n.commitChanges(i);},v._deleteComposite=function(e,t,n){var i=e._composite,o=e._owner,r=e._session;o.compositeState=f.committedDelete;var a=o.remoteData;e.bytesTotal=a.length,e._journal.manifestEtag&&e._journal.currentBranchEtag===o.manifestEtag&&(o.manifestEtag=e._journal.manifestEtag),r.updateManifest(o,a,t,function(t){if(t)return n(t);r.deleteCompositeDirectory(i,function(t){if(t)return n(t);e._journal.compositeHasBeenDeleted=!0,e._journal.commitChanges(function(e){if(e)return n(e);i.hasLocalStorage?_.writeFileAtomically(i._localStorage.pushedManifestPath(),o.localData,"utf8",function(e){if(e)return n(e);n(void 0,o);}):n(void 0,o);});});});},v._pushComponents=function(e,t,n){var i,o=t.allComponents(),a=e._composite,s=a._localStorage,l={},p=e._journal;function d(t,i,o){i?l[t.id]=i:delete l[t.id],o&&(e.failedComponents=e.failedComponents||[],e.failedComponents.push({component:t,error:o})),0===Object.keys(l).length&&p.commitChanges(n);}function m(t,n,i){d(t,"uploading"),_.info(n,function(o,s){if(o)return o=new c(c.INVALID_STATE,"Component asset missing",o),void d(t,null,o);var l=s.size,_=u.filePathComponents(n).fileName,m=p.getRecordForUploadedComponent(t.id);if(m&&m.length===l&&m["storage-name"]===_)return t.etag=m.etag,t.version=m.version,t.md5=m.md5,t.length=m.length,t.state=f.unmodified,void d(t,null);e.bytesTotal+=l;var v=e._session.uploadComponent(t,i,a.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,new h(n,l),function(e,n,i){if(!e){var o=y(n,i),r=o.etag,a=o.version,s=o.md5;r||(e=new c(c.UNEXPECTED_RESPONSE,"No etag")),a||(e=new c(c.UNEXPECTED_RESPONSE,"No version")),s||(e=new c(c.UNEXPECTED_RESPONSE,"No md5")),e||(t.etag=r,t.version=a,t.md5=s,t.length=l,t.state=f.unmodified,p.recordUploadedComponent(t.id,r,a,s,l,_),p.commitChanges());}d(t,null,e);});v&&(v.progress=e._reportProgress,v.token=e);});}function v(n,i,o){function l(){if(s){var e=s.componentAssetPath(n,t._local());if("string"==typeof e)return m(n,e,o);}}var u=p.getRecordForUploadedComponent(n.id);if(u&&u["source-href"]===i)return n.etag=u.etag,n.version=u.version,n.md5=u.md5,n.length=u.length,void(n.state=f.unmodified);d(n,"copying"),e._session._getCopyDelegate(i,e._composite.href,function(t,s){if(t)return l();var u=s(n.id,n.type,o,a.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,function(e,t,o){if(e)return l();var r=y(t,o),a=r.etag,s=r.version,u=r.md5,_=r.length;a||(e=new c(c.UNEXPECTED_RESPONSE,"No etag")),s||(e=new c(c.UNEXPECTED_RESPONSE,"No version")),u||(e=new c(c.UNEXPECTED_RESPONSE,"No md5")),_||(e=new c(c.UNEXPECTED_RESPONSE,"No length")),e||(n.etag=a,n.version=s,n.md5=u,n.length=_,n.state=f.unmodified,p.recordUploadedComponent(n.id,a,s,u,_,void 0,i),p.commitChanges()),d(n,null,e);});u&&(u.progress=e._reportProgress,u.token=e);});}for(i=0;i<o.length;++i){var g=o[i],E=g.state,O=!g.etag;if(E||(E=f.unmodified),O||E===f.modified){var S=t._core._getSourceHrefOfComponent(g);if(t.hasLocalStorage||S){var A=O||e._compositeIsNew;if(S)v(g,S,A);else{var T=s.componentAssetPath(g,t._local());"string"==typeof T&&m(g,T,A);}}else{var b=new c(c.INVALID_STATE,"Component should not be modified or new without local storage");e.failedComponents=e.failedComponents||[],e.failedComponents.push({component:g,error:b});}}else E===f.unmodified?p.removeRecordForUploadedComponent(g.id):E!==f.committedDelete&&E!==f.pendingDelete||t.removeComponent(g);}0===Object.keys(l).length&&n();},i=function(e,t,n,i,o,r,s,l,u){if("function"!=typeof u)throw new c(c.INVALID_PARAMS,'Param "callback" must be a function.');var _=o.length||o.byteLength||o.size,h=new p(l,u);h.bytesTotal=_;var d=l.uploadAssetForComponentId(e,t,s,n,i,h,o,function(n,i,o){var s;if(!n)try{s=new a._UploadResults(r),_=_||d.bytesSent,s.records[e]=function(e,t,n,i,o){if("number"!=typeof t)throw new c(c.UNEXPECTED_RESPONSE,"No length");var r=y(i,o),s=r.etag,l=r.version,u=r.md5;if(!s)throw new c(c.UNEXPECTED_RESPONSE,"No etag");if(!l)throw new c(c.UNEXPECTED_RESPONSE,"No version");if(!u)throw new c(c.UNEXPECTED_RESPONSE,"No md5");return new a._UploadRecord(e,s,l,u,t,n);}(e,_,t,i,o);}catch(e){n=e,s=void 0;}h._xferComplete(n,s);});return d&&(d.progress=h._reportProgress,d.token=h),h;},o=function(e,t,n,i,o,r,s,l,u){if("function"!=typeof u)throw new c(c.INVALID_PARAMS,'Param "callback" must be a function.');var _=new p(l,u),h=l.copyAssetToComponentId(e,t,s,n,i,_,o,function(n,i,o){if(!_._aborted){var s;if(!n)try{(s=new a._UploadResults(r)).records[e]=function(e,t,n,i){var o=y(i,t),r=o.etag,s=o.version,l=o.md5,u=o.length;if("number"!=typeof u)throw new c(c.UNEXPECTED_RESPONSE,"No length");if(!r)throw new c(c.UNEXPECTED_RESPONSE,"No etag");if(!s)throw new c(c.UNEXPECTED_RESPONSE,"No version");if(!l)throw new c(c.UNEXPECTED_RESPONSE,"No md5");return new a._UploadRecord(e,r,s,l,u,n);}(e,o,t,i);}catch(e){n=e,s=void 0;}u(n,s);}});return h&&(h.progress=_._reportProgress,h.token=_),_;},e.exports=v;},function(e,t,n){var i=n(12),o=n(13),r=n(0),a=n(1),s=n(5);var c={isSnapshot:function(e,t){var n,i=!1,o=function(e,o){i||(i=!0,n&&n.isOpen&&n.close(),t(e,o));};(void 0).open(e,{lazyEntries:!0},function(e,t){e?-1!==["EPERM","EACCES","ENOENT"].indexOf(e.code)?o(e):o(new r(r.INVALID_DATA,"Error while opening snapshot: "+e)):((n=t).on("entry",function(e){"mimetype"===e.fileName?n.openReadStream(e,function(e,t){if(e)o(e);else{var n=[];t.on("data",function(e){n.push(e);}),t.on("error",function(e){o(e);}),t.on("end",function(){var e=Buffer.concat(n).toString();e&&_(e,"dcxucf")?o(null,!0):o(null,!1);});}}):o(null,!1);}).on("error",function(e){o(e);}),n.readEntry());});},importSnapshot:function(e,t,n,o,r,a){return this.importSnapshotToDirectory(e,t,n,o,r,function(e,t){if(e)a(e);else try{var n=new i(null,null,t,null,null,null);n.loadCurrentFromLocalStorage(function(e){a(e,e?void 0:n);}),n.deleteTempFiles();}catch(e){a(e);}});}};c.importSnapshotToDirectory=function(e,t,n,i,c,l){var u,h,d,f,m=!1,v=0,y=0,g=0,E=!1,O=function(e,t){if(!E){if(E=!0,u&&u.isOpen&&u.close(),e)return t&&s.deleteDirectory(t),void l(e);l(e,t);}},S={},A={};return s.ensureDirectoryExists(t,function(l){l?O(l):(void 0).open(e,{lazyEntries:!0},function(e,l){e?-1!==["EPERM","EACCES","ENOENT"].indexOf(e.code)?O(e):O(new r(r.INVALID_DATA,"Error while opening snapshot: "+e)):((u=l).on("entry",function(e){if(v++,y=0,g=0,p(e,i)){if(1===v)"mimetype"===e.fileName?u.openReadStream(e,function(e,t){if(e)O(e);else{var n=[];t.on("data",function(e){n.push(e);}),t.on("error",function(e){O(e);}),t.on("end",function(){var e=Buffer.concat(n).toString();e&&_(e,"dcxucf")||O(new r(r.INVALID_DATA,"Bad mimetype")),u.readEntry();});}}):O(new r(r.INVALID_DATA,"Missing mimetype file"));else if(2===v)"manifest"===e.fileName?u.openReadStream(e,function(e,t){if(e)O(e);else{var n=[];t.on("data",function(e){n.push(e);}),t.on("error",function(e){O(e);}),t.on("end",function(){var e=Buffer.concat(n).toString();if(e){if(h=JSON.parse(e),(d=new o(h))._resetIdentity(),i){var t=d.getComponentWithAbsolutePath("/META-INF/metadata.xml");t&&d.removeComponent(t);}f=h.id,u.readEntry();}else O(new r(r.INVALID_DATA,"Unable to parse manifest on import"));});}}):O(new r(r.INVALID_DATA,"Missing manifest file"));else if(f){y=e.uncompressedSize;var n=t+"/"+f+"/components";s.ensureDirectoryExists(n,function(t){t?O(t):u.openReadStream(e,function(t,i){if(t)O(t);else{var o=a.generateUuid(),r=e.fileName.split("/"),l=r[r.length-1].split(".");l&&(o=o+"."+l[l.length-1]),S["/"+e.fileName]=o,i.on("end",function(){u.readEntry();}),i.on("data",function(e){g+=e.length,function(){if(!m){var e=(v-1)/u.entryCount;y&&(e+=g/(y*u.entryCount)),c(Math.round(100*e));}}();}).on("error",function(e){O(e);}).pipe(s.createWriteStream(n+"/"+o));}});});}else O(new r(r.INVALID_DATA,"Missing manifest id"));}else u.readEntry();}).on("error",function(e){O(e);}).on("close",function(){E||(m?O(new r(r.UNEXPECTED,"Import cancelled")):(Object.keys(S).forEach(function(e){var t=d.getComponentWithAbsolutePath(e);t&&(A[t.id]=S[e]);}),h.local||(h.local={}),h.local["copyOnWrite#storageIds"]=A,n&&(h.local.compositeHref=n(h.id)),f?s.ensureDirectoryExists(t+"/"+f,function(e){e?O(e):s.writeFile(t+"/"+f+"/manifest",JSON.stringify(h,void 0,2),function(e){e?O(e):O(null,t+"/"+f);});}):O(new r(r.INVALID_DATA,"Missing manifest id"))));}),u.readEntry());});}),function(){m||(m=!0,u&&u.close());};},c.exportSnapshot=function(e,t,n,i,o){var c,u,h=!1,p=function(e){if(!h){if(h=!0,e)return void s.deleteFile(u,function(){return o(e);});s.move(u,t,!1,function(e){return o(e||null);});}};try{u=t.replace(/([^\\/]+)$/,"."+a.generateUuid()+"_$1"),c=s.createWriteStream(u);}catch(e){return void p(e);}var d,f=new(void 0).ZipFile();if(e.type&&_(e.type,"dcx")){d=e.type+"ucf",f.addBuffer(Buffer.from(d),"mimetype",{compress:!1});var v=l(e.current,n),y=JSON.stringify(v.manifest,void 0,2),g=v.lengths.total+y.length;f.addBuffer(Buffer.from(y),"manifest",{compress:!0});var E=v.componentMap,O=v.components.map(function(t){return{id:t.id,path:E&&E[t.id]||t.path,type:t.type,absolutePath:e.current.getComponentWithId(t.id).absolutePath.substring(1)};}).sort(function(e,t){return e.absolutePath<t.absolutePath?-1:e.absolutePath>t.absolutePath?1:0;}),S=!1,A=0;return O.forEach(function(t){var n=e.path+"/components/"+t.path;m(t.type)?f.addFile(n,t.absolutePath,{compress:!0}):f.addFile(n,t.absolutePath,{compress:!1});}),f.end(),f.on("error",function(){p(new r(r.INVALID_DATA,"Missing component file locally."));}),f.outputStream.on("error",function(e){p(S?new r(r.UNEXPECTED,"Export cancelled"):e);}).on("data",function(e){A+=e.length,S||i(Math.min(100,Math.round(100*A/g)));}).pipe(c).on("close",function(){p(S?new r(r.UNEXPECTED,"Export cancelled"):null);}).on("error",function(e){p(e);}),function(){S||(S=!0,f.outputStream.end());};}p(new r(r.INVALID_PARAMS,"Invalid composite type"));};var l=function(e,t){var n=JSON.parse(e.localData);t&&t(n);var i=u(n,n.local["copyOnWrite#storageIds"]||{});return delete n.local,delete n.manifestEtag,n.state="unmodified",{manifest:n,lengths:i.lengths,componentMap:i.componentMap,components:i.components};},u=function e(t,n,i,o,r){return r=r||[],i=i||{},o=o||{total:0},t.components&&t.components.forEach(function(e){i[e.id]=n[e.id];var t=e.length||1e5;o[e.id]=t,o.total+=t,e.state="unmodified",delete e.version,delete e.md5,delete e.etag,r.push(e);}),t.children&&t.children.forEach(function(t){e(t,n,i,o,r);}),{lengths:o,componentMap:i,components:r};},_=function(e,t){var n=e.split("/");if(2===n.length){var i=n[1];if(i.length<t.length+2)return!1;if(i.substring(i.length-t.length)!==t)return!1;var o=i.length-(t.length+1);return"+"===i.charAt(o);}return!1;},h=/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\.[^/\\]+$/i,p=function(e,t){if("mimetype"===e.fileName||"manifest"===e.fileName)return!0;var n=e.fileName.split("/");if(n){var i=n[n.length-1];return!t&&"metadata.xml"===i||i.match(h);}return!1;},d=["text/"],f=["+json","+xml"],m=function(e){return d.forEach(function(t){if(e.startsWith(t))return!0;}),f.forEach(function(t){if(e.endsWith(t))return!0;}),!1;};e.exports=c;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t,n,i,o,r,a){try{var s=e[r](a),c=s.value;}catch(e){return void n(e);}s.done?t(c):Promise.resolve(c).then(i,o);}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}function a(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function s(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}(e):t;}function c(e,t,n){return(c="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=l(e)););return e;}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(n):o.value;}})(e,t,n||e);}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e);})(e);}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e;})(e,t);}var _=n(33),h=n(2),p=n(3),d=function(e){function t(){return r(this,t),s(this,l(t).apply(this,arguments));}var n,i,_,d,f;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t);}(t,e),n=t,(i=[{key:"_dosync",value:function(e,t){var n=this;this._clearSyncErrors(),this._syncManager.getServerComposites(this,function(i,o,r){if(i)return i=p.getSyncError(i,void 0,{403:h.ACCESS_DENIED}),n._reportSyncError(i),void t(null,!1);o=o.filter(function(e){return!e.collaboration||"incoming"!==e.collaboration.toLowerCase();});var a=[];if(a.push(n._syncNewLibraries(o)),a.push(n._syncExistingLibraries(r,e)),a.push(n._handlePendingDeletes()),!e){var s=n._bookmarkManager.sync().then(function(){return!1;});a.push(s);}a.push(n._getUserQuota()),Promise.all(a).then(function(e){n._handleExternalPendingDeletes(),t(null,e.some(function(e){return e;}));});});}},{key:"_getUserQuota",value:(d=regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this._userQuota||this._fetchingUserQuota){e.next=14;break;}return e.prev=1,this._fetchingUserQuota=!0,e.next=5,this._syncManager.getUserQuota();case 5:this._userQuota=e.sent,e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),this._services.log("Unable to get user quota. Error: ".concat(e.t0));case 11:return e.prev=11,this._fetchingUserQuota=!1,e.finish(11);case 14:case"end":return e.stop();}},e,this,[[1,8,11,14]]);}),f=function(){var e=this,t=arguments;return new Promise(function(n,i){var r=d.apply(e,t);function a(e){o(r,n,i,a,s,"next",e);}function s(e){o(r,n,i,a,s,"throw",e);}a(void 0);});},function(){return f.apply(this,arguments);})},{key:"_ensureDefaultLibrary",value:function(){var e="ok"===this.syncState&&!this.isInitialSyncInProgress&&this._config.SYNCING_ENABLED,t=this.libraries.some(function(e){return!e.isDeletedLocally&&!e.isDeletedFromServer&&!e.toolkitId;});if(e&&!t){var n=this._localisation.translate("LIBS_DEFAULT_LIBRARY_NAME");this._services.log("Creating default library: "+n),this.createLibrary(n);}}},{key:"_updateSyncState",value:function(){c(l(t.prototype),"_updateSyncState",this).call(this),this._ensureDefaultLibrary();}},{key:"_shouldOmitComposite",value:function(e){return"sharedWithUser"===e.collaborationType;}},{key:"createLibrary",value:function(e){return c(l(t.prototype),"createLibrary",this).call(this,e,void 0);}},{key:"createBookmark",value:function(e,t,n,i){var o=this._isBookmarkDataInvalid(e,n);if(o)return i(o);this._bookmarkManager.createBookmark(e,t,n,void 0,i);}},{key:"_isBookmarkDataInvalid",value:function(e,t,n){var i=this._config.BOOKMARKS_TYPES[e];if(!i)return new h(h.INVALID_PARAMETER,"unsupported bookmark type: ".concat(e));var o=i.allowed,r=i.required;return r&&!Array.isArray(r)&&(r=n&&r[n.condition]||r.default),(!r.every(function(e){return"string"==typeof t[e];})||!Object.keys(t).every(function(e){return o.includes(e);}))&&new h(h.INVALID_PARAMETER,"bookmarks of type ".concat(e," must have the following data keys: ").concat(o.join(", ")));}},{key:"removeBookmark",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0;this._bookmarkManager.removeBookmark(e,void 0,t,n);}},{key:"findBookmark",value:function(e){return this._bookmarkManager.findBookmark(e);}},{key:"syncBookmarks",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};this._bookmarkManager.sync().then(function(){return e();});}},{key:"addBookmarkChangeListener",value:function(e){this._bookmarkManager.addChangeListener(e);}},{key:"removeBookmarkChangeListener",value:function(e){this._bookmarkManager.removeChangeListener(e);}},{key:"addPlatformFolderChangeListener",value:function(e){this._platformManager.addChangeListener(e);}},{key:"removePlatformFolderChangeListener",value:function(e){this._platformManager.removeChangeListener(e);}},{key:"getDefaultLibrary",value:function(){return this.libraries.reduce(function(e,t){var n=!e||(e.created||0)>(t.created||0);return t._collection.isPrivate&&n?t:e;},void 0);}},{key:"getToolkitLibrary",value:function(e){var t=this._libraries.filter(function(t){return t.toolkitId===e;});if(!t.length){var n=this.createLibrary(this._localisation.getToolkitName(e));return n.setValue(this._config.TOOLKIT_NAMESPACE,this._config.TOOLKIT_ID_KEY,e),n;}return t.sort(function(e,t){return e.created-t.created;}),t[0];}},{key:"bookmarks",get:function(){return this._bookmarkManager.getBookmarks();}},{key:"fontManager",get:function(){return this._fontManager;}},{key:"userQuota",get:function(){return this._userQuota;}},{key:"storageUsed",get:function(){return this._libraries.reduce(function(e,t){return e+t.storageUsed;},0);}}])&&a(n.prototype,i),_&&a(n,_),t;}(_);e.exports=d;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function a(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}(e):t;}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e);})(e);}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e;})(e,t);}var l=n(0),u=n(8),_=n(1),h=n(34),p=n(19),d=n(17),f=n(2),m=n(42),v=n(6),y=n(3),g=n(43),E=function(e){function t(){return o(this,t),a(this,s(t).apply(this,arguments));}var n,i,h;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t);}(t,e),n=t,(i=[{key:"_syncNewLibraries",value:function(e){var t=this;this._loadingHint&&(e=e.slice()).sort(function(e,n){return Number(t._loadingHint.includes(n.name))-Number(t._loadingHint.includes(e.name));});var n=(e=e.filter(function(e){return!t._doesLibraryExist(e.name);})).map(function(e){return new Promise(function(n){t._syncNewLibrary(e.name,void 0,e,function(e,i){e&&t._reportSyncError(e),n(i);});});});return Promise.all(n).then(function(e){return e.some(function(e){return e;});});}},{key:"_syncExistingLibraries",value:function(e,t){var n=this,i=[];return this._libraries.forEach(function(o){var r=e&&e[o.id];if(r&&(o._setAssetId(r.urn),o._setCollaboration(r),o._deletedFromServer&&(o._deletedFromServer=!1,o._notifyChange())),t)(t[o.id]||r&&!r.isUnmodified)&&i.push(function(e){return o._sync(!1,e);});else{var a=!e||r&&r.isUnmodified;void 0===o.collaboration?i.push(function(e){return o._sync(a,e);}):a?i.push(function(e){n._syncManager.hasCompositeChangedOnServer(o._dcxComposite,function(t){o._sync(!t,e);});}):i.push(function(e){return o._sync(!1,e);});}}),Promise.all(i.map(function(e){return new Promise(function(t){e(function(e,i){e&&n._reportSyncError(e),t(i);});});})).then(function(e){return e.some(function(e){return e;});});}},{key:"_handlePendingDeletes",value:function(){var e=this,t=this._pendingDeletes.map(function(t){return new Promise(function(n){var i,o=t._dcxBranch.getLocalData("pendingOperation");if(o&&"remove"===o.operation){var r=o.condition,a=e._apiRoot.getLoadedCollections().find(function(e){return e.cloudId===r.cloudId;});if(!(i=a&&a.getLibraryById(r.libraryId)))return t._dcxBranch.setLocalData("pendingOperation"),t._dcxBranch.compositeState="modified",e._libraries.push(t),e._libraryIdMap[t.id]=t,e._removeFromPendingDeletes(t),e._notifyChange(!0),t._commit(!1,!0),void n(!0);if("on_pushed_new"!==r.condition||!i._dcxBranch.isBound)return n(!1);}e._removeFromPendingDeletes(t),e._activeDeletes.push(t),t._deleteFromServer(!1,function(r){var a=function(i){return e._reportSyncError(i),e._removeFromActiveDeletes(t),e._pendingDeletes.push(t),n(!1);},s=function(i){if(i)return a(i);t._deletedFromDisk=!0,e._services.fileUtils.deleteLibraryFromDisk(e,t.id,function(i){i&&e._reportSyncError(i),e._removeFromActiveDeletes(t),n(!0);});};if(r&&r.code===l.UPDATE_CONFLICT)return o&&i?void t._pull(function(e){if(e)return a(e);v.recoverReadOnlyEdits(t,i._dcxBranch,function(e){if(e)return a(e);t._deleteFromServer(!0,s);});}):(e._libraries.push(t),e._libraryIdMap[t.id]=t,t._markDeletedLocally(!1),e._removeFromActiveDeletes(t),e._updateSyncState(),e._notifyChange(!0),void n(!0));s(r);});});});return Promise.all(t).then(function(e){return e.some(function(e){return e;});});}},{key:"_handleExternalPendingDeletes",value:function(){var e=this;return Promise.all(this._apiRoot.getLoadedCollections().map(function(t){return t!==e&&t._handlePendingDeletes?t._handlePendingDeletes():Promise.resolve(!1);})).then(function(e){return e.some(function(e){return e;});});}},{key:"_removeFromPendingDeletes",value:function(e){var t=this._pendingDeletes.indexOf(e);-1!==t&&this._pendingDeletes.splice(t,1);}},{key:"_removeFromActiveDeletes",value:function(e){var t=this._activeDeletes.indexOf(e);-1!==t&&this._activeDeletes.splice(t,1);}},{key:"_dosync",value:function(e,t){var n=this;this._clearSyncErrors(),this._syncManager.getServerComposites(this,function(i,o,r){if(i)return i=y.getSyncError(i,void 0,{403:f.ACCESS_DENIED}),n._reportSyncError(i),void t(null,!1);var a=[];a.push(n._syncNewLibraries(o)),a.push(n._syncExistingLibraries(r,e)),a.push(n._handlePendingDeletes()),Promise.all(a).then(function(e){n._handleExternalPendingDeletes(),t(null,e.some(function(e){return e;}));});});}},{key:"_doRemoveLibrary",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},i=this._libraries.indexOf(e);if(-1!==i&&(this._libraries.splice(i,1),delete this._libraryIdMap[e.id]),e._removeAllListeners(),this._config.SHARED_LOCAL_STORAGE)this._prepareCompositeForDelete(e._dcxComposite),e._commit(!1,!0),e._markDeletedLocally(!0),n(null);else{this._pendingDeletes.push(e);var o=e._dcxComposite&&e._dcxComposite.getLocalData("pendingOperation");o?(this._prepareCompositeForDelete(e._dcxComposite),e._commit(!0,!0),n(null)):this._config.SYNCING_ENABLED?e._deleteFromServer(!0,function(i){e._markDeletedLocally(!0),i?n(null):(t._removeFromPendingDeletes(e),e._deletedFromDisk=!0,t._services.fileUtils.deleteLibraryFromDisk(t,e.id,n));}):(this._prepareCompositeForDelete(e._dcxComposite),e._commit(!0,!0),e._markDeletedLocally(!0),n(null));}this._notifyChange(!0);}},{key:"_doImportLibrary",value:function(e,t,n){var i,o=this;if(this._config.SHARED_LOCAL_STORAGE){var r=this._services.uuid();return this._storageInterface.importLibrary(this,e,r,t),this._addOperation(r,"import");}var a=this._addOperation(n||this._services.uuid(),"import",void 0,function(){return i&&i();});return i=g.importLibrary(this,e,function(e){return a._updateProgress(e);},function(e,n){a._updateProgress(100),o._removeOperation(a),t(e,n);}),a;}},{key:"_pushNewLibrary",value:function(e){this._libraries.push(e),this._libraryIdMap[e.id]=e,this._notifyChange(!0),e._commit(!1,!0);}},{key:"createLibrary",value:function(e,t){var n=this._services.uuid(),i=this._config.COMPOSITE_TYPE,o=this._getCompositeDir(n);e=v.sanitizeLibraryName(e);var r=this._services.dcx.newEmptyComposite(e,i,o,n);r.current.rootNode.setValue(this._config.VERSION_KEY,this._config.VERSION),this._prepareCompositeForPush(r,t);var a=new d(this,r);return a._updateCreatedTime(),this._pushNewLibrary(a),this._analytics.reportCreateLibrary(a),a;}},{key:"removeLibrary",value:function(e,t){this._doRemoveLibrary(e,t),this._analytics.reportDeleteLibrary(e);}},{key:"moveLibrary",value:function(e,t,n){var i=this,o=this._apiRoot.getLoadedCollections().find(function(e){return e.isCollaborated;});e?this._libraries.includes(e)?o?this!==o?this.isCollaborated?n(new f(f.NOT_ALLOWED,"Source collection cannot be a collaborated collection")):t instanceof m?t.isWritable?"incoming"!==e.collaboration?this._config.SHARED_LOCAL_STORAGE?this._storageInterface.moveLibrary(e,t,n):this._syncManager.removeAllCollaborators(e).then(function(){i._services.dcx.copyCompositeAndAssetsFrom(e._dcxComposite,void 0,void 0,o._getCompositeDir()+"/"+e.id,e.id,_.getTemplateFromLinks(t.links,u.CREATE),function(r,a){if(r)return n(r);o._prepareCompositeForPush(a,t);var s=new d(o,a);e._dcxBranch.setLocalData("pendingOperation",{operation:"remove",condition:{condition:"on_pushed_new",cloudId:o.cloudId,libraryId:s.id}}),s._renditionCache.copyFullCache(e).then(function(){i._doRemoveLibrary(e,function(){o._pushNewLibrary(s),n(null,s);});var t=p.waitForPushNew(s.id);o._bookmarkManager.createBookmark("collab",s.id,{},t);});});},n):n(new f(f.NOT_ALLOWED,"moving can only be done to owned libraries")):n(new f(f.NOT_ALLOWED,"You do not have write access to the destination folder")):n(new f(f.INVALID_PARAMETER,"Missing platform folder parameter")):n(new f(f.INVALID_PARAMETER,"Library is already in the target collection")):n(new f(f.INVALID_PARAMETER,"No collaborated collection found")):n(new f(f.INVALID_PARAMETER,"Library not in this collection")):n(new f(f.INVALID_PARAMETER,"No library specified"));}},{key:"importLibrary",value:function(e,t){var n=this;if("string"==typeof e){if(this._config.SHARED_LOCAL_STORAGE||this._services.hasFileSystem())return this._doImportLibrary(e,function(e,i){n._analytics.reportImportLibrary(e,i),t(e,i);});t(new f(f.REQUIRES_FILESYSTEM,"importLibrary only supported when you have a filesystem"));}else t(new f(f.INVALID_PARAMETER,"path must be a string"));}},{key:"isPublic",get:function(){return!1;}}])&&r(n.prototype,i),h&&r(n,h),t;}(h);e.exports=E;},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var o=n(0),r=n(1),a=n(17),s=n(78),c=n(2),l=n(83),u=n(19),_=n(86),h=n(87),p=n(6),d=n(3),f=n(43),m=n(7),v=n(89),y=n(4).promisify,g=function(){function e(t,n,i){var o=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._apiRoot=t,this._userId=n.USER_ID,this._userProfile=n.USER_PROFILE,this._cloudId=n.CLOUD_ID,this._privateCollection=i||this,this._bookmarkManager=i?i._bookmarkManager:new u(this),this._fontManager=i?i._fontManager:new _(this),this._platformManager=i?i._platformManager:new h(this),this._syncManager=(i||this)._getSyncManager(n),this._libraries=[],this._syncState="syncing",this._syncProgressMap={},this._externalLinkDownloadProgressMap={},this._initialSyncInProgress=!1,this._syncErrors=[],this._listenerManager=new m(["change","deepchange","sync","operation","commitError"],function(e){return o._services.log(e);}),this._operations=[],v.connect(this),this._libraryIdMap={},this._operationIdMap={},this._removeOperationTimeout={},this._pendingDeletes=[],this._activeDeletes=[],this._loaded=!1,this._syncing=!1,this._lastSyncTime=0,this._pendingSyncs=[],this._backoffTicks=0,this._numBackoffs=0,this._numRetries=0,this._recoveredLibraryCount=0,this._newLibrariesLoading={},this._partialSyncedNewLibraries={};}var t,n,g;return t=e,(n=[{key:"_dispose",value:function(){v.disconnect(this);}},{key:"_getSyncManager",value:function(e){return this._syncManagers=this._syncManagers||{},this._syncManagers[e.STORAGE_HOSTNAME]||(this._syncManagers[e.STORAGE_HOSTNAME]=new s(this._apiRoot,e)),this._syncManagers[e.STORAGE_HOSTNAME];}},{key:"_getNewCompositeHref",value:function(e){return r.appendPathElements(this._href,e);}},{key:"_prepareCompositeForPush",value:function(e,t){e.href=this._getNewCompositeHref(e.id,t);}},{key:"_prepareCompositeForDelete",value:function(e){e._current.compositeState=this.links?"pendingDiscard":"pendingDelete";}},{key:"_removeAllListeners",value:function(){this._listenerManager.removeAll(),this._libraries.forEach(function(e){return e._removeAllListeners();});}},{key:"_notifyChange",value:function(e){this._listenerManager.notify("deepchange"),e&&this._listenerManager.notify("change");}},{key:"_cleanLocalData",value:function(){var e=this,t=this._apiRoot._getPrivateCollection(this.userId);if("ok"!==this.syncState||t&&"ok"!==t.syncState)return Promise.resolve();var n=Object.keys(this._partialSyncedNewLibraries);return this._partialSyncedNewLibraries={},n.length>0&&this._services.log("Deleting local data for partial library sync: ".concat(n.join(", "))),Promise.all(n.map(function(t){return new Promise(function(n){e._services.fileUtils.deleteLibraryFromDisk(e,t,function(){return n();});});}));}},{key:"_loadLibrary",value:function(e,t){var n=this,i=this._getCompositeDir(e),o=function(i){n._services.log("Load error: ".concat(i)),n._services.fileUtils.deleteLibraryFromDisk(n,e,function(){return t(null);});},r=function(i){var o=new a(n,i,n.isPublic&&e);"pendingDelete"===i.current.compositeState?(n._pendingDeletes.push(o),t(null)):(n._libraries.push(o),n._libraryIdMap[o.id]=o,o._renditionCache.load().then(t));};this._services.dcx.newCompositeFromLocalStorage(i,function(i,a){return i||!a?o("DCX error loading composite for ".concat(e)):n._shouldOmitComposite(a)?(n._services.log("Library is explicitly omitted from collection: ".concat(e)),t(null)):a.current?n.isPublic||a.id===e?void(a.href&&a.current.isBound?a.loadBaseBranch(function(t,n){t||!n?o("missing base branch for ".concat(e," (even though bound to server)")):r(a);}):r(a)):o("library id ".concat(a.id," doesn't match folder on disk ").concat(e)):(n._services.log("Found incomplete pull of new library: ".concat(e)),n._partialSyncedNewLibraries[e]=!0,t(null));});}},{key:"_shouldOmitComposite",value:function(){return!1;}},{key:"_load",value:function(e,t){var n=this;this._loaded?e(null):(this._loaded=!0,(this.isPrivate?this._platformManager.load():Promise.resolve()).then(function(){n._services.fileUtils.readLibraryDirectory(n,function(i,o){if(!i&&o){if(!t&&!n.isPublic&&o.length>=n._config.ELMO_LOCAL_LIBRARY_LIMIT)p.recoverFromElmo(n,o,function(){n._loaded=!1,n._load(e,!0);});else{var r=[];o.forEach(function(e){if(p.validateLibraryId(e,n.isPublic)){var t=y(n._loadLibrary.bind(n))(e).catch(function(e){return n._reportCommitError(e);});r.push(t);}}),r.push(n._externalLinkCache.load()),n.isPrivate&&r.push(n._bookmarkManager.load()),Promise.all(r).then(function(){n._services.log("Loaded "+n._libraries.length+" libraries and "+n._pendingDeletes.length+" pending deletes"),e(null);});}}else e(null);});}));}},{key:"_getLocalLibraryById",value:function(e){return this._libraryIdMap[e]||this._pendingDeletes.find(function(t){return t.id===e;})||this._activeDeletes.find(function(t){return t.id===e;});}},{key:"_doesLibraryExist",value:function(e){return void 0!==this._getLocalLibraryById(e);}},{key:"_syncNewLibrary",value:function(e,t,n,i){var o=t||this._getNewCompositeHref(e),r=this._services.hasFileSystem()&&this._getCompositeDir(e),a=this._services.dcx.newCompositeWithHref(o,r);return this._syncNewLibraryWithComposite(e,a,n,i);}},{key:"_syncNewLibraryWithComposite",value:function(e,t,n,i){var r=this;delete this._partialSyncedNewLibraries[e],this._libraryIdMap[e]="pending",this._updateSyncState(),n&&n.urn&&(t.assetId=n.urn);var s={id:e,_dcxComposite:t,collection:this};this._syncManager.pullLibrary(s,function(s,l){if(s||!l)return delete r._libraryIdMap[e],r._updateSyncState(),s=s?s.code===o.NO_COMPOSITE||s.code===o.DELETED_COMPOSITE?null:d.getSyncError(s,e):new c(c.NETWORK_ERROR,"No pulled branch"),void i(s,!0);t.resolvePullWithBranch(l,function(o){var s=t.id&&t.id.toLowerCase(),l=e&&e.toLowerCase();if(o||!r.isPublic&&s!==l)return delete r._libraryIdMap[e],r._updateSyncState(),o=o?d.getCommitError(o,e):new c(c.CORRUPTED_LIBRARY,"Library id does not match sync group id"),void i(o,!0);var u=new a(r,t,r.isPublic&&e);r._libraries.push(u),r._libraryIdMap[u.id]=u,r._updateSyncState(),u._setCollaboration(n),u._prefetchRenditions(),r._notifyChange(!0),i(null,!0);});});}},{key:"_reportSyncError",value:function(e){e&&(this._services.log("Sync error: "+d.errorToString(e)),this._syncErrors.push(e));}},{key:"_clearSyncErrors",value:function(e){this._syncErrors=e?this._syncErrors.filter(function(t){return t.libraryId!==e;}):[];}},{key:"_reportCommitError",value:function(e){this._lastCommitError=e,e&&(this._services.log("Commit error: "+d.errorToString(e)),this._listenerManager.notify("commitError",[e]));}},{key:"_updateRetryState",value:function(){var e=this;if(!this._retryTimeoutId&&"syncing"!==this._syncState){if("error"===this._syncState){var t=this.getPrimarySyncError();if(t&&t.code===c.RETRYABLE_SERVER_ERROR){if(this._numRetries++,this._numRetries>this._config.ERROR_RETRY_INTERVALS.length)return this._retryTime="never",this._services.log("Retry Failed"),void(this._config.MAX_SYNC_INTERVAL=this._config.RETRY_FAIL_MAX_SYNC_INTERVAL);this._services.log("Retry "+this._numRetries);var n=t.underlyingError&&t.underlyingError.response&&t.underlyingError.response.headers,i=1e3*this._config.getRetryAfterHeader(n);return i>0?(this._numRetries=this._config.ERROR_RETRY_INTERVALS.length,this._services.log("Got Retry-After header")):i=1e3*this._config.ERROR_RETRY_INTERVALS[this._numRetries-1],this._services.log("Retrying after "+i+"ms"),this._retryTime=Date.now()+i,void(this._retryTimeoutId=setTimeout(function(){e._retryTimeoutId=void 0,e._retryTime=void 0,e._services.log("Starting retry"),e._syncWithParameters(!1);},i));}if(t&&t.code===c.EXCEEDS_QUOTA)return this._config.MAX_SYNC_INTERVAL=this._config.RETRY_FAIL_MAX_SYNC_INTERVAL,this._numRetries=this._config.ERROR_RETRY_INTERVALS.length+1,void(this._retryTime="never");}this._numRetries=0,this._retryTime=void 0;}}},{key:"_setInitialSyncState",value:function(e,t){this._initialSyncInProgress=e,this._loadingHint=t,this._updateSyncState();}},{key:"_resetPollBackoff",value:function(){this._backoffTicks=0,this._numBackoffs=0;}},{key:"_updateSyncState",value:function(){var e=this,t="syncing";this._initialSyncInProgress||Object.keys(this._libraryIdMap).some(function(t){var n=e._libraryIdMap[t];return"pending"===n||n._isSyncing();})||(this._syncErrors.length>0?(t="error",this._syncManager.clearSyncGroupCache(),this._analytics.reportError(this.getPrimarySyncError())):t="ok",this._syncProgressMap={},this._syncProgress=void 0);var n=this._syncState;this._syncState=t,this._updateRetryState(),n===t&&"error"!==this._syncState||this._listenerManager.notify("sync");}},{key:"_updateProgress",value:function(e,t,n){n?this._syncProgressMap[e]={bytesLoaded:t||0,bytesTotal:n,progress:this._syncProgressMap[e]&&this._syncProgressMap[e].progress}:this._syncProgressMap[e]?(0===this._syncProgressMap[e].bytesTotal&&(this._syncProgressMap[e].bytesTotal=1e4),this._syncProgressMap[e].bytesLoaded=this._syncProgressMap[e].bytesTotal):this._syncProgressMap[e]={bytesLoaded:0,bytesTotal:0};var i=!1,o=t||0,r=(n||0)>0?Math.max(0,Math.min(100,Math.round(o/n*100))):void 0;this._syncProgressMap[e].progress!==r&&(this._syncProgressMap[e].progress=r,i=!0);var a=0,s=0,c=0,l=0,u=this._syncProgressMap;Object.keys(u).forEach(function(e){a++,u[e].bytesTotal>0&&s++,c+=u[e].bytesLoaded,l+=u[e].bytesTotal;});var _=l>0?c*s/(l*a):0,h=Math.max(0,Math.min(100,Math.round(100*_)));(!this._syncProgress||this._syncProgress<h||100===this._syncProgress&&h<100)&&(this._syncProgress=h,i=!0),i&&this._listenerManager.notify("sync");}},{key:"_updateExternalLinkDownloadProgress",value:function(e,t,n,i){var o,r=e.element.library.id+"."+e.element.id+"."+e.id;n?(t=t||0,o=Math.max(0,Math.min(100,Math.round(t/n*100)))):i&&(o=-1),o!==this._externalLinkDownloadProgressMap[r]&&(void 0===o?delete this._externalLinkDownloadProgressMap[r]:this._externalLinkDownloadProgressMap[r]=o,this._listenerManager.notify("sync"));}},{key:"_getExternalLinkDownloadProgress",value:function(e){var t=e.element.library.id+"."+e.element.id+"."+e.id;return this._externalLinkDownloadProgressMap[t];}},{key:"_abortPushOrPull",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];Object.keys(this._libraryIdMap).forEach(function(t){var n=e._libraryIdMap[t];"pending"===n?e._syncManager.abortPushOrPull(t):n._abortPushOrPull();}),this._pendingDeletes.forEach(function(e){return e._abortPushOrPull();});var n=this._pendingSyncs;this._pendingSyncs=[],n.forEach(function(e){return e(new c(c.TRANSFER_ABORTED,"abort push or pull operation"));}),t&&this._syncManager.abortAllDownloads();}},{key:"_getBaseDir",value:function(){var e=this._services.getPathSeparator();return this._services.fileUtils.getUserDir(this._userId)+e+this._directoryName;}},{key:"_getLibraryDir",value:function(e,t){var n=this._services.getPathSeparator(),i=this._getBaseDir()+n+e;return t&&(i+=n+t),i;}},{key:"_getCompositeDir",value:function(e){return this._getLibraryDir("dcx",e);}},{key:"_getTempDir",value:function(){var e=this._services.getPathSeparator();return this._getBaseDir()+e+".tmp";}},{key:"_getRenditionCacheDir",value:function(e){return this._getLibraryDir("renditions",e);}},{key:"_addOperation",value:function(e,t,n,i){var o=new l(this,e,t,n,i);return this._operations.push(o),this._operationIdMap[o.id]=o,this._notifyOperationChange(),o;}},{key:"_removeOperation",value:function(e){var t=this._operations.indexOf(e);-1!==t&&(this._operations.splice(t,1),delete this._operationIdMap[e.id]),this._notifyOperationChange();}},{key:"_delayedRemoveOperation",value:function(e){var t=this;this._removeOperationTimeout[e.id]||(this._removeOperationTimeout[e.id]=setTimeout(function(){delete t._removeOperationTimeout[e.id],t._removeOperation(e);},this._config.REMOVE_OPERATION_TIMEOUT));}},{key:"_updateOperation",value:function(e,t,n,i){this._operationIdMap[e]||this._addOperation(e,t,n),this._removeOperationTimeout[e]&&(clearTimeout(this._removeOperationTimeout[e]),delete this._removeOperationTimeout[e]),this._operationIdMap[e]._updateProgress(i);}},{key:"_notifyOperationChange",value:function(){this._listenerManager.notify("operation");}},{key:"_doExportLibrary",value:function(e,t,n,i){var o,r=this;if(this._config.SHARED_LOCAL_STORAGE){var a=this._services.uuid();return this._storageInterface.exportLibrary(e,t,a,n),this._addOperation(a,"export",{libraryId:e.id});}i=i||this._services.uuid(),e._setAutoGC("export_"+i,!1);var s=this._addOperation(i,"export",{libraryId:e.id},function(){return o&&o();});return o=f.exportLibrary(e,t,function(e){return s._updateProgress(e);},function(t){s._updateProgress(100),r._removeOperation(s),e._setAutoGC("export_"+i,!0),n(t);}),s;}},{key:"_syncWithParameters",value:function(e,t,n,i){var o=this,r=function(){return i&&i(null);};if(this._config.SHARED_LOCAL_STORAGE)return this._storageInterface.sync(this),void r();this._config.SYNCING_ENABLED&&!this._retryTimeoutId?(e||this._resetPollBackoff(),this._syncing?this.isPolling?r():this._pendingSyncs.push(r):Date.now()<this._lastSyncTime+this._config.MAX_SYNC_INTERVAL?t?r():setTimeout(function(){return o._syncWithParameters(e,!0,n,r);},this._config.MAX_SYNC_INTERVAL):(this._services.log("Start Sync: "+this.cloudId+(e?" [polling]":"")),this._syncing=!0,this._lastSyncTime=Date.now(),this._dosync(n,function(e,t){o._updateSyncState(),o._cleanLocalData().then(function(){return function(e,t){if(o._syncing=!1,o._services.log("End Sync: "+o.cloudId),t&&o._resetPollBackoff(),o._pendingSyncs.length>0){var n=o._pendingSyncs;o._pendingSyncs=[],o.sync(function(){return n.forEach(function(e){return e();});});}r();}(0,t);});}))):r();}},{key:"addChangeListener",value:function(e){this._listenerManager.add("change",e);}},{key:"removeChangeListener",value:function(e){this._listenerManager.remove("change",e);}},{key:"addDeepChangeListener",value:function(e){this._listenerManager.add("deepchange",e);}},{key:"removeDeepChangeListener",value:function(e){this._listenerManager.remove("deepchange",e);}},{key:"addOperationChangeListener",value:function(e){this._listenerManager.add("operation",e);}},{key:"removeOperationChangeListener",value:function(e){this._listenerManager.remove("operation",e);}},{key:"addSyncListener",value:function(e){this._listenerManager.add("sync",e);}},{key:"removeSyncListener",value:function(e){this._listenerManager.remove("sync",e);}},{key:"addCommitErrorListener",value:function(e){this._listenerManager.add("commitError",e);}},{key:"removeCommitErrorListener",value:function(e){this._listenerManager.remove("commitError",e);}},{key:"removeDeletedLibraries",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){};"function"==typeof e&&(n=e,e=void 0);var i=e&&e.exclude||[],o=function(e){var n=t._libraries.indexOf(e);return-1!==n&&(t._libraries.splice(n,1),delete t._libraryIdMap[e.id]),e._deletedFromDisk=!0,e._markDeletedLocally(!0),y(t._services.fileUtils.deleteLibraryFromDisk.bind(t._services.fileUtils))(t,e.id);},r=this._libraries.filter(function(e){return e.isDeletedFromServer&&i.every(function(t){return e!==t;});}).map(function(e){return o(e);}),a=function(e){r.length>0&&t._notifyChange(!0),n(e);};Promise.all(r).then(function(){return a(null);},a);}},{key:"exportLibrary",value:function(e,t,n){var i=this;if(-1!==this._libraries.indexOf(e)){if("string"==typeof t){if(0===t.length||t[t.length-1].match(/\\|\//))n(new c(c.INVALID_PARAMETER,"path must end in a filename"));else{if(t.substring(t.length-this._config.EXPORT_EXTENSION.length)!==this._config.EXPORT_EXTENSION&&(t+=this._config.EXPORT_EXTENSION),this._config.SHARED_LOCAL_STORAGE||this._services.hasFileSystem())return this._doExportLibrary(e,t,function(t){i._analytics.reportExportLibrary(t,e),n(t);});n(new c(c.REQUIRES_FILESYSTEM,"exportLibrary only supported when you have a filesystem"));}}else n(new c(c.INVALID_PARAMETER,"path must be a string"));}else n(new c(c.INVALID_PARAMETER,"library not in this collection"));}},{key:"sync",value:function(e){this._syncWithParameters(!1,!1,void 0,e);}},{key:"syncChanges",value:function(e,t){var n={};(e=e||[]).forEach(function(e){return n[e]=!0;}),this._syncWithParameters(!1,!1,n,t);}},{key:"syncFull",value:function(e){this._syncManager.clearSyncGroupCache(),this._syncWithParameters(!1,!1,void 0,e);}},{key:"getPrimarySyncError",value:function(){var e=this._syncErrors[0];return this._syncErrors.forEach(function(t){var n=d.getErrorPriority(t),i=d.getErrorPriority(e);n>i?e=t:n===i&&e.code===t.code&&e.libraryId!==t.libraryId&&(e=new c(e.code,"multiple errors (see libraryCollection.syncErrors)",void 0));}),e;}},{key:"getNewLibrarySyncProgress",value:function(){var e=this;return this._newLibraryProgress?this._newLibraryProgress:Object.keys(this._libraryIdMap).filter(function(t){return"pending"===e._libraryIdMap[t];}).map(function(t){return{id:t,progress:e._syncProgressMap[t]&&e._syncProgressMap[t].progress};});}},{key:"startPolling",value:function(){var e=this;if(this._config.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"startPolling() not supported with shared local storage");this.isPolling||(this._pollTimerId=setInterval(function(){"never"!==e._retryTime&&(e._backoffTicks>0?e._backoffTicks--:(0===e._backoffTicks&&(e._numBackoffs++,e._backoffTicks=e._config.getBackoffTicks(e._numBackoffs)),e._syncWithParameters(!0)));},this._pollInterval));}},{key:"stopPolling",value:function(){if(this._config.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"stopPolling() not supported with shared local storage");this.isPolling&&(clearInterval(this._pollTimerId),delete this._pollTimerId),this._retryTimeoutId&&(clearTimeout(this._retryTimeoutId),delete this._retryTimeoutId);}},{key:"getLibraryById",value:function(e){var t=this._libraryIdMap[e];if(t instanceof a)return t;}},{key:"updateAccessToken",value:function(e){if(this._config.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"updateAccessToken() not supported with shared local storage");this._syncManager.updateAccessToken(e),this._services.log("defined");}},{key:"getTempDir",value:function(e){if(this._services.hasFileSystem()){var t=this._getTempDir();this._services.fileUtils.ensurePathExists(t,function(n){return e(n,t);});}else e(new c(c.REQUIRES_FILESYSTEM,"getTempDir only supported when you have a filesystem"));}},{key:"copyFileToTempDir",value:function(e,t){var n=this;this.getTempDir(function(i,o){if(i)t(i);else{var r=n._services.fileUtils.getFileExtension(e),a=o+n._services.getPathSeparator()+n._services.uuid()+(r?"."+r:"");n._services.fileUtils.copyFile(e,a,function(e){e?n._services.fileUtils.deleteFile(a,function(){return t(e);}):t(null,a);});}});}},{key:"_loadLibraryFromBookmark",value:function(e,t){var n=this,i=e.id,o=e.role,r=this.getLibraryById(i);if(r){var a="editor"===o;return!this.isPublic&&o&&a!==r._dcxComposite.isWritable&&(r._dcxComposite.isWritable=a,r._commit(!0,!0)),void t(null,r);}if(!e||this.canLoadLibrary(e)){var s=this._newLibrariesLoading[i];if(s)s.push(t);else{this._newLibrariesLoading[i]=[t];var l=function(e,t){var o=n._newLibrariesLoading[i];delete n._newLibrariesLoading[i],o.forEach(function(n){return n(e,t);});};if(this._config.SHARED_LOCAL_STORAGE)throw new c(c.NOT_ALLOWED,"Library cannot be loaded from bookmark in shared-storage mode.");this._syncNewLibrary(i,e.url||e.urn,void 0,function(e){if(e)l(e);else{var t=n.getLibraryById(i);t?(n.isPublic&&(t._dcxComposite.isWritable=!1,t._commit(!0,!0)),l(null,t)):l(new c(c.NOT_FOUND,"Library could not be found: ".concat(i)));}}),e._onRemove=function(){n._newLibrariesLoading[i]&&(n._newLibrariesLoading[i].push(function(){n._services.fileUtils.deleteLibraryFromDisk(n,i,t);}),n._syncManager.abortPushOrPull(i));};}}else t(new c(c.INVALID_PARAMETER,"Invalid library location"));}},{key:"_unloadLibrary",value:function(e,t){var n=this._libraries.indexOf(e);if(-1!==n){if(this._libraries.splice(n,1),delete this._libraryIdMap[e.id],e._abortPushOrPull(),e._markDeletedLocally(!0),this._config.SHARED_LOCAL_STORAGE)return t(new c(c.NOT_ALLOWED,"Libraries cannot be unloaded in shared-storage mode."));e._deletedFromDisk=!0,this._services.fileUtils.deleteLibraryFromDisk(this,e.id,t),this._listenerManager.notify("change");}else t(null);}},{key:"_getLibrariesToUnload",value:function(){return[];}},{key:"_collectionManager",get:function(){return this._apiRoot._collectionManager;}},{key:"_services",get:function(){return this._apiRoot._services;}},{key:"_config",get:function(){return this._apiRoot._config;}},{key:"_analytics",get:function(){return this._apiRoot._analytics;}},{key:"_localisation",get:function(){return this._apiRoot._localisation;}},{key:"_storageInterface",get:function(){return this._apiRoot._storageInterface;}},{key:"_directoryName",get:function(){return this._cloudId;}},{key:"platformFolders",get:function(){return this._platformManager.folders;}},{key:"_href",get:function(){return this.isPrivate?r.appendPathElements(this._syncManager.getStorageHost(),this._config.STORAGE_ASSETS_PATH,this._config.LIBRARY_SYNC_GROUP):null;}},{key:"libraries",get:function(){return this._libraries;}},{key:"commitError",get:function(){return this._lastCommitError;}},{key:"syncState",get:function(){return this._syncState;}},{key:"syncErrors",get:function(){return this._syncErrors;}},{key:"syncProgress",get:function(){return this._syncProgress;}},{key:"supportsONSNotifications",get:function(){return!1;}},{key:"isInitialSyncInProgress",get:function(){return this._initialSyncInProgress;}},{key:"isPolling",get:function(){return void 0!==this._pollTimerId;}},{key:"isPrivate",get:function(){return!this.isPublic&&!this.isCollaborated;}},{key:"isLoggedIn",get:function(){if(!this._config.SHARED_LOCAL_STORAGE)return this._syncManager.isLoggedIn();}},{key:"retryTime",get:function(){return"never"!==this._retryTime?this._retryTime:void 0;}},{key:"userId",get:function(){return this._userId;}},{key:"userProfile",get:function(){return this._userProfile;}},{key:"cloudId",get:function(){return this._cloudId;}},{key:"operations",get:function(){return this._operations;}},{key:"_pollInterval",get:function(){return 6e4*this._config.POLL_INTERVAL;}}])&&i(t.prototype,n),g&&i(t,g),e;}();e.exports=g;},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var o=n(2),r=n(6),a=n(7),s=function(){function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._listenerManager=new a(["change"],function(e){return t._services.log(e);});}var t,n,s;return t=e,(n=[{key:"_getRawName",value:function(){return this._dcxNode.name||"";}},{key:"_getName",value:function(){var e=this._localisation.getLocale(),t=e&&this.getLocalizedName(e);return t||this._getRawName();}},{key:"_setName",value:function(e){this._dcxNode.name=e,this._dcxNode.removeValue(this._config.LOCALIZED_NAME_KEY),this._dcxNode.removeValue(this._config.AUTO_NAMED_KEY);}},{key:"_markDeletedLocally",value:function(e){this._deletedLocally=e,e&&this._listenerManager.removeAll();}},{key:"_removeAllListeners",value:function(){this._listenerManager.removeAll();}},{key:"toString",value:function(){return JSON.stringify(this._toJSON());}},{key:"jasmineToString",value:function(){return this.toString();}},{key:"_constructActions",value:function(e,t,n,i){var o=this,r=[];t.forEach(function(t){!n.products[t]||e&&e!==n.products[t].action||r.push(new i(o,n.products[t]));});var a=r.map(function(e,t){return{i:t,v:e};});return a.sort(function(e,t){return e.v.isCompatibleVersionInstalled&&!t.v.isCompatibleVersionInstalled?-1:t.v.isCompatibleVersionInstalled&&!e.v.isCompatibleVersionInstalled?1:e.i-t.i;}),a.map(function(e){return e.v;});}},{key:"getLocalizedName",value:function(e){return this.getLocalizedNames()[e]||"";}},{key:"getLocalizedNames",value:function(){return this._dcxNode.getValue(this._config.LOCALIZED_NAME_KEY)||{};}},{key:"setLocalizedName",value:function(e,t){if(r.checkDeletedState(this),!this.isWritable)throw new o(o.NOT_ALLOWED,"you do not have write access to this library",this._libraryId);var n=this.getLocalizedNames();n[e]=t,this._dcxNode.setValue(this._config.LOCALIZED_NAME_KEY,n),this._commitMetadata();}},{key:"addChangeListener",value:function(e){r.checkDeletedState(this),this._listenerManager.add("change",e);}},{key:"removeChangeListener",value:function(e){this._listenerManager.remove("change",e);}},{key:"_libraryId",get:function(){return this.library?this.library.id:this.id;}},{key:"name",get:function(){return this._getName();},set:function(e){if(r.checkDeletedState(this),!this.isWritable)throw new o(o.NOT_ALLOWED,"you do not have write access to this library",this._libraryId);this._setName(e),this._updateName&&this._updateName(),this._commitMetadata(),this._reportRename&&this._reportRename();}},{key:"created",get:function(){return this._dcxNode.getValue(this._config.CREATED_KEY);}},{key:"modified",get:function(){return this._dcxNode.getValue(this._config.MODIFIED_KEY);}},{key:"isDeletedLocally",get:function(){return this._deletedLocally;}}])&&i(t.prototype,n),s&&i(t,s),e;}();e.exports=s;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function r(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}(e):t;}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e);})(e);}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e;})(e,t);}var c=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,t),(n=r(this,a(t).call(this)))._library=e,n;}var n,i,c;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t);}(t,e),n=t,(i=[{key:"_getEventData",value:function(e,t){var n=!t&&{},i=this._dcxNode.getValue(this._config[e+"_DATA_KEY"])||n;if("CREATED"!==e&&"DESCRIPTION"!==e){var o=this._dcxNode.getValue(this._config[e+"_KEY"]);if(!o||o!==i.time)return n;}return i;}},{key:"_setEventData",value:function(e,t){if(this._config.DEVICE_ID){var n={userId:this.library.collection.userId,deviceId:this._config.DEVICE_ID};this._config.DEVICE_DESCRIPTION&&(n.device=this._config.DEVICE_DESCRIPTION),this._config.APP_DESCRIPTION&&(n.app=this._config.APP_DESCRIPTION),t&&(n.time=t),this._dcxNode.setValue(this._config[e+"_DATA_KEY"],n);}else this._clearEventData(e);}},{key:"_clearEventData",value:function(e){this._dcxNode.getValue(this._config[e+"_DATA_KEY"])&&this._dcxNode.removeValue(this._config[e+"_DATA_KEY"]);}},{key:"_isLocalEvent",value:function(e){var t=this._getEventData(e).deviceId;if(t&&this._config.DEVICE_ID)return t===this._config.DEVICE_ID;}},{key:"_getEventContext",value:function(e){var t=JSON.parse(JSON.stringify(this._getEventData(e)));return delete t.time,delete t.deviceId,delete t.userId,t;}},{key:"_commit",value:function(){this._updateModifiedTime(),this._listenerManager.notify("change"),this._library._commit();}},{key:"_commitMetadata",value:function(){this._listenerManager.notify("change"),this._library._commit();}},{key:"_updateCreatedTime",value:function(){var e=Date.now();this._dcxNode.setValue(this._config.CREATED_KEY,e),this._dcxNode.setValue(this._config.MODIFIED_KEY,e),this._setEventData("CREATED"),this._setEventData("MODIFIED",e);}},{key:"_updateModifiedTime",value:function(){var e=Date.now();this._dcxNode.setValue(this._config.MODIFIED_KEY,e),this._setEventData("MODIFIED",e);}},{key:"_ensureModifiedDataValid",value:function(e){this._getEventData("MODIFIED",!0)||(e?this._setEventData("MODIFIED",this.modified):this._clearEventData("MODIFIED")),this._ensureRemovedDataValid(e);}},{key:"_ensureCreatedDataValid",value:function(e){e&&!this._getEventData("CREATED",!0)&&this._setEventData("CREATED"),this._ensureModifiedDataValid(e);}},{key:"touch",value:function(){this._commit();}},{key:"_config",get:function(){return this._library._config;}},{key:"_services",get:function(){return this._library._services;}},{key:"_analytics",get:function(){return this._library._analytics;}},{key:"_localisation",get:function(){return this._library._localisation;}},{key:"id",get:function(){return this._dcxNode.id;}},{key:"library",get:function(){return this._library;}},{key:"isWritable",get:function(){return this._library.isWritable;}},{key:"createdBy",get:function(){return this._getEventData("CREATED").userId;}},{key:"createdContext",get:function(){return this._getEventContext("CREATED");}},{key:"wasCreatedLocally",get:function(){return this._isLocalEvent("CREATED");}},{key:"modifiedBy",get:function(){return this._getEventData("MODIFIED").userId;}},{key:"modifiedContext",get:function(){return this._getEventContext("MODIFIED");}},{key:"wasModifiedLocally",get:function(){return this._isLocalEvent("MODIFIED");}}])&&o(n.prototype,i),c&&o(n,c),t;}(n(35));e.exports=c;},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var o=n(2),r=n(4),a=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._item=t,this._id=n.action,this._appCode=n.appCode,this._appName=n.appName,this._minVersion=n.minVersion,this._installedVersions=this._config.ELEMENT_ACTION_PRODUCT_MAP.installedApps.filter(function(e){return e.code===n.appCode;}).map(function(e){return e.version;}).sort(r.compareVersions),this._invokable=this._installedVersions.length>0&&r.compareVersions(n.minVersion,this._installedVersions[0])>=0,Object.freeze(this._installedVersions);}var t,n,a;return t=e,(n=[{key:"invoke",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};this.isCompatibleVersionInstalled?(this._analytics.reportActionInvoked(this),this._storageInterface.sendAction(this,function(n,i){n?(n=-1!==["APP_NOT_INSTALLED","NO_COMPATIBLE_VERSION"].indexOf(n)?new o(o.NO_COMPATIBLE_APP_FOUND,"A compatible version of application is needed for this action:"+n):new o(o.APP_LAUNCH_FAILED,"Launching the app failed:"+n),e._analytics.reportActionFailed(e,n)):e._analytics.reportActionSuccessful(e,i),t(n,i);})):t(new o(o.NO_COMPATIBLE_APP_FOUND,"A compatible version of application is needed for this action",this._appCode));}},{key:"_config",get:function(){return this._item._config;}},{key:"_analytics",get:function(){return this._item._analytics;}},{key:"_storageInterface",get:function(){return this._item._storageInterface;}},{key:"appCode",get:function(){return this._appCode;}},{key:"appName",get:function(){return this._appName;}},{key:"minAppVersion",get:function(){return this._minVersion;}},{key:"installedVersions",get:function(){return this._installedVersions;}},{key:"isCompatibleVersionInstalled",get:function(){return!!this._invokable;}}])&&i(t.prototype,n),a&&i(t,a),e;}();e.exports=a;},function(e,t){var n={},i={"application/x-indesign":!0,"application/postscript":!0,"application/illustrator":!0,"application/pdf":!0,"application/vnd.adobe.psremix":!0,"application/vnd.adobe.pstouch":!0,"application/vnd.adobe.ideas":!0,"application/vnd.adobe.ase":!0,"image/jpeg":!0,"image/jpg":!0,"image/pjpeg":!0,"image/tiff":!0,"image/gif":!0,"image/bmp":!0,"image/x-ms-bmp":!0,"image/svg+xml":!0,"image/png":!0,"image/x-png":!0,"image/jp2":!0,"image/psd":!0,"image/vnd.adobe.photoshop":!0,"image/heic":!0,"application/photoshop":!0,"application/x-photoshop":!0,"image/raw":!0,"image/dng":!0,"image/x-adobe-dng":!0,"video/mp4":!0,"video/mpeg":!0,"video/x-ms-wmv":!0,"video/3gpp":!0,"video/3gpp2":!0,"video/quicktime":!0,"video/x-msvideo":!0,"video/x-flv":!0,"video/x-ms-asf":!0,"video/x-m4v":!0,"video/mp2t":!0,"application/mxf":!0,"application/x-shockwave-flash":!0,"application/vnd.adobe.brushes.brush+ucf":!0,"application/vnd.adobe.collage":!0,"application/vnd.adobe.proto":!0,"application/msword":!0,"application/msexcel":!0,"application/mspowerpoint":!0,"application/vnd.ms-publisher":!0,"application/vnd.openxmlformats-officedocument.wordprocessingml.document":!0,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":!0,"application/vnd.openxmlformats-officedocument.presentationml.presentation":!0,"text/plain":!0,"text/rtf":!0,"application/illustrator.template":!0,"application/vnd.adobe.indesign.template":!0,"application/vnd.adobe.photoshop.template":!0,"image/vnd.adobe.photoshop.template":!0};n.canComputeRenditionFromMimeType=function(e){return!!i[e];},n.canComputeRendition=function(e){return!(void 0===e._dcxComponent||!n.canComputeRenditionFromMimeType(e.type));},Object.seal(n),e.exports=n;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var r=n(76),a=n(77),s=n(9),c=n(3),l=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._apiRoot=t,this._rootDir=n,this._cache={},this._pendingCacheItems={},this._lock=new s(),this._fs=r(this._services.fs,this._services.fileUtils),this._path=a(this._services.getPathSeparator());}var t,n,l;return t=e,(n=[{key:"load",value:function(){var e=this;return this._loadingPromise||(this._loadingPromise=this._doTransaction(function(){return e._load();},!1)),this._loadingPromise;}},{key:"save",value:function(){var e=this;return this._doTransaction(function(){return e._save();});}},{key:"_doTransaction",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=function(){return t._lock.release();},o=new Promise(function(e){return t._lock.obtain(e);}).then(e);return n&&(o=o.then(function(e){return t._save().then(function(){return e;});})),o.then(i,i),o;}},{key:"_load",value:function(){var e=this;return!this._services.hasFileSystem()||this._config.SHARED_LOCAL_STORAGE?Promise.resolve():this._services.fileUtils.readJSONData(this._path.join(this._rootDir,this._config.RENDITION_CACHE_FILE)).catch(function(){}).then(function(t){e._cache=t||{};});}},{key:"_save",value:function(){var e=this;return!this._services.hasFileSystem()||this._config.SHARED_LOCAL_STORAGE?Promise.resolve():this._services.fileUtils.writeJSONData(this._rootDir,this._config.RENDITION_CACHE_FILE,this._cache).then(function(){return e._gcUnreferencedFiles();});}},{key:"_waitForCommit",value:function(e){if(!this._lock.isLocked())return e();this._doTransaction(e,!1);}},{key:"_getCache",value:function(e){for(var t=this._cache,n=0;t&&n<e.length;n++)t=t[e[n]];return t;}},{key:"_isErrorCode",value:function(e){return e&&c.isErrorCode(e);}},{key:"_isPath",value:function(e){return e&&e!==this._config.RENDITION_CACHE_PLACEHOLDER&&!this._isErrorCode(e);}},{key:"_getFilePath",value:function(e,t){if(e){if(t&&!this._isPath(e))return e;var n=this._path.join(this._rootDir,e);return this._config.SHARED_LOCAL_STORAGE||this._fs.statSync(n)?n:void 0;}}},{key:"_setCacheEntry",value:function(e,t){for(var n=this._cache,i=0;i<e.length-1;i++){var o=e[i];n=n[o]=n[o]||{};}var r=e[e.length-1];return void 0===t?delete n[r]:n[r]=t,t;}},{key:"_setCache",value:function(e,t,n){var i=this,o=this._services.fileUtils.getFileExtension(t)||"png",r="".concat(this._services.uuid(),".").concat(o);return this._fs.ensureDir(this._rootDir).then(function(){i._pendingCacheItems[r]=!0;var e=n?"rename":"copy";return i._fs[e](t,i._path.join(i._rootDir,r));}).then(function(){return delete i._pendingCacheItems[r],i._setCacheEntry(e,r),i._path.join(i._rootDir,r);}).catch(function(e){return delete i._pendingCacheItems[r],Promise.reject(c.getCommitError(e,void 0,"unable to save cache to disk"));});}},{key:"_iterate",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._cache,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];Object.keys(n).forEach(function(r){"object"===i(n[r])?t._iterate(e,n[r],o.concat(r)):e(o,n[r]);});}},{key:"_gcUnreferencedFiles",value:function(){var e=this,t={};return this._iterate(function(n,i){t[i]=!0,delete e._pendingCacheItems[i];}),this._fs.readdir(this._rootDir).then(function(n){var i=[];return n.forEach(function(n){var o=e._services.fileUtils.normaliseTempFileName(n);n===e._config.RENDITION_CACHE_FILE||t[n]||e._pendingCacheItems[o]||i.push(e._fs.remove(e._path.join(e._rootDir,n)));}),Promise.all(i);});}},{key:"_config",get:function(){return this._apiRoot._config;}},{key:"_services",get:function(){return this._apiRoot._services;}},{key:"_storageInterface",get:function(){return this._apiRoot._storageInterface;}}])&&o(t.prototype,n),l&&o(t,l),e;}();e.exports=l;},function(e,t){function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable;})),n.push.apply(n,i);}return n;}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e;}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var r=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._type=t,this._id=n;}var t,r,a;return t=e,(r=[{key:"toJSON",value:function(e){return function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?n(Object(o),!0).forEach(function(t){i(e,t,o[t]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t));});}return e;}({type:this._type,id:this._id},e);}},{key:"toString",value:function(){return JSON.stringify(this.toJSON());}},{key:"isReferenceTo",value:function(){return!1;}},{key:"id",get:function(){return this._id;}},{key:"type",get:function(){return this._type;}}])&&o(t.prototype,r),a&&o(t,a),e;}();e.exports=r;},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var o=n(9),r=n(7),a=n(3),s=n(2),c=function(){function e(t,n){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._fileName=t,this._collection=n,this._lock=new o(),this._listenerManager=new r(["change"],function(e){return i._services.log(e);});}var t,n,c;return t=e,(n=[{key:"_getBaseDir",value:function(){return this._collection._getBaseDir();}},{key:"_toJSON",value:function(){throw new s(s.NOT_IMPLEMENTED,"_toJSON must be defined by child class.");}},{key:"_fromJSON",value:function(){throw new s(s.NOT_IMPLEMENTED,"_fromJSON must be defined by child class.");}},{key:"_load",value:function(){var e=this;if(!this._services.hasFileSystem())return Promise.resolve();this._services.log("Loading from disk: ".concat(this._fileName));var t=this._getBaseDir()+this._services.getPathSeparator()+this._fileName;return this._services.fileUtils.readJSONData(t).then(function(t){return e._fromJSON(t);}).catch(function(t){e._collection._reportCommitError(a.getCommitError(t,null,"data could not be loaded from disk"));});}},{key:"_save",value:function(){var e=this;return this._services.hasFileSystem()?(this._services.log("Saving to disk: ".concat(this._fileName)),this._services.fileUtils.writeJSONData(this._getBaseDir(),this._fileName,this._toJSON()).catch(function(t){e._collection._reportCommitError(a.getCommitError(t,null,"serialized data could not be saved"));})):Promise.resolve();}},{key:"load",value:function(){var e=this;return this._lock.execute(function(){return e._load();});}},{key:"save",value:function(){var e=this;return this._lock.execute(function(){return e._save();});}},{key:"addChangeListener",value:function(e){this._listenerManager.add("change",e);}},{key:"removeChangeListener",value:function(e){this._listenerManager.remove("change",e);}},{key:"_services",get:function(){return this._collection._services;}},{key:"_storageInterface",get:function(){return this._collection._storageInterface;}},{key:"_config",get:function(){return this._collection._config;}},{key:"_syncManager",get:function(){return this._collection._syncManager;}}])&&i(t.prototype,n),c&&i(t,c),e;}();e.exports=c;},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var i=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._id=t.id,this._name=t.name,this._links=t.links,this._permissions=t.permissions,this._ownerType=t.ownerType,this._ownerId=t.ownerId,this._ownerName=t.ownerName,this._createdBy=t.createdBy;}var t,i,o;return t=e,(i=[{key:"toJSON",value:function(){return{id:this.id,name:this.name,links:this.links,permissions:this.permissions,ownerType:this.ownerType,ownerId:this.ownerId,ownerName:this.ownerName,createdBy:this.createdBy};}},{key:"id",get:function(){return this._id;}},{key:"name",get:function(){return this._name;}},{key:"links",get:function(){return this._links;}},{key:"isWritable",get:function(){return this._permissions&&this._permissions.includes("write");}},{key:"ownerId",get:function(){return this._ownerId;}},{key:"ownerType",get:function(){return this._ownerType;}},{key:"ownerName",get:function(){return this._ownerName;}},{key:"createdBy",get:function(){return this._createdBy;}},{key:"permissions",get:function(){return this._permissions;}}])&&n(t.prototype,i),o&&n(t,o),e;}();e.exports=i;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}var o=n(31),r=n(3),a=n(2),s={},c=/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\.[^/\\]+$/i;s.importLibrary=function(e,t,n,i){var c,l,u=e._services.fileUtils,_=function(t,n){if(l&&(t=new a(a.OPERATION_CANCELLED,"import cancelled")),t)i(t);else{c=void 0;var o=n.libraryId,s=n.extractPath,_=e._getCompositeDir(),h=e._getCompositeDir(o),p=function(e){u.recursiveDeleteDirectory(s),u.recursiveDeleteDirectory(h),i(e);};u.ensurePathExists(_,function(t){t?i(r.getFileSystemError(t,"unable to create folder to move extracted zip")):u.rename(s,h,function(t){if(t)return p(r.getFileSystemError(t,"unable to move extracted zip after import"));e._loadLibrary(o,function(t){if(t)return p(t);var n=e.getLibraryById(o);if(!n)return p(new a(a.INVALID_DATA,"could not load library after import"));e._notifyChange(!0),n._push(),i(null,n);});});});}};return o.isSnapshot(t,function(i,a){if(i||l)_(i&&r.getSnapshotError(i,void 0,"error opening library archive"));else{var u=e._getTempDir();if(a){c=o.importSnapshot(t,u,function(t){return e._getNewCompositeHref(t);},!1,n,function(e,t){!e&&t?_(null,{libraryId:t.id,extractPath:t.path}):_(r.getSnapshotError(e,void 0,"cannot import the snapshot file"));});}else c=s._importNonSnapshotLibrary(e,t,u,n,_);}}),function(){l||(l=!0,c&&c());};},s._importNonSnapshotLibrary=function(e,t,n,o,s){var l=e._services.fileUtils,u=e._services.getPathSeparator(),_=e._services.fs,h=e._services.yauzl;if(h){var p,d=e._services.uuid(),f=n+e._services.getPathSeparator()+d,m=e._getNewCompositeHref(d),v=!1,y=-1,g=0,E=0,O=!1,S=function(e){O||(O=!0,e&&l.recursiveDeleteDirectory(f),s(e,e?void 0:{libraryId:d,extractPath:f}));},A=f+u+"components";return l.ensurePathExists(A,function(n){n?S(r.getFileSystemError(n,"unable to create temp dir")):h.open(t,{lazyEntries:!0},function(t,n){t?-1!==["EPERM","EACCES","ENOENT"].indexOf(t.code)?S(r.getFileSystemError(t,"error opening library archive")):S(new a(a.INVALID_DATA,"error opening library archive: "+t)):((p=n).on("entry",function(t){y++,g=0,E=0,function(e){return"data"===e.fileName||e.fileName.match(c);}(t)?"data"!==t.fileName?(g=t.uncompressedSize,p.openReadStream(t,function(e,n){e?S(r.getFileSystemError(e,"error extracting zip file")):(n.on("end",function(){p.readEntry();}),n.on("data",function(e){E+=e.length,function(){if(!v){var e=y/p.entryCount;g&&(e+=E/(g*p.entryCount)),o(Math.round(100*e));}}();}).on("error",function(e){S(r.getFileSystemError(e,"error extracting zip file"));}).pipe(_.createWriteStream(A+u+t.fileName)));})):p.openReadStream(t,function(t,n){if(t)S(r.getFileSystemError(t,"error reading zip file entry"));else{var o=[];n.on("data",function(e){o.push(e);}),n.on("error",function(e){S(r.getFileSystemError(e,"error extracting zip file"));}),n.on("end",function(){var t=function(e,t,n,o){var r;try{r=JSON.parse(e);}catch(e){return null;}if(!r||r.version!==o)return null;var a=r.manifest,s=r.componentMap;return"object"!==i(s)||Object.keys(s).some(function(e){return"string"!=typeof s[e];})?null:(a.id=t,a.local={version:2,change:1,compositeHref:n,"copyOnWrite#storageIds":r.componentMap},{json:r,manifest:a});}(Buffer.concat(o).toString(),d,m,e._config.EXPORT_VERSION);t&&t.manifest?_.writeFile(f+u+"manifest",JSON.stringify(t.manifest,void 0,2),function(e){e?S(r.getFileSystemError(e,"unable to write manifest file")):p.readEntry();}):S(new a(a.INVALID_DATA,"unable to parse export data"));});}}):p.readEntry();}).on("error",function(e){S(r.getFileSystemError(e,"error extracting zip file"));}).on("close",function(){v?S(new a(a.OPERATION_CANCELLED,"import cancelled")):S();}),p.readEntry());});}),function(){v||(v=!0,p&&p.close());};}s(new a(a.NOT_SUPPORTED,"yauzl (unzip) module not present"));},s.exportLibrary=function(e,t,n,i){var s,c=o.exportSnapshot(e._dcxComposite,t,function(t){return delete t["".concat(e._config.TOOLKIT_NAMESPACE,"#").concat(e._config.TOOLKIT_ID_KEY)],delete t[e._config.DOCUMENT_ID_KEY],delete t[e._config.DOCUMENT_TYPE_KEY],t.children=t.children.filter(function(t){return t.name!==e._config.REMOVED_ELEMENTS_NAME;}),t;},n,function(t){i(s?new a(a.OPERATION_CANCELLED,"export cancelled"):t&&r.getSnapshotError(t,e.id,"cannot export a snapshot file"));});return function(){s||(s=!0,c());};},Object.seal(s),e.exports=s;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function a(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}(e):t;}function s(e,t,n){return(s="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=c(e)););return e;}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(n):o.value;}})(e,t,n||e);}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e);})(e);}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e;})(e,t);}var u=n(90),_=n(19),h=function(e){function t(){return o(this,t),a(this,c(t).apply(this,arguments));}var n,i,u;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t);}(t,e),n=t,(i=[{key:"createLibrary",value:function(e,n){var i=s(c(t.prototype),"createLibrary",this).call(this,e,n),o=_.waitForPushNew(i.id);return this._bookmarkManager.createBookmark("collab",i.id,{role:"editor"},o),i;}},{key:"removeLibrary",value:function(e,n){s(c(t.prototype),"removeLibrary",this).call(this,e,n);var i=this._bookmarkManager.findBookmark(e);if(i){var o=_.waitForDelete(e.id);this._bookmarkManager.removeBookmark(i,o);}}},{key:"canLoadLibrary",value:function(e){return e.urn&&!e.url;}},{key:"loadLibrary",value:function(e,t){return this._loadLibraryFromBookmark(e,t);}},{key:"isCollaborated",get:function(){return!0;}}])&&r(n.prototype,i),u&&r(n,u),t;}(u);e.exports=h;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t,n,i,o,r,a){try{var s=e[r](a),c=s.value;}catch(e){return void n(e);}s.done?t(c):Promise.resolve(c).then(i,o);}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function a(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}(e):t;}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e);})(e);}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e;})(e,t);}var l=function(e){function t(e,n,i){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,t),n.IS_PUBLIC=!0,n.USER_ID=n.USER_ID||e._config.PUBLIC_USER_ID,a(this,s(t).call(this,e,n,i));}var n,i,l;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t);}(t,e),n=t,(i=[{key:"_dosync",value:function(e,t){var n=this;this._clearSyncErrors();var i=this._libraries.map(function(){var e,t=(e=regeneratorRuntime.mark(function e(t){var i;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t._dcxComposite.isWritable&&(t._dcxComposite.isWritable=!1,t._commit(!0,!0)),t._dcxComposite.assetId){e.next=12;break;}return e.prev=2,e.next=5,n._syncManager.getPublicLibraryAssetId(t);case 5:i=e.sent,e.next=11;break;case 8:e.prev=8,e.t0=e.catch(2),n._services.log("Unable to get assetId for ".concat(t.id,". Error: ").concat(e.t0));case 11:i&&(t._dcxComposite.assetId=i,t._commit(!0,!0));case 12:return e.abrupt("return",n._doSyncLibrary(t));case 13:case"end":return e.stop();}},e,null,[[2,8]]);}),function(){var t=this,n=arguments;return new Promise(function(i,r){var a=e.apply(t,n);function s(e){o(a,i,r,s,c,"next",e);}function c(e){o(a,i,r,s,c,"throw",e);}s(void 0);});});return function(e){return t.apply(this,arguments);};}());Promise.all(i).then(function(e){return t(null,e.some(function(e){return e;}));});}},{key:"_doSyncLibrary",value:function(e){var t=this;return new Promise(function(n){t._syncManager.hasCompositeChangedOnServer(e._dcxComposite,function(i){if(e.isDeletedLocally)return n(!1);e._sync(!i,function(e,i){e&&t._reportSyncError(e),n(i);});});});}},{key:"canLoadLibrary",value:function(e){var t=e.url;return new RegExp("".concat(this._syncManager.getStorageHost(),"/(.+)")).test(t);}},{key:"loadLibrary",value:function(e,t){return this._loadLibraryFromBookmark(e,t);}},{key:"unloadLibrary",value:function(e,t){return this._unloadLibrary(e,t);}},{key:"_getLibrariesToUnload",value:function(){var e=this;return this.libraries.filter(function(t){return!e._bookmarkManager.findBookmark(t);});}},{key:"isPublic",get:function(){return!0;}}])&&r(n.prototype,i),l&&r(n,l),t;}(n(34));e.exports=l;},function(e,t,n){n(47),e.exports=n(49);},function(e,t,n){(function(e){function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}var n=function(e){"use strict";var n=Object.prototype,i=n.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},r=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t];}try{c({},"");}catch(e){c=function(e,t,n){return e[t]=n;};}function l(e,t,n,i){var o=t&&t.prototype instanceof h?t:h,r=Object.create(o.prototype),a=new T(i||[]);return r._invoke=function(e,t,n){var i="suspendedStart";return function(o,r){if("executing"===i)throw new Error("Generator is already running");if("completed"===i){if("throw"===o)throw r;return L();}for(n.method=o,n.arg=r;;){var a=n.delegate;if(a){var s=O(a,n);if(s){if(s===_)continue;return s;}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===i)throw i="completed",n.arg;n.dispatchException(n.arg);}else"return"===n.method&&n.abrupt("return",n.arg);i="executing";var c=u(e,t,n);if("normal"===c.type){if(i=n.done?"completed":"suspendedYield",c.arg===_)continue;return{value:c.arg,done:n.done};}"throw"===c.type&&(i="completed",n.method="throw",n.arg=c.arg);}};}(e,n,a),r;}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)};}catch(e){return{type:"throw",arg:e};}}e.wrap=l;var _={};function h(){}function p(){}function d(){}var f={};f[r]=function(){return this;};var m=Object.getPrototypeOf,v=m&&m(m(b([])));v&&v!==n&&i.call(v,r)&&(f=v);var y=d.prototype=h.prototype=Object.create(f);function g(e){["next","throw","return"].forEach(function(t){c(e,t,function(e){return this._invoke(t,e);});});}function E(e,n){var o;this._invoke=function(r,a){function s(){return new n(function(o,s){!function o(r,a,s,c){var l=u(e[r],e,a);if("throw"!==l.type){var _=l.arg,h=_.value;return h&&"object"===t(h)&&i.call(h,"__await")?n.resolve(h.__await).then(function(e){o("next",e,s,c);},function(e){o("throw",e,s,c);}):n.resolve(h).then(function(e){_.value=e,s(_);},function(e){return o("throw",e,s,c);});}c(l.arg);}(r,a,o,s);});}return o=o?o.then(s,s):s();};}function O(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,O(e,t),"throw"===t.method))return _;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method");}return _;}var i=u(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,_;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,_):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,_);}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t);}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t;}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0);}function b(e){if(e){var t=e[r];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(i.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t;};return o.next=o;}}return{next:L};}function L(){return{value:void 0,done:!0};}return p.prototype=y.constructor=d,d.constructor=p,p.displayName=c(d,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name));},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,c(e,s,"GeneratorFunction")),e.prototype=Object.create(y),e;},e.awrap=function(e){return{__await:e};},g(E.prototype),E.prototype[a]=function(){return this;},e.AsyncIterator=E,e.async=function(t,n,i,o,r){void 0===r&&(r=Promise);var a=new E(l(t,n,i,o),r);return e.isGeneratorFunction(n)?a:a.next().then(function(e){return e.done?e.value:a.next();});},g(y),c(y,s,"Generator"),y[r]=function(){return this;},y.toString=function(){return"[object Generator]";},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var i=t.pop();if(i in e)return n.value=i,n.done=!1,n;}return n.done=!0,n;};},e.values=b,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(A),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0);},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval;},dispatchException:function(e){if(this.done)throw e;var t=this;function n(n,i){return a.type="throw",a.arg=e,t.next=n,i&&(t.method="next",t.arg=void 0),!!i;}for(var o=this.tryEntries.length-1;o>=0;--o){var r=this.tryEntries[o],a=r.completion;if("root"===r.tryLoc)return n("end");if(r.tryLoc<=this.prev){var s=i.call(r,"catchLoc"),c=i.call(r,"finallyLoc");if(s&&c){if(this.prev<r.catchLoc)return n(r.catchLoc,!0);if(this.prev<r.finallyLoc)return n(r.finallyLoc);}else if(s){if(this.prev<r.catchLoc)return n(r.catchLoc,!0);}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<r.finallyLoc)return n(r.finallyLoc);}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&i.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var r=o;break;}}r&&("break"===e||"continue"===e)&&r.tryLoc<=t&&t<=r.finallyLoc&&(r=null);var a=r?r.completion:{};return a.type=e,a.arg=t,r?(this.method="next",this.next=r.finallyLoc,_):this.complete(a);},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),_;},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),A(n),_;}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var i=n.completion;if("throw"===i.type){var o=i.arg;A(n);}return o;}}throw new Error("illegal catch attempt");},delegateYield:function(e,t,n){return this.delegate={iterator:b(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),_;}},e;}("object"===t(e)?e.exports:{});try{regeneratorRuntime=n;}catch(e){Function("r","regeneratorRuntime = r")(n);}}).call(this,n(48)(e));},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l;}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i;}}),e.webpackPolyfill=1),e;};},function(e,t,n){function i(e,t){return function(e){if(Array.isArray(e))return e;}(e)||function(e,t){if(!(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)))return;var n=[],i=!0,o=!1,r=void 0;try{for(var a,s=e[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);i=!0);}catch(e){o=!0,r=e;}finally{try{i||null==s.return||s.return();}finally{if(o)throw r;}}return n;}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance");}();}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable;})),n.push.apply(n,i);}return n;}function r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach(function(t){a(e,t,n[t]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t));});}return e;}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e;}function s(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var c=n(50),l=n(16),u=n(68),_=n(32),h=n(44),p=n(45),d=n(91),f=n(2),m=n(92),v=n(117),y=n(121),g=n(122),E=n(10),O=n(38),S=n(6),A=new RegExp("cloud-asset://(.+)/([A-Za-z0-9-]+);node=([A-Za-z0-9-]+)"),T=function(){function e(t,n){var i=this;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._config=new l(),this._services=new c(this._config),this._services.hasFileSystem()||void 0!==n.SHARED_LOCAL_STORAGE||(n.SHARED_LOCAL_STORAGE=!1),this._services.hasFileSystem()&&!n.ROOT_DIR&&!1===n.SHARED_LOCAL_STORAGE)throw new f(f.INVALID_PARAMETER,"Missing ROOT_DIR option");if(this._services.hasFileSystem()&&n.ROOT_DIR&&!1!==n.SHARED_LOCAL_STORAGE)throw new f(f.INVALID_PARAMETER,"ROOT_DIR option doesn't apply when using shared local storage");if(!this._services.hasFileSystem()&&n.ROOT_DIR)throw new f(f.REQUIRES_FILESYSTEM,"ROOT_DIR option only applies when you have a filesystem");if(!1===n.SHARED_LOCAL_STORAGE&&!n.STORAGE_API_KEY)throw new f(f.INVALID_PARAMETER,"Missing STORAGE_API_KEY option");if(!1===n.SHARED_LOCAL_STORAGE&&!n.DEVICE_ID)throw new f(f.INVALID_PARAMETER,"Missing DEVICE_ID option");if(!1!==n.SHARED_LOCAL_STORAGE&&!this._services.hasCEPVulcan()&&!t.vulcanCall)throw new f(f.INVALID_PARAMETER,"Shared local storage requires either the CEP VulcanInterface/VulcanMessage as globals, or for you to pass in the vulcanCall dependency");if(!n.APP_DESCRIPTION)throw new f(f.INVALID_PARAMETER,'Missing APP_DESCRIPTION option - should be a string of the form <name>-<version>, e.g. "PHXS-16.0".');if(n.ROOT_DIR)for(;-1!==["/","\\"].indexOf(n.ROOT_DIR.substr(-1));)n.ROOT_DIR=n.ROOT_DIR.slice(0,-1);Object.keys(n).forEach(function(e){return i._config.setParameter(e,n[e]);}),this._services.vulcanCall=t.vulcanCall,this._services._log=t.log,this._services._getNodeTunnelOptions=t.getNodeTunnelOptions,this._services._getOrgBetaStatus=t.getOrgBetaStatus,t.renditionGenerator&&this._services.setRenditionGenerator(t.renditionGenerator),this._analytics=new u(t.analytics,this._config),this._storageInterface=new v(this,{onConnected:t.onClientConnected}),this._externalUtils=new y(this),this._externalAnalyticsUtils=new g(this),this._localisation=new m(this,n.LOCALE),delete n.LOCALE,this._collectionManager=new d(this),this._loadingState={},this._services.log("Configure: "+(this._config.SHARED_LOCAL_STORAGE?"<shared local storage>":this._config.ROOT_DIR));}var t,n,o;return t=e,o=[{key:"getSNISettings",value:function(){var e=new l();return{TLS_DISCOVERY_PORT_RANGE:e.TLS_DISCOVERY_PORT_RANGE,TLS_DELAY_ON_DECLINE:2*e.TLS_DELAY_ON_DECLINE,TLS_DELAY_ON_READY:2*e.TLS_DELAY_ON_READY};}},{key:"mimeTypeToExtensions",value:function(e){return E.getExtensions(e);}},{key:"extensionToMimeTypes",value:function(e){return E.getMimeTypes(e);}},{key:"canGenerateRenditionFromMimeType",value:function(e){return O.canComputeRenditionFromMimeType(e);}},{key:"errors",get:function(){return f;}}],(n=[{key:"_addLoadCallback",value:function(e,t,n){var i=e+"/"+t,o=void 0!==this._loadingState[i];return this._loadingState[i]=this._loadingState[i]||[],this._loadingState[i].push(n),o;}},{key:"_notifyLoadCallbacks",value:function(e,t){var n;n=e===this._config.PUBLIC_USER_ID?this._collectionManager.getPublicLibraryCollection(t):t===this._config.COLLABORATED_CLOUD_ID?this._collectionManager.getCollaboratedLibraryCollection(e):this._collectionManager.getLibraryCollection(e,t);var i=e+"/"+t,o=this._loadingState[i];o&&(delete this._loadingState[i],o.forEach(function(e){return e(null,n);}));}},{key:"_getPrivateCollection",value:function(e){return this._collectionManager.getLoadedCollections().find(function(t){return t.isPrivate&&t.userId===e;});}},{key:"setOption",value:function(e,t){if(-1!==["ROOT_DIR","SHARED_LOCAL_STORAGE","ELEMENT_TYPE_FILTERS","STORAGE_API_KEY"].indexOf(e))throw new f(f.INVALID_PARAMETER,"Cannot reconfigure "+e);this._config.setParameter(e,t);}},{key:"getOption",value:function(e){return this._config[e];}},{key:"setLocalSetting",value:function(e,t){this._config.setLocalSetting(e,t);}},{key:"getLocalSetting",value:function(e){return this._config.LOCAL_SETTINGS[e];}},{key:"addConfigurationChangeListener",value:function(e){this._config.addChangeListener(e);}},{key:"removeConfigurationChangeListener",value:function(e){this._config.removeChangeListener(e);}},{key:"getLoadedCollections",value:function(){return this._collectionManager.getLoadedCollections().slice(0);}},{key:"getLoadedCollectionById",value:function(e,t){return this._collectionManager.getLibraryCollection(e,t);}},{key:"getLoadedPublicCollectionById",value:function(e){return this._collectionManager.getPublicLibraryCollection(e);}},{key:"getLoadedCollaboratedCollectionById",value:function(e){return this._collectionManager.getCollaboratedLibraryCollection(e);}},{key:"addLoadedCollectionsListener",value:function(e){this._collectionManager.addLoadedCollectionsListener(e);}},{key:"removeLoadedCollectionsListener",value:function(e){this._collectionManager.removeLoadedCollectionsListener(e);}},{key:"getRootDir",value:function(){if(!this._services.hasFileSystem())throw new f(f.REQUIRES_FILESYSTEM,"ROOT_DIR option only applies when you have a filesystem");return this._config.ROOT_DIR;}},{key:"refreshPlatformFolders",value:function(e){var t=this.getLoadedCollections().find(function(e){return e.isPrivate;});if(!t)return e();t._platformManager.refreshPlatformFolders(e);}},{key:"_getCachedRootDocument",value:function(){return this.getLoadedCollections().find(function(e){return e.isPrivate;})._platformManager.cachedRootDocument;}},{key:"getLocale",value:function(){return this._localisation.getLocale();}},{key:"unloadLibraryCollection",value:function(e){if(this._config.SHARED_LOCAL_STORAGE)throw new f(f.NOT_SUPPORTED,"unloadLibraryCollection() not supported with shared local storage");e.stopPolling(),e._removeAllListeners(),e._abortPushOrPull(!0),this._collectionManager.removeLibraryCollection(e);}},{key:"loadLibraryCollection",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if("function"!=typeof t){if(this._config.SHARED_LOCAL_STORAGE)n(new f(f.NOT_SUPPORTED,"loadLibraryCollection() not supported with shared local storage"));else{t.CLOUD_ID=t.CLOUD_ID||this._config.DEFAULT_CLOUD_ID;var i=["STORAGE_HOSTNAME","CC_LIBRARY_SERVICE_HOSTNAME","CC_IMAGE_HOSTNAME","CC_IMAGE_X_HOSTNAME","TYPEKIT_HOSTNAME"];this._services.hasFileSystem()?i.unshift("USER_ID"):t.USER_ID="<browser_user>";for(var o=0;o<i.length;o++){var r=i[o];if(!t[r])return void n(new f(f.INVALID_PARAMETER,"Missing ".concat(r," option")));}var a=this._collectionManager.getLibraryCollection(t.USER_ID,t.CLOUD_ID),s=this._addLoadCallback(t.USER_ID,t.CLOUD_ID,n);if(!a||s){if(!s){a=new _(this,t);var c=function(){e._collectionManager.addLibraryCollection(a),e._config.AUTO_START_POLLING&&a.startPolling(),e._notifyLoadCallbacks(t.USER_ID,t.CLOUD_ID);};if(this._services.hasFileSystem())this._services.fileUtils.doesRootDirExist(a,function(e,t){a._load(function(){t||a._setInitialSyncState(!0),a.sync(function(){return a._setInitialSyncState(!1);}),c();});});else if("all"===t.WAIT_FOR)a._setInitialSyncState(!0),a.sync(function(){a._setInitialSyncState(!1),c();});else if(S.validateLibraryId(t.WAIT_FOR,!1)){a._setInitialSyncState(!0,[t.WAIT_FOR]),a.sync(function(){return a._setInitialSyncState(!1);});var l=function e(){"syncing"===a.syncState&&"pending"===a._libraryIdMap[t.WAIT_FOR]||(a.removeChangeListener(e),a.removeSyncListener(e),c());};a.addChangeListener(l),a.addSyncListener(l);}else a._setInitialSyncState(!0),a.sync(function(){return a._setInitialSyncState(!1);}),c();}}else this._notifyLoadCallbacks(t.USER_ID,t.CLOUD_ID);}}else(n=t)(new f(f.INVALID_PARAMETER,"options argument not specified"));}},{key:"loadPublicLibraryCollection",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if("function"!=typeof t){if(this._config.SHARED_LOCAL_STORAGE)n(new f(f.NOT_SUPPORTED,"loadPublicLibraryCollection() not supported with shared local storage"));else if(t.CLOUD_ID=t.CLOUD_ID||this._config.DEFAULT_CLOUD_ID,t.STORAGE_HOSTNAME){var i=this._collectionManager.getPublicLibraryCollection(t.CLOUD_ID),o=this._addLoadCallback(this._config.PUBLIC_USER_ID,t.CLOUD_ID,n);if(!i||o){if(!o){var r=this._getPrivateCollection(t.USER_ID);i=new p(this,t,r);var a=function(){e._collectionManager.addLibraryCollection(i),e._config.AUTO_START_POLLING&&i.startPolling(),e._notifyLoadCallbacks(e._config.PUBLIC_USER_ID,t.CLOUD_ID);};this._services.hasFileSystem()?i._load(function(){i.sync(),a();}):a();}}else this._notifyLoadCallbacks(this._config.PUBLIC_USER_ID,t.CLOUD_ID);}else n(new f(f.INVALID_PARAMETER,"Missing STORAGE_HOSTNAME option"));}else(n=t)(new f(f.INVALID_PARAMETER,"options argument not specified"));}},{key:"loadCollaboratedLibraryCollection",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if("function"!=typeof t){if(this._config.SHARED_LOCAL_STORAGE)n(new f(f.NOT_SUPPORTED,"loadCollaboratedLibraryCollection() not supported with shared local storage"));else if(t.STORAGE_HOSTNAME){var i=this._collectionManager.getCollaboratedLibraryCollection(t.USER_ID),o=this._addLoadCallback(t.USER_ID,this._config.COLLABORATED_CLOUD_ID,n);if(!i||o){if(!o){var a=this._getPrivateCollection(t.USER_ID);i=new h(this,r({},t,{CLOUD_ID:this._config.COLLABORATED_CLOUD_ID}),a);var s=function(){e._collectionManager.addLibraryCollection(i),e._notifyLoadCallbacks(t.USER_ID,e._config.COLLABORATED_CLOUD_ID);};this._services.hasFileSystem()?i._load(function(){i.sync(),s();}):s();}}else this._notifyLoadCallbacks(t.USER_ID,this._config.COLLABORATED_CLOUD_ID);}else n(new f(f.INVALID_PARAMETER,"Missing STORAGE_HOSTNAME option"));}else(n=t)(new f(f.INVALID_PARAMETER,"options argument not specified"));}},{key:"isConnected",value:function(){if(!this._config.SHARED_LOCAL_STORAGE)throw new f(f.NOT_SUPPORTED,"isConnected() is only applicable if using shared local storage");return this._storageInterface&&this._storageInterface.isConnected();}},{key:"reconnect",value:function(){if(!this._config.SHARED_LOCAL_STORAGE)throw new f(f.NOT_SUPPORTED,"reconnect() is only applicable if using shared local storage");this._storageInterface&&this._storageInterface.reconnect();}},{key:"disconnect",value:function(){if(!this._config.SHARED_LOCAL_STORAGE)throw new f(f.NOT_SUPPORTED,"disconnect() is only applicable if using shared local storage");this._storageInterface&&this._storageInterface.isConnected()&&this._storageInterface.shutdown();}},{key:"getServiceInfo",value:function(){if(!this._config.SHARED_LOCAL_STORAGE)throw new f(f.NOT_SUPPORTED,"getServiceInfo() is only applicable if using shared local storage");return this._storageInterface&&this._storageInterface.getServiceInfo();}},{key:"isSyncingEnabled",value:function(){if(this._config.SHARED_LOCAL_STORAGE){var e=this.getServiceInfo();return Boolean(e&&e.syncingEnabled);}return this._config.SYNCING_ENABLED;}},{key:"enableSyncing",value:function(){this._config.SHARED_LOCAL_STORAGE?this._storageInterface.setSyncEnabled(!0):(this._config.SYNCING_ENABLED=!0,this.getLoadedCollections().forEach(function(e){return e.sync();}));}},{key:"disableSyncing",value:function(){this._config.SHARED_LOCAL_STORAGE?this._storageInterface.setSyncEnabled(!1):(this._config.SYNCING_ENABLED=!1,this.getLoadedCollections().forEach(function(e){return e._abortPushOrPull();}));}},{key:"getLibraryById",value:function(e){return this.getLoadedCollections().reduce(function(t,n){return t||n.getLibraryById(e);},null);}},{key:"getLibraryFolderById",value:function(e){return this.getLoadedCollections().find(function(e){return e.isPrivate;}).platformFolders.find(function(t){return t.id===e;});}},{key:"resolveElementReference",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=e.match(A);if(n){var o=i(n,4),r=o[2],a=o[3];return this.getLoadedCollections().map(function(e){var n=e.getLibraryById(r);return n&&n.getElementById(a,!t);}).find(function(e){return e;});}}},{key:"resolveElementReferenceToLibrary",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=e.match(A);if(t){var n=i(t,3),o=n[2];return this.getLoadedCollections().map(function(e){return e.getLibraryById(o);}).find(function(e){return e;});}}},{key:"getAccessToken",value:function(e,t,n,i,o){this._config.SHARED_LOCAL_STORAGE?0!==this._collectionManager.getLoadedCollections().length?this._storageInterface.getAccessToken(e,t,n,i,o):o(new f(f.LOGGED_OUT,"User must be logged in to request an access token")):o(new f(f.NOT_SUPPORTED,"getAccessToken() is only supported with shared local storage"));}},{key:"openInCCD",value:function(e,t){this._config.SHARED_LOCAL_STORAGE?this._storageInterface.openInCCD(e,t):t(new f(f.NOT_SUPPORTED,"launchCCD() is only supported with shared local storage"));}},{key:"utils",get:function(){return this._externalUtils;}},{key:"analyticsUtils",get:function(){return this._externalAnalyticsUtils;}}])&&s(t.prototype,n),o&&s(t,o),e;}();e.exports=T;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var r=n(11),a=n(67),s=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._config=t,this._fileUtils=new a(this,t),this.uuid=n(22),("undefined"==typeof window?{}:window).nodeRequire&&(this.fs=("undefined"==typeof window?{}:window).nodeRequire("fs"),this.path=("undefined"==typeof window?{}:window).nodeRequire("path")),this._initDCX();}var t,s,c;return t=e,(s=[{key:"_initDCX",value:function(){var e=this;this.dcx=new r(this.fs,{preserveFileExtensions:!0,logCallback:function(t){return e._log&&e._log("DCX: "+t);}});}},{key:"log",value:function(e){this._log&&this._log("CC Libraries: "+e);}},{key:"hasFileSystem",value:function(){return void 0!==this.fs;}},{key:"setFileSystem",value:function(e){this.fs=e,this._initDCX();}},{key:"hasRenditionGenerator",value:function(){return void 0!==this.renditionGenerator;}},{key:"setRenditionGenerator",value:function(e){this.renditionGenerator=e;}},{key:"getVulcanInterface",value:function(){if("undefined"!==("undefined"==typeof VulcanInterface?"undefined":i(VulcanInterface)))return VulcanInterface;}},{key:"getVulcanMessage",value:function(){if("undefined"!==("undefined"==typeof VulcanMessage?"undefined":i(VulcanMessage)))return VulcanMessage;}},{key:"hasCEPVulcan",value:function(){return void 0!==this.getVulcanInterface()&&void 0!==this.getVulcanMessage();}},{key:"getNodeTunnelOptions",value:function(e){return this._getNodeTunnelOptions?this._getNodeTunnelOptions(e):{};}},{key:"getPathSeparator",value:function(){return"/";}},{key:"getFileNameFromPath",value:function(e){return!e.includes("/")&&e.includes("\\")&&(e=e.replace(/\\/g,"/")),e.split("/").pop();}},{key:"fileUtils",get:function(){return this._fileUtils;}}])&&o(t.prototype,s),c&&o(t,c),e;}();e.exports=s;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}var o=n(0),r=n(1);function a(e,t,n){e?this._setData(e):this._data={},this._readOnly=t,this._isRoot=n;}a.ROOT_PATH="/",Object.defineProperties(a.prototype,{id:{get:function(){return this._data.id;},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(this._owner)throw new o(o.READ_ONLY,"Cannot change the id of a node that is part of a branch or element.");if("string"!=typeof e||""===e)throw new o(o.INVALID_PARAMS,"Expecting a non-empty string.");this._data.id=e,this._setDirty();}},name:{get:function(){return this._data.name;},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.name=e,this._setDirty();}},type:{get:function(){return this._data.type;},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.type=e,this._setDirty();}},relationship:{get:function(){return this._data.rel;},set:function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");this._data.rel=e,this._setDirty();}},path:{get:function(){return this._isRoot?"/":this._data.path;},set:function(e){if(e!==this.path){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(this._isRoot)throw new o(o.READ_ONLY,"Cannot change the path of the root node.");if(e&&!r.isValidPath(e))throw new o(o.INVALID_PARAMS,"Expecting a valid path or undefined.");this._owner?this._owner._setPathOfNode(this,e||void 0):(this._data.path=e||void 0,this._parentPath=""),this._setDirty();}}},parentPath:{get:function(){return this._parentPath;},set:function(){throw new o(o.READ_ONLY,"parentPath is read-only.");}},absolutePath:{get:function(){var e=this.path;return this._isRoot?e:e&&this._owner?r.appendPathElements(this._parentPath,e):void 0;},set:function(){throw new o(o.READ_ONLY,"absolutePath is read-only.");}},isRoot:{get:function(){return this._isRoot;},set:function(){throw new o(o.READ_ONLY,"isRoot is read-only.");}}}),a.prototype.getLink=function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "relationship" must be a string');return this._data._links?this._data._links[e]:void 0;},a.prototype.setLink=function(e,t){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("object"!==i(e))throw new o(o.INVALID_PARAMS,'Param "link" must be an object.');if("string"!=typeof t)throw new o(o.INVALID_PARAMS,'Param "relationship" must be a string');var n=this._data._links;n||(n=this._data._links={}),n[t]=e,this._setDirty();},a.prototype.removeLink=function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "relationship" must be a string');var t=this._data._links;t&&(delete t[e],Object.keys(t).length<1&&delete this._data._links,this._setDirty());};var s={components:!0,children:!0,"manifest-format-version":!0,id:!0,name:!0,type:!0,state:!0,local:!0},c={components:!0,children:!0,rel:!0,path:!0,id:!0,name:!0,type:!0};a.prototype.getCustomKeys=function(){var e,t=[],n=Object.keys(this._data),i=n.length;for(e=0;e<i;e++){var o=n[e];(this._isRoot?s[o]:c[o])||t.push(o);}return t;},a.prototype.getValue=function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "key" must be a string');if("children"===e||"components"===e)throw new o(o.INVALID_PARAMS,"Illegal key");return this._data[e];},a.prototype.setValue=function(e,t){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "key" must be a string');if("children"===e||"components"===e)throw new o(o.INVALID_PARAMS,"Illegal key");this._data[e]=t,this._setDirty();},a.prototype.removeValue=function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "key" must be a string');if("children"===e||"components"===e)throw new o(o.INVALID_PARAMS,"Illegal key");delete this._data[e],this._setDirty();},a.prototype.copy=function(){var e=null,t=this._data.children,n=this._data.components;try{t&&delete this._data.children,n&&delete this._data.components,e=new a(JSON.parse(JSON.stringify(this._data)));}finally{t&&(this._data.children=t),n&&(this._data.components=n);}return e;},a.prototype.isEqualTo=function(e,t,n){return this._isEqual(this._data,e._data,r.merge({children:!0,components:!0},t),n);},a.prototype._isEqual=function(e,t,n,i){var o,a,s,c,l,u,_;if(!r.objectsEqual(e,t,n))return!1;if(a=e.components,s=t.components,(c=a?a.length:0)!==(s?s.length:0))return!1;if(c)for(o=0;o<c;o++){for(l=a[o],u=null,_=0;_<c;_++)if(l.id===s[_].id){u=s[_];break;}if(!u)return!1;if(!r.objectsEqual(l,u,i))return!1;}if(a=e.children,s=t.children,(c=a?a.length:0)!==(s?s.length:0))return!1;if(c)for(o=0;o<c;o++)if(!this._isEqual(a[o],s[o],n,i))return!1;return!0;},a.prototype._setData=function(e){var t=this._verify(e);if(null===t)return this._data=e,this;throw t;},a.prototype._verify=function(e){return"string"!=typeof e.id?new o(o.INVALID_DATA,"Node is missing an id of type string"):null;},a.prototype._setDirty=function(){this._owner&&this._owner._setDirty();},e.exports=a;},function(e,t,n){(function(t){var n,i=void 0!==t&&(t.crypto||t.msCrypto);if(i&&i.getRandomValues){var o=new Uint8Array(16);n=function(){return i.getRandomValues(o),o;};}if(!n){var r=new Array(16);n=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),r[t]=e>>>((3&t)<<3)&255;return r;};}e.exports=n;}).call(this,n(53));},function(e,t){function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}var i;i=function(){return this;}();try{i=i||new Function("return this")();}catch(e){"object"===(void 0===("undefined"==typeof window?{}:window)?"undefined":n("undefined"==typeof window?{}:window))&&(i="undefined"==typeof window?{}:window);}e.exports=i;},function(e,t){for(var n=[],i=0;i<256;++i)n[i]=(i+256).toString(16).substr(1);e.exports=function(e,t){var i=t||0,o=n;return o[e[i++]]+o[e[i++]]+o[e[i++]]+o[e[i++]]+"-"+o[e[i++]]+o[e[i++]]+"-"+o[e[i++]]+o[e[i++]]+"-"+o[e[i++]]+o[e[i++]]+"-"+o[e[i++]]+o[e[i++]]+o[e[i++]]+o[e[i++]]+o[e[i++]]+o[e[i++]];};},function(e,t,n){var i=n(20),o=n(0),r=n(1);function a(e,t,n){(this._owner=t,e)?e=this._setData(e,n):(e={id:r.generateUuid()},this._core=new i(e,this,n),this._data=e);}Object.defineProperties(a.prototype,{rootNode:{get:function(){return this._core.rootNode;},set:function(e){this._core.rootNode=e;}},name:{get:function(){return this._core.rootNode.name;},set:function(e){var t=this._core;if(t._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new o(o.INVALID_PARAMS,"Expecting a string or undefined.");t.rootNode.name=e;}},type:{get:function(){return this._core.rootNode.type;},set:function(e){var t=this._core;if(t._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("string"!=typeof e||""===e)throw new o(o.INVALID_PARAMS,"Expecting a non-empty string.");t.rootNode.type=e;}},compositeHref:{get:function(){return this._owner.compositeHref;},set:function(){throw new o(o.READ_ONLY,'Property "compositeHref" is read-only.');}},_localStorage:{get:function(){return this._core._localStorage;},set:function(e){this._core._localStorage=e;}},hasLocalStorage:{get:function(){return this._core.hasLocalStorage;},set:function(e){this._core.hasLocalStorage=e;}},_isDirty:{get:function(){return this._core._isDirty;},set:function(e){this._core._isDirty=e;}},isDirty:{get:function(){return this._isDirty;},set:function(e){this._core.isDirty=e;}},changeCount:{get:function(){return this._core.changeCount;},set:function(e){this._core.changeCount=e;}}}),a.prototype.getChildWithId=function(e){return this._core.getChildWithId(e);},a.prototype.getChildWithAbsolutePath=function(e){return this._core.getChildWithAbsolutePath(e);},a.prototype.getChildrenOf=function(e){return this._core.getChildrenOf(e);},a.prototype.addChild=function(e,t,n,i){return this._core.addChild(e,t,n,i);},a.prototype.removeChild=function(e){return this._core.removeChild(e);},a.prototype.moveChild=function(e,t,n){return this._core.moveChild(e,t,n);},a.prototype.copyChild=function(e,t,n,i,o,r){return this._core.copyChild(e,t,n,i,o,r);},a.prototype.allComponents=function(){return this._core.allComponents();},a.prototype.getComponentWithId=function(e){return this._core.getComponentWithId(e);},a.prototype.getComponentWithAbsolutePath=function(e){return this._core.getComponentWithAbsolutePath(e);},a.prototype.getComponentsOf=function(e){return this._core.getComponentsOf(e);},a.prototype.addComponent=function(e,t,n,i,o,r,a,s,c,l){return this._core.addComponent(e,t,n,i,o,r,a,s,c,l);},a.prototype.addComponentWithUploadResults=function(e,t,n,i,o){return this._core.addComponentWithUploadResults(e,t,n,i,o);},a.prototype.updateComponent=function(e,t,n,i){return this._core.updateComponent(e,t,n,i);},a.prototype.updateComponentWithUploadResults=function(e,t){return this._core.updateComponentWithUploadResults(e,t);},a.prototype.removeComponent=function(e){return this._core.removeComponent(e);},a.prototype.moveComponent=function(e,t){return this._core.moveComponent(e,t);},a.prototype.copyComponent=function(e,t,n,i,o){return this._core.copyComponent(e,t,n,i,o);},a.prototype.assetOfComponent=function(e,t){return this._core.assetOfComponent(e,t);},a.prototype.parse=function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "data" must be a string');var t=null;try{t=JSON.parse(e);}catch(e){throw new o(o.INVALID_JSON,"Manifest could not be parsed. Underlying error: "+e.message);}return this._setData(t,this._core._readOnly);},a.prototype.copy=function(){return new a(JSON.parse(JSON.stringify(this._data)),this._owner);},a.prototype._updateLocalDataFromBranch=function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");if(!e._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage for source.");if(this._localStorage.compositePath!==e._localStorage.compositePath)throw new o(o.INVALID_PARAMS,"Branches must have same storage path.");this._core._localStorage.copyLocalStorageData(e,e._core._local(),this,this._core._local()),this._core._copySourceHrefsFrom(e._core);},a.prototype._verify=function(e){return"string"!=typeof e.id?new o(o.INVALID_DATA,"Element is missing an id of type string"):"string"!=typeof e.name?new o(o.INVALID_DATA,"Element is missing a name of type string"):"string"!=typeof e.type?new o(o.INVALID_DATA,"Element is missing a type of type string"):null;},a.prototype._setData=function(e,t){var n=this._verify(e);if(null===n)return this._core=new i(e,this,t),this._data=e,this;throw n;},a.prototype._local=function(){return this._core._local();},a.prototype._setDirty=function(e){this._core._setDirty(e);},a.prototype._setPathOfNode=function(e,t){this._core._setPathOfNode(e,t);},a.prototype._verifyIntegrity=function(e,t,n){return this._core._verifyIntegrity(e,t,n);},e.exports=a;},function(e,t,n){var i=n(0),o=n(1),r=n(5),a=n(57);function s(e,t){if("string"!=typeof e||""===e)throw new i(i.INVALID_PARAMS,'Param "compositePath" must be a non-empty string.');this._compositePath=e,this._preserveFileExtensions=t,this._inMemoryBranchesAndElements=[],this._inflightComponents=[];}Object.defineProperties(s.prototype,{compositePath:{get:function(){return this._compositePath;},set:function(e){if("string"!=typeof e||""===e)throw new i(i.INVALID_PARAMS,'Param "compositePath" must be a non-empty string.');this._compositePath=e;}}}),s.prototype.currentManifestPath=function(){return this._compositePath+"/manifest";},s.prototype.currentBaseManifestPath=function(){return this._compositePath+"/manifest.base";},s.prototype.pulledManifestPath=function(){return this._compositePath+"/pull.manifest";},s.prototype.pushedManifestPath=function(){return this._compositePath+"/push.manifest";},s.prototype.resolvePulledBranch=function(e,t){var n=this;r.writeFileAtomically(this.currentManifestPath(),e.localData,"utf8",function(e){e?(e.code!==i.OUT_OF_SPACE&&(e=new i(i.INVALID_STATE,"Could not write current manifest.",e)),t(e)):r.move(n.pulledManifestPath(),n.currentBaseManifestPath(),!1,function(e){e?t(new i(i.INVALID_STATE,"Could not move pull manifest.",e)):(n._pullJournal&&n._pullJournal.clear(),t());});});},s.prototype.acceptPushedBranch=function(e,t){var n=this;r.writeFileAtomically(this.currentManifestPath(),e.localData,"utf8",function(e){e?(e.code!==i.OUT_OF_SPACE&&(e=new i(i.INVALID_STATE,"Could not write current manifest.",e)),t(new i(i.INVALID_STATE,"Could not write current manifest.",e))):r.move(n.pushedManifestPath(),n.currentBaseManifestPath(),!1,function(e){e?t(new i(i.INVALID_STATE,"Could not move push manifest.",e)):n._deleteJournal(t);});});},s.prototype.discardPulledBranch=function(e){r.deleteFile(this.pulledManifestPath(),e);},s.prototype.discardPushedBranch=function(e){var t=this;r.deleteFile(this.pushedManifestPath(),function(n){n?e(n):t._deleteJournal(e);});},s.prototype.discardBaseBranch=function(e){r.deleteFile(this.currentBaseManifestPath(),e);},s.prototype.registerInMemoryBranchOrElement=function(e){if(this._inMemoryBranchesAndElements.indexOf(e)>=0)throw new i(i.INVALID_STATE,"Branch or element is already registered.");this._inMemoryBranchesAndElements.push(e);},s.prototype.unregisterInMemoryBranchOrElement=function(e){var t=this._inMemoryBranchesAndElements.indexOf(e);if(t<0)throw new i(i.INVALID_STATE,"Unknown branch or element.");this._inMemoryBranchesAndElements.splice(t,1);},s.prototype._deleteJournal=function(e){r.deleteFile(this.pushJournalPath(),e);};var c=/(\/)|(\.$)/;s.prototype.componentAssetName=function(e,t){var n=t["copyOnWrite#storageIds"],i=n?n[e.id]:null;return i&&c.test(i)&&(i=null),i;},s.prototype.componentAssetPath=function(e,t){var n=this.componentAssetName(e,t);return n?this._componentPathFromName(n):null;},s.prototype.ingestComponentAsset=function(e,t,n,o,a){var s=this,c=this._newFileNameForComponent(e),l=this._componentPathFromName(c);this._inflightComponents.push(c);var u=function(t){if(!t)try{s._setComponentName(e,o,c);}catch(e){t=e;}var n=s._inflightComponents.indexOf(c);n<0&&!t&&(t=new i(i.INVALID_STATE,"Could not find inflight component.")),s._inflightComponents.splice(n,1),a(t);};n?r.copyFile(t,l,u):r.move(t,l,!0,u);},s.prototype.removeComponentAsset=function(e,t){var n=t["copyOnWrite#storageIds"];n&&delete n[e.id];},s.prototype.componentIds=function(e){var t=e["copyOnWrite#storageIds"];return t?Object.keys(t):[];},s.prototype.copyLocalStorageData=function(e,t,n,i){var o,r=n.allComponents(),a=r.length,s=t["copyOnWrite#storageIds"];if(s){var c=i["copyOnWrite#storageIds"];for(c||(c=i["copyOnWrite#storageIds"]={}),o=0;o<a;o++){var l=r[o],u=l.id,_=e.getComponentWithId(u);if(_&&_.etag===l.etag){var h=s[u];h&&(c[u]=h);}}}},s.prototype.removeUnusedLocalFiles=function(e,t){var n,o,a,s,c,l=this,u=function(e){l._deleteComponentAsset(e,function(e){e&&!n&&(n=e),0===--c&&t(n);});},_=function(){try{var e,n=s.length,i=[];for(e=0;e<n;e++){var r=s[e].name,_=s[e].info;!o[r]&&_.mtime.getTime()<a&&l._inflightComponents.indexOf(r)<0&&i.push(r);}if((c=n=i.length)>0)for(e=0;e<n;e++)u(i[e]);}catch(e){return void t(e);}0===c&&t();};this._gatherComponentAssetNames([this.currentManifestPath(),this.currentBaseManifestPath(),this.pulledManifestPath(),this.pushedManifestPath()],e,function(e,r,c,l){if(n)t(n);else{if(!e)try{if(r<1||!l)throw new i(i.INVALID_STATE,r<1?"No manifest found.":"Invalid time stamp");o=c,a=l;}catch(t){e=t;}e&&(n=e),s&&(n?t(n):_());}}),r.directoryListing(this._compositePath+"/components",function(e,i){if(n)t(n);else{if(!e)try{s=i;}catch(t){e=t;}e&&(n=e),o&&(n?t(n):_());}});},s.prototype.tempPathForComponent=function(){return this._compositePath+"/tmp/"+o.generateUuid();},s.prototype.deleteTempFiles=function(e){r.deleteDirectory(this._compositePath+"/tmp",e);},s.prototype.clientDataPath=function(){return this._compositePath+"/clientdata";},s.prototype.pushJournalPath=function(){return this._compositePath+"/push.journal";},s.prototype.pullJournalPath=function(){return this._compositePath+"/pull.journal";},s.prototype.loadPullJournal=function(){return this._pullJournal?Promise.resolve(this._pullJournal):(this._pullJournal=new a(this.pullJournalPath()),this._pullJournal.load());},s.prototype._copyComponentMapping=function(e,t,n,i){var o=t["copyOnWrite#storageIds"];if(o){var r=i["copyOnWrite#storageIds"];r||(r=i["copyOnWrite#storageIds"]={});var a=o[e];return a&&(r[n]=a),a;}},s.prototype._componentPathFromName=function(e){return this._compositePath+"/components/"+e;},s.prototype._newFileNameForComponent=function(e){var t=o.generateUuid();if(this._preserveFileExtensions){var n=e.path?o.filePathComponents(e.path).extension:null;n&&(t=t+"."+n);}return t;},s.prototype._setComponentName=function(e,t,n){var i=t["copyOnWrite#storageIds"];i||(i=t["copyOnWrite#storageIds"]={}),i[e.id]=n;},s.prototype._gatherComponentAssetNames=function(e,t,n){try{var i,a,s={},c=t||o.timeStamp(!0),l=e.length,u=l,_=0,h=function(e){if(e){e=e["copyOnWrite#storageIds"];var t,n=Object.keys(e);for(t=0;t<n.length;t++){var i=e[n[t]];s[i]=!0;}}},p=function(e){r.exists(e,function(t){t?(_++,r.info(e,function(t,i){if(!t)try{var o=i.mtime.getTime();o<c&&(c=o),r.readFile(e,"utf8",function(e,t){if(u--,!e)try{t=JSON.parse(t),h(t.local);}catch(t){e=t;}e&&!a&&(a=e),0===u&&n(a,_,s,c);});}catch(e){t=e;}t&&(u--,a||(a=t),0===u&&n(a));})):0===--u&&n(a,_,s,c);});};for(i=0;i<l;i++)p(e[i]);for(l=this._inMemoryBranchesAndElements.length,i=0;i<l;i++)h(this._inMemoryBranchesAndElements[i]._local());}catch(e){n(e);}},s.prototype._deleteComponentAsset=function(e,t){r.deleteFile(this._componentPathFromName(e),t);},e.exports=s;},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var o=n(5),r=n(1),a=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._filePath=t,this._data={version:1,downloadedComponents:{}};}var t,n,a;return t=e,(n=[{key:"saveComponentPath",value:function(e){var t=e._owner;return this._data.downloadedComponents=this._data.downloadedComponents||[],this._data.downloadedComponents[e.id]={version:e.version,path:t._localStorage.componentAssetName(e,t._local())},this.save();}},{key:"restoreComponentPath",value:function(e){var t=e._owner,n=this._data.downloadedComponents[e.id];return!(!n||n.version!==e.version||(t._localStorage._setComponentName(e,t._local(),n.path),0));}},{key:"clear",value:function(){return this._data.downloadedComponents=[],this.save();}},{key:"load",value:function(){var e=this;return new Promise(function(t){o.readFile(e._filePath,"utf8",function(n,i){var o;try{o=JSON.parse(i);}catch(n){}o&&1===o.version&&o.downloadComponents&&(e._data=o),t(e);});});}},{key:"_doSave",value:function(){var e=this;return new Promise(function(t){var n=function(e){e&&r.log("Error writing pull journal: ".concat(e)),t();};0===e._data.downloadedComponents.length?o.deleteFile(e._filePath,n):o.writeFileAtomically(e._filePath,JSON.stringify(e._data),"utf8",n);});}},{key:"save",value:function(){var e=this;return this._savingPromise?this._pendingSave=!0:this._savingPromise=this._doSave().then(function(){if(delete e._savingPromise,e._pendingSave)return delete e._pendingSave,e.save();}),this._savingPromise;}}])&&i(t.prototype,n),a&&i(t,a),e;}();e.exports=a;},function(e,t,n){var i,o=n(1),r=n(0),a=n(5),s=n(14),c=n(24),l=n(59).TextEncoder;i=("undefined"==typeof window?{}:window).XMLHttpRequest;var u=o.merge;function _(e){this._requestQueue=[],this._requestsOutstanding=[],this._rejectedAuths=[],this._authCallback=e,this._isActive=!0,this._waitingForAuthentication=!!e,this._currentAuthId=o.generateUuid(),this._https=void 0,this._XMLHttpRequest=i,this._handlesRedirects=void 0!==i,this._maxOutstanding=5;}Object.defineProperties(_.prototype,{isActive:{get:function(){return this._isActive;},set:function(e){this._isActive!==e&&(this._isActive=e,e||(this._authValue=void 0,this._checkQueue()));}},crossOriginCredentials:{get:function(){return this._withCredentials;},set:function(e){this._withCredentials=e;}},maxOutstanding:{get:function(){return this._maxOutstanding;},set:function(e){this._maxOutstanding=e,this._checkQueue();}},handlesRedirects:{get:function(){return this._handlesRedirects;}}}),_.prototype._forceXhr=function(e,t){this._https=void 0,this._XMLHttpRequest=e||i,this._handlesRedirects=!t;},_.prototype.setAdditionalHeaders=function(e){this._additionalHeaders=e||{};},_.prototype.setAdditionalNodeOptions=function(e){this._additionalNodeOptions=e;},_.prototype.setApiKey=function(e){this._apiKey=e;},_.prototype.setTimeout=function(e){this._timeout=e;},_.prototype.setAuthToken=function(e){e?(this._authValue="Bearer "+e,this.resume()):(this._authValue=void 0,this._currentAuthId=o.generateUuid());},_.prototype.resume=function(){this._currentAuthId=o.generateUuid(),this._waitingForAuthentication=!1,this._checkQueue();},_.prototype.setRequestHooks=function(e,t){this._beforeHook=e,this._afterHook=t;},_.prototype.invoke=function(e,t,n,i,c,l){if(void 0===t)return l(new r(r.INVALID_PARAMS,"No href provided"));var _=(c=c||{}).responseType;if(_ instanceof s){if(!a.canUseFileSystem)throw new r(r.INVALID_PARAMS,"No filesystem access");}else if("buffer"===_){if("function"!=typeof Buffer)throw new r(r.INVALID_PARAMS,"No Buffer class");}else if("blob"===_){if("function"!=typeof Blob)throw new r(r.INVALID_PARAMS,"No Blob class");}else if(_&&"text"!==_&&"json"!==_&&"arraybuffer"!==_)throw new r(r.INVALID_PARAMS,"Unsupported response type");n=u({},n,this._additionalHeaders),this._apiKey&&(n["x-api-key"]=this._apiKey);var h={method:e,href:t,headers:n,callback:l,body:i,options:c},p=c.reuseRequestDesc;if(p){if(this._requestQueue.indexOf(p)>=0||this._requestsOutstanding.indexOf(p)>=0)throw new r(r.INVALID_PARAMS,"Request descriptor still in use.");h=o.merge(p,h);}return this._doRequest(h),h;},_.prototype._getSize=function(e){return new Promise(function(t){e instanceof s?a.info(e.filename,function(e,n){return t(n&&n.size);}):"string"==typeof e?t(new l().encode(e).length):t();});},_.prototype._doRequest=function(e){var t,n,i,l=this,_=this,h=0,p=[],d=e.body,f=e.options.responseType;function m(t,i){if(t)o.log("["+e.id+"] error: "+t);else{var a=new Date().valueOf()-e.startTime;i.complete?o.log("["+e.id+"] success ("+a+"ms)"):o.log("["+e.id+"] success ("+a+"ms) but response is incomplete");}var s=_._requestsOutstanding.indexOf(e);s>=0&&_._requestsOutstanding.splice(s,1);var c=e.callback;c&&(e.callback=void 0,t&&(t.clientRequest=e.clientRequest,t.xhr=e.xhr),t&&t.code!==r.SERVICE_IS_INACTIVE&&!_._isActive?t=new r(r.SERVICE_IS_INACTIVE,"Service is now inactive",t):e.timedOut&&(t=new r(r.TIMED_OUT,"timed out request",t)),c(t,i)),n&&n.end(),_._isActive&&_._checkQueue();}if(!this._isActive)return m(new r(r.SERVICE_IS_INACTIVE,"Network request in inactive state"));function v(t){var i=!1,c=!1,l=!1;function u(){if(!c)return c=!0,n=void 0,m(void 0,t);}var h=_._requestsOutstanding.indexOf(e);if(h<0)_._checkQueue();else{e.response=t;var d=new Date().valueOf()-e.startTime;if(o.log("["+e.id+"] "+t.statusCode+" ("+d+"ms)"),401===t.statusCode&&_._authCallback)_._requestsOutstanding.splice(h,1),_._requestQueue.unshift(e),_._authFail(e),o.consumeStream(t);else{var v=e.progress;200===t.statusCode||201===t.statusCode||202===t.statusCode?(t.on("data",function(e){e.length&&v&&v(e.length),!n&&e&&p.push(e);}),_._https&&f instanceof s&&(n=a.createWriteStream(f.filename),t.pipe(n),i=!0)):(f="text",t.on("data",function(e){return p.push(e);})),t.once("end",function(){l=!0;var n=_._requestsOutstanding.indexOf(e);if(!(n<0||(_._requestsOutstanding.splice(n,1),_._checkQueue(),i||c)))return c=!0,t.response=Buffer.concat(p),"arraybuffer"===f?t.response=new ArrayBuffer(t.response):"text"===f&&(t.response=t.response.toString()),m(void 0,t);});var y=function(){if(!l&&!c)return c=!0,m(new r(r.NETWORK_ERROR,"incomplete response"));};t.once("close",y),t.once("aborted",function(){t.complete||y();}),i&&(n.once("finish",u),n.once("close",u));}}}function y(t){t.pipe(i),t.on("error",function(t){m(new r(r.TERMINATED_INPUTSTREAM,"Input stream terminated abnormally",t)),_.abort(e);});}if(this._waitingForAuthentication||this._requestsOutstanding.length>=this._maxOutstanding||e.options.noSoonerThen)this._requestQueue.push(e),this._waitingForAuthentication||this._checkQueue();else{var g=e.headers;if(0!==e.href.indexOf("https:"))return m(new r(r.INVALID_PARAMS,"http not supported - network requests must use https"));if(null===g.Authorization?delete g.Authorization:this._authValue&&(g.Authorization=this._authValue),this._currentAuthId&&(e.authId=this._currentAuthId),this._beforeHook&&this._beforeHook(e),e.id=o.generateUuid(),e.startTime=new Date().valueOf(),null!==g["X-Request-Id"]?g["X-Request-Id"]=e.id:delete g["X-Request-Id"],this._https){this._requestsOutstanding.push(e);var E=(void 0).parse(e.href),O=u({},this._additionalNodeOptions,E);O.method=e.method||"GET",O.headers=g,o.log("["+e.id+"] "+O.method+" "+e.href),this._getSize(d).then(function(t){t&&(null===O.headers["Content-Length"]?delete O.headers["Content-Length"]:void 0===O.headers["Content-Length"]&&(O.headers["Content-Length"]=t)),i=l._https.request(O,v),e.clientRequest=i,i.once("error",m),i.once("abort",function(){return m(new r(r.NETWORK_ERROR,"Request aborted"));}),_._timeout&&i.setTimeout(_._timeout,function(){e.timedOut=!0,i.abort();}),e.bytesSent=0,e.bytesReported=0,i.once("end",function(){if(e.progress){var t=e.bytesSent-e.bytesReported;t>0&&(e.progress(t),e.bytesReported+=t);}});var n=i.write;if(i.write=function(t){var o=t&&t.length;return o&&(e.bytesSent+=o),n.call(i,t,function(){e.progress&&t&&(e.progress(o),e.bytesReported+=o);});},d instanceof s)y(a.createReadStream(d.filename,d.range));else if(d instanceof c){if(d.getStream)y(d.getStream());else d.getStreamAsync&&d.getStreamAsync(function(t,n){if(t)return m(new r(r.TERMINATED_INPUTSTREAM,"Error creating input stream",t)),void _.abort(e);y(n);});}else if(d instanceof Buffer)i.write(d),i.end();else if(d instanceof ArrayBuffer)i.write(Buffer.from(new Int8Array(d))),i.end();else if("string"==typeof d)i.write(Buffer.from(d,"utf8")),i.end();else{if(d)return m(new r(r.INVALID_PARAMS,"Invalid data type"));i.end();}l._afterHook&&l._afterHook(e,i);}).catch(m);}else{if(d instanceof s)return a.canUseFileSystem?void a.readFile(d.filename,{},function(t,n){if(t)return m(t);e.body=n,_._doRequest(e);}):m(new r(r.INVALID_PARAMS,"Can't use FileContent without filesystem support"));var S;for(S in"function"==typeof Buffer&&d instanceof Buffer&&(e.body=d=new Int8Array(d)),this._requestsOutstanding.push(e),o.log("["+e.id+"] "+e.method+" "+e.href),(t=new this._XMLHttpRequest()).open(e.method,e.href,!0),this._withCredentials&&(t.withCredentials=!0),f&&(t.responseType=f instanceof s?"buffer":f),t.onreadystatechange=function(){var n=e.progress;if(n&&t.response){var i=t.response.length;n(i-h),h=i;}if(4===t.readyState){if(0===t.status)return m(new r(r.UNEXPECTED,"XHR failure"));var c=_._requestsOutstanding.indexOf(e);if(c<0)_._checkQueue();else{var l=new Date().valueOf()-e.startTime;if(o.log("["+e.id+"] "+t.status+" ("+l+"ms)"),_._requestsOutstanding.splice(c,1),401!==t.status||!_._authCallback){if(e.xhr=t,e.response=t,t.statusCode=t.status,t.headers=o.parseHeaders(t.getAllResponseHeaders()),f instanceof s){var u=t.response.response;return void a.writeFileAtomically(f.filename,u,void 0,function(e){return e?m(new r(r.UNEXPECTED,"Can't create file",e,t)):m(void 0,t);});}return n&&d&&n(d.length||d.size),m(void 0,t);}_._requestQueue.unshift(e),_._authFail(e),_._checkQueue();}}},g)g.hasOwnProperty(S)&&t.setRequestHeader(S,g[S]);e.xhr=t,_._timeout&&(t.timeout=_._timeout,t.ontimeout=function(){e.timedOut=!0,t.abort();}),d?t.send(d):t.send(),this._afterHook&&this._afterHook(e,t);}}},_.prototype._authFail=function(e){if(this._authCallback){var t=e.authId;if(-1!==this._rejectedAuths.indexOf(t))return;this._authValue=null,this._waitingForAuthentication=!0,this._rejectedAuths.unshift(t)>this._maxOutstanding&&(this._rejectedAuths.length=this._maxOutstanding),this._authCallback(this);}},_.prototype._checkQueue=function(){if(!this._isActive){var e=this._requestsOutstanding;this._requestsOutstanding=[],e.forEach(function(e){e.xhr&&e.xhr.abort(),e.clientRequest&&e.clientRequest.abort();var t=e.callback;t&&(e.callback=void 0,t(new r(r.SERVICE_IS_INACTIVE,"Network request in inactive state")));});var t=this._requestQueue;return this._requestQueue=[],t.forEach(function(e){var t=new r(r.SERVICE_IS_INACTIVE,"Network request in inactive state"),n=e.callback;n&&(e.callback=void 0,n(t));}),void(this._checkQueueTimerId&&(clearTimeout(this._checkQueueTimerId),this._checkQueueTimerId=void 0,this._checkQueueTimerWhen=void 0));}for(var n,i=Date.now(),o=i+3e5,a=0;!(this._waitingForAuthentication||this._requestsOutstanding.length>=this._maxOutstanding||a>=this._requestQueue.length);){var s=this._requestQueue[a];(n=s.options.noSoonerThen||i)&&n>o&&(n=s.options.noSoonerThen=o),n<=i?(this._requestQueue.splice(a,1),s.options.noSoonerThen=void 0,this._doRequest(s)):a++;}if(!this._waitingForAuthentication&&this._requestsOutstanding.length<this._maxOutstanding&&this._requestQueue.length>0){var c,l,u=this._requestQueue.length;for(l=0;l<u;l++)(n=this._requestQueue[l].options.noSoonerThen)&&n>o&&(n=this._requestQueue[l].options.noSoonerThen=o),n&&(c=c&&c<n?c:n);if(c&&(!this._checkQueueTimerWhen||this._checkQueueTimerWhen>c)){this._checkQueueTimerId&&clearTimeout(this._checkQueueTimerId),this._checkQueueTimerWhen=c;var _=this;this._checkQueueTimerId=setTimeout(function(){_._checkQueueTimerWhen=void 0,_._checkQueueTimerId=void 0,_._checkQueue();},c-i);}}},_.prototype.abort=function(e){var t=this._requestQueue.indexOf(e);t>=0?this._requestQueue.splice(t,1):(t=this._requestsOutstanding.indexOf(e))>=0&&(this._requestsOutstanding.splice(t,1),e.xhr&&e.xhr.abort(),e.clientRequest&&e.clientRequest.abort(),this._checkQueue());};var h=function(e){var t=e&&e.callback;t&&(e.callback=void 0,t(new r(r.NETWORK_ERROR,"Request aborted")));};_.prototype.abortAllWithToken=function(e){if(e){for(var t=0;t<this._requestQueue.length;++t){var n=this._requestQueue[t];n.token===e&&(h(n),this._requestQueue.splice(t,1),--t);}for(var i=0;i<this._requestsOutstanding.length;++i)if(this._requestsOutstanding[i].token===e){var o=this._requestsOutstanding[i];this._requestsOutstanding.splice(i,1),--i,o.xhr&&o.xhr.abort(),o.clientRequest&&o.clientRequest.abort();}this._checkQueue();}},_.prototype.abortAll=function(){this._requestQueue.slice().forEach(h),this._requestQueue=[],this._requestsOutstanding.slice().forEach(function(e){e.xhr&&e.xhr.abort(),e.clientRequest&&e.clientRequest.abort();}),this._requestsOutstanding=[],this._checkQueue();},e.exports=_;},function(e,t,n){(function(e){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}var o=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),n={},i=0;i<t.length;i++)n[t[i]]=Object.getOwnPropertyDescriptor(e,t[i]);return n;},r=/%[sdj%]/g;t.format=function(e){if(!y(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(c(arguments[n]));return t.join(" ");}n=1;for(var i=arguments,o=i.length,a=String(e).replace(r,function(e){if("%%"===e)return"%";if(n>=o)return e;switch(e){case"%s":return String(i[n++]);case"%d":return Number(i[n++]);case"%j":try{return JSON.stringify(i[n++]);}catch(e){return"[Circular]";}default:return e;}}),s=i[n];n<o;s=i[++n])m(s)||!O(s)?a+=" "+s:a+=" "+c(s);return a;},t.deprecate=function(n,i){if(void 0!==e&&!0===e.noDeprecation)return n;if(void 0===e)return function(){return t.deprecate(n,i).apply(this,arguments);};var o=!1;return function(){if(!o){if(e.throwDeprecation)throw new Error(i);e.traceDeprecation?console.trace(i):console.error(i),o=!0;}return n.apply(this,arguments);};};var a,s={};function c(e,n){var i={seen:[],stylize:u};return arguments.length>=3&&(i.depth=arguments[2]),arguments.length>=4&&(i.colors=arguments[3]),f(n)?i.showHidden=n:n&&t._extend(i,n),g(i.showHidden)&&(i.showHidden=!1),g(i.depth)&&(i.depth=2),g(i.colors)&&(i.colors=!1),g(i.customInspect)&&(i.customInspect=!0),i.colors&&(i.stylize=l),_(i,e,i.depth);}function l(e,t){var n=c.styles[t];return n?"["+c.colors[n][0]+"m"+e+"["+c.colors[n][1]+"m":e;}function u(e,t){return e;}function _(e,n,i){if(e.customInspect&&n&&T(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var o=n.inspect(i,e);return y(o)||(o=_(e,o,i)),o;}var r=function(e,t){if(g(t))return e.stylize("undefined","undefined");if(y(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string");}if(v(t))return e.stylize(""+t,"number");if(f(t))return e.stylize(""+t,"boolean");if(m(t))return e.stylize("null","null");}(e,n);if(r)return r;var a=Object.keys(n),s=function(e){var t={};return e.forEach(function(e,n){t[e]=!0;}),t;}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(n)),A(n)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return h(n);if(0===a.length){if(T(n)){var c=n.name?": "+n.name:"";return e.stylize("[Function"+c+"]","special");}if(E(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(S(n))return e.stylize(Date.prototype.toString.call(n),"date");if(A(n))return h(n);}var l,u="",O=!1,b=["{","}"];(d(n)&&(O=!0,b=["[","]"]),T(n))&&(u=" [Function"+(n.name?": "+n.name:"")+"]");return E(n)&&(u=" "+RegExp.prototype.toString.call(n)),S(n)&&(u=" "+Date.prototype.toUTCString.call(n)),A(n)&&(u=" "+h(n)),0!==a.length||O&&0!=n.length?i<0?E(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special"):(e.seen.push(n),l=O?function(e,t,n,i,o){for(var r=[],a=0,s=t.length;a<s;++a)R(t,String(a))?r.push(p(e,t,n,i,String(a),!0)):r.push("");return o.forEach(function(o){o.match(/^\d+$/)||r.push(p(e,t,n,i,o,!0));}),r;}(e,n,i,s,a):a.map(function(t){return p(e,n,i,s,t,O);}),e.seen.pop(),function(e,t,n){if(e.reduce(function(e,t){return t.indexOf("\n")>=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1;},0)>60)return n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n  ")+" "+n[1];return n[0]+t+" "+e.join(", ")+" "+n[1];}(l,u,b)):b[0]+u+b[1];}function h(e){return"["+Error.prototype.toString.call(e)+"]";}function p(e,t,n,i,o,r){var a,s,c;if((c=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?s=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(s=e.stylize("[Setter]","special")),R(i,o)||(a="["+o+"]"),s||(e.seen.indexOf(c.value)<0?(s=m(n)?_(e,c.value,null):_(e,c.value,n-1)).indexOf("\n")>-1&&(s=r?s.split("\n").map(function(e){return"  "+e;}).join("\n").substr(2):"\n"+s.split("\n").map(function(e){return"   "+e;}).join("\n")):s=e.stylize("[Circular]","special")),g(a)){if(r&&o.match(/^\d+$/))return s;(a=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"));}return a+": "+s;}function d(e){return Array.isArray(e);}function f(e){return"boolean"==typeof e;}function m(e){return null===e;}function v(e){return"number"==typeof e;}function y(e){return"string"==typeof e;}function g(e){return void 0===e;}function E(e){return O(e)&&"[object RegExp]"===b(e);}function O(e){return"object"===i(e)&&null!==e;}function S(e){return O(e)&&"[object Date]"===b(e);}function A(e){return O(e)&&("[object Error]"===b(e)||e instanceof Error);}function T(e){return"function"==typeof e;}function b(e){return Object.prototype.toString.call(e);}function L(e){return e<10?"0"+e.toString(10):e.toString(10);}t.debuglog=function(n){if(g(a)&&(a=e.env.NODE_DEBUG||""),n=n.toUpperCase(),!s[n])if(new RegExp("\\b"+n+"\\b","i").test(a)){var i=e.pid;s[n]=function(){var e=t.format.apply(t,arguments);console.error("%s %d: %s",n,i,e);};}else s[n]=function(){};return s[n];},t.inspect=c,c.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},c.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=d,t.isBoolean=f,t.isNull=m,t.isNullOrUndefined=function(e){return null==e;},t.isNumber=v,t.isString=y,t.isSymbol=function(e){return"symbol"===i(e);},t.isUndefined=g,t.isRegExp=E,t.isObject=O,t.isDate=S,t.isError=A,t.isFunction=T,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"===i(e)||void 0===e;},t.isBuffer=n(61);var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function P(){var e=new Date(),t=[L(e.getHours()),L(e.getMinutes()),L(e.getSeconds())].join(":");return[e.getDate(),I[e.getMonth()],t].join(" ");}function R(e,t){return Object.prototype.hasOwnProperty.call(e,t);}t.log=function(){console.log("%s - %s",P(),t.format.apply(t,arguments));},t.inherits=n(62),t._extend=function(e,t){if(!t||!O(t))return e;for(var n=Object.keys(t),i=n.length;i--;)e[n[i]]=t[n[i]];return e;};var C="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function N(e,t){if(!e){var n=new Error("Promise was rejected with a falsy value");n.reason=e,e=n;}return t(e);}t.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(C&&e[C]){var t;if("function"!=typeof(t=e[C]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,C,{value:t,enumerable:!1,writable:!1,configurable:!0}),t;}function t(){for(var t,n,i=new Promise(function(e,i){t=e,n=i;}),o=[],r=0;r<arguments.length;r++)o.push(arguments[r]);o.push(function(e,i){e?n(e):t(i);});try{e.apply(this,o);}catch(e){n(e);}return i;}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),C&&Object.defineProperty(t,C,{value:t,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(t,o(e));},t.promisify.custom=C,t.callbackify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');function n(){for(var n=[],i=0;i<arguments.length;i++)n.push(arguments[i]);var o=n.pop();if("function"!=typeof o)throw new TypeError("The last argument must be of type Function");var r=this,a=function(){return o.apply(r,arguments);};t.apply(this,n).then(function(t){e.nextTick(a,null,t);},function(t){e.nextTick(N,t,a);});}return Object.setPrototypeOf(n,Object.getPrototypeOf(t)),Object.defineProperties(n,o(t)),n;};}).call(this,n(60));},function(e,t){var n,i,o=e.exports={};function r(){throw new Error("setTimeout has not been defined");}function a(){throw new Error("clearTimeout has not been defined");}function s(e){if(n===setTimeout)return setTimeout(e,0);if((n===r||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0);}catch(t){try{return n.call(null,e,0);}catch(t){return n.call(this,e,0);}}}!function(){try{n="function"==typeof setTimeout?setTimeout:r;}catch(e){n=r;}try{i="function"==typeof clearTimeout?clearTimeout:a;}catch(e){i=a;}}();var c,l=[],u=!1,_=-1;function h(){u&&c&&(u=!1,c.length?l=c.concat(l):_=-1,l.length&&p());}function p(){if(!u){var e=s(h);u=!0;for(var t=l.length;t;){for(c=l,l=[];++_<t;)c&&c[_].run();_=-1,t=l.length;}c=null,u=!1,function(e){if(i===clearTimeout)return clearTimeout(e);if((i===a||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(e);try{i(e);}catch(t){try{return i.call(null,e);}catch(t){return i.call(this,e);}}}(e);}}function d(e,t){this.fun=e,this.array=t;}function f(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];l.push(new d(e,t)),1!==l.length||u||s(p);},d.prototype.run=function(){this.fun.apply(null,this.array);},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=f,o.addListener=f,o.once=f,o.off=f,o.removeListener=f,o.removeAllListeners=f,o.emit=f,o.prependListener=f,o.prependOnceListener=f,o.listeners=function(e){return[];},o.binding=function(e){throw new Error("process.binding is not supported");},o.cwd=function(){return"/";},o.chdir=function(e){throw new Error("process.chdir is not supported");},o.umask=function(){return 0;};},function(e,t){function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}e.exports=function(e){return e&&"object"===n(e)&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8;};},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}});}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n(),e.prototype.constructor=e;};},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function r(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}(e):t;}function a(e,t,n){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=s(e)););return e;}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(n):o.value;}})(e,t,n||e);}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e);})(e);}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e;})(e,t);}var l=n(25),u=n(0),_=n(8),h=n(27),p=u.networkError,d=u.unexpectedResponse,f=n(1),m=f.appendPathElements,v=/^https:\/\/platform-cs(?:-stage)?(?:-[a-zA-Z0-9]+)?\.adobe\.io/,y=function(e){function t(e,n,i,o){var a;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,t),(a=r(this,s(t).call(this,e,n,i)))._platformEndpoint=o,a;}var n,i,l;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t);}(t,e),n=t,(i=[{key:"getCollection",value:function(e,t,n){if(!(e=this._resolveUrl(e)))return n(new u(u.WRONG_ENDPOINT,"Wrong endpoint: "+e));var i;e+="?order=asc&orderby=name";var o={};t&&(o["If-None-Match"]=t);var r=this;return this._service.invoke("GET",e,o,void 0,{responseType:"text"},function t(a,s){if(a)return n(p("Error retrieving a collection",a,s));if(200===s.statusCode){var c,l=s.responseText||s.response;try{c=JSON.parse(l);}catch(e){return(a=new u(u.INVALID_DATA,"Invalid JSON returned by server",e)).response=s,n(a);}i?i.children=i.children.concat(c.children):i=c;var _=s.headers["x-children-next-start"];if(_){var h=e+"&start="+_;r._service.invoke("GET",h,o,void 0,{responseType:"text"},t);}else n(void 0,i,s.headers.etag,s.headers);}else 304===s.statusCode?n(void 0,null,s.headers.etag,s.headers):n(d("Unexpected status code while getting a collection",void 0,s));});}},{key:"pagedGetCollection",value:function(e,t,n,i,o,r,a,s){if(!(e=this._resolveUrl(e)))return s(new u(u.WRONG_ENDPOINT,"Wrong endpoint: "+e));e+=function(e,t,n,i){var o=[t&&"order=".concat(t),e&&"orderBy=".concat(e),n&&"start=".concat(n),i&&"limit=".concat(i)].filter(function(e){return e;});return 0===o.length?"":"?".concat(o.join("&"));}(n,i,o,r);var c={};return t&&(c["If-None-Match"]=t),this._service.invoke("GET",e,c,void 0,{responseType:"text"},function(e,t){if(e)return s(p("Error retrieving a collection",e,t));if(200===t.statusCode){var n,i=t.responseText||t.response;try{n=JSON.parse(i);}catch(n){return(e=new u(u.INVALID_DATA,"Invalid JSON returned by server",n)).response=t,s(e);}a?a.children=a.children.concat(n.children):a=n,s(void 0,a,t.headers.etag,t.headers);}else 304===t.statusCode?s(void 0,null,t.headers.etag,t.headers):s(d("Unexpected status code while getting a collection",void 0,t));});}},{key:"getComponent",value:function(e,t,n){var i=this.getComponentHref(e,e.version);return this.getAsset(i,void 0,t,n);}},{key:"getRenditionOfComponent",value:function(e,t,n,i,o){var r=this.getComponentRenditionHref(e,e.version,n);return this.getAsset(r,{accept:t},i,o);}},{key:"getSyncGroups",value:function(e,t){var n=m(this._server,"assets");return this.getCollection(n,e,t);}},{key:"getSyncGroup",value:function(e,t,n){var i=m(this._server,"assets",e);return this.getCollection(i,t,n);}},{key:"getCompositeManifest",value:function(e,t,n){var i=e.href;return i&&(i=this._resolveUrl(i)),i?(i=m(i,"manifest"),this.getAssetAsType(i,"text",t,n)):n(new u(u.WRONG_ENDPOINT,"Wrong endpoint: "+i));}},{key:"createCompositeDirectory",value:function(e,t,n){var i=this,o=this._resolveUrl(e.href);if(!o)return n(new u(u.WRONG_ENDPOINT,"Wrong endpoint: "+o));function r(e,t,n){var r={"Content-Type":e.type,"X-Update":"content"};t&&(r["If-Match"]="*"),i._service.invoke("PUT",o,r,void 0,void 0,function(t,i){if(t)return n(p("Error Creating composite directory",t,i));if(409===i.statusCode)return(t=new u(u.ALREADY_EXISTS,t)).response=i,n(t);try{var o=JSON.parse(i.response);o&&o.urn&&(e.assetId=o.urn);}catch(t){f.log("Could not get assetId from create response: ".concat(e.name));}n(void 0,i);});}r(e,t,function(a,s){if(a)return n(a);var c=s.statusCode;if(200===c||201===c)n(void 0,s);else if(404===c){var l=f.parentDirectory(o);i._service.invoke("PUT",l,{},void 0,void 0,function(i,o){if(i)return n(p("Error creating composite directory",i,o));var a=o.statusCode;200===a||201===a||409===a?r(e,t,function(e,t){if(e)return n(e);var i=t.statusCode;200===i||201===i?n(void 0,t):n(p("Error creating composite directory",e,t));}):n(d("Unexpected response creating composite directory",i,o));});}else n(d("Unexpected response creating composite directory",a,s));});}},{key:"deleteCompositeDirectory",value:function(e,t){var n=this,i=this._resolveUrl(e.href);if(!i)return t(new u(u.WRONG_ENDPOINT,"Wrong endpoint: "+i));i+="?recursive=true&invocation_mode=sync,async";var o=this._service.invoke("DELETE",i,{"If-Match":"*"},void 0,void 0,function(e,i){if(e)return t(p("Error deleting composite directory",e,i));var r=i.statusCode;return 200===r||204===r||404===r?t(void 0,i):202===r?n._handle202Response(i,o,n.SYNC_ASYNC_DEFAULT_DELAY,void 0,t):void t(d("Unexpected response deleting composite directory",e,i));});}},{key:"discardComposite",value:function(e,t){t(new u(u.INVALID_STATE,"Composites can only be discarded on platform."));}},{key:"uploadComponent",value:function(e,t,n,i,o,r){if(!e._owner||!e._owner.compositeHref)throw new u(u.INVALID_STATE,"Component must be part of a branch of a bound composite.");return this.uploadAssetForComponentId(e.id,e.type,e._owner.compositeHref,t,n,i,o,r);}},{key:"uploadAssetForComponentId",value:function(e,t,n,i,o,r,a,s){var c=this._constructComponentHref(n,e);return o&&(c+="?intermediates=false"),this.uploadAssetAtComponentHref(c,t,n,i,o,r,a,s);}},{key:"copyAssetToComponentId",value:function(e,t,n,i,o,r,a,s){var c=this._makeRelativeUrl(a);if(!c)return s(new u(u.WRONG_ENDPOINT,"Cannot copy asset: "+a));var l=this,_=this._constructComponentHref(n,e);_+="?invocation_mode=sync,async",o&&(_+="&intermediates=false");var h={};function f(e,t,n){e?delete h["If-Match"]:h["If-Match"]="*";var i=l._service.invoke("PUT",_,h,void 0,{responseType:"text"},function(e,o){if(e)return n(p("Error uploading component",e,o));var r=o.statusCode;200===r||201===r||204===r?n(void 0,o,t):202===r?l._handle202Response(o,i,l.SYNC_ASYNC_DEFAULT_DELAY,void 0,function(e,i){n(e,i,t);}):n(d("Unexpected response copying a component asset",e,o),o,t);});return i.token=r,i;}return t&&(h["Content-Type"]=t),h.Link="<"+c+">;rel=source",f(i,!0,function e(t,n,o){var r;if(t){if(!(n=t.response))return s(t);var a=n.statusCode;o||404!==a&&409!==a&&412!==a?s(t):f(!i,!0,e);}else{try{r=JSON.parse(n.responseText||n.response);}catch(e){return(t=new u(u.INVALID_DATA,"Invalid JSON returned by server",e)).response=n,s(t);}s(void 0,n,r);}});}},{key:"updateManifest",value:function(e,t,n,i){var o=this.getBranchManifestHref(e);this.updateManifestAtHref(o,t,e.manifestEtag,n,i);}},{key:"getHrefForComposite",value:function(e,t){if(!e.type)throw new u(u.INVALID_STATE,"Composite needs a type");if(!e.id)throw new u(u.INVALID_STATE,"Composite needs an id");return e.href?e.href:this._resolveUrl(m("assets",t,e.id));}},{key:"getHrefForCompositeWithId",value:function(e,t){return this._resolveUrl(m("assets",t,e));}},{key:"getCompositeManifestHref",value:function(e){var t=this._resolveUrl(e.href);if(!t)throw new u(u.WRONG_ENDPOINT,"Wrong endpoint: "+t);return m(t,"manifest");}},{key:"getBranchManifestHref",value:function(e){var t=this._resolveUrl(e.compositeHref);if(!t)throw new u(u.WRONG_ENDPOINT,"Wrong endpoint: "+t);return m(t,"manifest");}},{key:"getComponentHref",value:function(e,t){var n,i=e._owner;if(!i||!i.compositeHref)throw new u(u.INVALID_STATE,"Component must be part of a branch of a bound composite.");return i._core&&(n=i._core._getSourceHrefOfComponent(e)),n&&this._resolveUrl(n)||this._constructComponentHref(i.compositeHref,e.id,t);}},{key:"getComponentRenditionHref",value:function(e,t,n){var i=e._owner;if(!i||!i.compositeHref)throw new u(u.INVALID_STATE,"Component must be part of a branch of a bound composite.");if(i._core&&i._core._getSourceHrefOfComponent(e))throw new u(u.INVALID_STATE,"Getting a rendition of a source href not implemented.");return this._constructComponentRenditionHref(i.compositeHref,e,t,n);}},{key:"_constructComponentHref",value:function(e,t,n){var i=m(this._resolveUrl(e),t);return i&&void 0!==n&&(i+=";version="+n),i;}},{key:"_invokeOperation",value:function(e,t,n,i,o){var r=this,a="".concat(this._resolveUrl("/ops"),"?invocation_mode=sync,async"),s={op:e,id:f.generateUuid(),target:n,source:t};i&&(s.value=i),f.log("[invoke operation]: ".concat(JSON.stringify(s,void 0,2)));var c=function(e,t){var n;if(e)return o(e);try{n=JSON.parse(t.responseText||t.response);}catch(n){return(e=new u(u.INVALID_DATA,"Invalid JSON returned by server",n)).response=t,o(e);}if(n.error)return(e=new u(u.UNEXPECTED_RESPONSE,"Error in operation result: "+JSON.stringify(n.error,void 0,2))).response=t,o(e);o(void 0,t,n);},l=this._service.invoke("POST",a,{"Content-Type":"application/vnd.adobe.asset-operation+json"},JSON.stringify(s),{responseType:"text"},function(t,n){if(t)return c(p("Error invoking operation "+e,t,n));var i=n.statusCode;200===i||201===i||204===i?c(void 0,n):202===i?r._handle202Response(n,l,r.SYNC_ASYNC_DEFAULT_DELAY,void 0,function(e,t){c(e,t);}):c(d("Unexpected response for operation "+e,t,n),n);});return l;}},{key:"_constructComponentRenditionHref",value:function(e,t,n,i){var o=m(this._constructComponentHref(e,t.id),":rendition");return o+=";size="+(i||"full"),void 0!==n&&(o+=";version="+n),o;}},{key:"_getTransientPlatformSession",value:function(){var e=this;return this._transientPlatformSession?Promise.resolve(this._transientPlatformSession):new Promise(function(t,n){var i=new h(e._service,e._platformEndpoint,v);i.getRootDocument(function(o){if(o)return n(o);e._transientPlatformSession=i,t(e._transientPlatformSession);});});}},{key:"_getCopyDelegate",value:function(e,n,i){var o=this;a(s(t.prototype),"_getCopyDelegate",this).call(this,e,n,function(t,r){return t?v.test(e)?void o._doHeadRequest(n,function(t,r){if(t)return i(t);var a=(r&&r.headers||{})["x-resource-urn"];if(!a)return i(new u(u.INVALID_DATA,"Request for composite did not return a URN: ".concat(n)));o._getTransientPlatformSession().then(function(t){t.getLinksFromUrn(a,function(t,n){if(t)return i(new u(u.INVALID_DATA,"Could not get links for URN: ".concat(a)));var r=f.getUrlFromLinks(n,_.PRIMARY);i(null,function(t,n,i,a,s,c){return o._transientPlatformSession.copyAssetToComponentId(t,n,r,i,a,s,e,c);});});});}):i(new u(u.INVALID_PARAMS,"Href is not for a platform component: ".concat(e))):i(null,r);});}}])&&o(n.prototype,i),l&&o(n,l),t;}(l);e.exports=y;},function(e,t,n){function i(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n;}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e);}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance");}();}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function a(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e;}var s=n(0),c=n(28),l=function(){function e(t,n){var i=this;o(this,e),this._sharedRequestDescriptor=t,this._callback=n,this._aborted=!1,this._handleAbort=function(){i._aborted||(i._aborted=!0,i._sharedRequestDescriptor.removeProxy(i),i._callback(new s(s.NETWORK_ERROR,"Request aborted")));};}return a(e,[{key:"bytesSent",get:function(){return this._sharedRequestDescriptor.bytesSent;}},{key:"token",set:function(e){this._token&&this._token.removeAbortListener(this._handleAbort),e&&(this._token=e,this._token.addAbortListener(this._handleAbort));}},{key:"progress",set:function(e){this._progress=e;},get:function(){return this._progress;}},{key:"callback",get:function(){return this._callback;}}]),e;}(),u=function(){function e(t,n){var i=this;o(this,e),this._proxies=[],this._onProgress=function(e){i._xferContext._reportProgress(e),i._proxies.forEach(function(t){return t.progress&&t.progress(e);});},this.callback=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];i._args=t,i._proxies.forEach(function(e){return e.callback.apply(e,t);});},this._xferContext=new c(t,this.callback),this._descriptor=n(function(){var e;return(e=i._xferContext)._callCallback.apply(e,arguments);}),this._descriptor.token=this._xferContext,this._descriptor.progress=this._onProgress,this._expiry=Date.now()+3e4;}return a(e,[{key:"push",value:function(e){var t=new l(this,e);return this._proxies.push(t),this._args&&e.apply(void 0,i(this._args)),t;}},{key:"removeProxy",value:function(e){var t=this._proxies.indexOf(e);-1!==t&&(this._proxies.splice(t,1),0===this._proxies.length&&this._xferContext.abort());}},{key:"bytesSent",get:function(){return this._descriptor.bytesSent;}},{key:"expiry",get:function(){return this._expiry;}}]),e;}();e.exports=u;},function(e,t,n){"use strict";function i(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n;}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e);}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance");}();}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var r=/^utf-?8|ascii|utf-?16-?le|ucs-?2|base-?64|latin-?1$/i,a=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,s=/\s|\uFEFF|\xA0/,c=/\r?\n[\x20\x09]+/g,l=/[;,"]/,u=/[;,"]|\s/,_=/^[!#$%&'*+\-\.^_`|~\da-zA-Z]+$/,h=1,p=2,d=4;function f(e){return e.replace(a,"");}function m(e){return s.test(e);}function v(e,t){for(;m(e[t]);)t++;return t;}function y(e){return u.test(e)||!_.test(e);}var g=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this.refs=[],t&&this.parse(t);}var t,n,r;return t=e,(n=[{key:"rel",value:function(e){for(var t=[],n=e.toLowerCase(),i=0;i<this.refs.length;i++)this.refs[i].rel.toLowerCase()===n&&t.push(this.refs[i]);return t;}},{key:"get",value:function(e,t){e=e.toLowerCase();for(var n=[],i=0;i<this.refs.length;i++)this.refs[i][e]===t&&n.push(this.refs[i]);return n;}},{key:"set",value:function(e){return this.refs.push(e),this;}},{key:"has",value:function(e,t){e=e.toLowerCase();for(var n=0;n<this.refs.length;n++)if(this.refs[n][e]===t)return!0;return!1;}},{key:"parse",value:function(t,n){t=f(t=(n=n||0)?t.slice(n):t).replace(c,"");for(var o,r=h,a=t.length,s=(n=0,null);n<a;)if(r===h){if(m(t[n])){n++;continue;}if("<"!==t[n])throw new Error('Unexpected character "'+t[n]+'" at offset '+n);var u;if(null!=s&&(null!=s.rel?(u=this.refs).push.apply(u,i(e.expandRelations(s))):this.refs.push(s)),-1===(g=t.indexOf(">",n)))throw new Error("Expected end of URI delimiter at offset "+n);s={uri:t.slice(n+1,g)},n=g,r=p,n++;}else if(r===p){if(m(t[n])){n++;continue;}if(";"===t[n])r=d,n++;else{if(","!==t[n])throw new Error('Unexpected character "'+t[n]+'" at offset '+n);r=h,n++;}}else{if(r!==d)throw new Error('Unknown parser state "'+r+'"');if(";"===t[n]||m(t[n])){n++;continue;}if(-1===(g=t.indexOf("=",n)))throw new Error("Expected attribute delimiter at offset "+n);var _=f(t.slice(n,g)).toLowerCase(),y="";if('"'===t[n=v(t,n=g+1)])for(n++;n<a;){if('"'===t[n]){n++;break;}"\\"===t[n]&&n++,y+=t[n],n++;}else{for(var g=n+1;!l.test(t[g])&&g<a;)g++;y=t.slice(n,g),n=g;}switch(s[_]&&e.isSingleOccurenceAttr(_)||("*"===_[_.length-1]?s[_]=e.parseExtendedValue(y):(y="type"===_?y.toLowerCase():y,null!=s[_]?Array.isArray(s[_])?s[_].push(y):s[_]=[s[_],y]:s[_]=y)),t[n]){case",":r=h;break;case";":r=d;}n++;}return null!=s&&(null!=s.rel?(o=this.refs).push.apply(o,i(e.expandRelations(s))):this.refs.push(s)),s=null,this;}},{key:"toString",value:function(){for(var t=[],n="",i=null,o=0;o<this.refs.length;o++)i=this.refs[o],n=Object.keys(this.refs[o]).reduce(function(t,n){return"uri"===n?t:t+"; "+e.formatAttribute(n,i[n]);},"<"+i.uri+">"),t.push(n);return t.join(", ");}}])&&o(t.prototype,n),r&&o(t,r),e;}();g.isCompatibleEncoding=function(e){return r.test(e);},g.parse=function(e,t){return new g().parse(e,t);},g.isSingleOccurenceAttr=function(e){return"rel"===e||"type"===e||"media"===e||"title"===e||"title*"===e;},g.isTokenAttr=function(e){return"rel"===e||"type"===e||"anchor"===e;},g.escapeQuotes=function(e){return e.replace(/"/g,'\\"');},g.expandRelations=function(e){return e.rel.split(" ").map(function(t){var n=Object.assign({},e);return n.rel=t,n;});},g.parseExtendedValue=function(e){var t=/([^']+)?(?:'([^']+)')?(.+)/.exec(e);return{language:t[2].toLowerCase(),encoding:g.isCompatibleEncoding(t[1])?null:t[1].toLowerCase(),value:g.isCompatibleEncoding(t[1])?decodeURIComponent(t[3]):t[3]};},g.formatExtendedAttribute=function(e,t){var n=(t.encoding||"utf-8").toUpperCase();return e+"="+n+"'"+(t.language||"en")+"'"+(Buffer.isBuffer(t.value)&&g.isCompatibleEncoding(n)?t.value.toString(n):Buffer.isBuffer(t.value)?t.value.toString("hex").replace(/[0-9a-f]{2}/gi,"%$1"):encodeURIComponent(t.value));},g.formatAttribute=function(e,t){return Array.isArray(t)?t.map(function(t){return g.formatAttribute(e,t);}).join("; "):"*"===e[e.length-1]||"string"!=typeof t?g.formatExtendedAttribute(e,t):(g.isTokenAttr(e)?t=y(t)?'"'+g.escapeQuotes(t)+'"':g.escapeQuotes(t):y(t)&&(t='"'+(t=(t=encodeURIComponent(t)).replace(/%20/g," ").replace(/%2C/g,",").replace(/%3B/g,";"))+'"'),e+"="+t);},e.exports=g;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function a(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}(e):t;}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e);})(e);}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e;})(e,t);}var l=n(26),u=n(0),_=n(1),h=/^\/?content\/2\/[^/]+\/[^/]+/,p=/^\/?api\/v2\/[^/]+\/assets\/[^/]+/,d={"image/jpeg":"jpg","image/png":"png"},f=_.appendPathElements,m=function(e){function t(){return o(this,t),a(this,s(t).apply(this,arguments));}var n,i,l;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t);}(t,e),n=t,(i=[{key:"getCompositeManifestHref",value:function(e){var t=this._resolveUrl(e.href);if(!t)throw new u(u.WRONG_ENDPOINT,"Wrong endpoint: "+t);return f(t,"manifest");}},{key:"getComponent",value:function(e,t,n){var i=this.getComponentHref(e,e.version);return this.getAsset(i,void 0,t,n);}},{key:"getRenditionOfComponent",value:function(e,t,n,i,o,r){var a=this.getComponentRenditionHref(e,e.version,t,n,i);return this.getAsset(a,{accept:t},o,r);}},{key:"getCompositeManifest",value:function(e,t,n){var i=e.href;return i&&(i=this._resolveUrl(i)),i?(i=f(i,"manifest"),this.getAssetAsType(i,"text",t,n)):n(new u(u.WRONG_ENDPOINT,"Wrong endpoint: "+i));}},{key:"getComponentHref",value:function(e,t){var n,i=e._owner;if(!i||!i.compositeHref)throw new u(u.INVALID_STATE,"Component must be part of a branch of a bound composite.");return i._core&&(n=i._core._getSourceHrefOfComponent(e)),n||this._constructComponentHref(i.compositeHref,e,t);}},{key:"getComponentRenditionHref",value:function(e,t,n,i,o){var r=e._owner;if(!r||!r.compositeHref)throw new u(u.INVALID_STATE,"Component must be part of a branch of a bound composite.");if(r._core&&r._core._getSourceHrefOfComponent(e))throw new u(u.INVALID_STATE,"Getting a rendition of a source href not implemented.");return this._constructComponentRenditionHref(r.compositeHref,e,t,n,i,o);}},{key:"_constructComponentHref",value:function(e,t,n){var i=t.absolutePath.slice(1),o=f(this._resolveUrl(e),i);return o&&void 0!==n&&(this._hrefUsesContentApis(e)?o+="/version/"+n:o+="?version="+n),o;}},{key:"_constructComponentRenditionHref",value:function(e,t,n,i,o,r){var a,s,c=t.absolutePath.slice(1),l=_.parseURI(e).path;if("/content/2/"===l.slice(0,"/content/2/".length)){var f=d[i];if(!f)throw new u(u.INVALID_PARAMS,"Unsupported rendition media type: "+i);if(!((a=h.exec(l))&&a.length>0))throw new u(u.INVALID_PARAMS,"Failed to parse composite href: "+e);s=this._resolveUrl(_.appendPathElements(a[0],"rendition",c,"version",n,"format",f,"dimension",o,"size",String(r)));}else{if(!((a=p.exec(l))&&a.length>0))throw new u(u.INVALID_PARAMS,"Failed to parse composite href: "+e);s=this._resolveUrl(_.appendPathElements(a[0],"rendition",o,String(r),c)+"?version="+n);}return s;}},{key:"_hrefUsesContentApis",value:function(e){return"/content/2/"===_.parseURI(e).path.slice(0,"/content/2/".length);}}])&&r(n.prototype,i),l&&r(n,l),t;}(l);e.exports=m;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n;}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e);}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance");}();}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var a=n(3),s=n(2),c=/(.*)\.TEMP_[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i,l=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._config=n,this._services=t;}var t,n,l;return t=e,(n=[{key:"_uuid",value:function(){return this._services.uuid();}},{key:"_getTempPath",value:function(e){return e+".TEMP_"+this._uuid();}},{key:"_stripTempSuffix",value:function(e){var t=e.match(c);return t&&t[1]?t[1]:e;}},{key:"_fsApply",value:function(e){for(var t=this,n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];var a=i.find(function(e){return"function"==typeof e;}),s=i.slice(0,i.indexOf(a)),c=i.indexOf(a)===i.length-1?0:i[i.length-1],l=function(n){if(n&&"EPERM"===n.code&&c<t._config.FS_MAX_RETRIES)setTimeout(function(){t._fsApply.apply(t,[e].concat(o(s),[a,c+1]));},t._config.FS_RETRY_INTERVAL);else{for(var i=arguments.length,r=new Array(i>1?i-1:0),l=1;l<i;l++)r[l-1]=arguments[l];a.apply(void 0,[n].concat(r));}};this._fs[e].apply(this._fs,s.concat(l));}},{key:"ensurePathExists",value:function(e,t){var n=this;!function e(t,i,o){var r=i.slice(0,t).join(n._pathSep),a=function(){t<i.length?e(t+1,i,o):o(null);};n._fs.exists(r,function(e){return e?a():n._fs.mkdir(r,a);});}(2,e.replace(/\\/g,this._pathSep).split(this._pathSep),t);}},{key:"copyFile",value:function(e,t,n){var i=this,o=this._getTempPath(t);this._fsApply("copyFile",e,o,function(e){e?n(e):i._fsApply("rename",o,t,n);});}},{key:"getAvailablePath",value:function(e,t,n){var i=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=t.lastIndexOf(".");r=-1===r?t.length:r;var a=t.substring(0,r),s=t.substring(r+1),c="".concat(o?" (".concat(o,")"):"").concat(s?".".concat(s):""),l=255-this._getTempPath("").length-c.length,u=a.substr(0,l);u[u.length-1].charCodeAt(0)>=55296&&u[u.length-1].charCodeAt(0)<=56319&&(u=u.substr(0,u.length-1));var _="".concat(e).concat(u).concat(c);this.statFile(_,function(r){r&&r.underlyingError&&"ENOENT"===r.underlyingError.code?n(null,_):r?n(r):i.getAvailablePath(e,t,n,o+1);});}},{key:"rename",value:function(e,t,n){this._fsApply("rename",e,t,n);}},{key:"deleteFile",value:function(e,t){this._fsApply("unlink",e,t);}},{key:"normaliseTempFileName",value:function(e){return this._stripTempSuffix(e);}},{key:"getFileExtension",value:function(e){var t=e&&e.replace(/^.*[\\/]/,""),n=t?t.lastIndexOf("."):-1;if(-1!==n)return t.substr(n+1).toLowerCase();}},{key:"recursiveDeleteDirectory",value:function(e,t){var n=this,i=function(e){e&&"ENOENT"===e.code&&(e=null),t&&t(e);};this._fsApply("readdir",e,function(t,o){if(t)i(t);else if(o&&0!==o.length){var r=null,a=0,s=function(t){t&&"ENOENT"===t.code&&(t=null),r=r||t,++a===o.length&&(r?i(r):n._fs.rmdir(e,i));};o.forEach(function(t){var i=e+n._pathSep+t;n._fsApply("readdir",i,function(e){e?n._fs.unlink(i,s):n.recursiveDeleteDirectory(i,s);});});}else n._fs.rmdir(e,i);});}},{key:"getUserDir",value:function(e){var t=this._services.getPathSeparator(),n=e.replace(/@/g,"_");return this._config.ROOT_DIR+t+n;}},{key:"moveLibrary",value:function(e,t,n){var i=this;if(t!==e.id){var o=e._collection._getCompositeDir(t),r=e._getCompositeDir(),a=e._collection._getRenditionCacheDir(t),s=e._getRenditionCacheDir();this.rename(o,r,function(t){t?n(t):(e._dcxComposite.path=r,i.rename(a,s,function(e){return n(e&&"ENOENT"===e.code?null:e);}));});}else n(null);}},{key:"readLibraryDirectory",value:function(e,t){var n=this,i=e._getTempDir();this.recursiveDeleteDirectory(i,function(){var i=e._getCompositeDir();n._fsApply("readdir",i,t);});}},{key:"doesRootDirExist",value:function(e,t){var n=e._getCompositeDir();this._fs.exists(n,function(e){return t(null,e);});}},{key:"deleteLibraryFromDisk",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){};if(this._fs){var o=e._getCompositeDir(t),r=e._getRenditionCacheDir(t);this.recursiveDeleteDirectory(o,function(){return n.recursiveDeleteDirectory(r,i);});}else i(null);}},{key:"writeJSONData",value:function(e,t,n){var i=this;return new Promise(function(o,r){i.ensurePathExists(e,function(a){if(a)r(a);else{var s=e+i._services.getPathSeparator()+t,c=s+".TEMP_"+i._uuid();i._fs.writeFile(c,JSON.stringify(n,void 0,2),"utf8",function(e){e?r(e):i._fsApply("rename",c,s,function(e){return e?r(e):o(s);});});}});});}},{key:"readJSONData",value:function(e){var t=this;return new Promise(function(n,o){t._fs.readFile(e,"utf8",function(e,t){if(e)"ENOENT"===e.code?n():o(e);else try{var r=t&&JSON.parse(t);n("object"===i(r)?r:void 0);}catch(e){o(e);}});});}},{key:"statFile",value:function(e,t){this._fs.stat(e,function(e,n){e?t(a.getFileSystemError(e,"unable to stat file")):t(null,n);});}},{key:"checkFileSize",value:function(e,t){var n=this;this.statFile(e,function(e,i){e?t(e):i&&i.size>n._config.MAX_COMPONENT_SIZE?t(new s(s.FILE_TOO_LARGE,"Exceeds maximum file size")):t(null);});}},{key:"computeSHA",value:function(e){var t=this;return new Promise(function(n,i){var o=t._services.crypto.createHash("sha256");o.setEncoding("hex");var r=t._fs.createReadStream(e);r.on("error",function(e){return i(e);}),o.on("finish",function(){return n(o.read());}),r.pipe(o);});}},{key:"_fs",get:function(){return this._services.fs;}},{key:"_pathSep",get:function(){return this._services.getPathSeparator();}}])&&r(t.prototype,n),l&&r(t,l),e;}();e.exports=l;},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function i(e){if(!e)return{};var t={libraryID:e.id,libraryElementCount:e.elements.length,libraryGroupCount:e.getGroups().length};return e.toolkitId&&(t.libraryToolkitId=e.toolkitId),e.collection.isPublic?t.libraryShared="incoming-public":e.collaboration&&(t.libraryShared=e.collaboration,e.isWritable||(t.libraryShared+="-readonly")),t;}function o(e){if(!e)return{};var t=i(e.library);t.elementID=e.id,t.elementType=function(e){if(e.type){var t=e.type.match(/application\/vnd\.adobe\.element\.(.*)\+dcx/);return t&&2===t.length?t[1]:e.type;}return null;}(e),t.elementGroupIDs=e.getGroups(/.*/).map(function(e){return e.id;});var n=e.getPrimaryRepresentation();if(n){var o=function(e){var t=null;return e.getValues().forEach(function(e){"trackingdata"===e.key&&(t||(t={}),t[e.namespace]=e.value);}),t;}(n);o&&(t.trackingData=JSON.stringify(o)),t.elementPrimaryType=n.type;}return t;}function r(e,t){if(!e)return{};var n=t?{}:i(e.library);return n.groupID=e.id,n.groupClassifierName=e.classifierName,n;}function a(e){if(!e)return{};var t={element:function(){return o(e.element);},library:function(){return i(e.library);}}[e.type],n=t?t():{};return n.appCode=e.appCode,n.elementAction=e.id,n;}var s=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._analytics=t,this._config=n;}var t,s,c;return t=e,(s=[{key:"_isReportingEnabled",value:function(){return null!==this._analytics&&void 0!==this._analytics;}},{key:"reportError",value:function(e){this._isReportingEnabled()&&e&&this._analytics.reportError(e.code+(e.underlyingError?":"+e.underlyingError.code:""));}},{key:"reportCreateLibrary",value:function(e){this._isReportingEnabled()&&this._analytics.reportEvent("createLibrary",{libraryID:e.id});}},{key:"reportDeleteLibrary",value:function(e){this._isReportingEnabled()&&this._analytics.reportEvent("deleteLibrary",i(e));}},{key:"reportExportLibrary",value:function(e,t){if(this._isReportingEnabled()){var n=t?i(t):{};e&&(n.error=e.code),this._analytics.reportEvent("exportLibrary",n);}}},{key:"reportImportLibrary",value:function(e,t){if(this._isReportingEnabled()){var n=t?i(t):{};e&&(n.error=e.code),this._analytics.reportEvent("importLibrary",n);}}},{key:"reportCreateElement",value:function(e){this._isReportingEnabled()&&(this._lastUpdatedElement=e,this._lastUpdatedElementOn=Date.now(),this._analytics.reportEvent("createElement",o(e)));}},{key:"reportUpdateElement",value:function(e,t){if(this._isReportingEnabled()){if(e===this._lastUpdatedElement&&Date.now()-this._lastUpdatedElementOn<this._config.ANALYTICS_ELEMENT_UPDATE_THRESHOLD)return;this._lastUpdatedElement=e,this._lastUpdatedElementOn=Date.now();var n=o(e);n.updateType=t?"info":"representation",this._analytics.reportEvent("updateElement",n);}}},{key:"_reportUpdateElementMetadata",value:function(e,t,n){if(this._isReportingEnabled()){var i=o(e);i.updateType=t,n&&Object.assign(i,n),this._analytics.reportEvent("updateElementMetadata",i);}}},{key:"reportSetOrderInGroup",value:function(e,t,n){var i=r(t,!0);i.elementOrderInGroup=e.getOrderInGroup(t),i.removeExistingGroups=n,this._reportUpdateElementMetadata(e,"order",i);}},{key:"reportSetDescription",value:function(e){this._reportUpdateElementMetadata(e,"description");}},{key:"reportUseElement",value:function(e,t,n){if(this._isReportingEnabled()){var i=function(e){if(!e)return{};var t=o(e.element);return t.representationType=e.type,t.representationId=e.id,t;}(e);i.opType=t,i.details=n,this._analytics.reportEvent("useElement",i);}}},{key:"reportCheckoutElement",value:function(e,t,n){if(this._isReportingEnabled()){var i=o(e);i.opType=t,i.details=n,this._analytics.reportEvent("checkoutElement",i);}}},{key:"reportDeleteElement",value:function(e,t){if(this._isReportingEnabled()){var n=o(e);n.isPermanent=!!t,this._analytics.reportEvent("deleteElement",n);}}},{key:"reportRestoreElement",value:function(e){this._isReportingEnabled()&&this._analytics.reportEvent("restoreElement",o(e));}},{key:"reportCopyElement",value:function(e,t){if(this._isReportingEnabled()){this._lastUpdatedElement=e,this._lastUpdatedElementOn=Date.now();var n=o(e);n.oldLibraryID=t.library.id,n.oldElementID=t.id,this._analytics.reportEvent("copyElement",n);}}},{key:"reportMoveElement",value:function(e,t){if(this._isReportingEnabled()){this._lastUpdatedElement=e,this._lastUpdatedElementOn=Date.now();var n=o(e);n.oldLibraryID=t.library.id,n.oldElementID=t.id,this._analytics.reportEvent("moveElement",n);}}},{key:"reportCreateGroup",value:function(e){this._isReportingEnabled()&&this._analytics.reportEvent("createGroup",r(e));}},{key:"reportUpdateGroup",value:function(e){if(this._isReportingEnabled()){var t=r(e);t.updateType="name",this._analytics.reportEvent("updateGroup",t);}}},{key:"reportUpdateGroupMetadata",value:function(e,t,n){if(this._isReportingEnabled()){var i=r(e);i.updateType=t,n&&Object.assign(i,n),this._analytics.reportEvent("updateGroupMetadata",i);}}},{key:"reportDeleteGroup",value:function(e,t,n){if(this._isReportingEnabled()){var i=r(e);i.includeContents=t,t&&(i.numberElementsInGroup=n),this._analytics.reportEvent("deleteGroup",i);}}},{key:"reportCopyGroup",value:function(e,t,n,i){if(this._isReportingEnabled()){var o=r(e);o.oldLibraryID=t.library.id,o.oldGroupID=t.id,o.includeContents=n,n&&(o.numberElementsInGroup=i),this._analytics.reportEvent("copyGroup",o);}}},{key:"reportMoveGroup",value:function(e,t,n,i){if(this._isReportingEnabled()){var o=r(e);o.oldLibraryID=t.library.id,o.oldGroupID=t.id,o.includeContents=n,n&&(o.numberElementsInGroup=i),this._analytics.reportEvent("moveGroup",o);}}},{key:"reportCollisionElement",value:function(e){this._isReportingEnabled()&&this._analytics.reportEvent("collisionLibrary",o(e));}},{key:"reportCreateLink",value:function(e,t){if(this._isReportingEnabled()){var n=o(e);n.opType=t,this._analytics.reportEvent("createLink",n);}}},{key:"reportShareElementLink",value:function(e){this._isReportingEnabled()&&this._analytics.reportEvent("shareElementLink",o(e));}},{key:"reportShareLibraryLink",value:function(e){this._isReportingEnabled()&&this._analytics.reportEvent("shareLibraryLink",i(e));}},{key:"reportActionInvoked",value:function(e){this._isReportingEnabled()&&this._analytics.reportEvent("".concat(e.type,"ActionInvoked"),a(e));}},{key:"reportActionSuccessful",value:function(e,t){if(this._isReportingEnabled()){var n=a(e);n.appVersion=t&&t.version,n.appLaunchStatus=t?t.isAlreadyRunning?"Running":"Launched":"Unknown",this._analytics.reportEvent("".concat(e.type,"ActionSuccessful"),n);}}},{key:"reportActionFailed",value:function(e,t){if(this._isReportingEnabled()){var n=a(e);n.error=t?t.code+":"+t.message:"",this._analytics.reportEvent("".concat(e.type,"ActionFailed"),n);}}},{key:"reportUnexpectedState",value:function(e,t){if(this._isReportingEnabled()){var n=i(e);n.details=t,this._analytics.reportEvent("unexpectedState",n);}}},{key:"reportRemoveMissingComponents",value:function(e,t,n){if(this._isReportingEnabled()){var i={libraryID:e,numMissing:t.length,numFixed:n,componentErrors:[]};t.forEach(function(e){var t=e.error,n=t&&t.code,o=t&&t.response&&t.response.statusCode,r=(n||"UNKNOWN_ERROR")+(o?": "+o:"");i.componentErrors.push(r);}),this._analytics.reportEvent("removeMissingComponents",i);}}}])&&n(t.prototype,s),c&&n(t,c),e;}();e.exports=s;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function r(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}(e):t;}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e);})(e);}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e;})(e,t);}var c=n(36),l=n(6),u=n(2),_=function(e){function t(e,n){var i;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,t),(i=r(this,a(t).call(this,e)))._setDCXNode(n),i;}var n,i,c;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t);}(t,e),n=t,(i=[{key:"_setDCXNode",value:function(e){this._dcxNode=e,this._deletedLocally=!1;}},{key:"_reportRename",value:function(){this._analytics.reportUpdateGroup(this);}},{key:"_toJSON",value:function(){return{id:this.id,classifierName:this.classifierName,name:this.name,order:this.order};}},{key:"getValues",value:function(){return l.getCustomDCXData(this._dcxNode);}},{key:"classifierName",get:function(){return this._dcxNode.getValue(this._config.CLASSIFIER_KEY);}},{key:"order",get:function(){return this._dcxNode.getValue(this._config.ORDER_KEY);},set:function(e){if(l.checkDeletedState(this),!this.isWritable)throw new u(u.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if("string"!=typeof e)throw new u(u.INVALID_PARAMETER,"order must be a string",this._library.id);this._dcxNode.setValue(this._config.ORDER_KEY,e),this._commitMetadata(),this._analytics.reportUpdateGroupMetadata(this,"order",{groupOrder:e});}},{key:"parent",get:function(){var e=this._dcxNode.getValue(this._config.PARENT_KEY);return this._library.getGroups(this.classifierName).find(function(t){return t.id===e;});},set:function(e){if(l.checkDeletedState(this),!this.isWritable)throw new u(u.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(void 0===e)return this._dcxNode.removeValue(this._config.PARENT_KEY),this._commitMetadata(),void this._analytics.reportUpdateGroupMetadata(this,"parent");if(!(e instanceof t))throw new u(u.INVALID_PARAMETER,"not a valid group",this._library.id);if(e===this)throw new u(u.INVALID_PARAMETER,"group cannot be its own parent",this._library.id);if(e.library!==this.library)throw new u(u.INVALID_PARAMETER,"Cannot set parent to a group that is in a different library.",this._library.id);if(e.classifierName!==this.classifierName)throw new u(u.INVALID_PARAMETER,"Cannot set parent to a group that is in a different classifier.",this._library.id);this._dcxNode.setValue(this._config.PARENT_KEY,e.id),this._commitMetadata(),this._analytics.reportUpdateGroupMetadata(this,"parent",{groupParent:e.id});}},{key:"children",get:function(){var e=this;return this._library.getGroups(this.classifierName).filter(function(t){return t._dcxNode.getValue(e._config.PARENT_KEY)===e.id;});}},{key:"elements",get:function(){var e=this,t=[],n=function(n){return void 0!==n.getOrderInGroup(e)&&t.push(n);};return this._library._elements.forEach(n),this._library._documentationElements.forEach(n),t;}}])&&o(n.prototype,i),c&&o(n,c),t;}(c);e.exports=_;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function a(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}(e):t;}function s(e,t,n){return(s="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=c(e)););return e;}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(n):o.value;}})(e,t,n||e);}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e);})(e);}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e;})(e,t);}var u=n(36),_=n(71),h=n(2),p=n(72),d=n(9),f=n(18),m=n(6),v=n(73),y=n(38),g=n(3),E=n(4).promisify,O=function(e){function t(e,n){var i,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return o(this,t),(i=a(this,c(t).call(this,e)))._isDocumentationElement=r,i._renditionFetchLock=new d(),i._transactionCount=0,i._setDCXNode(n,!0),i;}var n,u,O;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t);}(t,e),n=t,(u=[{key:"_setDCXNode",value:function(e,t){var n=this,i=this._representations;this._representations=new f(),this._dcxNode=e,this._deletedLocally=!1,this._library._dcxBranch.getChildrenOf(e).forEach(function(e){var t=i&&i.getItemById(e.id);t?t._setDCXNode(e):t=new _(n,e),n._representations.add(t);}),this._library._dcxBranch.getComponentsOf(e).forEach(function(e){var t=i&&i.getItemById(e.id);t?t._setDCXComponent(e):t=new _(n,void 0,e),n._representations.add(t);}),m.sortRepresentations(this._representations.toArray()),t||this.library._renditionCache.clearCache(this);}},{key:"_markDeletedLocally",value:function(e){s(c(t.prototype),"_markDeletedLocally",this).call(this,e),this._representations.forEach(function(t){t._markDeletedLocally(e);});}},{key:"_toJSON",value:function(){var e={id:this.id,name:this.name,type:this.type,description:this.description,representations:this._representations.map(function(e){return e._toJSON();})};return e.representations.sort(function(e,t){return e.type>t.type?1:e.type<t.type?-1:0;}),e;}},{key:"_validateRelationship",value:function(e){var t=this;if(-1===this._config.VALID_RELATIONS.indexOf(e))throw new h(h.INVALID_PARAMETER,"Unsupported relationship",this._library.id);this._representations.size>0&&"primary"===e&&this._representations.forEach(function(n){if(n!==e&&"primary"===n.relationship)throw new h(h.INVALID_PARAMETER,"Cannot have more than one primary representation",t._library.id);});}},{key:"_doCreateRepresentation",value:function(e,t,n){var i=this,o=this._library._dcxBranch.addChild(void 0,void 0,void 0,this._dcxNode);if(o.type=e,o.setValue(this._config.RELATIONSHIP_KEY,t),void 0===n){var r=this._representations.toArray()[this._representations.size-1],a=Math.max(this._representations.size,r?r._getOrder()+1:0);o.setValue(this._config.REPRESENTATION_ORDER_KEY,a);}else o.setValue(this._config.REPRESENTATION_ORDER_KEY,n),this._representations.forEach(function(e,t){if(t>=n){var o=e._getDCXElement(),r=o.getValue(i._config.REPRESENTATION_ORDER_KEY);void 0!==r&&o.setValue(i._config.REPRESENTATION_ORDER_KEY,r+1);}});var s=new _(this,o);return this._representations.add(s,n),s;}},{key:"_updateTimestampOnRemove",value:function(e){var t=e||Date.now();this._dcxNode.setValue(this._config.REMOVED_KEY,t),this._setEventData("REMOVED",t);}},{key:"_updateTimestampOnRestore",value:function(){this._dcxNode.removeValue(this._config.REMOVED_KEY),this._clearEventData("REMOVED");}},{key:"_ensureRemovedDataValid",value:function(e){this.removed&&!this._getEventData("REMOVED",!0)?e?this._setEventData("REMOVED",this.removed):this._clearEventData("REMOVED"):this.removed||this._clearEventData("REMOVED");}},{key:"_commit",value:function(){this._forEachRepresentation(function(e){return e._clearCachedExternalLink(!0);}),this._updateName(),s(c(t.prototype),"_commit",this).call(this),this._analytics.reportUpdateElement(this,!1);}},{key:"_reportRename",value:function(){this._analytics.reportUpdateElement(this,!0);}},{key:"_getName",value:function(){return this.isAutoNamed?v.getGeneratedName(this):s(c(t.prototype),"_getName",this).call(this);}},{key:"_updateName",value:function(){var e=this._dcxNode.name;if(this.isAutoNamed){var t=v.getGeneratedName(this);t!==e&&(this._dcxNode.name=t,this._dcxNode.setValue(this._config.AUTO_NAMED_KEY,t));}}},{key:"_wrapOperation",value:function(e,t){var n=this;return this._library._wrapOperation(function(){var i=n._library._wrapOperation(e,t);return n._updateModifiedTime(),n._listenerManager.notify("change"),i;});}},{key:"_getMissingLocalComponents",value:function(){return this._representations.reduce(function(e,t){return e.concat(t._getMissingLocalComponents());},[]);}},{key:"_forEachRepresentation",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._representations;n.forEach(function(n){e(n),t._forEachRepresentation(e,n.children);});}},{key:"_shouldGCLocalData",value:function(){var e=Date.now();return this.removed&&e-this.removed>=this._config.REMOVED_ELEMENTS_CACHE_TIMEOUT;}},{key:"_stripObsoleteGroupsData",value:function(e){var t=this,n=this._dcxNode.getValue(this._config.GROUPS_KEY);if(n){var i=(e=e||this._config.DEFAULT_GROUP_CLASSIFIER)+"#",o=!1;Object.keys(n).forEach(function(e){if(e.startsWith(i)){var r=e.substring(i.length);t.library.getGroupById(r)||(delete n[e],o=!0);}}),o&&this._dcxNode.setValue(this._config.GROUPS_KEY,n);}}},{key:"_prefetchRenditions",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!this._services.hasFileSystem())return Promise.resolve();var n=this._config.RENDITION_SIZES||{},i=n[this.type]||n["*"]||[],o=E(this.getThumbnailPath.bind(this)),r=i.map(function(e){return o(e);});this._config.shouldPrefetchFullRendition(this)&&r.push(o(void 0)),this._forEachRepresentation(function(t){if(e._config.shouldPrefetchExternalLink(t)){var n=E(t.getContentPath.bind(t));r.push(n());}else if(t.isExternalLink){var i=E(t.testExternalLink.bind(t));r.push(i());}});var a=Promise.all(r);return t?a:a.catch(function(){});}},{key:"_getRenditionCandidate",value:function(e){var t,n=0;return"vector"===e&&this.supportsVectorThumbnail()?this.getPrimaryRepresentation():(this._representations.some(function(i){var o=Math.max(i.width||0,i.height||0),r=i.isFullSize?Number.POSITIVE_INFINITY:o,a="primary"===i.relationship,s="rendition"===i.relationship;if((!t||i.isPreferredThumbnail&&!t.isPreferredThumbnail||a&&"primary"!==t.relationship||s&&"primary"!==t.relationship&&"rendition"!==t.relationship||s&&"rendition"===t.relationship&&r>n)&&y.canComputeRendition(i)&&(t=i,n=r),s&&"image/png"===i.type&&e&&o===e)return!0;}),t);}},{key:"_setRenditionCache",value:function(e,t,n,i,o){var r=this;this.library._renditionCache.setCache(this,e,t,n).then(function(e){i&&r._storageInterface.notifyDownloadRendition(r),o(null,e);},o);}},{key:"_doSetOrderInGroup",value:function(e,t,n){var i=this._dcxNode.getValue(this._config.GROUPS_KEY)||{},o=e.classifierName+"#"+e.id;n&&Object.keys(i).forEach(function(t){t.startsWith(e.classifierName+"#")&&delete i[t];}),void 0===t&&i[o]&&delete i[o],void 0!==t&&(i[o]={order:t}),this._dcxNode.setValue(this._config.GROUPS_KEY,i);}},{key:"_getActions",value:function(e){var t=this.getPrimaryRepresentation();if(!t)return[];if(this.library.documentType){var n=this._config.DOCUMENT_LIBRARY_ACTION_PRODUCT_MAP,i=n.types[this.library.documentType]||[];return this._constructActions(e,i,n,p);}var o=this._config.ELEMENT_ACTION_PRODUCT_MAP,r=(o.types[this.type]||{})[t.type]||[];return this._constructActions(e,r,o,p);}},{key:"beginOperation",value:function(){if(m.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this.id);this._transactionCount++,this._library._beginOperation();}},{key:"endOperation",value:function(e){if(m.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this.id);this._transactionCount>0&&(this._transactionCount--,this._library._endOperation()),e&&this._library._waitForCommit(e,!0);}},{key:"createRepresentation",value:function(e,t,n,i){var o=this;if(m.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this._library.id);return this._wrapOperation(function(){if(e===o._config.LINK_REPRESENTATION_TYPE)throw new h(h.INVALID_PARAMETER,"Cannot create external link representation directly - use setContentFromURL instead",o._library.id);if(void 0!==n&&(n<0||n>o._representations.size))throw new h(h.INVALID_PARAMETER,"Invalid index",o._library.id);o._validateRelationship(t);var r=o._doCreateRepresentation(e,t,n);return i||o.library._renditionCache.clearCache(o,!0),r;});}},{key:"removeRepresentation",value:function(e){var t=this;if(m.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this._library.id);return this._wrapOperation(function(){t._representations.delete(e),e._dcxComponent?t._library._dcxBranch.removeComponent(e._dcxComponent):t._library._dcxBranch.removeChild(e._dcxNode),t.library._renditionCache.clearCache(t,!0),e._markDeletedLocally(!0);});}},{key:"removeAllRepresentations",value:function(){var e=this;if(m.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this._library.id);return this._wrapOperation(function(){e._representations.toArray().slice().forEach(function(t){return e.removeRepresentation(t);});});}},{key:"getPrimaryRepresentation",value:function(){return this._representations.find(function(e){return"primary"===e.relationship;});}},{key:"getValue",value:function(e,t){if(e===this._config.DL_NAMESPACE)throw new h(h.INVALID_PARAMETER,"Reserved namespace",this._library.id);var n=m.getDCXKey(e,t);return this._dcxNode.getValue(n);}},{key:"getValues",value:function(){return m.getCustomDCXData(this._dcxNode);}},{key:"setValue",value:function(e,t,n){if(m.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(e===this._config.DL_NAMESPACE)throw new h(h.INVALID_PARAMETER,"Reserved namespace",this._library.id);var i,o=m.getDCXKey(e,t);try{i=JSON.parse(JSON.stringify(n));}catch(e){throw new h(h.INVALID_PARAMETER,"Value cannot be serialized to JSON",this._library.id);}this._dcxNode.setValue(o,i),this._commit();}},{key:"removeValue",value:function(e,t){if(e===this._config.DL_NAMESPACE)throw new h(h.INVALID_PARAMETER,"Reserved namespace",this.id);var n=m.getDCXKey(e,t);this._dcxNode.removeValue(n);}},{key:"getThumbnailURL",value:function(e,t){var n=this;m.checkDeletedState(this,t)||this._library._waitForCommit(function(){if(!m.checkDeletedState(n,t)){var i=n._getRenditionCandidate(e);i?n._library._collection._syncManager.renditions.getURL(i,e,t):t(new h(h.THUMBNAIL_NOT_AVAILABLE,"no representation that can be converted into a thumbnail",n._library.id));}},!0);}},{key:"getAuthenticatedThumbnailURL",value:function(e,t){var n=this;this.getThumbnailURL(e,function(e,i){e?t(e):n._library._collection._syncManager.appendAccessTokenToURL(i,t);});}},{key:"getThumbnailPath",value:function(e,t){var n=this;this._services.hasFileSystem()?m.checkDeletedState(this,t)||this._library._waitForCommit(function(){if(!m.checkDeletedState(n,t)){var i=n.library._renditionCache.getCache(n,e);if(i)t(null,i);else{var o=n._getRenditionCandidate(e);if(o){if(n._config.SHARED_LOCAL_STORAGE)n._storageInterface.getRenditionPath(n,e,t);else{var r=function(e,i){n._renditionFetchLock.release(),t(e,i);};n._renditionFetchLock.obtain(function(){if(!m.checkDeletedState(n,r)){var t=n.library._renditionCache.getCache(n,e);if(t)r(null,t);else if("rendition"===o.relationship&&"image/png"===o.type&&e&&Math.max(o.width||0,o.height||0)===e)o.getContentPath(r);else{var i=n._library._collection._syncManager,a=n.modified,s=function(t,i){n.modified>a?r(new h(h.STALE_THUMBNAIL,"element changed before the rendition was received",n._library.id,t)):m.checkDeletedState(n,r)||(t?r(new h(h.THUMBNAIL_NOT_AVAILABLE,"error generating thumbnail",n._library.id,t)):n._setRenditionCache(e,i,!0,!0,r));};n._services.hasRenditionGenerator()&&e&&"vector"!==e?o.getContentPath(function(t,r){if(!t&&r){var a=o.element.library.collection._getTempDir()+n._services.getPathSeparator()+n._services.uuid()+".png";n._services.renditionGenerator(r,a,e,function(t){t?i.renditions.download(o,e,s):s(null,a);});}else i.renditions.download(o,e,s);}):i.renditions.download(o,e,s);}}});}}else t(new h(h.THUMBNAIL_NOT_AVAILABLE,"no representation that can be converted into a thumbnail",n._library.id));}}},!0):t(new h(h.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this._library.id));}},{key:"getCachedThumbnailPath",value:function(e){return this.library._renditionCache.getCache(this,e);}},{key:"getThumbnailContent",value:function(e,t,n){var i=this,o=this._services.fs;this._services.hasFileSystem()?m.checkDeletedState(this,n)||m.checkEncoding(t,["utf8","ascii","base64","buffer"],n)&&this.getThumbnailPath(e,function(e,r){if(!e&&r){if(!m.checkDeletedState(i,n)){var a=function(e,t){e&&(e=g.getCommitError(e,i._library.id,"error reading content from disk")),n(e,t);};"buffer"===t?o.readFile(r,a):o.readFile(r,t,a);}}else n(e);}):n(new h(h.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this._library.id));}},{key:"setThumbnailCache",value:function(e,t,n){"string"==typeof t?this._services.hasFileSystem()?m.checkDeletedState(this,n)||this._setRenditionCache(e,t,!1,!1,n):n(new h(h.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this._library.id)):n(new h(h.INVALID_PARAMETER,"path must be a string",this._library.id));}},{key:"supportsVectorThumbnail",value:function(){var e=this.getPrimaryRepresentation();return!!e&&this._config.VECTOR_RENDITION_ELEMENT_TYPES.indexOf(e.type)>-1;}},{key:"getActions",value:function(e){if(!this._config.SHARED_LOCAL_STORAGE)throw new h(h.NOT_SUPPORTED,"getActions() not supported without shared local storage");if(e&&-1===this._config.ELEMENT_ACTIONS.indexOf(e))throw new h(h.INVALID_PARAMETER,"Unknown id supplied. Potential ids are",this._config.ELEMENT_ACTIONS.join(", "));return this._getActions(e);}},{key:"getGroups",value:function(e){var t=this;e=e||this._config.DEFAULT_GROUP_CLASSIFIER;var n=this._dcxNode.getValue(this._config.GROUPS_KEY);if(!n)return[];var i=Object.keys(n);return this.library.getGroups(e).filter(function(e){return void 0!==t.getOrderInGroup(e);}).sort(function(e,t){var n=i.indexOf(e.classifierName+"#"+e.id),o=i.indexOf(t.classifierName+"#"+t.id);return n===o?0:n<o?-1:1;});}},{key:"getOrderInGroup",value:function(e){if(!e)throw new h(h.INVALID_PARAMETER,"No group specified",this._library.id);if(e.library===this.library){var t=this._dcxNode.getValue(this._config.GROUPS_KEY)||{},n=e.classifierName+"#"+e.id;return t[n]&&t[n].order;}}},{key:"setOrderInGroup",value:function(e,t,n){if(n=!1!==n,m.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(!e)throw new h(h.INVALID_PARAMETER,"No group specified",this._library.id);if(e.library!==this.library)throw new h(h.INVALID_PARAMETER,"Cannot set element order in a group that is in a different library.",this._library.id);if("string"!=typeof t&&void 0!==t)throw new h(h.INVALID_PARAMETER,"order must be a string",this._library.id);this._doSetOrderInGroup(e,t,n),this._commitMetadata(),this._analytics.reportSetOrderInGroup(this,e,n);}},{key:"getReference",value:function(){return"cloud-asset://"+this._library._collection._syncManager.getElementRefDomain()+this._library._collection._syncManager.getElementRefPath()+"/"+this._library.id+";node="+this.id;}},{key:"getRepresentationById",value:function(e){var t;return this._forEachRepresentation(function(n){t||n.id!==e||(t=n);}),t;}},{key:"_storageInterface",get:function(){return this._library._storageInterface;}},{key:"isDocumentationElement",get:function(){return this._isDocumentationElement;}},{key:"type",get:function(){return this._dcxNode.type;}},{key:"isAutoNamed",get:function(){var e=this._dcxNode.name,t=this._dcxNode.getValue(this._config.AUTO_NAMED_KEY);return!e||e===t;}},{key:"tags",get:function(){return this._dcxNode.getValue("tags")||[];},set:function(e){if(m.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(!e||e.constructor!==Array)throw new h(h.INVALID_PARAMETER,"tags must be an array",this._library.id);if(!e.every(function(e){return"string"==typeof e;}))throw new h(h.INVALID_PARAMETER,"tags must be an array of strings",this._library.id);0===e.length?this._dcxNode.removeValue("tags"):this._dcxNode.setValue("tags",e),this._commitMetadata(),this._analytics.reportUpdateElement(this,!0);}},{key:"description",get:function(){return this._dcxNode.getValue(this._config.DESCRIPTION_KEY)||"";},set:function(e){if(m.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this._library.id);this._dcxNode.setValue(this._config.DESCRIPTION_KEY,e);var t=Date.now();this._setEventData("DESCRIPTION",t),this._commitMetadata(),this._analytics.reportSetDescription(this);}},{key:"descriptionModified",get:function(){return this._getEventData("DESCRIPTION").time||0;}},{key:"descriptionModifiedBy",get:function(){return this._getEventData("DESCRIPTION").userId;}},{key:"descriptionModifiedContext",get:function(){return this._getEventContext("DESCRIPTION");}},{key:"wasDescriptionModifiedLocally",get:function(){return this._isLocalEvent("DESCRIPTION");}},{key:"removed",get:function(){return this._dcxNode.getValue(this._config.REMOVED_KEY);}},{key:"removedBy",get:function(){return this._getEventData("REMOVED").userId;}},{key:"removedContext",get:function(){return this._getEventContext("REMOVED");}},{key:"wasRemovedLocally",get:function(){return this._isLocalEvent("REMOVED");}},{key:"representations",get:function(){return this._representations.toArray();}},{key:"sourceRef",get:function(){return this._dcxNode.getValue(this._config.SOURCE_REF_KEY);},set:function(e){if(m.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if("string"!=typeof e||!e.startsWith("urn:"))throw new h(h.INVALID_PARAMETER,"sourceRef must be a string and a valid URN",this._library.id);this._dcxNode.setValue(this._config.SOURCE_REF_KEY,e),this._commit();}},{key:"sourceModified",get:function(){return this._dcxNode.getValue(this._config.SOURCE_MODIFIED_KEY);},set:function(e){if(m.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(!["string","number"].includes(i(e)))throw new h(h.INVALID_PARAMETER,"sourceModified must be a string or a number",this._library.id);this._dcxNode.setValue(this._config.SOURCE_MODIFIED_KEY,e),this._commit();}},{key:"dependencies",get:function(){var e=this,t=this._dcxNode.getValue(this._config.DEPENDENCIES_KEY);return t?t.reduce(function(t,n){var i=e.library.getElementById(n,!0);return i&&t.push(i),t;},[]):[];},set:function(e){var n=this;if(m.checkDeletedState(this),!this.isWritable)throw new h(h.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(!Array.isArray(e)||!e.every(function(e){return e instanceof t&&e.library===n.library&&!e.removed;}))throw new h(h.INVALID_PARAMETER,"dependencies must be an array of elements in this library",this._library.id);var i=[];e.forEach(function(e){var t=e.id;e.id===n.id||i.includes(t)||i.push(t);}),this._dcxNode.setValue(this._config.DEPENDENCIES_KEY,i),this._commit();}},{key:"hasMissingDependencies",get:function(){var e=this._dcxNode.getValue(this._config.DEPENDENCIES_KEY);return!!e&&this.dependencies.length<e.length;}}])&&r(n.prototype,u),O&&r(n,O),t;}(u);e.exports=O;},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var o=n(2),r=n(9),a=n(18),s=n(10),c=n(6),l=n(3),u=function(){function e(t,n,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),t instanceof e?this._parent=t:this._element=t,n?this._setDCXNode(n):this._setDCXComponent(i),this._lock=new r(),this._pendingDownloadCallbacks=[];}var t,n,u;return t=e,(n=[{key:"_setDCXNode",value:function(t){var n=this,i=this._children;this._dcxNode=t,delete this._dcxComponent,this._deletedLocally=!1,this._children=new a(),this.element.library._dcxBranch.getChildrenOf(t).forEach(function(t){var o=i&&i.getItemById(t.id);o?o._setDCXNode(t):o=new e(n,t),n._children.add(o);}),this.element.library._dcxBranch.getComponentsOf(t).forEach(function(t){var o=i&&i.getItemById(t.id);o?o._setDCXComponent(t):o=new e(n,void 0,t),n._children.add(o);});}},{key:"_setDCXComponent",value:function(e,t){this._dcxComponent=e,delete this._dcxNode,this._children=new a(),t||(this._deletedLocally=!1);}},{key:"_markDeletedLocally",value:function(e){this._deletedLocally=e;}},{key:"_toJSON",value:function(){var e={id:this.id,type:this.type,relationship:this.relationship};return this._services.hasFileSystem()&&(e._componentPath=this._getComponentPath()),e;}},{key:"_getOrder",value:function(){return this._getDCXElement().getValue(this._config.REPRESENTATION_ORDER_KEY)||0;}},{key:"_setComponentInBrowser",value:function(e,t,n){var i=this;this.element._library._collection._syncManager.uploadNewComponentForRepresentation(e,t,this,function(e,t){c.checkDeletedState(i,n)?n(e):e?n(e):(c.copyCustomDCXData(i._dcxNode,t),i.element._library._dcxBranch.removeChild(i._dcxNode),i._setDCXComponent(t,!0),i._commit(),n(null));});}},{key:"_setComponentFromPath",value:function(e,t,n,i){var o=this,r=e&&this._services.getFileNameFromPath(e),a=this._services.fileUtils.getFileExtension(r),s=this.id+"."+a;this._services.fileUtils.checkFileSize(e,function(a){a?i(a):o._storageInterface.getImageDimensions(e,function(a){o._storageInterface.notifyStartWrite(o.element._library,[],function(){var l=o.element._library._dcxBranch,u=o._parent?o._parent._dcxNode:o._element._dcxNode;l.addComponent(r,o.type,o.relationship,s,e,n,void 0,u,o.id,function(e,n){c.checkDeletedState(o,i)||(e?i(e):(c.copyCustomDCXData(o._dcxNode,n),l.removeChild(o._dcxNode),o._setDCXComponent(n,!0),a&&(n.setValue("width",a.width),n.setValue("height",a.height)),t&&n.setValue(o._config.SHA_KEY,t),o._commit(),i(null)));});});});});}},{key:"_setComponent",value:function(e,t,n,i){var o,r=this,a=this._services.fs,u=function(e){c.checkDeletedState(r,i)||(e?i(l.getCommitError(e,r.element._library.id,"error writing representation contents")):r._setComponentFromPath(o,void 0,!1,i));},_=this.element.library.collection._getTempDir();this._services.fileUtils.ensurePathExists(_,function(h){if(!c.checkDeletedState(r,i))if(h)i(l.getCommitError(h,r.element._library.id,"error creating temp directory"));else{if(!n){var p=s.getExtensions(r.type)[0];n=r.id+"."+p;}o=_+r._services.getPathSeparator()+n,"buffer"===t?a.writeFile(o,e,u):a.writeFile(o,e,t,u);}});}},{key:"_getCurrentComponentPath",value:function(){if(this._dcxComponent)return this.element._library._dcxBranch.assetOfComponent(this._dcxComponent);}},{key:"_getComponentPath",value:function(e,t){var n=this;if(!e)return this._getCurrentComponentPath();if(this.isExternalLink)return this.element.library.collection._externalLinkCache.getExternalLink(this).then(function(t){return e(null,t);},e);if(this._dcxComponent){var i=this._getCurrentComponentPath();if(i||t)e(null,i);else{var o=this.element._library;o._networkLock.obtain(function(t){t?e(t):c.checkDeletedState(n,e)?o._networkLock.release():(o._setSyncState("downloading"),o._collection._syncManager.downloadRepresentation(n,function(t){o._networkLock.release(),o._setSyncState(),c.checkDeletedState(n,e)||(t?e(l.getSyncError(t,n.element._library.id)):(o._commit(!0,!0),o._notifyChange(),n._getComponentPath(e,!0)));}));});}}else{var r=this._getContentFromData();if(r){var a=this.element.library._renditionCache.getCache(this.element,this.id);a?e(null,a):this._generateContentDataFile(r,e);}else e(null);}}},{key:"_getContentFromData",value:function(){if(this._services.hasFileSystem()){var e=this._config.REPRESENTATION_CONTENT_VALUES[this.type];if(e&&e.contentFromData)return this.getValue(e.namespace,e.key);}}},{key:"_setExternalLink",value:function(e,t,n){var i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(this._dcxNode.setValue(this._config.LINK_TYPE_KEY,this._dcxNode.type),this._dcxNode.type=this._config.LINK_REPRESENTATION_TYPE,this._dcxNode.setValue(this._config.LINK_URL_KEY,e),t){n&&this._dcxNode.setValue(this._config.LENGTH_KEY,n);var o=this._config.DEFAULT_CONTENT_LOCATIONS.find(function(e){return t.startsWith(e);});if(o){var r=t.substring(o.length);this._dcxNode.setValue(this._config.LINK_LOCAL_PATH_KEY,r);}return this.element.library.collection._externalLinkCache.ensureExternalLinkCache(e,t,i);}return Promise.resolve();}},{key:"_clearCachedExternalLink",value:function(e){var t=this.element.library.collection._externalLinkCache;t&&this.isExternalLink&&(!e||t.getCachedError(this))&&(this._config.SHARED_LOCAL_STORAGE?this._storageInterface.clearCachedExternalLink(this):this._config.shouldPrefetchExternalLink(this)?t.getExternalLink(this,!0).catch(function(){}):t.testExternalLink(this,!0).catch(function(){}));}},{key:"_getLinkLocalPaths",value:function(){var e=this._dcxNode&&this._dcxNode.getValue(this._config.LINK_LOCAL_PATH_KEY);return e?this._config.DEFAULT_CONTENT_LOCATIONS.map(function(t){return"".concat(t).concat(e);}):[];}},{key:"_setContentFromPath",value:function(e,t,n){var i=this,o=function(o){var r=o&&i._config.SHA_CACHE[o];if(r){i._dcxNode.setValue(i._config.SHA_KEY,o);var a=function(){i._commit(),n(null);};return e=e.replace(/\\/g,"/"),void i._services.fs.stat(e,function(n,o){var s=!n&&o&&o.size;i._setExternalLink(r,e,s,t).then(a,a);});}i._setComponentFromPath(e,o,t,n);};this._storageInterface.computeSHA(e).then(o,function(){return o();});}},{key:"_generateContentDataFile",value:function(e,t){var n=this,i=this.element.library.collection._getTempDir(),o=s.getExtensions(this.type)[0];this._services.fileUtils.writeJSONData(i,this.id+"."+o,e).then(function(e){n.element.setThumbnailCache(n.id,e,function(e,i){n._storageInterface.notifyDownloadRendition(n.element),t(e,i);});},function(e){return t(l.getCommitError(e));});}},{key:"_getDCXElement",value:function(){return this._dcxComponent||this._dcxNode;}},{key:"_commit",value:function(e){e?this.element._commitMetadata():this.element._commit();}},{key:"_getMissingLocalComponents",value:function(){return this._services.hasFileSystem()&&this._dcxComponent&&!this._getCurrentComponentPath()?[this._dcxComponent]:[];}},{key:"jasmineToString",value:function(){return this.toString();}},{key:"toString",value:function(){return JSON.stringify(this._toJSON());}},{key:"isCompatibleType",value:function(e){if(this._dcxComponent){var t=this._services.fileUtils.getFileExtension(this._dcxComponent.path);if(-1===s.getExtensions(e).indexOf(t))return!1;}return c.isCompatibleType(e,this.type);}},{key:"getValue",value:function(e,t){if(e===this._config.DL_NAMESPACE)throw new o(o.INVALID_PARAMETER,"Reserved namespace",this.element._library.id);var n=c.getDCXKey(e,t);return this._getDCXElement().getValue(n);}},{key:"getValues",value:function(){return c.getCustomDCXData(this._getDCXElement());}},{key:"setValue",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(c.checkDeletedState(this),!this.isWritable)throw new o(o.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id);if(e===this._config.DL_NAMESPACE)throw new o(o.INVALID_PARAMETER,"Reserved namespace",this.element._library.id);var r,a=c.getDCXKey(e,t);try{r=JSON.parse(JSON.stringify(n));}catch(e){throw new o(o.INVALID_PARAMETER,"Value cannot be serialized to JSON",this.element._library.id);}this._getDCXElement().setValue(a,r),this._commit(i);}},{key:"setContent",value:function(e,t,n,i){if(!c.checkDeletedState(this,i))if(this.isWritable){if(this._dcxComponent||this.isExternalLink)i(new o(o.INVALID_PARAMETER,"Cannot modify representation content once set",this.element._library.id));else if(this._services.hasFileSystem()){if(!c.checkEncoding(t,["utf8","ascii","base64","buffer"],i))return;this._setComponent(e,t,n,i);}else{if(void 0!==t)return void i(new o(o.INVALID_PARAMETER,"Encoding parameter not supported in-browser"));this._setComponentInBrowser(e,n,i);}}else i(new o(o.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id));}},{key:"setContentFromPath",value:function(e,t,n){"function"==typeof t&&(n=t,t=!1),this._services.hasFileSystem()?c.checkDeletedState(this,n)||(this.isWritable?this._dcxComponent||this.isExternalLink?n(new o(o.INVALID_PARAMETER,"Cannot modify representation content once set",this.element._library.id)):this._setContentFromPath(e,!t,n):n(new o(o.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id))):n(new o(o.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this.element._library.id));}},{key:"setContentFromURL",value:function(e,t,n,i){var r=this;if(this._services.hasFileSystem()||e){if(!c.checkDeletedState(this,i))if(this.isWritable){if("boolean"==typeof e){if(this._dcxComponent||this.isExternalLink)i(new o(o.INVALID_PARAMETER,"Cannot modify representation content once set",this.element._library.id));else{if(e)return this._setExternalLink(t),this._commit(),void i(null);var a=this.element.library.collection,u=a._getTempDir();this._storageInterface.downloadURL(a,t,n,u,function(e,t,n,o){if(e)i(l.getSyncError(e));else if(!c.checkDeletedState(r,i)){var a=r._config.getContentTypeHeader(o&&o.headers);if(a){var u=t+"."+s.getExtensions(a)[0];r._services.fileUtils.rename(t,u,function(e){e?i(l.getCommitError(e)):r._setComponentFromPath(u,void 0,!1,i);});}else r._setComponentFromPath(t,void 0,!1,i);}});}}else i(new o(o.INVALID_PARAMETER,"Invalid createLink parameter: must be Boolean",this.element._library.id));}else i(new o(o.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id));}else i(new o(o.NOT_IMPLEMENTED,"not yet implemented setContentFromURL without a filesystem",this.element._library.id));}},{key:"getContentPath",value:function(e){this._services.hasFileSystem()?c.checkDeletedState(this,e)||this._getComponentPath(e):e(new o(o.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this.element._library.id));}},{key:"getCachedContentPath",value:function(){if(this._services.hasFileSystem())return this.isExternalLink?this.element.library.collection._externalLinkCache.getCachedPath(this):this._dcxComponent?this._getCurrentComponentPath()||void 0:this._getContentFromData()&&this.element.library._renditionCache.getCache(this.element,this.id)||void 0;}},{key:"getContent",value:function(e,t){var n=this,i=this._services.fs;if(!c.checkDeletedState(this,t))if(this._services.hasFileSystem()){if(!c.checkEncoding(e,["utf8","ascii","base64","buffer"],t))return;this._getComponentPath(function(o,r){if(!o&&r){if(!c.checkDeletedState(n,t)){var a=function(e,i){e&&(e=l.getCommitError(e,n.element._library.id,"error reading content from disk")),t(e,i);};"buffer"===e?i.readFile(r,a):i.readFile(r,e,a);}}else t(o);});}else{if(!c.checkEncoding(e,["text","blob","arraybuffer"],t))return;if(!this._dcxComponent)return void t(null);this.element._library._collection._syncManager.getContent(this._dcxComponent,e,t);}}},{key:"getContentURL",value:function(){return this.isExternalLink?this._dcxNode.getValue(this._config.LINK_URL_KEY):this._dcxComponent?this.element._library._collection._syncManager.getContentURL(this._dcxComponent):void 0;}},{key:"getAuthenticatedContentURL",value:function(e){var t=this.getContentURL();this.element._library._collection._syncManager.appendAccessTokenToURL(t,e);}},{key:"createChild",value:function(t){if(!this._dcxNode)throw new o(o.NOT_ALLOWED,"can't create child on a component representation",this.element.library.id);var n=this.element.library._dcxBranch.addChild(void 0,void 0,void 0,this._dcxNode);n.type=t,n.setValue(this._config.RELATIONSHIP_KEY,this._config.RELATIONSHIP_CHILD);var i=new e(this,n);return this._children.add(i),this._commit(),i;}},{key:"removeChild",value:function(e){if(c.checkDeletedState(this),!this.isWritable)throw new o(o.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(e._parent!==this)throw new o(o.INVALID_PARAMETER,"cannot remove a child that doesn't belong to this representation",this._library.id);e._dcxComponent?this.element.library._dcxBranch.removeComponent(e._dcxComponent):this.element.library._dcxBranch.removeChild(e._dcxNode),this._children.delete(e),this._commit();}},{key:"testExternalLink",value:function(e){this.isExternalLink&&this.getContentURL()?this.element.library.collection._externalLinkCache.testExternalLink(this).then(function(){return e(null,!0);},function(){return e(null,!1);}):e(new o(o.INVALID_PARAMETER,"Not an external link",this.element._library.id));}},{key:"clearCachedExternalLink",value:function(){if(!this.isExternalLink||!this.getContentURL())throw new o(o.INVALID_PARAMETER,"Not an external link",this.element._library.id);this._clearCachedExternalLink();}},{key:"getCachedExternalLinkError",value:function(){return this.isExternalLink&&this.getContentURL()?this.element.library.collection._externalLinkCache.getCachedError(this):new o(o.INVALID_PARAMETER,"Not an external link",this.element._library.id);}},{key:"getExternalLinkDownloadProgress",value:function(){if(this.isExternalLink)return this.element.library.collection._getExternalLinkDownloadProgress(this);}},{key:"_services",get:function(){return this.element._services;}},{key:"_storageInterface",get:function(){return this.element._storageInterface;}},{key:"_config",get:function(){return this.element._config;}},{key:"id",get:function(){return this._getDCXElement().id;}},{key:"element",get:function(){return this._parent?this._parent.element:this._element;}},{key:"children",get:function(){return this._children.toArray();}},{key:"isWritable",get:function(){return this.element.isWritable;}},{key:"type",get:function(){var e=this._getDCXElement().type;return e===this._config.LINK_REPRESENTATION_TYPE?this._getDCXElement().getValue(this._config.LINK_TYPE_KEY):e;}},{key:"relationship",get:function(){return this._dcxComponent?this._dcxComponent.relationship||this._dcxComponent.getValue(this._config.RELATIONSHIP_KEY):this._dcxNode.getValue(this._config.RELATIONSHIP_KEY)||this._dcxNode.getValue("relationship");},set:function(e){if(this._parent)throw new o(o.NOT_ALLOWED,"you cannot set relationship on child representations",this.element._library.id);this.element._validateRelationship(e,this),this._dcxComponent?this._dcxComponent.relationship=e:this._dcxNode.setValue(this._config.RELATIONSHIP_KEY,e);}},{key:"width",get:function(){return this._dcxComponent?this._dcxComponent.getValue("width"):this._dcxNode.getValue(this._config.WIDTH_KEY);},set:function(e){if(c.checkDeletedState(this),!this.isWritable)throw new o(o.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id);if(!this._dcxComponent&&!this.isExternalLink)throw new o(o.INVALID_PARAMETER,"Cannot set width on a representation without contents",this.element._library.id);if("number"!=typeof e||e<0)throw new o(o.INVALID_PARAMETER,"Invalid width",this.element._library.id);this._dcxComponent?this._dcxComponent.setValue("width",e):this._dcxNode.setValue(this._config.WIDTH_KEY,e),this._commit();}},{key:"height",get:function(){return this._dcxComponent?this._dcxComponent.getValue("height"):this._dcxNode.getValue(this._config.HEIGHT_KEY);},set:function(e){if(c.checkDeletedState(this),!this.isWritable)throw new o(o.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id);if(!this._dcxComponent&&!this.isExternalLink)throw new o(o.INVALID_PARAMETER,"Cannot set height on a representation without contents",this.element._library.id);if("number"!=typeof e||e<0)throw new o(o.INVALID_PARAMETER,"Invalid height",this.element._library.id);this._dcxComponent?this._dcxComponent.setValue("height",e):this._dcxNode.setValue(this._config.HEIGHT_KEY,e),this._commit();}},{key:"isFullSize",get:function(){return this._getDCXElement().getValue(this._config.IS_FULL_SIZE_KEY)||this._getDCXElement().getValue(this._config.CSDK_IS_FULL_SIZE_KEY);},set:function(e){if(c.checkDeletedState(this),!this.isWritable)throw new o(o.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id);if(!this._dcxComponent&&!this.isExternalLink)throw new o(o.INVALID_PARAMETER,"Cannot set isFullSize on a representation without contents",this.element._library.id);if("boolean"!=typeof e)throw new o(o.INVALID_PARAMETER,"Invalid isFullSize",this.element._library.id);this._getDCXElement().setValue(this._config.IS_FULL_SIZE_KEY,e),this._commit();}},{key:"isPreferredThumbnail",get:function(){return this._getDCXElement().getValue(this._config.IS_PREFERRED_THUMBNAIL_KEY)||!1;},set:function(e){if(c.checkDeletedState(this),!this.isWritable)throw new o(o.NOT_ALLOWED,"you do not have write access to this library",this.element._library.id);if("boolean"!=typeof e)throw new o(o.INVALID_PARAMETER,"Invalid isPreferredThumbnail",this.element._library.id);this._getDCXElement().setValue(this._config.IS_PREFERRED_THUMBNAIL_KEY,e),this._commit();}},{key:"contentLength",get:function(){if(this.isExternalLink)return this._dcxNode.getValue(this._config.LENGTH_KEY);if(this._dcxComponent){if(void 0===this._dcxComponent.length&&this._services.fs&&this._services.fs.statSync){var e=this._getCurrentComponentPath();try{var t=this._services.fs.statSync(e);return t&&t.size;}catch(e){}}return this._dcxComponent.length;}},set:function(e){if(!this.isExternalLink)throw new o(o.READ_ONLY,"setContentLength can only be used for an externally-linked representation",this.element._library.id);if("number"!=typeof e||e<0)throw new o(o.INVALID_PARAMETER,"Invalid content length",this.element._library.id);this._dcxNode.setValue(this._config.LENGTH_KEY,e),this._commit();}},{key:"contentHash",get:function(){return this._getDCXElement().getValue(this._config.SHA_KEY);}},{key:"isDeletedLocally",get:function(){return this._deletedLocally;}},{key:"isExternalLink",get:function(){return void 0!==this._dcxNode&&this._dcxNode.type===this._config.LINK_REPRESENTATION_TYPE;}}])&&i(t.prototype,n),u&&i(t,u),e;}();e.exports=u;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function a(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}(e):t;}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e);})(e);}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e;})(e,t);}var l=function(e){function t(){return o(this,t),a(this,s(t).apply(this,arguments));}var n,i,l;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t);}(t,e),n=t,(i=[{key:"type",get:function(){return"element";}},{key:"id",get:function(){return this._id;}},{key:"element",get:function(){return this._item;}}])&&r(n.prototype,i),l&&r(n,l),t;}(n(37));e.exports=l;},function(e,t,n){var i;function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e;}var r=n(16),a=function(e){return"RGB"===e.mode;},s=function(e){return a(e)&&(!e.profileName||"sRGB IEC61966-2.1"===e.profileName);},c=function(e){var t=Array.isArray(e)?e.find(s)||e.find(a):e;return t&&t.value?function(e,t,n){for(var i=(Math.round(e)<<16|Math.round(t)<<8|Math.round(n)).toString(16);i.length<6;)i="0"+i;return"#".concat(i).toUpperCase();}(t.value.r,t.value.g,t.value.b):"";},l=function(e,t,n){for(var i="application/vnd.adobe.".concat(t,"+json"),o=0;o<e.representations.length;o++){var r=e.representations[o];if(r.type===i){var a=r.getValue(t,"data");if(a&&(!n||n(a)))return a;}}},u=function(e){return function(t){var n=l(t,e);if(n){var i=n.adbeFont&&n.adbeFont.style.toLowerCase();return!i||i.includes("normal")||i.includes("regular")?n.fontFamily:"".concat(n.fontFamily," ").concat(n.adbeFont.style);}};},_=(o(i={},r.COLOR_ELEMENT_TYPE,function(e){var t=l(e,"color",s)||l(e,"color",a);return c(t);}),o(i,r.CHARACTER_STYLE_ELEMENT_TYPE,u("characterstyle")),o(i,r.PARAGRAPH_STYLE_ELEMENT_TYPE,u("paragraphstyle")),i);e.exports={colorDataToHexString:c,getGeneratedName:function(e){var t=_[e.type];return t?t(e):"";}};},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function a(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}(e):t;}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e);})(e);}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e;})(e,t);}var l=function(e){function t(){return o(this,t),a(this,s(t).apply(this,arguments));}var n,i,l;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t);}(t,e),n=t,(i=[{key:"type",get:function(){return"library";}},{key:"id",get:function(){return this._id;}},{key:"library",get:function(){return this._item;}}])&&r(n.prototype,i),l&&r(n,l),t;}(n(37));e.exports=l;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function r(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}(e):t;}function a(e,t,n){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=s(e)););return e;}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(n):o.value;}})(e,t,n||e);}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e);})(e);}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e;})(e,t);}var l=n(39),u="renditions",_=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,t),(n=r(this,s(t).call(this,e.collection._apiRoot,e._getRenditionCacheDir())))._library=e,n._pendingSetCache=[],n;}var n,i,l;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t);}(t,e),n=t,(i=[{key:"getCache",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"full",n=this._getCache([u,e.id,t]);return this._getFilePath(n);}},{key:"setCache",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"full",i=arguments.length>2?arguments[2]:void 0,o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return this._config.SHARED_LOCAL_STORAGE?this._requestSetCache(e.id,n,i):this._doTransaction(function(){return t._setCache([u,e.id,n],i,o);});}},{key:"clearCache",value:function(e,t){var n=this,i=this._getCache([u,e.id]);return i?(t&&this._config.SHARED_LOCAL_STORAGE&&this._storageInterface.supportsClearRenditionCache()&&Object.keys(i).forEach(function(t){return n._requestSetCache(e.id,t,"CLEAR");}),this._clearCache(e)):Promise.resolve();}},{key:"copyCache",value:function(e,t){var n=this;return this._config.SHARED_LOCAL_STORAGE?(this._copyCache(e,t),Promise.resolve()):this._doTransaction(function(){return n._copyCache(e,t);});}},{key:"copyFullCache",value:function(e){var t=this;return this._config.SHARED_LOCAL_STORAGE?this._copyFullCache(e):this._doTransaction(function(){return t._copyFullCache(e);});}},{key:"serializeCache",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1?arguments[1]:void 0,i={},o=function(o){i[o.id]=e.serializeElementCache(o,t,n);};return this._library.elements.forEach(o),this._library.removedElements.forEach(o),i;}},{key:"serializeElementCache",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,i=Object.assign({},this._cache.renditions&&this._cache.renditions[e.id]||{});return t&&this._convertToAbsolutePaths(i),this._addExternalLinksToElementCache(i,e,t,n),i;}},{key:"replaceCache",value:function(e){var t,n,i;this._cache=(i=e,(n=u)in(t={})?Object.defineProperty(t,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[n]=i,t);}},{key:"replaceElementCache",value:function(e,t){this._cache.renditions=this._cache.renditions||{},this._cache.renditions[e.id]=t;}},{key:"checkAndInvalidateRenditions",value:function(e,t){var n,i=this,o=this._getCache([u,e.id])||{};return Object.keys(o).some(function(r){if(Number(r)){var a=i._path.join(i._rootDir,o[r]),s=a&&i._fs.statSync(a);return s&&s.size>t?(i.clearCache(e),n="Invalidating rendition - ".concat(e.id," ").concat(e.name," dimension: ").concat(r," size: ").concat(s.size),!0):void 0;}}),n;}},{key:"doRequestSetCache",value:function(){var e=this;return this._requestingSetCache=this._pendingSetCache,this._pendingSetCache=[],{data:this._requestingSetCache.map(function(e){return{element:e.element,size:e.size,path:e.path};}),cancel:function(){e._pendingSetCache=e._requestingSetCache.concat(e._pendingSetCache),delete e._requestingSetCache;},complete:function(t){return e._completeRequestSetCache(t);}};}},{key:"applyRequestSetCache",value:function(e){var t=this;return this._doTransaction(function(){return t._applyRequestSetCache(e);});}},{key:"gc",value:function(){var e=this,t={},n=function(e){e._shouldGCLocalData()||(t[e.id]=!0);};this._library.elements.forEach(n),this._library.removedElements.forEach(n);var i=this._cache.renditions||{},o=!1;Object.keys(i).forEach(function(n){t[n]||(e._setCacheEntry([u,n]),o=!0);});var r=o?this.save():Promise.resolve(),a=this._library.collection._externalLinkCache;return r.then(function(){return a&&a.gc();});}},{key:"_load",value:function(){var e=this;return a(s(t.prototype),"_load",this).call(this).then(function(){e.serializeCache(!0,!1);});}},{key:"_gcUnreferencedFiles",value:function(){return this._library._dcxComposite.autoRemoveUnusedLocalFiles?a(s(t.prototype),"_gcUnreferencedFiles",this).call(this):Promise.resolve();}},{key:"_copyCache",value:function(e,t){var n=this,i=e.library._renditionCache,o=i._getCache([u,e.id])||{},r=Object.keys(o).map(function(r){var a=i._getFilePath(o[r],!0);if(!a)return Promise.resolve();var s=e.getRepresentationById(r);if(s&&!t.getRepresentationById(r)){var c=e.representations.indexOf(s);c>=0&&c<t.representations.length&&(r=t.representations[c].id);}return i._isPath(a)?n._config.SHARED_LOCAL_STORAGE?n._requestSetCache(t.id,r,a):n._setCache([u,t.id,r],a):Promise.resolve(n._setCacheEntry([u,t.id,r],a));});return Promise.all(r);}},{key:"_copyFullCache",value:function(e){var t=this;return Promise.all(e.elements.map(function(e){var n=t._library.getElementById(e.id);return n?t._copyCache(e,n):Promise.resolve();}));}},{key:"_requestSetCache",value:function(e,t,n){var i=this;return new Promise(function(o,r){i._pendingSetCache=i._pendingSetCache.filter(function(n){return!(n.element===e&&n.size===t&&"CLEAR"===n.path);}),i._pendingSetCache.push({element:e,size:t,path:n,callback:function(e,t){return e?r(e):o(t);}});});}},{key:"_applyRequestSetCache",value:function(e){var t=this,n=e.map(function(e){var n=e.element,i=e.size,o=e.path;return"CLEAR"===o?(t._setCacheEntry([u,n,i]),Promise.resolve()):t._setCache([u,n,i],o);});return Promise.all(n);}},{key:"_completeRequestSetCache",value:function(e){var t=this,n={};return e.forEach(function(e,i){var o=t._requestingSetCache[i],r=t._library.getElementById(o.element);if(o&&r&&e&&0===e.indexOf(t._rootDir)){var a=e.substring(t._rootDir.length+1);t._setCacheEntry([u,o.element,o.size],a),n[r.id]=r;}o&&o.callback(null,e);}),delete this._requestingSetCache,Object.keys(n).map(function(e){return n[e];});}},{key:"_clearCache",value:function(e,t){var n=t?[u,e.id,t]:[u,e.id];return this._setCacheEntry(n),this.save();}},{key:"_convertToAbsolutePaths",value:function(e){var t=this;Object.keys(e).forEach(function(n){var i=e[n];e[n]=t._isPath(i)?t._path.join(t._rootDir,i):i;});}},{key:"_legacyGetCacheEntry",value:function(e){var t=this._getCache([u,e.element.id,e.id]);return this._getFilePath(t,!0);}},{key:"_legacyClearCacheEntry",value:function(e){var t=[u,e.element.id,e.id];this._getCache(t)&&(this._setCacheEntry(t),this.save());}},{key:"_addExternalLinksToElementCache",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3?arguments[3]:void 0;e=e||{};var r=this._library.collection._externalLinkCache;t._forEachRepresentation(function(t){if(t.isExternalLink&&!e[t.id]){var a=r._getCacheEntry(t);a&&(e[t.id]=!i&&a.startsWith(r._rootDir)?n._path.relative(n._rootDir,a):a,r._notifyDownloadRendition(t,o));}});}}])&&o(n.prototype,i),l&&o(n,l),t;}(l);e.exports=_;},function(e,t,n){var i=n(3),o=n(4).promisify,r=function(e,t){var n=e[t].bind(e);return function(){return o(n).apply(void 0,arguments).catch(function(e){return Promise.reject(i.getCommitError(e));});};};e.exports=function(e,t){return{stat:function(t){return r(e,"stat")(t);},statSync:function(t){try{return e.statSync(t);}catch(e){}},unlink:function(t){return r(e,"unlink")(t);},readdir:function(t){return r(e,"readdir")(t);},rename:function(e,n){return r(t,"rename")(e,n);},copy:function(e,n){return r(t,"copyFile")(e,n);},ensureDir:function(e){return r(t,"ensurePathExists")(e);},remove:function(e){var n=this;return this.stat(e).then(function(i){return i&&i.isDirectory()?r(t,"recursiveDeleteDirectory")(e):n.unlink(e);});}};};},function(e,t){e.exports=function(e){return{join:function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return n.join(e);},relative:function(t,n){for(var i=t.replace(/\\/g,e).split(e),o=n.replace(/\\/g,e).split(e);i[0]===o[0];)i.shift(),o.shift();return new Array(i.length).fill("..").concat(o).join(e);}};};},function(e,t,n){function i(e,t,n,i,o,r,a){try{var s=e[r](a),c=s.value;}catch(e){return void n(e);}s.done?t(c):Promise.resolve(c).then(i,o);}function o(e){return function(){var t=this,n=arguments;return new Promise(function(o,r){var a=e.apply(t,n);function s(e){i(a,o,r,s,c,"next",e);}function c(e){i(a,o,r,s,c,"throw",e);}s(void 0);});};}function r(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n;}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e);}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance");}();}function a(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var s=n(30),c=n(1),l=n(0),u=n(2),_=n(6),h=n(10),p=n(79),d=n(80),f=n(81),m=n(82),v=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._apiRoot=t,this._userId=n.USER_ID,this._isPublic=n.IS_PUBLIC,this._storageHost=n.STORAGE_HOSTNAME,this._storageHostRegex=n.STORAGE_HOSTNAME_REGEX,this._platformHost=n.PLATFORM_HOSTNAME,this._isACP=m.isACPHost(n.STORAGE_HOSTNAME),this._ccLibraryHost=n.CC_LIBRARY_SERVICE_HOSTNAME,this._invitationsHost=n.INVITATIONS_HOSTNAME,this._apiKey=this._config.STORAGE_API_KEY,this._XHR=n.XHR,this._requiresCommunitySession=n.REQUIRES_COMMUNITY_SESSION,this._getAccessToken=n.getAccessToken,this._httpServices=[],this._storageService=this._createStorageSession(this.getStorageHost(),!0),this._storageServices={},this._renditionSync=new d(this,n),this._externalLinkSync=new p(this),this._typekitSync=new f(this,n),this._lastSyncGroupState={},this._hasSetAuthToken=!1,this._authToken=void 0,this._inProgressSyncMap={},this._config.SHARED_LOCAL_STORAGE||this._isPublic||this._updateAuthToken();}var t,n,i,v,y;return t=e,(n=[{key:"_getCommonRequestHeaders",value:function(){var e={};return this._config.USER_AGENT_HEADER&&(e["User-Agent"]=this._config.USER_AGENT_HEADER),e;}},{key:"_setAuthToken",value:function(e){this._hasSetAuthToken=!0,this._authToken=e,this._httpServices.forEach(function(t){e?(t.isActive=!0,t.setAuthToken(e)):t.isActive=!1;});}},{key:"_updateAuthToken",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};this._getAccessToken(this._authToken,function(n,i){!n&&i?e._setAuthToken(i):(n&&n.code===u.ACCESS_DENIED&&e._apiRoot.getLoadedCollections().forEach(function(t){t._syncManager===e&&(t._reportSyncError(n),t._updateSyncState());}),e._setAuthToken()),t(null,i);});}},{key:"_getAuthToken",value:function(e){this._hasSetAuthToken?e(null,this._authToken):this._updateAuthToken(e);}},{key:"_authHandler",value:function(){this._updateAuthToken();}},{key:"_createStorageSession",value:function(e,t){var n=this._getHttpService(e,t);if(e===this.getStorageHost()){if(this._requiresCommunitySession)return this._services.dcx.createCommunitySession(n,e,this._storageHostRegex);if(this._isACP)return this._services.dcx.createPlatformSession(n,e,this._storageHostRegex,this._platformRootDocument);}return this._services.dcx.createStorageSession(n,e,this._storageHostRegex,this.getPlatformHost());}},{key:"getPlatformSession",value:function(){if(!this._platformSession){var e=this.getPlatformHost(),t=this._getHttpService(e,!0);this._platformSession=this._services.dcx.createPlatformSession(t,e,this._storageHostRegex);}return this._platformSession;}},{key:"_getHttpService",value:function(e,t){var n,i=this._isPublic&&e===this.getStorageHost();return t&&this._getAccessToken&&!i?(this._authToken||this._updateAuthToken(),(n=this._services.dcx.createHTTPService(this._authHandler.bind(this))).setAuthToken(this._authToken),this._httpServices.push(n)):n=this._services.dcx.createHTTPService(),n.setTimeout(this._config.NETWORK_TIMEOUT),n.setAdditionalNodeOptions(this._services.getNodeTunnelOptions(e)),(t||i)&&(n.setApiKey(this._apiKey),n.setAdditionalHeaders(this._getCommonRequestHeaders())),this._XHR&&n._forceXhr(this._XHR),n;}},{key:"_getStorageSession",value:function(e){var t=c.parseURI(e),n=t.scheme+"://"+t.authority,i=this._config.isAdobeDomain(t.authority);return this._storageServices[n]||(this._storageServices[n]=this._createStorageSession(n,i)),this._storageServices[n];}},{key:"_doJSONRequest",value:function(e,t,n){var i=this._getStorageSession(t),o={"Content-Type":"application/json"};return n=n&&JSON.stringify(n),new Promise(function(r,a){i._service.invoke(e,t,o,n,{responseType:"text"},function(e,t){if(e)return a(e);var n;if(t.response)try{n=JSON.parse(t.response);}catch(e){var i=new u(u.TRANSFER_ERROR,"Invalid JSON: ".concat(t.response));return i.response=t,void a(i);}r({statusCode:t.statusCode,response:n,headers:t.headers});});});}},{key:"_isManifestOnly",value:function(){return"manifestOnly"===this._config.SYNC_POLICY||!this._services.hasFileSystem();}},{key:"_pullCompositeComponents",value:function(e,t,n,i,o){if(this._isManifestOnly())o(null);else{var r=s.downloadComponents(e,t,this._storageService,o);this._inProgressSyncMap[i]=r,r.onProgress=function(e,t){0!==t&&n._updateProgress(i,e,t);};}}},{key:"_pullComposite",value:function(e,t,n,i){var o=this;this._inProgressSyncMap[n]=s.pullCompositeManifestOnly(e,this._storageService,function(e,a){if(!e&&a){var s=a.getChildrenOf().find(function(e){return e.name===o._config.ELEMENTS_NAME;}),c=a.getComponentsOf();s&&function e(t,n){n.push.apply(n,r(a.getComponentsOf(t))),a.getChildrenOf(t).forEach(function(t){return e(t,n);});}(s,c),o._pullCompositeComponents(c,a,t,n,function(e){return i(e,a);});}else i(e,a);});}},{key:"getServerComposites",value:function(e,t){var n=this;if(!e._href)return t(null,[]);var i=this._lastSyncGroupState.etag;this._storageService.getCollection(e._href,i,function(e,i,o,r){if(e)e.response&&404===e.response.statusCode?t(null,[]):t(e);else{if(!i){var a=Math.max(n._config.DEFAULT_MAX_SYNC_INTERVAL,1e3*n._config.getRetryAfterHeader(r));return n._config.MAX_SYNC_INTERVAL=a,void t(null,[]);}n._config.MAX_SYNC_INTERVAL=n._config.DEFAULT_MAX_SYNC_INTERVAL;var s=n._lastSyncGroupState.compositeEtags||{},c={},l=[],u={};(i.children||[]).forEach(function(e){e&&_.validateLibraryId(e.name,!1)&&(e.isUnmodified=e.etag&&s[e.name]===e.etag,l.push(e),u[e.name]=e,c[e.name]=e.etag);}),n._lastSyncGroupState={etag:o,compositeEtags:c},t(null,l,u);}});}},{key:"deleteAllServerComposites",value:function(e,t){var n=e._href;n?this._storageService.deleteCompositeDirectory({href:n},t):t(null);}},{key:"abortAllDownloads",value:function(){var e=this;Object.keys(this._storageServices).map(function(t){return e._storageServices[t];}).forEach(function(e){return e.abortAll();});}},{key:"clearSyncGroupCache",value:function(){this._lastSyncGroupState={};}},{key:"doHeadRequest",value:function(e,t){var n;try{n=this._storageService.getCompositeManifestHref(e);}catch(e){return void t(e);}this._storageService.headRequest(n,t);}},{key:"hasCompositeChangedOnServer",value:function(e,t){this.doHeadRequest(e,function(n,i){if(n)t(!0);else{var o=i&&i.headers&&i.headers.etag,r=e.current&&e.current.manifestEtag;t(o!==r);}});}},{key:"downloadComponent",value:function(e,t,n){s.downloadComponents([t],e,this._storageService,n);}},{key:"downloadRepresentation",value:function(e,t){var n=e._dcxComponent,i=e.element.library._dcxBranch;this.downloadComponent(i,n,t);}},{key:"updateCompositeMetadata",value:function(e,t,n){var i=this;this._services.log("Started library metadata update: ".concat(e)),this._inProgressSyncMap[e]=s.updateCompositeMetadata(t,this._storageService,function(t,o){i._services.log("Finished library metadata update: ".concat(e,", change: ").concat(o,", error: ").concat(t)),delete i._inProgressSyncMap[e],n(t,o);});}},{key:"newCompositeWithAssetId",value:function(e,t,n,i){var o=this;this._inProgressSyncMap[e]=this._services.dcx.newCompositeWithAssetId(t,n,void 0,void 0,void 0,this._storageService,function(t,n){if(delete o._inProgressSyncMap[e],t){if(t.code===l.NETWORK_ERROR&&"Request aborted"===t.message)return i(new u(u.TRANSFER_ABORTED,"Request aborted",e,t));if(t.code===l.NO_COMPOSITE)return i(new u(u.NOT_FOUND,"Library not found",e,t));if(!(t instanceof u))return i(new u(u.NETWORK_ERROR,"Unable load library from assetId",e,t));}return i(t,n);});}},{key:"abortPushOrPull",value:function(e){this._inProgressSyncMap[e]&&(this._inProgressSyncMap[e].abort(new u(u.TRANSFER_ABORTED,"abort push or pull operation")),delete this._inProgressSyncMap[e]);}},{key:"pullLibrary",value:function(e,t){var n=this,i=e._dcxComposite,o=e.collection,r=e.id;if(!r&&i.href){var a=i.href.split("/");r=a&&a[a.length-1];}this._services.log("Started pulling: "+r+(this._isManifestOnly()?" (manifest only)":""));var s=Date.now();o._updateProgress(r),this._pullComposite(i,o,r,function(e,a){var c=Date.now()-s;n._services.log("Finished pulling: "+r+(e?" ["+e.code+"]":"")+" duration="+c),delete n._inProgressSyncMap[r],o._updateProgress(r),a&&(a=a.copy(),_.ensureBranchDataValid(a)),e&&e.code===l.COMPONENT_DOWNLOAD_ERROR?n.doHeadRequest(i,function(n,i){if(!n&&i&&200===i.statusCode){var r=_.removeMissingComponents(o,e.pulledBranch.copy(),e.failedComponents);if(r)return void t(null,r);}t(e,a);}):t(e,a);});}},{key:"pullMissingComponents",value:function(e,t){var n=this,i=e.id,o=e.collection,r=e._getMissingLocalComponents();if(this._isManifestOnly()||0===r.length)t(null);else{e._setSyncState("downloading"),this._services.log("Started pulling missing components: "+i);var a=Date.now();o._updateProgress(i),this._pullCompositeComponents(r,e._dcxBranch,o,i,function(r){var s=Date.now()-a;n._services.log("Finished pulling missing components: "+i+(r?" ["+r.code+"]":"")+" duration="+s),delete n._inProgressSyncMap[i],o._updateProgress(i),e._setSyncState(),r&&r.code===u.TRANSFER_ABORTED?t(null):t(r);});}}},{key:"pushLibrary",value:function(e,t,n){var i=this,o=e._dcxComposite,r=e.collection,a=e.id;this._services.log("Started pushing: "+a);var c=Date.now();r._updateProgress(a),this._inProgressSyncMap[a]=s.pushComposite(o,t,this._storageService,function(e){var t=Date.now()-c;i._services.log("Finished pushing: "+a+(e?" ["+e.code+"]":"")+" duration="+t),delete i._inProgressSyncMap[a],r._updateProgress(a),n(e);}),this._inProgressSyncMap[a].onProgress=function(e,t){0!==t&&r._updateProgress(a,e,t);};}},{key:"pushDeletedLibrary",value:function(e,t,n,i){var o=this,r=e._dcxComposite;if(!r.current||r.current.isBound){if(this._isACP)return this._storageService.discardComposite(r,i);this._services.log("Pushing deleted composite: "+r.id),this.pushLibrary(e,n,function(t){if(t){if(t.code===l.UNEXPECTED_RESPONSE&&t.response&&404===t.response.statusCode)return void o._storageService.deleteCompositeDirectory(r,i);if(t.code===l.UPDATE_CONFLICT){var n=t;return void o.pullLibrary(e,function(e){e&&e.code===l.NO_COMPOSITE?o._storageService.deleteCompositeDirectory(r,i):e&&e.code===l.DELETED_COMPOSITE?i(null):i(e||n);});}}i(t);});}else i(null);}},{key:"getStorageHost",value:function(){return"https://".concat(this._storageHost);}},{key:"getPlatformHost",value:function(){return this._platformHost&&"https://".concat(this._platformHost);}},{key:"getElementRefDomain",value:function(){return this._requiresCommunitySession?this._config.CP_CLOUD_ID:this._storageHost;}},{key:"getElementRefPath",value:function(){return this._config.STORAGE_ASSETS_PATH+this._config.LIBRARY_SYNC_GROUP;}},{key:"getElementRefDomainPath",value:function(){return this.getElementRefDomain()+this.getElementRefPath();}},{key:"getCollaborationHost",value:function(){return"https://"+this._collaborationHost;}},{key:"getContentURL",value:function(e){return this._storageService.getComponentHref(e,e.version);}},{key:"getContent",value:function(e,t,n){this._storageService.getAssetAsType(this.getContentURL(e),t,{},function(e,t){return e?n(e):n(null,t);});}},{key:"appendAccessTokenToURL",value:function(e,t){if(e){var n=this._apiKey;this._getAuthToken(function(i,o){t(null,e+="?api_key="+n+(o?"&user_token="+o:""));});}else t(null,void 0);}},{key:"updateAccessToken",value:function(e){this._setAuthToken(e);}},{key:"isLoggedIn",value:function(){return this._isPublic||this._httpServices[0].isActive;}},{key:"uploadNewComponentForRepresentation",value:function(e,t,n,i){var o=n._element._library._dcxComposite;s.uploadNewComponent(e,n.type,o,n.id,this._storageService,function(e,r){if(e)i(e);else{var a=t?t.lastIndexOf("."):-1,s=-1!==a&&t.substr(a+1).toLowerCase(),c=n.id+"."+s,l=n._parent?n._parent._dcxNode:n._element._dcxNode,u=o.current.addComponentWithUploadResults(t,n.relationship,c,l,r);i(null,u);}});}},{key:"uploadNewComponentForLibrary",value:function(e,t,n,i,o,r){var a=o._dcxComposite;s.uploadNewComponent(e,n,a,t,this._storageService,function(e,o){if(e)r(e);else{var s=h.getExtensions(n)[0],c=t+"."+s,l=a.current.addComponentWithUploadResults(c,i,c,a,o);r(null,l);}});}},{key:"pushClientTokenInfo",value:function(e,t){var n="https://".concat(this._ccLibraryHost,"/api/v1/client-tokens/").concat(e),i={token:JSON.stringify(t),ttl:300};return this._doJSONRequest("POST",n,i).then(function(e){return 201===e.statusCode;},function(){return!1;});}},{key:"getBookmarks",value:function(){var e="https://".concat(this._ccLibraryHost,"/api/v1/libraries/bookmarks");return this._doJSONRequest("GET",e).then(function(e){var t=e.statusCode,n=e.response;if(404!==t)return 200!==t?Promise.reject(new u(u.TRANSFER_ERROR,"Unexpected response getting bookmarks: ".concat(t))):n;});}},{key:"createBookmarks",value:function(e){var t=this,n="https://".concat(this._ccLibraryHost,"/api/v1/libraries/bookmarks");return this._doJSONRequest("POST",n,e).then(function(e){var n=e.statusCode,i=e.response;if(201!==n){var o=t._config.isUnrecoverableClientError(n)?u.TRANSFER_ERROR:u.RETRYABLE_SERVER_ERROR;return Promise.reject(new u(o,"Unexpected response creating bookmarks: ".concat(n)));}return i;});}},{key:"removeBookmark",value:function(e){var t=this,n="https://".concat(this._ccLibraryHost,"/api/v1/libraries/bookmarks/").concat(e);return this._doJSONRequest("DELETE",n).then(function(e){var n=e.statusCode;if(![200,204,404].includes(n)){var i=t._config.isUnrecoverableClientError(n)?u.TRANSFER_ERROR:u.RETRYABLE_SERVER_ERROR;return Promise.reject(new u(i,"Unexpected response deleting bookmark: ".concat(n)));}});}},{key:"removeAllCollaborators",value:function(e){var t=this;if(!e.collection.isPrivate)return Promise.resolve();var n=e._dcxComposite.href&&encodeURIComponent(e._dcxComposite.href),i="https://".concat(this._invitationsHost,"/api/v3/share/").concat(n);return this._doJSONRequest("GET",i).then(function(e){var i=e.response,o=e.statusCode;return[200,204,404].includes(o)?t.removeCollaborators(n,i.collaborators.map(function(e){return e.id;}),i.invitations.map(function(e){return e.id;})):Promise.reject(o);});}},{key:"removeCollaborators",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i="https://".concat(this._invitationsHost,"/api/v3/share/").concat(e);return this._doJSONRequest("PATCH",i,{collaborators:t.map(function(e){return{id:e,action:"remove"};}),invitations:n.map(function(e){return{id:e,action:"remove"};})}).then(function(e){var t=e.statusCode;if(![200,204,404].includes(t))return Promise.reject(new u(u.TRANSFER_ERROR,"Failed to remove collaborators: ".concat(t)));}).catch(function(e){if(!e.response||404!==e.response.statusCode)return Promise.reject(e);});}},{key:"getUserQuota",value:(y=o(regeneratorRuntime.mark(function e(){var t,n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isPublic&&!this._isACP){e.next=2;break;}throw new u(u.NOT_ALLOWED,"Cannot get user quota on non-private collection.");case 2:return t="https://".concat(this._storageHost,"/profile/quota"),e.next=5,this._doJSONRequest("GET",t);case 5:if(200===(n=e.sent).statusCode){e.next=8;break;}throw new u(u.NETWORK_ERROR,"Could not get quota from storage service. Status: ".concat(n.statusCode));case 8:return e.abrupt("return",n.response);case 9:case"end":return e.stop();}},e,this);})),function(){return y.apply(this,arguments);})},{key:"getPublicLibraryAssetId",value:(v=o(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this._isPublic){e.next=2;break;}throw new u(u.NOT_ALLOWED,"getPublicLibraryAssetId is only supported for public collections.");case 2:return e.next=4,this._doJSONRequest("HEAD",t._dcxComposite.href);case 4:return n=e.sent,e.abrupt("return",n&&n.headers&&n.headers["x-resource-urn"]);case 6:case"end":return e.stop();}},e,this);})),function(e){return v.apply(this,arguments);})},{key:"_config",get:function(){return this._apiRoot._config;}},{key:"_services",get:function(){return this._apiRoot._services;}},{key:"_platformRootDocument",get:function(){return this._apiRoot._getCachedRootDocument();}},{key:"typekit",get:function(){return this._typekitSync;}},{key:"renditions",get:function(){return this._renditionSync;}},{key:"links",get:function(){return this._externalLinkSync;}}])&&a(t.prototype,n),i&&a(t,i),e;}();e.exports=v;},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var o=n(11),r=n(0),a=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._syncManager=t;}var t,n,a;return t=e,(n=[{key:"_getStorageSession",value:function(e){return this._syncManager._getStorageSession(e);}},{key:"download",value:function(e,t,n,i,a){var s=this,c=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;this._services.log("download external link: "+e);var l=this._getStorageSession(e),u=n+this._services.getPathSeparator()+this._services.uuid(),_=new o.FileContent(u);t=t||{},this._services.fileUtils.ensurePathExists(n,function(o){var h;if(o)a(o);else if((h=l.getAssetAsType(e,_,t,function(o,l,_,p){if(h&&delete h.progress,o&&o.code===r.UNEXPECTED_RESPONSE){var d=o.response&&o.response.statusCode;if(s._services.log("download external link: Unexpected Response "+d+" from "+e),s._config.isRedirect(d)){var f=s._config.getLocationHeader(o.response.headers);if(f&&c<s._config.MAX_REDIRECT_FOLLOW)return s._services.log("download external link: Redirecting to "+f),void s.download(f,t,n,i,a,c+1);o.response.statusCode=404;}}a(o,u,_,p);}))&&i){var p,d=0;h.progress=function(e){d+=e,!p&&h.response&&h.response.headers&&(p=s._config.getContentLengthHeader(h.response.headers)),i(d,p||1);},i(0,1);}});}},{key:"test",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=this._getStorageSession(e);o.headRequest(e,function(o,r){var a=r?r.statusCode:o;if(n._services.log("test external link: "+e+" -> "+a),r&&n._config.isRedirect(r.statusCode)){var s=n._config.getLocationHeader(r.headers);if(s&&i<n._config.MAX_HEAD_REDIRECT_FOLLOW)return n._services.log("test external link: Redirecting to "+s),void n.test(s,t,i+1);i>0&&(r.statusCode=404);}t(o,r);});}},{key:"_config",get:function(){return this._syncManager._config;}},{key:"_services",get:function(){return this._syncManager._services;}}])&&i(t.prototype,n),a&&i(t,a),e;}();e.exports=a;},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var o=n(11),r=n(3),a=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._syncManager=t,this._imageHost=n.CC_IMAGE_HOSTNAME,this._imageXHost=n.CC_IMAGE_X_HOSTNAME,this._renditionStorageService=this._getStorageSession(t.getStorageHost()),this._requiresCommunitySession=n.REQUIRES_COMMUNITY_SESSION;}var t,n,a;return t=e,(n=[{key:"_getStorageSession",value:function(e){return this._syncManager._getStorageSession(e);}},{key:"_downloadRendition",value:function(e,t,n,i,a){var s=this,c=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;if(e.isDeletedLocally||e.element.library.isDeletedFromServer)a("Error: representation deleted");else{var l=function(o){return s._downloadRendition(e,t,n,i,a,o);};if(c>0&&"uploading"===e.element.library.syncState)setTimeout(function(){return l(c);},this._config.RENDITION_RETRY_INTERVAL);else{var u=n+this._services.getPathSeparator()+this._services.uuid()+".png",_=new o.FileContent(u);this._renditionStorageService.getAssetAsType(t,_,i,function(t){var n=t&&t.response&&t.response.headers,i=function(){return a(t,u);};if(404===r.getErrorStatusCode(t))return s._retry404IfNeeded(e,n,c,l,i);i();});}}}},{key:"_retry404IfNeeded",value:function(e,t,n,i,o){var r=1e3*this._config.getRetryAfterHeader(t);if(this._config.RENDITION_RETRY_INTERVAL=Math.max(this._config.DEFAULT_RENDITION_RETRY_INTERVAL,r),this._config.RENDITION_404_BACKOFF=Math.max(this._config.DEFAULT_RENDITION_404_BACKOFF,r),n<this._config.RENDITION_MAX_RETRIES)return n++,this._services.log("404 fetching rendition: retrying ("+n+")"),void setTimeout(function(){return i(n);},this._config.RENDITION_RETRY_INTERVAL);this._services.log("404 fetching rendition: reached maximum retries"),this._services.log("Backing off rendition fetch of "+e.id+" for "+this._config.RENDITION_404_BACKOFF+"ms"),e._lastRendition404=Date.now(),o();}},{key:"_getImageServiceSVGRendition",value:function(e,t,n){var i=this,o=e.element,r="https://"+this._imageHost+"/createagc",a=this._getStorageSession(r),s={inputs:{application_file:{href:o.getReference()}},outputs:{agc:{disposition:"location"}}};if(e.isDeletedLocally||e.element.library.isDeletedFromServer)n("Error: representation deleted");else{var c=function(t){return i._getImageServiceSVGRendition(e,t,n);};a._service.invoke("POST",r,{"Content-Type":"application/vnd.adobe.image-operation+json"},JSON.stringify(s),{responseType:"text"},function(r,a){if(r||200!==a.statusCode){var s=function(){return n(r||"Image service call failed with: "+a.statusCode);};return a&&404===a.statusCode?i._retry404IfNeeded(e,a&&a.headers,t,c,s):void s();}var l;try{l=JSON.parse(a.response);}catch(e){return n(e);}if(l&&l.outputs&&l.outputs.agc&&l.outputs.agc.location){var u="https://"+i._imageXHost+"/agctosvg",_=i._getStorageSession(u),h={inputs:{href:l.outputs.agc.location}};return _._service.invoke("POST",u,{"Content-Type":"application/vnd.adobe.dwbedrockservice-operation+json"},JSON.stringify(h),{responseType:"text"},function(e,t){if(e||200!==t.statusCode)return n(e||"Image-x service call failed with: "+t.statusCode);var r=t.response,a=o.library.collection._getTempDir(),s=a+i._services.getPathSeparator()+i._services.uuid()+".svg";i._services.fileUtils.ensurePathExists(a,function(e){if(e)return n(e);i._services.fs.writeFile(s,r,function(e){return e?n(e):n(null,s);});});});}n("Invalid image service response");});}}},{key:"getURL",value:function(e,t,n){if(e._dcxComponent)try{n(null,this._requiresCommunitySession?this._renditionStorageService.getComponentRenditionHref(e._dcxComponent,e._dcxComponent.version,"image/png","width",t||"full"):this._renditionStorageService.getComponentRenditionHref(e._dcxComponent,e._dcxComponent.version,t||"full"));}catch(e){n(e);}else n("representation must be a component to generate a rendition");}},{key:"download",value:function(e,t,n){var i=this;if(e.element.library.isDeletedFromServer)return this._services.log("Error: Trying to fetch rendition from deleted library."),void n("Error: library deleted");Date.now()-(e._lastRendition404||0)<this._config.RENDITION_404_BACKOFF?n("Error: got 404 on last rendition attempt - backing off"):"vector"===t&&e.element.supportsVectorThumbnail()?function t(){"uploading"!==e.element.library.syncState?i._getImageServiceSVGRendition(e,0,n):setTimeout(t,i._config.RENDITION_RETRY_INTERVAL);}():this.getURL(e,t,function(t,o){if(t)n(t);else{var r={Accept:"image/png"},a=e.element.library.collection._getTempDir();i._services.fileUtils.ensurePathExists(a,function(t){t?n(t):i._downloadRendition(e,o,a,r,n);});}});}},{key:"_config",get:function(){return this._syncManager._config;}},{key:"_services",get:function(){return this._syncManager._services;}}])&&i(t.prototype,n),a&&i(t,a),e;}();e.exports=a;},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var i=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._syncManager=t,this._typekitHost=n.TYPEKIT_HOSTNAME;}var t,i,o;return t=e,(i=[{key:"_getStorageSession",value:function(e){return this._syncManager._getStorageSession(e);}},{key:"getFontData",value:function(e,t){var n="https://"+this._typekitHost+"/v1/variations?include=trial,full,marketplace,purchased&include_marketplace_data=true&purpose=sync";this._getStorageSession(n)._service.invoke("POST",n,null,JSON.stringify(e),{responseType:"text"},function(e,n){if(e||200!==n.statusCode)return t(e||"Typekit service call failed with: "+n.statusCode);try{t(null,JSON.parse(n.response));}catch(e){t(e);}});}}])&&n(t.prototype,i),o&&n(t,o),e;}();e.exports=i;},function(e,t){var n=/^platform-cs(-stage)?(-[a-zA-Z0-9]+)?\.adobe\.io$/;e.exports={isACPHost:function(e){return n.test(e);}};},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var o=n(7),r=function(){function e(t,n,i,r,a){var s=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._listenerManager=new o(["progress"],function(e){return s._collection._services.log(e);}),this._collection=t,this._id=n,this._type=i,this._data=r,this._cancelCallback=a,this._progress=0;}var t,n,r;return t=e,(n=[{key:"_updateProgress",value:function(e){this._progress!==e&&(this._progress=e,this._listenerManager.notify("progress",[this]),this._collection._notifyOperationChange());}},{key:"addProgressListener",value:function(e){this._listenerManager.add("progress",e);}},{key:"removeProgressListener",value:function(e){this._listenerManager.remove("progress",e);}},{key:"cancel",value:function(){this._config.SHARED_LOCAL_STORAGE?this._storageInterface.cancelOperation(this._collection,this._id):this._cancelCallback&&this._cancelCallback();}},{key:"_config",get:function(){return this._collection._config;}},{key:"_storageInterface",get:function(){return this._collection._storageInterface;}},{key:"id",get:function(){return this._id;}},{key:"type",get:function(){return this._type;}},{key:"data",get:function(){return this._data;}},{key:"progress",get:function(){return this._progress;}},{key:"isDone",get:function(){return 100===this._progress;}},{key:"result",get:function(){return this._result;},set:function(e){this._result=e;}},{key:"error",get:function(){return this._error;},set:function(e){this._error=e,this._progress=100;}}])&&i(t.prototype,n),r&&i(t,r),e;}();e.exports=r;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function r(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}(e):t;}function a(e,t,n){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=s(e)););return e;}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(n):o.value;}})(e,t,n||e);}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e);})(e);}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e;})(e,t);}var l=function(e){function t(e,n){var i;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,t),(i=r(this,s(t).call(this,"public",e)))._url=n,i;}var n,i,l;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t);}(t,e),n=t,(i=[{key:"toJSON",value:function(){return a(s(t.prototype),"toJSON",this).call(this,{url:this._url});}},{key:"isReferenceTo",value:function(e){return this.url===e._dcxComposite.href;}},{key:"url",get:function(){return this._url;}}])&&o(n.prototype,i),l&&o(n,l),t;}(n(40));e.exports=l;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function r(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}(e):t;}function a(e,t,n){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=s(e)););return e;}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(n):o.value;}})(e,t,n||e);}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e);})(e);}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e;})(e,t);}var l=function(e){function t(e,n,i){var o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,t),(o=r(this,s(t).call(this,"collab",e)))._urn=n,o._role=i,o;}var n,i,l;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t);}(t,e),n=t,(i=[{key:"toJSON",value:function(){return a(s(t.prototype),"toJSON",this).call(this,{urn:this._urn,role:this._role});}},{key:"isReferenceTo",value:function(e){return e.id===this.id;}},{key:"urn",get:function(){return this._urn;}},{key:"role",get:function(){return this._role;}}])&&o(n.prototype,i),l&&o(n,l),t;}(n(40));e.exports=l;},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var o=n(2),r=n(7),a=function(){function e(t){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._collection=t,this._listenerManager=new r(["change"],function(e){return n._services.log(e);}),this._fontsCache={};}var t,n,a;return t=e,(n=[{key:"_clearCache",value:function(){this._fontsCache={},this._listenerManager.notify("change");}},{key:"addChangeListener",value:function(e){this._listenerManager.add("change",e);}},{key:"removeChangeListener",value:function(e){this._listenerManager.remove("change",e);}},{key:"getFontData",value:function(e,t){var n=this,i=this._fontsCache[e];i?t(null,i):this._config.SHARED_LOCAL_STORAGE?this._storageInterface.getFontData(this._collection,e,function(i,o){o&&(n._fontsCache[e]=o),t(i,o);}):this._collection._syncManager.typekit.getFontData([e],function(i,r){if(i)t(new o(o.NETWORK_ERROR,"Error occurred while getting font data",null,i));else{var a=r&&r[0];n._fontsCache[e]=a,t(null,a);}});}},{key:"isSystemFontAvailable",value:function(e,t,n){if(!this._config.SHARED_LOCAL_STORAGE)return n(new o(o.NOT_SUPPORTED,"isSystemFontAvailable() is only supported with shared local storage"));this._storageInterface.isFontAvailable(e,t,n);}},{key:"_config",get:function(){return this._collection._config;}},{key:"_services",get:function(){return this._collection._services;}},{key:"_storageInterface",get:function(){return this._collection._storageInterface;}}])&&i(t.prototype,n),a&&i(t,a),e;}();e.exports=a;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable;})),n.push.apply(n,i);}return n;}function r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach(function(t){a(e,t,n[t]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t));});}return e;}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e;}function s(e,t,n,i,o,r,a){try{var s=e[r](a),c=s.value;}catch(e){return void n(e);}s.done?t(c):Promise.resolve(c).then(i,o);}function c(e){return function(){var t=this,n=arguments;return new Promise(function(i,o){var r=e.apply(t,n);function a(e){s(r,i,o,a,c,"next",e);}function c(e){s(r,i,o,a,c,"throw",e);}a(void 0);});};}function l(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function u(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}(e):t;}function _(e,t,n){return(_="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=h(e)););return e;}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(n):o.value;}})(e,t,n||e);}function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e);})(e);}function p(e,t){return(p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e;})(e,t);}var d=n(42),f=n(2),m=n(88),v=n(41),y=n(1),g=n(8),E=n(4).promisify,O=function(e){function t(e){var n;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,t),(n=u(this,h(t).call(this,e._config.PLATFORM_DATA_FILENAME,e)))._folders=[],n._root=void 0,n._rootTTL=void 0,n._rootVersion=void 0,n;}var n,i,o,a,s,v,O,S;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&p(e,t);}(t,e),n=t,(i=[{key:"load",value:(S=c(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,_(h(t.prototype),"load",this).call(this);case 3:return e.prev=3,e.prev=4,e.next=7,this._loadRootDocument();case 7:this.refreshPlatformFolders(),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(4),this._services.log("Unable to load root document: ".concat(e.t0));case 13:return e.finish(3);case 14:case"end":return e.stop();}},e,this,[[0,,3,14],[4,10]]);})),function(){return S.apply(this,arguments);})},{key:"_fromJSON",value:function(e){e?(this._folders=e.folders.map(function(e){return new d(e);}),this._root=e.root,this._rootTTL=e.root_ttl,this._rootVersion=e.root_version,this._listenerManager.notify("change")):this._services.log("Unable to load platform data from disk.");}},{key:"_toJSON",value:function(){return{folders:this._folders.map(function(e){return e.toJSON();}),root:this._root,root_version:this._config.PLATFORM_DATA_VERSION,root_ttl:this._rootTTL};}},{key:"_loadRootDocument",value:(O=c(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=E(this._platformSession.getRootDocument.bind(this._platformSession)),!this._config.SHARED_LOCAL_STORAGE){e.next=3;break;}throw new f(f.NOT_ALLOWED,"Cannot access platform session from shared local storage");case 3:if(!(this._root&&Date.now()<this._rootTTL&&this._rootVersion===this._config.PLATFORM_DATA_VERSION)){e.next=5;break;}return e.abrupt("return",this._platformSession.setRootDocument(this._root));case 5:return e.next=7,t();case 7:this._root=e.sent,this._rootTTL=Date.now()+this._config.PLATFORM_DATA_TTL,this._save();case 10:case"end":return e.stop();}},e,this);})),function(){return O.apply(this,arguments);})},{key:"refreshPlatformFolders",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};if(this._refreshCallbacks=this._refreshCallbacks||[],this._refreshCallbacks.push(t),!this._inRefreshQuietPeriod){var n=function(){var t=e._refreshCallbacks;e._refreshCallbacks=[],t.forEach(function(e){return e();});};this._inRefreshQuietPeriod=!0,setTimeout(function(){e._inRefreshQuietPeriod=!1,e._refreshCallbacks.length>0&&e._refreshPlatformFolders().finally(n);},this._config.PLATFORM_FOLDER_REFRESH_INTERVAL),this._refreshPlatformFolders().finally(n);}}},{key:"_refreshPlatformFolders",value:(v=c(regeneratorRuntime.mark(function e(){var t,n,i,o,r,a,s,c=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._config.SHARED_LOCAL_STORAGE){e.next=2;break;}return e.abrupt("return",this._storageInterface.refreshPlatformFolders());case 2:return t=E(this._platformSession.getAssets.bind(this._platformSession)),n=E(this._platformSession.getRepositories.bind(this._platformSession)),e.next=6,n();case 6:if(i=e.sent,(o=m.extractRepositoryData(i))&&0!==o.length){e.next=11;break;}return this._services.log("Error: User doesn't have a repository"),e.abrupt("return");case 11:return r=o[0]&&o[0]["repo:owner"]&&o[0]["repo:owner"].id,e.next=14,this._services._getOrgBetaStatus(r||"no-org");case 14:if(this._isBetaMember=e.sent,!this._isBetaMember||!r){e.next=19;break;}this._services.log("Organization is permitted to access beta. ".concat(r)),e.next=24;break;case 19:return this._services.log("Organization is not permitted to access beta. ".concat(r)),this._folders=[],this._save(),this._listenerManager.notify("change"),e.abrupt("return");case 24:return e.next=26,t();case 26:if((a=e.sent)&&a.children){e.next=29;break;}throw new f("INDEX_ERROR","Bad response from ACP discovery API");case 29:return e.next=31,Promise.all(o.map(function(e){return c._getPlatformFoldersForRepository(e,a);}));case 31:s=e.sent,this._folders=s.flat().map(function(e){return new d(e);}),this._save(),this._listenerManager.notify("change");case 35:case"end":return e.stop();}},e,this);})),function(){return v.apply(this,arguments);})},{key:"_getPlatformFoldersForRepository",value:(s=c(regeneratorRuntime.mark(function e(t,n){var i,o,a,s,l,u,_,h=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:i=E(this._platformSession.getEffectiveACFromLinks.bind(this._platformSession)),o=t["repo:repositoryId"],a=function(){var e=c(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Promise.all(t.map(function(){var e=c(regeneratorRuntime.mark(function e(t){var n;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i(t.links);case 2:if((n=e.sent)&&n.includes("write")&&n.includes("read")){e.next=5;break;}return e.abrupt("return");case 5:return e.abrupt("return",r({},t,{name:t.ownerName,permissions:n}));case 6:case"end":return e.stop();}},e);}));return function(t){return e.apply(this,arguments);};}()));case 2:return n=(n=e.sent).filter(function(e){return e;}),h._services.log("Fetched ".concat(n.length," folders: ").concat(n.map(function(e){return e.name;}).join(", "))),e.abrupt("return",n);case 6:case"end":return e.stop();}},e);}));return function(t){return e.apply(this,arguments);};}(),e.prev=3,s=m.getPlatformFoldersFromAssetsResponse(t,n,this._apiRoot._localisation.getLocale()),l=m.getRootLinksFromAssetsResponse(o,n),e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(3),this._services.log("Could not parse platform assets response: ".concat(o)),e.t0;case 12:if(l){e.next=14;break;}return e.abrupt("return",a(s));case 14:return e.next=16,i(l);case 16:if(e.sent.includes("write")){e.next=19;break;}return e.abrupt("return",a(s));case 19:return e.next=21,this._getFolderAtPath(o,m.TOP_LEVEL_FOLDER_PATH);case 21:u=e.sent,e.prev=22,_=m.getPlatformFoldersFromAssetsResponse(t,u,this._apiRoot._localisation.getLocale()),e.next=30;break;case 26:throw e.prev=26,e.t1=e.catch(22),this._services.log("Could not parse platform directory response: ".concat(o)),e.t1;case 30:return e.abrupt("return",a(_));case 31:case"end":return e.stop();}},e,this,[[3,8],[22,26]]);})),function(e,t){return s.apply(this,arguments);})},{key:"_getFolderAtPath",value:(a=c(regeneratorRuntime.mark(function e(t,n){var i,o,r,a;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return i=E(this._platformSession.getLinksFromPath.bind(this._platformSession)),o=E(this._platformSession.getCollection.bind(this._platformSession)),e.next=4,i(t,n);case 4:return r=e.sent,a=y.getUrlFromLinks(r,g.ID),e.abrupt("return",o(a,void 0));case 7:case"end":return e.stop();}},e,this);})),function(e,t){return a.apply(this,arguments);})},{key:"_apiRoot",get:function(){return this._collection._apiRoot;}},{key:"_platformSession",get:function(){return this._syncManager.getPlatformSession();}},{key:"folders",get:function(){return this._folders;}},{key:"cachedRootDocument",get:function(){return this._root;}},{key:"isBetaMember",get:function(){return this._isBetaMember;}}])&&l(n.prototype,i),o&&l(n,o),t;}(v);e.exports=O;},function(e,t,n){var i=n(8),o=n(2),r=/^\/content\/assets\/[^/]+$/,a=function(e){var t="application/vnd.adobecloud.directory+json"===e["dc:format"],n="ACTIVE"===e["repo:state"];return t&&n;},s=function(e,t){for(var n=e["dc:title"],i=/^rdf:_/,o=Object.keys(n).filter(function(e){return i.test(e);}),r=t?t.replace("_","-"):"",a="",s=0;s<o.length;s++){if(n[o[s]]["@language"]&&n[o[s]]["@language"].toLowerCase()===r.toLowerCase())return n[o[s]]["@value"];"i-default"===n[o[s]]["@language"]&&(a=n[o[s]]["@value"]);}return a||"<org>";};e.exports={extractRepositoryData:function(e){return(e&&e.children||[]).filter(function(e){var t=e._embedded&&e._embedded[i.PRIMARY]&&e._embedded[i.PRIMARY]["repo:owner"];return t&&"org"===t.type;}).map(function(e){return e._embedded[i.PRIMARY];});},getRootLinksFromAssetsResponse:function(e,t){var n=t.children.find(function(t){var n=t&&t._embedded&&t._embedded[i.METADATA];if(n)return"/"===n["repo:path"]&&n["repo:repositoryId"]===e;});return n&&n._embedded[i.METADATA]._links;},getPlatformFoldersFromAssetsResponse:function(e,t,n){var c=[];return t.children.forEach(function(t){var l=t._embedded?t._embedded[i.METADATA]:t,u=e["repo:repositoryId"];if(!l)throw new o(o.INVALID_DATA,"Malformed ACP-CS index entry: ".concat(u));var _=a(l),h=r.test(l["repo:path"]),p=l["repo:repositoryId"]===u,d=l["repo:name"]&&"everyone"===l["repo:name"].toLowerCase(),f=[];_||f.push("Not visible: repo:state=".concat(l["repo:state"]," dc:format=").concat(l["dc:format"])),h||f.push("Not top level: repo:path=".concat(l["repo:path"])),p||f.push("Not in correct repo: repositoryId=".concat(l["repo:repositoryId"])),d||f.push("Not named 'Everyone': repo:name=".concat(l["repo:name"]));var m=s(e,n);0===f.length&&c.push({id:l["repo:assetId"],ownerId:l["storage:assignee"]&&l["storage:assignee"].id,ownerType:l["storage:assignee"]&&l["storage:assignee"].type,ownerName:m,name:l["repo:name"],links:l._links,createdBy:l["repo:createdBy"]});}),c;},isVisibleFolder:a,getOwnerName:s,TOP_LEVEL_FOLDER_PATH:"/content/assets"};},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}(e):t;}function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e);})(e);}function a(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function s(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),e;}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e;})(e,t);}var l=n(2),u=n(10),_=n(3),h=n(39),p=n(4).promisify,d={},f=function(e){function t(e,n){var i;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,t);var a=e._services.fileUtils.getUserDir(n)+e._services.getPathSeparator()+"links";return(i=o(this,r(t).call(this,e,a)))._userId=n,i._collections=[],i._pendingDownloads={},i._pendingTests={},i._referencedLinks={},i._sentNotifications={},i._sharedStorage={downloadExternalLink:function(e){return p(i._storageInterface.downloadExternalLink.bind(i._storageInterface))(e);},testExternalLink:function(e){return p(i._storageInterface.testExternalLink.bind(i._storageInterface))(e);}},i;}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t);}(t,e),s(t,null,[{key:"connect",value:function(e){var n=e.userId,i=d[n]=d[n]||new t(e._apiRoot,n);return i._connect(e),i;}},{key:"disconnect",value:function(e){var t=e.userId;d[t]&&d[t]._disconnect(e);}}]),s(t,[{key:"getCachedPath",value:function(e){var t=this._getCacheEntry(e);return this._isPath(t)?t:void 0;}},{key:"getCachedError",value:function(e){var t=this._config.validateURL(e.getContentURL(),this._privateCollection);if(t)return t;var n=this._getCacheEntry(e);return this._isErrorCode(n)?new l(n,"Broken link, or access denied"):null;}},{key:"getExternalLink",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=e.getContentURL(),o=this._config.validateURL(i,this._privateCollection);if(o)return Promise.reject(o);if(n)e.element.library._renditionCache._legacyClearCacheEntry(e),this._setCacheEntry(["urls",i]);else{var r=this._getCacheEntry(e);if(this._isPath(r))return Promise.resolve(r);if(this._isErrorCode(r))return Promise.reject(new l(r,"Broken link, or access denied"));}if(this._config.SHARED_LOCAL_STORAGE)return this._sharedStorage.downloadExternalLink(e);if(!this._pendingDownloads[i]){var a=function(){t._notifyDownloadFinished(t._pendingDownloads[i]);var n=e.element;n.supportsVectorThumbnail()&&n.library._renditionCache._clearCache(n,"vector"),delete t._pendingDownloads[i];};this._pendingDownloads[i]={promise:this._doGetExternalLink(e),representations:[]},this._pendingDownloads[i].promise.then(a,a);}return this._pendingDownloads[i].representations.push(e),this._pendingDownloads[i].promise;}},{key:"testExternalLink",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=e.getContentURL();if(this._config.validateURL(i,this._privateCollection))return Promise.reject();if(n)e.element.library._renditionCache._legacyClearCacheEntry(e),this._setCacheEntry(["urls",i]);else{var o=this._getCacheEntry(e);if(o)return this._isErrorCode(o)?Promise.reject():Promise.resolve();}if(this._config.SHARED_LOCAL_STORAGE&&this._privateCollection._storageInterface.supportsTestExternalLink())return this._sharedStorage.testExternalLink(e);if(!this._pendingTests[i]){var r=this._getOnDownloadProgressCallback("_pendingTests",i),a=function(){t._notifyDownloadFinished(t._pendingTests[i]),r(),delete t._pendingTests[i];};this._pendingTests[i]={promise:this._doTest(i),representations:[]},r(0,1),this._pendingTests[i].promise.then(a,a);}return this._pendingTests[i].representations.push(e),this._pendingTests[i].promise;}},{key:"ensureExternalLinkCache",value:function(e,t){var n=this,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=this._getCache(["urls",e]);return this._getFilePath(o)?i?Promise.resolve():this._fs.unlink(t):this._doTransaction(function(){return n._setCache(["urls",e],t,!i);});}},{key:"gc",value:function(){var e=this,t={};this._collections.forEach(function(n){n.libraries.forEach(function(n){Object.assign(t,e._getReferences(n));});});var n=this._cache.urls||{},i=!1;return Object.keys(n).forEach(function(n){t[n]||(e._setCacheEntry(["urls",n]),i=!0);}),i?this.save():Promise.resolve();}},{key:"_connect",value:function(e){this._collections.push(e),e._externalLinkCache=this;}},{key:"_disconnect",value:function(e){var t=this._collections.indexOf(e);-1!==t&&this._collections.splice(t,1),0===this._collections.length&&delete d[this._userId];}},{key:"_getCacheEntry",value:function(e){var t=e.element.library._renditionCache._legacyGetCacheEntry(e);if(t)return t;var n=e.getContentURL(),i=this._getCache(["urls",n]);return this._getFilePath(i,!0);}},{key:"_doGetExternalLink",value:function(e){var t=this,n=e.getContentURL(),i=e._getLinkLocalPaths().find(function(e){return t._fs.statSync(e);});return i?this._doTransaction(function(){return t._setCache(["urls",n],i);}):this._doDownload(n,e.type);}},{key:"_doDownload",value:function(e,t){var n=this,i=this._getOnDownloadProgressCallback("_pendingDownloads",e),o=this._privateCollection._getTempDir();return this._downloadURL(this._privateCollection,e,o,i).then(function(o){var r=o.tempFilePath,a=o.response,s=n._config.getContentTypeHeader(a&&a.headers)||t,c=r+"."+(u.getExtensions(s)[0]||"data"),l=n._fs.rename(r,c).then(function(){return n._doTransaction(function(){return n._setCache(["urls",e],c,!0);});});return l.then(i,i),l;}).catch(function(t){var o,r=t&&t.response&&t.response.statusCode;return n._config.isUnrecoverableClientError(r)?(n._setCacheEntry(["urls",e],l.RENDITION_NOT_AVAILABLE),o=n.save().then(function(){return Promise.reject(new l(l.RENDITION_NOT_AVAILABLE,"Broken link, or access denied"));})):o=Promise.reject(_.getSyncError(t)),o.catch(function(){return i(void 0,void 0,t);}),o;});}},{key:"_doTest",value:function(e){var t=this;return this._testURL(this._privateCollection,e).then(function(n){var i,o=n&&n.statusCode;return t._config.isUnrecoverableClientError(o)?i=l.RENDITION_NOT_AVAILABLE:o&&o>=200&&o<400&&(i=t._config.RENDITION_CACHE_PLACEHOLDER),i?(t._setCacheEntry(["urls",e],i),t.save().then(function(){return t._isErrorCode(i)?Promise.reject():Promise.resolve();})):Promise.resolve();});}},{key:"_getOnDownloadProgressCallback",value:function(e,t){var n=this;return function(i,o,r){var a=n[e]&&n[e][t]&&n[e][t].representations;a&&a.forEach(function(e){e.element.library.collection._updateExternalLinkDownloadProgress(e,i,o,r);});};}},{key:"_notifyDownloadFinished",value:function(e){var t=this;e.representations.forEach(function(e){return t._notifyDownloadRendition(e,!0);});}},{key:"_notifyDownloadRendition",value:function(e,t){var n="".concat(e.element.library.id,".").concat(e.element.id,".").concat(e.id);!0!==t&&this._sentNotifications[n]||(this._sentNotifications[n]=!0,!1!==t&&this._storageInterface.notifyDownloadRendition(e.element));}},{key:"_getReferences",value:function(e){var t=this;if(this._referencedLinks[e.id]=this._referencedLinks[e.id]||{},this._referencedLinks[e.id].modified!==e.modified){this._referencedLinks[e.id].modified=e.modified,this._referencedLinks[e.id].urlMap={};var n=function(n){n._shouldGCLocalData()||n._forEachRepresentation(function(n){var i=n.isExternalLink&&n.getContentURL();i&&(t._referencedLinks[e.id].urlMap[i]=!0);});};e.elements.forEach(n),e.removedElements.forEach(n);}return this._referencedLinks[e.id].urlMap;}},{key:"_downloadURL",value:function(e,t,n,i){var o=this;return new Promise(function(r,a){var s=Date.now();o._services.log("Downloading from external URL: "+t),e._syncManager.links.download(t,{},n,i,function(e,t,n,i){o._services.log("Finished downloading from external URL: "+(Date.now()-s)+"ms"),e?a(e):r({tempFilePath:t,etag:n,response:i});});});}},{key:"_testURL",value:function(e,t){var n=this;return new Promise(function(i){var o=Date.now();n._services.log("HEAD request of external URL: "+t),n._storageInterface.testURL(e,t,function(e,t){n._services.log("Finished HEAD request of external URL: "+(Date.now()-o)+"ms"),i(t);});});}},{key:"_privateCollection",get:function(){return this._collections.find(function(e){return e.isPrivate;});}}]),t;}(h);e.exports=f;},function(e,t,n){function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}function o(e,t,n,i,o,r,a){try{var s=e[r](a),c=s.value;}catch(e){return void n(e);}s.done?t(c):Promise.resolve(c).then(i,o);}function r(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var a=e.apply(t,n);function s(e){o(a,i,r,s,c,"next",e);}function c(e){o(a,i,r,s,c,"throw",e);}s(void 0);});};}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}function s(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function c(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}(e):t;}function l(e,t,n){return(l="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=u(e)););return e;}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(n):o.value;}})(e,t,n||e);}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e);})(e);}function _(e,t){return(_=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e;})(e,t);}var h=n(33),p=n(1),d=n(8),f=n(2),m=n(4).promisify,v=function(e){function t(){return a(this,t),c(this,u(t).apply(this,arguments));}var n,i,o,h;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_(e,t);}(t,e),n=t,(i=[{key:"_dosync",value:function(e,t){var n=this;this._clearSyncErrors();var i=this._libraries.map(function(){var e=r(regeneratorRuntime.mark(function e(t){var i,o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(i=function(e){return new Promise(function(i){if(t.isDeletedLocally)return i(!1);t._sync(!e,function(e,t){e&&n._reportSyncError(e),i(t);});});},e.prev=1,!t._dcxComposite.getLocalData("migrateFromStorageUrl")){e.next=10;break;}return e.next=5,n._doMigrationFromStorageUrl(t);case 5:if(t=e.sent){e.next=8;break;}return e.abrupt("return");case 8:e.next=12;break;case 10:if(t.isPushedToServer){e.next=12;break;}return e.abrupt("return",i(!1));case 12:return e.next=14,m(t._updateMetadata.bind(t))();case 14:if(!t._deletedFromServer){e.next=16;break;}return e.abrupt("return");case 16:return e.next=18,new Promise(function(e){return n._syncManager.hasCompositeChangedOnServer(t._dcxComposite,e);});case 18:return o=e.sent,t._dcxComposite.isDiscarded&&(o=!0),e.abrupt("return",i(o));case 23:e.prev=23,e.t0=e.catch(1),n._reportSyncError(e.t0);case 26:case"end":return e.stop();}},e,null,[[1,23]]);}));return function(t){return e.apply(this,arguments);};}());i.push(this._handlePendingDeletes().then(function(){return!1;})),Promise.all(i).then(function(e){n._handleExternalPendingDeletes(),t(null,e.some(function(e){return e;}));});}},{key:"_doMigrationFromStorageUrl",value:(h=r(regeneratorRuntime.mark(function e(t){var n,i,o,r=this;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this._services.log("Migrating library ".concat(t.id," from storage URL")),n=t._dcxComposite.getLocalData("migrateFromStorageUrl"),e.prev=2,e.next=5,this._syncManager._doJSONRequest("HEAD",n);case 5:if(i=e.sent,o=i&&i.headers["x-resource-urn"],404!==i.statusCode){e.next=13;break;}return e.next=10,new Promise(function(e,n){return r._unloadLibrary(t,function(t){return t?n(t):e();});});case 10:return e.abrupt("return");case 13:if(200===i.statusCode){e.next=15;break;}throw new f(f.NETWORK_ERROR,"Unexpected response from storage service. Code: ".concat(i.statusCode));case 15:if(o){e.next=17;break;}throw new f(f.TRANSFER_ERROR,"X-Resource-Urn not provided for asset. Can't migrate.");case 17:return t._dcxComposite.setLocalData("migrateFromStorageUrl"),t._dcxComposite.assetId=o,this._services.log("Finished migrating library ".concat(t.id," from storage URL - Success. Asset id is ").concat(o)),e.abrupt("return",t);case 23:throw e.prev=23,e.t0=e.catch(2),this._services.log("Unable to migrate library ".concat(t.id,". Error: ").concat(e.t0)),e.t0;case 27:case"end":return e.stop();}},e,this,[[2,23]]);})),function(e){return h.apply(this,arguments);})},{key:"createLibrary",value:function(e,n){if(!n)throw new f(f.INVALID_PARAMETER,"A platform folder must be provided.");if(!n.isWritable)throw new f(f.NOT_ALLOWED,"Cannot create a library in a read-only folder.");return l(u(t.prototype),"createLibrary",this).call(this,e,n);}},{key:"_getNewCompositeHref",value:function(e,t){return p.getTemplateFromLinks(t.links,d.CREATE);}},{key:"_prepareCompositeForPush",value:function(e,n){return e.parentAssetId=n.id,e.storageAssignee={id:n.owner,type:n.ownerType},e.isParentWritable=!0,e.isWritable=!0,l(u(t.prototype),"_prepareCompositeForPush",this).call(this,e,n);}},{key:"removeLibrary",value:function(e,n){if(!e.isWritable)return n(new f(f.NOT_ALLOWED,"Library cannot be deleted. Collection is not writable. ".concat(e.id)));l(u(t.prototype),"removeLibrary",this).call(this,e,n);}},{key:"_syncNewLibrary",value:function(e,t,n,i){var o=this;if(!t)return i(new f(f.INVALID_PARAMETER));var r=this._services.hasFileSystem()&&this._getCompositeDir(e);this._syncManager.newCompositeWithAssetId(e,t,r,function(t,r){if(t)return i(t);o._syncNewLibraryWithComposite(e,r,n,i);});}},{key:"unloadLibrary",value:function(e,t){return this._unloadLibrary(e,t);}},{key:"_getLibrariesToUnload",value:function(){var e=this;return this.libraries.filter(function(t){return!e._bookmarkManager.findBookmark(t)||t.isPushedToServer&&!p.getUrlFromLinks(t._dcxComposite.links,d.DISCARD);});}},{key:"_onLibraryPush",value:function(e,t){var n=this,i=function(){!t&&n.libraries.includes(e)||n._bookmarkManager.sync();};t?this._handleExternalPendingDeletes().then(i):i();}},{key:"supportsONSNotifications",get:function(){return!0;}}])&&s(n.prototype,i),o&&s(n,o),t;}(h);e.exports=v;},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var o=n(7),r=function(){function e(t){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._apiRoot=t,this._collections=[],this._listenerManager=new o(["change"],function(e){return n._services.log(e);});}var t,n,r;return t=e,(n=[{key:"getLibraryCollection",value:function(e,t){return this._collections.find(function(n){return n.isPrivate&&n.userId===e&&n.cloudId===t;});}},{key:"getPublicLibraryCollection",value:function(e){return this._collections.find(function(t){return t.isPublic&&t.cloudId===e;});}},{key:"getCollaboratedLibraryCollection",value:function(e){return this._collections.find(function(t){return t.isCollaborated&&t.userId===e;});}},{key:"addLibraryCollection",value:function(e){this._collections.push(e),this._listenerManager.notify("change");}},{key:"removeLibraryCollection",value:function(e){e._dispose();var t=this._collections.indexOf(e);-1!==t&&(this._collections.splice(t,1),this._listenerManager.notify("change"));}},{key:"removeAllLibraryCollections",value:function(){this._collections.forEach(function(e){return e._dispose();}),this._collections=[],this._listenerManager.notify("change");}},{key:"getLoadedCollections",value:function(){return this._collections;}},{key:"addLoadedCollectionsListener",value:function(e){this._listenerManager.add("change",e);}},{key:"removeLoadedCollectionsListener",value:function(e){this._listenerManager.remove("change",e);}},{key:"_services",get:function(){return this._apiRoot._services;}}])&&i(t.prototype,n),r&&i(t,r),e;}();e.exports=r;},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;})(e);}var r=n(4),a="undefined"!==("undefined"==typeof LOCALE_ROOT?"undefined":o(LOCALE_ROOT)),s={photoshop:"LIBS_TOOLKIT_NAME_PHOTOSHOP",photoshop_swatches:"LIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES",photoshop_brushes:"LIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES",photoshop_gradients:"LIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS",photoshop_patterns:"LIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS",photoshop_styles:"LIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES",photoshop_shapes:"LIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES",photoshop_swatches_prerelease:"LIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR",photoshop_brushes_prerelease:"LIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR",photoshop_gradients_prerelease:"LIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR",photoshop_patterns_prerelease:"LIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR",photoshop_styles_prerelease:"LIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR",photoshop_shapes_prerelease:"LIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR"},c=function(){function e(t,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._apiRoot=t,this._localeData={},this._services.hasFileSystem()&&a||(this._localeData={cs_CZ:n(93),da_DK:n(94),de_DE:n(95),en_US:n(96),es_ES:n(97),es_MX:n(98),fi_FI:n(99),fr_CA:n(100),fr_FR:n(101),fr_MA:n(102),hu_HU:n(103),it_IT:n(104),ja_JP:n(105),ko_KR:n(106),nb_NO:n(107),nl_NL:n(108),pl_PL:n(109),pt_BR:n(110),ru_RU:n(111),sv_SE:n(112),tr_TR:n(113),uk_UA:n(114),zh_CN:n(115),zh_TW:n(116)}),this.setLocale(i);}var t,o,c;return t=e,(o=[{key:"_getLocaleData",value:function(e){if(!this._localeData[e]&&this._services.hasFileSystem()&&a)try{this._localeData[e]=this._services.fs.readFileSync("".concat(LOCALE_ROOT).concat(e,"/messages.properties"),"utf8");}catch(e){}return this._localeData[e]||"";}},{key:"_normaliseLocale",value:function(e){var t=(e=e.replace("-","_")).split("_");return t[0]=t[0]&&t[0].toLowerCase(),t[1]=t[1]&&t[1].toUpperCase(),t.join("_");}},{key:"setLocale",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";e=this._normaliseLocale(e),this._getLocaleData(e)||(e="en_US"),this._locale=e,this._strings=r.parseLocalisationFile(this._getLocaleData(e));}},{key:"getLocale",value:function(){return this._locale;}},{key:"translate",value:function(e,t){var n=this._strings[e];return n&&t&&(n=r.constructStringFromTemplate(n,t)),n||e;}},{key:"getToolkitName",value:function(e){return this.translate(s[e]||"LIBS_TOOLKIT_NAME_DEFAULT");}},{key:"_services",get:function(){return this._apiRoot._services;}}])&&i(t.prototype,o),c&&i(t,c),e;}();e.exports=c;},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Vaše knihovna\nLIBS_RECOVERED_LIBRARY={{name}} (obnoveno)\nLIBS_TOOLKIT_NAME_DEFAULT=Vaše sada nástrojů\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Vaše knihovna aplikace Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Vaše vzorníky v aplikaci Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Vaše štětce v aplikaci Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Vaše přechody v aplikaci Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Vaše vzory v aplikaci Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Vaše styly v aplikaci Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Vaše tvary v aplikaci Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=Vzorky barev předběžné verze aplikace Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=Štětce předběžné verze aplikace Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=Přechody předběžné verze aplikace Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=Vzory předběžné verze aplikace Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=Styly předběžné verze aplikace Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=Tvary předběžné verze aplikace Ps";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Dit bibliotek\nLIBS_RECOVERED_LIBRARY={{name}} (Gendannet)\nLIBS_TOOLKIT_NAME_DEFAULT=Din værktøjspakke\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Dit Photoshop-bibliotek\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Dine Photoshop-farveprøver\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Dine Photoshop-pensler\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Dine Photoshop-farveforløb\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Dine Photoshop-mønstre\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Dine Photoshop-typer\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Dine Photoshop-former\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=Dine Ps Prerelease-farveprøver\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=Dine Ps Prerelease-pensler\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=Dine Ps Prerelease-farveforløb\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=Dine Ps Prerelease-mønstre\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=Dine Ps Prerelease-typer\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=Dine Ps Prerelease-former";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Ihre Bibliothek\nLIBS_RECOVERED_LIBRARY={{name}} (Wiederhergestellt)\nLIBS_TOOLKIT_NAME_DEFAULT=Ihr Toolkit\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Ihre Photoshop-Bibliothek\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Ihre Photoshop-Farbfelder\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Ihre Photoshop-Pinsel\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Ihre Photoshop-Verläufe\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Ihre Photoshop-Muster\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Ihre Photoshop-Stile\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Ihre Photoshop-Formen\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=Ihre Ps Prerelease-Farbfelder\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=Ihre Ps Prerelease-Pinsel\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=Ihre Ps Prerelease-Verläufe\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=Ihre Ps Prerelease-Muster\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=Ihre Ps Prerelease-Stile\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=Ihre Ps Prerelease-Formen";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Your Library\nLIBS_RECOVERED_LIBRARY={{name}} (Recovered)\nLIBS_TOOLKIT_NAME_DEFAULT=Your Toolkit\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Your Photoshop Library\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Your Photoshop Swatches\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Your Photoshop Brushes\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Your Photoshop Gradients\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Your Photoshop Patterns\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Your Photoshop Styles\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Your Photoshop Shapes\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=Your Ps Prerelease Swatches\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=Your Ps Prerelease Brushes\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=Your Ps Prerelease Gradients\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=Your Ps Prerelease Patterns\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=Your Ps Prerelease Styles\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=Your Ps Prerelease Shapes";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Su biblioteca\nLIBS_RECOVERED_LIBRARY={{name}} (recuperado)\nLIBS_TOOLKIT_NAME_DEFAULT=Su kit de herramientas\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Su biblioteca de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Sus muestras de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Sus pinceles de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Sus degradados de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Sus motivos de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Sus estilos de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Sus formas de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=Sus muestras de la versión previa de Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=Sus pinceles de la versión previa de Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=Sus degradados de la versión previa de Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=Sus motivos de la versión previa de Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=Sus estilos de la versión previa de Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=Sus formas de la versión previa de Ps";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Su biblioteca\nLIBS_RECOVERED_LIBRARY={{name}} (recuperado)\nLIBS_TOOLKIT_NAME_DEFAULT=Su kit de herramientas\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Su biblioteca de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Sus muestras de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Sus pinceles de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Sus degradados de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Sus motivos de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Sus estilos de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Sus formas de Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=Sus muestras de la versión previa de Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=Sus pinceles de la versión previa de Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=Sus degradados de la versión previa de Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=Sus motivos de la versión previa de Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=Sus estilos de la versión previa de Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=Sus formas de la versión previa de Ps";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Oma kirjasto\nLIBS_RECOVERED_LIBRARY={{name}} (palautettu)\nLIBS_TOOLKIT_NAME_DEFAULT=Oma työkalusarja\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Oma Photoshop-kirjasto\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Omat Photoshop-värimallit\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Omat Photoshop-siveltimet\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Omat Photoshop-liukuvärit\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Omat Photoshop-kuviot\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Omat Photoshop-tyylit\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Omat Photoshop-muodot\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=Omat Ps Prerelease -värimallit\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=Omat Ps Prerelease -siveltimet\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=Omat Ps Prerelease -liukuvärit\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=Omat Ps Prerelease -kuviot\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=Omat Ps Prerelease -tyylit\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=Omat Ps Prerelease -muodot";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Votre bibliothèque\nLIBS_RECOVERED_LIBRARY={{name}} (Récupéré)\nLIBS_TOOLKIT_NAME_DEFAULT=Votre boîte à outils\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Votre bibliothèque Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Vos nuances Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Vos pinceaux Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Vos dégradés Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Vos motifs Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Vos styles Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Vos formes Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=Vos nuances Version préliminaire Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=Vos pinceaux Version préliminaire Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=Vos dégradés Version préliminaire Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=Vos motifs Version préliminaire Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=Vos styles Version préliminaire Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=Vos formes Version préliminaire Ps";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Votre bibliothèque\nLIBS_RECOVERED_LIBRARY={{name}} (Récupéré)\nLIBS_TOOLKIT_NAME_DEFAULT=Votre boîte à outils\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Votre bibliothèque Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Vos nuances Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Vos pinceaux Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Vos dégradés Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Vos motifs Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Vos styles Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Vos formes Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=Vos nuances Version préliminaire Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=Vos pinceaux Version préliminaire Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=Vos dégradés Version préliminaire Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=Vos motifs Version préliminaire Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=Vos styles Version préliminaire Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=Vos formes Version préliminaire Ps";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Votre bibliothèque\nLIBS_RECOVERED_LIBRARY={{name}} (Récupéré)\nLIBS_TOOLKIT_NAME_DEFAULT=Votre boîte à outils\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Votre bibliothèque Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Vos nuances Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Vos pinceaux Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Vos dégradés Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Vos motifs Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Vos styles Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Vos formes Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=Vos nuances Version préliminaire Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=Vos pinceaux Version préliminaire Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=Vos dégradés Version préliminaire Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=Vos motifs Version préliminaire Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=Vos styles Version préliminaire Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=Vos formes Version préliminaire Ps";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Az Ön könyvtára\nLIBS_RECOVERED_LIBRARY={{name}} (helyreállított)\nLIBS_TOOLKIT_NAME_DEFAULT=Az Ön eszköztára\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Az Ön Photoshop könyvtára\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Az Ön Photoshop színtárai\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Az Ön Photoshop ecsetei\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Az Ön Photoshop színátmenetei\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Az Ön Photoshop mintái\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Az Ön Photoshop stílusai\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Az Ön Photoshop alakzatai\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=PS előzetes kiadás – színtárak\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=PS előzetes kiadás – ecsetek\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=PS előzetes kiadás – színátmenetek\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=PS előzetes kiadás – minták\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=PS előzetes kiadás – stílusok\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=PS előzetes kiadás – alakzatok";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Libreria\nLIBS_RECOVERED_LIBRARY={{name}} (recuperato)\nLIBS_TOOLKIT_NAME_DEFAULT=Il vostro toolkit\nLIBS_TOOLKIT_NAME_PHOTOSHOP=La vostra Libreria Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Campioni di Photoshop personali\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Pennelli di Photoshop personali\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Sfumature di Photoshop personali\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Pattern di Photoshop personali\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Stili di Photoshop personali\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Forme di Photoshop personali\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=I campioni Ps Prerelease\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=I pennelli Ps Prerelease\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=Le sfumature Ps Prerelease\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=I pattern Ps Prerelease\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=Gli stili Ps Prerelease\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=Le forme Ps Prerelease";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=ライブラリ\nLIBS_RECOVERED_LIBRARY={{name}} (回復済み)\nLIBS_TOOLKIT_NAME_DEFAULT=自分の Toolkit\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Photoshop ライブラリ\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=あなたの Photoshop スウォッチ\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=あなたの Photoshop ブラシ\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=あなたの Photoshop グラデーション\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=あなたの Photoshop パターン\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=あなたの Photoshop スタイル\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=あなたの Photoshop シェイプ\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=Ps プレリリースのサンプル\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=Ps プレリリースのブラシ\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=Ps プレリリースのグラデーション\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=Ps プレリリースのパターン\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=Ps プレリリースのスタイル\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=Ps プレリリースのシェイプ";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=귀하의 라이브러리\nLIBS_RECOVERED_LIBRARY={{name}}(복구됨)\nLIBS_TOOLKIT_NAME_DEFAULT=툴킷\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Photoshop Library\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Photoshop 견본\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Photoshop 브러시\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Photoshop 그래디언트\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Photoshop 패턴\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Photoshop 스타일\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Photoshop 모양\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=Ps 사전 릴리스 견본\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=Ps 사전 릴리스 브러시\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=Ps 사전 릴리스 그래디언트\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=Ps 사전 릴리스 패턴\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=Ps 사전 릴리스 스타일\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=Ps 사전 릴리스 모양";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Ditt bibliotek\nLIBS_RECOVERED_LIBRARY={{name}} (gjenopprettet)\nLIBS_TOOLKIT_NAME_DEFAULT=Ditt verktøysett\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Ditt Photoshop-bibliotek\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Dine Photoshop-fargekart\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Dine Photoshop-pensler\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Dine Photoshop-graderinger\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Dine Photoshop-mønstre\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Dine Photoshop-stiler\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Dine Photoshop-former\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=Dine forhåndsutgivelsesfargekart for Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=Dine forhåndsutgivelsespensler for Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=Dine forhåndsutgivelsesgraderinger for Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=Dine forhåndsutgivelsesmønstre for Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=Dine forhåndsutgivelsesstiler for Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=Dine forhåndsutgivelsesformer for Ps";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Uw bibliotheek\nLIBS_RECOVERED_LIBRARY={{name}} (hersteld)\nLIBS_TOOLKIT_NAME_DEFAULT=Uw toolkit\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Uw Photoshop-bibliotheek\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Uw Photoshop-stalen\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Uw Photoshop-penselen\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Uw Photoshop-verlopen\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Uw Photoshop-patronen\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Uw Photoshop-stijlen\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Uw Photoshop-vormen\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=Ps Prerelease-stalen\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=Ps Prerelease-penselen\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=Ps Prerelease-verlopen\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=Ps Prerelease-patronen\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=Ps Prerelease-stijlen\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=Ps Prerelease-vormen";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Twoja biblioteka\nLIBS_RECOVERED_LIBRARY={{name}} (Odzyskane)\nLIBS_TOOLKIT_NAME_DEFAULT=Twój zestaw narzędzi\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Biblioteka programu Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Próbki programu Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Pędzle programu Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Gradienty programu Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Wzory programu Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Style programu Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Kształty programu Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=Próbki we wstępnym wydaniu Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=Pędzle we wstępnym wydaniu Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=Gradienty we wstępnym wydaniu Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=Wzory we wstępnym wydaniu Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=Style we wstępnym wydaniu Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=Kształty we wstępnym wydaniu Ps";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Sua biblioteca\nLIBS_RECOVERED_LIBRARY={{name}} (Recuperado)\nLIBS_TOOLKIT_NAME_DEFAULT=Seu kit de ferramentas\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Sua biblioteca do Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Suas amostras do Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Seus pincéis do Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Seus gradientes do Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Seus padrões do Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Seus estilos do Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Suas formas do Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=Suas amostras de pré-lançamento do Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=Seus pincéis de pré-lançamento do Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=Seus gradientes de pré-lançamento do Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=Seus padrões de pré-lançamento do Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=Seus estilos de pré-lançamento do Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=Suas formas de pré-lançamento do Ps";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Ваша библиотека\nLIBS_RECOVERED_LIBRARY={{name}} (восстановлено)\nLIBS_TOOLKIT_NAME_DEFAULT=Инструменты\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Библиотека Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Ваши образцы Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Ваши кисти Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Ваши градиенты Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Ваши узоры Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Ваши стили Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Ваши фигуры Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=Ваши образцы предв. версии Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=Ваши кисти предв. версии Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=Ваши градиенты предв. версии Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=Ваши узоры предв. версии Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=Ваши стили предв. версии Ps\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=Ваши фигуры предв. версии Ps";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Ditt bibliotek\nLIBS_RECOVERED_LIBRARY={{name}} (återskapet)\nLIBS_TOOLKIT_NAME_DEFAULT=Ditt Toolkit\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Ditt Photoshop-bibliotek\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Dina Photoshop-färgrutor\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Dina Photoshop-penslar\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Dina Photoshop-övertoningar\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Dina Photoshop-mönster\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Dina Photoshop-format\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Dina Photoshop-former\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=Färgrutor i den tidiga Ps-versionen\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=Penslar i den tidiga Ps-versionen\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=Övertoningar i den tidiga Ps-versionen\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=Mönster i den tidiga Ps-versionen\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=Format i den tidiga Ps-versionen\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=Former i den tidiga Ps-versionen";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Kitaplığınız\nLIBS_RECOVERED_LIBRARY={{name}} ((Kurtarıldı))\nLIBS_TOOLKIT_NAME_DEFAULT=Araç Setiniz\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Photoshop Kitaplığınız\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Photoshop Renk Örnekleriniz\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Photoshop Fırçalarınız\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Photoshop Degradeleriniz\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Photoshop Desenleriniz\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Photoshop Stilleriniz\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Photoshop Şekilleriniz\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=Ps Ön Sürüm Renk Örnekleriniz\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=Ps Ön Sürüm Fırçalarınız\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=Ps Ön Sürüm Degradeleriniz\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=Ps Ön Sürüm Desenleriniz\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=Ps Ön Sürüm Stilleriniz\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=Ps Ön Sürüm Şekilleriniz";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=Ваша бібліотека\nLIBS_RECOVERED_LIBRARY={{name}} (відновлено)\nLIBS_TOOLKIT_NAME_DEFAULT=Мій інструментарій\nLIBS_TOOLKIT_NAME_PHOTOSHOP=Моя бібліотека Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=Ваші зразки робіт, створені за допомогою Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=Ваші пензлі Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=Ваші градієнти Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=Ваші візерунки Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=Ваші стилі Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=Ваші фігури Photoshop\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=Ваші зразки Ps, доступні напередодні випуску\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=Ваші пензлі Ps, доступні напередодні випуску\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=Ваші градієнти Ps, доступні напередодні випуску\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=Ваші візерунки Ps, доступні напередодні випуску\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=Ваші стилі Ps, доступні напередодні випуску\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=Ваші фігури Ps, доступні напередодні випуску";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=您的库\nLIBS_RECOVERED_LIBRARY={{name}} （已恢复）\nLIBS_TOOLKIT_NAME_DEFAULT=您的工具箱\nLIBS_TOOLKIT_NAME_PHOTOSHOP=您的 Photoshop 库\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=您的 Photoshop 色板\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=您的 Photoshop 画笔\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=您的 Photoshop 渐变\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=您的 Photoshop 图案\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=您的 Photoshop 样式\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=您的 Photoshop 形状\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=您的 PS Prerelease 色板\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=您的 PS Prerelease 画笔\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=您的 PS Prerelease 渐变\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=您的 PS Prerelease 图案\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=您的 PS Prerelease 样式\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=您的 PS Prerelease 形状";},function(e,t){e.exports="LIBS_DEFAULT_LIBRARY_NAME=您的資料庫\nLIBS_RECOVERED_LIBRARY={{name}} (已復原)\nLIBS_TOOLKIT_NAME_DEFAULT=您的工具組。\nLIBS_TOOLKIT_NAME_PHOTOSHOP=您的 Photoshop 資料庫\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES=您的 Photoshop 色票\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES=您的 Photoshop 筆刷\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS=您的 Photoshop 漸層\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS=您的 Photoshop 圖樣圖樣\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES=您的 Photoshop 樣式\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES=您的 Photoshop 形狀\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SWATCHES_PR=您的 Ps 預先發佈色票\nLIBS_TOOLKIT_NAME_PHOTOSHOP_BRUSHES_PR=您的 Ps 預先發佈筆刷\nLIBS_TOOLKIT_NAME_PHOTOSHOP_GRADIENTS_PR=您的 Ps 預先發佈漸層\nLIBS_TOOLKIT_NAME_PHOTOSHOP_PATTERNS_PR=您的 Ps 預先發佈圖樣\nLIBS_TOOLKIT_NAME_PHOTOSHOP_STYLES_PR=您的 Ps 預先發佈樣式\nLIBS_TOOLKIT_NAME_PHOTOSHOP_SHAPES_PR=您的 Ps 預先發佈形狀";},function(e,t,n){function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}function o(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e;}var a=n(12),s=n(13),c=n(32),l=n(44),u=n(45),_=n(17),h=n(2),p=n(118),d=n(119),f=n(120),m=n(6),v=n(4).promisify,y=function(e){return{isCollaborated:e.isCollaborated,isPublic:e.isPublic,userId:e.userId,cloudId:e.cloudId};},g=function(e){return{id:e.id};},E=function(e,t){return Object.assign(y(e.collection),r({},t||"id",e.id));},O=function(e,t,n){return Object.assign(E(e.library,n),r({},t||"element",e.id));},S=function(e){return Object.assign(O(e.element),{representation:e.id});},A=["bmp","cur","gif","ico","jpeg","jpg","png","psd","tiff","tif","webp","svg","dds"],T=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this,e),this._apiRoot=t,this._acceptPushedBranchListeners=[],this._downloadRenditionListeners=[],this._rootListeners=[],this._baseBranches={},this._portDiagnosis="UNKNOWN",this._logIndex=0,this._connectedCallback=n.onConnected||function(){},this._config.addChangeListener(this.updateConfiguration.bind(this)),this._config.SHARED_LOCAL_STORAGE&&(this._connect(),this.fs=new f(this),this._services.hasFileSystem()||this._services.setFileSystem(this.fs));}var t,n,r;return t=e,(n=[{key:"_getBase",value:function(e){var t=this._baseBranches[e];return t&&t.base;}},{key:"_setBase",value:function(e,t){this._baseBranches[e]=this._baseBranches[e]||{},this._baseBranches[e].base=t;}},{key:"_getLogIndex",value:function(){return this._logIndex++;}},{key:"_getServicePort",value:function(e){var t=this._config.VULCAN_PREFIX+this._config.VULCAN_QUERY_REQUEST,n=this._config.VULCAN_PREFIX+this._config.VULCAN_QUERY_RESPONSE,i=function(t){var n;try{n=JSON.parse(t);}catch(e){}n?e(null,n):e("NO_DATA");};if(this._services.vulcanCall)this._services.vulcanCall(t,"",n,i);else if(this._services.hasCEPVulcan()){var o,r=this._services.getVulcanInterface(),a=this._services.getVulcanMessage(),s=function t(a){r.removeMessageListener(n,t),clearTimeout(o),a?i(r.getPayload(a)):e("NO_VULCAN_MESSAGE");};r.addMessageListener(n,s),o=setTimeout(s,this._config.VULCAN_QUERY_TIMEOUT);var c=new a(t);c.setPayload(""),r.dispatchMessage(c);}}},{key:"_connectToPort",value:function(e,t){var n=this,i=t&&t.port,o=t&&t.token,r=t&&t.domain;if(this._portDiagnosis=t?t.portdiagnosis:"UNKNOWN",this._connectionPort=i,!this._channel){if(!i||"SIMPLE_HOSTNAME_GOING_TO_PROXY"===this._portDiagnosis)return this._onConnect(e);try{var a=function(e){return n._services.log(e);},s=new d(i,o,r,this._config.SHARED_LOCAL_STORAGE_VERSION,a);this._channel=new p(this._apiRoot,s),this._channel.setLogCallback(a);}catch(e){return this._onConnect(e);}this._channel.addListener("environmentinfo",this._onEnvironmentInfo.bind(this)),this._channel.addListener("collectionadded",this._onCollectionAdded.bind(this)),this._channel.addListener("collectionremoved",this._onCollectionRemoved.bind(this)),this._channel.addListener("clearcollections",this._onClearCollections.bind(this)),this._channel.addListener("syncstate",this._onSyncState.bind(this)),this._channel.addListener("librarychange",this._onLibraryChange.bind(this)),this._channel.addListener("renditioncachechange",this._onRenditionCacheChange.bind(this)),this._channel.addListener("librarydeleted",this._onLibraryDeleted.bind(this)),this._channel.addListener("bookmarkschanged",this._onBookmarksChanged.bind(this)),this._channel.addListener("folderschanged",this._onFoldersChanged.bind(this)),this._channel.addListener("fontcachechanged",this._onFontCacheChanged.bind(this)),this._channel.addListener("operationschanged",this._onOperationsChanged.bind(this)),this._channel.onOpen(function(){n._services.log("Websocket opened"),n._isConnected=!0,n._sendConfiguration(),n._onConnect();}),this._channel.onClose(function(){n._services.log("Websocket closed"),n._onDisconnect();}),this._channel.onError(function(e){n._services.log("Websocket error: ".concat(e)),n._onDisconnect();});}}},{key:"_connect",value:function(){this._getServicePort(this._connectToPort.bind(this));}},{key:"_onConnect",value:function(e){!this._channel||e?this._connectedCallback(new h(h.CLIENT_CONNECTION_ERROR,"Error creating message channel",e)):this._connectedCallback();}},{key:"_onDisconnect",value:function(){this._channel&&(this._channel.shutdown(),this._channel=void 0),this._isConnected=!1,this._collectionManager.removeAllLibraryCollections();}},{key:"_sendConfiguration",value:function(){this._channel.send("configure",{CLIENT_DESCRIPTION:this._config.CLIENT_DESCRIPTION,RENDITION_SIZES:this._config.RENDITION_SIZES,FULL_RENDITION_CONFIG:this._config.FULL_RENDITION_CONFIG,LOCAL_SETTINGS:this._config.LOCAL_SETTINGS});}},{key:"_onEnvironmentInfo",value:function(e){var t=!this._serviceInfo||!this._serviceInfo.syncingEnabled;this._serviceInfo=e,e.allowedDomains&&(this._config.ALLOWED_DOMAINS=e.allowedDomains),e.elementActionProductMap&&this._config.updateElementActionMap(this._getServiceVersion(),e.elementActionProductMap),e.documentLibraryActionProductMap&&(this._config.DOCUMENT_LIBRARY_ACTION_PRODUCT_MAP=e.documentLibraryActionProductMap),e.deviceId&&(this._config.DEVICE_ID=e.deviceId),e.deviceDescription&&(this._config.DEVICE_DESCRIPTION=e.deviceDescription),e.maxElements&&(this._config.MAX_ELEMENTS=e.maxElements),e.maxRemovedElements&&(this._config.MAX_REMOVED_ELEMENTS=e.maxRemovedElements),e.maxDocumentationElements&&(this._config.MAX_DOCUMENTATION_ELEMENTS=e.maxDocumentationElements),e.maxComponentSize&&(this._config.MAX_COMPONENT_SIZE=e.maxComponentSize),e.localSettings&&(this._config.LOCAL_SETTINGS=e.localSettings),e.shaCache&&(this._config.SHA_CACHE=e.shaCache),e.defaultContentLocations&&(this._config.DEFAULT_CONTENT_LOCATIONS=e.defaultContentLocations),e.analyticsEnabled&&(this._config.ANALYTICS_ENABLED=e.analyticsEnabled),this._collectionManager._collections.forEach(function(n){e.syncingEnabled&&t&&(n._syncState="ok"),n._listenerManager.notify("sync");}),this._config._listenerManager.notify("change");}},{key:"_onCollectionAdded",value:function(e){var t=this;this._config.ROOT_DIR=e.rootDir;var n,i={USER_ID:e.userId,CLOUD_ID:e.cloudId,STORAGE_HOSTNAME:e.storageHost,CC_LIBRARY_SERVICE_HOSTNAME:e.cclibsHost,CC_IMAGE_HOSTNAME:e.imageHost,CC_IMAGE_X_HOSTNAME:e.imageXHost,TYPEKIT_HOSTNAME:e.typekitHost,REQUIRES_COMMUNITY_SESSION:e.requiresCommunitySession},o=this._collectionManager.getLoadedCollections().find(function(t){return t.isPrivate&&t.userId===e.userId;});n=e.isPublic?new u(this._apiRoot,i,o):e.isCollaborated?new l(this._apiRoot,i,o):new c(this._apiRoot,i);var r=v(this.loadExistingLibrary.bind(this));Promise.all(e.libraries.map(function(e){return r(n,e.id,e.path,e.manifest,e.deletedFromServer,e.renditionCache);})).then(function(){return t._collectionManager.addLibraryCollection(n);});}},{key:"_getLibraryCollection",value:function(e){return e.isPublic?this._collectionManager.getPublicLibraryCollection(e.cloudId):e.isCollaborated?this._collectionManager.getCollaboratedLibraryCollection(e.userId):this._collectionManager.getLibraryCollection(e.userId,e.cloudId);}},{key:"_onCollectionRemoved",value:function(e){var t=this._getLibraryCollection(e);t&&this._collectionManager.removeLibraryCollection(t);}},{key:"_onClearCollections",value:function(){this._collectionManager.removeAllLibraryCollections();}},{key:"_onSyncState",value:function(e){var t=this._getLibraryCollection(e);t&&(t._userQuota=e.quota,t._syncState=e.state,t._syncProgress=e.progress,t._syncProgressMap=e.progressMap,t._externalLinkDownloadProgressMap=e.externalLinkDownloadProgressMap||{},t._newLibraryProgress=e.newLibraryProgress,t._initialSyncInProgress=e.initialSyncInProgress,t._syncErrors=[],e.errors.forEach(function(e){t._syncErrors.push(new h(e.code,e.message,e.libraryId));}),e.libraryStates.forEach(function(e){var n=t.getLibraryById(e.id);n&&(n._syncState=e.state);}),t._listenerManager.notify("sync"));}},{key:"_onLibraryChange",value:function(e){var t=this._getLibraryCollection(e);if(t){var n=t.getLibraryById(e.id);n?(this._services.log("onLibraryChange: "+n.id),n._deletedFromServer!==e.deletedFromServer&&(n._deletedFromServer=e.deletedFromServer,n._notifyChange()),e.renditionCache=e.renditionCache||{},n._renditionCache.replaceCache(e.renditionCache),this.updateExistingLibrary(t,n,e.manifest,void 0,this._getBase(n.id),function(){n._renditionCache.replaceCache(e.renditionCache);})):this.loadExistingLibrary(t,e.id,e.path,e.manifest,e.deletedFromServer,e.renditionCache);}}},{key:"_onRenditionCacheChange",value:function(e){var t=this._getLibraryCollection(e),n=t&&t.getLibraryById(e.id),i=n&&n.getElementById(e.elementId);i&&e.renditionCache&&(n._renditionCache.replaceElementCache(i,e.renditionCache),i._listenerManager.notify("change"));}},{key:"_onOperationsChanged",value:function(e){var t=this._getLibraryCollection(e),n=e.operations,i={};n.forEach(function(e){t._updateOperation(e.id,e.type,e.data,e.progress),i[e.id]=!0;}),Object.keys(t._operationIdMap).forEach(function(e){i[e]||t._delayedRemoveOperation(t._operationIdMap[e]);});}},{key:"_onLibraryDeleted",value:function(e){var t=this._getLibraryCollection(e),n=t&&t.getLibraryById(e.id);if(n){this._services.log("deleteLibrary");var i=t._libraries.indexOf(n);-1!==i&&(t._libraries.splice(i,1),delete t._libraryIdMap[n.id]),n._markDeletedLocally(!0),t._notifyChange(!0);}}},{key:"_onBookmarksChanged",value:function(e){var t=this._getLibraryCollection(e);t&&e.bookmarks&&t._bookmarkManager._deserialize(e.bookmarks);}},{key:"_onFoldersChanged",value:function(e){var t=this._collectionManager.getLoadedCollections().find(function(e){return e.isPrivate;});t&&e&&t._platformManager._fromJSON(e);}},{key:"_onFontCacheChanged",value:function(e){var t=this._getLibraryCollection(e);t&&t.fontManager&&t.fontManager._clearCache();}},{key:"_loadBranch",value:function(e,t,n){try{var i=new s(void 0,n).parse(t);return i._localStorage=e._localStorage,i;}catch(e){}}},{key:"_addLibrary",value:function(e,t,n,i,o){n=n||e._getCompositeDir(t);var r=new a(null,null,n,null,null,{preserveFileExtensions:!0}),s=this._loadBranch(r,i,!1);if(s){if("pendingDelete"!==s.compositeState&&"pendingDiscard"!==s.compositeState){r._current=s,this._setBase(t,i);var c=new _(e,r,e.isPublic&&t);e._libraries.push(c),e._libraryIdMap[c.id]=c,e._notifyChange(!0),o(null,c);}else o(null);}else o(new h(h.CORRUPTED_LIBRARY,"Library corrupted in local storage",t));}},{key:"isConnected",value:function(){return this._isConnected;}},{key:"reconnect",value:function(){this._channel||this._connect();}},{key:"shutdown",value:function(){this._onDisconnect();}},{key:"getServiceInfo",value:function(){return this._serviceInfo?{updateRequired:this._serviceInfo.updateRequired,version:this._serviceInfo.codeVersion,buildNumber:this._serviceInfo.buildNumber,apiVersion:this._serviceInfo.version,environment:this._serviceInfo.environment,syncingEnabled:this._serviceInfo.syncingEnabled,portDiagnosis:this._portDiagnosis,connectionPort:this._connectionPort}:{portDiagnosis:this._portDiagnosis,connectionPort:this._connectionPort};}},{key:"updateConfiguration",value:function(){this._config.SHARED_LOCAL_STORAGE&&this._channel&&this._isConnected&&this._sendConfiguration();}},{key:"sync",value:function(e){this._channel.send("sync",y(e));}},{key:"setSyncEnabled",value:function(e){this._channel.send("configuresync",{enable:e});}},{key:"commitManifest",value:function(e,t){var n=this;if(this._config.SHARED_LOCAL_STORAGE){var i=e._dcxBranch.localData,o=e._renditionCache.doRequestSetCache(),r=E(e);r.current=i,r.base=this._getBase(e.id),r.renditions=o.data,this._services.log("Start commit"),this._channel.call("commit",r,function(a){n._services.log("Finish commit: "+(a.success?"success":"fail")),a.success?(n._services.log("Update base after commit"),n._setBase(e.id,i),a.renditions&&o.complete(a.renditions).forEach(function(e){return e._listenerManager.notify("change");})):(o.cancel(),e._waitForCommit(function(){n.notifyStartWrite(e,[],function(){e._deletedFromServer=a.deletedFromServer,n.updateExistingLibrary(e.collection,e,a.manifest,void 0,r.base,function(){e._commit(!0,!0);});});})),t(null,a.success);});}else e._dcxLock.obtain(function(){e._gcLocalData(function(){e._dcxComposite.commitChanges(function(n){e._dcxLock.release(),e._renditionCache.gc(),t(n,!0);});});});}},{key:"resolvePullWithBranch",value:function(e,t,n,i,o){var r=this;this._services.log("resolvePullWithBranch"),this._config.SHARED_LOCAL_STORAGE?(e._dcxComposite._current=t,this._setBase(e.id,n),this._services.log("Finished resolvePullWithBranch: shared local storage"),o(),e._unblockCommits()):i?e._dcxLock.obtain(function(){e._dcxComposite._current=t,e._dcxLock.release(),r._services.log("Finished resolvePullWithBranch: local merge"),o();}):e._dcxLock.obtain(function(){e._dcxComposite.resolvePullWithBranch(t,function(t,n){e._dcxLock.release(),e._commit(!0,!0),e._waitForCommit(function(){r._services.log("Finished resolvePullWithBranch: remote merge"),o(t,n);});});});}},{key:"acceptPush",value:function(e,t){var n=this;this._services.log("acceptPush"),e._dcxLock.obtain(function(){e._dcxComposite.acceptPush(function(i){e._dcxLock.release(),n._services.log("Finished acceptPush"),n._acceptPushedBranchListeners.forEach(function(t){return t(e);}),t(i);});});}},{key:"onAcceptPushedBranch",value:function(e){this._acceptPushedBranchListeners.push(e);}},{key:"removeOnAcceptPushedBranchListeners",value:function(){this._acceptPushedBranchListeners=[];}},{key:"createNewLibrary",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){};this._services.log("createNewLibrary"),this._addLibrary(e,t,void 0,n,function(e,t){!e&&t?(t._commit(!1,!0),t._waitForCommit(i)):i(e);});}},{key:"loadExistingLibrary",value:function(e,t,n,i,o,r){var a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:function(){};this._services.log("loadExistingLibrary"),this._addLibrary(e,t,void 0,i,function(e,t){!e&&t?(t._deletedFromServer=o,r&&t._renditionCache.replaceCache(r),a(null,t)):a(e);});}},{key:"updateExistingLibrary",value:function(e,t,n,i,o){var r=this,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:function(){},s="updateExistingLibrary["+this._getLogIndex()+"]: ",c=function(e){var i=m.getManifestForComparison(t,n);return m.areManifestsEqual(i,e);};if(c(n))return this._services.log(s+"already up-to-date"),void a();var l=this._loadBranch(t._dcxComposite,n,!1);if(this._services.log(s+"changes to update (state = "+(l&&l.compositeState)+")"),l){var u=m.ensureBranchDataValid(l);if(this._services.log(s+"fixed branch data: "+u),"pendingDelete"===l.compositeState||"pendingDiscard"===l.compositeState)return e._doRemoveLibrary(t),void a();t._waitForCommit(function(){if(i){if(!c(i))return r._services.log(s+"Commit aborting: something changed and it's no longer a fast-forward"),void a(!0);}else i=r._getBase(t.id);if(o&&i!==o)return r._services.log(s+"Commit aborting: base manifest changed before we got chance to update!"),void a(!0);var e=r._loadBranch(t._dcxComposite,i,!0)||l;r._services.log(s+"base "+e.changeCount+" -> updated "+l.changeCount),t._mergeAndSwitchToBranch(l,e,function(){r._services.log(s+"finished merge"),r._config.SHARED_LOCAL_STORAGE?a(null):(t._commit(!1,!0),t._waitForCommit(a));});});}else a(new h(h.CORRUPTED_LIBRARY,"Invalid manifest",t.id));}},{key:"getRenditionPath",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=e.library._renditionCache.getCache(e,t||"full");if(r)i(null,r);else{var a=O(e);a.size=t,this._services.log("Get rendition path from CCLibrary process"),this._channel.call("getrenditionpath",a,function(r){if(!r&&o<n._config.LOCAL_RENDITION_MAX_RETRIES)return n._services.log("getrenditionpath: rendition not found"),void setTimeout(function(){return n.getRenditionPath(e,t,i,o+1);},n._config.LOCAL_RENDITION_RETRY_INTERVAL);i(null,r);});}}},{key:"notifyDownloadRendition",value:function(e){this._downloadRenditionListeners.forEach(function(t){return t(e);}),e._listenerManager.notify("change");}},{key:"onDownloadRendition",value:function(e){this._downloadRenditionListeners.push(e);}},{key:"removeOnDownloadRenditionListeners",value:function(){this._downloadRenditionCacheListeners=[];}},{key:"notifyStartWrite",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){};if(this._config.SHARED_LOCAL_STORAGE){var i=E(e);i.dependencies=t.map(function(e){return E(e);}),this._channel.call("startcomponentwrite",i,function(){return n(null);});}else n(null);}},{key:"refreshPlatformFolders",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){};this._channel.call("refreshplatformfolders",{},function(){return e(null);});}},{key:"downloadURL",value:function(e,t,n,i,o){if(this._config.SHARED_LOCAL_STORAGE){var r=y(e);r.url=t,r.headers=n,r.tempDir=i,this._channel.call("downloadfile",r,function(e){o(e.err,e.tempFilePath,e.etag,{headers:e.responseHeaders});});}else e._syncManager.links.download(t,n,i,void 0,o);}},{key:"testURL",value:function(e,t,n){this._config.SHARED_LOCAL_STORAGE?n(null):e._syncManager.links.test(t,n);}},{key:"downloadExternalLink",value:function(e,t){this._services.log("Download external link from CCLibrary process"),this._channel.call("downloadexternallink",S(e),function(e){return t(e.err,e.path);});}},{key:"testExternalLink",value:function(e,t){this._services.log("Test external link via CCLibrary process"),this._channel.call("testexternallink",S(e),function(e){return t(e.err,e.success);});}},{key:"clearCachedExternalLink",value:function(e){this._services.log("Clear cached external link via CCLibrary process"),this._channel.send("clearcachedexternallink",S(e));}},{key:"createBookmark",value:function(e,t,n,i,o){var r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:function(){},a=y(e);a.type=t,a.id=n,a.data=i,a.condition=o,this._channel.call("createBookmark",a,function(e){var t=e&&e.err,n=e&&e.bookmarks;r(t,n);});}},{key:"removeBookmark",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){},o=y(e);o.id=t.id,o.removeCollaboration=n,this._channel.call("removeBookmark",o,function(e){return i(e);});}},{key:"sendAction",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},n={element:function(){return O(e.element,"elementId","libraryId");},library:function(){return E(e.library,"libraryId");}}[e.type],i=n?n():{};i.appCode=e.appCode,i.minVersion=e.minAppVersion,i.action=e.id,this._channel.call("performAction",i,function(e){return t(e.err,e.data);});}},{key:"getImageDimensions",value:function(e,t){var n=this._services.fileUtils.getFileExtension(e);!n||A.includes(n)?this._config.SHARED_LOCAL_STORAGE?this._channel.call("getImageDimensions",e,function(e){return t(e.data);}):this._services.imageSize(e,function(e,n){return t(n);}):t();}},{key:"importLibrary",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){},o=y(e);o.path=t,o.operationId=n,this._channel.call("importlibrary",o,function(t){i(t.err,e.getLibraryById(t.libraryId));});}},{key:"exportLibrary",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){},o=E(e);o.path=t,o.operationId=n,this._channel.call("exportlibrary",o,function(e){return i(e.err);});}},{key:"cancelOperation",value:function(e,t){var n=y(e);n.operationId=t,this._channel.send("canceloperation",n);}},{key:"moveLibrary",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},i=this._collectionManager.getLoadedCollections().find(function(e){return e.isCollaborated;});if(!i)return n(new h(h.INVALID_DATA,"No collaborated collection found."));var o=E(e);o.target=g(t),this._channel.call("movelibrary",o,function(e){n(e.err,e.libraryId&&i.getLibraryById(e.libraryId));});}},{key:"getFontData",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},i=y(e);i.fontId=t,this._channel.call("getfontdata",i,function(e){return n(e.err,e.data);});}},{key:"isFontAvailable",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},i={fontName:e,matchFamily:t};this._channel.call("isfontavailable",i,function(e){var t=e.err,i=e.data;return n(t,i);});}},{key:"getAccessToken",value:function(e,t,n,i){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:function(){},r={userId:e,clientId:t,clientSecret:n,scopes:i};this._channel.call("getaccesstoken",r,function(e){var t=e.err,n=e.data;return o(t,n);});}},{key:"openInCCD",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){},n={path:e};this._channel.call("openinccd",n,function(e){var n=e.err,i=e.data;return t(n,i);});}},{key:"computeSHA",value:function(e){var t=this;return this._config.SHARED_LOCAL_STORAGE?new Promise(function(n,i){t._channel.call("computesha",{path:e},function(e){var t=e.err,o=e.data;return t?i(t):n(o);});}):this._services.fileUtils.computeSHA(e);}},{key:"_getServiceVersion",value:function(){var e=this.getServiceInfo();return e&&e.apiVersion||0;}},{key:"supportsClearRenditionCache",value:function(){return this._getServiceVersion()>=7;}},{key:"supportsTestExternalLink",value:function(){return this._getServiceVersion()>=10;}},{key:"_collectionManager",get:function(){return this._apiRoot._collectionManager;}},{key:"_services",get:function(){return this._apiRoot._services;}},{key:"_config",get:function(){return this._apiRoot._config;}}])&&o(t.prototype,n),r&&o(t,r),e;}();e.exports=T;},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var o=n(7),r=function(e){return"".concat(e,"_req");},a=function(e){return"".concat(e,"_res");},s=function(e,t,n){return"".concat(e,"#").concat(t,"#").concat(n);},c=function(){function e(t,n,i,r){var a=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._apiRoot=t,this._channelManager=i,this._socket=n,this._version=r,this._listenerManager=new o(void 0,function(e){return a._services.log(e);}),this._socketListenerManager=new o(void 0,function(e){return a._services.log(e);}),this._pendingWriteState={},this._pendingWriteDependencyMap={},this._stringMap={},this._addSocketListener("message",function(e){return a._onMessage(e);});}var t,n,c;return t=e,(n=[{key:"_onMessage",value:function(e){var t=this;if(this._pendingStringId)return this._log("RECEIVE STRING ".concat(this._pendingStringId)),this._stringMap[this._pendingStringId]=e,void delete this._pendingStringId;if(":"!==e[0]){var n=JSON.parse(e,function(e,n){if("manifest"===e&&t._stringMap[n]){var i=t._stringMap[n];return delete t._stringMap[n],i;}return n;});this._log("RECEIVE ".concat(this._getLogMessage(n.type,n.data))),this._listenerManager.notify(n.type,[n.data]);}else this._pendingStringId=e;}},{key:"_addSocketListener",value:function(e,t){this._socketListenerManager.add(e,t),this._socket.addListener(e,t);}},{key:"_removeSocketListeners",value:function(){var e=this;this._socketListenerManager.forEach(function(t,n){return e._socket.removeListener(t,n);}),this._socketListenerManager.removeAll();}},{key:"_log",value:function(e){this._logCallback&&this._logCallback(e);}},{key:"_getLogMessage",value:function(e,t){var n=e;return"syncstate"===e&&(n+=" ".concat(t.cloudId,": ").concat(t.state)),n;}},{key:"setPendingWriteState",value:function(e,t,n){var i=s(e,t,n);this._pendingWriteState[i]=!0;}},{key:"setPendingWriteDependency",value:function(e,t,n,i,o,r){var a=s(e,t,n),c=s(i,o,r);a!==c&&(this._pendingWriteDependencyMap[a]=this._pendingWriteDependencyMap[a]||{},this._pendingWriteDependencyMap[a][c]={userId:i,cloudId:o,id:r});}},{key:"clearPendingWriteState",value:function(e,t,n){var i=this,o=s(e,t,n),r=[];return Object.keys(this._pendingWriteDependencyMap[o]||{}).forEach(function(e){r.push(i._pendingWriteDependencyMap[o][e]);}),delete this._pendingWriteState[o],delete this._pendingWriteDependencyMap[o],r;}},{key:"getPendingWriteState",value:function(e,t,n,i){var o=this,r=s(e,t,n),a=!1;return!i&&this._pendingWriteState[r]&&(a=this._pendingWriteState[r]),Object.keys(this._pendingWriteDependencyMap).forEach(function(e){o._pendingWriteDependencyMap[e][r]&&(a=o._pendingWriteState[e]||a);}),a;}},{key:"setLogCallback",value:function(e){this._logCallback=e;}},{key:"addListener",value:function(e,t){this._listenerManager.add(e,t);}},{key:"removeListener",value:function(e,t){this._listenerManager.remove(e,t);}},{key:"send",value:function(e,t){var n=this;if(!this._channelManager||this._disableMiddleware)return this._send(e,t);var i=this._channelManager._middleware.filter(function(e){return e.checkVersion(n.version);});this._disableMiddleware=!0;var o=!0,r=!1,a=void 0;try{for(var s,c=i[Symbol.iterator]();!(o=(s=c.next()).done);o=!0)if(!1===(t=s.value.middleware(this,e,t)))return void(this._disableMiddleware=!1);}catch(e){r=!0,a=e;}finally{try{o||null==c.return||c.return();}finally{if(r)throw a;}}this._disableMiddleware=!1,this._send(e,t);}},{key:"_send",value:function(e,t){var n=this;try{this._log("SEND ".concat(this._getLogMessage(e,t)));var i=JSON.stringify({type:e,data:t},function(e,t){if("manifest"===e&&"function"==typeof t&&(t=t(n._version<21)),"manifest"===e&&n._version>=16){var i=":"+n._services.uuid();return n._log("SEND STRING ".concat(i)),n._socket.send(i),n._socket.send(t),i;}return t;});this._socket.send(i);}catch(e){this._log("ERROR ".concat(e)),this._socketListenerManager.notify("error",[e]);}}},{key:"addCallListener",value:function(e,t){var n=this;this.addListener(r(e),function(i){var o=i.id;t(i.data,function(t){n.send(a(e),{id:o,data:t});});});}},{key:"removeCallListener",value:function(e,t){this.removeListener(r(e),t);}},{key:"call",value:function(e,t,n){var i=this,o=this._services.uuid();this.addListener(a(e),function t(r){r.id===o&&(i.removeListener(a(e),t),n(r.data));}),this.send(r(e),{id:o,data:t});}},{key:"onOpen",value:function(e){this._addSocketListener("open",e);}},{key:"onClose",value:function(e){this._addSocketListener("close",e);}},{key:"onError",value:function(e){this._addSocketListener("error",e);}},{key:"shutdown",value:function(){var e=this;this._addSocketListener("close",function(){e._removeSocketListeners(),e._listenerManager.removeAll();});try{this._socket.close();}catch(e){}}},{key:"_services",get:function(){return this._apiRoot._services;}},{key:"version",get:function(){return this._version;}}])&&i(t.prototype,n),c&&i(t,c),e;}();e.exports=c;},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var o=n(7),r=function(){function e(t,n,i,r,a){var s=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e);var c=i?"wss://".concat(i,":").concat(t):"ws://127.0.0.1:".concat(t);c+="/?version=".concat(r),n&&(c+="&token=".concat(n)),this._socket=new WebSocket(c),this._socket.onopen=function(){return s._listenerManager.notify("open");},this._socket.onclose=function(){return s._listenerManager.notify("close");},this._socket.onmessage=function(e){return s._listenerManager.notify("message",[e.data]);},this._socket.onerror=function(e){return s._listenerManager.notify("error",[e]);},this._listenerManager=new o(["open","close","message","error"],a);}var t,n,r;return t=e,(n=[{key:"send",value:function(e){this._socket.send(e);}},{key:"addListener",value:function(e,t){this._listenerManager.add(e,t);}},{key:"removeListener",value:function(e,t){this._listenerManager.remove(e,t);}},{key:"close",value:function(){this._socket.close(),this._socket.onopen=void 0,this._socket.onclose=void 0,this._socket.onmessage=void 0,this._socket.onerror=void 0,this._listenerManager.removeAll();}}])&&i(t.prototype,n),r&&i(t,r),e;}();e.exports=r;},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var i=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._storageInterface=t;}var t,i,o;return t=e,(i=[{key:"_fsCall",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];var o="function"==typeof n[n.length-1]?n.pop():function(){};this._storageInterface._channel.call("fscall",{method:e,args:n},function(e){return o.apply(null,e);});}},{key:"rename",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._fsCall.apply(this,["rename"].concat(t));}},{key:"stat",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._fsCall.apply(this,["stat"].concat(t));}},{key:"unlink",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._fsCall.apply(this,["unlink"].concat(t));}},{key:"rmdir",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._fsCall.apply(this,["rmdir"].concat(t));}},{key:"mkdir",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._fsCall.apply(this,["mkdir"].concat(t));}},{key:"readdir",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._fsCall.apply(this,["readdir"].concat(t));}},{key:"utimes",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._fsCall.apply(this,["utimes"].concat(t));}},{key:"readFile",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._fsCall.apply(this,["readFile"].concat(t));}},{key:"writeFile",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._fsCall.apply(this,["writeFile"].concat(t));}},{key:"copyFile",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._fsCall.apply(this,["copyFile"].concat(t));}},{key:"exists",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._fsCall.apply(this,["exists"].concat(t));}}])&&n(t.prototype,i),o&&n(t,o),e;}();e.exports=i;},function(e,t,n){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var o=n(4),r=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._apiRoot=t;}var t,n,r;return t=e,(n=[{key:"generateUuid",value:function(){return this._services.uuid();}},{key:"copyFile",value:function(e,t,n,i){var o=this;if(n)return this._services.fileUtils.copyFile(e,t,i);var r=this._services.getFileNameFromPath(t);this._services.fileUtils.getAvailablePath(t.substring(0,t.indexOf(r)),r,function(t,n){return t?i(t):o._services.fileUtils.copyFile(e,n,i);});}},{key:"getFileSize",value:function(e,t){this._services.fileUtils.statFile(e,function(e,n){return t(e,n&&n.size);});}},{key:"getInstalledVersion",value:function(e){return(this._config.ELEMENT_ACTION_PRODUCT_MAP.installedApps||[]).filter(function(t){return t.code.toLowerCase()===e.toLowerCase();}).map(function(e){return e.version;}).sort(o.compareVersions)[0];}},{key:"isValidOrderString",value:function(e){return o.isValidOrderString(e);}},{key:"getOrderStringBetween",value:function(e,t){return o.getOrderStringBetween(e,t);}},{key:"getMultipleOrderStringsBetween",value:function(e,t,n){return o.getMultipleOrderStringsBetween(e,t,n);}},{key:"_services",get:function(){return this._apiRoot._services;}},{key:"_config",get:function(){return this._apiRoot._config;}}])&&i(t.prototype,n),r&&i(t,r),e;}();e.exports=r;},function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i);}}var i=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function");}(this,e),this._apiRoot=t;}var t,i,o;return t=e,(i=[{key:"reportUseElement",value:function(e,t,n){this._analytics.reportUseElement(e,t,n);}},{key:"reportCheckoutElement",value:function(e,t,n){this._analytics.reportCheckoutElement(e,t,n);}},{key:"reportCreateLink",value:function(e,t){this._analytics.reportCreateLink(e,t);}},{key:"reportShareElementLink",value:function(e){this._analytics.reportShareElementLink(e);}},{key:"reportShareLibraryLink",value:function(e){this._analytics.reportShareLibraryLink(e);}},{key:"_analytics",get:function(){return this._apiRoot._analytics;}}])&&n(t.prototype,i),o&&n(t,o),e;}();e.exports=i;}]);});
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__("HDXh").Buffer))

/***/ })

}]);