/************************************************************************!
*
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2015-2019 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){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},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 o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},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=61)}([function(e,t,n){var o=n(45);function i(){this.uuid=n(47),this.fs=n(19),this.path=n(14),this.imageSize=n(67),this.yazl=n(54),this.yauzl=n(55),this._initDCX()}i.prototype._initDCX=function(){var e=this;this.dcx=new o(this.fs,{preserveFileExtensions:!0,logCallback(t){e._log&&e._log("DCX: "+t)}})},i.prototype.uuid=function(){return this.uuid()},i.prototype.log=function(e){this._log&&this._log("CC Libraries: "+e)},i.prototype.getDisplayName=function(e){return this._getDisplayName?this._getDisplayName(e):e.name},i.prototype.hasFileSystem=function(){return void 0!==this.fs},i.prototype.setFileSystem=function(e){this.fs=e,this._initDCX()},i.prototype.hasRenditionGenerator=function(){return void 0!==this.renditionGenerator},i.prototype.setRenditionGenerator=function(e){this.renditionGenerator=e},i.prototype.getVulcanInterface=function(){if("undefined"!==typeof VulcanInterface)return VulcanInterface},i.prototype.getVulcanMessage=function(){if("undefined"!==typeof VulcanMessage)return VulcanMessage},i.prototype.hasCEPVulcan=function(){return void 0!==this.getVulcanInterface()&&void 0!==this.getVulcanMessage()},i.prototype.getNodeTunnelOptions=function(e){return this._getNodeTunnelOptions?this._getNodeTunnelOptions(e):{}},i.prototype.getPathSeparator=function(){return"/"},i.prototype.getFileNameFromPath=function(e){return-1===e.indexOf("/")&&-1!==e.indexOf("\\")&&(e=e.replace(/\\/g,"/")),e.split("/").pop()},Object.freeze(i),Object.seal(i.prototype),e.exports=new i},function(e,t,n){var o=n(2),i=["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","SHARED_LOCAL_STORAGE_ANALYTICS","WHITELISTED_DOMAINS","CLIENT_DESCRIPTION","DEVICE_ID","DEVICE_DESCRIPTION","APP_DESCRIPTION","DEFAULT_RENDITION_404_BACKOFF"];function r(){this.name="config"}r.prototype.VERSION=1,r.prototype.MAX_ELEMENTS=1e3,r.prototype.MAX_REMOVED_ELEMENTS=1e3,r.prototype.MAX_COMPONENT_SIZE=1073741824,r.prototype.VALID_RELATIONS=["rendition","primary","alternate"],r.prototype.VALID_LIBRARY_RENDITION_TYPES=["banner","cover"],r.prototype.VALID_SYNC_POLICIES=["manifestAndAssets","manifestOnly"],r.prototype.ELEMENT_TYPE_FILTERS=[],r.prototype.VECTOR_RENDITION_ELEMENT_TYPES=["application/illustrator"],r.prototype.DL_NAMESPACE="library",r.prototype.DL_PREFIX=r.prototype.DL_NAMESPACE+"#",r.prototype.VERSION_KEY=r.prototype.DL_PREFIX+"version",r.prototype.RELATIONSHIP_KEY=r.prototype.DL_PREFIX+"rel",r.prototype.WIDTH_KEY=r.prototype.DL_PREFIX+"width",r.prototype.HEIGHT_KEY=r.prototype.DL_PREFIX+"height",r.prototype.LENGTH_KEY=r.prototype.DL_PREFIX+"length",r.prototype.IS_FULL_SIZE_KEY=r.prototype.DL_PREFIX+"isFullSize",r.prototype.IS_PREFERRED_THUMBNAIL_KEY=r.prototype.DL_PREFIX+"isPreferredThumbnail",r.prototype.MODIFIED_KEY=r.prototype.DL_PREFIX+"modified",r.prototype.CREATED_KEY=r.prototype.DL_PREFIX+"created",r.prototype.REMOVED_KEY=r.prototype.DL_PREFIX+"removed",r.prototype.MODIFIED_DATA_KEY=r.prototype.DL_PREFIX+"modifiedData",r.prototype.CREATED_DATA_KEY=r.prototype.DL_PREFIX+"createdData",r.prototype.REMOVED_DATA_KEY=r.prototype.DL_PREFIX+"removedData",r.prototype.DESCRIPTION_KEY=r.prototype.DL_PREFIX+"description",r.prototype.DESCRIPTION_DATA_KEY=r.prototype.DL_PREFIX+"descriptionData",r.prototype.GROUPS_KEY=r.prototype.DL_PREFIX+"groups",r.prototype.ORDER_KEY=r.prototype.DL_PREFIX+"order",r.prototype.CLASSIFIER_KEY=r.prototype.DL_PREFIX+"classifier",r.prototype.ANIMATION_ELEMENT_TYPE="application/vnd.adobe.element.animation+dcx",r.prototype.BRUSH_ELEMENT_TYPE="application/vnd.adobe.element.brush+dcx",r.prototype.COLOR_ELEMENT_TYPE="application/vnd.adobe.element.color+dcx",r.prototype.IMAGE_ELEMENT_TYPE="application/vnd.adobe.element.image+dcx",r.prototype.LAYER_STYLE_ELEMENT_TYPE="application/vnd.adobe.element.layerstyle+dcx",r.prototype.REPRESENTATION_CONTENT_VALUES={"application/vnd.adobe.color+json":{namespace:"color",key:"data"},"application/vnd.adobe.text+json":{namespace:"text",key:"data",contentFromData:!0}},r.prototype.LINK_TYPE_KEY=r.prototype.DL_PREFIX+"linktype",r.prototype.LINK_URL_KEY=r.prototype.DL_PREFIX+"linkurl",r.prototype.REPRESENTATION_ORDER_KEY=r.prototype.DL_PREFIX+"representationOrder",r.prototype.RENDITION_TYPE_KEY=r.prototype.DL_PREFIX+"renditiontype",r.prototype.DEFAULT_GROUP_CLASSIFIER="$default",r.prototype.COMPOSITE_TYPE="application/vnd.adobe.library+dcx",r.prototype.LINK_REPRESENTATION_TYPE="application/vnd.adobe.library.link+dcx",r.prototype.GROUP_TYPE="application/vnd.adobe.library.group+dcx",r.prototype.ELEMENTS_NAME="elements",r.prototype.REMOVED_ELEMENTS_NAME="removed_elements",r.prototype.GROUPS_NAME="groups",r.prototype.DATA_COLLABORATION_ROLE="collaborationRole",r.prototype.FS_RETRY_INTERVAL=100,r.prototype.FS_MAX_RETRIES=10,r.prototype.MAX_DCX_CONCURRENT_COPIES=10,r.prototype.REMOVE_OPERATION_TIMEOUT=100,r.prototype.EXPORT_VERSION=1,r.prototype.EXPORT_EXTENSION=".cclibs",r.prototype.ANALYTICS_ELEMENT_UPDATE_THRESHOLD=500,r.prototype.BOOKMARKS_FILENAME="bookmarks.json",r.prototype.BOOKMARKS_PATH="/bookmarks",r.prototype.BOOKMARKS_MONITOR_PATH="/sync/adobe-libraries/"+r.prototype.BOOKMARKS_FILENAME,r.prototype.PUBLIC_USER_ID="public",r.prototype.DEFAULT_CLOUD_ID="creative_cloud",r.prototype.DEFAULT_CORESYNC_CLOUD_ID="00000000-0000-0000-0000-000000000000",r.prototype.STORAGE_ASSETS_PATH="/assets/",r.prototype.LIBRARY_SYNC_GROUP="adobe-libraries",r.prototype.CP_CLOUD_ID="community-platform",r.prototype.CP_STORAGE_ASSETS_PATH="/content/2/",r.prototype.STORAGE_API_KEY="",r.prototype.USER_AGENT_HEADER=void 0,r.prototype.SYNCING_ENABLED=!0,r.prototype.VULCAN_QUERY_TIMEOUT=8e3,r.prototype.DEFAULT_MAX_SYNC_INTERVAL=1e4,r.prototype.RETRY_FAIL_MAX_SYNC_INTERVAL=6e4,r.prototype.MAX_SYNC_INTERVAL=r.prototype.DEFAULT_MAX_SYNC_INTERVAL,r.prototype.POLL_INTERVAL=1,r.prototype.AUTO_START_POLLING=!1,r.prototype.RENDITION_SIZES={},r.prototype.FULL_RENDITION_CONFIG={},r.prototype.BACKOFF_INTERVALS=[1,1,2,3,5,8,13,21,34,55],r.prototype.ERROR_RETRY_INTERVALS=[30,60,120],r.prototype.NETWORK_TIMEOUT=6e5,r.prototype.IMAGE_SERVICE_NETWORK_TIMEOUT=18e4,r.prototype.RETRY_RANDOM_SECONDS=30,r.prototype.RENDITION_MAX_RETRIES=2,r.prototype.DEFAULT_RENDITION_RETRY_INTERVAL=1e3,r.prototype.RENDITION_RETRY_INTERVAL=r.prototype.DEFAULT_RENDITION_RETRY_INTERVAL,r.prototype.DEFAULT_RENDITION_404_BACKOFF=3e5,r.prototype.RENDITION_404_BACKOFF=r.prototype.DEFAULT_RENDITION_404_BACKOFF,r.prototype.LOCAL_RENDITION_MAX_RETRIES=5,r.prototype.LOCAL_RENDITION_RETRY_INTERVAL=200,r.prototype.MAX_UPDATE_CONFLICTS=5,r.prototype.MAX_REDIRECT_FOLLOW=5,r.prototype.MAX_HEAD_REDIRECT_FOLLOW=0,r.prototype.WHITELISTED_DOMAINS=[],r.prototype.ADOBE_AUTHENTICATED_DOMAINS=["adobe.com","adobe.io","adobestock.com","fotolia.net"],r.prototype.SYNC_POLICY="manifestAndAssets",r.prototype.REMOVED_ELEMENTS_CACHE_TIMEOUT=6e5,r.prototype.RENDITION_CACHE_FILE="cache.json",r.prototype.RENDITION_CACHE_PLACEHOLDER="<placeholder>",r.prototype.SHARED_LOCAL_STORAGE=!0,r.prototype.SHARED_LOCAL_STORAGE_VERSION=13,r.prototype.SHARED_LOCAL_STORAGE_MIN_CLIENT_VERSION=6,r.prototype.SHARED_LOCAL_STORAGE_MAX_CLIENT_VERSION=13,r.prototype.VULCAN_PREFIX="vulcan.SuiteMessage.",r.prototype.VULCAN_STARTUP_MESSAGE="cclibraries.service.Initialized",r.prototype.VULCAN_SHUTDOWN_REQUEST="cclibraries.service.TerminateServiceRequest",r.prototype.VULCAN_QUERY_REQUEST="cclibraries.service.QueryRequest",r.prototype.VULCAN_QUERY_RESPONSE="cclibraries.service.QueryResponse",r.prototype.VULCAN_LIBRARY_CHANGED_LOCAL_TYPE="cclibraries.service.LibraryChangedLocal",r.prototype.VULCAN_LIBRARY_CHANGED_REMOTE_TYPE="cclibraries.service.LibraryChangedRemote",r.prototype.VULCAN_LIBRARY_DELETED_TYPE="cclibraries.service.LibraryDeleted",r.prototype.VULCAN_COLLECTIONS_LOADED_TYPE="cclibraries.service.LibrariesLoaded",r.prototype.VULCAN_COLLECTIONS_UNLOADED_TYPE="cclibraries.service.LibrariesUnloaded",r.prototype.VULCAN_PROXY_QUERY_REQUEST="cclibraries.service.QueryProxySettingsRequest",r.prototype.VULCAN_PROXY_QUERY_RESPONSE="cclibraries.service.QueryProxySettingsResponse",r.prototype.VULCAN_PROXY_CHANGE_MESSAGE="cclibraries.service.ProxySettingsChanged",r.prototype.VULCAN_APP_READY_MESSAGE="cclibraries.accessor.AppReady",r.prototype.VULCAN_APP_SEND_ACTION_MESSAGE="cclibraries.accessor.EditElementRequest",r.prototype.VULCAN_APP_ACTION_ACCEPTED_MESSAGE="cclibraries.accessor.EditAcceptedMessage",r.prototype.LOCAL_SETTINGS={},r.prototype.ELEMENT_ACTIONS=["edit","openStock"],r.prototype.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:[]},r.prototype.STOCK_NAMESPACE="adobestock",r.prototype.STOCK_DATA_KEY="trackingdata",r.prototype.STOCK_STATE_PURCHASED="purchased",r.prototype.setParameter=function(e,t){if(-1===i.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},Object.freeze(r),Object.seal(r.prototype),e.exports=new r},function(e,t){var n=["INVALID_PARAMETER","READ_ONLY","NOT_IMPLEMENTED","NOT_SUPPORTED","REQUIRES_FILESYSTEM","DELETED_LOCALLY"];function o(e,t,i,r){if(-1!==n.indexOf(e))if(Error.call(this),Error.captureStackTrace)Error.captureStackTrace(this,o);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=i,this.underlyingError=r}o.prototype=Object.create(Error.prototype),o.prototype.name="AdobeLibraryError",o.INVALID_PARAMETER="INVALID_PARAMETER",o.READ_ONLY="READ_ONLY",o.NOT_IMPLEMENTED="NOT_IMPLEMENTED",o.NOT_SUPPORTED="NOT_SUPPORTED",o.REQUIRES_FILESYSTEM="REQUIRES_FILESYSTEM",o.DELETED_LOCALLY="DELETED_LOCALLY",o.NOT_ALLOWED="NOT_ALLOWED",o.FILE_TOO_LARGE="FILE_TOO_LARGE",o.EXCEEDS_MAX_LIBRARY_SIZE="EXCEEDS_MAX_LIBRARY_SIZE",o.CORRUPTED_LIBRARY="CORRUPTED_LIBRARY",o.THUMBNAIL_NOT_AVAILABLE="THUMBNAIL_NOT_AVAILABLE",o.STALE_THUMBNAIL="STALE_THUMBNAIL",o.RENDITION_NOT_AVAILABLE="RENDITION_NOT_AVAILABLE",o.FS_ERROR="FS_ERROR",o.OUT_OF_SPACE="OUT_OF_SPACE",o.LOGGED_OUT="LOGGED_OUT",o.EXCEEDS_QUOTA="EXCEEDS_QUOTA",o.RETRYABLE_SERVER_ERROR="RETRYABLE_SERVER_ERROR",o.TRANSFER_ERROR="TRANSFER_ERROR",o.TRANSFER_ABORTED="TRANSFER_ABORTED",o.NETWORK_ERROR="NETWORK_ERROR",o.ACCESS_DENIED="ACCESS_DENIED",o.URL_VALIDATION_FAILED="URL_VALIDATION_FAILED",o.NO_COMPATIBLE_APP_FOUND="NO_COMPATIBLE_APP_FOUND",o.APP_LAUNCH_FAILED="APP_LAUNCH_FAILED",o.OPERATION_CANCELLED="OPERATION_CANCELLED",o.INVALID_DATA="INVALID_DATA",Object.freeze(o),Object.seal(o.prototype),e.exports=o},function(e,t){function n(e,t,o){if(Error.call(this),Error.captureStackTrace)Error.captureStackTrace(this,n);else{var i=new Error;i.name=this.name,this.stack=i.stack}this.code=e,this.message="["+e+"] "+t,this.underlyingError=o}n.prototype=Object.create(Error.prototype),n.prototype.name="AdobeDCXError",n.INVALID_JSON="INVALID_JSON",n.READ_ONLY="READ_ONLY",n.INVALID_PARAMS="",n.INVALID_DATA="INVALID_DATA",n.DUPLICATE_VALUE="DUPLICATE_VALUE",n.NO_LOCAL_STORAGE="NO_LOCAL_STORAGE",n.INVALID_STATE="INVALID_STATE",n.DELETED_COMPOSITE="DELETED_COMPOSITE",n.UNEXPECTED_RESPONSE="UNEXPECTED_RESPONSE",n.NETWORK_ERROR="NETWORK_ERROR",n.COMPONENT_DOWNLOAD_ERROR="COMPONENT_DOWNLOAD_ERROR",n.COMPONENT_UPLOAD_ERROR="COMPONENT_UPLOAD_ERROR",n.COMPONENT_MODIFIED_ERROR="COMPONENT_MODIFIED_ERROR",n.UPDATE_CONFLICT="UPDATE_CONFLICT",n.NO_COMPOSITE="NO_COMPOSITE",n.ALREADY_EXISTS="ALREADY_EXISTS",n.SERVICE_IS_INACTIVE="SERVICE_IS_INACTIVE",n.EXCEEDS_QUOTA="EXCEEDS_QUOTA",n.NOT_IMPLEMENTED="NOT_IMPLEMENTED",n.RETRYABLE_SERVER_ERROR="RETRYABLE_SERVER_ERROR",n.TIMED_OUT="TIMED_OUT",n.UNEXPECTED="UNEXPECTED",n.TERMINATED_INPUTSTREAM="TERMINATED_INPUTSTREAM",n.WRONG_ENDPOINT="WRONG_ENDPOINT",n.OUT_OF_SPACE="ENOSPC";var o={};o[n.SERVICE_IS_INACTIVE]=1,o[n.NOT_IMPLEMENTED]=1,o[n.EXCEEDS_QUOTA]=1,o[n.RETRYABLE_SERVER_ERROR]=1,o[n.TIMED_OUT]=1,o[n.TERMINATED_INPUTSTREAM]=1,o[n.WRONG_ENDPOINT]=1,o[n.OUT_OF_SPACE]=1,n.wrapError=function(e,t,i,r){if(!i||!o[i.code]){if(r){var a=r.statusCode;a>=500&&a<600&&(501===a?(e=n.NOT_IMPLEMENTED,t="Unimplemented request"):507===a?(e=n.EXCEEDS_QUOTA,t="Quota exceeded"):(e=n.RETRYABLE_SERVER_ERROR,t="Server error"))}i=new n(e,t,i)}return r&&(i.response=r),i},n.networkError=function(e,t,o){return n.wrapError(n.NETWORK_ERROR,e,t,o)},n.unexpectedResponse=function(e,t,o){return n.wrapError(n.UNEXPECTED_RESPONSE,e,t,o)},e.exports=n},function(e,t,n){var o,i=n(19),r=n(39),a=n(0),s=n(1),c={ENVIRONMENT:"production",SETTINGS_FILE:"settings.json",SETTINGS_FILE_VERSION:2,CC_SETTINGS_FILE:"C3Config.xml",CONSOLE_LOGGING:!1,SCOPES:"openid,AdobeID,creative_cloud,creative_sdk,cc_private,sao.cce_private",MAX_LOG_SIZE:5242880,MAX_ANALYTIC_LOGS:100,CORE_SYNC_REQUEST_TIMEOUT:5e3,CORE_SYNC_NUM_RETRIES:3,CORE_SYNC_NOTIFICATION_DEBOUNCE:500,ACCESS_TOKEN_CACHE_DURATION:6e5,SYNC_STATE_BROADCAST_THROTTLE:100,ANALYTICS_PROJECT:"cclib-process",ANALYTICS_INGEST_TYPE:"dunamis",ANALYTICS_DEFAULT_DEBOUNCE:1e4,ANALYTICS_DEBOUNCE:1e4,MAX_QUEUED_ANALYTICS:200,GET_ACTIVE_CLOUD_TIMEOUT:1e4,GET_NOTIFICATION_TIMEOUT:2e3,PROXY_REQUEST_TIMEOUT:2e3,CONFIGURE_SYNC_TIMEOUT:5e3,THOR_LAUNCH_WAIT:5e3,CORE_SYNC_ANALYTICS_WAIT:3e5,ANALYTICS_ERROR_HISTORY:5,CONNECTION_VALIDATION_INTERVAL:5e3,LAUNCH_APP_POLL_INTERVAL:5e3,LAUNCH_APP_TIMEOUT:3e5,SEND_ACTION_TIMEOUT:5e3,OS_TOAST_NOTIFICATIONS_BACKOFF:1e3,OS_TOAST_NOTIFICATIONS_DELAY:100,LOCAL_THUMBNAILS_SHUTDOWN_DELAY:5e3,VALIDATE_RENDITIONS_SIZE_THRESHOLD:1048576,REST_API_VERSION:2,REST_API_MIN_VERSION:2,REST_API_MAX_VERSION:2,WSS_PORT:23456,PRODUCT_LAUNCHER_SUPPORTED_PRODUCTS:{illustrator:"ILST",photoshop:"PHXS",indesign:"IDSN",premierepro:"PPRO",aftereffects:"AEFT",flash:"FLPR",euclid:"ESHR",creativecloud:"ADCS"},PRODUCT_BRIDGE_ELEMENT_TYPES:["application/vnd.adobe.element.image+dcx","application/vnd.adobe.element.video+dcx","application/vnd.adobe.element.3d+dcx","application/vnd.adobe.element.template+dcx","application/vnd.adobe.element.text+dcx","application/vnd.adobe.element.animation+dcx"],PRODUCT_BRIDGE_INMEMORY_LIFETIME:6e5,EXTERNAL_LINK_PREFETCH:{"application/vnd.adobe.element.video+dcx":!1}},l={staging:{LABEL:"Staging",CLIENT_ID:"ProjectCentral16",CLIENT_SECRET:"5c597af3-e18a-41bc-8b65-82fd532e5f12",STORAGE_HOST:"cc-api-storage-stage.adobe.io",CCWEB_HOST:"assets-stage.adobecc.com",CCLIB_HOST:"cc-api-assets-stage.adobe.io",COLLAB_HOST:"cc-collab-stage.adobe.io",CC_IMAGE_HOST:"cc-api-image-stage.adobe.io",CC_IMAGE_X_HOST:"cc-api-image-x-stage.adobe.io",PUBLIC_HOSTS:[{host:"public-stage.adobecc.com"},{host:"drakozoxj1229.cloudfront.net",community_platform:!0},{host:"cdn-stage.cp.adobe.io",community_platform:!0}],TYPEKIT_HOST:"cctypekit-relstage.adobe.io",IMS:"ims-na1-stg1.adobelogin.com"},production:{LABEL:"Production",CLIENT_ID:"ProjectCentral16",CLIENT_SECRET:"1ba6923b-fc3d-4114-a506-f3bc5b34093a",STORAGE_HOST:"cc-api-storage.adobe.io",CCWEB_HOST:"creative.adobe.com",CCLIB_HOST:"cc-api-assets.adobe.io",COLLAB_HOST:"cc-collab.adobe.io",CC_IMAGE_HOST:"cc-api-image.adobe.io",CC_IMAGE_X_HOST:"cc-api-image-x.adobe.io",PUBLIC_HOSTS:[{host:"public.adobecc.com"},{host:"d35fgcharv2shj.cloudfront.net",community_platform:!0},{host:"cdn.cp.adobe.io",community_platform:!0}],TYPEKIT_HOST:"cctypekit.adobe.io",IMS:"ims-na1.adobelogin.com"}};var p={SETTINGS_FILE_VERSION:c.SETTINGS_FILE_VERSION};var d={};d._init=function(){if(d.isPlatformWindows()){var e=process.env.USERPROFILE.replace(/\\/g,"/");c.ROOT_DIR=e+"/AppData/Roaming/",c.LOG_DIR=process.env.TEMP.replace(/\\/g,"/")+"/CreativeCloud/Creative Cloud Libraries/";var t=(process.env["ProgramFiles(x86)"]||process.env.PROGRAMFILES).replace(/\\/g,"/");c.CC_DIR=t+"/Adobe/Adobe Creative Cloud/"}else c.ROOT_DIR=process.env.HOME+"/Library/Application Support/",c.LOG_DIR=process.env.HOME+"/Library/Logs/CreativeCloud/Creative Cloud Libraries/",c.CC_DIR="/Applications/Utilities/Adobe Creative Cloud/";c.ROOT_DIR+="Adobe/Creative Cloud Libraries/LIBS/",function(){try{o=i.readFileSync(c.ROOT_DIR+c.SETTINGS_FILE,"utf8");var e=JSON.parse(o);p.SETTINGS_FILE_VERSION===e.SETTINGS_FILE_VERSION&&(p=e)}catch(e){}}(),function(){var e=!1;try{var t=i.readFileSync(c.CC_DIR+c.CC_SETTINGS_FILE,"utf8");new r.Parser({async:!1}).parseString(t,function(t,n){t||n.C3Config.config[0].namespace.forEach(function(t){t&&t.$&&t.$.name&&"accc.container"===t.$.name&&t.property.forEach(function(t){t&&t.$&&t.$.name&&"IMS_ENV"===t.$.name&&"STG"===t._&&(e=!0)})})})}catch(e){}return e}()&&(c.ENVIRONMENT="staging"),process.argv.forEach(function(e){"--debug"===e&&(c.CONSOLE_LOGGING=!0)}),c.CONSOLE_LOGGING||console.log(`Outputting logs to: ${c.LOG_DIR}\nTo view log messages on the console, use the --debug argument`),p.DISABLE_CERTIFICATE_CHECK&&(console.warn("Disabling Certificate Check"),process.env.NODE_TLS_REJECT_UNAUTHORIZED=0),"number"==typeof p.MAX_ELEMENTS&&(s.MAX_ELEMENTS=p.MAX_ELEMENTS)},d.isPlatformWindows=function(){return 0===process.platform.indexOf("win")},d.getValue=function(e){return void 0!==p[e]?p[e]:c[e]},d.setValue=function(e,t){return p[e]=t,function(){var e=JSON.stringify(p,void 0,2);if(e===o)return!1;try{var t=c.SETTINGS_FILE+".TEMP_"+a.uuid();i.writeFileSync(c.ROOT_DIR+t,e),i.renameSync(c.ROOT_DIR+t,c.ROOT_DIR+c.SETTINGS_FILE),o=e}catch(e){}return!0}()},d.getEnvironment=function(){var e=d.getValue("ENVIRONMENT");return l[e]||l[c.ENVIRONMENT]},d._init(),e.exports=d},function(e,t,n){var o=n(0),i=n(2);function r(e){this._restrictedTypes=e,this._listeners={}}r.prototype._checkType=function(e){if(this._restrictedTypes&&-1===this._restrictedTypes.indexOf(e)){var t="["+this._restrictedTypes.join(", ")+"]";throw new i(i.INVALID_PARAMETER,e+" is not allowed. Should be one of: "+t)}},r.prototype.add=function(e,t){this._checkType(e),this._listeners[e]=this._listeners[e]||[],this._listeners[e].push(t)},r.prototype.remove=function(e,t){this._checkType(e);var n=this._listeners[e];if(n){var o=n.indexOf(t);-1!==o&&n.splice(o,1)}},r.prototype.removeAll=function(e){e?(this._checkType(e),delete this._listeners[e]):this._listeners={}},r.prototype.notify=function(e,t){this._checkType(e);var n=this._listeners[e];n&&n.slice(0).forEach(function(e){try{e.apply(void 0,t||[])}catch(e){o.log("Error in listener callback: "+(e?e.toString():"")),e&&e.stack&&o.log(e.stack)}})},r.prototype.hasListeners=function(e){this._checkType(e);var t=this._listeners[e];return!!(t&&t.length>0)},r.prototype.forEach=function(e){var t=this._listeners;Object.keys(t).forEach(function(n){t[n].forEach(function(t){e(n,t)})})},Object.freeze(r),Object.seal(r.prototype),e.exports=r},function(e,t,n){var o,i;o=n(47);var r={_setLogCallback:function(e){i=e},merge:function(e){var t,n;for(t=1;t<arguments.length;++t){var o=arguments[t];if("object"==typeof o)for(n in o)o.hasOwnProperty(n)&&(e[n]=o[n])}return e},parentDirectory:function(e){var t=e.split("/");return t.pop(),t.join("/")},filePathComponents:function(e){var t=e.split("/"),n=t.pop(),o=n.split("."),i=o.length>1?o.pop():null;return{directory:t.join("/"),fileName:n,baseName:o.join("."),extension:i}},appendPathElements:function(){var e,t=[],n=arguments.length;for(e=0;e<n;e++){var o=arguments[e];"string"==typeof o&&""!==o&&(0===e&&1!==o.length||"/"===o.charAt(0)&&(o=o.slice(1)),e!==n-1&&"/"===o.charAt(o.length-1)&&(o=o.slice(0,o.length-1)),t.push(o))}return t.join("/")}},a=/^[^\u0000-\u001F\u0022\u002A\u003A\u003C\u003E\u003F\u005C\u007F]*[^\u0000-\u001F\u0022\u002A\u002E\u003A\u003C\u003E\u003F\u005C\u007F]{1}$/;r.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 o,i=n.length;for(o=0;o<i;o++){if(n[o].length>255||!a.test(n[o]))return!1}if(t&&n.length>0){var r=n[0];if("manifest"===r||"mimetype"===r)return!1}return!0}catch(e){return!1}},r.isValidAbsolutePath=function(e){return r.isValidPath(e,!0)};var s=r.noOp=function(){};r.consumeStream=function(e,t,n){e.on("data",n||s),e.on("end",t||s)},r.flatCopy=function(e){var t,n={},o=Object.keys(e),i=o.length;for(t=0;t<i;t++){var r=o[t];n[r]=e[r]}return n},r.deepCopy=function(e){return JSON.parse(JSON.stringify(e))},r.objectsEqual=function(e,t,n){var o,i,a={},s=Object.keys(e),c=s.length;for(i=0;i<c;i++){if(o=s[i],!n||!n[o]){var l=e[o],p=t[o],d=typeof l;if(d!==typeof p)return!1;if("object"===d){if(!r.objectsEqual(l,p,n))return!1}else if(l!==p)return!1}a[o]=!0}for(c=(s=Object.keys(t)).length,i=0;i<c;i++)if(!a[o=s[i]])return!1;return!0};var c=new RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?");r.parseURI=function(e){var t=e.match(c);return{scheme:t[2],authority:t[4],path:t[5],query:t[7],fragment:t[9]}},r.endPointOf=function(e){var t,n=r.parseURI(e),o=n.scheme,i=n.authority,a="https"===o?443:"http"===o?80:-1;return o&&i&&(t=(o+"://"+i).toLowerCase(),a>=0&&i.indexOf(":")<0&&(t=t+":"+a)),t},r.ensureRelativeHrefStartsWithSlash=function(e){if(e){var t=r.parseURI(e),n=t.scheme,o=t.authority;n||o||"/"!==e.charAt(0)&&(e="/"+e)}return e};var l=/^([^:]+):(.*)$/,p=/^\s+|\s+$/g;r.parseHeaders=function(e){var t,n,o,i={},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=l.exec(a);c&&c.length>1&&(n=c[1].toLowerCase(),o=(o=c[2]||"").replace(p,""),i[n]?i[n]=i[n]+","+o:i[n]=o)}else i[n]=i[n]+" "+a.replace(p,"")}}return i},r.timeStamp=function(e){var t=(new Date).getTime();return e&&(t-=t%1e3),t},r.generateUuid=o,r.log=function(e){if("function"==typeof i)try{i(e)}catch(e){}},e.exports=r},function(e,t){var n={wrapCallback:function(e){return function(){e&&e.apply(this,arguments)}},constructStringFromTemplate:function(e,t){var n=e;return Object.keys(t).forEach(function(e){n=n.replace("{{"+e+"}}",t[e])}),n},parseLocalisationFile:function(e){var t,n,o,i,r={},a=0,s=e.split(/\n/);for(a=0;a<s.length;a++)if(s[a]=s[a].replace(/^\s\s*/,"").replace(/\s\s*$/,""),s[a].length>0&&"#"!==s[a].match("^#")){for(n=(t=s[a].split("="))[0].replace(/^\s\s*/,"").replace(/\s\s*$/,""),o=1===t.length?"":t[1];o.match(/\\$/)&&"\\"===o.match(/\\$/).toString();)o=o.substring(0,o.length-1),o+=s[++a].replace(/\s\s*$/,"");for(i=2;i<t.length;i++)o+="="+t[i];o=o.replace(/^\s\s*/,"").replace(/\s\s*$/,""),r[n]=o}return r},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;var n,o,i=e.split("."),r=t.split(".");for(n=0;n<i.length&&n<r.length;n++){if(o=parseInt(i[n],10)-parseInt(r[n],10),isNaN(o))return isNaN(parseInt(i[n],10))?1:-1;if(o>0)return-1;if(o<0)return 1}return(o=i.length-r.length)>0?-1:o<0?1:0}};Object.seal(n),e.exports=n},function(e,t,n){var o,i=n(19),r=n(4),a=n(5),s=n(9),c=r.getValue("LOG_DIR")+"CC Library Process.log",l=r.getValue("LOG_DIR")+"CC Library Process (prev).log",p=!1,d=new a(["logWrite"]),u=!1;function h(e,t,n){i.exists(t,function(o){i.exists(e,function(r){r&&!o?i.rename(e,t,n):n(null)})})}function _(e){!function(e){if(u)e(null);else{u=!0;var t=r.getValue("LOG_DIR")+"log.txt";h(r.getValue("LOG_DIR")+"log_prev.txt",l,function(){h(t,c,e)})}}(function(){i.stat(c,function(t,n){!t&&n.size>r.getValue("MAX_LOG_SIZE")?i.rename(c,l,e):e(null)})})}var f=[];var m={};m.log=function(){var e=Array.prototype.slice.call(arguments).join(": ");r.getValue("CONSOLE_LOGGING")&&console.log(e),function(e){f.length>=r.getValue("MAX_ANALYTIC_LOGS")&&f.shift(),f.push(e)}(e);var t=(new Date).toString()+" "+e+"\n";o?o+=t:(o=t,p||function e(){s.ensurePathExists(r.getValue("LOG_DIR"),function(t){if(t)return o=void 0,void console.error(t);_(function(t){if(t)return o=void 0,void console.error(t);var n=o;o=void 0,p=!0,i.appendFile(c,n,function(t){t&&console.error(t),p=!1,o&&e(),d.notify("logWrite")})})})}())},m.getRecentLogs=function(){return f},m.clearRecentLogs=function(){f=[]},m.addLogWriteListener=function(e){d.add("logWrite",e)},m.removeLogWriteListener=function(e){d.remove("logWrite",e)},m._listenerManager=d,e.exports=m},function(e,t,n){var o=n(0),i=n(7),r=n(12),a=n(1),s=n(2),c=["bmp","cur","gif","ico","jpeg","jpg","png","psd","tiff","tif","webp","svg","dds"],l={};const p=function(e,...t){const n=o.fs,i=t.find(e=>"function"==typeof e),r=t.slice(0,t.indexOf(i)),s=t.indexOf(i)===t.length-1?0:t[t.length-1];n[e].apply(n,r.concat((t,...n)=>{t&&"EPERM"===t.code&&s<a.FS_MAX_RETRIES?setTimeout(function(){p(e,...r,i,s+1)},a.FS_RETRY_INTERVAL):i(t,...n)}))};l.ensurePathExists=function(e,t){var n=o.getPathSeparator(),i=o.fs;!function e(t,o,r){var a=o.slice(0,t).join(n),s=function(){t<o.length?e(t+1,o,r):r(null)};i.exists(a,function(e){e?s():i.mkdir(a,s)})}(2,e.split(n),t)},l.copyFile=function(e,t,n){var i=o.fs;try{var r=function(e){return e+".TEMP_"+o.uuid()}(t),a=i.createWriteStream(r),s=i.createReadStream(e),c=!1;s.on("end",function(){c||p("rename",r,t,n)}),s.on("error",function(e){c=!0,n(e)}),s.pipe(a)}catch(e){n(e)}},l.rename=function(e,t,n){p("rename",e,t,n)},l.normaliseTempFileName=function(e){return function(e){var t=e.match(/(.*)\.TEMP_[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i);return t&&t[1]?t[1]:e}(e)},l.getFileExtension=function(e){var t=e&&e.replace(/^.*[\\/]/,""),n=t?t.lastIndexOf("."):-1;if(-1!==n)return t.substr(n+1).toLowerCase()},l.recursiveDeleteDirectory=function(e,t){var n=o.getPathSeparator(),i=o.fs,r=function(e){e&&"ENOENT"===e.code&&(e=null),t&&t(e)};p("readdir",e,function(t,o){if(t)r(t);else if(o&&0!==o.length){var a=null,s=0;o.forEach(function(t){var o=e+n+t;p("readdir",o,function(e){e?i.unlink(o,c):l.recursiveDeleteDirectory(o,c)})})}else i.rmdir(e,r);function c(t){t&&"ENOENT"===t.code&&(t=null),a=a||t,++s===o.length&&(a?r(a):i.rmdir(e,r))}})},l.moveLibrary=function(e,t,n){if(t!==e.id){var o=e._collection._getCompositeDir(t),i=e._getCompositeDir(),r=e._collection._getRenditionCacheDir(t),a=e._getRenditionCacheDir();l.rename(o,i,function(t){t?n(t):(e._dcxComposite.path=i,l.rename(r,a,n))})}else n(null)},l.readLibraryDirectory=function(e,t){var n=e._getTempDir();l.recursiveDeleteDirectory(n,function(){var n=e._getCompositeDir();p("readdir",n,t)})},l.doesRootDirExist=function(e,t){var n=o.fs,i=e._getCompositeDir();n.exists(i,function(e){t(null,e)})},l.deleteLibraryFromDisk=function(e,t,n){var r=i.wrapCallback(n);if(o.hasFileSystem()){var a=e._getCompositeDir(t),s=e._getRenditionCacheDir(t);l.recursiveDeleteDirectory(a,function(){l.recursiveDeleteDirectory(s,r)})}else r(null)},l.writeJSONData=function(e,t,n,i){var r=o.fs;l.ensurePathExists(e,function(a){if(a)i(a);else{var s=e+o.getPathSeparator()+t,c=s+".TEMP_"+o.uuid();r.writeFile(c,JSON.stringify(n,void 0,2),"utf8",function(e){e?i(e):p("rename",c,s,function(e){if(e)return i(e);i(null,s)})})}})},l.readJSONData=function(e,t){o.fs.readFile(e,"utf8",function(e,n){if(e){if("ENOENT"===e.code)return t(null)}else try{n=n&&JSON.parse(n)}catch(t){n=void 0,e=t}t(e,n)})},l.statFile=function(e,t){o.fs.stat(e,function(e,n){e?t(r.getFileSystemError(e,"unable to stat file")):t(null,n)})},l.checkFileSize=function(e,t){l.statFile(e,function(e,n){e?t(e):n&&n.size>a.MAX_COMPONENT_SIZE?t(new s(s.FILE_TOO_LARGE,"Exceeds maximum file size")):t(null)})},l.getImageDimensions=function(e,t){var n=l.getFileExtension(e);!n||c.includes(n)?a.SHARED_LOCAL_STORAGE?o.storageInterface.getImageDimensions(e,t):o.imageSize(e,function(e,n){t(n)}):t()},Object.seal(l),e.exports=l},function(e,t,n){var o=n(2);function i(){this._operations=[],this._isRunning=!1}i.prototype.addOperation=function(e,t,n){if(this._isRunning)throw new o(o.INVALID_PARAMETER,"Cannot add operations after calling run()");this._operations.push({operation:e,argsArray:t||[],thisObject:n})},i.prototype.run=function(e,t){function n(t,n,o){e&&e(t,n,o)}if(this._isRunning)throw new o(o.INVALID_PARAMETER,"Cannot call run() more than once");this._isRunning=!0;var i=this._operations.length;0===i&&n(null,!1,[]);var r,a=0,s=!1,c=[],l=[];this._operations.forEach(function(e,p){e.argsArray.push(function(e,d){!function(e,p,d){if(e&&t&&t(e),!s){if(r=r||e,c[d])return s=!0,void n(new o(o.INVALID_PARAMETER,"Operation not valid: calls callback multiple times"));if(a++,l[d]=p,c[d]=!0,a===i){s=!0;var u=!!l.reduce(function(e,t){return e||t},!1);n(r||null,u,l)}}}(e,d,p)}),e.operation.apply(e.thisObject,e.argsArray)})},Object.freeze(i),Object.seal(i.prototype),e.exports=i},function(e,t,n){var o=n(0),i=n(1),r=n(42),a=n(58),s=n(102),c=n(2),l=n(22),p=n(103),d=n(106),u=n(107),h=n(9),_=n(16),f=new s,m={};function E(e,t,n){var o=e+"/"+t,i=void 0!==m[o];return m[o]=m[o]||[],m[o].push(n),i}function g(e,t){var n;n=e===i.PUBLIC_USER_ID?f.getPublicLibraryCollection(t):f.getLibraryCollection(e,t);var o=e+"/"+t,r=m[o];r&&(delete m[o],r.forEach(function(e){e(null,n)}))}var y={configure:function(e,t){if(o.hasFileSystem()||void 0!==t.SHARED_LOCAL_STORAGE||(t.SHARED_LOCAL_STORAGE=!1),o.hasFileSystem()&&!t.ROOT_DIR&&!1===t.SHARED_LOCAL_STORAGE)throw new c(c.INVALID_PARAMETER,"Missing ROOT_DIR option");if(o.hasFileSystem()&&t.ROOT_DIR&&!1!==t.SHARED_LOCAL_STORAGE)throw new c(c.INVALID_PARAMETER,"ROOT_DIR option doesn't apply when using shared local storage");if(!o.hasFileSystem()&&t.ROOT_DIR)throw new c(c.REQUIRES_FILESYSTEM,"ROOT_DIR option only applies when you have a filesystem");if(!1===t.SHARED_LOCAL_STORAGE&&!t.STORAGE_API_KEY)throw new c(c.INVALID_PARAMETER,"Missing STORAGE_API_KEY option");if(!1===t.SHARED_LOCAL_STORAGE&&!t.DEVICE_ID)throw new c(c.INVALID_PARAMETER,"Missing DEVICE_ID option");if(!1!==t.SHARED_LOCAL_STORAGE&&!o.hasCEPVulcan()&&!e.vulcanCall)throw new c(c.INVALID_PARAMETER,"Shared local storage requires either the CEP VulcanInterface/VulcanMessage as globals, or for you to pass in the vulcanCall dependency");if(!t.APP_DESCRIPTION)throw new c(c.INVALID_PARAMETER,'Missing APP_DESCRIPTION option - should be a string of the form <name>-<version>, e.g. "PHXS-16.0".');if(t.ROOT_DIR)for(;-1!==["/","\\"].indexOf(t.ROOT_DIR.substr(-1));)t.ROOT_DIR=t.ROOT_DIR.slice(0,-1);t.LOCALE&&(l.setLocale(t.LOCALE),delete t.LOCALE),Object.keys(t).forEach(function(e){i.setParameter(e,t[e])}),o.analytics=e.analytics,o.vulcanCall=e.vulcanCall,o._log=e.log,o._getDisplayName=e.getDisplayName,o._getNodeTunnelOptions=e.getNodeTunnelOptions,e.renditionGenerator&&o.setRenditionGenerator(e.renditionGenerator),o.storageInterface&&o.storageInterface.shutdown(),o.storageInterface=new p(f),o.log("Configure: "+(i.SHARED_LOCAL_STORAGE?"<shared local storage>":i.ROOT_DIR))},setOption:function(e,t){if(-1!==["ROOT_DIR","SHARED_LOCAL_STORAGE","ELEMENT_TYPE_FILTERS","STORAGE_API_KEY"].indexOf(e))throw new c(c.INVALID_PARAMETER,"Cannot reconfigure "+e);i.setParameter(e,t),o.storageInterface.updateConfiguration()},getOption:function(e){return i[e]},setLocalSetting:function(e,t){if("string"!=typeof e)throw new c(c.INVALID_PARAMETER,"Key must be a string");try{JSON.stringify(t)}catch(e){throw new c(c.INVALID_PARAMETER,"Value must be serializable to JSON")}i.LOCAL_SETTINGS[e]=t,o.storageInterface.updateConfiguration()},getLocalSetting:function(e){return i.LOCAL_SETTINGS[e]},getLoadedCollections:function(){return f.getLoadedCollections().slice(0)},getLoadedCollectionById:function(e,t){return f.getLibraryCollection(e,t)},getLoadedPublicCollectionById:function(e){return f.getPublicLibraryCollection(e)},addLoadedCollectionsListener:function(e){f.addLoadedCollectionsListener(e)},removeLoadedCollectionsListener:function(e){f.removeLoadedCollectionsListener(e)},getRootDir:function(){if(!o.hasFileSystem())throw new c(c.REQUIRES_FILESYSTEM,"ROOT_DIR option only applies when you have a filesystem");return i.ROOT_DIR},getLocale:function(){return l.getLocale()},unloadLibraryCollection:function(e){if(i.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"unloadLibraryCollection() not supported with shared local storage");e.stopPolling(),e._removeAllListeners(),f.removeLibraryCollection(e)},loadLibraryCollection:function(e,t){if("function"!=typeof e)if(i.SHARED_LOCAL_STORAGE)t(new c(c.NOT_SUPPORTED,"loadLibraryCollection() not supported with shared local storage"));else if(!o.hasFileSystem()||i.SHARED_LOCAL_STORAGE||i.ROOT_DIR)if(e=e||{},!o.hasFileSystem()||e.USER_ID)if(e.CLOUD_ID=e.CLOUD_ID||i.DEFAULT_CLOUD_ID,e.STORAGE_HOSTNAME)if(e.COLLABORATION_HOSTNAME)if(e.CC_IMAGE_HOSTNAME)if(e.CC_IMAGE_X_HOSTNAME)if(e.TYPEKIT_HOSTNAME){var n=f.getLibraryCollection(e.USER_ID,e.CLOUD_ID),a=E(e.USER_ID,e.CLOUD_ID,t);if(!n||a){if(!a)if(n=new r(e),o.hasFileSystem())h.doesRootDirExist(n,function(e,t){n._load(function(){t||n._setInitialSyncState(!0),n.sync(function(){n._setInitialSyncState(!1)}),l()})});else if("all"===e.WAIT_FOR)n._setInitialSyncState(!0),n.sync(function(){n._setInitialSyncState(!1),l()});else if(_.validateLibraryId(e.WAIT_FOR,!1)){n._setInitialSyncState(!0,[e.WAIT_FOR]),n.sync(function(){n._setInitialSyncState(!1)});var s=function(){"syncing"===n.syncState&&"pending"===n._libraryIdMap[e.WAIT_FOR]||(n.removeChangeListener(s),n.removeSyncListener(s),l())};n.addChangeListener(s),n.addSyncListener(s)}else n._setInitialSyncState(!0),n.sync(function(){n._setInitialSyncState(!1)}),l()}else g(e.USER_ID,e.CLOUD_ID)}else t(new c(c.INVALID_PARAMETER,"Missing TYPEKIT_HOSTNAME option"));else t(new c(c.INVALID_PARAMETER,"Missing CC_IMAGE_X_HOSTNAME option"));else t(new c(c.INVALID_PARAMETER,"Missing CC_IMAGE_HOSTNAME option"));else t(new c(c.INVALID_PARAMETER,"Missing COLLABORATION_HOSTNAME option"));else t(new c(c.INVALID_PARAMETER,"Missing STORAGE_HOSTNAME option"));else t(new c(c.INVALID_PARAMETER,"Missing USER_ID option"));else t(new c(c.INVALID_PARAMETER,"ROOT_DIR not configured. Make sure you call CCLibraries.configure()"));else(t=e)(new c(c.INVALID_PARAMETER,"options argument not specified"));function l(){f.addLibraryCollection(n),i.AUTO_START_POLLING&&n.startPolling(),g(e.USER_ID,e.CLOUD_ID)}},loadPublicLibraryCollection:function(e,t){if("function"!=typeof e)if(i.SHARED_LOCAL_STORAGE)t(new c(c.NOT_SUPPORTED,"loadPublicLibraryCollection() not supported with shared local storage"));else if(!o.hasFileSystem()||i.SHARED_LOCAL_STORAGE||i.ROOT_DIR)if((e=e||{}).CLOUD_ID=e.CLOUD_ID||i.DEFAULT_CLOUD_ID,e.STORAGE_HOSTNAME){var n=f.getPublicLibraryCollection(e.CLOUD_ID),r=E(i.PUBLIC_USER_ID,e.CLOUD_ID,t);!n||r?r||(n=new a(e),o.hasFileSystem()?n._load(function(){n.sync(),s()}):s()):g(i.PUBLIC_USER_ID,e.CLOUD_ID)}else t(new c(c.INVALID_PARAMETER,"Missing STORAGE_HOSTNAME option"));else t(new c(c.INVALID_PARAMETER,"ROOT_DIR not configured. Make sure you call CCLibraries.configure()"));else(t=e)(new c(c.INVALID_PARAMETER,"options argument not specified"));function s(){f.addLibraryCollection(n),i.AUTO_START_POLLING&&n.startPolling(),g(i.PUBLIC_USER_ID,e.CLOUD_ID)}},isConnected:function(){if(!i.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"isConnected() is only applicable if using shared local storage");return o.storageInterface&&o.storageInterface.isConnected()},reconnect:function(){if(!i.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"reconnect() is only applicable if using shared local storage");o.storageInterface&&o.storageInterface.reconnect()},disconnect:function(){if(!i.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"disconnect() is only applicable if using shared local storage");o.storageInterface&&o.storageInterface.isConnected()&&o.storageInterface.shutdown()},getServiceInfo:function(){if(!i.SHARED_LOCAL_STORAGE)throw new c(c.NOT_SUPPORTED,"getServiceInfo() is only applicable if using shared local storage");return o.storageInterface&&o.storageInterface.getServiceInfo()},isSyncingEnabled:function(){if(i.SHARED_LOCAL_STORAGE){var e=y.getServiceInfo();return!(!e||!e.syncingEnabled)}return i.SYNCING_ENABLED},enableSyncing:function(){i.SHARED_LOCAL_STORAGE?o.storageInterface.setSyncEnabled(!0):(i.SYNCING_ENABLED=!0,y.getLoadedCollections().forEach(function(e){e.sync()}))},disableSyncing:function(){i.SHARED_LOCAL_STORAGE?o.storageInterface.setSyncEnabled(!1):i.SYNCING_ENABLED=!1},getLibraryById:function(e){var t;return y.getLoadedCollections().some(function(n){return t=n.getLibraryById(e)}),t},resolveElementReference:function(e){e=e||"";var t,n=new RegExp("cloud-asset://(.+)/([A-Za-z0-9-]+);node=([A-Za-z0-9-]+)"),o=e.match(n);if(o){var i=o[1],r=o[2],a=o[3];y.getLoadedCollections().every(function(e){if(i===e._syncManager.getElementRefDomainPath()){var n=e.getLibraryById(r);return n&&(t=n.getElementById(a)),!1}return!0})}return t}};y.errors=c,y.utils=d,y.analyticsUtils=u,Object.seal(y),e.exports=y},function(e,t,n){var o=n(3),i=n(2),r={getErrorStatusCode:function(e){if(e){var t=e.code===o.UNEXPECTED_RESPONSE&&e.response&&e.response.statusCode;return t||(e.underlyingError?r.getErrorStatusCode(e.underlyingError):void 0)}},getSyncError:function(e,t,n){if(e){var a=r.getErrorStatusCode(e);return e.code===o.SERVICE_IS_INACTIVE?new i(i.LOGGED_OUT,"no access token: call updateAccessToken() and try again",t,e):e.code===o.NETWORK_ERROR?new i(i.NETWORK_ERROR,"error connecting to server",t,e):e.code===o.EXCEEDS_QUOTA?new i(i.EXCEEDS_QUOTA,"push failed due to insufficient remaining quota",t,e):e.code===o.OUT_OF_SPACE?new i(i.OUT_OF_SPACE,"not enough disk space",t,e):e.code===o.NOT_IMPLEMENTED?new i(i.NOT_IMPLEMENTED,"tried to call an API not implemented on the server",t,e):e.code===o.RETRYABLE_SERVER_ERROR?new i(i.RETRYABLE_SERVER_ERROR,"intermittent server failure - can retry later",t,e):e.code===o.INVALID_DATA||e.code===o.INVALID_JSON?new i(i.CORRUPTED_LIBRARY,"unable to read manifest",t,e):a&&n&&n[a]?new i(n[a],"server returned "+a+"response",t,e):new i(i.TRANSFER_ERROR,"something went wrong during a push/pull operation",t,e)}},getCommitError:function(e,t,n){if(e){var r=n?" - "+n:"";return e.code===o.INVALID_DATA||e.code===o.INVALID_JSON?new i(i.CORRUPTED_LIBRARY,"unable to read manifest"+r,t,e):e.code===o.OUT_OF_SPACE?new i(i.OUT_OF_SPACE,"not enough disk space"+r,t,e):new i(i.FS_ERROR,"filesystem error"+r,t,e)}},getFileSystemError:function(e,t,n){if(e)return"ENOSPC"===e.code?new i(i.OUT_OF_SPACE,t,n,e):new i(i.FS_ERROR,t,n,e)},getSnapshotError:function(e,t,n){if(e)return e.code===o.INVALID_DATA||e.code===o.INVALID_PARAMS?new i(i.INVALID_DATA,n,t,e):r.getFileSystemError(e,n,t)},getErrorPriority:function(e){var t=[i.OPERATION_CANCELLED,i.EXCEEDS_MAX_LIBRARY_SIZE,i.THUMBNAIL_NOT_AVAILABLE,i.RENDITION_NOT_AVAILABLE,i.URL_VALIDATION_FAILED,i.CORRUPTED_LIBRARY,i.TRANSFER_ABORTED,i.TRANSFER_ERROR,i.NETWORK_ERROR,i.EXCEEDS_QUOTA,i.RETRYABLE_SERVER_ERROR,i.LOGGED_OUT,i.FILE_TOO_LARGE,i.INVALID_DATA,i.FS_ERROR,i.OUT_OF_SPACE,i.ACCESS_DENIED,i.NOT_ALLOWED,i.DELETED_LOCALLY,i.REQUIRES_FILESYSTEM,i.NOT_SUPPORTED,i.NOT_IMPLEMENTED,i.INVALID_PARAMETER,i.READ_ONLY],n=e&&e.code&&t.indexOf(e.code);return void 0!==n?n:-1},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,o=e.error,i=o&&o.message,r=o&&o.response&&o.response.statusCode;t+="\n    ["+n+"] "+i+(r?": "+r:"")}))),t},isErrorCode:function(e){return!!e&&(i.hasOwnProperty(e)&&i[e]===e)}};Object.seal(r),e.exports=r},function(e,t,n){var o=n(1),i=n(0),r=n(10),a=n(9),s=n(12),c=n(7),l={},p={"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,"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,"application/vnd.adobe.charts+zip":!0,"text/plain":!0,"text/rtf":!0},d=function(e,t){var n=i.fs;n.stat(e,function(o,i){o?t(o):i&&i.isDirectory()?a.recursiveDeleteDirectory(e,t):n.unlink(e,t)})};l.readRenditionCacheData=function(e,t){var n=i.getPathSeparator(),r=e._getRenditionCacheDir();a.readJSONData(r+n+o.RENDITION_CACHE_FILE,function(e,n){var o=n||{};o.renditions=o.renditions||{},t(null,o)})},l.writeRenditionCacheData=function(e,t,n){var s=e._getRenditionCacheDir();a.writeJSONData(s,o.RENDITION_CACHE_FILE,t,function(s){s?n(s):function(e,t,n){var s=i.getPathSeparator(),c=i.fs;if(e._dcxComposite.autoRemoveUnusedLocalFiles){var l={};Object.keys(t.renditions).forEach(function(n){var o=t.renditions[n];Object.keys(o).forEach(function(t){var n=o[t];l[n]=!0,delete e._pendingRenditionCacheItems[n]})});var p=e._getRenditionCacheDir();c.readdir(p,function(t,i){if(t)n(t);else{var c=new r;i.forEach(function(t){var n=a.normaliseTempFileName(t);t===o.RENDITION_CACHE_FILE||l[t]||e._pendingRenditionCacheItems[n]||c.addOperation(d,[p+s+t])}),c.run(n)}})}else n(null)}(e,t,n)})},l.copyRenditionCache=function(e,t,n,a){var c=t._library._getRenditionCacheDir()+i.getPathSeparator(),l=new r,p=n||{};Object.keys(p).forEach(function(n){var i=p[n],r=t.getRepresentationById(n);if(r&&!e.getRepresentationById(n)){var a=t.representations.indexOf(r);if(a>=0&&a<e.representations.length)n=e.representations[a].id}i===o.RENDITION_CACHE_PLACEHOLDER||s.isErrorCode(i)?e._renditionCache[n]=i:l.addOperation(e.setThumbnailCache,[n,c+i],e)}),o.SHARED_LOCAL_STORAGE?(l.run(),a(null)):l.run(a)},l.canComputeRenditionFromMimeType=function(e){return!!p[e]},l.canComputeRendition=function(e){return!(void 0===e._dcxComponent||!l.canComputeRenditionFromMimeType(e.type))},l.shouldPrefetchFullRendition=function(e){var t=(o.FULL_RENDITION_CONFIG||{})[e.type];if(!t)return!1;var n=!1;return Object.keys(t).forEach(function(o){var i=t[o];if("IF_NO_MATCHING_REPRESENTATION"===i.condition&&i.types){var r=e.representations.every(function(e){return-1===i.types.indexOf(e.type)});n=n||r}}),n},l.shouldPrefetchExternalLink=function(e){if(!e.isExternalLink)return!1;var t=(o.EXTERNAL_LINK_PREFETCH||{})[e.element.type];return void 0===t||t},l.prefetchRenditionsForElement=function(e,t){var n=c.wrapCallback(t);if(i.hasFileSystem()){var a=new r,s=o.RENDITION_SIZES||{};(s[e.type]||s["*"]||[]).forEach(function(t){a.addOperation(e.getThumbnailPath,[t],e)}),l.shouldPrefetchFullRendition(e)&&a.addOperation(e.getThumbnailPath,[void 0],e),e.representations.forEach(function(e){l.shouldPrefetchExternalLink(e)?a.addOperation(e.getContentPath,[],e):e.isExternalLink&&a.addOperation(e.testExternalLink,[],e)}),a.run(n)}else n(null)},l.prefetchRenditions=function(e,t){var n=c.wrapCallback(t);if(i.hasFileSystem()){var o=new r;e.elements.forEach(function(e){o.addOperation(l.prefetchRenditionsForElement,[e],l)}),o.run(n)}else n(null)},l.addToRenditionSizeConfig=function(e){var t=o.RENDITION_SIZES,n=t["*"]||[];n=JSON.parse(JSON.stringify(n));var 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(o){var i=t[o]||JSON.parse(JSON.stringify(n));e[o].forEach(function(e){-1===i.indexOf(e)&&i.push(e)}),t[o]=i}),o.setParameter("RENDITION_SIZES",t)},l.addToFullRenditionConfig=function(e){var t=o.FULL_RENDITION_CONFIG;Object.keys(e).forEach(function(n){var o=t[n]||{};e[n].forEach(function(e){e.id&&(o[e.id]=e)}),t[n]=o}),o.setParameter("FULL_RENDITION_CONFIG",t)},l.addToPendingSetRenditionCache=function(e,t,n,o,i){var r=[];return(e=e||{data:[],callbacks:[]}).data.forEach(function(o,i){e.callbacks[i]||o.element!==t.id||o.size!==n||"CLEAR"!==o.path||r.unshift(i)}),r.forEach(function(t){e.data.splice(t,1),e.callbacks.splice(t,1)}),e.data.push({element:t.id,size:n,path:o}),e.callbacks.push(i),e},Object.seal(l),e.exports=l},function(e,t){e.exports=require("path")},function(e,t,n){var o,i,r=n(6);i=n(63);var a={canUseFileSystem:!1,_setFS:function(e){o=e,a.canUseFileSystem=!!e},ensureDirectoryExists:function(e,t){var n=function(e){e&&"EEXIST"===e.code?t():t(e)},i=function(i){if(i)t();else{var s=r.parentDirectory(e);s?a.ensureDirectoryExists(s,function(i){i?t(i):o.mkdir(e,n)}):o.mkdir(e,n)}};e?o.exists(e,i):i(!0)},getTempFilePathAt:function(e,t){var n=function(){var o=e+r.generateUuid();a.exists(o,function(e){e?n():t(o)})};n()},exists:function(e,t){o.exists(e,t)},deleteFile:function(e,t){o.unlink(e,function(e){e&&"ENOENT"!==e.code?t(e):t()})},readFile:function(e,t,n){o.readFile(e,t,n)},writeFile:function(e,t,n,i){var s=r.parentDirectory(e);a.ensureDirectoryExists(s,function(r){r?i(r):o.writeFile(e,t,n,i)})},writeFileAtomically:function(e,t,n,i){var s=r.parentDirectory(e);a.ensureDirectoryExists(s,function(r){r?i(r):a.getTempFilePathAt(s+"/",function(r){o.writeFile(r,t,n,function(t){t?i(t):o.rename(r,e,i)})})})},createWriteStream:function(e,t){return o.createWriteStream(e,t)},createReadStream:function(e,t){return o.createReadStream(e,t)},move:function(e,t,n,i){var s=r.parentDirectory(t);a.ensureDirectoryExists(s,function(r){if(r)i(r);else if(n){var a=(new Date).getTime()/1e3;o.utimes(e,a,a,function(n){n?i(n):o.rename(e,t,i)})}else o.rename(e,t,i)})},info:function(e,t){o.stat(e,t)},directoryListing:function(e,t){var n,i,r=[],a=function(a){o.stat(e+"/"+a,function(e,o){if(!e)try{r.push({name:a,info:o}),n--}catch(t){e=t}e?i||(i=e,t(e)):0===n&&t(void 0,r)})};o.readdir(e,function(e,o){if(!e)try{var i,r=o.length;for(n=r,i=0;i<r;i++)a(o[i])}catch(t){e=t}e?t(e):0===n&&t(void 0,[])})},deleteDirectory:function(e,t){var n,i,r=function(){try{o.rmdir(e,t)}catch(e){t(e)}},s=function(e){e&&!n&&(n=e),--i<1&&(n?t(n):r())},c=function(t){var n=e+"/"+t;o.unlink(n,function(e){try{e?a.deleteDirectory(n,function(e){s(e)}):s()}catch(e){s(e)}})};o.readdir(e,function(e,n){if(!e)try{var o,a=n.length;if(a<1)r();else for(i=a,o=0;o<a;o++)c(n[o])}catch(t){e=t}e&&t(e)})}};a.copyFile=function(e,t,n){var i=r.parentDirectory(t);a.ensureDirectoryExists(i,function(i){i?n(i):function(e,t,n){try{var i=t+r.generateUuid(),a=o.createWriteStream(i),s=o.createReadStream(e);s.on("end",function(){o.rename(i,t,n)}),s.on("error",function(e){n(e)}),s.pipe(a)}catch(e){n(e)}}(e,t,n)})},a.getMD5Hash=function(e,t){const n=i.createHash("md5").setEncoding("base64");try{const i=o.createReadStream(e);i.pipe(n).on("finish",()=>t(null,n.read())),i.on("error",e=>t(e))}catch(e){t(e)}},e.exports=a},function(e,t,n){var o=n(45),i=n(3),r=n(1),a=n(0),s=n(22),c=n(2),l=n(18),p=n(10),d=/"manifest-format-version": ([0-9]+)/,u={},h={};u.isCompatibleType=function(e,t){return e===t||e===h[t]},u.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},u.validateLibrary=function(e){return(e.current&&e.current.rootNode.getValue(r.VERSION_KEY))===r.VERSION},u.areManifestsEqual=function(e,t){if(e===t)return!0;var n=d.exec(e),o=d.exec(t);if(n&&o&&n[1]!==o[1])try{var i=JSON.parse(e),r=JSON.parse(t);if(delete i["manifest-format-version"],delete r["manifest-format-version"],JSON.stringify(i)===JSON.stringify(r))return!0}catch(e){}return!1},u.getDCXKey=function(e,t){if(!e||!("string"==typeof e||e instanceof String)||""===e)throw new c(c.INVALID_PARAMETER,"Invalid namespace");if(!t||!("string"==typeof t||t instanceof String)||""===t)throw new c(c.INVALID_PARAMETER,"Invalid key");return e+"#"+t},u.getCustomDCXData=function(e){var t=[];return e.getCustomKeys().forEach(function(n){var o=n.split("#"),i=o.length>=2;i&&o.forEach(function(e){""===e&&(i=!1)});var a=0===n.indexOf(r.DL_PREFIX);i&&!a&&t.push({namespace:o.shift(),key:o.join("#"),value:e.getValue(n)})}),t},u.copyCustomDCXData=function(e,t){u.getCustomDCXData(e).forEach(function(e){t.setValue(u.getDCXKey(e.namespace,e.key),e.value)}),[r.REPRESENTATION_ORDER_KEY,r.IS_PREFERRED_THUMBNAIL_KEY].forEach(function(n){var o=e.getValue(n);o&&t.setValue(n,o)})},u.checkDeletedState=function(e,t){if(e.isDeletedLocally){if(t)return t(new c(c.DELETED_LOCALLY,"deleted/orphan object")),!0;throw new c(c.DELETED_LOCALLY,"deleted/orphan object")}return!1},u.checkEncoding=function(e,t,n){if(-1===t.indexOf(e)){var o=t.join(", ");return n(new c(c.INVALID_PARAMETER,"Unsupported encoding. Supported encodings are: "+o)),!1}return!0},u.sortRepresentations=function(e){if(e.length<2)return;let t=!0;for(;t;){t=!1;for(let n=1;n<e.length;n++){const o=e[n-1],i=e[n];i._getOrder()<o._getOrder()&&(e[n-1]=i,e[n]=o,t=!0)}}},u.removeMissingComponents=function(e,t){if(e&&t){var n=0,o=0;return t.forEach(function(t){var i=t.component,r=t.error;i&&r&&r.response&&404===r.response.statusCode&&(e.removeComponent(i),n++,a.log("Removed missing component: "+i.id+" from library "+e.compositeId)),i&&r&&"[UNEXPECTED_RESPONSE] Incorrect content length"===r.message&&(o++,a.log("Skipped length-mismatch component: "+i.id+" from library "+e.compositeId))}),a.log("Fixed "+n+" of "+t.length+" components that failed to download"),l.reportRemoveMissingComponents(e.compositeId,t,n),t.length===n+o?e:void 0}};u.removeMissingLocalComponents=function(e,t){if(e&&t){var n=0,o=[];t.forEach(function(t){var r=t.component,s=t.error;if(r&&s&&s.code===i.INVALID_STATE){var c=function(e,t){var n;return e.elements.some(function(e){return e.representations.some(function(e){if(e.id===t)return n=e,!0})}),n}(e,r.id);c?o.push(c):e._dcxBranch.removeComponent(r),n++,a.log("Removed missing local component: "+r.id+" from library "+e.id)}}),n>0&&(e._beginOperation(),o.forEach(function(e){e.element.removeRepresentation(e)}),e._endOperation()),a.log("Fixed "+n+" of "+t.length+" components that failed to upload")}},u.recoverReadOnlyEdits=function(e,t,n){var o=[];e.elements.forEach(function(e){var n=t&&t.getChildWithId(e.id);(n&&n.getValue(r.MODIFIED_KEY))!==e.modified&&o.push(e)});var i=new p;if(o.length>0){var c,l=s.translate("LIBS_RECOVERED_LIBRARY",{name:e.name});e.collection.libraries.some(function(e){if(e.name===l&&e.isWritable&&"incoming"!==e.collaboration&&e.elements.length<r.MAX_ELEMENTS)return c=e,!0}),c||(c=e.collection.createLibrary(l)),o.forEach(function(t){i.addOperation(e.copyElement,[t,c],e)}),a.log("Recovering "+o.length+" elements from read-only library")}i.run(n)},u.ensureBranchDataValid=function(e){var t=[r.ELEMENTS_NAME,r.REMOVED_ELEMENTS_NAME],n=!1;return e.getChildrenOf().forEach(function(o){if(-1!==t.indexOf(o.name)){var i=o.name===r.REMOVED_ELEMENTS_NAME;e.getChildrenOf(o).forEach(function(e){var t=e.getValue(r.REMOVED_KEY);!i&&t?(e.removeValue(r.REMOVED_KEY),n=!0):i&&!t&&(e.setValue(r.REMOVED_KEY,(new Date).valueOf()),n=!0)})}}),n},u.collaborationStateToDCX=function(e){return"incoming"===e?o.COLLABORATION.SHARED_WITH_USER:"outgoing"===e?o.COLLABORATION.SHARED_BY_USER:o.COLLABORATION.PRIVATE},u.collaborationStateFromDCX=function(e){return e===o.COLLABORATION.SHARED_WITH_USER?"incoming":e===o.COLLABORATION.SHARED_BY_USER?"outgoing":void 0},u.getCompositeRenditionMap=function(e){var t=e.getComponentsOf(),n={};return t&&t.forEach(function(e){if("rendition"===e.relationship){var t=e.getValue(r.RENDITION_TYPE_KEY);t&&(n[t]=e)}}),n},Object.seal(u),e.exports=u},function(e,t,n){var o=n(8),i=n(5),r=n(1);o.log("Vulcan","Loading Vulcan Library...");var a=n(114),s=new a.VulcanAdapter("LIBS","1.0.0"),c=new a.VulcanControlAdapter;o.log("Vulcan","Vulcan Library Successfully Loaded");var l=new i;s.addMessageListener(function(e,t,n,i){e=e.replace(r.VULCAN_PREFIX,""),l.hasListeners(e)&&(o.log("Vulcan","<- "+n+" "+i+": "+e),l.notify(e,[t,n,i]))});var p={sendMessage:function(e,t,n,i){var r=n?n+" "+(i||"*"):"BROADCAST";o.log("Vulcan","-> "+r+": "+e),s.sendMessage(e,t||"",n||"",i||"")},addListener:function(e,t){l.add(e,t)},removeListener:function(e,t){l.remove(e,t)},call:function(e,t){var n,i,r=!1,a=function(o,a){r||!1!==t(o,a)&&(r=!0,clearTimeout(n),l.remove(e.responseType,i))};i=function(e){a(null,e)},l.add(e.responseType,i),e.timeout&&(n=setTimeout(function(){o.log("Vulcan","Timed out on "+e.responseType),a("timeout")},e.timeout)),p.sendMessage(e.requestType,e.payload,e.targetId,e.targetVersion)}};p.isAppInstalled=c.isAppInstalled.bind(c),p.getSpecifiers=c.getSpecifiers.bind(c),p.getAppPath=c.getAppPath.bind(c),p.isAppRunning=c.isAppRunning.bind(c),p.getAppVersion=c.getAppVersion.bind(c),p.launchApp=c.launchApp.bind(c),e.exports=p},function(e,t,n){var o,i,r=n(0),a=n(1);function s(e){if(!e)return{};var t={libraryID:e.id,libraryElementCount:e._elements.length,libraryGroupCount:e._groups?e._groups.length:0};return e.collection.isPublic?t.libraryShared="incoming-public":e.collaboration&&(t.libraryShared=e.collaboration,e.isWritable||(t.libraryShared+="-readonly")),t}function c(e){if(!e)return{};var t=s(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 l(e,t){if(!e)return{};var n=t?{}:s(e._library);return n.groupID=e.id,n.groupClassifierName=e.classifierName,n}function p(e){if(!e)return{};var t=c(e.element);return t.appCode=e.appCode,t.elementAction=e.id,t}function d(){return null!==r.analytics&&void 0!==r.analytics}var u={reportError:function(e){d()&&e&&r.analytics.reportError(e.code+(e.underlyingError?":"+e.underlyingError.code:""))},reportCreateLibrary:function(e){d()&&r.analytics.reportEvent("createLibrary",{libraryID:e.id})},reportDeleteLibrary:function(e){d()&&r.analytics.reportEvent("deleteLibrary",s(e))},reportExportLibrary:function(e,t){if(d()){var n=t?s(t):{};e&&(n.error=e.code),r.analytics.reportEvent("exportLibrary",n)}},reportImportLibrary:function(e,t){if(d()){var n=t?s(t):{};e&&(n.error=e.code),r.analytics.reportEvent("importLibrary",n)}},reportCreateElement:function(e){d()&&(o=e,i=Date.now(),r.analytics.reportEvent("createElement",c(e)))},reportUpdateElement:function(e,t){if(d()){if(e===o&&Date.now()-i<a.ANALYTICS_ELEMENT_UPDATE_THRESHOLD)return;o=e,i=Date.now();var n=c(e);n.updateType=t?"info":"representation",r.analytics.reportEvent("updateElement",n)}},_reportUpdateElementMetadata:function(e,t,n){if(d()){var o=c(e);o.updateType=t,n&&Object.assign(o,n),r.analytics.reportEvent("updateElementMetadata",o)}},reportSetOrderInGroup:function(e,t,n){var o=l(t,!0);o.elementOrderInGroup=e.getOrderInGroup(t),o.removeExistingGroups=n,this._reportUpdateElementMetadata(e,"order",o)},reportSetDescription:function(e){this._reportUpdateElementMetadata(e,"description")}};u.reportUseElement=function(e,t,n){if(d()){var o=function(e){if(!e)return{};var t=c(e._element);return t.representationType=e.type,t}(e);o.opType=t,o.details=n,r.analytics.reportEvent("useElement",o)}},u.reportCheckoutElement=function(e,t,n){if(d()){var o=c(e);o.opType=t,o.details=n,r.analytics.reportEvent("checkoutElement",o)}},u.reportDeleteElement=function(e,t){if(d()){var n=c(e);n.isPermanent=!!t,r.analytics.reportEvent("deleteElement",n)}},u.reportRestoreElement=function(e){d()&&r.analytics.reportEvent("restoreElement",c(e))},u.reportCopyElement=function(e,t){if(d()){o=e,i=Date.now();var n=c(e);n.oldLibraryID=t._library.id,n.oldElementID=t.id,r.analytics.reportEvent("copyElement",n)}},u.reportMoveElement=function(e,t){if(d()){o=e,i=Date.now();var n=c(e);n.oldLibraryID=t._library.id,n.oldElementID=t.id,r.analytics.reportEvent("moveElement",n)}},u.reportCreateGroup=function(e){d()&&r.analytics.reportEvent("createGroup",l(e))},u.reportUpdateGroup=function(e){if(d()){var t=l(e);t.updateType="name",r.analytics.reportEvent("updateGroup",t)}},u.reportUpdateGroupMetadata=function(e,t){if(d()){var n=l(e);n.updateType="order",n.groupOrder=t,r.analytics.reportEvent("updateGroupMetadata",n)}},u.reportDeleteGroup=function(e,t,n){if(d()){var o=l(e);o.includeContents=t,t&&(o.numberElementsInGroup=n),r.analytics.reportEvent("deleteGroup",o)}},u.reportCopyGroup=function(e,t,n,o){if(d()){var i=l(e);i.oldLibraryID=t._library.id,i.oldGroupID=t.id,i.includeContents=n,n&&(i.numberElementsInGroup=o),r.analytics.reportEvent("copyGroup",i)}},u.reportMoveGroup=function(e,t,n,o){if(d()){var i=l(e);i.oldLibraryID=t._library.id,i.oldGroupID=t.id,i.includeContents=n,n&&(i.numberElementsInGroup=o),r.analytics.reportEvent("moveGroup",i)}},u.reportCollisionElement=function(e){d()&&r.analytics.reportEvent("collisionLibrary",c(e))},u.reportCreateLink=function(e,t){if(d()){var n=c(e);n.opType=t,r.analytics.reportEvent("createLink",n)}},u.reportShareElementLink=function(e){d()&&r.analytics.reportEvent("shareElementLink",c(e))},u.reportShareLibraryLink=function(e){d()&&r.analytics.reportEvent("shareLibraryLink",s(e))},u.reportElementActionInvoked=function(e){d()&&r.analytics.reportEvent("elementActionInvoked",p(e))},u.reportElementActionSuccessful=function(e,t){if(d()){var n=p(e);n.appVersion=t&&t.version,n.appLaunchStatus=t?t.isAlreadyRunning?"Running":"Launched":"Unknown",r.analytics.reportEvent("elementActionSuccessful",n)}},u.reportElementActionFailed=function(e,t){if(d()){var n=p(e);n.error=t?t.code+":"+t.message:"",r.analytics.reportEvent("elementActionFailed",n)}},u.reportUnexpectedState=function(e,t){if(d()){var n=s(e);n.details=t,n.logs=!0,r.analytics.reportEvent("unexpectedState",n)}},u.reportRemoveMissingComponents=function(e,t,n){if(d()){var o={libraryID:e,numMissing:t.length,numFixed:n,componentErrors:[]};t.forEach(function(e){var t=e.error,n=t&&t.code,i=t&&t.response&&t.response.statusCode,r=(n||"UNKNOWN_ERROR")+(i?": "+i:"");o.componentErrors.push(r)}),r.analytics.reportEvent("removeMissingComponents",o)}},Object.seal(u),e.exports=u},function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("os")},function(e,t,n){var o=n(3),i=n(27),r=n(48),a=n(65),s=n(40).STATES,c=n(15),l=n(6),p={PRIVATE:void 0,SHARED_BY_USER:"sharedByUser",SHARED_WITH_USER:"sharedWithUser"};function d(e,t,n,o,r,a){r=l.ensureRelativeHrefStartsWithSlash(r),this._options=a||{},n?this._setPath(n):r?(this._href=r,e&&(this._name=e),t&&(this._type=t),o&&(this._id=o)):t&&(this._current=new i,e&&(this._current._data.name=e),this._current._data.type=t,o&&(this._current.compositeId=o)),this._autoRemoveUnusedLocalFiles=!0,this._options.xhrBaseBranchSupport&&(this._baseBranchData=void 0,this._pushedBranchData=void 0,this._pulledBranchData=void 0),this._collaborationType=p.PRIVATE}d.newCompositeAsCopyOf=function(e,t,n,r,a,s,c){var p=e._core;if(p||e.current&&(p=e.current._core),!p)throw new o(o.INVALID_PARAMS,"compositeBranchOrElement must be a branch, an element or a composite with a current branch.");var u=new d(void 0,void 0,void 0,void 0,void 0,c);return r&&(u.path=r),u._current=i._newBranchAsCopyOfCore(p,this._localStorage),u.id=a||l.generateUuid(),t&&(u.name=t),n&&(u.type=n),s&&(u.href=s),u},d.COLLABORATION=p,Object.defineProperties(d.prototype,{id:{get(){return this._current?this._current.compositeId:this._id},set(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string.");this._current&&(this._current.compositeId=e),this._id=e}},name:{get(){return this._current?this._current.name:this._name},set(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string.");this._current&&(this._current.name=e),this._name=e}},type:{get(){return this._current?this._current.type:this._type},set(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string.");this._current&&(this._current.type=e),this._type=e}},href:{get(){return this._current?this._current.compositeHref:this._href},set(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string.");e=l.ensureRelativeHrefStartsWithSlash(e),this._current&&(this._current.compositeHref=e),this._href=e}},collaborationType:{get(){return this._current?this._current._collaborationType:this._collaborationType},set(e){if(e!==p.PRIVATE&&e!==p.SHARED_BY_USER&&e!==p.SHARED_WITH_USER)throw new o(o.INVALID_PARAMS,"Invalid value: ."+e);this._current&&(this._current._collaborationType=e),this._collaborationType=e}},clientDataString:{get(){return this._current?this._current._clientDataString:this._clientDataString},set(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(){return this._path},set(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a string.");this._setPath(e)}},isBound:{get(){return this._current&&this._current.isBound||!this._current&&this._href},set(){throw new o(o.READ_ONLY,"Cannot set the property isBound. Use resetIdentity or resetBinding instead.")}},hasLocalStorage:{get(){return this._localStorage},set(){throw new o(o.READ_ONLY,"Cannot set the property hasLocalStorage.")}},autoRemoveUnusedLocalFiles:{get(){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");return this._autoRemoveUnusedLocalFiles},set(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._autoRemoveUnusedLocalFiles=e}},clientDataStoragePath:{get(){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");return this._localStorage.clientDataPath()},set(){throw new o(o.READ_ONLY,'Property "clientDataStoragePath" is read-only.')}},current:{get(){return this._current},set(){throw new o(o.READ_ONLY,'Property "current" is read-only.')}}}),d.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,o){if(!n&&o)try{t._current=o,t._currentBranchCommittedAtDate=l.timeStamp(!0)}catch(e){n=e}e(n,n?void 0:o)})},d.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;c.writeFileAtomically(this._localStorage.currentManifestPath(),this._current.localData,"utf8",function(n){if(!n)try{t._currentBranchCommittedAtDate=l.timeStamp(!0),t._current._isDirty=!1}catch(e){n=e}e(n)})},d.prototype.tempAssetPath=function(){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");return this._localStorage.tempPathForComponent()},d.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)})},d.prototype.removeUnusedLocalFiles=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._localStorage.removeUnusedLocalFiles(this._currentBranchCommittedAtDate,e)},d.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,l){if(r&&"ENOENT"!==r.code)t([r]);else{var p,d,u=[],h={};for(p=0;p<e.length;++p){var _=e[p],f=i.getComponentWithId(_),m=a?a.getComponentWithId(_):void 0,E=l?l.getComponentWithId(_):void 0;if(!(f&&"/META-INF/metadata.xml"===f.absolutePath||m&&"/META-INF/metadata.xml"===m.absolutePath||E&&"/META-INF/metadata.xml"===E.absolutePath))if(f&&f.state===s.modified||m&&m.state===s.modified){var g=new o(o.COMPONENT_MODIFIED_ERROR,"Cannot remove the file of a modified component.");g.componentId=_,u.push(g)}else f&&(d=i.assetOfComponent(f))&&(void 0===h[d]&&(h[d]=_),n._localStorage.removeComponentAsset(f,i._local()),i._setDirty(!0)),m&&(d=a.assetOfComponent(m))&&void 0===h[d]&&(h[d]=_),E&&(d=l.assetOfComponent(E))&&void 0===h[d]&&(h[d]=_)}var y=Object.keys(h),v=y.length;if(v>0){var A=function(e){c.deleteFile(e,function(n){n&&(n.componentId=h[e],u.push(n)),0===--v&&t(u.length>0?u:void 0)})};for(p=0;p<y.length;++p)A(y[p])}else t(u.length>0?u:void 0)}})})},d.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."));c.deleteDirectory(this._path,e)},d.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 i(void 0,!0).parse(this._baseBranchData)}catch(e){t=e}e(t,n)}},d.prototype.loadPulledBranch=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._loadBranch(this._localStorage.pulledManifestPath(),!1,e)},d.prototype.loadPushedBranch=function(e){if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");this._loadBranch(this._localStorage.pushedManifestPath(),!1,e)},d.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)}},d.prototype.acceptPush=function(e){if(this._localStorage&&!e)throw new o(o.INVALID_PARAMS,"Need a callback function.");var t,n,i=this,a=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,a();var s,c=2;r.readJournal(i._localStorage.pushJournalPath(),i,!1,function(e,n){c--,s?a():(e?"ENOENT"!==e.code&&(s=new o(o.INVALID_STATE,"Failed to load push journal.",e)):t=n,c||a())}),this._loadBranch(this._localStorage.currentManifestPath(),!1,function(e,t){c--,s?a():(e?s=new o(o.INVALID_STATE,"Failed to load current manifest.",e):n=t,c||a())})},d.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)})},d.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)})},d.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())},d.prototype.resetIdentity=function(e){delete this._href,this._current?(this._current._resetIdentity(),this._id=this._current.compositeId):this._id=l.generateUuid(),this._localStorage?this._discardEveryBranchButCurrent(e):(this._baseBranchData=void 0,this._pushedBranchData=void 0,this._pulledBranchData=void 0,e&&e())},d.prototype._loadBranch=function(e,t,n){if("function"!=typeof n)throw new o(o.INVALID_PARAMS,'Param "callback" must be a function.');var r=this;c.exists(e,function(o){o?c.readFile(e,"utf8",function(o,a){var s;if(!o)try{(s=new i(void 0,t,e).parse(a))._localStorage=r._localStorage}catch(e){o=e}n(o,s)}):n()})},d.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)},d.prototype._setPath=function(e){this._localStorage?this._localStorage.compositePath=e:c.canUseFileSystem&&(this._localStorage=new a(e,this._options.preserveFileExtensions),this._current&&(this._current._localStorage=this._localStorage)),this._path=e},e.exports=d},function(e,t,n){var o=n(0),i=n(7),r={},a="undefined"!==typeof LOCALE_ROOT;function s(){this.setLocale()}o.hasFileSystem()&&a||(r={cs_CZ:n(70),da_DK:n(71),de_DE:n(72),en_US:n(73),es_ES:n(74),es_MX:n(75),fi_FI:n(76),fr_CA:n(77),fr_FR:n(78),fr_MA:n(79),hu_HU:n(80),it_IT:n(81),ja_JP:n(82),ko_KR:n(83),nb_NO:n(84),nl_NL:n(85),pl_PL:n(86),pt_BR:n(87),ru_RU:n(88),sv_SE:n(89),tr_TR:n(90),uk_UA:n(91),zh_CN:n(92),zh_TW:n(93)}),s.prototype._getLocaleData=function(e){if(!r[e]&&o.hasFileSystem()&&a)try{r[e]=o.fs.readFileSync(LOCALE_ROOT+e+"/messages.properties","utf8")}catch(e){}return r[e]},s.prototype._normaliseLocale=function(e){if(e){var t=(e=e.replace("-","_")).split("_");return t[0]=t[0]&&t[0].toLowerCase(),t[1]=t[1]&&t[1].toUpperCase(),t.join("_")}},s.prototype.setLocale=function(e){(e=this._normaliseLocale(e))&&this._getLocaleData(e)||(e="en_US"),this._locale=e,this._strings=i.parseLocalisationFile(this._getLocaleData(this._locale))},s.prototype.getLocale=function(){return this._locale},s.prototype.translate=function(e,t){var n=this._strings[e];return n&&t&&(n=i.constructStringFromTemplate(n,t)),n||e},Object.freeze(s),Object.seal(s.prototype),e.exports=new s},function(e,t){function n(){this._isLocked=!1,this._pendingContinuations=[]}n.prototype.obtain=function(e,t){this._isLocked?this._pendingContinuations.push({continuation:e,thisObject:t}):(this._isLocked=!0,e.apply(t,[null]))},n.prototype.release=function(){if(this._pendingContinuations.length>0){var e=this._pendingContinuations.shift();setTimeout(function(){e.continuation.apply(e.thisObject,[null])})}else this._isLocked=!1},n.prototype.abortPendingOperations=function(e){var t=this._pendingContinuations;this._pendingContinuations=[],t.forEach(function(t){t.continuation.apply(t.thisObject,[e])})},n.prototype.isLocked=function(){return this._isLocked},n.prototype.hasPendingRequest=function(){return this._pendingContinuations.length>0},Object.freeze(n),Object.seal(n.prototype),e.exports=n},function(e,t,n){var o,i,r=n(8),a="Proxy",s={},c=new(n(5))(["change","error"]),l={},p=n(117)(function(e,t){r.log(a,t),0===e&&c.notify("error",[t])});function d(e,t){p.resolve(e,function(e,n){e?t(e):t(null,n&&n[0])})}function u(e,t){d(e,function(n,i){delete t.agent,t.agent=i&&i.agent,t.agent?r.log(a,"Setting proxy for "+e+": "+i.hostname+":"+i.port+(o?" with":" without")+" authentication"):r.log(a,"No proxy (direct connection) for "+e)})}function h(){Object.keys(s).forEach(function(e){u(e,s[e])})}p.setAuthenticationCallback(function(e,t){var n=l[e.proxy.host+e.proxy.port]||{};n.username===o&&n.password===i?t("No new credentials"):o?(n.username=o,n.password=i,t(null,n),l[e.proxy.host+e.proxy.port]=n):t("No credentials present")}),p.on("change",function(){r.log(a,"System proxy settings changed"),h(),c.notify("change",[!0])});var _={};_.isLocalhostProxied=p.isLocalhostProxiedUnderHttp,_.addListener=function(e,t){c.add(e,t)},_.removeListener=function(e,t){c.remove(e,t)},_.removeAllListeners=function(e){c.removeAll(e)},_.getProxyForURL=function(e,t){d(e,t)},_.getNodeTunnelOptionsForURL=function(e){if(!s[e]){var t={};s[e]=t,u(e,t)}return s[e]},_.setProxyCredentials=function(e,t){o===e&&i===t||(r.log(a,"Setting proxy username and password"),o=e,i=t,h(),c.notify("change",[!1]))},_.getProxyCredentials=function(){return{user:o,password:i}},_.getRootCA=function(e){p.getRootCA(e)},_.getOSLocale=function(){return p.getOSLocale()},e.exports=_},function(e,t,n){var o,i=n(20),r=n(121),a=n(4),s=n(8),c=n(24),l=n(36),p=n(11),d=n(1),u=n(0),h=n(34),_=function(){if(!o){var e={ENVIRONMENT:"Staging"===a.getEnvironment().LABEL?"stage":"prod",ANALYTICS_API_KEY:a.getEnvironment().CLIENT_ID,ANALYTICS_X_PRODUCT:"CCLibraryProcess/"+h.version,ANALYTICS_PROJECT:a.getValue("ANALYTICS_PROJECT"),ANALYTICS_INGEST_TYPE:a.getValue("ANALYTICS_INGEST_TYPE"),ANALYTICS_MAX_QUEUED_EVENTS:a.getValue("MAX_QUEUED_ANALYTICS"),ANALYTICS_DEBOUNCE:a.getValue("ANALYTICS_DEBOUNCE"),ANALYTICS_USER_REGION:"US"};(o=new r({getAccessToken(e){l.getAccessToken(e)},getAgent(e,t){var n=c.getNodeTunnelOptionsForURL(e);t(null,n&&n.agent)},log(e){s.log("Analytics",e)}},e)).enable(d.SHARED_LOCAL_STORAGE_ANALYTICS)}return o},f=[];var m={_updateDefaults:function(e){e.logs&&(e.logs=s.getRecentLogs(),s.clearRecentLogs());var t=p.getLoadedCollections(),n={"event.guid":u.uuid(),"event.user_guid":l.getUserId(),"event.category":"Library-Process","event.type":"info","event.dts_end":(new Date).valueOf(),"event.cloud_id":t&&t.length>0?t[0].cloudId:"","source.client_id":a.getEnvironment().CLIENT_ID,"source.version":h.version,"source.platform":i.platform()};return Object.keys(e).forEach(function(t){-1===t.indexOf(".")?n["ccxlp."+t]=e[t]:n[t]=e[t]}),n},_postEvent:function(e,t,n){_().postEvent(e,n),t&&_().flush(!0)},_reset:function(){o=void 0},reportEvent:function(e,t,n,o){t=Object.assign({"event.type":"info","event.subtype":e},t||{}),t=m._updateDefaults(t),m._postEvent(t,n,o)}};m.reportError=function(e,t,n,o){var i=e+": "+(t||"");if(function(e){return-1===f.indexOf(e)&&(f.length===a.getValue("ANALYTICS_ERROR_HISTORY")&&f.shift(),f.push(e),!0)}(i)){var r={"event.type":"error","event.error_type":e,"event.error_desc":i};r=m._updateDefaults(r),m._postEvent(r,n,o)}else o&&o(null,0)},m.setEnabled=function(e){d.SHARED_LOCAL_STORAGE_ANALYTICS!==e&&(d.setParameter("SHARED_LOCAL_STORAGE_ANALYTICS",e),a.setValue("SHARED_LOCAL_STORAGE_ANALYTICS",d.SHARED_LOCAL_STORAGE_ANALYTICS),_().enable(d.SHARED_LOCAL_STORAGE_ANALYTICS))},m.isEnabled=function(){return d.SHARED_LOCAL_STORAGE_ANALYTICS},e.exports=m},function(e,t){e.exports=require("https")},function(e,t,n){var o=n(46),i=n(64),r=n(3),a=n(6),s=6;function c(e,t,n){if(e)e=this._setData(e,t);else{var i=a.generateUuid();e={"manifest-format-version":s,id:i},this.originalManifestFormatVersion=s,this._core=new o(e,this,t),this._data=e}this._pendingElements=[],this.manifestPath=n}function l(e){var t=e["manifest-format-version"];if(t<s){if(t<4)throw new r(r.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,o,i=t.components;if(i)for(o=i.length,n=0;n<o;n++)delete i[n].localStorageAssetId;var r=t.children;if(r)for(o=r.length,n=0;n<o;n++)e(r[n])}(e),t<6&&function e(t,n){n&&t.path&&delete t.path;var o,i=t.components;if("object"==typeof i)for(o=0;o<i.length;o++){var r=i[o];"number"==typeof r.version&&(r.version=r.version.toString())}var a=t.children;if("object"==typeof a)for(o=0;o<a.length;o++)e(a[o])}(e,!0)}}c._newBranchAsCopyOfCore=function(e,t){var n=new c(JSON.parse(JSON.stringify(e._data))),o=n._core;return n._localStorage=t,n._resetIdentity(function(n){var i=e.getComponentWithId(n.id);if(!i)throw new r(r.INVALID_STATE,"Could not find original component.");if("modified"===i.state||!i.etag)throw new r(r.INVALID_STATE,"Cannot create a new composite from a branch that contains modified or unbound components.");var a=e._getHrefOfComponent(i);if(!a)throw new r(r.INVALID_STATE,"Cannot determine the href of component id "+i.id);o._setSourceHrefOfComponent(a,n),t&&t.removeComponentAsset(n,o._local())}),n},Object.defineProperties(c.prototype,{compositeId:{get(){return this._core.rootNode.id},set(e){var t=this._core;if(t._readOnly)throw new r(r.READ_ONLY,"This object is read-only.");if("string"!=typeof e||""===e)throw new r(r.INVALID_PARAMS,"Expecting a non-empty string.");if(t._allNodes[e])throw new r(r.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(){return this._core.rootNode},set(e){this._core.rootNode=e}},name:{get(){return this._core.rootNode.name},set(e){var t=this._core;if(t._readOnly)throw new r(r.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new r(r.INVALID_PARAMS,"Expecting a string or undefined.");t.rootNode.name=e}},type:{get(){return this._core.rootNode.type},set(e){var t=this._core;if(t._readOnly)throw new r(r.READ_ONLY,"This object is read-only.");if("string"!=typeof e||""===e)throw new r(r.INVALID_PARAMS,"Expecting a non-empty string.");t.rootNode.type=e}},compositeHref:{get(){return this._data.local?this._data.local.compositeHref:void 0},set(e){var t=this._core;if(t._readOnly)throw new r(r.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new r(r.INVALID_PARAMS,"Expecting a string or undefined.");t._local().compositeHref=a.ensureRelativeHrefStartsWithSlash(e),t._setDirty(!0)}},_collaborationType:{get(){return this._data.local?this._data.local.collaborationType:void 0},set(e){var t=this._core;if(t._readOnly)throw new r(r.READ_ONLY,"This object is read-only.");e?t._local().collaborationType=e:delete t._local().collaborationType,t._setDirty(!0)}},_clientDataString:{get(){return this._data.local?this._data.local.clientDataString:void 0},set(e){var t=this._core;if(t._readOnly)throw new r(r.READ_ONLY,"This object is read-only.");e?t._local().clientDataString=e:delete t._local().clientDataString,t._setDirty(!0)}},manifestEtag:{get(){return this._data.local?this._data.local.manifestEtag:void 0},set(e){var t=this._core;if(t._readOnly)throw new r(r.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new r(r.INVALID_PARAMS,"Expecting a string or undefined.");t._local().manifestEtag=e,t._setDirty(!0)}},compositeState:{get(){return this._data.state||"unmodified"},set(e){var t=this._core;if(t._readOnly)throw new r(r.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new r(r.INVALID_PARAMS,"Expecting a string.");if("unmodified"!==e&&"modified"!==e&&"pendingDelete"!==e&&"committedDelete"!==e)throw new r(r.INVALID_PARAMS,'State must be "modified", "unmodified", "pendingDelete", or "committedDelete".');if("pendingDelete"===e&&"committedDelete"===e&&("pending"===this.compositeArchivalState||"archived"===this.compositeArchivalState))throw new r(r.INVALID_STATE,"Cannot delete an archived composite.");this._data.state=e,t._setDirty(!0)}},compositeArchivalState:{get(){return this._core._local().archivalState||"active"},set(e){var t=this._core;if(t._readOnly)throw new r(r.READ_ONLY,"This object is read-only.");if("string"!=typeof e)throw new r(r.INVALID_PARAMS,"Expecting a string.");if("pending"!==e&&"archived"!==e&&"active"!==e)throw new r(r.INVALID_PARAMS,'State must be "pending", "archived", or undefined.');if("archived"===this.compositeArchivalState)throw new r(r.INVALID_STATE,"Composite has already been archived.");if("active"!==e&&("pendingDelete"===this.compositeState||"committedDelete"===this.compositeState))throw new r(r.INVALID_STATE,"Cannot archive a deleted composite.");"active"===e?delete this._core._local().archivalState:this._core._local().archivalState=e,t._setDirty(!0)}},isBound:{get(){return this.manifestEtag&&this.compositeHref},set(){throw new r(r.READ_ONLY,"Cannot set the property isBound. Use resetIdentity instead.")}},_localStorage:{get(){return this._core._localStorage},set(e){this._core._localStorage=e}},hasLocalStorage:{get(){return this._core.hasLocalStorage},set(e){this._core.hasLocalStorage=e}},_isDirty:{get(){return this._core._isDirty},set(e){this._core._isDirty=e}},isDirty:{get(){return this._core.isDirty},set(e){this._core.isDirty=e}},localData:{get(){return this._core._stringify(!1,!0)},set(){throw new r(r.READ_ONLY,"Cannot set the property localData.")}},remoteData:{get(){return this._core._stringify(!0)},set(){throw new r(r.READ_ONLY,"Cannot set the property remoteData.")}},pendingElements:{get(){return this._pendingElements},set(){throw new r(r.READ_ONLY,"Cannot set the property pendingElements.")}},changeCount:{get(){return this._core.changeCount},set(e){this._core.changeCount=e}},readOnly:{get(){return this._core._readOnly},set(e){this._core._readOnly=e}}}),c.prototype.parse=function(e){if("string"!=typeof e)throw new r(r.INVALID_PARAMS,'Param "data" must be a string');var t=null;try{t=JSON.parse(e)}catch(e){throw new r(r.INVALID_JSON,"Manifest could not be parsed. Underlying error: "+e.message)}return this._setData(t,this._core._readOnly)},c.prototype.getElementWithId=function(e){return this._createElement(this._core.getChildWithId(e))},c.prototype.getElementWithAbsolutePath=function(e){return this._createElement(this._core.getChildWithAbsolutePath(e))},c.prototype.addElement=function(e,t,n,o,i,a){if("string"!=typeof e)throw new r(r.INVALID_PARAMS,"Element must have a name of type string");if("string"!=typeof t)throw new r(r.INVALID_PARAMS,"Element must have a type of type string");if("string"!=typeof n)throw new r(r.INVALID_PARAMS,"Element must have a path of type string");var s=this._core.addChild(e,o,i,a);try{s.path=n}catch(e){throw this._core.removeChild(s),e}return s._data.type=t,this._createElement(s)},c.prototype.updateElement=function(e){var t=this.getChildWithId(e.rootNode.id);if(!t)throw new r(r.INVALID_PARAMS,"Element does not exist in branch.");var n=this._core.replaceChild(e.rootNode,t.path);return this._deleteElement(e),n},c.prototype.abandonElement=function(e){this._deleteElement(e)},c.prototype.getChildWithId=function(e){return this._core.getChildWithId(e)},c.prototype.getChildWithAbsolutePath=function(e){return this._core.getChildWithAbsolutePath(e)},c.prototype.getChildrenOf=function(e){return this._core.getChildrenOf(e)},c.prototype.addChild=function(e,t,n,o){return this._core.addChild(e,t,n,o)},c.prototype.removeChild=function(e){return this._core.removeChild(e)},c.prototype.moveChild=function(e,t,n){return this._core.moveChild(e,t,n)},c.prototype.copyChild=function(e,t,n,o,i,r){return this._core.copyChild(e,t,n,o,i,r)},c.prototype.replaceChild=function(e,t,n,o){return this._core.replaceChild(e,t,n,o)},c.prototype.allComponents=function(){return this._core.allComponents()},c.prototype.getComponentWithId=function(e){return this._core.getComponentWithId(e)},c.prototype.getComponentWithAbsolutePath=function(e){return this._core.getComponentWithAbsolutePath(e)},c.prototype.getComponentsOf=function(e){return this._core.getComponentsOf(e)},c.prototype.addComponent=function(e,t,n,o,i,r,a,s,c,l){return this._core.addComponent(e,t,n,o,i,r,a,s,c,l)},c.prototype.addComponentWithUploadResults=function(e,t,n,o,i){return this._core.addComponentWithUploadResults(e,t,n,o,i)},c.prototype.updateComponent=function(e,t,n,o){return this._core.updateComponent(e,t,n,o)},c.prototype.updateComponentWithUploadResults=function(e,t){return this._core.updateComponentWithUploadResults(e,t)},c.prototype.removeComponent=function(e){return this._core.removeComponent(e)},c.prototype.moveComponent=function(e,t){return this._core.moveComponent(e,t)},c.prototype.copyComponent=function(e,t,n,o,i){return this._core.copyComponent(e,t,n,o,i)},c.prototype.replaceComponent=function(e,t,n,o){return this._core.replaceComponent(e,t,n,o)},c.prototype.assetOfComponent=function(e,t){return this._core.assetOfComponent(e,t)},c.prototype.copy=function(){var e=new c(JSON.parse(JSON.stringify(this._data)));return e._localStorage=this._localStorage,e},c.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 i(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},c.prototype._deleteElement=function(e){var t=this._pendingElements.indexOf(e);if(t<0)throw new r(r.INVALID_PARAMS,"Unknown element.");this._pendingElements.splice(t,1),this._localStorage&&this._localStorage.unregisterInMemoryBranchOrElement(e)},c.prototype._updateLocalDataFromBranch=function(e){if(this._readOnly)throw new r(r.READ_ONLY,"This object is read-only.");if(!this._localStorage)throw new r(r.NO_LOCAL_STORAGE,"No local storage.");if(!e._localStorage)throw new r(r.NO_LOCAL_STORAGE,"No local storage for source.");if(this._localStorage.compositePath!==e._localStorage.compositePath)throw new r(r.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)},c.prototype._verify=function(e){return"string"!=typeof e.id?new r(r.INVALID_DATA,"Manifest is missing an id of type string"):"string"!=typeof e.name?new r(r.INVALID_DATA,"Manifest is missing a name of type string"):"string"!=typeof e.type?new r(r.INVALID_DATA,"Manifest is missing a type of type string"):"number"!=typeof e["manifest-format-version"]?new r(r.INVALID_DATA,"Manifest is missing a manifest-format-version of type number"):null},c.prototype._setData=function(e,t){this.originalManifestFormatVersion=e["manifest-format-version"],l(e),e.local&&(e.local.version=2);var n=this._verify(e);if(null===n)return e["manifest-format-version"]=s,this._core=new o(e,this,t),this._data=e,this;throw n},c.prototype._reset=function(e,t){if(this._readOnly)throw new r(r.READ_ONLY,"This object is read-only.");this._data.local&&(delete this._data.local.manifestEtag,delete this._data.local.compositeHref),e||(this._data.id=a.generateUuid()),this._data.state="modified",this._core._recursiveReset(this._data,t),this._core._setDirty()},c.prototype._resetBinding=function(e){this._reset(!0,e)},c.prototype._resetIdentity=function(e){this._reset(!1,e)},c.prototype._local=function(){return this._core._local()},c.prototype._setDirty=function(e){this._core._setDirty(e)},c.prototype._setPathOfNode=function(e,t){this._core._setPathOfNode(e,t)},c.prototype._verifyIntegrity=function(e,t,n){return this._core._verifyIntegrity(e,t,n)},e.exports=c},function(e,t){var n={},o={"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.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.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.ibl.light+zip":["zip"],"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.ppro.graphic+zip":["prgraphic"],"application/vnd.adobe.ae.graphic+zip":["aegraphic"],"application/vnd.adobe.graphic+json":["json"],"application/vnd.adobe.mdl.material+zip":["zip"],"application/vnd.adobe.muse-collection":["muse"],"application/vnd.adobe.obj.3d+zip":["zip"],"application/vnd.adobe.paragraphstyle+json":["style"],"application/vnd.adobe.paragraphstyle+snippet":["idms"],"application/vnd.adobe.ribbon.brush+zip":["brush"],"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/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mp4":["mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","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/webm":["weba"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","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/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/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"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":["qt","mov"],"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"],"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-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]},i={};Object.keys(o).forEach(function(e){o[e].forEach(function(t){i[t]=i[t]||[],i[t].push(e)})}),n.getExtensions=function(e){return e?o[e.toLowerCase()]||function(e){var t=e.match(/application\/x-adobe-libraries-(.+)/);return t?[t[1]]:[]}(e.toLowerCase()):[]},n.getMimeTypes=function(e){return e?i[e.toLowerCase()]||function(e){return["application/x-adobe-libraries-"+e]}(e.toLowerCase()):[]},Object.seal(n),e.exports=n},function(e,t,n){var o=n(1),i=n(2),r=n(6),a={getBackoffTicks:function(e){var t=o.BACKOFF_INTERVALS;return t[Math.max(0,Math.min(e,t.length-1))]-1},getRetryAfterHeader: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 r=(new Date).valueOf();return Math.max(0,i-r)/1e3+Math.floor(Math.random()*o.RETRY_RANDOM_SECONDS)}}catch(e){}}return 0},getLocationHeader:function(e){if(e){var t=e.location||e.Location;if(t)return t}},getContentTypeHeader: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}}},getContentLengthHeader:function(e){if(e){var t=e["content-length"]||e["Content-Length"];return Number(t)||void 0}},isUnrecoverableClientError:function(e,t){return!!e&&(e>=400&&e<500&&(401!==e||!!t)&&407!==e&&408!==e)},isRedirect:function(e){return 301===e||302===e||303===e||307===e}},s=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})};a.isAdobeDomain=function(e){return!!e&&s(e,o.ADOBE_AUTHENTICATED_DOMAINS)},a.validateURL=function(e){if(!e)return new i(i.URL_VALIDATION_FAILED,"URL not specified");var t=r.parseURI(e);return"https"!==t.scheme?new i(i.URL_VALIDATION_FAILED,"URL must be https://"):a.isAdobeDomain(t.authority)||s(t.authority,o.WHITELISTED_DOMAINS)?null:new i(i.URL_VALIDATION_FAILED,"URL domain not in whitelist")},Object.seal(a),e.exports=a},function(e,t,n){var o=n(0),i=n(1),r=function(){return o.storageInterface.getServiceInfo()},a=function(){var e=r();return e&&e.apiVersion||0},s={supportsClearRenditionCache:function(){return a()>=7},supportsTestExternalLink:function(){return a()>=10},updateElementActionMap:function(e){if(r()){if(a()<9){var t=e.types;e.types=i.ELEMENT_ACTION_PRODUCT_MAP.types,e.types["application/vnd.adobe.element.image+dcx"]=t}i.ELEMENT_ACTION_PRODUCT_MAP=e}},formatElementActionMapForClient:function(e){return e<9?{types:i.ELEMENT_ACTION_PRODUCT_MAP.types["application/vnd.adobe.element.image+dcx"],products:i.ELEMENT_ACTION_PRODUCT_MAP.products,installedApps:i.ELEMENT_ACTION_PRODUCT_MAP.installedApps}:i.ELEMENT_ACTION_PRODUCT_MAP}};Object.seal(s),e.exports=s},function(e,t,n){var o=n(9),i=n(0),r=n(1),a=n(10),s=n(2),c=n(29),l={};function p(e,t,n,o){var i=t.createRepresentation(n.type,n.relationship);void 0!==n.values&&n.values.forEach(function(e){i.setValue(e.namespace,e.key,e.value)});var s=r.REPRESENTATION_CONTENT_VALUES[n.type];if(s){try{i.setValue(s.namespace,s.key,n.content)}catch(e){return void o(e)}o(null)}else{var c=new a;n.content.path?c.addOperation(i.setContentFromPath,[n.content.path,n.content.moveFile],i):c.addOperation(i.setContentFromURL,[n.content.isLink,n.content.URL,{}],i),c.run(function(e){e?o(e):(n.dimensions&&(i.width=n.dimensions.width,i.height=n.dimensions.height),o(null))})}}function d(e,t,n,l){!function(e,t,n){if(void 0!==t.name&&null!==t.name){var i=new a;t.representations.forEach(function(e){if(void 0!==e.content){var t=r.REPRESENTATION_CONTENT_VALUES[e.type];void 0===e.content||void 0!==e.content.path||void 0!==e.content.URL||t?e.content.path&&e.content.URL?i.addOperation(function(e){e(new s(s.INVALID_PARAMETER,"Cannot provide both path and url for represenation"))}):e.content.path?i.addOperation(o.checkFileSize,[e.content.path]):e.content.URL?i.addOperation(function(t){t(c.validateURL(e.content.URL))}):t&&0===Object.keys(e.content).length&&i.addOperation(function(e){e(new s(s.INVALID_PARAMETER,"Content value missing for representation type"))}):i.addOperation(function(e){e(new s(s.INVALID_PARAMETER,"path/url/content value is missing"))})}else i.addOperation(function(e){e(new s(s.INVALID_PARAMETER,"representation content is missing - needed to create representation"))})}),void 0!==t.thumbnail&&"string"==typeof t.thumbnail.path&&i.addOperation(o.checkFileSize,[t.thumbnail.path]),i.run(n)}else n(new s(s.INVALID_PARAMETER,"Element name missing - is a required parameter"))}(0,t,function(o){if(o)return i.log("Failed to create element of type "+n+": "+o),void l(o);i.log("Creating element of type "+n),function(e,t,n,o){var r=e.createElement(t.name,n);void 0!==t.values&&t.values.forEach(function(e){r.setValue(e.namespace,e.key,e.value)});var s=new a;t.representations.forEach(function(t){"primary"===t.relationship&&s.addOperation(p,[e,r,t])}),t.representations.forEach(function(t){"primary"!==t.relationship&&s.addOperation(p,[e,r,t])}),s.run(function(n){if(n)return e.removeElement(r),void o(n);i.log("Element Created with Id: "+r.id),t.thumbnail?(r.setThumbnailCache(t.thumbnail.size,t.thumbnail.path,function(){o(null,r)}),r.endOperation()):r.endOperation(function(){o(null,r)})})}(e,t,n,l)})}l.createAnimationElement=function(e,t,n){d(e,t,r.ANIMATION_ELEMENT_TYPE,n)},l.createBrushElement=function(e,t,n){d(e,t,r.BRUSH_ELEMENT_TYPE,n)},l.createColorElement=function(e,t,n){d(e,t,r.COLOR_ELEMENT_TYPE,n)},l.createGraphicElement=function(e,t,n){d(e,t,r.IMAGE_ELEMENT_TYPE,n)},l.createLayerStyleElement=function(e,t,n){d(e,t,r.LAYER_STYLE_ELEMENT_TYPE,n)},l.supportsVectorRendition=function(e){var t=e&&e.getPrimaryRepresentation&&e.getPrimaryRepresentation();return!!t&&r.VECTOR_RENDITION_ELEMENT_TYPES.indexOf(t.type)>-1},Object.seal(l),e.exports=l},function(e,t){e.exports=require("fs-extra")},function(e,t){e.exports=require("child_process")},function(e){e.exports={name:"cc-libraries-api-js",version:"3.2.3",private:!0,description:"Adobe Creative Cloud Libraries API for JavaScript",dependencies:{"dcx-js":"git+ssh://git@git.corp.adobe.com:ProjectCentral/dcx-js.git#v1.7.18","fs-extra":"7.0.1",glob:"7.1.1",uuid:"3.3.2","uuid-browser":"3.1.0",yauzl:"2.9.1",yazl:"2.4.3"},optionalDependencies:{bufferutil:"1.3.0",ffi:"2.2.0","fs-ext":"1.2.1","idle-gc":"1.0.1","image-size":"0.6.2","node-ProxyResolver":"git+ssh://git@git.corp.adobe.com:ProjectCentral/node-ProxyResolver.git#v1.2.3","node-imslib":"git+ssh://git@git.corp.adobe.com:ProjectCentral/node-imslib.git#v1.2.7","node-vulcanjs":"git+ssh://git@git.corp.adobe.com:slade/VulcanJS.git#v1.2.4","node-thumbnailgenerator":"git+ssh://git@git.corp.adobe.com:ProjectCentral/node-ThumbnailGenerator.git#v1.3.2","ps-node":"^0.1.6",ref:"1.3.5",restify:"7.2.0",ws:"6.1.2",xml2js:"0.4.17","@ccx/ingest":"git+ssh://git@git.corp.adobe.com:CCX/Ingest.git#2.0.0"},devDependencies:{"7zip":"0.0.6","@babel/core":"^7.1.2","@babel/preset-env":"^7.1.0","@ccx/hyperdrive-builder":"git+ssh://git@git.corp.adobe.com:CCX/hyperdrive-builder.git#v3.0.14","babel-loader":"^8.0.4",fetch:"^1.1.0",grunt:"1.0.1","grunt-contrib-clean":"1.0.0","grunt-contrib-compress":"1.3.0","grunt-contrib-copy":"1.0.0","grunt-eslint":"21.0.0","grunt-jsdoc":"2.1.0","grunt-node-gyp":"3.1.0","ignore-loader":"^0.1.2","ink-docstrap":"1.3.0",istanbul:"0.4.5","jasmine-node":"1.14.5",matchdep:"1.0.1",mkdirp:"0.5.1",mockery:"2.0.0",mustache:"2.3.0",nock:"9.0.14","raw-loader":"^0.5.1",request:"2.87.0",sugar:"1.4.1",webpack:"^4.20.2","webpack-node-externals":"^1.7.2",zock:"git+ssh://git@git.corp.adobe.com:DMA/zock.git#master"},engines:{node:">=8.11.0"},bin:{"cc-libraries":"./scripts/cli"},main:"src/main.js",scripts:{test:"grunt test",install:"node ./scripts/skip_native || node-gyp rebuild",start:"node server",debug:"node server.js --debug"},cepPanels:[{source:"ftp://sjstore.corp.adobe.com/builds03/cclibs/develop/2.3.1050/CCLibraries.zxp",destination:"CC_LIBRARIES_PANEL_EXTENSION_2_3_1050"},{source:"ftp://sjstore.corp.adobe.com/builds03/cclibs/develop/2.6.64/CCLibraries.zxp",destination:"CC_LIBRARIES_PANEL_EXTENSION_2_6_64"},{source:"ftp://sjstore.corp.adobe.com/builds03/cclibs/develop/2.10.86/CCLibraries.zxp",destination:"CC_LIBRARIES_PANEL_EXTENSION_2_10_86"},{source:"ftp://sjstore.corp.adobe.com/builds03/cclibs/develop/2.11.27/CCLibraries.zxp",destination:"CC_LIBRARIES_PANEL_EXTENSION_2_11_27"},{source:"ftp://sjstore.corp.adobe.com/builds03/cclibs/develop/2.13.141/CCLibraries.zxp",destination:"CC_LIBRARIES_PANEL_EXTENSION_2_13_141"},{source:"ftp://sjstore.corp.adobe.com/builds03/cclibs/develop/3.2.108/CCLibraries.zxp",destination:"CC_LIBRARIES_PANEL_EXTENSION_3_2_108"}],cepPanelsToRemove:["CC_LIBRARIES_PANEL_EXTENSION_2_3_1012","CC_LIBRARIES_PANEL_EXTENSION_2_3_1026_DEV","CC_LIBRARIES_PANEL_EXTENSION_2_3_1038_DEV","CC_LIBRARIES_PANEL_EXTENSION_2_3_1044_DEV","CC_LIBRARIES_PANEL_EXTENSION_2_3_1046_DEV","CC_LIBRARIES_PANEL_EXTENSION_2_3_1047_DEV","CC_LIBRARIES_PANEL_EXTENSION_2_3_1048","CC_LIBRARIES_PANEL_EXTENSION_2_6_60_DEV","CC_LIBRARIES_PANEL_EXTENSION_2_10_56"],thor:[{product:"ACCC",subproduct:"Application",version:"4.7",certification:"Integration Ready",name:"ACCCx4_7_0_{{build}}",volume:"Creative Cloud",build:"^\\d+$"},{product:"ACCC",subproduct:"HDSetup",version:"4.7",certification:"Integration Ready",name:"HDSetup",volume:"Release"}]}},function(e,t,n){var o=n(39),i={parseXML:function(e,t){var n;return new o.Parser({async:!1}).parseString(e,function(e,o){e?t&&t(e):n=o}),n},parseQueryString:function(e){var t={},n=e&&e.split("?");n[1]&&n[1].split("&").forEach(function(e){var n=e.split("=");n[1]&&(t[n[0]]=n[1])});return t},stripProtocolPrefix:function(e){return["http://","https://"].forEach(function(t){e&&0===e.indexOf(t)&&(e=e.substring(t.length))}),e}};e.exports=i},function(e,t,n){var o=n(4),i=n(8),r=n(2),a="IMS",s=["creative_cloud","cce_private"];i.log(a,"Loading IMS Library...");var c,l,p,d,u,h,_,f=o.getEnvironment(),m=n(113),E=[],g=[];function y(e,t){if(t)return t.some(function(t){return-1!==e.indexOf(t.serviceCode)&&"CLOSED"!==t.serviceStatus})}function v(e,t){e.forEach(function(e){try{e.apply(void 0,t)}catch(e){i.log(a,"Error in callback: "+e)}})}function A(){var e=m.createRefEx(f.IMS);return d&&d.name&&d.pass&&m.setProxyCredentialsInIMSLibSession(e,d.name,d.pass),e}var C,I=!1;try{!function(){var e=A();m.registerClientToGroup(e,f.CLIENT_ID,"AAM"),c=m.getDeviceID(e),i.log(a,"DeviceID: "+c),m.releaseRef(e)}(),I=!0,i.log(a,"IMS Library Successfully Loaded")}catch(e){i.log(a,"IMS Library Failed to Load: "+e)}var S={getDeviceId:function(){return c},getUserId:function(){if(!l&&I){var e,t,n=A();try{t=(e=m.fetchDefaultUserInfoForClientId(n,f.CLIENT_ID))?"Default User: "+e.Email+" ("+e.UserID+")":"No default user"}catch(e){t="Error fetching default user: "+e}m.releaseRef(n),t!==C&&i.log(a,t),C=t,(l=e&&e.UserID)&&(_=!0,this.getAccessToken(function(e,t,n){p=n&&n.serviceAccounts,_=!1;var o=g;g=[],v(o,[])}))}return l},clearUserId:function(){l=void 0,p=void 0,u=void 0,C=void 0;var e=E;E=[];var t=g;g=[],v(t,[]),v(e,[null])},getAccessToken:function(e,t){if("function"==typeof e&&(t=e,e=void 0),l){if(u&&Date.now()<u.expires){if(!(e&&u.response.access_token&&e===u.response.access_token))return void t(null,u.response.access_token,u.response);if(h&&Date.now()<h)return delete u.response.access_token,u.expires=h,void t(null);h=Date.now()+o.getValue("ACCESS_TOKEN_CACHE_DURATION")}if(E.push(t),!(E.length>1)){u=void 0;var n=A();i.log(a,"Started IMSLib.fetchAccessToken"),m.fetchAccessToken(n,f.CLIENT_ID,f.CLIENT_SECRET,l,"",o.getValue("SCOPES"),function(e,t){i.log(a,"Finished IMSLib.fetchAccessToken"),setTimeout(function(){m.releaseRef(n)});var c=function(e,t,n){var o=E;E=[],v(o,[e,t,n])};return e?(i.log(a,e),void c(null)):!t.error&&!y(s,t.serviceAccounts)||"ride_AdobeID_subs_actreq"===t.error?(i.log(a,"Services not provisioned"),void c(new r(r.ACCESS_DENIED,"services not provisioned"),void 0,t)):(t.error?i.log(a,"Unknown Error: "+t.error):i.log(a,"Successfully obtained access token"),u={response:t,expires:Date.now()+o.getValue("ACCESS_TOKEN_CACHE_DURATION")},void c(null,t.access_token,t))})}}else t(null,void 0)},hasEntitlement:function(e,t){var n=function(){var n=y([e],p);t(n)};_?g.push(n):n()},setProxyCredentials:function(e,t){d={name:e,pass:t}}};e.exports=S},function(e,t,n){const o=n(14),i=n(11),r=n(38),a=e=>{const t={id:e.id,type:e.type,relationship:e.relationship,content_length:e.contentLength,width:e.width,height:e.height,is_external_link:!!e.isExternalLink||void 0,is_full_size:!!e.isFullSize||void 0,url:e.isExternalLink?e.getContentURL():void 0},n=e.getCachedContentPath();return n&&(t.path=o.normalize(n)),e.getValues().forEach(e=>{t[`${e.namespace}#${e.key}`]=e.value}),t},s=e=>{const t={id:e.id,name:e.name,type:e.type,created_date:e.created,modified_date:e.modified,element_ref:e.getReference(),tags:e.tags};return t.groups=e.getGroups(/.*/).map(t=>({id:t.id,classifier:t.classifierName,order:e.getOrderInGroup(t)})),t.representations=e.representations.map(a),t};e.exports={getRequestHandler:(e,t,n)=>(o,a)=>{let s,c,l,p;if(o.params.libraryId){if(!(s=i.getLibraryById(o.params.libraryId))||s.isDeletedFromServer)return a.send(r.LIBRARY_NOT_FOUND);if(t&&!s.isWritable)return a.send(r.LIBRARY_NOT_WRITABLE)}if(o.params.elementId&&(!(c=s.getElementById(o.params.elementId))||(n?!c.removed:c.removed)))return a.send(r.ELEMENT_NOT_FOUND);if(o.params.representationId&&!(l=c.getRepresentationById(o.params.representationId)))return a.send(r.REPRESENTATION_NOT_FOUND);if(o.params.groupId&&!(p=s.getGroupById(o.params.groupId)))return a.send(r.GROUP_NOT_FOUND);try{e(o.params,o.body,p||l||c||s).then(e=>{a.send(e)}).catch(e=>{a.send(e)})}catch(e){a.send(r.getResponseError(e))}},getPollingRequestHandler:e=>(t,n)=>{if(!t.body)return n.send(r.NOTIFICATIONS_DATA_NOT_FOUND);const o=e(t.body,e=>{n.send(e)});o&&t.on("close",o)},getGroupResponseData:e=>{return{id:e.id,name:e.name,classifier:e.classifierName,order:e.order,created_date:e.created,modified_date:e.modified}},getElementResponseData:s,getLibraryResponseData:(e,t)=>{const n={id:e.id,name:e.name,created_date:e.created,modified_date:e.modified,details:{num_elements:e.elements.length,num_archived_elements:e.removedElements.length}};if(n.groups=e.getGroups(/.*/).map(e=>({id:e.id,name:e.name,classifier:e.classifierName,order:e.order,created_date:e.created,modified_date:e.modified})),e.collection.isPublic||e.collection.getDefaultLibrary()!==e||(n.default=!0),e.collaboration){const t=e.collaboration.toLowerCase();n.collaboration={state:t},n.collaboration.role="outgoing"===t?"owner":e.isWritable?"editor":"viewer",n.ownership=t}else n.ownership=e.collection.isPublic?"public":"private";return t&&(n.elements=e.elements.map(s)),n}}},function(e,t,n){const o=n(131),i=n(2),r={};r[i.ACCESS_DENIED]=o.ForbiddenError,r[i.DELETED_LOCALLY]=o.NotFoundError,r[i.FILE_TOO_LARGE]=o.RequestEntityTooLargeError,r[i.INVALID_DATA]=o.BadRequestError,r[i.INVALID_PARAMETER]=o.BadRequestError,r[i.LOGGED_OUT]=o.UnauthorizedError,r[i.NOT_ALLOWED]=o.ForbiddenError,r[i.NOT_IMPLEMENTED]=o.NotImplementedError,r[i.NOT_SUPPORTED]=o.NotAcceptableError,r[i.READ_ONLY]=o.ForbiddenError,r[i.RENDITION_NOT_AVAILABLE]=o.NotFoundError,r[i.OUT_OF_SPACE]=o.InsufficientStorageError,r[i.URL_VALIDATION_FAILED]=o.BadRequestError,r[i.THUMBNAIL_NOT_AVAILABLE]=o.NotFoundError,e.exports={COLLECTION_NOT_FOUND:new o.InternalServerError("Cannot find private collection"),LIBRARY_NAME_MISSING:new o.BadRequestError("Library name is missing"),LIBRARY_ID_MISSING:new o.BadRequestError("Library id is missing"),LIBRARY_URL_MISSING:new o.BadRequestError("Library URL is missing"),LIBRARY_NOT_FOUND:new o.NotFoundError("Cannot find library"),LIBRARY_NOT_WRITABLE:new o.ForbiddenError("Library is read-only"),LIBRARY_NOT_ENOUGH_SPACE:new o.InsufficientStorageError("Library does not have enough space for new elements"),ELEMENT_NOT_FOUND:new o.NotFoundError("Cannot find element"),ELEMENT_IDS_MISSING:new o.BadRequestError("Element ids are missing"),ELEMENT_DATA_MISSING:new o.BadRequestError("Element data is missing"),ELEMENT_TYPE_MISSING:new o.BadRequestError("Element type is missing"),ELEMENT_BODY_MISSING:new o.BadRequestError("Element name or representation data or tag data is needed"),ELEMENT_NAME_INVALID:new o.BadRequestError("Element name must be a string"),ELEMENT_TAGS_INVALID:new o.BadRequestError("Element tags must be an array of strings"),REPRESENTATION_DATA_MISSING:new o.BadRequestError("Representations are missing"),REPRESENTATION_NOT_FOUND:new o.NotFoundError("Cannot find representation"),REPRESENTATION_PATH_NOT_FOUND:new o.NotFoundError("Cannot find representation path"),REPRESENTATION_ID_NOT_RESOLVED:new o.BadRequestError("Representation id cannot be resolved"),REPRESENTATION_TYPE_MISSING:new o.BadRequestError("Representation type is missing"),REPRESENTATION_REL_MISSING:new o.BadRequestError("Representation relationship is missing"),REPRESENTATION_REL_INVALID:new o.BadRequestError("Representation relationship is invalid"),REPRESENTATION_REL_PRIMARY_FOUND:new o.BadRequestError("Cannot have multiple primary representations"),REPRESENTATION_WIDTH_INVALID:new o.BadRequestError("Representation width is invalid"),REPRESENTATION_HEIGHT_INVALID:new o.BadRequestError("Representation height is invalid"),REPRESENTATION_CONTENT_LENGTH_INVALID:new o.BadRequestError("Representation content_length is invalid"),REPRESENTATION_CONTENT_LENGTH_UNEXPECTED:new o.BadRequestError("Representation content_length can only be used for an externally-linked representation"),REPRESENTATION_FULL_SIZE_INVALID:new o.BadRequestError("Representation is_full_size is invalid"),REPRESENTATION_SOURCE_MISSING:new o.BadRequestError("Representation source should have a URL or Path"),GROUP_NOT_FOUND:new o.NotFoundError("Cannot find group"),GROUP_NAME_MISSING:new o.BadRequestError("Group name is missing"),GROUP_ORDER_MISSING:new o.BadRequestError("Group order is missing"),GROUP_BODY_MISSING:new o.BadRequestError("Group name or order is needed"),NOTIFICATIONS_DATA_NOT_FOUND:new o.BadRequestError("Notification base data is missing"),getResponseError:e=>{if(e instanceof i){return new(r[e.code]||o.InternalServerError)(e.message)}return new o.InternalServerError(e&&e.message?e.message:e)}}},function(e,t){e.exports=require("xml2js")},function(e,t,n){var o=n(3),i=n(6);function r(e,t){e?this._setData(e):this._data={},this._readOnly=t}var a={unmodified:"unmodified",modified:"modified",pendingDelete:"pendingDelete",committedDelete:"committedDelete"};r.STATES=a,r._UploadResults=function(e){this.compositeId=e,this.records={}},r._UploadRecord=function(e,t,n,o,i,r){this.id=e,this.etag=t,this.version=n,this.md5=o,this.length=i,this.type=r},Object.defineProperties(r.prototype,{id:{get(){return this._data.id},set(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(){return this._data.name},set(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(){return this._data.type},set(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(){return this._data.path},set(e){if(this._data.path!==e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!i.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(){return this._parentPath},set(){throw new o(o.READ_ONLY,"parentPath is read-only.")}},absolutePath:{get(){return this._data.path&&this._owner?i.appendPathElements(this._parentPath,this._data.path):void 0},set(){throw new o(o.READ_ONLY,"absolutePath is read-only.")}},relationship:{get(){return this._data.rel},set(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(){return this._data.state},set(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(!a.hasOwnProperty(e))throw new o(o.INVALID_PARAMS,'State must be "modified", "unmodified", "pendingDelete", or "committedDelete".');this._data.state=e,this._setDirty()}},etag:{get(){return this._data.etag},set(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(){return this._data.md5},set(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(){return this._data.version},set(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(){return this._data.length},set(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(){return this._data.width},set(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(){return this._data.height},set(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 s={name:!0,id:!0,state:!0,path:!0,rel:!0,type:!0,etag:!0,length:!0,version:!0,md5:!0,width:!0,height:!0};r.prototype.getCustomKeys=function(){var e,t=[],n=Object.keys(this._data),o=n.length;for(e=0;e<o;e++){var i=n[e];s[i]||t.push(i)}return t},r.prototype.getValue=function(e){if("string"!=typeof e)throw new o(o.INVALID_PARAMS,'Param "key" must be a string');return this._data[e]},r.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()},r.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()},r.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},r.prototype.setLink=function(e,t){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("object"!=typeof 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()},r.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())},r.prototype.isEqualTo=function(e,t){return i.objectsEqual(this._data,e._data,t)},r.prototype._setData=function(e){var t=this._verify(e);if(null===t)return this._data=e,this;throw t},r.prototype._setDirty=function(){this._owner&&this._owner._setDirty()},r.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=r},function(e,t,n){var o=n(3),i=o.networkError,r=o.unexpectedResponse,a=n(6),s=a.merge,c=n(49),l=a.appendPathElements;function p(e,t){this._service=e,this._server=t,t&&(this._endPoint=a.endPointOf(t)),this.SYNC_ASYNC_DEFAULT_DELAY=5,this.ASYNC_DEFAULT_DELAY=1,this.DEFAULT_POLL_DELAY=10,this._maxRedirects=5,this._authenticationWhitelist=[]}p.FileContent=c.FileContent,p.StreamProvider=c.StreamProvider,Object.defineProperties(p.prototype,{maxRedirects:{get(){return this._maxRedirects},set(e){if("number"!=typeof e)throw new o(o.INVALID_PARAMS,"Expecting a number.");this._maxRedirects=Math.floor(e)}},authenticationWhitelist:{get(){return this._authenticationWhitelist},set(e){if(!Array.isArray(e))throw new o(o.INVALID_PARAMS,"Expecting an array.");this._authenticationWhitelist=e}}}),p.prototype.isValidHref=function(e){var t=a.endPointOf(e);return!t||t===this._endPoint},p.prototype.isDomainOnWhitelist=function(e){var t=a.parseURI(e).authority;if(!t||0===t.length)return!0;var n,o=t.length,i=this._authenticationWhitelist.length;for(n=0;n<i;n++){var r=this._authenticationWhitelist[n],s=r.length;if((o>s?t.slice(-s):t)===r)return!0}return!1},p.prototype.getAsset=function(e,t,n,c){if(!(e=this._resolveUrl(e)))return c(new o(o.WRONG_ENDPOINT,"Wrong endpoint: "+e));var l,p={};"string"==typeof t?p["If-None-Match"]=t:s(p,t);var d,u=this,h=0;function _(e,t){if(e)return c(i("Error downloading an asset",e,t));var n=t.statusCode;if(200===n)c(void 0,t);else if(304===n)c(void 0,t);else if(301===n||302===n||303===n||307===n)if(!u._service.handlesRedirects&&u.maxRedirects)if(h<u.maxRedirects){var o=t.headers.location;o?d(o):c(r("Missing location header in redirect response",e,t))}else c(r("Too many redirects",e,t));else c(r("Unexpected response getting an asset",e,t));else c(r("Unexpected response getting an asset",e,t))}return(l=(d=function(t){var o={responseType:n};return t&&(h++,o.reuseRequestDesc=l,u.isDomainOnWhitelist(t)||(p.Authorization=null)),u._service.invoke("GET",t||e,p,void 0,o,_)})()).progress=a.noOp,l},p.prototype.getAssetAsType=function(e,t,n,o){return this.getAsset(e,n,t,function(e,t){if(e)return o(e);if(200===t.statusCode){var n=t.response||t.responseText;o(void 0,n,t.headers.etag,t)}else 304===t.statusCode?o(void 0,null,t.headers.etag,t):o(r("Unexpected response getting asset",e,t))})},p.prototype._resolveUrl=function(e){var t=a.endPointOf(e);if(t){if(t!==this._endPoint)return;return e}return l(this._server,e)},p.prototype._makeRelativeUrl=function(e){var t=a.endPointOf(e);if(t){if(t!==this._endPoint)return;var n=a.parseURI(e);(n.scheme||n.authority)&&(e=n.path,n.query&&(e+="?"+n.query),n.fragment&&(e+="#"+n.fragment))}return e},p.prototype._parseAsyncResponse=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 s=t.search(/\r?\n\r?\n/);-1===s&&(s=t.length);var c=t.slice(i+1,s);n.headers=a.parseHeaders(c);var l="\r"===t.charAt(s)?s+4:s+2;return n.response=t.slice(l),n},p.prototype._pollForAsyncResponse=function(e,t,n,o){var s=this,c=Date.now()+1e3*t,l={responseType:"text",reuseRequestDesc:n,noSoonerThen:c};a.log("asynchronous request - polling"),n=this._service.invoke("GET",e,void 0,void 0,l,function(t,c){if(t)return o(i("Error polling for an asynchronous reponse",t,c));var l=c.statusCode;if(202===l){a.log("asynchronous request - not yet ready");var p=c.headers["retry-after"];p&&(p=parseInt(p,10)),s._pollForAsyncResponse(e,p||s.DEFAULT_POLL_DELAY,n,o)}else if(200===l){a.log("asynchronous request - success");try{c=s._parseAsyncResponse(c)}catch(e){return o(r("Error parsing response body.",e,c))}200===(l=c.statusCode)||201===l||204===l?o(void 0,c):o(r("Unexpected response polling for an asynchronous response",t,c))}else a.log("asynchronous request - error"),o(r("Unexpected response polling for an asynchronous response",t,c))})},p.prototype._handle202Response=function(e,t,n,o){var i,a=e.responseText||e.response;try{i=JSON.parse(a)}catch(t){return o(r("Error parsing 202 response body.",t,e))}var s=i.href;if(!s)return o(r("202 response missing an href.",void 0,e));var c=e.headers["retry-after"];c=c?parseInt(c,10):n,this._pollForAsyncResponse(this._resolveUrl(s),c,t,o)},e.exports=p},function(e,t,n){var o=n(3),i=n(56),r=n(0),a=n(1),s=n(97),c=n(98),l=n(99),p=n(18),d=n(2),u=n(22),h=n(100),_=n(10),f=n(9),m=n(16),E=n(12),g=n(29),y=n(7),v=n(13),A=n(101),C=n(5);function I(e){this._rootDir=a.ROOT_DIR,this._userId=e.USER_ID,this._cloudId=e.CLOUD_ID,this._cloudInfo=e.CLOUD_INFO||{},this._syncManager=new s(this,e),this._libraries=[],this._syncState="syncing",this._syncProgressMap={},this._externalLinkDownloadProgressMap={},this._initialSyncInProgress=!1,this._syncErrors=[],this._listenerManager=new C(["change","deepchange","sync","operation","commitError"]),this._operations=[],this._libraryIdMap={},this._operationIdMap={},this._removeOperationTimeout={},this._pendingDeletes=[],this._loaded=!1,this._syncing=!1,this._lastSyncTime=0,this._pendingSyncs=[],this._backoffTicks=0,this._numBackoffs=0,this._numRetries=0,this.isPublic||(this._bookmarkManager=new c(this),this._fontManager=new l(this))}I.prototype._removeAllListeners=function(){this._listenerManager.removeAll(),this._libraries.forEach(function(e){e._removeAllListeners()})},I.prototype._notifyChange=function(e){this._listenerManager.notify("deepchange"),e&&this._listenerManager.notify("change")},I.prototype._loadLibrary=function(e,t){const n=this._getCompositeDir(e),o=n=>{r.log(`Load error: ${n}`),f.deleteLibraryFromDisk(this,e,()=>t(null))},a=n=>{const o=new i(this,n);this.isPublic&&(o._publicId=e,o._writable=!1),"pendingDelete"===n.current.compositeState?(this._pendingDeletes.push(o),t(null)):(this._libraries.push(o),this._libraryIdMap[o.id]=o,o._loadRenditionCache(t))};r.dcx.newCompositeFromLocalStorage(n,(t,n)=>t?o(`DCX error loading composite for ${e}`):n&&n.current?m.validateLibrary(n)?this.isPublic||n.id===e?void(n.href&&n.current.isBound?n.loadBaseBranch((t,i)=>{t||!i?o(`missing base branch for ${e} (even though bound to server)`):a(n)}):a(n)):o(`library id ${n.id} doesn't match folder on disk ${e}`):o(`failed validation for ${e}`):o(`composite/branch not loaded for ${e}`))},I.prototype._load=function(e){if(this._loaded)e(null);else{this._loaded=!0;var t=this;f.readLibraryDirectory(this,function(n,o){if(!n&&o){var i=new _;o.forEach(function(e){m.validateLibraryId(e,t.isPublic)&&i.addOperation(t._loadLibrary,[e],t)}),t.isPublic||i.addOperation(t._bookmarkManager.load,[],t._bookmarkManager),i.run(function(){r.log("Loaded "+t._libraries.length+" libraries and "+t._pendingDeletes.length+" pending deletes"),e(null)},function(e){t._reportCommitError(e)})}else e(null)})}},I.prototype._removeFromPendingDeletes=function(e){var t=this._pendingDeletes.indexOf(e);-1!==t&&this._pendingDeletes.splice(t,1)},I.prototype._handlePendingDeletes=function(e){var t=this,n=new _;this._pendingDeletes.forEach(function(e){n.addOperation(function(n){e._deleteFromServer(!1,function(i){if(i&&i.code===o.UPDATE_CONFLICT)return t._removeFromPendingDeletes(e),t._libraries.push(e),t._libraryIdMap[e.id]=e,e._markDeletedLocally(!1),t._updateSyncState(),t._notifyChange(!0),void n(null,!0);i?n(i):(t._removeFromPendingDeletes(e),e._deletedFromDisk=!0,f.deleteLibraryFromDisk(t,e.id,function(e){n(e,!0)}))})})}),n.run(e)},I.prototype._doesLibraryExist=function(e){if(this._libraryIdMap[e])return!0;var t;for(t=0;t<this._pendingDeletes.length;t++)if(this._pendingDeletes[t].id===e)return!0;return!1},I.prototype._syncNewLibrary=function(e,t,n,a){var s=this,c=t||this._syncManager.getCompositePath(e),l=r.hasFileSystem()&&this._getCompositeDir(e),p=r.dcx.newCompositeWithHref(c,l);s._libraryIdMap[e]="pending",s._updateSyncState(),s._syncManager.pullComposite(p,s,function(t,r){if(t||!r)return delete s._libraryIdMap[e],s._updateSyncState(),t=t?t.code===o.NO_COMPOSITE||t.code===o.DELETED_COMPOSITE?null:E.getSyncError(t,e):new d(d.NETWORK_ERROR,"No pulled branch"),void a(t,!0);p.resolvePullWithBranch(r,function(t){if(t||!s.isPublic&&p.id!==e)return delete s._libraryIdMap[e],s._updateSyncState(),t=t?E.getCommitError(t,e):new d(d.CORRUPTED_LIBRARY,"Library id does not match sync group id"),void a(t,!0);var o=new i(s,p);s.isPublic&&(o._publicId=e,o._writable=!1),s._libraries.push(o),s._libraryIdMap[o.id]=o,s._updateSyncState(),o._setCollaboration(n),v.prefetchRenditions(o),s._notifyChange(!0),a(null,!0)})})},I.prototype._syncNewLibraries=function(e,t){var n=this,o=new _;if(this._loadingHint){var i=[];e.forEach(function(e){-1!==n._loadingHint.indexOf(e.name)&&i.push(e)}),e.forEach(function(e){-1===n._loadingHint.indexOf(e.name)&&i.push(e)}),e=i}e.forEach(function(e){var t=e.name;n._doesLibraryExist(e.name)||o.addOperation(n._syncNewLibrary,[t,void 0,e],n)}),o.run(t)},I.prototype._syncExistingLibraries=function(e,t,n){var o=this,i=new _;this._libraries.forEach(function(n){var r=e&&e[n.id];if(r&&(n._setCollaboration(r),n._deletedFromServer&&(n._deletedFromServer=!1,n._notifyChange())),t)(t[n.id]||r&&!r.isUnmodified)&&i.addOperation(n._sync,[!1],n);else{var a=!e||r&&r.isUnmodified;void 0===n.collaboration?i.addOperation(n._sync,[a],n):a?i.addOperation(function(e){o._syncManager.hasCompositeChangedOnServer(n._dcxComposite,function(t){n._sync(!t,e)})}):i.addOperation(n._sync,[!1],n)}}),i.run(n)},I.prototype._dosync=function(e,t){var n=this;this._clearSyncErrors(),this._syncManager.getServerComposites(function(o,i,r){if(o)return o=E.getSyncError(o,void 0,{403:d.ACCESS_DENIED}),n._reportSyncError(o),void t(null,!1);var a=new _;a.addOperation(n._syncNewLibraries,[i],n),a.addOperation(n._syncExistingLibraries,[r,e],n),a.addOperation(n._handlePendingDeletes,[],n),e||a.addOperation(n._bookmarkManager.sync,[],n._bookmarkManager),a.run(function(e,n){t(null,n)},function(e){n._reportSyncError(e)})})},I.prototype._reportSyncError=function(e){e&&(r.log("Sync error: "+E.errorToString(e)),this._syncErrors.push(e))},I.prototype._clearSyncErrors=function(e){if(e){var t=[];this._syncErrors.forEach(function(n){n.libraryId!==e&&t.push(n)}),this._syncErrors=t}else this._syncErrors=[]},I.prototype._reportCommitError=function(e){this._lastCommitError=e,e&&(r.log("Commit error: "+E.errorToString(e)),this._listenerManager.notify("commitError",[e]))},I.prototype._updateRetryState=function(){if(!this._retryTimeoutId&&"syncing"!==this._syncState){if("error"===this._syncState){var e=this.getPrimarySyncError();if(e&&e.code===d.RETRYABLE_SERVER_ERROR){if(this._numRetries++,this._numRetries>a.ERROR_RETRY_INTERVALS.length)return this._retryTime="never",r.log("Retry Failed"),void(a.MAX_SYNC_INTERVAL=a.RETRY_FAIL_MAX_SYNC_INTERVAL);r.log("Retry "+this._numRetries);var t=e.underlyingError&&e.underlyingError.response&&e.underlyingError.response.headers,n=1e3*g.getRetryAfterHeader(t);n>0?(this._numRetries=a.ERROR_RETRY_INTERVALS.length,r.log("Got Retry-After header")):n=1e3*a.ERROR_RETRY_INTERVALS[this._numRetries-1],r.log("Retrying after "+n+"ms"),this._retryTime=(new Date).valueOf()+n;var o=this;return void(this._retryTimeoutId=setTimeout(function(){o._retryTimeoutId=void 0,o._retryTime=void 0,r.log("Starting retry"),o._syncWithParameters(!1)},n))}if(e&&e.code===d.EXCEEDS_QUOTA)return a.MAX_SYNC_INTERVAL=a.RETRY_FAIL_MAX_SYNC_INTERVAL,this._numRetries=a.ERROR_RETRY_INTERVALS.length+1,void(this._retryTime="never")}this._numRetries=0,this._retryTime=void 0}},I.prototype._updateSyncState=function(){var e,t=this,n=this._initialSyncInProgress;Object.keys(this._libraryIdMap).forEach(function(e){var o=t._libraryIdMap[e],i="pending"===o||o._isSyncing();n=n||i}),n?e="syncing":(this._syncErrors.length>0?(e="error",t._syncManager.clearSyncGroupCache(),p.reportError(this.getPrimarySyncError())):e="ok",this._syncProgressMap={},this._syncProgress=void 0);var o=this._syncState;this._syncState=e,this._updateRetryState(),o===e&&"error"!==this._syncState||this._listenerManager.notify("sync"),t._ensureDefaultLibrary()},I.prototype._updateProgress=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 o=!1,i=t||0,r=(n||0)>0?Math.max(0,Math.min(100,Math.round(i/n*100))):void 0;this._syncProgressMap[e].progress!==r&&(this._syncProgressMap[e].progress=r,o=!0);var a=0,s=0,c=0,l=0,p=this._syncProgressMap;Object.keys(p).forEach(function(e){a++,p[e].bytesTotal>0&&s++,c+=p[e].bytesLoaded,l+=p[e].bytesTotal});var d=l>0?c*s/(l*a):0,u=Math.max(0,Math.min(100,Math.round(100*d)));(!this._syncProgress||this._syncProgress<u||100===this._syncProgress&&u<100)&&(this._syncProgress=u,o=!0),o&&this._listenerManager.notify("sync")},I.prototype._updateExternalLinkDownloadProgress=function(e,t,n,o){var i,r=e.element.library.id+"."+e.element.id+"."+e.id;n?(t=t||0,i=Math.max(0,Math.min(100,Math.round(t/n*100)))):o&&(i=-1),i!==this._externalLinkDownloadProgressMap[r]&&(void 0===i?delete this._externalLinkDownloadProgressMap[r]:this._externalLinkDownloadProgressMap[r]=i,this._listenerManager.notify("sync"))},I.prototype._getExternalLinkDownloadProgress=function(e){var t=e.element.library.id+"."+e.element.id+"."+e.id;return this._externalLinkDownloadProgressMap[t]},I.prototype._setInitialSyncState=function(e,t){this._initialSyncInProgress=e,this._loadingHint=t,this._updateSyncState()},I.prototype._resetPollBackoff=function(){this._backoffTicks=0,this._numBackoffs=0},I.prototype._getBaseDir=function(){var e=r.getPathSeparator(),t=this._userId.replace(/@/g,"_"),n=this._rootDir+e+t;return this._isPublic&&t!==a.PUBLIC_USER_ID&&(n+=e+a.PUBLIC_USER_ID),n+e+this._cloudId},I.prototype._getCompositeDir=function(e){var t=r.getPathSeparator(),n=this._getBaseDir()+t+"dcx";return e&&(n+=t+e),n},I.prototype._getTempDir=function(){var e=r.getPathSeparator();return this._getBaseDir()+e+".tmp"},I.prototype._getRenditionCacheDir=function(e){var t=r.getPathSeparator(),n=this._getBaseDir()+t+"renditions";return e&&(n+=t+e),n},I.prototype._ensureDefaultLibrary=function(){var e="ok"===this.syncState&&!this.isInitialSyncInProgress&&a.SYNCING_ENABLED,t=0;if(this.libraries.forEach(function(e){e.isDeletedLocally||e.isDeletedFromServer||t++}),!this.isPublic&&e&&0===t){var n=u.translate("LIBS_DEFAULT_LIBRARY_NAME");r.log("Creating default library: "+n),this.createLibrary(n)}},I.prototype._doRemoveLibrary=function(e,t){var n=this,o=y.wrapCallback(t),i=this._libraries.indexOf(e);-1!==i&&(this._libraries.splice(i,1),delete this._libraryIdMap[e.id]),e._removeAllListeners(),a.SHARED_LOCAL_STORAGE?(e._dcxBranch.compositeState="pendingDelete",e._commit(!1,!0),e._markDeletedLocally(!0),o(null)):(n._pendingDeletes.push(e),a.SYNCING_ENABLED?e._deleteFromServer(!0,function(t){e._markDeletedLocally(!0),t?o(null):(n._removeFromPendingDeletes(e),e._deletedFromDisk=!0,f.deleteLibraryFromDisk(n,e.id,o))}):(e._dcxBranch.compositeState="pendingDelete",e._commit(!0,!0),e._markDeletedLocally(!0),o(null))),this._notifyChange(!0)},I.prototype._doExportLibrary=function(e,t,n,o){var i,s=this;if(a.SHARED_LOCAL_STORAGE){var c=r.uuid();return r.storageInterface.exportLibrary(e,t,c,n),this._addOperation(c,"export",{libraryId:e.id})}o=o||r.uuid(),e._setAutoGC("export_"+o,!1);var l=this._addOperation(o,"export",{libraryId:e.id},function(){i&&i()});return i=A.exportLibrary(e,t,function(e){l._updateProgress(e)},function(t){l._updateProgress(100),s._removeOperation(l),e._setAutoGC("export_"+o,!0),n(t)}),l},I.prototype._doImportLibrary=function(e,t,n){var o,i=this;if(a.SHARED_LOCAL_STORAGE){var s=r.uuid();return r.storageInterface.importLibrary(this,e,s,t),this._addOperation(s,"import")}var c=this._addOperation(n||r.uuid(),"import",void 0,function(){o&&o()});return o=A.importLibrary(this,e,function(e){c._updateProgress(e)},function(e,n){c._updateProgress(100),i._removeOperation(c),t(e,n)}),c},I.prototype._addOperation=function(e,t,n,o){var i=new h(this,e,t,n,o);return this._operations.push(i),this._operationIdMap[i.id]=i,this._notifyOperationChange(),i},I.prototype._removeOperation=function(e){var t=this._operations.indexOf(e);-1!==t&&(this._operations.splice(t,1),delete this._operationIdMap[e.id]),this._notifyOperationChange()},I.prototype._delayedRemoveOperation=function(e){var t=this;this._removeOperationTimeout[e.id]||(this._removeOperationTimeout[e.id]=setTimeout(function(){delete t._removeOperationTimeout[e.id],t._removeOperation(e)},a.REMOVE_OPERATION_TIMEOUT))},I.prototype._updateOperation=function(e,t,n,o){this._operationIdMap[e]||this._addOperation(e,t,n),this._removeOperationTimeout[e]&&(clearTimeout(this._removeOperationTimeout[e]),delete this._removeOperationTimeout[e]),this._operationIdMap[e]._updateProgress(o)},I.prototype._notifyOperationChange=function(){this._listenerManager.notify("operation")},Object.defineProperties(I.prototype,{libraries:{get(){return this._libraries},set(){throw new d(d.READ_ONLY,"Cannot modify libraries list directly")}},commitError:{get(){return this._lastCommitError},set(){throw new d(d.READ_ONLY,"commitError is a read-only property")}},syncState:{get(){return this._syncState},set(){throw new d(d.READ_ONLY,"syncState is a read-only property")}},syncErrors:{get(){return this._syncErrors},set(){throw new d(d.READ_ONLY,"syncErrors is a read-only property")}},syncProgress:{get(){return this._syncProgress},set(){throw new d(d.READ_ONLY,"syncProgress is a read-only property")}},isInitialSyncInProgress:{get(){return this._initialSyncInProgress},set(){throw new d(d.READ_ONLY,"isInitialSyncInProgress is a read-only property")}},isPolling:{get(){return void 0!==this._pollTimerId},set(){throw new d(d.READ_ONLY,"isPolling is a read-only property")}},isLoggedIn:{get(){if(!a.SHARED_LOCAL_STORAGE)return this._syncManager.isLoggedIn()},set(){throw new d(d.READ_ONLY,"isLoggedIn is a read-only property")}},retryTime:{get(){return"never"!==this._retryTime?this._retryTime:void 0},set(){throw new d(d.READ_ONLY,"retryTime is a read-only property")}},userId:{get(){return this._userId},set(){throw new d(d.READ_ONLY,"userId is a read-only property")}},cloudId:{get(){return this._cloudId},set(){throw new d(d.READ_ONLY,"cloudId is a read-only property")}},cloudInfo:{get(){return this._cloudInfo},set(){throw new d(d.READ_ONLY,"cloudInfo is a read-only property")}},isPublic:{get:()=>!1,set(){throw new d(d.READ_ONLY,"isPublic is a read-only property")}},bookmarks:{get(){return this._bookmarkManager.getBookmarks()},set(){throw new d(d.READ_ONLY,"bookmarks is a read-only property")}},fontManager:{get(){return this._fontManager},set(){throw new d(d.READ_ONLY,"fontManager is a read-only property")}},operations:{get(){return this._operations},set(){throw new d(d.READ_ONLY,"operations is a read-only property")}}}),I.prototype.addChangeListener=function(e){this._listenerManager.add("change",e)},I.prototype.removeChangeListener=function(e){this._listenerManager.remove("change",e)},I.prototype.addDeepChangeListener=function(e){this._listenerManager.add("deepchange",e)},I.prototype.removeDeepChangeListener=function(e){this._listenerManager.remove("deepchange",e)},I.prototype.createLibrary=function(e){var t=r.uuid(),n=a.COMPOSITE_TYPE,o=this._getCompositeDir(t),s=r.dcx.newEmptyComposite(e,n,o,t);s.current.rootNode.setValue(a.VERSION_KEY,a.VERSION),this._syncManager.prepareCompositeForPush(s);var c=new i(this,s);return c._updateCreatedTime(),this._libraries.push(c),this._libraryIdMap[c.id]=c,this._notifyChange(!0),c._commit(!1,!0),p.reportCreateLibrary(c),c},I.prototype.removeLibrary=function(e,t){this._doRemoveLibrary(e,t),p.reportDeleteLibrary(e)},I.prototype.removeDeletedLibraries=function(e,t){var n=this,o=y.wrapCallback(t);"function"==typeof e&&(o=e,e=void 0);var i=e&&e.exclude||[];function r(e,t){var o=n._libraries.indexOf(e);-1!==o&&(n._libraries.splice(o,1),delete n._libraryIdMap[e.id]),e._deletedFromDisk=!0,f.deleteLibraryFromDisk(n,e.id,t),e._markDeletedLocally(!0)}var a=new _,s=!1;this._libraries.forEach(function(e){if(e.isDeletedFromServer){var t=!0;i.forEach(function(n){t=t&&e!==n}),t&&(s=!0,a.addOperation(r,[e]))}}),a.run(function(e){s&&n._notifyChange(!0),o(e)})},I.prototype.exportLibrary=function(e,t,n){if(-1!==this._libraries.indexOf(e))if("string"==typeof t)if(0===t.length||t[t.length-1].match(/\\|\//))n(new d(d.INVALID_PARAMETER,"path must end in a filename"));else{if(t.substring(t.length-a.EXPORT_EXTENSION.length)!==a.EXPORT_EXTENSION&&(t+=a.EXPORT_EXTENSION),a.SHARED_LOCAL_STORAGE||r.hasFileSystem())return this._doExportLibrary(e,t,function(t){p.reportExportLibrary(t,e),n(t)});n(new d(d.REQUIRES_FILESYSTEM,"exportLibrary only supported when you have a filesystem"))}else n(new d(d.INVALID_PARAMETER,"path must be a string"));else n(new d(d.INVALID_PARAMETER,"library not in this collection"))},I.prototype.importLibrary=function(e,t){if("string"==typeof e){if(a.SHARED_LOCAL_STORAGE||r.hasFileSystem())return this._doImportLibrary(e,function(e,n){p.reportImportLibrary(e,n),t(e,n)});t(new d(d.REQUIRES_FILESYSTEM,"importLibrary only supported when you have a filesystem"))}else t(new d(d.INVALID_PARAMETER,"path must be a string"))},I.prototype.sync=function(e){this._syncWithParameters(!1,!1,void 0,e)},I.prototype.syncChanges=function(e,t){var n={};(e=e||[]).forEach(function(e){n[e]=!0}),this._syncWithParameters(!1,!1,n,t)},I.prototype.syncFull=function(e){this._syncManager.clearSyncGroupCache(),this._syncWithParameters(!1,!1,void 0,e)},I.prototype.syncBookmarks=function(e){this._bookmarkManager.sync(function(t){e&&e(t)})},I.prototype._syncWithParameters=function(e,t,n,o){var i=this,s=function(){o&&o(null)};if(a.SHARED_LOCAL_STORAGE)return r.storageInterface.sync(this),void s();if(a.SYNCING_ENABLED)if(this._retryTimeoutId)s();else{if(e||this._resetPollBackoff(),this.isPolling){if(this._syncing)return void s()}else if(this._syncing)return void i._pendingSyncs.push(s);if((new Date).valueOf()<this._lastSyncTime+a.MAX_SYNC_INTERVAL)return t?void s():void setTimeout(function(){i._syncWithParameters(e,!0,n,s)},a.MAX_SYNC_INTERVAL);r.log("Start Sync: "+this.cloudId+(e?" [polling]":"")),this._syncing=!0,this._lastSyncTime=(new Date).valueOf(),this._dosync(n,function(e,t){if(i._syncing=!1,i._updateSyncState(),r.log("End Sync: "+i.cloudId),t&&(i._backoffTicks=0,i._numBackoffs=0),i._pendingSyncs.length>0){var n=i._pendingSyncs;i._pendingSyncs=[],i.sync(function(){n.forEach(function(e){e()})})}s()})}else s()},I.prototype.addSyncListener=function(e){this._listenerManager.add("sync",e)},I.prototype.removeSyncListener=function(e){this._listenerManager.remove("sync",e)},I.prototype.getPrimarySyncError=function(){var e=this._syncErrors[0];return this._syncErrors.forEach(function(t){var n=E.getErrorPriority(t),o=E.getErrorPriority(e);n>o?e=t:n===o&&e.code===t.code&&e.libraryId!==t.libraryId&&(e=new d(e.code,"multiple errors (see libraryCollection.syncErrors)",void 0))}),e},I.prototype.getNewLibrarySyncProgress=function(){var e=this;if(this._newLibraryProgress)return this._newLibraryProgress;var t=[];return Object.keys(this._libraryIdMap).forEach(function(n){"pending"===e._libraryIdMap[n]&&t.push({id:n,progress:e._syncProgressMap[n]&&e._syncProgressMap[n].progress})}),t},I.prototype.addOperationChangeListener=function(e){this._listenerManager.add("operation",e)},I.prototype.removeOperationChangeListener=function(e){this._listenerManager.remove("operation",e)},I.prototype.addCommitErrorListener=function(e){this._listenerManager.add("commitError",e)},I.prototype.removeCommitErrorListener=function(e){this._listenerManager.remove("commitError",e)},I.prototype.startPolling=function(){if(a.SHARED_LOCAL_STORAGE)throw new d(d.NOT_SUPPORTED,"startPolling() not supported with shared local storage");if(!this.isPolling){var e=this,t=6e4*a.POLL_INTERVAL;this._pollTimerId=setInterval(function(){"never"!==e._retryTime&&(e._backoffTicks>0?e._backoffTicks--:(0===e._backoffTicks&&(e._numBackoffs++,e._backoffTicks=g.getBackoffTicks(e._numBackoffs)),e._syncWithParameters(!0)))},t)}},I.prototype.stopPolling=function(){if(a.SHARED_LOCAL_STORAGE)throw new d(d.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)},I.prototype.createBookmark=function(e,t,n){this._bookmarkManager.createBookmark(e,t,n)},I.prototype.removeBookmark=function(e,t){this._bookmarkManager.removeBookmark(e,t)},I.prototype.findBookmark=function(e){var t;return this.bookmarks&&this.bookmarks.some(function(n){if(n.url===e._dcxComposite.href)return t=n,!0}),t},I.prototype.getDefaultLibrary=function(){var e;return this.libraries.forEach(function(t){"incoming"!==t.collaboration&&(!e||(e.created||0)>(t.created||0))&&(e=t)}),e},I.prototype.getLibraryById=function(e){var t=this._libraryIdMap[e];if(t instanceof i)return t},I.prototype.updateAccessToken=function(e){if(a.SHARED_LOCAL_STORAGE)throw new d(d.NOT_SUPPORTED,"updateAccessToken() not supported with shared local storage");this._syncManager.updateAccessToken(e),r.log("defined")},I.prototype.getTempDir=function(e){if(r.hasFileSystem()){var t=this._getTempDir();f.ensurePathExists(t,function(n){e(n,t)})}else e(new d(d.REQUIRES_FILESYSTEM,"getTempDir only supported when you have a filesystem"))},Object.freeze(I),Object.seal(I.prototype),e.exports=I},function(e,t,n){var o=n(1),i=n(13),r={getStockData:function(e){return e&&e.getValue(o.STOCK_NAMESPACE,o.STOCK_DATA_KEY)},getStockDataForElement:function(e,t,n){var o=void 0===t?e.getPrimaryRepresentation():e.representations[t],a=r.getStockData(o);return a&&o.isExternalLink&&(i.shouldPrefetchExternalLink(o)&&!o.getCachedContentPath()||o.getCachedExternalLinkError())?r.getStockDataForElement(e,void 0===t?0:t+1,n||a.content_id):(!a&&n&&(a={content_id:n}),a)},getElementStockId:function(e){var t=r.getStockDataForElement(e);if(t)return String(t.content_id)},getElementStockLicense:function(e){var t=r.getStockDataForElement(e);if(t&&t.state===o.STOCK_STATE_PURCHASED)return String(t.license)}};e.exports=r},function(e,t){e.exports=require("ws")},function(e,t,n){var o=n(21),i=n(49),r=n(51),a=n(66),s=n(52),c=n(6),l=n(3),p=n(15),d=n(53);function u(e,t){e&&p._setFS(e),this._compositeOptions=c.merge({},t),t&&t.logCallback&&c._setLogCallback(t.logCallback)}u.COLLABORATION={PRIVATE:o.COLLABORATION.PRIVATE,SHARED_BY_USER:o.COLLABORATION.SHARED_BY_USER,SHARED_WITH_USER:o.COLLABORATION.SHARED_WITH_USER},u.AdobeDCXError=l,u.FileContent=i.FileContent,u.StreamProvider=i.StreamProvider,u.prototype.newEmptyComposite=function(e,t,n,i){var r=new o(e,t,null,i,null,this._compositeOptions);return n&&(r.path=n),r},u.prototype.newCompositeFromLocalStorage=function(e,t){try{if("string"!=typeof e)throw new l(l.INVALID_PARAMS,"");var n=new o(null,null,e,null,null,this._compositeOptions);n.loadCurrentFromLocalStorage(function(e){t(e,e?void 0:n)}),n.deleteTempFiles()}catch(e){t(e)}},u.prototype.newCompositeWithHref=function(e,t,n,i,r){var a=new o(n,r,null,i,e,this._compositeOptions);return t&&(a.path=t),a},u.prototype.newCompositeAsCopyOf=function(e,t,n,i,r,a){return o.newCompositeAsCopyOf(e,t,n,i,r,a,this._compositeOptions)},u.prototype.createHTTPService=function(e){return new i(e)},u.prototype.createStorageSession=function(e,t){return new r(e,t)},u.prototype.createCommunitySession=function(e,t){return new a(e,t)},u.prototype.compositeXfer=s,u.prototype.snapshot=d,e.exports=u},function(e,t,n){var o=n(3),i=n(62),r=n(40),a=n(15),s=n(6);function c(e,t,n){this._readOnly=n,this._owner=t,this._setData(e),this._localStorage=void 0}function l(e,t,n,i,r,a,c,l){var p=t._owner._core,d=e._owner._core,u=n&&e.id===t.id,h=d._getSourceHrefOfComponent(e),_=p.getComponentWithId(t.id),f=i&&(!_||!_.etag)&&"unmodified"===e.state,m=!u&&!h,E=m;if(r&&!_&&(h||m)&&e.id===t.id&&(t._data.id=s.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,c)&&(E=!1,u||(t.state="modified")),m){if(f){if(h=d._getHrefOfComponent(e),p._setSourceHrefOfComponent(h,t,c),!h&&E)throw new o(o.INVALID_STATE,"Failed to determine the source href of a component that does not have a local file.")}else if(E)throw new o(o.INVALID_STATE,"Could not use server-to-server copy for component "+e.id)}else p._setSourceHrefOfComponent(h,t,c);h&&(t.state="modified")}Object.defineProperties(c.prototype,{rootNode:{get(){return this.getChildWithAbsolutePath(i.ROOT_PATH)},set(){throw new o(o.READ_ONLY,'Property "rootNode" is read-only.')}},hasLocalStorage:{get(){return this._localStorage},set(){throw new o(o.READ_ONLY,"Cannot set the property hasLocalStorage.")}},isDirty:{get(){return this._isDirty},set(){throw new o(o.READ_ONLY,"Cannot set the property isDirty.")}},changeCount:{get(){return this._data.local&&this._data.local.change||0},set(){throw new o(o.READ_ONLY,"Cannot set the property changeCount.")}}}),c.prototype.getChildWithId=function(e){return this._allNodes[e]},c.prototype.getChildWithAbsolutePath=function(e){var t=this._absolutePaths[e.toLowerCase()];return t&&t instanceof i?t:void 0},c.prototype.getChildrenOf=function(e){if(!(e=e?this._allNodes[e.id]:this.rootNode))throw new o(o.INVALID_PARAMS,"Unknown node");var t,n=[],i=e._data.children;if(Array.isArray(i))for(t=0;t<i.length;t++){var r=i[t],a=this._allNodes[r.id];if(!a)throw new o(o.INVALID_DATA,"Node not in cache");n[n.length]=a}return n},c.prototype.addChild=function(e,t,n,r){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(t=t||s.generateUuid(),this._allNodes[t])throw new o(o.DUPLICATE_VALUE,"Node already exists in branch.");if(n&&("number"!=typeof n||n%1!=0))throw new o(o.INVALID_PARAMS,'Param "index" must be an integer.');var a=r?this._allNodes[r.id]:this.rootNode;if(!a)throw new o(o.INVALID_PARAMS,"Unknown parent node.");var c=new i;c.id=t,e&&(c.name=e),c._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]=c._data:l.splice(n,0,c._data)):a._data.children=[c._data],this._allNodes[c.id]=c,c._owner=this._owner,this._setDirty(),c},c.prototype.removeChild=function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "node".');if(e.isRoot)throw new o(o.INVALID_PARAMS,"Cannot remove the root node.");var t=e.id;if(!t)throw new o(o.INVALID_PARAMS,'Param "node" must have an id.');var n=this._nodeDataOfParentOfNode(e);if(!n)throw new o(o.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},c.prototype.moveChild=function(e,t,n){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "node".');if(e.isRoot)throw new o(o.INVALID_PARAMS,"Cannot move the root node.");if(t&&("number"!=typeof t||t%1!=0))throw new o(o.INVALID_PARAMS,'Param "index" must be an integer.');var i=e.id;if(!i)throw new o(o.INVALID_PARAMS,'Param "node" must have an id.');var r=this._nodeDataOfParentOfNode(e);if(e=this._allNodes[i],!r)throw new o(o.INVALID_PARAMS,"Node not found in this branch.");var a=n?this._allNodes[n.id]:this.rootNode;if(!a)throw new o(o.INVALID_PARAMS,"Unknown parent node.");if(this._nodeIdIsDescendantOf(a.id,e._data))throw new o(o.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[i]},c.prototype.copyChild=function(e,t,n,o,i,r){return this._copyChild(e,t,n,o,i,!1,r)},c.prototype.replaceChild=function(e,t,n,o){return this._copyChild(e,void 0,void 0,t,n||e.id,!0,o)},c.prototype.allComponents=function(){var e,t=[];for(e in this._allComponents)this._allComponents.hasOwnProperty(e)&&t.push(this._allComponents[e]);return t},c.prototype.getComponentWithId=function(e){return this._allComponents[e]},c.prototype.getComponentWithAbsolutePath=function(e){var t=this._absolutePaths[e.toLowerCase()];return t&&t instanceof r?t:void 0},c.prototype.getComponentsOf=function(e){if(!(e=e?this._allNodes[e.id]:this.rootNode))throw new o(o.INVALID_PARAMS,"Unknown node");var t,n=[],i=e._data.components;if(Array.isArray(i))for(t=0;t<i.length;t++){var r=i[t],a=this._allComponents[r.id];if(!a)throw new o(o.INVALID_DATA,"Component not in cache");n[n.length]=a}return n},c.prototype.addComponent=function(e,t,n,i,a,c,l,p,d,u){var h=this._localStorage;if(!h)throw new o(o.NO_LOCAL_STORAGE,"No local storage. Use AdobeDCXCompositeXfer.uploadNewComponent() followed by addComponentWithUploadResults()");if("function"!=typeof u&&a)throw new o(o.INVALID_PARAMS,'Param "callback" must be a function.');if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(d&&"string"!=typeof d)throw new o(o.INVALID_PARAMS,'Param "id" must be of type string.');if(!a&&!l)throw new o(o.INVALID_PARAMS,"Must provide either source or sourceHref.");try{if(l){var _=this._getBranchOf(this).compositeHref;if(_){var f=s.endPointOf(_),m=s.endPointOf(l);if(f&&m&&f!==m)throw new o(o.WRONG_ENDPOINT,"Given source href has an invalid endpoint: "+m)}}var E=this._local();d=d||s.generateUuid();var g=new r;g.id=d,g.name=e,g.type=t,g.relationship=n,g.path=i,g.state="modified";var y=this,v=function(e){if(!e)try{if(d&&y._allComponents[d])throw new o(o.DUPLICATE_VALUE,'The "id" of a component must be unique.');var t=p?y._allNodes[p.id]:y.rootNode;if(!t)throw new o(o.INVALID_PARAMS,"Unknown parent node.");var n=y._normalizedAbsolutePathForItem(g,t);if(y._absolutePaths[n])throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+n);if(!s.isValidAbsolutePath(n))throw new o(o.INVALID_PARAMS,"Invalid absolute path: "+n);g._parentPath=t.absolutePath||t._parentPath;var i=t._data.components;i?i.push(g._data):t._data.components=[g._data],g._owner=y._owner,l&&y._setSourceHrefOfComponent(l,g),y._allComponents[g.id]=g,y._absolutePaths[n]=g,y._setDirty()}catch(t){h.removeComponentAsset(g,E),l&&y._setSourceHrefOfComponent(void 0,g),g=void 0,e=t}if(u)return u(e,g);if(e)throw e;return g};if(!a)return v();h.ingestComponentAsset(g,a,c,E,v)}catch(e){if(u)return u(e);throw e}},c.prototype.addComponentWithUploadResults=function(e,t,n,i,a){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(a.compositeId!==this._owner.compositeId)throw new o(o.INVALID_PARAMS,"Param uploadResults does not appear valid to be for this composite.");var s=Object.keys(a.records);if(1!==s.length)throw new o(o.INVALID_PARAMS,"Param uploadResults must contain records of exactly one component upload.");if(this._localStorage)throw new o(o.INVALID_PARAMS,"This method is for in-browser use only. Use addComponent() instead.");var c=a.records[s[0]],l=c.id;if(this._allComponents[l])throw new o(o.DUPLICATE_VALUE,"Duplicate component id: "+l);var p=i?this._allNodes[i.id]:this.rootNode;if(!p)throw new o(o.INVALID_PARAMS,"Unknown parent node.");var d=new r;d.id=l,d.name=e,d.type=c.type,d.relationship=t,d.path=n,d.state="unmodified",d.etag=c.etag,d.length=c.length,d.version=c.version,d.md5=c.md5;var u=this._normalizedAbsolutePathForItem(d,p);if(this._absolutePaths[u])throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+u);d._parentPath=p.absolutePath||p._parentPath;var h=p._data.components;return h?h.push(d._data):p._data.components=[d._data],d._owner=this._owner,this._allComponents[l]=d,this._absolutePaths[u]=d,this._setDirty(),d},c.prototype.updateComponent=function(e,t,n,i){var r=this._localStorage;if(!r)throw new o(o.NO_LOCAL_STORAGE,"No local storage. Use AdobeDCXCompositeXfer.uploadComponent() to upload a new component asset and then call updateComponentWithUploadResults()");if("function"!=typeof i)throw new o(o.INVALID_PARAMS,'Param "callback" must be a function.');if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!(e=this._allComponents[e.id]))throw new o(o.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}i(t,e)})}catch(e){i(e)}},c.prototype.updateComponentWithUploadResults=function(e,t){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!(e=this._allComponents[e.id]))throw new o(o.INVALID_PARAMS,"Unknown component.");if(this._localStorage)throw new o(o.INVALID_PARAMS,"This method is for in-browser use only. Use updateComponent() instead.");if(t.compositeId!==this._owner.compositeId)throw new o(o.INVALID_PARAMS,"Param uploadResults does not appear valid to be for this composite.");var n=t.records[e.id];if(!n)throw new o(o.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},c.prototype.removeComponent=function(e){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "component".');var t=e.id;if(!t)throw new o(o.INVALID_PARAMS,'Param "component" must have an id.');var n=this._nodeDataOfParentOfComponent(e);if(!n)throw new o(o.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},c.prototype.moveComponent=function(e,t){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "component".');var n=e.id;if(!n)throw new o(o.INVALID_PARAMS,'Param "component" must have an id.');var i=this._nodeDataOfParentOfComponent(e);if(!i)throw new o(o.INVALID_PARAMS,"Component not found in this branch.");var r=t?this._allNodes[t.id]:this.rootNode;if(!r)throw new o(o.INVALID_PARAMS,"Unknown parent node.");var a=this._normalizedAbsolutePathForItem(e,r);if(this._absolutePaths[a])throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+a);var s=i.parentNodeData.components.splice(i.index,1)[0],c=r._data.components;return c?c.push(s):r._data.components=[s],0===i.parentNodeData.components.length&&delete i.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},c.prototype.copyComponent=function(e,t,n,o,i){return this._copyComponent(e,t,n,o,!1,i)},c.prototype.replaceComponent=function(e,t,n,o){return this._copyComponent(e,void 0,t,n||e.id,!0,o)},c.prototype.assetOfComponent=function(e,t){try{if(!this._localStorage)throw new o(o.NO_LOCAL_STORAGE,"No local storage.");if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "component".');if(!e.id)throw new o(o.INVALID_PARAMS,'Param "component" must have an id.');var n=this._localStorage.componentAssetPath(e,this._local());if(!t)return n;a.exists(n,function(e){t(void 0,e?n:null)})}catch(e){if(!t)throw e;t(e)}},c.prototype._getHrefOfComponent=function(e){var t,n=this._getBranchOf(e).compositeHref;return n&&void 0!==e.version&&(t=s.appendPathElements(n,e.id),t+=";version="+e.version),t},c.prototype._setSourceHrefOfComponent=function(e,t,n){var o=t.id,i=this._componentSourceHrefLookup(!0,n);e?i[o]=e:i[o]&&delete i[o]},c.prototype._getSourceHrefOfComponent=function(e,t){var n=e.id,o=this._componentSourceHrefLookup(!1,t);if(o)return o[n]},c.prototype._copySourceHrefsFrom=function(e){var t=e._componentSourceHrefLookup(!1),n=this.allComponents(),o=n.length;if(o&&t){var i,r=this._componentSourceHrefLookup(!0);for(i=0;i<o;i++){var a=n[i].id;r[a]=t[a]}}},c.prototype._getBranchOf=function(e){return e._owner?this._getBranchOf(e._owner):e},c.prototype._isSameComposite=function(e){var t=this._getBranchOf(this),n=this._getBranchOf(e);return t._data.id===n._data.id&&(t.compositeHref===n.compositeHref&&this._localStorage===e._localStorage)},c.prototype._stringify=function(e,t){if(e){var n=this._data.local,o=null;try{delete this._data.local,o=JSON.stringify(this._data,void 0,t?2:void 0)}catch(e){throw e}finally{n&&(this._data.local=n)}return o}return JSON.stringify(this._data,void 0,t?2:void 0)},c.prototype._setData=function(e){var t=new i(e,this._readOnly,!0);t._owner=this._owner,t._parentPath="";var n={},a={},c={};a[t.id]=t,c[i.ROOT_PATH]=t;var l=this,p=function(e,t,n,a,c){var d,u,h,_=e.components;if(Array.isArray(_))for(d=0;d<_.length;d++){var f=_[d],m=new r(f,l._readOnly);if(t[m.id])throw new o(o.INVALID_DATA,"Duplicate component id: "+m.id);if(m._owner=l._owner,m._parentPath=c,a[h=l._normalizedAbsolutePathForItem(m)])throw new o(o.INVALID_DATA,"Duplicate absolute path: "+h);if(!s.isValidAbsolutePath(h))throw new o(o.INVALID_DATA,"Invalid absolute component path: "+h);t[m.id]=m,a[h]=m}var E=e.children;if(Array.isArray(E))for(d=0;d<E.length;d++){var g=E[d],y=new i(g,l._readOnly);if(n[y.id])throw new o(o.INVALID_DATA,"Duplicate node id: "+y.id);if(u=y.path,y._owner=l._owner,y._parentPath=c,u){if(a[h=l._normalizedAbsolutePathForItem(y)])throw new o(o.INVALID_DATA,"Duplicate absolute path: "+h);if(!s.isValidAbsolutePath(h))throw new o(o.INVALID_DATA,"Invalid node absolute path: "+h);a[h]=y}n[y.id]=y,p(g,t,n,a,y.path?s.appendPathElements(c,y.path):c)}};return p(e,n,a,c,i.ROOT_PATH),this._data=e,this._allComponents=n,this._allNodes=a,this._absolutePaths=c,this._isDirty=!1,this},c.prototype._removeNodeFromCachesRecursively=function(e){var t,n=e.components;if(Array.isArray(n))for(t=0;t<n.length;t++){var o=n[t].id,i=this._allComponents[o];delete this._allComponents[o],delete this._absolutePaths[this._normalizedAbsolutePathForItem(i)],i._owner=void 0,this._localStorage&&(this._localStorage.removeComponentAsset(i,this._local()),this._setSourceHrefOfComponent(void 0,i))}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},c.prototype._local=function(){return this._data.local||(this._data.local={version:2}),this._data.local},c.prototype._componentSourceHrefLookup=function(e,t){if(e&&this._readOnly)throw new o(o.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}},c.prototype._recursiveReset=function(e,t){var n,o=e.components;if(o)for(n=o.length-1;n>=0;n--){var i=o[n];"committedDelete"===i.state?(delete o[n],delete this._allComponents[i.id],delete i._owner,this._localStorage&&this._localStorage.removeComponentAsset(i,this._local()),this._setSourceHrefOfComponent(void 0,i,this._local())):(delete i.etag,delete i.version,delete i.length,delete i.md5,i.state="modified",t&&t(i))}var r=e.children;if(r)for(n=0;n<r.length;n++)this._recursiveReset(r[n],t)},c.prototype._nodeIdIsDescendantOf=function(e,t){var n,o=t.children;if(o)for(n=0;n<o.length;n++){var i=o[n];if(i.id===e||this._nodeIdIsDescendantOf(e,i))return!0}return!1},c.prototype._recursivelyGetAllComponentsOfChild=function(e,t){t=t||[];var n,o,i=e._data||e,r=i.components;if(r)for(o=r.length,n=0;n<o;n++)t[t.length]=this._allComponents[r[n].id];var a=i.children;if(a)for(o=a.length,n=0;n<o;n++)t=this._recursivelyGetAllComponentsOfChild(a[n],t);return t},c.prototype._nodeDataOfParentOfNode=function(e,t){t=t||this._data;var n,o=e._data.id,i=t.children;if(i)for(n=0;n<i.length;n++){var r=i[n];if(r.id===o)return{parentNodeData:t,index:n};var a=this._nodeDataOfParentOfNode(e,r);if(a)return a}return null},c.prototype._nodeDataOfParentOfComponent=function(e,t){t=t||this._data;var n,o=e._data.id,i=t.components;if(i)for(n=0;n<i.length;n++){if(i[n].id===o)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},c.prototype._determineAbsolutePathChangesRecursively=function(e,t,n){var o,i=e.components;if(i)for(o=0;o<i.length;o++){var r=i[o],a=this._allComponents[r.id];n.push({item:a,parentPath:t,absPath:s.appendPathElements(t,r.path)})}var c=e.children;if(c)for(o=0;o<c.length;o++){var l=c[o],p=this._allNodes[l.id],d=l.path,u=d?s.appendPathElements(t,d):t;n.push({item:p,parentPath:t,absPath:d?u:void 0}),this._determineAbsolutePathChangesRecursively(l,u,n)}},c.prototype._setPathOfNode=function(e,t){var n=t?s.appendPathElements(e.parentPath,t):e.parentPath,i=[{item:e,absPath:t?n:void 0}];this._determineAbsolutePathChangesRecursively(e._data,n,i);var r,a,c=s.flatCopy(this._absolutePaths);for(r=0;r<i.length;r++){var l=i[r].item;l._data.path&&delete c[this._normalizedAbsolutePathForItem(l)]}for(r=0;r<i.length;r++)if((a=i[r]).absPath){var p=a.absPath.toLowerCase();if(c[p])throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+p);if(!s.isValidAbsolutePath(p))throw new o(o.INVALID_PARAMS,"Invalid absolute path: "+p);c[p]=a.item}for(r=0;r<i.length;r++)(a=i[r]).parentPath&&(a.item._parentPath=a.parentPath);e._data.path=t,this._absolutePaths=c},c.prototype._setPathOfComponent=function(e,t){if(!this._allComponents[e.id])throw new o(o.INVALID_PARAMS,"Unknown component.");var n=s.appendPathElements(e.parentPath,t).toLowerCase();if(this._absolutePaths[n])throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path for component: "+n);if(!s.isValidAbsolutePath(n))throw new o(o.INVALID_PARAMS,"Invalid absolute path: "+n);delete this._absolutePaths[this._normalizedAbsolutePathForItem(e)],this._absolutePaths[n]=e,e._data.path=t},c.prototype._setDirty=function(e){if(!e){if("pending"===this._local().archivalState||"archived"===this._local().archivalState)throw new o(o.INVALID_STATE,"Cannot modify an archived composite.");"pendingDelete"!==this._data.state&&"committedDelete"!==this._data.state||console.error("Modifying deleted composite")}this._isDirty=!0,this._local().change=this.changeCount+1,e||"unmodified"!==this._data.state&&this._data.state||(this._data.state="modified")},c.prototype._normalizedAbsolutePathForItem=function(e,t){return(t?s.appendPathElements(t.absolutePath||t._parentPath,e.path):e.absolutePath).toLowerCase()},c.prototype._hasSameEndpoint=function(e){var t=this._getBranchOf(this).compositeHref,n=this._getBranchOf(e).compositeHref;if(t&&n){var o=s.endPointOf(t),i=s.endPointOf(n);if(o&&i&&o!==i)return!1}return!0},c.prototype._copyComponent=function(e,t,n,i,r,a){if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "component".');if(a&&"function"!=typeof a)throw new o(o.INVALID_PARAMS,"Param callback must be a function.");var s=this,c=e._owner._core,p=this._isSameComposite(c),d=p||this._hasSameEndpoint(e),u=c._local(),h=this._localStorage,_=c._localStorage,f=h&&_;if(f&&!a&&!p)throw new o(o.INVALID_PARAMS,"Must pass a callback when copying between two different composites.");if(!f&&!d)throw new o(o.NO_LOCAL_STORAGE,"Cannot copy between two different endpoints without local storage.");var m=function(e,t,n){l(e,t,p,d,!i,f?h:void 0,n,u)},E=f?_.componentAssetPath(e,u):void 0;if(!a)return this._copyComponentModel(e,t,r,n,i,m);if(p||!E)try{a(void 0,this._copyComponentModel(e,t,r,n,i,m))}catch(e){a(e)}else{var g={};h.ingestComponentAsset(e,E,!0,g,function(o){if(o)a(o);else try{u=g,a(void 0,s._copyComponentModel(e,t,r,n,i,m))}catch(e){a(e)}})}},c.prototype._copyComponentModel=function(e,t,n,i,a,c){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "component".');var l=e._owner,p=new r(JSON.parse(JSON.stringify(e._data)));i?(p.path=i,p.id=a||s.generateUuid()):a&&(p.id=a),p._owner=this._owner,e.id===p.id&&this._isSameComposite(l._core)||(p.state="modified",p.etag=void 0,p.version=void 0,p.md5=void 0,p.length=void 0);var d,u,h=this._allComponents[p.id];if(h&&!n)throw new o(o.DUPLICATE_VALUE,"Component already exists.");if(n&&!h)throw new o(o.INVALID_PARAMS,"Could not find existing component.");if(n){var _=this._nodeDataOfParentOfComponent(h);if(!_)throw new o(o.INVALID_PARAMS,"Parent node of existing component not found in this branch.");var f=_.parentNodeData.id;if(!(u=this._allNodes[f]))throw new o(o.INVALID_STATE,"Unknown parent node.");d=_.index}else if(!(u=t?this._allNodes[t.id]:this.rootNode))throw new o(o.INVALID_PARAMS,"Unknown parent node.");p._parentPath=u.absolutePath||u._parentPath;var m=this._normalizedAbsolutePathForItem(p),E=this._absolutePaths[m];if(E&&E!==h)throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+m);if(!s.isValidAbsolutePath(m))throw new o(o.INVALID_PARAMS,"Component path must be a valid path for a component.");var g=this._local();c&&c(e,p,g=s.deepCopy(g));var y=u._data.components;return n?y[d]=p._data:y?y.push(p._data):u._data.components=[p._data],this._data.local=g,this._allComponents[p.id]=p,this._absolutePaths[m]=p,this._setDirty(),p},c.prototype._copyChild=function(e,t,n,i,r,a,s){if(!e)throw new o(o.INVALID_PARAMS,'Expecting param "node".');var c=this,p=e._owner._core,d=this._isSameComposite(p),u=d||this._hasSameEndpoint(e),h=p._local(),_=this._localStorage,f=p._localStorage,m=_&&f,E=p._recursivelyGetAllComponentsOfChild(e);if(E.length>0){if(m&&!s&&!d)throw new o(o.INVALID_PARAMS,"Must pass a callback when copying between two different composites.");if(!m&&!u)throw new o(o.NO_LOCAL_STORAGE,"Cannot copy components between two different endpoints without local storage.")}var g=function(e,t,n){l(e,t,d,u,!0,m?_:void 0,n,h)};if(!s)return this._copyChildModel(e,t,n,a,i,r,g);var y=function(){s(void 0,c._copyChildModel(e,t,n,a,i,r,g))};if(0===E.length||d||!m)try{y()}catch(e){s(e)}else{var v,A,C={},I=E.length,S=0,L=function(e){if(e&&!A&&(A=e),0===--S)if(A)s(A);else try{h=C,y()}catch(e){s(e)}};for(v=0;v<I;v++){var O=E[v],R=f.componentAssetPath(O,h);R&&(S++,_.ingestComponentAsset(O,R,!0,C,L))}if(0===S)try{y()}catch(e){s(e)}}},c.prototype._copyChildModel=function(e,t,n,a,c,l,p){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");var d=e._owner,u=new i(JSON.parse(JSON.stringify(e._data)));c?(u.path=c,u.id=l||s.generateUuid()):l&&(u.id=l),u._owner=this._owner,e.isRoot&&(delete u._data.local,delete u._data["manifest-format-version"]);var h,_=this._allNodes[u.id];if(_&&!a)throw new o(o.DUPLICATE_VALUE,"Child node already exists.");if(a&&!_)throw new o(o.INVALID_PARAMS,"Could not find existing node to replace.");if(a){var f=this._nodeDataOfParentOfNode(_);if(!f)throw new o(o.INVALID_PARAMS,"Parent of existing node not found in this branch.");var m=f.parentNodeData.id;if(!(h=this._allNodes[m]))throw new o(o.INVALID_STATE,"Unknown parent node.");n=f.index}else if(!(h=t?this._allNodes[t.id]:this.rootNode))throw new o(o.INVALID_PARAMS,"Unknown parent node.");if(u._parentPath=h.absolutePath||h._parentPath,u.path){var E=this._normalizedAbsolutePathForItem(u),g=this._absolutePaths[E];if(g&&g!==_)throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+E);if(!s.isValidAbsolutePath(E))throw new o(o.INVALID_PARAMS,"Node path must be a valid path for a node.")}var y=s.flatCopy(this._allNodes),v=s.flatCopy(this._allComponents),A=s.flatCopy(this._absolutePaths),C=s.deepCopy(this._local()),I=function(e,t,n,o,i,r){var a,s;delete n[e.id],e.path&&delete i[t._normalizedAbsolutePathForItem(e)];var c=e._data.children;if(c)for(s=c.length,a=0;a<s;a++)I(n[c[a].id],t,n,o,i,r);var l=e._data.components;if(l)for(s=l.length,a=0;a<s;a++){var p=o[l[a].id];delete o[p.id],delete i[t._normalizedAbsolutePathForItem(p)],t._localStorage&&(t._localStorage.removeComponentAsset(p,r),t._setSourceHrefOfComponent(void 0,p,r))}};_&&I(_,this,y,v,A,C);var S=function(e,t,n,a,c,l,d,u){if(a[e.id])throw new o(o.DUPLICATE_VALUE,"Duplicate node id: "+e.id);var h;if(a[e.id]=e,e.path){if(l[h=t._core._normalizedAbsolutePathForItem(e)])throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+h);l[h]=e}var _,f,m=e._data.children;if(m)for(f=m.length,_=0;_<f;_++){var E=new i(m[_]);a[E.id]&&(E.id=s.generateUuid()),E._owner=t,E._parentPath=e.absolutePath||e._parentPath,S(E,t,n,a,c,l,d,u)}var g=e._data.components;if(g)for(f=g.length,_=0;_<f;_++){var y=new r(g[_]),v=y.id;if(c[v]&&(y.id=s.generateUuid(),y.state="modified",y.etag=void 0,y.version=void 0,y.md5=void 0,y.length=void 0),y._owner=t,y._parentPath=e.absolutePath||e._parentPath,p&&p(n.getComponentWithId(v),y,d),c[y.id])throw new o(o.DUPLICATE_VALUE,"Duplicate component id: "+y.id);if(c[y.id]=y,l[h=t._core._normalizedAbsolutePathForItem(y)])throw new o(o.DUPLICATE_VALUE,"Duplicate absolute path: "+h);l[h]=y}};if(S(u,this._owner,d,y,v,A,C,d._local()),a)h._data.children[n]=u._data;else{var L=h._data.children;L?(n>=0&&n<=L.length||(n=L.length),n===L.length?L[n]=u._data:L.splice(n,0,u._data)):h._data.children=[u._data]}return this._allNodes=y,this._allComponents=v,this._absolutePaths=A,this._data.local=C,this._setDirty(),u},c.prototype._verifyIntegrity=function(e,t,n){var r,a=this,c=[],l=!1,p=function(e){return c.push(new o(o.INVALID_STATE,e)),t&&(l||(t("Branch for composite "+a.rootNode.id+" has the following errors:"),l=!0),t("   "+e)),!1},d=function(e,t){return!!e||p(t)},u=[],h=function(e){(u.indexOf(e)<0||p("Item "+e.id+" encountered more than once"))&&u.push(e)},_=s.flatCopy(this._allComponents),f=s.flatCopy(this._allNodes),m=s.flatCopy(this._absolutePaths),E=Object.keys(m),g=E.length;for(r=0;r<g;r++){var y=E[r];d("/"===y.charAt(0),"Absolute path "+y+" does not start with a slash.")}var v=function(e,t){var n,o,i=e.children;if(i)for(n=0;n<i.length;n++){var r=i[n],c=f[r.id];(c||p("Node "+r.id+" is not in cache."))&&(h(c),d(c._data===r,"Node "+c.id+" _data property incorrect."),delete f[c.id],c.path&&c._owner&&(o=a._normalizedAbsolutePathForItem(c),(m[o]||p("Absolute path of node "+c.id+" ("+o+") is not in cache."))&&delete m[o]),d(c._parentPath===t,"Parent path of node "+c.id+" should be "+t+" but is "+c._parentPath),d(c._owner===a._owner,"Node "+c.id+" _owner property is not correct.")),v(r,r.path?s.appendPathElements(t,r.path):t)}var l=e.components;if(l)for(n=0;n<l.length;n++){var u=l[n],E=_[u.id];(E||p("Component "+u.id+" is not in cache."))&&(h(E),d(E._data===u,"Component "+E.id+" _data property incorrect."),delete _[E.id],E._owner&&(o=a._normalizedAbsolutePathForItem(E),(m[o]||p("Absolute path "+o+" is not in cache."))&&delete m[o]),d(E._parentPath===t,"Parent path of component "+E.id+" should be "+t+" but is "+E._parentPath),d(E._owner===a._owner,"Component "+E.id+" _owner property is not correct."))}},A=m[i.ROOT_PATH];d(A,"Cannot find root node via path")&&(d(A.id===this._data.id,"Root node has correct id"),d(A.path===i.ROOT_PATH,"Root node has correct path"),d(""===A._parentPath,"Root node has correct parent path"),d(A._owner===this._owner,"Root node has correct owner"),d(A._data===this._data,"Root node has correct data"),d(f[A.id]===A,"Cannot find root node via id")&&delete f[A.id],delete m[i.ROOT_PATH]),v(this._data,i.ROOT_PATH);var C=Object.keys(_);for(r=0;r<C.length;r++)p("Component "+C[r]+" is in cache but could not be found.");for(C=Object.keys(f),r=0;r<C.length;r++)p("Node "+C[r]+" is in cache but could not be found.");for(C=Object.keys(m),r=0;r<C.length;r++)p("Absolute path "+C[r]+" is in cache but could not be found.");if(this._localStorage){var I=this._localStorage.componentIds(this._local());for(r=0;r<I.length;r++)d(this._allComponents[I[r]],"Component "+I[r]+" is in local storage mapping but could not be found in the manifest.");if(e)for(I=Object.keys(this._allComponents),r=0;r<I.length;r++){var S=I[r],L=this._allComponents[S],O=this._localStorage.componentAssetPath(L,this._local());d(O,"Component "+S+" does not have an entry in local storage mapping.")&&n&&d(n.existsSync(O),"Asset "+O+" does not exist.")}var R=this._componentSourceHrefLookup();if(R)for(g=(I=Object.keys(R)).length,r=0;r<g;r++){var N=this._allComponents[I[r]];N?d("modified"===N.state,"Component "+I[r]+" is in local source href mapping but has a state of "+N.state):d(!1,"Component "+I[r]+" is in local source href mapping but could not be found in the manifest.")}}return c.length?c:null},e.exports=c},function(e,t){e.exports=require("uuid/v4")},function(e,t,n){var o=n(3),i=n(15),r=3;function a(e,t,n){n?this._setData(n,e.href):this._data={"push-journal-format-version":r,"composite-href":e.href,"uploaded-components":{}},this._filePath=t,this._waitingCallbacks=[],this._commitInProgress=!1,this._needAnotherCommit=!1}a.readJournal=function(e,t,n,o){i.readFile(e,"utf8",function(i,r){var s;if(i&&i.code&&n&&(i=void 0),!i)try{r=JSON.parse(r),s=new a(t,e,r)}catch(o){n?s=new a(t,e):i=o}o(i,i?void 0:s)})},Object.defineProperties(a.prototype,{compositeHref:{get(){return this._data["composite-href"]},set(){throw new o(o.READ_ONLY,"This property is read-only.")}},manifestEtag:{get(){return this._data.etag},set(e){e?this._data.etag=e:delete this._data.etag}},currentBranchEtag:{get(){return this._data["current-branch-etag"]},set(e){e?this._data["current-branch-etag"]=e:delete this._data["current-branch-etag"]}},changeCount:{get(){return this._data.change},set(e){e?this._data.change=e:delete this._data.change}},compositeHasBeenCreated:{get(){return!!this._data["composite-created"]},set(e){e?this._data["composite-created"]=!0:delete this._data["composite-created"]}},compositeHasBeenDeleted:{get(){return!!this._data["composite-deleted"]},set(e){e?this._data["composite-deleted"]=!0:delete this._data["composite-deleted"]}},compositeHasBeenArchived:{get(){return!!this._data["composite-archived"]},set(e){e?this._data["composite-archived"]=!0:delete this._data["composite-archived"]}},isEmpty:{get(){return 0===Object.keys(this._data["uploaded-components"]).length&&!this.compositeHasBeenDeleted&&!this.manifestEtag},set(){throw new o(o.READ_ONLY,"This property is read-only.")}},isComplete:{get(){return!!(this._data.etag&&this._data.change||this._data["composite-deleted"]||this._data["composite-archived"])},set(){throw new o(o.READ_ONLY,"This property is read-only.")}}}),a.prototype.recordUploadedComponent=function(e,t,n,o,i,r,a){var s={etag:t,length:i,version:n,md5:o};r&&(s["storage-name"]=r),a&&(s["source-href"]=a),s.timestamp=(new Date).toISOString(),this._data["uploaded-components"][e]=s},a.prototype.idsOfAllUploadedComponents=function(){return Object.keys(this._data["uploaded-components"])};a.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},a.prototype.removeRecordForUploadedComponent=function(e){delete this._data["uploaded-components"][e]},a.prototype.applyToBranch=function(e,t){if(!this.isComplete)throw new o(o.INVALID_STATE,"Journal is not complete.");var n=e.isDirty;if(this.compositeHasBeenDeleted)e._data.state="committedDelete",e.manifestEtag=this.manifestEtag;else{this.compositeHasBeenArchived&&(e.compositeArchivalState="archived");var i,r="unmodified"!==e.compositeState&&this.changeCount!==e.changeCount,a=this.idsOfAllUploadedComponents(),s=a.length;for(i=0;i<s;i++){var c=a[i],l=e.getComponentWithId(c);if(l){var p=this.getRecordForUploadedComponent(l.id);l._data.etag=p.etag,l._data.length=p.length,l._data.version=p.version,l._data.md5=p.md5,p["source-href"]?e._core._getSourceHrefOfComponent(l)===p["source-href"]&&(l._data.state="unmodified",e._core._setSourceHrefOfComponent(void 0,l)):e.hasLocalStorage&&e._localStorage.componentAssetName(l,e._local())===p["storage-name"]?(l._data.state="unmodified",e._core._setSourceHrefOfComponent(void 0,l)):e.hasLocalStorage||(l._data.state="unmodified")}}e.manifestEtag=this.manifestEtag,r||(e._data.state="unmodified")}t&&(e._isDirty=n)},a.prototype.commitChanges=function(e){if(this._filePath){var t=this,n=function(e){t._needAnotherCommit=!1,t._commitInProgress=!0,t._waitingCallbacks=[],i.writeFileAtomically(t._filePath,JSON.stringify(t._data),"utf8",function(o){var i,r=e.length;for(i=0;i<r;i++)try{e[i](o)}catch(e){}t._needAnotherCommit?n(t._waitingCallbacks):t._commitInProgress=!1})};t._commitInProgress?(this._needAnotherCommit=!0,e&&this._waitingCallbacks.push(e)):n(e?[e]:[])}else e&&e()},a.prototype._setData=function(e,t){if(e["push-journal-format-version"]<=2){var n=e["uploaded-components"];if(n){var o,i=Object.keys(n),a=i.length;for(o=0;o<a;o++){var s=n[i[o]];"number"==typeof s.version&&(s.version=String(s.version))}}e["push-journal-format-version"]=r}var c=this._verify(e,t);if(null===c)return this._data=e,this;throw c},a.prototype._verify=function(e,t){return e["push-journal-format-version"]!==r?new o(o.INVALID_DATA,"Wrong push journal format version."):e["composite-href"]!==t?new o(o.INVALID_DATA,"Composite and journal hrefs mismatch."):e["uploaded-components"]?null:new o(o.INVALID_DATA,"Missing component list.")},e.exports=a},function(e,t,n){var o,i,r,a=n(6),s=n(3),c=n(15);i=n(26),r=n(50);var l=a.merge;function p(e){this.filename=e}function d(){}function u(e){this._requestQueue=[],this._requestsOutstanding=[],this._rejectedAuths=[],this._authCallback=e,this._isActive=!0,this._waitingForAuthentication=!1,this._currentAuthId=a.generateUuid(),this._https=i,this._XMLHttpRequest=o,this._handlesRedirects=void 0!==o,this._maxOutstanding=5}Object.defineProperties(u.prototype,{isActive:{get(){return this._isActive},set(e){this._isActive!==e&&(this._isActive=e,e||(this._authValue=void 0,this._checkQueue()))}},crossOriginCredentials:{get(){return this._withCredentials},set(e){this._withCredentials=e}},maxOutstanding:{get(){return this._maxOutstanding},set(e){this._maxOutstanding=e,this._checkQueue()}},handlesRedirects:{get(){return this._handlesRedirects}}}),u.prototype._forceXhr=function(e,t){this._https=void 0,this._XMLHttpRequest=e||o,this._handlesRedirects=!t},u.FileContent=p,u.StreamProvider=d,u.prototype.setAdditionalHeaders=function(e){this._additionalHeaders=e||{}},u.prototype.setAdditionalNodeOptions=function(e){this._additionalNodeOptions=e},u.prototype.setApiKey=function(e){this._apiKey=e},u.prototype.setTimeout=function(e){this._timeout=e},u.prototype.setAuthToken=function(e){e?(this._authValue="Bearer "+e,this.resume()):(this._authValue=void 0,this._currentAuthId=a.generateUuid())},u.prototype.resume=function(){this._currentAuthId=a.generateUuid(),this._waitingForAuthentication=!1,this._checkQueue()},u.prototype.setRequestHooks=function(e,t){this._beforeHook=e,this._afterHook=t},u.prototype.invoke=function(e,t,n,o,i,r){var d=(i=i||{}).responseType;if(d instanceof p){if(!c.canUseFileSystem)throw new s(s.INVALID_PARAMS,"No filesystem access")}else if("buffer"===d){if("function"!=typeof Buffer)throw new s(s.INVALID_PARAMS,"No Buffer class")}else if("blob"===d){if("function"!=typeof Blob)throw new s(s.INVALID_PARAMS,"No Blob class")}else if(d&&"text"!==d&&"json"!==d&&"arraybuffer"!==d)throw new s(s.INVALID_PARAMS,"Unsupported response type");n=l({},n,this._additionalHeaders),this._apiKey&&(n["x-api-key"]=this._apiKey);var u={method:e,href:t,headers:n,callback:r,body:o,options:i},h=i.reuseRequestDesc;if(h){if(this._requestQueue.indexOf(h)>=0||this._requestsOutstanding.indexOf(h)>=0)throw new s(s.INVALID_PARAMS,"Request descriptor still in use.");u=a.merge(h,u)}return this._doRequest(u),u},u.prototype._doRequest=function(e){var t,n,o,i=this,u=0,h=[],_=e.body,f=e.options.responseType;function m(t,o){t&&a.log("["+e.id+"] error: "+t),n&&n.end();var r=i._requestsOutstanding.indexOf(e);r>=0&&i._requestsOutstanding.splice(r,1);var c=e.callback;c&&(e.callback=void 0,t&&(t.clientRequest=e.clientRequest,t.xhr=e.xhr),t&&t.code!==s.SERVICE_IS_INACTIVE&&!i._isActive?t=new s(s.SERVICE_IS_INACTIVE,"Service is now inactive",t):e.timedOut&&(t=new s(s.TIMED_OUT,"timed out request",t)),c(t,o)),i._isActive&&i._checkQueue()}if(!this._isActive)return m(new s(s.SERVICE_IS_INACTIVE,"Network request in inactive state"));function E(t){t.pipe(o),t.on("error",function(t){return i.abort(e),m(new s(s.TERMINATED_INPUTSTREAM,"Input stream terminated abnormally",t))})}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(null===g.Authorization)delete g.Authorization;else{if(!this._allowAuthTokenToBeSentInsecurely_DONT_USE_THIS_IN_PRODUCTION&&0!==e.href.indexOf("https:"))return m(new s(s.INVALID_PARAMS,"Must not send auth token over unsecured connection"));this._authValue&&(g.Authorization=this._authValue)}if(this._currentAuthId&&(e.authId=this._currentAuthId),this._beforeHook&&this._beforeHook(e),e.id=a.generateUuid(),e.startTime=(new Date).valueOf(),g["X-Request-Id"]=e.id,this._https){this._requestsOutstanding.push(e);var y=r.parse(e.href),v=l({},this._additionalNodeOptions,y);v.method=e.method||"GET",v.headers=g,a.log("["+e.id+"] "+v.method+" "+e.href),o=this._https.request(v,function(t){var o=!1,r=!1,l=!1;function d(){if(!r)return r=!0,n=void 0,m(void 0,t)}var u=i._requestsOutstanding.indexOf(e);if(u<0)i._checkQueue();else{e.response=t;var _=(new Date).valueOf()-e.startTime;if(a.log("["+e.id+"] "+t.statusCode+" ("+_+"ms)"),401===t.statusCode&&i._authCallback)i._requestsOutstanding.splice(u,1),i._requestQueue.unshift(e),i._authFail(e),a.consumeStream(t);else{var E=e.progress;200===t.statusCode||201===t.statusCode||202===t.statusCode?(t.on("data",function(e){e.length&&E&&E(e.length),!n&&e&&h.push(e)}),i._https&&f instanceof p&&(n=c.createWriteStream(f.filename),t.pipe(n),o=!0)):a.consumeStream(t),t.once("end",function(){l=!0;var n=i._requestsOutstanding.indexOf(e);if(!(n<0||(i._requestsOutstanding.splice(n,1),i._checkQueue(),o||r)))return r=!0,t.response=Buffer.concat(h),"arraybuffer"===f?t.response=new ArrayBuffer(t.response):"text"===f&&(t.response=t.response.toString()),m(void 0,t)}),t.once("close",function(){if(!l&&!r)return r=!0,m(new s(s.NETWORK_ERROR,"incomplete response"))}),o&&(n.once("finish",d),n.once("close",d))}}}),e.clientRequest=o,o.once("error",m),i._timeout&&o.setTimeout(i._timeout,function(){e.timedOut=!0,o.abort()}),e.bytesSent=0,e.bytesReported=0,o.once("end",function(){if(e.progress){var t=e.bytesSent-e.bytesReported;t>0&&(e.progress(t),e.bytesReported+=t)}});var A=o.write;if(o.write=function(t){var n=t&&t.length;return n&&(e.bytesSent+=n),A.call(o,t,function(){e.progress&&t&&(e.progress(n),e.bytesReported+=n)})},_ instanceof p)E(c.createReadStream(_.filename));else if(_ instanceof d){if(_.getStream)E(_.getStream());else _.getStreamAsync&&_.getStreamAsync(function(t,n){if(t)return i.abort(e),m(new s(s.TERMINATED_INPUTSTREAM,"Error creating input stream",t));E(n)})}else if(_ instanceof Buffer)o.write(_),o.end();else if(_ instanceof ArrayBuffer)o.write(new Buffer(new Int8Array(_))),o.end();else if("string"==typeof _)o.write(new Buffer(_,"utf8")),o.end();else{if(_)return m(new s(s.INVALID_PARAMS,"Invalid data type"));o.end()}this._afterHook&&this._afterHook(e,o)}else{if(_ instanceof p)return c.canUseFileSystem?void c.readFile(_.filename,{},function(t,n){if(t)return m(t);e.body=n,i._doRequest(e)}):m(new s(s.INVALID_PARAMS,"Can't use FileContent without filesystem support"));var C;for(C in"function"==typeof Buffer&&_ instanceof Buffer&&(e.body=_=new Int8Array(_)),this._requestsOutstanding.push(e),a.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 p?"buffer":f),t.onreadystatechange=function(){var n=e.progress;if(n&&t.response){var o=t.response.length;n(o-u),u=o}if(4===t.readyState){if(0===t.status)return m(new s(s.UNEXPECTED,"XHR failure"));var r=i._requestsOutstanding.indexOf(e);if(r<0)i._checkQueue();else{var l=(new Date).valueOf()-e.startTime;if(a.log("["+e.id+"] "+t.status+" ("+l+"ms)"),i._requestsOutstanding.splice(r,1),401!==t.status||!i._authCallback){if(e.xhr=t,e.response=t,t.statusCode=t.status,t.headers=a.parseHeaders(t.getAllResponseHeaders()),f instanceof p){var d=t.response.response;return void c.writeFileAtomically(f.filename,d,void 0,function(e){return e?m(new s(s.UNEXPECTED,"Can't create file",e,t)):m(void 0,t)})}return n&&_&&n(_.length||_.size),m(void 0,t)}i._requestQueue.unshift(e),i._authFail(e),i._checkQueue()}}},g)g.hasOwnProperty(C)&&t.setRequestHeader(C,g[C]);e.xhr=t,i._timeout&&(t.timeout=i._timeout,t.ontimeout=function(){e.timedOut=!0,t.abort()}),_?t.send(_):t.send(),this._afterHook&&this._afterHook(e,t)}}},u.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)}},u.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 s(s.SERVICE_IS_INACTIVE,"Network request in inactive state")))});var t=this._requestQueue;return this._requestQueue=[],t.forEach(function(e){var t=new s(s.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,o=Date.now(),i=o+3e5,r=0;!(this._waitingForAuthentication||this._requestsOutstanding.length>=this._maxOutstanding||r>=this._requestQueue.length);){var a=this._requestQueue[r];(n=a.options.noSoonerThen||o)&&n>i&&(n=a.options.noSoonerThen=i),n<=o?(this._requestQueue.splice(r,1),a.options.noSoonerThen=void 0,this._doRequest(a)):r++}if(!this._waitingForAuthentication&&this._requestsOutstanding.length<this._maxOutstanding&&this._requestQueue.length>0){var c,l,p=this._requestQueue.length;for(l=0;l<p;l++)(n=this._requestQueue[l].options.noSoonerThen)&&n>i&&(n=this._requestQueue[l].options.noSoonerThen=i),n&&(c=c&&c<n?c:n);if(c&&(!this._checkQueueTimerWhen||this._checkQueueTimerWhen>c)){this._checkQueueTimerId&&clearTimeout(this._checkQueueTimerId),this._checkQueueTimerWhen=c;var d=this;this._checkQueueTimerId=setTimeout(function(){d._checkQueueTimerWhen=void 0,d._checkQueueTimerId=void 0,d._checkQueue()},c-o)}}},u.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())},u.prototype.abortAllWithToken=function(e){if(e){var t;for(t=0;t<this._requestQueue.length;++t)this._requestQueue[t].token===e&&(this._requestQueue.splice(t,1),--t);for(t=0;t<this._requestsOutstanding.length;++t)if(this._requestsOutstanding[t].token===e){var n=this._requestsOutstanding[t];this._requestsOutstanding.splice(t,1),--t,n.xhr&&n.xhr.abort(),n.clientRequest&&n.clientRequest.abort()}this._checkQueue()}},e.exports=u},function(e,t){e.exports=require("url")},function(e,t,n){var o=n(41),i=n(3),r=i.networkError,a=i.unexpectedResponse,s=n(21),c=n(6),l=n(15),p=c.appendPathElements,d="If-Match";function u(e,t){if(o.call(this,e,t),!this._endPoint)throw new i(i.INVALID_PARAMS,"Could not determine endpoint from: "+t);this.authenticationWhitelist=["adobe.com","adobe.io","fotolia.net"]}u.prototype=Object.create(o.prototype),u.prototype.name="AdobeStorageSession",u.FileContent=o.FileContent,u.StreamProvider=o.StreamProvider,u.prototype.getCollection=function(e,t,n){if(!(e=this._resolveUrl(e)))return n(new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+e));var o;e+="?order=asc&orderby=name";var s={};t&&(s["If-None-Match"]=t);var c=this;return this._service.invoke("GET",e,s,void 0,{responseType:"text"},function t(l,p){if(l)return n(r("Error retrieving a collection",l,p));if(200===p.statusCode){var d,u=p.responseText||p.response;try{d=JSON.parse(u)}catch(e){return(l=new i(i.INVALID_DATA,"Invalid JSON returned by server",e)).response=p,n(l)}o?o.children=o.children.concat(d.children):o=d;var h=p.headers["x-children-next-start"];if(h){var _=e+"&start="+h;c._service.invoke("GET",_,s,void 0,{responseType:"text"},t)}else n(void 0,o,p.headers.etag,p.headers)}else 304===p.statusCode?n(void 0,null,p.headers.etag,p.headers):n(a("Unexpected status code while getting a collection",void 0,p))})},u.prototype.pagedGetCollection=function(e,t,n,o,s,c,l,p){if(!(e=this._resolveUrl(e)))return p(new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+e));e+=function(e,t,n,o){var i=[],r="";return t&&i.push("order="+t),e&&i.push("orderBy="+e),n&&i.push("start="+n),o&&i.push("limit="+o),i.length>0&&(r="?"+i.join("&")),r}(n,o,s,c);var d={};return t&&(d["If-None-Match"]=t),this._service.invoke("GET",e,d,void 0,{responseType:"text"},function(e,t){if(e)return p(r("Error retrieving a collection",e,t));if(200===t.statusCode){var n,o=t.responseText||t.response;try{n=JSON.parse(o)}catch(n){return(e=new i(i.INVALID_DATA,"Invalid JSON returned by server",n)).response=t,p(e)}l?l.children=l.children.concat(n.children):l=n,p(void 0,l,t.headers.etag,t.headers)}else 304===t.statusCode?p(void 0,null,t.headers.etag,t.headers):p(a("Unexpected status code while getting a collection",void 0,t))})},u.prototype.getComponent=function(e,t,n){var o=this.getComponentHref(e,e.version);return this.getAsset(o,void 0,t,n)},u.prototype.getRenditionOfComponent=function(e,t,n,o,i){var r=this.getComponentRenditionHref(e,e.version,n);return this.getAsset(r,{accept:t},o,i)},u.prototype.getSyncGroups=function(e,t){var n=p(this._server,"assets");return this.getCollection(n,e,t)},u.prototype.getSyncGroup=function(e,t,n){var o=p(this._server,"assets",e);return this.getCollection(o,t,n)},u.prototype.getCompositeManifest=function(e,t,n){var o=e.href;return o&&(o=this._resolveUrl(o)),o?(o=p(o,"manifest"),this.getAssetAsType(o,"text",t,n)):n(new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+o))},u.prototype.headRequest=function(e,t){return this._service.invoke("HEAD",e,{},void 0,void 0,function(e,n){if(e)return t(e);t(e,n)})},u.prototype._checkForComponentAlreadyUploaded=function(e,t,n){if(!(l.canUseFileSystem&&e&&t&&t.filename))return n();l.getMD5Hash(t.filename,(t,o)=>{if(t)return n();this.headRequest(e,(e,t)=>{if(e)return n();const i=t&&t.statusCode,r=t&&t.headers["content-md5"];200!==i||r!==o?n():n(t,r)})})},u.prototype.remixComposite=function(e,t,n,o,i,r){var a={compositeId:o};i&&(a.creatorTool=i);var s={href:e};return t&&(s.authorization=t),this._invokeOperation("remix",s,{href:n},a,r)},u.prototype.createCompositeDirectory=function(e,t,n){var o=this,s=this._resolveUrl(e.href);if(!s)return n(new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+s));function l(e,t,n){var a={"Content-Type":"application/vnd.adobe.directory+json","X-Update":"content"};t&&(a[d]="*"),o._service.invoke("PUT",s,a,void 0,void 0,function(e,t){return e?n(r("Error Creating composite directory",e,t)):409===t.statusCode?((e=new i(i.ALREADY_EXISTS,e)).response=t,n(e)):void n(void 0,t)})}l(0,t,function(e,i){if(e)return n(e);var p=i.statusCode;if(200===p||201===p)n(void 0,i);else if(404===p){var d=c.parentDirectory(s);o._service.invoke("PUT",d,{},void 0,void 0,function(e,o){if(e)return n(r("Error creating composite directory",e,o));var i=o.statusCode;200===i||201===i||409===i?l(0,t,function(e,t){if(e)return n(e);var o=t.statusCode;200===o||201===o?n(void 0,t):n(r("Error creating composite directory",e,t))}):n(a("Unexpected response creating composite directory",e,o))})}else n(a("Unexpected response creating composite directory",e,i))})},u.prototype.deleteCompositeDirectory=function(e,t){var n=this,o=this._resolveUrl(e.href);if(!o)return t(new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+o));o+="?recursive=true&invocation_mode=sync,async";var s=this._service.invoke("DELETE",o,{"If-Match":"*"},void 0,void 0,function(e,o){if(e)return t(r("Error deleting composite directory",e,o));var i=o.statusCode;return 200===i||204===i||404===i?t(void 0,o):202===i?n._handle202Response(o,s,n.SYNC_ASYNC_DEFAULT_DELAY,t):void t(a("Unexpected response deleting composite directory",e,o))})},u.prototype.archiveCompositeDirectory=function(e,t){var n=this,o=this._makeRelativeUrl(e.href);if(!o)return t(new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+e.href));var s={"Content-Type":"application/vnd.adobe.directory+json",Link:"<"+o+">;rel=self"},c=this._resolveUrl("/archive/"+e.id)+"?invocation_mode=sync,async",l=this._service.invoke("PUT",c,s,void 0,void 0,function(e,o){if(e)return t(r("Error archiving composite directory",e,o));var i=o.statusCode;return 200===i||204===i||404===i?t(void 0,o):202===i?n._handle202Response(o,l,n.SYNC_ASYNC_DEFAULT_DELAY,t):void t(a("Unexpected response archiving composite directory",e,o))})},u.prototype.leaveSharedComposite=function(e,t){if(e.collaborationType!==s.COLLABORATION.SHARED_WITH_USER)throw new i(i.INVALID_STATE,"Composite's collaboration type must be sharedWithUser.");return this.deleteCompositeDirectory(e,t)},u.prototype.uploadComponent=function(e,t,n,o,r,a){if(!e._owner||!e._owner.compositeHref)throw new i(i.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,o,r,a)},u.prototype.uploadAssetForComponentId=function(e,t,n,o,s,c,l,p){const u=this._constructComponentHref(n,e);let h=u;s&&(h+="?intermediates=false");var _={};t&&(_["Content-Type"]=t);const f=(e,t)=>{e?delete _[d]:_[d]="*";var n=this._service.invoke("PUT",h,_,l,void 0,function(e,n){if(e)return t(r("Error uploading component",e,n));var o=n.statusCode;if(200===o||201===o||204===o){var s;try{s=JSON.parse(n.responseText||n.response)}catch(o){return(e=new i(i.INVALID_DATA,"Invalid JSON returned by server",o)).response=n,t(e,n,s)}t(void 0,n,s)}else 507===o?((e=new i(i.EXCEEDS_QUOTA,"Exceeds quota",e)).response=n,t(e)):((e=a("Unexpected response uploading component",e)).response=n,t(e))});return n.token=c,n};return f(o,(e,t,n)=>{if(e){if(!(t=e.response))return p(e);var i=t.statusCode;o||404!==i?!o||409!==i&&412!==i?p(e):this._checkForComponentAlreadyUploaded(u,l,(e,t)=>{e?p(null,e,{md5:t}):f(!1,p)}):f(!0,p)}else p(void 0,t,n)})},u.prototype.copyAssetToComponentId=function(e,t,n,o,s,c,l,p){var u=this._makeRelativeUrl(l);if(!u)return p(new i(i.WRONG_ENDPOINT,"Cannot copy asset: "+l));var h=this,_=this._constructComponentHref(n,e);_+="?invocation_mode=sync,async",s&&(_+="&intermediates=false");var f={};function m(e,t,n){e?delete f[d]:f[d]="*";var o=h._service.invoke("PUT",_,f,void 0,{responseType:"text"},function(e,i){if(e)return n(r("Error uploading component",e,i));var s=i.statusCode;200===s||201===s||204===s?n(void 0,i,t):202===s?h._handle202Response(i,o,h.SYNC_ASYNC_DEFAULT_DELAY,function(e,o){n(e,o,t)}):n(a("Unexpected response copying a component asset",e,i),i,t)});return o.token=c,o}t&&(f["Content-Type"]=t),f.Link="<"+u+">;rel=source";var E=function(e,t,n){var r;if(e){if(!(t=e.response))return p(e);var a=t.statusCode;n||404!==a&&409!==a&&412!==a?507===a?((e=new i(i.EXCEEDS_QUOTA,"Exceeds quota",e)).response=t,p(e)):p(e):m(!o,!0,E)}else{try{r=JSON.parse(t.responseText||t.response)}catch(n){return(e=new i(i.INVALID_DATA,"Invalid JSON returned by server",n)).response=t,p(e)}p(void 0,t,r)}};return m(o,!0,E)},u.prototype.updateManifest=function(e,t,n,o){var s=this.getBranchManifestHref(e),c={"Content-Type":"application/vnd.adobe.dcx-manifest+json"},l=e.manifestEtag;return n?c["If-Match"]="*":l&&(c["If-Match"]=l),this._service.invoke("PUT",s,c,t,void 0,function(e,t){if(e)return o(r("Error updating manifest",e,t));var s=t.statusCode;!t.headers.etag||200!==s&&201!==s&&204!==s?412===s||l&&!n&&409===s?((e=new i(i.UPDATE_CONFLICT,"Manifest has been changed")).response=t,o(e)):o(a("Unexpected response updating manifest",e,t)):o(void 0,t)})},u.prototype.getHrefForComposite=function(e,t){if(!e.type)throw new i(i.INVALID_STATE,"Composite needs a type");if(!e.id)throw new i(i.INVALID_STATE,"Composite needs an id");return e.href?e.href:this._resolveUrl(p("assets",t,e.id))},u.prototype.getHrefForCompositeWithId=function(e,t){return this._resolveUrl(p("assets",t,e))},u.prototype.getCompositeManifestHref=function(e){var t=this._resolveUrl(e.href);if(!t)throw new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+t);return p(t,"manifest")},u.prototype.getBranchManifestHref=function(e){var t=this._resolveUrl(e.compositeHref);if(!t)throw new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+t);return p(t,"manifest")},u.prototype.getComponentHref=function(e,t){var n,o=e._owner;if(!o||!o.compositeHref)throw new i(i.INVALID_STATE,"Component must be part of a branch of a bound composite.");return o._core&&(n=o._core._getSourceHrefOfComponent(e)),n||this._constructComponentHref(o.compositeHref,e.id,t)},u.prototype.getComponentRenditionHref=function(e,t,n){var o=e._owner;if(!o||!o.compositeHref)throw new i(i.INVALID_STATE,"Component must be part of a branch of a bound composite.");if(o._core&&o._core._getSourceHrefOfComponent(e))throw new i(i.INVALID_STATE,"Getting a rendition of a source href not implemented.");return this._constructComponentRenditionHref(o.compositeHref,e,t,n)},u.prototype._constructComponentHref=function(e,t,n){var o=p(this._resolveUrl(e),t);return o&&void 0!==n&&(o+=";version="+n),o},u.prototype._invokeOperation=function(e,t,n,o,s){var l=this,p=this._resolveUrl("/ops");p+="?invocation_mode=sync,async";var d={op:e,id:c.generateUuid(),target:n,source:t};o&&(d.value=o),c.log("[invoke operation]: "+JSON.stringify(d,void 0,2));var u=function(e,t){var n;if(e)return(t=e.response)?void(507===t.statusCode?((e=new i(i.EXCEEDS_QUOTA,"Exceeds quota",e)).response=t,s(e)):s(e)):s(e);try{n=JSON.parse(t.responseText||t.response)}catch(n){return(e=new i(i.INVALID_DATA,"Invalid JSON returned by server",n)).response=t,s(e)}if(n.error)return(e=new i(i.UNEXPECTED_RESPONSE,"Error in operation result: "+JSON.stringify(n.error,void 0,2))).response=t,s(e);s(void 0,t,n)},h=l._service.invoke("POST",p,{"Content-Type":"application/vnd.adobe.asset-operation+json"},JSON.stringify(d),{responseType:"text"},function(t,n){if(t)return u(r("Error invoking operation "+e,t,n));var o=n.statusCode;200===o||201===o||204===o?u(void 0,n):202===o?l._handle202Response(n,h,l.SYNC_ASYNC_DEFAULT_DELAY,function(e,t){u(e,t)}):u(a("Unexpected response for operation "+e,t,n),n)});return h},u.prototype._constructComponentRenditionHref=function(e,t,n,o){var i=p(this._constructComponentHref(e,t.id),":rendition");return i+=";size="+(o||"full"),void 0!==n&&(i+=";version="+n),i},e.exports=u},function(e,t,n){var o,i,r=n(21),a=n(40),s=n(27),c=n(3),l=n(48),p=n(41),d=n(6),u=n(15),h=p.FileContent,_=a.STATES;function f(e,t,n){return c.wrapError(c.UNEXPECTED_RESPONSE,e,t,n)}function m(e,t,n){this._session=e,this._callback=t,this._cleanup=n,this._componentsPending=0,this.bytesTransfered=0,this.bytesTotal=0,this.onProgress=d.noOp;var o=this;this._reportProgress=function(e){if(e>0){o.bytesTransfered+=e;var t=o.onProgress;t&&t(o.bytesTransfered,o.bytesTotal)}}}m.prototype._callCallback=function(e,t){var n=this._callback;n&&(this._callback=void 0,n(e,t))},m.prototype._xferComplete=function(e,t){var n=this._cleanup;n?(this._cleanup=void 0,n(e,t)):this._callCallback(e,t)},m.prototype.abort=function(e){this._aborted||(this._aborted=!0,this._session._service.abortAllWithToken(this)),e||(this._callback=void 0,e=new Error("Aborted")),this._xferComplete(e)};var E={};E.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)},E.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)},E.pullCompositeManifestOnly=function(e,t,n){return this._pullComposite(e,t,"none",n)},E.downloadComponents=function(e,t,n,o){var i=function e(t){return t._owner?e(t._owner):t}(t),r=new m(n,o);return r._referenceBranch=i,E._pullComponents(r,i,e||t.allComponents()),r},E.pushComposite=function(e,t,n,o){var i,r=e._localStorage;(i=new m(n,o,function(t,n){if(i._owner&&e.hasLocalStorage&&r.unregisterInMemoryBranchOrElement(i._owner),!e.hasLocalStorage){var o=i._journal;e._pushJournal=o.isEmpty?void 0:o}i._callCallback(t,n)}))._composite=e,i._overwriteExisting=t;var a=!e.isBound;if(i._compositeIsNew=a,e.hasLocalStorage)e._loadBranch(r.currentManifestPath(),!1,function(t,n){if(t)return i._xferComplete(t);i._owner=n,e._localStorage.registerInMemoryBranchOrElement(n),l.readJournal(r.pushJournalPath(),e,!0,function(t,n){if(t)return i._xferComplete(t);i._journal=n,E._pushComposite(e,i)})});else{if(!e.href)return i._xferComplete(new c(c.INVALID_STATE,"New composite has no href"));i._owner=e.current.copy(),i._journal=e._pushJournal||new l(e),E._pushComposite(e,i)}return i},E.remixComposite=function(e,t,n,o,i,r,a){var s=d.parseURI(n).path;if(!s||!o||s.split("/").pop()!==o)throw new c(c.INVALID_PARAMS,"Invalid combination of params targetHref ("+n+") and compositeId ("+o+")");var l=new m(r,a);return r.remixComposite(e,t,n,o,i,function(e){l._xferComplete(e,e?void 0:n)}).token=l,l},E.uploadNewComponent=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||d.generateUuid(),t,!0,n.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,n.id,n.href,a,s)},E.uploadComponent=function(e,t,n,i,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 o(e.id,e.type,!1,n.collaborationType===r.COLLABORATION.SHARED_WITH_USER,t,n.id,n.href,i,a)},E.copyAssetForNewComponent=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||d.generateUuid(),t,!0,n.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,n.id,n.href,a,s)},E.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)},E._pullComposite=function(e,t,n,o){if("string"!=typeof e.href)throw new c(c.INVALID_STATE,"Composite must have an href");var i;var r=function(o,r){if(o)return i._xferComplete(o);var a;r?(a=r.manifestEtag,i._referenceBranch=r):e.current&&(a=e.current.manifestEtag,i._referenceBranch=e.current);var l=t.getCompositeManifest(e,a,function(t,o,a){if(t)return t.response&&404===t.response.statusCode?i._xferComplete(new c(c.NO_COMPOSITE,"Composite missing or deleted",t.underlyingError||t)):i._xferComplete(t);if(null===o&&!r)return i._xferComplete(void 0,null);var l;if(null!==o)try{if((l=(new s).parse(o))._localStorage=e._localStorage,l.compositeHref=e.href,l._collaborationType=e.collaborationType,l._clientDataString=e.clientDataString,l.manifestEtag=a,l.compositeState===_.committedDelete||l.compositeState===_.pendingDelete)return void i._session.deleteCompositeDirectory(e,function(e){return e?i._xferComplete(new c(c.DELETED_COMPOSITE,"Error deleting composite directory",e)):i._xferComplete(new c(c.DELETED_COMPOSITE,"Composite is deleted"))});i._referenceBranch&&l.hasLocalStorage&&l._updateLocalDataFromBranch(i._referenceBranch)}catch(e){return i._xferComplete(new c(c.INVALID_JSON,"Corrupted manifest",e))}else l=r;var p,d,u=l.allComponents();for(p=0;p<u.length;++p)(d=u[p]).state===_.pendingDelete||d.state===_.committedDelete?l.removeComponent(d):d.state=_.unmodified;u=void 0,"all"===n?u=l.allComponents():"min"===n&&(d=l.getComponentWithAbsolutePath("/META-INF/metadata.xml"))&&(u=[d]),u?E._pullComponents(i,l,u):i._xferComplete(void 0,l)});l&&(l.token=i,l.progress=i._reportProgress)};return(i=new m(t,o,function(t,n){if(t){var o=t.pulledBranch;o?(o.compositeState=_.unmodified,o.hasLocalStorage?u.writeFileAtomically(e._localStorage.pulledManifestPath(),t.pulledBranch.localData,"utf8",function(){i._callCallback(t)}):i._callCallback(t)):i._callCallback(t)}else{if(null===n)return i._callCallback(void 0,null);if(n.compositeState=_.unmodified,n.readOnly=!0,n.hasLocalStorage){var r=e._localStorage.pulledManifestPath();u.writeFileAtomically(r,n.localData,"utf8",function(e){if(e)return i._callCallback(e);n.manifestPath=r,n._isDirty=!1,i._callCallback(void 0,n)})}else e._options.xhrBaseBranchSupport&&(e._pulledBranchData=n.localData),i._callCallback(void 0,n)}}))._composite=e,e.hasLocalStorage?e.loadPulledBranch(r):r(),i},E._pullComponents=function(e,t,n){if(!t.hasLocalStorage)throw new c(c.INVALID_PARAMS,"No local storage.");var o,i=e._session;function r(o,i){if(e._componentsPending-=1,o&&(e.failedComponents=e.failedComponents||[],e.failedComponents.push({component:i,error:o})),0===e._componentsPending&&!e._aborted){var r=e.failedComponents;if(r){o=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){o=new c(l.code,l.message);break}}o.pulledBranch=t,o.failedComponents=r}t.readOnly&&t.manifestPath&&(!r||n.length>r.length)?u.writeFileAtomically(t.manifestPath,t.localData,"utf8",function(n){o=o||n,e._xferComplete(o,o?void 0:t)}):e._xferComplete(o,o?void 0:t)}}function a(t){if(!e._aborted){e.bytesTotal+=t.length||0;var n=t._owner._localStorage.tempPathForComponent(t),o=d.parentDirectory(n);u.ensureDirectoryExists(o,function(o){if(o)return e.abort(o);var a=E._pullComponent(t,n,i,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,o=0;o<n.length;++o){var l,p=n[o];if(e._referenceBranch){var h=e._referenceBranch.getComponentWithId(p.id);h&&(l=h.etag)}p.etag!==l?a(p):s(p)}0===e._componentsPending&&e._xferComplete(void 0,t)},E._pullComponent=function(e,t,n,o){var i=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.");return n.getComponent(e,new h(t),function(n,r){if(n)o(n,e);else if(200===r.statusCode){var a=Number(r.headers["content-length"]);e.length&&!isNaN(a)&&a!==e.length?o(new c(c.UNEXPECTED_RESPONSE,"Incorrect content length",n,r)):i._localStorage.ingestComponentAsset(e,t,!1,i._local(),function(t){o(t,e,r.headers.etag)})}else 304===r.statusCode?o(void 0,e,r.headers.etag):o(f("Unexpected response getting a component",n,r),e)})},E._pushComposite=function(e,t){if(!e.href)return t._xferComplete(new c(c.INVALID_STATE,"New composite has no href"));var n=t._owner,o=t._journal,i=t._compositeIsNew,a=t._overwriteExisting,s=t._session,l=n.changeCount,p=n.remoteData.length+50;if(t.bytesTotal=p,n.compositeState===_.committedDelete)return t._xferComplete(new c(c.DELETED_COMPOSITE,"Attempt to push a deleted composite"));if("archived"===n.compositeArchivalState)return t._xferComplete(new c(c.DELETED_COMPOSITE,"Attempt to push an archived composite"));var d="pending"===n.compositeArchivalState;if(d&&e.collaborationType===r.COLLABORATION.SHARED_WITH_USER)return t._xferComplete(new c(c.INVALID_STATE,"Attempt to archive composite that is shared with this user."));if(!i&&!d&&n.compositeState===_.unmodified)return t._xferComplete();if(n.compositeState===_.pendingDelete)return i&&!a?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.")):E._deleteComposite(t,a,function(e,n){t._xferComplete(e,n)});function h(n,o){d?s.archiveCompositeDirectory(e,function(i){if(i)return o(i);n.compositeArchivalState="archived",t._journal.compositeHasBeenArchived=!0,t._journal.commitChanges(function(t){if(t)return o(t);e.hasLocalStorage?u.writeFileAtomically(e._localStorage.pushedManifestPath(),n.localData,"utf8",function(e){if(e)return o(e);o(void 0,n)}):o(void 0,n)})}):o(void 0,n)}function m(n){if(i)return t._xferComplete(n);var o=s.getCompositeManifestHref(e);s.headRequest(o,function(e,o){return e?t._xferComplete(e):404===o.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,o,i){function r(e){e||(t.compositeHasBeenCreated=!0);var n,o=t._compositeCreationCallbacks,i=o.length;for(n=0;n<i;n++)try{o[n](e)}catch(e){}t._compositeCreationCallbacks=void 0}e.isBound||t.compositeHasBeenCreated?i():t._compositeCreationCallbacks?t._compositeCreationCallbacks.push(i):(t._compositeCreationCallbacks=[i],o.createCompositeDirectory(e,n,function(t,i){if(t){if(t.code!==c.ALREADY_EXISTS)return r(f("Unexpected response creating a composite directory",t,i));if(n)r();else{var a=o.getCompositeManifestHref(e);o.headRequest(a,function(e,t){return e?r(e):404!==t.statusCode?r(e=new c(c.INVALID_STATE,"Composite already exists and overwriteExisting not specified")):void r()})}}else r()}))}(e,o,a,s,function(i){if(i)return t._xferComplete(i);E._pushComponents(t,n,function(){var r=t.failedComponents;if(r){i=new c(c.COMPONENT_UPLOAD_ERROR,"One or more components failed to upload.");var d,f=r.length;for(d=0;d<f;d++){var E=r[d].error;if(E.code===c.EXCEEDS_QUOTA){i=new c(E.code,E.message);break}}return i.failedComponents=r,m(i)}if(n.compositeState===_.modified){n.compositeState=_.unmodified,o.manifestEtag&&o.currentBranchEtag===n.manifestEtag&&(n.manifestEtag=o.manifestEtag);var g=n.remoteData;t.bytesTotal+=g.length,t.bytesTotal-=p;var y=s.updateManifest(n,g,a,function(i,r){if(i)return m(i);var a=r.headers.etag;o.manifestEtag=a,o.currentBranchEtag=n.manifestEtag,o.changeCount=l,o.commitChanges(function(i){if(i)return t._xferComplete(i);o.applyToBranch(n),n.compositeState=_.unmodified,e.hasLocalStorage?u.writeFileAtomically(e._localStorage.pushedManifestPath(),n.localData,"utf8",function(e){if(e)return t._xferComplete(e);n._isDirty=!1,h(n,function(e,n){t._xferComplete(e,n)})}):(e._options.xhrBaseBranchSupport&&(e._pushedBranchData=n.localData),h(n,function(e,n){t._xferComplete(e,n)}))})});y&&(y.progress=t._reportProgress,y.token=t)}else h(n,function(e,n){t._xferComplete(e,n)})})})},E._deleteComposite=function(e,t,n){var o=e._composite,i=e._owner,r=e._session;i.compositeState=_.committedDelete;var a=i.remoteData;e.bytesTotal=a.length,e._journal.manifestEtag&&e._journal.currentBranchEtag===i.manifestEtag&&(i.manifestEtag=e._journal.manifestEtag),r.updateManifest(i,a,t,function(t){if(t)return n(t);r.deleteCompositeDirectory(o,function(t){if(t)return n(t);e._journal.compositeHasBeenDeleted=!0,e._journal.commitChanges(function(e){if(e)return n(e);o.hasLocalStorage?u.writeFileAtomically(o._localStorage.pushedManifestPath(),i.localData,"utf8",function(e){if(e)return n(e);n(void 0,i)}):n(void 0,i)})})})},E._pushComponents=function(e,t,n){var o,i=t.allComponents(),a=e._composite,s=a._localStorage,l={},p=e._journal;function f(t,o,i){o?l[t.id]=o:delete l[t.id],i&&(e.failedComponents=e.failedComponents||[],e.failedComponents.push({component:t,error:i})),0===Object.keys(l).length&&p.commitChanges(n)}function m(t,n,o){f(t,"uploading"),u.info(n,function(i,s){if(i)return i=new c(c.INVALID_STATE,"Component asset missing",i),void f(t,null,i);var l=s.size,u=d.filePathComponents(n).fileName,m=p.getRecordForUploadedComponent(t.id);if(m&&m.length===l&&m["storage-name"]===u)return t.etag=m.etag,t.version=m.version,t.md5=m.md5,t.length=m.length,t.state=_.unmodified,void f(t,null);e.bytesTotal+=l;var E=e._session.uploadComponent(t,o,a.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,new h(n),function(e,n,o){if(!e){var i=n.headers.etag,r=n.headers["x-latest-version"],a=o.md5;i||(e=new c(c.UNEXPECTED_RESPONSE,"No etag")),r||(e=new c(c.UNEXPECTED_RESPONSE,"No version")),a||(e=new c(c.UNEXPECTED_RESPONSE,"No md5")),e||(t.etag=i,t.version=r,t.md5=a,t.length=l,t.state=_.unmodified,p.recordUploadedComponent(t.id,i,r,a,l,u),p.commitChanges())}f(t,null,e)});E&&(E.progress=e._reportProgress,E.token=e)})}function E(n,o,i){var l=p.getRecordForUploadedComponent(n.id);if(l&&l["source-href"]===o)return n.etag=l.etag,n.version=l.version,n.md5=l.md5,n.length=l.length,void(n.state=_.unmodified);f(n,"copying");var d=e._session.copyAssetToComponentId(n.id,n.type,e._composite.href,i,a.collaborationType===r.COLLABORATION.SHARED_WITH_USER,e,o,function(e,r,a){if(e){if(s){var l=s.componentAssetPath(n,t._local());if("string"==typeof l)return m(n,l,i)}}else{var d=r.headers.etag,u=r.headers["x-latest-version"],h=a.md5,E=a.size;d||(e=new c(c.UNEXPECTED_RESPONSE,"No etag")),u||(e=new c(c.UNEXPECTED_RESPONSE,"No version")),h||(e=new c(c.UNEXPECTED_RESPONSE,"No md5")),E||(e=new c(c.UNEXPECTED_RESPONSE,"No length")),e||(n.etag=d,n.version=u,n.md5=h,n.length=E,n.state=_.unmodified,p.recordUploadedComponent(n.id,d,u,h,E,void 0,o),p.commitChanges())}f(n,null,e)});d&&(d.progress=e._reportProgress,d.token=e)}for(o=0;o<i.length;++o){var g=i[o],y=g.state,v=!g.etag;if(y||(y=_.unmodified),v||y===_.modified){var A=t._core._getSourceHrefOfComponent(g);if(t.hasLocalStorage||A){var C=v||e._compositeIsNew;if(A)E(g,A,C);else{var I=s.componentAssetPath(g,t._local());"string"==typeof I&&m(g,I,C)}}else{var S=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:S})}}else y===_.unmodified?p.removeRecordForUploadedComponent(g.id):y!==_.committedDelete&&y!==_.pendingDelete||t.removeComponent(g)}0===Object.keys(l).length&&n()},o=function(e,t,n,o,i,r,s,l,p){if("function"!=typeof p)throw new c(c.INVALID_PARAMS,'Param "callback" must be a function.');var d=i.length||i.byteLength||i.size,u=new m(l,p);u.bytesTotal=d;var h=l.uploadAssetForComponentId(e,t,s,n,o,u,i,function(n,o,i){var s;if(!n)try{s=new a._UploadResults(r),d=d||h.bytesSent,s.records[e]=function(e,t,n,o,i){if("number"!=typeof t)throw new c(c.UNEXPECTED_RESPONSE,"No length");var r=o.headers.etag,s=o.headers["x-latest-version"],l=i.md5;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,t,n)}(e,d,t,o,i)}catch(e){n=e,s=void 0}u._xferComplete(n,s)});return h&&(h.progress=u._reportProgress,h.token=u),u},i=function(e,t,n,o,i,r,s,l,p){if("function"!=typeof p)throw new c(c.INVALID_PARAMS,'Param "callback" must be a function.');var d=new m(l,p),u=l.copyAssetToComponentId(e,t,s,n,o,d,i,function(n,o,i){if(!d._aborted){var s;if(!n)try{(s=new a._UploadResults(r)).records[e]=function(e,t,n,o){var i=o.headers.etag,r=o.headers["x-latest-version"],s=t.md5,l=t.size;if("number"!=typeof l)throw new c(c.UNEXPECTED_RESPONSE,"No length");if(!i)throw new c(c.UNEXPECTED_RESPONSE,"No etag");if(!r)throw new c(c.UNEXPECTED_RESPONSE,"No version");if(!s)throw new c(c.UNEXPECTED_RESPONSE,"No md5");return new a._UploadRecord(e,i,r,s,l,n)}(e,i,t,o)}catch(e){n=e,s=void 0}p(n,s)}});return u&&(u.progress=d._reportProgress,u.token=d),d},e.exports=E},function(e,t,n){var o=n(21),i=n(27),r=n(3),a=n(6),s=n(15);let c,l;c=n(54),l=n(55);var p={isSnapshot:function(e,t){var n,o=!1,i=function(e,i){o||(o=!0,n&&n.isOpen&&n.close(),t(e,i))};l.open(e,{lazyEntries:!0},function(e,t){e?-1!==["EPERM","EACCES","ENOENT"].indexOf(e.code)?i(e):i(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)i(e);else{var n=[];t.on("data",function(e){n.push(e)}),t.on("error",function(e){i(e)}),t.on("end",function(){var e=Buffer.concat(n).toString();e&&h(e,"dcxucf")?i(null,!0):i(null,!1)})}}):i(null,!1)}).on("error",function(e){i(e)}),n.readEntry())})},importSnapshot:function(e,t,n,i,r,a){return this.importSnapshotToDirectory(e,t,n,i,r,function(e,t){if(e)a(e);else try{var n=new o(null,null,t,null,null,null);n.loadCurrentFromLocalStorage(function(e){a(e,e?void 0:n)}),n.deleteTempFiles()}catch(e){a(e)}})}};p.importSnapshotToDirectory=function(e,t,n,o,c,p){var d,u,_,m,E=!1,g=0,y=0,v=0,A=!1,C=function(e,t){if(!A){if(A=!0,d&&d.isOpen&&d.close(),e)return t&&s.deleteDirectory(t),void p(e);p(e,t)}},I={},S={};return s.ensureDirectoryExists(t,function(p){p?C(p):l.open(e,{lazyEntries:!0},function(e,l){e?-1!==["EPERM","EACCES","ENOENT"].indexOf(e.code)?C(e):C(new r(r.INVALID_DATA,"Error while opening snapshot: "+e)):((d=l).on("entry",function(e){if(g++,y=0,v=0,f(e,o))if(1===g)"mimetype"===e.fileName?d.openReadStream(e,function(e,t){if(e)C(e);else{var n=[];t.on("data",function(e){n.push(e)}),t.on("error",function(e){C(e)}),t.on("end",function(){var e=Buffer.concat(n).toString();e&&h(e,"dcxucf")||C(new r(r.INVALID_DATA,"Bad mimetype")),d.readEntry()})}}):C(new r(r.INVALID_DATA,"Missing mimetype file"));else if(2===g)"manifest"===e.fileName?d.openReadStream(e,function(e,t){if(e)C(e);else{var n=[];t.on("data",function(e){n.push(e)}),t.on("error",function(e){C(e)}),t.on("end",function(){var e=Buffer.concat(n).toString();if(e){if(u=JSON.parse(e),(_=new i(u))._resetIdentity(),o){var t=_.getComponentWithAbsolutePath("/META-INF/metadata.xml");t&&_.removeComponent(t)}m=u.id,d.readEntry()}else C(new r(r.INVALID_DATA,"Unable to parse manifest on import"))})}}):C(new r(r.INVALID_DATA,"Missing manifest file"));else if(m){y=e.uncompressedSize;var n=t+"/"+m+"/components";s.ensureDirectoryExists(n,function(t){t?C(t):d.openReadStream(e,function(t,o){if(t)C(t);else{var i=a.generateUuid(),r=e.fileName.split("/"),l=r[r.length-1].split(".");l&&(i=i+"."+l[l.length-1]),I["/"+e.fileName]=i,o.on("end",function(){d.readEntry()}),o.on("data",function(e){v+=e.length,function(){if(!E){var e=(g-1)/d.entryCount;y&&(e+=v/(y*d.entryCount)),c(Math.round(100*e))}}()}).on("error",function(e){C(e)}).pipe(s.createWriteStream(n+"/"+i))}})})}else C(new r(r.INVALID_DATA,"Missing manifest id"));else d.readEntry()}).on("error",function(e){C(e)}).on("close",function(){A||(E?C(new r(r.UNEXPECTED,"Import cancelled")):(Object.keys(I).forEach(function(e){var t=_.getComponentWithAbsolutePath(e);t&&(S[t.id]=I[e])}),u.local||(u.local={}),u.local["copyOnWrite#storageIds"]=S,n&&(u.local.compositeHref=n.endsWith("/")?n+u.id:n+"/"+u.id),m?s.ensureDirectoryExists(t+"/"+m,function(e){e?C(e):s.writeFile(t+"/"+m+"/manifest",JSON.stringify(u,void 0,2),function(e){e?C(e):C(null,t+"/"+m)})}):C(new r(r.INVALID_DATA,"Missing manifest id"))))}),d.readEntry())})}),function(){E||(E=!0,d&&d.close())}},p.exportSnapshot=function(e,t,n,o,i){var l,p,u=!1,_={},f=function(e){if(!u){if(u=!0,Object.keys(_).forEach(function(e){_[e].close()}),e)return void s.deleteFile(p,()=>i(e));s.move(p,t,!1,e=>i(e||null))}};try{p=t.replace(/([^\\/]+)$/,"."+a.generateUuid()+"_$1"),l=s.createWriteStream(p)}catch(e){return void f(e)}var m,E=new c.ZipFile;e.type&&h(e.type,"dcx")?(m=e.type+"ucf",E.addBuffer(new Buffer(m),"mimetype",{compress:!1})):f(new r(r.INVALID_PARAMS,"Invalid composite type"));var y=d(e.current,n),v=y.lengths.total||1,A=new Buffer(JSON.stringify(y.manifest,void 0,2));E.addBuffer(A,"manifest",{compress:!0});var C=y.componentMap,I=!1,S=0,L=0,O=function(){I||o(Math.round(Math.min(50,100*L/v)+Math.round(50*S/v)))};return y.components.map(function(t){return{id:t.id,path:C&&C[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}).forEach(function(t){var n=s.createReadStream(e.path+"/components/"+t.path);_[t.path]=n,n.on("end",function(){delete _[t.path],S+=y.lengths[t.id],O()}),n.on("error",()=>{f(new r(r.INVALID_DATA,"Missing component file locally."))}),g(t.type)?E.addReadStream(n,t.absolutePath,{compress:!0}):E.addReadStream(n,t.absolutePath,{compress:!1})}),E.end(),E.outputStream.on("error",function(e){f(I?new r(r.UNEXPECTED,"Export cancelled"):e)}).on("data",function(e){L+=e.length,O()}).pipe(l).on("close",function(){f(I?new r(r.UNEXPECTED,"Export cancelled"):null)}).on("error",function(e){f(e)}),function(){I||(I=!0,E.outputStream.end())}};var d=function(e,t){var n=JSON.parse(e.localData);if(t){var o=[];n.children.forEach(function(e){t.includes(e.name)||o.push(e)}),n.children=o}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,o,i){return i=i||[],n=n||{},o=o||{total:0},e.components&&e.components.forEach(function(e){n[e.id]=t[e.id];var r=e.length||1e3;o[e.id]=r,o.total+=r,e.state="unmodified",delete e.version,delete e.md5,delete e.etag,i.push(e)}),e.children&&e.children.forEach(function(e){u(e,t,n,o,i)}),{lengths:o,componentMap:n,components:i}},h=function(e,t){var n=e.split("/");if(2===n.length){var o=n[1];if(o.length<t.length+2)return!1;if(o.substring(o.length-t.length)!==t)return!1;var i=o.length-(t.length+1);return"+"===o.charAt(i)}return!1},_=/^[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,f=function(e,t){if("mimetype"===e.fileName||"manifest"===e.fileName)return!0;var n=e.fileName.split("/");if(n){var o=n[n.length-1];return!t&&"metadata.xml"===o||o.match(_)}return!1},m=["text/"],E=["+json","+xml"],g=function(e){return m.forEach(function(t){if(e.startsWith(t))return!0}),E.forEach(function(t){if(e.endsWith(t))return!0}),!1};e.exports=p},function(e,t){e.exports=require("yazl")},function(e,t){e.exports=require("yauzl")},function(e,t,n){var o=n(3),i=n(69),r=n(94),a=n(1),s=n(18),c=n(2),l=n(0),p=n(22),d=n(10),u=n(23),h=n(13),_=n(16),f=n(12),m=n(9),E=n(7),g=n(28),y=n(5);function v(e,t){(this._collection=e,this._dcxComposite=t,this._dcxBranch=t.current,this._listenerManager=new y(["change"]),this._writable=!0,this._filterCache={},this._autoGCMode={},this._transactionCount=0,this._commitInProgress=!1,this._pendingCommit=!1,this._onCommitCallbacks=[],this._dcxLock=new u,this._renditionCacheLock=new u,this._pendingRenditionCacheItems={},this._networkLock=new u,this._syncState=void 0,this._deletedLocally=!1,this._deletedFromServer=!1,this._waitForSyncToFinishCallbacks=[],this._errors=[],this._pushFailedDueToQuota=!1,this._numUpdateConflicts=0,this._numActiveCopyNodeOperations=0,this._pendingCopyNodeOperations=[],this._dcxBranch.getChildrenOf().forEach(function(e){e.name===a.ELEMENTS_NAME&&(this._dcxElementsNode=e),e.name===a.REMOVED_ELEMENTS_NAME&&(this._dcxRemovedElementsNode=e),e.name===a.GROUPS_NAME&&(this._dcxGroupsNode=e)},this),this._dcxElementsNode||(this._dcxElementsNode=this._dcxBranch.addChild(a.ELEMENTS_NAME)),this._dcxCompositeRenditionMap=_.getCompositeRenditionMap(this._dcxBranch),this._elements=[],this._removedElements=[],this._groups=[],this._dcxBranch.getChildrenOf(this._dcxElementsNode).forEach(function(e){var t=new r(this,e);this._addElementToFilter(t),this._elements.push(t)},this),this._dcxRemovedElementsNode)&&(this._dcxBranch.getChildrenOf(this._dcxRemovedElementsNode).forEach(function(e){var t=new r(this,e);this._removedElements.push(t)},this),this._sortRemovedElements());this._dcxGroupsNode&&this._dcxBranch.getChildrenOf(this._dcxGroupsNode).forEach(function(e){var t=new i(this,e);this._groups.push(t)},this);l.hasFileSystem()||(this._dcxBaseBranch=this._dcxBranch.copy())}v.prototype._getRemovedElementsNode=function(){return this._dcxRemovedElementsNode||(this._dcxRemovedElementsNode=this._dcxBranch.addChild(a.REMOVED_ELEMENTS_NAME)),this._dcxRemovedElementsNode},v.prototype._getGroupsNode=function(){return this._dcxGroupsNode||(this._dcxGroupsNode=this._dcxBranch.addChild(a.GROUPS_NAME)),this._dcxGroupsNode},v.prototype._markDeletedLocally=function(e){this._deletedLocally=e,this._elements.forEach(function(t){t._markDeletedLocally(e)}),this._groups.forEach(function(t){t._markDeletedLocally(e)}),e&&this._listenerManager.removeAll()},v.prototype._removeAllListeners=function(){this._listenerManager.removeAll(),this._elements.forEach(function(e){e._removeAllListeners()})},v.prototype._toJSON=function(){var e={id:this.id,name:this.name,elements:[],renditionCache:{},groups:[]};return this._elements.forEach(function(t){e.elements.push(t._toJSON()),e.renditionCache[t.id]=JSON.parse(JSON.stringify(t._renditionCache))}),this._groups.forEach(function(t){e.groups.push(t._toJSON())}),e},v.prototype._getRenditionCache=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},v.prototype._setRenditionCache=function(e){var t=function(t){e[t.id]&&(t._renditionCache=e[t.id])};this._elements.forEach(t),this._removedElements.forEach(t)},v.prototype._loadRenditionCache=function(e){var t=this;h.readRenditionCacheData(this,function(n,o){!n&&o&&t._setRenditionCache(o.renditions),e(null)})},v.prototype._saveRenditionCache=function(e){var t=this;if(l.hasFileSystem()&&!a.SHARED_LOCAL_STORAGE){var n=function(n){t._renditionCacheLock.release(),e&&e(n)};this._renditionCacheLock.obtain(function(){var e={};e.renditions=this._getRenditionCache(),h.writeRenditionCacheData(this,e,n)},this)}else e&&e(null)},v.prototype._doCommit=function(e){var t=this;function n(n){var o=t._onCommitCallbacks;t._onCommitCallbacks=[],o.forEach(function(e){e.waitForSuccess&&!n?t._onCommitCallbacks.push(e):t._waitForCommit(e.callback)}),function(){if(e&&!a.SHARED_LOCAL_STORAGE){if(t._deletedLocally)return;t._collection._clearSyncErrors(),t._push(),t._collection._resetPollBackoff()}}()}function o(e,n){e&&(e=f.getCommitError(e,t.id,n)),t._collection._reportCommitError(e)}l.hasFileSystem()?this._commitInProgress?this._pendingCommit=!0:(this._commitInProgress=!0,l.storageInterface.commitManifest(this,function(i,r){o(i,"Failed to write composite to disk"),t._saveRenditionCache(function(i){o(i,"Failed to write rendition cache to disk"),t._commitInProgress=!1,t._pendingCommit?(t._pendingCommit=!1,0===t._transactionCount&&t._doCommit(e)):n(r)})})):n()},v.prototype._waitForCommit=function(e,t){this._commitInProgress||this._transactionCount>0?this._onCommitCallbacks.push({callback:e,waitForSuccess:t}):e()},v.prototype._notifyChange=function(){this._listenerManager.notify("change"),this._collection._notifyChange()},v.prototype._commit=function(e,t){0===this._transactionCount&&(t||(this._updateModifiedTime(),this._notifyChange()),this._doCommit(!e))},v.prototype._wrapOperation=function(e,t){var n;this._beginOperation();try{n=e.call(t)}catch(e){throw this._transactionCount--,e}return this._endOperation(),n},v.prototype._beginOperation=function(){this._transactionCount++},v.prototype._endOperation=function(){this._transactionCount--,this._commit()},v.prototype._updateModifiedTime=function(){var e=(new Date).valueOf();this._dcxBranch.rootNode.setValue(a.MODIFIED_KEY,e)},v.prototype._updateCreatedTime=function(){var e=(new Date).valueOf();this._dcxBranch.rootNode.setValue(a.CREATED_KEY,e),this._dcxBranch.rootNode.setValue(a.MODIFIED_KEY,e)},v.prototype._getMissingLocalComponents=function(){var e=[];return this._elements.forEach(function(t){e=e.concat(t._getMissingLocalComponents())}),e},v.prototype._gcLocalData=function(e){var t=[],n={},o=[];if(this._removedElements.forEach(function(e){e._shouldGCLocalData()&&(t.push(e),e.representations.forEach(function(e){var t=e._dcxComponent,i=e._getCurrentComponentPath();t&&i&&t.etag&&"modified"!==t.state?(n[i]=n[i]||[],n[i].push(t.id)):i&&o.push(i)}))}),0!==t.length){o.forEach(function(e){delete n[e]}),this._elements.forEach(function(e){e.representations.forEach(function(e){var t=e._getCurrentComponentPath();t&&delete n[t]})});var i=[];Object.keys(n).forEach(function(e){i.push.apply(i,n[e])}),t.forEach(function(e){e._renditionCache={}}),l.log("Removing local files for components: [ "+i.join(", ")+" ]"),this._dcxComposite.removeLocalFilesForComponentsWithIDs(i,e)}else e(null)},v.prototype._checkRenditionType=function(e,t){if(!e||-1===a.VALID_LIBRARY_RENDITION_TYPES.indexOf(e)){if(t)return t(new c(c.INVALID_PARAMETER,"composite rendition type not supported: "+e)),!1;throw new c(c.INVALID_PARAMETER,"composite rendition type not supported: "+e)}return!0},v.prototype._setRenditionFromPath=function(e,t,n,o){if(!_.checkDeletedState(this,o)){var i=this._dcxCompositeRenditionMap[e],r=this,s=t&&l.getFileNameFromPath(t),c=m.getFileExtension(s),p=l.uuid()+"."+c;m.checkFileSize(t,function(c){c?o(c):l.storageInterface.notifyStartWrite(r,[],function(){r._dcxBranch.addComponent(s,n,"rendition",p,t,!0,void 0,r._dcxBranch.rootNode,void 0,function(t,n){t?o(t):_.checkDeletedState(r,o)||(n.setValue(a.MODIFIED_KEY,(new Date).valueOf()),n.setValue(a.RENDITION_TYPE_KEY,e),i&&r._dcxBranch.removeComponent(i),r._dcxCompositeRenditionMap=_.getCompositeRenditionMap(r._dcxBranch),r._commit(),o(null))})})})}},v.prototype._setRendition=function(e,t,n,o,i){var r,a=l.fs,s=this;function c(t){t?i(f.getCommitError(t,s.id,"error writing library rendition")):_.checkDeletedState(s,i)||s._setRenditionFromPath(e,r,o,i)}var p=this.collection._getTempDir();m.ensurePathExists(p,function(e){if(e)i(f.getCommitError(e,s.id,"error creating temp directory"));else if(!_.checkDeletedState(s,i)){var d=g.getExtensions(o)[0],u=l.uuid()+"."+d;r=p+l.getPathSeparator()+u,"buffer"===n?a.writeFile(r,t,c):a.writeFile(r,t,n,c)}})},v.prototype._setRenditionInBrowser=function(e,t,n,o){var i=this,r=this._dcxCompositeRenditionMap[e],s=this._collection._syncManager,c=l.uuid();s.uploadNewComponentForLibrary(t,c,n,"rendition",this,function(t,n){t?o(t):_.checkDeletedState(i,o)||(n.setValue(a.MODIFIED_KEY,(new Date).valueOf()),n.setValue(a.RENDITION_TYPE_KEY,e),r&&i._dcxBranch.removeComponent(r),i._dcxCompositeRenditionMap=_.getCompositeRenditionMap(i._dcxBranch),i._commit(),o(null))})},v.prototype._getFilterKey=function(e){return e&&-1!==a.ELEMENT_TYPE_FILTERS.indexOf(e)?e:"*"},v.prototype._removeElementFromFilter=function(e){var t=this._getFilterKey(e.type);if(this._filterCache[t]){var n=this._filterCache[t].indexOf(e);-1!==n&&this._filterCache[t].splice(n,1)}},v.prototype._addElementToFilter=function(e){var t=this._getFilterKey(e.type);this._filterCache[t]=this._filterCache[t]||[],this._filterCache[t].push(e)},v.prototype._doCreateGroup=function(e,t,n){var o=this._getGroupsNode(),r=this._dcxBranch.addChild(e,void 0,void 0,o);r.type=a.GROUP_TYPE,r.setValue(a.CLASSIFIER_KEY,n),r.setValue(a.ORDER_KEY,t);var s=new i(this,r);return s._updateCreatedTime(),this._groups.push(s),s},v.prototype._doRemoveGroup=function(e,t){var n=this._groups.indexOf(e);this._groups.splice(n,1),this.elements.slice().forEach(function(n){void 0!==n.getOrderInGroup(e)&&(n._doSetOrderInGroup(e,void 0,!0),t&&this.removeElement(n))},this),this._dcxBranch.removeChild(e._dcxNode),e._markDeletedLocally(!0)},v.prototype._getNumberOfElementsInGroup=function(e){if(e){var t=0;return this.elements.forEach(function(n){void 0!==n.getOrderInGroup(e)&&t++}),t}},v.prototype._doCopyGroup=function(e,t,n,o,i){var r=e.library!==t&&t._groups.every(function(t){return t.id!==e.id})?e.id:l.uuid();this._doCopyDCXGroup(e,t,n,o,r,i)},v.prototype._doCopyDCXGroup=function(e,t,n,o,r,a){var c=this;t._beginOperation(),o&&c._beginOperation();var p=function(e){t._endOperation(),o&&c.endOperation(),a(e)};l.storageInterface.notifyStartWrite(t,[this],function(){var l=t._getGroupsNode();t._dcxBranch.copyChild(e._dcxNode,l,void 0,r,r,function(r,l){if(!_.checkDeletedState(c,a))if(r)p(r);else{var u=new i(t,l);t._groups.push(u);var h=function(){_.checkDeletedState(c,a)||(t._endOperation(),o&&(c._doRemoveGroup(e,!1),c.endOperation()),a(null,u))};if(n){var f=c.elements.filter(function(t){return void 0!==t.getOrderInGroup(e)}),m=new d;f.forEach(function(e){m.addOperation(c._doCopyElement,[e,t,o],c)}),m.run(function(t,n,o){if(t)p(t);else try{f.forEach(function(t,n){var i=t.getOrderInGroup(e),r=o[n];r._doSetOrderInGroup(u,i,!0),s.reportCopyElement(r,t)}),h()}catch(e){p(e)}})}else h()}})})},v.prototype._doCreateElement=function(e,t){var n=this._dcxBranch.addChild(e,void 0,void 0,this._dcxElementsNode);n.path=n.id,n.type=t;var o=new r(this,n);return o._updateCreatedTime(),this._elements.push(o),this._addElementToFilter(o),o},v.prototype._doRemoveElement=function(e,t){var n=this._elements.indexOf(e);-1!==n&&this._elements.splice(n,1),-1!==(n=this._removedElements.indexOf(e))&&this._removedElements.splice(n,1),this._removeElementFromFilter(e),t&&this._dcxBranch.removeChild(e._dcxNode),e._markDeletedLocally(!0)},v.prototype._ensureRemovedElementsSpace=function(){for(;this.removedElements.length>=a.MAX_REMOVED_ELEMENTS;)this._doRemoveElement(this.removedElements[0],!0)},v.prototype._sortRemovedElements=function(){this._removedElements.sort(function(e,t){return e.removed-t.removed})},v.prototype._doMarkElementRemoved=function(e,t){var n=this._elements.indexOf(e);-1!==n&&(this._ensureRemovedElementsSpace(),this._elements.splice(n,1),this._removeElementFromFilter(e),this._removedElements.push(e),this._sortRemovedElements(),t&&(e._dcxNode=this._dcxBranch.moveChild(e._dcxNode,void 0,this._getRemovedElementsNode()),e._updateTimestampOnRemove()))},v.prototype._doRestoreElement=function(e,t){var n=this._removedElements.indexOf(e);-1!==n&&(this._removedElements.splice(n,1),this._elements.push(e),this._addElementToFilter(e),t&&(e._dcxNode=this._dcxBranch.moveChild(e._dcxNode,void 0,this._dcxElementsNode),e._updateTimestampOnRestore(),e._stripObsoleteGroupsData()))},v.prototype._doCopyDCXNode=function(e,t,n,o,i){var r=this;if(this._numActiveCopyNodeOperations<a.MAX_DCX_CONCURRENT_COPIES)return this._numActiveCopyNodeOperations++,void e.copyChild(t,n,void 0,o,o,function(e,t){r._numActiveCopyNodeOperations--,i(e,t),r._pendingCopyNodeOperations.length>0&&r._pendingCopyNodeOperations.shift()()});this._pendingCopyNodeOperations.push(function(){r._doCopyDCXNode(e,t,n,o,i)})},v.prototype._doCopyDCXElement=function(e,t,n,o,i){var a=this;t._beginOperation(),l.storageInterface.notifyStartWrite(t,[this],function(){a._doCopyDCXNode(t._dcxBranch,e._dcxNode,t._dcxElementsNode,o,function(o,s){if(!_.checkDeletedState(a,i)){if(o)return t._endOperation(),void i(o);var c=new r(t,s);t._addElementToFilter(c),t._elements.push(c),c._stripObsoleteGroupsData();var p=function(){_.checkDeletedState(a,i)||(t._endOperation(),n&&a._wrapOperation(function(){a._doRemoveElement(e,!0)}),i(null,c))};l.hasFileSystem()?h.copyRenditionCache(c,e,e._renditionCache,p):p()}})})},v.prototype._doCopyElement=function(e,t,n,o){if(t._elements.length>=a.MAX_ELEMENTS)o(new c(c.EXCEEDS_MAX_LIBRARY_SIZE,"Library cannot have more than "+a.MAX_ELEMENTS+" elements",this.id));else{var i=e.id;t._elements.every(function(e){return e.id!==i})&&t._removedElements.every(function(e){return e.id!==i})||(i=l.uuid()),this._doCopyDCXElement(e,t,n,i,o)}},v.prototype.jasmineToString=function(){return this.toString()},v.prototype._setSyncState=function(e){this._syncState!==e&&(this._syncState=e,this._collection._updateSyncState(),this._checkSyncFinishedAndNotify())},v.prototype._isSyncing=function(){return void 0!==this._syncState},v.prototype._checkSyncFinishedAndNotify=function(){if(!this._isSyncing()){var e=this._waitForSyncToFinishCallbacks;this._waitForSyncToFinishCallbacks=[],e.forEach(function(e){e()})}},v.prototype._waitForSyncToFinish=function(e){this._waitForSyncToFinishCallbacks.push(e),this._checkSyncFinishedAndNotify()},v.prototype._getClientData=function(){var e={};if(this._dcxComposite.clientDataString)try{e=JSON.parse(this._dcxComposite.clientDataString)}catch(e){}return e},v.prototype._getClientDataValue=function(e){return this._getClientData()[e]},v.prototype._setClientDataValue=function(e,t){var n=this._getClientData();n[e]=t,this._dcxComposite.clientDataString=JSON.stringify(n)},v.prototype._setCollaboration=function(e){var t=e&&e.collaboration&&e.collaboration.toLowerCase(),n=e&&e.collaboration_role&&e.collaboration_role.toLowerCase(),o=this._getClientDataValue(a.DATA_COLLABORATION_ROLE);if(this.collaboration!==t||o!==n){var i=_.collaborationStateToDCX(t);this._dcxComposite.collaborationType=i,this._setClientDataValue(a.DATA_COLLABORATION_ROLE,n),this._commit(!0,!0),this._notifyChange(),this._revertLocalChangesIfNecessary()}},v.prototype._isDeletedError=function(e){var t=e&&(e.code===o.NO_COMPOSITE||e.code===o.DELETED_COMPOSITE),n=e&&e.code===o.UNEXPECTED_RESPONSE&&e.response&&401===e.response.statusCode;return t||this.collection.isPublic&&n},v.prototype._isAlreadyExistsError=function(e){var t=e&&e.code===o.ALREADY_EXISTS,n=e&&e.code===o.UNEXPECTED_RESPONSE&&e.response&&409===e.response.statusCode;return t||n},v.prototype._isReadOnlyError=function(e){if("incoming"!==this.collaboration)return!1;var t=!1;return!e||e.code!==o.COMPONENT_UPLOAD_ERROR&&e.code!==o.UNEXPECTED_RESPONSE||(e.code===o.UNEXPECTED_RESPONSE&&e.response&&403===e.response.statusCode&&(t=!0),e.code===o.COMPONENT_UPLOAD_ERROR&&Array.isArray(e.failedComponents)&&e.failedComponents.length>0&&(t=!0,e.failedComponents.forEach(function(e){e.error&&e.error.code===o.UNEXPECTED_RESPONSE&&e.error.response&&403===e.error.response.statusCode||(t=!1)}))),t},v.prototype._mergeAndSwitchToBranch=function(e,t,n){var o=this,c=void 0!==t,p=e.localData;function u(t,u){if(!_.checkDeletedState(o,n))if(t)n(f.getCommitError(t,o.id));else{l.log("Starting merge "+(c?"(local)":"(remote)")),u.name!==o.name&&(e.name=o.name);var m=e.rootNode.getValue(a.MODIFIED_KEY),E=Math.max(m||0,o.modified||0);u!==o._dcxBranch&&E&&m!==E&&e.rootNode.setValue(a.MODIFIED_KEY,E);var g,y,v,A=_.getCompositeRenditionMap(e),C=_.getCompositeRenditionMap(u);Object.keys(o._dcxCompositeRenditionMap).forEach(function(t){var n=o._dcxCompositeRenditionMap[t],i=C[t],r=A[t];i&&n.id===i.id||(r?(n.getValue(a.MODIFIED_KEY)||0)>(r.getValue(a.MODIFIED_KEY)||0)&&(e.removeComponent(r),e.copyComponent(n,e.rootNode)):e.copyComponent(n,e.rootNode))}),Object.keys(C).forEach(function(t){var n=o._dcxCompositeRenditionMap[t],i=C[t],r=A[t];!n&&r&&r.id===i.id&&e.removeComponent(r)}),e.getChildrenOf().forEach(function(e){e.name===a.ELEMENTS_NAME&&(g=e),e.name===a.REMOVED_ELEMENTS_NAME&&(y=e),e.name===a.GROUPS_NAME&&(v=e)}),g||(g=e.addChild(a.ELEMENTS_NAME));var I=function(){y||(y=e.addChild(a.REMOVED_ELEMENTS_NAME))},S=[],L={},O=[],R=function(e,t,n,o){var i=t.getValue(a.ORDER_KEY),r=n&&n.getValue(a.ORDER_KEY),s=o&&o.getValue(a.ORDER_KEY);if(s!==i)e._dcxNode.setValue(a.ORDER_KEY,i);else if(r!==s)return e.order!==r&&e._dcxNode.setValue(a.ORDER_KEY,r),!0;return!1};o._groups.forEach(function(t){var n=t.id,o=t._dcxNode,i=t.modified,r=e.getChildWithId(n),s=r&&r.getValue(a.MODIFIED_KEY),c=u&&u.getChildWithId(n),p=c&&c.getValue(a.MODIFIED_KEY);if(!p&&!s||p&&!s&&i!==p){l.log("1: group created locally");var d=e.copyChild(o,(v||(v=e.addChild(a.GROUPS_NAME)),v),void 0,void 0,void 0);t._setDCXNode(d)}else p&&!s&&i===p?(l.log("2: group deleted on server"),O.push(t)):p===i&&p===s?(l.log("3: no changes to group modified time"),t._setDCXNode(r),R(t,o,r,c)&&S.push(t)):p===i&&p!==s?(l.log("4: updated group on server"),t._setDCXNode(r),S.push(t),R(t,o,r,c)):p!==i&&p===s?(l.log("5: updated group locally"),t._setDCXNode(e.replaceChild(o,void 0,void 0)),R(t,o,r,c)&&S.push(t)):p!==i&&p!==s?(l.log("6: updated group locally and on server (conflict)"),t._setDCXNode(e.replaceChild(o,void 0,void 0)),R(t,o,r,c)&&S.push(t)):l.log("ERROR: unexpected group merge case: base="+p+", current="+i+", pulled="+s);L[n]=!0}),O.forEach(function(e){o._doRemoveGroup(e,!1)});var N=[],T=[],D=[],b=[],w=new d,P=function(t){var n=t.id,i=t._dcxNode,p=t.modified,d=t.removed,_=e.getChildWithId(n),f=_&&_.getValue(a.MODIFIED_KEY),m=_&&_.getValue(a.REMOVED_KEY),E=u&&u.getChildWithId(n),v=E&&E.getValue(a.MODIFIED_KEY),A=E&&E.getValue(a.REMOVED_KEY);o._dcxBranch=e;var C=function(){return d?(I(),y):g},O=function(){return!d&&t.removed?(D.push(t),!0):!(!d||t.removed)&&(b.push(t),!0)},R=function(){var e=!1,n=i.getValue(a.DESCRIPTION_DATA_KEY)||{time:0},o=_&&_.getValue(a.DESCRIPTION_DATA_KEY)||{time:0},r=E&&E.getValue(a.DESCRIPTION_DATA_KEY)||{time:0};if(n.time!==r.time){var s=i.getValue(a.DESCRIPTION_KEY);t._dcxNode.setValue(a.DESCRIPTION_KEY,s),t._dcxNode.setValue(a.DESCRIPTION_DATA_KEY,n)}else o.time!==r.time&&(e=!0);var c=i.getValue(a.GROUPS_KEY)||{},l=_&&_.getValue(a.GROUPS_KEY)||{},p=E&&E.getValue(a.GROUPS_KEY)||{},d={};return Object.keys(c).forEach(function(t){var n=c[t],o=l[t],i=p[t];i&&n.order===i.order?o||(e=!0):d[t]=n}),Object.keys(l).forEach(function(t){var n=c[t],o=l[t],i=p[t];i&&!n||d[t]||(d[t]=o,i&&o.order===i.order||(e=!0))}),(Object.keys(d).length>0||Object.keys(l).length>0)&&JSON.stringify(l)!==JSON.stringify(d)&&t._dcxNode.setValue(a.GROUPS_KEY,d),e};if(!v&&!f||v&&!f&&p!==v){l.log("1: created element locally");var P=e.copyChild(i,C(),void 0,void 0,void 0);t._setDCXNode(P,!0)}else if(v&&!f&&p===v)l.log("2: deleted element on server"),T.push(t);else if(v===p&&v===f){l.log("3: no changes to element modified time"),t._setDCXNode(_,!0,!0),A!==d&&(A===m?d&&!m?(l.log("3a: removed element locally"),I(),t._dcxNode=e.moveChild(t._dcxNode,void 0,y),t._updateTimestampOnRemove(d)):m&&!d&&(l.log("3b: restored element locally"),t._dcxNode=e.moveChild(t._dcxNode,void 0,g),t._updateTimestampOnRestore()):d||(l.log("3c: remove/restore element conflict - local restore wins"),t._dcxNode=e.moveChild(t._dcxNode,void 0,g),t._updateTimestampOnRestore()));var x=O(),k=R();(x||k)&&S.push(t),t._ensureRemovedDataValid(c&&!a.SHARED_LOCAL_STORAGE)}else if(v===p&&v!==f)l.log("4: updated element on server"),t._setDCXNode(_,c),S.push(t),O(),R(),t._ensureModifiedDataValid(c&&!a.SHARED_LOCAL_STORAGE);else if(v!==p&&v===f){l.log("5: updated element locally");var M=e.replaceChild(i,void 0,void 0);t._setDCXNode(M,!0),(d&&!m||m&&!d)&&(t._dcxNode=e.moveChild(t._dcxNode,void 0,C())),R()&&S.push(t)}else if(v!==p&&v!==f){l.log("6: updated element locally and on server (conflict)");var V=t._renditionCache;t._setDCXNode(_),S.push(t),O(),t._ensureModifiedDataValid(c&&!a.SHARED_LOCAL_STORAGE);var U=l.uuid(),F=e.copyChild(i,C(),void 0,U,U),B=new r(o,F);N.push(B),L[B.id]=!0,l.hasFileSystem()&&w.addOperation(h.copyRenditionCache,[B,t,V]),s.reportCollisionElement(t)}else l.log("ERROR: unexpected element merge case: base="+v+", current="+p+", pulled="+f);o._dcxBranch=o._dcxComposite.current,L[n]=!0};o._elements.forEach(P),o._removedElements.forEach(P);var x=function(e){e.removed?o._removedElements.push(e):(o._addElementToFilter(e),o._elements.push(e))};N.forEach(x),o._sortRemovedElements(),T.forEach(function(e){o._doRemoveElement(e,!1)}),D.forEach(function(e){o._doMarkElementRemoved(e,!1)}),b.forEach(function(e){o._doRestoreElement(e,!1)}),o._dcxBranch=e,o._dcxElementsNode=g,o._dcxRemovedElementsNode=y,o._dcxGroupsNode=v,o._dcxCompositeRenditionMap=_.getCompositeRenditionMap(e);var k=function(t,n){if(!L[t.id]){var s=t.getValue(a.MODIFIED_KEY),p=u&&u.getChildWithId(t.id),d=p&&p.getValue(a.MODIFIED_KEY);if(d&&s&&d===s)l.log(n?"7: deleted group locally":"7: deleted element locally"),e.removeChild(t);else if(l.log(n?"8: created group on server":"8: created element on server"),n){var h=new i(o,t);o._groups.push(h)}else{var _=new r(o,t);x(_),_._ensureCreatedDataValid(c&&!a.SHARED_LOCAL_STORAGE)}}},M=o._dcxBranch.getChildrenOf(o._dcxElementsNode),V=o._dcxRemovedElementsNode?o._dcxBranch.getChildrenOf(o._dcxRemovedElementsNode):[],U=o._dcxGroupsNode?o._dcxBranch.getChildrenOf(o._dcxGroupsNode):[];M.forEach(function(e){k(e)}),V.forEach(function(e){k(e)}),U.forEach(function(e){k(e,!0)}),o._transactionCount++,w.run(function(){_.checkDeletedState(o,n)||(o._transactionCount--,l.storageInterface.resolvePullWithBranch(o,e,p,c,function(t){_.checkDeletedState(o,n)||(t?n(f.getCommitError(t,o.id)):(l.hasFileSystem()||(o._dcxBaseBranch=e.copy()),a.SHARED_LOCAL_STORAGE||c||h.prefetchRenditions(o),n(null),S.forEach(function(e){e._listenerManager.notify("change")}),o._notifyChange()))}))})}}this._waitForCommit(function(){_.checkDeletedState(o,n)||(t?u(null,t):"unmodified"===o._dcxBranch.compositeState?u(null,o._dcxBranch):o._loadBaseBranch(u))})},v.prototype._pull=function(e){var t=this;if(this._dcxComposite.href&&this._dcxBranch.isBound)if(this._deletedFromServer)e(null,!1);else{var n=function(n,o){_.checkDeletedState(t,e)||(n&&t._collection._reportSyncError(n),t._setSyncState(),t._networkLock.release(),e(n,o))};this._networkLock.obtain(function(o){o?e(null):_.checkDeletedState(t,e)||(this._setSyncState("downloading"),this._collection._syncManager.pullComposite(this._dcxComposite,this._collection,function(o,i){_.checkDeletedState(t,e)||(t._isDeletedError(o)?l.hasFileSystem()&&"modified"===t._dcxBranch.compositeState&&"incoming"!==t.collaboration?(t._doRebindToServer(!1,e),t._networkLock.release()):(t._deletedFromServer=!0,t._notifyChange(),n(null,!0)):o?n(f.getSyncError(o,t.id)):i?t._mergeAndSwitchToBranch(i,void 0,function(o){_.checkDeletedState(t,e)||n(o,!0)}):n(null,!1))}))},this)}else e(null,!1)},v.prototype._pushWithParameters=function(e,t){var n=this,i=function(e,n){t&&t(null,n)};if(a.SYNCING_ENABLED)if(this._collection._retryTimeoutId)i(0,!1);else if(this._dcxBranch.isBound&&"modified"!==this._dcxBranch.compositeState)i(0,!1);else if(this._deletedFromServer)i(0,!1);else if(this.isWritable)if(this._pushPending)i(0,!1);else{var r=function(e,o){_.checkDeletedState(n,i)||(n._pushFailedDueToQuota=!1,e&&(n._collection._reportSyncError(e),e.code===c.EXCEEDS_QUOTA&&(n._pushFailedDueToQuota=!0)),n._setSyncState(),n._collection._syncManager.pullMissingComponents(n,function(){_.checkDeletedState(n,t)||(n._networkLock.release(),h.prefetchRenditions(n),i(0,o))}))};this._pushPending=!0,this._networkLock.obtain(function(t){t?i(0,!1):this._waitForCommit(function(){var t;_.checkDeletedState(n,i)||(n._pushPending=!1,l.hasFileSystem()||(t=n._dcxBranch.copy()),n._setSyncState("uploading"),n._collection._syncManager.pushComposite(n._dcxComposite,n._collection,e,function(e){if(!_.checkDeletedState(n,i))if(n._isDeletedError(e))l.hasFileSystem()&&"modified"===n._dcxBranch.compositeState&&"incoming"!==n.collaboration?(n._doRebindToServer(!1,i),n._networkLock.release()):(n._deletedFromServer=!0,n._notifyChange(),r(null,!0));else{if(n._isAlreadyExistsError(e))return n._dcxComposite.name=p.translate("LIBS_RECOVERED_LIBRARY",{name:n._dcxComposite.name}),n._doRebindToServer(!0,i),void n._networkLock.release();if(n._isReadOnlyError(e))return l.log("Push failed due to read only. Reverting: "+n.id),n._setClientDataValue(a.DATA_COLLABORATION_ROLE,"viewer"),void n._revertLocalChangesIfNecessary(function(e){r(e,!1)});if(e&&e.code===c.TRANSFER_ABORTED)r(null,!0);else{if(e&&e.code===o.UPDATE_CONFLICT){if(l.log("Push failed due to conflict: "+n.id),n._numUpdateConflicts++,n._numUpdateConflicts<=a.MAX_UPDATE_CONFLICTS)return n._sync(!1,i),void n._networkLock.release();s.reportUnexpectedState(n,"updateConflict"),l.log("Reached maximum number of update-conflict retries: "+n.id)}n._numUpdateConflicts=0,e&&e.code===o.COMPONENT_UPLOAD_ERROR&&(l.log("Push failed due to component upload failure: "+n.id),_.removeMissingLocalComponents(n,e.failedComponents)),e?r(f.getSyncError(e,n.id)):l.storageInterface.acceptPush(n,function(e){_.checkDeletedState(n,i)||(e?r(f.getCommitError(e,n.id),!0):(l.hasFileSystem()||(n._dcxBaseBranch=t),r(null,!0)))})}}}))})},this)}else i(0,!1);else i(0,!1)},v.prototype._loadBaseBranch=function(e){var t=this;l.hasFileSystem()?t._dcxComposite.loadBaseBranch(function(n,o){t._waitForCommit(function(){e(n,o)})}):e(null,t._dcxBaseBranch)},v.prototype._revertLocalChangesIfNecessary=function(e){var t=this,n=E.wrapCallback(e);this.isWritable||"modified"!==this._dcxBranch.compositeState?n(null):this._loadBaseBranch(function(e,o){t._transactionCount++,_.recoverReadOnlyEdits(t,o,function(e){e&&l.log("Error recovering library changes: "+e),t._transactionCount--;var i=o.copy(),r=t.collaboration,s=t._getClientDataValue(a.DATA_COLLABORATION_ROLE);t._mergeAndSwitchToBranch(i,t._dcxBranch,function(e){if(e)l.log("Error Reverting: "+t.id),n(e);else{var o=_.collaborationStateToDCX(r);t._dcxComposite.collaborationType=o,t._setClientDataValue(a.DATA_COLLABORATION_ROLE,s),t._commit(!0,!0),t._waitForCommit(function(){t._notifyChange(),n(null)})}})})})},v.prototype._push=function(e){this._pushWithParameters(!1,e)},v.prototype._abortPushOrPull=function(){this._networkLock.abortPendingOperations(new c(c.TRANSFER_ABORTED)),this._collection._syncManager.abortPushOrPull(this.id)},v.prototype._deleteFromServer=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(r){r?t(null):this._deletedFromDisk?i(null):(this._setSyncState("uploading"),this._dcxBranch.compositeState="pendingDelete",this._commit(!0,!0),this._waitForCommit(function(){n._deletedFromDisk?i(null):n._collection._syncManager.pushDeletedComposite(n._dcxComposite,n._collection,n.collaboration,e,function(t){t?n._isDeletedError(t)?(n._deletedFromServer=!0,t=null):(e||t.code!==o.UPDATE_CONFLICT)&&(t=f.getSyncError(t,n.id),n._collection._reportSyncError(t)):n._deletedFromServer=!0,i(t)})}))},this)}else t(null)},v.prototype._doRebindToServer=function(e,t){var n=this;this._deletedFromServer=!1;var o=e||"incoming"===this.collaboration?"resetIdentity":"resetBinding",i=this.id;this._dcxComposite[o](function(e){_.checkDeletedState(n,t)||(e?t(e):(n._transactionCount++,n.id!==i&&(n._collection._libraryIdMap[n.id]=n,delete n._collection._libraryIdMap[i]),m.moveLibrary(n,i,function(e){_.checkDeletedState(n,t)||(n._transactionCount--,e?t(e):(n._collection._syncManager.prepareCompositeForPush(n._dcxComposite),n._setCollaboration(),n._commit(!1,!0),n._pushWithParameters(!0,t)))})))})},v.prototype._sync=function(e,t){var n=this;function o(e,o){t&&n._waitForSyncToFinish(function(){t(e,o)})}function i(e,t){_.checkDeletedState(n,o)||(e?o(e,t):n._push(function(e,i){_.checkDeletedState(n,o)||o(e,t||i)}))}!a.SHARED_LOCAL_STORAGE&&a.SYNCING_ENABLED?this._collection._retryTimeoutId?o(null,!1):(this._collection._clearSyncErrors(this.id),e?i(null,!1):this._pull(i)):o(null,!1)},v.prototype._getCompositeDir=function(){return this._collection._getCompositeDir(this.id)},v.prototype._getRenditionCacheDir=function(){return this._collection._getRenditionCacheDir(this.id)},v.prototype._setAutoGC=function(e,t){!1===t?this._autoGCMode[e]=!1:delete this._autoGCMode[e],this._dcxComposite.autoRemoveUnusedLocalFiles=0===Object.keys(this._autoGCMode)},Object.defineProperties(v.prototype,{id:{get(){return this._publicId||this._dcxComposite.id},set(){throw new c(c.READ_ONLY,"Cannot change the id of an existing library",this.id)}},collection:{get(){return this._collection},set(){throw new c(c.READ_ONLY,"collection is a read-only property",this.id)}},isWritable:{get(){var e=this._getClientDataValue(a.DATA_COLLABORATION_ROLE);return this._writable&&"viewer"!==e},set(){throw new c(c.READ_ONLY,"isWritable is a read-only property",this.id)}},name:{get(){return this._dcxComposite.name||""},set(e){if(_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);this._dcxComposite.name=e,this._commit()}},modified:{get(){return this._dcxBranch.rootNode.getValue(a.MODIFIED_KEY)},set(){throw new c(c.READ_ONLY,"Cannot change the modified timestamp of a library directly",this.id)}},created:{get(){return this._dcxBranch.rootNode.getValue(a.CREATED_KEY)},set(){throw new c(c.READ_ONLY,"Cannot change the created timestamp of a library directly",this.id)}},elements:{get(){return this._elements},set(){throw new c(c.READ_ONLY,"Cannot modify elements list directly",this.id)}},removedElements:{get(){return this._removedElements},set(){throw new c(c.READ_ONLY,"Cannot modify removed elements list directly",this.id)}},isDeletedFromServer:{get(){return this._deletedFromServer},set(){throw new c(c.READ_ONLY,"isDeletedFromServer is a read-only property",this.id)}},isDeletedLocally:{get(){return this._deletedLocally},set(){throw new c(c.READ_ONLY,"isDeletedLocally is a read-only property",this.id)}},isQuotaExceeded:{get(){return this._pushFailedDueToQuota},set(){throw new c(c.READ_ONLY,"isQuotaExceeded is a read-only property",this.id)}},collaboration:{get(){var e=this._dcxComposite.collaborationType;return _.collaborationStateFromDCX(e)},set(){throw new c(c.READ_ONLY,"collaboration is a read-only property",this.id)}},syncState:{get(){return this._syncState},set(){throw new c(c.READ_ONLY,"syncState is a read-only property")}},syncProgress:{get(){var e=this._collection._syncProgressMap[this.id];return e&&e.progress},set(){throw new c(c.READ_ONLY,"syncProgress is a read-only property")}}}),v.prototype.toString=function(){return JSON.stringify(this._toJSON())},v.prototype.addChangeListener=function(e){_.checkDeletedState(this),this._listenerManager.add("change",e)},v.prototype.removeChangeListener=function(e){this._listenerManager.remove("change",e)},v.prototype.getGroups=function(e){return e=e||a.DEFAULT_GROUP_CLASSIFIER,this._groups.filter(function(t){return e instanceof RegExp?e.test(t.classifierName):e===t.classifierName})},v.prototype.getGroupById=function(e){return this._groups.find(function(t){return t.id===e})},v.prototype.createGroup=function(e,t,n){if(n=n||a.DEFAULT_GROUP_CLASSIFIER,_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);var o=this._doCreateGroup(e,t,n);return this._commit(),s.reportCreateGroup(o),o},v.prototype.removeGroup=function(e,t){if(_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);if(!e)throw new c(c.INVALID_PARAMETER,"No group specified",this.id);if(-1===this._groups.indexOf(e))throw new c(c.INVALID_PARAMETER,"group not in this library",this.id);var n;t&&(n=this._getNumberOfElementsInGroup(e)),this._wrapOperation(function(){this._doRemoveGroup(e,t)},this),s.reportDeleteGroup(e,t,n)},v.prototype.moveGroup=function(e,t,n,o){if(!_.checkDeletedState(this,o))if(this.isWritable)if(e)if(-1!==this._groups.indexOf(e))if(t)if(this!==t){var i;if(t.isWritable)return n&&(i=this._getNumberOfElementsInGroup(e)),this._doCopyGroup(e,t,n,!0,function(t,r){t?o(t):(s.reportMoveGroup(r,e,n,i),o(null,r))});o(new c(c.NOT_ALLOWED,"you do not have write access to the destination library",t.id))}else o(new c(c.INVALID_PARAMETER,"Move must have a different destination library",this.id));else o(new c(c.INVALID_PARAMETER,"No destination library specified",this.id));else o(new c(c.INVALID_PARAMETER,"Group not in this library",this.id));else o(new c(c.INVALID_PARAMETER,"No group specified",this.id));else o(new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id))},v.prototype.copyGroup=function(e,t,n,o){if(!_.checkDeletedState(this,o))if(e)if(-1!==this._groups.indexOf(e))if(t){var i;if(t.isWritable)return n&&(i=this._getNumberOfElementsInGroup(e)),this._doCopyGroup(e,t,n,!1,function(t,r){t?o(t):(s.reportCopyGroup(r,e,n,i),o(null,r))});o(new c(c.NOT_ALLOWED,"you do not have write access to the destination library",t.id))}else o(new c(c.INVALID_PARAMETER,"No destination library specified",this.id));else o(new c(c.INVALID_PARAMETER,"Group not in this library",this.id));else o(new c(c.INVALID_PARAMETER,"No group specified",this.id))},v.prototype.createElement=function(e,t){if(_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);if(this._elements.length>=a.MAX_ELEMENTS)throw new c(c.EXCEEDS_MAX_LIBRARY_SIZE,"Library cannot have more than "+a.MAX_ELEMENTS+" elements",this.id);return this._wrapOperation(function(){var n=this._doCreateElement(e,t);return s.reportCreateElement(n),n.beginOperation(),n},this)},v.prototype.removeElement=function(e,t){if(_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);if(!e)throw new c(c.INVALID_PARAMETER,"No element specified",this.id);if(-1===this._elements.indexOf(e)){if(-1===this._removedElements.indexOf(e))throw new c(c.INVALID_PARAMETER,"Element not in this library",this.id);if(!t)throw new c(c.INVALID_PARAMETER,"Element already removed",this.id)}return this._wrapOperation(function(){for(;e._transactionCount>0;)e.endOperation();t?this._doRemoveElement(e,!0):this._doMarkElementRemoved(e,!0),s.reportDeleteElement(e,t)},this)},v.prototype.restoreElement=function(e){if(_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);if(!e)throw new c(c.INVALID_PARAMETER,"No element specified",this.id);if(-1===this._removedElements.indexOf(e)){if(-1===this._elements.indexOf(e))throw new c(c.INVALID_PARAMETER,"Element not in this library",this.id);throw new c(c.INVALID_PARAMETER,"Element already restored",this.id)}if(this._elements.length>=a.MAX_ELEMENTS)throw new c(c.EXCEEDS_MAX_LIBRARY_SIZE,"Library cannot have more than "+a.MAX_ELEMENTS+" elements",this.id);return this._wrapOperation(function(){this._doRestoreElement(e,!0),s.reportRestoreElement(e)},this)},v.prototype.copyElement=function(e,t,n){if(!_.checkDeletedState(this,n))if(e)if(-1!==this._elements.indexOf(e)||-1!==this._removedElements.indexOf(e))if(t){if(t.isWritable)return this._doCopyElement(e,t,!1,function(t,o){t?n(t):(s.reportCopyElement(o,e),n(null,o))});n(new c(c.NOT_ALLOWED,"you do not have write access to the destination library",t.id))}else n(new c(c.INVALID_PARAMETER,"No destination library specified",this.id));else n(new c(c.INVALID_PARAMETER,"Element not in this library",this.id));else n(new c(c.INVALID_PARAMETER,"No element specified",this.id))},v.prototype.moveElement=function(e,t,n){if(!_.checkDeletedState(this,n))if(this.isWritable)if(e)if(-1!==this._elements.indexOf(e)||-1!==this._removedElements.indexOf(e))if(t)if(this!==t){if(t.isWritable)return this._doCopyElement(e,t,!0,function(t,o){t?n(t):(s.reportMoveElement(o,e),n(null,o))});n(new c(c.NOT_ALLOWED,"you do not have write access to the destination library",t.id))}else n(new c(c.INVALID_PARAMETER,"Move must have a different destination library",this.id));else n(new c(c.INVALID_PARAMETER,"No destination library specified",this.id));else n(new c(c.INVALID_PARAMETER,"Element not in this library",this.id));else n(new c(c.INVALID_PARAMETER,"No element specified",this.id));else n(new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id))},v.prototype.getRenditionPath=function(e,t){if(l.hasFileSystem()){if(!_.checkDeletedState(this,t)&&this._checkRenditionType(e,t)){var n=this._dcxCompositeRenditionMap[e];if(!n)return t(null);var o=this._dcxBranch.assetOfComponent(n);if(o)return t(null,o);var i=this;this._networkLock.obtain(function(e){e?t(e):_.checkDeletedState(i,t)?i._networkLock.release():(i._setSyncState("downloading"),i._collection._syncManager.downloadComponent(i._dcxBranch,n,function(e){i._networkLock.release(),i._setSyncState(),e?t(f.getSyncError(e,i.id)):_.checkDeletedState(i,t)||(i._commit(!0,!0),t(null,i._dcxBranch.assetOfComponent(n)))}))})}}else t(new c(c.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this.id))},v.prototype.getRenditionURL=function(e){_.checkDeletedState(this),this._checkRenditionType(e);var t=this._dcxCompositeRenditionMap[e];if(t)return this._collection._syncManager.getSharedCloudContentURL(t)},v.prototype.getAuthenticatedRenditionURL=function(e,t){if(!_.checkDeletedState(this,t)&&this._checkRenditionType(e,t)){var n=this.getRenditionURL(e);if(!n)return t(null);this._collection._syncManager.appendAccessTokenToURL(n,t)}},v.prototype.setRendition=function(e,t,n,o,i){if(!_.checkDeletedState(this,i)&&this._checkRenditionType(e,i))if(t)if(this.isWritable)if(l.hasFileSystem()){if(!_.checkEncoding(n,["utf8","ascii","base64","buffer"],i))return;this._setRendition(e,t,n,o,i)}else{if(void 0!==n)return void i(new c(c.INVALID_PARAMETER,"Encoding parameter not supported in-browser"));this._setRenditionInBrowser(e,t,o,i)}else i(new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id));else i(new c(c.INVALID_PARAMETER,"content must exist",this.id))},v.prototype.setRenditionFromPath=function(e,t,n,o){_.checkDeletedState(this,o)||this._checkRenditionType(e,o)&&("string"==typeof t?l.hasFileSystem()?this.isWritable?this._setRenditionFromPath(e,t,n,o):o(new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id)):o(new c(c.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this.id)):o(new c(c.INVALID_PARAMETER,"path must be a string",this.id)))},v.prototype.removeRendition=function(e){if(_.checkDeletedState(this),this._checkRenditionType(e),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);var t=this._dcxCompositeRenditionMap[e];if(t)return this._wrapOperation(function(){this._dcxBranch.removeComponent(t),this._dcxCompositeRenditionMap=_.getCompositeRenditionMap(this._dcxBranch),this._commit()},this)},v.prototype.beginOperation=function(){if(_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);this._beginOperation()},v.prototype.endOperation=function(){if(_.checkDeletedState(this),!this.isWritable)throw new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id);this._endOperation()},v.prototype.getFilteredElements=function(e){if(!e)throw new c(c.INVALID_PARAMETER,"must specify element type to filter",this.id);if("*"!==e&&-1===a.ELEMENT_TYPE_FILTERS.indexOf(e))throw new c(c.INVALID_PARAMETER,"must specify '*', or an element type in config.ELEMENT_TYPE_FILTERS",this.id);var t=this._getFilterKey(e);return this._filterCache[t]=this._filterCache[t]||[],this._filterCache[t]},v.prototype.sync=function(e){_.checkDeletedState(this,e)||this._sync(!1,e)},v.prototype.rebindToServer=function(e){l.hasFileSystem()?_.checkDeletedState(this,e)||(this.isWritable?this._deletedFromServer?this._doRebindToServer(!1,e):e(null):e(new c(c.NOT_ALLOWED,"you do not have write access to this library",this.id))):e(new c(c.REQUIRES_FILESYSTEM,"rebindToServer requires a filesystem",this.id))},v.prototype.getElementById=function(e,t){var n;return this.elements.forEach(function(t){t.id===e&&(n=t)}),n||t||this.removedElements.forEach(function(t){t.id===e&&(n=t)}),n},Object.freeze(v),Object.seal(v.prototype),e.exports=v},function(e,t,n){var o=n(2);function i(e,t){this._id=e,this._url=t}Object.defineProperties(i.prototype,{id:{get(){return this._id},set(){throw new o(o.READ_ONLY,"Cannot change the id of an existing bookmark")}},url:{get(){return this._url},set(){throw new o(o.READ_ONLY,"Cannot change the url of an existing bookmark")}}}),Object.freeze(i),Object.seal(i.prototype),e.exports=i},function(e,t,n){var o=n(42),i=n(2),r=n(1),a=n(0),s=n(10),c=n(9);function l(e){e.IS_PUBLIC=!0,e.USER_ID=e.USER_ID||r.PUBLIC_USER_ID,this._newLibrariesLoading={},o.call(this,e)}Object.keys(o.prototype).forEach(function(e){0===e.indexOf("_")&&(l.prototype[e]=o.prototype[e])}),l.prototype._dosync=function(e,t){var n=this;this._clearSyncErrors();var o=new s;this._libraries.forEach(function(e){o.addOperation(function(t){n._syncManager.hasCompositeChangedOnServer(e._dcxComposite,function(n){e._sync(!n,t)})})}),o.run(function(e,n){t(null,n)},function(e){n._reportSyncError(e)})},Object.defineProperties(l.prototype,{libraries:{get(){return this._libraries},set(){throw new i(i.READ_ONLY,"Cannot modify libraries list directly")}},commitError:{get(){return this._lastCommitError},set(){throw new i(i.READ_ONLY,"commitError is a read-only property")}},syncState:{get(){return this._syncState},set(){throw new i(i.READ_ONLY,"syncState is a read-only property")}},syncErrors:{get(){return this._syncErrors},set(){throw new i(i.READ_ONLY,"syncErrors is a read-only property")}},syncProgress:{get(){return this._syncProgress},set(){throw new i(i.READ_ONLY,"syncProgress is a read-only property")}},isPolling:{get(){return void 0!==this._pollTimerId},set(){throw new i(i.READ_ONLY,"isPolling is a read-only property")}},retryTime:{get(){return"never"!==this._retryTime?this._retryTime:void 0},set(){throw new i(i.READ_ONLY,"retryTime is a read-only property")}},userId:{get(){return this._userId},set(){throw new i(i.READ_ONLY,"userId is a read-only property")}},cloudId:{get(){return this._cloudId},set(){throw new i(i.READ_ONLY,"cloudId is a read-only property")}},cloudInfo:{get(){return this._cloudInfo},set(){throw new i(i.READ_ONLY,"cloudInfo is a read-only property")}},isPublic:{get:()=>!0,set(){throw new i(i.READ_ONLY,"isPublic is a read-only property")}},operations:{get(){return this._operations},set(){throw new i(i.READ_ONLY,"operations is a read-only property")}}}),l.prototype.addChangeListener=function(e){o.prototype.addChangeListener.call(this,e)},l.prototype.removeChangeListener=function(e){o.prototype.removeChangeListener.call(this,e)},l.prototype.addDeepChangeListener=function(e){o.prototype.addDeepChangeListener.call(this,e)},l.prototype.removeDeepChangeListener=function(e){o.prototype.removeDeepChangeListener.call(this,e)},l.prototype.canLoadLibrary=function(e){var t=new RegExp(this._syncManager.getSyncGroupPath()+"/(.+)");return!!e.match(t)},l.prototype.loadLibrary=function(e,t,n){var o=this,s=this.getLibraryById(e);if(s)n(null,s);else if(!t||this.canLoadLibrary(t)){var c=this._newLibrariesLoading[e];c?c.push(n):(this._newLibrariesLoading[e]=[n],r.SHARED_LOCAL_STORAGE?a.storageInterface.loadPublicLibrary(this,e,t,l):this._syncNewLibrary(e,t,void 0,function(t){t?l(t):((s=o.getLibraryById(e))&&(s._loadedExternally=!0),l(null,s))}))}else n(new i(i.INVALID_PARAMETER,"Invalid library url"));function l(t,n){var i=o._newLibrariesLoading[e];delete o._newLibrariesLoading[e],i.forEach(function(e){e(t,n)})}},l.prototype.unloadLibrary=function(e,t){var n=this._libraries.indexOf(e);-1!==n?(this._libraries.splice(n,1),delete this._libraryIdMap[e.id],e._markDeletedLocally(!0),r.SHARED_LOCAL_STORAGE?a.storageInterface.unloadPublicLibrary(e,t):(e._deletedFromDisk=!0,c.deleteLibraryFromDisk(this,e.id,t)),this._listenerManager.notify("change")):t(null)},l.prototype.removeDeletedLibraries=function(e,t){o.prototype.removeDeletedLibraries.call(this,e,t)},l.prototype.exportLibrary=function(e,t,n){return o.prototype.exportLibrary.call(this,e,t,n)},l.prototype.sync=function(e){o.prototype.sync.call(this,e)},l.prototype.addSyncListener=function(e){o.prototype.addSyncListener.call(this,e)},l.prototype.removeSyncListener=function(e){o.prototype.removeSyncListener.call(this,e)},l.prototype.getPrimarySyncError=function(){return o.prototype.getPrimarySyncError.call(this)},l.prototype.getNewLibrarySyncProgress=function(){return o.prototype.getNewLibrarySyncProgress.call(this)},l.prototype.addOperationChangeListener=function(e){this._listenerManager.add("operation",e)},l.prototype.removeOperationChangeListener=function(e){this._listenerManager.remove("operation",e)},l.prototype.addCommitErrorListener=function(e){o.prototype.addCommitErrorListener.call(this,e)},l.prototype.removeCommitErrorListener=function(e){o.prototype.removeCommitErrorListener.call(this,e)},l.prototype.startPolling=function(){o.prototype.startPolling.call(this)},l.prototype.stopPolling=function(){o.prototype.stopPolling.call(this)},l.prototype.getLibraryById=function(e){return o.prototype.getLibraryById.call(this,e)},l.prototype.getTempDir=function(e){o.prototype.getTempDir.call(this,e)},Object.freeze(l),Object.seal(l.prototype),e.exports=l},function(e,t,n){var o=n(0),i=n(5);function r(e){this._socket=e,this._listenerManager=new i,this._socketListenerManager=new i,this._pendingWriteState={},this._pendingWriteDependencyMap={},this._init()}function a(e){return e+"_req"}function s(e){return e+"_res"}function c(e,t,n){return e+"#"+t+"#"+n}r.prototype._init=function(){var e=this;this._addSocketListener("message",function(t){var n=JSON.parse(t);e._logReceive(n.type),e._listenerManager.notify(n.type,[n.data])})},r.prototype._addSocketListener=function(e,t){this._socketListenerManager.add(e,t),this._socket.addListener(e,t)},r.prototype._removeSocketListeners=function(){var e=this;this._socketListenerManager.forEach(function(t,n){e._socket.removeListener(t,n)}),this._socketListenerManager.removeAll()},r.prototype._logSend=function(e){this._logCallback&&this._logCallback("SEND "+e)},r.prototype._logReceive=function(e){this._logCallback&&this._logCallback("RECEIVE "+e)},r.prototype._logError=function(e){this._logCallback&&this._logCallback("ERROR "+e)},r.prototype.setPendingWriteState=function(e,t,n){var o=c(e,t,n);this._pendingWriteState[o]=!0},r.prototype.setPendingWriteDependency=function(e,t,n,o,i,r){var a=c(e,t,n),s=c(o,i,r);a!==s&&(this._pendingWriteDependencyMap[a]=this._pendingWriteDependencyMap[a]||{},this._pendingWriteDependencyMap[a][s]={userId:o,cloudId:i,id:r})},r.prototype.clearPendingWriteState=function(e,t,n){var o=c(e,t,n),i=[];return Object.keys(this._pendingWriteDependencyMap[o]||{}).forEach(function(e){i.push(this._pendingWriteDependencyMap[o][e])},this),delete this._pendingWriteState[o],delete this._pendingWriteDependencyMap[o],i},r.prototype.getPendingWriteState=function(e,t,n,o){var i=c(e,t,n),r=!1;return!o&&this._pendingWriteState[i]&&(r=this._pendingWriteState[i]),Object.keys(this._pendingWriteDependencyMap).forEach(function(e){this._pendingWriteDependencyMap[e][i]&&(r=this._pendingWriteState[e]||r)},this),r},r.prototype.setLogCallback=function(e){this._logCallback=e},r.prototype.addListener=function(e,t){this._listenerManager.add(e,t)},r.prototype.removeListener=function(e,t){this._listenerManager.remove(e,t)},r.prototype.send=function(e,t){try{this._logSend(e),this._socket.send(JSON.stringify({type:e,data:t}))}catch(e){this._logError(e),this._socketListenerManager.notify("error",[e])}},r.prototype.addCallListener=function(e,t){var n=this;this.addListener(a(e),function(o){var i=o.id;t(o.data,function(t){n.send(s(e),{id:i,data:t})})})},r.prototype.removeCallListener=function(e,t){this.removeListener(a(e),t)},r.prototype.call=function(e,t,n){var i=this,r=o.uuid(),c=function(t){t.id===r&&(i.removeListener(s(e),c),n(t.data))};this.addListener(s(e),c),this.send(a(e),{id:r,data:t})},r.prototype.onOpen=function(e){this._addSocketListener("open",e)},r.prototype.onClose=function(e){this._addSocketListener("close",e)},r.prototype.onError=function(e){this._addSocketListener("error",e)},r.prototype.shutdown=function(){var e=this;this._addSocketListener("close",function(){e._removeSocketListeners(),e._listenerManager.removeAll()}),this._socket.close()},Object.freeze(r),Object.seal(r.prototype),e.exports=r},function(e,t,n){var o=n(23),i={},r={obtainLock:function(e,t){i[e]||(i[e]=new o),i[e].obtain(t)},releaseLock:function(e){i[e]&&i[e].release()},isLocked:function(e){return!!i[e]&&i[e].isLocked()},hasPendingRequest:function(e){return!!i[e]&&i[e].hasPendingRequest()}};e.exports=r},function(e,t,n){global.LOCALE_ROOT=__dirname+"/locale/";const o=n(44),i=n(19),r=n(20),a=n(14),s=n(26);var c=n(4),l=n(8),p=n(68),d=n(108),u=n(110),h=n(111),_=n(35),f=n(60),m=n(43),E=n(112),g=n(116),y=n(36),v=n(120),A=n(122),C=n(123),I=n(124),S=n(25),L=n(24),O=n(125),R=n(126),N=n(127),T=n(128),D=n(11),b=n(2),w=n(1),P=n(0),x=n(22),k=n(135),M=n(16),V=n(12),U=n(10),F=n(13),B=n(9),Y="Service",H=!1;process.argv.forEach(function(e){"--test"===e&&(console.log("Testing CCLibrary Process..."),H=!0)}),n(136).start(),d.clearTempFiles(c.getValue("ROOT_DIR")),Error.stackTraceLimit=1/0;var G=function(e){var t=0,n=function(){2===++t&&process.exit()},o=function(){l.removeLogWriteListener(o),n()};l.addLogWriteListener(o),l.log(Y,"Uncaught exception: "+e+"\n"+e.stack),S.isEnabled()?S.reportError("Uncaught",e+"\n"+e.stack,!0,n):n()};H||process.on("uncaughtException",G);const j=[new o.Server({port:0,host:"127.0.0.1",verifyClient(e,t){if("file://"!==e.origin&&!e.origin.match(/http:\/\/localhost:[0-9]+$/))return l.log(Y,"Rejected attempt to connect to websocket server from: "+e.origin),S.reportEvent("rejectedClientOrigin",{origin:e.origin}),void t(!1);t(!0)}})];if(c.getValue("HTTPS_ENABLED")){const e=s.createServer({host:"localhost",key:i.readFileSync(a.join(__dirname,"certs","server.key")),cert:i.readFileSync(a.join(__dirname,"certs","server.crt")),ca:i.readFileSync(a.join(__dirname,"certs","ca.crt"))});e.listen(c.getValue("WSS_PORT")),j.push(new o.Server({server:e}))}var X=new k;function W(e){f.isLocked(e.id)||(X.broadcast("librarychange",u.getLibraryData(e)),E.libraryChanged(e,!1))}function q(e){return e.isPublic?D.getLoadedPublicCollectionById(e.cloudId):D.getLoadedCollectionById(e.userId,e.cloudId)}function z(e,t){var n=q(e);return n&&n.getLibraryById(e[t||"id"])}function K(e,t,n){var o=z(e,n);return o&&o.getElementById(e[t||"element"])}function J(e){var t=K(e);return t&&t.getRepresentationById(e.representation)}var Q=function(e,t){var n=z(e);n&&n._setAutoGC("client_writing",t)};function $(e,t,n){var o=function(){var o=function(){p.validateBookmarks()};n?e.syncChanges(n,o):t?e.syncFull(o):e.sync(o)};e.isPublic||e.isLoggedIn?o():y.getAccessToken(function(t,n){!t&&n&&(e.updateAccessToken(n),o())})}function Z(e){D.getLoadedCollections().forEach(function(t){e?t.isPublic||$(t,!1,e):$(t,!1)})}var ee,te="normal";var ne=[],oe=function(){var e=[],t={};ne.forEach(function(n){q(n)?(e.push(n),t[n.userId+"/"+n.cloudId]=!0):function(e){X.broadcast("collectionremoved",e)}(n)}),D.getLoadedCollections().forEach(function(n){var o=n.isPublic?w.PUBLIC_USER_ID:n.userId;t[o+"/"+n.cloudId]||(e.push({isPublic:n.isPublic,userId:o,cloudId:n.cloudId}),function(e){X.broadcast("collectionadded",u.getCollectionData(e)),X.broadcast("syncstate",u.getSyncStateData(e))}(n))}),ne=e};D.addLoadedCollectionsListener(oe);var ie={};function re(e){var t=(e.isPublic?"":e.userId)+"/"+e.cloudId;ie[t]=ie[t]||{};var n=ie[t];e.libraries.forEach(function(e){n[e.id]||(n[e.id]=function(){W(e)},e.addChangeListener(n[e.id]),W(e))}),Object.keys(n).forEach(function(t){e.getLibraryById(t)||(X.broadcast("librarydeleted",u.getDeletedLibraryData(e,t)),E.libraryDeleted(t),delete n[t])})}var ae=0;function se(){const e=e=>(t,n)=>{var o="client_"+ae++,r=_.parseQueryString(n.url),a=r.version||0,s="true"===r.diagnostics;l.log(Y,o,"Client connected: "+(s?"diagnostic":"version="+a));var d=X.newChannel(t);d.onClose(function(){l.log(Y,o,"Client disconnected")}),d.setLogCallback(function(e){l.log(Y,o,e)});var m=!e;if(r.token&&(m=r.token===c.getValue("SERVICE_TOKEN")),r.diagnostics||S.reportEvent("clientConnected",{clientId:o,clientVersion:a,numClients:X.numChannels(),hasToken:void 0!==r.token,isRejected:!m}),s)d.shutdown();else{var g=u.getEnvironmentData(a);if(m&&d.send("environmentinfo",g),g.updateRequired)return l.log(Y,o,"Incompatible version. Update required: "+g.updateRequired),void d.shutdown();if(!m)return l.log(Y,o,"Client validation failed"),void d.shutdown();d.addListener("configure",function(e){e.CLIENT_DESCRIPTION&&l.log(Y,"Configure: "+e.CLIENT_DESCRIPTION);var t=!1,n=!1;if(e.RENDITION_SIZES&&(t=h.mergeRenditionSizes(e.RENDITION_SIZES)),e.FULL_RENDITION_CONFIG&&(n=h.mergeFullRenditionConfig(e.FULL_RENDITION_CONFIG)),(t||n)&&(h.triggerRenditionPrefetch(),E.collectionsLoaded()),void 0!==e.SHARED_LOCAL_STORAGE_ANALYTICS&&S.setEnabled(e.SHARED_LOCAL_STORAGE_ANALYTICS),e.LOCAL_SETTINGS){h.mergeLocalSettings(e.LOCAL_SETTINGS)&&X.broadcast("environmentinfo",u.getEnvironmentData(),d)}}),d.addListener("sync",function(e){var t=q(e);(function(e){var t=e&&e.getPrimarySyncError();return!!t&&t.code===b.ACCESS_DENIED})(t)||(t&&$(t),A.ping())}),d.addListener("configuresync",function(e){v.configureFileSyncing(e.enable)}),d.addCallListener("commit",function(e,t){var n=q(e);f.obtainLock(e.id,function(){function o(){X.getPendingWriteState(e.userId,e.cloudId,e.id,d)||Q(e,!0)}function i(o,i){f.releaseLock(e.id);var r=n.getLibraryById(e.id),a={};o?((a=r?u.getLibraryData(r):a).success=!1,t(a)):h.updateRenditions(n,e.id,e.renditions||[],function(o,s){i||(!function(e,t,n){var o=e.getLibraryById(t);o?X.broadcast("librarychange",u.getLibraryData(o),n):X.broadcast("librarydeleted",u.getDeletedLibraryData(e,t),n)}(n,e.id,d),r?E.libraryChanged(r,!0):E.libraryDeleted(e.id)),a.success=!0,a.renditions=o?[]:s,function(n){d.clearPendingWriteState(e.userId,e.cloudId,e.id).forEach(function(e){X.getPendingWriteState(e.userId,e.cloudId,e.id)||Q(e,!0)}),t(n)}(a)})}var r=n.getLibraryById(e.id);if(r){var a=u.getLibraryData(r);M.areManifestsEqual(a.manifest,e.current)?(l.log(Y,"Commit skipped: nothing changed"),o(),i(null,!0)):M.areManifestsEqual(a.manifest,e.base)?(l.log(Y,"Commit proceeding: fast-forward"),o(),P.storageInterface.updateExistingLibrary(n,r,e.current,e.base,void 0,i)):(l.log(Y,"Commit fail: base mismatch"),i(!0))}else l.log(Y,"Commit proceeding: creating new library"),o(),P.storageInterface.createNewLibrary(n,e.id,e.current,i)})}),d.addCallListener("getrenditionpath",function(e,t){var n=K(e);n?n.getThumbnailPath(e.size,function(e,n){t(n)}):t()}),d.addCallListener("startcomponentwrite",function(e,t){Q(e,!1),d.setPendingWriteState(e.userId,e.cloudId,e.id),(e.dependencies||[]).forEach(function(t){Q(t,!1),d.setPendingWriteDependency(e.userId,e.cloudId,e.id,t.userId,t.cloudId,t.id)}),t()}),d.addCallListener("loadpubliclibrary",function(e,t){var n=q(e);n&&n.isPublic?n.loadLibrary(e.id,e.url,function(){t()}):t()}),d.addCallListener("unloadpubliclibrary",function(e,t){var n=q(e),o=n&&n.getLibraryById(e.id);n&&n.isPublic&&o?n.unloadLibrary(o,function(){t()}):t()}),d.addCallListener("createBookmark",function(e,t){var n=q(e);n&&!n.isPublic?n.createBookmark(e.id,e.url,function(e,n){t({err:e&&u.prepareErrorForSerialization(e),bookmark:n})}):t()}),d.addCallListener("removeBookmark",function(e,t){var n,o=q(e);if(o&&!o.isPublic&&(o.bookmarks.forEach(function(t){t.id===e.id&&(n=t)}),n))return void o.removeBookmark(n,t);t()}),d.addCallListener("downloadfile",function(e,t){var n=q(e);n?n._syncManager.getAssetFromURL(e.url,e.headers,e.tempDir,void 0,function(e,n,o,i){t({err:e&&u.prepareErrorForSerialization(e),tempFilePath:n,etag:o,responseHeaders:i&&i.headers})}):t({err:new b(b.INVALID_PARAMETER,"Library collection not found")})}),d.addCallListener("downloadexternallink",function(e,t){var n=J(e);n?n.getContentPath(function(e,n){t({err:e&&u.prepareErrorForSerialization(e),path:n})}):t({err:new b(b.INVALID_PARAMETER,"Representation not found")})}),d.addCallListener("testexternallink",function(e,t){var n=J(e);n?n.testExternalLink(function(e,n){t({err:e&&u.prepareErrorForSerialization(e),success:n})}):t({err:new b(b.INVALID_PARAMETER,"Representation not found")})}),d.addListener("clearcachedexternallink",function(e){var t=J(e);t&&t.isExternalLink&&t.clearCachedExternalLink()}),d.addCallListener("fscall",function(e,t){try{e.args.push(function(){var e=Array.prototype.slice.call(arguments);t(e)}),i[e.method].apply(i,e.args)}catch(e){t([e&&u.prepareErrorForSerialization(e)])}}),d.addCallListener("fspipe",function(e,t){try{var n=i.createReadStream(e.readStream.path,e.readStream.options),o=i.createWriteStream(e.writeStream.path,e.writeStream.options),r=!1;["end","error"].forEach(function(e){n.on(e,function(){r||(r=!0,t({event:e,args:Array.prototype.slice.call(arguments)}))})}),n.pipe(o)}catch(e){t({event:"error",args:[e&&u.prepareErrorForSerialization(e)]})}}),d.addCallListener("performElementAction",function(e,t){l.log(Y,"Recieved Element Action "+JSON.stringify(e));var n=K(e,"elementId","libraryId");O.launch({appCode:e.appCode,minVersion:e.minVersion,element:n,action:e.action},function(e,n){t({err:e,data:n})})}),d.addCallListener("importlibrary",function(e,t){var n=q(e);n?n._doImportLibrary(e.path,function(e,o){re(n),t({err:e&&u.prepareErrorForSerialization(e),libraryId:o&&o.id})},e.operationId):t({err:new b(b.INVALID_PARAMETER,"Library collection not found")})}),d.addCallListener("exportlibrary",function(e,t){var n=z(e);n?n.collection._doExportLibrary(n,e.path,function(e){t({err:e&&u.prepareErrorForSerialization(e)})},e.operationId):t({err:new b(b.INVALID_PARAMETER,"Library not found")})}),d.addListener("canceloperation",function(e){var t=q(e);t&&t._operationIdMap[e.operationId]&&t._operationIdMap[e.operationId].cancel()}),d.addCallListener("getImageDimensions",function(e,t){B.getImageDimensions(e,function(e){t({data:e})})}),d.addCallListener("getfontdata",function(e,t){var n=q(e);n&&n.fontManager?n.fontManager.getFontData(e.fontId,function(e,n){t({err:e&&u.prepareErrorForSerialization(e),data:n})}):t()});var y=D.getLoadedCollections();0===y.length?d.send("clearcollections"):y.forEach(function(e){d.send("collectionadded",u.getCollectionData(e)),d.send("syncstate",u.getSyncStateData(e)),e.isPublic||d.send("bookmarkschanged",p.getCollectionBookmarksData(e))})}};j.forEach((t,n)=>t.on("connection",e(0===n))),c.setValue("SERVICE_PORT",j[0]._server.address().port),c.setValue("SERVICE_TOKEN",P.uuid()),l.log(Y,"Version: "+u.getCodeVersion(!0)+" (protocol version = "+u.getAPIVersion()+")"),l.log(Y,"Environment: "+c.getEnvironment().LABEL),l.log(Y,"Root: "+c.getValue("ROOT_DIR")),l.log(Y,"Listening on port: "+c.getValue("SERVICE_PORT")),g.sendStartupMessage(),S.reportEvent("processStarted",{apiVersion:u.getAPIVersion(),environment:c.getEnvironment().LABEL,osType:r.type(),osPlatform:r.platform(),osArch:r.arch(),osRelease:r.release(),osTotalMem:r.totalmem(),osFreeMem:r.freemem()})}var ce=function(){O.updateInstallationMap(),X.broadcast("environmentinfo",u.getEnvironmentData())};v.addListener("installApplication",ce),v.addListener("uninstallApplication",ce),v.addListener("updateApplication",function(){O.updateInstallationMap(!0),ce()});var le={};function pe(e){var t=e.userId+"/"+e.cloudId;if(le[t]=le[t]||{lastBroadcast:0},!le[t].pendingBroadcast){var n=c.getValue("SYNC_STATE_BROADCAST_THROTTLE"),o=(new Date).valueOf();if(o-le[t].lastBroadcast<n)le[t].pendingBroadcast=setTimeout(function(){delete le[t].pendingBroadcast,pe(e)},n);else{le[t].lastBroadcast=o;var i=u.getSyncStateData(e);if(X.broadcast("syncstate",i),"error"===e.syncState){var r=e.getPrimarySyncError();S.reportError("SyncError",V.errorToString(r))}}}}function de(e){var t=u.getOperationsData(e);X.broadcast("operationschanged",t)}function ue(e,t){l.log(Y,"Load public collection: "+JSON.stringify(e)),D.loadPublicLibraryCollection(e,function(e,n){if(e)return l.log(Y,"Error loading public libraries: "+e),void G(e);n.startPolling(),n.addSyncListener(function(){re(n),pe(n)}),n.addOperationChangeListener(function(){de(n)}),n.addChangeListener(function(){re(n)}),re(n),E.collectionsLoaded(),t()})}function he(e){l.log(Y,"Load library collection: "+JSON.stringify(e)),D.loadLibraryCollection(e,function(t,n){if(t)return l.log(Y,"Error loading libraries: "+t),void G(t);n.addSyncListener(function(){re(n),pe(n)}),n.addOperationChangeListener(function(){de(n)}),re(n),E.collectionsLoaded(),function(e,t){var n=new U;c.getEnvironment().PUBLIC_HOSTS.forEach(function(t){var o={getAccessToken:y.getAccessToken,USER_ID:e.USER_ID,CC_IMAGE_HOSTNAME:e.CC_IMAGE_HOSTNAME,CC_IMAGE_X_HOSTNAME:e.CC_IMAGE_X_HOSTNAME,STORAGE_HOSTNAME:t.host};t.community_platform?(o.CLOUD_ID=w.CP_CLOUD_ID+"_"+t.host,o.REQUIRES_COMMUNITY_SESSION=!0):o.CLOUD_ID=t.host,n.addOperation(ue,[o])}),n.run(t)}(e,function(){p.validateBookmarks(),p.sendBookmarksChanged(X),n.addChangeListener(function(){p.validateBookmarks(),p.sendBookmarksChanged(X)}),h.fixRenditions(D.getLoadedCollections())})})}function _e(e,t,n){var o=y.getUserId();l.log(Y,"Loading collection for active cloud: "+JSON.stringify(t));var i={getAccessToken:y.getAccessToken,USER_ID:o,STORAGE_HOSTNAME:c.getValue("STORAGE_HOST")||c.getEnvironment().STORAGE_HOST,COLLABORATION_HOSTNAME:c.getValue("COLLAB_HOST")||c.getEnvironment().COLLAB_HOST,CC_IMAGE_HOSTNAME:c.getValue("CC_IMAGE_HOST")||c.getEnvironment().CC_IMAGE_HOST,CC_IMAGE_X_HOSTNAME:c.getValue("CC_IMAGE_X_HOST")||c.getEnvironment().CC_IMAGE_X_HOST,TYPEKIT_HOSTNAME:c.getValue("TYPEKIT_HOST")||c.getEnvironment().TYPEKIT_HOST};if(e)l.log(Y,"Error parsing cloud data: "+e);else{if(c.setValue("CLOUD_DATA_"+o,{activeCloud:t,numClouds:n}),!t)return i.CLOUD_INFO={switchingEnabled:n>1},void he(i);var r=t.features&&t.features.libraries,a=t.features&&t.features.files&&t.features.files.sync&&t.features.files.sync.uri,s=r&&r.storage&&r.storage.uri,p=r&&r.service&&r.service.uri,d=r&&r.view&&r.view.uri;if(!s)return l.log(Y,"Unexpected cloud data: expected features.libraries.storage.uri to be defined"),void S.reportError("UnexpectedCloudData","expected features.libraries.storage.uri to be defined");if(!p)return l.log(Y,"Unexpected cloud data: expected features.libraries.service.uri to be defined"),void S.reportError("UnexpectedCloudData","expected features.libraries.service.uri to be defined");i.CLOUD_ID=t.id,i.STORAGE_HOSTNAME=_.stripProtocolPrefix(s),i.COLLABORATION_HOSTNAME=_.stripProtocolPrefix(p),i.CLOUD_INFO={name:t.name,parameters:t.parameters,switchingEnabled:n>1,viewURI:_.stripProtocolPrefix(d),syncURI:a,useJumpToken:!1},he(i)}}var fe=!1;function me(e,t,n,o){if(!fe){var i=y.getUserId();i?(fe=!0,e?_e(t,n,o):y.hasEntitlement("cce_private",function(e){if(l.log(Y,"cc_private entitlement: "+e),!0===e)I.getActiveCloud(function(e,t,n){_e(e,t,n),S.reportEvent("getActiveCloud",{error:String(e),cloudId:t&&t.id,numClouds:n,cce_private:!0})});else if(!1===e)_e(null),I.getActiveCloud(function(e,t,n){S.reportEvent("getActiveCloud",{error:String(e),cloudId:t&&t.id,numClouds:n,cce_private:!1})});else{var t=c.getValue("CLOUD_DATA_"+i);_e(null,t&&t.activeCloud,t&&t.numClouds),S.reportEvent("getActiveCloud",{error:"UnknownEntitlement: could not determine cce_private entitlement",cloudId:t&&t.activeCloud&&t.activeCloud.id,numClouds:t&&t.numClouds})}})):y.clearUserId()}}function Ee(){D.getLoadedCollections().forEach(function(e){D.unloadLibraryCollection(e)}),ie={},fe=!1,E.collectionsUnloaded()}function ge(e,t,n){y.setProxyCredentials(e,t),L.setProxyCredentials(e,t),n&&y.hasEntitlement("cce_private",function(e){void 0===e?(y.clearUserId(),y.getUserId(),Ee(),me()):D.getLoadedCollections().forEach(function(e){"error"===e.syncState&&$(e)})})}var ye=new T;function ve(){var e,t="CCLibrary/"+u.getCodeVersion()+" "+r.platform()+"/"+r.arch()+"/"+r.release(),n={log:l.log,analytics:S,getNodeTunnelOptions:L.getNodeTunnelOptionsForURL,renditionGenerator:N.generate},o={ROOT_DIR:c.getValue("ROOT_DIR"),STORAGE_API_KEY:c.getEnvironment().CLIENT_ID,DEVICE_ID:y.getDeviceId(),DEVICE_DESCRIPTION:u.getDeviceDescription(),APP_DESCRIPTION:"LIBS-"+u.getCodeVersion(!0),USER_AGENT_HEADER:t,SHARED_LOCAL_STORAGE:!1,RENDITION_SIZES:c.getValue("RENDITION_SIZES")||{},FULL_RENDITION_CONFIG:c.getValue("FULL_RENDITION_CONFIG")||{},EXTERNAL_LINK_PREFETCH:c.getValue("EXTERNAL_LINK_PREFETCH")||{},SHARED_LOCAL_STORAGE_ANALYTICS:c.getValue("SHARED_LOCAL_STORAGE_ANALYTICS"),LOCALE:L.getOSLocale()},i=c.getValue("WHITELISTED_DOMAINS");i&&(o.WHITELISTED_DOMAINS=i),D.configure(n,o),O.updateInstallationMap(),ye.initialize(),P.storageInterface.onAcceptPushedBranch(function(e){var t=-1!==D.getLoadedCollections().indexOf(e.collection),n=e.collection.getLibraryById(e.id)===e;t&&n&&W(e)}),P.storageInterface.onDownloadRendition(function(e){X.broadcast("renditioncachechange",u.getElementRenditionCacheData(e))}),I.addListener("cloudChange",function(e,t,n){var o=t?t.id:w.DEFAULT_CLOUD_ID;D.getLoadedCollections().some(function(e){return e.cloudId===o})?l.log(Y,"Active cloud the same as already loaded"):(l.log(Y,"Active cloud changed"),Ee(),me(!0,e,t,n),S.reportEvent("cloudChange",{cloudId:o,numClouds:n}))});var a=!1;function s(e,t,n,o){R.sendToast({title:x.translate("LIBS_OPEN_IN_TITLE"),message:x.translate(e),key:t,data:n,overridable:o})}function p(e,t){var n={"ui.search_keyword":t.launchInfo.search_keyword,"event.context_guid":t.launchInfo.context_guid,"event.type":e,"event.category":"STOCK","event.subcategory":"Open-In","env.com.name":"stock_openin","consumer.name":t.launchInfo.appCode,"consumer.version":t.productInfo?t.productInfo.version:t.launchInfo.minVersion,"consumer.platform":r.platform(),"consumer.os_version":r.release(),"openin.element_id":t.launchInfo.elementRef,"openin.element_type":t.launchInfo.elementType,"openin.app_launch_status":t.productInfo?t.productInfo.isAlreadyRunning?"Running":"Launched":"Unknown"};t.error&&(n["event.error_desc"]=t.error),t.element&&(n["event.cloud_id"]=t.element.library.collection.cloudId,n["content.id"]=m.getElementStockId(t.element),n["content.status"]=m.getElementStockLicense(t.element),n["content.type"]=t.element.getPrimaryRepresentation().type),S.reportEvent("Library-Process-Open-In",n)}function d(e,t){l.log(Y,"Open Stock -  launch product "+e.elementRef),O.launch({appCode:e.appCode,minVersion:e.appVersion||"0",element:t,action:"openStock"},function(n,o){if(n)return l.log(Y,"Open Stock - Error opening product "+n),s("LIBS_OPEN_IN_PRODUCT_LAUNCH_FAILED_"+e.appCode),void p("error",{launchInfo:e,error:"Launch product failed",productInfo:o,element:t});l.log(Y,"Open Stock - Open request success"),p("useElement",{launchInfo:e,productInfo:o,element:t})})}A.addListener("libraryChange",function(t){e?a=!0:(Z(t),e=setTimeout(function(){a&&Z(),e=null,a=!1},c.getValue("CORE_SYNC_NOTIFICATION_DEBOUNCE")))}),A.addListener("bookmarkChange",function(){D.getLoadedCollections().forEach(function(e){e.isPublic||e.syncBookmarks()})}),A.addListener("fileSyncState",function(e,t){!function(e,t){if(te!==e){if(clearTimeout(ee),"normal"!==e){var n=c.getValue("CORE_SYNC_ANALYTICS_WAIT");ee=setTimeout(function(){S.reportEvent("fileSyncState",{state:e,isNotification:!!t,reportingDelay:n})},n)}te=e,D.isSyncingEnabled()&&"turned_off"===te?(l.log(Y,"Syncing disabled"),D.disableSyncing(),X.broadcast("environmentinfo",u.getEnvironmentData())):D.isSyncingEnabled()||"turned_off"===te||(l.log(Y,"Syncing enabled"),D.enableSyncing(),X.broadcast("environmentinfo",u.getEnvironmentData()),Z())}}(e,t)}),v.addListener("signOut",function(){Ee(),y.clearUserId()}),v.addListener("signIn",function(){me()}),v.addListener("proxySettingsChanged",function(e,t){ge(e,t,!0)}),v.getProxyCredentials(function(e,t){ge(e,t),me(),setTimeout(se,100)}),R.addListener("clickNotification",function(e){"LAUNCH_CC"===e&&O.launch({appCode:"ADCS",waitForCompletion:!1},function(e){e?l.log(Y,"Open Stock - Launch CC failed "+e):l.log(Y,"Open Stock - Successfully launched CC from user click")})}),C.addListener("stock.open.request",function(e){if(l.log(Y,"Open Stock - Recieved open request via ANS "+JSON.stringify(e)),e.state&&"new"!==e.state.toLowerCase())l.log(Y,"Open Stock - Message state not new. Returning");else{C.setState({id:e.id,state:"received"});var t=e.payload;if(p("response",{launchInfo:t}),!t.protocolVersion||!t.elementRef||!t.appCode)return l.log(Y,"Open Stock - ANS request corrupt "+JSON.stringify(e)),s("LIBS_OPEN_IN_DOWNLOAD_ERROR"),void p("error",{launchInfo:t,error:"ANS request corrupt"});if("1"!==t.protocolVersion.split(".")[0])return l.log(Y,"Open Stock - Unsupported protocol version from ans message "+t.protocolVersion),s("LIBS_OPEN_IN_UNSUPPORTED_PROTOCOL","LAUNCH_CC"),void p("error",{launchInfo:t,error:"Unsupported protocol version from ans message"});if(!D.isSyncingEnabled())return l.log(Y,"Open Stock - Sync Disabled."),s("LIBS_OPEN_IN_SYNC_DISABLED"),void p("error",{launchInfo:t,error:"Sync Disabled"});var n=O.appStatus({appCode:t.appCode,minVersion:t.appVersion||"0"});if("APP_NOT_INSTALLED"===n)return s("LIBS_OPEN_IN_NOT_INSTALLED_"+t.appCode,"LAUNCH_CC"),void p("notify",{launchInfo:t});if("NO_COMPATIBLE_VERSION"===n)return s("LIBS_OPEN_IN_NO_COMPATIBLE_VERSION_"+t.appCode,"LAUNCH_CC"),void p("notify",{launchInfo:t});s("LIBS_OPEN_IN_START_DOWNLOAD",null,null,!0),h.findElement(t.elementRef,function(e,n){if(e){l.log(Y,"Open Stock - Error from find element "+e);var o="COLLECTION_NOT_FOUND"===e?"LIBS_OPEN_IN_COLLECTION_NOT_FOUND":"LIBS_OPEN_IN_DOWNLOAD_ERROR";return s(o),void p("error",{launchInfo:t,error:o})}l.log(Y,"Open Stock -  downloading element "+t.elementRef),n.library.sync(function(e){if(e)return l.log(Y,"Open Stock - Error downloading element "+e),s("LIBS_OPEN_IN_DOWNLOAD_ERROR"),void p("error",{launchInfo:t,error:"Download Failed"});F.prefetchRenditionsForElement(n,function(e){if(e)return l.log(Y,"Open Stock - Error downloading element "+e),s("LIBS_OPEN_IN_DOWNLOAD_ERROR"),void p("error",{launchInfo:t,error:"Download Failed"});E.libraryChanged(n.library,!1),E.isSyncing()?(l.log(Y,"Open Stock -  waiting for product bridge to update "+t.elementRef),E.addListener("syncEnd",function e(){E.isSyncing()||(E.removeListener("syncEnd",e),d(t,n))})):d(t,n)})})})}}),C.addListener("sharing.collaboration.updaterole",function(){D.getLoadedCollections().forEach(function(e){e.isPublic||$(e,!0)})}),C.addListener("com.adobe.system.inform.typekit.generic.entitlementschanged",function(){D.getLoadedCollections().forEach(function(e){e.isPublic||(e.fontManager._clearCache(),X.broadcast("fontcachechanged",u.getCollectionData(e)))})}),L.addListener("change",function(e){e&&v.getProxyCredentials(function(e,t){ge(e,t,!0)})}),L.addListener("error",function(e){S.reportError("ProxyResolverError",e)})}N.test(function(){}),d.obtainProcessLock("lockfile",function(e){e||H?L.getRootCA(function(e,t){if(t&&t.length>0){var o=n(26).globalAgent.options;o.ca=(o.ca||[]).concat(t)}if(H)return console.log("Testing OK"),void process.exit(0);ve()}):process.exit(1)}),e.exports={shutdown:function(){j.forEach(e=>e.close()),v.removeAllListeners(),A.removeAllListeners(),C.removeAllListeners(),I.removeAllListeners(),L.removeAllListeners(),ye.shutdown(),D.removeLoadedCollectionsListener(oe),P.storageInterface.removeOnAcceptPushedBranchListeners(),Ee()},loadPublicCollection:ue,unloadCollections:Ee,handleUncaughtException:G}},function(e,t,n){var o=n(3),i=n(6);function r(e,t,n){e?this._setData(e):this._data={},this._readOnly=t,this._isRoot=n}r.ROOT_PATH="/",Object.defineProperties(r.prototype,{id:{get(){return this._data.id},set(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(){return this._data.name},set(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(){return this._data.type},set(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(){return this._data.rel},set(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(){return this._isRoot?"/":this._data.path},set(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&&!i.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(){return this._parentPath},set(){throw new o(o.READ_ONLY,"parentPath is read-only.")}},absolutePath:{get(){var e=this.path;return this._isRoot?e:e&&this._owner?i.appendPathElements(this._parentPath,e):void 0},set(){throw new o(o.READ_ONLY,"absolutePath is read-only.")}},isRoot:{get(){return this._isRoot},set(){throw new o(o.READ_ONLY,"isRoot is read-only.")}}}),r.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},r.prototype.setLink=function(e,t){if(this._readOnly)throw new o(o.READ_ONLY,"This object is read-only.");if("object"!=typeof 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()},r.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 a={components:!0,children:!0,"manifest-format-version":!0,id:!0,name:!0,type:!0,state:!0,local:!0},s={components:!0,children:!0,rel:!0,path:!0,id:!0,name:!0,type:!0};r.prototype.getCustomKeys=function(){var e,t=[],n=Object.keys(this._data),o=n.length;for(e=0;e<o;e++){var i=n[e];(this._isRoot?a[i]:s[i])||t.push(i)}return t},r.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]},r.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()},r.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()},r.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 r(JSON.parse(JSON.stringify(this._data)))}finally{t&&(this._data.children=t),n&&(this._data.components=n)}return e},r.prototype.isEqualTo=function(e,t,n){return this._isEqual(this._data,e._data,i.merge({children:!0,components:!0},t),n)},r.prototype._isEqual=function(e,t,n,o){var r,a,s,c,l,p,d;if(!i.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(r=0;r<c;r++){for(l=a[r],p=null,d=0;d<c;d++)if(l.id===s[d].id){p=s[d];break}if(!p)return!1;if(!i.objectsEqual(l,p,o))return!1}if(a=e.children,s=t.children,(c=a?a.length:0)!==(s?s.length:0))return!1;if(c)for(r=0;r<c;r++)if(!this._isEqual(a[r],s[r],n,o))return!1;return!0},r.prototype._setData=function(e){var t=this._verify(e);if(null===t)return this._data=e,this;throw t},r.prototype._verify=function(e){return"string"!=typeof e.id?new o(o.INVALID_DATA,"Node is missing an id of type string"):null},r.prototype._setDirty=function(){this._owner&&this._owner._setDirty()},e.exports=r},function(e,t){e.exports=require("crypto")},function(e,t,n){var o=n(46),i=n(3),r=n(6);function a(e,t,n){(this._owner=t,e)?e=this._setData(e,n):(e={id:r.generateUuid()},this._core=new o(e,this,n),this._data=e)}Object.defineProperties(a.prototype,{rootNode:{get(){return this._core.rootNode},set(e){this._core.rootNode=e}},name:{get(){return this._core.rootNode.name},set(e){var t=this._core;if(t._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("string"!=typeof e&&void 0!==e)throw new i(i.INVALID_PARAMS,"Expecting a string or undefined.");t.rootNode.name=e}},type:{get(){return this._core.rootNode.type},set(e){var t=this._core;if(t._readOnly)throw new i(i.READ_ONLY,"This object is read-only.");if("string"!=typeof e||""===e)throw new i(i.INVALID_PARAMS,"Expecting a non-empty string.");t.rootNode.type=e}},compositeHref:{get(){return this._owner.compositeHref},set(){throw new i(i.READ_ONLY,'Property "compositeHref" is read-only.')}},_localStorage:{get(){return this._core._localStorage},set(e){this._core._localStorage=e}},hasLocalStorage:{get(){return this._core.hasLocalStorage},set(e){this._core.hasLocalStorage=e}},_isDirty:{get(){return this._core._isDirty},set(e){this._core._isDirty=e}},isDirty:{get(){return this._isDirty},set(e){this._core.isDirty=e}},changeCount:{get(){return this._core.changeCount},set(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,o){return this._core.addChild(e,t,n,o)},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,o,i,r){return this._core.copyChild(e,t,n,o,i,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,o,i,r,a,s,c,l){return this._core.addComponent(e,t,n,o,i,r,a,s,c,l)},a.prototype.addComponentWithUploadResults=function(e,t,n,o,i){return this._core.addComponentWithUploadResults(e,t,n,o,i)},a.prototype.updateComponent=function(e,t,n,o){return this._core.updateComponent(e,t,n,o)},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,o,i){return this._core.copyComponent(e,t,n,o,i)},a.prototype.assetOfComponent=function(e,t){return this._core.assetOfComponent(e,t)},a.prototype.parse=function(e){if("string"!=typeof e)throw new i(i.INVALID_PARAMS,'Param "data" must be a string');var t=null;try{t=JSON.parse(e)}catch(e){throw new i(i.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 i(i.READ_ONLY,"This object is read-only.");if(!this._localStorage)throw new i(i.NO_LOCAL_STORAGE,"No local storage.");if(!e._localStorage)throw new i(i.NO_LOCAL_STORAGE,"No local storage for source.");if(this._localStorage.compositePath!==e._localStorage.compositePath)throw new i(i.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 i(i.INVALID_DATA,"Element is missing an id of type string"):"string"!=typeof e.name?new i(i.INVALID_DATA,"Element is missing a name of type string"):"string"!=typeof e.type?new i(i.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 o(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 o=n(3),i=n(6),r=n(15);function a(e,t){if("string"!=typeof e||""===e)throw new o(o.INVALID_PARAMS,'Param "compositePath" must be a non-empty string.');this._compositePath=e,this._preserveFileExtensions=t,this._inMemoryBranchesAndElements=[],this._inflightComponents=[]}Object.defineProperties(a.prototype,{compositePath:{get(){return this._compositePath},set(e){if("string"!=typeof e||""===e)throw new o(o.INVALID_PARAMS,'Param "compositePath" must be a non-empty string.');this._compositePath=e}}}),a.prototype.currentManifestPath=function(){return this._compositePath+"/manifest"},a.prototype.currentBaseManifestPath=function(){return this._compositePath+"/manifest.base"},a.prototype.pulledManifestPath=function(){return this._compositePath+"/pull.manifest"},a.prototype.pushedManifestPath=function(){return this._compositePath+"/push.manifest"},a.prototype.resolvePulledBranch=function(e,t){var n=this;r.writeFileAtomically(this.currentManifestPath(),e.localData,"utf8",function(e){e?(e.code!==o.OUT_OF_SPACE&&(e=new o(o.INVALID_STATE,"Could not write current manifest.",e)),t(e)):r.move(n.pulledManifestPath(),n.currentBaseManifestPath(),!1,function(e){e?t(new o(o.INVALID_STATE,"Could not move pull manifest.",e)):t()})})},a.prototype.acceptPushedBranch=function(e,t){var n=this;r.writeFileAtomically(this.currentManifestPath(),e.localData,"utf8",function(e){e?(e.code!==o.OUT_OF_SPACE&&(e=new o(o.INVALID_STATE,"Could not write current manifest.",e)),t(new o(o.INVALID_STATE,"Could not write current manifest.",e))):r.move(n.pushedManifestPath(),n.currentBaseManifestPath(),!1,function(e){e?t(new o(o.INVALID_STATE,"Could not move push manifest.",e)):n._deleteJournal(t)})})},a.prototype.discardPulledBranch=function(e){r.deleteFile(this.pulledManifestPath(),e)},a.prototype.discardPushedBranch=function(e){var t=this;r.deleteFile(this.pushedManifestPath(),function(n){n?e(n):t._deleteJournal(e)})},a.prototype.discardBaseBranch=function(e){r.deleteFile(this.currentBaseManifestPath(),e)},a.prototype.registerInMemoryBranchOrElement=function(e){if(this._inMemoryBranchesAndElements.indexOf(e)>=0)throw new o(o.INVALID_STATE,"Branch or element is already registered.");this._inMemoryBranchesAndElements.push(e)},a.prototype.unregisterInMemoryBranchOrElement=function(e){var t=this._inMemoryBranchesAndElements.indexOf(e);if(t<0)throw new o(o.INVALID_STATE,"Unknown branch or element.");this._inMemoryBranchesAndElements.splice(t,1)},a.prototype._deleteJournal=function(e){r.deleteFile(this.pushJournalPath(),e)};var s=/(\/)|(\.$)/;a.prototype.componentAssetName=function(e,t){var n=t["copyOnWrite#storageIds"],o=n?n[e.id]:null;return o&&s.test(o)&&(o=null),o},a.prototype.componentAssetPath=function(e,t){var n=this.componentAssetName(e,t);return n?this._componentPathFromName(n):null},a.prototype.ingestComponentAsset=function(e,t,n,i,a){var s=this,c=this._newFileNameForComponent(e),l=this._componentPathFromName(c);this._inflightComponents.push(c);var p=function(t){if(!t)try{s._setComponentName(e,i,c)}catch(e){t=e}var n=s._inflightComponents.indexOf(c);n<0&&!t&&(t=new o(o.INVALID_STATE,"Could not find inflight component.")),s._inflightComponents.splice(n,1),a(t)};n?r.copyFile(t,l,p):r.move(t,l,!0,p)},a.prototype.removeComponentAsset=function(e,t){var n=t["copyOnWrite#storageIds"];n&&delete n[e.id]},a.prototype.componentIds=function(e){var t=e["copyOnWrite#storageIds"];return t?Object.keys(t):[]},a.prototype.copyLocalStorageData=function(e,t,n,o){var i,r=n.allComponents(),a=r.length,s=t["copyOnWrite#storageIds"];if(s){var c=o["copyOnWrite#storageIds"];for(c||(c=o["copyOnWrite#storageIds"]={}),i=0;i<a;i++){var l=r[i],p=l.id,d=e.getComponentWithId(p);if(d&&d.etag===l.etag){var u=s[p];u&&(c[p]=u)}}}},a.prototype.removeUnusedLocalFiles=function(e,t){var n,i,a,s,c,l=this,p=function(e){l._deleteComponentAsset(e,function(e){e&&!n&&(n=e),0===--c&&t(n)})},d=function(){try{var e,n=s.length,o=[];for(e=0;e<n;e++){var r=s[e].name,d=s[e].info;!i[r]&&d.mtime.getTime()<a&&l._inflightComponents.indexOf(r)<0&&o.push(r)}if((c=n=o.length)>0)for(e=0;e<n;e++)p(o[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 o(o.INVALID_STATE,r<1?"No manifest found.":"Invalid time stamp");i=c,a=l}catch(t){e=t}e&&(n=e),s&&(n?t(n):d())}}),r.directoryListing(this._compositePath+"/components",function(e,o){if(n)t(n);else{if(!e)try{s=o}catch(t){e=t}e&&(n=e),i&&(n?t(n):d())}})},a.prototype.tempPathForComponent=function(){return this._compositePath+"/tmp/"+i.generateUuid()},a.prototype.deleteTempFiles=function(e){r.deleteDirectory(this._compositePath+"/tmp",e)},a.prototype.clientDataPath=function(){return this._compositePath+"/clientdata"},a.prototype.pushJournalPath=function(){return this._compositePath+"/push.journal"},a.prototype._copyComponentMapping=function(e,t,n,o){var i=t["copyOnWrite#storageIds"];if(i){var r=o["copyOnWrite#storageIds"];r||(r=o["copyOnWrite#storageIds"]={});var a=i[e];return a&&(r[n]=a),a}},a.prototype._componentPathFromName=function(e){return this._compositePath+"/components/"+e},a.prototype._newFileNameForComponent=function(e){var t=i.generateUuid();if(this._preserveFileExtensions){var n=e.path?i.filePathComponents(e.path).extension:null;n&&(t=t+"."+n)}return t},a.prototype._setComponentName=function(e,t,n){var o=t["copyOnWrite#storageIds"];o||(o=t["copyOnWrite#storageIds"]={}),o[e.id]=n},a.prototype._gatherComponentAssetNames=function(e,t,n){try{var o,a,s={},c=t||i.timeStamp(!0),l=e.length,p=l,d=0,u=function(e){if(e){e=e["copyOnWrite#storageIds"];var t,n=Object.keys(e);for(t=0;t<n.length;t++){var o=e[n[t]];s[o]=!0}}},h=function(e){r.exists(e,function(t){t?(d++,r.info(e,function(t,o){if(!t)try{var i=o.mtime.getTime();i<c&&(c=i),r.readFile(e,"utf8",function(e,t){if(p--,!e)try{t=JSON.parse(t),u(t.local)}catch(t){e=t}e&&!a&&(a=e),0===p&&n(a,d,s,c)})}catch(e){t=e}t&&(p--,a||(a=t),0===p&&n(a))})):0===--p&&n(a,d,s,c)})};for(o=0;o<l;o++)h(e[o]);for(l=this._inMemoryBranchesAndElements.length,o=0;o<l;o++)u(this._inMemoryBranchesAndElements[o]._local())}catch(e){n(e)}},a.prototype._deleteComponentAsset=function(e,t){r.deleteFile(this._componentPathFromName(e),t)},e.exports=a},function(e,t,n){var o=n(41),i=n(3),r=n(6),a=r.appendPathElements;function s(e,t){if(o.call(this,e,t),!this._endPoint)throw new i(i.INVALID_PARAMS,"Could not determine endpoint from: "+t);this.authenticationWhitelist=["adobe.com","adobe.io","fotolia.net"]}s.prototype=Object.create(o.prototype),s.prototype.name="AdobeCommunitySession",s.FileContent=o.FileContent,s.StreamProvider=o.StreamProvider,s.prototype.getCompositeManifestHref=function(e){var t=this._resolveUrl(e.href);if(!t)throw new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+t);return a(t,"manifest")},s.prototype.getComponent=function(e,t,n){var o=this.getComponentHref(e,e.version);return this.getAsset(o,void 0,t,n)},s.prototype.getRenditionOfComponent=function(e,t,n,o,i,r){var a=this.getComponentRenditionHref(e,e.version,t,n,o);return this.getAsset(a,{accept:t},i,r)},s.prototype.getCompositeManifest=function(e,t,n){var o=e.href;return o&&(o=this._resolveUrl(o)),o?(o=a(o,"manifest"),this.getAssetAsType(o,"text",t,n)):n(new i(i.WRONG_ENDPOINT,"Wrong endpoint: "+o))},s.prototype.headRequest=function(e,t){return this._service.invoke("HEAD",e,{},void 0,void 0,function(e,n){if(e)return t(e);t(e,n)})},s.prototype.getComponentHref=function(e,t){var n,o=e._owner;if(!o||!o.compositeHref)throw new i(i.INVALID_STATE,"Component must be part of a branch of a bound composite.");return o._core&&(n=o._core._getSourceHrefOfComponent(e)),n||this._constructComponentHref(o.compositeHref,e,t)},s.prototype.getComponentRenditionHref=function(e,t,n,o,r){var a=e._owner;if(!a||!a.compositeHref)throw new i(i.INVALID_STATE,"Component must be part of a branch of a bound composite.");if(a._core&&a._core._getSourceHrefOfComponent(e))throw new i(i.INVALID_STATE,"Getting a rendition of a source href not implemented.");return this._constructComponentRenditionHref(a.compositeHref,e,t,n,o,r)},s.prototype._constructComponentHref=function(e,t,n){var o=t.absolutePath.slice(1),i=a(this._resolveUrl(e),o);return i&&void 0!==n&&(this._hrefUsesContentApis(e)?i+="/version/"+n:i+="?version="+n),i};var c=/^\/?content\/2\/[^/]+\/[^/]+/,l=/^\/?api\/v2\/[^/]+\/assets\/[^/]+/,p={"image/jpeg":"jpg","image/png":"png"};s.prototype._constructComponentRenditionHref=function(e,t,n,o,a,s){var d,u,h=t.absolutePath.slice(1),_=r.parseURI(e).path;if("/content/2/"===_.slice(0,"/content/2/".length)){var f=p[o];if(!f)throw new i(i.INVALID_PARAMS,"Unsupported rendition media type: "+o);if(!((d=c.exec(_))&&d.length>0))throw new i(i.INVALID_PARAMS,"Failed to parse composite href: "+e);u=this._resolveUrl(r.appendPathElements(d[0],"rendition",h,"version",n,"format",f,"dimension",a,"size",String(s)))}else{if(!((d=l.exec(_))&&d.length>0))throw new i(i.INVALID_PARAMS,"Failed to parse composite href: "+e);u=this._resolveUrl(r.appendPathElements(d[0],"rendition",a,String(s),h)+"?version="+n)}return u},s.prototype._hrefUsesContentApis=function(e){return"/content/2/"===r.parseURI(e).path.slice(0,"/content/2/".length)},e.exports=s},function(e,t){e.exports=require("image-size")},function(e,t,n){var o=n(11),i=n(8),r={getCollectionBookmarksData:function(e){var t=[];return e.bookmarks&&e.bookmarks.forEach(function(e){t.push({_id:e.id,_url:e.url})}),{isPublic:e.isPublic,userId:e.userId,cloudId:e.cloudId,bookmarks:t}},validateBookmarks:function(){var e=[];o.getLoadedCollections().forEach(function(t){t.isPublic||(e=e.concat(t.bookmarks))}),e.forEach(function(e){o.getLoadedCollections().forEach(function(t){t.isPublic&&!t.getLibraryById(e.id)&&t.canLoadLibrary(e.url)&&t.loadLibrary(e.id,e.url,function(t,n){t?i.log("BookmarkUtil","Error loading a public library: "+e.id+" url: "+e.url+" error: "+t):n&&delete n._loadedExternally})})}),o.getLoadedCollections().forEach(function(e){e.isPublic&&e.libraries.forEach(function(t){t._loadedExternally||(o.getLoadedCollections().some(function(e){return!e.isPublic&&e.findBookmark(t)})||e.unloadLibrary(t,function(e){e&&i.log("BookmarkUtil","Error unloading a public library: "+e)}))})})},sendBookmarksChanged:function(e){o.getLoadedCollections().forEach(function(t){t.isPublic||e.broadcast("bookmarkschanged",r.getCollectionBookmarksData(t))})}};e.exports=r},function(e,t,n){var o=n(1),i=n(2),r=n(18),a=n(16),s=n(5);function c(e,t){this._library=e,this._listenerManager=new s(["change"]),this._setDCXNode(t)}c.prototype._setDCXNode=function(e){this._dcxNode=e,this._deletedLocally=!1},c.prototype._getEventData=function(e){return this._dcxNode.getValue(o[e+"_DATA_KEY"])||{}},c.prototype._getEventContext=function(e){var t=JSON.parse(JSON.stringify(this._getEventData(e)));return delete t.deviceId,delete t.userId,t},c.prototype._isLocalEvent=function(e){var t=this._getEventData(e).deviceId;if(t&&o.DEVICE_ID)return t===o.DEVICE_ID},c.prototype._markDeletedLocally=function(e){this._deletedLocally=e,e&&this._listenerManager.removeAll()},c.prototype._commit=function(){this._updateModifiedTime(),this._library._commit(),this._listenerManager.notify("change"),r.reportUpdateGroup(this)},c.prototype._commitMetadata=function(){this._library._commit(),this._listenerManager.notify("change")},c.prototype._updateCreatedTime=function(){var e=(new Date).valueOf();this._dcxNode.setValue(o.CREATED_KEY,e),this._dcxNode.setValue(o.MODIFIED_KEY,e),this._setEventData("CREATED"),this._setEventData("MODIFIED")},c.prototype._updateModifiedTime=function(){var e=(new Date).valueOf();this._dcxNode.setValue(o.MODIFIED_KEY,e),this._setEventData("MODIFIED")},c.prototype._toJSON=function(){return{id:this.id,classifierName:this.classifierName,name:this.name,order:this.order}},c.prototype.toString=function(){return JSON.stringify(this._toJSON())},c.prototype.jasmineToString=function(){return this.toString()},c.prototype._setEventData=function(e){if(o.DEVICE_ID){var t={userId:this.library.collection.userId,deviceId:o.DEVICE_ID};o.DEVICE_DESCRIPTION&&(t.device=o.DEVICE_DESCRIPTION),o.APP_DESCRIPTION&&(t.app=o.APP_DESCRIPTION),this._dcxNode.setValue(o[e+"_DATA_KEY"],t)}else this._clearEventData(e)},c.prototype._clearEventData=function(e){this._dcxNode.getValue(o[e+"_DATA_KEY"])&&this._dcxNode.removeValue(o[e+"_DATA_KEY"])},Object.defineProperties(c.prototype,{id:{get(){return this._dcxNode.id},set(){throw new i(i.READ_ONLY,"Cannot change the id of an existing group",this._library.id)}},library:{get(){return this._library},set(){throw new i(i.READ_ONLY,"library is a read-only property",this._library.id)}},name:{get(){return this._dcxNode.name},set(e){if(a.checkDeletedState(this),!this.isWritable)throw new i(i.NOT_ALLOWED,"you do not have write access to this library",this._library.id);this._dcxNode.name=e,this._commit()}},classifierName:{get(){return this._dcxNode.getValue(o.CLASSIFIER_KEY)},set(){throw new i(i.READ_ONLY,"classifierName is a read-only property",this._library.id)}},order:{get(){return this._dcxNode.getValue(o.ORDER_KEY)},set(e){if(!this.isWritable)throw new i(i.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if("string"!=typeof e)throw new i(i.INVALID_PARAMETER,"order must be a string",this._library.id);this._dcxNode.setValue(o.ORDER_KEY,e),this._commitMetadata(),r.reportUpdateGroupMetadata(this,e)}},isWritable:{get(){return this._library.isWritable},set(){throw new i(i.READ_ONLY,"isWritable is a read-only property",this.id)}},created:{get(){return this._dcxNode.getValue(o.CREATED_KEY)},set(){throw new i(i.READ_ONLY,"Cannot change the created timestamp of a group directly",this._library.id)}},createdBy:{get(){return this._getEventData("CREATED").userId},set(){throw new i(i.READ_ONLY,"Cannot change the createdBy property of a group directly",this._library.id)}},createdContext:{get(){return this._getEventContext("CREATED")},set(){throw new i(i.READ_ONLY,"Cannot change the createdContext property of a group directly",this._library.id)}},wasCreatedLocally:{get(){return this._isLocalEvent("CREATED")},set(){throw new i(i.READ_ONLY,"Cannot change the wasCreatedLocally property of a group directly",this._library.id)}},modified:{get(){return this._dcxNode.getValue(o.MODIFIED_KEY)},set(){throw new i(i.READ_ONLY,"Cannot change the modified timestamp of a group directly",this._library.id)}},modifiedBy:{get(){return this._getEventData("MODIFIED").userId},set(){throw new i(i.READ_ONLY,"Cannot change the modifiedBy property of a group directly",this._library.id)}},modifiedContext:{get(){return this._getEventContext("MODIFIED")},set(){throw new i(i.READ_ONLY,"Cannot change the modifiedContext property of a group directly",this._library.id)}},wasModifiedLocally:{get(){return this._isLocalEvent("MODIFIED")},set(){throw new i(i.READ_ONLY,"Cannot change the wasModifiedLocally property of a group directly",this._library.id)}},isDeletedLocally:{get(){return this._deletedLocally},set(){throw new i(i.READ_ONLY,"isDeletedLocally is a read-only property",this._library.id)}}}),c.prototype.addChangeListener=function(e){a.checkDeletedState(this),this._listenerManager.add("change",e)},c.prototype.removeChangeListener=function(e){this._listenerManager.remove("change",e)},Object.freeze(c),Object.seal(c.prototype),e.exports=c},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,n){var o=n(0),i=n(1),r=n(95),a=n(18),s=n(2),c=n(96),l=n(31),p=n(23),d=n(16),u=n(9),h=n(13),_=n(12),f=n(30),m=n(5);function E(e,t){this._library=e,this._renditionCache={},this._renditionCacheLock=new p,this._renditionFetchLock=new p,this._listenerManager=new m(["change"]),this._transactionCount=0,this._setDCXNode(t)}E.prototype._setDCXNode=function(e,t,n){var o=this,i={};this._representations&&this._representations.forEach(function(e){i[e.id]=e}),this._dcxNode=e,this._representations=[],this._deletedLocally=!1,this._library._dcxBranch.getChildrenOf(e).forEach(function(e){var t=i[e.id];t?(t._setDCXNode(e),delete i[e.id]):t=new r(o,e),o._representations.push(t)}),this._library._dcxBranch.getComponentsOf(e).forEach(function(e){var t=i[e.id];t?(t._setDCXComponent(e),delete i[e.id]):t=new r(o,void 0,e),o._representations.push(t)}),d.sortRepresentations(this._representations),n||this._clearRenditionCache(t,!1),this._displayName=void 0},E.prototype._markDeletedLocally=function(e){this._deletedLocally=e,this._representations.forEach(function(t){t._markDeletedLocally(e)}),e&&this._listenerManager.removeAll()},E.prototype._removeAllListeners=function(){this._listenerManager.removeAll()},E.prototype._toJSON=function(){var e={id:this.id,name:this.name,type:this.type,description:this.description,representations:[]};return this._representations.forEach(function(t){e.representations.push(t._toJSON())}),e.representations.sort(function(e,t){return e.type>t.type?1:e.type<t.type?-1:0}),e},E.prototype._addRepresentation=function(e,t){void 0!==t?this._representations.splice(t,0,e):this._representations.push(e)},E.prototype._removeRepresentation=function(e){var t=this._representations.indexOf(e);-1!==t&&this._representations.splice(t,1)},E.prototype._validateRelationship=function(e){if(-1===i.VALID_RELATIONS.indexOf(e))throw new s(s.INVALID_PARAMETER,"Unsupported relationship",this._library.id);this._representations.length>0&&"primary"===e&&this._representations.forEach(t=>{if(t!==e&&"primary"===t.relationship)throw new s(s.INVALID_PARAMETER,"Cannot have more than one primary representation",this._library.id)})},E.prototype._doCreateRepresentation=function(e,t,n){var o=this._library._dcxBranch.addChild(void 0,void 0,void 0,this._dcxNode);if(o.type=e,o.setValue(i.RELATIONSHIP_KEY,t),void 0===n){var a=this.representations[this.representations.length-1],s=Math.max(this.representations.length,a?a._getOrder()+1:0);o.setValue(i.REPRESENTATION_ORDER_KEY,s)}else o.setValue(i.REPRESENTATION_ORDER_KEY,n),this._representations.forEach(function(e,t){if(t>=n){var o=e._getDCXElement(),r=o.getValue(i.REPRESENTATION_ORDER_KEY);void 0!==r&&o.setValue(i.REPRESENTATION_ORDER_KEY,r+1)}});var c=new r(this,o);return this._addRepresentation(c,n),c},E.prototype._lookupRenditionPath=function(e){var t=o.getPathSeparator(),n=this._renditionCache[e];if(n){if(n===i.RENDITION_CACHE_PLACEHOLDER||_.isErrorCode(n))return n;var r=this._library._getRenditionCacheDir()+t+n;if(i.SHARED_LOCAL_STORAGE||o.fs.existsSync(r))return r}},E.prototype._getNewRenditionPath=function(e,t){var n=this,i=o.getPathSeparator(),r=this._library._getRenditionCacheDir();u.ensurePathExists(r,function(a){if(!d.checkDeletedState(n,t)){var s=o.uuid()+"."+(e||"png");t(a,r+i+s,s)}})},E.prototype._getEventData=function(e,t){var n=!t&&{},o=this._dcxNode.getValue(i[e+"_DATA_KEY"])||n;if("CREATED"!==e&&"DESCRIPTION"!==e){var r=this._dcxNode.getValue(i[e+"_KEY"]);r&&r===o.time||(o=n)}return o},E.prototype._isLocalEvent=function(e){var t=this._getEventData(e).deviceId;if(t&&i.DEVICE_ID)return t===i.DEVICE_ID},E.prototype._getEventContext=function(e){var t=JSON.parse(JSON.stringify(this._getEventData(e)));return delete t.time,delete t.deviceId,delete t.userId,t},E.prototype._clearEventData=function(e){this._dcxNode.getValue(i[e+"_DATA_KEY"])&&this._dcxNode.removeValue(i[e+"_DATA_KEY"])},E.prototype._setEventData=function(e,t){if(i.DEVICE_ID){var n={userId:this.library.collection.userId,deviceId:i.DEVICE_ID};i.DEVICE_DESCRIPTION&&(n.device=i.DEVICE_DESCRIPTION),i.APP_DESCRIPTION&&(n.app=i.APP_DESCRIPTION),t&&(n.time=t),this._dcxNode.setValue(i[e+"_DATA_KEY"],n)}else this._clearEventData(e)},E.prototype._updateModifiedTime=function(){var e=(new Date).valueOf();this._dcxNode.setValue(i.MODIFIED_KEY,e),this._setEventData("MODIFIED",e)},E.prototype._updateCreatedTime=function(){var e=(new Date).valueOf();this._dcxNode.setValue(i.CREATED_KEY,e),this._dcxNode.setValue(i.MODIFIED_KEY,e),this._setEventData("CREATED"),this._setEventData("MODIFIED",e)},E.prototype._updateTimestampOnRemove=function(e){var t=e||(new Date).valueOf();this._dcxNode.setValue(i.REMOVED_KEY,t),this._setEventData("REMOVED",t)},E.prototype._updateTimestampOnRestore=function(){this._dcxNode.removeValue(i.REMOVED_KEY),this._clearEventData("REMOVED")},E.prototype._ensureRemovedDataValid=function(e){this.removed&&!this._getEventData("REMOVED",!0)?e?this._setEventData("REMOVED",this.removed):this._clearEventData("REMOVED"):this.removed||this._clearEventData("REMOVED")},E.prototype._ensureModifiedDataValid=function(e){this._getEventData("MODIFIED",!0)||(e?this._setEventData("MODIFIED",this.modified):this._clearEventData("MODIFIED")),this._ensureRemovedDataValid(e)},E.prototype._ensureCreatedDataValid=function(e){e&&!this._getEventData("CREATED",!0)&&this._setEventData("CREATED"),this._ensureModifiedDataValid(e)},E.prototype._clearRenditionCache=function(e,t){var n=this,r=this._renditionCache;this._renditionCache={};var a=t&&i.SHARED_LOCAL_STORAGE&&f.supportsClearRenditionCache();Object.keys(r).forEach(function(t){!e&&!n.getRepresentationById(t)||_.isErrorCode(r[t])?a&&o.storageInterface.setRenditionCache(n,t,"CLEAR"):n._renditionCache[t]=r[t]})},E.prototype._commit=function(e){this._displayName=void 0,this._updateModifiedTime(),this._clearRenditionCache(!0,!0),this._listenerManager.notify("change"),this._library._commit(),a.reportUpdateElement(this,e)},E.prototype._commitMetadata=function(){this._listenerManager.notify("change"),this._library._commit()},E.prototype._commitRenditionCache=function(){this._listenerManager.notify("change"),this._library._commit(!0,!0)},E.prototype._setRenditionCache=function(e,t,n){this._renditionCache[e]=t,this._commitRenditionCache(),n&&(o.storageInterface.notifyDownloadRendition(this),this._listenerManager.notify("change"))},E.prototype._wrapOperation=function(e,t){return this._library._wrapOperation(function(){var n=this._library._wrapOperation(e,t);return this._updateModifiedTime(),this._listenerManager.notify("change"),n},this)},E.prototype._getMissingLocalComponents=function(){var e=[];return this._representations.forEach(function(t){e=e.concat(t._getMissingLocalComponents())}),e},E.prototype._shouldGCLocalData=function(){var e=(new Date).valueOf();return this.removed&&e-this.removed>=i.REMOVED_ELEMENTS_CACHE_TIMEOUT},E.prototype.jasmineToString=function(){return this.toString()},E.prototype._stripObsoleteGroupsData=function(e){var t=this._dcxNode.getValue(i.GROUPS_KEY);if(t){var n=(e=e||i.DEFAULT_GROUP_CLASSIFIER)+"#",o=!1;Object.keys(t).forEach(function(e){if(e.startsWith(n)){var i=e.substring(n.length);this.library.getGroupById(i)||(delete t[e],o=!0)}},this),o&&this._dcxNode.setValue(i.GROUPS_KEY,t)}},Object.defineProperties(E.prototype,{id:{get(){return this._dcxNode.id},set(){throw new s(s.READ_ONLY,"Cannot change the id of an existing element",this._library.id)}},library:{get(){return this._library},set(){throw new s(s.READ_ONLY,"library is a read-only property",this._library.id)}},isWritable:{get(){return this._library.isWritable},set(){throw new s(s.READ_ONLY,"isWritable is a read-only property",this.id)}},name:{get(){return this._dcxNode.name||""},set(e){if(d.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);this._dcxNode.name=e,this._commit(!0)}},displayName:{get(){return void 0===this._displayName&&(this._displayName=o.getDisplayName(this)||""),this._displayName},set(){throw new s(s.READ_ONLY,"displayName is a read-only property",this._library.id)}},type:{get(){return this._dcxNode.type},set(){throw new s(s.READ_ONLY,"Cannot change the type of an existing element",this._library.id)}},tags:{get(){return this._dcxNode.getValue("tags")||[]},set(e){if(d.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(!e||e.constructor!==Array)throw new s(s.INVALID_PARAMETER,"tags must be an array",this._library.id);if(!e.every(function(e){return"string"==typeof e}))throw new s(s.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._commit(!0)}},description:{get(){return this._dcxNode.getValue(i.DESCRIPTION_KEY)||""},set(e){if(d.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);this._dcxNode.setValue(i.DESCRIPTION_KEY,e);var t=(new Date).valueOf();this._setEventData("DESCRIPTION",t),this._commitMetadata(),a.reportSetDescription(this)}},descriptionModified:{get(){return this._getEventData("DESCRIPTION").time||0},set(){throw new s(s.READ_ONLY,"Cannot change the descriptionModified timestamp of an element directly",this._library.id)}},descriptionModifiedBy:{get(){return this._getEventData("DESCRIPTION").userId},set(){throw new s(s.READ_ONLY,"Cannot change the descriptionModifiedBy property of an element directly",this._library.id)}},descriptionModifiedContext:{get(){return this._getEventContext("DESCRIPTION")},set(){throw new s(s.READ_ONLY,"Cannot change the descriptionModifiedContext property of an element directly",this._library.id)}},wasDescriptionModifiedLocally:{get(){return this._isLocalEvent("DESCRIPTION")},set(){throw new s(s.READ_ONLY,"Cannot change the wasDescriptionModifiedLocally property of an element directly",this._library.id)}},modified:{get(){return this._dcxNode.getValue(i.MODIFIED_KEY)},set(){throw new s(s.READ_ONLY,"Cannot change the modified timestamp of an element directly",this._library.id)}},modifiedBy:{get(){return this._getEventData("MODIFIED").userId},set(){throw new s(s.READ_ONLY,"Cannot change the modifiedBy property of an element directly",this._library.id)}},modifiedContext:{get(){return this._getEventContext("MODIFIED")},set(){throw new s(s.READ_ONLY,"Cannot change the modifiedContext property of an element directly",this._library.id)}},wasModifiedLocally:{get(){return this._isLocalEvent("MODIFIED")},set(){throw new s(s.READ_ONLY,"Cannot change the wasModifiedLocally property of an element directly",this._library.id)}},created:{get(){return this._dcxNode.getValue(i.CREATED_KEY)},set(){throw new s(s.READ_ONLY,"Cannot change the created timestamp of an element directly",this._library.id)}},createdBy:{get(){return this._getEventData("CREATED").userId},set(){throw new s(s.READ_ONLY,"Cannot change the createdBy property of an element directly",this._library.id)}},createdContext:{get(){return this._getEventContext("CREATED")},set(){throw new s(s.READ_ONLY,"Cannot change the createdContext property of an element directly",this._library.id)}},wasCreatedLocally:{get(){return this._isLocalEvent("CREATED")},set(){throw new s(s.READ_ONLY,"Cannot change the wasCreatedLocally property of an element directly",this._library.id)}},removed:{get(){return this._dcxNode.getValue(i.REMOVED_KEY)},set(){throw new s(s.READ_ONLY,"Cannot change the removed timestamp of an element directly",this._library.id)}},removedBy:{get(){return this._getEventData("REMOVED").userId},set(){throw new s(s.READ_ONLY,"Cannot change the removedBy property of an element directly",this._library.id)}},removedContext:{get(){return this._getEventContext("REMOVED")},set(){throw new s(s.READ_ONLY,"Cannot change the removedContext property of an element directly",this._library.id)}},wasRemovedLocally:{get(){return this._isLocalEvent("REMOVED")},set(){throw new s(s.READ_ONLY,"Cannot change the wasRemovedLocally property of an element directly",this._library.id)}},representations:{get(){return this._representations},set(){throw new s(s.READ_ONLY,"Cannot modify representation list directly",this._library.id)}},isDeletedLocally:{get(){return this._deletedLocally},set(){throw new s(s.READ_ONLY,"isDeletedLocally is a read-only property",this._library.id)}}}),E.prototype.toString=function(){return JSON.stringify(this._toJSON())},E.prototype.addChangeListener=function(e){d.checkDeletedState(this),this._listenerManager.add("change",e)},E.prototype.removeChangeListener=function(e){this._listenerManager.remove("change",e)},E.prototype.beginOperation=function(){if(d.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this.id);this._transactionCount++,this._library._beginOperation()},E.prototype.endOperation=function(e){if(d.checkDeletedState(this),!this.isWritable)throw new s(s.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)},E.prototype.createRepresentation=function(e,t,n,o){if(d.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);return this._wrapOperation(function(){if(e===i.LINK_REPRESENTATION_TYPE)throw new s(s.INVALID_PARAMETER,"Cannot create external link representation directly - use setContentFromURL instead",this._library.id);if(void 0!==n&&(n<0||n>this._representations.length))throw new s(s.INVALID_PARAMETER,"Invalid index",this._library.id);this._validateRelationship(t);var r=this._doCreateRepresentation(e,t,n);return o||this._clearRenditionCache(!1,!0),r},this)},E.prototype.removeRepresentation=function(e){if(d.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);return this._wrapOperation(function(){this._removeRepresentation(e),e._dcxComponent?this._library._dcxBranch.removeComponent(e._dcxComponent):this._library._dcxBranch.removeChild(e._dcxNode),this._clearRenditionCache(!1,!0),e._markDeletedLocally(!0)},this)},E.prototype.removeAllRepresentations=function(){if(d.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);return this._wrapOperation(function(){for(;this._representations[0];)this.removeRepresentation(this._representations[0])},this)},E.prototype.getPrimaryRepresentation=function(){var e;return this._representations.forEach(function(t){e||"primary"!==t.relationship||(e=t)}),e},E.prototype.getValue=function(e,t){if(e===i.DL_NAMESPACE)throw new s(s.INVALID_PARAMETER,"Reserved namespace",this._library.id);var n=d.getDCXKey(e,t);return this._dcxNode.getValue(n)},E.prototype.getValues=function(){return d.getCustomDCXData(this._dcxNode)},E.prototype.setValue=function(e,t,n){if(d.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(e===i.DL_NAMESPACE)throw new s(s.INVALID_PARAMETER,"Reserved namespace",this._library.id);var o,r=d.getDCXKey(e,t);try{o=JSON.parse(JSON.stringify(n))}catch(e){throw new s(s.INVALID_PARAMETER,"Value cannot be serialized to JSON",this._library.id)}this._dcxNode.setValue(r,o),this._commit()},E.prototype._getRenditionCandidate=function(e){var t,n,o,i,r,a,s,c=0;if("vector"===e&&l.supportsVectorRendition(this))return this.getPrimaryRepresentation();for(n=0;n<this._representations.length&&(o=this._representations[n],i=Math.max(o.width||0,o.height||0),r=o.isFullSize?Number.POSITIVE_INFINITY:i,a="primary"===o.relationship,s="rendition"===o.relationship,(!t||o.isPreferredThumbnail&&!t.isPreferredThumbnail||a&&"primary"!==t.relationship||s&&"primary"!==t.relationship&&"rendition"!==t.relationship||s&&"rendition"===t.relationship&&r>c)&&h.canComputeRendition(o)&&(t=o,c=r),!s||"image/png"!==o.type||!e||i!==e);n++);return t},E.prototype.getThumbnailURL=function(e,t){var n=this;d.checkDeletedState(this,t)||this._library._waitForCommit(function(){if(!d.checkDeletedState(n,t)){var o=n._getRenditionCandidate(e);if(o)n._library._collection._syncManager.getSharedCloudRenditionUrl(o,e,t);else t(new s(s.THUMBNAIL_NOT_AVAILABLE,"no representation that can be converted into a thumbnail",n._library.id))}})},E.prototype.getAuthenticatedThumbnailURL=function(e,t){this.getThumbnailURL(e,function(e,n){e?t(e):this._library._collection._syncManager.appendAccessTokenToURL(n,t)}.bind(this))},E.prototype.getThumbnailPath=function(e,t){var n=this;o.hasFileSystem()?d.checkDeletedState(this,t)||this._library._waitForCommit(function(){if(!d.checkDeletedState(n,t))if(i.SHARED_LOCAL_STORAGE)o.storageInterface.getRenditionPath(n,e,t);else{var r=function(e,o){n._renditionFetchLock.release(),t(e,o)};n._renditionFetchLock.obtain(function(){if(!d.checkDeletedState(n,r)){var t=this._lookupRenditionPath(e||"full");if(t)r(null,t);else{var i=this._getRenditionCandidate(e);if(i){if("rendition"===i.relationship&&"image/png"===i.type&&e&&Math.max(i.width||0,i.height||0)===e)return void i.getContentPath(r);var a=this._library._collection._syncManager,c=this.modified,l=function(t,o){n.modified>c?r(new s(s.STALE_THUMBNAIL,"element changed before the rendition was received",n._library.id,t)):d.checkDeletedState(n,r)||(t?r(new s(s.THUMBNAIL_NOT_AVAILABLE,"error generating thumbnail",n._library.id,t)):n._doSetThumbnailCache(e,o,!0,!0,r))};o.hasRenditionGenerator()&&e&&"vector"!==e?i.getContentPath(function(t,n){if(!t&&n){var r=i.element.library.collection._getTempDir()+o.getPathSeparator()+o.uuid()+".png";o.renditionGenerator(n,r,e,function(t){t?a.getSharedCloudRendition(i,e,l):l(null,r)})}else a.getSharedCloudRendition(i,e,l)}):a.getSharedCloudRendition(i,e,l)}else r(new s(s.THUMBNAIL_NOT_AVAILABLE,"no representation that can be converted into a thumbnail",n._library.id))}}},n)}}):t(new s(s.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this._library.id))},E.prototype.getThumbnailContent=function(e,t,n){const i=o.fs;o.hasFileSystem()?d.checkDeletedState(this,n)||d.checkEncoding(t,["utf8","ascii","base64","buffer"],n)&&this.getThumbnailPath(e,(e,o)=>{if(!e&&o){if(!d.checkDeletedState(this,n)){var r=(e,t)=>{e&&(e=_.getCommitError(e,this._library.id,"error reading content from disk")),n(e,t)};"buffer"===t?i.readFile(o,r):i.readFile(o,t,r)}}else n(e)}):n(new s(s.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this._library.id))},E.prototype._doSetThumbnailCache=function(e,t,n,o,i){var r=this,a=function(e,t){r._renditionCacheLock.release(),i(e,t)};this._renditionCacheLock.obtain(function(){d.checkDeletedState(r,a)||this._getNewRenditionPath(u.getFileExtension(t),function(i,s,c){if(!d.checkDeletedState(r,a))if(i)a(_.getCommitError(i,r._library.id,"unable to create thumbnail cache directory"));else{r._library._pendingRenditionCacheItems[c]=!0;var l=function(t){d.checkDeletedState(r,a)||(t?a(_.getCommitError(t,r._library.id,"unable to write thumbnail to cache")):(r._setRenditionCache(e||"full",c,o),a(null,s)))};n?u.rename(t,s,l):u.copyFile(t,s,l)}})},this)},E.prototype.setThumbnailCache=function(e,t,n){"string"==typeof t?o.hasFileSystem()?d.checkDeletedState(this,n)||(i.SHARED_LOCAL_STORAGE?o.storageInterface.setRenditionCache(this,e,t,n):this._doSetThumbnailCache(e,t,!1,!1,n)):n(new s(s.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this._library.id)):n(new s(s.INVALID_PARAMETER,"path must be a string",this._library.id))},E.prototype._getActions=function(e){var t=this.getPrimaryRepresentation();if(!t)return[];var n=i.ELEMENT_ACTION_PRODUCT_MAP,o=[];((n.types[this.type]||{})[t.type]||[]).forEach(function(t){!n.products[t]||e&&e!==n.products[t].action||o.push(new c(this,n.products[t]))}.bind(this));var r=o.map(function(e,t){return{i:t,v:e}});return r.sort(function(e,t){return e.v.isCompatibleVersionInstalled&&!t.v.isCompatibleVersionInstalled?-1:t.v.isCompatibleVersionInstalled&&!e.v.isCompatibleVersionInstalled?1:e.i-t.i}),r.map(function(e){return e.v})},E.prototype.getActions=function(e){if(!i.SHARED_LOCAL_STORAGE)throw new s(s.NOT_SUPPORTED,"getActions() not supported without shared local storage");if(e&&-1===i.ELEMENT_ACTIONS.indexOf(e))throw new s(s.INVALID_PARAMETER,"Unknown id supplied. Potential ids are",i.ELEMENT_ACTIONS.join(", "));return this._getActions(e)},E.prototype.getGroups=function(e){e=e||i.DEFAULT_GROUP_CLASSIFIER;var t=this._dcxNode.getValue(i.GROUPS_KEY);if(!t)return[];var n=Object.keys(t);return this.library.getGroups(e).filter(function(e){return void 0!==this.getOrderInGroup(e)},this).sort(function(e,t){var o=n.indexOf(e.classifierName+"#"+e.id),i=n.indexOf(t.classifierName+"#"+t.id);return o===i?0:o<i?-1:1})},E.prototype.getOrderInGroup=function(e){if(!e)throw new s(s.INVALID_PARAMETER,"No group specified",this._library.id);if(e.library===this.library){var t=this._dcxNode.getValue(i.GROUPS_KEY)||{},n=e.classifierName+"#"+e.id;return t[n]&&t[n].order}},E.prototype._doSetOrderInGroup=function(e,t,n){var o=this._dcxNode.getValue(i.GROUPS_KEY)||{},r=e.classifierName+"#"+e.id;n&&Object.keys(o).forEach(function(t){t.startsWith(e.classifierName+"#")&&delete o[t]}),void 0===t&&o[r]&&delete o[r],void 0!==t&&(o[r]={order:t}),this._dcxNode.setValue(i.GROUPS_KEY,o),this._commitMetadata()},E.prototype.setOrderInGroup=function(e,t,n){if(n=!1!==n,d.checkDeletedState(this),!this.isWritable)throw new s(s.NOT_ALLOWED,"you do not have write access to this library",this._library.id);if(!e)throw new s(s.INVALID_PARAMETER,"No group specified",this._library.id);if(e.library!==this.library)throw new s(s.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 s(s.INVALID_PARAMETER,"order must be a string",this._library.id);this._doSetOrderInGroup(e,t,n),a.reportSetOrderInGroup(this,e,n)},E.prototype.getReference=function(){return"cloud-asset://"+this._library._collection._syncManager.getElementRefDomain()+this._library._collection._syncManager.getElementRefPath()+"/"+this._library.id+";node="+this.id},E.prototype.getRepresentationById=function(e){var t;return this.representations.forEach(function(n){n.id===e&&(t=n)}),t},Object.freeze(E),Object.seal(E.prototype),e.exports=E},function(e,t,n){var o=n(0),i=n(1),r=n(2),a=n(23),s=n(28),c=n(16),l=n(9),p=n(12),d=n(29),u=n(7),h=n(13),_=n(30),f=n(31);function m(e,t,n){this._element=e,t?this._setDCXNode(t):this._setDCXComponent(n),this._lock=new a,this._pendingDownloadCallbacks=[]}m.prototype._setDCXNode=function(e){this._dcxNode=e,delete this._dcxComponent,this._deletedLocally=!1},m.prototype._setDCXComponent=function(e,t){this._dcxComponent=e,delete this._dcxNode,t||(this._deletedLocally=!1)},m.prototype._markDeletedLocally=function(e){this._deletedLocally=e},m.prototype._toJSON=function(){var e={id:this.id,type:this.type,relationship:this.relationship};return o.hasFileSystem()&&(e._componentPath=this._getComponentPath()),e},m.prototype._getOrder=function(){return this._getDCXElement().getValue(i.REPRESENTATION_ORDER_KEY)||0},m.prototype._setComponentInBrowser=function(e,t,n){var o=this;this._element._library._collection._syncManager.uploadNewComponentForRepresentation(e,t,this,function(e,t){c.checkDeletedState(o,n)?n(e):e?n(e):(c.copyCustomDCXData(o._dcxNode,t),o._element._library._dcxBranch.removeChild(o._dcxNode),o._setDCXComponent(t,!0),o._commit(),n(null))})},m.prototype._setComponentFromPath=function(e,t,n){var i=this,r=e&&o.getFileNameFromPath(e),a=l.getFileExtension(r),s=this.id+"."+a;l.checkFileSize(e,function(a){a?n(a):l.getImageDimensions(e,function(a){o.storageInterface.notifyStartWrite(i._element._library,[],function(){var o=i._element._library._dcxBranch;o.addComponent(r,i.type,i.relationship,s,e,t,void 0,i._element._dcxNode,i.id,function(e,t){c.checkDeletedState(i,n)||(e?n(e):(c.copyCustomDCXData(i._dcxNode,t),o.removeChild(i._dcxNode),i._setDCXComponent(t,!0),a&&(t.setValue("width",a.width),t.setValue("height",a.height)),i._commit(),n(null)))})})})})},m.prototype._setComponent=function(e,t,n,i){var r,a=o.fs,d=this;function u(e){c.checkDeletedState(d,i)||(e?i(p.getCommitError(e,d._element._library.id,"error writing representation contents")):d._setComponentFromPath(r,!1,i))}var h=this.element.library.collection._getTempDir();l.ensurePathExists(h,function(l){if(!c.checkDeletedState(d,i))if(l)i(p.getCommitError(l,d._element._library.id,"error creating temp directory"));else{if(!n){var _=s.getExtensions(d.type)[0];n=d.id+"."+_}r=h+o.getPathSeparator()+n,"buffer"===t?a.writeFile(r,e,u):a.writeFile(r,e,t,u)}})},m.prototype._getCurrentComponentPath=function(){if(this._dcxComponent)return this._element._library._dcxBranch.assetOfComponent(this._dcxComponent)},m.prototype._getComponentPath=function(e,t){var n=this;if(!e)return this._getCurrentComponentPath();if(this.isExternalLink)this._getExternalLinkPath(!1,e);else if(this._dcxComponent){var o=this._getCurrentComponentPath();if(o||t)e(null,o);else{var i=this._element._library;i._networkLock.obtain(function(t){t?e(t):c.checkDeletedState(n,e)?i._networkLock.release():(i._setSyncState("downloading"),i._collection._syncManager.downloadRepresentation(n,function(t){i._networkLock.release(),i._setSyncState(),c.checkDeletedState(n,e)||(t?e(p.getSyncError(t,n._element._library.id)):(i._commit(!0,!0),n._getComponentPath(e,!0)))}))})}}else{var r=this._getContentFromData();if(r){var a=this.element._lookupRenditionPath(this.id);a?e(null,a):this._generateContentDataFile(r,e)}else e(null)}},m.prototype._getContentFromData=function(){if(o.hasFileSystem()){var e=i.REPRESENTATION_CONTENT_VALUES[this.type];if(e&&e.contentFromData)return this.getValue(e.namespace,e.key)}},m.prototype._generateContentDataFile=function(e,t){var n=this,i=this.element.library.collection._getTempDir(),r=s.getExtensions(this.type)[0];l.writeJSONData(i,this.id+"."+r,e,function(e,i){if(e)return t(p.getCommitError(e));n.element.setThumbnailCache(n.id,i,function(e,i){o.storageInterface.notifyDownloadRendition(n.element),t(e,i)})})},m.prototype._setRenditionCache=function(e,t,n,o){var i=this.element;i._renditionCacheLock.obtain(function(){i._setRenditionCache(e,t,n),i._renditionCacheLock.release(),o()})},m.prototype._getCachedExternalLinkPath=function(e){var t=null,n=this.element._lookupRenditionPath(this.id);if(e||n!==i.RENDITION_CACHE_PLACEHOLDER||(n=void 0),p.isErrorCode(n)&&(t=new r(n,"Broken link, or access denied",this.element.library.id),n=void 0),!t&&!n){var o=this._dcxNode.getValue(i.LINK_URL_KEY);t=d.validateURL(o)}return{err:t,path:n}},m.prototype._getExternalLinkPath=function(e,t){var n=this;n._lock.obtain(function(){n._getExternalLinkPathUnsafe(e,function(e,o){n._lock.release(),t(e,o)})})},m.prototype._getExternalLinkPathUnsafe=function(e,t){var n=this,a=this.element.library,u=a.collection,h=u._getTempDir();if(!e){var _=this._getCachedExternalLinkPath();if(_.err||_.path)return void t(_.err,_.path)}if(i.SHARED_LOCAL_STORAGE)o.storageInterface.downloadExternalLink(n,t);else if(this._pendingDownloadCallbacks.push(t),!(this._pendingDownloadCallbacks.length>1)){var m=function(e,t,o){u._updateExternalLinkDownloadProgress(n,e,t,o)},E=function(e,t){var i=function(t,o){m(void 0,void 0,e),function(e,t){var o=n._pendingDownloadCallbacks;n._pendingDownloadCallbacks=[],o.forEach(function(n){n(e,t)})}(t,o)};e?i(e):p.isErrorCode(t)?n._setRenditionCache(n.id,t,!0,function(){i(new r(t,"Broken link, or access denied",a.id))}):(f.supportsVectorRendition(n.element)&&delete n.element._renditionCache.vector,n.element.setThumbnailCache(n.id,t,function(e,t){o.storageInterface.notifyDownloadRendition(n.element),i(e,t)}))},g=this._dcxNode.getValue(i.LINK_URL_KEY),y=(new Date).valueOf();o.log("Downloading from external URL: "+g),u._syncManager.getAssetFromURL(g,{},h,m,function(e,t,i,a){if(o.log("Finished downloading from external URL: "+((new Date).valueOf()-y)+"ms"),!c.checkDeletedState(n,E)){var h=e&&e.response&&e.response.statusCode;if(d.isUnrecoverableClientError(h,u.isPublic))E(null,r.RENDITION_NOT_AVAILABLE);else if(e)E(p.getSyncError(e));else{var _=d.getContentTypeHeader(a&&a.headers)||n.type,f=t+"."+(s.getExtensions(_)[0]||"data");l.rename(t,f,function(e){e?E(p.getCommitError(e)):E(null,f)})}}})}},m.prototype._testExternalLink=function(e,t){var n=this;n._lock.obtain(function(){n._testExternalLinkUnsafe(e,function(e,o){n._lock.release(),t(e,o)})})},m.prototype._testExternalLinkUnsafe=function(e,t){var n=this;if(!e){var a=this._getCachedExternalLinkPath(!0);if(a.err)return void t(null,!1);if(a.path)return void t(null,!0)}if(i.SHARED_LOCAL_STORAGE&&_.supportsTestExternalLink())o.storageInterface.testExternalLink(this,t);else{var s=this.element.library.collection,c=this._dcxNode.getValue(i.LINK_URL_KEY);s._updateExternalLinkDownloadProgress(this,0,1);var l=function(e,o){s._updateExternalLinkDownloadProgress(n),t(e,o)},p=(new Date).valueOf();o.log("HEAD request of external URL: "+c),o.storageInterface.doHeadRequestOfURL(s,c,function(e,t){if(o.log("Finished HEAD request of external URL: "+((new Date).valueOf()-p)+"ms"),e)l(null,!0);else{var a=t&&t.statusCode;d.isUnrecoverableClientError(a,s.isPublic)?n._setRenditionCache(n.id,r.RENDITION_NOT_AVAILABLE,!0,function(){l(null,!1)}):a&&a>=200&&a<400?n._setRenditionCache(n.id,i.RENDITION_CACHE_PLACEHOLDER,!1,function(){l(null,!0)}):l(null,!0)}})}},m.prototype._getDCXElement=function(){return this._dcxComponent||this._dcxNode},m.prototype._commit=function(){this._element._commit()},m.prototype._getMissingLocalComponents=function(){return o.hasFileSystem()&&this._dcxComponent&&!this._getCurrentComponentPath()?[this._dcxComponent]:[]},m.prototype.jasmineToString=function(){return this.toString()},Object.defineProperties(m.prototype,{id:{get(){return this._getDCXElement().id},set(){throw new r(r.READ_ONLY,"Cannot change the id of an existing representation",this._element._library.id)}},element:{get(){return this._element},set(){throw new r(r.READ_ONLY,"element is a read-only property",this._element._library.id)}},isWritable:{get(){return this._element.isWritable},set(){throw new r(r.READ_ONLY,"isWritable is a read-only property",this._element._library.id)}},type:{get(){var e=this._getDCXElement().type;return e===i.LINK_REPRESENTATION_TYPE&&(e=this._getDCXElement().getValue(i.LINK_TYPE_KEY)),e},set(){throw new r(r.READ_ONLY,"Cannot change the content type of an existing representation",this._element._library.id)}},relationship:{get(){return this._dcxComponent?this._dcxComponent.relationship:this._dcxNode.getValue(i.RELATIONSHIP_KEY)||this._dcxNode.getValue("relationship")},set(e){this._element._validateRelationship(e,this),this._dcxComponent?this._dcxComponent.relationship=e:this._dcxNode.setValue(i.RELATIONSHIP_KEY,e)}},width:{get(){return this._dcxComponent?this._dcxComponent.getValue("width"):this._dcxNode.getValue(i.WIDTH_KEY)},set(e){if(c.checkDeletedState(this),!this.isWritable)throw new r(r.NOT_ALLOWED,"you do not have write access to this library",this._element._library.id);if(!this._dcxComponent&&!this.isExternalLink)throw new r(r.INVALID_PARAMETER,"Cannot set width on a representation without contents",this._element._library.id);if("number"!=typeof e||e<0)throw new r(r.INVALID_PARAMETER,"Invalid width",this._element._library.id);this._dcxComponent?this._dcxComponent.setValue("width",e):this._dcxNode.setValue(i.WIDTH_KEY,e),this._commit()}},height:{get(){return this._dcxComponent?this._dcxComponent.getValue("height"):this._dcxNode.getValue(i.HEIGHT_KEY)},set(e){if(c.checkDeletedState(this),!this.isWritable)throw new r(r.NOT_ALLOWED,"you do not have write access to this library",this._element._library.id);if(!this._dcxComponent&&!this.isExternalLink)throw new r(r.INVALID_PARAMETER,"Cannot set height on a representation without contents",this._element._library.id);if("number"!=typeof e||e<0)throw new r(r.INVALID_PARAMETER,"Invalid height",this._element._library.id);this._dcxComponent?this._dcxComponent.setValue("height",e):this._dcxNode.setValue(i.HEIGHT_KEY,e),this._commit()}},isFullSize:{get(){return this._getDCXElement().getValue(i.IS_FULL_SIZE_KEY)},set(e){if(c.checkDeletedState(this),!this.isWritable)throw new r(r.NOT_ALLOWED,"you do not have write access to this library",this._element._library.id);if(!this._dcxComponent&&!this.isExternalLink)throw new r(r.INVALID_PARAMETER,"Cannot set isFullSize on a representation without contents",this._element._library.id);if("boolean"!=typeof e)throw new r(r.INVALID_PARAMETER,"Invalid isFullSize",this._element._library.id);this._getDCXElement().setValue(i.IS_FULL_SIZE_KEY,e),this._commit()}},isPreferredThumbnail:{get(){return this._getDCXElement().getValue(i.IS_PREFERRED_THUMBNAIL_KEY)||!1},set(e){if(c.checkDeletedState(this),!this.isWritable)throw new r(r.NOT_ALLOWED,"you do not have write access to this library",this._element._library.id);if("boolean"!=typeof e)throw new r(r.INVALID_PARAMETER,"Invalid isPreferredThumbnail",this._element._library.id);this._getDCXElement().setValue(i.IS_PREFERRED_THUMBNAIL_KEY,e),this._commit()}},contentLength:{get(){if(this.isExternalLink)return this._dcxNode.getValue(i.LENGTH_KEY);if(this._dcxComponent){if(void 0===this._dcxComponent.length&&o.hasFileSystem()){var e=this._getCurrentComponentPath();try{var t=o.fs.statSync(e);return t&&t.size}catch(e){}}return this._dcxComponent.length}},set(e){if(!this.isExternalLink)throw new r(r.READ_ONLY,"setContentLength can only be used for an externally-linked representation",this._element._library.id);if("number"!=typeof e||e<0)throw new r(r.INVALID_PARAMETER,"Invalid content length",this._element._library.id);this._dcxNode.setValue(i.LENGTH_KEY,e),this._commit()}},isDeletedLocally:{get(){return this._deletedLocally},set(){throw new r(r.READ_ONLY,"isDeletedLocally is a read-only property",this._element._library.id)}},isExternalLink:{get(){return void 0!==this._dcxNode&&this._dcxNode.type===i.LINK_REPRESENTATION_TYPE},set(){throw new r(r.READ_ONLY,"isExternalLink is a read-only property",this._element._library.id)}}}),m.prototype.isCompatibleType=function(e){if(this._dcxComponent){var t=l.getFileExtension(this._dcxComponent.path);if(-1===s.getExtensions(e).indexOf(t))return!1}return c.isCompatibleType(e,this.type)},m.prototype.toString=function(){return JSON.stringify(this._toJSON())},m.prototype.getValue=function(e,t){if(e===i.DL_NAMESPACE)throw new r(r.INVALID_PARAMETER,"Reserved namespace",this._element._library.id);var n=c.getDCXKey(e,t);return this._getDCXElement().getValue(n)},m.prototype.getValues=function(){return c.getCustomDCXData(this._getDCXElement())},m.prototype.setValue=function(e,t,n){if(c.checkDeletedState(this),!this.isWritable)throw new r(r.NOT_ALLOWED,"you do not have write access to this library",this._element._library.id);if(e===i.DL_NAMESPACE)throw new r(r.INVALID_PARAMETER,"Reserved namespace",this._element._library.id);var o,a=c.getDCXKey(e,t);try{o=JSON.parse(JSON.stringify(n))}catch(e){throw new r(r.INVALID_PARAMETER,"Value cannot be serialized to JSON",this._element._library.id)}this._getDCXElement().setValue(a,o),this._commit()},m.prototype.setContent=function(e,t,n,i){if(!c.checkDeletedState(this,i))if(this.isWritable)if(this._dcxComponent||this.isExternalLink)i(new r(r.INVALID_PARAMETER,"Cannot modify representation content once set",this._element._library.id));else if(o.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 r(r.INVALID_PARAMETER,"Encoding parameter not supported in-browser"));this._setComponentInBrowser(e,n,i)}else i(new r(r.NOT_ALLOWED,"you do not have write access to this library",this._element._library.id))},m.prototype.setContentFromPath=function(e,t,n){"function"==typeof t&&(n=t,t=!1),o.hasFileSystem()?c.checkDeletedState(this,n)||(this.isWritable?this._dcxComponent||this.isExternalLink?n(new r(r.INVALID_PARAMETER,"Cannot modify representation content once set",this._element._library.id)):this._setComponentFromPath(e,!t,n):n(new r(r.NOT_ALLOWED,"you do not have write access to this library",this._element._library.id))):n(new r(r.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this._element._library.id))},m.prototype.setContentFromURL=function(e,t,n,a){if(o.hasFileSystem()||e){if(!c.checkDeletedState(this,a))if(this.isWritable)if("boolean"==typeof e)if(this._dcxComponent||this.isExternalLink)a(new r(r.INVALID_PARAMETER,"Cannot modify representation content once set",this._element._library.id));else{if(e)return this._dcxNode.setValue(i.LINK_TYPE_KEY,this._dcxNode.type),this._dcxNode.type=i.LINK_REPRESENTATION_TYPE,this._dcxNode.setValue(i.LINK_URL_KEY,t),this._commit(),void a(null);var u=this,h=this.element.library.collection,_=h._getTempDir();o.storageInterface.getAssetFromURL(h,t,n,_,function(e,t,n,o){if(e)a(p.getSyncError(e));else if(!c.checkDeletedState(u,a)){var i=d.getContentTypeHeader(o&&o.headers);if(i){var r=t+"."+s.getExtensions(i)[0];l.rename(t,r,function(e){e?a(p.getCommitError(e)):u._setComponentFromPath(r,!1,a)})}else u._setComponentFromPath(t,!1,a)}})}else a(new r(r.INVALID_PARAMETER,"Invalid createLink parameter: must be Boolean",this._element._library.id));else a(new r(r.NOT_ALLOWED,"you do not have write access to this library",this._element._library.id))}else a(new r(r.NOT_IMPLEMENTED,"not yet implemented setContentFromURL without a filesystem",this._element._library.id))},m.prototype.getContentPath=function(e){o.hasFileSystem()?c.checkDeletedState(this,e)||this._getComponentPath(e):e(new r(r.REQUIRES_FILESYSTEM,"path-based APIs require a filesystem",this._element._library.id))},m.prototype.getCachedContentPath=function(){if(o.hasFileSystem())return this.isExternalLink?this._getCachedExternalLinkPath().path:this._dcxComponent&&this._getCurrentComponentPath()||void 0},m.prototype.getContent=function(e,t){var n=o.fs,i=this;if(!c.checkDeletedState(this,t))if(o.hasFileSystem()){if(!c.checkEncoding(e,["utf8","ascii","base64","buffer"],t))return;this._getComponentPath(function(o,r){if(!o&&r){if(!c.checkDeletedState(i,t)){var a=function(e,n){e&&(e=p.getCommitError(e,i._element._library.id,"error reading content from disk")),t(e,n)};"buffer"===e?n.readFile(r,a):n.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.getSharedCloudContent(this,e,t)}},m.prototype.getContentURL=function(){return this.isExternalLink?this._dcxNode.getValue(i.LINK_URL_KEY):this._dcxComponent?this._element._library._collection._syncManager.getSharedCloudContentURL(this._dcxComponent):void 0},m.prototype.getAuthenticatedContentURL=function(e){var t=this.getContentURL();this._element._library._collection._syncManager.appendAccessTokenToURL(t,e)},m.prototype.testExternalLink=function(e){this.isExternalLink&&this.getContentURL()?this._testExternalLink(!1,e):e(new r(r.INVALID_PARAMETER,"Not an external link",this._element._library.id))},m.prototype.clearCachedExternalLink=function(){if(!this.isExternalLink||!this.getContentURL())throw new r(r.INVALID_PARAMETER,"Not an external link",this._element._library.id);if(i.SHARED_LOCAL_STORAGE)o.storageInterface.clearCachedExternalLink(this);else{var e=u.wrapCallback();h.shouldPrefetchExternalLink(this)?this._getExternalLinkPath(!0,e):this._testExternalLink(!0,e)}},m.prototype.getCachedExternalLinkError=function(){return this.isExternalLink&&this.getContentURL()?this._getCachedExternalLinkPath().err:new r(r.INVALID_PARAMETER,"Not an external link",this._element._library.id)},m.prototype.getExternalLinkDownloadProgress=function(){if(this.isExternalLink)return this.element.library.collection._getExternalLinkDownloadProgress(this)},Object.freeze(m),Object.seal(m.prototype),e.exports=m},function(e,t,n){var o=n(2),i=n(7),r=n(1),a=n(0),s=n(18);function c(e,t){this._element=e,this._id=t.action,this._appCode=t.appCode,this._appName=t.appName,this._minVersion=t.minVersion,this._installedVersions=r.ELEMENT_ACTION_PRODUCT_MAP.installedApps.filter(function(e){return e.code===t.appCode}).map(function(e){return e.version}).sort(i.compareVersions),this._invokable=this._installedVersions.length>0&&i.compareVersions(t.minVersion,this._installedVersions[0])>=0,Object.freeze(this._installedVersions)}Object.defineProperties(c.prototype,{id:{get(){return this._id},set(){throw new o(o.READ_ONLY,"Cannot change the id of an existing element action",this._id)}},element:{get(){return this._element},set(){throw new o(o.READ_ONLY,"element is a read-only property",this._element.id)}},appCode:{get(){return this._appCode},set(){throw new o(o.READ_ONLY,"Cannot change the app code of an element action",this._appCode)}},appName:{get(){return this._appName},set(){throw new o(o.READ_ONLY,"Cannot change the app name of an element action",this._appName)}},minAppVersion:{get(){return this._minVersion},set(){throw new o(o.READ_ONLY,"Cannot change the min version of an element action",this._minVersion)}},installedVersions:{get(){return this._installedVersions},set(){throw new o(o.READ_ONLY,"Cannot change the installed versions of an element action")}},isCompatibleVersionInstalled:{get(){return!!this._invokable},set(){throw new o(o.READ_ONLY,"Cannot change the compatibility of an element action")}}}),c.prototype.invoke=function(e){var t=i.wrapCallback(e);this.isCompatibleVersionInstalled?(s.reportElementActionInvoked(this),a.storageInterface.sendElementAction(this,function(e,n){e?(e=-1!==["APP_NOT_INSTALLED","NO_COMPATIBLE_VERSION"].indexOf(e)?new o(o.NO_COMPATIBLE_APP_FOUND,"A compatible version of application is needed for this action:"+e):new o(o.APP_LAUNCH_FAILED,"Launching the app failed:"+e),s.reportElementActionFailed(this,e)):s.reportElementActionSuccessful(this,n),t(e,n)})):t(new o(o.NO_COMPATIBLE_APP_FOUND,"A compatible version of application is needed for this action",this._appCode))},Object.freeze(c),Object.seal(c.prototype),e.exports=c},function(e,t,n){var o=n(51),i=n(52),r=n(6),a=n(3),s=n(1),c=n(2),l=n(0),p=n(29),d=n(12),u=n(9),h=n(7),_=n(16),f=n(28),m=n(31);function E(e,t){this._collection=e,this._isPublic=t.IS_PUBLIC,this._storageHost=t.STORAGE_HOSTNAME,this._collaborationHost=t.COLLABORATION_HOSTNAME,this._imageHost=t.CC_IMAGE_HOSTNAME,this._imageXHost=t.CC_IMAGE_X_HOSTNAME,this._typekitHost=t.TYPEKIT_HOSTNAME,this._storageAssetsPath=this._isPublic?t.STORAGE_ASSETS_PATH:s.STORAGE_ASSETS_PATH,this._apiKey=s.STORAGE_API_KEY,this._syncGroup=this._isPublic?t.SYNC_GROUP:s.LIBRARY_SYNC_GROUP,this._XHR=t.XHR,this._requiresCommunitySession=t.REQUIRES_COMMUNITY_SESSION,this._getAccessToken=t.getAccessToken,this._httpServices=[],this._storageService=this._createStorageSession(),this._renditionStorageService=this._createStorageSession(),this._temporaryStorageServices={},this._lastSyncGroupState={},this._hasSetAuthToken=!1,this._authToken=void 0,this._inProgressSyncMap={},s.SHARED_LOCAL_STORAGE||this._isPublic||this._updateAuthToken()}E.prototype._getCommonRequestHeaders=function(){var e={};return s.USER_AGENT_HEADER&&(e["User-Agent"]=s.USER_AGENT_HEADER),e},E.prototype._setAuthToken=function(e){this._hasSetAuthToken=!0,this._authToken=e,this._httpServices.forEach(function(t){e?(t.isActive=!0,t.setAuthToken(e)):t.isActive=!1})},E.prototype._updateAuthToken=function(e){var t=this,n=h.wrapCallback(e);this._getAccessToken(this._authToken,function(e,o){!e&&o?t._setAuthToken(o):(e&&e.code===c.ACCESS_DENIED&&(t._collection._reportSyncError(e),t._collection._updateSyncState()),t._setAuthToken()),n(null,o)})},E.prototype._getAuthToken=function(e){this._hasSetAuthToken?e(null,this._authToken):this._updateAuthToken(e)},E.prototype._authHandler=function(){this._updateAuthToken()},E.prototype._createStorageSession=function(){var e;return this._isPublic?e=l.dcx.createHTTPService():(e=l.dcx.createHTTPService(this._authHandler.bind(this)),this._httpServices.push(e)),e.setApiKey(this._apiKey),e.setTimeout(s.NETWORK_TIMEOUT),e.setAdditionalNodeOptions(l.getNodeTunnelOptions(this.getStorageHost())),e.setAdditionalHeaders(this._getCommonRequestHeaders()),this._XHR&&e._forceXhr(this._XHR),this._requiresCommunitySession?l.dcx.createCommunitySession(e,this.getStorageHost()):l.dcx.createStorageSession(e,this.getStorageHost())},E.prototype._createTemporaryStorageSession=function(e,t){var n;return t&&this._getAccessToken?(this._authToken||this._updateAuthToken(),(n=l.dcx.createHTTPService(this._authHandler.bind(this))).setApiKey(this._apiKey),n.setAdditionalHeaders(this._getCommonRequestHeaders()),n.setAuthToken(this._authToken),this._httpServices.push(n)):n=l.dcx.createHTTPService(),n.setTimeout(s.NETWORK_TIMEOUT),n.setAdditionalNodeOptions(l.getNodeTunnelOptions(e)),this._XHR&&n._forceXhr(this._XHR),l.dcx.createStorageSession(n,e)},E.prototype._getTemporaryStorageSession=function(e){var t=r.parseURI(e),n=t.scheme+"://"+t.authority,o=p.isAdobeDomain(t.authority);return this._temporaryStorageServices[n]||(this._temporaryStorageServices[n]=this._createTemporaryStorageSession(n,o)),this._temporaryStorageServices[n]},E.prototype.getServerComposites=function(e){var t=this,n=this._lastSyncGroupState.etag;this._storageService.getCollection(this.getSyncGroupPath(),n,function(n,o,i,r){if(n)n.response&&404===n.response.statusCode?e(null,[]):e(n);else{if(!o){var a=Math.max(s.DEFAULT_MAX_SYNC_INTERVAL,1e3*p.getRetryAfterHeader(r));return s.MAX_SYNC_INTERVAL=a,void e(null,[])}s.MAX_SYNC_INTERVAL=s.DEFAULT_MAX_SYNC_INTERVAL;var c=t._lastSyncGroupState.compositeEtags||{},l={},d=[],u={};(o.children||[]).forEach(function(e){e&&_.validateLibraryId(e.name,!1)&&(e.isUnmodified=e.etag&&c[e.name]===e.etag,d.push(e),u[e.name]=e,l[e.name]=e.etag)}),t._lastSyncGroupState={etag:i,compositeEtags:l},e(null,d,u)}})},E.prototype.clearSyncGroupCache=function(){this._lastSyncGroupState={}},E.prototype.doHeadRequest=function(e,t){var n;try{n=this._storageService.getCompositeManifestHref(e)}catch(e){return void t(e)}this._storageService.headRequest(n,t)},E.prototype.hasCompositeChangedOnServer=function(e,t){this.doHeadRequest(e,function(n,o){if(n)t(!0);else{var i=o&&o.headers&&o.headers.etag,r=e.current&&e.current.manifestEtag;t(i!==r)}})},E.prototype.downloadComponent=function(e,t,n){i.downloadComponents([t],e,this._storageService,n)},E.prototype.downloadRepresentation=function(e,t){var n=e._dcxComponent,o=e.element.library._dcxBranch;this.downloadComponent(o,n,t)},E.prototype.abortPushOrPull=function(e){this._inProgressSyncMap[e]&&(this._inProgressSyncMap[e].abort(new c(c.TRANSFER_ABORTED,"abort push or pull operation")),delete this._inProgressSyncMap[e])},E.prototype._isManifestOnly=function(){return"manifestOnly"===s.SYNC_POLICY||!l.hasFileSystem()},E.prototype._pullCompositeComponents=function(e,t,n,o,r){if(this._isManifestOnly())r(null);else{var a=i.downloadComponents(e,t,this._storageService,r);this._inProgressSyncMap[o]=a,a.onProgress=function(e,t){0!==t&&n._updateProgress(o,e,t)}}},E.prototype._pullComposite=function(e,t,n,o){var r=this;this._inProgressSyncMap[n]=i.pullCompositeManifestOnly(e,this._storageService,function(e,i){if(!e&&i){var a=i.getComponentsOf();i.getChildrenOf().forEach(function(e){e.name===s.ELEMENTS_NAME&&i.getChildrenOf(e).forEach(function(e){a=a.concat(i.getComponentsOf(e))})}),r._pullCompositeComponents(a,i,t,n,function(e){o(e,i)})}else o(e,i)})},E.prototype.pullComposite=function(e,t,n){var o=this,i=e.id;if(!i&&e.href){var r=e.href.split("/");i=r&&r[r.length-1]}l.log("Started pulling: "+i+(this._isManifestOnly()?" (manifest only)":""));var s=(new Date).valueOf();t._updateProgress(i),this._pullComposite(e,t,i,function(r,p){var d=(new Date).valueOf()-s;l.log("Finished pulling: "+i+(r?" ["+r.code+"]":"")+" duration="+d),delete o._inProgressSyncMap[i],t._updateProgress(i),p&&(p=p.copy(),_.ensureBranchDataValid(p)),r&&r.code===a.COMPONENT_DOWNLOAD_ERROR?o.doHeadRequest(e,function(e,t){if(!e&&t&&200===t.statusCode){var o=_.removeMissingComponents(r.pulledBranch.copy(),r.failedComponents);if(o)return void n(null,o)}n(r,p)}):r&&r.code===c.TRANSFER_ABORTED?n(null,void 0):n(r,p)})},E.prototype.pullMissingComponents=function(e,t){var n=this,o=e.id,i=e.collection,r=e._getMissingLocalComponents();if(this._isManifestOnly()||0===r.length)t(null);else{e._setSyncState("downloading"),l.log("Started pulling missing components: "+o);var a=(new Date).valueOf();i._updateProgress(o),this._pullCompositeComponents(r,e._dcxBranch,i,o,function(r){var s=(new Date).valueOf()-a;l.log("Finished pulling missing components: "+o+(r?" ["+r.code+"]":"")+" duration="+s),delete n._inProgressSyncMap[o],i._updateProgress(o),e._setSyncState(),r&&r.code===c.TRANSFER_ABORTED?t(null):t(r)})}},E.prototype.pushComposite=function(e,t,n,o){var r=this,a=e.id;l.log("Started pushing: "+a);var s=(new Date).valueOf();t._updateProgress(a),this._inProgressSyncMap[a]=i.pushComposite(e,n,this._storageService,function(e){var n=(new Date).valueOf()-s;l.log("Finished pushing: "+a+(e?" ["+e.code+"]":"")+" duration="+n),delete r._inProgressSyncMap[a],t._updateProgress(a),o(e)}),this._inProgressSyncMap[a].onProgress=function(e,n){0!==n&&t._updateProgress(a,e,n)}},E.prototype.pushDeletedComposite=function(e,t,n,o,i){var r=this;"incoming"===n?(l.log("Deleting incoming collaboration without pushing: "+e.id),this._storageService.deleteCompositeDirectory(e,i)):e.current&&!e.current.isBound?i(null):(l.log("Pushing deleted composite: "+e.id),this.pushComposite(e,t,o,function(n){if(n){if(n.code===a.UNEXPECTED_RESPONSE&&n.response&&404===n.response.statusCode)return void r._storageService.deleteCompositeDirectory(e,i);if(n.code===a.UPDATE_CONFLICT){var o=n;return void r.pullComposite(e,t,function(t){t&&t.code===a.NO_COMPOSITE?r._storageService.deleteCompositeDirectory(e,i):t&&t.code===a.DELETED_COMPOSITE?i(null):i(t||o)})}}i(n)}))},E.prototype.getStorageHost=function(){return"https://"+this._storageHost},E.prototype.getSyncGroupPath=function(){var e=this.getStorageHost()+(this._storageAssetsPath||"");return this._syncGroup?r.appendPathElements(e,this._syncGroup):e},E.prototype.getCompositePath=function(e){return r.appendPathElements(this.getSyncGroupPath(),e)},E.prototype.getComponentPath=function(e,t){return r.appendPathElements(this.getSyncGroupPath(),e,t)},E.prototype.getElementRefDomain=function(){return this._requiresCommunitySession?s.CP_CLOUD_ID:this._storageHost},E.prototype.getElementRefPath=function(){return s.STORAGE_ASSETS_PATH+s.LIBRARY_SYNC_GROUP},E.prototype.getElementRefDomainPath=function(){return this.getElementRefDomain()+this.getElementRefPath()},E.prototype.getCollaborationHost=function(){return"https://"+this._collaborationHost},E.prototype._getSharedCloudRenditionUrl=function(e,t,n){if(e._dcxComponent)try{n(null,this._requiresCommunitySession?this._storageService.getComponentRenditionHref(e._dcxComponent,e._dcxComponent.version,"image/png","width",t||"full"):this._storageService.getComponentRenditionHref(e._dcxComponent,e._dcxComponent.version,t||"full"))}catch(e){n(e)}else n("representation must be a component to generate a rendition")},E.prototype._getTypekitFontData=function(e,t){var n="https://"+this._typekitHost+"/v1/variations?include=trial,full,marketplace,purchased&include_marketplace_data=true&purpose=sync";this._getTemporaryStorageSession(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)}})},E.prototype._retry404IfNeeded=function(e,t,n,o,i){var r=1e3*p.getRetryAfterHeader(t);if(s.RENDITION_RETRY_INTERVAL=Math.max(s.DEFAULT_RENDITION_RETRY_INTERVAL,r),s.RENDITION_404_BACKOFF=Math.max(s.DEFAULT_RENDITION_404_BACKOFF,r),n<s.RENDITION_MAX_RETRIES)return n++,l.log("404 fetching rendition: retrying ("+n+")"),void setTimeout(o,s.RENDITION_RETRY_INTERVAL,n);l.log("404 fetching rendition: reached maximum retries"),l.log("Backing off rendition fetch of "+e.id+" for "+s.RENDITION_404_BACKOFF+"ms"),e._lastRendition404=(new Date).valueOf(),i()},E.prototype._getImageServiceSVGRendition=function(e,t,n){var o=this,i=e.element,r="https://"+this._imageHost+"/createagc",a=this._getTemporaryStorageSession(r),s={"Content-Type":"application/vnd.adobe.image-operation+json"},c={inputs:{application_file:{href:i.getReference()}},outputs:{agc:{disposition:"location"}}};if(e.isDeletedLocally||e.element.library.isDeletedFromServer)n("Error: representation deleted");else{var p=function(t){o._getImageServiceSVGRendition(e,t,n)};a._service.invoke("POST",r,s,JSON.stringify(c),{responseType:"text"},function(d,h){if(d||200!==h.statusCode){var _=function(){return n(d||"Image service call failed with: "+h.statusCode)};return h&&404===h.statusCode?o._retry404IfNeeded(e,h&&h.headers,t,p,_):void _()}var f;try{f=JSON.parse(h.response)}catch(e){return n(e)}if(f&&f.outputs&&f.outputs.agc&&f.outputs.agc.location)return r="https://"+o._imageXHost+"/agctosvg",a=o._getTemporaryStorageSession(r),s={"Content-Type":"application/vnd.adobe.dwbedrockservice-operation+json"},c={inputs:{href:f.outputs.agc.location}},a._service.invoke("POST",r,s,JSON.stringify(c),{responseType:"text"},function(e,t){if(e||200!==t.statusCode)return n(e||"Image-x service call failed with: "+t.statusCode);var o=t.response,r=i.library.collection._getTempDir(),a=r+l.getPathSeparator()+l.uuid()+".svg";u.ensurePathExists(r,function(e){if(e)return n(e);l.fs.writeFile(a,o,function(e){if(e)return n(e);n(null,a)})})});n("Invalid image service response")})}},E.prototype._getAssetAsType=function(e,t,n,i,r,a){var c=this;if(a=a||0,e.isDeletedLocally||e.element.library.isDeletedFromServer)r("Error: representation deleted");else{var p=function(o){c._getAssetAsType(e,t,n,i,r,o)};if(a>0&&"uploading"===e.element.library.syncState)setTimeout(p,s.RENDITION_RETRY_INTERVAL,a);else{var u=n+l.getPathSeparator()+l.uuid()+".png",h=new o.FileContent(u);this._renditionStorageService.getAssetAsType(t,h,i,function(t){var n=t&&t.response&&t.response.headers,o=function(){r(t,u)};if(404===d.getErrorStatusCode(t))return c._retry404IfNeeded(e,n,a,p,o);o()})}}},E.prototype.getSharedCloudRenditionUrl=function(e,t,n){this._getSharedCloudRenditionUrl(e,t,n)},E.prototype.getSharedCloudRendition=function(e,t,n){var o=this;if(e.element.library.isDeletedFromServer)return l.log("Error: Trying to fetch rendition from deleted library."),void n("Error: library deleted");if((new Date).valueOf()-(e._lastRendition404||0)<s.RENDITION_404_BACKOFF)n("Error: got 404 on last rendition attempt - backing off");else if("vector"===t&&m.supportsVectorRendition(e.element)){var i=function(){"uploading"!==e.element.library.syncState?o._getImageServiceSVGRendition(e,0,n):setTimeout(i,s.RENDITION_RETRY_INTERVAL)};i()}else this._getSharedCloudRenditionUrl(e,t,function(t,i){if(t)n(t);else{var r={Accept:"image/png"},a=e.element.library.collection._getTempDir();u.ensurePathExists(a,function(t){t?n(t):o._getAssetAsType(e,i,a,r,n)})}})},E.prototype.getSharedCloudContentURL=function(e){return this._storageService.getComponentHref(e,e.version)},E.prototype.appendAccessTokenToURL=function(e,t){if(e){var n=this._apiKey;this._getAuthToken(function(o,i){t(null,e+="?api_key="+n+(i?"&user_token="+i:""))})}else t(null,void 0)},E.prototype.getSharedCloudContent=function(e,t,n){var o=this._storageService.getComponentHref(e._dcxComponent,e._dcxComponent.version);this._storageService.getAssetAsType(o,t,{},function(e,t){e?n(e):n(null,t)})},E.prototype.getAssetFromURL=function(e,t,n,i,r,c){var d=this;l.log("getAssetFromURL: "+e);var h=this._getTemporaryStorageSession(e),_=n+l.getPathSeparator()+l.uuid(),f=new o.FileContent(_);c=c||0,t=t||{},u.ensurePathExists(n,function(o){if(o)r(o);else{var u=h.getAssetAsType(e,f,t,function(o,h,f,m){if(u&&delete u.progress,o&&o.code===a.UNEXPECTED_RESPONSE){var E=o.response&&o.response.statusCode;if(l.log("getAssetFromURL: Unexpected Response "+E+" from "+e),p.isRedirect(E)){var g=p.getLocationHeader(o.response.headers);if(g&&c<s.MAX_REDIRECT_FOLLOW)return l.log("getAssetFromURL: Redirecting to "+g),void d.getAssetFromURL(g,t,n,i,r,c+1);o.response.statusCode=404}}r(o,_,f,m)});if(u&&i){var m,E=0;u.progress=function(e){E+=e,!m&&u.response&&u.response.headers&&(m=p.getContentLengthHeader(u.response.headers)),i(E,m||1)},i(0,1)}}})},E.prototype.doHeadRequestOfURL=function(e,t,n){var o=this;n=n||0,this._getTemporaryStorageSession(e).headRequest(e,function(i,r){var a=r?r.statusCode:i;if(l.log("doHeadRequestOfURL: "+e+" -> "+a),r&&p.isRedirect(r.statusCode)){var c=p.getLocationHeader(r.headers);if(c&&n<s.MAX_HEAD_REDIRECT_FOLLOW)return l.log("doHeadRequestOfURL: Redirecting to "+c),void o.doHeadRequestOfURL(c,t,n+1);n>0&&(r.statusCode=404)}t(i,r)})},E.prototype.prepareCompositeForPush=function(e){e.href=this.getCompositePath(e.id)},E.prototype.updateAccessToken=function(e){this._setAuthToken(e)},E.prototype.isLoggedIn=function(){return this._isPublic||this._httpServices[0].isActive},E.prototype.uploadNewComponentForRepresentation=function(e,t,n,o){var r=n._element._library._dcxComposite;i.uploadNewComponent(e,n.type,r,n.id,this._storageService,function(e,i){if(e)o(e);else{var a=t?t.lastIndexOf("."):-1,s=-1!==a&&t.substr(a+1).toLowerCase(),c=n.id+"."+s,l=r.current.addComponentWithUploadResults(t,n.relationship,c,n._element._dcxNode,i);o(null,l)}})},E.prototype.uploadNewComponentForLibrary=function(e,t,n,o,r,a){var s=r._dcxComposite;i.uploadNewComponent(e,n,s,t,this._storageService,function(e,i){if(e)a(e);else{var r=f.getExtensions(n)[0],c=t+"."+r,l=s.current.addComponentWithUploadResults(c,o,c,s,i);a(null,l)}})},Object.freeze(E),Object.seal(E.prototype),e.exports=E},function(e,t,n){var o=n(57),i=n(0),r=n(1),a=n(23),s=n(9),c=n(12);function l(e){this._collection=e,this._bookmarks=[],this._bookmarksEtag=void 0,this._bookmarksBase=void 0,this._syncModified=!1,this._lock=new a,this._service=e._syncManager._createTemporaryStorageSession(e._syncManager.getCollaborationHost(),!0)._service,this._bookmarksURL=e._syncManager.getCollaborationHost()+r.BOOKMARKS_PATH}function p(e,t){var n;return e.some(function(e){if(e.id===t)return n=e,!0}),n}function d(e){var t=[];return e.forEach(function(e){t.push({id:e.id,url:e.url})}),t}function u(e){var t=[];return e&&e.forEach(function(e){t.push(new o(e.id,e.url))}),t}l.prototype._getBookmarksDir=function(){return this._collection._getBaseDir()},l.prototype._saveBookmarks=function(e){if(i.hasFileSystem()){var t={bookmarks:d(this._bookmarks),etag:this._bookmarksEtag};this._bookmarksBase&&(t.bookmarks_base=this._bookmarksBase),s.writeJSONData(this._getBookmarksDir(),r.BOOKMARKS_FILENAME,t,function(t){t&&(t=c.getCommitError(t,null,"bookmarks could not be saved")),e(t)})}else e(null)},l.prototype._loadBookmarks=function(e){if(i.hasFileSystem()){var t=this,n=this._getBookmarksDir()+i.getPathSeparator()+r.BOOKMARKS_FILENAME;s.readJSONData(n,function(n,o){if(n)return n=c.getCommitError(n,null,"bookmarks could not be loaded"),e(n);o&&(t._bookmarks=u(o.bookmarks),t._bookmarksEtag=o.etag,t._bookmarksBase=o.bookmarks_base&&u(o.bookmarks_base)),e(null)})}else e(null)},l.prototype._pullBookmarks=function(e){i.log("Pulling bookmarks");var t={},n=this;this._bookmarksEtag&&(t["If-None-Match"]=this._bookmarksEtag),this._service.invoke("GET",this._bookmarksURL,t,void 0,{responseType:"text"},function(t,o){if(t)return e(t);if(200===o.statusCode)try{var i=JSON.parse(o.response);n._syncModified=!0,e(null,u(i.bookmarks),o.headers.etag)}catch(t){e("Cannot parse data: "+o.response)}else 304===o.statusCode||404===o.statusCode?e(null,void 0,o.headers.etag):e("Unexpected response getting bookmarks: "+o.statusCode)})},l.prototype._mergeBookmarks=function(e,t){if(i.log("Merging bookmarks"),e){if(this._bookmarksBase){var n=this;e.forEach(function(t){var o=p(n._bookmarks,t.id),i=p(n._bookmarksBase,t.id);!o&&i&&e.splice(e.indexOf(t),1)}),this._bookmarks.forEach(function(t){var o=p(e,t.id),i=p(n._bookmarksBase,t.id);o||i||e.push(t)})}this._bookmarks=e}this._bookmarksEtag=t},l.prototype._pushBookmarks=function(e){i.log("Pushing bookmarks");var t={"Content-Type":"application/json"};this._bookmarksEtag&&(t["If-Match"]=this._bookmarksEtag);var n=this,o=JSON.stringify({bookmarks:d(this._bookmarks)});this._service.invoke("PUT",this._bookmarksURL,t,o,void 0,function(t,o){if(t)return e(t);var i=o.statusCode;!o.headers.etag||200!==i&&201!==i&&204!==i?409===i||412===i?n._pullBookmarks(function(t,o,i){if(t)return e(t);n._mergeBookmarks(o,i),n._pushBookmarks(e)}):e("Unexpected response updating bookmarks: "+i):e(null,o.headers.etag)})},l.prototype._commit=function(e){i.log("Commiting bookmarks");var t=this;this._lock.obtain(function(){t._saveBookmarks(function(n){t._lock.release(),n?t._collection._reportCommitError(n):e&&t.sync(function(e){e&&t._collection._reportSyncError(e)})})})},l.prototype._sync=function(e){var t=this;this._bookmarksBase?t._pushBookmarks(function(n,o){if(n)return e(n);t._bookmarksEtag=o,t._bookmarksBase=void 0,t._commit(),e(null)}):t._pullBookmarks(function(n,o,i){if(n)return e(n);o&&(t._bookmarks=o,t._bookmarksEtag=i,t._bookmarksBase=void 0,t._commit()),e(null)})},l.prototype._createBase=function(){this._bookmarksBase||(this._bookmarksBase=this._bookmarks.slice())},l.prototype.load=function(e){i.log("Loading bookmarks");var t=this;this._lock.obtain(function(){t._loadBookmarks(function(n){t._lock.release(),e(n)})})},l.prototype.sync=function(e){i.log("Syncing bookmarks");var t=this;this._lock.obtain(function(){t._syncModified=!1,t._sync(function(n){if(t._lock.release(),n)return n=c.getSyncError(n,null),e(n);e(null),t._syncModified&&t._collection._notifyChange(!0)})})},l.prototype.createBookmark=function(e,t,n){if(r.SHARED_LOCAL_STORAGE)i.storageInterface.createBookmark(this._collection,e,t,n);else{i.log("Creating bookmark: "+e+" url: "+t);var a=this;this._lock.obtain(function(){var i=p(a._bookmarks,e),s=!1;i||(a._createBase(),i=new o(e,t),a._bookmarks.push(i),s=!0),a._lock.release(),n(null,i,s),s&&(a._commit(r.SYNCING_ENABLED),a._collection._notifyChange(!0))})}},l.prototype.removeBookmark=function(e,t){if(r.SHARED_LOCAL_STORAGE)i.storageInterface.removeBookmark(this._collection,e,t);else{i.log("Removing bookmark: "+e.id+" url: "+e.id);var n=this;this._lock.obtain(function(){(e=p(n._bookmarks,e.id))&&(n._createBase(),n._bookmarks.splice(n._bookmarks.indexOf(e),1)),n._lock.release(),t(null),e&&(n._commit(r.SYNCING_ENABLED),n._collection._notifyChange(!0))})}},l.prototype.getBookmarks=function(){return this._bookmarks.slice()},Object.freeze(l),Object.seal(l.prototype),e.exports=l},function(e,t,n){var o=n(1),i=n(2),r=n(0),a=n(5);function s(e){this._collection=e,this._listenerManager=new a(["change"]),this._fontsCache={}}s.prototype._clearCache=function(){this._fontsCache={},this._listenerManager.notify("change")},s.prototype.addChangeListener=function(e){this._listenerManager.add("change",e)},s.prototype.removeChangeListener=function(e){this._listenerManager.remove("change",e)},s.prototype.getFontData=function(e,t){var n=this,a=this._fontsCache[e];a?t(null,a):o.SHARED_LOCAL_STORAGE?r.storageInterface.getFontData(this._collection,e,function(o,i){i&&(n._fontsCache[e]=i),t(o,i)}):this._collection._syncManager._getTypekitFontData([e],function(o,r){o?t(new i(i.NETWORK_ERROR,"Error occurred while getting font data",null,o)):(a=r&&r[0],n._fontsCache[e]=a,t(null,a))})},Object.freeze(s),Object.seal(s.prototype),e.exports=s},function(e,t,n){var o=n(2),i=n(0),r=n(1),a=n(5);function s(e,t,n,o,i){this._listenerManager=new a(["progress"]),this._collection=e,this._id=t,this._type=n,this._data=o,this._cancelCallback=i,this._progress=0}s.prototype._updateProgress=function(e){this._progress!==e&&(this._progress=e,this._listenerManager.notify("progress",[this]),this._collection._notifyOperationChange())},Object.defineProperties(s.prototype,{id:{get(){return this._id},set(){throw new o(o.READ_ONLY,"Cannot modify id directly")}},type:{get(){return this._type},set(){throw new o(o.READ_ONLY,"Cannot modify type directly")}},data:{get(){return this._data},set(){throw new o(o.READ_ONLY,"Cannot modify data directly")}},progress:{get(){return this._progress},set(){throw new o(o.READ_ONLY,"Cannot modify progress directly")}}}),s.prototype.addProgressListener=function(e){this._listenerManager.add("progress",e)},s.prototype.removeProgressListener=function(e){this._listenerManager.remove("progress",e)},s.prototype.cancel=function(){r.SHARED_LOCAL_STORAGE?i.storageInterface.cancelOperation(this._collection,this._id):this._cancelCallback&&this._cancelCallback()},Object.freeze(s),Object.seal(s.prototype),e.exports=s},function(e,t,n){const o=n(53),i=n(1),r=n(0),a=n(9),s=n(12),c=n(2),l={},p=/^[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;l.importLibrary=((e,t,n,i)=>{let r,p;const d=(t,n)=>{if(p&&(t=new c(c.OPERATION_CANCELLED,"import cancelled")),t)return void i(t);r=void 0;const o=n.libraryId,l=n.extractPath,d=e._getCompositeDir(o),u=e=>{a.recursiveDeleteDirectory(l),a.recursiveDeleteDirectory(d),i(e)};a.rename(l,d,t=>{if(t)return u(s.getFileSystemError(t,"unable to move extracted zip after import"));e._loadLibrary(o,t=>{if(t)return u(t);const n=e.getLibraryById(o);if(!n)return u(new c(c.INVALID_DATA,"could not load library after import"));e._notifyChange(!0),n._push(),i(null,n)})})};return o.isSnapshot(t,(i,a)=>{if(i||p)return void d(i&&s.getSnapshotError(i,void 0,"error opening library archive"));const c=e._getTempDir();if(a){const i=e._syncManager.getSyncGroupPath();r=o.importSnapshot(t,c,i,!1,n,(e,t)=>{!e&&t?d(null,{libraryId:t.id,extractPath:t.path}):d(s.getSnapshotError(e,void 0,"cannot import the snapshot file"))})}else r=l._importNonSnapshotLibrary(e,t,c,n,d)}),()=>{p||(p=!0,r&&r())}}),l._importNonSnapshotLibrary=((e,t,n,o,l)=>{const d=r.getPathSeparator(),u=r.fs,h=r.yauzl;if(!h)return void l(new c(c.NOT_SUPPORTED,"yauzl (unzip) module not present"));const _=r.uuid(),f=n+r.getPathSeparator()+_,m=e._syncManager.getCompositePath(_);let E,g=!1,y=-1,v=0,A=0;let C=!1;const I=e=>{C||(C=!0,e&&a.recursiveDeleteDirectory(f),l(e,e?void 0:{libraryId:_,extractPath:f}))},S=f+d+"components";return a.ensurePathExists(S,e=>{e?I(s.getFileSystemError(e,"unable to create temp dir")):h.open(t,{lazyEntries:!0},(e,t)=>{e?-1!==["EPERM","EACCES","ENOENT"].indexOf(e.code)?I(s.getFileSystemError(e,"error opening library archive")):I(new c(c.INVALID_DATA,"error opening library archive: "+e)):((E=t).on("entry",e=>{y++,v=0,A=0,(e=>"data"===e.fileName||e.fileName.match(p))(e)?"data"!==e.fileName?(v=e.uncompressedSize,E.openReadStream(e,(t,n)=>{t?I(s.getFileSystemError(t,"error extracting zip file")):(n.on("end",()=>{E.readEntry()}),n.on("data",e=>{A+=e.length,(()=>{if(!g){let e=y/E.entryCount;v&&(e+=A/(v*E.entryCount)),o(Math.round(100*e))}})()}).on("error",e=>{I(s.getFileSystemError(e,"error extracting zip file"))}).pipe(u.createWriteStream(S+d+e.fileName)))})):E.openReadStream(e,(e,t)=>{if(e)return void I(s.getFileSystemError(e,"error reading zip file entry"));const n=[];t.on("data",e=>{n.push(e)}),t.on("error",e=>{I(s.getFileSystemError(e,"error extracting zip file"))}),t.on("end",()=>{const e=((e,t,n)=>{let o;try{o=JSON.parse(e)}catch(e){return null}if(!o||o.version!==i.EXPORT_VERSION)return null;const r=o.manifest,a=o.componentMap;return"object"!=typeof a||Object.keys(a).some(e=>"string"!=typeof a[e])?null:(r.id=t,r.local={version:2,change:1,compositeHref:n,"copyOnWrite#storageIds":o.componentMap},{json:o,manifest:r})})(Buffer.concat(n).toString(),_,m);e&&e.manifest?u.writeFile(f+d+"manifest",JSON.stringify(e.manifest,void 0,2),e=>{e?I(s.getFileSystemError(e,"unable to write manifest file")):E.readEntry()}):I(new c(c.INVALID_DATA,"unable to parse export data"))})}):E.readEntry()}).on("error",e=>{I(s.getFileSystemError(e,"error extracting zip file"))}).on("close",()=>{g?I(new c(c.OPERATION_CANCELLED,"import cancelled")):I()}),E.readEntry())})}),()=>{g||(g=!0,E&&E.close())}}),l.exportLibrary=((e,t,n,r)=>{let a;const l=o.exportSnapshot(e._dcxComposite,t,[i.REMOVED_ELEMENTS_NAME],n,t=>{r(a?new c(c.OPERATION_CANCELLED,"export cancelled"):t&&s.getSnapshotError(t,e.id,"cannot export a snapshot file"))});return()=>{a||(a=!0,l())}}),Object.seal(l),e.exports=l},function(e,t,n){var o=n(5);function i(){this._collections=[],this._listenerManager=new o(["change"])}i.prototype.getLibraryCollection=function(e,t){var n;return this._collections.forEach(function(o){o.isPublic||o.userId!==e||o.cloudId!==t||(n=o)}),n},i.prototype.getPublicLibraryCollection=function(e){var t;return this._collections.forEach(function(n){n.isPublic&&n.cloudId===e&&(t=n)}),t},i.prototype.addLibraryCollection=function(e){this._collections.push(e),this._listenerManager.notify("change")},i.prototype.removeLibraryCollection=function(e){var t=this._collections.indexOf(e);-1!==t&&(this._collections.splice(t,1),this._listenerManager.notify("change"))},i.prototype.removeAllLibraryCollections=function(){this._collections=[],this._listenerManager.notify("change")},i.prototype.getLoadedCollections=function(){return this._collections},i.prototype.addLoadedCollectionsListener=function(e){this._listenerManager.add("change",e)},i.prototype.removeLoadedCollectionsListener=function(e){this._listenerManager.remove("change",e)},Object.freeze(i),Object.seal(i.prototype),e.exports=i},function(e,t,n){var o=n(21),i=n(27),r=n(42),a=n(58),s=n(56),c=n(57),l=n(2),p=n(1),d=n(0),u=n(59),h=n(104),_=n(105),f=n(10),m=n(16),E=n(13),g=n(7),y=n(30);function v(e){this._collectionManager=e,this._acceptPushedBranchListeners=[],this._downloadRenditionListeners=[],this._rootListeners=[],this._baseBranches={},this._pendingSetRenditionCache={},this._portDiagnosis="UNKNOWN",this._logIndex=0,p.SHARED_LOCAL_STORAGE&&(this._connect(),this.fs=new _(this),d.hasFileSystem()||d.setFileSystem(this.fs))}var A=function(e){var t={};return t.isPublic=e.isPublic,t.userId=e.userId,t.cloudId=e.cloudId,t},C=function(e,t){var n=A(e.collection);return n[t||"id"]=e.id,n},I=function(e,t,n){var o=C(e.library,n);return o[t||"element"]=e.id,o},S=function(e){var t=I(e.element);return t.representation=e.id,t};v.prototype._getBase=function(e){var t=this._baseBranches[e];return t&&t.base},v.prototype._setBase=function(e,t){this._baseBranches[e]=this._baseBranches[e]||{},this._baseBranches[e].base=t},v.prototype._getLogIndex=function(){return this._logIndex++},v.prototype._getServicePort=function(e){var t=p.VULCAN_PREFIX+p.VULCAN_QUERY_REQUEST,n=p.VULCAN_PREFIX+p.VULCAN_QUERY_RESPONSE;function o(t){var n;try{n=JSON.parse(t)}catch(e){}n?e(null,n):e("NO_DATA")}if(d.vulcanCall)d.vulcanCall(t,"",n,o);else if(d.hasCEPVulcan()){var i,r=d.getVulcanInterface(),a=d.getVulcanMessage(),s=function(t){r.removeMessageListener(n,s),clearTimeout(i),t?o(r.getPayload(t)):e("NO_VULCAN_MESSAGE")};r.addMessageListener(n,s),i=setTimeout(s,p.VULCAN_QUERY_TIMEOUT);var c=new a(t);c.setPayload(""),r.dispatchMessage(c)}},v.prototype._connectToPort=function(e,t){const n=t&&t.port,o=t&&t.token,i=t&&t.https;if(this._portDiagnosis=t?t.portdiagnosis:"UNKNOWN",this._connectionPort=n,!this._isConnected&&n&&"SIMPLE_HOSTNAME_GOING_TO_PROXY"!==this._portDiagnosis){try{var r=new h(n,o,i);this._channel=new u(r),this._isConnected=!0}catch(e){}this._isConnected&&(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("fontcachechanged",this._onFontCacheChanged.bind(this)),this._channel.addListener("operationschanged",this._onOperationsChanged.bind(this)),this._channel.onOpen(this._sendConfiguration.bind(this)),this._channel.onClose(this._onDisconnect.bind(this)))}},v.prototype._connect=function(){this._getServicePort(this._connectToPort.bind(this))},v.prototype.shutdown=function(){this._collectionManager.removeAllLibraryCollections(),this._isConnected&&this._onDisconnect()},v.prototype._onDisconnect=function(){this._isConnected=!1,this._collectionManager.removeAllLibraryCollections(),this._channel.shutdown(),this._channel=void 0},v.prototype._sendConfiguration=function(){this._channel.send("configure",{CLIENT_DESCRIPTION:p.CLIENT_DESCRIPTION,RENDITION_SIZES:p.RENDITION_SIZES,FULL_RENDITION_CONFIG:p.FULL_RENDITION_CONFIG,SHARED_LOCAL_STORAGE_ANALYTICS:p.SHARED_LOCAL_STORAGE_ANALYTICS,LOCAL_SETTINGS:p.LOCAL_SETTINGS})},v.prototype._onEnvironmentInfo=function(e){this._serviceInfo=e,e.whitelistedDomains&&(p.WHITELISTED_DOMAINS=e.whitelistedDomains),e.elementActionProductMap&&y.updateElementActionMap(e.elementActionProductMap),e.deviceId&&(p.DEVICE_ID=e.deviceId),e.deviceDescription&&(p.DEVICE_DESCRIPTION=e.deviceDescription),e.maxElements&&(p.MAX_ELEMENTS=e.maxElements),e.maxRemovedElements&&(p.MAX_REMOVED_ELEMENTS=e.maxRemovedElements),e.maxComponentSize&&(p.MAX_COMPONENT_SIZE=e.maxComponentSize),e.localSettings&&(p.LOCAL_SETTINGS=Object.assign(e.localSettings,p.LOCAL_SETTINGS)),this._collectionManager._collections.forEach(function(e){e._listenerManager.notify("sync")})},v.prototype._onCollectionAdded=function(e){var t=this;p.ROOT_DIR=e.rootDir;var n,o=new f,i={USER_ID:e.userId,CLOUD_ID:e.cloudId,CLOUD_INFO:e.cloudInfo,STORAGE_HOSTNAME:e.storageHost,COLLABORATION_HOSTNAME:e.collaborationHost,CC_IMAGE_HOSTNAME:e.imageHost,CC_IMAGE_X_HOSTNAME:e.imageXHost,TYPEKIT_HOSTNAME:e.typekitHost,REQUIRES_COMMUNITY_SESSION:e.requiresCommunitySession};n=e.isPublic?new a(i):new r(i),e.libraries.forEach(function(e){o.addOperation(t.loadExistingLibrary,[n,e.id,e.path,e.manifest,e.deletedFromServer,e.renditionCache],t)}),o.run(function(){t._collectionManager.addLibraryCollection(n)})},v.prototype._getLibraryCollection=function(e){return e.isPublic?this._collectionManager.getPublicLibraryCollection(e.cloudId):this._collectionManager.getLibraryCollection(e.userId,e.cloudId)},v.prototype._onCollectionRemoved=function(e){var t=this._getLibraryCollection(e);t&&this._collectionManager.removeLibraryCollection(t)},v.prototype._onClearCollections=function(){this._collectionManager.removeAllLibraryCollections()},v.prototype._onSyncState=function(e){var t=this._getLibraryCollection(e);t&&(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 l(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"))},v.prototype._onLibraryChange=function(e){var t=this._getLibraryCollection(e);if(t){var n=t.getLibraryById(e.id);n?(d.log("onLibraryChange: "+n.id),n._deletedFromServer!==e.deletedFromServer&&(n._deletedFromServer=e.deletedFromServer,n._notifyChange()),e.renditionCache=e.renditionCache||{},n._setRenditionCache(e.renditionCache),this.updateExistingLibrary(t,n,e.manifest,void 0,this._getBase(n.id),function(){n._setRenditionCache(e.renditionCache)})):this.loadExistingLibrary(t,e.id,e.path,e.manifest,e.deletedFromServer,e.renditionCache)}},v.prototype._onRenditionCacheChange=function(e){var t=this._getLibraryCollection(e),n=t&&t.getLibraryById(e.id),o=n&&n.getElementById(e.elementId);o&&e.renditionCache&&(o._renditionCache=e.renditionCache,o._listenerManager.notify("change"))},v.prototype._onOperationsChanged=function(e){var t=this._getLibraryCollection(e),n={};e.operations.forEach(function(e){t._updateOperation(e.id,e.type,e.data,e.progress),n[e.id]=!0}),Object.keys(t._operationIdMap).forEach(function(e){n[e]||t._delayedRemoveOperation(t._operationIdMap[e])})},v.prototype._onLibraryDeleted=function(e){var t=this._getLibraryCollection(e);t&&this._deleteLibrary(t,e.id)},v.prototype._onBookmarksChanged=function(e){var t=this._getLibraryCollection(e);if(t&&e.bookmarks){var n=[];e.bookmarks.forEach(function(e){n.push(new c(e._id,e._url))}),t._bookmarkManager._bookmarks=n}},v.prototype._onFontCacheChanged=function(e){var t=this._getLibraryCollection(e);t&&t.fontManager&&t.fontManager._clearCache()},v.prototype.isConnected=function(){return this._isConnected},v.prototype.reconnect=function(){this._isConnected||this._connect()},v.prototype.getServiceInfo=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}},v.prototype.updateConfiguration=function(){p.SHARED_LOCAL_STORAGE&&this._isConnected&&this._channel&&this._sendConfiguration()},v.prototype.sync=function(e){this._channel.send("sync",A(e))},v.prototype.setSyncEnabled=function(e){this._channel.send("configuresync",{enable:e})},v.prototype.commitManifest=function(e,t){var n=this;if(p.SHARED_LOCAL_STORAGE){var o=e._dcxBranch.localData,i=this._pendingSetRenditionCache[e.id]||{data:[],callbacks:[]};delete this._pendingSetRenditionCache[e.id];var r=C(e);r.current=o,r.base=this._getBase(e.id),r.renditions=i.data,d.log("Start commit"),this._channel.call("commit",r,function(a){if(d.log("Finish commit: "+(a.success?"success":"fail")),a.success){if(d.log("Update base after commit"),n._setBase(e.id,o),a.renditions){const t={};a.renditions.forEach(function(n,o){if(n){var r=n.split("/").pop(),a=i.data[o],s=e.getElementById(a.element);s&&(s._renditionCache=s._renditionCache||{},s._renditionCache[a.size]=r,t[s.id]=s);var c=i.callbacks[o];c&&c(null,n)}}),Object.keys(t).forEach(e=>t[e]._listenerManager.notify("change"))}}else n._pendingSetRenditionCache[e.id]=i,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(),t(n,!0)})})})},v.prototype.resolvePullWithBranch=function(e,t,n,o,i){d.log("resolvePullWithBranch"),p.SHARED_LOCAL_STORAGE?(e._dcxComposite._current=t,this._setBase(e.id,n),d.log("Finished resolvePullWithBranch: shared local storage"),i()):o?e._dcxLock.obtain(function(){e._dcxComposite._current=t,e._dcxLock.release(),d.log("Finished resolvePullWithBranch: local merge"),i()}):e._dcxLock.obtain(function(){e._dcxComposite.resolvePullWithBranch(t,function(t,n){e._dcxLock.release(),e._commit(!0,!0),e._waitForCommit(function(){d.log("Finished resolvePullWithBranch: remote merge"),i(t,n)})})})},v.prototype.acceptPush=function(e,t){var n=this;d.log("acceptPush"),e._dcxLock.obtain(function(){e._dcxComposite.acceptPush(function(o){e._dcxLock.release(),d.log("Finished acceptPush"),n._acceptPushedBranchListeners.forEach(function(t){t(e)}),t(o)})})},v.prototype.onAcceptPushedBranch=function(e){this._acceptPushedBranchListeners.push(e)},v.prototype.removeOnAcceptPushedBranchListeners=function(){this._acceptPushedBranchListeners=[]},v.prototype._deleteLibrary=function(e,t){d.log("deleteLibrary");var n=e.getLibraryById(t);if(n){var o=e._libraries.indexOf(n);-1!==o&&(e._libraries.splice(o,1),delete e._libraryIdMap[n.id]),n._markDeletedLocally(!0),e._notifyChange(!0)}},v.prototype._loadBranch=function(e,t,n){var o;try{(o=new i(void 0,n).parse(t))._localStorage=e._localStorage}catch(e){}return o},v.prototype._addLibrary=function(e,t,n,i,r){n=n||e._getCompositeDir(t);var a=new o(null,null,n,null,null,{preserveFileExtensions:!0}),c=this._loadBranch(a,i,!1);if(c)if("pendingDelete"!==c.compositeState){a._current=c,this._setBase(t,i);var p=new s(e,a);e.isPublic&&(p._publicId=t,p._writable=!1),e._libraries.push(p),e._libraryIdMap[p.id]=p,e._notifyChange(!0),r(null,p)}else r(null);else r(new l(l.CORRUPTED_LIBRARY,"Library corrupted in local storage",t))},v.prototype.createNewLibrary=function(e,t,n,o){var i=g.wrapCallback(o);d.log("createNewLibrary"),this._addLibrary(e,t,void 0,n,function(e,t){!e&&t?(t._commit(!1,!0),t._waitForCommit(i)):i(e)})},v.prototype.loadExistingLibrary=function(e,t,n,o,i,r,a){var s=g.wrapCallback(a);d.log("loadExistingLibrary"),this._addLibrary(e,t,void 0,o,function(e,t){!e&&t?(t._deletedFromServer=i,r&&t._setRenditionCache(r),s(null,t)):s(e)})},v.prototype.updateExistingLibrary=function(e,t,n,o,i,r){var a=this,s=g.wrapCallback(r),c="updateExistingLibrary["+this._getLogIndex()+"]: ";if(m.areManifestsEqual(t._dcxBranch.localData,n))return d.log(c+"already up-to-date"),void s();var u=this._loadBranch(t._dcxComposite,n,!1);if(d.log(c+"changes to update (state = "+(u&&u.compositeState)+")"),u){var h=m.ensureBranchDataValid(u);d.log(c+"fixed branch data: "+h),"pendingDelete"===u.compositeState?(e._doRemoveLibrary(t),s()):t._waitForCommit(function(){if(o){if(!m.areManifestsEqual(t._dcxBranch.localData,o))return d.log(c+"Commit aborting: something changed and it's no longer a fast-forward"),void s(!0)}else o=a._getBase(t.id);if(i&&o!==i)return d.log(c+"Commit aborting: base manifest changed before we got chance to update!"),void s(!0);var e=a._loadBranch(t._dcxComposite,o,!0)||u;d.log(c+"base "+e.changeCount+" -> updated "+u.changeCount),t._mergeAndSwitchToBranch(u,e,function(){d.log(c+"finished merge"),p.SHARED_LOCAL_STORAGE?s(null):(t._commit(!1,!0),t._waitForCommit(s))})})}else s(new l(l.CORRUPTED_LIBRARY,"Invalid manifest",t.id))},v.prototype.setRenditionCache=function(e,t,n,o){var i=this._pendingSetRenditionCache[e.library.id],r=E.addToPendingSetRenditionCache(i,e,t,n,o);this._pendingSetRenditionCache[e.library.id]=r},v.prototype.getRenditionPath=function(e,t,n,o){o=o||0;var i=this,r=g.wrapCallback(n),a=e._lookupRenditionPath(t||"full");if(a)r(null,a);else{var s=I(e);s.size=t,d.log("Get rendition path from CCLibrary process"),this._channel.call("getrenditionpath",s,function(a){if(!a&&o<p.LOCAL_RENDITION_MAX_RETRIES)return d.log("getrenditionpath: rendition not found"),void setTimeout(function(){i.getRenditionPath(e,t,n,o+1)},p.LOCAL_RENDITION_RETRY_INTERVAL);r(null,a)})}},v.prototype.notifyDownloadRendition=function(e){this._downloadRenditionListeners.forEach(function(t){t(e)})},v.prototype.onDownloadRendition=function(e){this._downloadRenditionListeners.push(e)},v.prototype.removeOnDownloadRenditionListeners=function(){this._downloadRenditionCacheListeners=[]},v.prototype.notifyStartWrite=function(e,t,n){var o=g.wrapCallback(n);if(p.SHARED_LOCAL_STORAGE){var i=C(e);i.dependencies=[],t.forEach(function(e){i.dependencies.push(C(e))}),this._channel.call("startcomponentwrite",i,function(){o(null)})}else o(null)},v.prototype.loadPublicLibrary=function(e,t,n,o){var i=g.wrapCallback(o),r=A(e);r.id=t,r.url=n,this._channel.call("loadpubliclibrary",r,function(){i(null)})},v.prototype.unloadPublicLibrary=function(e,t){var n=g.wrapCallback(t),o=C(e);this._channel.call("unloadpubliclibrary",o,function(){n(null)})},v.prototype.getAssetFromURL=function(e,t,n,o,i){if(p.SHARED_LOCAL_STORAGE){var r=A(e);r.url=t,r.headers=n,r.tempDir=o,this._channel.call("downloadfile",r,function(e){i(e.err,e.tempFilePath,e.etag,{headers:e.responseHeaders})})}else e._syncManager.getAssetFromURL(t,n,o,void 0,i)},v.prototype.doHeadRequestOfURL=function(e,t,n){p.SHARED_LOCAL_STORAGE?n(null):e._syncManager.doHeadRequestOfURL(t,n)},v.prototype.downloadExternalLink=function(e,t){d.log("Download external link from CCLibrary process"),this._channel.call("downloadexternallink",S(e),function(e){t(e.err,e.path)})},v.prototype.testExternalLink=function(e,t){d.log("Test external link via CCLibrary process"),this._channel.call("testexternallink",S(e),function(e){t(e.err,e.success)})},v.prototype.clearCachedExternalLink=function(e){d.log("Clear cached external link via CCLibrary process"),this._channel.send("clearcachedexternallink",S(e))},v.prototype.createBookmark=function(e,t,n,o){var i=g.wrapCallback(o),r=A(e);r.id=t,r.url=n,this._channel.call("createBookmark",r,function(e){var t=e&&e.err,n=e&&e.bookmark;n&&(n=new c(n._id,n._url)),i(t,n)})},v.prototype.removeBookmark=function(e,t,n){var o=g.wrapCallback(n),i=A(e);i.id=t.id,this._channel.call("removeBookmark",i,function(e){o(e)})},v.prototype.sendElementAction=function(e,t){var n=g.wrapCallback(t),o=I(e.element,"elementId","libraryId");o.appCode=e.appCode,o.minVersion=e.minAppVersion,o.action=e.id,this._channel.call("performElementAction",o,function(e){n(e.err,e.data)})},v.prototype.getImageDimensions=function(e,t){this._channel.call("getImageDimensions",e,function(e){t(e.data)})},v.prototype.importLibrary=function(e,t,n,o){var i=g.wrapCallback(o),r=A(e);r.path=t,r.operationId=n,this._channel.call("importlibrary",r,function(t){i(t.err,e.getLibraryById(t.libraryId))})},v.prototype.exportLibrary=function(e,t,n,o){var i=g.wrapCallback(o),r=C(e);r.path=t,r.operationId=n,this._channel.call("exportlibrary",r,function(e){i(e.err)})},v.prototype.cancelOperation=function(e,t){var n=A(e);n.operationId=t,this._channel.send("canceloperation",n)},v.prototype.getFontData=function(e,t,n){var o=g.wrapCallback(n),i=A(e);i.fontId=t,this._channel.call("getfontdata",i,function(e){o(e.err,e.data)})},Object.freeze(v),Object.seal(v.prototype),e.exports=v},function(e,t,n){var o=n(1),i=n(5);function r(e,t,n=!1){let r=n?`wss://localhost:${e}`:`ws://127.0.0.1:${e}`;r+=`/?version=${o.SHARED_LOCAL_STORAGE_VERSION}`,t&&(r+=`&token=${t}`),this._socket=new WebSocket(r),this._socket.onopen=this._onSocketOpen.bind(this),this._socket.onclose=this._onSocketClose.bind(this),this._socket.onmessage=this._onSocketMessage.bind(this),this._socket.onerror=this._onSocketError.bind(this),this._listenerManager=new i(["open","close","message","error"])}r.prototype._onSocketOpen=function(){this._listenerManager.notify("open")},r.prototype._onSocketClose=function(){this._listenerManager.notify("close")},r.prototype._onSocketMessage=function(e){this._listenerManager.notify("message",[e.data])},r.prototype._onSocketError=function(e){this._listenerManager.notify("error",[e])},r.prototype.send=function(e){this._socket.send(e)},r.prototype.addListener=function(e,t){this._listenerManager.add(e,t)},r.prototype.removeListener=function(e,t){this._listenerManager.remove(e,t)},r.prototype.close=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()},Object.freeze(r),Object.seal(r.prototype),e.exports=r},function(e,t,n){var o=n(2),i=n(7),r={rename:!0,renameSync:!1,ftruncate:!1,ftruncateSync:!1,truncate:!1,truncateSync:!1,chown:!1,chownSync:!1,fchown:!1,fchownSync:!1,lchown:!1,lchownSync:!1,chmod:!1,chmodSync:!1,fchmod:!1,fchmodSync:!1,lchmod:!1,lchmodSync:!1,stat:!0,lstat:!1,fstat:!1,statSync:!1,lstatSync:!1,fstatSync:!1,link:!1,linkSync:!1,symlink:!1,symlinkSync:!1,readlink:!1,readlinkSync:!1,realpath:!1,realpathSync:!1,unlink:!0,unlinkSync:!1,rmdir:!0,rmdirSync:!1,mkdir:!0,mkdirSync:!1,readdir:!0,readdirSync:!1,close:!1,closeSync:!1,open:!1,openSync:!1,utimes:!0,utimesSync:!1,futimes:!1,futimesSync:!1,fsync:!1,fsyncSync:!1,write:!1,writeSync:!1,read:!1,readSync:!1,readFile:!0,readFileSync:!1,writeFile:!0,writeFileSync:!1,appendFile:!1,appendFileSync:!1,watchFile:!1,unwatchFile:!1,watch:!1,exists:!0,existsSync:!1,createReadStream:!1,createWriteStream:!1};function a(e){this._storageInterface=e}a.prototype._fsCall=function(e,t,n){var o=i.wrapCallback(n),r={method:e,args:t};this._storageInterface._channel.call("fscall",r,function(e){o.apply(null,e)})},a.prototype._pipeCall=function(e,t,n,o){var r=i.wrapCallback(o),a={readStream:{path:e,options:t},writeStream:n};this._storageInterface._channel.call("fspipe",a,r)},Object.keys(r).forEach(function(e){a.prototype[e]=r[e]?function(){var t,n=Array.prototype.slice.call(arguments);"function"==typeof n[n.length-1]&&(t=n.pop()),this._fsCall(e,n,t)}:function(){var t=new o(o.NOT_IMPLEMENTED,e+" is not implemented in shared local storage"),n=arguments[arguments.length-1];if("function"!=typeof n)throw t;n(t)}}),a.prototype.createReadStream=function(e){var t=this,n={on:function(e,t){n[e]=t},pipe:function(o,i){t._pipeCall(e,i,o,function(e){n[e.event]&&n[e.event].apply(null,e.args)})}};return n},a.prototype.createWriteStream=function(e,t){return{path:e,options:t}},Object.freeze(a),Object.seal(a.prototype),e.exports=a},function(e,t,n){var o=n(0),i=n(28),r=n(13),a=n(9),s={mimeTypeToExtensions:function(e){return i.getExtensions(e)},extensionToMimeTypes:function(e){return i.getMimeTypes(e)},canGenerateRenditionFromMimeType:function(e){return r.canComputeRenditionFromMimeType(e)},generateUuid:function(){return o.uuid()},copyFile:function(e,t,n){return a.copyFile(e,t,n)}};Object.seal(s),e.exports=s},function(e,t,n){var o=n(18),i={reportUseElement:function(e,t,n){o.reportUseElement(e,t,n)},reportCheckoutElement:function(e,t,n){o.reportCheckoutElement(e,t,n)},reportCreateLink:function(e,t){o.reportCreateLink(e,t)},reportShareElementLink:function(e){o.reportShareElementLink(e)},reportShareLibraryLink:function(e){o.reportShareLibraryLink(e)}};Object.seal(i),e.exports=i},function(e,t,n){var o=n(32),i=n(109),r=n(4),a={obtainProcessLock:function(e,t){var n=r.getValue("ROOT_DIR");o.ensureDir(n,function(o){if(o)return console.error("Error: Could not create root directory: "+n),void t(!1);var r=i.openSync(n+"."+e,"w");i.flock(r,"exnb",function(e){if(e)return console.error("Error: CCLibrary process is already running."),void t(!1);t(!0)})})},clearTempFiles:function(e){try{var t=o.readdirSync(e);t&&t.forEach(function(t){if(-1!==t.indexOf(".TEMP_"))try{o.unlinkSync(e+"/"+t)}catch(e){}})}catch(e){}}};e.exports=a},function(e,t){e.exports=require("fs-ext")},function(e,t,n){var o,i=n(20),r=n(33),a=n(4),s=n(1),c=n(30),l=n(34),p={};p.getLibraryData=function(e){return{isPublic:e.collection.isPublic,userId:e.collection.userId,cloudId:e.collection.cloudId,id:e.id,path:e._dcxComposite.path,manifest:e._dcxBranch.localData,deletedFromServer:e._deletedFromServer,isDeletedFromServer:e._deletedFromServer,renditionCache:e._getRenditionCache()}},p.getElementRenditionCacheData=function(e){return{isPublic:e.library.collection.isPublic,userId:e.library.collection.userId,cloudId:e.library.collection.cloudId,id:e.library.id,elementId:e.id,renditionCache:e._renditionCache}},p.getDeletedLibraryData=function(e,t){return{isPublic:e.isPublic,userId:e.userId,cloudId:e.cloudId,id:t}},p.getSyncStateData=function(e){var t={isPublic:e.isPublic,userId:e.userId,cloudId:e.cloudId,state:e._syncState,libraryStates:[],progress:e._syncProgress,progressMap:e._syncProgressMap,externalLinkDownloadProgressMap:e._externalLinkDownloadProgressMap,newLibraryProgress:e.getNewLibrarySyncProgress(),errors:[],initialSyncInProgress:e._initialSyncInProgress};return e.libraries.forEach(function(e){t.libraryStates.push({id:e.id,state:e._syncState})}),e._syncErrors.forEach(function(e){t.errors.push({code:e.code,message:e._message,libraryId:e.libraryId})}),t},p.prepareErrorForSerialization=function(e,t){return t=t||[e],Object.keys(e).forEach(function(n){if("underlyingError"===n&&e.underlyingError)-1===t.indexOf(e.underlyingError)?e.underlyingError=p.prepareErrorForSerialization(e.underlyingError,t.concat([e.underlyingError])):delete e.underlyingError;else try{JSON.stringify(e[n])}catch(t){delete e[n]}}),e},p.getCollectionData=function(e){var t={rootDir:e._rootDir,isPublic:e.isPublic,userId:e.userId,cloudId:e.cloudId,cloudInfo:e.cloudInfo,storageHost:e._syncManager._storageHost,collaborationHost:e._syncManager._collaborationHost,imageHost:e._syncManager._imageHost,imageXHost:e._syncManager._imageXHost,typekitHost:e._syncManager._typekitHost,requiresCommunitySession:e._syncManager._requiresCommunitySession,libraries:[]};return e.libraries.forEach(function(e){t.libraries.push(p.getLibraryData(e))}),t},p.getOperationsData=function(e){var t=e.operations.map(function(e){return{id:e.id,type:e.type,data:e.data,progress:e.progress}});return{isPublic:e.isPublic,userId:e.userId,cloudId:e.cloudId,operations:t}},p.getAPIVersion=function(){return s.SHARED_LOCAL_STORAGE_VERSION},p.getCodeVersion=function(e){var t=l.version;return e&&(t+="-17"),t},p.getDeviceDescription=function(e){if(!o||e){var t,n=i.platform(),a={darwin:"mac",win32:"win",win64:"win"}[n]||n;if("darwin"===n)try{t=r.execSync("sw_vers -productVersion",{timeout:1e3}).toString().trim()}catch(e){}else t=i.release();o=a,t&&(o+="-"+t)}return o},p.getEnvironmentData=function(e){var t;return void 0!==e&&e<s.SHARED_LOCAL_STORAGE_MIN_CLIENT_VERSION&&(t="client"),void 0!==e&&e>s.SHARED_LOCAL_STORAGE_MAX_CLIENT_VERSION&&(t="server"),{updateRequired:t,version:p.getAPIVersion(),codeVersion:p.getCodeVersion(),buildNumber:"17",environment:a.getEnvironment().LABEL,syncingEnabled:s.SYNCING_ENABLED,whitelistedDomains:s.ADOBE_AUTHENTICATED_DOMAINS.concat(s.WHITELISTED_DOMAINS),elementActionProductMap:c.formatElementActionMapForClient(e),deviceId:s.DEVICE_ID,deviceDescription:s.DEVICE_DESCRIPTION,maxElements:s.MAX_ELEMENTS,maxRemovedElements:s.MAX_REMOVED_ELEMENTS,maxComponentSize:s.MAX_COMPONENT_SIZE,localSettings:s.LOCAL_SETTINGS}},e.exports=p},function(e,t,n){var o=n(19),i=n(4),r=n(8),a=n(11),s=n(10),c=n(13),l=n(31),p=n(1),d={updateRenditions:function(e,t,n,o){var i=e.getLibraryById(t),r=new s;n.forEach(function(e){var t=i&&i.getElementById(e.element);t?"CLEAR"===e.path?(delete t._renditionCache[e.size],l.supportsVectorRendition(t)&&delete t._renditionCache.vector,r.addOperation(function(e){e(null)})):r.addOperation(t.setThumbnailCache,[e.size,e.path],t):r.addOperation(function(e){e(null)})}),r.run(function(e,t,n){e?o(e):(i&&c.prefetchRenditions(i),o(null,n))})},mergeRenditionSizes:function(e){return c.addToRenditionSizeConfig(e),i.setValue("RENDITION_SIZES",p.RENDITION_SIZES)},mergeFullRenditionConfig:function(e){return c.addToFullRenditionConfig(e),i.setValue("FULL_RENDITION_CONFIG",p.FULL_RENDITION_CONFIG)},mergeLocalSettings:function(e){return Object.assign(p.LOCAL_SETTINGS,e),i.setValue("LOCAL_SETTINGS",p.LOCAL_SETTINGS)},triggerRenditionPrefetch:function(){a.getLoadedCollections().forEach(function(e){e.libraries.forEach(function(e){c.prefetchRenditions(e)})})},findElement:function(e,t){e=e||"";var n=new RegExp("cloud-asset://(.+)/([A-Za-z0-9-]+);node=([A-Za-z0-9-]+)"),o=e.match(n);if(o){var i,r,s,c=o[1],l=o[2],p=o[3];a.getLoadedCollections().every(function(e){return c!==e._syncManager.getElementRefDomainPath()||(i=e,(r=e.getLibraryById(l))&&(s=r.getElementById(p)),!1)}),s?t(null,s):0===a.getLoadedCollections().length?t("NO_COLLECTIONS_PRESENT"):i?r?r.sync(function(){(s=r.getElementById(p))?t(null,s):"error"===i.syncState?t("COLLECTION_SYNC_ERROR"):t("ELEMENT_NOT_FOUND")}):i.sync(function(){(r=i.getLibraryById(l))?d.findElement(e,t):"error"===i.syncState?t("COLLECTION_SYNC_ERROR"):t("LIBRARY_NOT_FOUND")}):t("COLLECTION_NOT_FOUND")}else t("UNPARSABLE_ELEMENT_REF")}};d.fixRenditions=function(e){const t=e&&e.filter(e=>!e.isPublic)[0],n=t&&t.userId;if(!n)return;const a="VALIDATE_RENDITIONS_"+n;if(i.getValue(a))return;i.setValue(a,!0);const s=i.getValue("VALIDATE_RENDITIONS_SIZE_THRESHOLD");r.log("VALIDATE_RENDITIONS","Rendition invalidation check starting"),e.forEach(e=>{e.libraries.forEach(e=>{let t=!1;e.elements.forEach(e=>{t=(e=>Object.keys(e._renditionCache).some(t=>{if(Number(t)){const n=e._lookupRenditionPath(t);if(n){let i;try{i=o.statSync(n)}catch(e){}if(i&&i.size>s)return r.log("VALIDATE_RENDITIONS",`Invalidating rendition - ${e.id} ${e.name} dimension: ${t} size: ${i.size}`),e._clearRenditionCache(),!0}}}))(e)||t}),t&&(e._commit(!0,!0),e._notifyChange())})}),r.log("VALIDATE_RENDITIONS","Rendition invalidation check ending")},e.exports=d},function(e,t,n){var o,i,r,a=n(36),s=n(4),c=n(8),l=n(60),p=n(17),d=n(11),u=n(43),h=n(115),_=n(1),f=n(5),m="ProductBridge",E="ProductBridgeLock",g=s.getValue("ROOT_DIR")+"librarylookupfile",y=new f(["syncBegin","syncEnd"]),v={},A={};function C(){r&&(clearTimeout(r),r=null)}function I(e){l.isLocked(E)||y.notify("syncBegin",[]),l.obtainLock(E,e)}function S(){l.releaseLock(E),l.isLocked(E)||y.notify("syncEnd",[])}function L(){return l.hasPendingRequest(E)}function O(){if(0!==Object.keys(v).length){var e=JSON.stringify(v);p.sendMessage(i?_.VULCAN_LIBRARY_CHANGED_LOCAL_TYPE:_.VULCAN_LIBRARY_CHANGED_REMOTE_TYPE,e),c.log(m,e),v={},i=null}}function R(e,t,n){0!==Object.keys(v).length&&(v[e]||i!==n)&&O(),v[e]=t,i=n}function N(e,t,n){C(),c.log(m,"Saving lookup file"),e.userId=a.getUserId(),h.saveLookupMap(g,e,function(i){if(i)return c.log(m,i.toString()),o=null,void n();o=e,C(),r=setTimeout(function(){r=null,o=null,c.log(m,"Released lookup file")},s.getValue("PRODUCT_BRIDGE_INMEMORY_LIFETIME")),t?p.sendMessage(_.VULCAN_COLLECTIONS_LOADED_TYPE):L()||O(),c.log(m,"Lookup file saved"),c.log(m,"Lookup library count: "+Object.keys(o.libraries).length),n()})}function T(e){if(o)return e(o);c.log(m,"Reading lookup file"),h.readLookupMap(g,function(t,n){if(t)return c.log(m,t),void e(null);c.log(m,"Lookup file read"),e(o=n)})}function D(e,t,n){c.log(m,"Update Callback Received"),I(function(){T(function(o){if(!o)return S(),void A.collectionsLoaded();var i=e&&e.library,r=i&&o.libraries[i.id];if(r){var a=r.elements[e.id];if(a&&h.updateElementLookupData(a,t)){a.mod=h.getElementModifiedTime(e);var s={name:i.name,domain:i._collection._syncManager.getElementRefDomain(),path:i._collection._syncManager.getElementRefPath(),elements:{}};return s.elements[e.id]=a,R(i.id,s,n),void N(o,!1,function(){S()})}}L()||O(),S()})})}A.collectionsLoaded=function(){c.log(m,"Collections Loaded"),I(function(){v={},i=null;var e=d.getLoadedCollections(),t={elementTypes:s.getValue("PRODUCT_BRIDGE_ELEMENT_TYPES")||[],libraries:{}};e&&e.forEach(function(e){e.libraries.forEach(function(e){t.libraries[e.id]=h.buildLibraryLookupData(e,D)})}),N(t,!0,function(){S()})})},A.collectionsUnloaded=function(){c.log(m,"Collections Unloaded"),I(function(){!function(e){C(),c.log(m,"Deleting lookup file"),h.deleteLookupMap(g,function(t){t&&c.log(m,t.toString()),o=null,c.log(m,"Lookup file deleted"),e()})}(function(){p.sendMessage(_.VULCAN_COLLECTIONS_UNLOADED_TYPE),S()})})},A.libraryChanged=function(e,t){c.log(m,"Library Changed - "+(t?"Local":"Remote")+": "+e.id),I(function(){T(function(n){if(!n)return S(),void A.collectionsLoaded();var o,i=n.libraries[e.id],r=!1,a=function(e,n){D(e,n,t)};if(i){o={elements:{}},i.name!==e.name&&(i.name=e.name,r=!0);var s=[];e.elements.forEach(function(e){if(h.shouldIncludeInLookupData(e)){var t,n,c,l=i.elements[e.id];if(!(n=(n=!l||l.mod!==h.getElementModifiedTime(e))||!l||l.stockLicense!==u.getElementStockLicense(e)))l.reps.forEach(function(e){e.path||(c=c||[]).push(e.id)}),c&&(n=(t=h.buildElementLookupData(e,a)).reps.some(function(e){return e.path&&c.indexOf(e.id)>-1}));n&&(t=t||h.buildElementLookupData(e,a),o.elements[e.id]=t,i.elements[e.id]=t,r=!0),s.push(e.id)}}),Object.keys(i.elements).forEach(function(e){-1===s.indexOf(e)&&(o.elements[e]=null,delete i.elements[e],r=!0)})}else{var c=h.buildLibraryLookupData(e,a);o=c,n.libraries[e.id]=c,r=!0}if(!r)return L()||O(),void S();o.name=e.name,o.domain=e._collection._syncManager.getElementRefDomain(),o.path=e._collection._syncManager.getElementRefPath(),R(e.id,o,t),N(n,!1,function(){S()})})})},A.libraryDeleted=function(e){c.log(m,"Library Deleted: "+e),I(function(){O(),T(function(t){if(!t)return S(),void A.collectionsLoaded();delete t.libraries[e],N(t,!1,function(){S(),p.sendMessage(_.VULCAN_LIBRARY_DELETED_TYPE,e)})})})},A.isSyncing=function(){return L()||l.isLocked(E)},A.addListener=function(e,t){y.add(e,t)},A.removeListener=function(e,t){y.remove(e,t)},e.exports=A},function(e,t){e.exports=require("node-imslib")},function(e,t){e.exports=require("node-vulcanjs")},function(e,t,n){var o=n(19),i=n(4),r=n(43),a=n(0),s=n(13),c={normalizePath:function(e){return i.isPlatformWindows()&&e?e.replace(/\//g,"\\"):e},getElementModifiedTime:function(e){return e.representations.some(function(e){return e.isExternalLink&&!e.getCachedContentPath()&&!e.getCachedExternalLinkError()})?e.modified-1:e.modified},updateElementLookupData:function(e,t){var n=!1;return Array.isArray(t.reps)&&t.reps.forEach(function(t){n=e.reps.some(function(n,o){if(n.id===t.id&&n.path!==t.path)return e.reps[o]=t,!0})||n}),void 0!==t.stockLicense&&t.stockLicense!==e.stockLicense&&(n=!0,e.stockLicense=t.stockLicense,null===e.stockLicense&&delete e.stockLicense),n},buildElementLookupData:function(e,t){var n=e.modified,o={name:e.name,type:i.getValue("PRODUCT_BRIDGE_ELEMENT_TYPES").indexOf(e.type),mod:c.getElementModifiedTime(e),reps:[]},a=r.getElementStockId(e),l=r.getElementStockLicense(e);if(a&&(o.stockId=a),l&&(o.stockLicense=l),e.wasModifiedLocally&&(o.local=!0),e.representations.forEach(function(i){var a=!i.isExternalLink||s.shouldPrefetchExternalLink(i);if(i.isCompatibleType(i.type)&&a){"primary"===i.relationship?o.reps.unshift({id:i.id}):o.reps.push({id:i.id});var p=!0;i.getContentPath(function(a,s){if(s){var d={reps:[{id:i.id,type:i.type,path:c.normalizePath(s)}]};(l=r.getElementStockLicense(e))&&(d.stockLicense=l),p?c.updateElementLookupData(o,d):n===e.modified&&t(e,d)}else i.isExternalLink&&r.getElementStockLicense(e)!==o.stockLicense&&t(e,{stockLicense:r.getElementStockLicense(e)||null})}),p=!1}else i.isCompatibleType(i.type)&&i.isExternalLink&&i.testExternalLink(function(){r.getElementStockLicense(e)!==o.stockLicense&&t(e,{stockLicense:r.getElementStockLicense(e)||null})})}),s.shouldPrefetchFullRendition(e)){o.reps.push({id:"FULL_RENDITION"});var p=!0;e.getThumbnailPath(void 0,function(i,r){if(r){var a={id:"FULL_RENDITION",type:"image/png",path:c.normalizePath(r)};p?c.updateElementLookupData(o,{reps:[a]}):n===e.modified&&t(e,{reps:[a]})}}),p=!1}return o},buildLibraryLookupData:function(e,t){var n={name:e.name,domain:e._collection._syncManager.getElementRefDomain(),path:e._collection._syncManager.getElementRefPath(),elements:{}};return e.elements.forEach(function(e){c.shouldIncludeInLookupData(e)&&(n.elements[e.id]=c.buildElementLookupData(e,t))}),n},saveLookupMap:function(e,t,n){var i=e+".TEMP_"+a.uuid();o.writeFile(i,JSON.stringify(t),function(t){t?n(t):o.rename(i,e,function(e){n(e)})})},readLookupMap:function(e,t){o.exists(e,function(n){n?o.readFile(e,"utf8",function(e,n){try{n=n&&JSON.parse(n)}catch(t){n=void 0,e=t}t(e,n)}):t(null)})},deleteLookupMap:function(e,t){o.exists(e,function(n){n?o.unlink(e,function(e){t(e)}):t(null)})},shouldIncludeInLookupData:function(e){return-1!==(i.getValue("PRODUCT_BRIDGE_ELEMENT_TYPES")||[]).indexOf(e.type)}};e.exports=c},function(e,t,n){var o,i=n(4),r=n(17),a=n(24),s=n(118),c=n(1);r.addListener(c.VULCAN_SHUTDOWN_REQUEST,function(){o?o():process.exit(0)}),r.addListener(c.VULCAN_QUERY_REQUEST,function(e,t,n){s.perform(function(e){var o={port:i.getValue("SERVICE_PORT"),token:i.getValue("SERVICE_TOKEN")};e&&(o.portdiagnosis=e),i.setValue("SERVICE_LAST_QUERY_TIME",(new Date).valueOf()),r.sendMessage(c.VULCAN_QUERY_RESPONSE,JSON.stringify(o),t,n)})}),r.addListener(c.VULCAN_PROXY_QUERY_REQUEST,function(e,t,n){var o={};try{o=JSON.parse(e)}catch(e){}var i={requestId:o.requestId};if(!o.url||"string"!=typeof o.url)return i.err="url parameter must be specified, and must be a string",void r.sendMessage(c.VULCAN_PROXY_QUERY_RESPONSE,JSON.stringify(i),t,n);a.getProxyForURL(o.url,function(e,o){if(e)i.err=e;else{var s=a.getProxyCredentials();i.proxyHost=o.hostname,i.proxyPort=o.port,i.proxyUser=s.user,i.proxyPassword=s.password}r.sendMessage(c.VULCAN_PROXY_QUERY_RESPONSE,JSON.stringify(i),t,n)})}),a.addListener("change",function(){r.sendMessage(c.VULCAN_PROXY_CHANGE_MESSAGE,"","","")});var l={setShutdownListener:function(e){o=e},sendStartupMessage:function(){r.sendMessage(c.VULCAN_STARTUP_MESSAGE,"","","")}};e.exports=l},function(e,t){e.exports=require("node-ProxyResolver")},function(e,t,n){var o=n(119),i=n(4),r=n(44),a=n(8),s=n(24),c=n(50),l={WORKING:"WORKING",DNS_RESOLUTION_FAILED:"DNS_RESOLUTION_FAILED",SIMPLE_HOSTNAME_GOING_TO_PROXY:"SIMPLE_HOSTNAME_GOING_TO_PROXY",COULD_NOT_CONNECT_SOCKET:"COULD_NOT_CONNECT_SOCKET"};function p(){return new Promise(function(e,t){var n=c.format({protocol:"ws",host:"localhost:"+i.getValue("SERVICE_PORT")+"/",slashes:!0,query:{diagnostics:!0,token:i.getValue("SERVICE_TOKEN")}}),o=new r(n,{origin:"file://"});o.on("error",function(e){t(l.COULD_NOT_CONNECT_SOCKET,e)}),o.on("open",function(){o.close(),e()})})}function d(){return new Promise(function(e,t){s.isLocalhostProxied(function(n,o){!0===o?t(l.SIMPLE_HOSTNAME_GOING_TO_PROXY):e()})})}e.exports.perform=function(e){new Promise(function(e,t){o.lookup("localhost",function(n,o){"127.0.0.1"!==o?(a.log("DIAGNOSTICS","Expected localhost to resolve to 127.0.0.1, but instead it resolved to "+o),t(l.DNS_RESOLUTION_FAILED,n,o)):e()})}).then(d).then(p).then(function(){e(l.WORKING)}).catch(function(t){a.log("DIAGNOSTICS",t),e(t)})},e.exports.RESULTS=l},function(e,t){e.exports=require("dns")},function(e,t,n){var o=n(17),i=n(8),r=n(4),a=n(25),s=n(24),c=n(7),l=n(5),p=n(0);function d(e,t){var n=null;if(e){var o=new RegExp("<"+t+"[^<>]*>([^<>]*)</"+t+">",""),i=e.match(o);n=i&&i[1]}return n}function u(e){return e.replace("{{uuid}}",p.uuid())}var h=new l(["signIn","signOut","proxySettingsChanged","installApplication","uninstallApplication","updateApplication"]);o.addListener("accc.localapps.panel.refresh.ssoevent",function(e){var t=d(e,"event_type");i.log("Thor","ACCC Sign-on State: "+t),"signin_success"===t?h.notify("signIn"):"signout_success"===t&&h.notify("signOut")}),o.addListener("com.adobe.aam.AAMIMSStatus",function(e){var t=d(e,"Status");i.log("Thor","AAM Sign-on State: "+t),"USER_AUTH_SUCCESS"===t&&h.notify("signIn")}),o.addListener("com.adobe.aam.AAMSIGNOUTStatus",function(){i.log("Thor","AAM Sign-on State: signOut"),h.notify("signOut")}),o.addListener("any.accc.app.ProductDeploymentEvent",function(e){var t={productCode:function(e){var t=e;return"PHSP"===e&&(t="PHXS"),t}(d(e,"productCode")),productVersion:d(e,"productVersion"),productLanguage:d(e,"productLanguage"),countryCode:d(e,"countryCode"),subscriptionStatus:d(e,"subscriptionStatus")};switch(d(e,"eventType")){case"Install":h.notify("installApplication",[t]);break;case"Uninstall":h.notify("uninstallApplication",[t]);break;case"Update":h.notify("updateApplication",[t])}}),o.addListener("any.accc.app.ProxySettingsChanged",function(e){var t=d(e,"proxyuser"),n=d(e,"proxypassword");null!==t&&null!==n&&h.notify("proxySettingsChanged",[t,n])});var _={addListener:function(e,t){h.add(e,t)},removeListener:function(e,t){h.remove(e,t)},removeAllListeners:function(e){h.removeAll(e)},getProxyCredentials:function(e){s.getProxyForURL("https://adobe.com",function(t,n){if(n&&n.hostname){var i={requestType:"accc.app.ProxySettingsRequest",responseType:"accc.app.ProxySettingsResponse",payload:u('<?xml version="1.0" encoding="utf-8"?><request><type>accc.app.ProxySettingsRequest</type><request_id>{{uuid}}</request_id></request>'),targetId:"ADCS",targetVersion:"",timeout:r.getValue("PROXY_REQUEST_TIMEOUT")};o.call(i,function(t,n){if(t)return a.reportError("GetProxySettingsError","timed out getting proxy settings from Thor"),void e(null,null);var o=d(n,"proxyuser"),i=d(n,"proxypassword");a.reportEvent("getProxySettings",{isAuthenticatingProxy:!!o}),e(o,i)})}else e(null,null)})},configureFileSyncing:function(e,t){var n=c.wrapCallback(t),i=function(){var t={requestType:"accc.files.setFilesSyncStatusRequest",responseType:"adbproduct.files.setFilesSyncStatusResponse",payload:u(e?'<?xml version="1.0" encoding="utf-8"?><request><sync>on</sync><request-id>{{uuid}}</request-id></request>':'<?xml version="1.0" encoding="utf-8"?><request><sync>off</sync><request-id>{{uuid}}</request-id></request>'),targetId:"ADCS",targetVersion:"",timeout:r.getValue("CONFIGURE_SYNC_TIMEOUT")};o.call(t,function(e){e&&a.reportError("ConfigureFileSyncError","timed out turning on/off file sync via Thor"),n(e)})};o.isAppRunning("creativecloud")?i():o.launchApp("creativecloud",!1,"--showwindow=false",function(){setTimeout(i,r.getValue("THOR_LAUNCH_WAIT"))})}};e.exports=_},function(e,t,n){"use strict";function o(e,t){var n=e.toString();if(n.length<t){var o=[];o.length=t-n.length+1,n=o.join("0")+n}return n}function i(e,t){return Object.getOwnPropertyNames(t).forEach(function(n){if("object"==typeof t[n])"object"!=typeof e[n]&&(e[n]={}),i(e[n],t[n]);else{var o=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,o)}}),e}function r(e,t,n){e.forEach(function(e){setTimeout(function(){e(t,n)})})}var a={prod:"cc-api-data.adobe.io",stage:"cc-api-data-stage.adobe.io",dev:"cc-api-data-dev.adobe.io"},s={ENVIRONMENT:"prod",ALLOW_NO_TOKEN:!1,ANALYTICS_INGEST_TYPE:"dunamis",ANALYTICS_MAX_QUEUED_EVENTS:50,ANALYTICS_DEBOUNCE:1e4,ANALYTICS_API_KEY:null,ANALYTICS_X_PRODUCT:null,ANALYTICS_X_PRODUCT_LOCATION:void 0,ANALYTICS_PROJECT:null,ANALYTICS_USER_REGION:"UNKNOWN",TIMESTAMP_PROPERTY_NAME:"event.dts_end"},c=["ANALYTICS_API_KEY","ANALYTICS_X_PRODUCT","ANALYTICS_PROJECT"];function l(e,t){var n=this;e=e||{},t=t||{};var o=function(e){throw n._log(e),new Error("ERROR: "+e)};this._queuedEvents=[],this._queuedCallbacks=[],this._lastSendTime=0,this._isEnabled=!1,this._dependencies=i({},e),e.getAccessToken&&"function"==typeof e.getAccessToken||o("Missing dependency: getAccessToken"),this._options={},Object.keys(s).forEach(function(e){this._options[e]=t[e]||s[e]},this),c.forEach(function(e){this._options[e]||o("Missing option: "+e)},this)}l.prototype._log=function(e){var t=this._dependencies.log;t&&t("Ingest :: "+e)},l.prototype._getAgent=function(e,t){this._dependencies.getAgent?this._dependencies.getAgent(e,t):t(null,{})},l.prototype._getAccessToken=function(e){this._dependencies.getAccessToken(e)},l.prototype._clearAccessToken=function(){this._dependencies.clearAccessToken&&this._dependencies.clearAccessToken()},l.prototype._getEnvironment=function(){return a[this._options.ENVIRONMENT]?this._options.ENVIRONMENT:"prod"},l.prototype._getAnalyticsHost=function(){return a[this._getEnvironment()]},l.prototype._formatTimestamp=function(e){var t=e.getFullYear(),n=o(e.getMonth()+1,2),i=o(e.getDate(),2),r=o(e.getHours(),2),a=o(e.getMinutes(),2),s=o(e.getSeconds(),2),c=o(e.getMilliseconds(),3),l=e.getTimezoneOffset(),p=l<0?"+":"-",d=Math.floor(Math.abs(l)/60),u=Math.abs(l)%60;return t+"-"+n+"-"+i+"T"+r+":"+a+":"+s+"."+c+(p+o(d,2)+o(u,2))},l.prototype._updateDebounce=function(e){var t=e&&(e["retry-after"]||e["Retry-After"]),n=0;if(t){var o;try{o=parseInt(t,10)}catch(e){}if(o)n=Math.max(0,o);else{var i=Date.parse(t);if(i){var r=(new Date).valueOf();n=Math.max(0,i-r)/1e3+Math.floor(10*Math.random())}}}this._options.ANALYTICS_DEBOUNCE=Math.max(1e3*n,this._options.ANALYTICS_DEBOUNCE)},l.prototype._queueEvent=function(e){this._queuedEvents.length>=this._options.ANALYTICS_MAX_QUEUED_EVENTS&&this._queuedEvents.shift(),this._queuedEvents.push(e)},l.prototype._requeueEvents=function(e){this._queuedEvents=e.concat(this._queuedEvents),this._queuedEvents=function(e,t){var n=e;if(e&&e.length>t&&t>0){var o=e.length-t;n=e.slice(o,e.length)}return n}(this._queuedEvents,this._options.ANALYTICS_MAX_QUEUED_EVENTS)},l.prototype._sendAnalytics=function(e,t,o){var a=this;if(o=o||0,t&&this._queuedCallbacks.push(t),!this._isEnabled||0===this._queuedEvents.length){var s=this._queuedCallbacks;return this._queuedCallbacks=[],void(this._isEnabled?r(s,null,0):r(s,new Error("Analytics Disabled")))}var c=this._options.ANALYTICS_DEBOUNCE;if(e&&(c=0,clearTimeout(this._pendingSendAnalyticsTimeout),this._pendingSendAnalyticsTimeout=void 0),this._sendingEvents||this._pendingSendAnalyticsTimeout)this._log("Queued "+this._queuedEvents.length+" events to be sent.");else{var l=(new Date).valueOf();if(l-this._lastSendTime<c)this._pendingSendAnalyticsTimeout=setTimeout(function(){a._pendingSendAnalyticsTimeout=void 0,a._sendAnalytics()},c);else{this._lastSendTime=l,this._sendingEvents=this._queuedEvents,this._sendingCallbacks=this._queuedCallbacks,this._queuedEvents=[],this._queuedCallbacks=[];var p=function(){var e=function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)};return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()}(),d="["+p+"] ",u={events:this._sendingEvents},h=function(e){var t=a._queuedEvents.length,n=a._sendingEvents.length;e?(a._requeueEvents(a._sendingEvents),a._log(d+"Error sending "+n+" events: "+e)):a._log(d+"Success sending "+n+" events: "+JSON.stringify(a._sendingEvents)),delete a._sendingEvents;var o=a._sendingCallbacks;delete a._sendingCallbacks,e?r(o,e):r(o,null,n),t>0&&a._sendAnalytics()},_=function(e,t){if(a._updateDebounce(t),401===e&&0===o)return a._clearAccessToken(),a._requeueEvents(a._sendingEvents),delete a._sendingEvents,a._queuedCallbacks=a._sendingCallbacks.concat(a._queuedCallbacks),delete a._sendingCallbacks,a._log(d+"Access token is expired. Retry one more time."),void a._sendAnalytics(!0,void 0,o+1);200===e?h():h(new Error("Unexpected Response: "+e))};this._getAccessToken(function(e,t){if(e)h(e);else if(t&&0!==t.length||a._options.ALLOW_NO_TOKEN){var o="https://"+a._getAnalyticsHost();if(a._log(d+"Sending analytics to "+o+"/ingest"),"undefined"!=typeof global&&global.Buffer){var r={"x-api-key":a._options.ANALYTICS_API_KEY,"X-Product":a._options.ANALYTICS_X_PRODUCT,"X-Request-Id":p,"Content-Type":"application/json"};t&&(r.Authorization="Bearer "+t);var s={hostname:a._getAnalyticsHost(),port:443,path:"/ingest",method:"POST",headers:r};a._options.ANALYTICS_X_PRODUCT_LOCATION&&(s.headers["X-Product-Location"]=a._options.ANALYTICS_X_PRODUCT_LOCATION),a._getAgent(o,function(e,t){t&&t.agent?s.agent=t&&t.agent:i(s,t||{});var o=n(26).request(s,function(e){e&&function(e){var t=function(){};e.on("data",t),e.on("end",t)}(e);var t=e&&e.statusCode,n=e&&e.headers;_(t,n)});o.once("error",function(e){h(e)}),o.end(JSON.stringify(u))})}else{!function(e){var n=new XMLHttpRequest;n.onreadystatechange=function(){if(4===this.readyState){var e=n.getAllResponseHeaders();_(this.status,e)}},n.onerror=function(e){h(new Error(e))},n.open("POST",o+"/ingest",!0),n.setRequestHeader("x-api-key",a._options.ANALYTICS_API_KEY),n.setRequestHeader("x-user-region",a._options.ANALYTICS_USER_REGION),n.setRequestHeader("Content-Type","application/json"),t&&n.setRequestHeader("Authorization","Bearer "+t),n.setRequestHeader("X-Product",a._options.ANALYTICS_X_PRODUCT),n.setRequestHeader("X-Product-Location",a._options.ANALYTICS_X_PRODUCT_LOCATION),n.setRequestHeader("X-Request-Id",p),n.send(e)}(JSON.stringify(u))}}else h(new Error("No access token"))})}}},l.prototype.enable=function(e){this._isEnabled=e,e&&this._sendAnalytics(!0)},l.prototype.postEvent=function(e,t){var n=this._formatTimestamp(new Date);e[this._options.TIMESTAMP_PROPERTY_NAME]=n;var o={time:n,project:this._options.ANALYTICS_PROJECT,environment:this._getEnvironment(),ingesttype:this._options.ANALYTICS_INGEST_TYPE,data:e};this._queueEvent(o),this._sendAnalytics(!1,t)},l.prototype.flush=function(e,t){this._sendAnalytics(e,t)},e.exports=l},function(e,t,n){var o,i,r,a=n(17),s=n(8),c=n(35),l=n(4),p=n(11),d=n(10),u=n(7),h=n(5),_=n(0),f=n(1),m={job:"files"},E={filterjob:"files",observe:{attrs:'type="sync.out.notify.job.status"'}},g={changemonitor:"cclibraries"},y={changemonitor:"cclibraries",pathprefix:[f.STORAGE_ASSETS_PATH+f.LIBRARY_SYNC_GROUP,f.BOOKMARKS_MONITOR_PATH]},v={filterchangemonitor:"cclibraries"},A=new RegExp(".*/([^/]+)/manifest$"),C=new RegExp(".*/([^/]+)$"),I=function(e){var t=c.parseXML(e,function(e){s.log("CoreSyncNotifications",e)}),n=t&&t.message||{};Object.keys(n).forEach(function(e){n[e]=n[e][0]});var o=n.events&&n.events.event;o&&(n.events=[],o.forEach(function(e){n.events.push(e.$)}));var i=n.errors&&n.errors.error;return i&&(delete n.errors,n.numErrors=i.length,n.firstError=i[0]&&i[0].$),n},S=function(e,t,n,o,i){i=i||0;var r=_.uuid(),c="sync.in.request."+t,p="sync.out.response."+t,d=JSON.parse(JSON.stringify(n));e&&(d.userid=e.userId,d.cloudid=function(e){return e===f.DEFAULT_CLOUD_ID?f.DEFAULT_CORESYNC_CLOUD_ID:e}(e.cloudId)),d.requestid=r,d.type=c;var u={requestType:c,responseType:p,payload:function(e){var t="";return Object.keys(e).forEach(function(n){var o=e[n];o.attrs?t+="<"+n+" "+o.attrs+" />":Array.isArray(o)?o.forEach(function(e){t+="<"+n+">"+e+"</"+n+">"}):t+="<"+n+">"+o+"</"+n+">"}),'<?xml version="1.0" encoding="utf-8"?><message>'+t+"</message>"}(d),targetId:"CORS",targetVersion:"",timeout:l.getValue("CORE_SYNC_REQUEST_TIMEOUT")};a.call(u,function(a,c){if(a)i<l.getValue("CORE_SYNC_NUM_RETRIES")?S(e,t,n,o,i+1):o(a);else{var p=I(c);if(!p||p.requestid!==r)return!1;s.log("CoreSyncNotifications",t+":\n"+JSON.stringify(p,void 0,2)),o(null,p)}})},L=new h(["libraryChange","bookmarkChange","fileSyncState"]),O={},R=!0,N=function(){i=void 0,o=void 0,O={}},T=function(e){return e.userId+"/"+e.cloudId},D=function(e,t){var n=!!t&&void 0===t.status;i=e||!t?String(e):"disabled"===t.majorstate||"does_not_exist"===t.status?"turned_off":"syncing"===t.majorstate||"idle"===t.majorstate?"normal":"error_"+(t.status||t.majorstate),L.notify("fileSyncState",[i,n])},b=function(e,t){S(e,"job.getstatus",m,function(e,n){D(e,n),t(e)})},w=function(e,t){S(e,"changemonitor.enable",g,function(e,n){if(e)t(e);else{var o=n&&n.status;"success"===o?t(null):(s.log("CoreSyncNotifications","Error enabling changemonitor: "+o),t("enable_error"))}})},P=function(e,t){S(void 0,"observer.create",e,function(e,n){if(e)t(e);else{var o=n&&n.status;"success"===o?t(null,n.observerid):(s.log("CoreSyncNotifications","Error creating observer: "+o),t("create_error"))}})},x=function(e,t){!function(e,t){S(e,"changemonitor.getstatus",g,function(n,o){if(n)t(n);else{var i=o&&o.status;if("does_not_exist"===i){var r=Object.assign({},y);e.cloudId!==f.DEFAULT_CLOUD_ID&&(r.syncurl=e.syncurl),S(e,"changemonitor.create",r,function(n,o){n?t(n):"success"===(i=o&&o.status)?w(e,t):(s.log("CoreSyncNotifications","Error creating changemonitor: "+i),t("create_error"))})}else"success"===i?"active"===o.majorstate?t(null):w(e,t):(s.log("CoreSyncNotifications","Unexpected changemonitor status: "+i),t("status_error"))}})}(e,function(n){n?t(n):(e.isEnabled=!0,e.observerId?t(null):P(v,function(n,o){n?t(n):(e.observerId=o,t(null))}))})},k=function(e,t){!function(e,t){S(void 0,"observer.destroy",{observerid:e},function(e,n){if(e)t(e);else{var o=n&&n.status;"success"===o?t(null):(s.log("CoreSyncNotifications","Error destroying observer: "+o),t("destroy_error"))}})}(e.observerId,function(){delete e.observerId,function(e,t){S(e,"changemonitor.destroy",g,function(e,n){if(e)t(e);else{var o=n&&n.status;"success"===o?t(null):(s.log("CoreSyncNotifications","Error destroying changemonitor: "+o),t("destroy_error"))}})}(e,t)})},M=[],V=function(e,t){var n=u.wrapCallback(e);if(t=t||0,M.push(n),!(M.length>1)){var a=function(e){var n=M;M=[],n.forEach(function(t){t(e)}),e?e&&!r&&t<l.getValue("CORE_SYNC_NUM_RETRIES")&&(r=setTimeout(function(){V(void 0,t+1)},l.getValue("CORE_SYNC_REQUEST_TIMEOUT"))):clearTimeout(r)};if(!R)return N(),void a(null);var s=new d;if(Object.keys(O).forEach(function(e){var t=O[e];p.getLoadedCollectionById(t.userId,t.cloudId)||(delete O[e],s.addOperation(k,[t]))}),p.getLoadedCollections().forEach(function(e){if(!e.isPublic){var t=T(e);if(O[t])O[t].isEnabled?"stopped"===O[t].state&&"normal"===i&&s.addOperation(x,[O[t]]):s.addOperation(x,[O[t]]);else{var n={userId:e.userId,cloudId:e.cloudId,syncurl:e.cloudInfo&&e.cloudInfo.syncURI};s.addOperation(function(e){x(n,function(o){o||(O[t]=n),e(o)})})}}}),!o){s.addOperation(function(e){P(E,function(t,n){t?e(t):(o=n,e(null))})});var c=p.getLoadedCollections()[0];c&&s.addOperation(b,[c])}s.run(a)}};p.addLoadedCollectionsListener(V),a.addListener("sync.out.broadcast.app.startedup",function(){N(),R=!0,V()}),a.addListener("sync.out.broadcast.app.shuttingdown",function(){L.notify("fileSyncState",["shutdown",!0]),R=!1,V()}),a.addListener("sync.out.notify.job.status",function(e){var t=I(e);s.log("CoreSyncNotifications","sync.out.notify.job.status:\n"+JSON.stringify(t,void 0,2)),D(null,t),V()}),a.addListener("sync.out.notify.changemonitor.status",function(e){var t=I(e);s.log("CoreSyncNotifications","sync.out.notify.changemonitor.status:\n"+JSON.stringify(t,void 0,2));var n=T({userId:t.userid,cloudId:function(e){return e===f.DEFAULT_CORESYNC_CLOUD_ID?f.DEFAULT_CLOUD_ID:e}(t.cloudid)});O[n]&&(O[n].state=t.majorstate,"disabled"===t.majorstate&&(s.log("CoreSyncNotifications","Change monitor was disabled - need to re-enable"),O[n].isEnabled=!1,V()))}),a.addListener("sync.out.notify.changemonitor.pathevent",function(e){var t=I(e);s.log("CoreSyncNotifications","sync.out.notify.changemonitor.pathevent:\n"+JSON.stringify(t,void 0,2));var n={},o=!1;(t.events||[]).forEach(function(e){if(e)if(e.path!==f.BOOKMARKS_MONITOR_PATH){var t=e.path&&e.path.match(A);if(t)n[t[1]]=!0;else{var i=e.path&&e.path.match(C);"deleted"===e.type&&"folder"===e.file_type&&i&&(n[i[1]]=!0)}}else o=!0});var i=Object.keys(n);i.length>0&&(s.log("CoreSyncNotifications","Report library change"),L.notify("libraryChange",[i])),o&&(s.log("CoreSyncNotifications","Report bookmark change"),L.notify("bookmarkChange",[]))});var U={addListener:function(e,t){L.add(e,t)},removeListener:function(e,t){L.remove(e,t)},removeAllListeners:function(e){L.removeAll(e)},ping:function(e){V(e)}};e.exports=U},function(e,t,n){var o=n(17),i=n(4),r=n(8),a=n(35),s=n(25),c=n(5),l=n(7),p=n(0),d={"com.adobe.designlibrary.v1":["sharing.invite","sharing.invite.accept.self","sharing.invite.accept.other","sharing.collaboration.updaterole","stock.open.request"],"com.adobe.system.inform.typekit.generic":["com.adobe.system.inform.typekit.generic.entitlementschanged"]},u=function(){var e=[];return Object.keys(d).forEach(function(t){e=e.concat(d[t])}),e}(),h=new c(u),_=function(e){return a.parseXML(e,function(t){r.log("ANS",t),s.reportError("ANS","Failed to parse ANS message: "+e)})},f=function(e,t){return e&&e[t]&&e[t][0]},m=function(e,t){return e&&e[t]||[]};o.addListener("cclibraries.notification.ans",function(e){var t=_(e),n=t&&t["notifications-signal"],a=n&&n["notification-signal"];a&&a.forEach(function(e){var t=e.$&&e.$["sub-type"];if(r.log("ANS","Received notification: "+t),-1!==u.indexOf(t)){var n=[];m(e,"notification-info").forEach(function(e){var t=f(e,"notification-ids"),o=m(t,"notification-id");n=n.concat(o)}),function(e,t){var n=p.uuid(),a="";e.forEach(function(e){a+="<notification-id>"+e+"</notification-id>"});var c={NOTIFICATION_IDS:a,REQUEST_ID:n,REQUEST_NAMESPACE:"cclibraries.notification.ans.byID.data"},d={requestType:"accc.notifications",responseType:"cclibraries.notification.ans.byID.data",payload:l.constructStringFromTemplate('<?xml version="1.0" encoding="utf-8"?><NEMessage action="GetDataByID"><notification-ids>{{NOTIFICATION_IDS}}</notification-ids><request-context>{{REQUEST_ID}}</request-context><requestor-namespace>{{REQUEST_NAMESPACE}}</requestor-namespace></NEMessage>',c),targetId:"ADCS",targetVersion:"",timeout:i.getValue("GET_NOTIFICATION_TIMEOUT")};o.call(d,function(e,o){if(e)return"timeout"===e&&(r.log("ANS","Timed out getting notification data from Thor"),s.reportError("ANS","Timed out getting notification data from Thor")),void t(e);var i=[];if(o){var a=_(o),c=a&&a.notifications;if(f(c,"request-context")!==n)return!1;m(c,"notification").forEach(function(e){var t=f(e,"notification-id"),n=f(e,"payload");try{n=n&&JSON.parse(n)}catch(t){r.log("ANS","Failed to parse ANS payload: "+e.payload),s.reportError("ANS","Failed to parse ANS payload: "+e.payload)}i.push({id:t,payload:n,state:f(e,"state"),created:parseInt(f(e,"timestamp"),10),modified:parseInt(f(e,"modifiedTimeStamp"),10)})})}t(null,i)})}(n,function(e,n){e||n.forEach(function(e){h.notify(t,[e])})})}})});var E={};E.EVENTS=d,E.addListener=function(e,t){h.hasListeners(e)||function(e){var t;Object.keys(d).some(function(n){if(d[n].includes(e))return t=n,!0});var n={NOTIFICATION_TYPE:t,NOTIFICATION_SUB_TYPE:e,OBSERVER_NAMESPACE:"cclibraries.notification.ans"};o.sendMessage("accc.notifications",l.constructStringFromTemplate('<?xml version="1.0" encoding="utf-8"?><NEMessage action="RegisterObserver"><type>{{NOTIFICATION_TYPE}}</type><sub-type>{{NOTIFICATION_SUB_TYPE}}</sub-type><observer-namespace>{{OBSERVER_NAMESPACE}}</observer-namespace></NEMessage>',n),"ADCS","")}(e),h.add(e,t)},E.removeListener=function(e,t){h.remove(e,t)},E.removeAllListeners=function(e){h.removeAll(e)},E.setState=function(e){var t={NOTIFICATION_ID:e.id,STATE:e.state};o.sendMessage("accc.notifications",l.constructStringFromTemplate('<?xml version="1.0" encoding="utf-8"?><NEMessage action="UpdateServerNotification"><notification><notification-id>{{NOTIFICATION_ID}}</notification-id><state>{{STATE}}</state></notification></NEMessage>',t),"ADCS","")},e.exports=E},function(e,t,n){var o=n(4),i=n(5),r=n(0),a=n(39),s=n(17),c={Ipc:{GetActiveCloudRequest:"accc.app.GetActiveCloudRequest",GetActiveCloudResponse:"any.app.GetActiveCloudResponse",UpdateActiveCloud:"any.accc.app.UpdateActiveCloud",SuiteMessage:"vulcan.SuiteMessage."}};function l(e,t){a.parseString(e,function(e,n){if(e)t("Error parsing XML response: "+e);else{var o=n&&n.response&&n.response.clouds&&n.response.clouds[0],i=(o=o||n&&n.message&&n.message.clouds&&n.message.clouds[0])&&o.$&&o.$.activeCloud,r=o&&o.$&&o.$.trueCloudCount&&parseInt(o.$.trueCloudCount,10),a=o&&o._;if(i){var s=[];if(a)try{var c=new Buffer(a,"base64");s=JSON.parse(c.toString())}catch(e){}t(null,s,i,r)}else t("Invalid response from any.app.GetActiveCloudResponse")}})}var p=new i(["cloudChange"]);s.addListener(c.Ipc.UpdateActiveCloud,function(e){l(e,function(e,t,n,o){var i;e?p.notify("cloudChange",[e]):(t.forEach(function(e){e.id===n&&(i=e)}),p.notify("cloudChange",[e,i,o]))})});var d={};d.getClouds=function(e){var t,n=setTimeout(function(){s.removeListener(c.Ipc.GetActiveCloudResponse,t),e("GetActiveCloud timed out after "+o.getValue("GET_ACTIVE_CLOUD_TIMEOUT")+"ms")},o.getValue("GET_ACTIVE_CLOUD_TIMEOUT"));t=function(o){clearTimeout(n),l(o,e),s.removeListener(c.Ipc.GetActiveCloudResponse,t)},s.addListener(c.Ipc.GetActiveCloudResponse,t),s.sendMessage(c.Ipc.GetActiveCloudRequest,"<request><type>"+c.Ipc.GetActiveCloudRequest+"</type><requestid>"+r.uuid()+"</requestid></request>","ADCS","1.9.0")},d.getActiveCloud=function(e){d.getClouds(function(t,n,o,i){var r;t?e(t):(n.forEach(function(e){e.id===o&&(r=e)}),e(null,r,i))})},d.addListener=function(e,t){p.add(e,t)},d.removeListener=function(e,t){p.remove(e,t)},d.removeAllListeners=function(e){p.removeAll(e)},e.exports=d},function(e,t,n){var o=n(4),i=n(17),r=n(25),a=n(8),s=n(1),c=n(7),l=n(0),p=n(14),d="ProductLauncher",u=o.getValue("PRODUCT_LAUNCHER_SUPPORTED_PRODUCTS"),h={};function _(e,t){var n=e.specifierInfo;if(e.element)if(e.action){if(!e.element._getActions(e.action).some(function(t){return t.appCode===e.specifierInfo.code})){var c=e.element.getPrimaryRepresentation(),p=e.element.type+":"+(c&&c.type),u="Unexpectedly trying to ["+e.action+"] "+p+" in "+n.code;a.log(d,"Error: "+u),r.reportError("ElementActionConfigMismatch",u)}var h=null,_={elementRef:e.element.getReference(),requestID:l.uuid(),appCode:n.code,path:n.path,action:e.action};if(!1===e.waitForCompletion)return i.sendMessage(s.VULCAN_APP_SEND_ACTION_MESSAGE,JSON.stringify(_),n.code,n.version),void t(null,n);a.log(d,"Sending open request: ",JSON.stringify(_)),i.addListener(s.VULCAN_APP_ACTION_ACCEPTED_MESSAGE,f),i.sendMessage(s.VULCAN_APP_SEND_ACTION_MESSAGE,JSON.stringify(_),n.code,n.version),h=setTimeout(function(){i.removeListener(s.VULCAN_APP_ACTION_ACCEPTED_MESSAGE,f,n.code,n.version),t("APP_SEND_ACTION_FAILED")},o.getValue("SEND_ACTION_TIMEOUT"))}else t("NO_ACTION_SPECIFIED");else t(null,n);function f(e,o,r){a.log(d,"Recieved edit accept from :",o," ",r,": ",e),e===_.requestID?(clearTimeout(h),i.removeListener(s.VULCAN_APP_ACTION_ACCEPTED_MESSAGE,f,n.code,n.version),t(null,n)):a.log(d,"RequestID didn't match: Expected "+_.requestID+" to be "+e)}}function f(e){return e?e.isUnsupported?(a.log(d,"Unsupported version "+e.version),"NO_COMPATIBLE_VERSION"):"USABLE":(a.log(d,"App not installed "+e),"APP_NOT_INSTALLED")}h.getAppDetails=function(e){var t=[];return s.ELEMENT_ACTION_PRODUCT_MAP.installedApps.forEach(function(n){if(n.code===e.appCode){var o={};Object.assign(o,n),-1===c.compareVersions(e.minVersion||0,o.version)?o.isUnsupported=!0:o.isAlreadyRunning=i.isAppRunning(o.specifier),t.push(o)}}),t.sort(function(t,n){if(!1!==e.prioritizeRunning){if(t.isAlreadyRunning&&!n.isAlreadyRunning)return-1;if(n.isAlreadyRunning&&!t.isAlreadyRunning)return 1}return c.compareVersions(t.version,n.version)}),a.log(d,"Installed app details: "+JSON.stringify(t)),t[0]},h.appStatus=function(e){return f(h.getAppDetails(e))};var m={};h.launch=function(e,t){const n=h.getAppDetails(e),r=f(n);if(t=t||(()=>void 0),"USABLE"!==r)return void t(r);var c=n.specifier;if(e.specifierInfo=n,n.isAlreadyRunning||!1===e.waitForCompletion&&!e.element)return a.log(d,"Switching focus to app: "+c),void i.launchApp(c,!0,"",function(){_(e,t)});if(m[c]=m[c]||[],m[c].push({options:e,callback:t}),m[c].length>1)return;function l(e){var t=m[c];delete m[c],t.forEach(e)}let u;function E(e,t,o){var r={};try{r=JSON.parse(e)}catch(n){return void a.log(d,"Unparsable payload received from "+t+" "+o,e)}p.normalize(r.path)===p.normalize(n.path)?(clearInterval(u),i.removeListener(s.VULCAN_APP_READY_MESSAGE,E),l(e=>_(e.options,e.callback))):a.log(d,"Received unknown app ready: "+e+" from "+t+" "+o+", specifier - "+JSON.stringify(n))}i.addListener(s.VULCAN_APP_READY_MESSAGE,E);const g=(e,t)=>{clearInterval(u),i.removeListener(s.VULCAN_APP_READY_MESSAGE,E),a.log(d,t),l(t=>t.callback(e))},y=(new Date).valueOf();u=setInterval(()=>{(new Date).valueOf()-y>o.getValue("LAUNCH_APP_TIMEOUT")?g("APP_LAUNCH_TIMEOUT","Launch app timed out: "+c):i.isAppRunning(c)||g("APP_LAUNCH_FAILED","App was killed before it finished launching: "+c)},o.getValue("LAUNCH_APP_POLL_INTERVAL")),a.log(d,"Launching app: "+c),i.launchApp(c,!0,"",(e,t)=>{(e||!0!==t)&&g("APP_LAUNCH_FAILED","Vulcan could not launch app: "+c+" "+e)})},h.updateInstallationMap=function(e){var t=i.getSpecifiers();a.log(d,"Recieved the list of installed apps: "+t.join(", "));var n={};(s.ELEMENT_ACTION_PRODUCT_MAP.installedApps||[]).forEach(function(e){n[e.specifier]=e});var o=[];return t.forEach(function(t){if(!n[t]||e){var r=t.split("-");if(2===r.length){var s=u[r[0]];if(!s)return;var c=i.getAppPath(t);if(!c)return void a.log(d,"No application path for specifier: "+t);var l=i.getAppVersion(t);if(!l)return void a.log(d,"No application version for specifier: "+t+" at "+c+" ("+l+")");o.push({specifier:t,code:s,version:l,path:p.normalize(c)})}else a.log(d,"Unexpected app specifier structure: "+t)}else o.push(n[t])}),s.ELEMENT_ACTION_PRODUCT_MAP.installedApps=o,a.log(d,"Updated installation map: ",JSON.stringify(o)),o},e.exports=h},function(e,t,n){var o=n(8),i=n(35),r=n(17),a=n(4),s=n(5),c=n(7),l=n(0),p={handlers:{}},d="accc.app.ShowNotificationRequest",u='<?xml version="1.0" encoding="utf-8"?><request><requestid>{{REQUEST_ID}}</requestid><context>{{CONTEXT}}</context><ackNamespace>cclibrary.app.ShowNotificationResponse</ackNamespace><title>{{TITLE}}</title><message>{{MESSAGE}}</message></request>',h=new s(["clickNotification"]);r.addListener("cclibrary.app.ShowNotificationResponse",function(e){var t,n,r,a,s=i.parseXML(e);try{r=s.response.requestid[0],a=s.response.context[0],t=(n=JSON.parse(a)).type}catch(t){o.log("Toast","Failed to parse, notification response "+e)}h.hasListeners("clickNotification")&&h.notify("clickNotification",[t,r,n.data])}),p.addListener=function(e,t){h.add(e,t)},p.removeListener=function(e,t){h.remove(e,t)};var _,f=[];p.sendToast=function(e){var t={REQUEST_ID:l.uuid(),CONTEXT:JSON.stringify({type:e.type,data:e.data}),TITLE:e.title,MESSAGE:e.message,overridable:e.overridable};f.length>0&&f[f.length-1].overridable?f[f.length-1]=t:f.push(t),function e(t){if(!_)if(t)_=setTimeout(function(){_=void 0,e()},t);else if(0!==f.length){var n=f.shift(),o=c.constructStringFromTemplate(u,n);r.sendMessage(d,o,"ADCS",""),e(a.getValue("OS_TOAST_NOTIFICATIONS_BACKOFF"))}}(e.overridable?a.getValue("OS_TOAST_NOTIFICATIONS_DELAY"):0)},e.exports=p},function(e,t,n){var o,i,r=n(33),a=n(4),s=n(14),c=n(8),l=n(25),p=0,d={},u={_isEnabled:!0};u._scriptPath=s.join(__dirname,"localThumbnailsProcess.js"),u._startChildProcess=function(){o||(c.log("LocalThumbnails","Starting child process"),o=r.fork(u._scriptPath),process.on("exit",u._stopChildProcess),o.on("message",u._handleResponse),o.on("exit",u._handleExit))},u._stopChildProcess=function(e){o&&(c.log("LocalThumbnails","Stopping child process"),o.removeListener("message",u._handleResponse),o.removeListener("exit",u._handleExit),process.removeListener("exit",u._stopChildProcess),e||o.send({exit:!0}),o=void 0)},u._handleResponse=function(e){var t=d[e.id];if(delete d[e.id],t){0===Object.keys(d).length&&(i&&clearTimeout(i),i=setTimeout(function(){0===Object.keys(d).length&&u._stopChildProcess(),i=null},a.getValue("LOCAL_THUMBNAILS_SHUTDOWN_DELAY")));var n=" ("+((new Date).valueOf()-t.startTime)+"ms)";"__test__"===t.source?(c.log("LocalThumbnails","Testing: Success"+n),t.callback(e.err)):e.err?(c.log("LocalThumbnails","["+t.id+"] Error received: "+e.err+n),l.reportError("ThumbnailGeneratorError",e.err),t.callback(e.err)):(c.log("LocalThumbnails","["+t.id+"] Success"+n),t.callback(null,t.destination))}},u._handleExit=function(e,t){u._stopChildProcess(!0);var n=Object.keys(d);if(0!==n.length){var o="Unexpected exit: "+(null!==e?e:t);l.reportError("ThumbnailGeneratorError",o),n.forEach(function(e){var t=d[e];"__test__"===t.source?c.log("LocalThumbnails","Testing: Failed - "+o):c.log("LocalThumbnails","["+e+"] "+o),t.callback("unexpected_exit")}),d={}}},u.generate=function(e,t,n,i){if(u._isEnabled)if(e&&t){u._startChildProcess();var r={id:p++,startTime:(new Date).valueOf(),source:e,destination:t,size:n,callback:i};d[r.id]=r,"__test__"!==e&&c.log("LocalThumbnails","["+r.id+"] Requesting (size "+n+"): "+e),o.send({id:r.id,src:s.normalize(e),dest:s.normalize(t),size:n})}else i("Missing source and/or destination path - source:"+e+"destination:"+t);else i("local_thumbnails_disabled")},u.test=function(e){u.generate("__test__","__test__",250,function(t){var n="unexpected_exit"!==t;u._isEnabled=n,e(n)})},e.exports=u},function(e,t,n){const o=n(129),i=n(11),r=n(36),a=n(4),s=n(8),c=n(17),l=n(0),p=n(130),d=n(132),u=n(133),h=n(134),_="API",f="cclibraries.api.QueryRequest",m="cclibraries.api.QueryResponse";e.exports=class{initialize(e){return this._server?Promise.reject("API is already initialized"):(this._server=o.createServer({name:"CCLibraries REST API"}),this._server.use(o.plugins.bodyParser()),this._server.use(o.plugins.queryParser({mapParams:!0})),this._server.use((e,t,n)=>{let o=this._logRequest(e,t);if(t.header("x-request-id",o),t.header("x-env",a.getEnvironment().LABEL),t.charSet("utf-8"),(e.headers.token||e.query.token)!==this._serviceToken)return t.send(401);if(0===i.getLoadedCollections().length){const e=r.getUserId();return t.send(403,{userId:e})}n()}),this._elementsRoute=new p(this._server),this._groupsRoute=new d(this._server),this._librariesRoute=new u(this._server),this._notificationsRoute=new h(this._server),new Promise(t=>{this._server.listen(e||0,"127.0.0.1",()=>{s.log(_,`${this._server.name} listening at ${this._server.url}`),this._serviceHostname=this._server.url,this._serviceToken=l.uuid(),this._onConnectionHandler=this._connectionHandler.bind(this),c.addListener(f,this._onConnectionHandler),t()})}))}_logRequest(e,t){const n=Date.now(),o=e.headers["x-request-id"]||l.uuid();return s.log(_,`[${o}] ${e.method.toUpperCase()} ${e.headers.host}${e.href()}`),t.on("finish",()=>{s.log(_,`[${o}] ${t.statusCode} (${Date.now()-n}ms)`)}),o}_connectionHandler(e,t,n){let o;s.log(_,`Client connected: ${t} - ${n}`);try{o=e&&JSON.parse(e)}catch(t){s.log(_,`Parse error, client message: ${e}`)}const i=o&&o.apiVersion,r={apiVersion:a.getValue("REST_API_VERSION"),apiMinVersion:a.getValue("REST_API_MIN_VERSION"),apiMaxVersion:a.getValue("REST_API_MAX_VERSION")};!i||i<r.apiMinVersion?r.updateRequired="client":i>r.apiMaxVersion?r.updateRequired="server":(r.serviceHostname=this._serviceHostname,r.serviceToken=this._serviceToken),c.sendMessage(m,JSON.stringify(r),t,n)}shutdown(){this._server&&(this._serviceHostname=void 0,this._serviceToken=void 0,this._elementsRoute.dispose(),this._elementsRoute=void 0,this._groupsRoute.dispose(),this._groupsRoute=void 0,this._librariesRoute.dispose(),this._librariesRoute=void 0,this._notificationsRoute.dispose(),this._notificationsRoute=void 0,this._server.close(),this._server=void 0,c.removeListener(f,this._onConnectionHandler))}}},function(e,t){e.exports=require("restify")},function(e,t,n){const o=n(14),{getRequestHandler:i,getElementResponseData:r}=n(37),a=n(38),s=n(11),c=n(1);e.exports=class{constructor(e){this._server=e,this._routes=[],this._routes.push(this._server.get("/libraries/:libraryId/elements",i(this.getElements.bind(this)))),this._routes.push(this._server.post("/libraries/:libraryId/elements",i(this.createElement.bind(this),!0))),this._routes.push(this._server.get("/libraries/:libraryId/elements/:elementId",i(this.getElement.bind(this)))),this._routes.push(this._server.put("/libraries/:libraryId/elements/:elementId",i(this.updateElement.bind(this),!0))),this._routes.push(this._server.del("/libraries/:libraryId/elements/:elementId",i(this.removeElement.bind(this),!0))),this._routes.push(this._server.get("/libraries/:libraryId/elements/:elementId/representations/:representationId/path",i(this.getRepresentationPath.bind(this)))),this._routes.push(this._server.get("/libraries/:libraryId/removed_elements",i(this.getRemovedElements.bind(this)))),this._routes.push(this._server.get("/libraries/:libraryId/removed_elements/:elementId",i(this.getElement.bind(this),null,!0))),this._routes.push(this._server.del("/libraries/:libraryId/removed_elements/:elementId",i(this.removeElement.bind(this),null,!0)))}_buildRepresentations(e,t){const n=[];if(e.representations.length>0){const n=t.filter(e=>e.id).map(e=>e.id);e.representations.slice().forEach(t=>{n.includes(t.id)||e.removeRepresentation(t)})}return t.forEach(t=>{if(t.id)return;const o=e.createRepresentation(t.type,t.relationship);t.source&&(t.source.path||t.source.url)&&n.push(new Promise((e,n)=>{t.source.path?o.setContentFromPath(t.source.path,t.source.moveFile,t=>{t?n(t):e()}):t.source.url&&o.setContentFromURL(!!t.source.createLink,t.source.url,t.source.headers,t=>{t?n(t):e()})}).then(()=>{void 0!==t.width&&(o.width=t.width),void 0!==t.height&&(o.height=t.height),void 0!==t.content_length&&(o.contentLength=t.content_length),void 0!==t.is_full_size&&(o.isFullSize=t.is_full_size)})),Object.keys(t).forEach(e=>{const n=e.split("#");2===n.length&&o.setValue(n[0],n[1],t[e])})}),Promise.all(n)}_validateElementData(e,t,n,o){if(e&&"string"!=typeof e)return a.ELEMENT_NAME_INVALID;if(t&&(!Array.isArray(t)||!t.every(e=>"string"==typeof e)))return a.ELEMENT_TAGS_INVALID;if(n||!o){if(!n||!Array.isArray(n)||0===n.length)return a.REPRESENTATION_DATA_MISSING;let e=!1;for(let t of n){let n;if(o&&t.id){if(!(n=o.getRepresentationById(t.id)))return a.REPRESENTATION_ID_NOT_RESOLVED}else{if(!t.type)return a.REPRESENTATION_TYPE_MISSING;if(!t.relationship)return a.REPRESENTATION_REL_MISSING;if(!c.VALID_RELATIONS.includes(t.relationship))return a.REPRESENTATION_REL_INVALID;if(t.source&&!t.source.path&&!t.source.url)return a.REPRESENTATION_SOURCE_MISSING;if(void 0!==t.width&&"number"!=typeof t.width||t.width<0)return a.REPRESENTATION_WIDTH_INVALID;if(void 0!==t.height&&"number"!=typeof t.height||t.height<0)return a.REPRESENTATION_HEIGHT_INVALID;if(void 0!==t.content_length){if(!t.source.url||!t.source.createLink)return a.REPRESENTATION_CONTENT_LENGTH_UNEXPECTED;if("number"!=typeof t.content_length||t.content_length<0)return a.REPRESENTATION_CONTENT_LENGTH_INVALID}if(void 0!==t.is_full_size&&"boolean"!=typeof t.is_full_size)return a.REPRESENTATION_FULL_SIZE_INVALID}if("primary"===(n&&n.relationship||t.relationship)){if(e)return a.REPRESENTATION_REL_PRIMARY_FOUND;e=!0}}}}createElement(e,t,n){const o=t;if(!o)return Promise.reject(a.ELEMENT_DATA_MISSING);if(o.self||o.source)return this.copyOrMoveElements(e,t,n);if(!o.type)return Promise.reject(a.ELEMENT_TYPE_MISSING);if(n.elements.length>=c.MAX_ELEMENTS)return Promise.reject(a.LIBRARY_NOT_ENOUGH_SPACE);const i=o.tags,s=o.representations,l=this._validateElementData(o.name,i,s);if(l)return Promise.reject(l);const p=n.createElement(o.name,o.type);return i&&(p.tags=i),new Promise((e,t)=>{this._buildRepresentations(p,s).then(()=>{p.endOperation(),e(r(p))}).catch(e=>{n.removeElement(p),t(a.getResponseError(e))})})}copyOrMoveElements(e,t,n){const o=!!t.self,i=t.self||t.source,l=i.id,p=i.elements;if(!l)return Promise.reject(a.LIBRARY_ID_MISSING);if(!p||!Array.isArray(p)||0===p.length)return Promise.reject(a.ELEMENT_IDS_MISSING);const d=s.getLibraryById(l);if(!d)return Promise.reject(a.LIBRARY_NOT_FOUND);if(o&&!d.isWritable)return Promise.reject(a.LIBRARY_NOT_WRITABLE);if(n.elements.length+p.length>c.MAX_ELEMENTS)return Promise.reject(a.LIBRARY_NOT_ENOUGH_SPACE);const u=p.map(e=>d.getElementById(e));if(u.some(e=>!e))return Promise.reject(a.ELEMENT_NOT_FOUND);n.beginOperation(),o&&d.beginOperation();const h=o?d.moveElement.bind(d):d.copyElement.bind(d),_=()=>{n.endOperation(),o&&d.endOperation()},f=[];return u.forEach(e=>{f.push(new Promise((t,o)=>{h(e,n,(e,n)=>{e?o(a.getResponseError(e)):t(n)})}))}),Promise.all(f).then(e=>(_(),{elements:e.map(r)})).catch(e=>(_(),Promise.reject(e)))}getElement(e,t,n){return Promise.resolve(r(n))}getElements(e,t,n){return Promise.resolve({elements:n.elements.map(r)})}getRemovedElements(e,t,n){return Promise.resolve({elements:n.removedElements.map(r)})}getRepresentationPath(e,t,n){return new Promise((e,t)=>{n.getContentPath((n,i)=>n?t(a.getResponseError(n)):i?void e({path:o.normalize(i)}):t(a.REPRESENTATION_PATH_NOT_FOUND))})}updateElement(e,t,n){const o=t;if(!o)return Promise.reject(a.ELEMENT_DATA_MISSING);const i=o.tags,s=o.representations;if(!o.name&&!s&&!i)return Promise.reject(a.ELEMENT_BODY_MISSING);const c=this._validateElementData(o.name,i,s,n);return c?Promise.reject(c):(n.beginOperation(),o.name&&(n.name=o.name),o.tags&&(n.tags=i),s?new Promise((e,t)=>{this._buildRepresentations(n,s).then(()=>{n.endOperation(),e(r(n))}).catch(e=>{n.endOperation(),t(a.getResponseError(e))})}):(n.endOperation(),Promise.resolve(r(n))))}removeElement(e,t,n){return n.library.removeElement(n,e.permanent||n.removed),Promise.resolve()}dispose(){this._routes.forEach(e=>this._server.rm(e))}}},function(e,t){e.exports=require("restify-errors")},function(e,t,n){const{getRequestHandler:o,getGroupResponseData:i}=n(37),r=n(38);e.exports=class{constructor(e){this._server=e,this._routes=[],this._routes.push(this._server.get("/libraries/:libraryId/groups",o(this.getGroups.bind(this)))),this._routes.push(this._server.post("/libraries/:libraryId/groups",o(this.createGroup.bind(this),!0))),this._routes.push(this._server.get("/libraries/:libraryId/groups/:groupId",o(this.getGroup.bind(this)))),this._routes.push(this._server.put("/libraries/:libraryId/groups/:groupId",o(this.updateGroup.bind(this),!0))),this._routes.push(this._server.del("/libraries/:libraryId/groups/:groupId",o(this.removeGroup.bind(this),!0)))}createGroup(e,t,n){const o=t&&t.name,a=t&&t.classifier,s=t&&t.order;if(!o)return Promise.reject(r.GROUP_NAME_MISSING);if(!s)return Promise.reject(r.GROUP_ORDER_MISSING);const c=n.createGroup(o,s,a);return Promise.resolve(i(c))}removeGroup(e,t,n){return n.library.removeGroup(n,e.include_contents),Promise.resolve()}getGroup(e,t,n){return Promise.resolve(i(n))}getGroups(e,t,n){const o={groups:[]},r=e.classifier||/.*/;return o.groups=n.getGroups(r).map(e=>i(e)),Promise.resolve(o)}updateGroup(e,t,n){const o=t&&t.name,a=t&&t.order;return o||a?(n.library.beginOperation(),o&&(n.name=o),a&&(n.order=a),n.library.endOperation(),Promise.resolve(i(n))):Promise.reject(r.GROUP_BODY_MISSING)}dispose(){this._routes.forEach(e=>this._server.rm(e))}}},function(e,t,n){const{getRequestHandler:o,getLibraryResponseData:i}=n(37),r=n(38),a=n(11);e.exports=class{constructor(e){this._server=e,this._routes=[],this._routes.push(this._server.get("/libraries",o(this.getLibraries.bind(this)))),this._routes.push(this._server.post("/libraries",o(this.createLibrary.bind(this)))),this._routes.push(this._server.get("/libraries/:libraryId",o(this.getLibrary.bind(this)))),this._routes.push(this._server.put("/libraries/:libraryId",o(this.updateLibrary.bind(this),!0))),this._routes.push(this._server.del("/libraries/:libraryId",o(this.removeLibrary.bind(this))))}createLibrary(e,t){if(t&&t.follow)return this.followLibrary(e,t);const n=t&&t.name||e&&e.name;if(!n)return Promise.reject(r.LIBRARY_NAME_MISSING);const o=a.getLoadedCollections().find(e=>!e.isPublic);if(!o)return Promise.reject(r.COLLECTION_NOT_FOUND);const s=o.createLibrary(n);return Promise.resolve(i(s))}followLibrary(e,t){const n=t&&t.id,o=t&&t.url;if(!n)return Promise.reject(r.LIBRARY_ID_MISSING);if(!o)return Promise.reject(r.LIBRARY_URL_MISSING);const i=a.getLoadedCollections().find(e=>!e.isPublic);return i?new Promise((e,t)=>{i._bookmarkManager.createBookmark(n,o,n=>{n?t(n):e()})}):Promise.reject(r.COLLECTION_NOT_FOUND)}removeLibrary(e,t,n){return n.collection.removeLibrary(n,()=>{}),Promise.resolve()}getLibrary(e,t,n){return Promise.resolve(i(n,!0))}getLibraries(){const e={libraries:[]};return a.getLoadedCollections().forEach(t=>{t.libraries.forEach(t=>{t.isDeletedFromServer||e.libraries.push(i(t))})}),Promise.resolve(e)}updateLibrary(e,t,n){const o=t&&t.name||e&&e.name;return o?(n.name=o,Promise.resolve(i(n))):Promise.reject(r.LIBRARY_NAME_MISSING)}dispose(){this._routes.forEach(e=>this._server.rm(e))}}},function(e,t,n){const{getPollingRequestHandler:o,getLibraryResponseData:i}=n(37),r=n(11);e.exports=class{constructor(e){this._server=e,this._routes=[],this._monitoredCollections=[],this._pendingSyncChangeCallbacks=[],this._pendingLibraryChangeCallbacks=[],this._onLibrariesChanged=this._librariesChanged.bind(this),this._onSyncStatusChanged=this._syncStatusChanged.bind(this),this._onCollectionsChanged=this._collectionsChanged.bind(this),r.addLoadedCollectionsListener(this._onCollectionsChanged),this._ensureCollectionListeners(),this._routes.push(this._server.post("/notifications/libraries",o(this.handleLibraryNotifications.bind(this)))),this._routes.push(this._server.post("/notifications/libraries/sync",o(this.handleSyncStatusNotifications.bind(this))))}_ensureCollectionListeners(){const e=r.getLoadedCollections();e.filter(e=>!this._monitoredCollections.includes(e)).forEach(e=>{e.addSyncListener(this._onSyncStatusChanged),e.addDeepChangeListener(this._onLibrariesChanged)}),this._monitoredCollections=e}_collectionsChanged(){this._ensureCollectionListeners(),this._librariesChanged(),this._syncStatusChanged()}_librariesChanged(){if(0===this._pendingLibraryChangeCallbacks.length)return;const e=this._getLibrariesData();this._pendingLibraryChangeCallbacks=this._pendingLibraryChangeCallbacks.filter(t=>!t(e))}_syncStatusChanged(){if(0===this._pendingSyncChangeCallbacks.length)return;const e=this._getSyncStatusData();this._pendingSyncChangeCallbacks=this._pendingSyncChangeCallbacks.filter(t=>!t(e))}_getLibrariesData(){const e={};return r.getLoadedCollections().forEach(t=>{t.libraries.forEach(t=>{t.isDeletedFromServer||(e[t.id]=t.modified)})}),e}_getSyncStatusData(){let e,t="ok";return r.getLoadedCollections().some(n=>{if("error"===n.syncState)return t=n.syncState,e=n.getPrimarySyncError(),!0;"syncing"===n.syncState&&(t=n.syncState)}),{state:t,error:e}}_getChangedLibrariesData(e,t){let n=Object.keys(t).length!==Object.keys(e).length;const o={};return Object.keys(t).forEach(a=>{const s=t[a];e[a]!==s?(o[a]=i(r.getLibraryById(a)),n=!0):o[a]=s}),n?o:void 0}_compareSyncStatusData(e,t){return!e||e.state!==t.state||e.error!==t.error}handleLibraryNotifications(e,t){const n=this._getLibrariesData(),o=this._getChangedLibrariesData(e,n);if(o)return void t(o);const i=n=>{const o=this._getChangedLibrariesData(e,n);if(o)return t(o),!0};return this._pendingLibraryChangeCallbacks.push(i),()=>{this._pendingLibraryChangeCallbacks.includes(i)&&this._pendingLibraryChangeCallbacks.splice(this._pendingLibraryChangeCallbacks.indexOf(i),1)}}handleSyncStatusNotifications(e,t){const n=this._getSyncStatusData();if(this._compareSyncStatusData(e,n))return void t(n);const o=n=>{if(this._compareSyncStatusData(e,n))return t(n)};return this._pendingSyncChangeCallbacks.push(o),()=>{this._pendingSyncChangeCallbacks.includes(o)&&this._pendingSyncChangeCallbacks.splice(this._pendingSyncChangeCallbacks.indexOf(o),1)}}dispose(){r.removeLoadedCollectionsListener(this._onCollectionsChanged),this._routes.forEach(e=>this._server.rm(e))}}},function(e,t,n){var o=n(59);function i(){this._channels=[]}i.prototype.broadcast=function(e,t,n){this._channels.forEach(function(o){n&&o===n||o.send(e,t)})},i.prototype.newChannel=function(e){var t=this,n=new o(e);return this._channels.push(n),n.onClose(function(){var e=t._channels.indexOf(n);-1!==e&&t._channels.splice(e,1),n.shutdown()}),n},i.prototype.numChannels=function(){return this._channels.length},i.prototype.getPendingWriteState=function(e,t,n,o){var i=!1;return this._channels.forEach(function(r){i=i||r.getPendingWriteState(e,t,n,r===o)}),i},Object.freeze(i),Object.seal(i.prototype),e.exports=i},function(e,t){e.exports=require("idle-gc")}]);